的com.sun.star.style.ParagraphProperties
服務支持屬性 ParaAdjust
,支持5個值從com.sun.star.style.ParagraphAdjust
(ParagraphProperties,ParagraphAdjust)。如何使用Libre/Open Office中的pyUNO庫檢查段落調整?
要設置的值,這兩種方法中的一種,可以使用:
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獲取這些值?
- 我在官方文檔中遺漏了什麼嗎?
注意:
uno.getConstantByName('com.sun.star.style.ParagraphAdjust.RIGHT')
從版本4.1不起作用:
在LibreOffice的4.0(也許在老版本太),你可以用得到這個值(正確,不是一個常數)。