Write Modify Page Header Borders
The ooodev.format.writer.modify.page.header.borders.Sides
, ooodev.format.writer.modify.page.header.borders.Padding
, and ooodev.format.writer.modify.page.header.borders.Shadow
classes are used to modify the border values seen in Fig. 1139 of a character border style.
Default Page Header Borders Style Dialog
Setup
General function used to run these examples.
Note that in order to apply a style, the document header must be turned on as seen in Write Modify Page Header.
from ooodev.format.writer.modify.page.header import Header, WriterStylePageKind
from ooodev.format.writer.modify.page.header.borders import Padding, Shadow, Sides
from ooodev.format.writer.modify.page.header.borders import BorderLineKind, LineSize, Side
from ooodev.format import Styler
from ooodev.office.write import Write
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
from ooodev.utils.color import StandardColor
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)
header_style = Header(
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,
)
side = Side(line=BorderLineKind.DOUBLE, color=StandardColor.RED, width=LineSize.MEDIUM)
sides_style = Sides(all=side, style_name=WriterStylePageKind.STANDARD)
Styler.apply(doc, header_style, sides_style)
style_obj = Sides.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())
Border Sides
Setting Border Sides
# ... other code
side = Side(line=BorderLineKind.DOUBLE, color=StandardColor.RED, width=LineSize.MEDIUM)
sides_style = Sides(all=side, style_name=WriterStylePageKind.STANDARD)
Styler.apply(doc, header_style, sides_style)
Style results.
Getting border sides from a style
# ... other code
style_obj = Sides.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Border Padding
Setting Border Padding
# ... other code
padding_style = Padding(
left=5, right=5, top=3, bottom=3, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, header_style, padding_style)
Style results.
Getting border padding from a style
We can get the border padding from the document.
# ... other code
style_obj = Padding.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)
Border Shadow
Setting Border Shadow
# ... other code
shadow_style = Shadow(
color=StandardColor.BLUE_DARK2, width=1.5, style_name=WriterStylePageKind.STANDARD
)
Styler.apply(doc, header_style, shadow_style)
Style results.
Getting border shadow from a style
We can get the border shadow from the document.
# ... other code
style_obj = Shadow.from_style(doc=doc, style_name=WriterStylePageKind.STANDARD)
assert style_obj.prop_style_name == str(WriterStylePageKind.STANDARD)