From e60dd634bcd695e5406f324c90a9e5ea6dad8b06 Mon Sep 17 00:00:00 2001 From: Matthew Hoopes Date: Wed, 1 Apr 2015 12:08:31 -0400 Subject: [PATCH] added custom geom stuff to the group shape stuff --- pptx/oxml/shapes/groupshape.py | 2 +- pptx/shapes/groupshape.py | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pptx/oxml/shapes/groupshape.py b/pptx/oxml/shapes/groupshape.py index 1468f2641..f7cd24004 100644 --- a/pptx/oxml/shapes/groupshape.py +++ b/pptx/oxml/shapes/groupshape.py @@ -83,7 +83,7 @@ def add_custom_geometry(self, id_, name, left, top, width, height): position and size. """ sp = CT_Shape.new_custom_geometry_sp(id_, name, left, top, width, height) - self.insert_element_before(sp, 'p:extList') + self.insert_element_before(sp, 'p:extLst') return sp def add_groupshape(self, id_, name, x, y, cx, cy): diff --git a/pptx/shapes/groupshape.py b/pptx/shapes/groupshape.py index fe752ba1e..954822b14 100644 --- a/pptx/shapes/groupshape.py +++ b/pptx/shapes/groupshape.py @@ -170,6 +170,23 @@ def add_textbox(self, left, top, width, height): textbox = self._shape_factory(sp) return textbox + def add_custom_geometry(self, left, top, width, height): + """ + Add a custom geometry shpane of specified size at specified position + on slide. + """ + sp = self._add_cust_geom_sp(left, top, width, height) + cust_geom = self._shape_factory(sp) + return cust_geom + + def add_groupshape(self, left, top, width, height): + """ + Add groupshape of specified size at specified position on slide. + """ + sp = self._add_groupshape_sp(left, top, width, height) + groupshape = self._shape_factory(sp) + return groupshape + def clone_layout_placeholders(self, slide_layout): """ Add placeholder shapes based on those in *slide_layout*. Z-order of @@ -284,6 +301,24 @@ def _add_textbox_sp(self, x, y, cx, cy): sp = self._grpSp.add_textbox(id_, name, x, y, cx, cy) return sp + def _add_cust_geom_sp(self, x, y, cx, cy): + """ + Return a newly-added custom geometry ```` element + """ + id_ = self._next_shape_id + name = 'CustGeom %s' % id_ + sp = self._grpSp.add_custom_geometry(id_, name, x, y, cx, cy) + return sp + + def _add_groupshape_sp(self, x, y, cx, cy): + """ + + """ + id_ = self._next_shape_id + name = 'GroupShape %d' % (id_-1) + sp = self._grpSp.add_groupshape(id_, name, x, y, cx, cy) + return sp + def _clone_layout_placeholder(self, layout_placeholder): """ Add a new placeholder shape based on the slide layout placeholder