Python Libre office Uno:实例化com.sun.star公司.drawing.LineStyle.SOLID?

2024-04-25 14:02:08 发布

您现在位置:Python中文网/ 问答频道 /正文

使用LibreOffice 6.0.7.3 00m0(构建:3)在Ubuntu 18.04上,希望在LibreOffice Draw中有一个Python宏:

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!

。。。但我无法实例化com.sun.star.drawing.LineStyle.SOLID。如何在Python宏中实例化它?你知道吗


Tags: ornofromimportcomisnamedstar

热门问题