Beispiel #1
0
 def add_paragraph(self):
     """
     Return new |_Paragraph| instance appended to the sequence of
     paragraphs contained in this text frame.
     """
     # <a:p> elements are last in txBody, so can simply append new one
     p = _Element('a:p', namespaces('a'))
     self.__txBody.append(p)
     return _Paragraph(p)
Beispiel #2
0
 def add_paragraph(self):
     """
     Return new |_Paragraph| instance appended to the sequence of
     paragraphs contained in this text frame.
     """
     # <a:p> elements are last in txBody, so can simply append new one
     p = _Element("a:p", namespaces("a"))
     self.__txBody.append(p)
     return _Paragraph(p)
 def __minimal_element(self):
     """
     Return element containing the minimal XML for a slide, based on what
     is required by the XMLSchema.
     """
     sld = _Element('p:sld', _nsmap)
     
   
     return 
Beispiel #4
0
 def font(self):
     """
     |_Font| object containing run-level character properties for the text
     in this run. Character properties can and perhaps most often are
     inherited from parent objects such as the paragraph and slide layout
     the run is contained in. Only those specifically assigned at the run
     level are contained in the |_Font| object.
     """
     if not hasattr(self.__r, 'rPr'):
         self.__r.insert(0, _Element('a:rPr', namespaces('a')))
     return _Font(self.__r.rPr)
Beispiel #5
0
 def add_run(self):
     """Return a new run appended to the runs in this paragraph."""
     r = _Element('a:r', namespaces('a'))
     _SubElement(r, 'a:t')
     # work out where to insert it, ahead of a:endParaRPr if there is one
     endParaRPr = _child(self.__p, 'a:endParaRPr')
     if endParaRPr is not None:
         endParaRPr.addprevious(r)
     else:
         self.__p.append(r)
     return _Run(r)
Beispiel #6
0
 def add_run(self):
     """Return a new run appended to the runs in this paragraph."""
     r = _Element("a:r", namespaces("a"))
     _SubElement(r, "a:t")
     # work out where to insert it, ahead of a:endParaRPr if there is one
     endParaRPr = _child(self.__p, "a:endParaRPr")
     if endParaRPr is not None:
         endParaRPr.addprevious(r)
     else:
         self.__p.append(r)
     return _Run(r)
Beispiel #7
0
 def font(self):
     """
     |_Font| object containing run-level character properties for the text
     in this run. Character properties can and perhaps most often are
     inherited from parent objects such as the paragraph and slide layout
     the run is contained in. Only those specifically assigned at the run
     level are contained in the |_Font| object.
     """
     if not hasattr(self.__r, "rPr"):
         self.__r.insert(0, _Element("a:rPr", namespaces("a")))
     return _Font(self.__r.rPr)
Beispiel #8
0
 def add_run(self):
     """Return a new run appended to the runs in this paragraph."""
     r = _Element('a:r', _nsmap)
     _SubElement(r, 'a:t')
     # work out where to insert it, ahead of a:endParaRPr if there is one
     endParaRPr = _child(self.__p, 'a:endParaRPr')
     if endParaRPr is not None:
         endParaRPr.addprevious(r)
     else:
         self.__p.append(r)
     return _Run(r)
Beispiel #9
0
 def _set_level(self, level):
     """
     Set indentation level of this paragraph to *level*, an integer value
     between 0 and 8 inclusive.
     """
     if not isinstance(level, int) or level < 0 or level > 8:
         msg = "paragraph level must be integer between 0 and 8 inclusive"
         raise ValueError(msg)
     if not hasattr(self.__p, 'pPr'):
         pPr = _Element('a:pPr', namespaces('a'))
         self.__p.insert(0, pPr)
     self.__p.pPr.set('lvl', str(level))
Beispiel #10
0
 def _set_level(self, level):
     """
     Set indentation level of this paragraph to *level*, an integer value
     between 0 and 8 inclusive.
     """
     if not isinstance(level, int) or level < 0 or level > 8:
         msg = "paragraph level must be integer between 0 and 8 inclusive"
         raise ValueError(msg)
     if not hasattr(self.__p, "pPr"):
         pPr = _Element("a:pPr", namespaces("a"))
         self.__p.insert(0, pPr)
     self.__p.pPr.set("lvl", str(level))
Beispiel #11
0
 def __rewrite_sldIdLst(self):
     """
     Rewrite the ``<p:sldIdLst>`` element in ``<p:presentation>`` to
     reflect current ordering of slide relationships and possible
     renumbering of ``rId`` values.
     """
     sldIdLst = _child(self._element, 'p:sldIdLst', _nsmap)
     if sldIdLst is None:
         sldIdLst = self.__add_sldIdLst()
     sldIdLst.clear()
     sld_rels = self._relationships.rels_of_reltype(RT_SLIDE)
     for idx, rel in enumerate(sld_rels):
         sldId = _Element('p:sldId', _nsmap)
         sldIdLst.append(sldId)
         sldId.set('id', str(256 + idx))
         sldId.set(qn('r:id'), rel._rId)
