summaryrefslogtreecommitdiff
path: root/pyuno/demo
diff options
context:
space:
mode:
Diffstat (limited to 'pyuno/demo')
-rw-r--r--pyuno/demo/Addons.xcu20
-rw-r--r--pyuno/demo/hello_world_comp.py40
-rw-r--r--pyuno/demo/makefile.mk366
3 files changed, 265 insertions, 161 deletions
diff --git a/pyuno/demo/Addons.xcu b/pyuno/demo/Addons.xcu
new file mode 100644
index 000000000000..dcbb3ac92f2f
--- /dev/null
+++ b/pyuno/demo/Addons.xcu
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oor:node xmlns:oor="http://openoffice.org/2001/registry"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ oor:name="Addons" oor:package="org.openoffice.Office">
+<node oor:name="AddonUI">
+ <node oor:name="AddonMenu">
+ <node oor:name="org.openoffice.comp.pyuno.demo.HelloWorld" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>service:org.openoffice.comp.pyuno.demo.HelloWorld?insert</value>
+ </prop>
+ <prop oor:name="ImageIdentifier" oor:type="xs:string">
+ <value>private:image/3216</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Insert Hello World</value>
+ </prop>
+ </node>
+ </node>
+</node>
+</oor:node>
diff --git a/pyuno/demo/hello_world_comp.py b/pyuno/demo/hello_world_comp.py
new file mode 100644
index 000000000000..a9bc488853ec
--- /dev/null
+++ b/pyuno/demo/hello_world_comp.py
@@ -0,0 +1,40 @@
+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
+ "org.openoffice.comp.pyuno.demo.HelloWorld", # implemenation name
+ ("com.sun.star.task.Job",),) # list of implemented services
+ # (the only service)
diff --git a/pyuno/demo/makefile.mk b/pyuno/demo/makefile.mk
index 8aef71f4a75d..f328ac5a6ddc 100644
--- a/pyuno/demo/makefile.mk
+++ b/pyuno/demo/makefile.mk
@@ -4,182 +4,226 @@ PRJ=..
.INCLUDE : settings.mk
.INCLUDE : pyversion.mk
-VERSION=0.9.4
-PYDIRNAME=python-$(PYVERSION)
-.IF "$(GUI)"=="WNT"
-INISUFFIX=.ini
-BATCHSUFFIX=.bat
-ENVSUFFIX=.bat
-PLATFORM=win32
-EXESUFFIX=.exe
-PACKSUFFIX=.zip
-MYCOPY=copy
-DOLLAR_SIGN=$$
-.ELSE
-DOLLAR_SIGN=\$$
-PACKSUFFIX=.tar.gz
-MYCOPY=cp
-BATCHSUFFIX=.sh
-ENVSUFFIX=.tcsh
-INISUFFIX=rc
-PYUNOMODULE=$(DESTROOT)$/program$/pyuno$(DLLPOST)
-PYTHONLIBRARY=$(DESTROOT)$/program$/$(DLLPRE)python$(DLLPOST).$(PYVERSION)
-PYRUNTIMELINK=$(DESTROOT)$/program$/python
-PYRUNTIMELIBLINK1=$(DESTROOT)$/program$/libpython.so.2
-PYRUNTIMELIBLINK2=$(DESTROOT)$/program$/libpython.so
-
-.IF "$(OS)$(CPU)"=="SOLARISS"
-PLATFORM=solaris-sparc
-.ELIF "$(OS)$(CPU)"=="SOLARISI"
-PLATFORM=solaris-x86
-.ELIF "$(OS)$(CPU)"=="LINUXI"
-PLATFORM=linux-x86
-.ELIF "$(OS)$(CPU)"=="LINUXP"
-PLATFORM=linux-ppc
-.ELSE
-error please add your platform
-.ENDIF
-
-.ENDIF
-
-DESTROOT=$(BIN)$/root
-
-FINDDIRS=$(subst,/,$/ $(shell +cd $(SOLARLIBDIR)$/python && $(FIND) . -type d))
-FINDLIBFILES=$(subst,/,$/ $(shell +cd $(SOLARLIBDIR)$/python && $(FIND) . -type f))
-
-PYRUNTIME_DIRS=\
- $(DESTROOT) \
- $(DESTROOT)$/program \
- $(DESTROOT)$/program/pydemo \
- $(DESTROOT)$/program$/$(PYDIRNAME) \
- $(DESTROOT)$/program$/$(PYDIRNAME)$/bin \
- $(DESTROOT)$/program$/$(PYDIRNAME)$/lib \
- $(foreach,i,$(FINDDIRS) $(DESTROOT)$/program$/$(PYDIRNAME)$/lib$/$(i))
+ROOT=$(MISC)$/pyuno-doc
FILES=\
- $(DESTROOT)$/program$/$(DLLPRE)pyuno$(DLLPOST) \
- $(DESTROOT)$/program$/pythonloader.uno$(DLLPOST) \
- $(DESTROOT)$/program$/pyuno$(INISUFFIX) \
- $(DESTROOT)$/program$/uno.py \
- $(DESTROOT)$/program$/unohelper.py \
- $(DESTROOT)$/program$/pythonloader.py \
- $(DESTROOT)$/program$/pyuno_setup$(BATCHSUFFIX) \
- $(DESTROOT)$/program$/regcomp$(EXESUFFIX) \
- $(DESTROOT)$/program$/pyunoenv$(ENVSUFFIX) \
- $(DESTROOT)$/program$/pydemo$/biblioaccess.py \
- $(DESTROOT)$/program$/pydemo$/ooextract.py \
- $(DESTROOT)$/program$/pydemo$/swriter.py \
- $(DESTROOT)$/program$/pydemo$/swritercomp.py \
- $(DESTROOT)$/program$/pydemo$/swritercompclient.py \
- $(DESTROOT)$/program$/pydemo$/swritercompclient.py \
- $(DESTROOT)$/program$/pydemo$/python-bridge.html \
- $(PYUNOMODULE) \
- $(PYTHONLIBRARY) \
- $(DESTROOT)$/program$/$(PYDIRNAME)$/bin$/python$(EXESUFFIX) \
- $(foreach,i,$(FINDLIBFILES) $(DESTROOT)$/program$/$(PYDIRNAME)$/lib$/$(i)) \
- $(PYRUNTIMELINK) \
- $(PYRUNTIMELIBLINK1) \
- $(PYRUNTIMELIBLINK2)
-
-
-
-$(BIN)$/pyuno-$(PLATFORM)-$(PYVERSION)$(PACKSUFFIX) : makefile.mk dirs $(FILES)
- -rm $@
-.IF "$(GUI)"=="WNT"
- +cd $(DESTROOT) && zip -r ..$/pyuno-$(PLATFORM)-$(VERSION)$(PACKSUFFIX) program
-.ELSE
- $(FIND) $(DESTROOT) -name '*.so' | xargs strip
- cd $(DESTROOT) && tar -cO program | gzip - > ..$/pyuno-$(PLATFORM)-$(VERSION)$(PACKSUFFIX)
-.ENDIF
-
-
-dirs .PHONY:
- -mkdir $(PYRUNTIME_DIRS)
-
-# Some symbolic links for unix
-.IF "$(GUI)" == "UNX"
-$(PYRUNTIMELINK) : makefile.mk
+ $(ROOT)$/python-bridge.html \
+ $(ROOT)$/customized_setup.png \
+ $(ROOT)$/mode_component.png \
+ $(ROOT)$/mode_ipc.png \
+ $(ROOT)$/modes.sxd \
+ $(ROOT)$/optional_components.png \
+ $(ROOT)$/samples$/swriter.py \
+ $(ROOT)$/samples$/swritercomp.py \
+ $(ROOT)$/samples$/ooextract.py \
+ $(ROOT)$/samples$/biblioaccess.py \
+ $(ROOT)$/samples$/swritercompclient.py \
+ $(ROOT)$/samples$/hello_world_pyuno.zip
+
+
+
+$(MISC)$/pyuno-doc.zip : dirs $(FILES)
-rm -f $@
- cd $(DESTROOT)$/program && ln -s $(PYDIRNAME) python
+ cd $(MISC) && zip -r pyuno-doc.zip pyuno-doc
+dirs .PHONY :
+ -mkdir $(ROOT)
+ -mkdir $(ROOT)$/samples
-$(PYRUNTIMELIBLINK1) : makefile.mk
- -rm -f $@
- cd $(DESTROOT)$/program && ln -s $(DLLPRE)python$(DLLPOST).$(PYVERSION) $(DLLPRE)python$(DLLPOST).$(PYMAJOR)
-$(PYRUNTIMELIBLINK2) : makefile.mk
+$(ROOT)$/samples$/hello_world_pyuno.zip : hello_world_comp.py Addons.xcu
-rm -f $@
- cd $(DESTROOT)$/program && ln -s $(DLLPRE)python$(DLLPOST).$(PYVERSION) $(DLLPRE)python$(DLLPOST)
-.ENDIF
-
-$(DESTROOT)$/program$/regcomp$(EXESUFFIX) : $(SOLARBINDIR)$/regcomp$(EXESUFFIX)
- cp $? $@
-.IF "$(GUI)" == "UNX"
- strip $@
- chmod +x $@
-.ENDIF
+ zip $@ hello_world_comp.py Addons.xcu
-
-$(DESTROOT)$/program$/pyunoenv$(ENVSUFFIX) : pyunoenv$(ENVSUFFIX)
+$(ROOT)$/samples$/% : %
-rm -f $@
cat $? > $@
-$(DESTROOT)$/program$/$(DLLPRE)pyuno$(DLLPOST) : $(DLLDEST)$/$(DLLPRE)pyuno$(DLLPOST)
- cp $? $@
-
-$(DESTROOT)$/program$/pyuno_setup$(BATCHSUFFIX) : makefile.mk
- -rm -f $@
-.IF "$(GUI)"!="WNT"
- echo #\!/bin/sh >> $@
- chmod +x $@
-.ENDIF
- echo regcomp -register -r services.rdb -c pythonloader.uno >>$@
-# echo "$(MYCOPY) applicat.rdb pydemo$/applicat.rdb" >> $@
- echo regcomp -register -br types.rdb -br services.rdb -r services.rdb -c vnd.openoffice.pymodule:swritercomp -l com.sun.star.loader.Python >>$@
-
-$(DESTROOT)$/program$/$(DLLPRE)python$(DLLPOST).$(PYVERSION) : $(SOLARLIBDIR)$/$(DLLPRE)python$(DLLPOST).$(PYVERSION)
- cp $? $@
-
-$(DESTROOT)$/program$/pythonloader.uno$(DLLPOST) : $(DLLDEST)$/pythonloader.uno$(DLLPOST)
- cp $? $@
-
-$(DESTROOT)$/program$/%.py : $(DLLDEST)$/%.py
- cp $? $@
-
-.IF "$(GUI)" == "UNX"
-$(DESTROOT)$/program$/pyuno$(DLLPOST) : $(DLLDEST)$/pyuno$(DLLPOST)
- cp $? $@
-.ENDIF
-
-$(DESTROOT)$/program$/pydemo$/%.py : %.py
- -rm -f $@
- cat $? > $@
-
-$(DESTROOT)$/program$/pyuno$(INISUFFIX) : makefile.mk
- -rm -f $@ $(DESTROOT)$/program$/pyuno.tmp
- echo UNO_TYPES=$(DOLLAR_SIGN)PYUNOLIBDIR/types.rdb > $(DESTROOT)$/program$/pyuno.tmp
- echo UNO_SERVICES=$(DOLLAR_SIGN)PYUNOLIBDIR/services.rdb >> $(DESTROOT)$/program$/pyuno.tmp
- mv $(DESTROOT)$/program$/pyuno.tmp $@
-
-$(DESTROOT)$/program$/pydemo$/python-bridge.html : ..$/doc$/python-bridge.html
+$(ROOT)$/% : ..$/doc$/%
-rm -f $@
cat $? > $@
-
+#VERSION=0.9.4
+#PYDIRNAME=python-$(PYVERSION)
+#.IF "$(GUI)"=="WNT"
+#INISUFFIX=.ini
+#BATCHSUFFIX=.bat
+#ENVSUFFIX=.bat
+#PLATFORM=win32
+#EXESUFFIX=.exe
+#PACKSUFFIX=.zip
+#MYCOPY=copy
+#DOLLAR_SIGN=$$
+#.ELSE
+#DOLLAR_SIGN=\$$
+#PACKSUFFIX=.tar.gz
+#MYCOPY=cp
+#BATCHSUFFIX=.sh
+#ENVSUFFIX=.tcsh
+#INISUFFIX=rc
+#PYUNOMODULE=$(DESTROOT)$/program$/pyuno$(DLLPOST)
+#PYTHONLIBRARY=$(DESTROOT)$/program$/$(DLLPRE)python$(DLLPOST).$(PYVERSION)
+#PYRUNTIMELINK=$(DESTROOT)$/program$/python
+#PYRUNTIMELIBLINK1=$(DESTROOT)$/program$/libpython.so.2
+#PYRUNTIMELIBLINK2=$(DESTROOT)$/program$/libpython.so
+#
+#.IF "$(OS)$(CPU)"=="SOLARISS"
+#PLATFORM=solaris-sparc
+#.ELIF "$(OS)$(CPU)"=="SOLARISI"
+#PLATFORM=solaris-x86
+#.ELIF "$(OS)$(CPU)"=="LINUXI"
+#PLATFORM=linux-x86
+#.ELIF "$(OS)$(CPU)"=="LINUXP"
+#PLATFORM=linux-ppc
+#.ELSE
+#error please add your platform
+#.ENDIF
+#
+#.ENDIF
+#
+#DESTROOT=$(BIN)$/root
+#
+#FINDDIRS=$(subst,/,$/ $(shell +cd $(SOLARLIBDIR)$/python && $(FIND) . -type d))
+#FINDLIBFILES=$(subst,/,$/ $(shell +cd $(SOLARLIBDIR)$/python && $(FIND) . -type f))
+#
+#PYRUNTIME_DIRS=\
+# $(DESTROOT) \
+# $(DESTROOT)$/program \
+# $(DESTROOT)$/program/pydemo \
+# $(DESTROOT)$/program$/$(PYDIRNAME) \
+# $(DESTROOT)$/program$/$(PYDIRNAME)$/bin \
+# $(DESTROOT)$/program$/$(PYDIRNAME)$/lib \
+# $(foreach,i,$(FINDDIRS) $(DESTROOT)$/program$/$(PYDIRNAME)$/lib$/$(i))
+#
+#
+#FILES=\
+# $(DESTROOT)$/program$/$(DLLPRE)pyuno$(DLLPOST) \
+# $(DESTROOT)$/program$/pythonloader.uno$(DLLPOST) \
+# $(DESTROOT)$/program$/pyuno$(INISUFFIX) \
+# $(DESTROOT)$/program$/uno.py \
+# $(DESTROOT)$/program$/unohelper.py \
+# $(DESTROOT)$/program$/pythonloader.py \
+# $(DESTROOT)$/program$/pyuno_setup$(BATCHSUFFIX) \
+# $(DESTROOT)$/program$/regcomp$(EXESUFFIX) \
+# $(DESTROOT)$/program$/pyunoenv$(ENVSUFFIX) \
+# $(DESTROOT)$/program$/pydemo$/biblioaccess.py \
+# $(DESTROOT)$/program$/pydemo$/ooextract.py \
+# $(DESTROOT)$/program$/pydemo$/swriter.py \
+# $(DESTROOT)$/program$/pydemo$/swritercomp.py \
+# $(DESTROOT)$/program$/pydemo$/swritercompclient.py \
+# $(DESTROOT)$/program$/pydemo$/swritercompclient.py \
+# $(DESTROOT)$/program$/pydemo$/python-bridge.html \
+# $(PYUNOMODULE) \
+# $(PYTHONLIBRARY) \
+# $(DESTROOT)$/program$/$(PYDIRNAME)$/bin$/python$(EXESUFFIX) \
+# $(foreach,i,$(FINDLIBFILES) $(DESTROOT)$/program$/$(PYDIRNAME)$/lib$/$(i)) \
+# $(PYRUNTIMELINK) \
+# $(PYRUNTIMELIBLINK1) \
+# $(PYRUNTIMELIBLINK2)
+#
+#
+#
+#$(BIN)$/pyuno-$(PLATFORM)-$(PYVERSION)$(PACKSUFFIX) : makefile.mk dirs $(FILES)
+# -rm $@
+#.IF "$(GUI)"=="WNT"
+# +cd $(DESTROOT) && zip -r ..$/pyuno-$(PLATFORM)-$(VERSION)$(PACKSUFFIX) program
+#.ELSE
+# $(FIND) $(DESTROOT) -name '*.so' | xargs strip
+# cd $(DESTROOT) && tar -cO program | gzip - > ..$/pyuno-$(PLATFORM)-$(VERSION)$(PACKSUFFIX)
+#.ENDIF
+#
+#
+#dirs .PHONY:
+# -mkdir $(PYRUNTIME_DIRS)
+#
+## Some symbolic links for unix
+#.IF "$(GUI)" == "UNX"
+#$(PYRUNTIMELINK) : makefile.mk
+# -rm -f $@
+# cd $(DESTROOT)$/program && ln -s $(PYDIRNAME) python
+#
+#$(PYRUNTIMELIBLINK1) : makefile.mk
+# -rm -f $@
+# cd $(DESTROOT)$/program && ln -s $(DLLPRE)python$(DLLPOST).$(PYVERSION) $(DLLPRE)python$(DLLPOST).$(PYMAJOR)
+#
+#$(PYRUNTIMELIBLINK2) : makefile.mk
+# -rm -f $@
+# cd $(DESTROOT)$/program && ln -s $(DLLPRE)python$(DLLPOST).$(PYVERSION) $(DLLPRE)python$(DLLPOST)
+#.ENDIF
+#
+#$(DESTROOT)$/program$/regcomp$(EXESUFFIX) : $(SOLARBINDIR)$/regcomp$(EXESUFFIX)
+# cp $? $@
+#.IF "$(GUI)" == "UNX"
+# strip $@
+# chmod +x $@
+#.ENDIF
+#
+#
+#$(DESTROOT)$/program$/pyunoenv$(ENVSUFFIX) : pyunoenv$(ENVSUFFIX)
+# -rm -f $@
+# cat $? > $@
+#
+#$(DESTROOT)$/program$/$(DLLPRE)pyuno$(DLLPOST) : $(DLLDEST)$/$(DLLPRE)pyuno$(DLLPOST)
+# cp $? $@
+#
+#$(DESTROOT)$/program$/pyuno_setup$(BATCHSUFFIX) : makefile.mk
+# -rm -f $@
+#.IF "$(GUI)"!="WNT"
+# echo #\!/bin/sh >> $@
+# chmod +x $@
+#.ENDIF
+# echo regcomp -register -r services.rdb -c pythonloader.uno >>$@
+## echo "$(MYCOPY) applicat.rdb pydemo$/applicat.rdb" >> $@
+# echo regcomp -register -br types.rdb -br services.rdb -r services.rdb -c vnd.openoffice.pymodule:swritercomp -l com.sun.star.loader.Python >>$@
+#
+#$(DESTROOT)$/program$/$(DLLPRE)python$(DLLPOST).$(PYVERSION) : $(SOLARLIBDIR)$/$(DLLPRE)python$(DLLPOST).$(PYVERSION)
+# cp $? $@
+#
+#$(DESTROOT)$/program$/pythonloader.uno$(DLLPOST) : $(DLLDEST)$/pythonloader.uno$(DLLPOST)
+# cp $? $@
+#
+#$(DESTROOT)$/program$/%.py : $(DLLDEST)$/%.py
+# cp $? $@
+#
+#.IF "$(GUI)" == "UNX"
+#$(DESTROOT)$/program$/pyuno$(DLLPOST) : $(DLLDEST)$/pyuno$(DLLPOST)
+# cp $? $@
+#.ENDIF
+#
+#$(DESTROOT)$/program$/pydemo$/%.py : %.py
+# -rm -f $@
+# cat $? > $@
+#
+#$(DESTROOT)$/program$/pyuno$(INISUFFIX) : makefile.mk
+# -rm -f $@ $(DESTROOT)$/program$/pyuno.tmp
+# echo UNO_TYPES=$(DOLLAR_SIGN)PYUNOLIBDIR/types.rdb > $(DESTROOT)$/program$/pyuno.tmp
+# echo UNO_SERVICES=$(DOLLAR_SIGN)PYUNOLIBDIR/services.rdb >> $(DESTROOT)$/program$/pyuno.tmp
+# mv $(DESTROOT)$/program$/pyuno.tmp $@
+#
+#$(DESTROOT)$/program$/pydemo$/python-bridge.html : ..$/doc$/python-bridge.html
+# -rm -f $@
+# cat $? > $@
+#
+#
# $(DESTROOT)$/program$/$(PYDIRNAME)$/lib$/%.so : $(SOLARLIBDIR)$/python$/%.so
# -rm -f $@
# cat $? > $@
# strip $@
-
-$(DESTROOT)$/program$/$(PYDIRNAME)$/lib$/% : $(SOLARLIBDIR)$/python$/%
- -rm -f $@
- cat $? > $@
-
-
-$(DESTROOT)$/program$/$(PYDIRNAME)$/bin$/python$(EXESUFFIX) : $(SOLARBINDIR)$/python$(EXESUFFIX)
- -rm -f $@
- cat $? > $@
-.IF "$(GUI)" == "UNX"
- strip $@
- chmod +x $@
-.ENDIF
+#
+#$(DESTROOT)$/program$/$(PYDIRNAME)$/lib$/% : $(SOLARLIBDIR)$/python$/%
+# -rm -f $@
+# cat $? > $@
+#
+#
+#$(DESTROOT)$/program$/$(PYDIRNAME)$/bin$/python$(EXESUFFIX) : $(SOLARBINDIR)$/python$(EXESUFFIX)
+# -rm -f $@
+# cat $? > $@
+#.IF "$(GUI)" == "UNX"
+# strip $@
+# chmod +x $@
+#.ENDIF
+#
+#
+#
+#
+# \ No newline at end of file