4 from com
.sun
.star
.task
import XJobExecutor
6 # implement a UNO component by deriving from the standard unohelper.Base class
7 # and from the interface(s) you want to implement.
8 class HelloWorldJob( unohelper
.Base
, XJobExecutor
):
9 def __init__( self
, ctx
):
10 # store the component context for later use
13 def trigger( self
, args
):
14 # note: args[0] == "HelloWorld", see below config settings
16 # retrieve the desktop object
17 desktop
= self
.ctx
.ServiceManager
.createInstanceWithContext(
18 "com.sun.star.frame.Desktop", self
.ctx
)
20 # get current document model
21 model
= desktop
.getCurrentComponent()
23 # access the document's text property
27 cursor
= text
.createTextCursor()
29 # insert the text into the document
30 text
.insertString( cursor
, "Hello World", 0 )
32 # pythonloader looks for a static g_ImplementationHelper variable
33 g_ImplementationHelper
= unohelper
.ImplementationHelper()
36 g_ImplementationHelper
.addImplementation( \
37 HelloWorldJob
, # UNO object class
38 "org.openoffice.comp.pyuno.demo.HelloWorld", # implemenation name
39 ("com.sun.star.task.Job",),) # list of implemented services