Python macro to create new cell style
I was programming this LibreOffice project: https://github.com/Kazhuu/movelister and I'm wondering how to create new cell style in Python using pyuno. So far I've followed this example: https://wiki.openoffice.org/wiki/Docu.... From that example cell style is made with call:
Object aCellStyle = xServiceManager.createInstance("com.sun.star.style.CellStyle");
Which is then inserted with name to the style family. Now because of Python I've followed this guide to write macros in python: https://wiki.openoffice.org/wiki/Pyth.... It says I should write following:
smgr.createInstanceWithContext("com.sun.star.style.CellStyle", ctx) or smgr.createInstance("com.sun.star.style.CellStyle")
But the problem is that both calls return None for me. I also have tried using: uno.createUnoStruct('com.sun.star.sheet.CellStyle') but this one raises exception: uno.com.sun.star.uno.RuntimeException: pyuno.getClass: uno exception com.sun.star.sheet.TableCellStyle is unknown
Is creating styles supported by Python macros and pyuno or am I missing something?
In the Java example, the
xServiceManager
interface is obtained fromxDocument
. Since Python does not care about the type, there is no need to specify which interface is required, so we can simply use the document object.