Class Draw
- class ooodev.office.draw.Draw[source]
Draw Class
- static add_bullet(bulls_txt, 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).
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
bulls_txt (XText) – Text object
level (int) – Bullet Level
text (str) – Bullet Text
- Raises:
DrawError – If error adding bullet.
- Return type:
None
- classmethod add_connector(slide, shape1, shape2, start_conn=None, end_conn=None)[source]
Add connector.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide.
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)
- classmethod add_dispatch_shape(slide, shape_dispatch, x, y, width, height, fn)[source]
Adds a shape to a Draw slide via a dispatch command.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide.
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
Example - Impress Make Slides
- static add_layer(lm, layer_name)[source]
Adds a layer.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
lm (XLayerManager) – Layer Manager.
layer_name (str) – Layer Name.
- Raises:
DrawError – If error occurs.
- Returns:
Newly added layer.
- Return type:
XLayer
- classmethod add_pres_shape(slide, shape_type, x, y, width, height)[source]
Creates a shape from the “com.sun.star.presentation” package.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide.
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
- classmethod add_shape(slide, shape_type, x, y, width, height)[source]
Adds a shape to a slide.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide
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
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.See also
Changed in version 0.17.14: Now does not set size and/or position unless the values are greater than
0
.
- classmethod add_slide(doc)[source]
Add a slide to the end of the document.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Raises:
DrawPageMissingError – If unable to get pages.
DrawPageError – If any other error occurs.
- Returns:
The slide that was inserted at the end of the document.
- Return type:
XDrawPage
- classmethod add_slide_number(slide)[source]
Adds slide number to a slide.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide.
- Raises:
ShapeError – If error occurs.
- Returns:
Slide number shape.
- Return type:
XShape
- classmethod add_text(shape, msg, font_size=0, **props)[source]
Add text to a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
msg (str) – Text to add
font_size (float, optional) – Font size in Points or UnitT.
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
- static blank_slide(slide)[source]
Inserts a blank slide.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide.
- Raises:
DrawError – If error occurs.
- Return type:
None
- classmethod build_play_list(doc, custom_name, *slide_idxs)[source]
Build a named play list container of slides from doc. The name of the play list is
custom_name
.Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document
custom_name (str) – Name for play list
slide_idxs (int) – One or more index’s of existing slides to add to play list.
- Raises:
DrawError – If error occurs.
- Returns:
Name Container.
- Return type:
XNameContainer
- classmethod bullets_slide(slide, title)[source]
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.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide
title (str) – Title
- Raises:
DrawError – If error setting slide.
- Returns:
Text Object.
- Return type:
XText
- static combine_shape(doc, shapes, combine_op)[source]
Combines one or more shapes using a dispatch command.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
doc (XComponent) – Document.
shapes (XShapes) – Shapes to combine.
combine_op (ShapeCompKind) – Combine Operation.
- Raises:
ShapeError – If error occurs.
- Returns:
New combined shape.
- Return type:
XShape
- classmethod copy_shape(slide, old_shape)[source]
Copies a shape.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide
old_shape (XShape) – Old Shape
- Raises:
ShapeError – If unable to copy shape.
- Returns:
Newly Copied shape.
- Return type:
XShape
- classmethod copy_shape_contents(slide, old_shape)[source]
Copies a shapes contents from old shape into new shape.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide.
old_shape (XShape) – Old shape.
- Raises:
ShapeError – If unable to copy shape contents.
- Returns:
New shape with contents of old shape copied.
- Return type:
XShape
- classmethod create_control_shape(label, x, y, width, height, shape_kind, **props)[source]
Creates a control shape.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
label (str) – Label to apply.
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.
shape_kind (FormControlKind | str) – The kind of control to create.
props (Any, optional) – Any extra key value options to set on the Model of the control being created such as
FontHeight=18.0, Name="BLA"
.
- Raises:
ShapeError – If error occurs.
- Returns:
Control Shape.
- Return type:
XControlShape
Changed in version 0.17.0: No longer sets
FontHeight
orFontName
properties.
- static create_dispatch_shape(slide, shape_dispatch, fn)[source]
Creates a shape via a dispatch command.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide.
shape_dispatch (ShapeDispatchKind | str) – Dispatch Command.
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
Example - Impress Make Slides
- static create_draw_doc()[source]
- static create_draw_doc(loader: com.sun.star.frame.XComponentLoader)
- static create_draw_doc(lo_inst: ooodev.loader.inst.lo_inst.LoInst)
- static create_draw_doc(*args, **kwargs)
Creates a new Draw document.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
loader (XComponentLoader) – Component Loader. Usually generated with
Lo
- Returns:
Component representing document
- Return type:
XComponent
- static create_impress_doc()[source]
- static create_impress_doc(loader: com.sun.star.frame.XComponentLoader)
- static create_impress_doc(lo_inst: ooodev.loader.inst.lo_inst.LoInst)
- static create_impress_doc(*args, **kwargs)
Creates a new Impress document.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
loader (XComponentLoader) – Component Loader. Usually generated with
Lo
- Returns:
Component representing document
- Return type:
XComponent
- classmethod delete_slide(doc, idx)[source]
Deletes a slide.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
idx (int) – Index.
- Returns:
True
on success; Otherwise,False
- Return type:
bool
- classmethod draw_bezier(slide, pts, flags, is_open)[source]
Draws a bezier curve.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide.
pts (Sequence[Point]) – Points.
flags (Sequence[PolygonFlags]) – Flags.
is_open (bool) – Determines if an open or closed bezier is drawn.
- 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:
XShape
- classmethod draw_circle(slide, x, y, radius)[source]
Gets a circle.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Circle Shape.
- Return type:
XShape
- classmethod draw_ellipse(slide, x, y, width, height)[source]
Gets an ellipse.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Ellipse Shape.
- Return type:
XShape
- classmethod draw_formula(slide, formula, x, y, width, height)[source]
Draws a formula.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- 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
.
- classmethod draw_image(slide: com.sun.star.drawing.XDrawPage, fnm: Any)[source]
- classmethod draw_image(slide: com.sun.star.drawing.XDrawPage, fnm: Any)
- classmethod draw_image(slide: com.sun.star.drawing.XDrawPage, fnm: Any)
- classmethod draw_image(*args, **kwargs)
Draws an image.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Shape.
- Return type:
XShape
- classmethod draw_image_offset(slide, fnm, xoffset, yoffset)[source]
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.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- 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:
XShape | None
- classmethod draw_line(slide, x1, y1, x2, y2)[source]
Draws a line.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- 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:
XShape
- classmethod draw_lines(slide, xs, ys)[source]
Draw lines.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- 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:
XShape
Note
The number of points must be the same for both
xs
andys
.
- classmethod draw_media(slide, fnm, x, y, width, height)[source]
Draws media.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- 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
.
- classmethod draw_polar_line(slide, x, y, degrees, distance)[source]
Draw a line from
x
,y
in the direction of degrees, for the specified distance degrees is measured clockwise from x-axis.Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
- Raises:
ShapeError – If unable to create Polar Line Shape.
- Returns:
Polar Line Shape.
- Return type:
XShape
- classmethod draw_polygon(slide: com.sun.star.drawing.XDrawPage, x: int | UnitT, y: int | UnitT, sides: PolySides | int) com.sun.star.drawing.XShape [source]
- classmethod draw_polygon(slide: com.sun.star.drawing.XDrawPage, x: int | UnitT, y: int | UnitT, sides: PolySides | int, radius: int) com.sun.star.drawing.XShape
- classmethod draw_polygon(slide, x, y, sides, radius=20)
Gets a polygon.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
slide (XDrawPage) – Slide.
x (int, UnitT) – Shape X position in mm units or UnitT.
y (int, UnitT) – Shape Y position in mm units or UnitT.
sides (PolySides | int) – Polygon Sides value from
3
to30
.radius (int, optional) – Shape radius in mm units. Defaults to the value of
Draw.POLY_RADIUS
.
- Raises:
ShapeError – If error occurs.
- Returns:
Polygon Shape.
- Return type:
XShape
- classmethod draw_rectangle(slide, x, y, width, height)[source]
Gets a rectangle.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Returns:
Rectangle 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
.
- classmethod draw_text(slide: com.sun.star.drawing.XDrawPage, msg: str, x: int, y: int, width: int, height: int) com.sun.star.drawing.XShape [source]
- classmethod draw_text(slide: com.sun.star.drawing.XDrawPage, msg: str, x: int, y: int, width: int, height: int, font_size: int) com.sun.star.drawing.XShape
- classmethod draw_text(slide, msg, x, y, width, height, font_size=0)
Draws Text.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- 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:
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
.
- classmethod duplicate(doc, idx)[source]
Duplicates a slide.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
idx (int) – Index of slide to duplicate.
- Raises:
DrawError If unable to create duplicate. –
- Returns:
Duplicated slide.
- Return type:
XDrawPage
- classmethod find_biggest_zorder(slide)[source]
Finds the shape with the largest z-order.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide
- Raises:
DrawError – If unable to find biggest z-order.
- Returns:
Z-Order
- Return type:
int
- static find_master_page(doc, style)[source]
Finds master page.
- Parameters:
doc (XComponent) – Document.
style (str) – Style of master page.
- Return type:
XDrawPage
Method is Lo Instance Safe for use with multiple documents.
- Raises:
DrawPageMissingError – If unable to match
style
.DrawPageError – if any other error occurs.
- Returns:
Master page as Draw Page if found.
- Return type:
XDrawPage
- Parameters:
doc (XComponent) –
style (str) –
- classmethod find_shape_by_name(slide, shape_name)[source]
Finds a shape by its name.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide.
shape_name (str) – Shape Name.
- Raises:
ShapeMissingError – If shape is not found.
ShapeError – If any other error occurs.
- Returns:
Shape.
- Return type:
XShape
- classmethod find_shape_by_type(slide, shape_type)[source]
Finds a shape by its type.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide
shape_type (DrawingNameSpaceKind | str) – Shape Type
- Raises:
ShapeMissingError – If shape is not found.
ShapeError – If any other error occurs.
- Returns:
Shape
- Return type:
XShape
- classmethod find_slide_idx_by_name(doc, name)[source]
Gets a slides index by its name.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
name (str) – Slide Name.
- Returns:
Zero based index if found; Otherwise
-1
.- Return type:
int
- classmethod find_top_shape(slide)[source]
Gets the top most shape of a slide.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – 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:
XShape
- classmethod gen_polygon_points(x, y, radius, sides)[source]
Generates a list of polygon points.
Method is Lo Instance Safe for use with multiple documents.
- static get_animation_node(slide)[source]
Gets Animation Node.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide.
- Raises:
DrawPageError – If error occurs.
- Returns:
Animation Node.
- Return type:
XAnimationNode
- classmethod get_chart_shape(slide, x, y, width, height)[source]
Gets a chart shape.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
- Raises:
ShapeError – If Error occurs.
- Returns:
Chart Shape.
- Return type:
XShape
- static get_fill_color(shape)[source]
Gets the fill color of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Raises:
ColorError – If error occurs.
- Returns:
Color
- Return type:
- static get_form_container(slide)[source]
Gets form container. The first form in slide is returned if found.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide
- Raises:
DrawError – If error occurs.
- Returns:
Form Container on success, None otherwise.
- Return type:
XIndexContainer | None
- static get_glue_points(shape)[source]
Gets Glue Points.
Method is Lo Instance Safe for use with multiple documents.
- 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.
- static get_handout_master_page(doc)[source]
Gets handout master page for an impress document.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Impress Document.
- Raises:
DrawError – If unable to get hand-out master page.
DrawPageMissingError – If Draw Page is
None
.
- Returns:
Draw Page
- Return type:
XDrawPage
- static get_layer(doc, layer_name)[source]
Gets layer from layer name.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
layer_name (str) – Layer Name.
- Raises:
NameError – If
layer_name
does not exist.DrawError – If unable to get layer.
- Returns:
Found Layer
- Return type:
XLayer
- static get_layer_manager(doc)[source]
Gets Layer manager for document.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Raises:
DrawError – If error occurs.
- Returns:
Layer Manager.
- Return type:
XLayerManager
- static get_line_color(shape)[source]
Gets the line color of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Raises:
ColorError – If error occurs.
- Returns:
Color
- Return type:
- static get_line_thickness(shape)[source]
Gets line thickness of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Returns:
Line Thickness on success; Otherwise,
0
.- Return type:
int
- classmethod get_master_page(doc: com.sun.star.lang.XComponent, idx: int)[source]
- classmethod get_master_page(slide: com.sun.star.drawing.XDrawPage)
- classmethod get_master_page(*args, **kwargs)
Gets master page.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
idx (int) – Index of page.
slide (XDrawPage) – Slide to get master page from.
- Raises:
DrawPageError – if unable to get master page.
IndexError – if
idx
is out of bounds.
- Returns:
Draw page.
- Return type:
XDrawPage
- static get_master_page_count(doc)[source]
Gets master page count.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Raises:
DrawError – If error occurs.
- Returns:
Master Page Count.
- Return type:
int
- static get_name(slide)[source]
Gets the name of a slide.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide.
- Raises:
DrawError – If error occurs getting name.
- Returns:
Slide name.
- Return type:
str
New in version 0.17.13.
- static get_notes_page(slide)[source]
Gets the notes page of a slide.
Each draw page has a notes page.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide
- Raises:
DrawPageMissingError – If notes page is
None
.DrawPageError – If any other error occurs.
- Returns:
Notes Page.
- Return type:
XDrawPage
See also
- classmethod get_notes_page_by_index(doc, idx)[source]
Gets notes page by index.
Each draw page has a notes page.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document
idx (int) – Index
- Raises:
DrawPageError – If error occurs.
- Returns:
Notes Page.
- Return type:
XDrawPage
See also
- classmethod get_ordered_shapes(doc: com.sun.star.lang.XComponent)[source]
- classmethod get_ordered_shapes(slide: com.sun.star.drawing.XDrawPage)
- classmethod get_ordered_shapes(*args, **kwargs)
Gets ordered shapes.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
slide (XDrawPage) – Slide.
- Returns:
List of Ordered Shapes.
- Return type:
List[XShape]
See also
- static get_play_list(doc)[source]
Gets Play list.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Raises:
DrawError – If error occurs.
- Returns:
Name Container.
- Return type:
XNameContainer
- static get_position(shape)[source]
Gets position in mm units.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
- Raises:
PointError – If error occurs.
- Returns:
Position as Point in mm units.
- Return type:
- static get_rotation(shape)[source]
Gets the rotation of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Raises:
ShapeError – If error occurs.
- Returns:
Rotation angle.
- Return type:
- classmethod get_shape_text(shape: com.sun.star.drawing.XShape)[source]
- classmethod get_shape_text(slide: com.sun.star.drawing.XDrawPage)
- classmethod get_shape_text(*args, **kwargs)
Gets the text from inside a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
slide (XDrawPage) – Slide.
- Raises:
DrawError – If error occurs getting shape text.
- Returns:
Shape text.
- Return type:
str
- classmethod get_shapes(doc: com.sun.star.lang.XComponent)[source]
- classmethod get_shapes(slide: com.sun.star.drawing.XDrawPage)
- classmethod get_shapes(*args, **kwargs)
Gets Shapes.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
slide (XDrawPage) – Slide.
- Raises:
ShapeError – Conditionally if event
DrawNamedEvent.GET_SHAPES_ERROR
is subscribe to. See Note.- Returns:
List of shapes.
- Return type:
List[XShape]
Note
By default
get_shapes
will ignore shapes that fail to load. This behavior can be overridden by subscribing toDrawNamedEvent.GET_SHAPES_ERROR
event.The event is called with
CancelEventArgs
.If
event.cancel
isTrue
then a list of shapes is returned containing all shapes that were added before first error occurred.If
Event.event_data["raise_error] = True
then aShapeError
is raised.from ooodev.events.args.cancel_event_args import CancelEventArgs from ooodev.events.lo_events import LoEvents from ooodev.events.draw_named_event import DrawNamedEvent from ooodev.exceptions.ex import ShapeError def on_shapes_error(source: Any, e: CancelEventArgs) -> None: e.event_data["raise_error] = True LoEvents().on(DrawNamedEvent.GET_SHAPES_ERROR, on_shapes_error) def do_something(doc: XComponent) -> None: try: shapes = Draw.get_shapes(doc) except ShapeError: # this error only occurred because event raise_error was set in on_shapes_error # handle error ...
- classmethod get_shapes_text(doc)[source]
Gets the text from inside all the document shapes.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Returns:
Shapes text.
- Return type:
str
See also
- static get_show(doc)[source]
Gets Slide show Presentation.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Raises:
DrawError – If error occurs.
- Returns:
Slide Show Presentation.
- Return type:
XPresentation2
- static get_show_controller(show)[source]
Gets slide show controller.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
show (XPresentation2) – Slide Show Presentation.
- Raises:
DrawError – If error occurs.
- Returns:
Slide Show Controller.
- Return type:
XSlideShowController
Note
It may take a little bit for the slides show to start. For this reason this method will wait up to five seconds.
- static get_size(shape)[source]
Gets Size in mm units.
Method is Lo Instance Safe for use with multiple documents.
- classmethod get_slide(doc: com.sun.star.lang.XComponent)[source]
- classmethod get_slide(doc: com.sun.star.lang.XComponent, idx: int)
- classmethod get_slide(slides: com.sun.star.drawing.XDrawPages)
- classmethod get_slide(slides: com.sun.star.drawing.XDrawPages, idx: int)
- classmethod get_slide(*args, **kwargs)
Gets slide by page index.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
slides (XDrawPages) – Draw Pages.
idx (int) – Index of slide. Default
0
.
- Raises:
IndexError – If
idx
is out of bounds.DrawError – If any other error occurs.
- Returns:
Slide as Draw Page.
- Return type:
XDrawPage
- classmethod get_slide_number(xdraw_view: com.sun.star.drawing.XDrawView)[source]
- classmethod get_slide_number(slide: com.sun.star.drawing.XDrawPage)
- classmethod get_slide_number(*args, **kwargs)
Gets slide number.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
xdraw_view (XDrawView) – Draw View.
slide (XDrawPage) – Slide.
- Raises:
DrawError – If error occurs.
- Returns:
Slide Number.
- Return type:
int
- static get_slide_size(slide)[source]
Gets size of the given slide page (in mm units).
Method is Lo Instance Safe for use with multiple documents.
- static get_slide_template_path()[source]
Gets Slide template directory.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Returns:
Path as string.
- Return type:
str
See also
- classmethod get_slide_title(slide)[source]
Gets slide title if it exist.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide
- Raises:
DrawError – If error occurs.
- Returns:
Slide Title on success; Otherwise,
None
.- Return type:
str | None
- static get_slides(doc)[source]
Gets the draw pages of a document.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Raises:
DrawPageMissingError – If there are no draw pages.
DrawPageError – If any other error occurs.
- Returns:
Draw Pages.
- Return type:
XDrawPages
- classmethod get_slides_count(doc)[source]
Gets the slides count.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Returns:
Number of slides.
- Return type:
int
- classmethod get_slides_list(doc)[source]
Gets all the slides as a list of XDrawPage.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document
- Returns:
List of pages
- Return type:
List[XDrawPage]
- static get_text_properties(shape)[source]
Gets the properties associated with the text area inside the shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Raises:
PropertySetError – If error occurs.
- Returns:
Property Set
- Return type:
XPropertySet
- static get_transformation(shape)[source]
Gets a transformation matrix which seems to represent a clockwise rotation.
Homogeneous matrix has three homogeneous lines
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Raises:
ShapeError – If error occurs.
- Returns:
Matrix
- Return type:
HomogenMatrix3
- static get_viewed_page(doc)[source]
Gets viewed page.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Raises:
DrawPageError – If error occurs.
- Returns:
Draw Page.
- Return type:
XDrawPage
- static get_zorder(shape)[source]
Gets the z-order of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Raises:
DrawError – If unable to get z-order.
- Returns:
Z-Order
- Return type:
int
- classmethod goto_page(doc: com.sun.star.lang.XComponent, page: com.sun.star.drawing.XDrawPage)[source]
- classmethod goto_page(ctl: com.sun.star.frame.XController, page: com.sun.star.drawing.XDrawPage)
- classmethod goto_page(*args, **kwargs)
Go to page.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
ctl (XController) – Controller.
page (XDrawPage) – Page.
- Raises:
DrawError – If error occurs.
- Return type:
None
- static insert_master_page(doc, idx)[source]
Inserts a master page.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
idx (int) – Index used to insert page.
- Raises:
DrawPageError – If unable to insert master page.
- Returns:
The newly inserted draw page.
- Return type:
XDrawPage
- classmethod insert_slide(doc, idx)[source]
Inserts a slide at the given position in the document.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document
idx (int) – Index
- Raises:
DrawPageMissingError – If unable to get pages.
DrawPageError – If any other error occurs.
- Returns:
New slide that was inserted.
- Return type:
XDrawPage
- static is_draw(doc)[source]
Gets if the document is a Draw document.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
- Returns:
True
if is Draw document; Otherwise,False
.- Return type:
bool
- static is_group(shape)[source]
Gets if a shape is a Group Shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Returns:
True
if shape is a group; Otherwise;False
.- Return type:
bool
- static is_image(shape)[source]
Gets if a shape is an image (GraphicObjectShape).
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Returns:
True
if shape is image; Otherwise,False
.- Return type:
bool
- static is_impress(doc)[source]
Gets if the document is an Impress document.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document
- Returns:
True
if is Impress document; Otherwise,False
- Return type:
bool
- static is_shapes_based(doc)[source]
Gets if the document is supports Draw or Impress.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document
- Returns:
True
if supports Draw or Impress; Otherwise,False
.- Return type:
bool
- classmethod make_shape(shape_type, x, y, width, height)[source]
Creates a shape.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- 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:
New 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.See also
Changed in version 0.17.14: Now does not set size and/or position unless the values are greater than
0
.
- classmethod move_to_bottom(slide, shape)[source]
Moves a shape to the bottom of the z-order.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide.
shape (XShape) – Shape.
- Raises:
ShapeMissingError – If unable to find shapes for slide.
ShapeError – If any other error occurs.
- Return type:
None
- classmethod move_to_top(slide, shape)[source]
Moves the z-order of a shape to the top.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide
shape (XShape) – Shape
- Raises:
DrawError – If unable to move shape to top.
- Return type:
None
- static print_matrix(mat)[source]
Prints matrix to console
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
mat (HomogenMatrix3) – Matrix
- Return type:
None
- static print_point(pt)[source]
Prints point to console in mm units.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
pt (Point) – Point object.
- Return type:
None
- static print_size(sz)[source]
Prints size to console in mm units.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
sz (SizeObj) – Size object.
- Return type:
None
- static remove_master_page(doc, slide)[source]
Removes a master page.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
doc (XComponent) – Document.
slide (XDrawPage) – Draw page to remove.
- Raises:
DrawError – If unable to remove master page.
- Return type:
None
- classmethod report_pos_size(shape)[source]
Prints shape information to the console.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Return type:
None
- static save_page(page, fnm, mime_type, filter_data=None)[source]
Saves a Draw page to file.
Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.
- Parameters:
page (XDrawPage) – Page to save
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.
- classmethod set_angle(shape, angle)[source]
Set the line style for a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
angle (Angle | int) – Angle to set.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- static set_bitmap_color(shape, name)[source]
Set bitmap color of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
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.
- static set_bitmap_file_color(shape, fnm)[source]
Set bitmap color from file.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
fnm (PathOrStr) – path to file.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- static set_dashed_line(shape, is_dashed)[source]
Set a dashed line.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
is_dashed (bool) – Determines if line is to be dashed or solid.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- classmethod set_gradient_color(shape: com.sun.star.drawing.XShape, name: DrawingGradientKind | str)[source]
- classmethod set_gradient_color(shape: com.sun.star.drawing.XShape, start_color: Color)
- classmethod set_gradient_color(shape: com.sun.star.drawing.XShape, start_color: Color)
- classmethod set_gradient_color(*args, **kwargs)
Set the gradient color of the shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
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
- static set_gradient_properties(shape, grad)[source]
Sets shapes gradient properties.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
grad (Gradient) – Gradient properties to set.
- Return type:
None
See also
- static set_hatch_color(shape, name)[source]
Set hatching color of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
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.
- static set_image(shape, fnm)[source]
Sets the image of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
fnm (PathOrStr) – Path to image.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- static set_image_graphic(shape, graphic)[source]
Sets the image of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
graphic (XGraphic) – Graphic.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- classmethod set_line_style(shape, style)[source]
Set the line style for a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
style (LineStyle) – Line Style.
- Raises:
ShapeError – If error occurs.
- Return type:
None
Sets master footer text.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
master (XDrawPage) – Master Draw Page.
text (str) – Footer text.
- Raises:
ShapeMissingError – If unable to find footer shape.
DrawPageError – If any other error occurs.
- Return type:
None
- static set_master_page(slide, page)[source]
Sets master page.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide.
page (XDrawPage) – Page to set as master.
- Raises:
DrawError – If unable to set master page.
- Return type:
None
- static set_name(slide, name)[source]
Sets the name of a slide.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide.
name (str) – Name.
- Raises:
DrawError – If error occurs setting name.
- Return type:
None
- classmethod set_position(shape: com.sun.star.drawing.XShape, pt: ooo.lo.awt.point.Point)[source]
- classmethod set_position(shape: com.sun.star.drawing.XShape, x: int | UnitT)
- classmethod set_position(*args, **kwargs)
Sets Position of shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Return type:
None
Note
If
x
ory
is negative or0
then the shape position will not be set.Changed in version 0.17.14: Now does not set position unless the values are greater than
0
.
- static set_rotation(shape, angle)[source]
Set the rotation of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
angle (Angle | int) – Angle or int. An angle value from
0
to359
.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- static set_shape_props(shape, **props)[source]
Sets properties on a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape object
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
Draw.set_shape_props(shape, Loop=True, MediaURL=FileIO.fnm_to_url(fnm))
- classmethod set_size(shape: com.sun.star.drawing.XShape, sz: object)[source]
- classmethod set_size(shape: com.sun.star.drawing.XShape, width: int | UnitT)
- classmethod set_size(*args, **kwargs)
Sets set_size of shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
- Raises:
ShapeError – If error occurs.
- Return type:
None
Note
If
width
orheight
is negative or0
then the shape size will not be set.Changed in version 0.17.14: Now does not set size unless the values are greater than
0
.
- static set_style(shape, graphic_styles, style_name)[source]
Set the graphic style for a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
graphic_styles (XNameContainer) – Graphic styles.
style_name (GraphicStyleKind | str) – Graphic Style Name.
- Raises:
DrawError – If error occurs.
- Return type:
None
- static set_transition(slide, fade_effect, speed, change, duration)[source]
Sets the transition for a slide.
Method is Lo Instance Safe for use with multiple documents.
- 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
- static set_transparency(shape, level)[source]
Sets the transparency level for the shape. Higher level means more transparent.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
level (Intensity, int) – Transparency value. Represents a intensity value from
0
to100
.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- classmethod set_visible(shape, is_visible)[source]
Set the line style for a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
is_visible (bool) – Set is shape is visible or not.
- Raises:
ShapeError – If error occurs.
- Return type:
None
- static set_zorder(shape, order)[source]
Sets the z-order of a shape.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape.
order (int) – Z-Order.
- Raises:
DrawError – If unable to set z-order.
- Return type:
None
- classmethod show_shape_info(shape)[source]
Prints shape info to console.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
shape (XShape) – Shape
- Return type:
None
- classmethod show_shapes_info(slide)[source]
Prints info for shapes to console.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide/
- Return type:
None
- classmethod title_only_slide(slide, header)[source]
Creates a slide with only a title.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide
header (str) – Header text.
- Raises:
DrawError – If error occurs.
- Return type:
None
- classmethod title_slide(slide, title)[source]
- classmethod title_slide(slide, title, sub_title)
- classmethod title_slide(slide, title, sub_title='')
Set a slides title and sub title.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
slide (XDrawPage) – Slide.
title (str) – Title.
sub_title (str) – Sub Title.
- Raises:
DrawError – If error setting Slide.
- Return type:
None
- static wait_ended(sc)[source]
Wait for until the slide is ended, which occurs when he user exits the slide show.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
sc (XSlideShowController) – Slide Show Controller
- Return type:
None
- static wait_last(sc, delay)[source]
Wait for delay milliseconds when the last slide is shown before returning.
Method is Lo Instance Safe for use with multiple documents.
- Parameters:
sc (XSlideShowController) – Slide Show Controller
delay (int) – Delay in milliseconds
- Return type:
None
- classmethod warns_position(slide, x, y)[source]
Warns via console if a
x
ory
is not on the page.Method is Lo Instance Safe for use with multiple documents.
- Parameters:
- Return type:
None
Note
This method uses
Lo.print()
. and if thoseprint()
commands are suppressed then this method will not be effective.
- POLY_RADIUS: int = 20
Default Poly Radius