Write Modify Paragraph Indent & Spacing

The ooodev.format.writer.modify.para.indent_space.Indent, ooodev.format.writer.modify.para.indent_space.LineSpacing, and ooodev.format.writer.modify.para.indent_space.Spacing classes are used to set the Indent & Spacing style of a paragraph.

Default Paragraph Indent & Spacing Style Dialog

Writer dialog Paragraph Indent & Spacing default

Fig. 1093 Writer dialog Paragraph Indent & Spacing default

Setup

General function used to run these examples.

from ooodev.format.writer.modify.para.indent_space import Indent, Spacing, LineSpacing
from ooodev.format.writer.modify.para.indent_space import StyleParaKind, ModeKind
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_indent_style = Indent(
            before=22.0, after=20.0, first=8.0, style_name=StyleParaKind.STANDARD
        )
        para_indent_style.apply(doc)

        style_obj = Indent.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())

Indent Class

Setting Indent

# ... other code

para_indent_style = Indent(before=22.0, after=20.0, first=8.0, style_name=StyleParaKind.STANDARD)
para_indent_style.apply(doc)

Style results.

Writer dialog Paragraph Indent & Spacing style changed indent

Fig. 1094 Writer dialog Paragraph Indent & Spacing style changed indent

Getting indent from a style

# ... other code

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

Spacing Class

Setting Spacing

# ... other code

para_spacing_style = Spacing(above=8.0, below=10.0, style_name=StyleParaKind.STANDARD)
para_spacing_style.apply(doc)

Style results.

Writer dialog Paragraph Indent & Spacing style changed spacing

Fig. 1095 Writer dialog Paragraph Indent & Spacing style changed spacing

Getting spacing from a style

# ... other code

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

LineSpacing Class

Setting Line Spacing Style

# ... other code

para_ln_spacing_style = LineSpacing(
    mode=ModeKind.PROPORTIONAL, value=85, style_name=StyleParaKind.STANDARD
)
para_ln_spacing_style.apply(doc)

Style results.

Writer dialog Paragraph Indent & Spacing style changed line spacing

Fig. 1096 Writer dialog Paragraph Indent & Spacing style changed line spacing

Getting line spacing from a style

# ... other code

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