OOO Development Tools

Book:

  • Python LibreOffice Programming

Help:

  • Help Documentation
    • Spreadsheets (Calc)
    • Chart2
    • Draw Documents (Draw)
    • Text Documents (Writer)
      • Write Formatting and Style
        • Direct
        • Modify
        • Style
    • Common Help Topics

Guides:

  • Guides

Misc:

  • Events
  • Version History
  • Credits and Acknowledgements

DEVELOPER API:

  • ooodev

DEVELOPING ODEV:

  • Dev Docs
OOO Development Tools
  • Help Documentation
  • Text Documents (Writer)
  • Write Formatting and Style
  • Modify
  • Writer Format Modify Page
  • Writer Format Modify Page Footer
  • Write Modify Page Footer Transparency
  • Edit on GitHub

Write Modify Page Footer Transparency

Table of Contents

  • Setup

  • Transparency

    • Setting Transparency

    • Getting transparency from a style

  • Transparency Gradient

    • Setting Transparency Gradient

    • Getting gradient from a style

  • Related Topics

The ooodev.format.writer.modify.page.footer.transparency.Transparency and ooodev.format.writer.modify.page.footer.transparency.Gradient classes are used to modify the Area style values seen in Fig. 1168 of a Page style.

Writer dialog Footer Transparency default

Fig. 1168 Writer dialog Footer Transparency default

Default Page Style Dialog

Setup

General function used to run these examples.

from ooodev.format.writer.modify.page.footer import Footer, WriterStylePageKind
from ooodev.format.writer.modify.page.footer.transparency import (
    Transparency,
    Gradient,
    IntensityRange,
    GradientStyle,
)
from ooodev.format.writer.modify.page.footer.area import Color as HeaderAreaColor
from ooodev.format import Styler
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)

        footer_style = Footer(
            on=True,
            shared_first=True,
            shared=True,
            height=10.0,
            spacing=3.0,
            spacing_dyn=True,
            margin_left=1.5,
            margin_right=2.0,
            style_name=WriterStylePageKind.STANDARD,
        )
        page_footer_style_kind = WriterStylePageKind.STANDARD
        color_style = HeaderAreaColor(color=StandardColor.RED, style_name=page_footer_style_kind)
        transparency_style = Transparency(value=85, style_name=page_footer_style_kind)
        Styler.apply(doc, footer_style, color_style, transparency_style)

        style_obj = Transparency.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())

Transparency

The Transparency class is used to modify the transparency of a page footer style. The result are seen in Fig. 1169 and Fig. 1170.

Setting Transparency

In this example we will apply a transparency to the page footer style background color. The transparency needs to be applied after the page footer style color as the transparency is applied to the color. This means the order Styler.apply(doc, footer_style, color_style, transparency_style) is important. The transparency is set to 85% in this example.

# ... other code

page_footer_style_kind = WriterStylePageKind.STANDARD
color_style = HeaderAreaColor(color=StandardColor.RED, style_name=page_footer_style_kind)
transparency_style = Transparency(value=85, style_name=page_footer_style_kind)
Styler.apply(doc, footer_style, color_style, transparency_style)

Style results.

Writer Page Footer

Fig. 1169 Writer Page Footer

Writer dialog Page Footer Transparency style changed

Fig. 1170 Writer dialog Page Footer Transparency style changed

Getting transparency from a style

# ... other code

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

Transparency Gradient

Setting Transparency Gradient

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

In this example we will apply a transparency to the page footer style background color. The transparency needs to be applied after the page footer style color as the transparency is applied to the color. This means the order Styler.apply(doc, footer_style, color_style, footer_gradient_style) is important.

# ... other code

page_footer_style_kind = WriterStylePageKind.STANDARD
color_style = HeaderAreaColor(color=StandardColor.GREEN_DARK1, style_name=page_footer_style_kind)
footer_gradient_style = Gradient(
    style=GradientStyle.LINEAR,
    angle=45,
    border=22,
    grad_intensity=IntensityRange(0, 100),
    style_name=page_footer_style_kind,
)
Styler.apply(doc, footer_style, color_style, footer_gradient_style)

Style results.

Writer Page Footer

Fig. 1171 Writer Page Footer

Writer dialog Page Footer Transparency style changed

Fig. 1172 Writer dialog Page Footer Transparency style changed

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)

Related Topics

See also

  • Formatting and Styling kinds

  • Format Coding Style

  • Write Modify Page Header Transparency

  • Write Modify Page Transparency

  • GUI

  • Lo

  • ooodev.format.writer.modify.page.footer.transparency.Transparency

  • ooodev.format.writer.modify.page.footer.transparency.Gradient

Previous Next

© Copyright 2022-2024, :Barry-Thomas-Paul: Moss. Revision 8b0142c4.

Built with Sphinx using a theme provided by Read the Docs.