From d968bcfda55fd650dfbfc95e0481baccb81a1f5d Mon Sep 17 00:00:00 2001 From: Seyong Um Date: Thu, 29 Apr 2021 15:48:01 +0900 Subject: [PATCH] Handle a Shape having formula - AlternateContent Symptom: Once a formula added into any type of shape, then Slide.shapes will not handle the Shape Reason: The shape is represented inside of AlternateContent element. Solution: Select first item of AlternateContent as a content. --- pptx/oxml/shapes/groupshape.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pptx/oxml/shapes/groupshape.py b/pptx/oxml/shapes/groupshape.py index e428bd79e..b9c622d65 100644 --- a/pptx/oxml/shapes/groupshape.py +++ b/pptx/oxml/shapes/groupshape.py @@ -145,6 +145,25 @@ def iter_shape_elms(self): if elm.tag in self._shape_tags: yield elm + if elm.tag == qn("ve:AlternateContent"): + choice = elm.find(qn("ve:Choice")) + + if choice != None: + for content in choice.iterchildren(): + #Choose first, among proper items + if content.tag in self._shape_tags: + yield content + break + else: + fallback = elm.find(qn("ve:Fallback")) + + if fallback != None: + for content in fallback.iterchildren(): + # Choose first, among proper items + if content.tag in self._shape_tags: + yield content + break + @property def max_shape_id(self): """Maximum int value assigned as @id in this slide.