from __future__ import absolute_import
# Copyright (c) 2010-2015 openpyxl

from openpyxl.styles.colors import Color, BLACK, WHITE

from openpyxl.utils.units import (
    pixels_to_EMU,
    EMU_to_pixels,
    short_color,
)

from openpyxl.compat import deprecated
from openpyxl.xml.functions import Element, SubElement, tostring
from openpyxl.xml.constants import (
    DRAWING_NS,
    SHEET_DRAWING_NS,
    CHART_NS,
    CHART_DRAWING_NS,
    PKG_REL_NS
)
from openpyxl.compat.strings import safe_string


class Shape(object):
    """ a drawing inside a chart
        coordiantes are specified by the user in the axis units
    """

    MARGIN_LEFT = 6 + 13 + 1
    MARGIN_BOTTOM = 17 + 11

    FONT_WIDTH = 7
    FONT_HEIGHT = 8

    ROUND_RECT = 'roundRect'
    RECT = 'rect'

    # other shapes to define :
    '''
    "line"
    "lineInv"
    "triangle"
    "rtTriangle"
    "diamond"
    "parallelogram"
    "trapezoid"
    "nonIsoscelesTrapezoid"
    "pentagon"
    "hexagon"
    "heptagon"
    "octagon"
    "decagon"
    "dodecagon"
    "star4"
    "star5"
    "star6"
    "star7"
    "star8"
    "star10"
    "star12"
    "star16"
    "star24"
    "star32"
    "roundRect"
    "round1Rect"
    "round2SameRect"
    "round2DiagRect"
    "snipRoundRect"
    "snip1Rect"
    "snip2SameRect"
    "snip2DiagRect"
    "plaque"
    "ellipse"
    "teardrop"
    "homePlate"
    "chevron"
    "pieWedge"
    "pie"
    "blockArc"
    "donut"
    "noSmoking"
    "rightArrow"
    "leftArrow"
    "upArrow"
    "downArrow"
    "stripedRightArrow"
    "notchedRightArrow"
    "bentUpArrow"
    "leftRightArrow"
    "upDownArrow"
    "leftUpArrow"
    "leftRightUpArrow"
    "quadArrow"
    "leftArrowCallout"
    "rightArrowCallout"
    "upArrowCallout"
    "downArrowCallout"
    "leftRightArrowCallout"
    "upDownArrowCallout"
    "quadArrowCallout"
    "bentArrow"
    "uturnArrow"
    "circularArrow"
    "leftCircularArrow"
    "leftRightCircularArrow"
    "curvedRightArrow"
    "curvedLeftArrow"
    "curvedUpArrow"
    "curvedDownArrow"
    "swooshArrow"
    "cube"
    "can"
    "lightningBolt"
    "heart"
    "sun"
    "moon"
    "smileyFace"
    "irregularSeal1"
    "irregularSeal2"
    "foldedCorner"
    "bevel"
    "frame"
    "halfFrame"
    "corner"
    "diagStripe"
    "chord"
    "arc"
    "leftBracket"
    "rightBracket"
    "leftBrace"
    "rightBrace"
    "bracketPair"
    "bracePair"
    "straightConnector1"
    "bentConnector2"
    "bentConnector3"
    "bentConnector4"
    "bentConnector5"
    "curvedConnector2"
    "curvedConnector3"
    "curvedConnector4"
    "curvedConnector5"
    "callout1"
    "callout2"
    "callout3"
    "accentCallout1"
    "accentCallout2"
    "accentCallout3"
    "borderCallout1"
    "borderCallout2"
    "borderCallout3"
    "accentBorderCallout1"
    "accentBorderCallout2"
    "accentBorderCallout3"
    "wedgeRectCallout"
    "wedgeRoundRectCallout"
    "wedgeEllipseCallout"
    "cloudCallout"
    "cloud"
    "ribbon"
    "ribbon2"
    "ellipseRibbon"
    "ellipseRibbon2"
    "leftRightRibbon"
    "verticalScroll"
    "horizontalScroll"
    "wave"
    "doubleWave"
    "plus"
    "flowChartProcess"
    "flowChartDecision"
    "flowChartInputOutput"
    "flowChartPredefinedProcess"
    "flowChartInternalStorage"
    "flowChartDocument"
    "flowChartMultidocument"
    "flowChartTerminator"
    "flowChartPreparation"
    "flowChartManualInput"
    "flowChartManualOperation"
    "flowChartConnector"
    "flowChartPunchedCard"
    "flowChartPunchedTape"
    "flowChartSummingJunction"
    "flowChartOr"
    "flowChartCollate"
    "flowChartSort"
    "flowChartExtract"
    "flowChartMerge"
    "flowChartOfflineStorage"
    "flowChartOnlineStorage"
    "flowChartMagneticTape"
    "flowChartMagneticDisk"
    "flowChartMagneticDrum"
    "flowChartDisplay"
    "flowChartDelay"
    "flowChartAlternateProcess"
    "flowChartOffpageConnector"
    "actionButtonBlank"
    "actionButtonHome"
    "actionButtonHelp"
    "actionButtonInformation"
    "actionButtonForwardNext"
    "actionButtonBackPrevious"
    "actionButtonEnd"
    "actionButtonBeginning"
    "actionButtonReturn"
    "actionButtonDocument"
    "actionButtonSound"
    "actionButtonMovie"
    "gear6"
    "gear9"
    "funnel"
    "mathPlus"
    "mathMinus"
    "mathMultiply"
    "mathDivide"
    "mathEqual"
    "mathNotEqual"
    "cornerTabs"
    "squareTabs"
    "plaqueTabs"
    "chartX"
    "chartStar"
    "chartPlus"
    '''

    @deprecated("Chart Drawings need a complete rewrite")
    def __init__(self,
                 chart,
                 coordinates=((0, 0), (1, 1)),
                 text=None,
                 scheme="accent1"):
        self.chart = chart
        self.coordinates = coordinates  # in axis units
        self.text = text
        self.scheme = scheme
        self.style = Shape.RECT
        self.border_width = 0
        self.border_color = BLACK  # "F3B3C5"
        self.color = WHITE
        self.text_color = BLACK

    @property
    def border_color(self):
        return self._border_color

    @border_color.setter
    def border_color(self, color):
        self._border_color = short_color(color)

    @property
    def color(self):
        return self._color

    @color.setter
    def color(self, color):
        self._color = short_color(color)

    @property
    def text_color(self):
        return self._text_color

    @text_color.setter
    def text_color(self, color):
        self._text_color = short_color(color)

    @property
    def border_width(self):
        return self._border_width

    @border_width.setter
    def border_width(self, w):
        self._border_width = w

    @property
    def coordinates(self):
        """Return coordindates in axis units"""
        return self._coordinates

    @coordinates.setter
    def coordinates(self, coords):
        """ set shape coordinates in percentages (left, top, right, bottom)
        """
        # this needs refactoring to reflect changes in charts
        self.axis_coordinates = coords
        (x1, y1), (x2, y2) = coords # bottom left, top right
        drawing_width = pixels_to_EMU(self.chart.drawing.width)
        drawing_height = pixels_to_EMU(self.chart.drawing.height)
        plot_width = drawing_width * self.chart.width
        plot_height = drawing_height * self.chart.height

        margin_left = self.chart._get_margin_left() * drawing_width
        xunit = plot_width / self.chart.get_x_units()

        margin_top = self.chart._get_margin_top() * drawing_height
        yunit = self.chart.get_y_units()

        x_start = (margin_left + (float(x1) * xunit)) / drawing_width
        y_start = ((margin_top
                    + plot_height
                    - (float(y1) * yunit))
                    / drawing_height)

        x_end = (margin_left + (float(x2) * xunit)) / drawing_width
        y_end = ((margin_top
                  + plot_height
                  - (float(y2) * yunit))
                  / drawing_height)

        # allow user to specify y's in whatever order
        # excel expect y_end to be lower
        if y_end < y_start:
            y_end, y_start = y_start, y_end

        self._coordinates = (
            self._norm_pct(x_start), self._norm_pct(y_start),
            self._norm_pct(x_end), self._norm_pct(y_end)
        )

    @staticmethod
    def _norm_pct(pct):
        """ force shapes to appear by truncating too large sizes """
        if pct > 1:
            return 1
        elif pct < 0:
            return 0
        return pct


