Code: Select all
10.0 seconds for 122 styles
Am I doing something wrong?
// LibreOffice 3.5.4.2, 3.4.2-std-def-alt1 #1 SMP
Code: Select all
def print_styles(doc):
stf = doc.getStyleFamilies()
pss = stf.getByName('ParagraphStyles')
n = pss.getCount()
t_begin = time.time()
for i in range(n):
ps = pss.getByIndex(i)
print ps.getName(), '/', ps.DisplayName
t_end = time.time()
print '%s seconds for %s styles' % (round(t_end - t_begin), n)
# setup to call the code above
import uno, os, time
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
document = desktop.loadComponentFromURL(uno.systemPathToFileUrl(os.path.abspath('hello.odt')), '_blank', 0, tuple())
print_styles(document)