@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.
Files changed (207) hide show
  1. package/NOTICE +4 -0
  2. package/README.md +92 -4
  3. package/dist/html/convert.mjs +2 -1
  4. package/dist/html/elements.mjs +2 -1
  5. package/dist/model/color/ColorMath.d.mts +29 -0
  6. package/dist/model/color/ColorMath.mjs +146 -0
  7. package/dist/model/color/ColorTables.d.mts +6 -0
  8. package/dist/model/color/ColorTables.mjs +83 -0
  9. package/dist/model/color/DrawingMLColors.d.mts +52 -0
  10. package/dist/model/color/DrawingMLColors.mjs +374 -0
  11. package/dist/model/color/ResolvedColor.d.mts +36 -0
  12. package/dist/model/color/ResolvedColor.mjs +65 -0
  13. package/dist/model/color/SpreadsheetColors.d.mts +36 -0
  14. package/dist/model/color/SpreadsheetColors.mjs +84 -0
  15. package/dist/model/color/StyleFill.d.mts +28 -0
  16. package/dist/model/color/StyleFill.mjs +21 -0
  17. package/dist/model/color/ThemeColors.d.mts +86 -0
  18. package/dist/model/color/ThemeColors.mjs +304 -0
  19. package/dist/model/color/WordColors.d.mts +71 -0
  20. package/dist/model/color/WordColors.mjs +121 -0
  21. package/dist/model/color/index.d.mts +6 -0
  22. package/dist/model/color/index.mjs +30 -0
  23. package/dist/model/content/Body.d.mts +145 -23
  24. package/dist/model/content/Body.mjs +507 -150
  25. package/dist/model/content/Comment.d.mts +23 -5
  26. package/dist/model/content/Comment.mjs +207 -26
  27. package/dist/model/content/ContentControl.d.mts +198 -19
  28. package/dist/model/content/ContentControl.mjs +672 -99
  29. package/dist/model/content/Font.d.mts +70 -17
  30. package/dist/model/content/Font.mjs +119 -36
  31. package/dist/model/content/InlinePicture.d.mts +11 -0
  32. package/dist/model/content/InlinePicture.mjs +21 -1
  33. package/dist/model/content/List.d.mts +6 -3
  34. package/dist/model/content/List.mjs +18 -8
  35. package/dist/model/content/Paragraph.d.mts +200 -14
  36. package/dist/model/content/Paragraph.mjs +898 -82
  37. package/dist/model/content/Range.d.mts +227 -12
  38. package/dist/model/content/Range.mjs +785 -59
  39. package/dist/model/content/ResolvedView.d.mts +104 -0
  40. package/dist/model/content/ResolvedView.mjs +596 -0
  41. package/dist/model/content/Table.d.mts +29 -3
  42. package/dist/model/content/Table.mjs +135 -49
  43. package/dist/model/content/TrackedChange.d.mts +174 -15
  44. package/dist/model/content/TrackedChange.mjs +734 -170
  45. package/dist/model/content/comments.d.mts +20 -6
  46. package/dist/model/content/comments.mjs +67 -57
  47. package/dist/model/content/generalException.d.mts +18 -0
  48. package/dist/model/content/generalException.mjs +24 -0
  49. package/dist/model/content/index.d.mts +10 -3
  50. package/dist/model/content/index.mjs +10 -2
  51. package/dist/model/content/mathText.d.mts +21 -0
  52. package/dist/model/content/mathText.mjs +267 -0
  53. package/dist/model/content/officeText.d.mts +27 -0
  54. package/dist/model/content/officeText.mjs +74 -0
  55. package/dist/model/content/ooxml.mjs +12 -1
  56. package/dist/model/content/outline.d.mts +5 -0
  57. package/dist/model/content/outline.mjs +13 -0
  58. package/dist/model/content/paraIds.d.mts +5 -0
  59. package/dist/model/content/paraIds.mjs +54 -0
  60. package/dist/model/content/placeholders.d.mts +110 -0
  61. package/dist/model/content/placeholders.mjs +253 -0
  62. package/dist/model/content/search.d.mts +74 -0
  63. package/dist/model/content/search.mjs +255 -9
  64. package/dist/model/content/spanEdits.d.mts +159 -0
  65. package/dist/model/content/spanEdits.mjs +728 -0
  66. package/dist/model/content/story.d.mts +47 -0
  67. package/dist/model/content/story.mjs +95 -0
  68. package/dist/model/content/tableColumns.d.mts +1 -1
  69. package/dist/model/content/tableColumns.mjs +108 -80
  70. package/dist/model/content/tableRevisions.d.mts +11 -3
  71. package/dist/model/content/tableRevisions.mjs +72 -42
  72. package/dist/model/content/tableRules.d.mts +30 -0
  73. package/dist/model/content/tableRules.mjs +102 -0
  74. package/dist/model/content/textBoxes.d.mts +18 -0
  75. package/dist/model/content/textBoxes.mjs +105 -0
  76. package/dist/model/content/trackedChangeFilter.d.mts +39 -0
  77. package/dist/model/content/trackedChangeFilter.mjs +81 -0
  78. package/dist/model/content/tracking.d.mts +63 -6
  79. package/dist/model/content/tracking.mjs +242 -22
  80. package/dist/model/content/tree.d.mts +172 -24
  81. package/dist/model/content/tree.mjs +328 -54
  82. package/dist/model/content/wordRange.d.mts +48 -0
  83. package/dist/model/content/wordRange.mjs +97 -0
  84. package/dist/model/customxml/CustomXmlPartCollection.d.mts +30 -1
  85. package/dist/model/customxml/CustomXmlPartCollection.mjs +81 -12
  86. package/dist/model/customxml/XmlMapping.d.mts +32 -8
  87. package/dist/model/customxml/XmlMapping.mjs +64 -10
  88. package/dist/model/customxml/bindings.d.mts +33 -4
  89. package/dist/model/customxml/bindings.mjs +171 -45
  90. package/dist/model/customxml/index.d.mts +1 -0
  91. package/dist/model/customxml/index.mjs +1 -0
  92. package/dist/model/customxml/kinds.d.mts +8 -3
  93. package/dist/model/customxml/kinds.mjs +26 -5
  94. package/dist/model/customxml/opendope.d.mts +4 -1
  95. package/dist/model/customxml/opendope.mjs +9 -6
  96. package/dist/model/customxml/picturePlaceholder.d.mts +17 -0
  97. package/dist/model/customxml/picturePlaceholder.mjs +32 -0
  98. package/dist/model/customxml/pictures.d.mts +4 -3
  99. package/dist/model/customxml/pictures.mjs +22 -8
  100. package/dist/model/customxml/storeItems.d.mts +57 -0
  101. package/dist/model/customxml/storeItems.mjs +122 -0
  102. package/dist/model/customxml/xhtml.mjs +23 -22
  103. package/dist/model/dateZone.d.mts +25 -0
  104. package/dist/model/dateZone.mjs +57 -0
  105. package/dist/model/index.d.mts +3 -0
  106. package/dist/model/index.mjs +5 -0
  107. package/dist/model/listnumbering/Emulator.d.mts +37 -5
  108. package/dist/model/listnumbering/Emulator.mjs +63 -9
  109. package/dist/model/properties/PropertyResolver.d.mts +74 -2
  110. package/dist/model/properties/PropertyResolver.mjs +133 -5
  111. package/dist/model/properties/catalogue.d.mts +19 -5
  112. package/dist/model/properties/catalogue.mjs +41 -15
  113. package/dist/model/properties/index.d.mts +1 -1
  114. package/dist/model/properties/log.d.mts +1 -1
  115. package/dist/model/properties/log.mjs +5 -5
  116. package/dist/model/properties/styleUtil.d.mts +3 -1
  117. package/dist/model/properties/styleUtil.mjs +20 -24
  118. package/dist/model/properties/table.mjs +4 -2
  119. package/dist/model/text/CaseMapping.d.mts +38 -0
  120. package/dist/model/text/CaseMapping.mjs +86 -0
  121. package/dist/model/text/Extractor.d.mts +349 -0
  122. package/dist/model/text/Extractor.mjs +2406 -0
  123. package/dist/model/text/LinkTargets.d.mts +45 -0
  124. package/dist/model/text/LinkTargets.mjs +170 -0
  125. package/dist/model/text/MarkdownExporter.d.mts +140 -0
  126. package/dist/model/text/MarkdownExporter.mjs +255 -0
  127. package/dist/model/text/PlainText.d.mts +29 -0
  128. package/dist/model/text/PlainText.mjs +542 -0
  129. package/dist/model/text/TextContext.d.mts +256 -0
  130. package/dist/model/text/TextContext.mjs +600 -0
  131. package/dist/model/text/TextOptions.d.mts +233 -0
  132. package/dist/model/text/TextOptions.mjs +419 -0
  133. package/dist/model/text/TextResult.d.mts +621 -0
  134. package/dist/model/text/TextResult.mjs +629 -0
  135. package/dist/model/text/Texts.d.mts +99 -0
  136. package/dist/model/text/Texts.mjs +187 -0
  137. package/dist/model/text/WmlToMarkdown.d.mts +120 -0
  138. package/dist/model/text/WmlToMarkdown.mjs +936 -0
  139. package/dist/model/text/caseMapping.generated.d.mts +7 -0
  140. package/dist/model/text/caseMapping.generated.mjs +214 -0
  141. package/dist/model/text/commonmark.d.mts +121 -0
  142. package/dist/model/text/commonmark.mjs +655 -0
  143. package/dist/model/text/index.d.mts +8 -0
  144. package/dist/model/text/index.mjs +9 -0
  145. package/dist/model/text/normalize.d.mts +8 -0
  146. package/dist/model/text/normalize.mjs +13 -0
  147. package/dist/model/text/outline.d.mts +4 -0
  148. package/dist/model/text/outline.mjs +71 -0
  149. package/dist/model/wordIntegers.d.mts +29 -0
  150. package/dist/model/wordIntegers.mjs +78 -0
  151. package/dist/office-js/document.mjs +15 -1
  152. package/dist/office-js/fragment.d.mts +7 -5
  153. package/dist/office-js/fragment.mjs +63 -14
  154. package/dist/office-js/proxy.d.mts +8 -0
  155. package/dist/office-js/proxy.mjs +29 -0
  156. package/dist/office-js/run.mjs +2 -0
  157. package/dist/office-js/supported.generated.mjs +16 -0
  158. package/dist/office-js/toApiScript.mjs +29 -12
  159. package/dist/opc/DirectoryPartStore.d.mts +6 -2
  160. package/dist/opc/DirectoryPartStore.mjs +11 -4
  161. package/dist/opc/FlatOpcPartStore.d.mts +4 -2
  162. package/dist/opc/FlatOpcPartStore.mjs +11 -8
  163. package/dist/opc/Load.d.mts +32 -0
  164. package/dist/opc/Load.mjs +115 -5
  165. package/dist/opc/PartStore.d.mts +34 -1
  166. package/dist/opc/PartStore.mjs +71 -8
  167. package/dist/opc/Save.d.mts +32 -0
  168. package/dist/opc/Save.mjs +110 -4
  169. package/dist/opc/ZipPartStore.d.mts +4 -2
  170. package/dist/opc/ZipPartStore.mjs +12 -7
  171. package/dist/opc/exceptions.d.mts +140 -0
  172. package/dist/opc/exceptions.mjs +108 -0
  173. package/dist/opc/index.d.mts +8 -5
  174. package/dist/opc/index.mjs +5 -3
  175. package/dist/opc/mce/preprocessor.d.mts +141 -5
  176. package/dist/opc/mce/preprocessor.mjs +119 -18
  177. package/dist/opc/mce/understood.d.mts +3 -11
  178. package/dist/opc/mce/understood.mjs +27 -23
  179. package/dist/opc/repair/breaks.d.mts +23 -0
  180. package/dist/opc/repair/breaks.mjs +288 -0
  181. package/dist/opc/repair/hosts.d.mts +12 -0
  182. package/dist/opc/repair/hosts.mjs +33 -0
  183. package/dist/opc/repair/mainRoot.d.mts +19 -0
  184. package/dist/opc/repair/mainRoot.mjs +168 -0
  185. package/dist/opc/repair/unknownElements.d.mts +8 -0
  186. package/dist/opc/repair/unknownElements.mjs +180 -0
  187. package/dist/opc/repair/wmlNames.generated.d.mts +2 -0
  188. package/dist/opc/repair/wmlNames.generated.mjs +80 -0
  189. package/dist/opc/skipped.d.mts +50 -0
  190. package/dist/opc/skipped.mjs +140 -0
  191. package/dist/packages/OpcPackage.d.mts +110 -4
  192. package/dist/packages/OpcPackage.mjs +123 -7
  193. package/dist/packages/WordprocessingMLPackage.d.mts +45 -8
  194. package/dist/packages/WordprocessingMLPackage.mjs +158 -21
  195. package/dist/packages/index.d.mts +1 -1
  196. package/dist/parts/DefaultXmlPart.mjs +2 -2
  197. package/dist/parts/Part.d.mts +14 -2
  198. package/dist/parts/RelationshipsPart.d.mts +15 -0
  199. package/dist/parts/RelationshipsPart.mjs +66 -1
  200. package/dist/parts/XmlPart.d.mts +63 -32
  201. package/dist/parts/XmlPart.mjs +240 -96
  202. package/dist/parts/wml/comments.mjs +30 -0
  203. package/dist/parts/wml/index.d.mts +12 -1
  204. package/dist/parts/wml/index.mjs +37 -1
  205. package/dist/xml/dom.d.mts +7 -0
  206. package/dist/xml/dom.mjs +18 -0
  207. package/package.json +2 -2