Beispiel #12
0
 def __minimal_element(self):
     """
     Return element containing the minimal XML for a slide, based on what
     is required by the XMLSchema.
     """
     sld = _Element('p:sld', _nsmap)
     _SubElement(sld, 'p:cSld', _nsmap)
     _SubElement(sld.cSld, 'p:spTree', _nsmap)
     _SubElement(sld.cSld.spTree, 'p:nvGrpSpPr', _nsmap)
     _SubElement(sld.cSld.spTree.nvGrpSpPr, 'p:cNvPr', _nsmap)
     _SubElement(sld.cSld.spTree.nvGrpSpPr, 'p:cNvGrpSpPr', _nsmap)
     _SubElement(sld.cSld.spTree.nvGrpSpPr, 'p:nvPr', _nsmap)
     _SubElement(sld.cSld.spTree, 'p:grpSpPr', _nsmap)
     sld.cSld.spTree.nvGrpSpPr.cNvPr.set('id', '1')
     sld.cSld.spTree.nvGrpSpPr.cNvPr.set('name', '')
     return sld
Beispiel #13
0
 def __rewrite_sldIdLst(self):
     """
     Rewrite the ``<p:sldIdLst>`` element in ``<p:presentation>`` to
     reflect current ordering of slide relationships and possible
     renumbering of ``rId`` values.
     """
     sldIdLst = _child(self._element, 'p:sldIdLst', _nsmap)
     if sldIdLst is None:
         sldIdLst = self.__add_sldIdLst()
     sldIdLst.clear()
     sld_rels = self._relationships.rels_of_reltype(RT_SLIDE)
     for idx, rel in enumerate(sld_rels):
         sldId = _Element('p:sldId', _nsmap)
         sldIdLst.append(sldId)
         sldId.set('id', str(256+idx))
         sldId.set(qn('r:id'), rel._rId)
Beispiel #14
0
 def __minimal_element(self):
     """
     Return element containing the minimal XML for a slide, based on what
     is required by the XMLSchema.
     """
     sld = _Element('p:sld', _nsmap)
     _SubElement(sld, 'p:cSld', _nsmap)
     _SubElement(sld.cSld, 'p:spTree', _nsmap)
     _SubElement(sld.cSld.spTree, 'p:nvGrpSpPr', _nsmap)
     _SubElement(sld.cSld.spTree.nvGrpSpPr, 'p:cNvPr', _nsmap)
     _SubElement(sld.cSld.spTree.nvGrpSpPr, 'p:cNvGrpSpPr', _nsmap)
     _SubElement(sld.cSld.spTree.nvGrpSpPr, 'p:nvPr', _nsmap)
     _SubElement(sld.cSld.spTree, 'p:grpSpPr', _nsmap)
     sld.cSld.spTree.nvGrpSpPr.cNvPr.set('id', '1')
     sld.cSld.spTree.nvGrpSpPr.cNvPr.set('name', '')
     return sld
Beispiel #15
0
 def __add_sldIdLst(self):
     """
     Add a <p:sldIdLst> element to <p:presentation> in the right sequence
     among its siblings.
     """
     sldIdLst = _child(self._element, 'p:sldIdLst', _nsmap)
     assert sldIdLst is None, '__add_sldIdLst() called where '\
                              '<p:sldIdLst> already exists'
     sldIdLst = _Element('p:sldIdLst', _nsmap)
     # insert new sldIdLst element in right sequence
     sldSz = _child(self._element, 'p:sldSz', _nsmap)
     if sldSz is not None:
         sldSz.addprevious(sldIdLst)
     else:
         notesSz = _child(self._element, 'p:notesSz', _nsmap)
         notesSz.addprevious(sldIdLst)
     return sldIdLst
Beispiel #16
0
 def __add_sldIdLst(self):
     """
     Add a <p:sldIdLst> element to <p:presentation> in the right sequence
     among its siblings.
     """
     sldIdLst = _child(self._element, 'p:sldIdLst', _nsmap)
     assert sldIdLst is None, '__add_sldIdLst() called where '\
                              '<p:sldIdLst> already exists'
     sldIdLst = _Element('p:sldIdLst', _nsmap)
     # insert new sldIdLst element in right sequence
     sldSz = _child(self._element, 'p:sldSz', _nsmap)
     if sldSz is not None:
         sldSz.addprevious(sldIdLst)
     else:
         notesSz = _child(self._element, 'p:notesSz', _nsmap)
         notesSz.addprevious(sldIdLst)
     return sldIdLst
Beispiel #17
0
 def font(self):
     """
     |_Font| object containing default character properties for the runs in
     this paragraph. These character properties override default properties
     inherited from parent objects such as the text frame the paragraph is
     contained in and they may be overridden by character properties set at
     the run level.
     """
     # A _Font instance is created on first access if it doesn't exist.
     # This can cause "litter" <a:pPr> and <a:defRPr> elements to be
     # included in the XML if the _Font element is referred to but not
     # populated with values.
     if not hasattr(self.__p, 'pPr'):
         pPr = _Element('a:pPr', namespaces('a'))
         self.__p.insert(0, pPr)
     if not hasattr(self.__p.pPr, 'defRPr'):
         _SubElement(self.__p.pPr, 'a:defRPr')
     return _Font(self.__p.pPr.defRPr)
Beispiel #18
0
 def font(self):
     """
     |_Font| object containing default character properties for the runs in
     this paragraph. These character properties override default properties
     inherited from parent objects such as the text frame the paragraph is
     contained in and they may be overridden by character properties set at
     the run level.
     """
     # A _Font instance is created on first access if it doesn't exist.
     # This can cause "litter" <a:pPr> and <a:defRPr> elements to be
     # included in the XML if the _Font element is referred to but not
     # populated with values.
     if not hasattr(self.__p, "pPr"):
         pPr = _Element("a:pPr", namespaces("a"))
         self.__p.insert(0, pPr)
     if not hasattr(self.__p.pPr, "defRPr"):
         _SubElement(self.__p.pPr, "a:defRPr")
     return _Font(self.__p.pPr.defRPr)