Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/chart/text.py: 52%
34 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1# Copyright (c) 2010-2022 openpyxl
2from openpyxl.descriptors.serialisable import Serialisable
3from openpyxl.descriptors import (
4 Typed,
5 Alias,
6 Sequence,
7)
10from openpyxl.drawing.text import (
11 RichTextProperties,
12 ListStyle,
13 Paragraph,
14)
16from .data_source import StrRef
19class RichText(Serialisable):
21 """
22 From the specification: 21.2.2.216
24 This element specifies text formatting. The lstStyle element is not supported.
25 """
27 tagname = "rich"
29 bodyPr = Typed(expected_type=RichTextProperties)
30 properties = Alias("bodyPr")
31 lstStyle = Typed(expected_type=ListStyle, allow_none=True)
32 p = Sequence(expected_type=Paragraph)
33 paragraphs = Alias('p')
35 __elements__ = ("bodyPr", "lstStyle", "p")
37 def __init__(self,
38 bodyPr=None,
39 lstStyle=None,
40 p=None,
41 ):
42 if bodyPr is None:
43 bodyPr = RichTextProperties()
44 self.bodyPr = bodyPr
45 self.lstStyle = lstStyle
46 if p is None:
47 p = [Paragraph()]
48 self.p = p
51class Text(Serialisable):
53 """
54 The value can be either a cell reference or a text element
55 If both are present then the reference will be used.
56 """
58 tagname = "tx"
60 strRef = Typed(expected_type=StrRef, allow_none=True)
61 rich = Typed(expected_type=RichText, allow_none=True)
63 __elements__ = ("strRef", "rich")
65 def __init__(self,
66 strRef=None,
67 rich=None
68 ):
69 self.strRef = strRef
70 if rich is None:
71 rich = RichText()
72 self.rich = rich
75 def to_tree(self, tagname=None, idx=None, namespace=None):
76 if self.strRef and self.rich:
77 self.rich = None # can only have one
78 return super(Text, self).to_tree(tagname, idx, namespace)