Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/drawing/picture.py: 58%
80 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.xml.constants import DRAWING_NS
5from openpyxl.descriptors.serialisable import Serialisable
6from openpyxl.descriptors import (
7 Typed,
8 Bool,
9 NoneSet,
10 Integer,
11 Set,
12 String,
13 Alias,
14)
15from openpyxl.descriptors.excel import ExtensionList as OfficeArtExtensionList
17from openpyxl.chart.shapes import GraphicalProperties
19from .fill import RelativeRect, BlipFillProperties
20from .properties import NonVisualDrawingProps, NonVisualGroupDrawingShapeProps
21from .geometry import ShapeStyle
24class PictureLocking(Serialisable):
26 tagname = "picLocks"
27 namespace = DRAWING_NS
29 #Using attribute group AG_Locking
30 noCrop = Bool(allow_none=True)
31 noGrp = Bool(allow_none=True)
32 noSelect = Bool(allow_none=True)
33 noRot = Bool(allow_none=True)
34 noChangeAspect = Bool(allow_none=True)
35 noMove = Bool(allow_none=True)
36 noResize = Bool(allow_none=True)
37 noEditPoints = Bool(allow_none=True)
38 noAdjustHandles = Bool(allow_none=True)
39 noChangeArrowheads = Bool(allow_none=True)
40 noChangeShapeType = Bool(allow_none=True)
41 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
43 __elements__ = ()
45 def __init__(self,
46 noCrop=None,
47 noGrp=None,
48 noSelect=None,
49 noRot=None,
50 noChangeAspect=None,
51 noMove=None,
52 noResize=None,
53 noEditPoints=None,
54 noAdjustHandles=None,
55 noChangeArrowheads=None,
56 noChangeShapeType=None,
57 extLst=None,
58 ):
59 self.noCrop = noCrop
60 self.noGrp = noGrp
61 self.noSelect = noSelect
62 self.noRot = noRot
63 self.noChangeAspect = noChangeAspect
64 self.noMove = noMove
65 self.noResize = noResize
66 self.noEditPoints = noEditPoints
67 self.noAdjustHandles = noAdjustHandles
68 self.noChangeArrowheads = noChangeArrowheads
69 self.noChangeShapeType = noChangeShapeType
72class NonVisualPictureProperties(Serialisable):
74 tagname = "cNvPicPr"
76 preferRelativeResize = Bool(allow_none=True)
77 picLocks = Typed(expected_type=PictureLocking, allow_none=True)
78 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
80 __elements__ = ("picLocks",)
82 def __init__(self,
83 preferRelativeResize=None,
84 picLocks=None,
85 extLst=None,
86 ):
87 self.preferRelativeResize = preferRelativeResize
88 self.picLocks = picLocks
91class PictureNonVisual(Serialisable):
93 tagname = "nvPicPr"
95 cNvPr = Typed(expected_type=NonVisualDrawingProps, )
96 cNvPicPr = Typed(expected_type=NonVisualPictureProperties, )
98 __elements__ = ("cNvPr", "cNvPicPr")
100 def __init__(self,
101 cNvPr=None,
102 cNvPicPr=None,
103 ):
104 if cNvPr is None:
105 cNvPr = NonVisualDrawingProps(id=0, name="Image 1", descr="Name of file")
106 self.cNvPr = cNvPr
107 if cNvPicPr is None:
108 cNvPicPr = NonVisualPictureProperties()
109 self.cNvPicPr = cNvPicPr
114class PictureFrame(Serialisable):
116 tagname = "pic"
118 macro = String(allow_none=True)
119 fPublished = Bool(allow_none=True)
120 nvPicPr = Typed(expected_type=PictureNonVisual, )
121 blipFill = Typed(expected_type=BlipFillProperties, )
122 spPr = Typed(expected_type=GraphicalProperties, )
123 graphicalProperties = Alias('spPr')
124 style = Typed(expected_type=ShapeStyle, allow_none=True)
126 __elements__ = ("nvPicPr", "blipFill", "spPr", "style")
128 def __init__(self,
129 macro=None,
130 fPublished=None,
131 nvPicPr=None,
132 blipFill=None,
133 spPr=None,
134 style=None,
135 ):
136 self.macro = macro
137 self.fPublished = fPublished
138 if nvPicPr is None:
139 nvPicPr = PictureNonVisual()
140 self.nvPicPr = nvPicPr
141 if blipFill is None:
142 blipFill = BlipFillProperties()
143 self.blipFill = blipFill
144 if spPr is None:
145 spPr = GraphicalProperties()
146 self.spPr = spPr
147 self.style = style