In the end the «getFlatParagraphIterator()» turned to be unrelated to
what I want to. I found an answer, and since α) nobody seems to know
out there for how to do it, and β) it is impossible to guess how to do
it without someone's example, so I'll leave the code here.
def removeNumberingSomeHeading1s(text):
"""Removes numbering from the first Heading1 (intro), then skips
three heading1s (chapters), and
removes from the rest Heading1s and Heading2s"""
enumeration = text.createEnumeration()
heading1s = 0
while enumeration.hasMoreElements():
par = enumeration.nextElement()
if ( par.supportsService("com.sun.star.text.Paragraph") and
par.ParaStyleName != None):
if par.ParaStyleName == HEADING1:
heading1s = heading1s + 1
if ((heading1s > 4 or heading1s == 1) and
par.ParaStyleName == HEADING1 or
par.ParaStyleName == HEADING2):
par.setPropertyValue("NumberingStyleName", "NONE")
It takes Document.Text property as arg. The magic «paragraph iterator»
function in the end turned to be the «Text.createEnumeration()». I
guess it enumerates not only paragraphs, so one need to check that it
actually is — in above the code I'm doing this with the «if (
par.supportsService("com.sun.star.text.Paragraph")»