@@ -0,0 +1,180 @@
1
+ // An element Word doesn't know, read as Word 365 reads it (CR-026 section 3.7, D7 to D12; WD REQ-308 to REQ-316; check 76). The pass
2
+ // runs on the DOM ahead of CR-021's and of the runtime, which drops what it isn't given a place for. An unknown w: element in a
3
+ // content host loses its tags and keeps what it holds. A run in one in a paragraph's w:pPr goes to the head of the paragraph. A w:p
4
+ // in one, last in a w:p with a run before it, ends that paragraph. Everything else is left for the runtime to skip and report.
5
+ import { childElements } from '../../xml/dom.mjs';
6
+ import { dropped, skippedElement, skippedText } from '../skipped.mjs';
7
+ import { UNDERSTOOD_NAMESPACES } from '../mce/understood.mjs';
8
+ import { W, MC, isUnknown, isW, hostOf } from './hosts.mjs';
9
+ function outermostUnknown(root) {
10
+ const found = [];
11
+ const visit = (e) => {
12
+ for (const c of childElements(e)) {
13
+ if (isUnknown(c))
14
+ found.push(c);
15
+ else
16
+ visit(c);
17
+ }
18
+ };
19
+ visit(root);
20
+ return found;
21
+ }
22
+ /** What `e` holds with any unknown element in it taken away, in order. */
23
+ function heldElements(e) {
24
+ return childElements(e).flatMap((c) => (isUnknown(c) ? heldElements(c) : [c]));
25
+ }
26
+ /** What the pass takes is Word's own reading, and Word's save holds the same: written without it, never refused (CR-025 section 10). */
27
+ const READ_THROUGH = dropped('REQ-308');
28
+ function reportAll(e, skipped, partName) {
29
+ skipped.push(skippedElement(e, partName, undefined, READ_THROUGH));
30
+ for (const c of childElements(e))
31
+ if (isUnknown(c))
32
+ reportAll(c, skipped, partName);
33
+ }
34
+ function reportText(e, skipped, partName) {
35
+ for (let c = e.firstChild; c !== null; c = c.nextSibling) {
36
+ if ((c.nodeType === 3 || c.nodeType === 4) && /[^ \t\r\n]/.test(c.data))
37
+ skipped.push(skippedText(c.data, c, partName));
38
+ if (c.nodeType === 1 && isUnknown(c))
39
+ reportText(c, skipped, partName);
40
+ }
41
+ }
42
+ /** `e`'s tags gone and what it holds in its place, any text with them: text in no run goes (REQ-314). */
43
+ function unwrap(e) {
44
+ const parent = e.parentNode;
45
+ for (const held of heldElements(e))
46
+ parent.insertBefore(held, e);
47
+ parent.removeChild(e);
48
+ }
49
+ const insideAParagraph = (host) => {
50
+ for (let n = host; n !== null && n.nodeType === 1; n = n.parentNode)
51
+ if (isW(n, 'p'))
52
+ return true;
53
+ return false;
54
+ };
55
+ /**
56
+ * REQ-316, D11: a w:p in the element, last in its w:p, with a run before it, ends that paragraph, the held w:p's mark taking the
57
+ * host's place. The host takes the held w:p's properties if it has any, a further held w:p stands alone, and what's left of the host
58
+ * is an empty paragraph with the host's properties (`76t43`, `76t56`, `76t58`, `76t68`, `76t69`). Word refuses every other place.
59
+ */
60
+ function endHost(e, host, held) {
61
+ const doc = host.ownerDocument;
62
+ const pPrOf = (p) => childElements(p).find((c) => isW(c, 'pPr'));
63
+ const [first, ...further] = held;
64
+ const hostPPr = pPrOf(host);
65
+ const firstPPr = pPrOf(first);
66
+ host.removeChild(e);
67
+ for (let c = first.firstChild; c !== null;) {
68
+ const next = c.nextSibling;
69
+ if (c !== firstPPr)
70
+ host.appendChild(c);
71
+ c = next;
72
+ }
73
+ if (firstPPr) {
74
+ if (hostPPr)
75
+ host.removeChild(hostPPr);
76
+ host.insertBefore(firstPPr, host.firstChild);
77
+ }
78
+ const parent = host.parentNode;
79
+ const after = host.nextSibling;
80
+ for (const p of further)
81
+ parent.insertBefore(p, after);
82
+ const rest = doc.createElementNS(W, host.prefix ? `${host.prefix}:p` : 'p');
83
+ if (hostPPr)
84
+ rest.appendChild(firstPPr ? hostPPr : hostPPr.cloneNode(true));
85
+ parent.insertBefore(rest, after);
86
+ }
87
+ /** The paragraph a w:pPr, or a w:sectPr in one, belongs to, through a w:pPrChange (`76t40`, `76t50`). */
88
+ function paragraphOfProperties(parent) {
89
+ var _a;
90
+ let n = parent;
91
+ const sectPr = isW(n, 'sectPr') ? n : undefined;
92
+ if (sectPr)
93
+ n = sectPr.parentNode;
94
+ if (!n || !isW(n, 'pPr'))
95
+ return undefined;
96
+ n = n.parentNode;
97
+ if (n && isW(n, 'pPrChange')) {
98
+ n = (_a = n.parentNode) === null || _a === void 0 ? void 0 : _a.parentNode;
99
+ }
100
+ return n && isW(n, 'p') ? { paragraph: n, sectPr } : undefined;
101
+ }
102
+ /** REQ-311, D8 to D10: runs in the element go to the head of the paragraph, in order; a property goes with the element. */
103
+ function runsToHead(e, at, heads, skipped, partName) {
104
+ var _a;
105
+ const runs = childElements(e).filter((c) => isW(c, 'r'));
106
+ if (runs.length === 0)
107
+ return;
108
+ const { paragraph, sectPr } = at;
109
+ const stays = childElements(e).some((c) => !isW(c, 'r'));
110
+ if (!stays)
111
+ skipped.push(skippedElement(e, partName, undefined, dropped('76t27')));
112
+ if (!heads.has(paragraph)) {
113
+ const pPr = childElements(paragraph).find((c) => isW(c, 'pPr'));
114
+ heads.set(paragraph, pPr ? pPr.nextSibling : paragraph.firstChild);
115
+ }
116
+ const head = (_a = heads.get(paragraph)) !== null && _a !== void 0 ? _a : null;
117
+ for (const r of runs)
118
+ paragraph.insertBefore(r, head);
119
+ if (!stays)
120
+ e.parentNode.removeChild(e);
121
+ if (sectPr) {
122
+ skipped.push(skippedElement(sectPr, partName, undefined, dropped('76t50')));
123
+ sectPr.parentNode.removeChild(sectPr);
124
+ }
125
+ }
126
+ /** Reads a part's unknown w: elements as Word does, reporting each it takes. What it leaves, the runtime skips and reports. */
127
+ export function readThroughUnknownElements(doc, partName) {
128
+ const root = doc.documentElement;
129
+ if (!root || root.namespaceURI !== W)
130
+ return [];
131
+ const found = outermostUnknown(root);
132
+ if (found.length === 0)
133
+ return [];
134
+ const skipped = [];
135
+ const heads = new Map();
136
+ for (const e of found) {
137
+ const parent = e.parentNode;
138
+ const host = hostOf(parent);
139
+ if (!host) {
140
+ const at = paragraphOfProperties(parent);
141
+ if (at)
142
+ runsToHead(e, at, heads, skipped, partName);
143
+ continue;
144
+ }
145
+ const held = heldElements(e);
146
+ if (held.some((c) => isW(c, 'p')) && insideAParagraph(host)) {
147
+ const inHost = childElements(host);
148
+ const last = inHost[inHost.length - 1] === e;
149
+ const runBefore = inHost.slice(0, -1).some((c) => isW(c, 'r'));
150
+ if (!isW(host, 'p') || parent !== host || !last || !runBefore || !held.every((c) => isW(c, 'p')))
151
+ continue; // Word refuses, or nothing measures it
152
+ reportAll(e, skipped, partName);
153
+ endHost(e, host, held);
154
+ continue;
155
+ }
156
+ reportAll(e, skipped, partName);
157
+ reportText(e, skipped, partName);
158
+ unwrap(e);
159
+ }
160
+ return skipped;
161
+ }
162
+ /**
163
+ * The elements a caller's fragment holds that Word doesn't know, for `insertOoxml` to refuse (D12): an unknown w: element, and
164
+ * under a w: element one of a namespace the reader doesn't understand. What a w:t holds counts: CR-021's pass would remove it unreported.
165
+ */
166
+ export function unknownElementsIn(doc) {
167
+ const out = [];
168
+ const visit = (e) => {
169
+ for (const c of childElements(e)) {
170
+ const foreign = e.namespaceURI === W && c.namespaceURI !== null && c.namespaceURI !== W && c.namespaceURI !== MC && !UNDERSTOOD_NAMESPACES.has(c.namespaceURI);
171
+ if (isUnknown(c) || foreign)
172
+ out.push(c);
173
+ else
174
+ visit(c);
175
+ }
176
+ };
177
+ if (doc.documentElement)
178
+ visit(doc.documentElement);
179
+ return out;
180
+ }
@@ -0,0 +1,2 @@
1
+ /** Every element name the WordprocessingML schema declares: 605. */
2
+ export declare const WML_ELEMENT_NAMES: ReadonlySet<string>;
@@ -0,0 +1,80 @@
1
+ // Generated by scripts/generate-wml-names.mjs from docx4j's wml.xsd (sha256 191a5132795cdf83). Do not edit.
2
+ /** Every element name the WordprocessingML schema declares: 605. */
3
+ export const WML_ELEMENT_NAMES = new Set([
4
+ 'abstractNum', 'abstractNumId', 'active', 'activeRecord', 'activeWritingStyle', 'addressFieldName', 'adjustLineHeightInTable', 'adjustRightInd',
5
+ 'alias', 'aliases', 'alignBordersAndEdges', 'alignTablesRowByRow', 'allowPNG', 'allowSpaceOfSameStyleInTable', 'altChunk', 'altChunkPr',
6
+ 'altName', 'alwaysMergeEmptyNamespace', 'alwaysShowPlaceholderText', 'annotationRef', 'applyBreakingRules', 'attachedSchema', 'attachedTemplate', 'attr',
7
+ 'autoCaption', 'autoCaptions', 'autoFormatOverride', 'autoHyphenation', 'autoRedefine', 'autoSpaceDE', 'autoSpaceDN', 'autoSpaceLikeWord95',
8
+ 'autofitToFirstFixedWidthCell', 'b', 'bCs', 'background', 'balanceSingleByteDoubleByteWidth', 'bar', 'basedOn', 'bdo',
9
+ 'bdr', 'behavior', 'behaviors', 'between', 'bibliography', 'bidi', 'bidiVisual', 'blockQuote',
10
+ 'body', 'bodyDiv', 'bookFoldPrinting', 'bookFoldPrintingSheets', 'bookFoldRevPrinting', 'bookmarkEnd', 'bookmarkStart', 'bordersDoNotSurroundFooter',
11
+ 'bordersDoNotSurroundHeader', 'bottom', 'br', 'cachedColBalance', 'calcOnExit', 'calendar', 'cantSplit', 'caps',
12
+ 'caption', 'captions', 'category', 'cellDel', 'cellIns', 'cellMerge', 'characterSpacingControl', 'charset',
13
+ 'checkBox', 'checkErrors', 'checked', 'citation', 'clickAndTypeStyle', 'clrSchemeMapping', 'cnfStyle', 'col',
14
+ 'colDelim', 'color', 'cols', 'column', 'comboBox', 'comment', 'commentRangeEnd', 'commentRangeStart',
15
+ 'commentReference', 'comments', 'compat', 'compatSetting', 'connectString', 'consecutiveHyphenLimit', 'contextualSpacing', 'continuationSeparator',
16
+ 'control', 'convMailMergeEsc', 'cr', 'cs', 'customXml', 'customXmlDelRangeEnd', 'customXmlDelRangeStart', 'customXmlInsRangeEnd',
17
+ 'customXmlInsRangeStart', 'customXmlMoveFromRangeEnd', 'customXmlMoveFromRangeStart', 'customXmlMoveToRangeEnd', 'customXmlMoveToRangeStart', 'customXmlPr', 'dataBinding', 'dataSource',
18
+ 'dataType', 'date', 'dateFormat', 'dayLong', 'dayShort', 'ddList', 'decimalSymbol', 'default',
19
+ 'defaultTabStop', 'defaultTableStyle', 'del', 'delInstrText', 'delText', 'description', 'destination', 'dir',
20
+ 'dirty', 'displayBackgroundShape', 'displayHangulFixedWidth', 'displayHorizontalDrawingGridEvery', 'displayVerticalDrawingGridEvery', 'div', 'divBdr', 'divId',
21
+ 'divs', 'divsChild', 'doNotAutoCompressPictures', 'doNotAutofitConstrainedTables', 'doNotBreakConstrainedForcedTable', 'doNotBreakWrappedTables', 'doNotDemarcateInvalidXml', 'doNotDisplayPageBoundaries',
22
+ 'doNotEmbedSmartTags', 'doNotExpandShiftReturn', 'doNotHyphenateCaps', 'doNotIncludeSubdocsInStats', 'doNotLeaveBackslashAlone', 'doNotOrganizeInFolder', 'doNotRelyOnCSS', 'doNotSaveAsSingleFile',
23
+ 'doNotShadeFormData', 'doNotSnapToGridInCell', 'doNotSuppressBlankLines', 'doNotSuppressIndentation', 'doNotSuppressParagraphBorders', 'doNotTrackFormatting', 'doNotTrackMoves', 'doNotUseEastAsianBreakRules',
24
+ 'doNotUseHTMLParagraphAutoSpacing', 'doNotUseIndentAsNumberingTabStop', 'doNotUseLongFileNames', 'doNotUseMarginsForDrawingGridOrigin', 'doNotValidateAgainstSchema', 'doNotVertAlignCellWithSp', 'doNotVertAlignInTxbx', 'doNotWrapTextWithPunct',
25
+ 'docDefaults', 'docGrid', 'docPart', 'docPartBody', 'docPartCategory', 'docPartGallery', 'docPartList', 'docPartObj',
26
+ 'docPartPr', 'docPartUnique', 'docParts', 'docVar', 'docVars', 'document', 'documentProtection', 'documentType',
27
+ 'drawing', 'drawingGridHorizontalOrigin', 'drawingGridHorizontalSpacing', 'drawingGridVerticalOrigin', 'drawingGridVerticalSpacing', 'dropDownList', 'dstrike', 'dynamicAddress',
28
+ 'eastAsianLayout', 'effect', 'em', 'embedBold', 'embedBoldItalic', 'embedItalic', 'embedRegular', 'embedSystemFonts',
29
+ 'embedTrueTypeFonts', 'emboss', 'enabled', 'encoding', 'end', 'endnote', 'endnotePr', 'endnoteRef',
30
+ 'endnoteReference', 'endnotes', 'entryMacro', 'equation', 'evenAndOddHeaders', 'exitMacro', 'fHdr', 'family',
31
+ 'ffData', 'fieldMapData', 'fitText', 'flatBorders', 'fldChar', 'fldData', 'fldSimple', 'font',
32
+ 'fonts', 'footerReference', 'footnote', 'footnoteLayoutLikeWW8', 'footnotePr', 'footnoteRef', 'footnoteReference', 'footnotes',
33
+ 'forceUpgrade', 'forgetLastTabAlignment', 'formProt', 'format', 'formsDesign', 'frame', 'frameLayout', 'framePr',
34
+ 'frameset', 'framesetSplitbar', 'ftr', 'gallery', 'glossaryDocument', 'gridAfter', 'gridBefore', 'gridCol',
35
+ 'gridSpan', 'group', 'growAutofit', 'guid', 'gutterAtTop', 'hMerge', 'hdr', 'hdrShapeDefaults',
36
+ 'headerReference', 'headerSource', 'helpText', 'hidden', 'hideGrammaticalErrors', 'hideMark', 'hideSpellingErrors', 'highlight',
37
+ 'hps', 'hpsBaseText', 'hpsRaise', 'hyperlink', 'hyphenationZone', 'i', 'iCs', 'id',
38
+ 'ignoreMixedContent', 'ilvl', 'imprint', 'ind', 'ins', 'insideH', 'insideV', 'instrText',
39
+ 'isLgl', 'jc', 'keepLines', 'keepNext', 'kern', 'kinsoku', 'lang', 'lastRenderedPageBreak',
40
+ 'latentStyles', 'layoutRawTableWidth', 'layoutTableRowsApart', 'left', 'legacy', 'lid', 'lineWrapLikeWord6', 'link',
41
+ 'linkStyles', 'linkToQuery', 'linkedToFile', 'listEntry', 'listItem', 'listSeparator', 'lnNumType', 'lock',
42
+ 'locked', 'lsdException', 'lvl', 'lvlJc', 'lvlOverride', 'lvlPicBulletId', 'lvlRestart', 'lvlText',
43
+ 'mailAsAttachment', 'mailMerge', 'mailSubject', 'mainDocumentType', 'mappedName', 'marBottom', 'marH', 'marLeft',
44
+ 'marRight', 'marTop', 'marW', 'matchSrc', 'maxLength', 'mirrorIndents', 'mirrorMargins', 'monthLong',
45
+ 'monthShort', 'moveFrom', 'moveFromRangeEnd', 'moveFromRangeStart', 'moveTo', 'moveToRangeEnd', 'moveToRangeStart', 'movie',
46
+ 'multiLevelType', 'mwSmallCaps', 'name', 'next', 'noBorder', 'noBreakHyphen', 'noColumnBalance', 'noEndnote',
47
+ 'noExtraLineSpacing', 'noLeading', 'noLineBreaksAfter', 'noLineBreaksBefore', 'noProof', 'noPunctuationKerning', 'noResizeAllowed', 'noSpaceRaiseLower',
48
+ 'noTabHangInd', 'noWrap', 'notTrueType', 'nsid', 'num', 'numFmt', 'numId', 'numIdMacAtCleanup',
49
+ 'numPicBullet', 'numPr', 'numRestart', 'numStart', 'numStyleLink', 'numbering', 'numberingChange', 'oMath',
50
+ 'object', 'odso', 'optimizeForBrowser', 'outline', 'outlineLvl', 'overflowPunct', 'p', 'pBdr',
51
+ 'pPr', 'pPrChange', 'pPrDefault', 'pStyle', 'pageBreakBefore', 'panose1', 'paperSrc', 'permEnd',
52
+ 'permStart', 'personal', 'personalCompose', 'personalReply', 'pgBorders', 'pgMar', 'pgNum', 'pgNumType',
53
+ 'pgSz', 'pict', 'picture', 'pitch', 'pixelsPerInch', 'placeholder', 'pos', 'position',
54
+ 'printBodyTextBeforeHeader', 'printColBlack', 'printFormsData', 'printFractionalCharacterWidth', 'printPostScriptOverText', 'printTwoOnOne', 'printerSettings', 'proofErr',
55
+ 'proofState', 'ptab', 'qFormat', 'query', 'r', 'rFonts', 'rPr', 'rPrChange',
56
+ 'rPrDefault', 'rStyle', 'readModeInkLockDown', 'recipientData', 'recipients', 'relyOnVML', 'removeDateAndTime', 'removePersonalInformation',
57
+ 'result', 'revisionView', 'richText', 'right', 'rsid', 'rsidRoot', 'rsids', 'rt',
58
+ 'rtl', 'rtlGutter', 'ruby', 'rubyAlign', 'rubyBase', 'rubyPr', 'saveFormsData', 'saveInvalidXml',
59
+ 'savePreviewPicture', 'saveSmartTagsAsXml', 'saveSubsetFonts', 'saveThroughXslt', 'saveXmlDataOnly', 'scrollbar', 'sdt', 'sdtContent',
60
+ 'sdtEndPr', 'sdtPr', 'sectPr', 'sectPrChange', 'selectFldWithFirstOrLastChar', 'semiHidden', 'separator', 'settings',
61
+ 'shadow', 'shapeDefaults', 'shapeLayoutLikeWW8', 'shd', 'showBreaksInFrames', 'showEnvelope', 'showXMLTags', 'showingPlcHdr',
62
+ 'sig', 'size', 'sizeAuto', 'smallCaps', 'smartTag', 'smartTagPr', 'smartTagType', 'snapToGrid',
63
+ 'softHyphen', 'sourceFileName', 'spaceForUL', 'spacing', 'spacingInWholePoints', 'specVanish', 'splitPgBreakAndParaMark', 'src',
64
+ 'start', 'startOverride', 'statusText', 'storeMappedDataAs', 'strictFirstAndLastChars', 'strike', 'style', 'styleLink',
65
+ 'styleLockQFSet', 'styleLockTheme', 'stylePaneFormatFilter', 'stylePaneSortMethod', 'styles', 'subDoc', 'subFontBySize', 'suff',
66
+ 'summaryLength', 'suppressAutoHyphens', 'suppressBottomSpacing', 'suppressLineNumbers', 'suppressOverlap', 'suppressSpBfAfterPgBrk', 'suppressSpacingAtTopOfPage', 'suppressTopSpacing',
67
+ 'suppressTopSpacingWP', 'swapBordersFacingPages', 'sym', 'sz', 'szCs', 't', 'tab', 'table',
68
+ 'tabs', 'tag', 'targetScreenSz', 'tbl', 'tblBorders', 'tblCaption', 'tblCellMar', 'tblCellSpacing',
69
+ 'tblDescription', 'tblGrid', 'tblGridChange', 'tblHeader', 'tblInd', 'tblLayout', 'tblLook', 'tblOverlap',
70
+ 'tblPr', 'tblPrChange', 'tblPrEx', 'tblPrExChange', 'tblStyle', 'tblStyleColBandSize', 'tblStylePr', 'tblStyleRowBandSize',
71
+ 'tblW', 'tblpPr', 'tc', 'tcBorders', 'tcFitText', 'tcMar', 'tcPr', 'tcPrChange',
72
+ 'tcW', 'temporary', 'text', 'textAlignment', 'textDirection', 'textInput', 'textboxTightWrap', 'themeFontLang',
73
+ 'titlePg', 'tl2br', 'tmpl', 'top', 'topLinePunct', 'tr', 'tr2bl', 'trHeight',
74
+ 'trPr', 'trPrChange', 'trackRevisions', 'truncateFontHeightsLikeWP6', 'txbxContent', 'type', 'types', 'u',
75
+ 'udl', 'uiCompat97To2003', 'uiPriority', 'ulTrailSpace', 'underlineTabInNumList', 'unhideWhenUsed', 'uniqueTag', 'updateFields',
76
+ 'useAltKinsokuLineBreakRules', 'useAnsiKerningPairs', 'useFELayout', 'useNormalStyleForList', 'usePrinterMetrics', 'useSingleBorderforContiguousCells', 'useWord2002TableStyleRules', 'useWord97LineBreakRules',
77
+ 'useXSLTWhenSaving', 'vAlign', 'vMerge', 'vanish', 'vertAlign', 'view', 'viewMergedData', 'w',
78
+ 'wAfter', 'wBefore', 'webHidden', 'webSettings', 'widowControl', 'wordWrap', 'wpJustification', 'wpSpaceWidth',
79
+ 'wrapTrailSpaces', 'writeProtection', 'yearLong', 'yearShort', 'zoom',
80
+ ]);
@@ -0,0 +1,50 @@
1
+ /**
2
+ * What a save does with an item when the part holding it has changed (CR-025 section 10, D14): `dropped`, written without it
3
+ * as Word 365's own save writes it, listed on `lastSave.dropped` and never refused; or `lost`, which Word's save keeps, or
4
+ * which Word won't open, or which nobody has measured, refused unless `checkLossOnSave` is off (D15).
5
+ */
6
+ export type OnSave = 'dropped' | 'lost';
7
+ /** One element, attribute or stretch of text a read dropped. */
8
+ export interface ContentSkippedWarning {
9
+ code: 'part.skipped';
10
+ partName: string | undefined;
11
+ kind: 'element' | 'attribute' | 'text';
12
+ /** As the part writes it, `ext:opaque`; for text, its first 80 characters. */
13
+ name: string;
14
+ /** The element holding it, `w:sdtPr`. */
15
+ parentName: string;
16
+ /** That element's class, `org_docx4j_wml.SdtPr`. Absent for what CR-021's pass removes, which no class has met. */
17
+ parentClass?: string;
18
+ /** From the part's root, `/w:document/w:body/w:sdt/w:sdtPr/ext:opaque`; an attribute's last step is `@ext:a`, text's `text()`. */
19
+ path: string;
20
+ /** Its namespace is listed in `mc:Ignorable` where it stands. Always false for text. */
21
+ ignorable: boolean;
22
+ /** Its namespace URI, `null` for none and for text (CR-025 section 10). */
23
+ namespace: string | null;
24
+ /** What a save of the changed part does with it (CR-025 section 10.3): written without it, or refused. */
25
+ onSave: OnSave;
26
+ /** The Word file or statement that decides `onSave` (`'76i'`, `'REQ-314'`); absent for a lost item nobody measured. */
27
+ measured?: string;
28
+ /** Where the parser gives one, as `target.misplaced`: an attribute's is its element's. */
29
+ line?: number;
30
+ column?: number;
31
+ message: string;
32
+ }
33
+ export interface SaveClass {
34
+ readonly onSave: OnSave;
35
+ readonly measured?: string;
36
+ }
37
+ /** Written without, as Word's own save writes it; `measured` the Word file or statement. */
38
+ export declare const dropped: (measured: string) => SaveClass;
39
+ /** An element and all it holds. */
40
+ export declare function skippedElement(element: Element, partName: string | undefined, parentClass?: string, saveClass?: SaveClass): ContentSkippedWarning;
41
+ /** For a pass that goes beyond what Word was measured on: lost, whatever its shape (CR-025 D15). */
42
+ export declare const UNMEASURED: SaveClass;
43
+ /** An attribute of `owner`, named as the runtime reports it. */
44
+ export declare function skippedAttribute(name: {
45
+ namespaceURI?: string;
46
+ localPart: string;
47
+ prefix?: string;
48
+ }, owner: Element, partName: string | undefined, parentClass?: string): ContentSkippedWarning;
49
+ /** A stretch of text, as a text or CDATA node. */
50
+ export declare function skippedText(text: string, node: Node, partName: string | undefined, parentClass?: string): ContentSkippedWarning;
@@ -0,0 +1,140 @@
1
+ // What a read drops, as a part's warning (CR-025). `part.skipped` is python's code, agreed through its CR-033 Q9, and
2
+ // `kind`, `path` and `line` its `SkippedNode`'s. The runtime reports what it drops through three callbacks, which
3
+ // `XmlPart.unmarshal` alone passes: objects CR-007 keeps them per call, since a drop is sometimes the mechanism
4
+ // (`recordPPrChange`'s deep copy). CR-021's pass removes what it removes before the runtime sees it, so it reports its own.
5
+ import { UNDERSTOOD_NAMESPACES } from './mce/understood.mjs';
6
+ import { W, hostOf, isUnknown, isW } from './repair/hosts.mjs';
7
+ const MC = 'http://schemas.openxmlformats.org/markup-compatibility/2006';
8
+ const position = (node) => {
9
+ const { lineNumber, columnNumber } = node;
10
+ return { ...(typeof lineNumber === 'number' ? { line: lineNumber } : {}), ...(typeof columnNumber === 'number' ? { column: columnNumber } : {}) };
11
+ };
12
+ function pathOf(element) {
13
+ const steps = [];
14
+ for (let n = element; n !== null && n.nodeType === 1; n = n.parentNode)
15
+ steps.unshift(n.nodeName);
16
+ return `/${steps.join('/')}`;
17
+ }
18
+ /**
19
+ * Whether `mc:Ignorable` lists the namespace, there or on an ancestor, each prefix read where the attribute stands. A prefix
20
+ * that no longer resolves counts by its name, since `mcePreprocess` takes a branch out of the `mc:Choice` declaring it, but not
21
+ * where the item's own prefix still resolves to it: then it was declared only below the list, which doesn't put it in scope
22
+ * there, and the list names nothing (WD REQ-323, `ui-05`).
23
+ */
24
+ function isIgnorable(namespace, prefix, from) {
25
+ if (!namespace)
26
+ return false;
27
+ for (let n = from; n !== null && n.nodeType === 1; n = n.parentNode) {
28
+ const element = n;
29
+ const listed = element.getAttributeNS(MC, 'Ignorable');
30
+ if (!listed)
31
+ continue;
32
+ for (const candidate of listed.trim().split(/\s+/)) {
33
+ const uri = element.lookupNamespaceURI(candidate);
34
+ if (uri === namespace || (!uri && candidate === prefix && from.lookupNamespaceURI(prefix) !== namespace))
35
+ return true;
36
+ }
37
+ }
38
+ return false;
39
+ }
40
+ /** Written without, as Word's own save writes it; `measured` the Word file or statement. */
41
+ export const dropped = (measured) => ({ onSave: 'dropped', measured });
42
+ const lost = (measured) => (measured === undefined ? { onSave: 'lost' } : { onSave: 'lost', measured });
43
+ const isElement = (n) => n !== null && n.nodeType === 1;
44
+ /** Check 76's file for an element in a namespace Word doesn't understand, by its host: ignorable (`76a` ...) and not (`76e` ...). */
45
+ const FOREIGN_IGNORABLE = { sdtPr: '76a', p: '76b', r: '76c', tc: '76d', b: '76l', t: '76m' };
46
+ const FOREIGN_REFUSED = { p: '76e', sdtPr: '76o', pPr: '76p', r: '76q', tc: '76r', b: '76s', t: '76v' };
47
+ /** The property hosts where a run held by an unknown `w:` element makes Word refuse the file (CR-026 section 3.7). */
48
+ const RUN_REFUSED = { rPr: '76t28', sdtPr: '76t46', trPr: '76t47', tcPr: '76t48', tblPr: '76t49' };
49
+ /**
50
+ * An element's class (CR-025 section 10.3's table, D15): by the Word file that measured its shape, a shape nobody measured lost.
51
+ * `el` is the element as the read met it, in its parent.
52
+ */
53
+ function elementClass(el, ignorable) {
54
+ var _a;
55
+ const parent = el.parentNode;
56
+ if (!isElement(parent))
57
+ return lost('REQ-320'); // a part's root: what an unexpected root held, which has no reading to copy
58
+ const ns = el.namespaceURI;
59
+ if (!ns)
60
+ return lost('76x'); // in no namespace: Word won't open the file (76x, 76y)
61
+ const host = parent.namespaceURI === W ? parent.localName : undefined;
62
+ if (ns === W) {
63
+ if (isUnknown(el)) {
64
+ // an unknown w: element. CR-026's pass reads one through where Word does and gives its items that class itself; one it
65
+ // leaves in a content host is a shape Word refuses or nobody measured (76t53, 76t54, 76t57, 76t59), left to the runtime
66
+ if (isUnknown(parent) || hostOf(parent))
67
+ return lost();
68
+ if (host === 't')
69
+ return dropped('76u'); // CR-021's pass takes it with what it holds, as Word's save does
70
+ if (host === 'pPr')
71
+ return dropped('76g');
72
+ if (host !== undefined && RUN_REFUSED[host] !== undefined) {
73
+ if (el.getElementsByTagNameNS(W, 'r').length > 0)
74
+ return lost(RUN_REFUSED[host]);
75
+ return host === 'rPr' ? dropped('76t6') : lost();
76
+ }
77
+ if (host === 'sectPr' && isElement(parent.parentNode) && isW(parent.parentNode, 'pPr'))
78
+ return dropped('76t50');
79
+ return lost();
80
+ }
81
+ // a known w: element out of place
82
+ if (el.localName === 'document')
83
+ return lost('nd-10'); // a w:document in a w:document: Word won't open the file
84
+ if (el.localName === 'sectPr' && isUnknown(parent))
85
+ return dropped('mr-11');
86
+ if (el.localName === 'sectPr' && host === 'pPr')
87
+ return dropped('76t50');
88
+ if (el.localName === 'tab' && host === 't')
89
+ return dropped('76z');
90
+ return lost();
91
+ }
92
+ if (UNDERSTOOD_NAMESPACES.has(ns))
93
+ return lost(); // Word understands it and its save keeps it (python's 1b)
94
+ // a namespace Word doesn't understand: ignorable, Word ignores it wherever it stands (ISO/IEC 29500-3) and its save drops it
95
+ if (ignorable)
96
+ return dropped((_a = (host !== undefined ? FOREIGN_IGNORABLE[host] : undefined)) !== null && _a !== void 0 ? _a : 'mc:Ignorable');
97
+ return lost(host !== undefined ? FOREIGN_REFUSED[host] : undefined);
98
+ }
99
+ /** An attribute's class: an unknown `w:` one, or one in a namespace Word doesn't understand, ignorable or not, Word's save drops (76h to 76j). */
100
+ function attributeClass(ns, ignorable) {
101
+ if (ns === W)
102
+ return dropped('76j');
103
+ if (!ns || UNDERSTOOD_NAMESPACES.has(ns))
104
+ return lost();
105
+ return dropped(ignorable ? '76h' : '76i');
106
+ }
107
+ /** Text's class: held by an unknown `w:` element it's absent in Word's reading (REQ-314); in a run, Word's save drops it (`72m`). */
108
+ function textClass(parent) {
109
+ if (isUnknown(parent))
110
+ return dropped('REQ-314');
111
+ if (isW(parent, 'r'))
112
+ return dropped('72m');
113
+ return lost();
114
+ }
115
+ function warning(kind, name, parent, path, ignorable, located, partName, parentClass, namespace, saveClass) {
116
+ return {
117
+ code: 'part.skipped', partName, kind, name, parentName: parent.nodeName,
118
+ ...(parentClass !== undefined ? { parentClass } : {}),
119
+ path, ignorable, namespace, ...saveClass, ...position(located),
120
+ message: `${partName !== null && partName !== void 0 ? partName : 'a part'}: ${path}: the read dropped this ${kind}, which the model has no place for`,
121
+ };
122
+ }
123
+ /** An element and all it holds. */
124
+ export function skippedElement(element, partName, parentClass, saveClass) {
125
+ const ignorable = isIgnorable(element.namespaceURI, element.prefix, element);
126
+ return warning('element', element.nodeName, element.parentNode, pathOf(element), ignorable, element, partName, parentClass, element.namespaceURI || null, saveClass !== null && saveClass !== void 0 ? saveClass : elementClass(element, ignorable));
127
+ }
128
+ /** For a pass that goes beyond what Word was measured on: lost, whatever its shape (CR-025 D15). */
129
+ export const UNMEASURED = Object.freeze({ onSave: 'lost' });
130
+ /** An attribute of `owner`, named as the runtime reports it. */
131
+ export function skippedAttribute(name, owner, partName, parentClass) {
132
+ const shown = name.prefix ? `${name.prefix}:${name.localPart}` : name.localPart;
133
+ const ignorable = isIgnorable(name.namespaceURI, name.prefix, owner);
134
+ return warning('attribute', shown, owner, `${pathOf(owner)}/@${shown}`, ignorable, owner, partName, parentClass, name.namespaceURI || null, attributeClass(name.namespaceURI, ignorable));
135
+ }
136
+ /** A stretch of text, as a text or CDATA node. */
137
+ export function skippedText(text, node, partName, parentClass) {
138
+ const parent = node.parentNode;
139
+ return warning('text', text.length > 80 ? text.slice(0, 80) : text, parent, `${pathOf(parent)}/text()`, false, node, partName, parentClass, null, textClass(parent));
140
+ }
@@ -4,12 +4,21 @@ import { ContentTypeManager } from '../opc/ContentTypeManager.mjs';
4
4
  import { type PartStore, type PartSink } from '../opc/PartStore.mjs';
