properties.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. # Copyright (c) 2010-2024 openpyxl
  2. from openpyxl.xml.constants import DRAWING_NS
  3. from openpyxl.descriptors.serialisable import Serialisable
  4. from openpyxl.descriptors import (
  5. Typed,
  6. Bool,
  7. Integer,
  8. Set,
  9. String,
  10. Alias,
  11. NoneSet,
  12. )
  13. from openpyxl.descriptors.excel import ExtensionList as OfficeArtExtensionList
  14. from .geometry import GroupTransform2D, Scene3D
  15. from .text import Hyperlink
  16. class GroupShapeProperties(Serialisable):
  17. tagname = "grpSpPr"
  18. bwMode = NoneSet(values=(['clr', 'auto', 'gray', 'ltGray', 'invGray',
  19. 'grayWhite', 'blackGray', 'blackWhite', 'black', 'white', 'hidden']))
  20. xfrm = Typed(expected_type=GroupTransform2D, allow_none=True)
  21. scene3d = Typed(expected_type=Scene3D, allow_none=True)
  22. extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
  23. def __init__(self,
  24. bwMode=None,
  25. xfrm=None,
  26. scene3d=None,
  27. extLst=None,
  28. ):
  29. self.bwMode = bwMode
  30. self.xfrm = xfrm
  31. self.scene3d = scene3d
  32. self.extLst = extLst
  33. class GroupLocking(Serialisable):
  34. tagname = "grpSpLocks"
  35. namespace = DRAWING_NS
  36. noGrp = Bool(allow_none=True)
  37. noUngrp = Bool(allow_none=True)
  38. noSelect = Bool(allow_none=True)
  39. noRot = Bool(allow_none=True)
  40. noChangeAspect = Bool(allow_none=True)
  41. noMove = Bool(allow_none=True)
  42. noResize = Bool(allow_none=True)
  43. noChangeArrowheads = Bool(allow_none=True)
  44. noEditPoints = Bool(allow_none=True)
  45. noAdjustHandles = Bool(allow_none=True)
  46. noChangeArrowheads = Bool(allow_none=True)
  47. noChangeShapeType = Bool(allow_none=True)
  48. extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
  49. __elements__ = ()
  50. def __init__(self,
  51. noGrp=None,
  52. noUngrp=None,
  53. noSelect=None,
  54. noRot=None,
  55. noChangeAspect=None,
  56. noChangeArrowheads=None,
  57. noMove=None,
  58. noResize=None,
  59. noEditPoints=None,
  60. noAdjustHandles=None,
  61. noChangeShapeType=None,
  62. extLst=None,
  63. ):
  64. self.noGrp = noGrp
  65. self.noUngrp = noUngrp
  66. self.noSelect = noSelect
  67. self.noRot = noRot
  68. self.noChangeAspect = noChangeAspect
  69. self.noChangeArrowheads = noChangeArrowheads
  70. self.noMove = noMove
  71. self.noResize = noResize
  72. self.noEditPoints = noEditPoints
  73. self.noAdjustHandles = noAdjustHandles
  74. self.noChangeShapeType = noChangeShapeType
  75. class NonVisualGroupDrawingShapeProps(Serialisable):
  76. tagname = "cNvGrpSpPr"
  77. grpSpLocks = Typed(expected_type=GroupLocking, allow_none=True)
  78. extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
  79. __elements__ = ("grpSpLocks",)
  80. def __init__(self,
  81. grpSpLocks=None,
  82. extLst=None,
  83. ):
  84. self.grpSpLocks = grpSpLocks
  85. class NonVisualDrawingShapeProps(Serialisable):
  86. tagname = "cNvSpPr"
  87. spLocks = Typed(expected_type=GroupLocking, allow_none=True)
  88. txBax = Bool(allow_none=True)
  89. extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
  90. __elements__ = ("spLocks", "txBax")
  91. def __init__(self,
  92. spLocks=None,
  93. txBox=None,
  94. extLst=None,
  95. ):
  96. self.spLocks = spLocks
  97. self.txBox = txBox
  98. class NonVisualDrawingProps(Serialisable):
  99. tagname = "cNvPr"
  100. id = Integer()
  101. name = String()
  102. descr = String(allow_none=True)
  103. hidden = Bool(allow_none=True)
  104. title = String(allow_none=True)
  105. hlinkClick = Typed(expected_type=Hyperlink, allow_none=True)
  106. hlinkHover = Typed(expected_type=Hyperlink, allow_none=True)
  107. extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
  108. __elements__ = ["hlinkClick", "hlinkHover"]
  109. def __init__(self,
  110. id=None,
  111. name=None,
  112. descr=None,
  113. hidden=None,
  114. title=None,
  115. hlinkClick=None,
  116. hlinkHover=None,
  117. extLst=None,
  118. ):
  119. self.id = id
  120. self.name = name
  121. self.descr = descr
  122. self.hidden = hidden
  123. self.title = title
  124. self.hlinkClick = hlinkClick
  125. self.hlinkHover = hlinkHover
  126. self.extLst = extLst
  127. class NonVisualGroupShape(Serialisable):
  128. tagname = "nvGrpSpPr"
  129. cNvPr = Typed(expected_type=NonVisualDrawingProps)
  130. cNvGrpSpPr = Typed(expected_type=NonVisualGroupDrawingShapeProps)
  131. __elements__ = ("cNvPr", "cNvGrpSpPr")
  132. def __init__(self,
  133. cNvPr=None,
  134. cNvGrpSpPr=None,
  135. ):
  136. self.cNvPr = cNvPr
  137. self.cNvGrpSpPr = cNvGrpSpPr