Write Modify Page Area

The following classes are used to modify the Area style values seen in Fig. 1110 of a Page style.

Writer dialog Area default

Fig. 1110 Writer dialog Area default

Default Page Style Dialog

Setup

General function used to run these examples.

from ooodev.format.writer.modify.page.area import Color as PageAreaColor, WriterStylePageKind
from ooodev.utils.color import StandardColor
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.ENTIRE_PAGE)

        color_style = PageAreaColor(
            color=StandardColor.BLUE_LIGHT3, style_name=WriterStylePageKind.STANDARD
        )
        color_style.apply(doc)

        style_obj = PageAreaColor.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
        assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)

        Lo.delay(1_000)

        Lo.close_doc(doc)
    return 0

if __name__ == "__main__":
    SystemExit(main())

Area Color

The Color class is used to modify the area color of a page style. The result are seen in Fig. 1111.

Setting Area Color

from ooodev.format.writer.modify.page.area import Color as PageAreaColor, WriterStylePageKind
# ... other code

color_style = PageAreaColor(color=StandardColor.BLUE_LIGHT3, style_name=WriterStylePageKind.STANDARD)
color_style.apply(doc)

Style results.

Writer dialog Area style color set

Fig. 1111 Writer dialog Area style color set

Getting color from a style

# ... other code

style_obj = PageAreaColor.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)

Area Gradient

Setting Area Gradient

The Gradient class is used to modify the area gradient of a page style. The result are seen in Fig. 1112.

The PresetGradientKind class is used to look up the presets of gradient for convenience.

from ooodev.format.writer.modify.page.area import Gradient, PresetGradientKind, WriterStylePageKind
# ... other code

gradient_style = Gradient.from_preset(
    preset=PresetGradientKind.DEEP_OCEAN, style_name=WriterStylePageKind.STANDARD
)
gradient_style.apply(doc)

Style results.

Writer dialog Area style gradient set

Fig. 1112 Writer dialog Area style gradient set

Getting gradient from a style

# ... other code

style_obj = Gradient.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)

Area Image

Setting Area Image

The Img class is used to modify the area image of a page style. The result are seen in Fig. 1113.

The PresetImageKind class is used to look up the presets of image for convenience.

from ooodev.format.writer.modify.page.area import Img as PageAreaImg, PresetImageKind, WriterStylePageKind
# ... other code

img_style = PageAreaImg.from_preset(
    preset=PresetImageKind.COLOR_STRIPES, style_name=WriterStylePageKind.STANDARD
)
img_style.apply(doc)

Style results.

Writer dialog Area style image set

Fig. 1113 Writer dialog Area style image set

Getting image from a style

# ... other code

style_obj = PageAreaImg .from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)

Area Pattern

Setting Area Pattern

The Pattern class is used to modify the area pattern of a page style. The result are seen in Fig. 1114.

The PresetPatternKind class is used to look up the presets of pattern for convenience.

from ooodev.format.writer.modify.page.area import Pattern as PageStylePattern
from ooodev.format.writer.modify.page.area import PresetPatternKind, WriterStylePageKind
# ... other code

pattern_style = PageStylePattern.from_preset(
    preset=PresetPatternKind.HORIZONTAL_BRICK, style_name=WriterStylePageKind.STANDARD
)
pattern_style.apply(doc)

Style results.

Writer dialog Area style pattern set

Fig. 1114 Writer dialog Area style pattern set

Getting pattern from a style

# ... other code

style_obj = PageStylePattern .from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)

Area Hatch

Setting Area Hatch

The Hatch class is used to modify the area hatch of a page style. The result are seen in Fig. 1115.

The PresetHatchKind class is used to look up the presets of hatch for convenience.

from ooodev.format.writer.modify.page.area import Hatch as PageStyleHatch
from ooodev.format.writer.modify.page.area import PresetHatchKind, WriterStylePageKind
# ... other code

hatch_style = PageStyleHatch.from_preset(
    preset=PresetHatchKind.RED_45_DEGREES_NEG_TRIPLE, style_name=WriterStylePageKind.STANDARD
)
hatch_style.apply(doc)

Style results.

Writer dialog Area style hatch set

Fig. 1115 Writer dialog Area style hatch set

Getting hatch from a style

# ... other code

style_obj = PageStyleHatch .from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)