예제 #1
0
class _CT_TableCellEdge(BaseOxmlElement):
    """
    ''<a:ln{}>'' custom element class
    """
    w = RequiredAttribute('w', ST_Coordinate)
    cap = RequiredAttribute('cap', ST_CapType)
    cmpd = RequiredAttribute('cmpd', ST_EdgeType)
    algn = RequiredAttribute('algn', ST_EdgeAlignment)

    _tag_seq = ('a:prstDash', 'a:headEnd', 'a:tailEnd')
    eg_fillProperties = ZeroOrOneChoice((
        Choice("a:noFill"),
        Choice("a:solidFill"),
        Choice("a:gradFill"),
        Choice("a:blipFill"),
        Choice("a:pattFill"),
        Choice("a:grpFill"),
    ),
                                        successors=_tag_seq)
    eg_JointProperties = ZeroOrOneChoice((
        Choice("a:bevel"),
        Choice("a:miter"),
        Choice("a:round"),
    ),
                                         successors=_tag_seq[1:])

    prstDash = ZeroOrOne('a:prstDash',
                         successors=('a:headEnd', 'a:bevel', 'a:miter',
                                     'a:round', 'a:tailEnd'))
    headEnd = ZeroOrOne('a:headEnd', successors=_tag_seq[2:])
    tailEnd = ZeroOrOne('a:tailEnd')
    del _tag_seq
예제 #2
0
class CT_PositiveSize2D(BaseOxmlElement):
    """
    Custom element class for <a:ext> element.
    """

    cx = RequiredAttribute("cx", ST_PositiveCoordinate)
    cy = RequiredAttribute("cy", ST_PositiveCoordinate)
예제 #3
0
class CT_GeomGuide(BaseOxmlElement):
    """
    ``<a:gd>`` custom element class, defining a "guide", corresponding to
    a yellow diamond-shaped handle on an autoshape.
    """
    name = RequiredAttribute('name', XsdString)
    fmla = RequiredAttribute('fmla', XsdString)
예제 #4
0
class CT_Point2D(BaseOxmlElement):
    """
    Custom element class for <a:off> element.
    """

    x = RequiredAttribute("x", ST_Coordinate)
    y = RequiredAttribute("y", ST_Coordinate)
예제 #5
0
class CT_Path2DArcTo(BaseOxmlElement):
    """

    """
    wR = RequiredAttribute('wR', ST_AdjCoordinate)
    hR = RequiredAttribute('hR', ST_AdjCoordinate)
    stAng = RequiredAttribute('stAng', ST_AdjAngle)
    swAng = RequiredAttribute('swAng', ST_AdjAngle)
예제 #6
0
class CT_NonVisualDrawingProps(BaseOxmlElement):
    """
    ``<p:cNvPr>`` custom element class.
    """
    _tag_seq = ('a:hlinkClick', 'a:hlinkHover', 'a:extLst')
    hlinkClick = ZeroOrOne('a:hlinkClick', successors=_tag_seq[1:])
    hlinkHover = ZeroOrOne('a:hlinkHover', successors=_tag_seq[2:])
    id = RequiredAttribute('id', ST_DrawingElementId)
    name = RequiredAttribute('name', XsdString)
    del _tag_seq
예제 #7
0
class CT_NonVisualDrawingProps(BaseOxmlElement):
    """
    ``<p:cNvPr>`` custom element class.
    """

    _tag_seq = ("a:hlinkClick", "a:hlinkHover", "a:extLst")
    hlinkClick = ZeroOrOne("a:hlinkClick", successors=_tag_seq[1:])
    hlinkHover = ZeroOrOne("a:hlinkHover", successors=_tag_seq[2:])
    id = RequiredAttribute("id", ST_DrawingElementId)
    name = RequiredAttribute("name", XsdString)
    del _tag_seq
예제 #8
0
class CT_NonVisualDrawingProps(BaseOxmlElement):
    """
    ``<p:cNvPr>`` custom element class.
    """

    _tag_seq = ("a:hlinkClick", "a:hlinkHover", "a:extLst")
    hlinkClick = ZeroOrOne("a:hlinkClick", successors=_tag_seq[1:])
    hlinkHover = ZeroOrOne("a:hlinkHover", successors=_tag_seq[2:])
    id = RequiredAttribute("id", ST_DrawingElementId)
    name = RequiredAttribute("name", XsdString)
    descr = OptionalAttribute("descr", XsdString, default="")
    hidden = OptionalAttribute("hidden", XsdBoolean, default=False )
    title = OptionalAttribute("title", XsdString, default="")

    del _tag_seq
예제 #9
0
class CT_PresetGeometry2D(BaseOxmlElement):
    """
    <a:prstGeom> custom element class
    """

    avLst = ZeroOrOne("a:avLst")
    prst = RequiredAttribute("prst", MSO_AUTO_SHAPE_TYPE)

    @property
    def gd_lst(self):
        """
        Sequence containing the ``gd`` element children of ``<a:avLst>``
        child element, empty if none are present.
        """
        avLst = self.avLst
        if avLst is None:
            return []
        return avLst.gd_lst

    def rewrite_guides(self, guides):
        """
        Remove any ``<a:gd>`` element children of ``<a:avLst>`` and replace
        them with ones having (name, val) in *guides*.
        """
        self._remove_avLst()
        avLst = self._add_avLst()
        for name, val in guides:
            gd = avLst._add_gd()
            gd.name = name
            gd.fmla = "val %d" % val
예제 #10
0
class CT_ExternalData(BaseOxmlElement):
    """
    `<c:externalData>` element, defining link to embedded Excel package part
    containing the chart data.
    """
    autoUpdate = ZeroOrOne('c:autoUpdate')
    rId = RequiredAttribute('r:id', XsdString)
예제 #11
0
class CT_LineTailEnd(BaseOxmlElement):
    """
    ''<a:tailEnd>''
    """
    type = RequiredAttribute('type', ST_LineEndType)
    w = OptionalAttribute('w', ST_ReletiveSize)
    len = OptionalAttribute('len', ST_ReletiveSize)
예제 #12
0
class CT_NumFmt(BaseOxmlElement):
    """
    ``<c:numFmt>`` element specifying the formatting for number labels on a
    tick mark or data point.
    """
    formatCode = RequiredAttribute('formatCode', XsdString)
    sourceLinked = OptionalAttribute('sourceLinked', XsdBoolean)
예제 #13
0
class CT_TextFont(BaseOxmlElement):
    """
    Custom element class for <a:latin>, <a:ea>, <a:cs>, and <a:sym> child
    elements of CT_TextCharacterProperties, e.g. <a:rPr>.
    """

    typeface = RequiredAttribute("typeface", ST_TextTypeface)
예제 #14
0
class CT_SlideLayoutIdListEntry(BaseOxmlElement):
    """
    ``<p:sldLayoutId>`` element, child of ``<p:sldLayoutIdLst>`` containing
    a reference to a slide layout.
    """

    rId = RequiredAttribute("r:id", XsdString)
예제 #15
0
class CT_DLblPos(BaseOxmlElement):
    """
    ``<c:dLblPos>`` element specifying the positioning of a data label with
    respect to its data point.
    """

    val = RequiredAttribute("val", XL_DATA_LABEL_POSITION)
예제 #16
0
class CT_TextSpacingPercent(BaseOxmlElement):
    """
    <a:spcPct> element, specifying spacing in thousandths of a percent in its
    `val` attribute.
    """

    val = RequiredAttribute("val", ST_TextSpacingPercentOrPercentString)
예제 #17
0
class CT_TextSpacingPoint(BaseOxmlElement):
    """
    <a:spcPts> element, specifying spacing in centipoints in its `val`
    attribute.
    """

    val = RequiredAttribute("val", ST_TextSpacingPoint)
