Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python Libre office Uno: instantiating com.sun.star.drawing.LineStyle.SOLID?

Using LibreOffice 6.0.7.3 00m0(Build:3) on Ubuntu 18.04, want to have a Python macro in LibreOffice Draw:

import uno
import unohelper
#import com.sun.star.drawing #No module named 'com'
#from com.sun.star.lang import XServiceName # passes
#from com.sun.star.drawing import LineStyle # : No module named 'com' (or 'com.sun.star.drawing.LineStyle' is unknown)
#from com.sun.star import drawing # No module named 'com' (or 'com.sun.star.drawing' is unknown)

def myfunc():
  ...
  oCtx = uno.getComponentContext()
  oServiceManager = oCtx.ServiceManager

  oDoc = XSCRIPTCONTEXT.getDocument()
  oSlideList = oDoc.getDrawPages()
  ...

  #drawObject.LineStyle = com.sun.star.drawing.LineStyle.SOLID # name 'com' is not defined
  #drawObject.LineStyle = uno.createUnoStruct("com.sun.star.drawing.LineStyle.SOLID") # pyuno.getClass: uno exception com.sun.star.drawing.LineStyle.SOLID is unknown
  #drawObject.LineStyle = uno.createUnoStruct("com.sun.star.drawing.LineStyle") # pyuno.getClass: com.sun.star.drawing.LineStyleis a ENUM, expected EXCEPTION, STRUCT or INTERFACE
  #drawObject.LineStyle = oServiceManager.createInstance('com.sun.star.drawing.LineStyle') # TYPE is not supported!
  drawObject.LineStyle = oServiceManager.createInstance('com.sun.star.drawing.LineStyle.SOLID') # TYPE is not supported!

... but I simply cannot instantiate com.sun.star.drawing.LineStyle.SOLID. How can I instantiate it in a Python macro?