layout.py 2.0 KB

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