Class DrawPagePartial

class ooodev.draw.partial.draw_page_partial.DrawPagePartial(owner, component, lo_inst=None)[source]

Represents a draw page.

__init__(owner, component, lo_inst=None)[source]
Parameters:
  • owner (_T) –

  • component (XDrawPage) –

  • lo_inst (LoInst | None) –

Return type:

None

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).

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)[source]

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)[source]

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:
Returns:

Shape

Return type:

XShape

See also

DispatchShape

add_pres_shape(shape_type, x, y, width, height)[source]

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)[source]

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

Note

If x or y is negative or 0 then the shape position will not be set. If width or height is negative or 0 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()[source]

Adds slide number to a slide

Parameters:

slide (XDrawPage) – Slide

Raises:

ShapeError – If error occurs.

Returns:

Slide number shape.

Return type:

DrawShape

blank_slide()[source]

Inserts a blank slide

Parameters:

slide (XDrawPage) – Slide

Raises:

DrawError – If error occurs

Return type:

None

bullets_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

Parameters:
  • slide (XDrawPage) – Slide

  • title (str) – Title

Raises:

DrawError – If error setting slide.

Returns:

Text Object

Return type:

DrawText

copy_shape(old_shape)[source]

Copies a shape

Parameters:

old_shape (XShape) – Old Shape

Raises:

ShapeError – If unable to copy shape.

Returns:

Newly Copied shape.

Return type:

DrawShape

copy_shape_contents(old_shape)[source]

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:

DrawShape

draw_bezier_closed(pts: Sequence[ooo.lo.awt.point.Point], flags: Sequence[ooo.lo.drawing.polygon_flags.PolygonFlags]) ooodev.draw.shapes.closed_bezier_shape.ClosedBezierShape[ooodev.draw.partial.draw_page_partial._T][source]
draw_bezier_closed(pts: Sequence[Sequence[ooo.lo.awt.point.Point]], flags: Sequence[Sequence[ooo.lo.drawing.polygon_flags.PolygonFlags]]) ooodev.draw.shapes.closed_bezier_shape.ClosedBezierShape[ooodev.draw.partial.draw_page_partial._T]
draw_bezier_closed(pts, flags)

Draws a bezier curve.

Parameters:
  • pts (Sequence[Point]) – Points

  • flags (Sequence[PolygonFlags]) – Flags

Raises:
  • IndexError – If pts and flags do not have the same number of elements.

  • ShapeError – If unable to create Bezier Shape.

Returns:

Bezier Shape.

Return type:

ClosedBezierShape

draw_bezier_open(pts: Sequence[ooo.lo.awt.point.Point], flags: Sequence[ooo.lo.drawing.polygon_flags.PolygonFlags]) ooodev.draw.shapes.open_bezier_shape.OpenBezierShape[ooodev.draw.partial.draw_page_partial._T][source]
draw_bezier_open(pts: Sequence[Sequence[ooo.lo.awt.point.Point]], flags: Sequence[Sequence[ooo.lo.drawing.polygon_flags.PolygonFlags]]) ooodev.draw.shapes.open_bezier_shape.OpenBezierShape[ooodev.draw.partial.draw_page_partial._T]
draw_bezier_open(pts, flags)

Draws a bezier curve.

Parameters:
  • pts (Sequence[Point]) – Points

  • flags (Sequence[PolygonFlags]) – Flags

Raises:
  • IndexError – If pts and flags do not have the same number of elements.

  • ShapeError – If unable to create Bezier Shape.

Returns:

Bezier Shape.

Return type:

OpenBezierShape

draw_circle(x, y, radius)[source]

Gets a circle

Parameters:
  • x (int, UnitT) – Shape X position in mm units or UnitT.

  • y (int, UnitT) – Shape Y position in mm units or UnitT.

  • radius (int, UnitT) – Shape radius in mm units or UnitT.

Raises:

ShapeError – If error occurs.

Returns:

Circle Shape.

Return type:

EllipseShape

draw_ellipse(x, y, width, height)[source]

Gets an ellipse

Parameters:
  • 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:

Ellipse Shape.

Return type:

EllipseShape

draw_formula(formula, x, y, width, height)[source]

Draws a formula

Parameters:
  • slide (XDrawPage) – Slide

  • formula (str) – Formula as string 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

Raises:

ShapeError – If error occurs.

Returns:

Formula Shape.

Return type:

XShape

Note

If x or y is negative or 0 then the shape position will not be set. If width or height is negative or 0 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(fnm: Any)[source]
draw_image(fnm: Any, x: int | UnitT, y: int | UnitT)
draw_image(fnm: Any, x: int | UnitT, y: int | UnitT)
draw_image(*args, **kwargs)

Draws an image.

Parameters:
  • fnm (PathOrStr) – Path to image

  • 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:

Shape

Return type:

GraphicObjectShape

draw_image_offset(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.

Parameters:
  • slide (XDrawPage) – Slide

  • fnm (PathOrStr) – Path to image.

  • xoffset (ImageOffset, float) – X Offset with value between 0.0 and 1.0

  • yoffset (ImageOffset, float) – Y Offset with value between 0.0 and 1.0

Returns:

Shape on success, None otherwise.

Return type:

GraphicObjectShape | None

draw_line(x1, y1, x2, y2)[source]

Draws a line.

Parameters:
  • x1 (int, UnitT) – Line start X position in mm units or UnitT.

  • y1 (int, UnitT) – Line start Y position mm units or UnitT.

  • x2 (int, UnitT) – Line end X position mm units or UnitT.

  • y2 (int, UnitT) – Line end Y position mm units or UnitT.

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:

LineShape

draw_lines(xs, ys)[source]

Draw lines

Parameters:
  • xs (Sequence[Union[int, UnitT]) – Sequence of X positions in mm units or UnitT.

  • ys (Sequence[Union[int, UnitT]) – Sequence of Y positions in mm units or UnitT.

Raises:
  • IndexError – If xs and xy do not have the same number of elements.

  • ShapeError – If any other error occurs.

Returns:

Lines Shape.

Return type:

PolyLineShape

Note

The number of points must be the same for both xs and ys.

draw_media(fnm, x, y, width, height)[source]

Draws media.

Parameters:
  • fnm (PathOrStr) – Path to Media file.

  • 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:

Media shape.

Return type:

XShape

Note

If x or y is negative or 0 then the shape position will not be set. If width or height is negative or 0 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)[source]

Draw a line from x, y in the direction of degrees, for the specified distance degrees is measured clockwise from x-axis

Parameters:
  • x (int, UnitT) – Shape X position in mm units or UnitT.

  • y (int, UnitT) – Shape Y position in mm units or UnitT.

  • degrees (int) – Direction of degrees

  • distance (int, UnitT) – Distance of line in mm units or UnitT..

Raises:

ShapeError – If unable to create Polar Line Shape.

Returns:

Polar Line Shape.

Return type:

LineShape

draw_polygon(x: int | UnitT, y: int | UnitT, sides: PolySides | int) ooodev.draw.shapes.poly_polygon_shape.PolyPolygonShape[ooodev.draw.partial.draw_page_partial._T][source]
draw_polygon(x: int | UnitT, y: int | UnitT, sides: PolySides | int, radius: int) ooodev.draw.shapes.poly_polygon_shape.PolyPolygonShape[ooodev.draw.partial.draw_page_partial._T]
draw_polygon(x, y, sides, radius=20)

Gets a polygon.

Parameters:
  • 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 to 30.

  • radius (int, optional) – Shape radius in mm units. Defaults to the value of draw.Draw.POLY_RADIUS.

Raises:

ShapeError – If error occurs.

Returns:

Polygon Shape.

Return type:

PolyPolygonShape

draw_rectangle(x, y, width, height)[source]

Gets a rectangle.

Parameters:
  • 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:

Rectangle Shape.

Return type:

RectangleShape

Note

If x or y is negative or 0 then the shape position will not be set. If width or height is negative or 0 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)[source]

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:

TextShape

Note

If x or y is negative or 0 then the shape position will not be set. If width or height is negative or 0 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()[source]

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)[source]

