Source code

Download source archive ↓

src/openpyxl/chart/layout.py

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