layout.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (c) 2010-2024 openpyxl
  2. from openpyxl.descriptors.serialisable import Serialisable
  3. from openpyxl.descriptors import (
  4. NoneSet,
  5. Float,
  6. Typed,
  7. Alias,
  8. )
  9. from openpyxl.descriptors.excel import ExtensionList
  10. from openpyxl.descriptors.nested import (
  11. NestedNoneSet,
  12. NestedSet,
  13. NestedMinMax,
  14. )
  15. class ManualLayout(Serialisable):
  16. tagname = "manualLayout"
  17. layoutTarget = NestedNoneSet(values=(['inner', 'outer']))
  18. xMode = NestedNoneSet(values=(['edge', 'factor']))
  19. yMode = NestedNoneSet(values=(['edge', 'factor']))
  20. wMode = NestedSet(values=(['edge', 'factor']))
  21. hMode = NestedSet(values=(['edge', 'factor']))
  22. x = NestedMinMax(min=-1, max=1, allow_none=True)
  23. y = NestedMinMax(min=-1, max=1, allow_none=True)
  24. w = NestedMinMax(min=0, max=1, allow_none=True)
  25. width = Alias('w')
  26. h = NestedMinMax(min=0, max=1, allow_none=True)
  27. height = Alias('h')
  28. extLst = Typed(expected_type=ExtensionList, allow_none=True)
  29. __elements__ = ('layoutTarget', 'xMode', 'yMode', 'wMode', 'hMode', 'x',
  30. 'y', 'w', 'h')
  31. def __init__(self,
  32. layoutTarget=None,
  33. xMode=None,
  34. yMode=None,
  35. wMode="factor",
  36. hMode="factor",
  37. x=None,
  38. y=None,
  39. w=None,
  40. h=None,
  41. extLst=None,
  42. ):
  43. self.layoutTarget = layoutTarget
  44. self.xMode = xMode
  45. self.yMode = yMode
  46. self.wMode = wMode
  47. self.hMode = hMode
  48. self.x = x
  49. self.y = y
  50. self.w = w
  51. self.h = h
  52. class Layout(Serialisable):
  53. tagname = "layout"
  54. manualLayout = Typed(expected_type=ManualLayout, allow_none=True)
  55. extLst = Typed(expected_type=ExtensionList, allow_none=True)
  56. __elements__ = ('manualLayout',)
  57. def __init__(self,
  58. manualLayout=None,
  59. extLst=None,
  60. ):
  61. self.manualLayout = manualLayout