OO-Snippets: create document

Commons

Keywords
LanguagePython
ApplicationOffice
AuthorsDarragh Sherwin (initial)
Tom Schindl (initial)
Supported Versions
Supported OSAll  
QuestionHow can I create an empty document
Answer

Code-Snippet-Listing (snippet-source)

# Create a new, blank document and get all the specific services required
def createNewDocument( deskDict, url="private:factory/swriter" ):

        newDocument = deskDict['desktop'].loadComponentFromURL( url, "_blank", 0, () )
        controller = newDocument.getCurrentController()
        viewCursor = controller.getViewCursor()

        return  { 'document' : newDocument,
                'controller' : controller,
                'viewcursor' : viewCursor,
                'desktop'    : deskDict['desktop']
                }

if __name__=="__main__":
        # For a connection example see Office.ConnectViaPipe.snip
        remoteContext = connect()
        # How to get services see Office.FetchingServicesFromDesktop.snip
        deskDict = getDesktopDict( ctx )
	documentDict = createNewDocument( deskDict )

Changelog

DateUserModification

and