|
8 | 8 |
|
9 | 9 | from . import OxmlElement |
10 | 10 | from .ns import qn |
11 | | -from .simpletypes import ST_DecimalNumber, ST_OnOff |
| 11 | +from .simpletypes import ST_DecimalNumber, ST_OnOff, ST_String |
12 | 12 | from .xmlchemy import BaseOxmlElement, OptionalAttribute, RequiredAttribute |
13 | 13 |
|
14 | 14 |
|
@@ -42,34 +42,34 @@ class CT_String(BaseOxmlElement): |
42 | 42 | Used for ``<w:pStyle>`` and ``<w:tblStyle>`` elements and others, |
43 | 43 | containing a style name in its ``val`` attribute. |
44 | 44 | """ |
| 45 | + val = RequiredAttribute('w:val', ST_String) |
| 46 | + |
45 | 47 | @classmethod |
46 | 48 | def new(cls, nsptagname, val): |
47 | 49 | """ |
48 | 50 | Return a new ``CT_String`` element with tagname *nsptagname* and |
49 | 51 | ``val`` attribute set to *val*. |
50 | 52 | """ |
51 | | - return OxmlElement(nsptagname, attrs={qn('w:val'): val}) |
| 53 | + elm = OxmlElement(nsptagname) |
| 54 | + elm.val = val |
| 55 | + return elm |
52 | 56 |
|
53 | 57 | @classmethod |
54 | 58 | def new_pStyle(cls, val): |
55 | 59 | """ |
56 | 60 | Return a new ``<w:pStyle>`` element with ``val`` attribute set to |
57 | 61 | *val*. |
58 | 62 | """ |
59 | | - return OxmlElement('w:pStyle', attrs={qn('w:val'): val}) |
| 63 | + pStyle = OxmlElement('w:pStyle') |
| 64 | + pStyle.val = val |
| 65 | + return pStyle |
60 | 66 |
|
61 | 67 | @classmethod |
62 | 68 | def new_rStyle(cls, val): |
63 | 69 | """ |
64 | 70 | Return a new ``<w:rStyle>`` element with ``val`` attribute set to |
65 | 71 | *val*. |
66 | 72 | """ |
67 | | - return OxmlElement('w:rStyle', attrs={qn('w:val'): val}) |
68 | | - |
69 | | - @property |
70 | | - def val(self): |
71 | | - return self.get(qn('w:val')) |
72 | | - |
73 | | - @val.setter |
74 | | - def val(self, val): |
75 | | - return self.set(qn('w:val'), val) |
| 73 | + rStyle = OxmlElement('w:rStyle') |
| 74 | + rStyle.val = val |
| 75 | + return rStyle |
0 commit comments