Hello, I've tried to follow your steps but placing the code in wizards/com/sun/star/wizards/fax/CallWizard.py. So far I haven't been able to build it successfully. It complains and says: ERROR: File not found: CallWizard.py
I attach a file with the changes I've done. Greetings 2011/8/17 Caolán McNamara <caol...@redhat.com> > On Wed, 2011-08-17 at 09:06 +0100, Caolán McNamara wrote: > > I imagine that if you basically opengrok for mailmerge.py and > > mailmerge.component and follow the same pattern for your one that it'll > > get you a lot closer. > > Seeing as this is a bit tricky to get up and running, attached is a > rough-and-ready patch to turn wizards->letter into "hello world" in > python. > > i.e. > > a) add a "hello_world.component" (which gets run through the usual xslt > script via the local makefile.mk to tweak it to give the right location > where the .py will finally get installed) that describes a > hello_world.py component. The .component has the implementation name, > e.g. org.openoffice.comp.pyuno.demo.HelloWorld in it and the services it > implements, e.g. com.sun.star.task.Job > > b) I added a hello_world.py that implements that, see its > g_ImplementationHelper.addImplementation for the matching implementation > name and services > > c) add that hello_world.component to "postprocess" where it will be > basically added as an entry into the services.rdb in the final install > sets install/program/services.rdb (which is an xml file these days. That > should end up having "<component loader="com.sun.star.loader.Python" > uri="vnd.openoffice.pymodule:hello_world"><implementation > name="org.openoffice.comp.pyuno.demo.HelloWorld"><service > name="com.sun.star.task.Job"/></implementation></component></components>" > in it). > > d) change the wizards->letter line in officecfg to call it > > e) modify scp2 to install it > > f) I haven't a clue what the entry in instsetoo_native does anymore, I > think I used to know :-) > > hope this helps. > > C. >
From ac490d5f468ad36041ecd03e2761481be281c56a Mon Sep 17 00:00:00 2001 From: Xisco Fauli <aniste...@gmail.com> Date: Tue, 6 Sep 2011 19:39:20 +0200 Subject: [PATCH] call callwizard --- .../registry/data/org/openoffice/Office/Common.xcu | 2 +- postprocess/packcomponents/makefile.mk | 2 +- scp2/source/ooo/file_ooo.scp | 12 ++ scp2/source/ooo/module_hidden_ooo.scp | 1 + scripting/prj/d.lst | 1 + wizards/com/sun/star/wizards/fax/CallWizard.py | 175 ++++---------------- wizards/com/sun/star/wizards/fax/fax.component | 6 +- wizards/com/sun/star/wizards/fax/makefile.mk | 8 +- 8 files changed, 56 insertions(+), 151 deletions(-) diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu b/officecfg/registry/data/org/openoffice/Office/Common.xcu index 998ab38..85d4480 100644 --- a/officecfg/registry/data/org/openoffice/Office/Common.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu @@ -400,7 +400,7 @@ </node> <node oor:name="m1" oor:op="replace" install:module="writer"> <prop oor:name="URL" oor:type="xs:string"> - <value >service:com.sun.star.wizards.fax.CallWizard?start</value> + <value >service:com.sun.star.wizards.fax.CallWizard?insert</value> </prop> <prop oor:name="Title"> <value xml:lang="en-US">~Fax...</value> diff --git a/postprocess/packcomponents/makefile.mk b/postprocess/packcomponents/makefile.mk index addc3a2..ff264c8 100644 --- a/postprocess/packcomponents/makefile.mk +++ b/postprocess/packcomponents/makefile.mk @@ -364,7 +364,7 @@ my_components += evoab my_components += component/avmedia/source/gstreamer/avmediagstreamer .END -my_ooo_components = mailmerge +my_ooo_components = mailmerge component/wizards/com/sun/star/wizards/fax/fax .INCLUDE: target.mk diff --git a/scp2/source/ooo/file_ooo.scp b/scp2/source/ooo/file_ooo.scp index e77bdcf..3bc1eee 100644 --- a/scp2/source/ooo/file_ooo.scp +++ b/scp2/source/ooo/file_ooo.scp @@ -471,6 +471,18 @@ STD_JAR_FILE( gid_File_Jar_Saxon, saxon9 ) #endif #endif +#ifndef AIX +#ifndef DISABLE_PYUNO +File gid_File_PyFax + TXT_FILE_BODY; + Dir = gid_Dir_Program; + Name = "CallWizard.py"; + Styles = (PACKED); +End +#endif +#endif + + #ifndef SYSTEM_LIBTEXTCAT_DATA // fingerprint files (lm) diff --git a/scp2/source/ooo/module_hidden_ooo.scp b/scp2/source/ooo/module_hidden_ooo.scp index 9dd3ab1..287e277 100644 --- a/scp2/source/ooo/module_hidden_ooo.scp +++ b/scp2/source/ooo/module_hidden_ooo.scp @@ -139,6 +139,7 @@ Module gid_Module_Root_Files_3 gid_File_Jar_Table, gid_File_Jar_Letter, gid_File_Jar_Form, + gid_File_PyFax, gid_File_Jar_Agenda, gid_File_Jar_Web, gid_File_Jar_Query, diff --git a/scripting/prj/d.lst b/scripting/prj/d.lst index f1caf45..5deedbe 100644 --- a/scripting/prj/d.lst +++ b/scripting/prj/d.lst @@ -16,6 +16,7 @@ mkdir: %_DEST%\bin\pyuno ..\%__SRC%\lib\lib*static*.dylib %_DEST%\lib\lib*static*.dylib ..\%__SRC%\misc\mailmerge.component %_DEST%\xml\mailmerge.component +..\%__SRC%\misc\fax.component %_DEST%\xml\fax.component ..\%__SRC%\misc\ScriptFramework.component %_DEST%\xml\ScriptFramework.component ..\%__SRC%\misc\ScriptProviderForJava.component %_DEST%\xml\ScriptProviderForJava.component ..\%__SRC%\misc\basprov.component %_DEST%\xml\basprov.component diff --git a/wizards/com/sun/star/wizards/fax/CallWizard.py b/wizards/com/sun/star/wizards/fax/CallWizard.py index 2141450..33385a2 100644 --- a/wizards/com/sun/star/wizards/fax/CallWizard.py +++ b/wizards/com/sun/star/wizards/fax/CallWizard.py @@ -1,156 +1,43 @@ -import traceback +# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -class CallWizard(object): +import uno +import unohelper - ''' - Gives a factory for creating the service. This method is called by the - <code>JavaLoader</code> - <p></p> - @param stringImplementationName The implementation name of the component. - @param xMSF The service manager, who gives access to every known service. - @param xregistrykey Makes structural information (except regarding tree - structures) of a single registry key accessible. - @return Returns a <code>XSingleServiceFactory</code> - for creating the component. - @see com.sun.star.comp.loader.JavaLoader# - ''' +from com.sun.star.task import XJobExecutor - @classmethod - def __getServiceFactory(self, stringImplementationName, xMSF, \ - xregistrykey): +# 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 - xsingleservicefactory = None - if stringImplementationName.equals(WizardImplementation.Name): - xsingleservicefactory = FactoryHelper.getServiceFactory( \ - WizardImplementation, WizardImplementation.__serviceName, - xMSF, xregistrykey) + def trigger(self, args): + # note: args[0] == "HelloWorld", see below config settings - return xsingleservicefactory + # retrieve the desktop object + desktop = self.ctx.ServiceManager.createInstanceWithContext( + "com.sun.star.frame.Desktop", self.ctx) - ''' - This class implements the component. At least the interfaces XServiceInfo, - XTypeProvider, and XInitialization should be provided by the service. - ''' + # get current document model + model = desktop.getCurrentComponent() - class WizardImplementation: - __serviceName = "com.sun.star.wizards.fax.CallWizard" - #private XMultiServiceFactory xmultiservicefactory + # access the document's text property + text = model.Text - ''' - The constructor of the inner class has a XMultiServiceFactory - parameter. - @param xmultiservicefactoryInitialization A special service factory - could be introduced while initializing. - ''' + # create a cursor + cursor = text.createTextCursor() - @classmethod - def WizardImplementation_XMultiServiceFactory(self, \ - xmultiservicefactoryInitialization): + # insert the text into the document + text.insertString(cursor, "Hello World", 0) - tmp = WizardImplementation() - tmp.WizardImplementation_body_XMultiServiceFactory( \ - xmultiservicefactoryInitialization) - return tmp +# pythonloader looks for a static g_ImplementationHelper variable +g_ImplementationHelper = unohelper.ImplementationHelper() - def WizardImplementation_body_XMultiServiceFactory(self, \ - xmultiservicefactoryInitialization): - - self.xmultiservicefactory = xmultiservicefactoryInitialization - if self.xmultiservicefactory != None: - pass - - ''' - Execute Wizard - @param str only valid parameter is 'start' at the moment. - ''' - - def trigger(self, str): - if str.equalsIgnoreCase("start"): - lw = FaxWizardDialogImpl(self.xmultiservicefactory) - if not FaxWizardDialogImpl.running: - lw.startWizard(self.xmultiservicefactory, None) - - ''' - The service name, that must be used to get an instance of this service - The service manager, that gives access to all registered services. - This method is a member of the interface for initializing an object - directly after its creation. - @param object This array of arbitrary objects will be passed to the - component after its creation. - @throws com.sun.star.uno.Exception Every exception will not be - handled, but will be passed to the caller. - ''' - - def initialize(self, object): - pass - - ''' - This method returns an array of all supported service names. - @return Array of supported service names. - ''' - - def getSupportedServiceNames(self): - stringSupportedServiceNames = range(1) - stringSupportedServiceNames[0] = self.__class__.__serviceName - return (stringSupportedServiceNames) - - ''' - This method returns true, if the given service will be supported by - the component. - @param stringService Service name. - @return True, if the given service name will be supported. - ''' - - def supportsService(self, stringService): - booleanSupportsService = False - if stringService.equals(self.__class__.__serviceName): - booleanSupportsService = True - - return (booleanSupportsService) - - ''' - This method returns an array of bytes, that can be used to - unambiguously distinguish between two sets of types, - e.g. to realise hashing functionality when the object is introspected. - Two objects that return the same ID also have to return the same - set of types in getTypes(). If an unique implementation Id cannot be - provided this method has to return an empty sequence. Important: - If the object aggregates other objects the ID has to be unique for - the whole combination of objects. - @return Array of bytes, in order to distinguish between two sets. - ''' - - def getImplementationId(self): - byteReturn = [] - try: - byteReturn = ("" + self.hashCode()).Bytes - except Exception, exception: - traceback.print_exc() - - return (byteReturn) - - ''' - Return the class name of the component. - @return Class name of the component. - ''' - - def getImplementationName(self): - return (WizardImplementation.Name) - - ''' - Provides a sequence of all types (usually interface types) provided - by the object. - @return Sequence of all types (usually interface types) provided - by the service. - ''' - - def getTypes(self): - typeReturn = [] - try: - #COMMENTED - #typeReturn = [new Type (XPropertyAccess.class), new Type (XJob.class), new Type (XJobExecutor.class), new Type (XTypeProvider.class), new Type (XServiceInfo.class), new Type (XInitialization.class)] - except Exception, exception: - traceback.print_exc() - - return (typeReturn) +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 462fe29..a03d00a 100644 --- a/wizards/com/sun/star/wizards/fax/fax.component +++ b/wizards/com/sun/star/wizards/fax/fax.component @@ -26,10 +26,10 @@ * **********************************************************************--> -<component loader="com.sun.star.loader.Java2" +<component loader="com.sun.star.loader.Python" xmlns="http://openoffice.org/2010/uno-components"> <implementation - name="com.sun.star.wizards.fax.CallWizard$WizardImplementation"> - <service name="com.sun.star.wizards.fax.CallWizard"/> + name="com.sun.star.wizards.fax.CallWizard"> + <service name="com.sun.star.task.Job"/> </implementation> </component> diff --git a/wizards/com/sun/star/wizards/fax/makefile.mk b/wizards/com/sun/star/wizards/fax/makefile.mk index 1afdc87..a867a48 100644 --- a/wizards/com/sun/star/wizards/fax/makefile.mk +++ b/wizards/com/sun/star/wizards/fax/makefile.mk @@ -28,13 +28,17 @@ PRJ = ..$/..$/..$/..$/.. PRJNAME = wizards TARGET = fax -PACKAGE = com$/sun$/star$/wizards$/fax # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk # --- Targets ------------------------------------------------------ +ALL : ALLTAR \ + $(DLLDEST)$/CallWizard.py + +$(DLLDEST)$/%.py: %.py + cp $? $@ .INCLUDE : target.mk @@ -43,5 +47,5 @@ ALLTAR : $(MISC)/fax.component $(MISC)/fax.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ fax.component $(XSLTPROC) --nonet --stringparam uri \ - '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \ + '$(COMPONENTPREFIX_BASIS_PYTHON)fax' -o $@ \ $(SOLARENV)/bin/createcomponent.xslt fax.component -- 1.7.1
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice