Skip to content

Office Forms

OfficeForms class for “office:forms” tag.

Classes:

Name Description
OfficeForms

Container for “form:form” or “xforms:model” elements, “office:forms”.

OfficeFormsMixin

Mixin class for classes containing the OfficeForms container.

OfficeForms

Bases: FormMixin

Container for “form:form” or “xforms:model” elements, “office:forms”.

Methods:

Name Description
__init__

Initialize the OfficeForms container.

Attributes:

Name Type Description
apply_design_mode bool

Get the form:apply-design-mode attribute.

automatic_focus bool

Get the form:automatic-focus attribute.

Source code in odfdo/office_forms.py
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class OfficeForms(FormMixin):
    """Container for "form:form" or "xforms:model" elements, "office:forms"."""

    _tag = "office:forms"

    def __init__(
        self,
        **kwargs: Any,
    ) -> None:
        """Initialize the OfficeForms container.

        This element acts as a container for form definitions (`form:form`
        or `xforms:model`). It is usable within elements like `draw:page`,
        `office:text`, `presentation:notes`, `style:master-page`, and `table:table`.

        Args:
            **kwargs: Additional keyword arguments for the parent `FormMixin` class.
        """
        super().__init__(**kwargs)

    @property
    def apply_design_mode(self) -> bool:
        """Get the `form:apply-design-mode` attribute.

        Returns:
            bool: True if design mode is applied, False otherwise. Defaults to True.
        """
        return self._get_attribute_bool_default("form:apply-design-mode", True)

    @apply_design_mode.setter
    def apply_design_mode(self, apply_design_mode: bool) -> None:
        """Set the `form:apply-design-mode` attribute.

        Args:
            apply_design_mode: Whether to apply design mode.
        """
        self._set_attribute_bool_default(
            "form:apply-design-mode", apply_design_mode, True
        )

    @property
    def automatic_focus(self) -> bool:
        """Get the `form:automatic-focus` attribute.

        Returns:
            True if automatic focus is enabled, False otherwise. Defaults to False.
        """
        return self._get_attribute_bool_default("form:automatic-focus", False)

    @automatic_focus.setter
    def automatic_focus(self, automatic_focus: bool) -> None:
        """Set the `form:automatic-focus` attribute.

        Args:
            automatic_focus: Whether to enable automatic focus.
        """
        self._set_attribute_bool_default("form:automatic-focus", automatic_focus, False)

_tag class-attribute instance-attribute

_tag = 'office:forms'

apply_design_mode property writable

apply_design_mode: bool

Get the form:apply-design-mode attribute.

Returns:

Name Type Description
bool bool

True if design mode is applied, False otherwise. Defaults to True.

automatic_focus property writable

automatic_focus: bool

Get the form:automatic-focus attribute.

Returns:

Type Description
bool

True if automatic focus is enabled, False otherwise. Defaults to False.

__init__

__init__(**kwargs: Any) -> None

Initialize the OfficeForms container.

This element acts as a container for form definitions (form:form or xforms:model). It is usable within elements like draw:page, office:text, presentation:notes, style:master-page, and table:table.

Parameters:

Name Type Description Default
**kwargs Any

Additional keyword arguments for the parent FormMixin class.

{}
Source code in odfdo/office_forms.py
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def __init__(
    self,
    **kwargs: Any,
) -> None:
    """Initialize the OfficeForms container.

    This element acts as a container for form definitions (`form:form`
    or `xforms:model`). It is usable within elements like `draw:page`,
    `office:text`, `presentation:notes`, `style:master-page`, and `table:table`.

    Args:
        **kwargs: Additional keyword arguments for the parent `FormMixin` class.
    """
    super().__init__(**kwargs)

OfficeFormsMixin

Bases: Element

Mixin class for classes containing the OfficeForms container.

Used by the following classes: “draw:page”, “office:text”, “presentation:notes”, “style:master-page”, “table:table”.

Methods:

Name Description
get_office_forms

Retrieve the office:forms container within the element.

Attributes:

Name Type Description
office_forms OfficeForms | None

Get the office:forms container within the element.

Source code in odfdo/office_forms.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class OfficeFormsMixin(Element):
    """Mixin class for classes containing the OfficeForms container.

    Used by the following classes: "draw:page", "office:text",
    "presentation:notes", "style:master-page", "table:table".
    """

    def get_office_forms(self) -> OfficeForms | None:
        """Retrieve the `office:forms` container within the element.

        Returns:
            OfficeForms | None: The `OfficeForms` instance if found, otherwise `None`.
        """
        return cast(
            None | OfficeForms, self.get_element("descendant::office:forms")
        )

    @property
    def office_forms(self) -> OfficeForms | None:
        """Get the `office:forms` container within the element.

        Returns:
            OfficeForms | None: The `OfficeForms` instance if found, otherwise `None`.
        """
        return self.get_office_forms()

office_forms property

office_forms: OfficeForms | None

Get the office:forms container within the element.

Returns:

Type Description
OfficeForms | None

OfficeForms | None: The OfficeForms instance if found, otherwise None.

get_office_forms

get_office_forms() -> OfficeForms | None

Retrieve the office:forms container within the element.

Returns:

Type Description
OfficeForms | None

OfficeForms | None: The OfficeForms instance if found, otherwise None.

Source code in odfdo/office_forms.py
37
38
39
40
41
42
43
44
45
def get_office_forms(self) -> OfficeForms | None:
    """Retrieve the `office:forms` container within the element.

    Returns:
        OfficeForms | None: The `OfficeForms` instance if found, otherwise `None`.
    """
    return cast(
        None | OfficeForms, self.get_element("descendant::office:forms")
    )