Write Modify Paragraph Area Image

The ooodev.format.writer.modify.para.area.Img class is used to modify the values seen in Fig. 1075 of a paragraph style.

Setup

from ooodev.format.writer.modify.para.area import Gradient as ParaStyleGradient, StyleParaKind
from ooodev.format.writer.modify.para.area import PresetImageKind

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_area_img_style = ParaStyleImg.from_preset(
            preset=PresetImageKind.COFFEE_BEANS, style_name=StyleParaKind.STANDARD
        )
        para_area_img_style.apply(doc)

        style_obj = ParaStyleImg.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__":
    sys.exit(main())

Apply image to a style

Before applying Style

Writer dialog Paragraph Area Image style default

Fig. 1075 Writer dialog Paragraph Area Image style default

Apply style

# ... other code

para_area_img_style = ParaStyleImg.from_preset(
    preset=PresetImageKind.COFFEE_BEANS, style_name=StyleParaKind.STANDARD
)
para_area_img_style.apply(doc)

After applying style

Writer dialog Paragraph Area Image style changed

Fig. 1076 Writer dialog Paragraph Image style changed

Getting the area image from a style

We can get the area image from the document.

# ... other code

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