예제 #18
0
class CT_GradientStop(BaseOxmlElement):
    """`a:gs` custom element class."""

    eg_colorChoice = ZeroOrOneChoice(
        (Choice('a:scrgbClr'), Choice('a:srgbClr'), Choice('a:hslClr'),
         Choice('a:sysClr'), Choice('a:schemeClr'), Choice('a:prstClr')),
        successors=())
    pos = RequiredAttribute('pos', ST_PositiveFixedPercentage)
예제 #19
0
class ThemeDefinition(CT_OfficeStyleSheet):
    name = RequiredAttribute("name", XsdString)
    themeElements = OneAndOnlyOne("a:themeElements")

    @classmethod
    def new(cls, xml):
        """Return theme definition"""
        t = oxml.parse_xml(xml)
        return t
예제 #20
0
class CT_Parent(BaseOxmlElement):
    """
    ``<p:parent>`` element, an invented element for use in testing.
    """
    eg_zooChoice = ZeroOrOneChoice(
        (Choice('p:choice'), Choice('p:choice2')),
        successors=('p:oomChild', 'p:oooChild')
    )
    oomChild = OneOrMore('p:oomChild', successors=(
        'p:oooChild', 'p:zomChild', 'p:zooChild'
    ))
    oooChild = OneAndOnlyOne('p:oooChild')
    zomChild = ZeroOrMore('p:zomChild', successors=('p:zooChild',))
    zooChild = ZeroOrOne('p:zooChild', successors=())
    optAttr = OptionalAttribute('p:optAttr', ST_IntegerType)
    reqAttr = RequiredAttribute('reqAttr', ST_IntegerType)
예제 #21
0
class CT_TableRow(BaseOxmlElement):
    """
    ``<a:tr>`` custom element class
    """
    tc = ZeroOrMore('a:tc', successors=('a:extLst', ))
    h = RequiredAttribute('h', ST_Coordinate)

    def add_tc(self):
        """
        Return a reference to a newly added minimal valid ``<a:tc>`` child
        element.
        """
        return self._add_tc()

    def _new_tc(self):
        return CT_TableCell.new()
예제 #22
0
class CT_TableRow(BaseOxmlElement):
    """
    ``<a:tr>`` custom element class
    """
    tc = ZeroOrMore('a:tc', successors=('a:extLst', ))
    h = RequiredAttribute('h', ST_Coordinate)

    def add_tc(self):
        """
        Return a reference to a newly added minimal valid ``<a:tc>`` child
        element.
        """
        return self._add_tc()

    @property
    def row_idx(self):
        """Offset of this row in its table."""
        return self.getparent().tr_lst.index(self)

    def _new_tc(self):
        return CT_TableCell.new()
예제 #23
0
class CT_Double(BaseOxmlElement):
    """
    Used for floating point values.
    """
    val = RequiredAttribute('val', XsdDouble)
예제 #24
0
class CT_UnsignedInt(BaseOxmlElement):
    """
    ``<c:idx>`` element and others.
    """
    val = RequiredAttribute('val', XsdUnsignedInt)