5
5
  import { type FlatOpcSinkOptions } from '../opc/FlatOpcPartStore.mjs';
6
6
  import { type LoadOptions } from '../opc/Load.mjs';
7
+ import { type SaveReport } from '../opc/Save.mjs';
8
+ import { type DuplicateEntryWarning, type ExternalMainPartWarning, type MultipleMainPartsWarning, type RelationshipsNamespaceWarning } from '../opc/exceptions.mjs';
7
9
  import { Part, type RelationshipSource } from '../parts/Part.mjs';
8
10
  import { Parts } from '../parts/Parts.mjs';
9
11
  import { RelationshipsPart, type AddPartBehaviour } from '../parts/RelationshipsPart.mjs';
10
12
  import type { CustomXmlDataStoragePart } from '../parts/DefaultXmlPart.mjs';
11
13
  import { DocPropsCorePart, DocPropsExtendedPart, DocPropsCustomPart } from '../parts/docProps/index.mjs';
12
- import { type PartWarning } from '../opc/mce/preprocessor.mjs';
14
+ import { type PartWarning, type MisplacedContentWarning } from '../opc/mce/preprocessor.mjs';
15
+ /** A warning on `pkg.warnings`: the load's (a duplicated entry, CR-024; an `External` main relationship, CR-031) or a part's. */
16
+ export type PackageWarning = DuplicateEntryWarning | MultipleMainPartsWarning | ExternalMainPartWarning | PartWarning;
17
+ /**
18
+ * What a load repaired (WD REQ-207's `repaired`, CR-031): `'own'` where a repair of this package's own was made, `'word'` where
19
+ * only Word's were followed, else `'none'`.
20
+ */
21
+ export type Repaired = 'none' | 'word' | 'own';
13
22
  /** Anything `OpcPackage.load` accepts: zip bytes, a flat OPC string, or a container. */
