@docx4j/core-ts 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +4 -0
- package/README.md +32 -4
- package/dist/html/convert.mjs +2 -1
- package/dist/html/elements.mjs +2 -1
- package/dist/model/color/ColorMath.d.mts +29 -0
- package/dist/model/color/ColorMath.mjs +146 -0
- package/dist/model/color/ColorTables.d.mts +6 -0
- package/dist/model/color/ColorTables.mjs +83 -0
- package/dist/model/color/DrawingMLColors.d.mts +52 -0
- package/dist/model/color/DrawingMLColors.mjs +374 -0
- package/dist/model/color/ResolvedColor.d.mts +36 -0
- package/dist/model/color/ResolvedColor.mjs +65 -0
- package/dist/model/color/SpreadsheetColors.d.mts +36 -0
- package/dist/model/color/SpreadsheetColors.mjs +84 -0
- package/dist/model/color/StyleFill.d.mts +28 -0
- package/dist/model/color/StyleFill.mjs +21 -0
- package/dist/model/color/ThemeColors.d.mts +86 -0
- package/dist/model/color/ThemeColors.mjs +304 -0
- package/dist/model/color/WordColors.d.mts +71 -0
- package/dist/model/color/WordColors.mjs +121 -0
- package/dist/model/color/index.d.mts +6 -0
- package/dist/model/color/index.mjs +30 -0
- package/dist/model/content/Body.d.mts +145 -23
- package/dist/model/content/Body.mjs +509 -141
- package/dist/model/content/Comment.d.mts +21 -3
- package/dist/model/content/Comment.mjs +195 -19
- package/dist/model/content/ContentControl.d.mts +197 -18
- package/dist/model/content/ContentControl.mjs +664 -95
- package/dist/model/content/Font.d.mts +67 -17
- package/dist/model/content/Font.mjs +114 -35
- package/dist/model/content/InlinePicture.d.mts +11 -0
- package/dist/model/content/InlinePicture.mjs +21 -1
- package/dist/model/content/List.mjs +3 -0
- package/dist/model/content/Paragraph.d.mts +189 -13
- package/dist/model/content/Paragraph.mjs +870 -74
- package/dist/model/content/Range.d.mts +227 -12
- package/dist/model/content/Range.mjs +785 -59
- package/dist/model/content/ResolvedView.d.mts +104 -0
- package/dist/model/content/ResolvedView.mjs +596 -0
- package/dist/model/content/Table.d.mts +29 -3
- package/dist/model/content/Table.mjs +109 -33
- package/dist/model/content/TrackedChange.d.mts +172 -13
- package/dist/model/content/TrackedChange.mjs +728 -167
- package/dist/model/content/comments.d.mts +20 -6
- package/dist/model/content/comments.mjs +67 -57
- package/dist/model/content/generalException.d.mts +18 -0
- package/dist/model/content/generalException.mjs +24 -0
- package/dist/model/content/index.d.mts +8 -3
- package/dist/model/content/index.mjs +7 -2
- package/dist/model/content/mathText.d.mts +21 -0
- package/dist/model/content/mathText.mjs +267 -0
- package/dist/model/content/officeText.d.mts +27 -0
- package/dist/model/content/officeText.mjs +74 -0
- package/dist/model/content/outline.d.mts +5 -0
- package/dist/model/content/outline.mjs +13 -0
- package/dist/model/content/placeholders.d.mts +110 -0
- package/dist/model/content/placeholders.mjs +253 -0
- package/dist/model/content/search.d.mts +72 -0
- package/dist/model/content/search.mjs +204 -2
- package/dist/model/content/spanEdits.d.mts +159 -0
- package/dist/model/content/spanEdits.mjs +728 -0
- package/dist/model/content/story.d.mts +44 -0
- package/dist/model/content/story.mjs +92 -0
- package/dist/model/content/tableColumns.d.mts +1 -1
- package/dist/model/content/tableColumns.mjs +108 -80
- package/dist/model/content/tableRevisions.d.mts +11 -3
- package/dist/model/content/tableRevisions.mjs +72 -42
- package/dist/model/content/tableRules.d.mts +30 -0
- package/dist/model/content/tableRules.mjs +100 -0
- package/dist/model/content/textBoxes.d.mts +18 -0
- package/dist/model/content/textBoxes.mjs +105 -0
- package/dist/model/content/trackedChangeFilter.d.mts +39 -0
- package/dist/model/content/trackedChangeFilter.mjs +81 -0
- package/dist/model/content/tracking.d.mts +28 -0
- package/dist/model/content/tracking.mjs +149 -10
- package/dist/model/content/tree.d.mts +171 -22
- package/dist/model/content/tree.mjs +329 -53
- package/dist/model/customxml/CustomXmlPartCollection.d.mts +8 -0
- package/dist/model/customxml/CustomXmlPartCollection.mjs +34 -11
- package/dist/model/customxml/XmlMapping.d.mts +1 -1
- package/dist/model/customxml/XmlMapping.mjs +11 -0
- package/dist/model/customxml/bindings.d.mts +21 -2
- package/dist/model/customxml/bindings.mjs +76 -32
- package/dist/model/customxml/kinds.d.mts +8 -3
- package/dist/model/customxml/kinds.mjs +26 -5
- package/dist/model/customxml/picturePlaceholder.d.mts +17 -0
- package/dist/model/customxml/picturePlaceholder.mjs +32 -0
- package/dist/model/customxml/pictures.d.mts +4 -3
- package/dist/model/customxml/pictures.mjs +18 -6
- package/dist/model/customxml/xhtml.mjs +8 -2
- package/dist/model/index.d.mts +2 -0
- package/dist/model/index.mjs +4 -0
- package/dist/model/listnumbering/Emulator.d.mts +37 -5
- package/dist/model/listnumbering/Emulator.mjs +63 -9
- package/dist/model/properties/PropertyResolver.d.mts +60 -1
- package/dist/model/properties/PropertyResolver.mjs +115 -2
- package/dist/model/properties/catalogue.d.mts +19 -5
- package/dist/model/properties/catalogue.mjs +41 -15
- package/dist/model/properties/log.d.mts +1 -1
- package/dist/model/properties/log.mjs +5 -5
- package/dist/model/properties/table.mjs +4 -2
- package/dist/model/text/Extractor.d.mts +289 -0
- package/dist/model/text/Extractor.mjs +2162 -0
- package/dist/model/text/LinkTargets.d.mts +45 -0
- package/dist/model/text/LinkTargets.mjs +170 -0
- package/dist/model/text/MarkdownExporter.d.mts +140 -0
- package/dist/model/text/MarkdownExporter.mjs +255 -0
- package/dist/model/text/PlainText.d.mts +29 -0
- package/dist/model/text/PlainText.mjs +539 -0
- package/dist/model/text/TextContext.d.mts +161 -0
- package/dist/model/text/TextContext.mjs +425 -0
- package/dist/model/text/TextOptions.d.mts +150 -0
- package/dist/model/text/TextOptions.mjs +278 -0
- package/dist/model/text/TextResult.d.mts +504 -0
- package/dist/model/text/TextResult.mjs +526 -0
- package/dist/model/text/Texts.d.mts +99 -0
- package/dist/model/text/Texts.mjs +187 -0
- package/dist/model/text/WmlToMarkdown.d.mts +120 -0
- package/dist/model/text/WmlToMarkdown.mjs +911 -0
- package/dist/model/text/commonmark.d.mts +121 -0
- package/dist/model/text/commonmark.mjs +655 -0
- package/dist/model/text/index.d.mts +7 -0
- package/dist/model/text/index.mjs +8 -0
- package/dist/model/text/normalize.d.mts +8 -0
- package/dist/model/text/normalize.mjs +13 -0
- package/dist/model/text/outline.d.mts +4 -0
- package/dist/model/text/outline.mjs +71 -0
- package/dist/office-js/fragment.d.mts +7 -5
- package/dist/office-js/fragment.mjs +63 -14
- package/dist/office-js/proxy.d.mts +8 -0
- package/dist/office-js/proxy.mjs +29 -0
- package/dist/office-js/run.mjs +2 -0
- package/dist/office-js/supported.generated.mjs +16 -0
- package/dist/office-js/toApiScript.mjs +21 -5
- package/dist/opc/Save.d.mts +17 -0
- package/dist/opc/Save.mjs +12 -2
- package/dist/opc/index.d.mts +3 -3
- package/dist/opc/index.mjs +1 -1
- package/dist/opc/mce/preprocessor.d.mts +28 -3
- package/dist/opc/mce/preprocessor.mjs +4 -4
- package/dist/opc/mce/understood.d.mts +30 -6
- package/dist/opc/mce/understood.mjs +37 -7
- package/dist/packages/OpcPackage.d.mts +13 -0
- package/dist/packages/OpcPackage.mjs +1 -0
- package/dist/packages/WordprocessingMLPackage.d.mts +45 -8
- package/dist/packages/WordprocessingMLPackage.mjs +155 -20
- package/dist/parts/DefaultXmlPart.mjs +2 -2
- package/dist/parts/Part.d.mts +10 -2
- package/dist/parts/XmlPart.d.mts +12 -30
- package/dist/parts/XmlPart.mjs +44 -93
- package/dist/parts/wml/comments.mjs +30 -0
- package/dist/parts/wml/index.mjs +12 -0
- package/dist/xml/dom.d.mts +7 -0
- package/dist/xml/dom.mjs +18 -0
- package/package.json +2 -2
|
@@ -64,7 +64,8 @@ export interface NumberingResult {
|
|
|
64
64
|
ilvl: string | undefined;
|
|
65
65
|
/** The level definition, merged. Not docx4j's: a port convenience for CR-002 phase H. */
|
|
66
66
|
level: LevelDefinition | undefined;
|
|
67
|
-
/** The
|
|
67
|
+
/** The count this paragraph's level shows (the 3 of "1.3."), its counter once this paragraph is
|
|
68
|
+
* counted. docx4j `getValue()` (17.3.4), which this preceded. */
|
|
68
69
|
count: number | undefined;
|
|
69
70
|
/** No label was produced. docx4j returns an *empty* `ResultTriple` where a `w:num` or its
|
|
70
71
|
* level has no definition; this flags that case rather than leaving every member undefined
|
|
@@ -117,8 +118,32 @@ export declare class Emulator {
|
|
|
117
118
|
* to. The style itself, or any style it is based on, counts as the level's own. Direct
|
|
118
119
|
* formatting is never suppressed: a paragraph whose *own* `w:numPr` names such a level is
|
|
119
120
|
* numbered.
|
|
121
|
+
*
|
|
122
|
+
* A level which names no style belongs to one all the same: the first paragraph style in
|
|
123
|
+
* styles.xml whose own `w:numPr` names it ({@link levelStyleId}, docx4j 17.3.4, measured in
|
|
124
|
+
* Word 365 on the three documents of docx4j's `LevelOwnerTest`). Of two styles carrying such
|
|
125
|
+
* a level Word numbers the first in styles.xml - whatever their names, whichever the document
|
|
126
|
+
* uses first, whether or not it uses that style at all - and gives the other style's paragraphs
|
|
127
|
+
* no label and no count. They keep the level's indent, which the effective indent already
|
|
128
|
+
* gives them. A paragraph naming no style is the default paragraph style's in this check.
|
|
120
129
|
*/
|
|
121
130
|
styleLinkedElsewhere(numId: string, ilvl: string, pStyleVal: string | undefined): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* The paragraph style a numbering level belongs to: the one its `w:lvl/w:pStyle` names (the
|
|
133
|
+
* `w:num`'s override level's first, as {@link NumberingDefinitions.getLinkedStyleId} reads it),
|
|
134
|
+
* else the first paragraph style in styles.xml whose own `w:numPr` names a `w:num` on the same
|
|
135
|
+
* `w:abstractNum` at that level (its `w:ilvl`, 0 where it states none). Undefined where neither:
|
|
136
|
+
* no style carries the level, so a paragraph reaches it only through its own `w:numPr`.
|
|
137
|
+
*
|
|
138
|
+
* The level is the `w:abstractNum`'s, not a `w:num`'s: a style reaching it through a second
|
|
139
|
+
* `w:num` is on the same level, even where that `w:num` overrides it with a `w:lvl` of its own.
|
|
140
|
+
* A style's level is its `w:numPr`'s `w:ilvl`, not the level whose `w:pStyle` names it, as Word
|
|
141
|
+
* reads it (ECMA-376 17.9.24 has the naming level). docx4j `Emulator.levelStyleId` (17.3.4).
|
|
142
|
+
*
|
|
143
|
+
* @param numId a `w:numId` (not 0)
|
|
144
|
+
* @param ilvl a `w:ilvl`; undefined or empty for 0
|
|
145
|
+
*/
|
|
146
|
+
levelStyleId(numId: string, ilvl: string | undefined): string | undefined;
|
|
122
147
|
/**
|
|
123
148
|
* The one resolution of numId and ilvl for a paragraph. docx4j `Emulator.resolve`
|
|
124
149
|
* (CR-014 phase 3, which collapsed `getNumber`'s and `getInd`'s two copies onto it).
|
|
@@ -135,13 +160,18 @@ export declare class Emulator {
|
|
|
135
160
|
resolve(pStyleVal: string | undefined, numId: string | undefined, ilvl: string | undefined, directNumPr: boolean): NumRef;
|
|
136
161
|
/**
|
|
137
162
|
* The numbering reference a paragraph resolves to, without taking a number and without
|
|
138
|
-
* touching any state. docx4j `Emulator.numRefFor` (17.1.1); never undefined.
|
|
163
|
+
* touching any state. docx4j `Emulator.numRefFor` (17.1.1); never undefined. A paragraph with
|
|
164
|
+
* no `w:pPr` resolves as an empty one, against the default paragraph style, as
|
|
165
|
+
* {@link getNumber} resolves it (docx4j `c283dffdb`, 17.3.4).
|
|
139
166
|
*/
|
|
140
167
|
numRefFor(pPr: wml.PPr | undefined): NumRef;
|
|
141
168
|
/**
|
|
142
169
|
* The next number for a paragraph, from its `w:pPr` (its own `w:numPr`, else its style's),
|
|
143
170
|
* counted in `state` or in this emulator's default state.
|
|
144
171
|
*
|
|
172
|
+
* A paragraph with no `w:pPr` resolves as one with an empty `w:pPr` does, against the default
|
|
173
|
+
* paragraph style, which may be numbered (docx4j 17.3.4; before, it was not numbered).
|
|
174
|
+
*
|
|
145
175
|
* @returns undefined where the paragraph is not numbered
|
|
146
176
|
*/
|
|
147
177
|
getNumber(pPr: wml.PPr | undefined, state?: NumberingState): NumberingResult | undefined;
|
|
@@ -176,11 +206,13 @@ export declare class Emulator {
|
|
|
176
206
|
static peek(pkg: NumberedPackageLike, pPr: wml.PPr | undefined, state?: NumberingState): NumberingResult | undefined;
|
|
177
207
|
/**
|
|
178
208
|
* docx4j `Emulator.numRefFor(wmlPackage, pPr)`: where this paragraph's numbering resolves to,
|
|
179
|
-
* before any counting. Never undefined; a package with no numbering part
|
|
180
|
-
*
|
|
181
|
-
*
|
|
209
|
+
* before any counting. Never undefined; a package with no numbering part or a package whose
|
|
210
|
+
* `PropertyResolver` has not been built each answer {@link NumRef.notNumbered} with the reason.
|
|
211
|
+
* A null `w:pPr` resolves as an empty one (docx4j `c283dffdb`, 17.3.4).
|
|
182
212
|
*/
|
|
183
213
|
static numRefFor(pkg: NumberedPackageLike | undefined, pPr: wml.PPr | undefined): NumRef;
|
|
214
|
+
/** docx4j `Emulator.levelStyleId(numberingPart, numId, levelId)`: the paragraph style a level belongs to. */
|
|
215
|
+
static levelStyleId(part: NumberingPartLike, numId: string, ilvl: string | undefined): string | undefined;
|
|
184
216
|
/** docx4j `Emulator.getInd(wmlPackage, pStyleVal, numId, levelId)`. */
|
|
185
217
|
static getInd(pkg: NumberedPackageLike, pStyleVal: string | undefined, numId: string | undefined, ilvl: string | undefined): wml.PPrBase.Ind | undefined;
|
|
186
218
|
toString(): string;
|
|
@@ -70,12 +70,23 @@ export class Emulator {
|
|
|
70
70
|
* to. The style itself, or any style it is based on, counts as the level's own. Direct
|
|
71
71
|
* formatting is never suppressed: a paragraph whose *own* `w:numPr` names such a level is
|
|
72
72
|
* numbered.
|
|
73
|
+
*
|
|
74
|
+
* A level which names no style belongs to one all the same: the first paragraph style in
|
|
75
|
+
* styles.xml whose own `w:numPr` names it ({@link levelStyleId}, docx4j 17.3.4, measured in
|
|
76
|
+
* Word 365 on the three documents of docx4j's `LevelOwnerTest`). Of two styles carrying such
|
|
77
|
+
* a level Word numbers the first in styles.xml - whatever their names, whichever the document
|
|
78
|
+
* uses first, whether or not it uses that style at all - and gives the other style's paragraphs
|
|
79
|
+
* no label and no count. They keep the level's indent, which the effective indent already
|
|
80
|
+
* gives them. A paragraph naming no style is the default paragraph style's in this check.
|
|
73
81
|
*/
|
|
74
82
|
styleLinkedElsewhere(numId, ilvl, pStyleVal) {
|
|
75
83
|
var _a, _b;
|
|
76
|
-
const linked = this.
|
|
84
|
+
const linked = this.levelStyleId(numId, ilvl);
|
|
77
85
|
if (linked === undefined || linked === '')
|
|
78
86
|
return false;
|
|
87
|
+
// a paragraph naming no style is in the default paragraph style, which can own a level
|
|
88
|
+
if (pStyleVal === undefined && this.resolver !== undefined)
|
|
89
|
+
pStyleVal = this.resolver.getDefaultParagraphStyleId();
|
|
79
90
|
if (pStyleVal === undefined)
|
|
80
91
|
return true;
|
|
81
92
|
const seen = new Set();
|
|
@@ -89,6 +100,42 @@ export class Emulator {
|
|
|
89
100
|
}
|
|
90
101
|
return true;
|
|
91
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* The paragraph style a numbering level belongs to: the one its `w:lvl/w:pStyle` names (the
|
|
105
|
+
* `w:num`'s override level's first, as {@link NumberingDefinitions.getLinkedStyleId} reads it),
|
|
106
|
+
* else the first paragraph style in styles.xml whose own `w:numPr` names a `w:num` on the same
|
|
107
|
+
* `w:abstractNum` at that level (its `w:ilvl`, 0 where it states none). Undefined where neither:
|
|
108
|
+
* no style carries the level, so a paragraph reaches it only through its own `w:numPr`.
|
|
109
|
+
*
|
|
110
|
+
* The level is the `w:abstractNum`'s, not a `w:num`'s: a style reaching it through a second
|
|
111
|
+
* `w:num` is on the same level, even where that `w:num` overrides it with a `w:lvl` of its own.
|
|
112
|
+
* A style's level is its `w:numPr`'s `w:ilvl`, not the level whose `w:pStyle` names it, as Word
|
|
113
|
+
* reads it (ECMA-376 17.9.24 has the naming level). docx4j `Emulator.levelStyleId` (17.3.4).
|
|
114
|
+
*
|
|
115
|
+
* @param numId a `w:numId` (not 0)
|
|
116
|
+
* @param ilvl a `w:ilvl`; undefined or empty for 0
|
|
117
|
+
*/
|
|
118
|
+
levelStyleId(numId, ilvl) {
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
120
|
+
const linked = this.definitions.getLinkedStyleId(numId, ilvl);
|
|
121
|
+
if (linked !== undefined && linked !== '')
|
|
122
|
+
return linked;
|
|
123
|
+
const abstract = (_a = this.definitions.list(numId)) === null || _a === void 0 ? void 0 : _a.abstractDefinition;
|
|
124
|
+
if (abstract === undefined)
|
|
125
|
+
return undefined;
|
|
126
|
+
const level = ilvl === undefined || ilvl === '' ? '0' : ilvl;
|
|
127
|
+
for (const style of (_c = (_b = this.resolver) === null || _b === void 0 ? void 0 : _b.getStylesInOrder()) !== null && _c !== void 0 ? _c : []) {
|
|
128
|
+
const own = (_d = style.pPr) === null || _d === void 0 ? void 0 : _d.numPr;
|
|
129
|
+
if (style.type !== 'paragraph' || style.styleId === undefined || ((_e = own === null || own === void 0 ? void 0 : own.numId) === null || _e === void 0 ? void 0 : _e.val) === undefined)
|
|
130
|
+
continue;
|
|
131
|
+
if (((_f = this.definitions.list(String(own.numId.val))) === null || _f === void 0 ? void 0 : _f.abstractDefinition) !== abstract)
|
|
132
|
+
continue;
|
|
133
|
+
const ownLevel = ((_g = own.ilvl) === null || _g === void 0 ? void 0 : _g.val) === undefined ? '0' : String(own.ilvl.val);
|
|
134
|
+
if (ownLevel === level)
|
|
135
|
+
return style.styleId;
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
92
139
|
/**
|
|
93
140
|
* The one resolution of numId and ilvl for a paragraph. docx4j `Emulator.resolve`
|
|
94
141
|
* (CR-014 phase 3, which collapsed `getNumber`'s and `getInd`'s two copies onto it).
|
|
@@ -171,11 +218,13 @@ export class Emulator {
|
|
|
171
218
|
}
|
|
172
219
|
/**
|
|
173
220
|
* The numbering reference a paragraph resolves to, without taking a number and without
|
|
174
|
-
* touching any state. docx4j `Emulator.numRefFor` (17.1.1); never undefined.
|
|
221
|
+
* touching any state. docx4j `Emulator.numRefFor` (17.1.1); never undefined. A paragraph with
|
|
222
|
+
* no `w:pPr` resolves as an empty one, against the default paragraph style, as
|
|
223
|
+
* {@link getNumber} resolves it (docx4j `c283dffdb`, 17.3.4).
|
|
175
224
|
*/
|
|
176
225
|
numRefFor(pPr) {
|
|
177
226
|
if (pPr === undefined)
|
|
178
|
-
return
|
|
227
|
+
return this.resolve(undefined, undefined, undefined, false);
|
|
179
228
|
const [pStyleVal, numId, ilvl] = readNumPr(pPr);
|
|
180
229
|
return this.resolve(pStyleVal, numId, ilvl, numId !== undefined && numId !== '');
|
|
181
230
|
}
|
|
@@ -184,11 +233,14 @@ export class Emulator {
|
|
|
184
233
|
* The next number for a paragraph, from its `w:pPr` (its own `w:numPr`, else its style's),
|
|
185
234
|
* counted in `state` or in this emulator's default state.
|
|
186
235
|
*
|
|
236
|
+
* A paragraph with no `w:pPr` resolves as one with an empty `w:pPr` does, against the default
|
|
237
|
+
* paragraph style, which may be numbered (docx4j 17.3.4; before, it was not numbered).
|
|
238
|
+
*
|
|
187
239
|
* @returns undefined where the paragraph is not numbered
|
|
188
240
|
*/
|
|
189
241
|
getNumber(pPr, state) {
|
|
190
242
|
if (pPr === undefined)
|
|
191
|
-
return undefined;
|
|
243
|
+
return this.getNumberOf(undefined, undefined, undefined, false, state);
|
|
192
244
|
const [pStyleVal, numId, ilvl] = readNumPr(pPr);
|
|
193
245
|
return this.getNumberOf(pStyleVal, numId, ilvl, numId !== undefined && numId !== '', state);
|
|
194
246
|
}
|
|
@@ -280,13 +332,11 @@ export class Emulator {
|
|
|
280
332
|
}
|
|
281
333
|
/**
|
|
282
334
|
* docx4j `Emulator.numRefFor(wmlPackage, pPr)`: where this paragraph's numbering resolves to,
|
|
283
|
-
* before any counting. Never undefined; a package with no numbering part
|
|
284
|
-
*
|
|
285
|
-
*
|
|
335
|
+
* before any counting. Never undefined; a package with no numbering part or a package whose
|
|
336
|
+
* `PropertyResolver` has not been built each answer {@link NumRef.notNumbered} with the reason.
|
|
337
|
+
* A null `w:pPr` resolves as an empty one (docx4j `c283dffdb`, 17.3.4).
|
|
286
338
|
*/
|
|
287
339
|
static numRefFor(pkg, pPr) {
|
|
288
|
-
if (pPr === undefined)
|
|
289
|
-
return NumRef.not('no pPr');
|
|
290
340
|
const part = numberingPartOf(pkg);
|
|
291
341
|
if (part === undefined)
|
|
292
342
|
return NumRef.not('no numbering part');
|
|
@@ -296,6 +346,10 @@ export class Emulator {
|
|
|
296
346
|
}
|
|
297
347
|
return part.getEmulator().numRefFor(pPr);
|
|
298
348
|
}
|
|
349
|
+
/** docx4j `Emulator.levelStyleId(numberingPart, numId, levelId)`: the paragraph style a level belongs to. */
|
|
350
|
+
static levelStyleId(part, numId, ilvl) {
|
|
351
|
+
return part.getEmulator().levelStyleId(numId, ilvl);
|
|
352
|
+
}
|
|
299
353
|
/** docx4j `Emulator.getInd(wmlPackage, pStyleVal, numId, levelId)`. */
|
|
300
354
|
static getInd(pkg, pStyleVal, numId, ilvl) {
|
|
301
355
|
var _a;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type * as wml from '@docx4j/generated-objects-ts/modules/org_docx4j_wml';
|
|
2
|
+
import type * as dml from '@docx4j/generated-objects-ts/modules/org_docx4j_dml';
|
|
2
3
|
import { NumberingDefinitions } from '../listnumbering/definitions.mjs';
|
|
3
4
|
import { CellContext, TableContext } from './table.mjs';
|
|
5
|
+
import { ThemeColors } from '../color/ThemeColors.mjs';
|
|
6
|
+
import type { ResolvedColor } from '../color/ResolvedColor.mjs';
|
|
7
|
+
import { type DefaultTheme, type FontSettings } from '../fonts/defaultTheme.mjs';
|
|
4
8
|
/** The parts the resolver reads. Structural, so this module imports no part class. */
|
|
5
9
|
export interface ResolverSource {
|
|
6
10
|
/** The styles part's `w:styles`, or undefined when the package has none. */
|
|
@@ -9,9 +13,14 @@ export interface ResolverSource {
|
|
|
9
13
|
numbering?: wml.Numbering;
|
|
10
14
|
/**
|
|
11
15
|
* The settings part's `w:settings`, or undefined: read for the compatibility mode and
|
|
12
|
-
* `overrideTableStyleFontSizeAndJustification` (CR-007)
|
|
16
|
+
* `overrideTableStyleFontSizeAndJustification` (CR-007), and `w:clrSchemeMapping` (CR-008).
|
|
17
|
+
* A document with none is in mode 12.
|
|
13
18
|
*/
|
|
14
19
|
settings?: wml.CTSettings;
|
|
20
|
+
/** The theme part's `a:theme`, or undefined where the package has none (CR-008). */
|
|
21
|
+
theme?: dml.Theme;
|
|
22
|
+
/** The bundled theme a package with no theme part is read as having; `defaultThemeSetting()`'s where undefined. */
|
|
23
|
+
defaultTheme?: DefaultTheme;
|
|
15
24
|
}
|
|
16
25
|
/** As much of an `XmlPart<T>` as the resolver uses. */
|
|
17
26
|
interface ReadablePart<T> {
|
|
@@ -25,7 +34,9 @@ interface PackageLike {
|
|
|
25
34
|
styleDefinitionsPart?: ReadablePart<wml.Styles>;
|
|
26
35
|
numberingDefinitionsPart?: ReadablePart<wml.Numbering>;
|
|
27
36
|
documentSettingsPart?: ReadablePart<wml.CTSettings>;
|
|
37
|
+
themePart?: ReadablePart<dml.Theme>;
|
|
28
38
|
};
|
|
39
|
+
fonts?: FontSettings;
|
|
29
40
|
}
|
|
30
41
|
/** 108 twips (0.08in): the left and right cell margin of Word's built-in Normal Table. */
|
|
31
42
|
export declare const WORD_DEFAULT_CELL_MARGIN_TWIPS = 108;
|
|
@@ -48,6 +59,8 @@ export declare class PropertyResolver {
|
|
|
48
59
|
/** A style's `w:basedOn` chain merged root-first, WITHOUT the document defaults, per style id. */
|
|
49
60
|
private readonly chainPPrCache;
|
|
50
61
|
private readonly chainRPrCache;
|
|
62
|
+
/** A character style's chain as it applies to a run, where it differs from its chain: see {@link characterLevel}. */
|
|
63
|
+
private readonly characterLevelCache;
|
|
51
64
|
/** The document defaults with the chain applied over them: what the style overloads return. */
|
|
52
65
|
private readonly effectivePPrByStyle;
|
|
53
66
|
private readonly effectiveRPrByStyle;
|
|
@@ -68,6 +81,8 @@ export declare class PropertyResolver {
|
|
|
68
81
|
* where they state one. Read once per `refresh()`.
|
|
69
82
|
*/
|
|
70
83
|
private docDefaultsStateSize;
|
|
84
|
+
/** Whether a paragraph style and a character style hide a run, by paragraph style then character style (`isVanishedByStyles`). */
|
|
85
|
+
private readonly vanishCache;
|
|
71
86
|
/** Missing styles are logged once each per resolver. */
|
|
72
87
|
private readonly missingLogged;
|
|
73
88
|
private numberingDefinitions;
|
|
@@ -104,6 +119,28 @@ export declare class PropertyResolver {
|
|
|
104
119
|
* contents replaced. The content API calls it where it creates a style.
|
|
105
120
|
*/
|
|
106
121
|
refresh(): void;
|
|
122
|
+
private themeColors;
|
|
123
|
+
/**
|
|
124
|
+
* The document's theme colours: its theme part (or the bundled theme `pkg.fonts.defaultTheme` names where it has
|
|
125
|
+
* none) and the settings' `w:clrSchemeMapping`. Read once per `refresh()`. A resolver made `fromSource` with no
|
|
126
|
+
* theme parses the bundled one, which needs the objects package's context built (`ThemeColors.loadDefaultTheme()`).
|
|
127
|
+
*/
|
|
128
|
+
getThemeColors(): ThemeColors;
|
|
129
|
+
/**
|
|
130
|
+
* The colour Word draws for a run's `w:color`: its theme reference where it has one (the value beside it is a
|
|
131
|
+
* cache), else its value.
|
|
132
|
+
*
|
|
133
|
+
* @returns undefined for automatic: the caller's default (black text, as a rule)
|
|
134
|
+
*/
|
|
135
|
+
resolveColor(color: wml.Color | undefined): ResolvedColor | undefined;
|
|
136
|
+
/** A border's colour, as {@link resolveColor}; undefined for automatic. docx4j `resolveColor(CTBorder)`. */
|
|
137
|
+
resolveBorderColor(border: wml.CTBorder | undefined): ResolvedColor | undefined;
|
|
138
|
+
/** An underline's colour, as {@link resolveColor}; undefined for automatic (the text's). docx4j `resolveColor(U)`. */
|
|
139
|
+
resolveUnderlineColor(u: wml.U | undefined): ResolvedColor | undefined;
|
|
140
|
+
/** A shading's fill (`w:fill`, `w:themeFill`); undefined for automatic. */
|
|
141
|
+
resolveFill(shd: wml.CTShd | undefined): ResolvedColor | undefined;
|
|
142
|
+
/** A shading's pattern colour (`w:color`, `w:themeColor`); undefined for automatic. */
|
|
143
|
+
resolvePatternColor(shd: wml.CTShd | undefined): ResolvedColor | undefined;
|
|
107
144
|
getDocumentDefaultPPr(): wml.PPr;
|
|
108
145
|
getDocumentDefaultRPr(): wml.RPr;
|
|
109
146
|
/** The style id of the `w:default="1"` paragraph style, or undefined when the part declares none. */
|
|
@@ -112,6 +149,13 @@ export declare class PropertyResolver {
|
|
|
112
149
|
getResolvedDefaultParagraphStyle(): wml.PPr;
|
|
113
150
|
/** The style with this id, or undefined (docx4j `getStyle`). */
|
|
114
151
|
getStyle(styleId: string | undefined): wml.Style | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* The styles part's `w:style` elements in document order, from the tree this resolver reads (its
|
|
154
|
+
* private copy, or the part's own once that is unmarshalled); empty where there is no styles part.
|
|
155
|
+
* docx4j reads `StyleDefinitionsPart.getJaxbElement().getStyle()` where order matters
|
|
156
|
+
* (`Emulator.levelStyleId`: the first paragraph style in styles.xml carrying a level owns it).
|
|
157
|
+
*/
|
|
158
|
+
getStylesInOrder(): readonly wml.Style[];
|
|
115
159
|
/**
|
|
116
160
|
* The list definitions of the numbering part this resolver read (CR-001 Phase B step 3), or
|
|
117
161
|
* undefined where the package has none. The resolver builds them because the paragraph merge
|
|
@@ -138,6 +182,13 @@ export declare class PropertyResolver {
|
|
|
138
182
|
* object: copy before changing.
|
|
139
183
|
*/
|
|
140
184
|
getChainRPr(styleId: string | undefined): wml.RPr;
|
|
185
|
+
/**
|
|
186
|
+
* A character style's chain as a level over a run or a paragraph mark: {@link getChainRPr} without its highlight,
|
|
187
|
+
* since Word draws no highlight from a character style (docx4j CR-060 section 13, round 6: alone, with bold, or
|
|
188
|
+
* through `w:basedOn`; its save writes `w:highlight="none"` on such a run). A paragraph style's highlight and a
|
|
189
|
+
* run's own are drawn. docx4j `characterLevel` (1d1b824a9). Cached; live: copy before changing.
|
|
190
|
+
*/
|
|
191
|
+
private characterLevel;
|
|
141
192
|
/**
|
|
142
193
|
* A style's own `w:pPr` as a layer of its chain. The built-in heading styles have a fixed
|
|
143
194
|
* outline level, which Word takes from the style's built-in NAME ("heading 1" ...
|
|
@@ -199,6 +250,14 @@ export declare class PropertyResolver {
|
|
|
199
250
|
* context resolves exactly as `getEffectiveRPr(rPr, pPr)`. A new object each call.
|
|
200
251
|
*/
|
|
201
252
|
getEffectiveRPr(rPr: wml.RPr | undefined, pPr: wml.PPr | undefined, cellContext: CellContext | undefined): wml.RPr;
|
|
253
|
+
/**
|
|
254
|
+
* Whether a run with no `w:vanish` of its own is hidden by its styles: the effective `w:vanish` of its
|
|
255
|
+
* paragraph style (undefined: the default paragraph style) and its character style, the table style left
|
|
256
|
+
* out, as the text model's hidden rule has it (REQ-507). What `Paragraph.text` leaves out, as Office JS
|
|
257
|
+
* does (CR-012 phase 4, check 48b case 20). Cached per pair; a pair naming a style the part lacks is
|
|
258
|
+
* not cached, so that adding the style is seen.
|
|
259
|
+
*/
|
|
260
|
+
isVanishedByStyles(paragraphStyleId: string | undefined, runStyleId: string | undefined): boolean;
|
|
202
261
|
private effectiveRPrOfStyle;
|
|
203
262
|
/**
|
|
204
263
|
* The character style's chain, then the direct formatting.
|
|
@@ -4,6 +4,9 @@ import { log } from './log.mjs';
|
|
|
4
4
|
import { NumberingDefinitions } from '../listnumbering/definitions.mjs';
|
|
5
5
|
import { applyPPr, applyPPrBase, applyRPr, applyStyle, applyStyleLevel, applyTblPr, applyToggles, hasDirectFormattingPPr, hasDirectFormattingRPr, isCyclic, isEmptyStyle, } from './styleUtil.mjs';
|
|
6
6
|
import { TableContext, enclosingCellOf } from './table.mjs';
|
|
7
|
+
import { ThemeColors } from '../color/ThemeColors.mjs';
|
|
8
|
+
import { WordColors } from '../color/WordColors.mjs';
|
|
9
|
+
import { themeOfSettings } from '../fonts/defaultTheme.mjs';
|
|
7
10
|
/** The cache key for "no style" (a styles part with no default paragraph style). */
|
|
8
11
|
const NO_STYLE = '';
|
|
9
12
|
/** An empty table style: what a table with no style to apply contributes. Shared, never changed. */
|
|
@@ -110,6 +113,8 @@ export class PropertyResolver {
|
|
|
110
113
|
/** A style's `w:basedOn` chain merged root-first, WITHOUT the document defaults, per style id. */
|
|
111
114
|
this.chainPPrCache = new Map();
|
|
112
115
|
this.chainRPrCache = new Map();
|
|
116
|
+
/** A character style's chain as it applies to a run, where it differs from its chain: see {@link characterLevel}. */
|
|
117
|
+
this.characterLevelCache = new Map();
|
|
113
118
|
/** The document defaults with the chain applied over them: what the style overloads return. */
|
|
114
119
|
this.effectivePPrByStyle = new Map();
|
|
115
120
|
this.effectiveRPrByStyle = new Map();
|
|
@@ -130,6 +135,8 @@ export class PropertyResolver {
|
|
|
130
135
|
* where they state one. Read once per `refresh()`.
|
|
131
136
|
*/
|
|
132
137
|
this.docDefaultsStateSize = false;
|
|
138
|
+
/** Whether a paragraph style and a character style hide a run, by paragraph style then character style (`isVanishedByStyles`). */
|
|
139
|
+
this.vanishCache = new Map();
|
|
133
140
|
/** Missing styles are logged once each per resolver. */
|
|
134
141
|
this.missingLogged = new Set();
|
|
135
142
|
this.source = provider();
|
|
@@ -169,10 +176,24 @@ export class PropertyResolver {
|
|
|
169
176
|
catch (e) {
|
|
170
177
|
log.warn(`The settings part could not be read; taking compatibility mode ${DEFAULT_COMPATIBILITY_MODE}: ${String(e)}`);
|
|
171
178
|
}
|
|
179
|
+
// the theme, for its colours (CR-008), privately too; where there is none, or it can't be read, the bundled theme
|
|
180
|
+
// the package names, parsed now so that getThemeColors() needn't wait
|
|
181
|
+
const themePart = main.themePart;
|
|
182
|
+
let privateTheme;
|
|
183
|
+
try {
|
|
184
|
+
privateTheme = themePart === undefined ? undefined : await themePart.readContents();
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
log.warn(`The theme part could not be read; its colours are the default theme's: ${String(e)}`);
|
|
188
|
+
}
|
|
189
|
+
const defaultTheme = themeOfSettings(pkg.fonts);
|
|
190
|
+
await ThemeColors.loadDefaultTheme(defaultTheme);
|
|
172
191
|
return new PropertyResolver(() => ({
|
|
173
192
|
styles: (stylesPart === null || stylesPart === void 0 ? void 0 : stylesPart.isUnmarshalled) === true ? stylesPart.contents : privateStyles,
|
|
174
193
|
numbering: (numberingPart === null || numberingPart === void 0 ? void 0 : numberingPart.isUnmarshalled) === true ? numberingPart.contents : privateNumbering,
|
|
175
194
|
settings: (settingsPart === null || settingsPart === void 0 ? void 0 : settingsPart.isUnmarshalled) === true ? settingsPart.contents : privateSettings,
|
|
195
|
+
theme: (themePart === null || themePart === void 0 ? void 0 : themePart.isUnmarshalled) === true ? themePart.contents : privateTheme,
|
|
196
|
+
defaultTheme,
|
|
176
197
|
}), () => stylesPart !== undefined && !stylesPart.isUnmarshalled);
|
|
177
198
|
}
|
|
178
199
|
/** Builds a resolver over object trees directly (a test, or parts already in hand). */
|
|
@@ -266,13 +287,52 @@ export class PropertyResolver {
|
|
|
266
287
|
refresh() {
|
|
267
288
|
this.chainPPrCache.clear();
|
|
268
289
|
this.chainRPrCache.clear();
|
|
290
|
+
this.characterLevelCache.clear();
|
|
269
291
|
this.effectivePPrByStyle.clear();
|
|
270
292
|
this.effectiveRPrByStyle.clear();
|
|
293
|
+
this.vanishCache.clear();
|
|
271
294
|
this.clearTableCaches();
|
|
272
295
|
this.missingLogged.clear();
|
|
296
|
+
this.themeColors = undefined;
|
|
273
297
|
this.source = this.provider();
|
|
274
298
|
this.init();
|
|
275
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* The document's theme colours: its theme part (or the bundled theme `pkg.fonts.defaultTheme` names where it has
|
|
302
|
+
* none) and the settings' `w:clrSchemeMapping`. Read once per `refresh()`. A resolver made `fromSource` with no
|
|
303
|
+
* theme parses the bundled one, which needs the objects package's context built (`ThemeColors.loadDefaultTheme()`).
|
|
304
|
+
*/
|
|
305
|
+
getThemeColors() {
|
|
306
|
+
var _a, _b;
|
|
307
|
+
(_a = this.themeColors) !== null && _a !== void 0 ? _a : (this.themeColors = ThemeColors.ofTheme(this.source.theme, this.source.defaultTheme)
|
|
308
|
+
.withWordMapping((_b = this.source.settings) === null || _b === void 0 ? void 0 : _b.clrSchemeMapping));
|
|
309
|
+
return this.themeColors;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* The colour Word draws for a run's `w:color`: its theme reference where it has one (the value beside it is a
|
|
313
|
+
* cache), else its value.
|
|
314
|
+
*
|
|
315
|
+
* @returns undefined for automatic: the caller's default (black text, as a rule)
|
|
316
|
+
*/
|
|
317
|
+
resolveColor(color) {
|
|
318
|
+
return WordColors.of(color, this.getThemeColors());
|
|
319
|
+
}
|
|
320
|
+
/** A border's colour, as {@link resolveColor}; undefined for automatic. docx4j `resolveColor(CTBorder)`. */
|
|
321
|
+
resolveBorderColor(border) {
|
|
322
|
+
return WordColors.ofBorder(border, this.getThemeColors());
|
|
323
|
+
}
|
|
324
|
+
/** An underline's colour, as {@link resolveColor}; undefined for automatic (the text's). docx4j `resolveColor(U)`. */
|
|
325
|
+
resolveUnderlineColor(u) {
|
|
326
|
+
return WordColors.ofUnderline(u, this.getThemeColors());
|
|
327
|
+
}
|
|
328
|
+
/** A shading's fill (`w:fill`, `w:themeFill`); undefined for automatic. */
|
|
329
|
+
resolveFill(shd) {
|
|
330
|
+
return WordColors.fill(shd, this.getThemeColors());
|
|
331
|
+
}
|
|
332
|
+
/** A shading's pattern colour (`w:color`, `w:themeColor`); undefined for automatic. */
|
|
333
|
+
resolvePatternColor(shd) {
|
|
334
|
+
return WordColors.pattern(shd, this.getThemeColors());
|
|
335
|
+
}
|
|
276
336
|
// ------------------------------------------------------------------ defaults
|
|
277
337
|
getDocumentDefaultPPr() {
|
|
278
338
|
return this.documentDefaultPPr;
|
|
@@ -292,6 +352,16 @@ export class PropertyResolver {
|
|
|
292
352
|
getStyle(styleId) {
|
|
293
353
|
return this.getLiveStyle(styleId);
|
|
294
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* The styles part's `w:style` elements in document order, from the tree this resolver reads (its
|
|
357
|
+
* private copy, or the part's own once that is unmarshalled); empty where there is no styles part.
|
|
358
|
+
* docx4j reads `StyleDefinitionsPart.getJaxbElement().getStyle()` where order matters
|
|
359
|
+
* (`Emulator.levelStyleId`: the first paragraph style in styles.xml carrying a level owns it).
|
|
360
|
+
*/
|
|
361
|
+
getStylesInOrder() {
|
|
362
|
+
var _a, _b;
|
|
363
|
+
return (_b = (_a = this.source.styles) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : [];
|
|
364
|
+
}
|
|
295
365
|
/**
|
|
296
366
|
* The list definitions of the numbering part this resolver read (CR-001 Phase B step 3), or
|
|
297
367
|
* undefined where the package has none. The resolver builds them because the paragraph merge
|
|
@@ -366,6 +436,24 @@ export class PropertyResolver {
|
|
|
366
436
|
this.chainRPrCache.set(styleId, chain);
|
|
367
437
|
return chain;
|
|
368
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* A character style's chain as a level over a run or a paragraph mark: {@link getChainRPr} without its highlight,
|
|
441
|
+
* since Word draws no highlight from a character style (docx4j CR-060 section 13, round 6: alone, with bold, or
|
|
442
|
+
* through `w:basedOn`; its save writes `w:highlight="none"` on such a run). A paragraph style's highlight and a
|
|
443
|
+
* run's own are drawn. docx4j `characterLevel` (1d1b824a9). Cached; live: copy before changing.
|
|
444
|
+
*/
|
|
445
|
+
characterLevel(styleId) {
|
|
446
|
+
const chain = this.getChainRPr(styleId);
|
|
447
|
+
if (chain.highlight === undefined)
|
|
448
|
+
return chain;
|
|
449
|
+
let level = this.characterLevelCache.get(styleId);
|
|
450
|
+
if (level === undefined) {
|
|
451
|
+
level = deepCopy(chain);
|
|
452
|
+
delete level.highlight;
|
|
453
|
+
this.characterLevelCache.set(styleId, level);
|
|
454
|
+
}
|
|
455
|
+
return level;
|
|
456
|
+
}
|
|
369
457
|
/**
|
|
370
458
|
* A style's own `w:pPr` as a layer of its chain. The built-in heading styles have a fixed
|
|
371
459
|
* outline level, which Word takes from the style's built-in NAME ("heading 1" ...
|
|
@@ -452,6 +540,30 @@ export class PropertyResolver {
|
|
|
452
540
|
this.applyCharacterStyleAndDirect(arg, effective);
|
|
453
541
|
return effective;
|
|
454
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* Whether a run with no `w:vanish` of its own is hidden by its styles: the effective `w:vanish` of its
|
|
545
|
+
* paragraph style (undefined: the default paragraph style) and its character style, the table style left
|
|
546
|
+
* out, as the text model's hidden rule has it (REQ-507). What `Paragraph.text` leaves out, as Office JS
|
|
547
|
+
* does (CR-012 phase 4, check 48b case 20). Cached per pair; a pair naming a style the part lacks is
|
|
548
|
+
* not cached, so that adding the style is seen.
|
|
549
|
+
*/
|
|
550
|
+
isVanishedByStyles(paragraphStyleId, runStyleId) {
|
|
551
|
+
let byRunStyle = this.vanishCache.get(paragraphStyleId);
|
|
552
|
+
const cached = byRunStyle === null || byRunStyle === void 0 ? void 0 : byRunStyle.get(runStyleId);
|
|
553
|
+
if (cached !== undefined)
|
|
554
|
+
return cached;
|
|
555
|
+
const rPr = runStyleId === undefined ? undefined : { TYPE_NAME: 'org_docx4j_wml.RPr', rStyle: { TYPE_NAME: 'org_docx4j_wml.RStyle', val: runStyleId } };
|
|
556
|
+
const pPr = paragraphStyleId === undefined ? undefined : { TYPE_NAME: 'org_docx4j_wml.PPr', pStyle: { TYPE_NAME: 'org_docx4j_wml.PPrBase.PStyle', val: paragraphStyleId } };
|
|
557
|
+
const vanish = this.getEffectiveRPr(rPr, pPr).vanish;
|
|
558
|
+
const hidden = vanish !== undefined && vanish !== null && vanish.val !== false;
|
|
559
|
+
if ((paragraphStyleId === undefined || this.getLiveStyle(paragraphStyleId) !== undefined)
|
|
560
|
+
&& (runStyleId === undefined || this.getLiveStyle(runStyleId) !== undefined)) {
|
|
561
|
+
if (!byRunStyle)
|
|
562
|
+
this.vanishCache.set(paragraphStyleId, byRunStyle = new Map());
|
|
563
|
+
byRunStyle.set(runStyleId, hidden);
|
|
564
|
+
}
|
|
565
|
+
return hidden;
|
|
566
|
+
}
|
|
455
567
|
effectiveRPrOfStyle(styleId) {
|
|
456
568
|
const cached = this.effectiveRPrByStyle.get(styleId);
|
|
457
569
|
if (cached !== undefined)
|
|
@@ -481,7 +593,7 @@ export class PropertyResolver {
|
|
|
481
593
|
this.logMissing(runStyleId);
|
|
482
594
|
}
|
|
483
595
|
else {
|
|
484
|
-
applyStyleLevel(this.
|
|
596
|
+
applyStyleLevel(this.characterLevel(runStyleId), effective, this.documentDefaultRPr);
|
|
485
597
|
}
|
|
486
598
|
}
|
|
487
599
|
if (hasDirectFormattingRPr(rPr))
|
|
@@ -521,7 +633,7 @@ export class PropertyResolver {
|
|
|
521
633
|
this.logMissing(runStyleId);
|
|
522
634
|
}
|
|
523
635
|
else {
|
|
524
|
-
applyStyleLevel(this.
|
|
636
|
+
applyStyleLevel(this.characterLevel(runStyleId), effective, this.documentDefaultRPr);
|
|
525
637
|
}
|
|
526
638
|
}
|
|
527
639
|
applyRPr(mark, effective);
|
|
@@ -830,6 +942,7 @@ export class PropertyResolver {
|
|
|
830
942
|
// resolution of this style (and of anything based on it) has to be recomputed
|
|
831
943
|
this.chainPPrCache.clear();
|
|
832
944
|
this.chainRPrCache.clear();
|
|
945
|
+
this.characterLevelCache.clear();
|
|
833
946
|
this.effectivePPrByStyle.clear();
|
|
834
947
|
this.effectiveRPrByStyle.clear();
|
|
835
948
|
this.clearTableCaches();
|
|
@@ -41,11 +41,22 @@ export declare function isEmptyRStyle(value: wml.RStyle | undefined): boolean;
|
|
|
41
41
|
export declare function isEmptyRFonts(value: wml.RFonts | undefined): boolean;
|
|
42
42
|
/**
|
|
43
43
|
* A `w:color` stating only a theme colour is not empty: it is inherited, where until docx4j CR-034
|
|
44
|
-
* (2e381ef26) it was dropped.
|
|
44
|
+
* (2e381ef26) it was dropped. A value Word reads as absent (`F00`, `bogus`, `Auto`) is empty, so a style's
|
|
45
|
+
* colour beneath still shows, and only exactly `auto` overrides it (docx4j CR-060, {@link WordColors.stated};
|
|
46
|
+
* CR-015 section 2, rules 4 and 5).
|
|
45
47
|
*/
|
|
46
48
|
export declare function isEmptyColor(value: wml.Color | undefined): boolean;
|
|
47
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* The underline's colour attributes count, the theme ones too (docx4j CR-034, 2e381ef26); a colour Word reads as
|
|
51
|
+
* absent doesn't (docx4j CR-060, {@link WordColors.stated}).
|
|
52
|
+
*/
|
|
48
53
|
export declare function isEmptyU(value: wml.U | undefined): boolean;
|
|
54
|
+
/** Whether a `w:highlight` value is one of `ST_HighlightColor`'s, compared case-exactly, as Word does (docx4j `WordRepairs.isHighlightColor`). */
|
|
55
|
+
export declare function isHighlightColor(val: string | undefined): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* A value outside `ST_HighlightColor` (`YELLOW`, `bogus`), or none, is empty: Word's repair drops it, so a style's
|
|
58
|
+
* highlight beneath still shows (docx4j CR-060, its `StyleUtil.isEmpty(Highlight)`).
|
|
59
|
+
*/
|
|
49
60
|
export declare function isEmptyHighlight(value: wml.Highlight | undefined): boolean;
|
|
50
61
|
/** @since CR-015 phase 1: a style stating only `w:lang` used to count as empty and was never applied. */
|
|
51
62
|
export declare function isEmptyLang(value: wml.CTLanguage | undefined): boolean;
|
|
@@ -65,7 +76,10 @@ export declare function isEmptyTabs(value: wml.Tabs | undefined): boolean;
|
|
|
65
76
|
* its own (CR-015 probe styles-numpr-ilvl-only).
|
|
66
77
|
*/
|
|
67
78
|
export declare function isEmptyNumPr(value: wml.PPrBase.NumPr | undefined): boolean;
|
|
68
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Empty only with `w:anchorLock` absent too, as docx4j 82c64bf14 reads it (its CR-059: until then
|
|
81
|
+
* `isAnchorLock()`, which the schema's old `default="true"` made true for an absent attribute).
|
|
82
|
+
*/
|
|
69
83
|
export declare function isEmptyFramePr(value: wml.CTFramePr | undefined): boolean;
|
|
70
84
|
/** docx4j `apply(BooleanDefaultTrue, BooleanDefaultTrue)`: a copy of the source where it states one. */
|
|
71
85
|
export declare function mergeBool(source: wml.BooleanDefaultTrue | undefined, destination: wml.BooleanDefaultTrue | undefined): wml.BooleanDefaultTrue | undefined;
|
|
@@ -131,8 +145,8 @@ export declare const mergeSpacing: Merge<wml.PPrBase.Spacing>;
|
|
|
131
145
|
export declare const mergeTabs: Merge<wml.Tabs>;
|
|
132
146
|
/**
|
|
133
147
|
* `w:framePr`'s attributes each inherit on their own: a paragraph whose direct `w:framePr`
|
|
134
|
-
* gives only `w:x`/`w:y` keeps the anchors its style states
|
|
135
|
-
*
|
|
148
|
+
* gives only `w:x`/`w:y` keeps the anchors its style states, `w:anchorLock` among them (docx4j
|
|
149
|
+
* 82c64bf14 merges it as stated; until then its merge wrote `isAnchorLock()`'s default out).
|
|
136
150
|
*/
|
|
137
151
|
export declare const mergeFramePr: Merge<wml.CTFramePr>;
|
|
138
152
|
/**
|