properties.py 4.9 KB

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