Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/tppt/pptx/action.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Self

from pptx.action import ActionSetting as _PptxActionSetting
from pptx.action import Hyperlink as _PptxHyperlink
from pptx.enum.action import PP_ACTION_TYPE
Expand All @@ -16,6 +18,10 @@ def address(self) -> str | None:
def address(self, value: str | None):
self._pptx.address = value

def set_address(self, value: str | None) -> Self:
self.address = value
return self


class ActionSetting(PptxConvertible[_PptxActionSetting]):
@property
Expand All @@ -38,3 +44,7 @@ def target_slide(self, value: Slide | None):
self._pptx.target_slide = None
else:
self._pptx.target_slide = value._pptx

def set_target_slide(self, value: Slide | None) -> Self:
self.target_slide = value
return self
6 changes: 6 additions & 0 deletions src/tppt/pptx/dml/effect.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Self

from pptx.dml.effect import ShadowFormat as _PptxShadowFormat

from tppt.pptx.converter import PptxConvertible
Expand All @@ -11,3 +13,7 @@ def inherit(self) -> bool:
@inherit.setter
def inherit(self, value: bool) -> None:
self._pptx.inherit = value

def set_inherit(self, value: bool) -> Self:
self._pptx.inherit = value
return self
10 changes: 10 additions & 0 deletions src/tppt/pptx/dml/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def dash_style(
) -> None:
self._pptx.dash_style = to_pptx_line_dash_style(value)

def set_dash_style(
self, value: MSO_LINE_DASH_STYLE | LiteralLineDashStyle | None
) -> "LineFormat":
self.dash_style = value
return self

@property
def fill(self) -> FillFormat:
return FillFormat(self._pptx.fill)
Expand All @@ -37,3 +43,7 @@ def width(self) -> EnglishMetricUnits | None:
@width.setter
def width(self, value: EnglishMetricUnits | _PptxEmu) -> None:
self._pptx.width = to_english_metric_units(value)

def set_width(self, value: EnglishMetricUnits | _PptxEmu) -> "LineFormat":
self.width = value
return self
8 changes: 8 additions & 0 deletions src/tppt/pptx/presentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def slide_width(self) -> Length | None:
def slide_width(self, value: Length | LiteralLength) -> None:
self._pptx.slide_width = to_pptx_length(value)

def set_slide_width(self, value: Length | LiteralLength) -> Self:
self.slide_width = value
return self

@property
def slide_height(self) -> Length | None:
return to_tppt_length(self._pptx.slide_height)
Expand All @@ -86,6 +90,10 @@ def slide_height(self) -> Length | None:
def slide_height(self, value: Length | LiteralLength) -> None:
self._pptx.slide_height = to_pptx_length(value)

def set_slide_height(self, value: Length | LiteralLength) -> Self:
self.slide_height = value
return self

@property
def tree(self) -> dict[str, Any]:
"""Get the node tree of the presentation."""
Expand Down
4 changes: 4 additions & 0 deletions src/tppt/pptx/slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def name(self) -> str:
def name(self, value: str) -> None:
self._pptx.name = value

def set_name(self, value: str) -> Self:
self.name = value
return self


class Slide(_BaseSlide[PptxSlide]):
"""Slide wrapper with type safety."""
Expand Down
24 changes: 24 additions & 0 deletions src/tppt/pptx/text/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def name(self) -> str | None:
def name(self, name: str) -> None:
self._pptx.name = name

def set_name(self, name: str) -> "Font":
self.name = name
return self

@property
def size(self) -> Length | None:
return to_tppt_length(self._pptx.size)
Expand All @@ -23,6 +27,10 @@ def size(self) -> Length | None:
def size(self, size: Length) -> None:
self._pptx.size = to_pptx_length(size)

def set_size(self, size: Length) -> "Font":
self.size = size
return self

@property
def bold(self) -> bool | None:
return self._pptx.bold
Expand All @@ -31,6 +39,10 @@ def bold(self) -> bool | None:
def bold(self, bold: bool) -> None:
self._pptx.bold = bold

