Calc Modify Page Header Background

Overview

The ooodev.format.calc.modify.page.header.area.Color and ooodev.format.calc.modify.page.header.area.Img classes sets the background options for the Calc page.

Setup

General function used to run these examples.

import uno
from ooodev.format import Styler
from ooodev.format.calc.modify.page.header import Header, CalcStylePageKind
from ooodev.format.calc.modify.page.header.area import Color as HeaderColor
from ooodev.format.calc.modify.page.header.area import Img as HeaderImg, PresetImageKind
from ooodev.office.calc import Calc
from ooodev.utils.color import StandardColor
from ooodev.gui import GUI
from ooodev.loader.lo import Lo

def main() -> int:
    with Lo.Loader(connector=Lo.ConnectSocket()):
        doc = Calc.create_doc()
        GUI.set_visible(True, doc)
        Lo.delay(500)
        Calc.zoom_value(doc, 100)

        header_style = Header(
            on=True,
            shared_first=True,
            shared=True,
            height=10.0,
            spacing=3.0,
            margin_left=1.5,
            margin_right=2.0,
            style_name=CalcStylePageKind.DEFAULT,
        )
        header_color_style = HeaderColor(
            color=StandardColor.GREEN_LIGHT2, style_name=CalcStylePageKind.DEFAULT
        )
        Styler.apply(doc, header_style, header_color_style)

        style_obj = HeaderColor.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
        assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)

        Lo.delay(1_000)
        Lo.close_doc(doc)
    return 0

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

Header Background Color

Setting the Page Header Background Color

# .. other code
header_color_style = HeaderColor(
    color=StandardColor.GREEN_LIGHT2, style_name=CalcStylePageKind.DEFAULT
)
Styler.apply(doc, header_style, header_color_style)

Style results.

Calc dialog Page Header Background style color modified

Fig. 445 Calc dialog Page Header Background style color modified

Getting the background Header color from a style

# .. other code
style_obj = HeaderColor.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)

Header Background Image

Setting the Page Header Background Image

# .. other code
header_img_style = HeaderImg.from_preset(
    preset=PresetImageKind.COFFEE_BEANS, style_name=CalcStylePageKind.DEFAULT
)
Styler.apply(doc, header_style, header_img_style)

Style results.

Calc dialog Page Header Background style image modified

Fig. 446 Calc dialog Page Header Background style image modified