14
23
  export type PackageSource = Uint8Array | ArrayBuffer | string | PartStore;
15
24
  /**
@@ -27,10 +36,86 @@ export declare class OpcPackage implements RelationshipSource {
27
36
  /** Custom XML parts by the (lower-cased) itemID of their properties part. */
28
37
  readonly customXmlDataStorageParts: Map<string, CustomXmlDataStoragePart>;
29
38
  /** The options this package was loaded with. */
39
+ /**
40
+ * The names the container held more than one entry of, each read from its first entry under
41
+ * `LoadOptions.repair: 'word'` (WD REQ-206, CR-024); empty for a package loaded without one, or made here.
42
+ */
43
+ duplicateEntries: readonly DuplicateEntryWarning[];
44
+ /**
45
+ * Where the package relationships held more than one officeDocument relationship, read from the last under
46
+ * `LoadOptions.repair: 'word'` (WD REQ-206's statement, CR-024 section 9); undefined for a package with one, or made here.
47
+ */
48
+ multipleMainParts: MultipleMainPartsWarning | undefined;
49
+ /**
50
+ * Where the package relationships held an `External` officeDocument relationship beside an internal one, dropped under
51
+ * `LoadOptions.repair: 'all'` (WD REQ-206's NOTE, CR-031 section 2.2); undefined otherwise.
52
+ */
53
+ externalMainPart: ExternalMainPartWarning | undefined;
30
54
  loadOptions: LoadOptions;
31
55
  docPropsCorePart: DocPropsCorePart | undefined;
32
56
  docPropsExtendedPart: DocPropsExtendedPart | undefined;
33
57
  docPropsCustomPart: DocPropsCustomPart | undefined;
58
+ /**
59
+ * Whether a save writes run properties in their normal form (CR-015 D2; docx4j CR-061's
60
+ * `setNormaliseOnSave`): a colour Word accepts as upper-case `RRGGBB`, one it rejects left out (a text or
61
+ * underline colour) or `auto` (a fill's, a border's), a `w:highlight`, `w:vertAlign` or `w:em` Word repairs away
62
+ * left out; a revision's former properties too. Only what is written changes: the tree keeps what it read, and a
63
+ * part nobody unmarshalled is still copied byte for byte. Undefined defers to the objects package's process-wide
64
+ * `setNormaliseOnSave` (on unless set off); a package's own setting wins over it. False writes values as read.
65
+ * On/off values and `w:u`'s are settled when the part is read, so they are written the same either way.
66
+ */
67
+ normaliseOnSave: boolean | undefined;
68
+ /** What the last save did beyond writing the package: each value it normalised (CR-015 D8), each it wrote past what Word stores (CR-017 P3), each misplaced child it wrote under `checkContentOnSave = false` (CR-016). Undefined until one. */
69
+ lastSave: SaveReport | undefined;
70
+ /**
71
+ * Whether a save refuses a part holding a child its container never admits (CR-016 D2, docx4j CR-064's rules in the
72
+ * objects facade, its CR-017): a run straight in the body, a table in a paragraph, a cell beside a table's rows, a
73
+ * string in a run, a name and value that disagree. On by default: the save throws `MisplacedContentException` with
74
+ * every such child in the part, its path and docx4j's message naming the fix, and writes nothing, since Word 365
75
+ * refuses such a file or repairs it by dropping content (check 72). Off, the part is written as held and each is on
76
+ * `lastSave.misplaced`. Only a part being marshalled is checked (one unmarshalled, or given contents); a part copied
77
+ * from the source is never refused, so a document read and saved untouched never is. `checkContent()` is the same
78
+ * check on request. A misplaced child read from a file is a `target.misplaced` warning on its part (D7).
79
+ */
80
+ checkContentOnSave: boolean;
81
+ /**
82
+ * Whether a save refuses to lose what a read dropped (CR-025 sections 2.3 and 2.4, D8): a part holding `part.skipped` content
83
+ * that was changed throws `SaveLossException` and nothing is written. Off, the part is written without those items, each on
84
+ * `lastSave.lost`. A part read and not changed is copied either way, so nothing is lost there. Word's own save drops such
85
+ * content with no message (check 76), so off is Word's behaviour.
86
+ */
87
+ checkLossOnSave: boolean;
88
+ private dateTimeZone_;
89
+ /**
90
+ * The client's time zone for this package, an IANA id (`Australia/Sydney`), or undefined for the runtime's (CR-018; the
91
+ * portfolio's date rule of 2026-10-28, docx4j's `OpcPackage.setDateTimeZone`). Every instant the package holds is shown
92
+ * in it, and a `w:date` without `dateUtc` read in it: a new revision's or comment's stamp (Word's local wall-clock
93
+ * `w:date`), `TrackedChange.date` and `Comment.creationDate`, and date fields when they are evaluated (CR-012 phase 5).
94
+ * It is the client's for this package, not the document's, and reaches no saved file as such: a server reusing a
95
+ * loaded package sets it per request. Under Office JS the runtime's zone is already the client's. A bound date has no
96
+ * zone (CR-002 section 56) unless `boundDatesConvertedAsWord` asks for Word's conversion in this one. A zone the
97
+ * runtime does not know is refused with a `RangeError` at the set.
98
+ */
99
+ get dateTimeZone(): string | undefined;
100
+ set dateTimeZone(id: string | undefined);
101
+ /** The zone in force: `dateTimeZone`, else the runtime's. */
102
+ effectiveDateTimeZone(): string;
103
+ /**
104
+ * Show bound dates as Word displays them in the package's zone (CR-018, the date rule's point 3; docx4j's
105
+ * `setBoundDatesConvertedAsWord`): off by default, a bound date being the day its fields say wherever it is read
106
+ * (CR-002 section 56). On, a bound value carrying a `Z` or an offset is read as an instant and shown in
107
+ * `effectiveDateTimeZone()`, as Word reads the `Z` as UTC and shows the machine's local time (a day early west of
108
+ * UTC); a value with no marker, or a date alone, stays nominal. Setting `dateTimeZone` does not turn this on.
109
+ */
110
+ boundDatesConvertedAsWord: boolean;
111
+ /**
112
+ * Write the save's time into the core properties (CR-018, the date rule's point 6; docx4j's `docx4j.dcterms.write`):
113
+ * off by default, a save leaving `dcterms:created` and `dcterms:modified` as they are. On, each save sets
114
+ * `dcterms:modified` to now, UTC to the second (`2026-10-28T03:04:05Z`, the W3CDTF form Office writes), and
115
+ * `dcterms:created` too for a package created here that has none; a loaded package with no core properties part is
116
+ * left without one, as docx4j leaves it.
117
+ */
118
+ writeTimesOnSave: boolean;
34
119
  constructor();