def set_bold(self, bold: bool) -> "Font":
self.bold = bold
return self

@property
def italic(self) -> bool | None:
return self._pptx.italic
Expand All @@ -39,6 +51,10 @@ def italic(self) -> bool | None:
def italic(self, italic: bool) -> None:
self._pptx.italic = italic

def set_italic(self, italic: bool) -> "Font":
self.italic = italic
return self

@property
def underline(self) -> bool | MSO_TEXT_UNDERLINE_TYPE | None:
return self._pptx.underline
Expand All @@ -47,10 +63,18 @@ def underline(self) -> bool | MSO_TEXT_UNDERLINE_TYPE | None:
def underline(self, underline: bool | MSO_TEXT_UNDERLINE_TYPE) -> None:
self._pptx.underline = underline

def set_underline(self, underline: bool | MSO_TEXT_UNDERLINE_TYPE) -> "Font":
self.underline = underline
return self

@property
def color(self) -> ColorFormat:
return ColorFormat(self._pptx.color)

@color.setter
def color(self, color: ColorFormat) -> None:
self._pptx.color = color.to_pptx()

def set_color(self, color: ColorFormat) -> "Font":
self.color = color
return self
6 changes: 6 additions & 0 deletions src/tppt/pptx/text/hyperlink.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Self

from pptx.text.text import _Hyperlink as PptxHyperlink

from tppt.pptx.converter import PptxConvertible
Expand All @@ -11,3 +13,7 @@ def address(self) -> str | None:
@address.setter
def address(self, address: str | None) -> None:
self._pptx.address = address

def set_address(self, address: str | None) -> Self:
self._pptx.address = address
return self
26 changes: 26 additions & 0 deletions src/tppt/pptx/text/paragraph.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Self

from pptx.enum.text import PP_PARAGRAPH_ALIGNMENT
from pptx.text.text import _Paragraph as PptxParagraph
from pptx.util import Length as PptxLength
Expand All @@ -23,6 +25,10 @@ def alignment(self) -> PP_PARAGRAPH_ALIGNMENT | None:
def alignment(self, value: PP_PARAGRAPH_ALIGNMENT | None) -> None:
self._pptx.alignment = value

def set_alignment(self, value: PP_PARAGRAPH_ALIGNMENT | None) -> Self:
self.alignment = value
return self

def clear(self) -> None:
self._pptx.clear()

Expand All @@ -38,6 +44,10 @@ def level(self) -> int:
def level(self, value: int) -> None:
self._pptx.level = value

def set_level(self, value: int) -> Self:
self.level = value
return self

@property
def line_spacing(self) -> int | float | Length | None:
match self._pptx.line_spacing:
Expand All @@ -54,6 +64,10 @@ def line_spacing(self, value: int | float | Length | PptxLength | None) -> None:
case _:
self._pptx.line_spacing = to_pptx_length(value)

def set_line_spacing(self, value: int | float | Length | PptxLength | None) -> Self:
self.line_spacing = value
return self

@property
def runs(self) -> tuple[Run, ...]:
return tuple(Run(run) for run in self._pptx.runs)
Expand All @@ -74,6 +88,10 @@ def space_after(self, value: Length | PptxLength | None) -> None:
case _:
self._pptx.space_after = to_pptx_length(value)

def set_space_after(self, value: Length | PptxLength | None) -> Self:
self.space_after = value
return self

@property
def space_before(self) -> Length | None:
match self._pptx.space_before:
Expand All @@ -90,10 +108,18 @@ def space_before(self, value: Length | PptxLength | None) -> None:
case _:
self._pptx.space_before = to_pptx_length(value)

def set_space_before(self, value: Length | PptxLength | None) -> Self:
self.space_before = value
return self

@property
def text(self) -> str:
return self._pptx.text

@text.setter
def text(self, value: str) -> None:
self._pptx.text = value

def set_text(self, value: str) -> Self:
self.text = value
return self
6 changes: 6 additions & 0 deletions src/tppt/pptx/text/run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Self

