Class WriteTextFrames
- class ooodev.write.WriteTextFrames(owner, frames, lo_inst=None)[source]
Bases:
LoInstPropsPartial
,TextFramesComp
,WriteDocPropPartial
,QiPartial
,ServicePartial
Class for managing Writer Text Frames.
This class is Enumerable and returns
WriteTextFrame[WriteDoc]
instance on iteration.- __getitem__(index)[source]
Gets the Text Frame at the specified index or name.
This is short hand for
get_by_index()
orget_by_name()
.- Parameters:
key (key, str, int) – The index or name of the form. When getting by index can be a negative value to get from the end.
index (str | int) –
- Returns:
The from with the specified index or name.
- Return type:
See also
- __len__()[source]
Gets the number of Text Frames in the document.
- Returns:
Number of Text Frames in the document.
- Return type:
int
- add_text_frame(*, text='', ypos=300, width=5000, height=5000, page_num=1, border_color=None, background_color=None, styles=None)[source]
Adds a text frame.
- Parameters:
text (str, optional) – Frame Text
ypos (int, UnitT. optional) – Frame Y pos in
1/100th mm
or Class UnitT. Default300
.width (int, UnitT, optional) – Width in
1/100th mm
or Class UnitT.height (int, UnitT, optional) – Height in
1/100th mm
or Class UnitT.page_num (int, optional) – Page Number to add text frame. If
0
Then Frame is anchored to paragraph. Default1
.border_color (
Color
, optional) – .color.Color`, optional): Border Color.background_color (
Color
, optional) – Background Color.styles (Sequence[StyleT]) – One or more styles to apply to frame. Only styles that support
com.sun.star.text.TextFrame
service are applied.
- Raises:
CreateInstanceMsfError – If unable to create text.TextFrame
CancelEventError – If
WriteNamedEvent.TEXT_FRAME_ADDING
event is cancelledException – If unable to add text frame
- Returns:
Text frame that is added to document.
- Return type:
- Events:
Hint
Styles that can be applied are found in ooodev.format.writer.direct.frame subpackages.
Note
Event args
event_data
is a dictionary containing all method args.See also
- get_by_index(idx)[source]
Gets the element at the specified index.
- Parameters:
idx (int) – The Zero-based index of the element. Idx can be a negative value to index from the end of the list. For example, -1 will return the last element.
- Returns:
The element at the specified index.
- Return type:
- get_by_name(name)[source]
Gets the element with the specified name.
- Parameters:
name (str) – The name of the element.
- Raises:
MissingNameError – If text frame is not found.
- Returns:
The element with the specified name.
- Return type:
- get_count()
Gets the number of elements contained in the container.
- Returns:
The number of elements.
- Return type:
int
- get_element_names()
Gets the names of all elements contained in the container.
- Returns:
The names of all elements.
- Return type:
tuple[str, …]
- get_element_type()
Gets the type of the elements contained in the container.
- Returns:
The type of the elements.
None
means that it is a multi-type container and you cannot determine the exact types with this interface.- Return type:
Any
- get_services()
Gets service names for the instance.
- Returns:
service names
- Return type:
List[str]
- has_by_name(name)
Checks if the container has an element with the specified name.
- Parameters:
name (str) – The name of the element.
- Returns:
True
if the container has an element with the specified name, otherwiseFalse
.- Return type:
bool
- has_elements()
Determines whether the container has elements.
- Return type:
bool
- qi(atype, raise_err=False)
Generic method that get an interface instance from an object.
- Parameters:
atype (T) – Interface type to query obj for. Any Uno class that starts with ‘X’ such as XInterface
raise_err (bool, optional) – If True then raises MissingInterfaceError if result is None. Default False
- Raises:
MissingInterfaceError – If ‘raise_err’ is ‘True’ and result is None
- Returns:
instance of interface if supported; Otherwise, None
- Return type:
T | None
Note
When
raise_err=True
return value will never beNone
.
- support_service(*service)
Gets if instance supports a service.
- Parameters:
*service (str) – Variable length argument list of UNO namespace strings such as
com.sun.star.configuration.GroupAccess
- Returns:
True
if instance supports any passed in service; Otherwise,False
- Return type:
bool
- property component: com.sun.star.text.TextFrames
TextFrames Component
- Return type:
TextFrames
- property office_doc: OfficeDocumentT
Office Document.
- Return type: