Class WriteTextFrame
- class ooodev.write.WriteTextFrame(owner, component, lo_inst=None)[source]
Bases:
ShapeBase
,WriteDocPropPartial
,Generic
[T
],TextFrameComp
,PropertyChangeImplement
,VetoableChangeImplement
,DrawShapePartial
,QiPartial
,PropPartial
,StylePartial
Represents writer text content.
- __init__(owner, component, lo_inst=None)[source]
Constructor
- Parameters:
owner (T) – Owner of this component.
component (XTextFrame) – UNO object that supports
com.sun.star.text.TextFrame
service.lo_inst (LoInst, optional) – Lo instance. Defaults to
None
.
- Return type:
None
- add_event_observers(*args)
Adds observers that gets their
trigger
method called when this classtrigger
method is called.- Parameters:
args (EventObserver) – One or more observers to add.
- Return type:
None
Note
Observers are removed automatically when they are out of scope.
- add_event_property_change(name, cb)
Adds a listener for an event.
Event is invoked when property is changed.
The callback
EventArgs.event_data
will contain acom.sun.star.beans.PropertyChangeEvent
struct.- Parameters:
name (str) – Property Name
cb (EventArgsCallbackT) – Callback
- Return type:
None
- add_event_property_change_events_disposing(name, cb)
Adds a listener for an event.
Event is invoked when the property listener is about to be disposed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.lang.EventObject
struct.- Parameters:
name (str) – Property Name
cb (EventArgsCallbackT) – Callback
- Return type:
None
- add_event_vetoable_change(name, cb)
Adds a listener for an event.
Event is invoked when property is changed.
The callback
EventArgs.event_data
will contain acom.sun.star.beans.PropertyChangeEvent
struct.- Parameters:
name (str) – Property Name
cb (EventArgsCallbackT) – Callback
- Return type:
None
- add_event_vetoable_change_events_disposing(name, cb)
Adds a listener for an event.
Event is invoked when the property listener is about to be disposed.
The callback
EventArgs.event_data
will contain a UNOcom.sun.star.lang.EventObject
struct.- Parameters:
name (str) – Property Name
cb (EventArgsCallbackT) – Callback
- Return type:
None
- add_text(msg, font_size=0, **props)
Add text to a shape
- Parameters:
msg (str) – Text to add
font_size (int, optional) – Font size.
props (Any, optional) – Any extra properties that will be applied to cursor (font) such as
CharUnderline=1
- Raises:
ShapeError – If error occurs.
- 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
- export_shape_jpg(fnm, resolution=96)
Exports shape as jpg image.
- Parameters:
fnm (PathOrStr, optional) – Image file name.
resolution (int, optional) – Resolution in dpi. Defaults to 96.
- Events:
- Return type:
None
Note
On exporting event is Class CancelEventArgsExport. On exported event is Class EventArgsExport. Args
event_data
is aExportJpgT
dictionary.If
fnm
is not specified, the image file name is created based on the document name and page number and written to the same folder as the document.
- export_shape_png(fnm, resolution=96)
Exports shape as png image.
- Parameters:
fnm (PathOrStr, optional) – Image file name.
resolution (int, optional) – Resolution in dpi. Defaults to 96.
- Events:
- Return type:
None
Note
On exporting event is Class CancelEventArgsExport. On exported event is Class EventArgsExport. Args
event_data
is aExportPngT
dictionary.If
fnm
is not specified, the image file name is created based on the document name and page number and written to the same folder as the document.When page is exported as png, such as an impress slide, any images on the will not be exported if filter
translucent=True
. For this reason, the default value fortranslucent
isFalse
.
- get_glue_points()
Gets Glue Points.
- Raises:
DrawError – If error occurs.
- Returns:
Glue Points.
- Return type:
Tuple[GluePoint2, …]
Note
If a glue point can not be accessed then it is ignored.
- get_name()
Returns the name of the object.
- Return type:
str
- get_owner()
- Return type:
TypeVar
(_T
, bound= ComponentT)
- get_position_mm()
Gets position in mm units
- Raises:
PointError – If error occurs.
- Returns:
Position as Point in mm units
- Return type:
- get_property(name, default=<object object>)
Get property value
- Parameters:
name (str) – Property Name.
default (Any, optional) – Return value if property value is
None
.
- Returns:
Property value or default.
- Return type:
Any
- get_rotation()
Gets the rotation of a shape
- Parameters:
shape (XShape) – Shape
- Raises:
ShapeError – If error occurs.
- Returns:
Rotation angle.
- Return type:
- get_services()
Gets service names for the instance.
- Returns:
service names
- Return type:
List[str]
- get_shape_text()
Gets the text from inside a shape.
- Raises:
DrawError – If error occurs getting shape text.
- Returns:
Shape text
- Return type:
str
- get_shape_text_cursor()
Gets a cursor object for this text.
- Returns:
Cursor.
- Return type:
- get_shape_type()
Get the shape type. This is usually a service name and is manually set by the class.
- Return type:
str
- get_size_mm()
Gets Size in mm units.
- get_text_properties()
Gets the properties associated with the text area inside the shape.
- Raises:
PropertySetError – If error occurs.
- Returns:
Property Set
- Return type:
XPropertySet
- get_transformation()
Gets a transformation matrix which seems to represent a clockwise rotation.
Homogeneous matrix has three homogeneous lines
- Raises:
ShapeError – If error occurs.
- Returns:
Matrix
- Return type:
HomogenMatrix3
- get_zorder()
Gets the z-order of a shape
- Raises:
DrawError – If unable to get z-order.
- Returns:
Z-Order
- Return type:
int
- is_group()
Gets if a shape is a Group Shape
- Returns:
True
if shape is a group; Otherwise;False
.- Return type:
bool
- is_image()
Gets if a shape is an image (GraphicObjectShape).
- Returns:
True
if shape is image; Otherwise,False
.- Return type:
bool
- move_to_bottom()
Moves the shape to the bottom of the z-order
- Raises:
ShapeMissingError – If unable to find shapes for slide.
ShapeError – If any other error occurs.
- Return type:
None
- move_to_top()
Moves the shape to the top of the z-order
- Raises:
ShapeMissingError – If unable to find shapes for slide.
ShapeError – If any other error occurs.
- 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 beNone
.
- remove_event_observer(observer)
Removes an observer
- Parameters:
observer (EventObserver) – One or more observers to add.
- Returns:
True
if observer has been removed; Otherwise,False
.- Return type:
bool
- remove_event_property_change(name)
Removes a listener for an event
- Parameters:
name (str) – Property Name
- Return type:
None
- remove_event_property_change_events_disposing(name)
Removes a listener for an event
- Parameters:
name (str) – Property Name
- Return type:
None
- remove_event_vetoable_change(name)
Removes a listener for an event
- Parameters:
name (str) – Property Name
- Return type:
None
- remove_event_vetoable_change_events_disposing(name)
Removes a listener for an event
- Parameters:
name (str) – Property Name
- Return type:
None
- set_angle(angle)
Set the line style for a shape
- Parameters:
angle (Angle | int) – Angle to set.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_bitmap_color(name)
Set bitmap color of a shape.
- Parameters:
name (DrawingBitmapKind, str) – Bitmap Name
- Raises:
NameError – If
name
is not recognized.ShapeError – If any other error occurs.
- Return type:
None
Note
Getting the bitmap color name can be a bit challenging.
DrawingBitmapKind
contains name displayed in the Bitmap color menu of Draw.The Easiest way to get the colors is to open Draw and see what bitmap color names are available on your system.
- set_bitmap_file_color(fnm)
Set bitmap color from file.
- Parameters:
fnm (PathOrStr) – path to file.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_dashed_line(is_dashed)
Set a dashed line
- Parameters:
is_dashed (bool) – Determines if line is to be dashed or solid.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_gradient_color(*args, **kwargs)
Set the gradient color of the shape.
- Parameters:
name (DrawingGradientKind | str) – Gradient color name.
start_color (Color) – Start Color.
end_color (Color) – End Color.
angle (Angle, int) – Gradient angle.
- Raises:
NameError – If
name
is not recognized.ShapeError – If any other error occurs.
- Returns:
Gradient instance that just had properties set.
- Return type:
Gradient
Note
When using Gradient Name.
Getting the gradient color name can be a bit challenging.
DrawingGradientKind
contains name displayed in the Gradient color menu of Draw.The Easiest way to get the colors is to open Draw and see what gradient color names are available on your system.
See also
- set_gradient_properties(grad)
Sets shapes gradient properties.
- Parameters:
grad (Gradient) – Gradient properties to set.
- Return type:
None
See also
- set_hatch_color(name)
Set hatching color of a shape.
- Parameters:
name (DrawingHatchingKind, str) – Hatching Name.
- Raises:
NameError – If
name
is not recognized.ShapeError – If any other error occurs.
- Return type:
None
Note
Getting the hatching color name can be a bit challenging.
DrawingHatchingKind
contains name displayed in the Hatching color menu of Draw.The Easiest way to get the colors is to open Draw and see what gradient color names are available on your system.
- set_image(fnm)
Sets the image of a shape.
- Parameters:
fnm (PathOrStr) – Path to image.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_image_graphic(graphic)
Sets the image of a shape.
- Parameters:
graphic (XGraphic) – Graphic.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_line_style(style)
Set the line style for a shape.
- Parameters:
style (LineStyle) – Line Style.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_name(name)
Sets the name of the object.
- Return type:
None
- Parameters:
name (str) –
- set_position(*args, **kwargs)
Sets Position of shape.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_property(**kwargs)
Set property value
- Parameters:
**kwargs (
Any
) – Variable length Key value pairs used to set properties.- Return type:
None
- set_props(**props)
Sets properties on a shape.
- Parameters:
props (Any) – Key value pairs of property name and property value
- Raises:
MissingInterfaceError – if obj does not implement XPropertySet interface
MultiError – If unable to set a property
- Return type:
None
Example
set_props(Loop=True, MediaURL=FileIO.fnm_to_url(fnm))
- set_rotation(angle)
Set the rotation of a shape.
- Parameters:
angle (Angle | int) – Angle or int. An angle value from
0
to359
.- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_size(*args, **kwargs)
Sets set_size of shape.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_style(graphic_styles, style_name)
Set the graphic style for a shape.
- Parameters:
graphic_styles (XNameContainer) – Graphic styles.
style_name (GraphicStyleKind | str) – Graphic Style Name.
- Raises:
DrawError – If error occurs.
- Return type:
None
- set_transparency(level)
Sets the transparency level for the shape. Higher level means more transparent.
- Parameters:
level (Intensity, int) – Transparency value. Represents a intensity value from
0
to100
.- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_visible(is_visible)
Set the line style for a shape.
- Parameters:
is_visible (bool) – Set is shape is visible or not.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- set_zorder(order)
Sets the z-order of a shape.
- Parameters:
order (int) – Z-Order.
- Raises:
DrawError – If unable to set z-order.
- Return type:
None
- subscribe_event(event_name, callback)
Add an event listener to current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- subscribe_event_shape_jpg_exported(callback)
Add an event listener to current instance that is triggered on export complete.
- Parameters:
callback (Callable[[Any, EventArgsExport[ExportJpgT]], None]) – Callback of the event listener.
- Return type:
None
- subscribe_event_shape_jpg_exporting(callback)
Add an event listener to current instance that is triggered on exporting.
- Parameters:
callback (Callable[[Any, CancelEventArgsExport[ExportJpgT]], None]) – Callback of the event listener.
- Return type:
None
- subscribe_event_shape_png_exported(callback)
Add an event listener to current instance that is triggered on export complete.
- Parameters:
callback (Callable[[Any, EventArgsExport[ExportPngT]], None]) – Callback of the event listener.
- Return type:
None
- subscribe_event_shape_png_exporting(callback)
Add an event listener to current instance that is triggered on exporting.
- Parameters:
callback (Callable[[Any, CancelEventArgsExport[ExportPngT]], None]) – Callback of the event listener.
- Return type:
None
- 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
- trigger_event(event_name, event_args)
Trigger an event on current instance.
- Parameters:
event_name (str) – Event Name.
event_args (EventArgsT) – Event Args.
- Return type:
None
- unsubscribe_event(event_name, callback)
Remove an event listener from current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- unsubscribe_event_shape_jpg_exported(callback)
Remove an event listener from current instance.
- Parameters:
callback (Callable[[Any, EventArgsExport[ExportJpgT]], None]) – Callback of the event listener.
- Return type:
None
- unsubscribe_event_shape_jpg_exporting(callback)
Remove an event listener from current instance.
- Parameters:
callback (Callable[[Any, CancelEventArgsExport[ExportJpgT]], None]) – Callback of the event listener.
- Return type:
None
- unsubscribe_event_shape_png_exported(callback)
Remove an event listener from current instance.
- Parameters:
callback (Callable[[Any, EventArgsExport[ExportPngT]], None]) – Callback of the event listener.
- Return type:
None
- unsubscribe_event_shape_png_exporting(callback)
Remove an event listener from current instance.
- Parameters:
callback (Callable[[Any, CancelEventArgsExport[ExportPngT]], None]) – Callback of the event listener.
- Return type:
None
- property component: XShape
Gets the component.
- Return type:
XShape
- property event_observer: EventObserver
Gets/Sets The Event Observer for this instance.
- Return type:
- property extra_data: TheDict
Extra Data Key Value Pair Dictionary.
Properties can be assigned properties and access like a dictionary and with dot notation.
Note
This is a dictionary object that can be used to store key value pairs. Generally speaking this data is not part of the object’s main data structure and is not saved with the object (document).
This property is used to store data that is not part of the object’s main data structure and can be used however the developer sees fit.
- Return type:
- property name: str
Gets/Sets the name of this text frame.
- Return type:
str
- property office_doc: OfficeDocumentT
Office Document.
- Return type:
- property owner: T
Owner of this component.
- Return type:
TypeVar
(T
, bound= ComponentT)
- property position: PointStructGenericComp[UnitMM]
Gets/Sets the position of the shape in
UnitMM
Values.When setting this value, it can be set with a
com.sun.star.awt.Position
instance or aPointStructGenericComp
instance.The Position can be set by just setting a Position property.
- Returns:
Position in
UnitMM
Values.- Return type:
Note
This is the position as reported by the shape. This is not the same as the position of the shape on the page. The position of the shape on the page includes is from the page margins.
For instance if the page has a margin of 10mm and the shape is at position (15, 15) then the position of the shape in the Draw Dialog box is (5, 5) where as this position property will report (15, 15).
Example
Can be set by just setting a Position property using int or
UnitMM
.shape.position.x = 1000 # 10 mm shape.position.y = UnitMM(20) # 20 mm
Can also be set using any
UnitT
object.shape.position.x = UnitCM(1.2) shape.position.y = UnitMM(40)
Can also be set using a
com.sun.star.awt.Position
struct.shape.position = Position(1000, 2000) # in 1/100mm
- property shape_type: str
Gets the shape type.
- Return type:
str
- property size: SizeStructGenericComp[UnitMM]
Gets/Sets the size of the shape in
UnitMM
Values.When setting this value, it can be set with a
com.sun.star.awt.Size
instance or aSizeStructGenericComp
instance.The Size can be set by just setting a Size property.
- Returns:
Size in
UnitMM
Values.- Return type:
Example
Can be set by just setting a Size property using int or
UnitMM
.shape.size.width = 1000 # 10 mm shape.size.height = UnitMM(20) # 20 mm
Can also be set using any
UnitT
object.shape.size.width = UnitCM(1.2) shape.size.height = UnitMM(40)
Can also be set using a
com.sun.star.awt.Size
struct.shape.size = Size(1000, 2000) # in 1/100mm