From adf772680c7cf0e3d6ae135cab49c847447b5bf1 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Thu, 22 Sep 2011 11:36:19 +0200 Subject: Hello world (python) as a component --- instsetoo_native/util/makefile.mk | 1 + .../registry/data/org/openoffice/Office/Common.xcu | 2 +- postprocess/packcomponents/makefile.mk | 2 + scp2/source/ooo/file_ooo.scp | 11 ++++++ wizards/Module_wizards.mk | 1 + wizards/com/sun/star/wizards/fax/CallWizard.py | 43 ++++++++++++++++++++++ wizards/com/sun/star/wizards/fax/fax.component | 6 +-- 7 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 wizards/com/sun/star/wizards/fax/CallWizard.py diff --git a/instsetoo_native/util/makefile.mk b/instsetoo_native/util/makefile.mk index 39677d26b185..15bc3d6f6e47 100644 --- a/instsetoo_native/util/makefile.mk +++ b/instsetoo_native/util/makefile.mk @@ -74,6 +74,7 @@ LOCALPYFILES= \ $(BIN)$/pythonloader.py \ $(BIN)$/officehelper.py \ $(BIN)$/mailmerge.py \ + $(BIN)$/CallWizard.py \ $(BIN)$/msgbox.py .ENDIF diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index 215999a81a0c..05377ae1443f 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -404,7 +404,7 @@ - service:com.sun.star.wizards.fax.CallWizard?start + service:com.sun.star.wizards.fax.CallWizard?insert ~Fax... diff --git a/postprocess/packcomponents/makefile.mk b/postprocess/packcomponents/makefile.mk index a6d7e5d56849..10f964bb2bdd 100644 --- a/postprocess/packcomponents/makefile.mk +++ b/postprocess/packcomponents/makefile.mk @@ -357,6 +357,8 @@ my_components += evoab my_components += component/avmedia/source/gstreamer/avmediagstreamer .END +my_ooo_components = mailmerge component/wizards/com/sun/star/wizards/fax/fax + .INCLUDE: target.mk ALLTAR : $(MISC)/services.rdb diff --git a/scp2/source/ooo/file_ooo.scp b/scp2/source/ooo/file_ooo.scp index adce11d9b41a..f96a95387508 100644 --- a/scp2/source/ooo/file_ooo.scp +++ b/scp2/source/ooo/file_ooo.scp @@ -466,6 +466,17 @@ STD_JAR_FILE( gid_File_Jar_Saxon, saxon9 ) #endif #endif +#ifndef AIX +#ifndef DISABLE_PYUNO +File gid_File_PyCallFaxWizard + TXT_FILE_BODY; + Dir = gid_Dir_Program; + Name = "CallWizard.py"; + Styles = (PACKED); +End +#endif +#endif + #ifndef SYSTEM_LIBEXTTEXTCAT // fingerprint files (lm) diff --git a/wizards/Module_wizards.mk b/wizards/Module_wizards.mk index 7f08d0f08cfe..45f5c4f68a76 100644 --- a/wizards/Module_wizards.mk +++ b/wizards/Module_wizards.mk @@ -36,6 +36,7 @@ $(eval $(call gb_Module_add_targets,wizards,\ AllLangResTarget_tpl \ AllLangResTarget_wwz \ AllLangResTarget_wzi \ + Pyuno_fax \ Zip_depot \ Zip_euro \ Zip_form \ 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: diff --git a/wizards/com/sun/star/wizards/fax/fax.component b/wizards/com/sun/star/wizards/fax/fax.component index 462fe2901255..a03d00afc5a6 100644 --- a/wizards/com/sun/star/wizards/fax/fax.component +++ b/wizards/com/sun/star/wizards/fax/fax.component @@ -26,10 +26,10 @@ * **********************************************************************--> - - + name="com.sun.star.wizards.fax.CallWizard"> + -- cgit