von kvogelsa » Di, 02.02.2010 14:44
Hallo und guten Tag,
nach einiger Zeit mal wieder eine Frage zum Skripting:
Ich habe eine Openoffice Instanz auf dem Server unter der Konsole laufen, nun möchte ich mit einem Python Skript eine Tabelle einfügen.
Das klappt mit diesem (kopierten) Code auch ohne Probleme:
Code: Alles auswählen
#!/usr/bin/python
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
desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
document = desktop.loadComponentFromURL("file:///"+path+DOCID+".odt" ,"_blank", 0, ())
text = document.Text
cursor = text.createTextCursor()
# create a text table
table = document.createInstance( "com.sun.star.text.TextTable" )
# with 4 rows and 4 columns
table.initialize( 4,4)
(...)
document.dispose()
Meine Frage nun: wie kann ich die Tabelle an einer bestimmten Stelle erzeugen, zB dort, wo im Dokument ein Platzhalter steht. bin schon auf createTextCursorbyRange gestoßen, nur finde ich keine Möglichkeit, zu einem bestimmten string (platzhalter) zu springen.
Hallo und guten Tag,
nach einiger Zeit mal wieder eine Frage zum Skripting:
Ich habe eine Openoffice Instanz auf dem Server unter der Konsole laufen, nun möchte ich mit einem Python Skript eine Tabelle einfügen.
Das klappt mit diesem (kopierten) Code auch ohne Probleme:
[code]
#!/usr/bin/python
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
desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
document = desktop.loadComponentFromURL("file:///"+path+DOCID+".odt" ,"_blank", 0, ())
text = document.Text
cursor = text.createTextCursor()
# create a text table
table = document.createInstance( "com.sun.star.text.TextTable" )
# with 4 rows and 4 columns
table.initialize( 4,4)
(...)
document.dispose()
[/code]
Meine Frage nun: wie kann ich die Tabelle an einer bestimmten Stelle erzeugen, zB dort, wo im Dokument ein Platzhalter steht. bin schon auf createTextCursorbyRange gestoßen, nur finde ich keine Möglichkeit, zu einem bestimmten string (platzhalter) zu springen.