Skip to content

Form

Forms class for “form:form” tag.

Classes:

Name Description
Form

Specification a user-interface form and defines the contents and

FormMixin

Mixin class for classes containing Form.

Form

Bases: FormMixin, OfficeTargetFrameMixin

Specification a user-interface form and defines the contents and properties of the form, “form:form”.

The “form:form” element is usable within the following elements: “form:form” and “office:forms”.

(The main objective of the current minimal implementation is to parse the existing form in a document.)

Methods:

Name Description
__init__

Create a Form, “form:form”.

__repr__

Attributes:

Name Type Description
apply_filter
command
command_type
control_implementation
datasource
name
target_frame
Source code in odfdo/form.py
 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
class Form(FormMixin, OfficeTargetFrameMixin):
    """Specification a user-interface form and defines the contents and
    properties of the form, "form:form".

    The "form:form" element is usable within the following elements:
    "form:form" and "office:forms".

    (The main objective of the current minimal implementation is to parse
    the existing form in a document.)
    """

    _tag = "form:form"
    _properties = (
        PropDef("name", "form:name"),
        PropDef("command", "form:command"),
        PropDef("datasource", "form:datasource"),
        PropDef("apply_filter", "form:apply-filter"),
        PropDef("command_type", "form:command-type"),
        PropDef("control_implementation", "form:control-implementation"),
    )

    def __init__(
        self,
        name: str | None = "Form",
        command: str | None = None,
        datasource: str | None = None,
        apply_filter: bool | None = None,
        command_type: str | None = None,
        control_implementation: str | None = None,
        target_frame: str | None = None,
        **kwargs: Any,
    ) -> None:
        """Create a Form, "form:form".

        The "form:form" element is usable within the following elements:
        "form:form" and "office:forms".

        Args:
            name: The name of the form.
            command: The command for the form.
            datasource: The data source for the form.
            apply_filter: If True, a filter is applied.
            command_type: The type of the command.
            control_implementation: The control implementation.
            target_frame: The target frame for the form.
        """
        super().__init__(**kwargs)
        if self._do_init:
            if name is not None:
                self.name = name
            if command is not None:
                self.command = command
            if datasource is not None:
                self.datasource = datasource
            if apply_filter is not None:
                self.apply_filter = apply_filter
            if command_type is not None:
                self.command_type = command_type
            if control_implementation is not None:
                self.control_implementation = control_implementation
            if target_frame is not None:
                self.target_frame = target_frame

    def __repr__(self) -> str:
        return f"<{self.__class__.__name__} name={self.name}>"

_properties class-attribute instance-attribute

_properties = (
    PropDef("name", "form:name"),
    PropDef("command", "form:command"),
    PropDef("datasource", "form:datasource"),
    PropDef("apply_filter", "form:apply-filter"),
    PropDef("command_type", "form:command-type"),
    PropDef(
        "control_implementation",
        "form:control-implementation",
    ),
)

_tag class-attribute instance-attribute

_tag = 'form:form'

apply_filter instance-attribute

apply_filter = apply_filter

command instance-attribute

command = command

command_type instance-attribute

command_type = command_type

control_implementation instance-attribute

control_implementation = control_implementation

datasource instance-attribute

datasource = datasource

name instance-attribute

name = name

target_frame instance-attribute

target_frame = target_frame

__init__

__init__(
    name: str | None = "Form",
    command: str | None = None,
    datasource: str | None = None,
    apply_filter: bool | None = None,
    command_type: str | None = None,
    control_implementation: str | None = None,
    target_frame: str | None = None,
    **kwargs: Any,
) -> None

Create a Form, “form:form”.

The “form:form” element is usable within the following elements: “form:form” and “office:forms”.

Parameters:

Name Type Description Default
name str | None

The name of the form.

'Form'
command str | None

The command for the form.

None
datasource str | None

The data source for the form.

None
apply_filter bool | None

If True, a filter is applied.

None
command_type str | None

The type of the command.

None
control_implementation str | None

The control implementation.

None
target_frame str | None

The target frame for the form.

None
Source code in odfdo/form.py
 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
114
115
116
117
118
119
120
121
122
123
124
125
def __init__(
    self,
    name: str | None = "Form",
    command: str | None = None,
    datasource: str | None = None,
    apply_filter: bool | None = None,
    command_type: str | None = None,
    control_implementation: str | None = None,
    target_frame: str | None = None,
    **kwargs: Any,
) -> None:
    """Create a Form, "form:form".

    The "form:form" element is usable within the following elements:
    "form:form" and "office:forms".

    Args:
        name: The name of the form.
        command: The command for the form.
        datasource: The data source for the form.
        apply_filter: If True, a filter is applied.
        command_type: The type of the command.
        control_implementation: The control implementation.
        target_frame: The target frame for the form.
    """
    super().__init__(**kwargs)
    if self._do_init:
        if name is not None:
            self.name = name
        if command is not None:
            self.command = command
        if datasource is not None:
            self.datasource = datasource
        if apply_filter is not None:
            self.apply_filter = apply_filter
        if command_type is not None:
            self.command_type = command_type
        if control_implementation is not None:
            self.control_implementation = control_implementation
        if target_frame is not None:
            self.target_frame = target_frame

__repr__

__repr__() -> str
Source code in odfdo/form.py
127
128
def __repr__(self) -> str:
    return f"<{self.__class__.__name__} name={self.name}>"

FormMixin

Bases: Element

Mixin class for classes containing Form.

Used by the following classes: “form:form”, “office:forms”. And also in “office:text”, “table:table” for ease of use.

Methods:

Name Description
get_forms

Return all the Form that match the criteria.

Attributes:

Name Type Description
forms list[Form]

Return all the Form elements..

Source code in odfdo/form.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
55
56
57
58
59
60
61
class FormMixin(Element):
    """Mixin class for classes containing Form.

    Used by the following classes: "form:form", "office:forms".
    And also in "office:text", "table:table" for ease of use.
    """

    def get_forms(
        self,
        name: str | None = None,
    ) -> list[Form]:
        """Return all the Form that match the criteria.

        Args:
            name: The name of the form to filter by.

        Returns:
            list[Form]: A list of Form instances matching the criteria.
        """
        return cast(
            list[Form],
            self._filtered_elements("descendant::form:form", form_name=name),
        )

    @property
    def forms(self) -> list[Form]:
        """Return all the Form elements..

        Returns:
            list[Form]: A list of Form elements.
        """
        return cast(list[Form], self._filtered_elements("descendant::form:form"))

forms property

forms: list[Form]

Return all the Form elements..

Returns:

Type Description
list[Form]

list[Form]: A list of Form elements.

get_forms

get_forms(name: str | None = None) -> list[Form]

Return all the Form that match the criteria.

Parameters:

Name Type Description Default
name str | None

The name of the form to filter by.

None

Returns:

Type Description
list[Form]

list[Form]: A list of Form instances matching the criteria.

Source code in odfdo/form.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def get_forms(
    self,
    name: str | None = None,
) -> list[Form]:
    """Return all the Form that match the criteria.

    Args:
        name: The name of the form to filter by.

    Returns:
        list[Form]: A list of Form instances matching the criteria.
    """
    return cast(
        list[Form],
        self._filtered_elements("descendant::form:form", form_name=name),
    )