summaryrefslogtreecommitdiff
path: root/pyuno/demo
diff options
context:
space:
mode:
Diffstat (limited to 'pyuno/demo')
-rw-r--r--pyuno/demo/Addons.xcu21
-rw-r--r--pyuno/demo/biblioaccess.py36
-rw-r--r--pyuno/demo/hello_world_comp.py43
-rw-r--r--pyuno/demo/makefile.mk42
-rw-r--r--pyuno/demo/ooextract.py112
-rw-r--r--pyuno/demo/pyunoenv.bat6
-rw-r--r--pyuno/demo/pyunoenv.tcsh32
-rw-r--r--pyuno/demo/swriter.py105
-rw-r--r--pyuno/demo/swritercomp.py111
-rw-r--r--pyuno/demo/swritercompclient.py15
10 files changed, 0 insertions, 523 deletions
diff --git a/pyuno/demo/Addons.xcu b/pyuno/demo/Addons.xcu
deleted file mode 100644
index 75ec5188e..000000000
--- a/pyuno/demo/Addons.xcu
+++ /dev/null
@@ -1,21 +0,0 @@
-<?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="x-no-translate">Insert Hello World</value>
- <value xml:lang="en-US">Insert Hello World</value>
- </prop>
- </node>
- </node>
-</node>
-</oor:node>
diff --git a/pyuno/demo/biblioaccess.py b/pyuno/demo/biblioaccess.py
deleted file mode 100644
index 59d843ad6..000000000
--- a/pyuno/demo/biblioaccess.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-
-import uno
-from com.sun.star.sdb.CommandType import COMMAND
-
-def main():
- connectionString = "socket,host=localhost,port=2002"
-
- url = "uno:" + connectionString + ";urp;StarOffice.ComponentContext"
-
- localCtx = uno.getComponentContext()
- localSmgr = localCtx.ServiceManager
- resolver = localSmgr.createInstanceWithContext(
- "com.sun.star.bridge.UnoUrlResolver", localCtx)
- ctx = resolver.resolve(url)
- smgr = ctx.ServiceManager
-
- rowset =smgr.createInstanceWithContext("com.sun.star.sdb.RowSet", ctx)
- rowset.DataSourceName = "Bibliography"
- rowset.CommandType = COMMAND
- rowset.Command = "SELECT IDENTIFIER, AUTHOR FROM biblio"
-
- rowset.execute();
-
- print("Identifier\tAuthor")
-
- id = rowset.findColumn("IDENTIFIER")
- author = rowset.findColumn("AUTHOR")
- while rowset.next():
- print(rowset.getString(id) + "\t" + repr(rowset.getString(author)))
-
- rowset.dispose();
-
-main()
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/pyuno/demo/hello_world_comp.py b/pyuno/demo/hello_world_comp.py
deleted file mode 100644
index 32f405628..000000000
--- a/pyuno/demo/hello_world_comp.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- 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
- "org.openoffice.comp.pyuno.demo.HelloWorld", # implemenation name
- ("com.sun.star.task.Job",),) # list of implemented services
- # (the only service)
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/pyuno/demo/makefile.mk b/pyuno/demo/makefile.mk
deleted file mode 100644
index e00a2fb7c..000000000
--- a/pyuno/demo/makefile.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-PRJNAME=pyuno
-PRJ=..
-
-.INCLUDE : settings.mk
-.INCLUDE : pyversion.mk
-
-ROOT=$(MISC)/pyuno-doc
-
-FILES=\
- $(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 $(MISC) && zip -r pyuno-doc.zip pyuno-doc
-
-dirs .PHONY :
- -mkdir $(ROOT)
- -mkdir $(ROOT)/samples
-
-$(ROOT)/samples/hello_world_pyuno.zip : hello_world_comp.py Addons.xcu
- -rm -f $@
- zip $@ hello_world_comp.py Addons.xcu
-
-$(ROOT)/samples/% : %
- -rm -f $@
- $(COPY) $? $@
-
-$(ROOT)/% : ../doc/%
- -rm -f $@
- $(COPY) $? $@
diff --git a/pyuno/demo/ooextract.py b/pyuno/demo/ooextract.py
deleted file mode 100644
index 3959bf74b..000000000
--- a/pyuno/demo/ooextract.py
+++ /dev/null
@@ -1,112 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-
-import getopt,sys
-import uno
-from unohelper import Base,systemPathToFileUrl, absolutize
-from os import getcwd
-
-from com.sun.star.beans import PropertyValue
-from com.sun.star.beans.PropertyState import DIRECT_VALUE
-from com.sun.star.uno import Exception as UnoException
-from com.sun.star.io import IOException,XInputStream, XOutputStream
-
-class OutputStream(Base, XOutputStream):
- def __init__(self):
- self.closed = 0
-
- def closeOutput(self):
- self.closed = 1
-
- def writeBytes(self, seq):
- sys.stdout.write(seq.value)
-
- def flush(self):
- pass
-
-def main():
- retVal = 0
- doc = None
-
- try:
- opts, args = getopt.getopt(sys.argv[1:], "hc:", ["help", "connection-string=", "html"])
- format = None
- url = "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
- filterName = "Text (Encoded)"
- for o, a in opts:
- if o in ("-h", "--help"):
- usage()
- sys.exit()
- if o in ("-c", "--connection-string"):
- url = "uno:" + a + ";urp;StarOffice.ComponentContext"
- if o == "--html":
- filterName = "HTML (StarWriter)"
-
- print(filterName)
- if not len(args):
- usage()
- sys.exit()
-
- ctxLocal = uno.getComponentContext()
- smgrLocal = ctxLocal.ServiceManager
-
- resolver = smgrLocal.createInstanceWithContext(
- "com.sun.star.bridge.UnoUrlResolver", ctxLocal)
- ctx = resolver.resolve(url)
- smgr = ctx.ServiceManager
-
- desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
-
- cwd = systemPathToFileUrl(getcwd())
- outProps = (
- PropertyValue("FilterName" , 0, filterName, 0),
- PropertyValue("OutputStream", 0, OutputStream(), 0))
- inProps = PropertyValue("Hidden", 0 , True, 0),
- for path in args:
- try:
- fileUrl = uno.absolutize(cwd, systemPathToFileUrl(path))
- doc = desktop.loadComponentFromURL(fileUrl , "_blank", 0, inProps)
-
- if not doc:
- raise UnoException("Could not open stream for unknown reason", None)
-
- doc.storeToURL("private:stream", outProps)
- except IOException as e:
- sys.stderr.write("Error during conversion: " + e.Message + "\n")
- retVal = 1
- except UnoException as e:
- sys.stderr.write("Error (" + repr(e.__class__) + ") during conversion: " + e.Message + "\n")
- retVal = 1
- if doc:
- doc.dispose()
-
- except UnoException as e:
- sys.stderr.write("Error (" + repr(e.__class__) + "): " + e.Message + "\n")
- retVal = 1
- except getopt.GetoptError as e:
- sys.stderr.write(str(e) + "\n")
- usage()
- retVal = 1
-
- sys.exit(retVal)
-
-def usage():
- sys.stderr.write("usage: ooextract.py --help |\n"+
- " [-c <connection-string> | --connection-string=<connection-string>\n"+
- " file1 file2 ...\n"+
- "\n" +
- "Extracts plain text from documents and prints it to stdout.\n" +
- "Requires an OpenOffice.org instance to be running. The script and the\n"+
- "running OpenOffice.org instance must be able to access the file with\n"+
- "by the same system path.\n"
- "\n"+
- "-c <connection-string> | --connection-string=<connection-string>\n" +
- " The connection-string part of a uno url to where the\n" +
- " the script should connect to in order to do the conversion.\n" +
- " The strings defaults to socket,host=localhost,port=2002\n"
- "--html \n"
- " Instead of the text filter, the writer html filter is used\n"
- )
-
-main()
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/pyuno/demo/pyunoenv.bat b/pyuno/demo/pyunoenv.bat
deleted file mode 100644
index 1a8239992..000000000
--- a/pyuno/demo/pyunoenv.bat
+++ /dev/null
@@ -1,6 +0,0 @@
-set OOOHOME=
-
-
-set PYTHONPATH=.;%OOOHOME%\program;%OOOHOME%\program\pydemo;%OOOHOME%\program\python-2.2.2;%PYTHONPATH%
-set PATH=%OOOHOME%\program;%PYTHONHOME%;%OOOHOME%\program\python-2.2.2\bin;%PATH%
-
diff --git a/pyuno/demo/pyunoenv.tcsh b/pyuno/demo/pyunoenv.tcsh
deleted file mode 100644
index dbe69d0ec..000000000
--- a/pyuno/demo/pyunoenv.tcsh
+++ /dev/null
@@ -1,32 +0,0 @@
-# the path to the office installation (e.g. /home/joe/OpenOffice.org1.1Beta)
-setenv OOOHOME /src4/OpenOffice.org1.1Beta2
-
-# don't modify anything beyond these lines
-#---------------------------------------------
-setenv PYTHONHOME $OOOHOME/program/python
-
-if( ! $?LD_LIBRARY_PATH ) then
- setenv LD_LIBRARY_PATH
-endif
-
-if(! $?PYTHONPATH ) then
- setenv PYTHONPATH
-endif
-
-if( ! $?LD_LIBRARY_PATH ) then
-setenv LD_LIBRARY_PATH
-endif
-
-if( "$PYTHONPATH" != "" ) then
- setenv PYTHONPATH $OOOHOME/program:$OOOHOME/program/pydemo:$OOOHOME/program/python/lib:$PYTHONPATH
-else
- setenv PYTHONPATH $OOOHOME/program:$OOOHOME/program/pydemo:$OOOHOME/program/python/lib
-endif
-
-setenv LD_LIBRARY_PATH $OOOHOME/program:$LD_LIBRARY_PATH
-
-if( $?PYTHONHOME ) then
-setenv PATH $PYTHONHOME/bin:$PATH
-endif
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/pyuno/demo/swriter.py b/pyuno/demo/swriter.py
deleted file mode 100644
index bf40a56e9..000000000
--- a/pyuno/demo/swriter.py
+++ /dev/null
@@ -1,105 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-
-# bootstrap uno component context
-import uno
-import unohelper
-
-from com.sun.star.lang import IllegalArgumentException
-
-# a UNO struct later needed to create a document
-from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
-from com.sun.star.text.TextContentAnchorType import AS_CHARACTER
-from com.sun.star.awt import Size
-
-
-def insertTextIntoCell( table, cellName, text, color ):
- tableText = table.getCellByName( cellName )
- cursor = tableText.createTextCursor()
- cursor.setPropertyValue( "CharColor", color )
- tableText.setString( text )
-
-localContext = uno.getComponentContext()
-
-resolver = localContext.ServiceManager.createInstanceWithContext(
- "com.sun.star.bridge.UnoUrlResolver", localContext )
-
-smgr = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ServiceManager" )
-remoteContext = smgr.getPropertyValue( "DefaultContext" )
-
-#remoteContext = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
-#smgr = remoteContext.ServiceManager
-
-desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",remoteContext)
-
-# open a writer document
-doc = desktop.loadComponentFromURL( "private:factory/swriter","_blank", 0, () )
-
-text = doc.Text
-cursor = text.createTextCursor()
-text.insertString( cursor, "The first line in the newly created text document.\n", 0 )
-text.insertString( cursor, "Now we are in the second line\n" , 0 )
-
-# create a text table
-table = doc.createInstance( "com.sun.star.text.TextTable" )
-
-# with 4 rows and 4 columns
-table.initialize(4, 4)
-
-text.insertTextContent( cursor, table, 0 )
-rows = table.Rows
-
-table.setPropertyValue( "BackTransparent", False )
-table.setPropertyValue( "BackColor", 13421823 )
-row = rows.getByIndex(0)
-row.setPropertyValue( "BackTransparent", False )
-row.setPropertyValue( "BackColor", 6710932 )
-
-textColor = 16777215
-
-insertTextIntoCell( table, "A1", "FirstColumn", textColor )
-insertTextIntoCell( table, "B1", "SecondColumn", textColor )
-insertTextIntoCell( table, "C1", "ThirdColumn", textColor )
-insertTextIntoCell( table, "D1", "SUM", textColor )
-
-table.getCellByName("A2").setValue(22.5)
-table.getCellByName("B2").setValue(5615.3)
-table.getCellByName("C2").setValue(-2315.7)
-table.getCellByName("D2").setFormula("sum <A2:C2>")
-
-table.getCellByName("A3").setValue(21.5)
-table.getCellByName("B3").setValue(615.3)
-table.getCellByName("C3").setValue(-315.7)
-table.getCellByName("D3").setFormula("sum <A3:C3>")
-
-table.getCellByName("A4").setValue(121.5)
-table.getCellByName("B4").setValue(-615.3)
-table.getCellByName("C4").setValue(415.7)
-table.getCellByName("D4").setFormula("sum <A4:C4>")
-
-
-cursor.setPropertyValue( "CharColor", 255 )
-cursor.setPropertyValue( "CharShadowed", True )
-
-text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )
-text.insertString( cursor, " This is a colored Text - blue with shadow\n" , 0 )
-text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )
-
-textFrame = doc.createInstance( "com.sun.star.text.TextFrame" )
-textFrame.setSize( Size(15000,400))
-textFrame.setPropertyValue( "AnchorType" , AS_CHARACTER )
-
-
-text.insertTextContent( cursor, textFrame, 0 )
-
-textInTextFrame = textFrame.getText()
-cursorInTextFrame = textInTextFrame.createTextCursor()
-textInTextFrame.insertString( cursorInTextFrame, "The first line in the newly created text frame.", 0 )
-textInTextFrame.insertString( cursorInTextFrame, "\nWith this second line the height of the rame raises.",0)
-text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )
-
-cursor.setPropertyValue( "CharColor", 65536 )
-cursor.setPropertyValue( "CharShadowed", False )
-
-text.insertString( cursor, " That's all for now!" , 0 )
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/pyuno/demo/swritercomp.py b/pyuno/demo/swritercomp.py
deleted file mode 100644
index fd7025f04..000000000
--- a/pyuno/demo/swritercomp.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-
-# just a simple copy of the swriter.py demo, but implemented as a component. The advantage is,
-# that the component may run within the office process which may give a performance improvement.
-
-import unohelper
-import uno
-
-# a UNO struct later needed to create a document
-from com.sun.star.text.ControlCharacter import PARAGRAPH_BREAK
-from com.sun.star.text.TextContentAnchorType import AS_CHARACTER
-from com.sun.star.awt import Size
-
-from com.sun.star.lang import XMain
-
-def insertTextIntoCell( table, cellName, text, color ):
- tableText = table.getCellByName( cellName )
- cursor = tableText.createTextCursor()
- cursor.setPropertyValue( "CharColor", color )
- tableText.setString( text )
-
-# the UNO component
-# implementing the interface com.sun.star.lang.XMain
-# unohelper.Base implements the XTypeProvider interface
-class SWriterComp(XMain,unohelper.Base):
- def __init__( self, ctx ):
- self.ctx = ctx
-
- # implementation for XMain.run( [in] sequence< any > )
- def run( self,args ):
- ctx = self.ctx
- smgr = ctx.ServiceManager
- desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
-
- # open a writer document
- doc = desktop.loadComponentFromURL( "private:factory/swriter","_blank", 0, () )
-
- text = doc.Text
- cursor = text.createTextCursor()
- text.insertString( cursor, "The first line in the newly created text document.\n", 0 )
- text.insertString( cursor, "Now we are in the second line\n" , 0 )
-
- # create a text table
- table = doc.createInstance( "com.sun.star.text.TextTable" )
-
- # with 4 rows and 4 columns
- table.initialize( 4,4)
-
- text.insertTextContent( cursor, table, 0 )
- rows = table.Rows
-
- table.setPropertyValue( "BackTransparent", uno.Bool(0) )
- table.setPropertyValue( "BackColor", 13421823 )
- row = rows.getByIndex(0)
- row.setPropertyValue( "BackTransparent", uno.Bool(0) )
- row.setPropertyValue( "BackColor", 6710932 )
-
- textColor = 16777215
-
- insertTextIntoCell( table, "A1", "FirstColumn", textColor )
- insertTextIntoCell( table, "B1", "SecondColumn", textColor )
- insertTextIntoCell( table, "C1", "ThirdColumn", textColor )
- insertTextIntoCell( table, "D1", "SUM", textColor )
-
- table.getCellByName("A2").setValue(22.5)
- table.getCellByName("B2").setValue(5615.3)
- table.getCellByName("C2").setValue(-2315.7)
- table.getCellByName("D2").setFormula("sum <A2:C2>")
-
- table.getCellByName("A3").setValue(21.5)
- table.getCellByName("B3").setValue(615.3)
- table.getCellByName("C3").setValue(-315.7)
- table.getCellByName("D3").setFormula("sum <A3:C3>")
-
- table.getCellByName("A4").setValue(121.5)
- table.getCellByName("B4").setValue(-615.3)
- table.getCellByName("C4").setValue(415.7)
- table.getCellByName("D4").setFormula("sum <A4:C4>")
-
-
- cursor.setPropertyValue( "CharColor", 255 )
- cursor.setPropertyValue( "CharShadowed", uno.Bool(1) )
-
- text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )
- text.insertString( cursor, " This is a colored Text - blue with shadow\n" , 0 )
- text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )
-
- textFrame = doc.createInstance( "com.sun.star.text.TextFrame" )
- textFrame.setSize( Size(15000,400))
- textFrame.setPropertyValue( "AnchorType" , AS_CHARACTER )
-
- text.insertTextContent( cursor, textFrame, 0 )
-
- textInTextFrame = textFrame.getText()
- cursorInTextFrame = textInTextFrame.createTextCursor()
- textInTextFrame.insertString( cursorInTextFrame, "The first line in the newly created text frame.", 0 )
- textInTextFrame.insertString( cursorInTextFrame, "\nWith this second line the height of the rame raises.",0)
- text.insertControlCharacter( cursor, PARAGRAPH_BREAK, 0 )
-
- cursor.setPropertyValue( "CharColor", 65536 )
- cursor.setPropertyValue( "CharShadowed", uno.Bool(0) )
-
- text.insertString( cursor, " That's all for now!" , 0 )
- return 0
-
-# pythonloader looks for a static g_ImplementationHelper variable
-g_ImplementationHelper = unohelper.ImplementationHelper()
-g_ImplementationHelper.addImplementation( \
- SWriterComp,"org.openoffice.comp.pyuno.swriter",("org.openoffice.demo.SWriter",),)
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/pyuno/demo/swritercompclient.py b/pyuno/demo/swritercompclient.py
deleted file mode 100644
index 19ca6b5c1..000000000
--- a/pyuno/demo/swritercompclient.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-
-import uno
-
-localContext = uno.getComponentContext()
-resolver = localContext.ServiceManager.createInstanceWithContext(
- "com.sun.star.bridge.UnoUrlResolver", localContext )
-remoteContext = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
-remoteSmgr = remoteContext.ServiceManager
-
-pyComp = remoteSmgr.createInstanceWithContext( "org.openoffice.demo.SWriter" , remoteContext )
-
-pyComp.run( (), )
-
-# vim:set shiftwidth=4 softtabstop=4 expandtab: