3

The com.sun.star.style.ParagraphProperties service supports the property ParaAdjust, that supports 5 values from com.sun.star.style.ParagraphAdjust (ParagraphProperties, ParagraphAdjust).

To set the value, one of the two methods could be used:

cursor.ParaAdjust = com.sun.star.style.ParagraphAdjust.RIGHT
cursor.setPropertyValue('ParaAdjust', com.sun.star.style.ParagraphAdjust.RIGHT)

To check the value the first try was:

if cursor.ParaAdjust == com.sun.star.style.ParagraphAdjust.RIGHT:
    ...

but didn't work.

Inspecting:

type(cursor.ParaAdjust)
----> <class 'int'>
type(com.sun.star.style.ParagraphAdjust.RIGHT)
----> <class 'uno.Enum'>

right, I've assumed that these were constants (see Note below), my fault.

Now, the uno.Enum class has two properties typeName and value, so I've tried:

if cursor.ParaAdjust == com.sun.star.style.ParagraphAdjust.RIGHT.value:
    ...

but didn't work, too!

Inspecting:

type(com.sun.star.style.ParagraphAdjust.RIGHT.value)
----> <class 'string'>
print(com.sun.star.style.ParagraphAdjust.RIGHT.value)
----> 'RIGHT'

Setting the ParaAdjust property and then print its actual value, I get:

LEFT    = 0
RIGHT   = 1
BLOCK   = 2
CENTER  = 3
STRETCH = 0
(note that STRETCH is considered as LEFT,
 a bug or something not implemented?)

So:

  • Where are these values defined?
  • How could I get thes values using the UNO API?
  • Am I missing something from the official documentation?

Note:

In LibreOffice 4.0 (maybe in older versions too), you could get this values with:

uno.getConstantByName('com.sun.star.style.ParagraphAdjust.RIGHT')

from version 4.1 that doesn't work anymore (rightly, not being a constant).

LikosX
  • 81
  • 6

1 Answers1

2

Thanks to "hanya" from the OpenOffice Forum (link), here's some python code for mapping the values of ParagraphAdjust:

def get_paragraph_adjust_values():
    ctx = uno.getComponentContext()
    tdm = ctx.getByName(
            "/singletons/com.sun.star.reflection.theTypeDescriptionManager")
    v = tdm.getByHierarchicalName("com.sun.star.style.ParagraphAdjust")
    return {name : value
            for name, value
            in zip(v.getEnumNames(), v.getEnumValues())}

In python 2.6, that doesn't support the comprehension syntax for dictionaries, the dict() function can be used instead.

LikosX
  • 81
  • 6