Write Modify Paragraph Borders
The ooodev.format.writer.modify.para.borders.Sides
, ooodev.format.writer.modify.char.borders.Padding
, and ooodev.format.writer.modify.para.borders.Shadow
classes are used to modify the border values seen in Fig. 1079 of a character border style.
Default Paragraph Borders Style Dialog
Setup
General function used to run these examples.
import uno
from ooodev.format.writer.modify.para.borders import Padding, Shadow, Sides
from ooodev.format.writer.modify.para.borders import BorderLineKind, LineSize
from ooodev.format.writer.modify.para.borders import StyleParaKind, Side
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.ZOOM_150_PERCENT)
side = Side(line=BorderLineKind.DOUBLE, color=StandardColor.RED, width=LineSize.MEDIUM)
sides_style = Sides(all=side, style_name=StyleParaKind.STANDARD)
sides_style.apply(doc)
style_obj = Sides.from_style(doc=doc, style_name=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.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=StyleParaKind.STANDARD)
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=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)
Border Padding
Setting Border Padding
# ... other code
padding_style = Padding(left=5, right=5, top=3, bottom=3, style_name=StyleParaKind.STANDARD)
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=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)
Border Shadow
Setting Border Shadow
# ... other code
shadow_style = Shadow(color=StandardColor.BLUE_DARK2, width=1.5, style_name=StyleParaKind.STANDARD)
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=StyleParaKind.STANDARD)
assert style_obj.prop_style_name == str(StyleParaKind.STANDARD)