Calc Modify Page Borders
Overview
The ooodev.format.calc.modify.page.borders.Sides
, ooodev.format.calc.modify.page.borders.Padding
, and ooodev.format.calc.modify.page.borders.Shadow
classes are used to modify the border values seen in Fig. 429 of a character border style.
Default Page Borders Style Dialog
Setup
General function used to run these examples.
import uno
from ooodev.office.calc import Calc
from ooodev.gui import GUI
from ooodev.loader.lo import Lo
from ooodev.format.calc.modify.page.borders import Padding, Shadow, Sides
from ooodev.format.calc.modify.page.borders import BorderLineKind, LineSize
from ooodev.format.calc.modify.page.borders import Sides, Side, CalcStylePageKind
from ooodev.utils.color import StandardColor
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)
side = Side(line=BorderLineKind.DOUBLE, color=StandardColor.RED, width=LineSize.MEDIUM)
sides_style = Sides(all=side, style_name=CalcStylePageKind.DEFAULT)
sides_style.apply(doc)
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())
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=CalcStylePageKind.DEFAULT)
sides_style.apply(doc)
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)
Border Padding
Setting Border Padding
# ... other code
padding_style = Padding(
left=5,
right=5,
top=3,
bottom=3,
style_name=CalcStylePageKind.DEFAULT,
)
padding_style.apply(doc)
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)
Border Shadow
Setting Border Shadow
# ... other code
shadow_style = Shadow(
color=StandardColor.BLUE_DARK2,
width=1.5,
style_name=CalcStylePageKind.DEFAULT,
)
shadow_style.apply(doc)
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)