Draw Modify Indent
The ooodev.format.draw.modify.indent_space.Indent
, class is used to modify the values seen in Fig. 896 of a style.
Fig. 896 Draw dialog Indent default
Setting the Indent
from __future__ import annotations
import uno
from ooodev.draw import Draw, DrawDoc, ZoomKind
from ooodev.format.draw.modify import FamilyGraphics, DrawStyleFamilyKind
from ooodev.format.draw.modify.indent_space import Indent
from ooodev.loader.lo import Lo
def main() -> int:
with Lo.Loader(connector=Lo.ConnectSocket()):
doc = DrawDoc(Draw.create_draw_doc())
doc.set_visible()
Lo.delay(700)
doc.zoom(ZoomKind.ZOOM_75_PERCENT)
slide = doc.get_slide()
width = 100
height = 50
x = 10
y = 10
rect = slide.draw_rectangle(x=x, y=y, width=width, height=height)
rect.set_string("Hello World!")
style = Indent(
before=4.5,
after=5.5,
first=5.2,
style_name=FamilyGraphics.DEFAULT_DRAWING_STYLE,
style_family=DrawStyleFamilyKind.GRAPHICS,
)
doc.apply_styles(style)
Lo.delay(1_000)
doc.close_doc()
return 0
if __name__ == "__main__":
raise SystemExit(main())
Running the above code will produce the following results in the Draw dialog.
Fig. 897 Draw dialog Indent style changed
Note
The auto
argument of the Indent
class constructor is suppose to set the styles ParaIsAutoFirstLineIndent
property.
The ParaIsAutoFirstLineIndent
is suppose to be part of the com.sun.star.style.ParagraphProperties
service;
However, for some reason it is missing for Draw styles. Setting this auto
argument will result
in a print warning message in verbose mode. It is better to not set this argument.
It is left in just in case it starts working in the future.
There is a option in the Indent and Spacing dialog for Automatic
as seen in Fig. 896.
It seems to work, but it is not clear how it is implemented. It is not clear if it is a style property.
Getting indent from a style
# ... other code
f_style = Indent.from_style(
doc=doc.component,
style_name=style.prop_style_name,
style_family=style.prop_style_family_name
)
assert f_style is not None
assert f_style.prop_style_name == str(FamilyGraphics.DEFAULT_DRAWING_STYLE)