@docx4j/core-ts 0.1.0 → 0.1.2
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/README.md +410 -10
- package/dist/model/content/Body.d.mts +109 -4
- package/dist/model/content/Body.mjs +300 -29
- package/dist/model/content/Comment.d.mts +78 -0
- package/dist/model/content/Comment.mjs +429 -0
- package/dist/model/content/ContentControl.d.mts +173 -0
- package/dist/model/content/ContentControl.mjs +638 -0
- package/dist/model/content/Font.d.mts +48 -8
- package/dist/model/content/Font.mjs +55 -13
- package/dist/model/content/InlinePicture.d.mts +103 -0
- package/dist/model/content/InlinePicture.mjs +361 -0
- package/dist/model/content/List.d.mts +253 -0
- package/dist/model/content/List.mjs +778 -0
- package/dist/model/content/Paragraph.d.mts +213 -16
- package/dist/model/content/Paragraph.mjs +611 -57
- package/dist/model/content/Range.d.mts +48 -4
- package/dist/model/content/Range.mjs +161 -4
- package/dist/model/content/Table.d.mts +130 -0
- package/dist/model/content/Table.mjs +429 -0
- package/dist/model/content/TrackedChange.d.mts +96 -0
- package/dist/model/content/TrackedChange.mjs +352 -0
- package/dist/model/content/comments.d.mts +122 -0
- package/dist/model/content/comments.mjs +248 -0
- package/dist/model/content/index.d.mts +13 -3
- package/dist/model/content/index.mjs +15 -3
- package/dist/model/content/ooxml.d.mts +17 -0
- package/dist/model/content/ooxml.mjs +214 -0
- package/dist/model/content/styles.d.mts +21 -0
- package/dist/model/content/styles.mjs +86 -0
- package/dist/model/content/tracking.d.mts +104 -0
- package/dist/model/content/tracking.mjs +313 -0
- package/dist/model/content/tree.d.mts +56 -9
- package/dist/model/content/tree.mjs +104 -31
- package/dist/model/customxml/CustomXmlPart.d.mts +158 -0
- package/dist/model/customxml/CustomXmlPart.mjs +415 -0
- package/dist/model/customxml/CustomXmlPartCollection.d.mts +68 -0
- package/dist/model/customxml/CustomXmlPartCollection.mjs +183 -0
- package/dist/model/customxml/XmlMapping.d.mts +46 -0
- package/dist/model/customxml/XmlMapping.mjs +98 -0
- package/dist/model/customxml/bindings.d.mts +41 -0
- package/dist/model/customxml/bindings.mjs +230 -0
- package/dist/model/customxml/index.d.mts +7 -0
- package/dist/model/customxml/index.mjs +9 -0
- package/dist/model/customxml/insert.d.mts +20 -0
- package/dist/model/customxml/insert.mjs +22 -0
- package/dist/model/customxml/kinds.d.mts +103 -0
- package/dist/model/customxml/kinds.mjs +267 -0
- package/dist/model/customxml/xpath.d.mts +52 -0
- package/dist/model/customxml/xpath.mjs +205 -0
- package/dist/model/fonts/CJKToEnglish.d.mts +2 -0
- package/dist/model/fonts/CJKToEnglish.mjs +16 -0
- package/dist/model/fonts/FontFallback.d.mts +58 -0
- package/dist/model/fonts/FontFallback.mjs +219 -0
- package/dist/model/fonts/IdentityPlusMapper.d.mts +7 -0
- package/dist/model/fonts/IdentityPlusMapper.mjs +19 -0
- package/dist/model/fonts/LanguageTagToScriptMapping.d.mts +7 -0
- package/dist/model/fonts/LanguageTagToScriptMapping.mjs +67 -0
- package/dist/model/fonts/Mapper.d.mts +190 -0
- package/dist/model/fonts/Mapper.mjs +481 -0
- package/dist/model/fonts/PhysicalFont.d.mts +34 -0
- package/dist/model/fonts/PhysicalFont.mjs +62 -0
- package/dist/model/fonts/RunFontSelector.d.mts +194 -0
- package/dist/model/fonts/RunFontSelector.mjs +441 -0
- package/dist/model/fonts/ThemeFonts.d.mts +17 -0
- package/dist/model/fonts/ThemeFonts.mjs +76 -0
- package/dist/model/fonts/defaultTheme.d.mts +37 -0
- package/dist/model/fonts/defaultTheme.mjs +57 -0
- package/dist/model/fonts/families.generated.d.mts +11 -0
- package/dist/model/fonts/families.generated.mjs +17 -0
- package/dist/model/fonts/fontsInUse.d.mts +39 -0
- package/dist/model/fonts/fontsInUse.mjs +183 -0
- package/dist/model/fonts/index.d.mts +14 -0
- package/dist/model/fonts/index.mjs +29 -0
- package/dist/model/fonts/lookup.d.mts +5 -0
- package/dist/model/fonts/lookup.mjs +12 -0
- package/dist/model/fonts/registry.d.mts +31 -0
- package/dist/model/fonts/registry.mjs +103 -0
- package/dist/model/fonts/scripts.d.mts +2 -0
- package/dist/model/fonts/scripts.mjs +78 -0
- package/dist/model/fonts/substitutions.generated.d.mts +30 -0
- package/dist/model/fonts/substitutions.generated.mjs +12 -0
- package/dist/model/fonts/themes.generated.d.mts +6 -0
- package/dist/model/fonts/themes.generated.mjs +11 -0
- package/dist/model/index.d.mts +5 -0
- package/dist/model/index.mjs +13 -1
- package/dist/model/listnumbering/Emulator.d.mts +187 -0
- package/dist/model/listnumbering/Emulator.mjs +332 -0
- package/dist/model/listnumbering/definitions.d.mts +251 -0
- package/dist/model/listnumbering/definitions.mjs +571 -0
- package/dist/model/listnumbering/formats.d.mts +25 -0
- package/dist/model/listnumbering/formats.mjs +320 -0
- package/dist/model/listnumbering/index.d.mts +4 -0
- package/dist/model/listnumbering/index.mjs +15 -0
- package/dist/model/listnumbering/state.d.mts +97 -0
- package/dist/model/listnumbering/state.mjs +179 -0
- package/dist/model/properties/PropertyResolver.d.mts +216 -0
- package/dist/model/properties/PropertyResolver.mjs +524 -0
- package/dist/model/properties/catalogue.d.mts +179 -0
- package/dist/model/properties/catalogue.mjs +860 -0
- package/dist/model/properties/index.d.mts +4 -0
- package/dist/model/properties/index.mjs +9 -0
- package/dist/model/properties/log.d.mts +7 -0
- package/dist/model/properties/log.mjs +25 -0
- package/dist/model/properties/styleUtil.d.mts +112 -0
- package/dist/model/properties/styleUtil.mjs +359 -0
- package/dist/node/index.d.mts +1 -0
- package/dist/node/index.mjs +12 -0
- package/dist/office-js/document.d.mts +111 -0
- package/dist/office-js/document.mjs +267 -0
- package/dist/office-js/enums.d.mts +187 -0
- package/dist/office-js/enums.mjs +176 -0
- package/dist/office-js/errors.d.mts +29 -0
- package/dist/office-js/errors.mjs +39 -0
- package/dist/office-js/extras.d.mts +5 -0
- package/dist/office-js/extras.mjs +29 -0
- package/dist/office-js/fragment.d.mts +10 -0
- package/dist/office-js/fragment.mjs +23 -0
- package/dist/office-js/index.d.mts +183 -0
- package/dist/office-js/index.mjs +54 -0
- package/dist/office-js/proxy.d.mts +72 -0
- package/dist/office-js/proxy.mjs +279 -0
- package/dist/office-js/run.d.mts +32 -0
- package/dist/office-js/run.mjs +66 -0
- package/dist/office-js/supported.d.mts +7 -0
- package/dist/office-js/supported.generated.d.mts +1 -0
- package/dist/office-js/supported.generated.mjs +235 -0
- package/dist/office-js/supported.mjs +53 -0
- package/dist/office-js/toApiScript.d.mts +25 -0
- package/dist/office-js/toApiScript.mjs +394 -0
- package/dist/opc/ContentTypes.d.mts +11 -0
- package/dist/opc/ContentTypes.mjs +14 -0
- package/dist/opc/DirectoryPartStore.d.mts +47 -0
- package/dist/opc/DirectoryPartStore.mjs +123 -0
- package/dist/opc/exceptions.d.mts +30 -0
- package/dist/opc/exceptions.mjs +38 -0
- package/dist/opc/index.d.mts +1 -1
- package/dist/opc/index.mjs +1 -1
- package/dist/packages/OpcPackage.d.mts +19 -1
- package/dist/packages/OpcPackage.mjs +29 -0
- package/dist/packages/PresentationMLPackage.d.mts +71 -1
- package/dist/packages/PresentationMLPackage.mjs +179 -0
- package/dist/packages/SpreadsheetMLPackage.d.mts +30 -1
- package/dist/packages/SpreadsheetMLPackage.mjs +78 -0
- package/dist/packages/WordprocessingMLPackage.d.mts +124 -2
- package/dist/packages/WordprocessingMLPackage.mjs +309 -2
- package/dist/packages/index.d.mts +1 -1
- package/dist/packages/index.mjs +1 -1
- package/dist/parts/DefaultXmlPart.d.mts +18 -0
- package/dist/parts/DefaultXmlPart.mjs +34 -5
- package/dist/parts/Namespaces.d.mts +18 -0
- package/dist/parts/Namespaces.mjs +20 -0
- package/dist/parts/Part.d.mts +6 -0
- package/dist/parts/Part.mjs +13 -0
- package/dist/parts/PartRegistry.mjs +13 -1
- package/dist/parts/XmlPart.d.mts +33 -0
- package/dist/parts/XmlPart.mjs +105 -2
- package/dist/parts/pml/defaults.d.mts +6 -0
- package/dist/parts/pml/defaults.mjs +53 -0
- package/dist/parts/pml/index.d.mts +66 -3
- package/dist/parts/pml/index.mjs +206 -7
- package/dist/parts/pml/placeholders.d.mts +71 -0
- package/dist/parts/pml/placeholders.mjs +141 -0
- package/dist/parts/sml/index.d.mts +80 -1
- package/dist/parts/sml/index.mjs +154 -1
- package/dist/parts/wml/comments.d.mts +1 -0
- package/dist/parts/wml/comments.mjs +179 -0
- package/dist/parts/wml/defaultNumbering.d.mts +1 -0
- package/dist/parts/wml/defaultNumbering.mjs +216 -0
- package/dist/parts/wml/index.d.mts +121 -0
- package/dist/parts/wml/index.mjs +291 -0
- package/dist/xml/dom.mjs +1 -2
- package/package.json +25 -4
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { log } from '../properties/log.mjs';
|
|
2
|
+
import { NumberingState } from './state.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Where a paragraph's numbering comes from once its own `w:numPr` and its style chain have been
|
|
5
|
+
* read. docx4j `Emulator.NumRef` (17.1.1, CR-014 phase 3).
|
|
6
|
+
*/
|
|
7
|
+
export class NumRef {
|
|
8
|
+
constructor(numId, ilvl, direct, notNumbered, reason) {
|
|
9
|
+
this.numId = numId;
|
|
10
|
+
this.ilvl = ilvl;
|
|
11
|
+
this.direct = direct;
|
|
12
|
+
this.notNumbered = notNumbered;
|
|
13
|
+
this.reason = reason;
|
|
14
|
+
}
|
|
15
|
+
/** A paragraph Word numbers, at this list and level. */
|
|
16
|
+
static numbered(numId, ilvl, direct) {
|
|
17
|
+
return new NumRef(numId, ilvl, direct, false, undefined);
|
|
18
|
+
}
|
|
19
|
+
/** A paragraph Word does not number, and why. */
|
|
20
|
+
static not(reason) {
|
|
21
|
+
return new NumRef(undefined, undefined, false, true, reason);
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
return this.notNumbered
|
|
25
|
+
? `not numbered: ${this.reason}`
|
|
26
|
+
: `numId ${this.numId} ilvl ${this.ilvl} (${this.direct ? 'direct' : 'from style'})`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function numberingPartOf(pkg) {
|
|
30
|
+
try {
|
|
31
|
+
return pkg === null || pkg === void 0 ? void 0 : pkg.getMainDocumentPart().numberingDefinitionsPart;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined; // no main document part
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The numbering of one package's numbering part: the definitions, the `PropertyResolver` the
|
|
39
|
+
* resolution goes through, and the part's default {@link NumberingState}.
|
|
40
|
+
*
|
|
41
|
+
* docx4j's `Emulator` is a marker object with static methods over maps the part holds; here the
|
|
42
|
+
* instance carries what those statics look up, and the statics delegate to it.
|
|
43
|
+
*/
|
|
44
|
+
export class Emulator {
|
|
45
|
+
constructor(
|
|
46
|
+
/** The definitions this emulator counts in. */
|
|
47
|
+
definitions,
|
|
48
|
+
/** The resolver a style-contributed `w:numPr` is read through; undefined disables that path. */
|
|
49
|
+
resolver, state = new NumberingState()) {
|
|
50
|
+
this.definitions = definitions;
|
|
51
|
+
this.resolver = resolver;
|
|
52
|
+
this.state = state;
|
|
53
|
+
}
|
|
54
|
+
/** The counters the state-less calls use. docx4j `NumberingDefinitionsPart.getNumberingState()`. */
|
|
55
|
+
get numberingState() {
|
|
56
|
+
return this.state;
|
|
57
|
+
}
|
|
58
|
+
/** Every list starts again: what `getEmulator(true)` does to the part's default state. */
|
|
59
|
+
newState() {
|
|
60
|
+
this.state = new NumberingState();
|
|
61
|
+
return this.state;
|
|
62
|
+
}
|
|
63
|
+
// ---------------------------------------------------------------- resolution
|
|
64
|
+
/**
|
|
65
|
+
* Whether this level belongs to a **different** paragraph style than the one which brought the
|
|
66
|
+
* numbering to this paragraph, in which case Word paints no label and does not count the
|
|
67
|
+
* paragraph. docx4j `Emulator.styleLinkedElsewhere` (17.1.0, measured on `numbering-label-ilvl0`).
|
|
68
|
+
*
|
|
69
|
+
* ECMA-376 17.9.24's `w:pStyle` inside a `w:lvl` names the paragraph style the level is linked
|
|
70
|
+
* to. The style itself, or any style it is based on, counts as the level's own. Direct
|
|
71
|
+
* formatting is never suppressed: a paragraph whose *own* `w:numPr` names such a level is
|
|
72
|
+
* numbered.
|
|
73
|
+
*/
|
|
74
|
+
styleLinkedElsewhere(numId, ilvl, pStyleVal) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const linked = this.definitions.getLinkedStyleId(numId, ilvl);
|
|
77
|
+
if (linked === undefined || linked === '')
|
|
78
|
+
return false;
|
|
79
|
+
if (pStyleVal === undefined)
|
|
80
|
+
return true;
|
|
81
|
+
const seen = new Set();
|
|
82
|
+
let id = pStyleVal;
|
|
83
|
+
while (id !== undefined && !seen.has(id)) {
|
|
84
|
+
seen.add(id);
|
|
85
|
+
if (linked === id)
|
|
86
|
+
return false;
|
|
87
|
+
const style = (_a = this.resolver) === null || _a === void 0 ? void 0 : _a.getStyle(id);
|
|
88
|
+
id = (_b = style === null || style === void 0 ? void 0 : style.basedOn) === null || _b === void 0 ? void 0 : _b.val;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The one resolution of numId and ilvl for a paragraph. docx4j `Emulator.resolve`
|
|
94
|
+
* (CR-014 phase 3, which collapsed `getNumber`'s and `getInd`'s two copies onto it).
|
|
95
|
+
*
|
|
96
|
+
* From the paragraph's own `w:numPr` where it has one; otherwise from the *effective* `w:pPr`
|
|
97
|
+
* of its paragraph style - the `w:default="1"` paragraph style when it names none, since that
|
|
98
|
+
* style may itself be numbered (measured, CR-014 P6) - then the `w:numId` 0 rule and the
|
|
99
|
+
* §2.8 rule for a style-contributed level linked to another style.
|
|
100
|
+
*
|
|
101
|
+
* @param numId the paragraph's numId, or undefined/"" to read the style
|
|
102
|
+
* @param ilvl the paragraph's ilvl, or undefined/"" for the style's, else "0"
|
|
103
|
+
* @param directNumPr whether a numId given here is the paragraph's own
|
|
104
|
+
*/
|
|
105
|
+
resolve(pStyleVal, numId, ilvl, directNumPr) {
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
|
+
let styleId = pStyleVal === undefined || pStyleVal === '' ? undefined : pStyleVal;
|
|
108
|
+
let direct = directNumPr;
|
|
109
|
+
let list = numId === undefined || numId === '' ? undefined : numId;
|
|
110
|
+
let level = ilvl === undefined || ilvl === '' ? undefined : ilvl;
|
|
111
|
+
if (list === undefined) {
|
|
112
|
+
// no explicit numId: is it provided by the style (ie does this style, or the default
|
|
113
|
+
// paragraph style, have a list associated with it)?
|
|
114
|
+
direct = false;
|
|
115
|
+
if (styleId === undefined) {
|
|
116
|
+
styleId = (_a = this.resolver) === null || _a === void 0 ? void 0 : _a.getDefaultParagraphStyleId();
|
|
117
|
+
if (styleId === undefined) {
|
|
118
|
+
return NumRef.not('no numId, no paragraph style and no default paragraph style');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
let pPr;
|
|
122
|
+
try {
|
|
123
|
+
pPr = (_b = this.resolver) === null || _b === void 0 ? void 0 : _b.getEffectivePPr(styleId);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
log.warn(String(e));
|
|
127
|
+
return NumRef.not(`cyclic styles at ${styleId}`);
|
|
128
|
+
}
|
|
129
|
+
if (pPr === undefined)
|
|
130
|
+
return NumRef.not(`style '${styleId}' has no pPr`);
|
|
131
|
+
const numPr = pPr.numPr;
|
|
132
|
+
if (numPr === undefined) {
|
|
133
|
+
// no numbering set on the style either; that's ok
|
|
134
|
+
return NumRef.not(`no numId, and style '${styleId}' is not numbered`);
|
|
135
|
+
}
|
|
136
|
+
if (((_c = numPr.numId) === null || _c === void 0 ? void 0 : _c.val) === undefined) {
|
|
137
|
+
return NumRef.not(`style '${styleId}' has a w:numPr without a w:numId val`);
|
|
138
|
+
}
|
|
139
|
+
list = String(numPr.numId.val);
|
|
140
|
+
if (level === undefined) {
|
|
141
|
+
// w:ilvl (and its w:val) is optional; its absence means level 0
|
|
142
|
+
level = ((_d = numPr.ilvl) === null || _d === void 0 ? void 0 : _d.val) === undefined ? '0' : String(numPr.ilvl.val);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (list === '0') {
|
|
146
|
+
// ECMA-376 17.9.18: a w:numId of 0 never references a definition; it designates the
|
|
147
|
+
// removal of numbering at this level (a paragraph or style switching an inherited list
|
|
148
|
+
// off). docx4j adopted this reading, and these words, on 2026-09-19 (01d661547).
|
|
149
|
+
return NumRef.not(`${direct ? "the paragraph's" : `style '${styleId}'s`} w:numId 0 turns numbering off`);
|
|
150
|
+
}
|
|
151
|
+
const definition = this.definitions.list(list);
|
|
152
|
+
if (definition === undefined) {
|
|
153
|
+
// A w:numId naming no w:num - Word's own re-save leaves one behind in an untouched
|
|
154
|
+
// mc:Fallback after renumbering (docx4j CR-021 §8.5) - is not numbered, and says so
|
|
155
|
+
// here rather than as an empty result from getNumber (docx4j d34852bdd).
|
|
156
|
+
return NumRef.not(`no w:num for numId ${list}${sourceSuffix(direct, styleId)}`);
|
|
157
|
+
}
|
|
158
|
+
if (level === undefined) {
|
|
159
|
+
log.warn('No level id?! Default to 0.');
|
|
160
|
+
level = '0';
|
|
161
|
+
}
|
|
162
|
+
if (!definition.levelExists(level)) {
|
|
163
|
+
// The w:num exists but its definition has no w:lvl for this ilvl: not numbered, with
|
|
164
|
+
// the reason here rather than an empty result from getNumber (docx4j 7fba7a150).
|
|
165
|
+
return NumRef.not(`no w:lvl ${level} in w:num ${list}${sourceSuffix(direct, styleId)}`);
|
|
166
|
+
}
|
|
167
|
+
if (!direct && this.styleLinkedElsewhere(list, level, styleId)) {
|
|
168
|
+
return NumRef.not(`level ${level} of numId ${list} is linked to a paragraph style other than '${styleId}'`);
|
|
169
|
+
}
|
|
170
|
+
return NumRef.numbered(list, level, direct);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 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.
|
|
175
|
+
*/
|
|
176
|
+
numRefFor(pPr) {
|
|
177
|
+
if (pPr === undefined)
|
|
178
|
+
return NumRef.not('no pPr');
|
|
179
|
+
const [pStyleVal, numId, ilvl] = readNumPr(pPr);
|
|
180
|
+
return this.resolve(pStyleVal, numId, ilvl, numId !== undefined && numId !== '');
|
|
181
|
+
}
|
|
182
|
+
// ---------------------------------------------------------------- counting
|
|
183
|
+
/**
|
|
184
|
+
* The next number for a paragraph, from its `w:pPr` (its own `w:numPr`, else its style's),
|
|
185
|
+
* counted in `state` or in this emulator's default state.
|
|
186
|
+
*
|
|
187
|
+
* @returns undefined where the paragraph is not numbered
|
|
188
|
+
*/
|
|
189
|
+
getNumber(pPr, state) {
|
|
190
|
+
if (pPr === undefined)
|
|
191
|
+
return undefined;
|
|
192
|
+
const [pStyleVal, numId, ilvl] = readNumPr(pPr);
|
|
193
|
+
return this.getNumberOf(pStyleVal, numId, ilvl, numId !== undefined && numId !== '', state);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The next number given the paragraph's style and, where it has one, its own numId and ilvl.
|
|
197
|
+
* docx4j's `getNumber(pkg, pStyleVal, numId, levelId, directNumPr, state)`.
|
|
198
|
+
*/
|
|
199
|
+
getNumberOf(pStyleVal, numId, ilvl, directNumPr = numId !== undefined && numId !== '', state) {
|
|
200
|
+
const counters = state !== null && state !== void 0 ? state : this.state;
|
|
201
|
+
const ref = this.resolve(pStyleVal, numId, ilvl, directNumPr);
|
|
202
|
+
// docx4j logs the reason at DEBUG here; this package has no debug level, and a paragraph
|
|
203
|
+
// that is simply not in a list is the common case, so nothing is logged
|
|
204
|
+
if (ref.notNumbered)
|
|
205
|
+
return undefined;
|
|
206
|
+
return this.number(ref, counters);
|
|
207
|
+
}
|
|
208
|
+
/** Counts a resolved reference. The half of `getNumber` after `resolve`. */
|
|
209
|
+
number(ref, state) {
|
|
210
|
+
var _a;
|
|
211
|
+
const list = this.definitions.list(ref.numId);
|
|
212
|
+
const levelId = (_a = ref.ilvl) !== null && _a !== void 0 ? _a : '0';
|
|
213
|
+
if (list === undefined || !list.levelExists(levelId)) {
|
|
214
|
+
// Unreachable through `resolve`, which answers both cases with a `notNumbered` NumRef
|
|
215
|
+
// since docx4j d34852bdd / 7fba7a150; kept for a caller that builds a NumRef itself.
|
|
216
|
+
const reason = list === undefined
|
|
217
|
+
? `Couldn't find list ${ref.numId}`
|
|
218
|
+
: `Couldn't find level ${levelId} in list ${ref.numId}`;
|
|
219
|
+
log.warn(reason);
|
|
220
|
+
return emptyResult(ref, reason);
|
|
221
|
+
}
|
|
222
|
+
list.incrementCounter(levelId, state);
|
|
223
|
+
const level = list.level(levelId);
|
|
224
|
+
const numString = list.currentNumberString(levelId, state);
|
|
225
|
+
const font = level.font;
|
|
226
|
+
return {
|
|
227
|
+
numString,
|
|
228
|
+
numFont: font === undefined || font === '' ? undefined : font,
|
|
229
|
+
isBullet: level.isBullet,
|
|
230
|
+
bullet: level.isBullet ? level.lvlText : undefined,
|
|
231
|
+
ind: level.ind,
|
|
232
|
+
indResolved: this.definitions.indOf(list.numId, levelId),
|
|
233
|
+
rPr: level.rPr,
|
|
234
|
+
labelRPr: level.labelRPr,
|
|
235
|
+
lvl: level.abstractLvl,
|
|
236
|
+
numId: list.numId,
|
|
237
|
+
ilvl: level.ilvl,
|
|
238
|
+
level,
|
|
239
|
+
count: level.counter(state).value,
|
|
240
|
+
notNumbered: false,
|
|
241
|
+
reason: undefined,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/** What {@link getNumber} would return, leaving the state as it was. docx4j `peek`. */
|
|
245
|
+
peek(pPr, state) {
|
|
246
|
+
return this.getNumber(pPr, (state !== null && state !== void 0 ? state : this.state).copy());
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* The indent a paragraph's numbering level contributes, resolved the way {@link getNumber}
|
|
250
|
+
* resolves the level itself and read as `NumberingDefinitionsPart.getInd` reads it: the
|
|
251
|
+
* level's own `w:ind` first, then the linked style's, following `w:basedOn`. Undefined where
|
|
252
|
+
* the paragraph is not numbered or the level states none. docx4j `Emulator.getInd`.
|
|
253
|
+
*/
|
|
254
|
+
getInd(pStyleVal, numId, ilvl) {
|
|
255
|
+
const ref = this.resolve(pStyleVal, numId, ilvl, numId !== undefined && numId !== '');
|
|
256
|
+
if (ref.notNumbered)
|
|
257
|
+
return undefined;
|
|
258
|
+
return this.definitions.indOf(ref.numId, ref.ilvl);
|
|
259
|
+
}
|
|
260
|
+
// ---------------------------------------------------------------- docx4j's static entry points
|
|
261
|
+
/** The package's emulator, or undefined where it has no numbering part. */
|
|
262
|
+
static of(pkg) {
|
|
263
|
+
var _a;
|
|
264
|
+
return (_a = numberingPartOf(pkg)) === null || _a === void 0 ? void 0 : _a.getEmulator();
|
|
265
|
+
}
|
|
266
|
+
static getNumber(pkg, second, ...rest) {
|
|
267
|
+
const emulator = Emulator.of(pkg);
|
|
268
|
+
if (emulator === undefined)
|
|
269
|
+
return undefined;
|
|
270
|
+
if (typeof second === 'string' || rest.length > 1) {
|
|
271
|
+
const [numId, ilvl, directNumPr, state] = rest;
|
|
272
|
+
return emulator.getNumberOf(second, numId, ilvl, directNumPr !== null && directNumPr !== void 0 ? directNumPr : (numId !== undefined && numId !== ''), state);
|
|
273
|
+
}
|
|
274
|
+
return emulator.getNumber(second, rest[0]);
|
|
275
|
+
}
|
|
276
|
+
/** docx4j `Emulator.peek(wmlPackage, pPr, state)`: the number, without taking it. */
|
|
277
|
+
static peek(pkg, pPr, state) {
|
|
278
|
+
const emulator = Emulator.of(pkg);
|
|
279
|
+
return emulator === null || emulator === void 0 ? void 0 : emulator.peek(pPr, state);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* docx4j `Emulator.numRefFor(wmlPackage, pPr)`: where this paragraph's numbering resolves to,
|
|
283
|
+
* before any counting. Never undefined; a package with no numbering part, a null `w:pPr` or
|
|
284
|
+
* a package whose `PropertyResolver` has not been built each answer {@link NumRef.notNumbered}
|
|
285
|
+
* with the reason.
|
|
286
|
+
*/
|
|
287
|
+
static numRefFor(pkg, pPr) {
|
|
288
|
+
if (pPr === undefined)
|
|
289
|
+
return NumRef.not('no pPr');
|
|
290
|
+
const part = numberingPartOf(pkg);
|
|
291
|
+
if (part === undefined)
|
|
292
|
+
return NumRef.not('no numbering part');
|
|
293
|
+
const resolver = pkg === null || pkg === void 0 ? void 0 : pkg.propertyResolverOrUndefined;
|
|
294
|
+
if (resolver === undefined) {
|
|
295
|
+
return NumRef.not('no property resolver: await getPropertyResolver() first');
|
|
296
|
+
}
|
|
297
|
+
return part.getEmulator().numRefFor(pPr);
|
|
298
|
+
}
|
|
299
|
+
/** docx4j `Emulator.getInd(wmlPackage, pStyleVal, numId, levelId)`. */
|
|
300
|
+
static getInd(pkg, pStyleVal, numId, ilvl) {
|
|
301
|
+
var _a;
|
|
302
|
+
return (_a = Emulator.of(pkg)) === null || _a === void 0 ? void 0 : _a.getInd(pStyleVal, numId, ilvl);
|
|
303
|
+
}
|
|
304
|
+
toString() {
|
|
305
|
+
return `Emulator(${this.definitions.instanceListDefinitions.size} lists, `
|
|
306
|
+
+ `${this.definitions.abstractListDefinitions.size} definitions)`;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Where the `w:numPr` a reason is about came from, as docx4j words it: the paragraph's own
|
|
311
|
+
* direct formatting, or the style that contributed it.
|
|
312
|
+
*/
|
|
313
|
+
function sourceSuffix(direct, styleId) {
|
|
314
|
+
return direct ? " (the paragraph's own)" : ` (from style '${styleId}')`;
|
|
315
|
+
}
|
|
316
|
+
/** The paragraph style and the two `w:numPr` values a `w:pPr` states, each as a string. */
|
|
317
|
+
function readNumPr(pPr) {
|
|
318
|
+
var _a, _b, _c;
|
|
319
|
+
const pStyleVal = (_a = pPr.pStyle) === null || _a === void 0 ? void 0 : _a.val;
|
|
320
|
+
const numPr = pPr.numPr;
|
|
321
|
+
const numId = ((_b = numPr === null || numPr === void 0 ? void 0 : numPr.numId) === null || _b === void 0 ? void 0 : _b.val) === undefined ? undefined : String(numPr.numId.val);
|
|
322
|
+
const ilvl = ((_c = numPr === null || numPr === void 0 ? void 0 : numPr.ilvl) === null || _c === void 0 ? void 0 : _c.val) === undefined ? undefined : String(numPr.ilvl.val);
|
|
323
|
+
return [pStyleVal, numId, ilvl];
|
|
324
|
+
}
|
|
325
|
+
function emptyResult(ref, reason) {
|
|
326
|
+
return {
|
|
327
|
+
numString: undefined, numFont: undefined, isBullet: false, bullet: undefined,
|
|
328
|
+
ind: undefined, indResolved: undefined, rPr: undefined, labelRPr: undefined, lvl: undefined,
|
|
329
|
+
numId: ref.numId, ilvl: ref.ilvl, level: undefined, count: undefined,
|
|
330
|
+
notNumbered: true, reason,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import type * as wml from '@docx4j/generated-objects-ts/modules/org_docx4j_wml';
|
|
2
|
+
import type { NumberingIndents } from '../properties/styleUtil.mjs';
|
|
3
|
+
import type { Counter, NumberingState } from './state.mjs';
|
|
4
|
+
/** How many levels a list definition may have (ECMA-376: `w:ilvl` 0 to 8). */
|
|
5
|
+
export declare const LEVELS = 9;
|
|
6
|
+
/** What the definitions need of the styles: a style by id (the resolver's `getStyle`). */
|
|
7
|
+
export type StyleLookup = (styleId: string) => wml.Style | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* One `w:lvl`: the abstract definition's level, and - for a level of a `w:num` - the instance's
|
|
10
|
+
* `w:lvlOverride/w:lvl` applied over it. docx4j `ListLevel`; the count lives in a
|
|
11
|
+
* {@link NumberingState}, keyed by {@link abstractNumId} and {@link ilvl}.
|
|
12
|
+
*
|
|
13
|
+
* Five members are **merged** attribute by attribute, as docx4j's `setOverrides` merges them -
|
|
14
|
+
* the override replaces each only where it states one: `w:start`, `w:lvlRestart`, `w:lvlText`,
|
|
15
|
+
* `w:numFmt` (and so `isBullet`), and the `w:hAnsi` of the level's `w:rPr/w:rFonts`. Everything
|
|
16
|
+
* else is read off **one** `w:lvl`, the override where the instance has one and the abstract
|
|
17
|
+
* level otherwise ({@link controllingLvl}): `w:isLgl` (docx4j's rule, measured through
|
|
18
|
+
* `IsLglTest`), `w:pStyle`, `w:suff`, `w:lvlJc` and `w:lvlPicBulletId`. `w:ind` and the label's
|
|
19
|
+
* `w:rPr` have rules of their own; see {@link ind} and {@link labelRPr}.
|
|
20
|
+
*/
|
|
21
|
+
export declare class LevelDefinition {
|
|
22
|
+
/** `w:ilvl`, as a string ("0" to "8"): the counter's key, and docx4j's map key. */
|
|
23
|
+
readonly ilvl: string;
|
|
24
|
+
/** The `w:abstractNum/w:lvl` this level was read from. */
|
|
25
|
+
abstractLvl: wml.Lvl | undefined;
|
|
26
|
+
/** The instance's `w:lvlOverride/w:lvl` for this level, or undefined. */
|
|
27
|
+
overrideLvl: wml.Lvl | undefined;
|
|
28
|
+
/** The **referencing** `w:abstractNum` (the counter's key; never the `w:numStyleLink` target's). */
|
|
29
|
+
abstractNumId: string;
|
|
30
|
+
/** The `w:num` an instance level belongs to; undefined for an abstract one. */
|
|
31
|
+
ownerNumId: string | undefined;
|
|
32
|
+
/** `w:start` **less one**, since every fetch increments first. */
|
|
33
|
+
startValue: number;
|
|
34
|
+
/** This instance level carries a `w:startOverride`, spent on the `w:num`'s first use. */
|
|
35
|
+
hasStartOverride: boolean;
|
|
36
|
+
/** `w:lvlRestart` (ECMA-376 17.9.11), or undefined where the level states none. */
|
|
37
|
+
lvlRestart: number | undefined;
|
|
38
|
+
/** `w:lvlText`: the label pattern ("%1.%2."), or a bullet level's character. */
|
|
39
|
+
lvlText: string | undefined;
|
|
40
|
+
/** `w:numFmt`, or undefined where the level states none. */
|
|
41
|
+
numFmt: wml.NumberFormat | undefined;
|
|
42
|
+
/** Whether `w:numFmt` is `bullet`. */
|
|
43
|
+
isBullet: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The `w:hAnsi` of the level's `w:rPr/w:rFonts`, or undefined.
|
|
46
|
+
*
|
|
47
|
+
* @deprecated docx4j deprecated `ListLevel.getFont()` in 17.1.1: use {@link labelRPr} and its
|
|
48
|
+
* `w:rFonts`. Kept because `NumberingResult.numFont` is what the goldens record.
|
|
49
|
+
*/
|
|
50
|
+
font: string | undefined;
|
|
51
|
+
constructor(ilvl: string, lvl?: wml.Lvl);
|
|
52
|
+
/** Take from a `w:lvl` whatever it states; leave the rest alone. docx4j's constructor body. */
|
|
53
|
+
private read;
|
|
54
|
+
/** A copy for an instance definition. docx4j's copy constructor: no override, no owner. */
|
|
55
|
+
copy(): LevelDefinition;
|
|
56
|
+
/** Applies the instance's `w:lvlOverride/w:lvl`. docx4j `setOverrides`. */
|
|
57
|
+
applyOverride(lvl: wml.Lvl): void;
|
|
58
|
+
/** A `w:startOverride`: given effect on the first use of this `w:num` in a story. */
|
|
59
|
+
setStartValue(value: number): void;
|
|
60
|
+
/** `w:ilvl` as a number. */
|
|
61
|
+
get level(): number;
|
|
62
|
+
/**
|
|
63
|
+
* The one `w:lvl` the members docx4j does not merge are read from: the instance's override
|
|
64
|
+
* where there is one, else the abstract level's.
|
|
65
|
+
*/
|
|
66
|
+
get controllingLvl(): wml.Lvl | undefined;
|
|
67
|
+
/** `w:start` as the document states it (one more than {@link startValue}). */
|
|
68
|
+
get start(): number | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* `w:isLgl`: the levels this number *inherits* print in decimal whatever their own `w:numFmt`
|
|
71
|
+
* (Word's "legal style numbering": "Section 1.01" and not "Section I.01").
|
|
72
|
+
*/
|
|
73
|
+
get isLgl(): boolean;
|
|
74
|
+
/** The `w:pStyle` this level is linked to (ECMA-376 17.9.24), or undefined. */
|
|
75
|
+
get pStyle(): string | undefined;
|
|
76
|
+
/** `w:suff`: what separates the label from the text (tab, space, nothing). */
|
|
77
|
+
get suff(): string | undefined;
|
|
78
|
+
/** `w:lvlJc`: how the label is justified in its column. */
|
|
79
|
+
get lvlJc(): wml.JcEnumeration | undefined;
|
|
80
|
+
/** `w:lvlPicBulletId`: the `w:numPicBullet` a picture bullet level names. */
|
|
81
|
+
get lvlPicBulletId(): number | undefined;
|
|
82
|
+
/** The level's `w:pPr`: the override's where it has one, else the abstract level's. */
|
|
83
|
+
get pPr(): wml.PPr | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* The level's **own** `w:ind`: the instance's override level's where *it* states one, else the
|
|
86
|
+
* abstract level's (docx4j `Emulator.getNumber`'s `triple.ind`, since 17.1.0). The linked
|
|
87
|
+
* `w:pStyle`'s is not consulted here; {@link NumberingDefinitions.getInd} does that.
|
|
88
|
+
*/
|
|
89
|
+
get ind(): wml.PPrBase.Ind | undefined;
|
|
90
|
+
/** The **abstract** level's `w:rPr`, never the override's. docx4j `NumberingResult.getRPr()`. */
|
|
91
|
+
get rPr(): wml.RPr | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* The `w:rPr` the label is drawn with: the `w:lvlOverride/w:lvl`'s where the instance
|
|
94
|
+
* overrides this level with one carrying an rPr, else the abstract level's - one or the other,
|
|
95
|
+
* as Word applies them (CR-014 probe P3, measured: an abstract `w:i` under an override
|
|
96
|
+
* `w:b` + `w:sz 36` gives a bold 18pt label with no italic anywhere). It formats the number
|
|
97
|
+
* alone, never the paragraph's text (ECMA-376 17.9.24).
|
|
98
|
+
*/
|
|
99
|
+
get labelRPr(): wml.RPr | undefined;
|
|
100
|
+
/** This level's counter in the given state. */
|
|
101
|
+
counter(state: NumberingState): Counter;
|
|
102
|
+
/**
|
|
103
|
+
* One more item at this level. docx4j `incrementCounter(state)`.
|
|
104
|
+
*
|
|
105
|
+
* The shared counter takes this level's start value the first time it is met in the state, and
|
|
106
|
+
* again the first time this instance level's `w:num` is met there when that `w:num` overrides
|
|
107
|
+
* the start - deferred until then, since otherwise earlier numbering over the same abstract
|
|
108
|
+
* list would use it.
|
|
109
|
+
*/
|
|
110
|
+
incrementCounter(state: NumberingState): void;
|
|
111
|
+
/**
|
|
112
|
+
* A shallower level was used: the level shows its start value from now until it is next used,
|
|
113
|
+
* and that first use does not increment it (CR-014 probe P8; before, the counter went to
|
|
114
|
+
* start-1 and a deeper label printed "2.0.1" where Word prints "2.1.1").
|
|
115
|
+
*/
|
|
116
|
+
resetCounter(state: NumberingState): void;
|
|
117
|
+
/**
|
|
118
|
+
* Whether using `shallowerIlvl` (0-based) restarts this level. ECMA-376 17.9.11: without
|
|
119
|
+
* `w:lvlRestart` any shallower level restarts it; `w:val="0"` means none does; `w:val="n"`
|
|
120
|
+
* means levels 1..n (1-based, so ilvl 0..n-1) do and deeper ones do not. Measured, P8.
|
|
121
|
+
*/
|
|
122
|
+
restartsAfter(shallowerIlvl: number): boolean;
|
|
123
|
+
/** The count at this level, in this level's `w:numFmt`. */
|
|
124
|
+
currentValueFormatted(state: NumberingState, where?: string): string;
|
|
125
|
+
/** The count at this level as a decimal, whatever its `w:numFmt` (what `w:isLgl` shows). */
|
|
126
|
+
currentValueUnformatted(state: NumberingState): string;
|
|
127
|
+
toString(): string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* One `w:abstractNum`: its levels, and - where it carries `w:numStyleLink` - the numbering style
|
|
131
|
+
* whose definition it takes them from. docx4j `AbstractListNumberingDefinition`.
|
|
132
|
+
*/
|
|
133
|
+
export declare class AbstractListDefinition {
|
|
134
|
+
readonly abstractNum: wml.Numbering.AbstractNum;
|
|
135
|
+
/** `w:abstractNumId`. */
|
|
136
|
+
readonly id: string;
|
|
137
|
+
/** The levels, keyed by `w:ilvl` ("0" to "8"). */
|
|
138
|
+
readonly levels: Map<string, LevelDefinition>;
|
|
139
|
+
/** `w:numStyleLink`: the numbering style this definition takes its levels from. */
|
|
140
|
+
readonly linkedStyleId: string | undefined;
|
|
141
|
+
/** `w:styleLink`: the inverse pointer, read and not acted on, as docx4j. */
|
|
142
|
+
readonly styleLink: string | undefined;
|
|
143
|
+
constructor(abstractNum: wml.Numbering.AbstractNum);
|
|
144
|
+
private readLevels;
|
|
145
|
+
/** Adds (or replaces) the level read from this `w:lvl`. docx4j `readLevel`. */
|
|
146
|
+
readLevel(lvl: wml.Lvl): void;
|
|
147
|
+
/**
|
|
148
|
+
* The second pass for a definition carrying `w:numStyleLink`: read its levels from the
|
|
149
|
+
* abstract definition the numbering style's own `w:num` names. They count under **this**
|
|
150
|
+
* definition's id, not the linked one's. docx4j `updateDefinitionFromLinkedStyle`.
|
|
151
|
+
*/
|
|
152
|
+
updateFromLinkedStyle(linked: wml.Numbering.AbstractNum): void;
|
|
153
|
+
/** Whether this definition carries `w:numStyleLink`. */
|
|
154
|
+
get hasLinkedStyle(): boolean;
|
|
155
|
+
/** How many levels are defined; 0 for an unresolved `w:numStyleLink` definition. */
|
|
156
|
+
get levelCount(): number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* One `w:num`: the abstract definition it names, with its `w:lvlOverride`s applied to copies of
|
|
160
|
+
* that definition's levels, and the counting. docx4j `ListNumberingDefinition`.
|
|
161
|
+
*/
|
|
162
|
+
export declare class ListDefinition {
|
|
163
|
+
readonly num: wml.Numbering.Num;
|
|
164
|
+
/** `w:numId`. */
|
|
165
|
+
readonly numId: string;
|
|
166
|
+
/** The abstract definition this names, or undefined. */
|
|
167
|
+
readonly abstractDefinition: AbstractListDefinition | undefined;
|
|
168
|
+
/** The levels, with this instance's overrides applied. */
|
|
169
|
+
readonly levels: Map<string, LevelDefinition>;
|
|
170
|
+
constructor(num: wml.Numbering.Num, abstracts: ReadonlyMap<string, AbstractListDefinition>, resolveLinkedStyle: boolean);
|
|
171
|
+
/** The level with this `w:ilvl`, or undefined. */
|
|
172
|
+
level(ilvl: string | number): LevelDefinition | undefined;
|
|
173
|
+
/** Whether the level exists: Word writes `w:num`s whose abstract definition or level is missing. */
|
|
174
|
+
levelExists(ilvl: string | number): boolean;
|
|
175
|
+
/** Whether the level's `w:numFmt` is `bullet`. */
|
|
176
|
+
isBullet(ilvl: string | number): boolean;
|
|
177
|
+
/** The `w:hAnsi` font the level's `w:rPr` names, or undefined. */
|
|
178
|
+
font(ilvl: string | number): string | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* One more item at a level, and the deeper levels that restart after it reset.
|
|
181
|
+
* docx4j `incrementCounter(level, state)`.
|
|
182
|
+
*/
|
|
183
|
+
incrementCounter(ilvl: string | number, state: NumberingState): void;
|
|
184
|
+
/**
|
|
185
|
+
* The label of a level: its `w:lvlText` with the counters filled in ("1.2.", "(c)").
|
|
186
|
+
* docx4j `getCurrentNumberString(level, state)`.
|
|
187
|
+
*
|
|
188
|
+
* `w:isLgl` at **any** level shows the levels this number *inherits* in decimal whatever their
|
|
189
|
+
* own `w:numFmt`, the level carrying it keeping its own: Word's Article / Section numbering
|
|
190
|
+
* prints "Section 1.01" where the plain reading would print "Section I.01".
|
|
191
|
+
*/
|
|
192
|
+
currentNumberString(ilvl: string | number, state: NumberingState): string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The definitions of one `w:numbering`: every `w:abstractNum` and every `w:num`, with
|
|
196
|
+
* `w:numStyleLink` resolved. docx4j `NumberingDefinitionsPart.initialiseMaps` and the two maps
|
|
197
|
+
* it fills, plus `getInd` and `getLinkedStyleId`.
|
|
198
|
+
*
|
|
199
|
+
* Immutable once built; the numbering part rebuilds it when its tree changes.
|
|
200
|
+
*/
|
|
201
|
+
export declare class NumberingDefinitions implements NumberingIndents {
|
|
202
|
+
readonly numbering: wml.Numbering | undefined;
|
|
203
|
+
private readonly getStyle;
|
|
204
|
+
/** `w:abstractNumId` -> the definition. docx4j `getAbstractListDefinitions()`. */
|
|
205
|
+
readonly abstractListDefinitions: Map<string, AbstractListDefinition>;
|
|
206
|
+
/** `w:numId` -> the definition. docx4j `getInstanceListDefinitions()`. */
|
|
207
|
+
readonly instanceListDefinitions: Map<string, ListDefinition>;
|
|
208
|
+
/**
|
|
209
|
+
* @param numbering the `w:numbering` tree, or undefined for a package with no numbering part
|
|
210
|
+
* @param getStyle a style by id, for `w:numStyleLink` and a level's linked `w:pStyle`
|
|
211
|
+
*/
|
|
212
|
+
constructor(numbering: wml.Numbering | undefined, getStyle?: StyleLookup);
|
|
213
|
+
private readInstances;
|
|
214
|
+
/**
|
|
215
|
+
* docx4j `resolveLinkedAbstractNum`: the numbering style `w:numStyleLink` names, the `w:num`
|
|
216
|
+
* its `w:numPr` points at, and *that* `w:num`'s abstract definition, whose levels this one
|
|
217
|
+
* takes while counting under its own id - "treated as a separate list by Word (ie its numbers
|
|
218
|
+
* are incremented independently), and this code honours that".
|
|
219
|
+
*/
|
|
220
|
+
private resolveLinkedAbstractNum;
|
|
221
|
+
/** The definition of a `w:numId`, or undefined. */
|
|
222
|
+
list(numId: string | number | undefined): ListDefinition | undefined;
|
|
223
|
+
/** The level of a `w:numId` / `w:ilvl`, or undefined. */
|
|
224
|
+
level(numId: string | number | undefined, ilvl: string | number | undefined): LevelDefinition | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* The paragraph style this level is linked to - the `w:pStyle` of ECMA-376 17.9.24, on the
|
|
227
|
+
* instance's `w:lvlOverride/w:lvl` where it has one and on the abstract level otherwise - or
|
|
228
|
+
* undefined. docx4j `NumberingDefinitionsPart.getLinkedStyleId`.
|
|
229
|
+
*/
|
|
230
|
+
getLinkedStyleId(numId: string | undefined, ilvl: string | undefined): string | undefined;
|
|
231
|
+
/** docx4j `NumberingDefinitionsPart.getInd(NumPr)`: `w:ilvl` is optional and means level 0. */
|
|
232
|
+
getInd(numPr: wml.PPrBase.NumPr): wml.PPrBase.Ind | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* The indent this level contributes. docx4j `NumberingDefinitionsPart.getInd(String, String)`:
|
|
235
|
+
* the instance's override level first, then the abstract level, each read by
|
|
236
|
+
* {@link indFromLvl}.
|
|
237
|
+
*/
|
|
238
|
+
indOf(numId: string, ilvl: string | undefined): wml.PPrBase.Ind | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* **The level's own `w:pPr/w:ind` comes first** (ECMA-376 17.9.24: a `w:lvl/w:pPr` states the
|
|
241
|
+
* paragraph properties applied to a paragraph at this level). A `w:lvl/w:pStyle` only *links*
|
|
242
|
+
* the level to a paragraph style; it does not make that style's indent the level's. Where the
|
|
243
|
+
* level states no indent of its own the linked style's is still used, following `w:basedOn` as
|
|
244
|
+
* every other property a style contributes does (docx4j 17.1.0 and 17.1.1; CR-014 claim 7,
|
|
245
|
+
* measured, and probe P5).
|
|
246
|
+
*
|
|
247
|
+
* A style reference in the level's `w:pPr`, but not also as a sibling of `w:pPr`, contributes
|
|
248
|
+
* nothing here - and numbers nothing (CR-014 P4; `Emulator.resolve` decides "not numbered").
|
|
249
|
+
*/
|
|
250
|
+
private indFromLvl;
|
|
251
|
+
}
|