@docx4j/core-ts 0.5.0 → 0.7.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 +92 -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 +507 -150
- package/dist/model/content/Comment.d.mts +23 -5
- package/dist/model/content/Comment.mjs +207 -26
- package/dist/model/content/ContentControl.d.mts +198 -19
- package/dist/model/content/ContentControl.mjs +672 -99
- package/dist/model/content/Font.d.mts +70 -17
- package/dist/model/content/Font.mjs +119 -36
- package/dist/model/content/InlinePicture.d.mts +11 -0
- package/dist/model/content/InlinePicture.mjs +21 -1
- package/dist/model/content/List.d.mts +6 -3
- package/dist/model/content/List.mjs +18 -8
- package/dist/model/content/Paragraph.d.mts +200 -14
- package/dist/model/content/Paragraph.mjs +898 -82
- 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 +135 -49
- package/dist/model/content/TrackedChange.d.mts +174 -15
- package/dist/model/content/TrackedChange.mjs +734 -170
- 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 +10 -3
- package/dist/model/content/index.mjs +10 -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/ooxml.mjs +12 -1
- package/dist/model/content/outline.d.mts +5 -0
- package/dist/model/content/outline.mjs +13 -0
- package/dist/model/content/paraIds.d.mts +5 -0
- package/dist/model/content/paraIds.mjs +54 -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 +74 -0
- package/dist/model/content/search.mjs +255 -9
- package/dist/model/content/spanEdits.d.mts +159 -0
- package/dist/model/content/spanEdits.mjs +728 -0
- package/dist/model/content/story.d.mts +47 -0
- package/dist/model/content/story.mjs +95 -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 +102 -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 +63 -6
- package/dist/model/content/tracking.mjs +242 -22
- package/dist/model/content/tree.d.mts +172 -24
- package/dist/model/content/tree.mjs +328 -54
- package/dist/model/content/wordRange.d.mts +48 -0
- package/dist/model/content/wordRange.mjs +97 -0
- package/dist/model/customxml/CustomXmlPartCollection.d.mts +30 -1
- package/dist/model/customxml/CustomXmlPartCollection.mjs +81 -12
- package/dist/model/customxml/XmlMapping.d.mts +32 -8
- package/dist/model/customxml/XmlMapping.mjs +64 -10
- package/dist/model/customxml/bindings.d.mts +33 -4
- package/dist/model/customxml/bindings.mjs +171 -45
- package/dist/model/customxml/index.d.mts +1 -0
- package/dist/model/customxml/index.mjs +1 -0
- package/dist/model/customxml/kinds.d.mts +8 -3
- package/dist/model/customxml/kinds.mjs +26 -5
- package/dist/model/customxml/opendope.d.mts +4 -1
- package/dist/model/customxml/opendope.mjs +9 -6
- 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 +22 -8
- package/dist/model/customxml/storeItems.d.mts +57 -0
- package/dist/model/customxml/storeItems.mjs +122 -0
- package/dist/model/customxml/xhtml.mjs +23 -22
- package/dist/model/dateZone.d.mts +25 -0
- package/dist/model/dateZone.mjs +57 -0
- package/dist/model/index.d.mts +3 -0
- package/dist/model/index.mjs +5 -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 +74 -2
- package/dist/model/properties/PropertyResolver.mjs +133 -5
- package/dist/model/properties/catalogue.d.mts +19 -5
- package/dist/model/properties/catalogue.mjs +41 -15
- package/dist/model/properties/index.d.mts +1 -1
- package/dist/model/properties/log.d.mts +1 -1
- package/dist/model/properties/log.mjs +5 -5
- package/dist/model/properties/styleUtil.d.mts +3 -1
- package/dist/model/properties/styleUtil.mjs +20 -24
- package/dist/model/properties/table.mjs +4 -2
- package/dist/model/text/CaseMapping.d.mts +38 -0
- package/dist/model/text/CaseMapping.mjs +86 -0
- package/dist/model/text/Extractor.d.mts +349 -0
- package/dist/model/text/Extractor.mjs +2406 -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 +542 -0
- package/dist/model/text/TextContext.d.mts +256 -0
- package/dist/model/text/TextContext.mjs +600 -0
- package/dist/model/text/TextOptions.d.mts +233 -0
- package/dist/model/text/TextOptions.mjs +419 -0
- package/dist/model/text/TextResult.d.mts +621 -0
- package/dist/model/text/TextResult.mjs +629 -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 +936 -0
- package/dist/model/text/caseMapping.generated.d.mts +7 -0
- package/dist/model/text/caseMapping.generated.mjs +214 -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 +8 -0
- package/dist/model/text/index.mjs +9 -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/model/wordIntegers.d.mts +29 -0
- package/dist/model/wordIntegers.mjs +78 -0
- package/dist/office-js/document.mjs +15 -1
- 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 +29 -12
- package/dist/opc/DirectoryPartStore.d.mts +6 -2
- package/dist/opc/DirectoryPartStore.mjs +11 -4
- package/dist/opc/FlatOpcPartStore.d.mts +4 -2
- package/dist/opc/FlatOpcPartStore.mjs +11 -8
- package/dist/opc/Load.d.mts +32 -0
- package/dist/opc/Load.mjs +115 -5
- package/dist/opc/PartStore.d.mts +34 -1
- package/dist/opc/PartStore.mjs +71 -8
- package/dist/opc/Save.d.mts +32 -0
- package/dist/opc/Save.mjs +110 -4
- package/dist/opc/ZipPartStore.d.mts +4 -2
- package/dist/opc/ZipPartStore.mjs +12 -7
- package/dist/opc/exceptions.d.mts +140 -0
- package/dist/opc/exceptions.mjs +108 -0
- package/dist/opc/index.d.mts +8 -5
- package/dist/opc/index.mjs +5 -3
- package/dist/opc/mce/preprocessor.d.mts +141 -5
- package/dist/opc/mce/preprocessor.mjs +119 -18
- package/dist/opc/mce/understood.d.mts +3 -11
- package/dist/opc/mce/understood.mjs +27 -23
- package/dist/opc/repair/breaks.d.mts +23 -0
- package/dist/opc/repair/breaks.mjs +288 -0
- package/dist/opc/repair/hosts.d.mts +12 -0
- package/dist/opc/repair/hosts.mjs +33 -0
- package/dist/opc/repair/mainRoot.d.mts +19 -0
- package/dist/opc/repair/mainRoot.mjs +168 -0
- package/dist/opc/repair/unknownElements.d.mts +8 -0
- package/dist/opc/repair/unknownElements.mjs +180 -0
- package/dist/opc/repair/wmlNames.generated.d.mts +2 -0
- package/dist/opc/repair/wmlNames.generated.mjs +80 -0
- package/dist/opc/skipped.d.mts +50 -0
- package/dist/opc/skipped.mjs +140 -0
- package/dist/packages/OpcPackage.d.mts +110 -4
- package/dist/packages/OpcPackage.mjs +123 -7
- package/dist/packages/WordprocessingMLPackage.d.mts +45 -8
- package/dist/packages/WordprocessingMLPackage.mjs +158 -21
- package/dist/packages/index.d.mts +1 -1
- package/dist/parts/DefaultXmlPart.mjs +2 -2
- package/dist/parts/Part.d.mts +14 -2
- package/dist/parts/RelationshipsPart.d.mts +15 -0
- package/dist/parts/RelationshipsPart.mjs +66 -1
- package/dist/parts/XmlPart.d.mts +63 -32
- package/dist/parts/XmlPart.mjs +240 -96
- package/dist/parts/wml/comments.mjs +30 -0
- package/dist/parts/wml/index.d.mts +12 -1
- package/dist/parts/wml/index.mjs +37 -1
- package/dist/xml/dom.d.mts +7 -0
- package/dist/xml/dom.mjs +18 -0
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -35,6 +46,16 @@ export declare const WORD_DEFAULT_CELL_MARGIN_TWIPS = 108;
|
|
|
35
46
|
* {@link PropertyResolver.getLvlFromHeadingStyle} keys on the English style id.
|
|
36
47
|
*/
|
|
37
48
|
export declare function headingLevelByName(style: wml.Style | undefined): number;
|
|
49
|
+
/** How `create` reads the parts it is given. */
|
|
50
|
+
export interface PropertyResolverCreateOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Called with a styles or numbering part that cannot be read, which the resolver then leaves out, as for a package that
|
|
53
|
+
* lacks it, where `create` would otherwise refuse the whole (`readOrRefuse`). The text model's reading takes this
|
|
54
|
+
* (CR-012 section 28, WD REQ-801's `part.not_read`); the package's own resolver never does, so the content API still
|
|
55
|
+
* refuses such a part (CR-001 section 26).
|
|
56
|
+
*/
|
|
57
|
+
onUnreadable?: (role: 'styles' | 'numbering', error: unknown) => void;
|
|
58
|
+
}
|
|
38
59
|
export declare class PropertyResolver {
|
|
39
60
|
private readonly provider;
|
|
40
61
|
/** Set when the styles tree the resolver holds is not the styles part's own. */
|
|
@@ -48,6 +69,8 @@ export declare class PropertyResolver {
|
|
|
48
69
|
/** A style's `w:basedOn` chain merged root-first, WITHOUT the document defaults, per style id. */
|
|
49
70
|
private readonly chainPPrCache;
|
|
50
71
|
private readonly chainRPrCache;
|
|
72
|
+
/** A character style's chain as it applies to a run, where it differs from its chain: see {@link characterLevel}. */
|
|
73
|
+
private readonly characterLevelCache;
|
|
51
74
|
/** The document defaults with the chain applied over them: what the style overloads return. */
|
|
52
75
|
private readonly effectivePPrByStyle;
|
|
53
76
|
private readonly effectiveRPrByStyle;
|
|
@@ -68,6 +91,8 @@ export declare class PropertyResolver {
|
|
|
68
91
|
* where they state one. Read once per `refresh()`.
|
|
69
92
|
*/
|
|
70
93
|
private docDefaultsStateSize;
|
|
94
|
+
/** Whether a paragraph style and a character style hide a run, by paragraph style then character style (`isVanishedByStyles`). */
|
|
95
|
+
private readonly vanishCache;
|
|
71
96
|
/** Missing styles are logged once each per resolver. */
|
|
72
97
|
private readonly missingLogged;
|
|
73
98
|
private numberingDefinitions;
|
|
@@ -84,8 +109,11 @@ export declare class PropertyResolver {
|
|
|
84
109
|
* document whose styles nobody has edited still saves byte for byte. Once something else
|
|
85
110
|
* unmarshals the part - the comment styles, a caller's `getContents()` - `refresh()` picks
|
|
86
111
|
* up that live tree instead of the private copy.
|
|
112
|
+
*
|
|
113
|
+
* A styles or numbering part that cannot be read refuses the whole, unless `options.onUnreadable` is given, when the part
|
|
114
|
+
* is left out and reported to it.
|
|
87
115
|
*/
|
|
88
|
-
static create(pkg: PackageLike | ResolverSource): Promise<PropertyResolver>;
|
|
116
|
+
static create(pkg: PackageLike | ResolverSource, options?: PropertyResolverCreateOptions): Promise<PropertyResolver>;
|
|
89
117
|
/** Builds a resolver over object trees directly (a test, or parts already in hand). */
|
|
90
118
|
static fromSource(source: ResolverSource): PropertyResolver;
|
|
91
119
|
private init;
|
|
@@ -104,6 +132,28 @@ export declare class PropertyResolver {
|
|
|
104
132
|
* contents replaced. The content API calls it where it creates a style.
|
|
105
133
|
*/
|
|
106
134
|
refresh(): void;
|
|
135
|
+
private themeColors;
|
|
136
|
+
/**
|
|
137
|
+
* The document's theme colours: its theme part (or the bundled theme `pkg.fonts.defaultTheme` names where it has
|
|
138
|
+
* none) and the settings' `w:clrSchemeMapping`. Read once per `refresh()`. A resolver made `fromSource` with no
|
|
139
|
+
* theme parses the bundled one, which needs the objects package's context built (`ThemeColors.loadDefaultTheme()`).
|
|
140
|
+
*/
|
|
141
|
+
getThemeColors(): ThemeColors;
|
|
142
|
+
/**
|
|
143
|
+
* The colour Word draws for a run's `w:color`: its theme reference where it has one (the value beside it is a
|
|
144
|
+
* cache), else its value.
|
|
145
|
+
*
|
|
146
|
+
* @returns undefined for automatic: the caller's default (black text, as a rule)
|
|
147
|
+
*/
|
|
148
|
+
resolveColor(color: wml.Color | undefined): ResolvedColor | undefined;
|
|
149
|
+
/** A border's colour, as {@link resolveColor}; undefined for automatic. docx4j `resolveColor(CTBorder)`. */
|
|
150
|
+
resolveBorderColor(border: wml.CTBorder | undefined): ResolvedColor | undefined;
|
|
151
|
+
/** An underline's colour, as {@link resolveColor}; undefined for automatic (the text's). docx4j `resolveColor(U)`. */
|
|
152
|
+
resolveUnderlineColor(u: wml.U | undefined): ResolvedColor | undefined;
|
|
153
|
+
/** A shading's fill (`w:fill`, `w:themeFill`); undefined for automatic. */
|
|
154
|
+
resolveFill(shd: wml.CTShd | undefined): ResolvedColor | undefined;
|
|
155
|
+
/** A shading's pattern colour (`w:color`, `w:themeColor`); undefined for automatic. */
|
|
156
|
+
resolvePatternColor(shd: wml.CTShd | undefined): ResolvedColor | undefined;
|
|
107
157
|
getDocumentDefaultPPr(): wml.PPr;
|
|
108
158
|
getDocumentDefaultRPr(): wml.RPr;
|
|
109
159
|
/** The style id of the `w:default="1"` paragraph style, or undefined when the part declares none. */
|
|
@@ -112,6 +162,13 @@ export declare class PropertyResolver {
|
|
|
112
162
|
getResolvedDefaultParagraphStyle(): wml.PPr;
|
|
113
163
|
/** The style with this id, or undefined (docx4j `getStyle`). */
|
|
114
164
|
getStyle(styleId: string | undefined): wml.Style | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* The styles part's `w:style` elements in document order, from the tree this resolver reads (its
|
|
167
|
+
* private copy, or the part's own once that is unmarshalled); empty where there is no styles part.
|
|
168
|
+
* docx4j reads `StyleDefinitionsPart.getJaxbElement().getStyle()` where order matters
|
|
169
|
+
* (`Emulator.levelStyleId`: the first paragraph style in styles.xml carrying a level owns it).
|
|
170
|
+
*/
|
|
171
|
+
getStylesInOrder(): readonly wml.Style[];
|
|
115
172
|
/**
|
|
116
173
|
* The list definitions of the numbering part this resolver read (CR-001 Phase B step 3), or
|
|
117
174
|
* undefined where the package has none. The resolver builds them because the paragraph merge
|
|
@@ -138,6 +195,13 @@ export declare class PropertyResolver {
|
|
|
138
195
|
* object: copy before changing.
|
|
139
196
|
*/
|
|
140
197
|
getChainRPr(styleId: string | undefined): wml.RPr;
|
|
198
|
+
/**
|
|
199
|
+
* A character style's chain as a level over a run or a paragraph mark: {@link getChainRPr} without its highlight,
|
|
200
|
+
* since Word draws no highlight from a character style (docx4j CR-060 section 13, round 6: alone, with bold, or
|
|
201
|
+
* through `w:basedOn`; its save writes `w:highlight="none"` on such a run). A paragraph style's highlight and a
|
|
202
|
+
* run's own are drawn. docx4j `characterLevel` (1d1b824a9). Cached; live: copy before changing.
|
|
203
|
+
*/
|
|
204
|
+
private characterLevel;
|
|
141
205
|
/**
|
|
142
206
|
* A style's own `w:pPr` as a layer of its chain. The built-in heading styles have a fixed
|
|
143
207
|
* outline level, which Word takes from the style's built-in NAME ("heading 1" ...
|
|
@@ -199,6 +263,14 @@ export declare class PropertyResolver {
|
|
|
199
263
|
* context resolves exactly as `getEffectiveRPr(rPr, pPr)`. A new object each call.
|
|
200
264
|
*/
|
|
201
265
|
getEffectiveRPr(rPr: wml.RPr | undefined, pPr: wml.PPr | undefined, cellContext: CellContext | undefined): wml.RPr;
|
|
266
|
+
/**
|
|
267
|
+
* Whether a run with no `w:vanish` of its own is hidden by its styles: the effective `w:vanish` of its
|
|
268
|
+
* paragraph style (undefined: the default paragraph style) and its character style, the table style left
|
|
269
|
+
* out, as the text model's hidden rule has it (REQ-507). What `Paragraph.text` leaves out, as Office JS
|
|
270
|
+
* does (CR-012 phase 4, check 48b case 20). Cached per pair; a pair naming a style the part lacks is
|
|
271
|
+
* not cached, so that adding the style is seen.
|
|
272
|
+
*/
|
|
273
|
+
isVanishedByStyles(paragraphStyleId: string | undefined, runStyleId: string | undefined): boolean;
|
|
202
274
|
private effectiveRPrOfStyle;
|
|
203
275
|
/**
|
|
204
276
|
* 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. */
|
|
@@ -95,6 +98,18 @@ async function readOrRefuse(part, role) {
|
|
|
95
98
|
throw new Docx4JException(`${lead} ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
96
99
|
}
|
|
97
100
|
}
|
|
101
|
+
/** `readOrRefuse`, or, given `onUnreadable`, undefined for a part that cannot be read, reported to it. */
|
|
102
|
+
async function readOrOmit(part, role, onUnreadable) {
|
|
103
|
+
if (onUnreadable === undefined)
|
|
104
|
+
return readOrRefuse(part, role);
|
|
105
|
+
try {
|
|
106
|
+
return await part.readContents();
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
onUnreadable(role, e);
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
98
113
|
export class PropertyResolver {
|
|
99
114
|
constructor(provider,
|
|
100
115
|
/** Set when the styles tree the resolver holds is not the styles part's own. */
|
|
@@ -110,6 +125,8 @@ export class PropertyResolver {
|
|
|
110
125
|
/** A style's `w:basedOn` chain merged root-first, WITHOUT the document defaults, per style id. */
|
|
111
126
|
this.chainPPrCache = new Map();
|
|
112
127
|
this.chainRPrCache = new Map();
|
|
128
|
+
/** A character style's chain as it applies to a run, where it differs from its chain: see {@link characterLevel}. */
|
|
129
|
+
this.characterLevelCache = new Map();
|
|
113
130
|
/** The document defaults with the chain applied over them: what the style overloads return. */
|
|
114
131
|
this.effectivePPrByStyle = new Map();
|
|
115
132
|
this.effectiveRPrByStyle = new Map();
|
|
@@ -130,6 +147,8 @@ export class PropertyResolver {
|
|
|
130
147
|
* where they state one. Read once per `refresh()`.
|
|
131
148
|
*/
|
|
132
149
|
this.docDefaultsStateSize = false;
|
|
150
|
+
/** Whether a paragraph style and a character style hide a run, by paragraph style then character style (`isVanishedByStyles`). */
|
|
151
|
+
this.vanishCache = new Map();
|
|
133
152
|
/** Missing styles are logged once each per resolver. */
|
|
134
153
|
this.missingLogged = new Set();
|
|
135
154
|
this.source = provider();
|
|
@@ -143,8 +162,11 @@ export class PropertyResolver {
|
|
|
143
162
|
* document whose styles nobody has edited still saves byte for byte. Once something else
|
|
144
163
|
* unmarshals the part - the comment styles, a caller's `getContents()` - `refresh()` picks
|
|
145
164
|
* up that live tree instead of the private copy.
|
|
165
|
+
*
|
|
166
|
+
* A styles or numbering part that cannot be read refuses the whole, unless `options.onUnreadable` is given, when the part
|
|
167
|
+
* is left out and reported to it.
|
|
146
168
|
*/
|
|
147
|
-
static async create(pkg) {
|
|
169
|
+
static async create(pkg, options) {
|
|
148
170
|
if (typeof pkg.getMainDocumentPart !== 'function') {
|
|
149
171
|
const source = pkg;
|
|
150
172
|
return new PropertyResolver(() => source);
|
|
@@ -158,8 +180,8 @@ export class PropertyResolver {
|
|
|
158
180
|
}
|
|
159
181
|
const stylesPart = main.styleDefinitionsPart;
|
|
160
182
|
const numberingPart = main.numberingDefinitionsPart;
|
|
161
|
-
const privateStyles = stylesPart === undefined ? undefined : await
|
|
162
|
-
const privateNumbering = numberingPart === undefined ? undefined : await
|
|
183
|
+
const privateStyles = stylesPart === undefined ? undefined : await readOrOmit(stylesPart, 'styles', options === null || options === void 0 ? void 0 : options.onUnreadable);
|
|
184
|
+
const privateNumbering = numberingPart === undefined ? undefined : await readOrOmit(numberingPart, 'numbering', options === null || options === void 0 ? void 0 : options.onUnreadable);
|
|
163
185
|
// the settings are read for two compatibility values (CR-007), privately, as the others are
|
|
164
186
|
const settingsPart = main.documentSettingsPart;
|
|
165
187
|
let privateSettings;
|
|
@@ -169,10 +191,24 @@ export class PropertyResolver {
|
|
|
169
191
|
catch (e) {
|
|
170
192
|
log.warn(`The settings part could not be read; taking compatibility mode ${DEFAULT_COMPATIBILITY_MODE}: ${String(e)}`);
|
|
171
193
|
}
|
|
194
|
+
// the theme, for its colours (CR-008), privately too; where there is none, or it can't be read, the bundled theme
|
|
195
|
+
// the package names, parsed now so that getThemeColors() needn't wait
|
|
196
|
+
const themePart = main.themePart;
|
|
197
|
+
let privateTheme;
|
|
198
|
+
try {
|
|
199
|
+
privateTheme = themePart === undefined ? undefined : await themePart.readContents();
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
log.warn(`The theme part could not be read; its colours are the default theme's: ${String(e)}`);
|
|
203
|
+
}
|
|
204
|
+
const defaultTheme = themeOfSettings(pkg.fonts);
|
|
205
|
+
await ThemeColors.loadDefaultTheme(defaultTheme);
|
|
172
206
|
return new PropertyResolver(() => ({
|
|
173
207
|
styles: (stylesPart === null || stylesPart === void 0 ? void 0 : stylesPart.isUnmarshalled) === true ? stylesPart.contents : privateStyles,
|
|
174
208
|
numbering: (numberingPart === null || numberingPart === void 0 ? void 0 : numberingPart.isUnmarshalled) === true ? numberingPart.contents : privateNumbering,
|
|
175
209
|
settings: (settingsPart === null || settingsPart === void 0 ? void 0 : settingsPart.isUnmarshalled) === true ? settingsPart.contents : privateSettings,
|
|
210
|
+
theme: (themePart === null || themePart === void 0 ? void 0 : themePart.isUnmarshalled) === true ? themePart.contents : privateTheme,
|
|
211
|
+
defaultTheme,
|
|
176
212
|
}), () => stylesPart !== undefined && !stylesPart.isUnmarshalled);
|
|
177
213
|
}
|
|
178
214
|
/** Builds a resolver over object trees directly (a test, or parts already in hand). */
|
|
@@ -266,13 +302,52 @@ export class PropertyResolver {
|
|
|
266
302
|
refresh() {
|
|
267
303
|
this.chainPPrCache.clear();
|
|
268
304
|
this.chainRPrCache.clear();
|
|
305
|
+
this.characterLevelCache.clear();
|
|
269
306
|
this.effectivePPrByStyle.clear();
|
|
270
307
|
this.effectiveRPrByStyle.clear();
|
|
308
|
+
this.vanishCache.clear();
|
|
271
309
|
this.clearTableCaches();
|
|
272
310
|
this.missingLogged.clear();
|
|
311
|
+
this.themeColors = undefined;
|
|
273
312
|
this.source = this.provider();
|
|
274
313
|
this.init();
|
|
275
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* The document's theme colours: its theme part (or the bundled theme `pkg.fonts.defaultTheme` names where it has
|
|
317
|
+
* none) and the settings' `w:clrSchemeMapping`. Read once per `refresh()`. A resolver made `fromSource` with no
|
|
318
|
+
* theme parses the bundled one, which needs the objects package's context built (`ThemeColors.loadDefaultTheme()`).
|
|
319
|
+
*/
|
|
320
|
+
getThemeColors() {
|
|
321
|
+
var _a, _b;
|
|
322
|
+
(_a = this.themeColors) !== null && _a !== void 0 ? _a : (this.themeColors = ThemeColors.ofTheme(this.source.theme, this.source.defaultTheme)
|
|
323
|
+
.withWordMapping((_b = this.source.settings) === null || _b === void 0 ? void 0 : _b.clrSchemeMapping));
|
|
324
|
+
return this.themeColors;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The colour Word draws for a run's `w:color`: its theme reference where it has one (the value beside it is a
|
|
328
|
+
* cache), else its value.
|
|
329
|
+
*
|
|
330
|
+
* @returns undefined for automatic: the caller's default (black text, as a rule)
|
|
331
|
+
*/
|
|
332
|
+
resolveColor(color) {
|
|
333
|
+
return WordColors.of(color, this.getThemeColors());
|
|
334
|
+
}
|
|
335
|
+
/** A border's colour, as {@link resolveColor}; undefined for automatic. docx4j `resolveColor(CTBorder)`. */
|
|
336
|
+
resolveBorderColor(border) {
|
|
337
|
+
return WordColors.ofBorder(border, this.getThemeColors());
|
|
338
|
+
}
|
|
339
|
+
/** An underline's colour, as {@link resolveColor}; undefined for automatic (the text's). docx4j `resolveColor(U)`. */
|
|
340
|
+
resolveUnderlineColor(u) {
|
|
341
|
+
return WordColors.ofUnderline(u, this.getThemeColors());
|
|
342
|
+
}
|
|
343
|
+
/** A shading's fill (`w:fill`, `w:themeFill`); undefined for automatic. */
|
|
344
|
+
resolveFill(shd) {
|
|
345
|
+
return WordColors.fill(shd, this.getThemeColors());
|
|
346
|
+
}
|
|
347
|
+
/** A shading's pattern colour (`w:color`, `w:themeColor`); undefined for automatic. */
|
|
348
|
+
resolvePatternColor(shd) {
|
|
349
|
+
return WordColors.pattern(shd, this.getThemeColors());
|
|
350
|
+
}
|
|
276
351
|
// ------------------------------------------------------------------ defaults
|
|
277
352
|
getDocumentDefaultPPr() {
|
|
278
353
|
return this.documentDefaultPPr;
|
|
@@ -292,6 +367,16 @@ export class PropertyResolver {
|
|
|
292
367
|
getStyle(styleId) {
|
|
293
368
|
return this.getLiveStyle(styleId);
|
|
294
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* The styles part's `w:style` elements in document order, from the tree this resolver reads (its
|
|
372
|
+
* private copy, or the part's own once that is unmarshalled); empty where there is no styles part.
|
|
373
|
+
* docx4j reads `StyleDefinitionsPart.getJaxbElement().getStyle()` where order matters
|
|
374
|
+
* (`Emulator.levelStyleId`: the first paragraph style in styles.xml carrying a level owns it).
|
|
375
|
+
*/
|
|
376
|
+
getStylesInOrder() {
|
|
377
|
+
var _a, _b;
|
|
378
|
+
return (_b = (_a = this.source.styles) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : [];
|
|
379
|
+
}
|
|
295
380
|
/**
|
|
296
381
|
* The list definitions of the numbering part this resolver read (CR-001 Phase B step 3), or
|
|
297
382
|
* undefined where the package has none. The resolver builds them because the paragraph merge
|
|
@@ -366,6 +451,24 @@ export class PropertyResolver {
|
|
|
366
451
|
this.chainRPrCache.set(styleId, chain);
|
|
367
452
|
return chain;
|
|
368
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* A character style's chain as a level over a run or a paragraph mark: {@link getChainRPr} without its highlight,
|
|
456
|
+
* since Word draws no highlight from a character style (docx4j CR-060 section 13, round 6: alone, with bold, or
|
|
457
|
+
* through `w:basedOn`; its save writes `w:highlight="none"` on such a run). A paragraph style's highlight and a
|
|
458
|
+
* run's own are drawn. docx4j `characterLevel` (1d1b824a9). Cached; live: copy before changing.
|
|
459
|
+
*/
|
|
460
|
+
characterLevel(styleId) {
|
|
461
|
+
const chain = this.getChainRPr(styleId);
|
|
462
|
+
if (chain.highlight === undefined)
|
|
463
|
+
return chain;
|
|
464
|
+
let level = this.characterLevelCache.get(styleId);
|
|
465
|
+
if (level === undefined) {
|
|
466
|
+
level = deepCopy(chain);
|
|
467
|
+
delete level.highlight;
|
|
468
|
+
this.characterLevelCache.set(styleId, level);
|
|
469
|
+
}
|
|
470
|
+
return level;
|
|
471
|
+
}
|
|
369
472
|
/**
|
|
370
473
|
* A style's own `w:pPr` as a layer of its chain. The built-in heading styles have a fixed
|
|
371
474
|
* outline level, which Word takes from the style's built-in NAME ("heading 1" ...
|
|
@@ -452,6 +555,30 @@ export class PropertyResolver {
|
|
|
452
555
|
this.applyCharacterStyleAndDirect(arg, effective);
|
|
453
556
|
return effective;
|
|
454
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* Whether a run with no `w:vanish` of its own is hidden by its styles: the effective `w:vanish` of its
|
|
560
|
+
* paragraph style (undefined: the default paragraph style) and its character style, the table style left
|
|
561
|
+
* out, as the text model's hidden rule has it (REQ-507). What `Paragraph.text` leaves out, as Office JS
|
|
562
|
+
* does (CR-012 phase 4, check 48b case 20). Cached per pair; a pair naming a style the part lacks is
|
|
563
|
+
* not cached, so that adding the style is seen.
|
|
564
|
+
*/
|
|
565
|
+
isVanishedByStyles(paragraphStyleId, runStyleId) {
|
|
566
|
+
let byRunStyle = this.vanishCache.get(paragraphStyleId);
|
|
567
|
+
const cached = byRunStyle === null || byRunStyle === void 0 ? void 0 : byRunStyle.get(runStyleId);
|
|
568
|
+
if (cached !== undefined)
|
|
569
|
+
return cached;
|
|
570
|
+
const rPr = runStyleId === undefined ? undefined : { TYPE_NAME: 'org_docx4j_wml.RPr', rStyle: { TYPE_NAME: 'org_docx4j_wml.RStyle', val: runStyleId } };
|
|
571
|
+
const pPr = paragraphStyleId === undefined ? undefined : { TYPE_NAME: 'org_docx4j_wml.PPr', pStyle: { TYPE_NAME: 'org_docx4j_wml.PPrBase.PStyle', val: paragraphStyleId } };
|
|
572
|
+
const vanish = this.getEffectiveRPr(rPr, pPr).vanish;
|
|
573
|
+
const hidden = vanish !== undefined && vanish !== null && vanish.val !== false;
|
|
574
|
+
if ((paragraphStyleId === undefined || this.getLiveStyle(paragraphStyleId) !== undefined)
|
|
575
|
+
&& (runStyleId === undefined || this.getLiveStyle(runStyleId) !== undefined)) {
|
|
576
|
+
if (!byRunStyle)
|
|
577
|
+
this.vanishCache.set(paragraphStyleId, byRunStyle = new Map());
|
|
578
|
+
byRunStyle.set(runStyleId, hidden);
|
|
579
|
+
}
|
|
580
|
+
return hidden;
|
|
581
|
+
}
|
|
455
582
|
effectiveRPrOfStyle(styleId) {
|
|
456
583
|
const cached = this.effectiveRPrByStyle.get(styleId);
|
|
457
584
|
if (cached !== undefined)
|
|
@@ -481,7 +608,7 @@ export class PropertyResolver {
|
|
|
481
608
|
this.logMissing(runStyleId);
|
|
482
609
|
}
|
|
483
610
|
else {
|
|
484
|
-
applyStyleLevel(this.
|
|
611
|
+
applyStyleLevel(this.characterLevel(runStyleId), effective, this.documentDefaultRPr);
|
|
485
612
|
}
|
|
486
613
|
}
|
|
487
614
|
if (hasDirectFormattingRPr(rPr))
|
|
@@ -521,7 +648,7 @@ export class PropertyResolver {
|
|
|
521
648
|
this.logMissing(runStyleId);
|
|
522
649
|
}
|
|
523
650
|
else {
|
|
524
|
-
applyStyleLevel(this.
|
|
651
|
+
applyStyleLevel(this.characterLevel(runStyleId), effective, this.documentDefaultRPr);
|
|
525
652
|
}
|
|
526
653
|
}
|
|
527
654
|
applyRPr(mark, effective);
|
|
@@ -830,6 +957,7 @@ export class PropertyResolver {
|
|
|
830
957
|
// resolution of this style (and of anything based on it) has to be recomputed
|
|
831
958
|
this.chainPPrCache.clear();
|
|
832
959
|
this.chainRPrCache.clear();
|
|
960
|
+
this.characterLevelCache.clear();
|
|
833
961
|
this.effectivePPrByStyle.clear();
|
|
834
962
|
this.effectiveRPrByStyle.clear();
|
|
835
963
|
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
|
/**
|