Write Modify Paragraph Outline & List

The ooodev.format.writer.modify.para.outline_list.Outline, ooodev.format.writer.modify.para.outline_list.LineNum, and ooodev.format.writer.modify.para.outline_list.ListStyle classes are used to set the outline, list style, and line numbering of a paragraph.

Default Paragraph Outline & List Style Dialog

Writer dialog Paragraph Outline & List default

Fig. 1097 Writer dialog Paragraph Outline & List default

Setup

General function used to run these examples.

from ooodev.format.writer.modify.para.outline_list import Outline, LineNum, ListStyle
from ooodev.format.writer.modify.para.outline_list import LevelKind, StyleParaKind, StyleListKind
from ooodev.office.write import Write
from ooodev.gui import GUI
from ooodev.loader.lo import Lo

def main() -> int:
    with Lo.Loader(Lo.ConnectPipe()):
        doc = Write.create_doc()
        GUI.set_visible(doc=doc)
        Lo.delay(300)
        GUI.zoom(GUI.ZoomEnum.ZOOM_150_PERCENT)

        para_outline_style = Outline(level=LevelKind.LEVEL_01, style_name=StyleParaKind.STANDARD)
        para_outline_style.apply(doc)

        style_obj = Outline.from_style(doc=doc, style_name=StyleParaKind.STANDARD)
        assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)
        Lo.delay(1_000)

        Lo.close_doc(doc)
    return 0

if __name__ == "__main__":
    SystemExit(main())

Outline Class

Setting Outline

# ... other code

para_outline_style = Outline(level=LevelKind.LEVEL_01, style_name=StyleParaKind.STANDARD)
para_outline_style.apply(doc)

Style results.

Writer dialog Paragraph Outline & List style changed

Fig. 1098 Writer dialog Paragraph Outline & List style changed

Getting outlne from a style

# ... other code

style_obj = Outline.from_style(doc=doc, style_name=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)

ListStyle Class

Setting List Style

# ... other code

para_liststyle_style = ListStyle(
    list_style=StyleListKind.NUM_123, style_name=StyleParaKind.STANDARD
)
para_liststyle_style.apply(doc)

Style results.

Writer dialog Paragraph Outline & List style changed

Fig. 1099 Writer dialog Paragraph Outline & List style changed

Getting list style from a style

We can get the border padding from the document.

# ... other code

style_obj = ListStyle.from_style(doc=doc, style_name=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)

LineNum Class

Setting Line Number Style

# ... other code

para_linenum_style = LineNum(num_start=3, style_name=StyleParaKind.STANDARD)
para_linenum_style.apply(doc)

Style results.

Writer dialog Paragraph Outline & List style changed

Fig. 1100 Writer dialog Paragraph Outline & List style changed

Getting list number from a style

We can get the border shadow from the document.

# ... other code

style_obj = LineNum.from_style(doc=doc, style_name=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)