Ask Your Question
0

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

asked 2019-01-15 11:42:38 +0100

sdaau gravatar image

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?

edit retag flag offensive close merge delete

Comments

sdaau gravatar imagesdaau ( 2019-01-15 11:42:57 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-01-15 11:51:45 +0100

sdaau gravatar image

Found it, here: https://docs.libreoffice.org/librelog... :

from com.sun.star.drawing.LineStyle import SOLID # passes

def myfunc():
  ...
  drawObject.LineStyle = SOLID
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-01-15 11:42:38 +0100

Seen: 158 times

Last updated: Jan 15