Example #1
0
    def it_can_add_text(self, add_text_fixture, Text_):
        r, text_str, expected_xml = add_text_fixture
        run = Run(r, None)

        _text = run.add_text(text_str)

        assert run._r.xml == expected_xml
        assert _text is Text_.return_value
Example #2
0
 def add_run(self, text=None, style=None):
     """
     Append a run to this paragraph containing *text* and having character
     style identified by style ID *style*. *text* can contain tab
     (``\\t``) characters, which are converted to the appropriate XML form
     for a tab. *text* can also include newline (``\\n``) or carriage
     return (``\\r``) characters, each of which is converted to a line
     break.
     """
     r = self._p.add_r()
     run = Run(r, self)
     if text:
         run.text = text
     if style:
         run.style = style
     return run
Example #3
0
 def add_picture_fixture(self, part_prop_, document_part_, InlineShape_,
                         picture_):
     run = Run(element('w:r/wp:x'), None)
     image = 'foobar.png'
     width, height, inline = 1111, 2222, element('wp:inline{id=42}')
     expected_xml = xml('w:r/(wp:x,w:drawing/wp:inline{id=42})')
     document_part_.new_pic_inline.return_value = inline
     InlineShape_.return_value = picture_
     return (run, image, width, height, inline, expected_xml, InlineShape_,
             picture_)
Example #4
0
 def paragraph_contents(self):
     for child in self._element:
         ct = ParagraphContentType(child.tag)  # local_part
         co = None
         if ct == "run":
             co = Run(child, self)
         elif ct == "hyperlink":
             co = Hyperlink(child, self)
         else:
             co = child
         yield (ct, co)
Example #5
0
 def underline_get_fixture(self, request):
     r_cxml, expected_underline = request.param
     run = Run(element(r_cxml), None)
     return run, expected_underline
Example #6
0
 def text_set_fixture(self, request):
     new_text, expected_cxml = request.param
     initial_r_cxml = 'w:r/w:t"should get deleted"'
     run = Run(element(initial_r_cxml), None)
     expected_xml = xml(expected_cxml)
     return run, new_text, expected_xml
Example #7
0
 def text_get_fixture(self, request):
     r_cxml, expected_text = request.param
     run = Run(element(r_cxml), None)
     return run, expected_text
Example #8
0
 def style_set_fixture(self, request, part_prop_):
     r_cxml, value, style_id, expected_cxml = request.param
     run = Run(element(r_cxml), None)
     part_prop_.return_value.get_style_id.return_value = style_id
     expected_xml = xml(expected_cxml)
     return run, value, expected_xml
Example #9
0
 def style_get_fixture(self, part_prop_):
     style_id = 'Barfoo'
     r_cxml = 'w:r/w:rPr/w:rStyle{w:val=%s}' % style_id
     run = Run(element(r_cxml), None)
     style_ = part_prop_.return_value.get_style.return_value
     return run, style_id, style_
Example #10
0
 def bool_prop_set_fixture(self, request):
     initial_r_cxml, bool_prop_name, value, expected_cxml = request.param
     run = Run(element(initial_r_cxml), None)
     expected_xml = xml(expected_cxml)
     return run, bool_prop_name, value, expected_xml
Example #11
0
 def bool_prop_get_fixture(self, request):
     r_cxml, bool_prop_name, expected_value = request.param
     run = Run(element(r_cxml), None)
     return run, bool_prop_name, expected_value
Example #12
0
 def add_tab_fixture(self, request):
     r_cxml, expected_cxml = request.param
     run = Run(element(r_cxml), None)
     expected_xml = xml(expected_cxml)
     return run, expected_xml
Example #13
0
 def add_break_fixture(self, request):
     break_type, expected_cxml = request.param
     run = Run(element('w:r'), None)
     expected_xml = xml(expected_cxml)
     return run, break_type, expected_xml
Example #14
0
 def runs(self):
     return [Run(r, self) for r in self._h.r_lst]
Example #15
0
 def runs(self):
     """
     Sequence of |Run| instances corresponding to the <w:r> elements in
     this paragraph.
     """
     return [Run(r, self) for r in self._p.r_lst]
Example #16
0
 def underline_set_fixture(self, request):
     initial_r_cxml, new_underline, expected_cxml = request.param
     run = Run(element(initial_r_cxml), None)
     expected_xml = xml(expected_cxml)
     return run, new_underline, expected_xml
Example #17
0
 def underline_raise_fixture(self, request):
     invalid_underline_setting = request.param
     run = Run(element('w:r/w:rPr'), None)
     return run, invalid_underline_setting
Example #18
0
 def clear_fixture(self, request):
     initial_r_cxml, expected_cxml = request.param
     run = Run(element(initial_r_cxml), None)
     expected_xml = xml(expected_cxml)
     return run, expected_xml
Example #19
0
 def _makerun(self, elem):
     return Run(elem, self._parent._element)
Example #20
0
 def font_fixture(self, Font_, font_):
     run = Run(element('w:r'), None)
     return run, Font_, font_