35
120
  get package(): OpcPackage;
36
121
  /**
@@ -43,14 +128,35 @@ export declare class OpcPackage implements RelationshipSource {
43
128
  /** Adds a part as a target of the package (docProps, the main part). */
44
129
  addTargetPart(target: Part, mode?: AddPartBehaviour, proposedRelId?: string): Relationship;
45
130
  setPartShortcut(part: Part, relationshipType: string): boolean;
46
- /** The main part: the target of the officeDocument relationship. */
131
+ /** The main part: the target of the officeDocument relationship, an External one naming none. */
47
132
  getMainPart(): Part | undefined;
48
133
  /**
49
- * The warnings of every part parsed so far (each XML part's `warnings`, CR-010 phase 1). A part
134
+ * The warnings of every part parsed so far (each XML part's `warnings`, CR-010 phase 1), after the
135
+ * load's own: a name the container holds twice, and more than one officeDocument relationship, read under
136
+ * `repair: 'word'` (CR-024), and an `External` main relationship dropped under `repair: 'all'` (CR-031). A part
50
137
  * is parsed when something reads it, so a reader that wants a whole package's warnings reads its
51
138
  * parts first; `unmarshalAll()` does, at the cost of re-marshalling every part on save.
52
139
  */
53
- get warnings(): PartWarning[];
140
+ get warnings(): PackageWarning[];
141
+ /**
142
+ * Each relationships part a load under `repair: 'word'` read by local name, being in a wrong namespace (CR-031 section
143
+ * 2.3): the package's and its parts', in that order.
144
+ */
145
+ get relationshipsNamespaces(): RelationshipsNamespaceWarning[];
146
+ /**
147
+ * What the load repaired (WD REQ-207's `repaired`, CR-031 section 2.4), read from what it recorded, so it reports what the
148
+ * load did whatever the option: `'own'` for a repair of this package's own (an `External` main relationship dropped),
149
+ * `'word'` where only Word's were followed (a duplicated entry, several main relationships, a relationships part read by
150
+ * local name), else `'none'`.
151
+ */
152
+ get repaired(): Repaired;
153
+ /**
154
+ * Every child a part holds that its container never admits (CR-016 D6, the check on request): what a save would
155
+ * refuse for, over every typed XML part, each finding with its part, its path, the rule and docx4j's message naming
156
+ * the fix. Nothing is changed, and an untouched part stays untouched (read privately). `[]` for a package whose
157
+ * content is all in its place.
158
+ */
159
+ checkContent(): Promise<MisplacedContentWarning[]>;
54
160
  /** Unmarshals every XML part, so that `contents` is available synchronously everywhere. */
55
161
  unmarshalAll(): Promise<void>;
56
162
  /** Adds empty core properties if absent (docx4j addDocPropsCorePart). */