Commit 3bd4d9a
committed
[BUGFIX] Respect language based style names on reading Word files
Microsoft Office saves Office document with language based style
mappings for default styles. For example, if a german based Word
version is used, it writes following to the `word/styles.xml` in
the container archive (*.docs):
```
<w:style w:type="paragraph" w:styleId="berschrift1">
<w:name w:val="heading 1"/>
....
</w:style>
```
versus for a english based version it would be:
```
<w:style w:type="paragraph" w:styleId="Heading1">
<w:name w:val="heading 1"/>
...
</w:style>
```
The value of `<w:name />` defines the internal native code
identifier, whereas the `w:styleId` attribute on the outer
`<w:style />` tag would describe the virtual or alias name.
Later parsing of the document structure, for example the
paragraphs, references the alias (`w:styleId`) name of a
style. The reader code uses hardcoded RegEx matchings in
a case-insensitive manner but using the englisch speaking
variant (`Header\s+d`) - on the language based one, which
would not match at all.
Therefore, multiple tasks need to be done and contained
in this change:
* A alias map is implementend and used to register title
aliases. Along with this corresponding lookup method is
added.
* Use the lookup method to resolve for alias where the
hardcoded language RegEx is needed to be used.
* Gathering all style alias names during reading the
wordfile styles settings for all possible styles.1 parent 8b891bb commit 3bd4d9a
File tree
3 files changed
+87
-11
lines changed- src/PhpWord
- Reader/Word2007
3 files changed
+87
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
293 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
294 | 301 | | |
295 | 302 | | |
296 | | - | |
297 | 303 | | |
298 | | - | |
| 304 | + | |
| 305 | + | |
299 | 306 | | |
300 | | - | |
| 307 | + | |
301 | 308 | | |
302 | 309 | | |
303 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
| |||
76 | 86 | | |
77 | 87 | | |
78 | 88 | | |
79 | | - | |
| 89 | + | |
| 90 | + | |
80 | 91 | | |
81 | 92 | | |
82 | 93 | | |
83 | | - | |
| 94 | + | |
| 95 | + | |
84 | 96 | | |
85 | 97 | | |
86 | | - | |
| 98 | + | |
| 99 | + | |
87 | 100 | | |
88 | 101 | | |
89 | 102 | | |
90 | 103 | | |
91 | 104 | | |
92 | 105 | | |
93 | 106 | | |
94 | | - | |
| 107 | + | |
| 108 | + | |
95 | 109 | | |
96 | 110 | | |
97 | 111 | | |
98 | 112 | | |
99 | 113 | | |
100 | 114 | | |
101 | | - | |
| 115 | + | |
| 116 | + | |
102 | 117 | | |
103 | 118 | | |
104 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
127 | 180 | | |
128 | 181 | | |
129 | 182 | | |
| |||
144 | 197 | | |
145 | 198 | | |
146 | 199 | | |
| 200 | + | |
147 | 201 | | |
148 | 202 | | |
149 | 203 | | |
| |||
0 commit comments