Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/drawing/geometry.py: 72%
255 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1# Copyright (c) 2010-2022 openpyxl
3from openpyxl.descriptors.serialisable import Serialisable
4from openpyxl.descriptors import (
5 Typed,
6 Float,
7 Integer,
8 Bool,
9 MinMax,
10 Set,
11 NoneSet,
12 String,
13 Alias,
14)
15from openpyxl.descriptors.excel import Coordinate, Percentage
17from openpyxl.descriptors.nested import (
18 EmptyTag
19 )
21from openpyxl.descriptors.excel import ExtensionList as OfficeArtExtensionList
22from .colors import ColorChoiceDescriptor
23from .fill import (
24 GradientFillProperties,
25 BlipFillProperties,
26 PatternFillProperties,
27 )
28from .line import LineProperties
30from openpyxl.styles.colors import Color
31from openpyxl.xml.constants import DRAWING_NS
34class Point2D(Serialisable):
36 tagname = "off"
37 namespace = DRAWING_NS
39 x = Coordinate()
40 y = Coordinate()
42 def __init__(self,
43 x=None,
44 y=None,
45 ):
46 self.x = x
47 self.y = y
50class PositiveSize2D(Serialisable):
52 tagname = "ext"
53 namespace = DRAWING_NS
55 """
56 Dimensions in EMUs
57 """
59 cx = Integer()
60 width = Alias('cx')
61 cy = Integer()
62 height = Alias('cy')
64 def __init__(self,
65 cx=None,
66 cy=None,
67 ):
68 self.cx = cx
69 self.cy = cy
72class Transform2D(Serialisable):
74 tagname = "xfrm"
75 namespace = DRAWING_NS
77 rot = Integer(allow_none=True)
78 flipH = Bool(allow_none=True)
79 flipV = Bool(allow_none=True)
80 off = Typed(expected_type=Point2D, allow_none=True)
81 ext = Typed(expected_type=PositiveSize2D, allow_none=True)
82 chOff = Typed(expected_type=Point2D, allow_none=True)
83 chExt = Typed(expected_type=PositiveSize2D, allow_none=True)
85 __elements__ = ('off', 'ext', 'chOff', 'chExt')
87 def __init__(self,
88 rot=None,
89 flipH=None,
90 flipV=None,
91 off=None,
92 ext=None,
93 chOff=None,
94 chExt=None,
95 ):
96 self.rot = rot
97 self.flipH = flipH
98 self.flipV = flipV
99 self.off = off
100 self.ext = ext
101 self.chOff = chOff
102 self.chExt = chExt
105class GroupTransform2D(Serialisable):
107 tagname = "xfrm"
108 namespace = DRAWING_NS
110 rot = Integer(allow_none=True)
111 flipH = Bool(allow_none=True)
112 flipV = Bool(allow_none=True)
113 off = Typed(expected_type=Point2D, allow_none=True)
114 ext = Typed(expected_type=PositiveSize2D, allow_none=True)
115 chOff = Typed(expected_type=Point2D, allow_none=True)
116 chExt = Typed(expected_type=PositiveSize2D, allow_none=True)
118 __elements__ = ("off", "ext", "chOff", "chExt")
120 def __init__(self,
121 rot=0,
122 flipH=None,
123 flipV=None,
124 off=None,
125 ext=None,
126 chOff=None,
127 chExt=None,
128 ):
129 self.rot = rot
130 self.flipH = flipH
131 self.flipV = flipV
132 self.off = off
133 self.ext = ext
134 self.chOff = chOff
135 self.chExt = chExt
138class SphereCoords(Serialisable):
140 tagname = "sphereCoords" # usually
142 lat = Integer()
143 lon = Integer()
144 rev = Integer()
146 def __init__(self,
147 lat=None,
148 lon=None,
149 rev=None,
150 ):
151 self.lat = lat
152 self.lon = lon
153 self.rev = rev
156class Camera(Serialisable):
158 tagname = "camera"
160 prst = Set(values=[
161 'legacyObliqueTopLeft', 'legacyObliqueTop', 'legacyObliqueTopRight', 'legacyObliqueLeft',
162 'legacyObliqueFront', 'legacyObliqueRight', 'legacyObliqueBottomLeft',
163 'legacyObliqueBottom', 'legacyObliqueBottomRight', 'legacyPerspectiveTopLeft',
164 'legacyPerspectiveTop', 'legacyPerspectiveTopRight', 'legacyPerspectiveLeft',
165 'legacyPerspectiveFront', 'legacyPerspectiveRight', 'legacyPerspectiveBottomLeft',
166 'legacyPerspectiveBottom', 'legacyPerspectiveBottomRight', 'orthographicFront',
167 'isometricTopUp', 'isometricTopDown', 'isometricBottomUp', 'isometricBottomDown',
168 'isometricLeftUp', 'isometricLeftDown', 'isometricRightUp', 'isometricRightDown',
169 'isometricOffAxis1Left', 'isometricOffAxis1Right', 'isometricOffAxis1Top',
170 'isometricOffAxis2Left', 'isometricOffAxis2Right', 'isometricOffAxis2Top',
171 'isometricOffAxis3Left', 'isometricOffAxis3Right', 'isometricOffAxis3Bottom',
172 'isometricOffAxis4Left', 'isometricOffAxis4Right', 'isometricOffAxis4Bottom',
173 'obliqueTopLeft', 'obliqueTop', 'obliqueTopRight', 'obliqueLeft', 'obliqueRight',
174 'obliqueBottomLeft', 'obliqueBottom', 'obliqueBottomRight', 'perspectiveFront',
175 'perspectiveLeft', 'perspectiveRight', 'perspectiveAbove', 'perspectiveBelow',
176 'perspectiveAboveLeftFacing', 'perspectiveAboveRightFacing',
177 'perspectiveContrastingLeftFacing', 'perspectiveContrastingRightFacing',
178 'perspectiveHeroicLeftFacing', 'perspectiveHeroicRightFacing',
179 'perspectiveHeroicExtremeLeftFacing', 'perspectiveHeroicExtremeRightFacing',
180 'perspectiveRelaxed', 'perspectiveRelaxedModerately'])
181 fov = Integer(allow_none=True)
182 zoom = Typed(expected_type=Percentage, allow_none=True)
183 rot = Typed(expected_type=SphereCoords, allow_none=True)
186 def __init__(self,
187 prst=None,
188 fov=None,
189 zoom=None,
190 rot=None,
191 ):
192 self.prst = prst
193 self.fov = fov
194 self.zoom = zoom
195 self.rot = rot
198class LightRig(Serialisable):
200 tagname = "lightRig"
202 rig = Set(values=['legacyFlat1', 'legacyFlat2', 'legacyFlat3', 'legacyFlat4', 'legacyNormal1',
203 'legacyNormal2', 'legacyNormal3', 'legacyNormal4', 'legacyHarsh1',
204 'legacyHarsh2', 'legacyHarsh3', 'legacyHarsh4', 'threePt', 'balanced',
205 'soft', 'harsh', 'flood', 'contrasting', 'morning', 'sunrise', 'sunset',
206 'chilly', 'freezing', 'flat', 'twoPt', 'glow', 'brightRoom']
207 )
208 dir = Set(values=(['tl', 't', 'tr', 'l', 'r', 'bl', 'b', 'br']))
209 rot = Typed(expected_type=SphereCoords, allow_none=True)
211 def __init__(self,
212 rig=None,
213 dir=None,
214 rot=None,
215 ):
216 self.rig = rig
217 self.dir = dir
218 self.rot = rot
221class Vector3D(Serialisable):
223 tagname = "vector"
225 dx = Integer() # can be in or universl measure :-/
226 dy = Integer()
227 dz = Integer()
229 def __init__(self,
230 dx=None,
231 dy=None,
232 dz=None,
233 ):
234 self.dx = dx
235 self.dy = dy
236 self.dz = dz
239class Point3D(Serialisable):
241 tagname = "anchor"
243 x = Integer()
244 y = Integer()
245 z = Integer()
247 def __init__(self,
248 x=None,
249 y=None,
250 z=None,
251 ):
252 self.x = x
253 self.y = y
254 self.z = z
257class Backdrop(Serialisable):
259 anchor = Typed(expected_type=Point3D, )
260 norm = Typed(expected_type=Vector3D, )
261 up = Typed(expected_type=Vector3D, )
262 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
264 def __init__(self,
265 anchor=None,
266 norm=None,
267 up=None,
268 extLst=None,
269 ):
270 self.anchor = anchor
271 self.norm = norm
272 self.up = up
273 self.extLst = extLst
276class Scene3D(Serialisable):
278 camera = Typed(expected_type=Camera, )
279 lightRig = Typed(expected_type=LightRig, )
280 backdrop = Typed(expected_type=Backdrop, allow_none=True)
281 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
283 def __init__(self,
284 camera=None,
285 lightRig=None,
286 backdrop=None,
287 extLst=None,
288 ):
289 self.camera = camera
290 self.lightRig = lightRig
291 self.backdrop = backdrop
292 self.extLst = extLst
295class Bevel(Serialisable):
297 tagname = "bevel"
299 w = Integer()
300 h = Integer()
301 prst = NoneSet(values=
302 ['relaxedInset', 'circle', 'slope', 'cross', 'angle',
303 'softRound', 'convex', 'coolSlant', 'divot', 'riblet',
304 'hardEdge', 'artDeco']
305 )
307 def __init__(self,
308 w=None,
309 h=None,
310 prst=None,
311 ):
312 self.w = w
313 self.h = h
314 self.prst = prst
317class Shape3D(Serialisable):
319 namespace = DRAWING_NS
321 z = Typed(expected_type=Coordinate, allow_none=True)
322 extrusionH = Integer(allow_none=True)
323 contourW = Integer(allow_none=True)
324 prstMaterial = NoneSet(values=[
325 'legacyMatte','legacyPlastic', 'legacyMetal', 'legacyWireframe', 'matte', 'plastic',
326 'metal', 'warmMatte', 'translucentPowder', 'powder', 'dkEdge',
327 'softEdge', 'clear', 'flat', 'softmetal']
328 )
329 bevelT = Typed(expected_type=Bevel, allow_none=True)
330 bevelB = Typed(expected_type=Bevel, allow_none=True)
331 extrusionClr = Typed(expected_type=Color, allow_none=True)
332 contourClr = Typed(expected_type=Color, allow_none=True)
333 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
335 def __init__(self,
336 z=None,
337 extrusionH=None,
338 contourW=None,
339 prstMaterial=None,
340 bevelT=None,
341 bevelB=None,
342 extrusionClr=None,
343 contourClr=None,
344 extLst=None,
345 ):
346 self.z = z
347 self.extrusionH = extrusionH
348 self.contourW = contourW
349 self.prstMaterial = prstMaterial
350 self.bevelT = bevelT
351 self.bevelB = bevelB
352 self.extrusionClr = extrusionClr
353 self.contourClr = contourClr
354 self.extLst = extLst
357class Path2D(Serialisable):
359 w = Float()
360 h = Float()
361 fill = NoneSet(values=(['norm', 'lighten', 'lightenLess', 'darken', 'darkenLess']))
362 stroke = Bool(allow_none=True)
363 extrusionOk = Bool(allow_none=True)
365 def __init__(self,
366 w=None,
367 h=None,
368 fill=None,
369 stroke=None,
370 extrusionOk=None,
371 ):
372 self.w = w
373 self.h = h
374 self.fill = fill
375 self.stroke = stroke
376 self.extrusionOk = extrusionOk
379class Path2DList(Serialisable):
381 path = Typed(expected_type=Path2D, allow_none=True)
383 def __init__(self,
384 path=None,
385 ):
386 self.path = path
389class GeomRect(Serialisable):
391 l = Coordinate()
392 t = Coordinate()
393 r = Coordinate()
394 b = Coordinate()
396 def __init__(self,
397 l=None,
398 t=None,
399 r=None,
400 b=None,
401 ):
402 self.l = l
403 self.t = t
404 self.r = r
405 self.b = b
408class AdjPoint2D(Serialisable):
410 x = Coordinate()
411 y = Coordinate()
413 def __init__(self,
414 x=None,
415 y=None,
416 ):
417 self.x = x
418 self.y = y
421class ConnectionSite(Serialisable):
423 ang = MinMax(min=0, max=360) # guess work, can also be a name
424 pos = Typed(expected_type=AdjPoint2D, )
426 def __init__(self,
427 ang=None,
428 pos=None,
429 ):
430 self.ang = ang
431 self.pos = pos
434class ConnectionSiteList(Serialisable):
436 cxn = Typed(expected_type=ConnectionSite, allow_none=True)
438 def __init__(self,
439 cxn=None,
440 ):
441 self.cxn = cxn
444class AdjustHandleList(Serialisable):
446 pass
448class GeomGuide(Serialisable):
450 name = String()
451 fmla = String()
453 def __init__(self,
454 name=None,
455 fmla=None,
456 ):
457 self.name = name
458 self.fmla = fmla
461class GeomGuideList(Serialisable):
463 gd = Typed(expected_type=GeomGuide, allow_none=True)
465 def __init__(self,
466 gd=None,
467 ):
468 self.gd = gd
471class CustomGeometry2D(Serialisable):
473 avLst = Typed(expected_type=GeomGuideList, allow_none=True)
474 gdLst = Typed(expected_type=GeomGuideList, allow_none=True)
475 ahLst = Typed(expected_type=AdjustHandleList, allow_none=True)
476 cxnLst = Typed(expected_type=ConnectionSiteList, allow_none=True)
477 #rect = Typed(expected_type=GeomRect, allow_none=True)
478 pathLst = Typed(expected_type=Path2DList, )
480 def __init__(self,
481 avLst=None,
482 gdLst=None,
483 ahLst=None,
484 cxnLst=None,
485 rect=None,
486 pathLst=None,
487 ):
488 self.avLst = avLst
489 self.gdLst = gdLst
490 self.ahLst = ahLst
491 self.cxnLst = cxnLst
492 self.rect = None
493 self.pathLst = pathLst
496class PresetGeometry2D(Serialisable):
498 namespace = DRAWING_NS
500 prst = Set(values=(
501 ['line', 'lineInv', 'triangle', 'rtTriangle', 'rect',
502 'diamond', 'parallelogram', 'trapezoid', 'nonIsoscelesTrapezoid',
503 'pentagon', 'hexagon', 'heptagon', 'octagon', 'decagon', 'dodecagon',
504 'star4', 'star5', 'star6', 'star7', 'star8', 'star10', 'star12',
505 'star16', 'star24', 'star32', 'roundRect', 'round1Rect',
506 'round2SameRect', 'round2DiagRect', 'snipRoundRect', 'snip1Rect',
507 'snip2SameRect', 'snip2DiagRect', 'plaque', 'ellipse', 'teardrop',
508 'homePlate', 'chevron', 'pieWedge', 'pie', 'blockArc', 'donut',
509 'noSmoking', 'rightArrow', 'leftArrow', 'upArrow', 'downArrow',
510 'stripedRightArrow', 'notchedRightArrow', 'bentUpArrow',
511 'leftRightArrow', 'upDownArrow', 'leftUpArrow', 'leftRightUpArrow',
512 'quadArrow', 'leftArrowCallout', 'rightArrowCallout', 'upArrowCallout',
513 'downArrowCallout', 'leftRightArrowCallout', 'upDownArrowCallout',
514 'quadArrowCallout', 'bentArrow', 'uturnArrow', 'circularArrow',
515 'leftCircularArrow', 'leftRightCircularArrow', 'curvedRightArrow',
516 'curvedLeftArrow', 'curvedUpArrow', 'curvedDownArrow', 'swooshArrow',
517 'cube', 'can', 'lightningBolt', 'heart', 'sun', 'moon', 'smileyFace',
518 'irregularSeal1', 'irregularSeal2', 'foldedCorner', 'bevel', 'frame',
519 'halfFrame', 'corner', 'diagStripe', 'chord', 'arc', 'leftBracket',
520 'rightBracket', 'leftBrace', 'rightBrace', 'bracketPair', 'bracePair',
521 'straightConnector1', 'bentConnector2', 'bentConnector3',
522 'bentConnector4', 'bentConnector5', 'curvedConnector2',
523 'curvedConnector3', 'curvedConnector4', 'curvedConnector5', 'callout1',
524 'callout2', 'callout3', 'accentCallout1', 'accentCallout2',
525 'accentCallout3', 'borderCallout1', 'borderCallout2', 'borderCallout3',
526 'accentBorderCallout1', 'accentBorderCallout2', 'accentBorderCallout3',
527 'wedgeRectCallout', 'wedgeRoundRectCallout', 'wedgeEllipseCallout',
528 'cloudCallout', 'cloud', 'ribbon', 'ribbon2', 'ellipseRibbon',
529 'ellipseRibbon2', 'leftRightRibbon', 'verticalScroll',
530 'horizontalScroll', 'wave', 'doubleWave', 'plus', 'flowChartProcess',
531 'flowChartDecision', 'flowChartInputOutput',
532 'flowChartPredefinedProcess', 'flowChartInternalStorage',
533 'flowChartDocument', 'flowChartMultidocument', 'flowChartTerminator',
534 'flowChartPreparation', 'flowChartManualInput',
535 'flowChartManualOperation', 'flowChartConnector', 'flowChartPunchedCard',
536 'flowChartPunchedTape', 'flowChartSummingJunction', 'flowChartOr',
537 'flowChartCollate', 'flowChartSort', 'flowChartExtract',
538 'flowChartMerge', 'flowChartOfflineStorage', 'flowChartOnlineStorage',
539 'flowChartMagneticTape', 'flowChartMagneticDisk',
540 'flowChartMagneticDrum', 'flowChartDisplay', 'flowChartDelay',
541 'flowChartAlternateProcess', 'flowChartOffpageConnector',
542 'actionButtonBlank', 'actionButtonHome', 'actionButtonHelp',
543 'actionButtonInformation', 'actionButtonForwardNext',
544 'actionButtonBackPrevious', 'actionButtonEnd', 'actionButtonBeginning',
545 'actionButtonReturn', 'actionButtonDocument', 'actionButtonSound',
546 'actionButtonMovie', 'gear6', 'gear9', 'funnel', 'mathPlus', 'mathMinus',
547 'mathMultiply', 'mathDivide', 'mathEqual', 'mathNotEqual', 'cornerTabs',
548 'squareTabs', 'plaqueTabs', 'chartX', 'chartStar', 'chartPlus']))
549 avLst = Typed(expected_type=GeomGuideList, allow_none=True)
551 def __init__(self,
552 prst=None,
553 avLst=None,
554 ):
555 self.prst = prst
556 self.avLst = avLst
559class FontReference(Serialisable):
561 idx = NoneSet(values=(['major', 'minor']))
563 def __init__(self,
564 idx=None,
565 ):
566 self.idx = idx
569class StyleMatrixReference(Serialisable):
571 idx = Integer()
573 def __init__(self,
574 idx=None,
575 ):
576 self.idx = idx
579class ShapeStyle(Serialisable):
581 lnRef = Typed(expected_type=StyleMatrixReference, )
582 fillRef = Typed(expected_type=StyleMatrixReference, )
583 effectRef = Typed(expected_type=StyleMatrixReference, )
584 fontRef = Typed(expected_type=FontReference, )
586 def __init__(self,
587 lnRef=None,
588 fillRef=None,
589 effectRef=None,
590 fontRef=None,
591 ):
592 self.lnRef = lnRef
593 self.fillRef = fillRef
594 self.effectRef = effectRef
595 self.fontRef = fontRef