Reference
Classes:
| Name | Description |
|---|---|
AnimPar |
Container for SMIL animations, “anim:par”. |
AnimSeq |
Container for SMIL Presentation Animations, “anim:seq”. |
AnimTransFilter |
Transition between two frames, “anim:transitionFilter”. |
Annotation |
An annotation (private note), “text:annotation”. |
AnnotationEnd |
End of annotation marker, “office:annotation-end”. |
BackgroundImage |
Style for a background image, “style:background-image”. |
Body |
Root of the document content, “office:body”. |
Bookmark |
Bookmark class, “text:bookmark” tag. |
BookmarkEnd |
Bookmark end marker, “text:bookmark-end”. |
BookmarkStart |
Bookmark start marker, “text:bookmark-start”. |
Cell |
A cell of a table, “table:table-cell” and “table:covered-table-cell”. |
ChangeInfo |
Representation of information of a change, “office:change-info”. |
Chart |
Root of the Chart document content, “office:chart”. |
Column |
A Column of a table, “table:table-column”. |
ConnectorShape |
A connector shape, “draw:connector”. |
Container |
Storage of the ODF document, as zip or other format. |
Content |
Representation of the “content.xml” part. |
Database |
Root of the Database document content, “office:database”. |
DcCreatorMixin |
Creator of the document, “dc:creator”. |
DcDateMixin |
Date of the document, “dc:date”. |
Document |
Abstraction of the ODF document. |
DrawFillImage |
A link to a bitmap resource, “draw:fill-image”. |
DrawGroup |
Representation of a group of drawing shapes, “draw:g”. |
DrawImage |
An ODF image, “draw:image”. |
DrawPage |
ODF draw page for presentations and drawings, “draw:page”. |
Drawing |
Root of the Drawing document content, “office:drawing”. |
EText |
Representation of an XML text node (internal). |
Element |
Base class of all ODF classes, abstraction of the underlying XML. |
ElementTyped |
Subclass of Element for classes managing typed values. |
EllipseShape |
An ellipse shape, “draw:ellipse”. |
Frame |
ODF Frame, “draw:frame”. |
Header |
A title, a specialized paragraph, “text:h”. |
HeaderRows |
A header row of a table, “table:table-header-rows”. |
Image |
Root of the Image document content, “office:image”. |
IndexTitle |
The title of an index, “text:index-title”. |
IndexTitleTemplate |
Template style for title, “text:index-title-template”. |
LineBreak |
Representation of a line break, “text:line-break”. |
LineShape |
A line shape, “draw:line”. |
Link |
Representation of a link (URL), “text:a”. |
List |
A list of elements, “text:list”. |
ListItem |
An item of a list, “text:list-item”. |
Manifest |
Representation of the “manifest.xml” part. |
Meta |
Representation of the “meta.xml” part. |
MetaAutoReload |
Container for auto-reload properties, “meta:auto-reload”. |
MetaHyperlinkBehaviour |
Container for hyperlink-behaviour properties, “meta:hyperlink- |
MetaTemplate |
Container for the meta template properties, “meta:template”. |
Metadata |
Root of the Meta document content, “office:meta”. |
NamedRange |
Named range of cells in a table, “table:named-range”. |
Note |
A note (footnote or endnote), “text:note”. |
OfficeAutomaticStyles |
Container for automatic styles used in the document, “office:automatic- |
OfficeMasterStyles |
Container for master styles used in the document, “office:master- |
ParaMixin |
Mixin for Paragraph methods. |
Paragraph |
An ODF paragraph, “text:p”. |
Presentation |
Root of the Presentation document content, “office:presentation”. |
RectangleShape |
A rectangle shape, “draw:rect”. |
Reference |
A reference to a content marked by a reference mark, “text:reference- |
ReferenceMark |
A point reference, “text:reference-mark”. |
ReferenceMarkEnd |
End of a range reference, “text:reference-mark-end”. |
ReferenceMarkStart |
Start of a range reference, “text:reference-mark-start”. |
Row |
A row of a table, “table:table-row”. |
RowGroup |
A group of rows with common properties, “table:table-row-group”. |
Section |
Section of the text document, “text:section”. |
Spacer |
Representation of several spaces, “text:s”. |
Span |
A span tag (syled text in paragraph), “text:span”. |
Spreadsheet |
Root of the Spreadsheet document content, “office:spreadsheet”. |
Style |
Style class for many ODF tags, “style:style”, “number:date-style”,… |
StyleFooter |
Content of a footer in a StyleMasterPage, tag “style:footer”. |
StyleFooterLeft |
Content of a left page footer in a StyleMasterPage, tag “style:footer- |
StyleHeader |
Content of a header in a StyleMasterPage, tag “style:header”. |
StyleHeaderLeft |
Content of a left page header in a StyleMasterPage, tag “style:header- |
StyleMasterPage |
Container of headers and footers, “style:master-page”. |
StylePageLayout |
The “style:page-layout” element represents the styles that specify the |
Styles |
Representation of the “styles.xml” part. |
TOC |
A table of content, “text:table-of-content”. |
Tab |
Representation of a tabulation, “text:tab”. |
TabStopStyle |
Base style for a TOC entryBase style for a TOC entry, “style:tab- |
Table |
A table, in a spreadsheet or other document, “table:table”. |
Text |
Root of the Text document content, “office:text”. |
TextChange |
A text change position, “text:change”. |
TextChangeEnd |
End of a changed region, “text:change-end”. |
TextChangeStart |
Start of a changed region, “text:change-start”. |
TextChangedRegion |
A changed region of text, “text:changed-region”. |
TextDeletion |
Information on a text deletion, “text:deletion”. |
TextFormatChange |
A change in text formatting, “text:format-change”. |
TextInsertion |
Information on a text insertion, “text:insertion”. |
TocEntryTemplate |
Template for entry of TOC, “text:table-of-content-entry-template”. |
TrackedChanges |
A tracked change, “text:tracked-changes”. |
UserDefined |
A user defined field, “text:user-defined”. |
UserFieldDecl |
Declaration of a user field, “text:user-field-decl”. |
UserFieldDecls |
Container of user fields declarations, “text:user-field-decls”. |
UserFieldGet |
Representation of user field getter, “text:user-field-get”. |
UserFieldInput |
Representation of user field input, “text:user-field-input”. |
VarChapter |
Variable for a chapter, “text:chapter”. |
VarCreationDate |
Variable for the creation date, “text:creation-date”. |
VarCreationTime |
Variable for the creation time, “text:creation-time”. |
VarDate |
Variable for a date, “text:date”. |
VarDecl |
A variable declaration, “text:variable-decl”. |
VarDecls |
Container of variables declarations, “text:variable-decls”. |
VarDescription |
Variable for the text description, “text:description”. |
VarFileName |
Variable for the file name, “text:file-name”. |
VarGet |
Representation of a variable getter, “text:variable-get”. |
VarInitialCreator |
Variable for the initial creator, “text:initial-creator”. |
VarKeywords |
Variable for the keywords, “text:keywords”. |
VarPageCount |
Variable for page count, “text:page-count”. |
VarPageNumber |
Variable for page number, “text:page-number”. |
VarSet |
Representation of a variable setter, “text:variable-set”. |
VarSubject |
Variable for the subject, “text:subject”. |
VarTime |
Variable for a time, “text:time”. |
VarTitle |
Variable for the title, “text:title”. |
XmlPart |
Representation of an XML part. |
Functions:
| Name | Description |
|---|---|
PageBreak |
Return an empty paragraph with a manual page break. |
create_table_cell_style |
Return a cell style. |
default_boolean_style |
Return a default boolean style. |
default_currency_style |
Return a default currency style (€). |
default_date_style |
Return a default time style Y-M-D. |
default_frame_position_style |
Generate a style for positioning frames in desktop applications. |
default_number_style |
Return a default number style with two decimals. |
default_percentage_style |
Return a default percentage style with two decimals. |
default_time_style |
Return a default time style. |
default_toc_level_style |
Generate an automatic default style for the given TOC level. |
hex2rgb |
Convert “#RRGGBB” hexadecimal representation into (R, G, B) tuple. |
hexa_color |
Safe conversion from color tuple or string to hexadecimal |
make_table_cell_border_string |
Returns a string for “style:table-cell-properties” “fo:border”. |
rgb2hex |
Convert color name or (R, G, B) tuple into “#RRGGBB” hexadecimal. |
Attributes:
| Name | Type | Description |
|---|---|---|
FIRST_CHILD |
|
|
LAST_CHILD |
|
|
NEXT_SIBLING |
|
|
PREV_SIBLING |
|
FIRST_CHILD
module-attribute
FIRST_CHILD = 0
LAST_CHILD
module-attribute
LAST_CHILD = 1
NEXT_SIBLING
module-attribute
NEXT_SIBLING = 2
PREV_SIBLING
module-attribute
PREV_SIBLING = 3
AnimPar
Bases: Element
Container for SMIL animations, “anim:par”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a container for SMIL presentation animations “anim:par”. |
Attributes:
| Name | Type | Description |
|---|---|---|
presentation_node_type |
|
|
smil_begin |
|
Source code in odfdo/smil.py
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 62 | |
presentation_node_type
instance-attribute
presentation_node_type = presentation_node_type
smil_begin
instance-attribute
smil_begin = smil_begin
__init__
__init__(
presentation_node_type: str | None = None,
smil_begin: str | None = None,
**kwargs: Any,
) -> None
Create a container for SMIL presentation animations “anim:par”.
Args:
presentation_node_type -- default, on-click, with-previous,
after-previous, timing-root, main-sequence
and interactive-sequence
smil_begin -- indefinite, 10s, [id].click, [id].begin
Source code in odfdo/smil.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
AnimSeq
Bases: Element
Container for SMIL Presentation Animations, “anim:seq”.
Animations inside this block are executed after the slide has executed its initial transition.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a container for SMIL Presentation Animations “anim:seq”. |
Attributes:
| Name | Type | Description |
|---|---|---|
presentation_node_type |
|
Source code in odfdo/smil.py
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 | |
presentation_node_type
instance-attribute
presentation_node_type = presentation_node_type
__init__
__init__(
presentation_node_type: str | None = None, **kwargs: Any
) -> None
Create a container for SMIL Presentation Animations “anim:seq”.
Animations inside this block are executed after the slide has executed its initial transition.
Args:
presentation_node_type -- default, on-click, with-previous,
after-previous, timing-root, main-sequence
and interactive-sequence
Source code in odfdo/smil.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
AnimTransFilter
Bases: Element
Transition between two frames, “anim:transitionFilter”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a transition between two frames “anim:transitionFilter”. |
Attributes:
| Name | Type | Description |
|---|---|---|
smil_direction |
|
|
smil_dur |
|
|
smil_fadeColor |
|
|
smil_mode |
|
|
smil_subtype |
|
|
smil_type |
|
Source code in odfdo/smil.py
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
smil_direction
instance-attribute
smil_direction = smil_direction
smil_dur
instance-attribute
smil_dur = smil_dur
smil_fadeColor
instance-attribute
smil_fadeColor = smil_fadeColor
smil_mode
instance-attribute
smil_mode = smil_mode
smil_subtype
instance-attribute
smil_subtype = smil_subtype
smil_type
instance-attribute
smil_type = smil_type
__init__
__init__(
smil_dur: str | None = None,
smil_type: str | None = None,
smil_subtype: str | None = None,
smil_direction: str | None = None,
smil_fadeColor: str | None = None,
smil_mode: str | None = None,
**kwargs: Any,
) -> None
Create a transition between two frames “anim:transitionFilter”.
Args:
smil_dur – str, duration
smil_type and smil_subtype – see http://www.w3.org/TR/SMIL20/ smil-transitions.html#TransitionEffects-Appendix to get a list of all types/subtypes
smil_direction – forward, reverse
smil_fadeColor – forward, reverse
smil_mode – in, out
Source code in odfdo/smil.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
Annotation
Bases: MDTail, Element, DcCreatorMixin, DcDateMixin
An annotation (private note), “text:annotation”.
Methods:
| Name | Description |
|---|---|
__init__ |
An annotation (private note), “text:annotation”. |
check_validity |
|
delete |
Delete the given element from the XML tree. If no element is given, |
get_annotated |
Returns the annotated content from an annotation. |
Attributes:
| Name | Type | Description |
|---|---|---|
creator |
|
|
date |
|
|
dc_creator |
str | None
|
Alias for self.creator property. |
dc_date |
datetime | None
|
Alias for self.date property. |
end |
AnnotationEnd | None
|
Return the corresponding annotation-end tag or None. |
name |
|
|
note_body |
str
|
|
start |
Annotation
|
Return self. |
Source code in odfdo/annotation.py
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
creator
instance-attribute
creator = creator
date
instance-attribute
date = date
dc_creator
property
writable
dc_creator: str | None
Alias for self.creator property.
dc_date
property
writable
dc_date: datetime | None
Alias for self.date property.
name
instance-attribute
name = name
note_body
property
writable
note_body: str
__init__
__init__(
text_or_element: Element | str | None = None,
creator: str | None = None,
date: datetime | None = None,
name: str | None = None,
parent: Element | None = None,
**kwargs: Any,
) -> None
An annotation (private note), “text:annotation”.
Annotation element credited to the given creator with the given text, optionally dated (current date by default). If name not provided and some parent is provided, the name is autogenerated.
Args:
text -- str or odf_element
creator -- str
date -- datetime
name -- str
parent -- Element
Source code in odfdo/annotation.py
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 | |
check_validity
check_validity() -> None
Source code in odfdo/annotation.py
219 220 221 222 223 224 225 | |
delete
delete(
child: Element | None = None, keep_tail: bool = True
) -> None
Delete the given element from the XML tree. If no element is given, “self” is deleted. The XML library may allow to continue to use an element now “orphan” as long as you have a reference to it.
For Annotation : delete the annotation-end tag if exists.
Args:
child -- Element or None
Source code in odfdo/annotation.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
get_annotated
get_annotated(
as_text: bool = False,
no_header: bool = True,
clean: bool = True,
) -> Element | list | str | None
Returns the annotated content from an annotation.
If no content exists (single position annotation or annotation-end not found), returns [] (or “” if text flag is True). If as_text is True: returns the text content. If clean is True: suppress unwanted tags (deletions marks, …) If no_header is True: existing text:h are changed in text:p By default: returns a list of odf_element, cleaned and without headers.
Args:
as_text -- boolean
clean -- boolean
no_header -- boolean
Returns: list or Element or text or None
Source code in odfdo/annotation.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
AnnotationEnd
Bases: MDTail, Element
End of annotation marker, “office:annotation-end”.
AnnotationEnd: the “office:annotation-end” element may be used to define the end of a text range of document content that spans element boundaries. In that case, an “office:annotation” element shall precede the “office:annotation-end” element. Both elements shall have the same value for their office:name attribute. The “office:annotation-end” element shall be preceded by an “office:annotation” element that has the same value for its office:name attribute as the “office:annotation-end” element. An “office:annotation-end” element without a preceding “office:annotation” element that has the same name assigned is ignored.
Methods:
| Name | Description |
|---|---|
__init__ |
An annotation (private note), “text:annotation”. |
Attributes:
| Name | Type | Description |
|---|---|---|
end |
AnnotationEnd
|
Return self. |
name |
|
|
start |
Annotation | None
|
Return the corresponding annotation starting tag or None. |
Source code in odfdo/annotation.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
name
instance-attribute
name = name
__init__
__init__(
annotation: Annotation | None = None,
name: str | None = None,
**kwargs: Any,
) -> None
An annotation (private note), “text:annotation”.
Annotation element credited to the given creator with the given text, optionally dated (current date by default). If name not provided and some parent is provided, the name is autogenerated.
Args:
text -- str or odf_element
creator -- str
date -- datetime
name -- str
parent -- Element
Source code in odfdo/annotation.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
BackgroundImage
Style for a background image, “style:background-image”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create style for a background image “style:background-image”. |
Attributes:
| Name | Type | Description |
|---|---|---|
display_name |
|
|
family |
|
|
name |
|
|
position |
|
Source code in odfdo/style.py
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | |
display_name
instance-attribute
display_name = display_name
family
instance-attribute
family = 'background-image'
name
instance-attribute
name = name
position
instance-attribute
position = position
__init__
__init__(
name: str | None = None,
display_name: str | None = None,
position: str | None = None,
repeat: str | None = None,
opacity: str | None = None,
filter: str | None = None,
**kwargs: Any,
) -> None
Create style for a background image “style:background-image”.
Source code in odfdo/style.py
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | |
Body
Bases: Element
Root of the document content, “office:body”.
Methods:
| Name | Description |
|---|---|
get_table |
Return the table that matches the criteria. |
get_tables |
Return all the tables that match the criteria. |
Attributes:
| Name | Type | Description |
|---|---|---|
get_sheet |
|
|
get_sheets |
|
|
sheets |
|
|
tables |
list[Table]
|
Return all the tables. |
Source code in odfdo/body.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 114 115 116 117 | |
tables
property
tables: list[Table]
Return all the tables.
The property is also accessible via the alias sheets.
Returns: list of Table
get_table
get_table(
position: int = 0,
name: str | None = None,
content: str | None = None,
) -> Table | None
Return the table that matches the criteria.
The method is also accessible via the alias get_sheet()
Args:
position -- int
name -- str
content -- str regex
Returns: Table or None if not found
Source code in odfdo/body.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 | |
get_tables
get_tables(
style: str | None = None, content: str | None = None
) -> list[Table]
Return all the tables that match the criteria.
The method is also accessible via the alias get_sheets()
Args:
style -- str
content -- str regex
Returns: list of Table
Source code in odfdo/body.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
Bookmark
Bases: Element
Bookmark class, “text:bookmark” tag.
Methods:
| Name | Description |
|---|---|
__init__ |
Bookmark class, “text:bookmark” tag. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
Source code in odfdo/bookmark.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
name
instance-attribute
name = name
__init__
__init__(name: str = '', **kwargs: Any) -> None
Bookmark class, “text:bookmark” tag.
Args:
name -- str
Source code in odfdo/bookmark.py
36 37 38 39 40 41 42 43 44 45 | |
BookmarkEnd
Bases: Element
Bookmark end marker, “text:bookmark-end”.
Args:
name -- str
Methods:
| Name | Description |
|---|---|
__init__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
Source code in odfdo/bookmark.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
name
instance-attribute
name = name
__init__
__init__(name: str = '', **kwargs: Any) -> None
Source code in odfdo/bookmark.py
78 79 80 81 | |
BookmarkStart
Bases: Element
Bookmark start marker, “text:bookmark-start”.
Methods:
| Name | Description |
|---|---|
__init__ |
Bookmark start marker, “text:bookmark-start”. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
Source code in odfdo/bookmark.py
51 52 53 54 55 56 57 58 59 60 61 | |
name
instance-attribute
name = name
__init__
__init__(name: str = '', **kwargs: Any) -> None
Bookmark start marker, “text:bookmark-start”.
Source code in odfdo/bookmark.py
57 58 59 60 61 | |
Cell
Bases: ElementTyped
A cell of a table, “table:table-cell” and “table:covered-table-cell”.
Methods:
| Name | Description |
|---|---|
__init__ |
Cell of a Table, “table:table-cell”. |
is_covered |
Return whether the cell is covered (tag table:covered-table-cell). |
is_empty |
Return whether the cell has no value or the value evaluates to False |
is_spanned |
Return whether the cell is spanned over several cells. |
set_value |
Set the cell state from the Python value type. |
span_area |
Return the tuple (nb_columns, nb_rows) of the zone covered by a |
Attributes:
| Name | Type | Description |
|---|---|---|
bool |
_bool
|
Set / get the value of the cell as a boolean. |
clone |
Cell
|
|
currency |
str | None
|
Get / set the currency used for monetary values. |
date |
date
|
Set / get the value of the cell as a date. |
datetime |
datetime
|
Set / get the value of the cell as a datetime. |
decimal |
Decimal
|
Set / get the value of the cell as a Decimal (or 0.0). |
duration |
timedelta
|
Set / get the value of the cell as a duration (Python timedelta). |
float |
_float
|
Set / get the value of the cell as a float (or 0.0). |
formula |
str | None
|
Get / set the formula of the cell, or None if undefined. |
int |
_int
|
Set / get the value of the cell as a integer (or 0). |
repeated |
_int | None
|
Get / set the number of times the cell is repeated. |
string |
str
|
Set / get the value of the cell as a string (or ‘’). |
style |
str | None
|
Get / set the style of the cell itself. |
type |
str | None
|
Get / set the type of the cell: boolean, float, date, string or |
value |
str | _bool | _int | _float | Decimal | date | datetime | timedelta | None
|
Set / get the value of the cell. The type is read from the |
x |
int | None
|
|
y |
int | None
|
|
Source code in odfdo/cell.py
47 48 49 50 51 52 53 54 55 56 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
bool
property
writable
bool: _bool
Set / get the value of the cell as a boolean.
currency
property
writable
currency: str | None
Get / set the currency used for monetary values.
Returns: str | None
date
property
writable
date: date
Set / get the value of the cell as a date.
datetime
property
writable
datetime: datetime
Set / get the value of the cell as a datetime.
decimal
property
writable
decimal: Decimal
Set / get the value of the cell as a Decimal (or 0.0).
duration
property
writable
duration: timedelta
Set / get the value of the cell as a duration (Python timedelta).
float
property
writable
float: _float
Set / get the value of the cell as a float (or 0.0).
formula
property
writable
formula: str | None
Get / set the formula of the cell, or None if undefined.
The formula is not interpreted in any way.
Returns: str | None
int
property
writable
int: _int
Set / get the value of the cell as a integer (or 0).
repeated
property
writable
repeated: _int | None
Get / set the number of times the cell is repeated.
Always None when using the table API.
Returns: int or None
string
property
writable
string: str
Set / get the value of the cell as a string (or ‘’).
style
property
writable
style: str | None
Get / set the style of the cell itself.
Returns: str | None
type
property
writable
type: str | None
Get / set the type of the cell: boolean, float, date, string or time.
Returns: str | None
value
property
writable
value: (
str
| _bool
| _int
| _float
| Decimal
| date
| datetime
| timedelta
| None
)
Set / get the value of the cell. The type is read from the ‘office:value-type’ attribute of the cell. When setting the value, the type of the value will determine the new value_type of the cell.
Warning
- for date, datetime and timedelta, a default text value is generated.
- for boolean type, the text value is either ‘True’ or ‘False’.
- for numeric types, the return value is either Decimal or in, use the float, decimal or int properties to force the type.
- Use the method Cell.set_value() to customize the text value.
__init__
__init__(
value: Any = None,
text: str | None = None,
cell_type: str | None = None,
currency: str | None = None,
formula: str | None = None,
repeated: _int | None = None,
style: str | None = None,
**kwargs: Any,
) -> None
Cell of a Table, “table:table-cell”.
Create a cell element containing the given value. The textual representation is automatically formatted but can be provided. Cell type can be deduced as well, unless the number is a percentage or currency. If cell type is “currency”, the currency must be given. The cell can be repeated on the given number of columns.
Args:
value -- bool, int, float, Decimal, date, datetime, str,
timedelta
text -- str
cell_type -- 'boolean', 'currency', 'date', 'float', 'percentage',
'string' or 'time'
currency -- three-letter str
repeated -- int
style -- str
Source code in odfdo/cell.py
52 53 54 55 56 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 | |
is_covered
is_covered() -> _bool
Return whether the cell is covered (tag table:covered-table-cell).
Returns: True | False
Source code in odfdo/cell.py
523 524 525 526 527 528 | |
is_empty
is_empty(aggressive: _bool = False) -> _bool
Return whether the cell has no value or the value evaluates to False (empty string), and no style.
If aggressive is True, empty cells with style are considered empty.
Args:
aggressive -- bool
Returns: bool
Source code in odfdo/cell.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
is_spanned
is_spanned(covered: _bool = True) -> _bool
Return whether the cell is spanned over several cells.
If covered is True (the default), covered cells are considered as spanned, else only the top left cell. The top left contains the attributes “table:number-columns-spanned” and “table:number-rows-spanned”.
Args:
covered -- bool
Returns: True | False
Source code in odfdo/cell.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | |
set_value
set_value(
value: str
| bytes
| _float
| _int
| Decimal
| _bool
| datetime
| date
| timedelta
| None,
text: str | None = None,
cell_type: str | None = None,
currency: str | None = None,
formula: str | None = None,
) -> None
Set the cell state from the Python value type.
Text is how the cell is displayed. Cell type is guessed, unless provided.
For monetary values, provide the name of the currency.
Args:
value -- Python type
text -- str
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency' or 'percentage'
currency -- str
Source code in odfdo/cell.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
span_area
span_area() -> tuple[_int, _int]
Return the tuple (nb_columns, nb_rows) of the zone covered by a spanned cell.
If the cell is not spanned, return (0,0).
Returns: tuple[int, int]
Source code in odfdo/cell.py
554 555 556 557 558 559 560 561 562 563 564 | |
ChangeInfo
Bases: Element, DcCreatorMixin, DcDateMixin
Representation of information of a change, “office:change-info”.
The “office:change-info” element represents who made a change and when. It may also contain a comment (one or more Paragraph “text:p” elements) on the change.
The comments available in the ChangeInfo are available through:
-
paragraphs property, get_paragraphs and get_paragraph methods for actual Paragraph.
-
get_comments for a plain text version
Methods:
| Name | Description |
|---|---|
__init__ |
Create information of a change “office:change-info”. |
get_comments |
Get text content of the comments. If joined is True (default), the |
set_comments |
Set the text content of the comments. If replace is True (default), |
Attributes:
| Name | Type | Description |
|---|---|---|
creator |
|
|
date |
|
Source code in odfdo/tracked_changes.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 | |
creator
instance-attribute
creator = creator or 'Unknown'
date
instance-attribute
date = date
__init__
__init__(
creator: str | None = None,
date: datetime | None = None,
**kwargs: Any,
) -> None
Create information of a change “office:change-info”.
Args:
creator – str (or None)
date – datetime (or None)
Source code in odfdo/tracked_changes.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_comments
get_comments(joined: bool = True) -> str | list[str]
Get text content of the comments. If joined is True (default), the text of different paragraphs is concatenated, else a list of strings, one per paragraph, is returned.
Args:
joined -- boolean (default is True)
Returns: str or list of str.
Source code in odfdo/tracked_changes.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
set_comments
set_comments(text: str = '', replace: bool = True) -> None
Set the text content of the comments. If replace is True (default), the new text replace old comments, else it is added at the end.
Args:
text -- str
replace -- boolean
Source code in odfdo/tracked_changes.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
Chart
Bases: NRMixin, Body
Root of the Chart document content, “office:chart”.
Source code in odfdo/body.py
230 231 232 233 234 | |
Column
Bases: Element
A Column of a table, “table:table-column”.
Methods:
| Name | Description |
|---|---|
__init__ |
A Column of a table, “table:table-column”. |
get_default_cell_style |
Get or set the default cell style for column. |
set_default_cell_style |
Get or set the default cell style for column. |
Attributes:
| Name | Type | Description |
|---|---|---|
clone |
Column
|
|
default_cell_style |
str | None
|
Get or set the default cell style for column. |
repeated |
int | None
|
Get /set the number of times the column is repeated. |
style |
str | None
|
Get /set the style of the column itself. |
x |
int | None
|
|
Source code in odfdo/column.py
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 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
default_cell_style
property
writable
default_cell_style: str | None
Get or set the default cell style for column.
repeated
property
writable
repeated: int | None
Get /set the number of times the column is repeated.
Always None when using the table API.
Returns: int or None
style
property
writable
style: str | None
Get /set the style of the column itself.
Returns: str or None
x
instance-attribute
x: int | None = None
__init__
__init__(
default_cell_style: str | None = None,
repeated: int | None = None,
style: str | None = None,
**kwargs: Any,
) -> None
A Column of a table, “table:table-column”.
Create a column group element of the optionally given style. Cell style can be set for the whole column. If the properties apply to several columns, give the number of repeated columns.
Columns don’t contain cells, just style information.
You don’t generally have to create columns by hand, use the Table API.
Args:
default_cell_style -- str or None
repeated -- int or None
style -- str or None
Source code in odfdo/column.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
get_default_cell_style
get_default_cell_style() -> str | None
Get or set the default cell style for column.
(See also self.default_cell_style property.)
Source code in odfdo/column.py
86 87 88 89 90 91 | |
set_default_cell_style
set_default_cell_style(style: Style | str | None) -> None
Get or set the default cell style for column.
(See also self.default_cell_style property.)
Source code in odfdo/column.py
93 94 95 96 97 98 | |
ConnectorShape
Bases: ShapeBase
A connector shape, “draw:connector”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a Connector shape “draw:connector”. |
Attributes:
| Name | Type | Description |
|---|---|---|
end_glue_point |
|
|
end_shape |
|
|
start_glue_point |
|
|
start_shape |
|
|
x1 |
|
|
x2 |
|
|
y1 |
|
|
y2 |
|
Source code in odfdo/shapes.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
end_glue_point
instance-attribute
end_glue_point = glue_points[1]
end_shape
instance-attribute
end_shape = draw_id
start_glue_point
instance-attribute
start_glue_point = glue_points[0]
start_shape
instance-attribute
start_shape = draw_id
x1
instance-attribute
x1 = p1[0]
x2
instance-attribute
x2 = p2[0]
y1
instance-attribute
y1 = p1[1]
y2
instance-attribute
y2 = p2[1]
__init__
__init__(
style: str | None = None,
text_style: str | None = None,
draw_id: str | None = None,
layer: str | None = None,
connected_shapes: tuple | None = None,
glue_points: tuple | None = None,
p1: tuple | None = None,
p2: tuple | None = None,
**kwargs: Any,
) -> None
Create a Connector shape “draw:connector”.
Args:
style -- str
text_style -- str
draw_id -- str
layer -- str
connected_shapes -- (shape, shape)
glue_points -- (point, point)
p1 -- (str, str)
p2 -- (str, str)
Source code in odfdo/shapes.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
Container
Storage of the ODF document, as zip or other format.
Methods:
| Name | Description |
|---|---|
__init__ |
Storage of the ODF document, as zip or other format. |
del_part |
Mark a part for deletion. |
get_part |
Get the bytes of a part of the ODF. |
get_parts |
Get the list of members. |
open |
Load the content of an ODF file. |
save |
Save the container to the given target, a path or a file-like |
set_part |
Replace or add a new part. |
Attributes:
| Name | Type | Description |
|---|---|---|
clone |
Container
|
Make a copy of this container with no path. |
default_manifest_rdf |
str
|
|
mimetype |
str
|
Return str value of mimetype of the document. |
parts |
list[str]
|
Get the list of members. |
path |
Path | None
|
|
Source code in odfdo/container.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | |
default_manifest_rdf
property
default_manifest_rdf: str
mimetype
property
writable
mimetype: str
Return str value of mimetype of the document.
parts
property
parts: list[str]
Get the list of members.
path
instance-attribute
path: Path | None = None
__init__
__init__(path: Path | str | BytesIO | None = None) -> None
Storage of the ODF document, as zip or other format.
Args:
path – path like, io.BytesIO or None
Source code in odfdo/container.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
del_part
del_part(path: str) -> None
Mark a part for deletion.
Source code in odfdo/container.py
639 640 641 | |
get_part
get_part(path: str) -> str | bytes | None
Get the bytes of a part of the ODF.
Source code in odfdo/container.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
get_parts
get_parts() -> list[str]
Get the list of members.
Source code in odfdo/container.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | |
open
open(path_or_file: Path | str | BytesIO) -> None
Load the content of an ODF file.
Source code in odfdo/container.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
save
save(
target: str | Path | BytesIO | None,
packaging: str | None = None,
backup: bool = False,
pretty: bool = False,
) -> None
Save the container to the given target, a path or a file-like object.
Package the output document in the same format than current document, unless “packaging” is different.
Args:
target -- str or file-like or Path
packaging -- 'zip', or for debugging purpose 'xml' or 'folder'
backup -- boolean
Source code in odfdo/container.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | |
set_part
set_part(path: str, data: bytes) -> None
Replace or add a new part.
Source code in odfdo/container.py
635 636 637 | |
Content
Bases: XmlPart
Representation of the “content.xml” part.
Methods:
| Name | Description |
|---|---|
get_style |
Return the style uniquely identified by the name/family pair. If the |
get_styles |
Return the list of styles in the Content part, optionally limited to |
Source code in odfdo/content.py
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 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 | |
get_style
get_style(
family: str,
name_or_element: str | Element | None = None,
display_name: str | None = None,
) -> StyleBase | None
Return the style uniquely identified by the name/family pair. If the argument is already a style object, it will return it.
If the name is None, the default style is fetched.
If the name is not the internal name but the name you gave in the desktop application, use display_name instead.
Args:
family -- 'paragraph', 'text', 'graphic', 'table', 'list',
'number', ...
name_or_element -- str or Style
display_name -- str
Returns: Style or None if not found
Source code in odfdo/content.py
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 | |
get_styles
get_styles(family: str | None = None) -> list[StyleBase]
Return the list of styles in the Content part, optionally limited to the given family.
Args:
family -- str or None
Returns: list of Style
Source code in odfdo/content.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
Database
Bases: Body
Root of the Database document content, “office:database”.
Source code in odfdo/body.py
237 238 239 240 241 | |
DcCreatorMixin
Creator of the document, “dc:creator”.
Methods:
| Name | Description |
|---|---|
get_creator |
Get the creator of the document. |
set_creator |
Set the creator of the document. |
Attributes:
| Name | Type | Description |
|---|---|---|
creator |
str | None
|
Get or set the |
Source code in odfdo/mixin_dc_creator.py
27 28 29 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
creator
property
writable
creator: str | None
Get or set the
The
The
get_creator
get_creator() -> str | None
Get the creator of the document.
(Also available as “self.creator” property.)
Returns: str (or None if inexistent)
Example::
>>> document.meta.get_creator()
Unknown
Source code in odfdo/mixin_dc_creator.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
set_creator
set_creator(creator: str) -> None
Set the creator of the document.
(Also available as “self.creator” property.)
Args:
creator -- str
Example::
>>> document.meta.set_creator("Plato")
Source code in odfdo/mixin_dc_creator.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
DcDateMixin
Date of the document, “dc:date”.
Methods:
| Name | Description |
|---|---|
get_modification_date |
Get the last modified date of the document. |
set_modification_date |
Set the last modified date of the document. |
Attributes:
| Name | Type | Description |
|---|---|---|
date |
datetime | None
|
Get or set the |
set_dc_date |
|
Source code in odfdo/mixin_dc_date.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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
date
property
writable
date: datetime | None
Get or set the
If provided datetime is None, use current time.
The
get_modification_date
get_modification_date() -> datetime | None
Get the last modified date of the document.
(Also available as “self.date” property.)
Returns: datetime (or None if inexistent)
Source code in odfdo/mixin_dc_date.py
33 34 35 36 37 38 39 40 41 42 43 44 | |
set_modification_date
set_modification_date(date: datetime | None = None) -> None
Set the last modified date of the document.
If provided datetime is None, use current time.
(Also available as “self.date” property.)
Args:
dtdate -- datetime
Source code in odfdo/mixin_dc_date.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
Document
Bases: MDDocument
Abstraction of the ODF document.
Methods:
| Name | Description |
|---|---|
__init__ |
Abstraction of the ODF document. |
add_file |
Insert a file from a path or a file-like object in the container. |
add_page_break_style |
Ensure that the document contains the style required for a manual |
del_part |
Mark a part for deletion. |
delete_styles |
Remove all style information from content and all styles. |
get_cell_background_color |
Return the background color of a table cell of a .ods document, from |
get_cell_style_properties |
Return the style properties of a table cell of a .ods document, from |
get_formated_meta |
Return meta information as text, with some formatting. |
get_formatted_text |
Return content as text, with some formatting. |
get_language |
Get the default language of the document from default styles. |
get_list_style |
|
get_parent_style |
|
get_part |
Return the bytes of the given part. The path is relative to the |
get_parts |
Return available part names with path inside the archive, e.g. |
get_style |
Return the style uniquely identified by the name/family pair. If the |
get_style_properties |
Return the properties of the required style as a dict. |
get_styled_elements |
Brute-force to find paragraphs, tables, etc. using the given style |
get_styles |
|
get_table_displayed |
Return the table:display property of the style of the table, ie if |
get_table_style |
Return the Style instance the table. |
get_type |
Get the ODF type (also called class) of this document. |
insert_style |
Insert the given style object in the document, as required by the |
merge_styles_from |
Copy all the styles of a document into ourself. |
new |
Create a Document from a template. |
save |
Save the document, at the same place it was opened or at the given |
set_language |
Set the default language of the document, both in styles and |
set_part |
Set the bytes of the given part. The path is relative to the |
set_table_displayed |
Set the table:display property of the style of the table, ie if the |
show_styles |
|
to_markdown |
|
Attributes:
| Name | Type | Description |
|---|---|---|
body |
Body
|
Return the body element of the content part, where actual content is |
clone |
Document
|
Return an exact copy of the document. |
container |
Container | None
|
|
content |
Content
|
|
language |
str | None
|
Get or set the default language of the document, both in styles and |
manifest |
Manifest
|
Return the manifest part (manifest.xml) of the document. |
meta |
Meta
|
Return the meta part (meta.xml) of the document, where meta data are |
mimetype |
str
|
|
parts |
list[str]
|
Return available part names with path inside the archive, e.g. |
path |
Path | None
|
Shortcut to Document.Container.path. |
styles |
Styles
|
|
Source code in odfdo/document.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 | |
body
property
body: Body
Return the body element of the content part, where actual content is stored.
language
property
writable
language: str | None
Get or set the default language of the document, both in styles and metadata.
Returns: str
meta
property
meta: Meta
Return the meta part (meta.xml) of the document, where meta data are stored.
mimetype
property
writable
mimetype: str
parts
property
parts: list[str]
Return available part names with path inside the archive, e.g. [‘content.xml’, …, ‘Pictures/100000000000032000000258912EB1C3.jpg’]
path
property
writable
path: Path | None
Shortcut to Document.Container.path.
__init__
__init__(
target: str
| bytes
| Path
| Container
| BytesIO
| None = "text",
) -> None
Abstraction of the ODF document.
To create a new Document, several possibilities:
- Document() or Document("text") or Document("odt")
-> an "empty" document of type text
- Document("spreadsheet") or Document("ods")
-> an "empty" document of type spreadsheet
- Document("presentation") or Document("odp")
-> an "empty" document of type presentation
- Document("drawing") or Document("odg")
-> an "empty" document of type drawing
Meaning of “empty”: these documents are copies of the default
templates documents provided with this library, which, as templates,
are not really empty. It may be useful to clear the newly created
document: document.body.clear(), or adjust meta information like
description or default language: document.meta.language = 'fr-FR'
If the argument is not a known template type, or is a Path, Document(file) will load the content of the ODF file.
To explicitly create a document from a custom template, use the Document.new(path) method whose argument is the path to the template file.
Source code in odfdo/document.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
add_file
add_file(path_or_file: str | Path | BinaryIO) -> str
Insert a file from a path or a file-like object in the container.
Return the full path to reference in the content. The internal name of the file in the Picture/ folder is generated by a hash function.
Args:
path_or_file -- str or Path or file-like
Returns: str (URI)
Source code in odfdo/document.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
add_page_break_style
add_page_break_style() -> None
Ensure that the document contains the style required for a manual page break.
Then a manual page break can be added to the document with
from paragraph import PageBreak … document.body.append(PageBreak())
Note: this style uses the property ‘fo:break-after’, another possibility could be the property ‘fo:break-before’
Source code in odfdo/document.py
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 | |
del_part
del_part(path: str) -> None
Mark a part for deletion.
The path is relative to the archive, e.g. “Pictures/1003200258912EB1C3.jpg”
Source code in odfdo/document.py
381 382 383 384 385 386 387 388 389 390 391 392 393 | |
delete_styles
delete_styles() -> int
Remove all style information from content and all styles.
Returns: number of deleted styles
Source code in odfdo/document.py
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 | |
get_cell_background_color
get_cell_background_color(
table: str | int,
coord: tuple | list | str,
default: str = "#ffffff",
) -> str
Return the background color of a table cell of a .ods document, from the cell style, or from the row or column.
If color is not defined, return default value.
Source code in odfdo/document.py
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 | |
get_cell_style_properties
get_cell_style_properties(
table: str | int, coord: tuple | list | str
) -> dict[str, str]
Return the style properties of a table cell of a .ods document, from the cell style or from the row style.
Source code in odfdo/document.py
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 | |
get_formated_meta
get_formated_meta() -> str
Return meta information as text, with some formatting.
(Redirection to new implementation for compatibility.)
Source code in odfdo/document.py
571 572 573 574 575 576 | |
get_formatted_text
get_formatted_text(rst_mode: bool = False) -> str
Return content as text, with some formatting.
Source code in odfdo/document.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 | |
get_language
get_language() -> str
Get the default language of the document from default styles.
(Note: the Metadata value may differ).
Returns: str
Source code in odfdo/document.py
1353 1354 1355 1356 1357 1358 1359 1360 | |
get_list_style
get_list_style(style: StyleBase) -> StyleBase | None
Source code in odfdo/document.py
786 787 788 789 790 | |
get_parent_style
get_parent_style(style: StyleBase) -> StyleBase | None
Source code in odfdo/document.py
777 778 779 780 781 782 783 784 | |
get_part
get_part(path: str) -> XmlPart | str | bytes | None
Return the bytes of the given part. The path is relative to the archive, e.g. “Pictures/1003200258912EB1C3.jpg”.
‘content’, ‘meta’, ‘settings’, ‘styles’ and ‘manifest’ are shortcuts to the real path, e.g. content.xml, and return a dedicated object with its own API.
path formatted as URI, so always use ‘/’ separator
Source code in odfdo/document.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | |
get_parts
get_parts() -> list[str]
Return available part names with path inside the archive, e.g. [‘content.xml’, …, ‘Pictures/100000000000032000000258912EB1C3.jpg’]
Source code in odfdo/document.py
321 322 323 324 325 326 327 328 | |
get_style
get_style(
family: str,
name_or_element: str | StyleBase | None = None,
display_name: str | None = None,
) -> StyleBase | None
Return the style uniquely identified by the name/family pair. If the argument is already a style object, it will return it.
If the name is None, the default style is fetched.
If the name is not the internal name but the name you gave in a desktop application, use display_name instead.
Args:
family -- 'paragraph', 'text', 'graphic', 'table', 'list',
'number', 'page-layout', 'master-page', ...
name -- str or Element or None
display_name -- str
Returns: Style or None if not found.
Source code in odfdo/document.py
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | |
get_style_properties
get_style_properties(
family: str, name: str, area: str | None = None
) -> dict[str, str] | None
Return the properties of the required style as a dict.
Source code in odfdo/document.py
1215 1216 1217 1218 1219 1220 1221 1222 | |
get_styled_elements
get_styled_elements(name: str = '') -> list[Element]
Brute-force to find paragraphs, tables, etc. using the given style name (or all by default).
Args:
name -- str
Returns: list
Source code in odfdo/document.py
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 | |
get_styles
get_styles(
family: str | bytes = "", automatic: bool = False
) -> list[StyleBase]
Source code in odfdo/document.py
727 728 729 730 731 732 733 734 735 736 737 | |
get_table_displayed
get_table_displayed(table: str | int) -> bool
Return the table:display property of the style of the table, ie if the table should be displayed in a graphical interface.
Note: that method replaces the broken Table.displayd() method from previous odfdo versions.
Args:
table -- name or index of the table
Source code in odfdo/document.py
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 | |
get_table_style
get_table_style(table: str | int) -> StyleBase | None
Return the Style instance the table.
Args:
table -- name or index of the table
Source code in odfdo/document.py
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 | |
get_type
get_type() -> str
Get the ODF type (also called class) of this document.
'chart', 'database', 'formula', 'graphics',
| Type | Description |
|---|---|
str
|
‘graphics-template’, ‘image’, ‘presentation’, |
str
|
‘presentation-template’, ‘spreadsheet’, ‘spreadsheet-template’, |
str
|
‘text’, ‘text-master’, ‘text-template’ or ‘text-web’ |
Source code in odfdo/document.py
407 408 409 410 411 412 413 414 415 416 417 418 419 | |
insert_style
insert_style(
style: StyleBase | str,
name: str = "",
automatic: bool = False,
default: bool = False,
) -> Any
Insert the given style object in the document, as required by the style family and type.
The style is expected to be a common style with a name. In case it was created with no name, the given can be set on the fly.
If automatic is True, the style will be inserted as an automatic style.
If default is True, the style will be inserted as a default style and would replace any existing default style of the same family. Any name or display name would be ignored.
Automatic and default arguments are mutually exclusive.
All styles can’t be used as default styles. Default styles are allowed for the following families: paragraph, text, section, table, table-column, table-row, table-cell, table-page, chart, drawing-page, graphic, presentation, control and ruby.
Args:
style -- Style or str
name -- str
automatic -- bool
default -- bool
Return : style name – str
Source code in odfdo/document.py
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 | |
merge_styles_from
merge_styles_from(document: Document) -> None
Copy all the styles of a document into ourself.
Styles with the same type and name will be replaced, so only unique styles will be preserved.
Source code in odfdo/document.py
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 | |
new
classmethod
new(template: str | Path | BytesIO = 'text') -> Document
Create a Document from a template.
The template argument is expected to be the path to a ODF template.
Args:
template -- str or Path or file-like (io.BytesIO)
Return : ODF document – Document
Source code in odfdo/document.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
save
save(
target: str | Path | BytesIO | None = None,
packaging: str = ZIP,
pretty: bool | None = None,
backup: bool = False,
) -> None
Save the document, at the same place it was opened or at the given target path. Target can also be a file-like object. It can be saved as a Zip file (default), flat XML format or as files in a folder (for debugging purpose). XML parts can be pretty printed (the default for ‘folder’ and ‘xml’ packaging).
Note: ‘xml’ packaging is an experimental work in progress.
Args:
target -- str or file-like object
packaging -- 'zip', 'folder', 'xml'
pretty -- bool | None
backup -- bool
Source code in odfdo/document.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | |
set_language
set_language(language: str) -> None
Set the default language of the document, both in styles and metadata.
(Also available as “Document.language” property.)
Args:
language -- str
Example::
>>> document.set_language('fr-FR')
Source code in odfdo/document.py
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 | |
set_part
set_part(path: str, data: bytes) -> None
Set the bytes of the given part. The path is relative to the archive, e.g. “Pictures/1003200258912EB1C3.jpg”.
path formatted as URI, so always use ‘/’ separator
Source code in odfdo/document.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
set_table_displayed
set_table_displayed(
table: str | int, displayed: bool
) -> None
Set the table:display property of the style of the table, ie if the table should be displayed in a graphical interface.
Note: that method replaces the broken Table.displayd() method from previous odfdo versions.
Args:
table -- name or index of the table
displayed -- boolean flag
Source code in odfdo/document.py
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 | |
show_styles
show_styles(
automatic: bool = True,
common: bool = True,
properties: bool = False,
) -> str
Source code in odfdo/document.py
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 | |
to_markdown
to_markdown() -> str
Source code in odfdo/document.py
578 579 580 581 582 583 584 585 586 | |
DrawFillImage
Bases: DrawImage
A link to a bitmap resource, “draw:fill-image”.
Methods:
| Name | Description |
|---|---|
__init__ |
A link to a bitmap resource, “draw:fill-image”. |
Attributes:
| Name | Type | Description |
|---|---|---|
display_name |
|
|
family |
|
|
height |
|
|
name |
|
|
width |
|
Source code in odfdo/image.py
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 129 130 131 132 133 134 | |
display_name
instance-attribute
display_name = display_name
family
instance-attribute
family = ''
height
instance-attribute
height = height
name
instance-attribute
name = name
width
instance-attribute
width = width
__init__
__init__(
name: str | None = None,
display_name: str | None = None,
height: str | None = None,
width: str | None = None,
**kwargs: Any,
) -> None
A link to a bitmap resource, “draw:fill-image”.
The “draw:fill-image” element specifies a link to a bitmap resource. Fill image are not available as automatic styles. The “draw:fill-image” element is usable within the following element: “office:styles”
Args:
name -- str
display_name -- str
height -- str
width -- str
Source code in odfdo/image.py
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 129 130 131 132 133 134 | |
DrawGroup
Bases: Element, AnchorMix, ZMix, PosMix
Representation of a group of drawing shapes, “draw:g”.
Warning: implementation is currently minimal.
Drawing shapes contained by a “draw:g” element that is itself contained by a “draw:a” element, act as hyperlinks using the xlink:href attribute of the containing “draw:a” element. If the included drawing shapes are themselves contained within “draw:a” elements, then the xlink:href attributes of those “draw:a” elements act as the hyperlink information for the shapes they contain.
The “draw:g” element has the following attributes: draw:caption-id, draw:class-names, draw:id, draw:name, draw:style-name, draw:z-index, presentation:class-names, presentation:style-name, svg:y, table:end-cell-address, table:end-x, table:end-y, table:table-background, text:anchor-page-number, text:anchor-type, and xml:id.
The “draw:g” element has the following child elements: “dr3d:scene”, “draw:a”, “draw:caption”, “draw:circle”, “draw:connector”, “draw:control”, “draw:custom-shape”, “draw:ellipse”, “draw:frame”, “draw:g”, “draw:glue-point”, “draw:line”, “draw:measure”, “draw:page-thumbnail”, “draw:path”, “draw:polygon”, “draw:polyline”, “draw:rect”, “draw:regular-polygon”, “office:event-listeners”, “svg:desc” and “svg:title”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a group of drawing shapes “draw:g”. |
Attributes:
| Name | Type | Description |
|---|---|---|
anchor_page |
|
|
anchor_type |
|
|
draw_id |
|
|
name |
|
|
position |
|
|
presentation_style |
|
|
style |
|
|
z_index |
|
Source code in odfdo/shapes.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
anchor_page
instance-attribute
anchor_page = anchor_page
anchor_type
instance-attribute
anchor_type = anchor_type
draw_id
instance-attribute
draw_id = draw_id
name
instance-attribute
name = name
position
instance-attribute
position = position
presentation_style
instance-attribute
presentation_style = presentation_style
style
instance-attribute
style = style
z_index
instance-attribute
z_index = z_index
__init__
__init__(
name: str | None = None,
draw_id: str | None = None,
style: str | None = None,
position: tuple | None = None,
z_index: int = 0,
anchor_type: str | None = None,
anchor_page: int | None = None,
presentation_style: str | None = None,
**kwargs: Any,
) -> None
Create a group of drawing shapes “draw:g”.
Source code in odfdo/shapes.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
DrawImage
Bases: Element
An ODF image, “draw:image”.
The “draw:image” element represents an image. An image can be either a link to an external resource or most often embedded into the document.
Methods:
| Name | Description |
|---|---|
__init__ |
An ODF image, “draw:image”. |
Attributes:
| Name | Type | Description |
|---|---|---|
actuate |
|
|
filter_name |
|
|
show |
|
|
type |
|
|
url |
|
Source code in odfdo/image.py
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 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 | |
actuate
instance-attribute
actuate = actuate
filter_name
instance-attribute
filter_name = filter_name
show
instance-attribute
show = show
type
instance-attribute
type = xlink_type
url
instance-attribute
url = url
__init__
__init__(
url: str = "",
xlink_type: str = "simple",
show: str = "embed",
actuate: str = "onLoad",
filter_name: str | None = None,
**kwargs: Any,
) -> None
An ODF image, “draw:image”.
When image is embedded in the document, the url parameter is a reference to the local document obtained by copying the source image into the document, ie: url = document.add_file(image_path)
Warning: image elements must be stored in a frame “draw:frame”, see Frame().
Initialization of an DrawImage.
Args:
url -- str
type -- str
show -- str
actuate -- str
filter_name -- str
Source code in odfdo/image.py
48 49 50 51 52 53 54 55 56 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 | |
DrawPage
Bases: Element
ODF draw page for presentations and drawings, “draw:page”.
Methods:
| Name | Description |
|---|---|
__init__ |
ODF draw page for presentations and drawings, “draw:page”. |
get_formatted_text |
|
get_shapes |
|
get_transition |
|
set_transition |
|
Attributes:
| Name | Type | Description |
|---|---|---|
draw_id |
|
|
master_page |
|
|
name |
|
|
presentation_page_layout |
|
|
style |
|
Source code in odfdo/draw_page.py
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 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 114 115 116 117 118 119 120 121 122 123 124 125 | |
draw_id
instance-attribute
draw_id = draw_id
master_page
instance-attribute
master_page = master_page
name
instance-attribute
name = name
presentation_page_layout
instance-attribute
presentation_page_layout = presentation_page_layout
style
instance-attribute
style = style
__init__
__init__(
draw_id: str | None = None,
name: str | None = None,
master_page: str | None = None,
presentation_page_layout: str | None = None,
style: str | None = None,
**kwargs: Any,
) -> None
ODF draw page for presentations and drawings, “draw:page”.
Args:
draw_id -- str
name -- str
master_page -- str
presentation_page_layout -- str
style -- str
Source code in odfdo/draw_page.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
get_formatted_text
get_formatted_text(context: dict | None = None) -> str
Source code in odfdo/draw_page.py
113 114 115 116 117 118 119 120 121 122 123 124 125 | |
get_shapes
get_shapes() -> list[Element]
Source code in odfdo/draw_page.py
109 110 111 | |
get_transition
get_transition() -> AnimPar | None
Source code in odfdo/draw_page.py
82 83 | |
set_transition
set_transition(
smil_type: str,
subtype: str | None = None,
dur: str = "2s",
node_type: str = "default",
) -> None
Source code in odfdo/draw_page.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
Drawing
Bases: NRMixin, Body
Root of the Drawing document content, “office:drawing”.
Source code in odfdo/body.py
244 245 246 247 248 | |
EText
Bases: str
Representation of an XML text node (internal).
Created to hide the specifics of lxml in searching text nodes using XPath.
Constructed like any str object but only accepts lxml text objects.
Methods:
| Name | Description |
|---|---|
__init__ |
|
is_tail |
|
is_text |
|
Attributes:
| Name | Type | Description |
|---|---|---|
parent |
Element | None
|
|
Source code in odfdo/element.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
__init__
__init__(text_result: _Element) -> None
Source code in odfdo/element.py
309 310 311 312 313 314 315 | |
is_tail
is_tail() -> bool
Source code in odfdo/element.py
328 329 | |
is_text
is_text() -> bool
Source code in odfdo/element.py
325 326 | |
Element
Bases: MDBase
Base class of all ODF classes, abstraction of the underlying XML.
Methods:
| Name | Description |
|---|---|
__init__ |
Base class of all ODF classes, abstraction of the underlying XML. |
clear |
Remove text, children and attributes from the element. |
del_attribute |
|
delete |
Delete the given element from the XML tree. If no element is given, |
elements_repeated_sequence |
Utility method for table module. |
extend |
Fast append elements at the end of ourself using extend. |
from_tag |
Element class and subclass factory. |
from_tag_for_clone |
|
get_annotation |
Return the annotation that matches the criteria. |
get_annotation_end |
Return the annotation end that matches the criteria. |
get_annotation_ends |
Return all the annotation ends. |
get_annotations |
Return all the annotations that match the criteria. |
get_attribute |
Return the attribute value as type str | bool | None. |
get_attribute_integer |
Return either the attribute as type int, or None. |
get_attribute_string |
Return either the attribute as type str, or None. |
get_bookmark |
Return the bookmark that matches the criteria. |
get_bookmark_end |
Return the bookmark end that matches the criteria. |
get_bookmark_ends |
Return all the bookmark ends. |
get_bookmark_start |
Return the bookmark start that matches the criteria. |
get_bookmark_starts |
Return all the bookmark starts. |
get_bookmarks |
Return all the bookmarks. |
get_changes_ids |
Return a list of ids that refers to a change region in the tracked |
get_draw_connector |
Return the draw connector that matches the criteria. |
get_draw_connectors |
Return all the draw connectors that match the criteria. |
get_draw_ellipse |
Return the draw ellipse that matches the criteria. |
get_draw_ellipses |
Return all the draw ellipses that match the criteria. |
get_draw_group |
Return the draw group that matches the criteria. |
get_draw_groups |
Return all the draw groups that match the criteria. |
get_draw_line |
Return the draw line that matches the criteria. |
get_draw_lines |
Return all the draw lines that match the criteria. |
get_draw_page |
Return the draw page that matches the criteria. |
get_draw_pages |
Return all the draw pages that match the criteria. |
get_draw_rectangle |
Return the draw rectangle that matches the criteria. |
get_draw_rectangles |
Return all the draw rectangles that match the criteria. |
get_element |
Returns the first element obtained from the XPath query applied to |
get_elements |
Returns the elements obtained from the XPath query applied to the |
get_formatted_text |
This function should return a beautiful version of the text. |
get_frame |
Return the section that matches the criteria. |
get_frames |
Return all the frames that match the criteria. |
get_header |
Return the Header that matches the criteria. |
get_headers |
Return all the Headers that match the criteria. |
get_image |
Return the image matching the criteria. |
get_images |
Return all the images matching the criteria. |
get_link |
Return the link that matches the criteria. |
get_links |
Return all the links that match the criteria. |
get_list |
Return the list that matches the criteria. |
get_lists |
Return all the lists that match the criteria. |
get_note |
Return the note that matches the criteria. |
get_notes |
Return all the notes that match the criteria. |
get_office_names |
Return all the used office:name tags values of the element. |
get_orphan_draw_connectors |
Return a list of connectors which don’t have any shape connected to |
get_paragraph |
Return the paragraph that matches the criteria. |
get_paragraphs |
Return all the paragraphs that match the criteria. |
get_reference_mark |
Return the reference mark that match the criteria. Either single |
get_reference_mark_end |
Return the reference mark end that matches the criteria. Search only |
get_reference_mark_ends |
Return all the reference mark ends. Search only the tags |
get_reference_mark_single |
Return the reference mark that matches the criteria. Search only the |
get_reference_mark_start |
Return the reference mark start that matches the criteria. Search |
get_reference_mark_starts |
Return all the reference mark starts. Search only the tags |
get_reference_marks |
Return all the reference marks, either single position reference |
get_reference_marks_single |
Return all the reference marks. Search only the tags |
get_references |
Return all the references (text:reference-ref). If name is provided, |
get_section |
Return the section that matches the criteria. |
get_sections |
Return all the sections that match the criteria. |
get_span |
Return the span that matches the criteria. |
get_spans |
Return all the spans that match the criteria. |
get_style |
Return the style uniquely identified by the family/name pair. If the |
get_styled_elements |
Brute-force to find paragraphs, tables, etc. using the given style |
get_styles |
|
get_text_change |
Return the text change that matches the criteria. Either single |
get_text_change_deletion |
Return the text change of deletion kind that matches the criteria. |
get_text_change_deletions |
Return all the text changes of deletion kind: the tags text:change. |
get_text_change_end |
Return the text change-end that matches the criteria. Search only |
get_text_change_ends |
Return all the text change-end. Search only the tags |
get_text_change_start |
Return the text change-start that matches the criteria. Search |
get_text_change_starts |
Return all the text change-start. Search only for the tags |
get_text_changes |
Return all the text changes, either single deletion (text:change) or |
get_toc |
Return the table of contents that matches the criteria. |
get_tocs |
Return all the tables of contents. |
get_tracked_changes |
Return the tracked-changes part in the text body. |
get_user_defined |
Return the user defined declaration for the given name. |
get_user_defined_list |
Return all the user defined field declarations. |
get_user_defined_value |
Return the value of the given user defined field name. |
get_user_field_decl |
Return the user field declaration for the given name. |
get_user_field_decl_list |
Return all the user field declarations. |
get_user_field_decls |
Return the container for user field declarations. Created if not |
get_user_field_value |
Return the value of the given user field name. |
get_variable_decl |
Return the variable declaration for the given name. |
get_variable_decl_list |
Return all the variable declarations. |
get_variable_decls |
Return the container for variable declarations. Created if not |
get_variable_set |
Return the variable set for the given name (last one by default). |
get_variable_set_value |
Return the last value of the given variable name. |
get_variable_sets |
Return all the variable sets that match the criteria. |
index |
Return the position of the child in this element. |
insert |
Insert an element relatively to ourself. |
is_empty |
Check if the element is empty : no text, no children, no tail. |
match |
Return True if the pattern is found one or more times anywhere in |
replace |
Replace the pattern with the given text, or delete if text is an |
replace_element |
Replaces in place a sub element with the element passed as second |
search |
Return the first position of the pattern in the text content of the |
search_all |
Return all start and end positions of the regex pattern in the text |
search_first |
Return the start and end position of the first occurrence of the |
serialize |
Return text serialization of XML element. |
set_attribute |
|
set_style_attribute |
Shortcut to accept a style object as a value. |
text_at |
Return the text (recursive) content of the element between start and |
xpath |
Apply XPath query to the element and its subtree. |
Attributes:
| Name | Type | Description |
|---|---|---|
append |
|
|
attributes |
dict[str, str]
|
|
children |
list[Element]
|
|
clone |
Element
|
|
document_body |
Body | None
|
Return the first children of document body if any: ‘office:body/*[1]’ |
frames |
list[Frame]
|
Return all the frames. |
headers |
list[Header]
|
Return all the Headers. |
images |
list[DrawImage]
|
Return all the images. |
inner_text |
str
|
|
is_bound |
bool
|
|
lists |
list[List]
|
Return all the lists. |
paragraphs |
list[Paragraph]
|
Return all the paragraphs. |
parent |
Element | None
|
|
root |
Element
|
|
sections |
list[Section]
|
Return all the sections. |
spans |
list[Span]
|
Return all the spans. |
svg_description |
str | None
|
|
svg_title |
str | None
|
|
tag |
str
|
Get/set the underlying xml tag with the given qualified name. |
tail |
str | None
|
Get / set the text immediately following the element. |
text |
str
|
Get / set the text content of the element. |
text_changes |
list[TextChange | TextChangeStart]
|
Return all the text changes, either single deletion (text:change) or |
text_content |
str
|
Get / set the text of the embedded paragraphs, including embeded |
text_recursive |
str
|
|
toc |
TOC | None
|
Return the first table of contents. |
tocs |
list[TOC]
|
Return all the tables of contents. |
tracked_changes |
Element | None
|
Return the tracked-changes part in the text body. |
user_defined_list |
list[UserDefined]
|
Return all the user defined field declarations. |
Source code in odfdo/element.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 | |
append
class-attribute
instance-attribute
append = __append
attributes
property
attributes: dict[str, str]
document_body
property
document_body: Body | None
Return the first children of document body if any: ‘office:body/*[1]’
inner_text
property
inner_text: str
is_bound
property
is_bound: bool
paragraphs
property
paragraphs: list[Paragraph]
Return all the paragraphs.
Returns: list of Paragraph
svg_description
property
writable
svg_description: str | None
svg_title
property
writable
svg_title: str | None
tag
property
writable
tag: str
Get/set the underlying xml tag with the given qualified name.
Warning: direct change of tag does not change the element class.
Args:
qname -- str (e.g. "text:span")
tail
property
writable
tail: str | None
Get / set the text immediately following the element.
text
property
writable
text: str
Get / set the text content of the element.
text_changes
property
text_changes: list[TextChange | TextChangeStart]
Return all the text changes, either single deletion (text:change) or start of range of changes (text:change-start).
Returns: list of Element
text_content
property
writable
text_content: str
Get / set the text of the embedded paragraphs, including embeded annotations, cells…
Set does create a paragraph if missing.
text_recursive
property
text_recursive: str
toc
property
toc: TOC | None
Return the first table of contents.
Returns: odf_toc or None if not found
tracked_changes
property
tracked_changes: Element | None
Return the tracked-changes part in the text body.
Returns: Element or None
user_defined_list
property
user_defined_list: list[UserDefined]
Return all the user defined field declarations.
Returns: list of UserDefined
__init__
__init__(**kwargs: Any) -> None
Base class of all ODF classes, abstraction of the underlying XML.
Source code in odfdo/element.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
clear
clear() -> None
Remove text, children and attributes from the element.
Source code in odfdo/element.py
1269 1270 1271 | |
del_attribute
del_attribute(name: str) -> None
Source code in odfdo/element.py
824 825 826 827 | |
delete
delete(
child: Element | None = None, keep_tail: bool = True
) -> None
Delete the given element from the XML tree. If no element is given, “self” is deleted. The XML library may allow to continue to use an element now “orphan” as long as you have a reference to it.
if keep_tail is True (default), the tail text is not erased.
Args:
child -- Element
keep_tail -- boolean (default to True), True for most usages.
Source code in odfdo/element.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 | |
elements_repeated_sequence
elements_repeated_sequence(
xpath_instance: XPath, name: str
) -> list[tuple[int, int]]
Utility method for table module.
Source code in odfdo/element.py
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | |
extend
extend(odf_elements: Iterable[Element]) -> None
Fast append elements at the end of ourself using extend.
Source code in odfdo/element.py
1176 1177 1178 1179 1180 1181 | |
from_tag
classmethod
from_tag(tag_or_elem: str | _Element) -> Element
Element class and subclass factory.
Turn an lxml Element or ODF string tag into an ODF XML Element of the relevant class.
Args:
tag_or_elem -- ODF str tag or lxml.Element
Returns: Element (or subclass) instance
Source code in odfdo/element.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
from_tag_for_clone
classmethod
from_tag_for_clone(
tree_element: _Element, cache: tuple | None
) -> Element
Source code in odfdo/element.py
380 381 382 383 384 385 386 387 388 389 390 391 | |
get_annotation
get_annotation(
position: int = 0,
creator: str | None = None,
start_date: datetime | None = None,
end_date: datetime | None = None,
content: str | None = None,
name: str | None = None,
) -> Annotation | None
Return the annotation that matches the criteria.
Args:
position -- int
creator -- str
start_date -- datetime instance
end_date -- datetime instance
content -- str regex
name -- str
Returns: Annotation or None if not found
Source code in odfdo/element.py
1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 | |
get_annotation_end
get_annotation_end(
position: int = 0, name: str | None = None
) -> AnnotationEnd | None
Return the annotation end that matches the criteria.
Args:
position -- int
name -- str
Returns: AnnotationEnd or None if not found
Source code in odfdo/element.py
1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 | |
get_annotation_ends
get_annotation_ends() -> list[AnnotationEnd]
Return all the annotation ends.
Returns: list of AnnotationEnd
Source code in odfdo/element.py
1898 1899 1900 1901 1902 1903 1904 1905 | |
get_annotations
get_annotations(
creator: str | None = None,
start_date: datetime | None = None,
end_date: datetime | None = None,
content: str | None = None,
) -> list[Annotation]
Return all the annotations that match the criteria.
Args:
creator -- str
start_date -- datetime instance
end_date -- datetime instance
content -- str regex
Returns: list of Annotation
Source code in odfdo/element.py
1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 | |
get_attribute
get_attribute(name: str) -> str | bool | None
Return the attribute value as type str | bool | None.
Source code in odfdo/element.py
722 723 724 725 726 727 728 729 730 731 | |
get_attribute_integer
get_attribute_integer(name: str) -> int | None
Return either the attribute as type int, or None.
Source code in odfdo/element.py
733 734 735 736 737 738 739 740 741 742 743 | |
get_attribute_string
get_attribute_string(name: str) -> str | None
Return either the attribute as type str, or None.
Source code in odfdo/element.py
745 746 747 748 749 750 751 752 | |
get_bookmark
get_bookmark(
position: int = 0, name: str | None = None
) -> Bookmark | None
Return the bookmark that matches the criteria.
Args:
position -- int
name -- str
Returns: Bookmark or None if not found
Source code in odfdo/element.py
2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 | |
get_bookmark_end
get_bookmark_end(
position: int = 0, name: str | None = None
) -> BookmarkEnd | None
Return the bookmark end that matches the criteria.
Args:
position -- int
name -- str
Returns: BookmarkEnd or None if not found
Source code in odfdo/element.py
2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 | |
get_bookmark_ends
get_bookmark_ends() -> list[BookmarkEnd]
Return all the bookmark ends.
Returns: list of BookmarkEnd
Source code in odfdo/element.py
2298 2299 2300 2301 2302 2303 2304 2305 | |
get_bookmark_start
get_bookmark_start(
position: int = 0, name: str | None = None
) -> BookmarkStart | None
Return the bookmark start that matches the criteria.
Args:
position -- int
name -- str
Returns: BookmarkStart or None if not found
Source code in odfdo/element.py
2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 | |
get_bookmark_starts
get_bookmark_starts() -> list[BookmarkStart]
Return all the bookmark starts.
Returns: list of BookmarkStart
Source code in odfdo/element.py
2270 2271 2272 2273 2274 2275 2276 2277 | |
get_bookmarks
get_bookmarks() -> list[Bookmark]
Return all the bookmarks.
Returns: list of Bookmark
Source code in odfdo/element.py
2242 2243 2244 2245 2246 2247 2248 2249 | |
get_changes_ids
Return a list of ids that refers to a change region in the tracked changes list.
Source code in odfdo/element.py
2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 | |
get_draw_connector
get_draw_connector(
position: int = 0,
id: str | None = None,
content: str | None = None,
) -> ConnectorShape | None
Return the draw connector that matches the criteria.
Args:
position -- int
id -- str
content -- str regex
Returns: ConnectorShape or None if not found
Source code in odfdo/element.py
2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 | |
get_draw_connectors
get_draw_connectors(
draw_style: str | None = None,
draw_text_style: str | None = None,
content: str | None = None,
) -> list[ConnectorShape]
Return all the draw connectors that match the criteria.
Args:
draw_style -- str
draw_text_style -- str
content -- str regex
Returns: list of ConnectorShape
Source code in odfdo/element.py
2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 | |
get_draw_ellipse
get_draw_ellipse(
position: int = 0,
id: str | None = None,
content: str | None = None,
) -> EllipseShape | None
Return the draw ellipse that matches the criteria.
Args:
position -- int
id -- str
content -- str regex
Returns: EllipseShape or None if not found
Source code in odfdo/element.py
2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 | |
get_draw_ellipses
get_draw_ellipses(
draw_style: str | None = None,
draw_text_style: str | None = None,
content: str | None = None,
) -> list[EllipseShape]
Return all the draw ellipses that match the criteria.
Args:
draw_style -- str
draw_text_style -- str
content -- str regex
Returns: list of EllipseShape
Source code in odfdo/element.py
2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 | |
get_draw_group
get_draw_group(
position: int = 0,
name: str | None = None,
title: str | None = None,
description: str | None = None,
content: str | None = None,
) -> DrawGroup | None
Return the draw group that matches the criteria.
Args:
position -- int
name -- str or None
title -- str or None
description -- str regex or None
content -- str regex or None
Returns: DrawGroup or None if not found
Source code in odfdo/element.py
2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 | |
get_draw_groups
get_draw_groups(
title: str | None = None,
description: str | None = None,
content: str | None = None,
) -> list[DrawGroup]
Return all the draw groups that match the criteria.
Args:
title -- str or None
description -- str regex or None
content -- str regex or None
Returns: list of DrawGroup
Source code in odfdo/element.py
2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 | |
get_draw_line
get_draw_line(
position: int = 0,
id: str | None = None,
content: str | None = None,
) -> LineShape | None
Return the draw line that matches the criteria.
Args:
position -- int
id -- str
content -- str regex
Returns: LineShape or None if not found
Source code in odfdo/element.py
2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 | |
get_draw_lines
get_draw_lines(
draw_style: str | None = None,
draw_text_style: str | None = None,
content: str | None = None,
) -> list[LineShape]
Return all the draw lines that match the criteria.
Args:
draw_style -- str
draw_text_style -- str
content -- str regex
Returns: list of LineShape
Source code in odfdo/element.py
2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 | |
get_draw_page
get_draw_page(
position: int = 0,
name: str | None = None,
content: str | None = None,
) -> DrawPage | None
Return the draw page that matches the criteria.
Args:
position -- int
name -- str
content -- str regex
Returns: DrawPage or None if not found
Source code in odfdo/element.py
2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 | |
get_draw_pages
get_draw_pages(
style: str | None = None, content: str | None = None
) -> list[DrawPage]
Return all the draw pages that match the criteria.
Args:
style -- str
content -- str regex
Returns: list of DrawPage
Source code in odfdo/element.py
2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 | |
get_draw_rectangle
get_draw_rectangle(
position: int = 0,
id: str | None = None,
content: str | None = None,
) -> RectangleShape | None
Return the draw rectangle that matches the criteria.
Args:
position -- int
id -- str
content -- str regex
Returns: RectangleShape or None if not found
Source code in odfdo/element.py
2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 | |
get_draw_rectangles
get_draw_rectangles(
draw_style: str | None = None,
draw_text_style: str | None = None,
content: str | None = None,
) -> list[RectangleShape]
Return all the draw rectangles that match the criteria.
Args:
draw_style -- str
draw_text_style -- str
content -- str regex
Returns: list of RectangleShape
Source code in odfdo/element.py
2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 | |
get_element
get_element(xpath_query: str) -> Element | None
Returns the first element obtained from the XPath query applied to the current element.
Return an Element or None.
Source code in odfdo/element.py
690 691 692 693 694 695 696 697 698 699 | |
get_elements
get_elements(xpath_query: XPath | str) -> list[Element]
Returns the elements obtained from the XPath query applied to the current element.
Return list of Element.
Source code in odfdo/element.py
678 679 680 681 682 683 684 685 686 687 688 | |
get_formatted_text
get_formatted_text(context: dict | None = None) -> str
This function should return a beautiful version of the text.
Source code in odfdo/element.py
1307 1308 1309 | |
get_frame
get_frame(
position: int = 0,
name: str | None = None,
presentation_class: str | None = None,
title: str | None = None,
description: str | None = None,
content: str | None = None,
) -> Frame | None
Return the section that matches the criteria.
Args:
position -- int
name -- str
presentation_class -- str
title -- str regex
description -- str regex
content -- str regex
Returns: Frame or None if not found
Source code in odfdo/element.py
1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 | |
get_frames
get_frames(
presentation_class: str | None = None,
style: str | None = None,
title: str | None = None,
description: str | None = None,
content: str | None = None,
) -> list[Frame]
Return all the frames that match the criteria.
Args:
presentation_class -- str
style -- str
title -- str regex
description -- str regex
content -- str regex
Returns: list of Frame
Source code in odfdo/element.py
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 | |
get_header
get_header(
position: int = 0,
outline_level: str | None = None,
content: str | None = None,
) -> Header | None
Return the Header that matches the criteria.
Args:
position -- int
content -- str regex
Returns: Header or None if not found
Source code in odfdo/element.py
1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 | |
get_headers
get_headers(
style: str | None = None,
outline_level: str | None = None,
content: str | None = None,
) -> list[Header]
Return all the Headers that match the criteria.
Args:
style -- str
content -- str regex
Returns: list of Header
Source code in odfdo/element.py
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 | |
get_image
get_image(
position: int = 0,
name: str | None = None,
url: str | None = None,
content: str | None = None,
) -> DrawImage | None
Return the image matching the criteria.
Args:
position -- int
name -- str
url -- str regex
content -- str regex
Returns: DrawImage or None if not found
Source code in odfdo/element.py
1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 | |
get_images
get_images(
style: str | None = None,
url: str | None = None,
content: str | None = None,
) -> list[DrawImage]
Return all the images matching the criteria.
Args:
style -- str
url -- str regex
content -- str regex
Returns: list of DrawImage
Source code in odfdo/element.py
1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 | |
get_link
get_link(
position: int = 0,
name: str | None = None,
title: str | None = None,
url: str | None = None,
content: str | None = None,
) -> Link | None
Return the link that matches the criteria.
Args:
position -- int
name -- str
title -- str
url -- str regex
content -- str regex
Returns: Link or None if not found
Source code in odfdo/element.py
2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 | |
get_links
get_links(
name: str | None = None,
title: str | None = None,
url: str | None = None,
content: str | None = None,
) -> list[Link]
Return all the links that match the criteria.
Args:
name -- str
title -- str
url -- str regex
content -- str regex
Returns: list of Link
Source code in odfdo/element.py
2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 | |
get_list
get_list(
position: int = 0, content: str | None = None
) -> List | None
Return the list that matches the criteria.
Args:
position -- int
content -- str regex
Returns: List or None if not found
Source code in odfdo/element.py
1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 | |
get_lists
get_lists(
style: str | None = None, content: str | None = None
) -> list[List]
Return all the lists that match the criteria.
Args:
style -- str
content -- str regex
Returns: list of List
Source code in odfdo/element.py
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 | |
get_note
get_note(
position: int = 0,
note_id: str | None = None,
note_class: str | None = None,
content: str | None = None,
) -> Note | None
Return the note that matches the criteria.
Args:
position -- int
note_id -- str
note_class -- 'footnote' or 'endnote'
content -- str regex
Returns: Note or None if not found
Source code in odfdo/element.py
1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 | |
get_notes
get_notes(
note_class: str | None = None,
content: str | None = None,
) -> list[Note]
Return all the notes that match the criteria.
Args:
note_class -- 'footnote' or 'endnote'
content -- str regex
Returns: list of Note
Source code in odfdo/element.py
1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 | |
get_office_names
get_office_names() -> list[str]
Return all the used office:name tags values of the element.
Returns: list of unique str
Source code in odfdo/element.py
1928 1929 1930 1931 1932 1933 1934 1935 | |
get_orphan_draw_connectors
get_orphan_draw_connectors() -> list[ConnectorShape]
Return a list of connectors which don’t have any shape connected to them.
Returns: list of ConnectorShape
Source code in odfdo/element.py
2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 | |
get_paragraph
get_paragraph(
position: int = 0, content: str | None = None
) -> Paragraph | None
Return the paragraph that matches the criteria.
Args:
position -- int
content -- str regex
Returns: Paragraph or None if not found
Source code in odfdo/element.py
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 | |
get_paragraphs
get_paragraphs(
style: str | None = None, content: str | None = None
) -> list[Paragraph]
Return all the paragraphs that match the criteria.
Args:
style -- str
content -- str regex
Returns: list of Paragraph
Source code in odfdo/element.py
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 | |
get_reference_mark
get_reference_mark(
position: int = 0, name: str | None = None
) -> ReferenceMark | ReferenceMarkStart | None
Return the reference mark that match the criteria. Either single position reference mark (text:reference-mark) or start of range reference (text:reference-mark-start).
Args:
position -- int
name -- str
Returns: ReferenceMark or ReferenceMarkStart or None if not found
Source code in odfdo/element.py
2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 | |
get_reference_mark_end
get_reference_mark_end(
position: int = 0, name: str | None = None
) -> ReferenceMarkEnd | None
Return the reference mark end that matches the criteria. Search only the tags text:reference-mark-end. Consider using : get_reference_marks()
Args:
position -- int
name -- str
Returns: ReferenceMarkEnd or None if not found
Source code in odfdo/element.py
2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 | |
get_reference_mark_ends
get_reference_mark_ends() -> list[ReferenceMarkEnd]
Return all the reference mark ends. Search only the tags text:reference-mark-end. Consider using : get_reference_marks()
Returns: list of ReferenceMarkEnd
Source code in odfdo/element.py
2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 | |
get_reference_mark_single
get_reference_mark_single(
position: int = 0, name: str | None = None
) -> ReferenceMark | None
Return the reference mark that matches the criteria. Search only the tags text:reference-mark. Consider using : get_reference_mark()
Args:
position -- int
name -- str
Returns: ReferenceMark or None if not found
Source code in odfdo/element.py
2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 | |
get_reference_mark_start
get_reference_mark_start(
position: int = 0, name: str | None = None
) -> ReferenceMarkStart | None
Return the reference mark start that matches the criteria. Search only the tags text:reference-mark-start. Consider using : get_reference_mark()
Args:
position -- int
name -- str
Returns: ReferenceMarkStart or None if not found
Source code in odfdo/element.py
2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 | |
get_reference_mark_starts
get_reference_mark_starts() -> list[ReferenceMarkStart]
Return all the reference mark starts. Search only the tags text:reference-mark-start. Consider using : get_reference_marks()
Returns: list of ReferenceMarkStart
Source code in odfdo/element.py
2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 | |
get_reference_marks
get_reference_marks() -> list[
ReferenceMark | ReferenceMarkStart
]
Return all the reference marks, either single position reference (text:reference-mark) or start of range reference (text:reference-mark- start).
Returns: list of ReferenceMark or ReferenceMarkStart
Source code in odfdo/element.py
2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 | |
get_reference_marks_single
get_reference_marks_single() -> list[ReferenceMark]
Return all the reference marks. Search only the tags text:reference-mark. Consider using : get_reference_marks()
Returns: list of ReferenceMark
Source code in odfdo/element.py
2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 | |
get_references
get_references(name: str | None = None) -> list[Reference]
Return all the references (text:reference-ref). If name is provided, returns the references of that name.
Args:
name -- str or None
Returns: list of Reference
Source code in odfdo/element.py
2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 | |
get_section
get_section(
position: int = 0, content: str | None = None
) -> Section | None
Return the section that matches the criteria.
Args:
position -- int
content -- str regex
Returns: Section or None if not found
Source code in odfdo/element.py
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 | |
get_sections
get_sections(
style: str | None = None, content: str | None = None
) -> list[Section]
Return all the sections that match the criteria.
Args:
style -- str
content -- str regex
Returns: list of Section
Source code in odfdo/element.py
1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 | |
get_span
get_span(
position: int = 0, content: str | None = None
) -> Span | None
Return the span that matches the criteria.
Args:
position -- int
content -- str regex
Returns: Span or None if not found
Source code in odfdo/element.py
1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 | |
get_spans
get_spans(
style: str | None = None, content: str | None = None
) -> list[Span]
Return all the spans that match the criteria.
Args:
style -- str
content -- str regex
Returns: list of Span
Source code in odfdo/element.py
1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 | |
get_style
get_style(
family: str,
name_or_element: str | Element | None = None,
display_name: str | None = None,
) -> StyleBase | None
Return the style uniquely identified by the family/name pair. If the argument is already a style object, it will return it.
If the name is not the internal name but the name you gave in the desktop application, use display_name instead.
Args:
family -- 'paragraph', 'text', 'graphic', 'table', 'list',
'number'
name_or_element -- str or Style
display_name -- str
Returns: Style or None if not found
Source code in odfdo/element.py
2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 | |
get_styled_elements
get_styled_elements(name: str = '') -> list[Element]
Brute-force to find paragraphs, tables, etc. using the given style name (or all by default).
Args:
name -- str
Returns: list of Element
Source code in odfdo/element.py
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 | |
get_styles
get_styles(family: str | None = None) -> list[StyleBase]
Source code in odfdo/element.py
2991 2992 2993 2994 | |
get_text_change
get_text_change(
position: int = 0, idx: str | None = None
) -> TextChange | TextChangeStart | None
Return the text change that matches the criteria. Either single deletion (text:change) or start of range of changes (text:change-start). position : index of the element to retrieve if several matches, default is 0. idx : change-id of the element.
Args:
position -- int
idx -- str
Returns: Element or None if not found
Source code in odfdo/element.py
2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 | |
get_text_change_deletion
get_text_change_deletion(
position: int = 0, idx: str | None = None
) -> TextChange | None
Return the text change of deletion kind that matches the criteria. Search only for the tags text:change. Consider using : get_text_change()
Args:
position -- int
idx -- str
Returns: TextChange or None if not found
Source code in odfdo/element.py
2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 | |
get_text_change_deletions
get_text_change_deletions() -> list[TextChange]
Return all the text changes of deletion kind: the tags text:change. Consider using : get_text_changes()
Returns: list of TextChange
Source code in odfdo/element.py
2785 2786 2787 2788 2789 2790 2791 2792 2793 | |
get_text_change_end
get_text_change_end(
position: int = 0, idx: str | None = None
) -> TextChangeEnd | None
Return the text change-end that matches the criteria. Search only the tags text:change-end. Consider using : get_text_change()
Args:
position -- int
idx -- str
Returns: TextChangeEnd or None if not found
Source code in odfdo/element.py
2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 | |
get_text_change_ends
get_text_change_ends() -> list[TextChangeEnd]
Return all the text change-end. Search only the tags text:change-end. Consider using : get_text_changes()
Returns: list of TextChangeEnd
Source code in odfdo/element.py
2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 | |
get_text_change_start
get_text_change_start(
position: int = 0, idx: str | None = None
) -> TextChangeStart | None
Return the text change-start that matches the criteria. Search only the tags text:change-start. Consider using : get_text_change()
Args:
position -- int
idx -- str
Returns: TextChangeStart or None if not found
Source code in odfdo/element.py
2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 | |
get_text_change_starts
get_text_change_starts() -> list[TextChangeStart]
Return all the text change-start. Search only for the tags text:change-start. Consider using : get_text_changes()
Returns: list of TextChangeStart
Source code in odfdo/element.py
2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 | |
get_text_changes
get_text_changes() -> list[TextChange | TextChangeStart]
Return all the text changes, either single deletion (text:change) or start of range of changes (text:change-start).
Returns: list of TextChange or TextChangeStart
Source code in odfdo/element.py
2880 2881 2882 2883 2884 2885 2886 2887 | |
get_toc
get_toc(
position: int = 0, content: str | None = None
) -> TOC | None
Return the table of contents that matches the criteria.
Args:
position -- int
content -- str regex
Returns: TOC or None if not found
Source code in odfdo/element.py
2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 | |
get_tocs
get_tocs() -> list[TOC]
Return all the tables of contents.
Returns: list of TOC
Source code in odfdo/element.py
2929 2930 2931 2932 2933 2934 | |
get_tracked_changes
get_tracked_changes() -> TrackedChanges | None
Return the tracked-changes part in the text body.
Returns: TrackedChanges or None
Source code in odfdo/element.py
2759 2760 2761 2762 2763 2764 | |
get_user_defined
get_user_defined(
name: str, position: int = 0
) -> UserDefined | None
Return the user defined declaration for the given name.
Returns: UserDefined or none if not found
Source code in odfdo/element.py
2105 2106 2107 2108 2109 2110 2111 2112 | |
get_user_defined_list
get_user_defined_list() -> list[UserDefined]
Return all the user defined field declarations.
Returns: list of UserDefined
Source code in odfdo/element.py
2088 2089 2090 2091 2092 2093 2094 2095 | |
get_user_defined_value
get_user_defined_value(
name: str, value_type: str | None = None
) -> (
bool
| str
| int
| float
| Decimal
| datetime
| timedelta
| None
)
Return the value of the given user defined field name.
Args:
name -- str
value_type -- 'boolean', 'date', 'float',
'string', 'time' or automatic
Returns: most appropriate Python type
Source code in odfdo/element.py
2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 | |
get_user_field_decl
get_user_field_decl(
name: str, position: int = 0
) -> UserFieldDecl | None
Return the user field declaration for the given name.
Returns: UserFieldDecl or none if not found
Source code in odfdo/element.py
2056 2057 2058 2059 2060 2061 2062 2063 | |
get_user_field_decl_list
get_user_field_decl_list() -> list[UserFieldDecl]
Return all the user field declarations.
Returns: list of UserFieldDecl
Source code in odfdo/element.py
2047 2048 2049 2050 2051 2052 2053 2054 | |
get_user_field_decls
get_user_field_decls() -> UserFieldDecls | None
Return the container for user field declarations. Created if not found.
Returns: UserFieldDecls
Source code in odfdo/element.py
2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 | |
get_user_field_value
get_user_field_value(
name: str, value_type: str | None = None
) -> (
bool
| str
| int
| float
| Decimal
| datetime
| timedelta
| None
)
Return the value of the given user field name.
Args:
name -- str
value_type -- 'boolean', 'currency', 'date', 'float',
'percentage', 'string', 'time' or automatic
Returns: most appropriate Python type
Source code in odfdo/element.py
2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 | |
get_variable_decl
get_variable_decl(
name: str, position: int = 0
) -> VarDecls | None
Return the variable declaration for the given name.
Args:
name -- str
position -- int
Returns: VarDecls or none if not found
Source code in odfdo/element.py
1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 | |
get_variable_decl_list
get_variable_decl_list() -> list[VarDecls]
Return all the variable declarations.
Returns: list of VarDecls
Source code in odfdo/element.py
1955 1956 1957 1958 1959 1960 1961 1962 | |
get_variable_decls
get_variable_decls() -> VarDecls
Return the container for variable declarations. Created if not found.
Returns: VarDecls
Source code in odfdo/element.py
1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 | |
get_variable_set
get_variable_set(
name: str, position: int = -1
) -> VarSet | None
Return the variable set for the given name (last one by default).
Args:
name -- str
position -- int
Returns: VarSet or None if not found
Source code in odfdo/element.py
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 | |
get_variable_set_value
get_variable_set_value(
name: str, value_type: str | None = None
) -> (
bool
| str
| int
| float
| Decimal
| datetime
| timedelta
| None
)
Return the last value of the given variable name.
Args:
name -- str
value_type -- 'boolean', 'currency', 'date', 'float',
'percentage', 'string', 'time' or automatic
Returns: most appropriate Python type
Source code in odfdo/element.py
2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 | |
get_variable_sets
get_variable_sets(name: str | None = None) -> list[VarSet]
Return all the variable sets that match the criteria.
Args:
name -- str
Returns: list of VarSet
Source code in odfdo/element.py
1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 | |
index
index(child: Element) -> int
Return the position of the child in this element.
Inspired by lxml.
Source code in odfdo/element.py
1062 1063 1064 1065 1066 1067 1068 | |
insert
insert(
element: Element,
xmlposition: int | None = None,
position: int | None = None,
start: bool = False,
) -> None
Insert an element relatively to ourself.
Insert either using DOM vocabulary or by numeric position. If “start” is True, insert the element before any existing text.
Position start at 0.
Args:
element -- Element
xmlposition -- FIRST_CHILD, LAST_CHILD, NEXT_SIBLING
or PREV_SIBLING
start -- Boolean
position -- int
Source code in odfdo/element.py
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | |
is_empty
is_empty() -> bool
Check if the element is empty : no text, no children, no tail.
Returns: Boolean
Source code in odfdo/element.py
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | |
match
match(pattern: str) -> bool
Return True if the pattern is found one or more times anywhere in the text content of the element.
Python regular expression syntax applies.
Args:
pattern -- str
Returns: bool
Source code in odfdo/element.py
949 950 951 952 953 954 955 956 957 958 959 960 961 | |
replace
replace(
pattern: str,
new: str | None = None,
formatted: bool = False,
) -> int
Replace the pattern with the given text, or delete if text is an empty string, and return the number of replacements. By default, only return the number of occurrences that would be replaced.
It cannot replace patterns found across several element, like a word split into two consecutive spans.
Python regular expression syntax applies.
If formatted is True, and the target is a Paragraph, Span or Header, and the replacement text contains spaces, tabs or newlines, try to convert them into actual ODF elements to obtain a formatted result. On very complex contents, result may differ of expectations.
Args:
pattern -- str
new -- str
formatted -- bool
Returns: int
Source code in odfdo/element.py
963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | |
replace_element
Replaces in place a sub element with the element passed as second argument.
Warning : no clone for old element.
Source code in odfdo/element.py
1244 1245 1246 1247 1248 1249 1250 1251 | |
search
search(pattern: str) -> int | None
Return the first position of the pattern in the text content of the element, or None if not found.
Python regular expression syntax applies.
Args:
pattern -- str
Returns: int or None
Source code in odfdo/element.py
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | |
search_all
search_all(pattern: str) -> list[tuple[int, int]]
Return all start and end positions of the regex pattern in the text content of the element.
Result is a list of tuples of start and end position of the matches. Python regular expression syntax applies.
Args:
pattern -- str
Returns: list[tuple[int,int]]
Source code in odfdo/element.py
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | |
search_first
search_first(pattern: str) -> tuple[int, int] | None
Return the start and end position of the first occurrence of the regex pattern in the text content of the element.
Result is tuples of start and end position, or None. Python regular expression syntax applies.
Args:
pattern -- str
Returns: tuple[int,int] or None
Source code in odfdo/element.py
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 | |
serialize
serialize(
pretty: bool = False, with_ns: bool = False
) -> str
Return text serialization of XML element.
Source code in odfdo/element.py
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 | |
set_attribute
set_attribute(
name: str,
value: bool | str | tuple[int, int, int] | None,
) -> None
Source code in odfdo/element.py
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 | |
set_style_attribute
set_style_attribute(
name: str, value: Style | str | None
) -> None
Shortcut to accept a style object as a value.
Source code in odfdo/element.py
818 819 820 821 822 | |
text_at
text_at(start: int, end: int | None = None) -> str
Return the text (recursive) content of the element between start and end position.
If the end parameter is not set, return from start to the end of the recursive text.
Args:
start -- int
end -- int or None
Returns: str
Source code in odfdo/element.py
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | |
xpath
Apply XPath query to the element and its subtree.
Return list of Element or EText instances.
Source code in odfdo/element.py
1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | |
ElementTyped
Bases: Element
Subclass of Element for classes managing typed values.
Methods:
| Name | Description |
|---|---|
get_value |
Return Python typed value. |
set_value_and_type |
|
Source code in odfdo/element_typed.py
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 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
get_value
get_value(
value_type: str | None = None,
try_get_text: bool = True,
get_type: bool = False,
) -> Any | tuple[Any, str]
Return Python typed value.
Only for “with office:value-type” elements, not for meta fields.
Source code in odfdo/element_typed.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
set_value_and_type
set_value_and_type(
value: Any,
value_type: str | None = None,
text: str | None = None,
currency: str | None = None,
) -> str | None
Source code in odfdo/element_typed.py
47 48 49 50 51 52 53 54 55 56 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
EllipseShape
Bases: ShapeBase
An ellipse shape, “draw:ellipse”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a ellipse shape “draw:ellipse”. |
Source code in odfdo/shapes.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
__init__
__init__(
style: str | None = None,
text_style: str | None = None,
draw_id: str | None = None,
layer: str | None = None,
position: tuple | None = None,
size: tuple | None = None,
**kwargs: Any,
) -> None
Create a ellipse shape “draw:ellipse”.
Args:
style -- str
text_style -- str
draw_id -- str
layer -- str
position -- (str, str)
size -- (str, str)
Source code in odfdo/shapes.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
Frame
Bases: MDDrawFrame, Element, AnchorMix, PosMix, ZMix, SizeMix
ODF Frame, “draw:frame”.
Frames are not useful by themselves. Consider calling Frame.image_frame() or Frame.text_frame directly.
Methods:
| Name | Description |
|---|---|
__init__ |
ODF Frame, “draw:frame”. |
get_formatted_text |
|
get_image |
|
get_text_box |
|
image_frame |
Create a ready-to-use image, since image must be embedded in a |
set_image |
|
set_text_box |
|
text_frame |
Create a ready-to-use text box, since text box must be embedded in a |
Attributes:
| Name | Type | Description |
|---|---|---|
anchor_page |
|
|
anchor_type |
|
|
draw_id |
|
|
layer |
|
|
name |
|
|
position |
|
|
presentation_class |
|
|
presentation_style |
|
|
size |
|
|
style |
|
|
text_content |
str
|
|
z_index |
|
Source code in odfdo/frame.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
anchor_page
instance-attribute
anchor_page = anchor_page
anchor_type
instance-attribute
anchor_type = anchor_type
draw_id
instance-attribute
draw_id = draw_id
layer
instance-attribute
layer = layer
name
instance-attribute
name = name
position
instance-attribute
position = position
presentation_class
instance-attribute
presentation_class = presentation_class
presentation_style
instance-attribute
presentation_style = presentation_style
size
instance-attribute
size = size
style
instance-attribute
style = style
text_content
property
writable
text_content: str
z_index
instance-attribute
z_index = z_index
__init__
__init__(
name: str | None = None,
draw_id: str | None = None,
style: str | None = None,
position: tuple | None = None,
size: tuple = ("1cm", "1cm"),
z_index: int = 0,
presentation_class: str | None = None,
anchor_type: str | None = None,
anchor_page: int | None = None,
layer: str | None = None,
presentation_style: str | None = None,
**kwargs: Any,
) -> None
ODF Frame, “draw:frame”.
Frames are not useful by themselves. Consider calling Frame.image_frame() or Frame.text_frame directly.
Create a frame element of the given size. Position is relative to the context the frame is inserted in. If positioned by page, give the page number and the x, y position.
Size is a (width, height) tuple and position is a (left, top) tuple; items are strings including the unit, e.g. (‘10cm’, ‘15cm’).
Frames are not useful by themselves. You should consider calling: Frame.image_frame() or Frame.text_frame()
Args:
name -- str
draw_id -- str
style -- str
position -- (str, str)
size -- (str, str)
z_index -- int (default 0)
presentation_class -- str
anchor_type -- 'page', 'frame', 'paragraph', 'char' or 'as-char'
anchor_page -- int, page number is anchor_type is 'page'
layer -- str
presentation_style -- str
Source code in odfdo/frame.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
get_formatted_text
get_formatted_text(context: dict | None = None) -> str
Source code in odfdo/frame.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
get_image
get_image(
position: int = 0,
name: str | None = None,
url: str | None = None,
content: str | None = None,
) -> DrawImage | None
Source code in odfdo/frame.py
392 393 394 395 396 397 398 399 | |
get_text_box
get_text_box() -> Element | None
Source code in odfdo/frame.py
419 420 | |
image_frame
classmethod
image_frame(
image: DrawImage | str,
text: str | None = None,
name: str | None = None,
draw_id: str | None = None,
style: str | None = None,
position: tuple | None = None,
size: tuple = ("1cm", "1cm"),
z_index: int = 0,
presentation_class: str | None = None,
anchor_type: str | None = None,
anchor_page: int | None = None,
layer: str | None = None,
presentation_style: str | None = None,
**kwargs: Any,
) -> Element
Create a ready-to-use image, since image must be embedded in a frame.
The optional text will appear above the image.
Args:
image -- DrawImage or str, DrawImage element or URL of the image
text -- str, text for the image
See Frame() initialization for the other arguments
Returns: Frame
Source code in odfdo/frame.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
set_image
Source code in odfdo/frame.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | |
set_text_box
set_text_box(
text_or_element: Iterable[Element | str]
| Element
| str,
text_style: str | None = None,
) -> Element
Source code in odfdo/frame.py
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
text_frame
classmethod
text_frame(
text_or_element: Iterable[Element] | Element | str,
text_style: str | None = None,
name: str | None = None,
draw_id: str | None = None,
style: str | None = None,
position: tuple | None = None,
size: tuple = ("1cm", "1cm"),
z_index: int = 0,
presentation_class: str | None = None,
anchor_type: str | None = None,
anchor_page: int | None = None,
layer: str | None = None,
presentation_style: str | None = None,
**kwargs: Any,
) -> Element
Create a ready-to-use text box, since text box must be embedded in a frame.
The optional text will appear above the image.
Args:
text_or_element -- str or Element, or list of them, text content
of the text box.
text_style -- str, name of the style for the text
See Frame() initialization for the other arguments
Returns: Frame
Source code in odfdo/frame.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
Header
Bases: Paragraph, MDHeader
A title, a specialized paragraph, “text:h”.
Methods:
| Name | Description |
|---|---|
__init__ |
A title, a specialized paragraph, “text:h”. |
get_formatted_text |
|
Attributes:
| Name | Type | Description |
|---|---|---|
level |
|
|
restart_numbering |
|
|
start_value |
|
|
suppress_numbering |
|
|
text |
|
Source code in odfdo/header.py
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 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
level
instance-attribute
level = int(level)
restart_numbering
instance-attribute
restart_numbering = True
start_value
instance-attribute
start_value = start_value
suppress_numbering
instance-attribute
suppress_numbering = True
text
instance-attribute
text = ''
__init__
__init__(
level: int = 1,
text: str | None = None,
restart_numbering: bool = False,
start_value: int | None = None,
suppress_numbering: bool = False,
style: str | None = None,
formatted: bool = True,
**kwargs: Any,
) -> None
A title, a specialized paragraph, “text:h”.
Create a header element of the given style and level, containing the optional given text.
Level count begins at 1.
If “formatted” is True (the default), the given text is appended with
Args:
level -- int
text -- str
restart_numbering -- bool
start_value -- int
style -- str
formatted -- bool
Source code in odfdo/header.py
44 45 46 47 48 49 50 51 52 53 54 55 56 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 | |
get_formatted_text
get_formatted_text(
context: dict | None = None, simple: bool = False
) -> str
Source code in odfdo/header.py
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 129 130 131 132 | |
HeaderRows
Bases: Element
A header row of a table, “table:table-header-rows”.
Source code in odfdo/header_rows.py
31 32 33 34 | |
Image
Bases: Body
Root of the Image document content, “office:image”.
Source code in odfdo/body.py
251 252 253 254 255 | |
IndexTitle
Bases: Element
The title of an index, “text:index-title”.
The element has the following attributes: text:name, text:protected, text:protection-key, text:protection-key-digest-algorithm, text:style-name, xml:id.
The actual title is stored in a child element
Methods:
| Name | Description |
|---|---|
__init__ |
Create title of an index “text:index-title”. |
set_title_text |
|
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
|
style |
|
|
xml_id |
|
Source code in odfdo/toc.py
44 45 46 47 48 49 50 51 52 53 54 55 56 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 | |
name
instance-attribute
name = name
style
instance-attribute
style = style
xml_id
instance-attribute
xml_id = xml_id
__init__
__init__(
name: str | None = None,
style: str | None = None,
title_text: str | None = None,
title_text_style: str | None = None,
xml_id: str | None = None,
**kwargs: Any,
) -> None
Create title of an index “text:index-title”.
The element has the following attributes: text:name, text:protected, text:protection-key, text:protection-key-digest-algorithm, text:style-name, xml:id.
The actual title is stored in a child element
Source code in odfdo/toc.py
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 | |
set_title_text
set_title_text(
title_text: str, title_text_style: str | None = None
) -> None
Source code in odfdo/toc.py
94 95 96 97 98 99 100 | |
IndexTitleTemplate
Bases: Element
Template style for title, “text:index-title-template”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create template style for title “text:index-title-template”. |
Attributes:
| Name | Type | Description |
|---|---|---|
style |
|
Source code in odfdo/toc.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
style
instance-attribute
style = style
__init__
__init__(style: str | None = None, **kwargs: Any) -> None
Create template style for title “text:index-title-template”.
Args:
style -- str
Source code in odfdo/toc.py
477 478 479 480 481 482 483 484 485 486 | |
LineBreak
Bases: MDLineBreak, Element
Representation of a line break, “text:line-break”.
Methods:
| Name | Description |
|---|---|
__init__ |
Representation of a line break, “text:line-break”. |
Attributes:
| Name | Type | Description |
|---|---|---|
text |
str
|
Get / set the string (line break). |
Source code in odfdo/line_break.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
text
property
writable
text: str
Get / set the string (line break).
__init__
__init__(**kwargs: Any) -> None
Representation of a line break, “text:line-break”.
Source code in odfdo/line_break.py
39 40 41 | |
LineShape
Bases: ShapeBase
A line shape, “draw:line”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a line shape “draw:line”. |
Attributes:
| Name | Type | Description |
|---|---|---|
x1 |
|
|
x2 |
|
|
y1 |
|
|
y2 |
|
Source code in odfdo/shapes.py
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 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
x1
instance-attribute
x1 = p1[0]
x2
instance-attribute
x2 = p2[0]
y1
instance-attribute
y1 = p1[1]
y2
instance-attribute
y2 = p2[1]
__init__
__init__(
style: str | None = None,
text_style: str | None = None,
draw_id: str | None = None,
layer: str | None = None,
p1: tuple | None = None,
p2: tuple | None = None,
**kwargs: Any,
) -> None
Create a line shape “draw:line”.
Args:
style -- str
text_style -- str
draw_id -- str
layer -- str
p1 -- (str, str)
p2 -- (str, str)
Source code in odfdo/shapes.py
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 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
Link
Bases: MDLink, ParaFormattedTextMixin, Element
Representation of a link (URL), “text:a”.
Methods:
| Name | Description |
|---|---|
__init__ |
Representation of a link (URL), “text:a”. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
|
show |
|
|
style |
|
|
target_frame |
|
|
text |
|
|
title |
|
|
url |
|
|
visited_style |
|
Source code in odfdo/link.py
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 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 | |
name
instance-attribute
name = name
show
instance-attribute
show = 'new'
style
instance-attribute
style = style
target_frame
instance-attribute
target_frame = target_frame
text
instance-attribute
text = text
title
instance-attribute
title = title
url
instance-attribute
url = url
visited_style
instance-attribute
visited_style = visited_style
__init__
__init__(
url: str | None = "",
name: str | None = None,
title: str | None = None,
text: str | None = None,
target_frame: str | None = None,
style: str | None = None,
visited_style: str | None = None,
**kwargs: Any,
) -> None
Representation of a link (URL), “text:a”.
Args:
url -- str
name -- str
title -- str
text -- str
target_frame -- '_self', '_blank', '_parent', '_top'
style -- str
visited_style -- str
Source code in odfdo/link.py
47 48 49 50 51 52 53 54 55 56 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 | |
List
Bases: MDList, Element
A list of elements, “text:list”.
Methods:
| Name | Description |
|---|---|
__init__ |
A list of elements, “text:list”. |
append_item |
|
get_formatted_text |
|
get_item |
Return the list item that matches the criteria. In nested lists, |
get_items |
Return all the list items that match the criteria. |
insert_item |
|
set_list_header |
|
Attributes:
| Name | Type | Description |
|---|---|---|
style |
|
Source code in odfdo/list.py
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
style
instance-attribute
style = style
__init__
__init__(
list_content: str
| Element
| Iterable[str | Element]
| None = None,
style: str | None = None,
**kwargs: Any,
) -> None
A list of elements, “text:list”.
Create a list element, optionally loading the list by a list of item (str or elements).
The list_content argument is just a shortcut for the most common case. To create more complex lists, first create an empty list, and fill it afterwards.
Args:
list_content -- str or Element, or a list of str or Element
style -- str
Source code in odfdo/list.py
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 | |
append_item
Source code in odfdo/list.py
187 188 189 190 191 192 193 | |
get_formatted_text
get_formatted_text(context: dict | None = None) -> str
Source code in odfdo/list.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
get_item
get_item(
position: int = 0, content: str | None = None
) -> Element | None
Return the list item that matches the criteria. In nested lists, return the list item that really contains that content.
Args:
position -- int
content -- str regex
Returns: Element or None if not found
Source code in odfdo/list.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
get_items
get_items(content: str | None = None) -> list[Element]
Return all the list items that match the criteria.
Args:
style -- str
content -- str regex
Returns: list of Element
Source code in odfdo/list.py
112 113 114 115 116 117 118 119 120 121 122 123 | |
insert_item
insert_item(
item: ListItem | str | Element | None,
position: int | None = None,
before: Element | None = None,
after: Element | None = None,
) -> None
Source code in odfdo/list.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |
set_list_header
Source code in odfdo/list.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
ListItem
Bases: MDListItem, Element
An item of a list, “text:list-item”.
Methods:
| Name | Description |
|---|---|
__init__ |
An item of a list, “text:list-item”. |
Attributes:
| Name | Type | Description |
|---|---|---|
text_content |
|
Source code in odfdo/list.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
text_content
instance-attribute
text_content = text_or_element
__init__
__init__(
text_or_element: str | Element | None = None,
**kwargs: Any,
) -> None
An item of a list, “text:list-item”.
Create a list item element, optionally passing at creation time a string or Element as content.
Args:
text_or_element -- str or ODF Element
Source code in odfdo/list.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
Manifest
Bases: XmlPart
Representation of the “manifest.xml” part.
Methods:
| Name | Description |
|---|---|
add_full_path |
|
del_full_path |
|
get_media_type |
Get the media type of an existing path. |
get_path_medias |
Return the list of (full_path, media_type) pairs in the manifest. |
get_paths |
Return the list of full paths in the manifest. |
make_file_entry |
|
set_media_type |
Set the media type of an existing path. |
Source code in odfdo/manifest.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 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 | |
add_full_path
add_full_path(full_path: str, media_type: str = '') -> None
Source code in odfdo/manifest.py
103 104 105 106 107 108 109 | |
del_full_path
del_full_path(full_path: str) -> None
Source code in odfdo/manifest.py
111 112 113 | |
get_media_type
get_media_type(full_path: str) -> str | None
Get the media type of an existing path.
Returns: str
Source code in odfdo/manifest.py
68 69 70 71 72 73 74 75 76 77 78 79 80 | |
get_path_medias
get_path_medias() -> list[tuple]
Return the list of (full_path, media_type) pairs in the manifest.
Returns: list of str tuples
Source code in odfdo/manifest.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
get_paths
Return the list of full paths in the manifest.
Returns: list of str
Source code in odfdo/manifest.py
33 34 35 36 37 38 39 | |
make_file_entry
staticmethod
make_file_entry(full_path: str, media_type: str) -> Element
Source code in odfdo/manifest.py
94 95 96 97 98 99 100 101 | |
set_media_type
set_media_type(full_path: str, media_type: str) -> None
Set the media type of an existing path.
Args:
full_path -- str
media_type -- str
Source code in odfdo/manifest.py
82 83 84 85 86 87 88 89 90 91 92 | |
Meta
Bases: XmlPart, DcCreatorMixin, DcDateMixin
Representation of the “meta.xml” part.
Methods:
| Name | Description |
|---|---|
__init__ |
Create the Meta XML part. |
as_dict |
Return the metadata of the document as a Python dict. |
as_json |
Return the metadata of the document as a JSON string. |
as_text |
Return meta information as text, with some formatting for |
clear_user_defined_metadata |
Remove all user-defined metadata. |
delete_user_defined_metadata_of_name |
Delete the user-defined metadata of that name. |
from_dict |
Set the metadata of the document from a Python dict. |
get_auto_reload |
Get the MetaAutoReload “meta:auto-reload” element or None. |
get_creation_date |
Get the creation date of the document. |
get_description |
Get the description of the document. Also known as comments. |
get_editing_cycles |
Get the number of times the document was edited, as reported by the |
get_editing_duration |
Get the time the document was edited, as reported by the generator. |
get_generator |
Get the signature of the software that generated this document. |
get_hyperlink_behaviour |
Get the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element or |
get_initial_creator |
Get the first creator of the document. |
get_keywords |
Get the keywords of the document. Return the field as-is, without |
get_language |
Get the default language of the document BUT only from the metadata, |
get_statistic |
Get the statistics about a document, “meta:document-statistic” tag. |
get_subject |
Get the subject of the document. |
get_template |
Get the MetaTemplate “meta:template” element or None. |
get_title |
Get the title of the document. |
get_user_defined_metadata |
Get all additional user-defined metadata for a document. |
get_user_defined_metadata_of_name |
Return the content of the user defined metadata of that name. Return |
set_auto_reload |
Set the MetaAutoReload “meta:auto-reload” element. |
set_creation_date |
Set the creation date of the document. |
set_description |
Set the description of the document. Also known as comments. |
set_editing_cycles |
Set the number of times the document was edited. |
set_editing_duration |
Set the time the document was edited. |
set_generator |
Set the signature of the software that generated this document. |
set_generator_default |
Set the signature of the software that generated this document to |
set_hyperlink_behaviour |
Set the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” |
set_initial_creator |
Set the first creator of the document. |
set_keywords |
Set the keywords of the document. Although the name is plural, a str |
set_language |
Set the default language of the document BUT only in the metadata, |
set_statistic |
Set the statistics about a document, “meta:document-statistic” tag. |
set_subject |
Set the subject of the document. |
set_template |
Set the MetaTemplate “meta:template” element. |
set_title |
Set the title of the document. |
set_user_defined_metadata |
Set a user defined metadata of that name and value. |
strip |
Strip metadata to their minimal content. |
Attributes:
| Name | Type | Description |
|---|---|---|
auto_reload |
MetaAutoReload | None
|
Get the MetaAutoReload “meta:auto-reload” element or None. |
creation_date |
datetime | None
|
Get or set the date and time when a document was created |
description |
str | None
|
Get or set the description of a document |
editing_cycles |
int | None
|
Get or set the number of times a document has been edited |
editing_duration |
timedelta | None
|
Get or set the total time spent editing a document <meta:editing- |
generator |
str | None
|
Get or set the signature of the software that generated this |
get_comments |
|
|
get_meta_body |
|
|
hyperlink_behaviour |
MetaHyperlinkBehaviour | None
|
Get the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element or |
initial_creator |
str | None
|
Get or set the initial creator of a document |
keyword |
str | None
|
Get or set some keyword(s) keyword pertaining to a document |
keywords |
|
|
language |
str | None
|
Get or set the default language of the document BUT only in the |
meta_body |
Metadata
|
Return the body of the “meta.xml” part. |
odf_office_version |
str
|
Return the “office:version” value of the document. |
print_date |
datetime | None
|
Get or set the date and time when a document when a document was |
printed_by |
str | None
|
Get or set the name of the last person who printed a document. |
set_comments |
|
|
statistic |
dict[str, int] | None
|
Get or set the statistics about a document, “meta:document- |
subject |
str | None
|
Get or set the subject of a document |
template |
MetaTemplate | None
|
Get the MetaTemplate “meta:template” element or None. |
title |
str | None
|
Get or set the title of the document |
user_defined_metadata |
dict[str, Any]
|
Get or set all additional user-defined metadata for a document. |
Source code in odfdo/meta.py
51 52 53 54 55 56 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 | |
auto_reload
property
auto_reload: MetaAutoReload | None
Get the MetaAutoReload “meta:auto-reload” element or None.
creation_date
property
writable
creation_date: datetime | None
Get or set the date and time when a document was created
If provided datetime is None, use current time.
Returns: datetime (or None if inexistent)
description
property
writable
description: str | None
Get or set the description of a document
Returns: str (or None if inexistent)
editing_cycles
property
writable
editing_cycles: int | None
Get or set the number of times a document has been edited
When a document is created, this value is set to 1. Each time a document is saved, the editing-cycles number is incremented by 1.
Returns: int (or None if inexistent)
editing_duration
property
writable
editing_duration: timedelta | None
Get or set the total time spent editing a document
Returns: timedelta (or None if inexistent)
generator
property
writable
generator: str | None
Get or set the signature of the software that generated this document.
Returns: str (or None if inexistent)
Example::
>>> document.meta.generator
KOffice/2.0.0
>>> document.meta.generator = "Odfdo experiment"
get_meta_body
class-attribute
instance-attribute
get_meta_body = _get_body
hyperlink_behaviour
property
hyperlink_behaviour: MetaHyperlinkBehaviour | None
Get the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element or None.
initial_creator
property
writable
initial_creator: str | None
Get or set the initial creator of a document
Returns: str (or None if inexistent)
keyword
property
writable
keyword: str | None
Get or set some keyword(s) keyword pertaining to a document
Returns: str (or None if inexistent)
language
property
writable
language: str | None
Get or set the default language of the document BUT only in the metadata, “dc:language”.
To set globally the default language, prefer the Document.language property.
Returns: str (or None if inexistent)
odf_office_version
property
odf_office_version: str
Return the “office:version” value of the document.
print_date
property
writable
print_date: datetime | None
Get or set the date and time when a document when a document was
last printed
If provided datetime is None, use current time.
Returns: datetime (or None if inexistent)
printed_by
property
writable
printed_by: str | None
Get or set the name of the last person who printed a document.
Returns: str (or None if inexistent)
statistic
property
writable
statistic: dict[str, int] | None
Get or set the statistics about a document, “meta:document- statistic” tag.
Returns: dict (or None if inexistent)
Example::
>>> document.get_statistic():
{'meta:table-count': 1,
'meta:image-count': 2,
'meta:object-count': 3,
'meta:page-count': 4,
'meta:paragraph-count': 5,
'meta:word-count': 6,
'meta:character-count': 7,
'meta:non-whitespace-character-count':3}
subject
property
writable
subject: str | None
Get or set the subject of a document
Returns: str (or None if inexistent)
template
property
template: MetaTemplate | None
Get the MetaTemplate “meta:template” element or None.
title
property
writable
title: str | None
Get or set the title of the document
Returns: str (or None if inexistent)
user_defined_metadata
property
writable
user_defined_metadata: dict[str, Any]
Get or set all additional user-defined metadata for a document.
Return a dict of str/value mapping.
Value types can be: Decimal, date, time, boolean or str.
__init__
__init__(*args: Any, **kwargs: Any) -> None
Create the Meta XML part.
Source code in odfdo/meta.py
54 55 56 57 | |
as_dict
as_dict(full: bool = False) -> dict[str, Any]
Return the metadata of the document as a Python dict.
if ‘full’ is True, export also the keys with no value assigned.
Args:
full -- boolean
Source code in odfdo/meta.py
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 | |
as_json
as_json(full: bool = False) -> str
Return the metadata of the document as a JSON string.
if ‘full’ is True, export also the keys with no value assigned.
Args:
full -- boolean
Source code in odfdo/meta.py
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 | |
as_text
as_text(no_user_defined_msg: str = '') -> str
Return meta information as text, with some formatting for printing.
Source code in odfdo/meta.py
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 | |
clear_user_defined_metadata
clear_user_defined_metadata() -> None
Remove all user-defined metadata.
Source code in odfdo/meta.py
803 804 805 806 807 808 809 810 | |
delete_user_defined_metadata_of_name
delete_user_defined_metadata_of_name(name: str) -> None
Delete the user-defined metadata of that name.
Args:
name -- string, name (meta:name content)
Source code in odfdo/meta.py
898 899 900 901 902 903 904 905 906 907 | |
from_dict
from_dict(data: dict[str, Any]) -> None
Set the metadata of the document from a Python dict.
The loaded metadata are merged with the existing metadata. If the new value of a key is None: - meta:creation-date: use current time, - dc:date: use creation date, - meta:editing-duration: set to zero, - meta:editing-cycles: set to 1, - meta:generator: use odfdo generator string. Other keys (not mandatory keys): remove key/value pair from metadata.
Args:
data -- dict of metadata.
Source code in odfdo/meta.py
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 | |
get_auto_reload
get_auto_reload() -> MetaAutoReload | None
Get the MetaAutoReload “meta:auto-reload” element or None.
Source code in odfdo/meta.py
363 364 365 366 | |
get_creation_date
get_creation_date() -> datetime | None
Get the creation date of the document.
(Also available as “self.creation_date” property.)
Returns: datetime (or None if inexistent)
Source code in odfdo/meta.py
268 269 270 271 272 273 274 275 276 277 278 279 | |
get_description
get_description() -> str | None
Get the description of the document. Also known as comments.
(Also available as “self.description” property.)
Returns: str (or None if inexistent)
Source code in odfdo/meta.py
121 122 123 124 125 126 127 128 129 130 131 | |
get_editing_cycles
get_editing_cycles() -> int | None
Get the number of times the document was edited, as reported by the generator.
(Also available as “self.editing_cycles” property.)
Returns: int (or None if inexistent)
Source code in odfdo/meta.py
568 569 570 571 572 573 574 575 576 577 578 579 580 | |
get_editing_duration
get_editing_duration() -> timedelta | None
Get the time the document was edited, as reported by the generator.
(Also available as “self.editing_duration” property.)
Returns: timedelta (or None if inexistent)
Source code in odfdo/meta.py
525 526 527 528 529 530 531 532 533 534 535 536 | |
get_generator
get_generator() -> str | None
Get the signature of the software that generated this document.
(Also available as “self.generator” property.)
Returns: str (or None if inexistent)
Example::
>>> document.meta.get_generator()
KOffice/2.0.0
Source code in odfdo/meta.py
644 645 646 647 648 649 650 651 652 653 654 655 656 | |
get_hyperlink_behaviour
get_hyperlink_behaviour() -> MetaHyperlinkBehaviour | None
Get the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element or None.
Source code in odfdo/meta.py
381 382 383 384 385 386 387 388 | |
get_initial_creator
get_initial_creator() -> str | None
Get the first creator of the document.
(Also available as “self.initial_creator” property.)
Returns: str (or None if inexistent)
Example::
>>> document.meta.get_initial_creator()
Unknown
Source code in odfdo/meta.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
get_keywords
get_keywords() -> str | None
Get the keywords of the document. Return the field as-is, without any assumption on the keyword separator.
(Also available as “self.keyword” and “self.keywords” property.)
Returns: str (or None if inexistent)
Source code in odfdo/meta.py
481 482 483 484 485 486 487 488 489 490 491 492 | |
get_language
get_language() -> str | None
Get the default language of the document BUT only from the metadata, “dc:language”.
Prefer the Document.get_language() function.
(Also available as “self.language” property.)
Returns: str (or None if inexistent)
Example::
>>> document.meta.get_language()
fr-FR
Source code in odfdo/meta.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
get_statistic
get_statistic() -> dict[str, int] | None
Get the statistics about a document, “meta:document-statistic” tag.
(Also available as “self.statistic” property.)
Returns: dict (or None if inexistent)
Example::
>>> document.get_statistic():
{'meta:table-count': 1,
'meta:image-count': 2,
'meta:object-count': 3,
'meta:page-count': 4,
'meta:paragraph-count': 5,
'meta:word-count': 6,
'meta:character-count': 7,
'meta:non-whitespace-character-count': 3}
Source code in odfdo/meta.py
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | |
get_subject
get_subject() -> str | None
Get the subject of the document.
(Also available as “self.subject” property.)
Returns: str (or None if inexistent)
Source code in odfdo/meta.py
165 166 167 168 169 170 171 172 173 174 175 | |
get_template
get_template() -> MetaTemplate | None
Get the MetaTemplate “meta:template” element or None.
Source code in odfdo/meta.py
340 341 342 343 | |
get_title
get_title() -> str | None
Get the title of the document.
This is not the first heading but the title metadata.
(Also available as “self.title” property.)
Returns: str (or None if inexistent)
Source code in odfdo/meta.py
78 79 80 81 82 83 84 85 86 87 88 89 90 | |
get_user_defined_metadata
get_user_defined_metadata() -> dict[str, Any]
Get all additional user-defined metadata for a document.
(Also available as “self.user_defined_metadata” property.)
Return a dict of str/value mapping.
Value types can be: Decimal, date, time, boolean or str.
Source code in odfdo/meta.py
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 | |
get_user_defined_metadata_of_name
get_user_defined_metadata_of_name(
keyname: str,
) -> dict[str, Any] | None
Return the content of the user defined metadata of that name. Return None if no name matches or a dic of fields.
Args:
name -- string, name (meta:name content)
Returns: a dict with keys “name”, “value”, “value_type”, “text”.
Source code in odfdo/meta.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 | |
set_auto_reload
set_auto_reload(delay: timedelta, href: str = '') -> None
Set the MetaAutoReload “meta:auto-reload” element.
Source code in odfdo/meta.py
373 374 375 376 377 378 379 | |
set_creation_date
set_creation_date(date: datetime | None = None) -> None
Set the creation date of the document.
If provided datetime is None, use current time.
(Also available as “self.creation_date” property.)
Args:
date -- datetime
Source code in odfdo/meta.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
set_description
set_description(description: str) -> None
Set the description of the document. Also known as comments.
(Also available as “self.description” property.)
Args:
description -- str
Source code in odfdo/meta.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
set_editing_cycles
set_editing_cycles(cycles: int) -> None
Set the number of times the document was edited.
(Also available as “self.editing_cycles” property.)
Args:
cycles -- int
Source code in odfdo/meta.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | |
set_editing_duration
set_editing_duration(duration: timedelta) -> None
Set the time the document was edited.
(Also available as “self.editing_duration” property.)
Args:
duration -- timedelta
Source code in odfdo/meta.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | |
set_generator
set_generator(generator: str) -> None
Set the signature of the software that generated this document.
(Also available as “self.generator” property.)
Args:
generator -- str
Example::
>>> document.meta.set_generator("Odfdo experiment")
Source code in odfdo/meta.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |
set_generator_default
set_generator_default() -> None
Set the signature of the software that generated this document to ourself.
Example::
>>> document.meta.set_generator_default()
Source code in odfdo/meta.py
673 674 675 676 677 678 679 680 681 682 | |
set_hyperlink_behaviour
set_hyperlink_behaviour(
target_frame_name: str = "_blank", show: str = "replace"
) -> None
Set the MetaHyperlinkBehaviour “meta:hyperlink-behaviour” element.
Source code in odfdo/meta.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
set_initial_creator
set_initial_creator(creator: str) -> None
Set the first creator of the document.
(Also available as “self.initial_creator” property.)
Args:
creator -- str
Example::
>>> document.meta.set_initial_creator("Plato")
Source code in odfdo/meta.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | |
set_keywords
set_keywords(keywords: str) -> None
Set the keywords of the document. Although the name is plural, a str string is required, so join your list first.
(Also available as “self.keyword” and “self.keywords” property.)
Args:
keywords -- str
Source code in odfdo/meta.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
set_language
set_language(language: str) -> None
Set the default language of the document BUT only in the metadata, “dc:language”.
To set globally the default language, prefer the Document.set_language() function.
(Also available as “self.language” property.)
Args:
language -- str
Example::
>>> document.meta.set_language('fr-FR')
Source code in odfdo/meta.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
set_statistic
set_statistic(statistic: dict[str, int]) -> None
Set the statistics about a document, “meta:document-statistic” tag.
(Also available as “self.statistic” property.)
Args:
statistic -- dict
Example::
>>> statistic = {'meta:table-count': 1,
'meta:image-count': 2,
'meta:object-count': 3,
'meta:page-count': 4,
'meta:paragraph-count': 5,
'meta:word-count': 6,
'meta:character-count': 7,
'meta:non-whitespace-character-count': 3}
>>> document.meta.set_statistic(statistic)
Source code in odfdo/meta.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 | |
set_subject
set_subject(subject: str) -> None
Set the subject of the document.
(Also available as “self.subject” property.)
Args:
subject -- str
Source code in odfdo/meta.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
set_template
set_template(
date: datetime | None = None,
href: str = "",
title: str = "",
) -> None
Set the MetaTemplate “meta:template” element.
Source code in odfdo/meta.py
350 351 352 353 354 355 356 357 358 359 360 361 | |
set_title
set_title(title: str) -> None
Set the title of the document.
This is not the first heading but the title metadata.
(Also available as “self.title” property.)
Args:
title -- str
Source code in odfdo/meta.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
set_user_defined_metadata
set_user_defined_metadata(name: str, value: Any) -> None
Set a user defined metadata of that name and value.
If value is None, any existing metadata of that name is deleted.
Args:
name -- string, name (meta:name content)
value -- Decimal, date, time, boolean, str, None for deletion.
Source code in odfdo/meta.py
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 | |
strip
strip(
generator: str = GENERATOR,
creation_date: datetime | None = None,
) -> None
Strip metadata to their minimal content.
All user defined metadata are removed.
Args:
generator -- str, string for the meta:generator field.
creation_date -- datetime or None, meta:creation-date value.
Source code in odfdo/meta.py
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 | |
MetaAutoReload
Bases: Element
Container for auto-reload properties, “meta:auto-reload”.
Methods:
| Name | Description |
|---|---|
__init__ |
Container for auto-reload properties, “meta:auto-reload”. |
as_dict |
Return the MetaAutoReload attributes as a Python dict. |
from_dict |
Set all the MetaAutoReload attributes from a Python dict. |
Attributes:
| Name | Type | Description |
|---|---|---|
actuate |
|
|
href |
|
|
show |
|
|
type |
|
Source code in odfdo/meta_auto_reload.py
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 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 | |
actuate
instance-attribute
actuate = 'onLoad'
href
instance-attribute
href = href
show
instance-attribute
show = 'replace'
type
instance-attribute
type = 'simple'
__init__
__init__(
delay: timedelta | None = None,
href: str = "",
**kwargs: Any,
) -> None
Container for auto-reload properties, “meta:auto-reload”.
The
Args:
delay -- timedelta | None
href -- str
Source code in odfdo/meta_auto_reload.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
as_dict
as_dict() -> dict[str, Any]
Return the MetaAutoReload attributes as a Python dict.
Source code in odfdo/meta_auto_reload.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
from_dict
from_dict(data: dict[str, Any]) -> None
Set all the MetaAutoReload attributes from a Python dict.
Source code in odfdo/meta_auto_reload.py
104 105 106 107 108 109 110 | |
MetaHyperlinkBehaviour
Bases: Element
Container for hyperlink-behaviour properties, “meta:hyperlink- behaviour”.
Methods:
| Name | Description |
|---|---|
__init__ |
Container for hyperlink-behaviour properties, “meta:hyperlink- |
as_dict |
Return the MetaHyperlinkBehaviour attributes as a Python dict. |
from_dict |
Set all the MetaHyperlinkBehaviour attributes from a Python dict. |
Attributes:
| Name | Type | Description |
|---|---|---|
show |
|
|
target_frame_name |
|
Source code in odfdo/meta_hyperlink_behaviour.py
29 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
show
instance-attribute
show = show
target_frame_name
instance-attribute
target_frame_name = target_frame_name
__init__
__init__(
target_frame_name: str = "_blank",
show: str = "replace",
**kwargs: Any,
) -> None
Container for hyperlink-behaviour properties, “meta:hyperlink- behaviour”.
The “meta:hyperlink-behaviour” element specifies the default behavior for hyperlinks in a document.
Args:
target_frame_name -- str
show -- str
Source code in odfdo/meta_hyperlink_behaviour.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
as_dict
as_dict() -> dict[str, Any]
Return the MetaHyperlinkBehaviour attributes as a Python dict.
Source code in odfdo/meta_hyperlink_behaviour.py
73 74 75 76 77 78 | |
from_dict
from_dict(data: dict[str, Any]) -> None
Set all the MetaHyperlinkBehaviour attributes from a Python dict.
Source code in odfdo/meta_hyperlink_behaviour.py
80 81 82 83 | |
MetaTemplate
Bases: Element
Container for the meta template properties, “meta:template”.
Methods:
| Name | Description |
|---|---|
__init__ |
Container for the meta template properties, “meta:template”. |
as_dict |
Return the MetaTemplate attributes as a Python dict. |
from_dict |
Set all the MetaTemplate attributes from a Python dict. |
Attributes:
| Name | Type | Description |
|---|---|---|
actuate |
|
|
href |
|
|
title |
|
|
type |
|
Source code in odfdo/meta_template.py
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 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 | |
actuate
instance-attribute
actuate = 'onRequest'
href
instance-attribute
href = href
title
instance-attribute
title = title
type
instance-attribute
type = 'simple'
__init__
__init__(
date: datetime | None = None,
href: str = "",
title: str = "",
**kwargs: Any,
) -> None
Container for the meta template properties, “meta:template”.
The
Args:
date -- datetime or None
href -- str
title -- str
Source code in odfdo/meta_template.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
as_dict
as_dict() -> dict[str, Any]
Return the MetaTemplate attributes as a Python dict.
Source code in odfdo/meta_template.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
from_dict
from_dict(data: dict[str, Any]) -> None
Set all the MetaTemplate attributes from a Python dict.
Source code in odfdo/meta_template.py
101 102 103 104 105 106 107 | |
Metadata
Bases: Body
Root of the Meta document content, “office:meta”.
Source code in odfdo/body.py
279 280 281 282 283 | |
NamedRange
Bases: Element
Named range of cells in a table, “table:named-range”.
Identifies inside the spreadsheet a range of cells of a table by a name and the name of the table.
Name Ranges have the following attributes:
name -- name of the named range
table_name -- name of the table
start -- first cell of the named range, tuple (x, y)
end -- last cell of the named range, tuple (x, y)
crange -- range of the named range, tuple (x, y, z, t)
usage -- None or str, usage of the named range.
Methods:
| Name | Description |
|---|---|
__init__ |
Named range of cells in a table, “table:named-range”. |
get_value |
Shortcut to retrieve the value of the first cell of the named range. |
get_values |
Shortcut to retrieve the values of the cells of the named range. |
set_range |
Set the range of the named range. Range can be either one cell (like |
set_table_name |
Set the name of the table of the Named Range. |
set_usage |
Set the usage of the Named Range. Usage can be None (default) or one |
set_value |
Shortcut to set the value of the first cell of the named range. |
set_values |
Shortcut to set the values of the cells of the named range. |
Attributes:
| Name | Type | Description |
|---|---|---|
crange |
tuple[int, int, int, int]
|
|
end |
tuple[int, int]
|
|
name |
str | None
|
Get / set the name of the Named Range. |
start |
tuple[int, int]
|
|
table_name |
str
|
|
usage |
str | None
|
|
Source code in odfdo/named_range.py
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
crange
instance-attribute
crange: tuple[int, int, int, int] = (0, 0, 0, 0)
end
instance-attribute
end: tuple[int, int] = (0, 0)
name
property
writable
name: str | None
Get / set the name of the Named Range.
The name is mandatory, if a Named Range of the same name exists, it will be replaced. Name must contains only alphanumerics characters and ‘_’, and can not be of a cell coordinates form like ‘AB12’.
Args:
name -- str
start
instance-attribute
start: tuple[int, int] = (0, 0)
table_name
instance-attribute
table_name: str = name
usage
instance-attribute
usage: str | None = get_attribute_string(
"table:range-usable-as"
)
__init__
__init__(
name: str | None = None,
crange: str | tuple | list | None = None,
table_name: str | None = None,
usage: str | None = None,
**kwargs: Any,
) -> None
Named range of cells in a table, “table:named-range”.
Create a Named Range element. ‘name’ must contains only letters, digits and ‘_’, and must not be like a coordinate as ‘A1’. ‘table_name’ must be a correct table name (no “’” or “/” in it).
Args:
name -- str, name of the named range
crange -- str or tuple of int, cell or area coordinate
table_name -- str, name of the table
usage -- None or 'print-range', 'filter', 'repeat-column', 'repeat-row'
Source code in odfdo/named_range.py
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 129 130 131 132 133 134 | |
get_value
get_value(get_type: bool = False) -> Any
Shortcut to retrieve the value of the first cell of the named range.
See table.get_value() for the arguments description and return format.
Source code in odfdo/named_range.py
297 298 299 300 301 302 303 304 305 306 307 308 | |
get_values
get_values(
cell_type: str | None = None,
complete: bool = True,
get_type: bool = False,
flat: bool = False,
) -> list
Shortcut to retrieve the values of the cells of the named range.
See table.get_values() for the arguments description and return format.
Source code in odfdo/named_range.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
set_range
set_range(
crange: str
| tuple[int, int]
| tuple[int, int, int, int]
| list[int],
) -> None
Set the range of the named range. Range can be either one cell (like ‘A1’) or an area (‘A1:B2’). It can be provided as an alpha numeric value like “A1:B2’ or a tuple like (0, 0, 1, 1) or (0, 0).
Args:
crange -- str or tuple of int, cell or area coordinate
Source code in odfdo/named_range.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
set_table_name
set_table_name(name: str) -> None
Set the name of the table of the Named Range.
The name is mandatory.
Args:
name -- str
Source code in odfdo/named_range.py
213 214 215 216 217 218 219 220 221 222 223 | |
set_usage
set_usage(usage: str | None = None) -> None
Set the usage of the Named Range. Usage can be None (default) or one of :
- 'print-range'
- 'filter'
- 'repeat-column'
- 'repeat-row'
Args:
usage -- None or str
Source code in odfdo/named_range.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
set_value
set_value(
value: Any,
cell_type: str | None = None,
currency: str | None = None,
style: str | None = None,
) -> None
Shortcut to set the value of the first cell of the named range.
See table.set_value() for the arguments description.
Source code in odfdo/named_range.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
set_values
set_values(
values: list,
style: str | None = None,
cell_type: str | None = None,
currency: str | None = None,
) -> None
Shortcut to set the values of the cells of the named range.
See table.set_values() for the arguments description.
Source code in odfdo/named_range.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
Note
Bases: MDNote, Element
A note (footnote or endnote), “text:note”.
Either a footnote or a endnote element with the given text, optionally referencing it using the given note_id.
Methods:
| Name | Description |
|---|---|
__init__ |
A note (footnote or endnote), “text:note”. |
check_validity |
|
Attributes:
| Name | Type | Description |
|---|---|---|
NOTE_CLASS |
ClassVar
|
|
citation |
str
|
|
note_body |
str
|
|
note_class |
|
|
note_id |
|
Source code in odfdo/note.py
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 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
NOTE_CLASS
class-attribute
instance-attribute
NOTE_CLASS: ClassVar = {'footnote', 'endnote'}
citation
property
writable
citation: str
note_body
property
writable
note_body: str
note_class
instance-attribute
note_class = note_class
note_id
instance-attribute
note_id = note_id
__init__
__init__(
note_class: str = "footnote",
note_id: str | None = None,
citation: str | None = None,
body: str | None = None,
**kwargs: Any,
) -> None
A note (footnote or endnote), “text:note”.
Args:
note_class -- 'footnote' or 'endnote'
note_id -- str
citation -- str
body -- str or Element
Source code in odfdo/note.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
check_validity
check_validity() -> None
Source code in odfdo/note.py
115 116 117 118 119 120 121 122 123 | |
OfficeAutomaticStyles
Bases: Element
Container for automatic styles used in the document, “office:automatic- styles”.
An automatic style is one contains formatting properties that are considered to be properties of the object to which the style is assigned.
The “office:automatic-styles” element is usable within the following elements: “office:document”, “office:document-content” and “office:document-styles”.
The “office:automatic-styles” element has no attributes.
Source code in odfdo/style_containers.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
OfficeMasterStyles
Bases: Element
Container for master styles used in the document, “office:master- styles”.
A master style contains formatting and other content that is displayed with document content when the style is used.
The “office:master-styles” element is usable within the following elements: “office:document” and “office:document-styles”.
The “office:master-styles” element has no attributes.
Source code in odfdo/style_containers.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
ParaMixin
Bases: Element
Mixin for Paragraph methods.
Methods:
| Name | Description |
|---|---|
append |
|
append_plain_text |
Append plain text to the paragraph, replacing |
insert_annotation |
Insert an annotation, at the position defined by the regex (before, |
insert_annotation_end |
Insert an annotation end tag for an existing annotation. If some end |
insert_note |
|
insert_reference |
Create and insert a reference to a content marked by a reference |
insert_variable |
|
remove_link |
Return a copy of the element (not a clone), with the sub links |
remove_links |
Return a copy of the element, without links tags. |
remove_span |
Return a copy of the element, the spans (not a clone) removed. |
remove_spans |
Return copy of the element, without span styles. |
set_bookmark |
Insert a bookmark before or after the characters in the text which |
set_link |
Make a link to the provided url from text content matching either: |
set_reference_mark |
Insert a reference mark, at the position defined by the regex |
set_reference_mark_end |
Insert/move a ReferenceMarkEnd for an existing reference mark. If |
set_span |
Apply the given style with a Span to text content matching either: |
Source code in odfdo/mixin_paragraph.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 | |
append
append(
str_or_element: str | bytes | Element,
formatted: bool = True,
) -> None
Source code in odfdo/mixin_paragraph.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
append_plain_text
append_plain_text(text: str | bytes | None = '') -> None
Append plain text to the paragraph, replacing
Source code in odfdo/mixin_paragraph.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
insert_annotation
insert_annotation(
annotation_element: Annotation | None = None,
before: str | None = None,
after: str | Element | None = None,
position: int | tuple = 0,
content: str | Element | None = None,
body: str | None = None,
creator: str | None = None,
date: datetime | None = None,
) -> Annotation
Insert an annotation, at the position defined by the regex (before, after, content) or by positional argument (position). If content is provided, the annotation covers the full content regex. Else, the annotation is positioned either ‘before’ or ‘after’ provided regex.
If content is an odf element (ie: paragraph, span, …), the full inner content is covered by the annotation (of the position just after if content is a single empty tag).
If content/before or after exists (regex) and return a group of matching positions, the position value is the index of matching place to use.
annotation_element can contain a previously created annotation, else the annotation is created from the body, creator and optional date (current date by default).
Args:
annotation_element -- Annotation or None
before -- str regular expression or None
after -- str regular expression or Element or None
content -- str regular expression or None, or Element
position -- int or tuple of int
body -- str or Element
creator -- str
date -- datetime
Source code in odfdo/mixin_paragraph.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
insert_annotation_end
insert_annotation_end(
annotation_element: Annotation,
before: str | None = None,
after: str | None = None,
position: int = 0,
) -> AnnotationEnd
Insert an annotation end tag for an existing annotation. If some end tag already exists, replace it. Annotation end tag is set at the position defined by the regex (before or after).
If content/before or after (regex) returns a group of matching positions, the position value is the index of matching place to use.
Args:
annotation_element -- Annotation (mandatory)
before -- str regular expression or None
after -- str regular expression or None
position -- int
Source code in odfdo/mixin_paragraph.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
insert_note
insert_note(
note_element: Note | None = None,
after: str | Element | None = None,
note_class: str = "footnote",
note_id: str | None = None,
citation: str | None = None,
body: str | None = None,
) -> None
Source code in odfdo/mixin_paragraph.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
insert_reference
insert_reference(
name: str,
ref_format: str = "",
before: str | None = None,
after: str | Element | None = None,
position: int = 0,
display: str | None = None,
) -> None
Create and insert a reference to a content marked by a reference mark. The Reference element (“text:reference-ref”) represents a field that references a “text:reference-mark-start” or “text:reference-mark” element. Its “text:reference-format” attribute specifies what is displayed from the referenced element. Default is ‘page’. Actual content is not automatically updated except for the ‘text’ format.
name is mandatory and should represent an existing reference mark of the document.
ref_format is the argument for format reference (default is ‘page’).
The reference is inserted the position defined by the regex (before / after), or by positional argument (position). If ‘display’ is provided, it will be used as the text value for the reference.
If after is an ODF Element, the reference is inserted as first child of this element.
Args:
name -- str
ref_format -- one of : 'chapter', 'direction', 'page', 'text',
'caption', 'category-and-value', 'value',
'number', 'number-all-superior',
'number-no-superior'
before -- str regular expression or None
after -- str regular expression or odf element or None
position -- int
display -- str or None
Source code in odfdo/mixin_paragraph.py
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | |
insert_variable
insert_variable(
variable_element: Element, after: str | None
) -> None
Source code in odfdo/mixin_paragraph.py
666 667 | |
remove_link
Return a copy of the element (not a clone), with the sub links removed.
Args:
links -- Link or list of Link
Source code in odfdo/mixin_paragraph.py
761 762 763 764 765 766 767 768 769 | |
remove_links
remove_links() -> Element
Return a copy of the element, without links tags.
Source code in odfdo/mixin_paragraph.py
756 757 758 759 | |
remove_span
Return a copy of the element, the spans (not a clone) removed.
Args:
spans -- Element or list of Element
Source code in odfdo/mixin_paragraph.py
717 718 719 720 721 722 723 724 | |
remove_spans
remove_spans(keep_heading: bool = True) -> Element
Return copy of the element, without span styles.
If keep_heading is True (default), the first level heading style is left unchanged.
Source code in odfdo/mixin_paragraph.py
704 705 706 707 708 709 710 711 712 713 714 715 | |
set_bookmark
set_bookmark(
name: str,
before: str | None = None,
after: str | None = None,
position: int | tuple = 0,
role: str | None = None,
content: str | None = None,
) -> Element | tuple[Element, Element]
Insert a bookmark before or after the characters in the text which match the regex before/after. When the regex matches more of one part of the text, position can be set to choose which part must be used. If before and after are None, we use only position that is the number of characters.
So, by default, this function inserts a bookmark before the first character of the content. Role can be None, “start” or “end”, we insert respectively a position bookmark a bookmark-start or a bookmark-end.
If content is not None these 2 calls are equivalent:
paragraph.set_bookmark(“bookmark”, content=”xyz”)
and:
paragraph.set_bookmark(“bookmark”, before=”xyz”, role=”start”) paragraph.set_bookmark(“bookmark”, after=”xyz”, role=”end”)
If position is a 2-tuple, these 2 calls are equivalent:
paragraph.set_bookmark(“bookmark”, position=(10, 20))
and:
paragraph.set_bookmark(“bookmark”, position=10, role=”start”) paragraph.set_bookmark(“bookmark”, position=20, role=”end”)
Args:
name -- str
before -- str regex
after -- str regex
position -- int or (int, int)
role -- None, "start" or "end"
content -- str regex
Source code in odfdo/mixin_paragraph.py
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 | |
set_link
set_link(
url: str,
regex: str | None = None,
offset: int | None = None,
length: int = 0,
**kwargs: Any,
) -> list[Link]
Make a link to the provided url from text content matching either:
- the ‘regex’ match,
- or the string of length ‘length’ starting at ‘offset’.
Args:
url -- str
regex -- str regular expression, or None
offset -- int, or None
length -- int
Returns: list of generated Link instances.
Source code in odfdo/mixin_paragraph.py
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | |
set_reference_mark
set_reference_mark(
name: str,
before: str | None = None,
after: str | None = None,
position: int = 0,
content: str | Element | None = None,
) -> Element
Insert a reference mark, at the position defined by the regex (before, after, content) or by positional argument (position). If content is provided, the annotation covers the full range content regex (instances of ReferenceMarkStart and ReferenceMarkEnd are created). Else, an instance of ReferenceMark is positioned either ‘before’ or ‘after’ provided regex.
If content is an ODF Element (ie: Paragraph, Span, …), the full inner content is referenced (of the position just after if content is a single empty tag).
If content/before or after exists (regex) and return a group of matching positions, the position value is the index of matching place to use.
Name is mandatory and shall be unique in the document for the preference mark range.
Args:
name -- str
before -- str regular expression or None
after -- str regular expression or None,
content -- str regular expression or None, or Element
position -- int or tuple of int
Returns: the created ReferenceMark or ReferenceMarkStart
Source code in odfdo/mixin_paragraph.py
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | |
set_reference_mark_end
set_reference_mark_end(
reference_mark: Element,
before: str | None = None,
after: str | None = None,
position: int = 0,
) -> ReferenceMarkEnd
Insert/move a ReferenceMarkEnd for an existing reference mark. If some end tag already exists, replace it. Reference tag is set at the position defined by the regex (before or after).
If content/before or after (regex) returns a group of matching positions, the position value is the index of matching place to use.
Args:
reference_mark -- ReferenceMark or ReferenceMarkStart (mandatory)
before -- str regular expression or None
after -- str regular expression or None
position -- int
Source code in odfdo/mixin_paragraph.py
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | |
set_span
set_span(
style: str,
regex: str | None = None,
offset: int | None = None,
length: int = 0,
**kwargs: Any,
) -> list[Span]
Apply the given style with a Span to text content matching either:
- the ‘regex’ match,
- or the string of length ‘length’ starting at ‘offset’.
Args:
style -- str
regex -- str regular expression, or None
offset -- int, or None
length -- int
Returns: list of generated Span instances.
Source code in odfdo/mixin_paragraph.py
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | |
Paragraph
Bases: MDParagraph, ParaFormattedTextMixin, ParaMixin, Element
An ODF paragraph, “text:p”.
The “text:p” element represents a paragraph, which is the basic unit of text in an OpenDocument file.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a paragraph element “text:p” of the given style containing |
Attributes:
| Name | Type | Description |
|---|---|---|
style |
|
|
text |
|
Source code in odfdo/paragraph.py
53 54 55 56 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 | |
style
instance-attribute
style = style
text
instance-attribute
text = ''
__init__
__init__(
text_or_element: str | bytes | Element | None = None,
style: str | None = None,
formatted: bool = True,
**kwargs: Any,
)
Create a paragraph element “text:p” of the given style containing the optional given text.
If “formatted” is True (the default), the given text is appended with
Args:
text -- str, bytes or Element
style -- str
formatted -- bool
Source code in odfdo/paragraph.py
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 | |
Presentation
Bases: NRMixin, Body
Root of the Presentation document content, “office:presentation”.
Source code in odfdo/body.py
258 259 260 261 262 | |
RectangleShape
Bases: ShapeBase
A rectangle shape, “draw:rect”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a rectangle shape “draw:rect”. |
Source code in odfdo/shapes.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
__init__
__init__(
style: str | None = None,
text_style: str | None = None,
draw_id: str | None = None,
layer: str | None = None,
position: tuple | None = None,
size: tuple | None = None,
**kwargs: Any,
) -> None
Create a rectangle shape “draw:rect”.
Args:
style -- str
text_style -- str
draw_id -- str
layer -- str
position -- (str, str)
size -- (str, str)
Source code in odfdo/shapes.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
Reference
Bases: Element
A reference to a content marked by a reference mark, “text:reference- ref”.”.
The odf_reference element (“text:reference-ref”) represents a field that references a “text:reference-mark-start” or “text:reference-mark” element. Its text:reference-format attribute specifies what is displayed from the referenced element. Default is ‘page’ Actual content is not updated except for the ‘text’ format by the update() method.
Creation of references can be tricky, consider using this method: odfdo.paragraph.insert_reference()
Values for text:reference-format : The defined values for the text:reference-format attribute supported by all reference fields are: - ‘chapter’: displays the number of the chapter in which the referenced item appears. - ‘direction’: displays whether the referenced item is above or below the reference field. - ‘page’: displays the number of the page on which the referenced item appears. - ‘text’: displays the text of the referenced item. Additional defined values for the text:reference-format attribute supported by references to sequence fields are: - ‘caption’: displays the caption in which the sequence is used. - ‘category-and-value’: displays the name and value of the sequence. - ‘value’: displays the value of the sequence.
References to bookmarks and other references support additional values,
which display the list label of the referenced item. If the referenced
item is contained in a list or a numbered paragraph, the list label is
the formatted number of the paragraph which contains the referenced
item. If the referenced item is not contained in a list or numbered
paragraph, the list label is empty, and the referenced field therefore
displays nothing. If the referenced bookmark or reference contains more
than one paragraph, the list label of the paragraph at which the
bookmark or reference starts is taken.
Additional defined values for the text:reference-format attribute
supported by all references to bookmark's or other reference fields
are:
- 'number': displays the list label of the referenced item. [...]
- 'number-all-superior': displays the list label of the referenced
item and adds the contents of all list labels of superior levels
in front of it. [...]
- 'number-no-superior': displays the contents of the list label of
the referenced item.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a reference to a content marked by a reference mark |
update |
Update the content of the reference text field. |
Attributes:
| Name | Type | Description |
|---|---|---|
FORMAT_ALLOWED |
|
|
name |
|
|
ref_format |
str | None
|
|
Source code in odfdo/reference.py
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 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
FORMAT_ALLOWED
class-attribute
instance-attribute
FORMAT_ALLOWED = (
"chapter",
"direction",
"page",
"text",
"caption",
"category-and-value",
"value",
"number",
"number-all-superior",
"number-no-superior",
)
name
instance-attribute
name = name
ref_format
property
writable
ref_format: str | None
__init__
__init__(
name: str = "", ref_format: str = "", **kwargs: Any
) -> None
Create a reference to a content marked by a reference mark “text:reference-ref”.
An actual reference mark with the provided name should exist.
Consider using: odfdo.paragraph.insert_reference()
The text:ref-name attribute identifies a “text:reference-mark” or “text:referencemark-start” element by the value of that element’s text:name attribute. If ref_format is ‘text’, the current text content of the reference_mark is retrieved.
Args:
name -- str : name of the reference mark
ref_format -- str : format of the field. Default is 'page', allowed
values are 'chapter', 'direction', 'page', 'text',
'caption', 'category-and-value', 'value', 'number',
'number-all-superior', 'number-no-superior'.
Source code in odfdo/reference.py
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 129 | |
update
update() -> None
Update the content of the reference text field.
Currently only ‘text’ format is implemented. Other values, for example the ‘page’ text field, may need to be refreshed through a visual ODF parser.
Source code in odfdo/reference.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
ReferenceMark
Bases: Element
A point reference, “text:reference-mark”.
A point reference marks a position in text and is represented by a single “text:reference-mark” element.
Methods:
| Name | Description |
|---|---|
__init__ |
A point reference “text:reference-mark”. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
Source code in odfdo/reference.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
name
instance-attribute
name = name
__init__
__init__(name: str = '', **kwargs: Any) -> None
A point reference “text:reference-mark”.
A point reference marks a position in text and is represented by a single “text:reference-mark” element. Consider using the wrapper: odfdo.paragraph.set_reference_mark()
Args:
name -- str
Source code in odfdo/reference.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
ReferenceMarkEnd
Bases: Element
End of a range reference, “text:reference-mark-end”.
Methods:
| Name | Description |
|---|---|
__init__ |
The “text:reference-mark-end” element represent the end of a range |
referenced_text |
Return the text between reference-mark-start and reference-mark- |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
Source code in odfdo/reference.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
name
instance-attribute
name = name
__init__
__init__(name: str = '', **kwargs: Any) -> None
The “text:reference-mark-end” element represent the end of a range reference. Consider using the wrappers: odfdo.paragraph.set_reference_mark() and odfdo.paragraph.set_reference_mark_end()
Args:
name -- str
Source code in odfdo/reference.py
206 207 208 209 210 211 212 213 214 215 216 217 218 | |
referenced_text
referenced_text() -> str
Return the text between reference-mark-start and reference-mark- end.
Source code in odfdo/reference.py
220 221 222 223 224 225 226 227 228 229 230 231 | |
ReferenceMarkStart
Bases: Element
Start of a range reference, “text:reference-mark-start”.
Methods:
| Name | Description |
|---|---|
__init__ |
The “text:reference-mark-start” element represent the start of a range |
delete |
Delete the given element from the XML tree. If no element is given, |
get_referenced |
Return the document content between the start and end tags of the |
referenced_text |
Return the text between reference-mark-start and reference-mark- |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
Source code in odfdo/reference.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
name
instance-attribute
name = name
__init__
__init__(name: str = '', **kwargs: Any) -> None
The “text:reference-mark-start” element represent the start of a range reference. Consider using the wrapper: odfdo.paragraph.set_reference_mark()
Args:
name -- str
Source code in odfdo/reference.py
243 244 245 246 247 248 249 250 251 252 253 254 | |
delete
delete(
child: Element | None = None, keep_tail: bool = True
) -> None
Delete the given element from the XML tree. If no element is given, “self” is deleted. The XML library may allow to continue to use an element now “orphan” as long as you have a reference to it.
For odf_reference_mark_start : delete the reference-end tag if exists.
Args:
child -- Element
keep_tail -- boolean (default to True), True for most usages.
Source code in odfdo/reference.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
get_referenced
get_referenced(
no_header: bool = False,
clean: bool = True,
as_xml: bool = False,
as_list: bool = False,
) -> Element | list | str | None
Return the document content between the start and end tags of the reference. The content returned by this method can spread over several headers and paragraphs. By default, the content is returned as an “office:text” odf element.
Args:
no_header -- boolean (default to False), translate existing headers
tags "text:h" into paragraphs "text:p".
clean -- boolean (default to True), suppress unwanted tags. Striped
tags are : 'text:change', 'text:change-start',
'text:change-end', 'text:reference-mark',
'text:reference-mark-start', 'text:reference-mark-end'.
as_xml -- boolean (default to False), format the returned content as
a XML string (serialization).
as_list -- boolean (default to False), do not embed the returned
content in a "office:text'" element, instead simply
return a raw list of odf elements.
Source code in odfdo/reference.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
referenced_text
referenced_text() -> str
Return the text between reference-mark-start and reference-mark- end.
Source code in odfdo/reference.py
256 257 258 259 260 261 262 263 264 265 266 267 | |
Row
Bases: Element
A row of a table, “table:table-row”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a Row, “table:table-row”, optionally filled with “width” |
append_cell |
Append the given cell at the end of the row. Repeated cells are |
clear |
Remove text, children and attributes from the Row. |
delete_cell |
Delete the cell at the given position “x” starting from 0. |
extend_cells |
|
force_width |
Change the repeated property of the last cell of the row to comply |
get_cell |
Get the cell at position “x” starting from 0. Alphabetical positions |
get_cells |
Get the list of cells matching the criteria. |
get_elements |
|
get_sub_elements |
Shortcut to get the Elements inside cells in this row. |
get_value |
Shortcut to get the value of the cell at position “x”. If get_type |
get_values |
Shortcut to get the cell values in this row. |
insert_cell |
Insert the given cell at position “x” starting from 0. If no cell is |
is_empty |
Return whether every cell in the row has no value or the value |
iter_cells |
Yield as many cell elements as expected cells in the row, i.e. |
last_cell |
Return the las cell of the row. |
minimized_width |
Return the length of the row if the last repeated sequence is |
rstrip |
Remove in-place empty cells at the right of the row. An empty cell |
set_cell |
Push the cell back in the row at position “x” starting from 0. |
set_cells |
Set the cells in the row, from the ‘start’ column. This method does |
set_value |
Shortcut to set the value of the cell at position “x”. |
set_values |
Shortcut to set the value of cells in the row, from the ‘start’ |
Attributes:
| Name | Type | Description |
|---|---|---|
append |
|
|
cells |
list[Cell]
|
Get the list of all cells. |
clone |
Row
|
|
repeated |
int | None
|
Get / set the number of times the row is repeated. |
style |
str | None
|
Get /set the style of the row itself. |
traverse |
|
|
width |
int
|
Get the number of expected cells in the row, i.e. addition |
y |
|
Source code in odfdo/row.py
51 52 53 54 55 56 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | |
repeated
property
writable
repeated: int | None
Get / set the number of times the row is repeated.
Always None when using the table API.
Returns: int or None
style
property
writable
style: str | None
Get /set the style of the row itself.
Returns: str
width
property
width: int
Get the number of expected cells in the row, i.e. addition repetitions.
Returns: int
y
instance-attribute
y = None
__init__
__init__(
width: int | None = None,
repeated: int | None = None,
style: str | None = None,
**kwargs: Any,
) -> None
Create a Row, “table:table-row”, optionally filled with “width” number of cells.
Rows contain cells, their number determine the number of columns.
You don’t generally have to create rows by hand, use the Table API.
Args:
width -- int
repeated -- int
style -- str
Source code in odfdo/row.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 | |
append_cell
Append the given cell at the end of the row. Repeated cells are accepted. If no cell is given, an empty one is created.
Do not use when working on a table, use Table.append_cell().
Args:
cell -- Cell
_repeated -- (optional), repeated value of the row
returns the cell with x and y updated
Source code in odfdo/row.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
clear
clear() -> None
Remove text, children and attributes from the Row.
Source code in odfdo/row.py
117 118 119 120 121 | |
delete_cell
delete_cell(x: int | str) -> None
Delete the cell at the given position “x” starting from 0. Alphabetical positions like “D” are accepted.
Cells on the right will be shifted to the left. In a table, other rows remain unaffected.
Args:
x -- int or str
Source code in odfdo/row.py
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
extend_cells
extend_cells(cells: Iterable[Cell] | None = None) -> None
Source code in odfdo/row.py
506 507 508 509 510 | |
force_width
force_width(width: int) -> None
Change the repeated property of the last cell of the row to comply with the required max width.
Args:
width -- int
Source code in odfdo/row.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 | |
get_cell
get_cell(x: int, clone: bool = True) -> Cell | None
Get the cell at position “x” starting from 0. Alphabetical positions like “D” are accepted.
A copy is returned, use set_cell() to push it back.
Args:
x -- int or str
Returns: Cell | None
Source code in odfdo/row.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
get_cells
get_cells(
coord: str | tuple | None = None,
style: str | None = None,
content: str | None = None,
cell_type: str | None = None,
) -> list[Cell]
Get the list of cells matching the criteria.
Filter by cell_type, with cell_type ‘all’ will retrieve cells of any type, aka non empty cells.
Filter by coordinates will retrieve the amount of cells defined by ‘coord’, minus the other filters.
Args:
coord -- str or tuple of int : coordinates
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency', 'percentage' or 'all'
content -- str regex
style -- str
Returns: list of Cell
Source code in odfdo/row.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
get_elements
get_elements(xpath_query: XPath | str) -> list[Element]
Source code in odfdo/row.py
97 98 99 100 101 102 103 104 105 106 107 108 109 | |
get_sub_elements
get_sub_elements() -> list[Any]
Shortcut to get the Elements inside cells in this row.
Missing values are replaced by None. Cell type should be always ‘string’ when using this method, the length of the list is equal to the length of the row.
Returns: list of Elements.
Source code in odfdo/row.py
627 628 629 630 631 632 633 634 635 636 637 638 | |
get_value
get_value(
x: int | str, get_type: bool = False
) -> Any | tuple[Any, str]
Shortcut to get the value of the cell at position “x”. If get_type is True, returns the tuples (value, ODF type).
If the cell is empty, returns None or (None, None)
See get_cell() and Cell.get_value().
Source code in odfdo/row.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
get_values
get_values(
coord: str | tuple | None = None,
cell_type: str | None = None,
complete: bool = False,
get_type: bool = False,
) -> list[Any | tuple[Any, Any]]
Shortcut to get the cell values in this row.
Filter by cell_type, with cell_type ‘all’ will retrieve cells of any type, aka non empty cells. If cell_type is used and complete is True, missing values are replaced by None. If cell_type is None, complete is always True : with no cell type queried, get_values() returns None for each empty cell, the length of the list is equal to the length of the row (depending on coordinates use).
If get_type is True, returns a tuple (value, ODF type of value), or (None, None) for empty cells if complete is True.
Filter by coordinates will retrieve the amount of cells defined by coordinates with None for empty cells, except when using cell_type.
Args:
coord -- str or tuple of int : coordinates in row
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency', 'percentage' or 'all'
complete -- boolean
get_type -- boolean
Returns: list of Python types, or list of tuples.
Source code in odfdo/row.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | |
insert_cell
Insert the given cell at position “x” starting from 0. If no cell is given, an empty one is created.
Alphabetical positions like “D” are accepted.
Do not use when working on a table, use Table.insert_cell().
Args:
x -- int or str
cell -- Cell
returns the cell with x and y updated
Source code in odfdo/row.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
is_empty
is_empty(aggressive: bool = False) -> bool
Return whether every cell in the row has no value or the value evaluates to False (empty string), and no style.
If aggressive is True, empty cells with style are considered empty.
Args:
aggressive -- bool
Returns: bool
Source code in odfdo/row.py
800 801 802 803 804 805 806 807 808 809 810 811 812 | |
iter_cells
iter_cells(
start: int | None = None, end: int | None = None
) -> Iterator[Cell]
Yield as many cell elements as expected cells in the row, i.e. expand repetitions by returning the same cell as many times as necessary.
Copies are returned, use set_cell() to push them back.
Args:
start -- int
end -- int
Source code in odfdo/row.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
last_cell
last_cell() -> Cell | None
Return the las cell of the row.
Return Cell | None
Source code in odfdo/row.py
770 771 772 773 774 775 776 777 778 | |
minimized_width
minimized_width() -> int
Return the length of the row if the last repeated sequence is reduced to one.
Returns: int
Source code in odfdo/row.py
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
rstrip
rstrip(aggressive: bool = False) -> None
Remove in-place empty cells at the right of the row. An empty cell has no value but can have style. If “aggressive” is True, style is ignored.
Args:
aggressive -- bool
Source code in odfdo/row.py
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | |
set_cell
Push the cell back in the row at position “x” starting from 0. Alphabetical positions like “D” are accepted.
Args:
x -- int or str
returns the cell with x and y updated
Source code in odfdo/row.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
set_cells
set_cells(
cells: list[Cell] | tuple[Cell] | None = None,
start: int | str = 0,
clone: bool = True,
) -> None
Set the cells in the row, from the ‘start’ column. This method does not clear the row, use row.clear() before to start with an empty row.
Args:
cells -- list of cells
start -- int or str
Source code in odfdo/row.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |
set_value
set_value(
x: int | str,
value: Any,
style: str | None = None,
cell_type: str | None = None,
currency: str | None = None,
) -> None
Shortcut to set the value of the cell at position “x”.
Args:
x -- int or str
value -- Python type
cell_type -- 'boolean', 'currency', 'date', 'float', 'percentage',
'string' or 'time'
currency -- three-letter str
style -- str
See get_cell() and Cell.get_value().
Source code in odfdo/row.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
set_values
set_values(
values: list[Any],
start: int | str = 0,
style: str | None = None,
cell_type: str | None = None,
currency: str | None = None,
) -> None
Shortcut to set the value of cells in the row, from the ‘start’ column with values. This method does not clear the row, use row.clear() before to start with an empty row.
Args:
values -- list of Python types
start -- int or str
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency' or 'percentage'
currency -- three-letter str
style -- cell style
Source code in odfdo/row.py
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | |
RowGroup
Bases: Element
A group of rows with common properties, “table:table-row-group”.
Partial implementation.
The “table:table-row-group” element groups adjacent table rows. Every row group can contain header rows, and nested row groups. A row group can be visible or hidden.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a group of rows, “table:table-row-group”, optionally filled |
Source code in odfdo/row_group.py
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 62 63 64 65 66 67 68 69 70 71 | |
__init__
__init__(
height: int | None = None,
width: int | None = None,
**kwargs: Any,
) -> None
Create a group of rows, “table:table-row-group”, optionally filled with “height” number of rows, of “width” cells each.
Row group bear style information applied to a series of rows.
Args:
height -- int
width -- int
Source code in odfdo/row_group.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
Section
Bases: Element
Section of the text document, “text:section”.
Methods:
| Name | Description |
|---|---|
__init__ |
Section of the text document, “text:section”. |
get_formatted_text |
|
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
|
style |
|
Source code in odfdo/section.py
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 62 63 64 | |
name
instance-attribute
name = name
style
instance-attribute
style = style
__init__
__init__(
style: str | None = None,
name: str | None = None,
**kwargs: Any,
) -> None
Section of the text document, “text:section”.
Args:
style -- str
name -- str
Source code in odfdo/section.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
get_formatted_text
get_formatted_text(context: dict | None = None) -> str
Source code in odfdo/section.py
61 62 63 64 | |
Spacer
Bases: MDSpacer, Element
Representation of several spaces, “text:s”.
This element shall be used to represent the second and all following “ “ (U+0020, SPACE) characters in a sequence of “ “ (U+0020, SPACE) characters. Note: It is not an error if the character preceding the element is not a white space character, but it is good practice to use this element only for the second and all following SPACE characters in a sequence.
Methods:
| Name | Description |
|---|---|
__init__ |
Representation of several spaces, “text:s”. |
Attributes:
| Name | Type | Description |
|---|---|---|
length |
int
|
|
number |
str | None
|
|
text |
str
|
Get / set the string (spaces). |
Source code in odfdo/spacer.py
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 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 | |
length
property
writable
length: int
number
instance-attribute
number: str | None = str(number)
text
property
writable
text: str
Get / set the string (spaces).
__init__
__init__(number: int | None = 1, **kwargs: Any) -> None
Representation of several spaces, “text:s”.
Args:
number -- int
Source code in odfdo/spacer.py
47 48 49 50 51 52 53 54 55 56 57 58 59 | |
Span
Bases: MDSpan, MDParagraph, ParaFormattedTextMixin, ParaMixin, Element
A span tag (syled text in paragraph), “text:span”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a span element “text:span” of the given style containing the |
Attributes:
| Name | Type | Description |
|---|---|---|
style |
|
|
text |
|
Source code in odfdo/span.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 | |
style
instance-attribute
style = style
text
instance-attribute
text = ''
__init__
__init__(
text: str | None = None,
style: str | None = None,
formatted: bool = True,
**kwargs: Any,
) -> None
Create a span element “text:span” of the given style containing the optional given text.
If “formatted” is True (the default), the given text is appended with
Args:
text -- str
style -- str
formatted -- bool
Source code in odfdo/span.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
Spreadsheet
Bases: NRMixin, Body
Root of the Spreadsheet document content, “office:spreadsheet”.
Source code in odfdo/body.py
265 266 267 268 269 | |
Style
Bases: StyleProps
Style class for many ODF tags, “style:style”, “number:date-style”,…
Partial list: “style:style”, “number:date-style”, “number:number-style”, “number:percentage-style”, “number:time-style”, “style:font-face”, “style:page-layout”, “style:presentation-page-layout”, “text:list-style”, “text:outline-style”, “style:tab-stops” …
Methods:
| Name | Description |
|---|---|
__init__ |
Create a style of the given family. |
get_level_style |
|
set_background |
Set the background color of a text style, or the background color or |
set_font |
|
set_level_style |
Args: |
Attributes:
| Name | Type | Description |
|---|---|---|
display_name |
|
|
family |
str | None
|
|
master_page |
|
|
name |
|
|
parent_style |
|
Source code in odfdo/style.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | |
display_name
instance-attribute
display_name = display_name
family
property
writable
family: str | None
master_page
instance-attribute
master_page = master_page
name
instance-attribute
name = name
parent_style
instance-attribute
parent_style = parent_style
__init__
__init__(
family: str | None = None,
name: str | None = None,
display_name: str | None = None,
parent_style: str | None = None,
area: str | None = None,
color: str | tuple | None = None,
background_color: str | tuple | None = None,
italic: bool = False,
bold: bool = False,
master_page: str | None = None,
data_style: str | None = None,
border: str | None = None,
border_top: str | None = None,
border_right: str | None = None,
border_bottom: str | None = None,
border_left: str | None = None,
padding: str | None = None,
padding_top: str | None = None,
padding_bottom: str | None = None,
padding_left: str | None = None,
padding_right: str | None = None,
shadow: str | None = None,
height: str | None = None,
use_optimal_height: bool = False,
break_before: str | None = None,
break_after: str | None = None,
align: str | None = None,
width: str | None = None,
min_height: str | None = None,
font_name: str | None = None,
font_family: str | None = None,
font_family_generic: str | None = None,
font_pitch: str = "variable",
**kwargs: Any,
) -> None
Create a style of the given family.
The name is not mandatory at this point but will become required when inserting in a document as a common style.
The display name is the name the user sees in an office application.
The parent_style is the name of the style this style will inherit from.
To set properties, pass them as keyword arguments. The area properties apply to is optional and defaults to the family.
Args:
family -- 'paragraph', 'text', 'section', 'table', 'table-column',
'table-row', 'table-cell', 'table-page', 'chart',
'drawing-page', 'graphic', 'presentation',
'control', 'ruby', 'list', 'number', 'page-layout'
'font-face', or 'master-page'
name -- str
display_name -- str
parent_style -- str
area -- str
‘text’ Properties:
italic -- bool
bold -- bool
‘paragraph’ Properties:
master_page -- str
‘table-cell’ Properties:
border, border_top, border_right, border_bottom, border_left -- str,
e.g. "0.002cm solid #000000" or 'none'
padding, padding_top, padding_right, padding_bottom, padding_left -- str,
e.g. "0.002cm" or 'none'
shadow -- str, e.g. "#808080 0.176cm 0.176cm"
‘table-row’ Properties:
height -- str, e.g. '5cm'
use_optimal_height -- bool
‘table-column’ Properties:
width -- str, e.g. '5cm'
break_before -- 'page', 'column' or 'auto'
break_after -- 'page', 'column' or 'auto'
‘table’ Properties:
width -- str, e.g. '5cm'
align -- 'left', 'center', 'margins' or 'right'
Source code in odfdo/style.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
get_level_style
get_level_style(level: int) -> Style | None
Source code in odfdo/style.py
581 582 583 584 585 586 587 588 589 | |
set_background
set_background(
color: str | None = None,
url: str | None = None,
position: str | None = "center",
repeat: str | None = None,
opacity: str | int | None = None,
filter: str | None = None,
) -> None
Set the background color of a text style, or the background color or image of a paragraph style or page layout.
With no argument, remove any existing background.
The values of the position attribute are “left”, “center”, “right”, “top”, “bottom”, or two white space separated values, that may appear in any order. One of these values is one of: “left”, “center” or “right”. The other value is one of: “top”, “center” or “bottom”. The default value for this attribute is “center”.
The repeat value is one of ‘no-repeat’, ‘repeat’ or ‘stretch’.
The opacity is a percentage integer (not a string with the ‘%’ sign)
The filter is an application-specific filter name defined elsewhere.
Though this method is defined on the base style class, it will raise an error if the style type is not compatible.
Args:
color -- '#rrggbb'
url -- str
position -- str
repeat -- str
opacity -- int
filter -- str
Source code in odfdo/style.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | |
set_font
set_font(
name: str,
family: str | None = None,
family_generic: str | None = None,
pitch: str = "variable",
) -> None
Source code in odfdo/style.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | |
set_level_style
set_level_style(
level: int,
num_format: str | None = None,
bullet_char: str | None = None,
url: str | None = None,
display_levels: int | None = None,
prefix: str | None = None,
suffix: str | None = None,
start_value: int | None = None,
style: str | None = None,
clone: Style | None = None,
) -> Style | None
Args:
level -- int
num_format (for number) -- int
bullet_char (for bullet) -- str
url (for image) -- str
display_levels -- int
prefix -- str
suffix -- str
start_value -- int
style -- str
clone -- List Style
Returns:
| Type | Description |
|---|---|
Style | None
|
level_style created |
Source code in odfdo/style.py
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 | |
StyleFooter
Bases: StyleHeader
Content of a footer in a StyleMasterPage, tag “style:footer”.
The “style:display” attribute specifies whether the footer is displayed or not (“true” or “false”). The default value is “true”.
Source code in odfdo/master_page.py
274 275 276 277 278 279 280 281 | |
StyleFooterLeft
Bases: StyleHeader
Content of a left page footer in a StyleMasterPage, tag “style:footer- left”.
If left page different from the right page in a “style:master-page”.
The “style:display” attribute specifies whether the footer is displayed or not (“true” or “false”). The default value is “true”.
Source code in odfdo/master_page.py
297 298 299 300 301 302 303 304 305 306 307 | |
StyleHeader
Bases: StyleBase
Content of a header in a StyleMasterPage, tag “style:header”.
The “style:display” attribute specifies whether the header is displayed or not (“true” or “false”). The default value is “true”.
Methods:
| Name | Description |
|---|---|
__init__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
display |
bool
|
|
Source code in odfdo/master_page.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
display
property
writable
display: bool
__init__
__init__(
display: str | bool | None = True, **kwargs: Any
) -> None
Source code in odfdo/master_page.py
250 251 252 253 254 255 256 257 258 259 260 | |
StyleHeaderLeft
Bases: StyleHeader
Content of a left page header in a StyleMasterPage, tag “style:header- left”.
If left page different from the right page in a “style:master-page”.
The “style:display” attribute specifies whether the header is displayed or not (“true” or “false”). The default value is “true”.
Source code in odfdo/master_page.py
284 285 286 287 288 289 290 291 292 293 294 | |
StyleMasterPage
Bases: StyleBase
Container of headers and footers, “style:master-page”.
In text and spreadsheet documents, the “style:master-page” element contains the content of headers and footers. For these types of documents, consumers may generate a sequence of pages by making use of a single master page or a set of master pages.
In drawing and presentation documents, the “style:master-page” element is used to define master pages as common backgrounds for drawing pages. Each drawing page is directly linked to one master page, which is specified by the draw:master-page-name attribute of the drawing pages style.
Master pages are contained in the “office:master-styles” element.
All documents shall contain at least one master page element.
If a text or spreadsheet document is displayed in a paged layout, master pages are used to generate a sequence of pages containing the document content. When a page is created, an empty page is generated with the properties of the master page and the static content of the master page. The body of the page is then filled with content. A single master pages can be used to created multiple pages within a document.
In text and spreadsheet documents, a master page can be assigned to paragraph and table styles using a style:master-page-name attribute. Each time the paragraph or table style is applied to text, a page break is inserted before the paragraph or table. A page that starts at the page break position uses the specified master page.
In drawings and presentations, master pages can be assigned to drawing pages using a style:parent-style-name attribute.
The “style:master-page” element is usable within the following element: “office:master-styles”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a StyleMasterPage. |
get_page_footer |
Get the element that contains the footer contents. |
get_page_header |
Get the element that contains the header contents. |
set_font |
Not applicable to this class. |
set_page_footer |
Create or replace the footer by the given content. It can already be |
set_page_header |
Create or replace the header by the given content. It can already be |
Attributes:
| Name | Type | Description |
|---|---|---|
display_name |
|
|
draw_style_name |
|
|
family |
str | None
|
|
name |
|
|
next_style |
|
|
page_layout |
|
Source code in odfdo/master_page.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 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
display_name
instance-attribute
display_name = display_name
draw_style_name
instance-attribute
draw_style_name = draw_style_name
family
property
writable
family: str | None
name
instance-attribute
name = name
next_style
instance-attribute
next_style = next_style
page_layout
instance-attribute
page_layout = page_layout
__init__
__init__(
name: str | None = None,
display_name: str | None = None,
page_layout: str | None = None,
next_style: str | None = None,
draw_style_name: str | None = None,
**kwargs: Any,
) -> None
Create a StyleMasterPage.
The name is not mandatory at this point but will become required when inserting in a document as a common style. The display name is the name the user sees in an office application.
To set properties, pass them as keyword arguments.
Args:
name -- str
display_name -- str
page_layout -- str
next_style -- str
draw_style_name -- str
Source code in odfdo/master_page.py
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 129 130 131 132 133 | |
get_page_footer
get_page_footer() -> Element | None
Get the element that contains the footer contents.
If None, no footer was set.
Source code in odfdo/master_page.py
205 206 207 208 209 210 | |
get_page_header
get_page_header() -> Element | None
Get the element that contains the header contents.
If None, no header was set.
Source code in odfdo/master_page.py
182 183 184 185 186 187 | |
set_font
set_font(
name: str,
family: str | None = None,
family_generic: str | None = None,
pitch: str = "variable",
) -> None
Not applicable to this class.
Source code in odfdo/master_page.py
228 229 230 231 232 233 234 235 | |
set_page_footer
Create or replace the footer by the given content. It can already be a complete footer.
If you only want to update the existing footer, get it and use the API.
Args:
text_or_element -- str or Element or a list of them
Source code in odfdo/master_page.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
set_page_header
Create or replace the header by the given content. It can already be a complete header.
If you only want to update the existing header, get it and use the API.
Args:
text_or_element -- str or Element or a list of them
Source code in odfdo/master_page.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
StylePageLayout
Bases: StyleProps
The “style:page-layout” element represents the styles that specify the formatting properties of a page.
The “style:page-layout” element is usable within the following element: “office:automatic-styles”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a StylePageLayout. |
del_properties |
Delete the given properties, either by list argument or positional |
get_footer_style |
|
get_header_style |
|
get_properties |
Get the mapping of page-layout properties of StylePageLayout. |
set_background |
Set the background color of the page layout. |
set_footer_style |
|
set_header_style |
|
set_properties |
Set the properties of the page-layout. |
Attributes:
| Name | Type | Description |
|---|---|---|
family |
str | None
|
|
name |
|
|
page_usage |
str
|
|
Source code in odfdo/page_layout.py
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 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
family
property
writable
family: str | None
name
instance-attribute
name = name
page_usage
property
writable
page_usage: str
__init__
__init__(
name: str | None = None,
page_usage: str | None = None,
**kwargs: Any,
) -> None
Create a StylePageLayout.
The name is not mandatory at this point but will become required when inserting in a document as a automatic style.
The page_usage attribute specifies the type of pages that a page master should generate. Allowed values are: “all” (default), “left”, “mirrored”, “right”.
To set properties, pass them as keyword arguments.
Args:
name -- str
page_usage -- str
Source code in odfdo/page_layout.py
55 56 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 | |
del_properties
del_properties(
properties: list[str] | None = None,
area: str | None = None,
) -> None
Delete the given properties, either by list argument or positional argument (or both).
Args:
properties -- list
area -- "page-layout"
Source code in odfdo/page_layout.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
get_footer_style
get_footer_style() -> StyleBase | None
Source code in odfdo/page_layout.py
207 208 | |
get_header_style
get_header_style() -> StyleBase | None
Source code in odfdo/page_layout.py
198 199 | |
get_properties
get_properties(
area: str | None = "page-layout",
) -> dict[str, str | dict] | None
Get the mapping of page-layout properties of StylePageLayout.
Args:
area -- str (unused, kept for compatibility)
Returns: dict
Source code in odfdo/page_layout.py
107 108 109 110 111 112 113 114 115 116 117 118 | |
set_background
set_background(
color: str | None = None,
url: str | None = None,
position: str | None = "center",
repeat: str | None = None,
opacity: str | int | None = None,
filter: str | None = None,
) -> None
Set the background color of the page layout.
With no argument, remove any existing background.
The values of the position attribute are “left”, “center”, “right”, “top”, “bottom”, or two white space separated values, that may appear in any order. One of these values is one of: “left”, “center” or “right”. The other value is one of: “top”, “center” or “bottom”. The default value for this attribute is “center”.
The repeat value is one of ‘no-repeat’, ‘repeat’ or ‘stretch’.
The opacity is a percentage integer (not a string with the ‘%’ sign)
The filter is an application-specific filter name defined elsewhere.
Args:
color -- '#rrggbb'
url -- str
position -- str
repeat -- str
opacity -- int
filter -- str
Source code in odfdo/page_layout.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
set_footer_style
set_footer_style(new_style: StyleBase) -> None
Source code in odfdo/page_layout.py
210 211 212 213 214 | |
set_header_style
set_header_style(new_style: StyleBase) -> None
Source code in odfdo/page_layout.py
201 202 203 204 205 | |
set_properties
set_properties(
properties: dict[str, str | dict] | None = None,
style: StyleBase | None = None,
area: str | None = None,
**kwargs: Any,
) -> None
Set the properties of the page-layout.
Properties are given either as a dict or as named arguments (or both). The area is identical to the style family by default. If the properties element is missing, it is created.
Instead of properties, you can pass a style with properties of a page-layout style. These will be copied.
Args:
properties -- dict
style -- StylePageLayout
area -- "page-layout"
Source code in odfdo/page_layout.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
Styles
Bases: XmlPart
Representation of the “styles.xml” part.
Methods:
| Name | Description |
|---|---|
get_master_page |
|
get_style |
Return the style uniquely identified by the name/family pair. |
get_styles |
Return the list of styles in the Styles part, optionally limited to |
set_default_styles_language_country |
Set the default language in styles, in format “en-US”. |
Attributes:
| Name | Type | Description |
|---|---|---|
default_language |
str
|
Get or set the default language from styles, in format “en-US”. |
default_styles |
list[StyleBase]
|
Return the list of default styles “style:default-styles”. |
master_pages |
list[StyleMasterPage]
|
|
office_automatic_styles |
OfficeAutomaticStyles | None
|
|
office_master_styles |
OfficeMasterStyles | None
|
|
Source code in odfdo/styles.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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
default_language
property
writable
default_language: str
Get or set the default language from styles, in format “en-US”.
default_styles
property
default_styles: list[StyleBase]
Return the list of default styles “style:default-styles”.
Returns: list of Style
get_master_page
get_master_page(
position: int = 0,
) -> StyleMasterPage | None
Source code in odfdo/styles.py
218 219 220 221 222 223 | |
get_style
get_style(
family: str,
name_or_element: str | StyleBase | None = None,
display_name: str | None = None,
) -> StyleBase | None
Return the style uniquely identified by the name/family pair.
If the argument is already a style object, it will return it. If the name is None, the default style is fetched. If the name is not the internal name but the name you gave in the desktop application, use display_name instead.
Args:
family -- 'paragraph', 'text', 'graphic', 'table', 'list',
'number', 'page-layout', 'master-page'
name_or_element -- str, odf_style or None
display_name -- str or None
Returns: odf_style or None if not found
Source code in odfdo/styles.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
get_styles
get_styles(
family: str = "", automatic: bool = False
) -> list[StyleBase]
Return the list of styles in the Styles part, optionally limited to the given family, optionally limited to automatic styles.
Args:
family -- str
automatic -- bool
Returns: list of Style
Source code in odfdo/styles.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
set_default_styles_language_country
set_default_styles_language_country(value: str) -> None
Set the default language in styles, in format “en-US”.
Source code in odfdo/styles.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
TOC
Bases: MDToc, Element
A table of content, “text:table-of-content”.
The “text:table-of-content” element represents a table of contents for a document. The items that can be listed in a table of contents are:
-
Headings (as defined by the outline structure of the document), up to a selected level.
-
Table of contents index marks.
-
Paragraphs formatted with specified paragraph styles.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a table of content “text:table-of-content”. |
create_toc_source |
|
fill |
Fill the TOC with the titles found in the document. A TOC is not |
get_formatted_text |
|
get_title |
|
set_toc_title |
|
Attributes:
| Name | Type | Description |
|---|---|---|
body |
Element | None
|
|
name |
|
|
outline_level |
int | None
|
|
protected |
|
|
style |
|
Source code in odfdo/toc.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
name
instance-attribute
name = f'{title}1'
outline_level
property
writable
outline_level: int | None
protected
instance-attribute
protected = protected
style
instance-attribute
style = style
__init__
__init__(
title: str = "Table of Contents",
name: str | None = None,
protected: bool = True,
outline_level: int = 0,
style: str | None = None,
title_style: str = "Contents_20_Heading",
entry_style: str = "Contents_20_%d",
**kwargs: Any,
) -> None
Create a table of content “text:table-of-content”.
Default parameters are what most people use: protected from manual modifications and not limited in title levels.
The name is mandatory and derived automatically from the title if not given. Provide one in case of a conflict with other TOCs in the same document.
The “text:table-of-content” element has the following attributes: text:name, text:protected, text:protection-key, text:protection-key-digest-algorithm, text:style-name and xml:id.
Args:
title -- str
name -- str
protected -- bool
outline_level -- int
style -- str
title_style -- str
entry_style -- str
Source code in odfdo/toc.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
create_toc_source
staticmethod
create_toc_source(
title: str,
outline_level: int,
title_style: str,
entry_style: str,
) -> Element
Source code in odfdo/toc.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
fill
fill(
document: Document | None = None,
use_default_styles: bool = True,
) -> None
Fill the TOC with the titles found in the document. A TOC is not contextual so it will catch all titles before and after its insertion. If the TOC is not attached to a document, attach it beforehand or provide one as argument.
For having a pretty TOC, let use_default_styles by default.
Args:
document -- Document
use_default_styles -- bool
Source code in odfdo/toc.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
get_formatted_text
get_formatted_text(context: dict | None = None) -> str
Source code in odfdo/toc.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
get_title
get_title() -> str
Source code in odfdo/toc.py
343 344 345 346 347 348 349 350 | |
set_toc_title
set_toc_title(
title: str,
style: str | None = None,
text_style: str | None = None,
) -> None
Source code in odfdo/toc.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
Tab
Bases: MDTab, Element
Representation of a tabulation, “text:tab”.
This element represents the [UNICODE] tab character (HORIZONTAL TABULATION, U+0009).
The position attribute contains the number of the tab-stop to which a tab character refers. The position 0 marks the start margin of a paragraph. Note: The position attribute is only a hint to help non-layout oriented consumers to determine the tab/tab-stop association. Layout oriented consumers should determine the tab positions based on the style information
Methods:
| Name | Description |
|---|---|
__init__ |
Representation of a tabulation, “text:tab”. |
Attributes:
| Name | Type | Description |
|---|---|---|
position |
|
|
text |
str
|
Return “\t”. |
Source code in odfdo/tab.py
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 62 63 64 65 66 67 68 69 70 71 | |
position
instance-attribute
position = str(position)
text
property
writable
text: str
Return “\t”.
__init__
__init__(
position: int | None = None, **kwargs: Any
) -> None
Representation of a tabulation, “text:tab”.
Args:
position -- int
Source code in odfdo/tab.py
50 51 52 53 54 55 56 57 58 59 | |
TabStopStyle
Bases: Element
Base style for a TOC entryBase style for a TOC entry, “style:tab- stop”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create style for a TOC entryBase style for a TOC entry “style:tab- |
Attributes:
| Name | Type | Description |
|---|---|---|
leader_color |
|
|
leader_style |
|
|
leader_text |
|
|
leader_text_style |
|
|
leader_type |
|
|
leader_width |
|
|
style_char |
|
|
style_position |
|
|
style_type |
|
Source code in odfdo/toc.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
leader_color
instance-attribute
leader_color = leader_color
leader_style
instance-attribute
leader_style = leader_style
leader_text
instance-attribute
leader_text = leader_text
leader_text_style
instance-attribute
leader_text_style = leader_text_style
leader_type
instance-attribute
leader_type = leader_type
leader_width
instance-attribute
leader_width = leader_width
style_char
instance-attribute
style_char = style_char
style_position
instance-attribute
style_position = style_position
style_type
instance-attribute
style_type = style_type
__init__
__init__(
style_char: str | None = None,
leader_color: str | None = None,
leader_style: str | None = None,
leader_text: str | None = None,
leader_text_style: str | None = None,
leader_type: str | None = None,
leader_width: str | None = None,
style_position: str | None = None,
style_type: str | None = None,
**kwargs: Any,
)
Create style for a TOC entryBase style for a TOC entry “style:tab- stop”.
Source code in odfdo/toc.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
Table
Bases: MDTable, Element
A table, in a spreadsheet or other document, “table:table”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a table element “table:table”, optionally prefilled with |
append |
Dispatch .append() call to append_row() or append_column(). |
append_cell |
Append the given cell at the “y” coordinate. Repeated cells are |
append_column |
Append the column at the end of the table. If no column is given, an |
append_named_range |
Append the named range to the document. |
append_row |
Append the row at the end of the table. If no row is given, an empty |
clear |
Remove text, children and attributes from the Row. |
del_span |
Delete a Cell Span. ‘area’ is the cell coordinate of the upper left |
delete_cell |
Delete the cell at the given coordinates, so that next cells are |
delete_column |
Delete the column at the given position. ODF columns don’t contain |
delete_named_range |
Delete the Named Range of specified name. |
delete_row |
Delete the row at the given “y” position. |
extend_rows |
Append a list of rows at the end of the table. |
from_csv |
Import the CSV text content into a Table. |
get_cell |
Get the cell at the given coordinates. |
get_cells |
Get the cells matching the criteria. If ‘coord’ is None, parse the |
get_column |
Get the column at the given “x” position. |
get_column_cells |
Get the list of cells at the given position. |
get_column_values |
Shortcut to get the list of Python values for the cells at the given |
get_columns |
Get the list of columns matching the criteria. |
get_elements |
|
get_formatted_text |
|
get_named_range |
Return the Name Range of the specified name. |
get_named_ranges |
Return the list of Name Ranges. |
get_row |
Get the row at the given “y” position. |
get_row_sub_elements |
Shortcut to get the list of Elements values for the cells of the row |
get_row_values |
Shortcut to get the list of Python values for the cells of the row |
get_rows |
Get the list of rows matching the criteria. |
get_value |
Shortcut to get the Python value of the cell at the given |
get_values |
Get a matrix of values of the table. |
insert_cell |
Insert the given cell at the given coordinates. If no cell is given, |
insert_column |
Insert the column before the given “x” position. If no column is |
insert_row |
Insert the row before the given “y” position. If no row is given, an |
is_column_empty |
Return wether every cell in the column at “x” position has no value |
is_empty |
Return whether every cell in the table has no value or the value |
is_row_empty |
Return wether every cell in the row at the given “y” position has no |
iter_columns |
Yield as many column elements as expected columns in the table, i.e. |
iter_rows |
Yield as many row elements as expected rows in the table, i.e. |
iter_values |
Yield lines (lists) of Python values of the table. |
optimize_width |
Remove in-place empty rows below and empty cells at the right of |
rstrip |
Remove in-place empty rows below and empty cells at the right of |
set_cell |
Replace a cell of the table at the given coordinates. |
set_cell_image |
Deprecated, see related recipes to achieve the desired result. |
set_cells |
Set the cells in the table, from the ‘coord’ position. |
set_column |
Replace the column at the given “x” position. |
set_column_cells |
Shortcut to set the list of cells at the given position. |
set_column_values |
Shortcut to set the list of Python values of cells at the given |
set_named_range |
Create a Named Range element and insert it in the document. |
set_row |
Replace the row at the given position with the new one. Repetitions of |
set_row_cells |
Shortcut to set all the cells of the row at the given “y” |
set_row_values |
Shortcut to set the values of all cells of the row at the given |
set_span |
Create a Cell Span : span the first cell of the area on several |
set_value |
Set the Python value of the cell at the given coordinates. |
set_values |
Set the value of cells in the table, from the ‘coord’ position with |
to_csv |
Export the table as CSV. |
transpose |
Swap in-place rows and columns of the table. |
Attributes:
| Name | Type | Description |
|---|---|---|
cells |
list
|
Get all cells of the table. |
columns |
list[Column]
|
Get the list of all columns matching the criteria. |
height |
int
|
Get the current height of the table. |
name |
str | None
|
Get / set the name of the table. |
print_ranges |
list[str]
|
|
printable |
bool
|
|
protected |
bool
|
|
protection_key |
str | None
|
|
row_groups |
list[RowGroup]
|
Get the list of all RowGroup. |
rows |
list[Row]
|
Get the list of all rows. |
set_protection_key |
|
|
size |
tuple[int, int]
|
Shortcut to get the current width and height of the table. |
style |
str | None
|
Get / set the style of the table. |
traverse |
|
|
traverse_columns |
|
|
width |
int
|
Get the current width of the table, measured on columns. |
Source code in odfdo/table.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 | |
cells
property
cells: list
Get all cells of the table.
Returns: list of list of Cell
columns
property
columns: list[Column]
Get the list of all columns matching the criteria.
Copies are returned, use set_column() to push them back.
Returns: list of columns
height
property
height: int
Get the current height of the table.
Returns: int
name
property
writable
name: str | None
Get / set the name of the table.
The “name” parameter is required and cannot contain []*?:/ or \ characters, ’ (apostrophe) cannot be the first or last character.
print_ranges
property
writable
print_ranges: list[str]
printable
property
writable
printable: bool
protected
property
writable
protected: bool
protection_key
property
writable
protection_key: str | None
row_groups
property
row_groups: list[RowGroup]
Get the list of all RowGroup.
Returns: list of RowGroup
set_protection_key
instance-attribute
set_protection_key = protection_key
size
property
size: tuple[int, int]
Shortcut to get the current width and height of the table.
Returns: (int, int)
style
property
writable
style: str | None
Get / set the style of the table.
Returns: str
width
property
width: int
Get the current width of the table, measured on columns.
Rows may have different widths, use the Table API to ensure width consistency.
Returns: int
__init__
__init__(
name: str | None = None,
width: int | str | None = None,
height: int | str | None = None,
protected: bool = False,
protection_key: str | None = None,
printable: bool = True,
print_ranges: list[str] | None = None,
style: str | None = None,
**kwargs: Any,
) -> None
Create a table element “table:table”, optionally prefilled with “height” rows of “width” cells each.
The “name” parameter is required and cannot contain []*?:/ or \ characters, ’ (apostrophe) cannot be the first or last character.
If the table is to be protected, a protection key must be provided, i.e. a hash value of the password.
If the table must not be printed, set “printable” to False. The table will not be printed when it is not displayed, whatever the value of this argument.
Ranges of cells to print can be provided as a list of cell ranges, e.g. [‘E6:K12’, ‘P6:R12’] or directly as a raw string, e.g. “E6:K12 P6:R12”.
You can access and modify the XML tree manually, but you probably want to use the API to access and alter cells. It will save you from handling repetitions and the same number of cells for each row.
If you use both the table API and the XML API, you are on your own for ensuring model integrity.
Args:
name -- str
width -- int | str
height -- int | str
protected -- bool
protection_key -- str
printable -- bool
print_ranges -- list
style -- str
Source code in odfdo/table.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
append
append(something: Element | str) -> None
Dispatch .append() call to append_row() or append_column().
Source code in odfdo/table.py
588 589 590 591 592 593 594 595 596 | |
append_cell
Append the given cell at the “y” coordinate. Repeated cells are accepted. If no cell is given, an empty one is created.
Position start at 0. So cell A4 is on row 3.
Other rows remain untouched.
Args:
y -- int or str
cell -- Cell
returns the cell with x and y updated
Source code in odfdo/table.py
1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 | |
append_column
Append the column at the end of the table. If no column is given, an empty one is created.
ODF columns don’t contain cells, only style information.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
Args:
column -- Column
_repeated -- (optional), repeated value of the column
Source code in odfdo/table.py
2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 | |
append_named_range
append_named_range(
named_range: NamedRange, global_scope: bool = True
) -> None
Append the named range to the document.
An existing named range of same name is replaced.
If “global_scope” is True (default), append in the document body, else to the current Table.
Named ranges can be local to the Table or global. Global named ranges are stored at the body level, thus do not call this method on a cloned table if you need to access to the global named ranges.
Args:
named_range -- NamedRange
global_scope -- bool, search in entire document or in the current table.
Source code in odfdo/table.py
2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 | |
append_row
Append the row at the end of the table. If no row is given, an empty one is created.
Position start at 0. So cell A4 is on row 3.
Note the columns are automatically created when the first row is inserted in an empty table. So better insert a filled row.
Args:
row -- Row
_repeated -- (optional), repeated value of the row
returns the row, with updated row.y
Source code in odfdo/table.py
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 | |
clear
clear() -> None
Remove text, children and attributes from the Row.
Source code in odfdo/table.py
253 254 255 256 | |
del_span
del_span(area: str | tuple | list) -> bool
Delete a Cell Span. ‘area’ is the cell coordinate of the upper left cell of the spanned area.
Area can be either one cell (like ‘A1’) or an area (‘A1:B2’). It can be provided as an alpha numeric value like “A1:B2’ or a tuple like (0, 0, 1, 1) or (0, 0). If an area is provided, the upper left cell is used.
Args:
area -- str or tuple of int, cell or area coordinate
Source code in odfdo/table.py
2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 | |
delete_cell
delete_cell(coord: tuple | list | str) -> None
Delete the cell at the given coordinates, so that next cells are shifted to the left.
Coordinates are either a 2-tuple of (x, y) starting from 0, or a human-readable position like “C4”.
Use set_value() for erasing value.
Args:
coord -- (int, int) or str
Source code in odfdo/table.py
1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 | |
delete_column
delete_column(x: int | str) -> None
Delete the column at the given position. ODF columns don’t contain cells, only style information.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
Args:
x -- int or str
Source code in odfdo/table.py
2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 | |
delete_named_range
delete_named_range(
name: str, global_scope: bool = True
) -> None
Delete the Named Range of specified name.
If “global_scope” is True (default), search in the entire document, else limit search to the current Table.
Named ranges can be local to the Table or global. Global named ranges are stored at the body level, thus do not call this method on a cloned table if you need to access to the global named ranges.
Args:
name -- str
global_scope -- bool, search in entire document or in the current table.
Source code in odfdo/table.py
2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 | |
delete_row
delete_row(y: int | str) -> None
Delete the row at the given “y” position.
Position start at 0. So cell A4 is on row 3.
Args:
y -- int or str
Source code in odfdo/table.py
1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 | |
extend_rows
extend_rows(rows: list[Row] | None = None) -> None
Append a list of rows at the end of the table.
Args:
rows -- list of Row
Source code in odfdo/table.py
1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 | |
from_csv
classmethod
from_csv(
content: str,
name: str,
style: str | None = None,
**fmtparams: Any,
) -> Table
Import the CSV text content into a Table.
If the path_or_file parameter is a Path or a string, it is opened as a path. Else a opened file-like is expected.
CSV format can be autodetected to a certain limit. Use **fmtparams to define cvs.reader parameters.
Args:
contenr – str, CSV content
name – str, name of the Table
style – str, style of the Table
**fmtparams – names parameters passed to csv.reader method
Source code in odfdo/table.py
2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 | |
get_cell
get_cell(
coord: tuple | list | str,
clone: bool = True,
keep_repeated: bool = True,
) -> Cell
Get the cell at the given coordinates.
They are either a 2-tuple of (x, y) starting from 0, or a human-readable position like “C4”.
A copy is returned, use set_cell to push it back.
Args:
coord -- (int, int) or str
Returns: Cell
Source code in odfdo/table.py
1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 | |
get_cells
get_cells(
coord: tuple | list | str | None = None,
cell_type: str | None = None,
style: str | None = None,
content: str | None = None,
flat: bool = False,
) -> list
Get the cells matching the criteria. If ‘coord’ is None, parse the whole table, else parse the area defined by ‘coord’.
Filter by cell_type = “all” will retrieve cells of any type, aka non empty cells.
If flat is True (default is False), the method return a single list of all the values, else a list of lists of cells.
if cell_type, style and content are None, get_cells() will return the exact number of cells of the area, including empty cells.
Args:
coordinates -- str or tuple of int : coordinates of area
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency', 'percentage' or 'all'
content -- str regex
style -- str
flat -- boolean
Returns: list of list of Cell
Source code in odfdo/table.py
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 | |
get_column
get_column(x: int | str) -> Column
Get the column at the given “x” position.
ODF columns don’t contain cells, only style information.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
A copy is returned, use set_column() to push it back.
Args:
x -- int or str
Returns: Column
Source code in odfdo/table.py
2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 | |
get_column_cells
get_column_cells(
x: int | str,
style: str | None = None,
content: str | None = None,
cell_type: str | None = None,
complete: bool = False,
) -> list[Cell | None]
Get the list of cells at the given position.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
Filter by cell_type, with cell_type ‘all’ will retrieve cells of any type, aka non empty cells.
If complete is True, replace missing values by None.
Args:
x -- int or str
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency', 'percentage' or 'all'
content -- str regex
style -- str
complete -- boolean
Returns: list of Cell
Source code in odfdo/table.py
2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 | |
get_column_values
get_column_values(
x: int | str,
cell_type: str | None = None,
complete: bool = True,
get_type: bool = False,
) -> list[Any]
Shortcut to get the list of Python values for the cells at the given position.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
Filter by cell_type, with cell_type ‘all’ will retrieve cells of any type, aka non empty cells. If cell_type and complete is True, replace missing values by None.
If get_type is True, returns a tuple (value, ODF type of value)
Args:
x -- int or str
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency', 'percentage' or 'all'
complete -- boolean
get_type -- boolean
Returns: list of Python types
Source code in odfdo/table.py
2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 | |
get_columns
get_columns(
coord: tuple | list | str | None = None,
style: str | None = None,
) -> list[Column]
Get the list of columns matching the criteria.
Copies are returned, use set_column() to push them back.
Args:
coord -- str or tuple of int : coordinates of columns
style -- str
Returns: list of columns
Source code in odfdo/table.py
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 | |
get_elements
get_elements(xpath_query: XPath | str) -> list[Element]
Source code in odfdo/table.py
235 236 237 238 239 240 241 242 243 244 245 246 247 | |
get_formatted_text
get_formatted_text(context: dict | None = None) -> str
Source code in odfdo/table.py
698 699 700 701 | |
get_named_range
get_named_range(
name: str, global_scope: bool = True
) -> NamedRange | None
Return the Name Range of the specified name.
If “global_scope” is True (default), search in the entire document, else limit search to the current Table.
Named ranges can be local to the Table or global. Global named ranges are stored at the body level, thus do not call this method on a cloned table if you need to access to the global named ranges.
Args:
name -- str, name of the named range object
global_scope -- bool, search in entire document or in the current table.
Returns : NamedRange or None
Source code in odfdo/table.py
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 | |
get_named_ranges
get_named_ranges(
table_name: str | list[str] | None = None,
global_scope: bool = True,
) -> list[NamedRange]
Return the list of Name Ranges.
If “global_scope” is True (default), search in the entire document, else limit search to the current Table. If “table_name” is provided, limits the search to these tables.
Named ranges can be local to the Table or global. Global named ranges are stored at the body level, thus do not call this method on a cloned table if you need to access to the global named ranges.
Args:
table_names -- str or list of str, names of tables
global_scope -- bool, search in entire document or in the current table.
Returns : list of NamedRange
Source code in odfdo/table.py
2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 | |
get_row
get_row(
y: int | str, clone: bool = True, create: bool = True
) -> Row
Get the row at the given “y” position.
Position start at 0. So cell A4 is on row 3.
A copy is returned, use set_cell() to push it back.
Args:
y -- int or str
Returns: Row
Source code in odfdo/table.py
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 | |
get_row_sub_elements
get_row_sub_elements(y: int | str) -> list[Any]
Shortcut to get the list of Elements values for the cells of the row at the given “y” position.
Position start at 0. So cell A4 is on row 3.
Missing values replaced by None.
Args:
y -- int, str
Returns: list of lists of Elements
Source code in odfdo/table.py
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 | |
get_row_values
get_row_values(
y: int | str,
cell_type: str | None = None,
complete: bool = True,
get_type: bool = False,
) -> list
Shortcut to get the list of Python values for the cells of the row at the given “y” position.
Position start at 0. So cell A4 is on row 3.
Filter by cell_type, with cell_type ‘all’ will retrieve cells of any type, aka non empty cells. If cell_type and complete is True, replace missing values by None.
If get_type is True, returns a tuple (value, ODF type of value)
Args:
y -- int, str
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency', 'percentage' or 'all'
complete -- boolean
get_type -- boolean
Returns: list of lists of Python types
Source code in odfdo/table.py
1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 | |
get_rows
get_rows(
coord: tuple | list | str | None = None,
style: str | None = None,
content: str | None = None,
) -> list[Row]
Get the list of rows matching the criteria.
Filter by coordinates will parse the area defined by the coordinates.
Args:
coord -- str or tuple of int : coordinates of rows
content -- str regex
style -- str
Returns: list of rows
Source code in odfdo/table.py
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 | |
get_value
get_value(
coord: tuple | list | str, get_type: bool = False
) -> Any
Shortcut to get the Python value of the cell at the given coordinates.
If get_type is True, returns the tuples (value, ODF type)
coord is either a 2-tuple of (x, y) starting from 0, or a human-readable position like “C4”. If an Area is given, the upper left position is used as coord.
Args:
coord -- (int, int) or str : coordinate
Returns: Python type
Source code in odfdo/table.py
1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 | |
get_values
get_values(
coord: tuple | list | str | None = None,
cell_type: str | None = None,
complete: bool = True,
get_type: bool = False,
flat: bool = False,
) -> list
Get a matrix of values of the table.
Filter by coordinates will parse the area defined by the coordinates.
If ‘cell_type’ is used and ‘complete’ is True (default), missing values are replaced by None. Filter by ’ cell_type = “all” ’ will retrieve cells of any type, aka non empty cells.
If ‘cell_type’ is None, complete is always True : with no cell type queried, get_values() returns None for each empty cell, the length each lists is equal to the width of the table.
If get_type is True, returns tuples (value, ODF type of value), or (None, None) for empty cells with complete True.
If flat is True, the methods return a single list of all the values. By default, flat is False.
Args:
coord -- str or tuple of int : coordinates of area
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency', 'percentage' or 'all'
complete -- boolean
get_type -- boolean
Returns: list of lists of Python types
Source code in odfdo/table.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 | |
insert_cell
Insert the given cell at the given coordinates. If no cell is given, an empty one is created.
Coordinates are either a 2-tuple of (x, y) starting from 0, or a human-readable position like “C4”.
Cells on the right are shifted. Other rows remain untouched.
Args:
coord -- (int, int) or str
cell -- Cell
returns the cell with x and y updated
Source code in odfdo/table.py
1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 | |
insert_column
Insert the column before the given “x” position. If no column is given, an empty one is created.
ODF columns don’t contain cells, only style information.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
Args:
x -- int or str
column -- Column
Source code in odfdo/table.py
2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 | |
insert_row
Insert the row before the given “y” position. If no row is given, an empty one is created.
Position start at 0. So cell A4 is on row 3.
If row is None, a new empty row is created.
Args:
y -- int or str
row -- Row
returns the row, with updated row.y
Source code in odfdo/table.py
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 | |
is_column_empty
is_column_empty(
x: int | str, aggressive: bool = False
) -> bool
Return wether every cell in the column at “x” position has no value or the value evaluates to False (empty string), and no style.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
If aggressive is True, empty cells with style are considered empty.
Returns: bool
Source code in odfdo/table.py
2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 | |
is_empty
is_empty(aggressive: bool = False) -> bool
Return whether every cell in the table has no value or the value evaluates to False (empty string), and no style.
If aggressive is True, empty cells with style are considered empty.
Args:
aggressive -- bool
Source code in odfdo/table.py
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 | |
is_row_empty
is_row_empty(
y: int | str, aggressive: bool = False
) -> bool
Return wether every cell in the row at the given “y” position has no value or the value evaluates to False (empty string), and no style.
Position start at 0. So cell A4 is on row 3.
If aggressive is True, empty cells with style are considered empty.
Args:
y -- int or str
aggressive -- bool
Source code in odfdo/table.py
1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 | |
iter_columns
iter_columns(
start: int | None = None, end: int | None = None
) -> Iterator[Column]
Yield as many column elements as expected columns in the table, i.e. expand repetitions by returning the same column as many times as necessary.
Args:
start -- int
end -- int
Copies are returned, use set_column() to push them back.
Source code in odfdo/table.py
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | |
iter_rows
iter_rows(
start: int | None = None, end: int | None = None
) -> Iterator[Row]
Yield as many row elements as expected rows in the table, i.e. expand repetitions by returning the same row as many times as necessary.
Copies are returned, use set_row() to push them back.
Args:
start -- int
end -- int
Source code in odfdo/table.py
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 | |
iter_values
iter_values(
coord: tuple | list | str | None = None,
cell_type: str | None = None,
complete: bool = True,
get_type: bool = False,
) -> Iterator[list]
Yield lines (lists) of Python values of the table.
Filter by coordinates will parse the area defined by the coordinates.
cell_type, complete, grt_type : see get_values()
Args:
coord -- str or tuple of int : coordinates of area
cell_type -- 'boolean', 'float', 'date', 'string', 'time',
'currency', 'percentage' or 'all'
complete -- boolean
get_type -- boolean
Returns: iterator of lists
Source code in odfdo/table.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 | |
optimize_width
optimize_width() -> None
Remove in-place empty rows below and empty cells at the right of the table.
Keep repeated styles of empty cells but minimize row width.
Source code in odfdo/table.py
940 941 942 943 944 945 946 947 948 949 | |
rstrip
rstrip(aggressive: bool = False) -> None
Remove in-place empty rows below and empty cells at the right of the table. Cells are empty if they contain no value or it evaluates to False, and no style.
If aggressive is True, empty cells with style are removed too.
Argument:
aggressive -- bool
Source code in odfdo/table.py
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 | |
set_cell
Replace a cell of the table at the given coordinates.
They are either a 2-tuple of (x, y) starting from 0, or a human-readable position like “C4”.
Args:
coord -- (int, int) or str : coordinate
cell -- Cell
return the cell, with x and y updated
Source code in odfdo/table.py
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 | |
set_cell_image
set_cell_image(
coord: tuple | list | str,
image_frame: Frame,
doc_type: str | None = None,
) -> None
Deprecated, see related recipes to achieve the desired result.
Do all the magic to display an image in the cell at the given coordinates.
They are either a 2-tuple of (x, y) starting from 0, or a human-readable position like “C4”.
The frame element must contain the expected image position and dimensions.
DrawImage insertion depends on the document type, so the type must be provided or the table element must be already attached to a document.
Args:
coord -- (int, int) or str
image_frame -- Frame including an image
doc_type -- 'spreadsheet' or 'text'
Source code in odfdo/table.py
1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 | |
set_cells
set_cells(
cells: list[list[Cell]] | list[tuple[Cell]],
coord: tuple | list | str | None = None,
clone: bool = True,
) -> None
Set the cells in the table, from the ‘coord’ position.
‘coord’ is the coordinate of the upper left cell to be modified by values. If ‘coord’ is None, default to the position (0,0) (“A1”). If ‘coord’ is an area (e.g. “A2:B5”), the upper left position of this area is used as coordinate.
The table is not cleared before the operation, to reset the table before setting cells, use table.clear().
A list of lists is expected, with as many lists as rows to be set, and as many cell in each sublist as cells to be set in the row.
Args:
cells -- list of list of cells
coord -- tuple or str
values -- list of lists of python types
Source code in odfdo/table.py
1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 | |
set_column
Replace the column at the given “x” position.
ODF columns don’t contain cells, only style information.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
Args:
x -- int or str
column -- Column
Source code in odfdo/table.py
2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 | |
set_column_cells
set_column_cells(x: int | str, cells: list[Cell]) -> None
Shortcut to set the list of cells at the given position.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
The list must have the same length than the table height.
Args:
x -- int or str
cells -- list of Cell
Source code in odfdo/table.py
2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 | |
set_column_values
set_column_values(
x: int | str,
values: list,
cell_type: str | None = None,
currency: str | None = None,
style: str | None = None,
) -> None
Shortcut to set the list of Python values of cells at the given position.
Position start at 0. So cell C4 is on column 2. Alphabetical position like “C” is accepted.
The list must have the same length than the table height.
Args:
x -- int or str
values -- list of Python types
cell_type -- 'boolean', 'currency', 'date', 'float', 'percentage',
'string' or 'time'
currency -- three-letter str
style -- str
Source code in odfdo/table.py
2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 | |
set_named_range
set_named_range(
name: str,
crange: str | tuple | list,
table_name: str | None = None,
usage: str | None = None,
global_scope: bool = True,
) -> None
Create a Named Range element and insert it in the document.
An existing named range of same name is replaced.
If “global_scope” is True (default), insert in the document’s body, else to the current Table. If “table_name” is None, use current table name.
Named ranges can be local to the Table or global. Global named ranges are stored at the body level, thus do not call this method on a cloned table if you need to access to the global named ranges.
Args:
name -- str, name of the named range
crange -- str or tuple of int, cell or area coordinate
table_name -- str or None, name of the table
usage -- None or 'print-range', 'filter', 'repeat-column', 'repeat-row'
global_scope -- bool, search in entire document or in the current table.
Source code in odfdo/table.py
2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 | |
set_row
Replace the row at the given position with the new one. Repetitions of the old row will be adjusted.
If row is None, a new empty row is created.
Position start at 0. So cell A4 is on row 3.
Args:
y -- int or str
row -- Row
returns the row, with updated row.y
Source code in odfdo/table.py
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 | |
set_row_cells
set_row_cells(
y: int | str, cells: list | None = None
) -> Row
Shortcut to set all the cells of the row at the given “y” position.
Position start at 0. So cell A4 is on row 3.
Args:
y -- int or str
cells -- list of Python types
style -- str
returns the row, with updated row.y
Source code in odfdo/table.py
1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 | |
set_row_values
set_row_values(
y: int | str,
values: list,
cell_type: str | None = None,
currency: str | None = None,
style: str | None = None,
) -> Row
Shortcut to set the values of all cells of the row at the given “y” position.
Position start at 0. So cell A4 is on row 3.
Args:
y -- int or str
values -- list of Python types
cell_type -- 'boolean', 'currency', 'date', 'float', 'percentage',
'string' or 'time'
currency -- three-letter str
style -- str
returns the row, with updated row.y
Source code in odfdo/table.py
1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 | |
set_span
set_span(
area: str | tuple | list, merge: bool = False
) -> bool
Create a Cell Span : span the first cell of the area on several columns and/or rows.
If merge is True, replace text of the cell by the concatenation of existing text in covered cells. Beware : if merge is True, old text is changed, if merge is False (the default), old text in covered cells is still present but not displayed by most GUI.
If the area defines only one cell, the set span will do nothing. It is not allowed to apply set span to an area whose one cell already belongs to previous cell span.
Area can be either one cell (like ‘A1’) or an area (‘A1:B2’). It can be provided as an alpha numeric value like “A1:B2’ or a tuple like (0, 0, 1, 1) or (0, 0).
Args:
area -- str or tuple of int, cell or area coordinate
merge -- boolean
Source code in odfdo/table.py
2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 | |
set_value
set_value(
coord: tuple | list | str,
value: Any,
cell_type: str | None = None,
currency: str | None = None,
style: str | None = None,
) -> None
Set the Python value of the cell at the given coordinates.
They are either a 2-tuple of (x, y) starting from 0, or a human-readable position like “C4”.
Args:
coord -- (int, int) or str
value -- Python type
cell_type -- 'boolean', 'currency', 'date', 'float', 'percentage',
'string' or 'time'
currency -- three-letter str
style -- str
Source code in odfdo/table.py
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 | |
set_values
set_values(
values: list,
coord: tuple | list | str | None = None,
style: str | None = None,
cell_type: str | None = None,
currency: str | None = None,
) -> None
Set the value of cells in the table, from the ‘coord’ position with values.
‘coord’ is the coordinate of the upper left cell to be modified by values. If ‘coord’ is None, default to the position (0,0) (“A1”). If ‘coord’ is an area (e.g. “A2:B5”), the upper left position of this area is used as coordinate.
The table is not cleared before the operation, to reset the table before setting values, use table.clear().
A list of lists is expected, with as many lists as rows, and as many items in each sublist as cells to be set. None values in the list will create empty cells with no cell type (but eventually a style).
Args:
coord -- tuple or str
values -- list of lists of python types
cell_type -- 'boolean', 'currency', 'date', 'float', 'percentage',
'string' or 'time'
currency -- three-letter str
style -- str
Source code in odfdo/table.py
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | |
to_csv
to_csv(
path_or_file: str | Path | None = None,
dialect: str = "excel",
**fmtparams: Any,
) -> str | None
Export the table as CSV.
Save the CSV content to the path_or_file path, or return the content text if path_or_file is None.
Args:
path_or_file -- str or Path or None
dialect -- str, python csv.dialect, can be 'excel', 'unix'...
**fmtparams -- names parameters passed to csv.writer method
Source code in odfdo/table.py
2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 | |
transpose
transpose(coord: tuple | list | str | None = None) -> None
Swap in-place rows and columns of the table.
If ‘coord’ is not None, apply transpose only to the area defined by the coordinates. Beware, if area is not square, some cells mays be over written during the process.
Args:
coord -- str or tuple of int : coordinates of area
start -- int or str
Source code in odfdo/table.py
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 | |
Text
Bases: NRMixin, Body
Root of the Text document content, “office:text”.
Source code in odfdo/body.py
272 273 274 275 276 | |
TextChange
Bases: Element
A text change position, “text:change”.
The TextChange “text:change” element marks a position in an empty region where text has been deleted.
Methods:
| Name | Description |
|---|---|
get_change_element |
|
get_change_info |
|
get_changed_region |
|
get_deleted |
Shortcut to get the deleted information stored in the TextDeletion |
get_end |
Return None. |
get_id |
|
get_inserted |
Return None. |
get_start |
Return None. |
set_id |
|
Source code in odfdo/tracked_changes.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | |
get_change_element
Source code in odfdo/tracked_changes.py
534 535 536 537 538 539 540 541 | |
get_change_info
Source code in odfdo/tracked_changes.py
525 526 527 528 529 530 531 532 | |
get_changed_region
Source code in odfdo/tracked_changes.py
516 517 518 519 520 521 522 523 | |
get_deleted
get_deleted(
tracked_changes: Element | None = None,
as_text: bool = False,
no_header: bool = False,
clean: bool = True,
) -> Element | None
Shortcut to get the deleted information stored in the TextDeletion stored in the tracked changes.
Returns: Paragraph (or None).”
Source code in odfdo/tracked_changes.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
get_end
get_end() -> TextChangeEnd | None
Return None.
Source code in odfdo/tracked_changes.py
576 577 578 | |
get_id
get_id() -> str | None
Source code in odfdo/tracked_changes.py
504 505 | |
get_inserted
get_inserted(
as_text: bool = False,
no_header: bool = False,
clean: bool = True,
) -> str | Element | list[Element] | None
Return None.
Source code in odfdo/tracked_changes.py
563 564 565 566 567 568 569 570 | |
get_start
get_start() -> TextChangeStart | None
Return None.
Source code in odfdo/tracked_changes.py
572 573 574 | |
set_id
set_id(idx: str) -> None
Source code in odfdo/tracked_changes.py
507 508 | |
TextChangeEnd
Bases: TextChange
End of a changed region, “text:change-end”.
The TextChangeEnd “text:change-end” element marks the end of a region with content where text has been inserted or the format has been changed.
Methods:
| Name | Description |
|---|---|
get_deleted |
Return None. |
get_end |
Return self. |
get_inserted |
Return the content between text:change-start and text:change-end. |
get_start |
Return the corresponding annotation starting tag or None. |
Source code in odfdo/tracked_changes.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | |
get_deleted
get_deleted(*args: Any, **kwargs: Any) -> Element | None
Return None.
Source code in odfdo/tracked_changes.py
605 606 607 | |
get_end
get_end() -> TextChangeEnd | None
Return self.
Source code in odfdo/tracked_changes.py
601 602 603 | |
get_inserted
get_inserted(
as_text: bool = False,
no_header: bool = False,
clean: bool = True,
) -> str | Element | list[Element] | None
Return the content between text:change-start and text:change-end.
If no content exists (deletion tag), returns None (or ‘’ if text flag is True). If as_text is True: returns the text content. If clean is True: suppress unwanted tags (deletions marks, …) If no_header is True: existing text:h are changed in text:p By default: returns a list of Element, cleaned and with headers
Args:
as_text -- boolean
clean -- boolean
no_header -- boolean
Returns: list or Element or text
Source code in odfdo/tracked_changes.py
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | |
get_start
get_start() -> TextChangeStart | None
Return the corresponding annotation starting tag or None.
Source code in odfdo/tracked_changes.py
590 591 592 593 594 595 596 597 598 599 | |
TextChangeStart
Bases: TextChangeEnd
Start of a changed region, “text:change-start”.
The TextChangeStart “text:change-start” element marks the start of a region with content where text has been inserted or the format has been changed.
Methods:
| Name | Description |
|---|---|
delete |
Delete the given element from the XML tree. If no element is given, |
get_end |
Return the corresponding change-end tag or None. |
get_start |
Return self. |
Source code in odfdo/tracked_changes.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | |
delete
delete(
child: Element | None = None, keep_tail: bool = True
) -> None
Delete the given element from the XML tree. If no element is given, “self” is deleted. The XML library may allow to continue to use an element now “orphan” as long as you have a reference to it.
For TextChangeStart : delete also the end tag if exists.
Args:
child -- Element
keep_tail -- boolean (default to True), True for most usages.
Source code in odfdo/tracked_changes.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | |
get_end
get_end() -> TextChangeEnd
Return the corresponding change-end tag or None.
Source code in odfdo/tracked_changes.py
661 662 663 664 665 666 667 668 669 670 | |
get_start
get_start() -> TextChangeStart
Return self.
Source code in odfdo/tracked_changes.py
657 658 659 | |
TextChangedRegion
Bases: Element
A changed region of text, “text:changed-region”.
Each TextChangedRegion “text:changed-region” element contains a single element, one of TextInsertion, TextDeletion or TextFormatChange that corresponds to a change being tracked within the scope of the “text:tracked-changes” element that contains the “text:changed-region” instance. The xml:id attribute of the TextChangedRegion is referenced from the “text:change”, “text:change-start” and “text:change-end” elements that identify where the change applies to markup in the scope of the “text:tracked-changes” element.
Warning :
For this implementation, text:change should be referenced only once in the scope, which is different from ODF 1.2 requirement:
" A "text:changed-region" can be referenced by more than one
change, but the corresponding referencing change mark elements
shall be of the same change type - insertion, format change or
deletion. "
Methods:
| Name | Description |
|---|---|
get_change_element |
Get the change element child. It can be either: TextInsertion, |
get_change_info |
Shortcut to get the ChangeInfo element of the change element child. |
get_id |
Get the “text:id” attribute. |
set_change_info |
Shortcut to set the ChangeInfo element of the sub change element. |
set_id |
Set both the “text:id” and “xml:id” attributes with same value. |
Source code in odfdo/tracked_changes.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
get_change_element
get_change_element() -> Element | None
Get the change element child. It can be either: TextInsertion, TextDeletion, or TextFormatChange as an Element object.
Returns: Element.
Source code in odfdo/tracked_changes.py
400 401 402 403 404 405 406 407 408 409 410 411 | |
get_change_info
get_change_info() -> Element | None
Shortcut to get the ChangeInfo element of the change element child.
Returns: ChangeInfo element.
Source code in odfdo/tracked_changes.py
366 367 368 369 370 371 | |
get_id
get_id() -> str | None
Get the “text:id” attribute.
Returns: str
Source code in odfdo/tracked_changes.py
425 426 427 428 429 430 | |
set_change_info
set_change_info(
change_info: Element | None = None,
creator: str | None = None,
date: datetime | None = None,
comments: Element | list[Element] | None = None,
) -> None
Shortcut to set the ChangeInfo element of the sub change element. See TextInsertion.set_change_info() for details.
Args:
change_info -- ChangeInfo element (or None)
creator -- str (or None)
date -- datetime (or None)
comments -- Paragraph or list of Paragraph elements (or None)
Source code in odfdo/tracked_changes.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
set_id
set_id(idx: str) -> None
Set both the “text:id” and “xml:id” attributes with same value.
Source code in odfdo/tracked_changes.py
432 433 434 435 | |
TextDeletion
Bases: TextInsertion
Information on a text deletion, “text:deletion”.
The TextDeletion “text:deletion” contains information that identifies the person responsible for a deletion and the date of that deletion. This information may also contain one or more Paragraph which contains a comment on the deletion. The TextDeletion element may also contain content that was deleted while change tracking was enabled. The position where the text was deleted is marked by a “text:change” element. Deleted text is contained in a paragraph element. To reconstruct the original text, the paragraph containing the deleted text is merged with its surrounding paragraph or heading element. To reconstruct the text before a deletion took place: - If the change mark is inside a paragraph, insert the content that was deleted, but remove all leading start tags up to and including the first “text:p” element and all trailing end tags up to and including the last “/text:p” or “/text:h” element. If the last trailing element is a “/text:h”, change the end tag “/text:p” following this insertion to a “/text:h” element. - If the change mark is inside a heading, insert the content that was deleted, but remove all leading start tags up to and including the first “text:h” element and all trailing end tags up to and including the last “/text:h” or “/text:p” element. If the last trailing element is a “/text:p”, change the end tag “/text:h” following this insertion to a “/text:p” element. - Otherwise, copy the text content of the “text:deletion” element in place of the change mark.
Methods:
| Name | Description |
|---|---|
get_deleted |
Get the deleted information stored in the TextDeletion. |
get_inserted |
Return None. |
set_deleted |
Set the deleted information stored in the TextDeletion. An actual |
Source code in odfdo/tracked_changes.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
get_deleted
get_deleted(
as_text: bool = False, no_header: bool = False
) -> str | list[Element] | None
Get the deleted information stored in the TextDeletion. If as_text is True: returns the text content. If no_header is True: existing Heading are changed in Paragraph
Args:
as_text -- boolean
no_header -- boolean
Returns: Paragraph and Header list
Source code in odfdo/tracked_changes.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
get_inserted
get_inserted(
as_text: bool = False,
no_header: bool = False,
clean: bool = True,
) -> str | Element | list[Element] | None
Return None.
Source code in odfdo/tracked_changes.py
313 314 315 316 317 318 319 320 321 322 | |
set_deleted
Set the deleted information stored in the TextDeletion. An actual content that was deleted is expected, embedded in a Paragraph element or Header.
Args:
paragraph_or_list -- Paragraph or Header element (or list)
Source code in odfdo/tracked_changes.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
TextFormatChange
Bases: TextInsertion
A change in text formatting, “text:format-change”.
The TextFormatChange “text:format-change” element represents any change in formatting attributes. The region where the change took place is marked by “text:change-start”, “text:change-end” or “text:change” elements.
Note: This element does not contain formatting changes that have taken place.
Source code in odfdo/tracked_changes.py
325 326 327 328 329 330 331 332 333 334 335 336 337 | |
TextInsertion
Bases: Element
Information on a text insertion, “text:insertion”.
The TextInsertion “text:insertion” element contains the information that identifies the person responsible for a change and the date of that change. This information may also contain one or more “text:p” Paragraph which contain a comment on the insertion. The TextInsertion element’s parent “text:changed-region” element has an xml:id or text:id attribute, the value of which binds that parent element to the text:change-id attribute on the “text:change-start” and “text:change-end” elements.
Methods:
| Name | Description |
|---|---|
get_change_info |
Get the ChangeInfo child of the element. |
get_deleted |
Returns: None. |
get_inserted |
Shortcut to text:change-start.get_inserted(). Return the content |
set_change_info |
Set the ChangeInfo element for the change element. If change_info is |
Source code in odfdo/tracked_changes.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
get_change_info
get_change_info() -> Element | None
Get the ChangeInfo child of the element.
Returns: ChangeInfo element.
Source code in odfdo/tracked_changes.py
173 174 175 176 177 178 | |
get_deleted
get_deleted(
as_text: bool = False, no_header: bool = False
) -> str | list[Element] | None
Returns: None.
Source code in odfdo/tracked_changes.py
127 128 129 130 131 132 133 134 135 | |
get_inserted
get_inserted(
as_text: bool = False,
no_header: bool = False,
clean: bool = True,
) -> str | Element | list[Element] | None
Shortcut to text:change-start.get_inserted(). Return the content between text:change-start and text:change-end.
If as_text is True: returns the text content. If no_header is True: existing Heading are changed in Paragraph If no_header is True: existing text:h are changed in text:p By default: returns a list of Element, cleaned and with headers
Args:
as_text -- boolean
clean -- boolean
no_header -- boolean
Returns: list or Element or text
Source code in odfdo/tracked_changes.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
set_change_info
set_change_info(
change_info: Element | None = None,
creator: str | None = None,
date: datetime | None = None,
comments: Element | list[Element] | None = None,
) -> None
Set the ChangeInfo element for the change element. If change_info is not provided, creator, date and comments will be used to build a suitable change info element. Default for creator is ‘Unknown’, default for date is current time and default for comments is no comment at all. The new change info element will replace any existent ChangeInfo.
Args:
change_info -- ChangeInfo element (or None)
cretor -- str (or None)
date -- datetime (or None)
comments -- Paragraph or list of Paragraph elements (or None)
Source code in odfdo/tracked_changes.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
TocEntryTemplate
Bases: Element
Template for entry of TOC, “text:table-of-content-entry-template”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create template for entry of TOC “text:table-of-content-entry- |
complete_defaults |
|
Attributes:
| Name | Type | Description |
|---|---|---|
outline_level |
int | None
|
|
style |
|
Source code in odfdo/toc.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | |
outline_level
property
writable
outline_level: int | None
style
instance-attribute
style = style
__init__
__init__(
style: str | None = None,
outline_level: int | None = None,
**kwargs: Any,
) -> None
Create template for entry of TOC “text:table-of-content-entry- template”.
Args:
style -- str
Source code in odfdo/toc.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
complete_defaults
complete_defaults() -> None
Source code in odfdo/toc.py
526 527 528 529 530 531 532 533 534 | |
TrackedChanges
Bases: MDZap, Element
A tracked change, “text:tracked-changes”.
The TrackedChanges “text:tracked-changes” element acts as a container for TextChangedRegion elements that represent changes in a certain scope of an OpenDocument document. This scope is the element in which the TrackedChanges element occurs. Changes in this scope shall be tracked by TextChangedRegion elements contained in the TrackedChanges element in this scope. If a TrackedChanges element is absent, there are no tracked changes in the corresponding scope. In this case, all change mark elements in this scope shall be ignored.
Methods:
| Name | Description |
|---|---|
get_changed_region |
|
get_changed_regions |
|
Source code in odfdo/tracked_changes.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
get_changed_region
get_changed_region(
position: int = 0,
text_id: str | None = None,
creator: str | None = None,
date: datetime | None = None,
content: str | None = None,
) -> Element | None
Source code in odfdo/tracked_changes.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
get_changed_regions
get_changed_regions(
creator: str | None = None,
date: datetime | None = None,
content: str | None = None,
role: str | None = None,
) -> list[Element]
Source code in odfdo/tracked_changes.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
UserDefined
Bases: ElementTyped
A user defined field, “text:user-defined”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a user defined field “text:user-defined”. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
|
style |
|
|
text |
|
Source code in odfdo/user_field.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
name
instance-attribute
name = name
style
instance-attribute
style = style
text
instance-attribute
text = text
__init__
__init__(
name: str = "",
value: Any = None,
value_type: str | None = None,
text: str | None = None,
style: str | None = None,
from_document: Document | None = None,
**kwargs: Any,
) -> None
Create a user defined field “text:user-defined”.
If the current document is provided, try to extract the content of the meta user defined field of same name.
Args:
name -- str, name of the user defined field
value -- python typed value, value of the field
value_type -- str, office:value-type known type
text -- str
style -- str
from_document -- ODF document
Source code in odfdo/user_field.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
UserFieldDecl
Bases: ElementTyped
Declaration of a user field, “text:user-field-decl”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a user field “text:user-field-decl”. |
set_value |
|
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
Source code in odfdo/user_field.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
name
instance-attribute
name = name
__init__
__init__(
name: str | None = None,
value: Any = None,
value_type: str | None = None,
**kwargs: Any,
) -> None
Create a user field “text:user-field-decl”.
Source code in odfdo/user_field.py
45 46 47 48 49 50 51 52 53 54 55 56 57 | |
set_value
set_value(value: Any) -> None
Source code in odfdo/user_field.py
59 60 61 62 63 | |
UserFieldDecls
Bases: Element
Container of user fields declarations, “text:user-field-decls”.
Source code in odfdo/user_field.py
33 34 35 36 | |
UserFieldGet
Bases: ElementTyped
Representation of user field getter, “text:user-field-get”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a user field getter “text:user-field-get”. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
|
style |
|
|
text |
|
Source code in odfdo/user_field.py
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 | |
name
instance-attribute
name = name
style
instance-attribute
style = style
text
instance-attribute
text = text
__init__
__init__(
name: str | None = None,
value: Any = None,
value_type: str | None = None,
text: str | None = None,
style: str | None = None,
**kwargs: Any,
) -> None
Create a user field getter “text:user-field-get”.
Source code in odfdo/user_field.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
UserFieldInput
Bases: UserFieldGet
Representation of user field input, “text:user-field-input”.
Source code in odfdo/user_field.py
104 105 106 107 | |
VarChapter
Bases: Element
Variable for a chapter, “text:chapter”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable for a chapter “text:chapter”. |
Attributes:
| Name | Type | Description |
|---|---|---|
DISPLAY_VALUE_CHOICE |
ClassVar
|
|
display |
|
|
outline_level |
|
Source code in odfdo/variable.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
DISPLAY_VALUE_CHOICE
class-attribute
instance-attribute
DISPLAY_VALUE_CHOICE: ClassVar = {
"number",
"name",
"number-and-name",
"plain-number",
"plain-number-and-name",
}
display
instance-attribute
display = display
outline_level
instance-attribute
outline_level = outline_level
__init__
__init__(
display: str | None = "name",
outline_level: str | None = None,
**kwargs: Any,
) -> None
Create a variable for a chapter “text:chapter”.
display can be: ‘number’, ‘name’, ‘number-and-name’, ‘plain-number’ or ‘plain-number-and-name’
Source code in odfdo/variable.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
VarCreationDate
Bases: Element
Variable for the creation date, “text:creation-date”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable for the creation date “text:creation-date”. |
Attributes:
| Name | Type | Description |
|---|---|---|
data_style |
|
|
fixed |
|
Source code in odfdo/variable.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
data_style
instance-attribute
data_style = data_style
fixed
instance-attribute
fixed = True
__init__
__init__(
fixed: bool = False,
data_style: str | None = None,
**kwargs: Any,
) -> None
Create a variable for the creation date “text:creation-date”.
Source code in odfdo/variable.py
390 391 392 393 394 395 396 397 398 399 400 401 402 | |
VarCreationTime
Bases: Element
Variable for the creation time, “text:creation-time”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable for the creation time “text:creation-time”. |
Attributes:
| Name | Type | Description |
|---|---|---|
data_style |
|
|
fixed |
|
Source code in odfdo/variable.py
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
data_style
instance-attribute
data_style = data_style
fixed
instance-attribute
fixed = True
__init__
__init__(
fixed: bool = False,
data_style: str | None = None,
**kwargs: Any,
) -> None
Create a variable for the creation time “text:creation-time”.
Source code in odfdo/variable.py
417 418 419 420 421 422 423 424 425 426 427 428 429 | |
VarDate
Bases: Element
Variable for a date, “text:date”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create avariable for a date “text:date”. |
Attributes:
| Name | Type | Description |
|---|---|---|
data_style |
|
|
date |
|
|
date_adjust |
|
|
fixed |
|
|
text |
|
Source code in odfdo/variable.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
data_style
instance-attribute
data_style = data_style
date
instance-attribute
date = encode(date)
date_adjust
instance-attribute
date_adjust = encode(date_adjust)
fixed
instance-attribute
fixed = True
text
instance-attribute
text = text
__init__
__init__(
date: datetime | None = None,
fixed: bool = False,
data_style: str | None = None,
text: str | None = None,
date_adjust: timedelta | None = None,
**kwargs: Any,
) -> None
Create avariable for a date “text:date”.
Source code in odfdo/variable.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
VarDecl
Bases: Element
A variable declaration, “text:variable-decl”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable declaration “text:variable-decl”. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
|
value_type |
|
Source code in odfdo/variable.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
name
instance-attribute
name = name
value_type
instance-attribute
value_type = value_type
__init__
__init__(
name: str | None = None,
value_type: str | None = None,
**kwargs: Any,
) -> None
Create a variable declaration “text:variable-decl”.
Source code in odfdo/variable.py
57 58 59 60 61 62 63 64 65 66 67 68 69 | |
VarDecls
Bases: Element
Container of variables declarations, “text:variable-decls”.
Source code in odfdo/variable.py
42 43 44 45 | |
VarDescription
Bases: VarInitialCreator
Variable for the text description, “text:description”.
Source code in odfdo/variable.py
435 436 437 438 | |
VarFileName
Bases: Element
Variable for the file name, “text:file-name”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable for the file name “text:file-name”. |
Attributes:
| Name | Type | Description |
|---|---|---|
DISPLAY_VALUE_CHOICE |
ClassVar
|
|
display |
|
|
fixed |
|
Source code in odfdo/variable.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
DISPLAY_VALUE_CHOICE
class-attribute
instance-attribute
DISPLAY_VALUE_CHOICE: ClassVar = {
"full",
"path",
"name",
"name-and-extension",
}
display
instance-attribute
display = display
fixed
instance-attribute
fixed = True
__init__
__init__(
display: str | None = "full",
fixed: bool = False,
**kwargs: Any,
) -> None
Create a variable for the file name “text:file-name”.
display can be: ‘full’, ‘path’, ‘name’ or ‘name-and-extension’
Source code in odfdo/variable.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
VarGet
Bases: ElementTyped
Representation of a variable getter, “text:variable-get”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable getter “text:variable-get”. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
|
style |
|
|
text |
|
Source code in odfdo/variable.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
name
instance-attribute
name = name
style
instance-attribute
style = style
text
instance-attribute
text = text
__init__
__init__(
name: str | None = None,
value: Any = None,
value_type: str | None = None,
text: str | None = None,
style: str | None = None,
**kwargs: Any,
) -> None
Create a variable getter “text:variable-get”.
Source code in odfdo/variable.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
VarInitialCreator
Bases: Element
Variable for the initial creator, “text:initial-creator”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable for the initial creator “text:initial-creator”. |
Attributes:
| Name | Type | Description |
|---|---|---|
fixed |
|
Source code in odfdo/variable.py
365 366 367 368 369 370 371 372 373 374 375 | |
fixed
instance-attribute
fixed = True
__init__
__init__(fixed: bool = False, **kwargs: Any) -> None
Create a variable for the initial creator “text:initial-creator”.
Source code in odfdo/variable.py
371 372 373 374 375 | |
VarKeywords
Bases: VarInitialCreator
Variable for the keywords, “text:keywords”.
Source code in odfdo/variable.py
462 463 464 465 | |
VarPageCount
Bases: Element
Variable for page count, “text:page-count”.
Source code in odfdo/variable.py
194 195 196 197 | |
VarPageNumber
Bases: Element
Variable for page number, “text:page-number”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable for page number “text:page-number”. |
Attributes:
| Name | Type | Description |
|---|---|---|
page_adjust |
|
|
select_page |
|
Source code in odfdo/variable.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
page_adjust
instance-attribute
page_adjust = page_adjust
select_page
instance-attribute
select_page = select_page
__init__
__init__(
select_page: str | None = None,
page_adjust: str | None = None,
**kwargs: Any,
) -> None
Create a variable for page number “text:page-number”.
select_page – string in (‘previous’, ‘current’, ‘next’)
page_adjust – int (to add or subtract to the page number)
Source code in odfdo/variable.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
VarSet
Bases: ElementTyped
Representation of a variable setter, “text:variable-set”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable setter, “text:variable-set”. |
set_value |
|
Attributes:
| Name | Type | Description |
|---|---|---|
display |
|
|
name |
|
|
style |
|
|
text |
|
Source code in odfdo/variable.py
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 | |
display
instance-attribute
display = 'none'
name
instance-attribute
name = name
style
instance-attribute
style = style
text
instance-attribute
text = text
__init__
__init__(
name: str | None = None,
value: Any = None,
value_type: str | None = None,
display: str | bool = False,
text: str | None = None,
style: str | None = None,
**kwargs: Any,
) -> None
Create a variable setter, “text:variable-set”.
Source code in odfdo/variable.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 | |
set_value
set_value(value: Any) -> None
Source code in odfdo/variable.py
110 111 112 113 114 115 116 117 118 119 120 121 | |
VarSubject
Bases: VarInitialCreator
Variable for the subject, “text:subject”.
Source code in odfdo/variable.py
453 454 455 456 | |
VarTime
Bases: Element
Variable for a time, “text:time”.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a variable for a time “text:time”. |
Attributes:
| Name | Type | Description |
|---|---|---|
data_style |
|
|
fixed |
|
|
text |
|
|
time |
|
|
time_adjust |
|
Source code in odfdo/variable.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
data_style
instance-attribute
data_style = data_style
fixed
instance-attribute
fixed = True
text
instance-attribute
text = text
time
instance-attribute
time = encode(time)
time_adjust
instance-attribute
time_adjust = encode(time_adjust)
__init__
__init__(
time: datetime | time | None = None,
fixed: bool = False,
data_style: str | None = None,
text: str | None = None,
time_adjust: timedelta | None = None,
**kwargs: Any,
) -> None
Create a variable for a time “text:time”.
Source code in odfdo/variable.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
VarTitle
Bases: VarInitialCreator
Variable for the title, “text:title”.
Source code in odfdo/variable.py
444 445 446 447 | |
XmlPart
Representation of an XML part.
Abstraction of the XML library behind.
Methods:
| Name | Description |
|---|---|
__init__ |
Representation of an XML part. |
custom_pretty_tree |
|
delete_element |
|
get_element |
Returns the first element obtained from the XPath query applied to |
get_elements |
Returns the elements obtained from the XPath query applied to the |
pretty_serialize |
|
serialize |
|
xpath |
Apply XPath query to the root of the part and its subtree. |
Attributes:
| Name | Type | Description |
|---|---|---|
body |
Body
|
Get or set the document body : ‘office:body’ |
clone |
XmlPart
|
|
container |
|
|
part_name |
|
|
root |
Element
|
|
Source code in odfdo/xmlpart.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
container
instance-attribute
container = container
part_name
instance-attribute
part_name = part_name
__init__
__init__(part_name: str, container: Container) -> None
Representation of an XML part.
Source code in odfdo/xmlpart.py
45 46 47 48 49 50 51 52 | |
custom_pretty_tree
custom_pretty_tree() -> _ElementTree | _Element
Source code in odfdo/xmlpart.py
149 150 151 152 | |
delete_element
delete_element(child: Element) -> None
Source code in odfdo/xmlpart.py
109 110 | |
get_element
get_element(xpath_query: str) -> Element | None
Returns the first element obtained from the XPath query applied to the root of the XmlPart.
Return an Element or None.
Source code in odfdo/xmlpart.py
101 102 103 104 105 106 107 | |
get_elements
get_elements(xpath_query: str) -> list[Element]
Returns the elements obtained from the XPath query applied to the root of the XmlPart.
Return list of Element.
Source code in odfdo/xmlpart.py
93 94 95 96 97 98 99 | |
pretty_serialize
pretty_serialize() -> bytes
Source code in odfdo/xmlpart.py
141 142 143 144 145 146 147 | |
serialize
serialize(pretty: bool = False) -> bytes
Source code in odfdo/xmlpart.py
133 134 135 136 137 138 139 | |
xpath
Apply XPath query to the root of the part and its subtree.
Return list of Element or EText instances.
Source code in odfdo/xmlpart.py
112 113 114 115 116 117 | |
PageBreak
PageBreak() -> Paragraph
Return an empty paragraph with a manual page break.
Using this function requires to register the page break style with
document.add_page_break_style()
Source code in odfdo/paragraph.py
105 106 107 108 109 110 111 | |
create_table_cell_style
create_table_cell_style(
border: str | None = None,
border_top: str | None = None,
border_bottom: str | None = None,
border_left: str | None = None,
border_right: str | None = None,
padding: str | None = None,
padding_top: str | None = None,
padding_bottom: str | None = None,
padding_left: str | None = None,
padding_right: str | None = None,
background_color: str | tuple | None = None,
shadow: str | None = None,
color: str | tuple | None = None,
) -> Style
Return a cell style.
The borders arguments must be some style attribute strings or None, see the method ‘make_table_cell_border_string’ to generate them. If the ‘border’ argument as the value ‘default’, the default style “0.06pt solid #000000” is used for the 4 borders. If any value is used for border, it is used for the 4 borders, else any of the 4 borders can be specified by it’s own string. If all the border, border_top, border_bottom, … arguments are None, an empty border is used (ODF value is fo:border=”none”).
Padding arguments are string specifying a length (e.g. “0.5mm”)”. If ‘padding’ is provided, it is used for the 4 sides, else any of the 4 sides padding can be specified by it’s own string. Default padding is no padding.
Args:
border -- str, style string for borders on four sides
border_top -- str, style string for top if no 'border' argument
border_bottom -- str, style string for bottom if no 'border' argument
border_left -- str, style string for left if no 'border' argument
border_right -- str, style string for right if no 'border' argument
padding -- str, style string for padding on four sides
padding_top -- str, style string for top if no 'padding' argument
padding_bottom -- str, style string for bottom if no 'padding' argument
padding_left -- str, style string for left if no 'padding' argument
padding_right -- str, style string for right if no 'padding' argument
background_color -- str or rgb 3-tuple, str is 'black', 'grey', ... or '#012345'
shadow -- str, e.g. "#808080 0.176cm 0.176cm"
color -- str or rgb 3-tuple, str is 'black', 'grey', ... or '#012345'
Return : Style
Source code in odfdo/style.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
default_boolean_style
default_boolean_style() -> Style
Return a default boolean style.
Source code in odfdo/style_defaults.py
41 42 43 44 45 46 47 | |
default_currency_style
default_currency_style() -> Style
Return a default currency style (€).
Source code in odfdo/style_defaults.py
50 51 52 53 54 55 56 57 58 59 60 61 | |
default_date_style
default_date_style() -> Style
Return a default time style Y-M-D.
Source code in odfdo/style_defaults.py
64 65 66 67 68 69 70 71 72 73 74 | |
default_frame_position_style
default_frame_position_style(
name: str = "FramePosition",
horizontal_pos: str = "from-left",
vertical_pos: str = "from-top",
horizontal_rel: str = "paragraph",
vertical_rel: str = "paragraph",
) -> Style
Generate a style for positioning frames in desktop applications.
Default arguments should be enough.
Use the returned Style as the frame style or build a new graphic style with this style as the parent.
Source code in odfdo/frame.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
default_number_style
default_number_style() -> Style
Return a default number style with two decimals.
Source code in odfdo/style_defaults.py
77 78 79 80 81 82 83 84 | |
default_percentage_style
default_percentage_style() -> Style
Return a default percentage style with two decimals.
Source code in odfdo/style_defaults.py
87 88 89 90 91 92 93 94 | |
default_time_style
default_time_style() -> Style
Return a default time style.
Source code in odfdo/style_defaults.py
97 98 99 100 101 102 103 104 105 106 107 | |
default_toc_level_style
default_toc_level_style(level: int) -> Style
Generate an automatic default style for the given TOC level.
Source code in odfdo/toc.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
hex2rgb
hex2rgb(color: str) -> tuple[int, int, int]
Convert “#RRGGBB” hexadecimal representation into (R, G, B) tuple.
Args:
color -- str
Returns: tuple
Source code in odfdo/utils/color.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
hexa_color
hexa_color(
color: str | tuple[int, int, int] | None = None,
) -> str | None
Safe conversion from color tuple or string to hexadecimal representation.
Empty string is converted to black. None is converted to None.
Args:
color -- str or tuple or None
Returns: str or None
Source code in odfdo/utils/color.py
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 | |
make_table_cell_border_string
make_table_cell_border_string(
thick: str | float | int | None = None,
line: str | None = None,
color: str | tuple | None = None,
) -> str
Returns a string for “style:table-cell-properties” “fo:border”.
With default: “0.06pt solid #000000”
Args:
thick -- str or float or int
line -- str
color -- str or rgb 3-tuple, str is 'black', 'grey', ... or '#012345'
Source code in odfdo/style.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
rgb2hex
rgb2hex(color: str | tuple[int, int, int]) -> str
Convert color name or (R, G, B) tuple into “#RRGGBB” hexadecimal.
Args:
color -- str or tuple
Returns: str
Examples::
>>> rgb2hex('yellow')
'#FFFF00'
>>> rgb2hex((238, 130, 238))
'#EE82EE'
Source code in odfdo/utils/color.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |