• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


28 Mar, 2025

Updated at 20 May, 2025

Where do table cells get their CharHeight from in LibreOffice Writer

In a Libre Office Writer text document, i would like to reset all explicitely applied font size settings, both in text paragraphs as well as in tables. For paragraphs i can find such explicit settings by checking whether getPropertyState("CharHeight") returns DIRECT_VALUE. Sadly, when i also process tables in the document, the cell content does show a value of CharHeightwhich is different from the one in the Standard paragraph style, but when checking the property state it does return DEFAULT_VALUE which indicates that no explicit value has been set.

screenshot showing the issue

My code (executed as python macro) looks like this:

...
elements = doc.getText().createEnumeration()

while elements.hasMoreElements():
    element = elements.nextElement()
    
    if element.supportsService("com.sun.star.text.Paragraph"):
        
        # This works fine
        if element.getPropertyState("CharHeight") == DIRECT_VALUE:
            element.setPropertyToDefault("CharHeight")
        
    elif element.supportsService("com.sun.star.text.TextTable"):
        cell_names = element.getCellNames()

        for cell_name in cell_names:
            cell = element.getCellByName(cell_name)
            cell_cursor = cell.createTextCursor()
            
            # the following condition never results to be True for my document
            if cell_cursor.getPropertyState("CharHeight") == DIRECT_VALUE:
                cell_cursor.setPropertyToDefault("CharHeight")
...

Resetting the value to default has no effect, which is in line with the value not beeing directly set in the first place, just then i wonder, where does the actual value (15pt in my case) come from?