The
NumberingLevel property of the
par does indeed provide a short integer value between 0 (outer-most) and N (increasing number of nesting levels) that I can use.
The next question then is whether a numbering uses bullets of various kinds or an enumeration. So I looked at the paragraph's
NumberingRules property which gives a few hints by its own
NumberingType and
Name properties. However, scanning through a document I found that most of those properties are set to None or some funky integer (Name=45990630598139397491). Continuing my search I then found a
NumberingLevel service but neither the paragraph nor the numbering rules provide that service.
EDIT After some playing around I found that the following code works and it returns an integer which represents the
NumberingType value. It iterates over the NumberingRules's
PropertyValue list to find the one I'm interested in:
Code: Select all
# Helper function get access an object's attribute; return None if the attribute didn't exist for the object.
def get_uno_attr(obj, attr) :
return getattr(obj, attr) if hasattr(obj, attr) else None
# Helper function to iterate over a PropertyValue list to find a property by name, and return its value; return None if not found.
def get_uno_pval(plist, vname) :
for pval in plist :
if vname == get_uno_attr(pval, "Name") :
return get_uno_attr(pval, "Value")
return None
# Get the numbering rules for this paragraph, which contain more details.
rules = get_uno_attr(paragraph, "NumberingRules")
# Get the number of PropertyValue items for the paragraph's numbering rule set.
pnum = get_uno_attr(rules, "Count")
# Oddly, any hardwired index between 0..pnum-1 works and returns the same list or PropertyValues.
numtype = get_uno_pval(rules.getByIndex(0), "NumberingType"))
The numtype is an integer representing any of the NumberingType values. Other properties are the ones I found provided by the NumberingLevel service mentioned above. However, I can't explain why the above call to
getByIndex() would return the entire list (array) instead of the indexed item.
Mac 10.14 using LO 7.2.0.2, Gentoo Linux using LO 7.2.3.2 headless.