gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 08:26:37 25 4
gpt4 key购买 nike

在 Ubuntu 18.04 上使用 LibreOffice 6.0.7.3 00m0(Build:3),希望在 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 宏中实例化它?

最佳答案

在这里找到它:https://docs.libreoffice.org/librelogo/html/LibreLogo_8py_source.html :

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

def myfunc():
...
drawObject.LineStyle = SOLID

关于Python Libre Office Uno : instantiating com. sun.star.drawing.LineStyle.SOLID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54197102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com