class ShapeWriter(object):
    """ one file per shape """

    def __init__(self, shapes):

        self._shapes = shapes

    def write(self, shape_id):

        root = Element('{%s}userShapes' % CHART_NS)

        for shape in self._shapes:
            anchor = SubElement(root, '{%s}relSizeAnchor' % CHART_DRAWING_NS)

            xstart, ystart, xend, yend = shape.coordinates

            _from = SubElement(anchor, '{%s}from' % CHART_DRAWING_NS)
            SubElement(_from, '{%s}x' % CHART_DRAWING_NS).text = str(xstart)
            SubElement(_from, '{%s}y' % CHART_DRAWING_NS).text = str(ystart)

            _to = SubElement(anchor, '{%s}to' % CHART_DRAWING_NS)
            SubElement(_to, '{%s}x' % CHART_DRAWING_NS).text = str(xend)
            SubElement(_to, '{%s}y' % CHART_DRAWING_NS).text = str(yend)

            sp = SubElement(anchor, '{%s}sp' % CHART_DRAWING_NS, {'macro':'', 'textlink':''})
            nvspr = SubElement(sp, '{%s}nvSpPr' % CHART_DRAWING_NS)
            SubElement(nvspr, '{%s}cNvPr' % CHART_DRAWING_NS, {'id':str(shape_id), 'name':'shape %s' % shape_id})
            SubElement(nvspr, '{%s}cNvSpPr' % CHART_DRAWING_NS)

            sppr = SubElement(sp, '{%s}spPr' % CHART_DRAWING_NS)
            frm = SubElement(sppr, '{%s}xfrm' % DRAWING_NS,)
            # no transformation
            SubElement(frm, '{%s}off' % DRAWING_NS, {'x':'0', 'y':'0'})
            SubElement(frm, '{%s}ext' % DRAWING_NS, {'cx':'0', 'cy':'0'})

            prstgeom = SubElement(sppr, '{%s}prstGeom' % DRAWING_NS, {'prst':str(shape.style)})
            SubElement(prstgeom, '{%s}avLst' % DRAWING_NS)

            fill = SubElement(sppr, '{%s}solidFill' % DRAWING_NS, )
            SubElement(fill, '{%s}srgbClr' % DRAWING_NS, {'val':shape.color})

            border = SubElement(sppr, '{%s}ln' % DRAWING_NS, {'w':str(shape._border_width)})
            sf = SubElement(border, '{%s}solidFill' % DRAWING_NS)
            SubElement(sf, '{%s}srgbClr' % DRAWING_NS, {'val':shape.border_color})

            self._write_style(sp)
            self._write_text(sp, shape)

            shape_id += 1

        return tostring(root)

    def _write_text(self, node, shape):
        """ write text in the shape """

        tx_body = SubElement(node, '{%s}txBody' % CHART_DRAWING_NS)
        SubElement(tx_body, '{%s}bodyPr' % DRAWING_NS, {'vertOverflow':'clip'})
        SubElement(tx_body, '{%s}lstStyle' % DRAWING_NS)
        p = SubElement(tx_body, '{%s}p' % DRAWING_NS)
        if shape.text:
            r = SubElement(p, '{%s}r' % DRAWING_NS)
            rpr = SubElement(r, '{%s}rPr' % DRAWING_NS, {'lang':'en-US'})
            fill = SubElement(rpr, '{%s}solidFill' % DRAWING_NS)
            SubElement(fill, '{%s}srgbClr' % DRAWING_NS, {'val':shape.text_color})

            SubElement(r, '{%s}t' % DRAWING_NS).text = shape.text
        else:
            SubElement(p, '{%s}endParaRPr' % DRAWING_NS, {'lang':'en-US'})

    def _write_style(self, node):
        """ write style theme """

        style = SubElement(node, '{%s}style' % CHART_DRAWING_NS)

        ln_ref = SubElement(style, '{%s}lnRef' % DRAWING_NS, {'idx':'2'})
        scheme_clr = SubElement(ln_ref, '{%s}schemeClr' % DRAWING_NS, {'val':'accent1'})
        SubElement(scheme_clr, '{%s}shade' % DRAWING_NS, {'val':'50000'})

        fill_ref = SubElement(style, '{%s}fillRef' % DRAWING_NS, {'idx':'1'})
        SubElement(fill_ref, '{%s}schemeClr' % DRAWING_NS, {'val':'accent1'})

        effect_ref = SubElement(style, '{%s}effectRef' % DRAWING_NS, {'idx':'0'})
        SubElement(effect_ref, '{%s}schemeClr' % DRAWING_NS, {'val':'accent1'})

        font_ref = SubElement(style, '{%s}fontRef' % DRAWING_NS, {'idx':'minor'})
        SubElement(font_ref, '{%s}schemeClr' % DRAWING_NS, {'val':'lt1'})

