Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On Wed, 2011-09-07 at 11:24 +0100, Caolán McNamara wrote:
On Tue, 2011-09-06 at 19:49 +0200, Xisco Faulí wrote:
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 see that wizards has been converted to gmake in the meantime, so it no
longer uses dmake makefile.mk stuff, we need some gbuild support for
copying .py files into their final locations with some form of
pyuno .component file support support.

dtardon was good enough to put together the gmake stuff needed to get
this bootstrapped, which are now committed to master.

So here's your patch back again, except "gbuildified" so this should
work to make wizards->fax stick hello world into writer.

There's still a lot of nasty things, dumping the .py directly into
"program" as opposed to making some sort of subdir into which they can
go, but maybe it'll help

C.
From 9e5fa73cecb5ce2676bde611e4ab38611c9533d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Wed, 7 Sep 2011 17:15:52 +0100
Subject: [PATCH] demo, for the purposes of saying hello world

---
 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                       |   12 ++
 scp2/source/ooo/module_hidden_ooo.scp              |    2 +-
 scripting/prj/d.lst                                |    1 +
 wizards/Module_wizards.mk                          |    2 +-
 wizards/Pyuno_fax.mk                               |   34 ++++
 wizards/com/sun/star/wizards/fax/CallWizard.py     |  175 ++++----------------
 wizards/com/sun/star/wizards/fax/fax.component     |    6 +-
 11 files changed, 87 insertions(+), 152 deletions(-)
 create mode 100644 wizards/Pyuno_fax.mk

diff --git a/instsetoo_native/util/makefile.mk b/instsetoo_native/util/makefile.mk
index 6880750..fc1cc61 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 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 33f0f01..05bf897 100644
--- a/postprocess/packcomponents/makefile.mk
+++ b/postprocess/packcomponents/makefile.mk
@@ -370,7 +370,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 61589b6..4583dec 100644
--- a/scp2/source/ooo/file_ooo.scp
+++ b/scp2/source/ooo/file_ooo.scp
@@ -472,6 +472,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 273f802..c25c87b 100644
--- a/scp2/source/ooo/module_hidden_ooo.scp
+++ b/scp2/source/ooo/module_hidden_ooo.scp
@@ -139,7 +139,7 @@ Module gid_Module_Root_Files_3
        gid_File_Jar_Table,
        gid_File_Jar_Letter,
        gid_File_Jar_Form,
-       gid_File_Jar_Fax,
+       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/Module_wizards.mk b/wizards/Module_wizards.mk
index 7f08d0f..090a429 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 \
@@ -56,7 +57,6 @@ ifeq ($(SOLAR_JAVA),TRUE)
 $(eval $(call gb_Module_add_targets,wizards,\
        Jar_commonwizards \
        Jar_agenda \
-       Jar_fax \
        Jar_form \
        Jar_letter \
        Jar_query \
diff --git a/wizards/Pyuno_fax.mk b/wizards/Pyuno_fax.mk
new file mode 100644
index 0000000..1de81e0
--- /dev/null
+++ b/wizards/Pyuno_fax.mk
@@ -0,0 +1,34 @@
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# Copyright (C) 2011 David Tardon, Red Hat Inc. <dtardon@redhat.com> (initial developer)
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+$(eval $(call gb_Pyuno_Pyuno,CallWizard,$(SRCDIR)/wizards/com/sun/star/wizards/fax))
+
+$(eval $(call gb_Pyuno_add_files,CallWizard,\
+    CallWizard.py \
+))
+
+$(eval $(call gb_Pyuno_set_componentfile,CallWizard,wizards/com/sun/star/wizards/fax/fax))
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab:
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>

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.