Class DrawText

class ooodev.draw.DrawText(owner, component, lo_inst=None)[source]

Bases: Generic[_T], LoInstPropsPartial, OfficeDocumentPropPartial, TextComp, QiPartial, StylePartial, ServicePartial

Represents text content.

Contains Enumeration Access.

__init__(owner, component, lo_inst=None)[source]

Constructor

Parameters:
  • owner (_T) – Owner of this component.

  • component (XText) – UNO object that supports com.sun.star.text.Text service.

  • lo_inst (LoInst, optional) – Lo instance. Defaults to None.

Return type:

None

add_bullet(level, text)[source]

Add bullet text to the end of the bullets text area, specifying the nesting of the bullet using a numbering level value (numbering starts at 0).

Parameters:
  • level (int) – Bullet Level

  • text (str) – Bullet Text

Raises:

DrawError – If error adding bullet.

Return type:

None

apply_styles(*styles, **kwargs)

Applies style to component.

Parameters:
  • obj. (styles expandable list of styles object such as Font to apply to) –

  • kwargs (Any, optional) – Expandable list of key value pairs.

  • styles (StyleT) –

Return type:

None

create_text_cursor()

Creates a new text cursor.

Returns:

The new text cursor.

Return type:

XTextCursor

create_text_cursor_by_range(text_position)

The initial position is set to text_position.

Parameters:

text_position (XTextRange) – The initial position of the new text cursor.

Returns:

The new text cursor.

Return type:

XTextCursor

get_cursor()[source]

Get the cursor for this text.

Returns:

Cursor for this text.

Return type:

DrawTextCursor[_T]

get_end()

Returns a text range which contains only the end of this text range.

Return type:

TextRangeComp

get_services()

Gets service names for the instance.

Returns:

service names

Return type:

List[str]

get_start()

Returns a text range which contains only the start of this text range.

Return type:

TextRangeComp

get_string()

Returns the string of this text range.

Return type:

str

get_text()

Gets the text of the range.

Returns:

The text of the range.

Return type:

XText

insert_control_character(rng, control_character, absorb)

Inserts a control character (like a paragraph break or a hard space) into the text.

Parameters:
  • rng (XTextRange) – The position of the new control character.

  • control_character (ControlCharacterEnum) – The control character to be inserted.

  • absorb (bool) – If TRUE the text range will contain the new inserted control character, otherwise the range (and it’s text) will remain unchanged.

Raises:

IllegalArgumentExceptioncom.sun.star.lang.IllegalArgumentException

Return type:

None

insert_string(rng, text, absorb)

Inserts a string of characters into the text.

The string may contain the following white spaces:

If the parameter bAbsorb() was TRUE the text range will contain the new inserted string, otherwise the range (and it’s text) will remain unchanged.

Return type:

None

Parameters:
  • rng (XTextRange) –

  • text (str) –

  • absorb (bool) –

insert_text_content(rng, content, absorb)

Inserts a content, such as a text table, text frame or text field.

Parameters:
  • rng (XTextRange) – The position at which the content is inserted.

  • content (XTextContent) – The content to be inserted.

  • absorb (bool) – Specifies whether the text spanned by xRange will be replaced. If True then the content of range will be replaced by content, otherwise content will be inserted at the end of xRange.

Return type:

None

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 be None.

remove_text_content(content)

Removes a text content.

Parameters:

content (XTextContent) – the content that is to be removed.

Return type:

None

set_string(string)

Sets the string of this text range.

The whole string of characters of this piece of text is replaced. All styles are removed when applying this method.

Return type:

None

Parameters:

string (str) –

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.drawing.Text

Text Component

Return type:

Text

property lo_inst: LoInst

Lo Instance

Return type:

LoInst

property office_doc: OfficeDocumentT

Office Document.

Return type:

OfficeDocumentT

property owner: _T

Owner of this component.

Return type:

TypeVar(_T, bound= ComponentT)