Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/openpyxl/drawing/graphic.py: 89%
92 statements
« prev ^ index » next coverage.py v7.3.3, created at 2023-12-20 06:34 +0000
« prev ^ index » next coverage.py v7.3.3, created at 2023-12-20 06:34 +0000
1# Copyright (c) 2010-2023 openpyxl
3from openpyxl.xml.constants import CHART_NS, DRAWING_NS
4from openpyxl.descriptors.serialisable import Serialisable
5from openpyxl.descriptors import (
6 Typed,
7 Bool,
8 String,
9 Alias,
10)
11from openpyxl.descriptors.excel import ExtensionList as OfficeArtExtensionList
13from .effect import (
14 EffectList,
15 EffectContainer,
16)
17from .fill import (
18 Blip,
19 GradientFillProperties,
20 BlipFillProperties,
21)
22from .picture import PictureFrame
23from .properties import (
24 NonVisualDrawingProps,
25 NonVisualGroupShape,
26 GroupShapeProperties,
27)
28from .relation import ChartRelation
29from .xdr import XDRTransform2D
32class GraphicFrameLocking(Serialisable):
34 noGrp = Bool(allow_none=True)
35 noDrilldown = Bool(allow_none=True)
36 noSelect = Bool(allow_none=True)
37 noChangeAspect = Bool(allow_none=True)
38 noMove = Bool(allow_none=True)
39 noResize = Bool(allow_none=True)
40 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
42 def __init__(self,
43 noGrp=None,
44 noDrilldown=None,
45 noSelect=None,
46 noChangeAspect=None,
47 noMove=None,
48 noResize=None,
49 extLst=None,
50 ):
51 self.noGrp = noGrp
52 self.noDrilldown = noDrilldown
53 self.noSelect = noSelect
54 self.noChangeAspect = noChangeAspect
55 self.noMove = noMove
56 self.noResize = noResize
57 self.extLst = extLst
60class NonVisualGraphicFrameProperties(Serialisable):
62 tagname = "cNvGraphicFramePr"
64 graphicFrameLocks = Typed(expected_type=GraphicFrameLocking, allow_none=True)
65 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
67 def __init__(self,
68 graphicFrameLocks=None,
69 extLst=None,
70 ):
71 self.graphicFrameLocks = graphicFrameLocks
72 self.extLst = extLst
75class NonVisualGraphicFrame(Serialisable):
77 tagname = "nvGraphicFramePr"
79 cNvPr = Typed(expected_type=NonVisualDrawingProps)
80 cNvGraphicFramePr = Typed(expected_type=NonVisualGraphicFrameProperties)
82 __elements__ = ('cNvPr', 'cNvGraphicFramePr')
84 def __init__(self,
85 cNvPr=None,
86 cNvGraphicFramePr=None,
87 ):
88 if cNvPr is None:
89 cNvPr = NonVisualDrawingProps(id=0, name="Chart 0")
90 self.cNvPr = cNvPr
91 if cNvGraphicFramePr is None:
92 cNvGraphicFramePr = NonVisualGraphicFrameProperties()
93 self.cNvGraphicFramePr = cNvGraphicFramePr
96class GraphicData(Serialisable):
98 tagname = "graphicData"
99 namespace = DRAWING_NS
101 uri = String()
102 chart = Typed(expected_type=ChartRelation, allow_none=True)
105 def __init__(self,
106 uri=CHART_NS,
107 chart=None,
108 ):
109 self.uri = uri
110 self.chart = chart
113class GraphicObject(Serialisable):
115 tagname = "graphic"
116 namespace = DRAWING_NS
118 graphicData = Typed(expected_type=GraphicData)
120 def __init__(self,
121 graphicData=None,
122 ):
123 if graphicData is None:
124 graphicData = GraphicData()
125 self.graphicData = graphicData
128class GraphicFrame(Serialisable):
130 tagname = "graphicFrame"
132 nvGraphicFramePr = Typed(expected_type=NonVisualGraphicFrame)
133 xfrm = Typed(expected_type=XDRTransform2D)
134 graphic = Typed(expected_type=GraphicObject)
135 macro = String(allow_none=True)
136 fPublished = Bool(allow_none=True)
138 __elements__ = ('nvGraphicFramePr', 'xfrm', 'graphic', 'macro', 'fPublished')
140 def __init__(self,
141 nvGraphicFramePr=None,
142 xfrm=None,
143 graphic=None,
144 macro=None,
145 fPublished=None,
146 ):
147 if nvGraphicFramePr is None:
148 nvGraphicFramePr = NonVisualGraphicFrame()
149 self.nvGraphicFramePr = nvGraphicFramePr
150 if xfrm is None:
151 xfrm = XDRTransform2D()
152 self.xfrm = xfrm
153 if graphic is None:
154 graphic = GraphicObject()
155 self.graphic = graphic
156 self.macro = macro
157 self.fPublished = fPublished
160class GroupShape(Serialisable):
162 nvGrpSpPr = Typed(expected_type=NonVisualGroupShape)
163 nonVisualProperties = Alias("nvGrpSpPr")
164 grpSpPr = Typed(expected_type=GroupShapeProperties)
165 visualProperties = Alias("grpSpPr")
166 pic = Typed(expected_type=PictureFrame, allow_none=True)
168 __elements__ = ["nvGrpSpPr", "grpSpPr", "pic"]
170 def __init__(self,
171 nvGrpSpPr=None,
172 grpSpPr=None,
173 pic=None,
174 ):
175 self.nvGrpSpPr = nvGrpSpPr
176 self.grpSpPr = grpSpPr
177 self.pic = pic