src/openpyxl/worksheet/controls.py
1# Copyright (c) 2010-2024 openpyxl
2
3from openpyxl.descriptors.serialisable import Serialisable
4from openpyxl.descriptors import (
5 Typed,
6 Bool,
7 Integer,
8 String,
9 Sequence,
10)
11
12from openpyxl.descriptors.excel import Relation
13from .ole import ObjectAnchor
14
15
16class ControlProperty(Serialisable):
17
18 tagname = "controlPr"
19
20 anchor = Typed(expected_type=ObjectAnchor, )
21 locked = Bool(allow_none=True)
22 defaultSize = Bool(allow_none=True)
23 _print = Bool(allow_none=True)
24 disabled = Bool(allow_none=True)
25 recalcAlways = Bool(allow_none=True)
26 uiObject = Bool(allow_none=True)
27 autoFill = Bool(allow_none=True)
28 autoLine = Bool(allow_none=True)
29 autoPict = Bool(allow_none=True)
30 macro = String(allow_none=True)
31 altText = String(allow_none=True)
32 linkedCell = String(allow_none=True)
33 listFillRange = String(allow_none=True)
34 cf = String(allow_none=True)
35 id = Relation(allow_none=True)
36
37 __elements__ = ('anchor',)
38
39 def __init__(self,
40 anchor=None,
41 locked=True,
42 defaultSize=True,
43 _print=True,
44 disabled=False,
45 recalcAlways=False,
46 uiObject=False,
47 autoFill=True,
48 autoLine=True,
49 autoPict=True,
50 macro=None,
51 altText=None,
52 linkedCell=None,
53 listFillRange=None,
54 cf='pict',
55 id=None,
56 ):
57 self.anchor = anchor
58 self.locked = locked
59 self.defaultSize = defaultSize
60 self._print = _print
61 self.disabled = disabled
62 self.recalcAlways = recalcAlways
63 self.uiObject = uiObject
64 self.autoFill = autoFill
65 self.autoLine = autoLine
66 self.autoPict = autoPict
67 self.macro = macro
68 self.altText = altText
69 self.linkedCell = linkedCell
70 self.listFillRange = listFillRange
71 self.cf = cf
72 self.id = id
73
74
75class Control(Serialisable):
76
77 tagname = "control"
78
79 controlPr = Typed(expected_type=ControlProperty, allow_none=True)
80 shapeId = Integer()
81 name = String(allow_none=True)
82
83 __elements__ = ('controlPr',)
84
85 def __init__(self,
86 controlPr=None,
87 shapeId=None,
88 name=None,
89 ):
90 self.controlPr = controlPr
91 self.shapeId = shapeId
92 self.name = name
93
94
95class Controls(Serialisable):
96
97 tagname = "controls"
98
99 control = Sequence(expected_type=Control)
100
101 __elements__ = ('control',)
102
103 def __init__(self,
104 control=(),
105 ):
106 self.control = control
107