Calc Modify Page Header Borders
Overview
The ooodev.format.calc.modify.page.header.borders.Sides
, ooodev.format.calc.modify.page.header.borders.Padding
, and ooodev.format.calc.modify.page.header.borders.Shadow
classes are used to modify the border values seen in Fig. 447 of a character border style.
Default Page Header Borders Style Dialog
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.borders import BorderLineKind, LineSize
from ooodev.format.calc.modify.page.header.borders import Padding, Shadow, Sides
from ooodev.format.calc.modify.page.header.borders import Sides, Side
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,
)
side = Side(line=BorderLineKind.DOUBLE, color=StandardColor.RED, width=LineSize.MEDIUM)
header_sides_style = Sides(all=side, style_name=CalcStylePageKind.DEFAULT)
Styler.apply(doc, header_style, header_sides_style)
style_obj = Sides.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 Border Sides
Setting Border Sides
# ... other code
side = Side(line=BorderLineKind.DOUBLE, color=StandardColor.RED, width=LineSize.MEDIUM)
header_sides_style = Sides(all=side, style_name=CalcStylePageKind.DEFAULT)
Styler.apply(doc, header_style, header_sides_style)
Style results.
Getting border sides from a style
We can get the border sides from the document.
# ... other code
style_obj = Sides.from_style(doc=doc, style_name=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)
Header Border Padding
Setting Border Padding
# ... other code
padding_style = Padding(
left=5,
right=5,
top=3,
bottom=3,
style_name=CalcStylePageKind.DEFAULT,
)
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=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)
Header Border Shadow
Setting Border Shadow
# ... other code
shadow_style = Shadow(
color=StandardColor.BLUE_DARK2,
width=1.5,
style_name=CalcStylePageKind.DEFAULT,
)
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=CalcStylePageKind.DEFAULT)
assert style_obj.prop_style_name == str(CalcStylePageKind.DEFAULT)