summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/fax/CallWizard.py
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2011-09-22 11:36:19 +0200
committerMichael Meeks <michael.meeks@suse.com>2011-12-05 20:53:19 +0000
commitadf772680c7cf0e3d6ae135cab49c847447b5bf1 (patch)
tree35bb986d762aa876db3ef19cc58ae2388c51a4d5 /wizards/com/sun/star/wizards/fax/CallWizard.py
parente20b4fe7f98473bef13758070ab33b144c6930ff (diff)
Hello world (python) as a component
Diffstat (limited to 'wizards/com/sun/star/wizards/fax/CallWizard.py')
-rw-r--r--wizards/com/sun/star/wizards/fax/CallWizard.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/fax/CallWizard.py b/wizards/com/sun/star/wizards/fax/CallWizard.py
new file mode 100644
index 000000000000..33385a251a31
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/CallWizard.py
@@ -0,0 +1,43 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+import uno
+import unohelper
+
+from com.sun.star.task import XJobExecutor
+
+# implement a UNO component by deriving from the standard unohelper.Base class
+# and from the interface(s) you want to implement.
+class HelloWorldJob(unohelper.Base, XJobExecutor):
+ def __init__(self, ctx):
+ # store the component context for later use
+ self.ctx = ctx
+
+ def trigger(self, args):
+ # note: args[0] == "HelloWorld", see below config settings
+
+ # retrieve the desktop object
+ desktop = self.ctx.ServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", self.ctx)
+
+ # get current document model
+ model = desktop.getCurrentComponent()
+
+ # access the document's text property
+ text = model.Text
+
+ # create a cursor
+ cursor = text.createTextCursor()
+
+ # insert the text into the document
+ text.insertString(cursor, "Hello World", 0)
+
+# pythonloader looks for a static g_ImplementationHelper variable
+g_ImplementationHelper = unohelper.ImplementationHelper()
+
+g_ImplementationHelper.addImplementation( \
+ HelloWorldJob, # UNO object class
+ "com.sun.star.wizards.fax.CallWizard", # implemenation name
+ ("com.sun.star.task.Job",),) # list of implemented services
+ # (the only service)
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab: