Class MasterDrawPage
- class ooodev.draw.MasterDrawPage(owner, component, lo_inst=None)[source]
Bases:
DrawPagePartial
[_T
],LoInstPropsPartial
,OfficeDocumentPropPartial
,MasterPageComp
,PropertyChangeImplement
,VetoableChangeImplement
,ServicePartial
,QiPartial
,PropPartial
,StylePartial
,TheDictionaryPartial
,Generic
[_T
]Represents a draw page.
- __init__(owner, component, lo_inst=None)[source]
Constructor.
- Parameters:
lo_inst (LoInst, optional) – Lo instance.
owner (_T) –
component (XDrawPage) –
- Return type:
None
- add(shape)
Adds a shape to the collection.
- Parameters:
shape (XShape) – The shape to add.
- Return type:
None
- add_bullet(bulls_txt, level, text)
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:
bulls_txt (XText) – Text object
level (int) – Bullet Level
text (str) – Bullet Text
- Raises:
DrawError – If error adding bullet.
- Return type:
None
- add_connector(shape1, shape2, start_conn=None, end_conn=None)
Add connector
- Parameters:
shape1 (XShape) – First Shape to add connector to.
shape2 (XShape) – Second Shape to add connector to.
start_conn (GluePointsKind | None, optional) – Start connector kind. Defaults to right.
end_conn (GluePointsKind | None, optional) – End connector kind. Defaults to left.
- Raises:
ShapeError – If error occurs.
- Returns:
Connector Shape.
- Return type:
XShape
Note
Properties for shape can be added or changed by using
set_shape_props()
.For instance the default value is
EndShape=ConnectorType.STANDARD
. This could be changed.Draw.set_shape_props(shape, EndShape=ConnectorType.CURVE)
- add_dispatch_shape(shape_dispatch, x, y, width, height, fn)
Adds a shape to a Draw slide via a dispatch command
- Parameters:
shape_dispatch (ShapeDispatchKind | str) – Dispatch Command
x (int, UnitT) – Shape X position in mm units or UnitT.
y (int, UnitT) – Shape Y position in mm units or UnitT
width (int, UnitT) – Shape width in mm units or UnitT
height (int, UnitT) – Shape height in mm units or UnitT
fn (DispatchShape) – Function that is responsible for running the dispatch command and returning the shape.
- Raises:
NoneError – If adding a dispatch fails.
ShapeError – If any other error occurs.
- Returns:
Shape
- Return type:
XShape
See also
DispatchShape
- 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_pres_shape(shape_type, x, y, width, height)
Creates a shape from the “com.sun.star.presentation” package:
- Parameters:
shape_type (PresentationKind) – Kind of presentation package to create.
x (int, UnitT) – Shape X position in mm units or UnitT.
y (int, UnitT) – Shape Y position in mm units or UnitT.
width (int, UnitT) – Shape width in mm units or UnitT.
height (int, UnitT) – Shape height in mm units or UnitT.
- Raises:
ShapeError – If error occurs.
- Returns:
Presentation Shape.
- Return type:
XShape
- add_shape(shape_type, x, y, width, height)
Adds a shape to a slide.
- Parameters:
shape_type (DrawingShapeKind | str) – Shape type.
x (int, UnitT) – Shape X position in mm units or UnitT.
y (int, UnitT) – Shape Y position in mm units or UnitT.
width (int, UnitT) – Shape width in mm units or UnitT.
height (int, UnitT) – Shape height in mm units or UnitT.
- Raises:
ShapeError – If error occurs.
- Returns:
Newly added Shape.
- Return type:
XShape
See also
Note
If
x
ory
is negative or0
then the shape position will not be set. Ifwidth
orheight
is negative or0
then the shape size will not be set.Changed in version 0.17.14: Now does not set size and/or position unless the values are greater than
0
.
- add_slide_number()
Adds slide number to a slide
- Parameters:
slide (XDrawPage) – Slide
- Raises:
ShapeError – If error occurs.
- Returns:
Slide number shape.
- Return type:
- 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
- blank_slide()
Inserts a blank slide
- Parameters:
slide (XDrawPage) – Slide
- Raises:
DrawError – If error occurs
- Return type:
None
- bullets_slide(title)
Add text to the slide page by treating it as a bullet page, which has two text shapes: one for the title, the other for a sequence of bullet points; add the title text but return a reference to the bullet text area
- copy_shape(old_shape)
Copies a shape
- Parameters:
old_shape (XShape) – Old Shape
- Raises:
ShapeError – If unable to copy shape.
- Returns:
Newly Copied shape.
- Return type:
- copy_shape_contents(old_shape)
Copies a shapes contents from old shape into new shape.
- Parameters:
old_shape (XShape) – Old shape
- Raises:
ShapeError – If unable to copy shape contents.
- Returns:
New shape with contents of old shape copied.
- Return type:
- draw_bezier_closed(pts, flags)
Draws a bezier curve.
- Parameters:
pts (Sequence[Point]) – Points
flags (Sequence[PolygonFlags]) – Flags
- Raises:
IndexError – If
pts
andflags
do not have the same number of elements.ShapeError – If unable to create Bezier Shape.
- Returns:
Bezier Shape.
- Return type:
- draw_bezier_open(pts, flags)
Draws a bezier curve.
- Parameters:
pts (Sequence[Point]) – Points
flags (Sequence[PolygonFlags]) – Flags
- Raises:
IndexError – If
pts
andflags
do not have the same number of elements.ShapeError – If unable to create Bezier Shape.
- Returns:
Bezier Shape.
- Return type:
- draw_circle(x, y, radius)
Gets a circle
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Circle Shape.
- Return type:
- draw_ellipse(x, y, width, height)
Gets an ellipse
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Ellipse Shape.
- Return type:
- draw_formula(formula, x, y, width, height)
Draws a formula
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Formula Shape.
- Return type:
XShape
Note
If
x
ory
is negative or0
then the shape position will not be set. Ifwidth
orheight
is negative or0
then the shape size will not be set.Changed in version 0.17.14: Now does not set size and/or position unless the values are greater than
0
.
- draw_image(*args, **kwargs)
Draws an image.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Shape
- Return type:
- draw_image_offset(fnm, xoffset, yoffset)
Insert the specified picture onto the slide page in the doc presentation document. Use the supplied (x, y) offsets to locate the top-left of the image.
- Parameters:
slide (XDrawPage) – Slide
fnm (PathOrStr) – Path to image.
xoffset (ImageOffset, float) – X Offset with value between
0.0
and1.0
yoffset (ImageOffset, float) – Y Offset with value between
0.0
and1.0
- Returns:
Shape on success,
None
otherwise.- Return type:
GraphicObjectShape | None
- draw_line(x1, y1, x2, y2)
Draws a line.
- Parameters:
- Raises:
ValueError – If x values and y values are a point and not a line.
ShapeError – If unable to create Line.
- Returns:
Line Shape.
- Return type:
- draw_lines(xs, ys)
Draw lines
- Parameters:
- Raises:
IndexError – If
xs
andxy
do not have the same number of elements.ShapeError – If any other error occurs.
- Returns:
Lines Shape.
- Return type:
Note
The number of points must be the same for both
xs
andys
.
- draw_media(fnm, x, y, width, height)
Draws media.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Media shape.
- Return type:
XShape
Note
If
x
ory
is negative or0
then the shape position will not be set. Ifwidth
orheight
is negative or0
then the shape size will not be set.Changed in version 0.17.14: Now does not set size and/or position unless the values are greater than
0
.
- draw_polar_line(x, y, degrees, distance)
Draw a line from
x
,y
in the direction of degrees, for the specified distance degrees is measured clockwise from x-axis- Parameters:
- Raises:
ShapeError – If unable to create Polar Line Shape.
- Returns:
Polar Line Shape.
- Return type:
- draw_polygon(x, y, sides, radius=20)
Gets a polygon.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Polygon Shape.
- Return type:
- draw_rectangle(x, y, width, height)
Gets a rectangle.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Rectangle Shape.
- Return type:
Note
If
x
ory
is negative or0
then the shape position will not be set. Ifwidth
orheight
is negative or0
then the shape size will not be set.Changed in version 0.17.14: Now does not set size and/or position unless the values are greater than
0
.
- draw_text(msg, x, y, width, height, font_size=0)
Draws Text.
- Parameters:
slide (XDrawPage) – Slide.
msg (str) – Text to draw.
x (int, UnitT) – Shape X position in mm units or UnitT.
y (int, UnitT) – Shape Y position in mm units or UnitT.
width (int, UnitT) – Shape width in mm units or UnitT.
height (int, UnitT) – Shape height in mm units or UnitT.
font_size (float, UnitT, optional) – Font size of text in Points or UnitT.
- Raises:
ShapeError – If error occurs.
- Returns:
Shape
- Return type:
Note
If
x
ory
is negative or0
then the shape position will not be set. Ifwidth
orheight
is negative or0
then the shape size will not be set.Changed in version 0.17.14: Now does not set size and/or position unless the values are greater than
0
.
- find_biggest_zorder()
Finds the shape with the largest z-order.
- Raises:
DrawError – If unable to find biggest z-order.
- Returns:
Z-Order
- Return type:
int
- find_shape_at_position(x, y)
Finds a shape at a given position.
- Parameters:
x (int) – X position.
y (int) – Y position.
- Raises:
ShapeMissingError – If no shape is found.
ShapeError – If any other error occurs.
- Returns:
Shape if Found; Otherwise,
None
.- Return type:
ShapeBase[Any] | None
- find_shape_at_position_size(x, y, width, height)
Finds a shape at a given position with a given size.
- Parameters:
x (int) – X position.
y (int) – Y position.
width (int) – width of the shape.
height (int) – height of the shape.
- Raises:
ShapeMissingError – If no shape is found.
ShapeError – If any other error occurs.
- Returns:
Shape if Found; Otherwise,
None
.- Return type:
ShapeBase[Any] | None
- find_shape_by_name(shape_name)
Finds a shape by its name.
- Parameters:
shape_name (str) – Shape Name.
- Raises:
ShapeMissingError – If shape is not found.
ShapeError – If any other error occurs.
- Returns:
Shape.
- Return type:
- find_shape_by_type(shape_type)
Finds a shape by its type
- Parameters:
shape_type (DrawingNameSpaceKind | str) – Shape Type
- Raises:
ShapeMissingError – If shape is not found.
ShapeError – If any other error occurs.
- Returns:
Shape
- Return type:
- find_top_shape()
Gets the top most shape of a slide.
- Raises:
ShapeMissingError – If there are no shapes for slide or unable to find top shape.
ShapeError – If any other error occurs.
- Returns:
Top most shape.
- Return type:
- get_animation_node()
Gets Animation Node
- Parameters:
slide (XDrawPage) – Slide
- Raises:
DrawPageError – If error occurs.
- Returns:
Animation Node
- Return type:
XAnimationNode
- get_by_index(idx)
Gets the element at the specified index.
- Parameters:
idx (int) – The Zero-based index of the element.
- Returns:
The element at the specified index.
- Return type:
Any
- get_chart_shape(x, y, width, height)
Gets a chart shape.
- Parameters:
- Raises:
ShapeError – If Error occurs.
- Returns:
Chart Shape.
- Return type:
- get_count()
Gets the number of elements contained in the container.
- Returns:
The number of elements.
- Return type:
int
- 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_fill_color()
Gets the fill color of a shape.
- Parameters:
shape (XShape) – Shape
- Raises:
ColorError – If error occurs.
- Returns:
Color
- Return type:
- get_form_container()
Gets form container. The first form in slide is returned if found.
- Raises:
DrawError – If error occurs.
- Returns:
Form Container on success, None otherwise.
- Return type:
IndexContainerComp | None
- get_glue_points()
Gets Glue Points
- Parameters:
shape (XShape) – Shape
- 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_line_color()
Gets the line color of a shape.
- Raises:
ColorError – If error occurs.
- Returns:
Color
- Return type:
- get_line_thickness()
Gets line thickness of a shape.
- Returns:
Line Thickness on success; Otherwise,
0
.- Return type:
int
- get_master_page()[source]
Gets master page
- Raises:
DrawError – If error occurs.
- Returns:
Master Page.
- Return type:
- get_name()
Gets the name of the slide.
- Raises:
DrawError – If error occurs setting name.
- Returns:
Slide name.
- Return type:
str
New in version 0.17.13.
- get_notes_page()[source]
Gets the notes page of a slide.
Each draw page has a notes page.
- Raises:
DrawPageMissingError – If notes page is
None
.DrawPageError – If any other error occurs.
- Returns:
Notes Page.
- Return type:
See also
- get_ordered_shapes()
Gets ordered shapes
- Returns:
List of Ordered Shapes.
- Return type:
List[DrawShape[_T]]
See also
- 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_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_size_mm()
Gets size of the given slide page (in mm units)
- get_slide_number()
Gets slide number.
- Raises:
DrawError – If error occurs.
- Returns:
Slide Number.
- Return type:
int
- get_slide_title()
Gets slide title if it exist.
- Raises:
DrawError – If error occurs.
- Returns:
Slide Title on success; Otherwise,
None
.- Return type:
str | None
- goto_page()
Go to page represented by this object.
- Raises:
DrawError – If error occurs.
- Return type:
None
- group(shapes)
Groups the given shapes.
- Parameters:
shapes (XShapes) – The shapes to group.
- Returns:
The group shape.
- Return type:
XShapeGroup
- has_elements()
Determines whether the container has elements.
- Return type:
bool
- move_to_bottom(shape)
Moves a shape to the bottom of the z-order
- Parameters:
shape (XShape) – Shape
- Raises:
ShapeMissingError – If unable to find shapes for slide.
ShapeError – If any other error occurs.
- Return type:
None
- move_to_top(shape)
Moves a shape to the top of the z-order
- Parameters:
shape (XShape) – Shape
- 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(shape)
Removes a shape from the collection.
- Parameters:
shape (XShape) – The shape to remove.
- Return type:
None
- 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
- remove_master_page()
Removes a master page
- Parameters:
slide (XDrawPage) – Draw page to remove
- Raises:
DrawError – If unable to remove master page/
- Return type:
None
- save_page(fnm, mime_type, filter_data=None)
Saves a Draw page to file.
- Parameters:
fnm (PathOrStr) – Path to save page as
mime_type (str) – Mime Type of page to save as such as
image/jpeg
orimage/png
.filter_data (dict, optional) – Filter data. Defaults to
None
.
- Raises:
DrawError – If error occurs.
- Return type:
None
See also
Changed in version 0.21.3: Added filter_data parameter.
Sets master footer text.
- Parameters:
text (str) – Footer text.
- Raises:
ShapeMissingError – If unable to find footer shape.
DrawPageError – If any other error occurs.
- Return type:
None
- set_name(name)
Sets the name of a slide.
- Parameters:
name (str) – Name.
- Raises:
DrawError – If error occurs setting name.
- 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_transition(fade_effect, speed, change, duration)
Sets the transition for a slide.
- Parameters:
slide (XDrawPage) – Slide
fade_effect (FadeEffect) – Fade Effect
speed (AnimationSpeed) – Animation Speed
change (SlideShowKind) – Slide show kind
duration (int) – Duration of slide. Only used when
change=SlideShowKind.AUTO_CHANGE
- Raises:
DrawPageError – If error occurs.
- 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
- title_only_slide(header)
Creates a slide with only a title
- Parameters:
header (str) – Header text.
- Raises:
DrawError – If error occurs.
- Return type:
None
- ungroup(shape)
Un-groups the given shape.
- Parameters:
shape (XShapeGroup) – The shape to ungroup.
- Return type:
None
- property component: com.sun.star.drawing.MasterPage
MasterPage Component
- Return type:
MasterPage
- 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 office_doc: OfficeDocumentT
Office Document.
- Return type:
- property owner: _T
Component Owner
- Return type:
TypeVar
(_T
, bound= ComponentT)