【发布时间】:2015-03-13 13:55:48
【问题描述】:
com.sun.star.style.ParagraphProperties 服务支持该属性
ParaAdjust,支持来自 com.sun.star.style.ParagraphAdjust 的 5 个值
(ParagraphProperties,ParagraphAdjust)。
要设置值,可以使用以下两种方法之一:
cursor.ParaAdjust = com.sun.star.style.ParagraphAdjust.RIGHT
cursor.setPropertyValue('ParaAdjust', com.sun.star.style.ParagraphAdjust.RIGHT)
要检查第一次尝试的值是:
if cursor.ParaAdjust == com.sun.star.style.ParagraphAdjust.RIGHT:
...
但没用。
检查:
type(cursor.ParaAdjust)
----> <class 'int'>
type(com.sun.star.style.ParagraphAdjust.RIGHT)
----> <class 'uno.Enum'>
是的,我假设这些是常量(请参阅下面的注释),这是我的错。
现在,uno.Enum 类有两个属性typeName 和value,所以我试过了:
if cursor.ParaAdjust == com.sun.star.style.ParagraphAdjust.RIGHT.value:
...
但也没有用!
检查:
type(com.sun.star.style.ParagraphAdjust.RIGHT.value)
----> <class 'string'>
print(com.sun.star.style.ParagraphAdjust.RIGHT.value)
----> 'RIGHT'
设置ParaAdjust属性,然后打印它的实际值,我得到:
LEFT = 0
RIGHT = 1
BLOCK = 2
CENTER = 3
STRETCH = 0
(note that STRETCH is considered as LEFT,
a bug or something not implemented?)
所以:
- 这些值在哪里定义?
- 如何使用 UNO API 获取这些值?
- 我是否遗漏了官方文档中的某些内容?
注意:
在 LibreOffice 4.0(也可能在旧版本中)中,您可以通过以下方式获取此值:
uno.getConstantByName('com.sun.star.style.ParagraphAdjust.RIGHT')
从 4.1 版开始,它不再工作了(正确的,不是一个常数)。
【问题讨论】:
标签: openoffice.org libreoffice uno pyuno