Draw Direct Shape Line Arrow Styles
The ooodev.format.draw.direct.line.ArrowStyles
class is used to modify the values seen in Fig. 851 of a shape.
Setup
from __future__ import annotations
import uno
from ooodev.draw import Draw, DrawDoc, ZoomKind
from ooodev.loader.lo import Lo
from ooodev.format.draw.direct.line import ArrowStyles, GraphicArrowStyleKind
def main() -> int:
with Lo.Loader(connector=Lo.ConnectSocket()):
doc = DrawDoc(Draw.create_draw_doc())
doc.set_visible()
Lo.delay(500)
doc.zoom(ZoomKind.ZOOM_75_PERCENT)
slide = doc.get_slide()
width = 36
height = 36
x = round(width / 2)
y = round(height / 2)
line = slide.draw_line(x1=x, y1=y, x2=x + width, y2=y + height)
style = ArrowStyles(
start_line_name=GraphicArrowStyleKind.ARROW_LARGE,
start_line_center=True,
start_line_width=2.5,
end_line_name=GraphicArrowStyleKind.SQUARE_45,
end_line_center=False,
end_line_width=1.9,
)
style.apply(line.component)
f_style = ArrowStyles.from_obj(line.component)
assert f_style is not None
assert f_style.prop_start_line_name == GraphicArrowStyleKind.ARROW_LARGE.value
Lo.delay(1_000)
doc.close_doc()
return 0
if __name__ == "__main__":
raise SystemExit(main())
Add a Line Properties to the shape
Adding a Line Arrow Styles to the shape is done by using the ArrowStyles
class.
from ooodev.format.draw.direct.line import ArrowStyles, GraphicArrowStyleKind
# ... other code
line = slide.draw_line(x1=x, y1=y, x2=x + width, y2=y + height)
style = ArrowStyles(
start_line_name=GraphicArrowStyleKind.ARROW_LARGE,
start_line_center=True,
start_line_width=2.5,
end_line_name=GraphicArrowStyleKind.SQUARE_45,
end_line_center=False,
end_line_width=1.9,
)
style.apply(line.component)
The results of the setting the shape line properties can be seen in Fig. 852.
Get Shape Line Arrow Styles
We can get the line arrow styles of the shape by using the ArrowStyles.from_obj()
method.
from ooodev.format.draw.direct.line import ArrowStyles
# ... other code
# get the properties from the shape
f_style = ArrowStyles.from_obj(line.component)
assert f_style is not None
assert f_style.prop_start_line_name == GraphicArrowStyleKind.ARROW_LARGE.value