from pptx.text.text import _Run as PptxRun

from tppt.pptx.converter import PptxConvertible
Expand All @@ -21,3 +23,7 @@ def text(self) -> str:
@text.setter
def text(self, text: str) -> None:
self._pptx.text = text

def set_text(self, text: str) -> Self:
self.text = text
return self
34 changes: 34 additions & 0 deletions src/tppt/pptx/text/text_frame.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Self

from pptx.enum.text import MSO_AUTO_SIZE, MSO_VERTICAL_ANCHOR
from pptx.text.text import TextFrame as PptxTextFrame
from pptx.util import Length as PptxLength
Expand Down Expand Up @@ -28,6 +30,10 @@ def auto_size(self) -> MSO_AUTO_SIZE | None:
def auto_size(self, value: MSO_AUTO_SIZE | None) -> None:
self._pptx.auto_size = value

def set_auto_size(self, value: MSO_AUTO_SIZE | None) -> Self:
self.auto_size = value
return self

def clear(self) -> None:
self._pptx.clear()

Expand All @@ -49,6 +55,10 @@ def margin_bottom(self) -> EnglishMetricUnits:
def margin_bottom(self, value: Length | LiteralLength | PptxLength) -> None:
self._pptx.margin_bottom = to_pptx_length(value)

def set_margin_bottom(self, value: Length | LiteralLength | PptxLength) -> Self:
self.margin_bottom = value
return self

@property
def margin_left(self) -> EnglishMetricUnits:
return to_english_metric_units(self._pptx.margin_left)
Expand All @@ -57,6 +67,10 @@ def margin_left(self) -> EnglishMetricUnits:
def margin_left(self, value: Length | LiteralLength | PptxLength) -> None:
self._pptx.margin_left = to_pptx_length(value)

def set_margin_left(self, value: Length | LiteralLength | PptxLength) -> Self:
self.margin_left = value
return self

@property
def margin_right(self) -> EnglishMetricUnits:
return to_english_metric_units(self._pptx.margin_right)
Expand All @@ -65,6 +79,10 @@ def margin_right(self) -> EnglishMetricUnits:
def margin_right(self, value: Length | LiteralLength | PptxLength) -> None:
self._pptx.margin_right = to_pptx_length(value)

def set_margin_right(self, value: Length | LiteralLength | PptxLength) -> Self:
self.margin_right = value
return self

@property
def margin_top(self) -> EnglishMetricUnits:
return to_english_metric_units(self._pptx.margin_top)
Expand All @@ -73,6 +91,10 @@ def margin_top(self) -> EnglishMetricUnits:
def margin_top(self, value: Length | LiteralLength | PptxLength) -> None:
self._pptx.margin_top = to_pptx_length(value)

def set_margin_top(self, value: Length | LiteralLength | PptxLength) -> Self:
self.margin_top = value
return self

@property
def paragraphs(self) -> tuple[Paragraph, ...]:
return tuple(Paragraph(paragraph) for paragraph in self._pptx.paragraphs)
Expand All @@ -85,6 +107,10 @@ def text(self) -> str:
def text(self, text: str) -> None:
self._pptx.text = text

def set_text(self, text: str) -> Self:
self.text = text
return self

@property
def vertical_anchor(self) -> MSO_VERTICAL_ANCHOR | None:
return self._pptx.vertical_anchor
Expand All @@ -93,10 +119,18 @@ def vertical_anchor(self) -> MSO_VERTICAL_ANCHOR | None:
def vertical_anchor(self, value: MSO_VERTICAL_ANCHOR | None) -> None:
self._pptx.vertical_anchor = value

def set_vertical_anchor(self, value: MSO_VERTICAL_ANCHOR | None) -> Self:
self.vertical_anchor = value
return self

@property
def word_wrap(self) -> bool | None:
return self._pptx.word_wrap

@word_wrap.setter
def word_wrap(self, value: bool | None) -> None:
self._pptx.word_wrap = value

def set_word_wrap(self, value: bool | None) -> Self:
self.word_wrap = value
return self