controls.py 2.7 KB

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