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
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.
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.
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.
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)