Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/drawing/text.py: 64%
375 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
4from openpyxl.descriptors.serialisable import Serialisable
5from openpyxl.descriptors import (
6 Alias,
7 Typed,
8 Set,
9 NoneSet,
10 Sequence,
11 String,
12 Bool,
13 MinMax,
14 Integer
15)
16from openpyxl.descriptors.excel import (
17 HexBinary,
18 TextPoint,
19 Coordinate,
20 ExtensionList,
21 Relation,
22)
23from openpyxl.descriptors.nested import (
24 NestedInteger,
25 NestedString,
26 NestedText,
27 NestedValue,
28 EmptyTag
29)
30from openpyxl.xml.constants import DRAWING_NS
33from .colors import ColorChoiceDescriptor
34from .effect import *
35from .fill import *
36from .geometry import (
37 LineProperties,
38 Color,
39 Scene3D
40)
42from openpyxl.descriptors.excel import ExtensionList as OfficeArtExtensionList
43from openpyxl.descriptors.nested import NestedBool
46class EmbeddedWAVAudioFile(Serialisable):
48 name = String(allow_none=True)
50 def __init__(self,
51 name=None,
52 ):
53 self.name = name
56class Hyperlink(Serialisable):
58 tagname = "hlinkClick"
59 namespace = DRAWING_NS
61 invalidUrl = String(allow_none=True)
62 action = String(allow_none=True)
63 tgtFrame = String(allow_none=True)
64 tooltip = String(allow_none=True)
65 history = Bool(allow_none=True)
66 highlightClick = Bool(allow_none=True)
67 endSnd = Bool(allow_none=True)
68 snd = Typed(expected_type=EmbeddedWAVAudioFile, allow_none=True)
69 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
70 id = Relation(allow_none=True)
72 __elements__ = ('snd',)
74 def __init__(self,
75 invalidUrl=None,
76 action=None,
77 tgtFrame=None,
78 tooltip=None,
79 history=None,
80 highlightClick=None,
81 endSnd=None,
82 snd=None,
83 extLst=None,
84 id=None,
85 ):
86 self.invalidUrl = invalidUrl
87 self.action = action
88 self.tgtFrame = tgtFrame
89 self.tooltip = tooltip
90 self.history = history
91 self.highlightClick = highlightClick
92 self.endSnd = endSnd
93 self.snd = snd
94 self.id = id
97class Font(Serialisable):
99 tagname = "latin"
100 namespace = DRAWING_NS
102 typeface = String()
103 panose = HexBinary(allow_none=True)
104 pitchFamily = MinMax(min=0, max=52, allow_none=True)
105 charset = Integer(allow_none=True)
107 def __init__(self,
108 typeface=None,
109 panose=None,
110 pitchFamily=None,
111 charset=None,
112 ):
113 self.typeface = typeface
114 self.panose = panose
115 self.pitchFamily = pitchFamily
116 self.charset = charset
119class CharacterProperties(Serialisable):
121 tagname = "defRPr"
122 namespace = DRAWING_NS
124 kumimoji = Bool(allow_none=True)
125 lang = String(allow_none=True)
126 altLang = String(allow_none=True)
127 sz = MinMax(allow_none=True, min=100, max=400000) # 100ths of a point
128 b = Bool(allow_none=True)
129 i = Bool(allow_none=True)
130 u = NoneSet(values=(['words', 'sng', 'dbl', 'heavy', 'dotted',
131 'dottedHeavy', 'dash', 'dashHeavy', 'dashLong', 'dashLongHeavy',
132 'dotDash', 'dotDashHeavy', 'dotDotDash', 'dotDotDashHeavy', 'wavy',
133 'wavyHeavy', 'wavyDbl']))
134 strike = NoneSet(values=(['noStrike', 'sngStrike', 'dblStrike']))
135 kern = Integer(allow_none=True)
136 cap = NoneSet(values=(['small', 'all']))
137 spc = Integer(allow_none=True)
138 normalizeH = Bool(allow_none=True)
139 baseline = Integer(allow_none=True)
140 noProof = Bool(allow_none=True)
141 dirty = Bool(allow_none=True)
142 err = Bool(allow_none=True)
143 smtClean = Bool(allow_none=True)
144 smtId = Integer(allow_none=True)
145 bmk = String(allow_none=True)
146 ln = Typed(expected_type=LineProperties, allow_none=True)
147 highlight = Typed(expected_type=Color, allow_none=True)
148 latin = Typed(expected_type=Font, allow_none=True)
149 ea = Typed(expected_type=Font, allow_none=True)
150 cs = Typed(expected_type=Font, allow_none=True)
151 sym = Typed(expected_type=Font, allow_none=True)
152 hlinkClick = Typed(expected_type=Hyperlink, allow_none=True)
153 hlinkMouseOver = Typed(expected_type=Hyperlink, allow_none=True)
154 rtl = NestedBool(allow_none=True)
155 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
156 # uses element group EG_FillProperties
157 noFill = EmptyTag(namespace=DRAWING_NS)
158 solidFill = ColorChoiceDescriptor()
159 gradFill = Typed(expected_type=GradientFillProperties, allow_none=True)
160 blipFill = Typed(expected_type=BlipFillProperties, allow_none=True)
161 pattFill = Typed(expected_type=PatternFillProperties, allow_none=True)
162 grpFill = EmptyTag(namespace=DRAWING_NS)
163 # uses element group EG_EffectProperties
164 effectLst = Typed(expected_type=EffectList, allow_none=True)
165 effectDag = Typed(expected_type=EffectContainer, allow_none=True)
166 # uses element group EG_TextUnderlineLine
167 uLnTx = EmptyTag()
168 uLn = Typed(expected_type=LineProperties, allow_none=True)
169 # uses element group EG_TextUnderlineFill
170 uFillTx = EmptyTag()
171 uFill = EmptyTag()
173 __elements__ = ('ln', 'noFill', 'solidFill', 'gradFill', 'blipFill',
174 'pattFill', 'grpFill', 'effectLst', 'effectDag', 'highlight','uLnTx',
175 'uLn', 'uFillTx', 'uFill', 'latin', 'ea', 'cs', 'sym', 'hlinkClick',
176 'hlinkMouseOver', 'rtl', )
178 def __init__(self,
179 kumimoji=None,
180 lang=None,
181 altLang=None,
182 sz=None,
183 b=None,
184 i=None,
185 u=None,
186 strike=None,
187 kern=None,
188 cap=None,
189 spc=None,
190 normalizeH=None,
191 baseline=None,
192 noProof=None,
193 dirty=None,
194 err=None,
195 smtClean=None,
196 smtId=None,
197 bmk=None,
198 ln=None,
199 highlight=None,
200 latin=None,
201 ea=None,
202 cs=None,
203 sym=None,
204 hlinkClick=None,
205 hlinkMouseOver=None,
206 rtl=None,
207 extLst=None,
208 noFill=None,
209 solidFill=None,
210 gradFill=None,
211 blipFill=None,
212 pattFill=None,
213 grpFill=None,
214 effectLst=None,
215 effectDag=None,
216 uLnTx=None,
217 uLn=None,
218 uFillTx=None,
219 uFill=None,
220 ):
221 self.kumimoji = kumimoji
222 self.lang = lang
223 self.altLang = altLang
224 self.sz = sz
225 self.b = b
226 self.i = i
227 self.u = u
228 self.strike = strike
229 self.kern = kern
230 self.cap = cap
231 self.spc = spc
232 self.normalizeH = normalizeH
233 self.baseline = baseline
234 self.noProof = noProof
235 self.dirty = dirty
236 self.err = err
237 self.smtClean = smtClean
238 self.smtId = smtId
239 self.bmk = bmk
240 self.ln = ln
241 self.highlight = highlight
242 self.latin = latin
243 self.ea = ea
244 self.cs = cs
245 self.sym = sym
246 self.hlinkClick = hlinkClick
247 self.hlinkMouseOver = hlinkMouseOver
248 self.rtl = rtl
249 self.noFill = noFill
250 self.solidFill = solidFill
251 self.gradFill = gradFill
252 self.blipFill = blipFill
253 self.pattFill = pattFill
254 self.grpFill = grpFill
255 self.effectLst = effectLst
256 self.effectDag = effectDag
257 self.uLnTx = uLnTx
258 self.uLn = uLn
259 self.uFillTx = uFillTx
260 self.uFill = uFill
263class TabStop(Serialisable):
265 pos = Typed(expected_type=Coordinate, allow_none=True)
266 algn = Typed(expected_type=Set(values=(['l', 'ctr', 'r', 'dec'])))
268 def __init__(self,
269 pos=None,
270 algn=None,
271 ):
272 self.pos = pos
273 self.algn = algn
276class TabStopList(Serialisable):
278 tab = Typed(expected_type=TabStop, allow_none=True)
280 def __init__(self,
281 tab=None,
282 ):
283 self.tab = tab
286class Spacing(Serialisable):
288 spcPct = NestedInteger(allow_none=True)
289 spcPts = NestedInteger(allow_none=True)
291 __elements__ = ('spcPct', 'spcPts')
293 def __init__(self,
294 spcPct=None,
295 spcPts=None,
296 ):
297 self.spcPct = spcPct
298 self.spcPts = spcPts
301class AutonumberBullet(Serialisable):
303 type = Set(values=(['alphaLcParenBoth', 'alphaUcParenBoth',
304 'alphaLcParenR', 'alphaUcParenR', 'alphaLcPeriod', 'alphaUcPeriod',
305 'arabicParenBoth', 'arabicParenR', 'arabicPeriod', 'arabicPlain',
306 'romanLcParenBoth', 'romanUcParenBoth', 'romanLcParenR', 'romanUcParenR',
307 'romanLcPeriod', 'romanUcPeriod', 'circleNumDbPlain',
308 'circleNumWdBlackPlain', 'circleNumWdWhitePlain', 'arabicDbPeriod',
309 'arabicDbPlain', 'ea1ChsPeriod', 'ea1ChsPlain', 'ea1ChtPeriod',
310 'ea1ChtPlain', 'ea1JpnChsDbPeriod', 'ea1JpnKorPlain', 'ea1JpnKorPeriod',
311 'arabic1Minus', 'arabic2Minus', 'hebrew2Minus', 'thaiAlphaPeriod',
312 'thaiAlphaParenR', 'thaiAlphaParenBoth', 'thaiNumPeriod',
313 'thaiNumParenR', 'thaiNumParenBoth', 'hindiAlphaPeriod',
314 'hindiNumPeriod', 'hindiNumParenR', 'hindiAlpha1Period']))
315 startAt = Integer()
317 def __init__(self,
318 type=None,
319 startAt=None,
320 ):
321 self.type = type
322 self.startAt = startAt
325class ParagraphProperties(Serialisable):
327 tagname = "pPr"
328 namespace = DRAWING_NS
330 marL = Integer(allow_none=True)
331 marR = Integer(allow_none=True)
332 lvl = Integer(allow_none=True)
333 indent = Integer(allow_none=True)
334 algn = NoneSet(values=(['l', 'ctr', 'r', 'just', 'justLow', 'dist', 'thaiDist']))
335 defTabSz = Integer(allow_none=True)
336 rtl = Bool(allow_none=True)
337 eaLnBrk = Bool(allow_none=True)
338 fontAlgn = NoneSet(values=(['auto', 't', 'ctr', 'base', 'b']))
339 latinLnBrk = Bool(allow_none=True)
340 hangingPunct = Bool(allow_none=True)
342 # uses element group EG_TextBulletColor
343 # uses element group EG_TextBulletSize
344 # uses element group EG_TextBulletTypeface
345 # uses element group EG_TextBullet
346 lnSpc = Typed(expected_type=Spacing, allow_none=True)
347 spcBef = Typed(expected_type=Spacing, allow_none=True)
348 spcAft = Typed(expected_type=Spacing, allow_none=True)
349 tabLst = Typed(expected_type=TabStopList, allow_none=True)
350 defRPr = Typed(expected_type=CharacterProperties, allow_none=True)
351 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
352 buClrTx = EmptyTag()
353 buClr = Typed(expected_type=Color, allow_none=True)
354 buSzTx = EmptyTag()
355 buSzPct = NestedInteger(allow_none=True)
356 buSzPts = NestedInteger(allow_none=True)
357 buFontTx = EmptyTag()
358 buFont = Typed(expected_type=Font, allow_none=True)
359 buNone = EmptyTag()
360 buAutoNum = EmptyTag()
361 buChar = NestedValue(expected_type=str, attribute="char", allow_none=True)
362 buBlip = NestedValue(expected_type=Blip, attribute="blip", allow_none=True)
364 __elements__ = ('lnSpc', 'spcBef', 'spcAft', 'tabLst', 'defRPr',
365 'buClrTx', 'buClr', 'buSzTx', 'buSzPct', 'buSzPts', 'buFontTx', 'buFont',
366 'buNone', 'buAutoNum', 'buChar', 'buBlip')
368 def __init__(self,
369 marL=None,
370 marR=None,
371 lvl=None,
372 indent=None,
373 algn=None,
374 defTabSz=None,
375 rtl=None,
376 eaLnBrk=None,
377 fontAlgn=None,
378 latinLnBrk=None,
379 hangingPunct=None,
380 lnSpc=None,
381 spcBef=None,
382 spcAft=None,
383 tabLst=None,
384 defRPr=None,
385 extLst=None,
386 buClrTx=None,
387 buClr=None,
388 buSzTx=None,
389 buSzPct=None,
390 buSzPts=None,
391 buFontTx=None,
392 buFont=None,
393 buNone=None,
394 buAutoNum=None,
395 buChar=None,
396 buBlip=None,
397 ):
398 self.marL = marL
399 self.marR = marR
400 self.lvl = lvl
401 self.indent = indent
402 self.algn = algn
403 self.defTabSz = defTabSz
404 self.rtl = rtl
405 self.eaLnBrk = eaLnBrk
406 self.fontAlgn = fontAlgn
407 self.latinLnBrk = latinLnBrk
408 self.hangingPunct = hangingPunct
409 self.lnSpc = lnSpc
410 self.spcBef = spcBef
411 self.spcAft = spcAft
412 self.tabLst = tabLst
413 self.defRPr = defRPr
414 self.buClrTx = buClrTx
415 self.buClr = buClr
416 self.buSzTx = buSzTx
417 self.buSzPct = buSzPct
418 self.buSzPts = buSzPts
419 self.buFontTx = buFontTx
420 self.buFont = buFont
421 self.buNone = buNone
422 self.buAutoNum = buAutoNum
423 self.buChar = buChar
424 self.buBlip = buBlip
425 self.defRPr = defRPr
428class ListStyle(Serialisable):
430 tagname = "lstStyle"
431 namespace = DRAWING_NS
433 defPPr = Typed(expected_type=ParagraphProperties, allow_none=True)
434 lvl1pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
435 lvl2pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
436 lvl3pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
437 lvl4pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
438 lvl5pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
439 lvl6pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
440 lvl7pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
441 lvl8pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
442 lvl9pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
443 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
445 __elements__ = ("defPPr", "lvl1pPr", "lvl2pPr", "lvl3pPr", "lvl4pPr",
446 "lvl5pPr", "lvl6pPr", "lvl7pPr", "lvl8pPr", "lvl9pPr")
448 def __init__(self,
449 defPPr=None,
450 lvl1pPr=None,
451 lvl2pPr=None,
452 lvl3pPr=None,
453 lvl4pPr=None,
454 lvl5pPr=None,
455 lvl6pPr=None,
456 lvl7pPr=None,
457 lvl8pPr=None,
458 lvl9pPr=None,
459 extLst=None,
460 ):
461 self.defPPr = defPPr
462 self.lvl1pPr = lvl1pPr
463 self.lvl2pPr = lvl2pPr
464 self.lvl3pPr = lvl3pPr
465 self.lvl4pPr = lvl4pPr
466 self.lvl5pPr = lvl5pPr
467 self.lvl6pPr = lvl6pPr
468 self.lvl7pPr = lvl7pPr
469 self.lvl8pPr = lvl8pPr
470 self.lvl9pPr = lvl9pPr
473class RegularTextRun(Serialisable):
475 tagname = "r"
476 namespace = DRAWING_NS
478 rPr = Typed(expected_type=CharacterProperties, allow_none=True)
479 properties = Alias("rPr")
480 t = NestedText(expected_type=str)
481 value = Alias("t")
483 __elements__ = ('rPr', 't')
485 def __init__(self,
486 rPr=None,
487 t="",
488 ):
489 self.rPr = rPr
490 self.t = t
493class LineBreak(Serialisable):
495 tagname = "br"
496 namespace = DRAWING_NS
498 rPr = Typed(expected_type=CharacterProperties, allow_none=True)
500 __elements__ = ('rPr',)
502 def __init__(self,
503 rPr=None,
504 ):
505 self.rPr = rPr
508class TextField(Serialisable):
510 id = String()
511 type = String(allow_none=True)
512 rPr = Typed(expected_type=CharacterProperties, allow_none=True)
513 pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
514 t = String(allow_none=True)
516 __elements__ = ('rPr', 'pPr')
518 def __init__(self,
519 id=None,
520 type=None,
521 rPr=None,
522 pPr=None,
523 t=None,
524 ):
525 self.id = id
526 self.type = type
527 self.rPr = rPr
528 self.pPr = pPr
529 self.t = t
532class Paragraph(Serialisable):
534 tagname = "p"
535 namespace = DRAWING_NS
537 # uses element group EG_TextRun
538 pPr = Typed(expected_type=ParagraphProperties, allow_none=True)
539 properties = Alias("pPr")
540 endParaRPr = Typed(expected_type=CharacterProperties, allow_none=True)
541 r = Sequence(expected_type=RegularTextRun)
542 text = Alias('r')
543 br = Typed(expected_type=LineBreak, allow_none=True)
544 fld = Typed(expected_type=TextField, allow_none=True)
546 __elements__ = ('pPr', 'r', 'br', 'fld', 'endParaRPr')
548 def __init__(self,
549 pPr=None,
550 endParaRPr=None,
551 r=None,
552 br=None,
553 fld=None,
554 ):
555 self.pPr = pPr
556 self.endParaRPr = endParaRPr
557 if r is None:
558 r = [RegularTextRun()]
559 self.r = r
560 self.br = br
561 self.fld = fld
564class GeomGuide(Serialisable):
566 name = String(())
567 fmla = String(())
569 def __init__(self,
570 name=None,
571 fmla=None,
572 ):
573 self.name = name
574 self.fmla = fmla
577class GeomGuideList(Serialisable):
579 gd = Sequence(expected_type=GeomGuide, allow_none=True)
581 def __init__(self,
582 gd=None,
583 ):
584 self.gd = gd
587class PresetTextShape(Serialisable):
589 prst = Typed(expected_type=Set(values=(
590 ['textNoShape', 'textPlain','textStop', 'textTriangle', 'textTriangleInverted', 'textChevron',
591 'textChevronInverted', 'textRingInside', 'textRingOutside', 'textArchUp',
592 'textArchDown', 'textCircle', 'textButton', 'textArchUpPour',
593 'textArchDownPour', 'textCirclePour', 'textButtonPour', 'textCurveUp',
594 'textCurveDown', 'textCanUp', 'textCanDown', 'textWave1', 'textWave2',
595 'textDoubleWave1', 'textWave4', 'textInflate', 'textDeflate',
596 'textInflateBottom', 'textDeflateBottom', 'textInflateTop',
597 'textDeflateTop', 'textDeflateInflate', 'textDeflateInflateDeflate',
598 'textFadeRight', 'textFadeLeft', 'textFadeUp', 'textFadeDown',
599 'textSlantUp', 'textSlantDown', 'textCascadeUp', 'textCascadeDown'
600 ]
601 )))
602 avLst = Typed(expected_type=GeomGuideList, allow_none=True)
604 def __init__(self,
605 prst=None,
606 avLst=None,
607 ):
608 self.prst = prst
609 self.avLst = avLst
612class TextNormalAutofit(Serialisable):
614 fontScale = Integer()
615 lnSpcReduction = Integer()
617 def __init__(self,
618 fontScale=None,
619 lnSpcReduction=None,
620 ):
621 self.fontScale = fontScale
622 self.lnSpcReduction = lnSpcReduction
625class RichTextProperties(Serialisable):
627 tagname = "bodyPr"
628 namespace = DRAWING_NS
630 rot = Integer(allow_none=True)
631 spcFirstLastPara = Bool(allow_none=True)
632 vertOverflow = NoneSet(values=(['overflow', 'ellipsis', 'clip']))
633 horzOverflow = NoneSet(values=(['overflow', 'clip']))
634 vert = NoneSet(values=(['horz', 'vert', 'vert270', 'wordArtVert',
635 'eaVert', 'mongolianVert', 'wordArtVertRtl']))
636 wrap = NoneSet(values=(['none', 'square']))
637 lIns = Integer(allow_none=True)
638 tIns = Integer(allow_none=True)
639 rIns = Integer(allow_none=True)
640 bIns = Integer(allow_none=True)
641 numCol = Integer(allow_none=True)
642 spcCol = Integer(allow_none=True)
643 rtlCol = Bool(allow_none=True)
644 fromWordArt = Bool(allow_none=True)
645 anchor = NoneSet(values=(['t', 'ctr', 'b', 'just', 'dist']))
646 anchorCtr = Bool(allow_none=True)
647 forceAA = Bool(allow_none=True)
648 upright = Bool(allow_none=True)
649 compatLnSpc = Bool(allow_none=True)
650 prstTxWarp = Typed(expected_type=PresetTextShape, allow_none=True)
651 scene3d = Typed(expected_type=Scene3D, allow_none=True)
652 extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True)
653 noAutofit = EmptyTag()
654 normAutofit = EmptyTag()
655 spAutoFit = EmptyTag()
656 flatTx = NestedInteger(attribute="z", allow_none=True)
658 __elements__ = ('prstTxWarp', 'scene3d', 'noAutofit', 'normAutofit', 'spAutoFit')
660 def __init__(self,
661 rot=None,
662 spcFirstLastPara=None,
663 vertOverflow=None,
664 horzOverflow=None,
665 vert=None,
666 wrap=None,
667 lIns=None,
668 tIns=None,
669 rIns=None,
670 bIns=None,
671 numCol=None,
672 spcCol=None,
673 rtlCol=None,
674 fromWordArt=None,
675 anchor=None,
676 anchorCtr=None,
677 forceAA=None,
678 upright=None,
679 compatLnSpc=None,
680 prstTxWarp=None,
681 scene3d=None,
682 extLst=None,
683 noAutofit=None,
684 normAutofit=None,
685 spAutoFit=None,
686 flatTx=None,
687 ):
688 self.rot = rot
689 self.spcFirstLastPara = spcFirstLastPara
690 self.vertOverflow = vertOverflow
691 self.horzOverflow = horzOverflow
692 self.vert = vert
693 self.wrap = wrap
694 self.lIns = lIns
695 self.tIns = tIns
696 self.rIns = rIns
697 self.bIns = bIns
698 self.numCol = numCol
699 self.spcCol = spcCol
700 self.rtlCol = rtlCol
701 self.fromWordArt = fromWordArt
702 self.anchor = anchor
703 self.anchorCtr = anchorCtr
704 self.forceAA = forceAA
705 self.upright = upright
706 self.compatLnSpc = compatLnSpc
707 self.prstTxWarp = prstTxWarp
708 self.scene3d = scene3d
709 self.noAutofit = noAutofit
710 self.normAutofit = normAutofit
711 self.spAutoFit = spAutoFit
712 self.flatTx = flatTx