Write Modify Paragraph Drops Caps

The ooodev.format.writer.modify.para.drop_caps.DropCaps class is used to modify the values seen in Fig. 1083 of a paragraph style.

Setup

from ooodev.format.writer.modify.para.drop_caps import DropCaps, StyleParaKind, StyleCharKind
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_dc_style = DropCaps(
            count=4, style=StyleCharKind.DROP_CAPS, spaces=5.0, style_name=StyleParaKind.STANDARD
        )
        para_dc_style.apply(doc)

        style_obj = DropCaps.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 Drops Caps to a style

Before applying Style

Writer dialog Paragraph Drop Caps style default

Fig. 1083 Writer dialog Paragraph Drop Caps style default

Apply style

# ... other code

para_dc_style = DropCaps(
    count=4, style=StyleCharKind.DROP_CAPS, spaces=5.0, style_name=StyleParaKind.STANDARD
)
para_dc_style.apply(doc)

After appling style

Writer dialog Paragraph Drops Caps style changed

Fig. 1084 Writer dialog Paragraph Drops Caps style changed

Getting the area color from a style

We can get the area color from the document.

# ... other code

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