예제 #25
0
class CT_GraphicalObjectData(BaseShapeElement):
    """
    ``<p:graphicData>`` element, the direct container for a table, a chart,
    or another graphical object.
    """

    chart = ZeroOrOne("c:chart")
    tbl = ZeroOrOne("a:tbl")
    uri = RequiredAttribute("uri", XsdString)

    @property
    def blob_rId(self):
        """Optional "r:id" attribute value of `<p:oleObj>` descendent element.

        This value is `None` when this `p:graphicData` element does not enclose an OLE
        object. This value could also be `None` if an enclosed OLE object does not
        specify this attribute (it is specified optional in the schema) but so far, all
        OLE objects we've encountered specify this value.
        """
        return None if self._oleObj is None else self._oleObj.rId

    @property
    def is_embedded_ole_obj(self):
        """Optional boolean indicating an embedded OLE object.

        Returns `None` when this `p:graphicData` element does not enclose an OLE object.
        `True` indicates an embedded OLE object and `False` indicates a linked OLE
        object.
        """
        return None if self._oleObj is None else self._oleObj.is_embedded

    @property
    def progId(self):
        """Optional str value of "progId" attribute of `<p:oleObj>` descendent.

        This value identifies the "type" of the embedded object in terms of the
        application used to open it.

        This value is `None` when this `p:graphicData` element does not enclose an OLE
        object. This could also be `None` if an enclosed OLE object does not specify
        this attribute (it is specified optional in the schema) but so far, all OLE
        objects we've encountered specify this value.
        """
        return None if self._oleObj is None else self._oleObj.progId

    @property
    def showAsIcon(self):
        """Optional value of "showAsIcon" attribute value of `p:oleObj` descendent.

        This value is `None` when this `p:graphicData` element does not enclose an OLE
        object. It is False when the `showAsIcon` attribute is omitted on the `p:oleObj`
        element.
        """
        return None if self._oleObj is None else self._oleObj.showAsIcon

    @property
    def _oleObj(self):
        """Optional `<p:oleObj>` element contained in this `p:graphicData' element.

        Returns `None` when this graphic-data element does not enclose an OLE object.
        Note that this returns the last `p:oleObj` element found. There can be more
        than one `p:oleObj` element because an `<mc.AlternateContent>` element may
        appear as the child of `p:graphicData` and that alternate-content subtree can
        contain multiple compatibility choices. The last one should suit best for
        reading purposes because it contains the lowest common denominator.
        """
        oleObjs = self.xpath(".//p:oleObj")
        return oleObjs[-1] if oleObjs else None
예제 #26
0
class CT_TableCol(BaseOxmlElement):
    """
    ``<a:gridCol>`` custom element class
    """

    w = RequiredAttribute("w", ST_Coordinate)
예제 #27
0
class PresetShape(Geometry2D):
    """`drawml:PresetShape` element class."""

    name = RequiredAttribute("name", XsdString)
예제 #28
0
class CT_Style(BaseOxmlElement):
    """
    ``<c:style>`` element; defines the chart style.
    """

    val = RequiredAttribute("val", ST_Style)
예제 #29
0
class CT_Chart(BaseOxmlElement):
    """`c:chart` custom element class."""

    _tag_seq = (
        "c:title",
        "c:autoTitleDeleted",
        "c:pivotFmts",
        "c:view3D",
        "c:floor",
        "c:sideWall",
        "c:backWall",
        "c:plotArea",
        "c:legend",
        "c:plotVisOnly",
        "c:dispBlanksAs",
        "c:showDLblsOverMax",
        "c:extLst",
    )
    title = ZeroOrOne("c:title", successors=_tag_seq[1:])
    autoTitleDeleted = ZeroOrOne("c:autoTitleDeleted", successors=_tag_seq[2:])
    plotArea = OneAndOnlyOne("c:plotArea")
    legend = ZeroOrOne("c:legend", successors=_tag_seq[9:])
    rId = RequiredAttribute("r:id", XsdString)

    _chart_tmpl = '<c:chart %s %s r:id="%%s"/>' % (nsdecls("c"), nsdecls("r"))

    @property
    def has_legend(self):
        """
        True if this chart has a legend defined, False otherwise.
        """
        legend = self.legend
        if legend is None:
            return False
        return True

    @has_legend.setter
    def has_legend(self, bool_value):
        """
        Add, remove, or leave alone the ``<c:legend>`` child element depending
        on current state and *bool_value*. If *bool_value* is |True| and no
        ``<c:legend>`` element is present, a new default element is added.
        When |False|, any existing legend element is removed.
        """
        if bool(bool_value) is False:
            self._remove_legend()
        else:
            if self.legend is None:
                self._add_legend()

    @staticmethod
    def new_chart(rId):
        """
        Return a new ``<c:chart>`` element
        """
        xml = CT_Chart._chart_tmpl % (rId)
        chart = parse_xml(xml)
        return chart

    def _new_title(self):
        return CT_Title.new_title()
예제 #30
0
class CT_AdjPoint2D(BaseOxmlElement):
    """`a:pt` custom element class."""

    x = RequiredAttribute("x", ST_Coordinate)
    y = RequiredAttribute("y", ST_Coordinate)