Bases: object
Representation of an XML element. Abstraction of the XML library behind.
Insert element or text in the last position.
Append the named range to the spreadsheet, replacing existing named range of same name if any.
Arguments:
named_range – ODF named nange
Remove text, children and attributes from the element.
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.
Arguments:
child – odf_element
Delete the Named Range of specified name from the spreadsheet.
Arguments:
name – str
Fast append elements at the end of ourself using extend.
Return the section that matches the criteria.
End date is not included (as expected in Python).
Arguments:
position – int
creator – unicode
start_date – date object
end_date – date object
content – unicode regex
Return: odf_annotation or None if not found
Return all the sections that match the criteria.
End date is not included (as expected in Python).
Arguments:
creator – unicode
start_date – date object
end_date – date object
content – unicode regex
Return: list of odf_annotation
Return the bookmark that matches the criteria.
Arguments:
position – int
name – unicode
Return: odf_element or None if not found
Return the bookmark end that matches the criteria.
Arguments:
position – int
name – unicode
Return: odf_element or None if not found
Return all the bookmark ends.
Return: list of odf_element
Return the bookmark start that matches the criteria.
Arguments:
position – int
name – unicode
Return: odf_element or None if not found
Return all the bookmark starts.
Return: list of odf_element
Return all the bookmarks.
Return: list of odf_element
Return a list of ids that refers to a change region in the tracked changes list.
Return the draw connector that matches the criteria.
Arguments:
position – int
id – unicode
content – unicode regex
Return: odf_shape or None if not found
Return all the draw connectors that match the criteria.
Arguments:
draw_style – unicode
draw_text_style – unicode
content – unicode regex
Return: list of odf_shape
Return the draw ellipse that matches the criteria.
Arguments:
position – int
id – unicode
content – unicode regex
Return: odf_shape or None if not found
Return all the draw ellipses that match the criteria.
Arguments:
draw_style – unicode
draw_text_style – unicode
content – unicode regex
Return: list of odf_shape
Return the draw line that matches the criteria.
Arguments:
position – int
id – unicode
content – unicode regex
Return: odf_shape or None if not found
Return all the draw lines that match the criteria.
Arguments:
draw_style – unicode
draw_text_style – unicode
content – unicode regex
Return: list of odf_shape
Return the draw page that matches the criteria.
Arguments:
position – int
name – unicode
content – unicode regex
Return: odf_draw_page or None if not found
Return all the draw pages that match the criteria.
Arguments:
style – unicode
content – unicode regex
Return: list of odf_draw_page
Return the draw rectangle that matches the criteria.
Arguments:
position – int
id – unicode
content – unicode regex
Return: odf_shape or None if not found
Return all the draw rectangles that match the criteria.
Arguments:
draw_style – unicode
draw_text_style – unicode
content – unicode regex
Return: list of odf_shape
This function must return a beautiful version of the text
Return the section that matches the criteria.
Arguments:
position – int
title – unicode regex
description – unicode regex
content – unicode regex
Return: odf_frame or None if not found
Return all the frames that match the criteria.
Arguments:
style – unicode
title – unicode regex
description – unicode regex
content – unicode regex
Return: list of odf_frame
Return the heading that matches the criteria.
Arguments:
position – int
content – unicode regex
Return: odf_heading or None if not found
Return all the headings that match the criteria.
Arguments:
style – unicode
content – unicode regex
Return: list of odf_heading
Return the image that matches the criteria.
Arguments:
position – int
content – unicode regex
Return: odf_element or None if not found
Return all the sections that match the criteria.
Arguments:
style – str
url – unicode regex
content – unicode regex
Return: list of odf_element
Return the link that matches the criteria.
Arguments:
position – int
name – unicode
title – unicode
url – unicode regex
content – unicode regex
Return: odf_element or None if not found
Return all the links that match the criteria.
Arguments:
name – unicode
title – unicode
url – unicode regex
content – unicode regex
Return: list of odf_element
Return the list that matches the criteria.
Arguments:
position – int
content – unicode regex
Return: odf_list or None if not found
Return all the lists that match the criteria.
Arguments:
style – unicode
content – unicode regex
Return: list of odf_list
Return the named range of specified name, or None if not found.
Arguments:
name – str
Return: odf_named_range
Return all the tables named ranges.
Return: list of odf_named_range
Return the note that matches the criteria.
Arguments:
position – int
note_id – unicode
note_class – ‘footnote’ or ‘endnote’
content – unicode regex
Return: odf_note or None if not found
Return all the notes that match the criteria.
Arguments:
note_class – ‘footnote’ or ‘endnote’
content – unicode regex
Return: list of odf_note
Return a list of connectors which don’t have any shape connected to them.
Return the paragraph that matches the criteria.
Arguments:
position – int
content – unicode regex
Return: odf_paragraph or None if not found
Return all the paragraphs that match the criteria.
Arguments:
style – unicode
content – unicode regex
Return: list of odf_paragraph
Return the reference mark that matches the criteria.
Arguments:
position – int
name – unicode
Return: odf_element or None if not found
Return the reference mark end that matches the criteria.
Arguments:
position – int
name – unicode
Return: odf_element or None if not found
Return all the reference mark ends.
Return: list of odf_element
Return the reference mark start that matches the criteria.
Arguments:
position – int
name – unicode
Return: odf_element or None if not found
Return all the reference mark starts.
Return: list of odf_element
Return all the reference marks.
Return: list of odf_element
Return the section that matches the criteria.
Arguments:
position – int
content – unicode regex
Return: odf_element or None if not found
Return all the sections that match the criteria.
Arguments:
style – unicode
content – unicode regex
Return: list of odf_element
Return the span that matches the criteria.
Arguments:
position – int
content – unicode regex
Return: odf_span or None if not found
Return all the spans that match the criteria.
Arguments:
style – unicode
content – unicode regex
Return: list of odf_span
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.
Arguments:
- family – ‘paragraph’, ‘text’, ‘graphic’, ‘table’, ‘list’,
- ‘number’
name_or_element – unicode or odf_style
display_name – unicode
Return: odf_style or None if not found
Brute-force to find paragraphs, tables, etc. using the given style name (or all by default).
Arguments:
name – unicode
Return: list
Return the table that matches the criteria.
Arguments:
position – int
name – unicode
content – unicode regex
Return: odf_table or None if not found
Return all the tables that match the criteria.
Arguments:
style – unicode
content – unicode regex
Return: list of odf_table
Return the tag name of the element as a qualified name, e.g. “text:span”.
Return: str
Return the text immediately following the element.
Inspired by lxml.
Return the text content of the element.
If recursive is True, all text contents of the subtree.
Like “get_text” but return the text of the embedded paragraph: annotations, cells...
Return the table of contents that matches the criteria.
Arguments:
position – int
content – unicode regex
Return: odf_toc or None if not found
Return all the tables of contents.
Return: list of odf_toc
Return the tracked-changes part in the text body.
return the user field declaration for the given name.
return: odf_element or none if not found
Return all the user field declarations.
Return: list of odf_element
Return the container for user field declarations. Created if not found.
Return: odf_element
Return the value of the given user field name.
Arguments:
name – unicode
- value_type – ‘boolean’, ‘currency’, ‘date’, ‘float’,
- ‘percentage’, ‘string’, ‘time’ or automatic
Return: most appropriate Python type
return the variable declaration for the given name.
return: odf_element or none if not found
Return all the variable declarations.
Return: list of odf_element
Return the container for variable declarations. Created if not found.
Return: odf_element
Return the variable set for the given name (last one by default).
Arguments:
name – unicode
position – int
Return: odf_element or None if not found
Return the last value of the given variable name.
Arguments:
name – unicode
- value_type – ‘boolean’, ‘currency’, ‘date’, ‘float’,
- ‘percentage’, ‘string’, ‘time’ or automatic
Return: most appropriate Python type
Return all the variable sets that match the criteria.
Arguments:
name – unicode
Return: list of odf_element
Return the position of the child in this element.
Inspired by lxml
Insert an element relatively to ourself.
Insert either using DOM vocabulary or by numeric position.
Position start at 0.
Arguments:
element – odf_element
- xmlposition – FIRST_CHILD, LAST_CHILD, NEXT_SIBLING
- or PREV_SIBLING
position – int
return True if the pattern is found one or more times anywhere in the text content of the element.
Python regular expression syntax applies.
Arguments:
pattern – unicode
Return: bool
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 occurences 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.
Arguments:
pattern – unicode
new – unicode
Return: int
Return the first position of the pattern in the text content of the element, or None if not found.
Python regular expression syntax applies.
Arguments:
pattern – unicode
Return: int or None
Shortcut to accept a style object as a value.
Change the tag name of the element with the given qualified name. Return a new element as there may be a more appropriate class afterwards. XXX side effects?
Arguments:
qname – str
Return: odf_element or a subclass
Set the text immediately following the element.
Inspired by lxml.
Set the text content of the element.
Like “set_text” but set the text of the embedded paragraph: annotations, cells...
Create the paragraph if missing.
Apply XPath query to the element and its subtree. Return list of odf_element or odf_text instances translated from the nodes found.
Bases: unicode
Representation of an XML text node. Created to hide the specifics of lxml in searching text nodes using XPath.
Constructed like any unicode object but only accepts lxml text objects.
Associate a qualified element name to a Python class that handles this type of element.
Getting the right Python class when loading an existing ODF document is then transparent. Unassociated elements will be handled by the base odf_element class.
Most styles use the “style:style” qualified name and only differ by their “style:family” attribute. So the “family” attribute was added to register specialized style classes.
Arguments:
qname – str
cls – Python class
family – str