controls.py 2.7 KB

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