def non_placeholder_shapes_(self, request):
     autoshape_sp_ = instance_mock(
         request,
         CT_Shape,
         name="autoshape_sp_",
         is_autoshape=True,
         is_textbox=False,
         has_custom_geometry=False,
     )
     autoshape_shape_ = Shape(autoshape_sp_, None)
     textbox_sp_ = instance_mock(
         request,
         CT_Shape,
         name="textbox_sp_",
         is_autoshape=False,
         is_textbox=True,
         has_custom_geometry=False,
     )
     textbox_shape_ = Shape(textbox_sp_, None)
     freeform_sp_ = instance_mock(
         request,
         CT_Shape,
         name="freeform_sp_",
         is_autoshape=True,
         is_textbox=False,
         has_custom_geometry=True,
     )
     freeform_ = Shape(freeform_sp_, None)
     property_mock(request, Shape, "is_placeholder", return_value=False)
     return autoshape_shape_, textbox_shape_, freeform_
    def it_can_change_its_text(self, text_frame_prop_, text_frame_):
        text_frame_prop_.return_value = text_frame_
        shape = Shape(None, None)

        shape.text = "føøbår"

        assert text_frame_.text == "føøbår"
示例#3
0
    def it_can_change_its_text(self, text_frame_prop_, text_frame_):
        text_frame_prop_.return_value = text_frame_
        shape = Shape(None, None)

        shape.text = "føøbår"

        assert text_frame_.text == "føøbår"
示例#4
0
 def iter_fixture(self, BaseShapeFactory_):
     spTree = element('p:spTree/(p:sp,p:sp)')
     sps = spTree.xpath('p:sp')
     shapes = _BaseShapes(spTree, None)
     expected_shapes = [Shape(None, None), Shape(None, None)]
     calls = [call(sps[0], shapes), call(sps[1], shapes)]
     BaseShapeFactory_.side_effect = iter(expected_shapes)
     return shapes, expected_shapes, BaseShapeFactory_, calls
示例#5
0
 def non_placeholder_shapes_(self, request):
     autoshape_sp_ = instance_mock(
         request, CT_Shape, name='autoshape_sp_', is_autoshape=True,
         is_textbox=False
     )
     autoshape_shape_ = Shape(autoshape_sp_, None)
     textbox_sp_ = instance_mock(
         request, CT_Shape, name='textbox_sp_', is_autoshape=False,
         is_textbox=True
     )
     textbox_shape_ = Shape(textbox_sp_, None)
     property_mock(request, Shape, 'is_placeholder', return_value=False)
     return autoshape_shape_, textbox_shape_
示例#6
0
 def it_calculates_its_effective_size_to_help_fit_text(self):
     sp_cxml = (
         "p:sp/(p:spPr/a:xfrm/(a:off{x=914400,y=914400},a:ext{cx=914400,c"
         "y=914400}),p:txBody/(a:bodyPr,a:p))"
     )
     text_frame = Shape(element(sp_cxml), None).text_frame
     assert text_frame._extents == (731520, 822960)
    def it_knows_what_text_it_contains(self, text_frame_prop_, text_frame_):
        text_frame_prop_.return_value = text_frame_
        text_frame_.text = "foobar"
        shape = Shape(None, None)

        text = shape.text

        assert text == "foobar"
示例#8
0
 def write_shape(self, shape: Shape) -> None:
     """Write attributes to table in given pptx.shapes.autoshape.Shape."""
     if not shape.has_table:
         print(
             f"Warning: Could not write table style. {shape} has no table.")
         return
     if self.position is not None:
         shape.left, shape.top = self.position.tuple()
     self.write_table(shape.table)
示例#9
0
 def autoshape_type_fixture_(self, shape, prst):
     sp = (
         an_sp().with_nsdecls().with_child(
             an_nvSpPr().with_child(
                 a_cNvSpPr())).with_child(
             an_spPr().with_child(
                 a_prstGeom().with_prst('chevron')))
     ).element
     shape = Shape(sp, None)
     return shape, MSO_SHAPE.CHEVRON
示例#10
0
 def it_raises_when_shape_type_called_on_unrecognized_shape(self):
     xml = (
         '<p:sp xmlns:p="http://schemas.openxmlformats.org/presentationml/'
         '2006/main" xmlns:a="http://schemas.openxmlformats.org/drawingml/'
         '2006/main"><p:nvSpPr><p:cNvPr id="9" name="Unknown Shape Type 8"'
         '/><p:cNvSpPr/><p:nvPr/></p:nvSpPr><p:spPr/></p:sp>')
     sp = parse_xml(xml)
     shape = Shape(sp, None)
     # verify -----------------------
     with pytest.raises(NotImplementedError):
         shape.shape_type
示例#11
0
def copyShape(shape, idx):
    # pylint: disable=protected-access
    sp = shape._sp
    new_sp = None
    # ---duplicate original freeform---
    new_sp = copy.deepcopy(sp)
    new_shape = Shape(new_sp, shape._parent)
    # ---create a unique id for it---
    new_sp.nvSpPr.cNvPr.id = 1000 + idx
    # ---insert it after original---
    sp.addnext(new_sp)
    return new_shape
示例#12
0
 def non_autoshape_shape_(self, request, sp_):
     sp_.is_autoshape = False
     return Shape(sp_, None)
示例#13
0
 def txBody_fixture(self, request):
     sp_cxml = 'p:sp'
     expected_cxml = 'p:txBody/(a:bodyPr,a:p)'
     shape = Shape(element(sp_cxml), None)
     expected_xml = xml(expected_cxml)
     return shape, expected_xml
示例#14
0
 def text_set_fixture(self, request):
     sp_cxml, new_value, expected_sp_cxml = request.param
     shape = Shape(element(sp_cxml), None)
     expected_xml = xml(expected_sp_cxml)
     return shape, new_value, expected_xml
示例#15
0
 def text_get_fixture(self, request):
     sp_cxml, expected_value = request.param
     shape = Shape(element(sp_cxml), None)
     return shape, expected_value
示例#16
0
 def text_frame_fixture(self, TextFrame_, text_frame_):
     sp = element('p:sp/p:txBody')
     txBody = sp[0]
     shape = Shape(sp, None)
     return shape, text_frame_, TextFrame_, txBody
示例#17
0
 def placeholder_shape_(self, request, sp_):
     placeholder_shape_ = Shape(sp_, None)
     property_mock(request, Shape, 'is_placeholder', return_value=True)
     return placeholder_shape_
示例#18
0
 def shape(self, request, sp_):
     return Shape(sp_, None)
示例#19
0
 def it_knows_it_has_a_text_frame(self):
     shape = Shape(None, None)
     assert shape.has_text_frame is True