Write Modify Paragraph Area Pattern
The ooodev.format.writer.modify.para.area.Pattern
class is used to modify the values seen in Fig. 1077 of a paragraph style.
Setup
from ooodev.format.writer.modify.para.area import Pattern as ParaStylePattern
from ooodev.format.writer.modify.para.area import StyleParaKind, PresetPatternKind
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_pattern_style = ParaStylePattern.from_preset(
preset=PresetPatternKind.SHINGLE, style_name=StyleParaKind.STANDARD
)
para_area_pattern_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 pattern to a style
Before applying Style
![Writer dialog Paragraph Area Pattern style default](https://user-images.githubusercontent.com/4193389/234429874-d86ddec0-381e-4411-854f-6f2f8148de2e.png)
Fig. 1077 Writer dialog Paragraph Area Pattern style default
Apply style
# ... other code
para_area_pattern_style = ParaStylePattern.from_preset(
preset=PresetPatternKind.SHINGLE, style_name=StyleParaKind.STANDARD
)
para_area_img_style.apply(doc)
After appling style
![Writer dialog Paragraph Area Pattern style changed](https://user-images.githubusercontent.com/4193389/234428550-31533a46-102b-4a1b-99cf-4cb2d5eb6e19.png)
Fig. 1078 Writer dialog Paragraph Pattern style changed
Getting the area pattern from a style
We can get the area pattern from the document.
# ... other code
style_obj = ParaStylePattern.from_style(doc=doc, style_name=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)