Finds a shape at a given position.

Parameters:
  • x (int) – X position.

  • y (int) – Y position.

Raises:
Returns:

Shape if Found; Otherwise, None.

Return type:

ShapeBase[Any] | None

find_shape_at_position_size(x, y, width, height)[source]

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:
Returns:

Shape if Found; Otherwise, None.

Return type:

ShapeBase[Any] | None

find_shape_by_name(shape_name)[source]

Finds a shape by its name.

Parameters:

shape_name (str) – Shape Name.

Raises:
Returns:

Shape.

Return type:

DrawShape

find_shape_by_type(shape_type)[source]

Finds a shape by its type

Parameters:

shape_type (DrawingNameSpaceKind | str) – Shape Type

Raises:
Returns:

Shape

Return type:

DrawShape

find_top_shape()[source]

Gets the top most shape of a slide.

Raises:
Returns:

Top most shape.

Return type:

DrawShape

get_animation_node()[source]

Gets Animation Node

Parameters:

slide (XDrawPage) – Slide

Raises:

DrawPageError – If error occurs.

Returns:

Animation Node

Return type:

XAnimationNode

get_chart_shape(x, y, width, height)[source]

Gets a chart shape.

Parameters:
  • 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:

Chart Shape.

Return type:

OLE2Shape

get_fill_color()[source]

Gets the fill color of a shape.

Parameters:

shape (XShape) – Shape

Raises:

ColorError – If error occurs.

Returns:

Color

Return type:

Color

get_form_container()[source]

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()[source]

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()[source]

Gets the line color of a shape.

Raises:

ColorError – If error occurs.

Returns:

Color

Return type:

Color

get_line_thickness()[source]

Gets line thickness of a shape.

Returns:

Line Thickness on success; Otherwise, 0.

Return type:

int

get_name()[source]

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_ordered_shapes()[source]

Gets ordered shapes

Returns:

List of Ordered Shapes.

Return type:

List[DrawShape[_T]]

See also

get_shapes()

get_shape_text()[source]

Gets the text from inside a shape.

Raises:

DrawError – If error occurs getting shape text.

Returns:

Shape text

Return type:

str

get_shapes()[source]

Gets shapes

Returns:

List of Shapes.

Return type:

List[ShapeBase[_T]]

get_size_mm()[source]

Gets size of the given slide page (in mm units)

Raises:

SizeError – If unable to get size.

Returns:

Size struct.

Return type:

Size

get_slide_number()[source]

Gets slide number.

Raises:

DrawError – If error occurs.

Returns:

Slide Number.

Return type:

int

get_slide_title()[source]

Gets slide title if it exist.

Raises:

DrawError – If error occurs.

Returns:

Slide Title on success; Otherwise, None.

Return type:

str | None

goto_page()[source]

Go to page represented by this object.

Raises:

DrawError – If error occurs.

Return type:

None

move_to_bottom(shape)[source]

Moves a shape to the bottom of the z-order

Parameters:

shape (XShape) – Shape

Raises:
Return type:

None

move_to_top(shape)[source]

Moves a shape to the top of the z-order

Parameters:

shape (XShape) – Shape

Raises:
Return type:

None

remove_master_page()[source]

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)[source]

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 or image/png.

  • filter_data (dict, optional) – Filter data. Defaults to None.

Raises:

DrawError – If error occurs.

Return type:

None

Changed in version 0.21.3: Added filter_data parameter.

set_name(name)[source]

Sets the name of a slide.

Parameters:

name (str) – Name.

Raises:

DrawError – If error occurs setting name.

Return type:

None

set_transition(fade_effect, speed, change, duration)[source]

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

title_only_slide(header)[source]

Creates a slide with only a title

Parameters:

header (str) – Header text.

Raises:

DrawError – If error occurs.

Return type:

None