fdo#60670: Create a new document in case there's none
Change-Id: I7e03481beb1d4e60601fd93d787bc7354495e41f
This commit is contained in:
@@ -21,7 +21,12 @@
|
||||
def HelloWorldPython( ):
|
||||
"""Prints the string 'Hello World(in Python)' into the current document"""
|
||||
#get the doc from the scripting context which is made available to all scripts
|
||||
model = XSCRIPTCONTEXT.getDocument()
|
||||
desktop = XSCRIPTCONTEXT.getDesktop()
|
||||
model = desktop.getCurrentComponent()
|
||||
#check whether there's already an opened document. Otherwise, create a new one
|
||||
if not hasattr(model, "Text"):
|
||||
model = desktop.loadComponentFromURL(
|
||||
"private:factory/swriter","_blank", 0, () )
|
||||
#get the XText interface
|
||||
text = model.Text
|
||||
#create an XTextRange at the end of the document
|
||||
|
Reference in New Issue
Block a user