[((228, 5, 228, 57), 'openpyxl.compat.deprecated', 'deprecated', ({(228, 16, 228, 56): '"""Chart Drawings need a complete rewrite"""'}, {}), "('Chart Drawings need a complete rewrite')", False, 'from openpyxl.compat import deprecated\n'), ((250, 29, 250, 47), 'openpyxl.utils.units.short_color', 'short_color', ({(250, 41, 250, 46): 'color'}, {}), '(color)', False, 'from openpyxl.utils.units import pixels_to_EMU, EMU_to_pixels, short_color\n'), ((258, 22, 258, 40), 'openpyxl.utils.units.short_color', 'short_color', ({(258, 34, 258, 39): 'color'}, {}), '(color)', False, 'from openpyxl.utils.units import pixels_to_EMU, EMU_to_pixels, short_color\n'), ((266, 27, 266, 45), 'openpyxl.utils.units.short_color', 'short_color', ({(266, 39, 266, 44): 'color'}, {}), '(color)', False, 'from openpyxl.utils.units import pixels_to_EMU, EMU_to_pixels, short_color\n'), ((288, 24, 288, 63), 'openpyxl.utils.units.pixels_to_EMU', 'pixels_to_EMU', ({(288, 38, 288, 62): 'self.chart.drawing.width'}, {}), '(self.chart.drawing.width)', False, 'from openpyxl.utils.units import pixels_to_EMU, EMU_to_pixels, short_color\n'), ((289, 25, 289, 65), 'openpyxl.utils.units.pixels_to_EMU', 'pixels_to_EMU', ({(289, 39, 289, 64): 'self.chart.drawing.height'}, {}), '(self.chart.drawing.height)', False, 'from openpyxl.utils.units import pixels_to_EMU, EMU_to_pixels, short_color\n'), ((340, 15, 340, 51), 'openpyxl.xml.functions.Element', 'Element', ({(340, 23, 340, 50): "'{%s}userShapes' % CHART_NS"}, {}), "('{%s}userShapes' % CHART_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((381, 15, 381, 29), 'openpyxl.xml.functions.tostring', 'tostring', ({(381, 24, 381, 28): 'root'}, {}), '(root)', False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((386, 18, 386, 67), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(386, 29, 386, 33): 'node', (386, 35, 386, 66): "'{%s}txBody' % CHART_DRAWING_NS"}, {}), "(node, '{%s}txBody' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((387, 8, 387, 79), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(387, 19, 387, 26): 'tx_body', (387, 28, 387, 53): "('{%s}bodyPr' % DRAWING_NS)", (387, 55, 387, 78): "{'vertOverflow': 'clip'}"}, {}), "(tx_body, '{%s}bodyPr' % DRAWING_NS, {'vertOverflow': 'clip'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((388, 8, 388, 56), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(388, 19, 388, 26): 'tx_body', (388, 28, 388, 55): "('{%s}lstStyle' % DRAWING_NS)"}, {}), "(tx_body, '{%s}lstStyle' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((389, 12, 389, 53), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(389, 23, 389, 30): 'tx_body', (389, 32, 389, 52): "'{%s}p' % DRAWING_NS"}, {}), "(tx_body, '{%s}p' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((403, 16, 403, 64), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(403, 27, 403, 31): 'node', (403, 33, 403, 63): "'{%s}style' % CHART_DRAWING_NS"}, {}), "(node, '{%s}style' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((405, 17, 405, 73), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(405, 28, 405, 33): 'style', (405, 35, 405, 59): "'{%s}lnRef' % DRAWING_NS", (405, 61, 405, 72): "{'idx': '2'}"}, {}), "(style, '{%s}lnRef' % DRAWING_NS, {'idx': '2'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((406, 21, 406, 88), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(406, 32, 406, 38): 'ln_ref', (406, 40, 406, 68): "'{%s}schemeClr' % DRAWING_NS", (406, 70, 406, 87): "{'val': 'accent1'}"}, {}), "(ln_ref, '{%s}schemeClr' % DRAWING_NS, {'val': 'accent1'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((407, 8, 407, 73), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(407, 19, 407, 29): 'scheme_clr', (407, 31, 407, 55): "('{%s}shade' % DRAWING_NS)", (407, 57, 407, 72): "{'val': '50000'}"}, {}), "(scheme_clr, '{%s}shade' % DRAWING_NS, {'val': '50000'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((409, 19, 409, 77), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(409, 30, 409, 35): 'style', (409, 37, 409, 63): "'{%s}fillRef' % DRAWING_NS", (409, 65, 409, 76): "{'idx': '1'}"}, {}), "(style, '{%s}fillRef' % DRAWING_NS, {'idx': '1'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((410, 8, 410, 77), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(410, 19, 410, 27): 'fill_ref', (410, 29, 410, 57): "('{%s}schemeClr' % DRAWING_NS)", (410, 59, 410, 76): "{'val': 'accent1'}"}, {}), "(fill_ref, '{%s}schemeClr' % DRAWING_NS, {'val': 'accent1'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((412, 21, 412, 81), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(412, 32, 412, 37): 'style', (412, 39, 412, 67): "'{%s}effectRef' % DRAWING_NS", (412, 69, 412, 80): "{'idx': '0'}"}, {}), "(style, '{%s}effectRef' % DRAWING_NS, {'idx': '0'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((413, 8, 413, 79), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(413, 19, 413, 29): 'effect_ref', (413, 31, 413, 59): "('{%s}schemeClr' % DRAWING_NS)", (413, 61, 413, 78): "{'val': 'accent1'}"}, {}), "(effect_ref, '{%s}schemeClr' % DRAWING_NS, {'val': 'accent1'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((415, 19, 415, 81), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(415, 30, 415, 35): 'style', (415, 37, 415, 63): "'{%s}fontRef' % DRAWING_NS", (415, 65, 415, 80): "{'idx': 'minor'}"}, {}), "(style, '{%s}fontRef' % DRAWING_NS, {'idx': 'minor'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((416, 8, 416, 73), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(416, 19, 416, 27): 'font_ref', (416, 29, 416, 57): "('{%s}schemeClr' % DRAWING_NS)", (416, 59, 416, 72): "{'val': 'lt1'}"}, {}), "(font_ref, '{%s}schemeClr' % DRAWING_NS, {'val': 'lt1'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((343, 21, 343, 77), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(343, 32, 343, 36): 'root', (343, 38, 343, 76): "'{%s}relSizeAnchor' % CHART_DRAWING_NS"}, {}), "(root, '{%s}relSizeAnchor' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((347, 20, 347, 69), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(347, 31, 347, 37): 'anchor', (347, 39, 347, 68): "'{%s}from' % CHART_DRAWING_NS"}, {}), "(anchor, '{%s}from' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((351, 18, 351, 65), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(351, 29, 351, 35): 'anchor', (351, 37, 351, 64): "'{%s}to' % CHART_DRAWING_NS"}, {}), "(anchor, '{%s}to' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((355, 17, 355, 93), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(355, 28, 355, 34): 'anchor', (355, 36, 355, 63): "'{%s}sp' % CHART_DRAWING_NS", (355, 65, 355, 92): "{'macro': '', 'textlink': ''}"}, {}), "(anchor, '{%s}sp' % CHART_DRAWING_NS, {'macro': '', 'textlink': ''})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((356, 20, 356, 67), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(356, 31, 356, 33): 'sp', (356, 35, 356, 66): "'{%s}nvSpPr' % CHART_DRAWING_NS"}, {}), "(sp, '{%s}nvSpPr' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((358, 12, 358, 63), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(358, 23, 358, 28): 'nvspr', (358, 30, 358, 62): "('{%s}cNvSpPr' % CHART_DRAWING_NS)"}, {}), "(nvspr, '{%s}cNvSpPr' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((360, 19, 360, 64), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(360, 30, 360, 32): 'sp', (360, 34, 360, 63): "'{%s}spPr' % CHART_DRAWING_NS"}, {}), "(sp, '{%s}spPr' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((361, 18, 361, 60), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(361, 29, 361, 33): 'sppr', (361, 35, 361, 58): "'{%s}xfrm' % DRAWING_NS"}, {}), "(sppr, '{%s}xfrm' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((363, 12, 363, 71), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(363, 23, 363, 26): 'frm', (363, 28, 363, 50): "('{%s}off' % DRAWING_NS)", (363, 52, 363, 70): "{'x': '0', 'y': '0'}"}, {}), "(frm, '{%s}off' % DRAWING_NS, {'x': '0', 'y': '0'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((364, 12, 364, 73), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(364, 23, 364, 26): 'frm', (364, 28, 364, 50): "('{%s}ext' % DRAWING_NS)", (364, 52, 364, 72): "{'cx': '0', 'cy': '0'}"}, {}), "(frm, '{%s}ext' % DRAWING_NS, {'cx': '0', 'cy': '0'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((367, 12, 367, 58), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(367, 23, 367, 31): 'prstgeom', (367, 33, 367, 57): "('{%s}avLst' % DRAWING_NS)"}, {}), "(prstgeom, '{%s}avLst' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((369, 19, 369, 67), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(369, 30, 369, 34): 'sppr', (369, 36, 369, 64): "'{%s}solidFill' % DRAWING_NS"}, {}), "(sppr, '{%s}solidFill' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((370, 12, 370, 77), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(370, 23, 370, 27): 'fill', (370, 29, 370, 55): "('{%s}srgbClr' % DRAWING_NS)", (370, 57, 370, 76): "{'val': shape.color}"}, {}), "(fill, '{%s}srgbClr' % DRAWING_NS, {'val': shape.color})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((373, 17, 373, 65), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(373, 28, 373, 34): 'border', (373, 36, 373, 64): "'{%s}solidFill' % DRAWING_NS"}, {}), "(border, '{%s}solidFill' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((374, 12, 374, 82), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(374, 23, 374, 25): 'sf', (374, 27, 374, 53): "('{%s}srgbClr' % DRAWING_NS)", (374, 55, 374, 81): "{'val': shape.border_color}"}, {}), "(sf, '{%s}srgbClr' % DRAWING_NS, {'val': shape.border_color})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((391, 16, 391, 51), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(391, 27, 391, 28): 'p', (391, 30, 391, 50): "'{%s}r' % DRAWING_NS"}, {}), "(p, '{%s}r' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((392, 18, 392, 73), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(392, 29, 392, 30): 'r', (392, 32, 392, 54): "'{%s}rPr' % DRAWING_NS", (392, 56, 392, 72): "{'lang': 'en-US'}"}, {}), "(r, '{%s}rPr' % DRAWING_NS, {'lang': 'en-US'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((393, 19, 393, 64), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(393, 30, 393, 33): 'rpr', (393, 35, 393, 63): "'{%s}solidFill' % DRAWING_NS"}, {}), "(rpr, '{%s}solidFill' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((394, 12, 394, 82), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(394, 23, 394, 27): 'fill', (394, 29, 394, 55): "('{%s}srgbClr' % DRAWING_NS)", (394, 57, 394, 81): "{'val': shape.text_color}"}, {}), "(fill, '{%s}srgbClr' % DRAWING_NS, {'val': shape.text_color})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((398, 12, 398, 74), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(398, 23, 398, 24): 'p', (398, 26, 398, 55): "('{%s}endParaRPr' % DRAWING_NS)", (398, 57, 398, 73): "{'lang': 'en-US'}"}, {}), "(p, '{%s}endParaRPr' % DRAWING_NS, {'lang': 'en-US'})", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((348, 12, 348, 57), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(348, 23, 348, 28): '_from', (348, 30, 348, 56): "('{%s}x' % CHART_DRAWING_NS)"}, {}), "(_from, '{%s}x' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((349, 12, 349, 57), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(349, 23, 349, 28): '_from', (349, 30, 349, 56): "('{%s}y' % CHART_DRAWING_NS)"}, {}), "(_from, '{%s}y' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((352, 12, 352, 55), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(352, 23, 352, 26): '_to', (352, 28, 352, 54): "('{%s}x' % CHART_DRAWING_NS)"}, {}), "(_to, '{%s}x' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((353, 12, 353, 55), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(353, 23, 353, 26): '_to', (353, 28, 353, 54): "('{%s}y' % CHART_DRAWING_NS)"}, {}), "(_to, '{%s}y' % CHART_DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n'), ((396, 12, 396, 47), 'openpyxl.xml.functions.SubElement', 'SubElement', ({(396, 23, 396, 24): 'r', (396, 26, 396, 46): "('{%s}t' % DRAWING_NS)"}, {}), "(r, '{%s}t' % DRAWING_NS)", False, 'from openpyxl.xml.functions import Element, SubElement, tostring\n')]