Okay, I made a script that saves some properties to a file.
Code: Select all
import uno
import unohelper
import string
from com.sun.star.beans import PropertyValue
def writeProps(file, propsOwner):
"""First arg is an opened file to write, the second is the property owner"""
for p in propsOwner.PropertySetInfo.Properties:
file.write("•••••••••••\nProperty is:\n" + str(p).replace(',','\n') + "\n")
try: #Omg, why the hell UNO throws exception instead of None return
file.write("Property value is:\n" + str(propsOwner.getPropertyValue(p.Name)) + "\n")
except Exception: #uno.RuntimeException: wtf, why can't I handle it?
pass
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext )
smgr = resolver.resolve( "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" )
remoteContext = smgr.getPropertyValue( "DefaultContext" )
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",remoteContext)
#document
doc = desktop.loadComponentFromURL("file:///tmp/test.odt" ,"_blank", 0, ())
file = open('/tmp/log', 'w')
writeProps(file, doc)
#doc.Text
file.write("•••••••••••Doc.Text")
writeProps(file, doc.Text)
#every paragraph
enum = doc.Text.createEnumeration()
while enum.hasMoreElements():
nextPar = enum.nextElement()
writeProps(file, nextPar)
#every paragraph 2?
file.write("•••••••••••TextCursor")
cursor = doc.Text.createTextCursor()
while cursor.gotoNextParagraph(False):
writeProps(file, cursor)
file.close()
Next I made a simple test document, and wrote its properties before and after the «Outline Numbering» was changed. The interesting thing is that «NumberingStyleName» haven't changed — it was always set to "Outline" in some paragraphs.
In fact after I compared files with
vimdiff, the only thing that changed besides of [word,char] counters and
ids — is the «ListLabelString»
(just a string of heading counter). But the script doesn't write all existing properties, though, I think I am missing something.