@docx4j/core-ts 0.1.0 → 0.1.1

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 (168) hide show
  1. package/README.md +410 -10
  2. package/dist/model/content/Body.d.mts +109 -4
  3. package/dist/model/content/Body.mjs +300 -29
  4. package/dist/model/content/Comment.d.mts +78 -0
  5. package/dist/model/content/Comment.mjs +429 -0
  6. package/dist/model/content/ContentControl.d.mts +173 -0
  7. package/dist/model/content/ContentControl.mjs +638 -0
  8. package/dist/model/content/Font.d.mts +48 -8
  9. package/dist/model/content/Font.mjs +55 -13
  10. package/dist/model/content/InlinePicture.d.mts +103 -0
  11. package/dist/model/content/InlinePicture.mjs +361 -0
  12. package/dist/model/content/List.d.mts +253 -0
  13. package/dist/model/content/List.mjs +778 -0
  14. package/dist/model/content/Paragraph.d.mts +213 -16
  15. package/dist/model/content/Paragraph.mjs +611 -57
  16. package/dist/model/content/Range.d.mts +48 -4
  17. package/dist/model/content/Range.mjs +161 -4
  18. package/dist/model/content/Table.d.mts +130 -0
  19. package/dist/model/content/Table.mjs +429 -0
  20. package/dist/model/content/TrackedChange.d.mts +96 -0
  21. package/dist/model/content/TrackedChange.mjs +352 -0
  22. package/dist/model/content/comments.d.mts +122 -0
  23. package/dist/model/content/comments.mjs +248 -0
  24. package/dist/model/content/index.d.mts +13 -3
  25. package/dist/model/content/index.mjs +15 -3
  26. package/dist/model/content/ooxml.d.mts +17 -0
  27. package/dist/model/content/ooxml.mjs +214 -0
  28. package/dist/model/content/styles.d.mts +21 -0
  29. package/dist/model/content/styles.mjs +86 -0
  30. package/dist/model/content/tracking.d.mts +104 -0
  31. package/dist/model/content/tracking.mjs +313 -0
  32. package/dist/model/content/tree.d.mts +56 -9
  33. package/dist/model/content/tree.mjs +104 -31
  34. package/dist/model/customxml/CustomXmlPart.d.mts +158 -0
  35. package/dist/model/customxml/CustomXmlPart.mjs +415 -0
  36. package/dist/model/customxml/CustomXmlPartCollection.d.mts +68 -0
  37. package/dist/model/customxml/CustomXmlPartCollection.mjs +183 -0
  38. package/dist/model/customxml/XmlMapping.d.mts +46 -0
  39. package/dist/model/customxml/XmlMapping.mjs +98 -0
  40. package/dist/model/customxml/bindings.d.mts +41 -0
  41. package/dist/model/customxml/bindings.mjs +230 -0
  42. package/dist/model/customxml/index.d.mts +7 -0
  43. package/dist/model/customxml/index.mjs +9 -0
  44. package/dist/model/customxml/insert.d.mts +20 -0
  45. package/dist/model/customxml/insert.mjs +22 -0
  46. package/dist/model/customxml/kinds.d.mts +103 -0
  47. package/dist/model/customxml/kinds.mjs +267 -0
  48. package/dist/model/customxml/xpath.d.mts +52 -0
  49. package/dist/model/customxml/xpath.mjs +205 -0
  50. package/dist/model/fonts/CJKToEnglish.d.mts +2 -0
  51. package/dist/model/fonts/CJKToEnglish.mjs +16 -0
  52. package/dist/model/fonts/FontFallback.d.mts +58 -0
  53. package/dist/model/fonts/FontFallback.mjs +219 -0
  54. package/dist/model/fonts/IdentityPlusMapper.d.mts +7 -0
  55. package/dist/model/fonts/IdentityPlusMapper.mjs +19 -0
  56. package/dist/model/fonts/LanguageTagToScriptMapping.d.mts +7 -0
  57. package/dist/model/fonts/LanguageTagToScriptMapping.mjs +67 -0
  58. package/dist/model/fonts/Mapper.d.mts +190 -0
  59. package/dist/model/fonts/Mapper.mjs +481 -0
  60. package/dist/model/fonts/PhysicalFont.d.mts +34 -0
  61. package/dist/model/fonts/PhysicalFont.mjs +62 -0
  62. package/dist/model/fonts/RunFontSelector.d.mts +194 -0
  63. package/dist/model/fonts/RunFontSelector.mjs +441 -0
  64. package/dist/model/fonts/ThemeFonts.d.mts +17 -0
  65. package/dist/model/fonts/ThemeFonts.mjs +76 -0
  66. package/dist/model/fonts/defaultTheme.d.mts +37 -0
  67. package/dist/model/fonts/defaultTheme.mjs +57 -0
  68. package/dist/model/fonts/families.generated.d.mts +11 -0
  69. package/dist/model/fonts/families.generated.mjs +17 -0
  70. package/dist/model/fonts/fontsInUse.d.mts +39 -0
  71. package/dist/model/fonts/fontsInUse.mjs +183 -0
  72. package/dist/model/fonts/index.d.mts +14 -0
  73. package/dist/model/fonts/index.mjs +29 -0
  74. package/dist/model/fonts/lookup.d.mts +5 -0
  75. package/dist/model/fonts/lookup.mjs +12 -0
  76. package/dist/model/fonts/registry.d.mts +31 -0
  77. package/dist/model/fonts/registry.mjs +103 -0
  78. package/dist/model/fonts/scripts.d.mts +2 -0
  79. package/dist/model/fonts/scripts.mjs +78 -0
  80. package/dist/model/fonts/substitutions.generated.d.mts +30 -0
  81. package/dist/model/fonts/substitutions.generated.mjs +12 -0
  82. package/dist/model/fonts/themes.generated.d.mts +6 -0
  83. package/dist/model/fonts/themes.generated.mjs +11 -0
  84. package/dist/model/index.d.mts +5 -0
  85. package/dist/model/index.mjs +13 -1
  86. package/dist/model/listnumbering/Emulator.d.mts +187 -0
  87. package/dist/model/listnumbering/Emulator.mjs +332 -0
  88. package/dist/model/listnumbering/definitions.d.mts +251 -0
  89. package/dist/model/listnumbering/definitions.mjs +571 -0
  90. package/dist/model/listnumbering/formats.d.mts +25 -0
  91. package/dist/model/listnumbering/formats.mjs +320 -0
  92. package/dist/model/listnumbering/index.d.mts +4 -0
  93. package/dist/model/listnumbering/index.mjs +15 -0
  94. package/dist/model/listnumbering/state.d.mts +97 -0
  95. package/dist/model/listnumbering/state.mjs +179 -0
  96. package/dist/model/properties/PropertyResolver.d.mts +216 -0
  97. package/dist/model/properties/PropertyResolver.mjs +524 -0
  98. package/dist/model/properties/catalogue.d.mts +179 -0
  99. package/dist/model/properties/catalogue.mjs +860 -0
  100. package/dist/model/properties/index.d.mts +4 -0
  101. package/dist/model/properties/index.mjs +9 -0
  102. package/dist/model/properties/log.d.mts +7 -0
  103. package/dist/model/properties/log.mjs +25 -0
  104. package/dist/model/properties/styleUtil.d.mts +112 -0
  105. package/dist/model/properties/styleUtil.mjs +359 -0
  106. package/dist/node/index.d.mts +1 -0
  107. package/dist/node/index.mjs +12 -0
  108. package/dist/office-js/document.d.mts +111 -0
  109. package/dist/office-js/document.mjs +267 -0
  110. package/dist/office-js/enums.d.mts +187 -0
  111. package/dist/office-js/enums.mjs +176 -0
  112. package/dist/office-js/errors.d.mts +29 -0
  113. package/dist/office-js/errors.mjs +39 -0
  114. package/dist/office-js/extras.d.mts +5 -0
  115. package/dist/office-js/extras.mjs +29 -0
  116. package/dist/office-js/fragment.d.mts +10 -0
  117. package/dist/office-js/fragment.mjs +23 -0
  118. package/dist/office-js/index.d.mts +183 -0
  119. package/dist/office-js/index.mjs +54 -0
  120. package/dist/office-js/proxy.d.mts +72 -0
  121. package/dist/office-js/proxy.mjs +279 -0
  122. package/dist/office-js/run.d.mts +32 -0
  123. package/dist/office-js/run.mjs +66 -0
  124. package/dist/office-js/supported.d.mts +7 -0
  125. package/dist/office-js/supported.generated.d.mts +1 -0
  126. package/dist/office-js/supported.generated.mjs +235 -0
  127. package/dist/office-js/supported.mjs +53 -0
  128. package/dist/office-js/toApiScript.d.mts +25 -0
  129. package/dist/office-js/toApiScript.mjs +394 -0
  130. package/dist/opc/ContentTypes.d.mts +1 -0
  131. package/dist/opc/ContentTypes.mjs +1 -0
  132. package/dist/opc/DirectoryPartStore.d.mts +47 -0
  133. package/dist/opc/DirectoryPartStore.mjs +123 -0
  134. package/dist/opc/exceptions.d.mts +30 -0
  135. package/dist/opc/exceptions.mjs +38 -0
  136. package/dist/opc/index.d.mts +1 -1
  137. package/dist/opc/index.mjs +1 -1
  138. package/dist/packages/OpcPackage.d.mts +19 -1
  139. package/dist/packages/OpcPackage.mjs +29 -0
  140. package/dist/packages/PresentationMLPackage.d.mts +71 -1
  141. package/dist/packages/PresentationMLPackage.mjs +179 -0
  142. package/dist/packages/SpreadsheetMLPackage.d.mts +30 -1
  143. package/dist/packages/SpreadsheetMLPackage.mjs +78 -0
  144. package/dist/packages/WordprocessingMLPackage.d.mts +124 -2
  145. package/dist/packages/WordprocessingMLPackage.mjs +309 -2
  146. package/dist/packages/index.d.mts +1 -1
  147. package/dist/packages/index.mjs +1 -1
  148. package/dist/parts/DefaultXmlPart.d.mts +18 -0
  149. package/dist/parts/DefaultXmlPart.mjs +34 -5
  150. package/dist/parts/PartRegistry.mjs +1 -0
  151. package/dist/parts/XmlPart.d.mts +33 -0
  152. package/dist/parts/XmlPart.mjs +105 -2
  153. package/dist/parts/pml/defaults.d.mts +6 -0
  154. package/dist/parts/pml/defaults.mjs +53 -0
  155. package/dist/parts/pml/index.d.mts +66 -3
  156. package/dist/parts/pml/index.mjs +206 -7
  157. package/dist/parts/pml/placeholders.d.mts +71 -0
  158. package/dist/parts/pml/placeholders.mjs +141 -0
  159. package/dist/parts/sml/index.d.mts +19 -1
  160. package/dist/parts/sml/index.mjs +60 -1
  161. package/dist/parts/wml/comments.d.mts +1 -0
  162. package/dist/parts/wml/comments.mjs +179 -0
  163. package/dist/parts/wml/defaultNumbering.d.mts +1 -0
  164. package/dist/parts/wml/defaultNumbering.mjs +216 -0
  165. package/dist/parts/wml/index.d.mts +121 -0
  166. package/dist/parts/wml/index.mjs +291 -0
  167. package/dist/xml/dom.mjs +1 -2
  168. package/package.json +25 -4
@@ -21,6 +21,12 @@ export declare class XmlPart<T = unknown> extends Part {
21
21
  rootName: RootName | undefined;
22
22
  /** Runs over the DOM before unmarshalling; the package sets its MCE preprocessor here. */
23
23
  preprocessor: DomPreprocessor | undefined;
24
+ /**
25
+ * The namespace declarations the source root element carried, prefix to URI, recorded when the
26
+ * part was parsed. They are what `mc:Ignorable` prefixes the object model does not bind are
27
+ * re-declared from on marshal; see `declareIgnorablePrefixes`.
28
+ */
29
+ private sourceDeclarations;
24
30
  constructor(partName: PartName | string, contentType: string, relationshipType: string, rootName?: RootName);
25
31
  /** True once contents were unmarshalled or set; the part is then re-marshalled on save. */
26
32
  get isUnmarshalled(): boolean;
@@ -31,6 +37,16 @@ export declare class XmlPart<T = unknown> extends Part {
31
37
  get typedElement(): Jsonix.TypedNamedValue<T> | undefined;
32
38
  /** Unmarshals on first call (docx4j getContents()). */
33
39
  getContents(): Promise<T>;
40
+ /**
41
+ * The contents as a **private tree**, without marking the part unmarshalled - so a part read
42
+ * this way is still written back from its source bytes, byte for byte. The live tree is
43
+ * returned when the part is already unmarshalled, since then the part is re-marshalled
44
+ * anyway and a second copy would only go stale.
45
+ *
46
+ * This is what a reader that must not cost a part its round trip uses: `PropertyResolver`
47
+ * reads the styles and numbering parts of a document nobody has otherwise touched.
48
+ */
49
+ readContents(): Promise<T>;
34
50
  /** Replaces the contents (docx4j setJaxbElement / setContents). The root name defaults to the part's. */
35
51
  setContents(value: T, rootName?: RootName): void;
36
52
  /** Replaces the contents with raw XML bytes; they are unmarshalled on the next getContents(). */
@@ -43,4 +59,21 @@ export declare class XmlPart<T = unknown> extends Part {
43
59
  getBytes(): Promise<Uint8Array>;
44
60
  /** The root element as a DOM element (docx4j XmlUtils.marshaltoW3CDomDocument). */
45
61
  marshalToNode(): Promise<Element>;
62
+ /** The source root element's namespace declarations, prefix to URI (`xmlns=` is the empty prefix). */
63
+ private recordDeclarations;
64
+ /**
65
+ * Every prefix the marshalled root's `mc:Ignorable` names must be declared on that root
66
+ * (ECMA-376 Part 3 10.1.2; Word and Excel treat an undeclared one as a corrupt part and offer
67
+ * to repair the file). The object model binds only the namespaces it has modules for, so an
68
+ * `mc:Ignorable` prefix whose content was dropped on unmarshal - `xr6`, `xr10` and `xr2` on
69
+ * Excel's `xl/workbook.xml`, for instance - loses its declaration: the runtime declares one
70
+ * prefix per entry of the objects package's table and the facade can only *remove* unused
71
+ * declarations, never add one it never made (CR-001 section 17).
72
+ *
73
+ * So the part re-declares them itself: from what the source root declared, else from the
74
+ * objects package's `NAMESPACE_PREFIXES`. A prefix neither knows is dropped from
75
+ * `mc:Ignorable` - an undeclared prefix is the one thing that must not be written - and warned
76
+ * about once.
77
+ */
78
+ private declareIgnorablePrefixes;
46
79
  }
@@ -1,7 +1,23 @@
1
- import { unmarshalNode, marshalNode } from '@docx4j/generated-objects-ts';
1
+ import { unmarshalNode, marshalNode, NAMESPACE_PREFIXES } from '@docx4j/generated-objects-ts';
2
2
  import { Part } from './Part.mjs';
3
+ import { Namespaces } from './Namespaces.mjs';
3
4
  import { Docx4JException } from '../opc/exceptions.mjs';
4
5
  import { parseXml, serializeXml, encodeText, decodeXmlText, XML_DECLARATION } from '../xml/dom.mjs';
6
+ import { log } from '../model/properties/log.mjs';
7
+ const XMLNS_NS = 'http://www.w3.org/2000/xmlns/';
8
+ const MC_NS = Namespaces.MARKUP_COMPATIBILITY;
9
+ /** The objects package's prefix table the other way round, prefix to URI, built once. */
10
+ let prefixToUri;
11
+ function knownUriOf(prefix) {
12
+ if (prefixToUri === undefined) {
13
+ prefixToUri = new Map();
14
+ for (const [uri, p] of Object.entries(NAMESPACE_PREFIXES))
15
+ if (p !== '' && !prefixToUri.has(p))
16
+ prefixToUri.set(p, uri);
17
+ }
18
+ return prefixToUri.get(prefix);
19
+ }
20
+ const warnedPrefixes = new Set();
5
21
  /**
6
22
  * A part whose content is a typed element of the object model (docx4j JaxbXmlPart<E>). `T` is the
7
23
  * root element's value type (`Document`, `Styles`, ...). Contents are unmarshalled on first
@@ -38,6 +54,7 @@ export class XmlPart extends Part {
38
54
  if (bytes === undefined)
39
55
  throw new Docx4JException(`Part ${this.partName} has no content: set contents or load it from a container`);
40
56
  const doc = parseXml(decodeXmlText(bytes));
57
+ this.recordDeclarations(doc);
41
58
  (_b = this.preprocessor) === null || _b === void 0 ? void 0 : _b.call(this, doc, this);
42
59
  this.element = await unmarshalNode(doc);
43
60
  (_c = this.rootName) !== null && _c !== void 0 ? _c : (this.rootName = { namespaceURI: this.element.name.namespaceURI, localPart: this.element.name.localPart });
@@ -45,6 +62,27 @@ export class XmlPart extends Part {
45
62
  }
46
63
  return this.element.value;
47
64
  }
65
+ /**
66
+ * The contents as a **private tree**, without marking the part unmarshalled - so a part read
67
+ * this way is still written back from its source bytes, byte for byte. The live tree is
68
+ * returned when the part is already unmarshalled, since then the part is re-marshalled
69
+ * anyway and a second copy would only go stale.
70
+ *
71
+ * This is what a reader that must not cost a part its round trip uses: `PropertyResolver`
72
+ * reads the styles and numbering parts of a document nobody has otherwise touched.
73
+ */
74
+ async readContents() {
75
+ var _a, _b;
76
+ if (this.element !== undefined)
77
+ return this.element.value;
78
+ const bytes = (_a = this.bytes) !== null && _a !== void 0 ? _a : (await this.loadSourceBytes());
79
+ if (bytes === undefined)
80
+ throw new Docx4JException(`Part ${this.partName} has no content: set contents or load it from a container`);
81
+ const doc = parseXml(decodeXmlText(bytes));
82
+ this.recordDeclarations(doc);
83
+ (_b = this.preprocessor) === null || _b === void 0 ? void 0 : _b.call(this, doc, this);
84
+ return (await unmarshalNode(doc)).value;
85
+ }
48
86
  /** Replaces the contents (docx4j setJaxbElement / setContents). The root name defaults to the part's. */
49
87
  setContents(value, rootName) {
50
88
  var _a, _b;
@@ -82,6 +120,71 @@ export class XmlPart extends Part {
82
120
  async marshalToNode() {
83
121
  if (this.element === undefined)
84
122
  await this.getContents();
85
- return marshalNode(this.element);
123
+ const root = await marshalNode(this.element);
124
+ this.declareIgnorablePrefixes(root);
125
+ return root;
126
+ }
127
+ /** The source root element's namespace declarations, prefix to URI (`xmlns=` is the empty prefix). */
128
+ recordDeclarations(doc) {
129
+ var _a;
130
+ const root = doc.documentElement;
131
+ if (!root)
132
+ return;
133
+ const map = new Map();
134
+ for (const attr of Array.from(root.attributes)) {
135
+ if (attr.name === 'xmlns')
136
+ map.set('', attr.value);
137
+ else if (attr.namespaceURI === XMLNS_NS || attr.name.startsWith('xmlns:'))
138
+ map.set((_a = attr.localName) !== null && _a !== void 0 ? _a : attr.name.slice(6), attr.value);
139
+ }
140
+ this.sourceDeclarations = map;
141
+ }
142
+ /**
143
+ * Every prefix the marshalled root's `mc:Ignorable` names must be declared on that root
144
+ * (ECMA-376 Part 3 10.1.2; Word and Excel treat an undeclared one as a corrupt part and offer
145
+ * to repair the file). The object model binds only the namespaces it has modules for, so an
146
+ * `mc:Ignorable` prefix whose content was dropped on unmarshal - `xr6`, `xr10` and `xr2` on
147
+ * Excel's `xl/workbook.xml`, for instance - loses its declaration: the runtime declares one
148
+ * prefix per entry of the objects package's table and the facade can only *remove* unused
149
+ * declarations, never add one it never made (CR-001 section 17).
150
+ *
151
+ * So the part re-declares them itself: from what the source root declared, else from the
152
+ * objects package's `NAMESPACE_PREFIXES`. A prefix neither knows is dropped from
153
+ * `mc:Ignorable` - an undeclared prefix is the one thing that must not be written - and warned
154
+ * about once.
155
+ */
156
+ declareIgnorablePrefixes(root) {
157
+ var _a, _b;
158
+ const attr = Array.from(root.attributes).find((a) => { var _a; return a.namespaceURI === MC_NS && ((_a = a.localName) !== null && _a !== void 0 ? _a : a.name) === 'Ignorable'; });
159
+ if (!attr)
160
+ return;
161
+ const prefixes = attr.value.split(/\s+/).filter((p) => p !== '');
162
+ if (prefixes.length === 0)
163
+ return;
164
+ const kept = [];
165
+ let dropped = false;
166
+ for (const prefix of prefixes) {
167
+ if (root.getAttributeNS(XMLNS_NS, prefix) || root.getAttribute(`xmlns:${prefix}`)) {
168
+ kept.push(prefix);
169
+ continue;
170
+ }
171
+ const uri = (_b = (_a = this.sourceDeclarations) === null || _a === void 0 ? void 0 : _a.get(prefix)) !== null && _b !== void 0 ? _b : knownUriOf(prefix);
172
+ if (uri === undefined) {
173
+ dropped = true;
174
+ if (!warnedPrefixes.has(prefix)) {
175
+ warnedPrefixes.add(prefix);
176
+ log.warn(`${this.partName}: mc:Ignorable names the prefix "${prefix}", which nothing declares; dropping it (an undeclared prefix makes Word and Excel offer to repair the file)`);
177
+ }
178
+ continue;
179
+ }
180
+ root.setAttributeNS(XMLNS_NS, `xmlns:${prefix}`, uri);
181
+ kept.push(prefix);
182
+ }
183
+ if (!dropped)
184
+ return;
185
+ if (kept.length === 0)
186
+ root.removeAttributeNode(attr);
187
+ else
188
+ root.setAttributeNS(MC_NS, attr.name, kept.join(' '));
86
189
  }
87
190
  }
@@ -0,0 +1,6 @@
1
+ /** `/ppt/slideMasters/slideMaster1.xml` as docx4j's `SlideMasterPart.createSldMaster()` writes it. */
2
+ export declare const DEFAULT_SLIDE_MASTER_XML: string;
3
+ /** `/ppt/slideLayouts/slideLayout1.xml` as docx4j's `SlideLayoutPart.createSldLayout()` writes it. */
4
+ export declare const DEFAULT_SLIDE_LAYOUT_XML: string;
5
+ /** `/ppt/slides/slide1.xml` as docx4j's `SlidePart.createSld()` writes it. */
6
+ export declare const DEFAULT_SLIDE_XML: string;
@@ -0,0 +1,53 @@
1
+ // The template markup `PresentationMLPackage.createPackage()` starts a new presentation from, as
2
+ // docx4j builds it (docx4j VERSION_17_1_1 a58cf10b8):
3
+ //
4
+ // docx4j-core/src/main/java/org/docx4j/openpackaging/parts/PresentationML/JaxbPmlPart.java
5
+ // COMMON_SLIDE_DATA, COLOR_MAPPING
6
+ // .../PresentationML/SlideMasterPart.java createSldMaster()
7
+ // .../PresentationML/SlideLayoutPart.java createSldLayout() (cSld name "Title Slide")
8
+ // .../PresentationML/SlidePart.java createSld()
9
+ //
10
+ // docx4j unmarshals those fragments into a JAXB tree and marshals it back out; here they are the
11
+ // whole part, so a created slide, layout or master that nobody touches is written byte for byte
12
+ // as docx4j writes it. Generated content, not hand markup: do not edit without the Java.
13
+ //
14
+ // The placeholder shapes a created layout and slide also carry are not here either: they are
15
+ // built with the generated factories in `placeholders.mts`, because PowerPoint offers
16
+ // "Click to add title" only where the slide itself holds them (CR-001 section 17.2). So the
17
+ // layout and the slide are unmarshalled during creation and are no longer written byte for byte
18
+ // as they are below; the master still is.
19
+ //
20
+ // The theme part is not here: `createPackage()` uses the same embedded Office themes as
21
+ // `WordprocessingMLPackage.createPackage()` (`src/model/fonts/themes.generated.mts`), so which
22
+ // theme a new presentation carries follows `pkg.fonts.defaultTheme`, as it does for a new
23
+ // document. docx4j instead ships one fixed
24
+ // `org/docx4j/openpackaging/parts/PresentationML/theme.xml` (CR-001 section 16).
25
+ const XML_DECL = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
26
+ const NS = ' xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"'
27
+ + ' xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"'
28
+ + ' xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"';
29
+ /** docx4j `JaxbPmlPart.COMMON_SLIDE_DATA`: an empty shape tree. `name` is the `p:cSld/@name`. */
30
+ function commonSlideData(name) {
31
+ return `<p:cSld${name === undefined ? '' : ` name="${name}"`}>`
32
+ + '<p:spTree>'
33
+ + '<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>'
34
+ + '<p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>'
35
+ + '</p:spTree>'
36
+ + '</p:cSld>';
37
+ }
38
+ /** docx4j `JaxbPmlPart.COLOR_MAPPING`: the identity colour map a master needs. */
39
+ const COLOR_MAPPING = '<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1"'
40
+ + ' accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6"'
41
+ + ' hlink="hlink" folHlink="folHlink"/>';
42
+ /** `/ppt/slideMasters/slideMaster1.xml` as docx4j's `SlideMasterPart.createSldMaster()` writes it. */
43
+ export const DEFAULT_SLIDE_MASTER_XML = `${XML_DECL}<p:sldMaster${NS}>`
44
+ + commonSlideData() + COLOR_MAPPING + '<p:sldLayoutIdLst/>'
45
+ + '</p:sldMaster>';
46
+ /** `/ppt/slideLayouts/slideLayout1.xml` as docx4j's `SlideLayoutPart.createSldLayout()` writes it. */
47
+ export const DEFAULT_SLIDE_LAYOUT_XML = `${XML_DECL}<p:sldLayout${NS}>`
48
+ + commonSlideData('Title Slide')
49
+ + '</p:sldLayout>';
50
+ /** `/ppt/slides/slide1.xml` as docx4j's `SlidePart.createSld()` writes it. */
51
+ export const DEFAULT_SLIDE_XML = `${XML_DECL}<p:sld${NS}>`
52
+ + commonSlideData()
53
+ + '</p:sld>';
@@ -4,21 +4,83 @@ import { XmlPart } from '../XmlPart.mjs';
4
4
  import { BinaryPart } from '../BinaryPart.mjs';
5
5
  import { Part } from '../Part.mjs';
6
6
  import { PartName } from '../../opc/PartName.mjs';
7
+ import type { AddPartBehaviour } from '../RelationshipsPart.mjs';
7
8
  import { ThemePart } from '../dml/index.mjs';
9
+ /**
10
+ * A new `p:sldId/@id` (docx4j `JaxbPmlPart.getSlideId()`, ECMA-376 4.8.17 ST_SlideId: 256 to
11
+ * 2147483647). Random, as docx4j's is: nothing in the package numbers them.
12
+ */
13
+ export declare function nextSlideId(): number;
14
+ /**
15
+ * A new `p:sldLayoutId/@id` or `p:sldMasterId/@id` (docx4j
16
+ * `JaxbPmlPart.getSlideLayoutOrMasterId()`, ECMA-376 4.8.18 and 4.8.20: above 2147483648).
17
+ */
18
+ export declare function nextSlideLayoutOrMasterId(): number;
8
19
  export declare class MainPresentationPart extends XmlPart<pml.Presentation> {
9
20
  themePart: ThemePart | undefined;
21
+ notesMasterPart: NotesMasterPart | undefined;
22
+ commentAuthorsPart: CommentAuthorsPart | undefined;
23
+ presentationPropertiesPart: PresentationPropertiesPart | undefined;
24
+ viewPropertiesPart: ViewPropertiesPart | undefined;
25
+ tableStylesPart: TableStylesPart | undefined;
10
26
  constructor(partName?: PartName | string, contentType?: string);
11
27
  setPartShortcut(part: Part, relationshipType: string): boolean;
28
+ /**
29
+ * The slides, in `p:sldIdLst` order (docx4j `getSlideParts()`), once the part is unmarshalled;
30
+ * before that, in relationship order, which is the order they were added in.
31
+ */
12
32
  get slideParts(): SlidePart[];
33
+ /** The slides in `p:sldIdLst` order, unmarshalling the part first (docx4j `getSlideParts()`). */
34
+ getSlideParts(): Promise<SlidePart[]>;
35
+ /** The slide masters, in `p:sldMasterIdLst` order once the part is unmarshalled. */
36
+ get slideMasterParts(): SlideMasterPart[];
37
+ /** The slide at an index of `p:sldIdLst` (docx4j `getSlide(int)`). */
38
+ getSlide(index: number): SlidePart;
39
+ /** docx4j `getSlideCount()`. */
40
+ get slideCount(): number;
41
+ /**
42
+ * Adds a slide part as a target and appends a `p:sldId` for it (docx4j
43
+ * `addSlideIdListEntry(SlidePart)`); the part must be unmarshalled.
44
+ */
45
+ addSlideIdListEntry(slidePart: SlidePart, mode?: AddPartBehaviour): pml.Presentation.SldIdLst.SldId;
46
+ /**
47
+ * docx4j `addSlide(SlidePart)` / `addSlide(int, SlidePart)`: appends the slide, or inserts it
48
+ * at `index`, renaming the part if the name is taken (PowerPoint cannot open a package in which
49
+ * two relationships target the same slide, so a slide is never added twice).
50
+ *
51
+ * `layoutPart`, when given, becomes the slide's layout relationship, as a slide needs one.
52
+ */
53
+ addSlide(slidePart: SlidePart, index?: number, layoutPart?: SlideLayoutPart): pml.Presentation.SldIdLst.SldId;
54
+ /** docx4j `addSlideMasterIdListEntry(SlideMasterPart)`. */
55
+ addSlideMasterIdListEntry(masterPart: SlideMasterPart): pml.Presentation.SldMasterIdLst.SldMasterId;
56
+ /** docx4j `removeSlide(int)`: the `p:sldId`, the relationship and the part. */
57
+ removeSlide(index: number): SlidePart;
58
+ private sldIdLst;
13
59
  }
14
60
  export declare class SlidePart extends XmlPart<pml.Sld> {
15
- constructor(partName: PartName | string);
61
+ slideLayoutPart: SlideLayoutPart | undefined;
62
+ notesSlidePart: NotesSlidePart | undefined;
63
+ commentsPart: PresentationCommentsPart | undefined;
64
+ constructor(partName?: PartName | string);
65
+ setPartShortcut(part: Part, relationshipType: string): boolean;
16
66
  }
17
67
  export declare class SlideLayoutPart extends XmlPart<pml.SldLayout> {
18
- constructor(partName: PartName | string);
68
+ /** docx4j `SlideLayoutPart.getSlideMasterPart()`. */
69
+ slideMasterPart: SlideMasterPart | undefined;
70
+ constructor(partName?: PartName | string);
71
+ setPartShortcut(part: Part, relationshipType: string): boolean;
19
72
  }
20
73
  export declare class SlideMasterPart extends XmlPart<pml.SldMaster> {
21
- constructor(partName: PartName | string);
74
+ themePart: ThemePart | undefined;
75
+ constructor(partName?: PartName | string);
76
+ setPartShortcut(part: Part, relationshipType: string): boolean;
77
+ /**
78
+ * Adds a layout part as a target and appends a `p:sldLayoutId` for it (docx4j
79
+ * `addSlideLayoutIdListEntry`); the master must be unmarshalled.
80
+ */
81
+ addSlideLayoutIdListEntry(slideLayoutPart: SlideLayoutPart): pml.SlideLayoutIdList.SldLayoutId;
82
+ /** This master's layouts, in `p:sldLayoutIdLst` order once the master is unmarshalled. */
83
+ get slideLayoutParts(): SlideLayoutPart[];
22
84
  }
23
85
  export declare class NotesSlidePart extends XmlPart<pml.Notes> {
24
86
  constructor(partName: PartName | string);
@@ -51,3 +113,4 @@ export declare class TagsPart extends XmlPart<pml.TagLst> {
51
113
  export declare class FontDataPart extends BinaryPart {
52
114
  constructor(partName: PartName | string);
53
115
  }
116
+ export { type SlideTextOptions, type Rect, placeholderGeometry, placeholderShape, slidePlaceholders, layoutPlaceholders, addShapes, bodyLines, placeholdersOf, slidePlaceholdersFor, } from './placeholders.mjs';
@@ -1,41 +1,239 @@
1
+ import { createPresentationSldIdLstSldId, createPresentationSldMasterIdLstSldMasterId, createSlideLayoutIdListSldLayoutId, } from '@docx4j/generated-objects-ts/factory/org_pptx4j_pml';
1
2
  import { XmlPart } from '../XmlPart.mjs';
2
3
  import { BinaryPart } from '../BinaryPart.mjs';
3
4
  import { ContentTypes } from '../../opc/ContentTypes.mjs';
4
5
  import { Namespaces } from '../Namespaces.mjs';
6
+ import { Pptx4jException } from '../../opc/exceptions.mjs';
5
7
  const P = 'http://schemas.openxmlformats.org/presentationml/2006/main';
6
8
  const A = 'http://schemas.openxmlformats.org/drawingml/2006/main';
9
+ /** The parts an id list's `r:id`s point at, in list order, skipping any that is not of the class. */
10
+ function partsByRelId(entries, rp, cls) {
11
+ const out = [];
12
+ for (const entry of entries) {
13
+ const part = rp.getPart(entry.rid);
14
+ if (part instanceof cls)
15
+ out.push(part);
16
+ }
17
+ return out;
18
+ }
19
+ /**
20
+ * A new `p:sldId/@id` (docx4j `JaxbPmlPart.getSlideId()`, ECMA-376 4.8.17 ST_SlideId: 256 to
21
+ * 2147483647). Random, as docx4j's is: nothing in the package numbers them.
22
+ */
23
+ export function nextSlideId() {
24
+ return Math.floor(Math.random() * 2147483392) + 256;
25
+ }
26
+ /**
27
+ * A new `p:sldLayoutId/@id` or `p:sldMasterId/@id` (docx4j
28
+ * `JaxbPmlPart.getSlideLayoutOrMasterId()`, ECMA-376 4.8.18 and 4.8.20: above 2147483648).
29
+ */
30
+ export function nextSlideLayoutOrMasterId() {
31
+ return Math.floor(Math.random() * 2147483647) + 2147483648;
32
+ }
7
33
  export class MainPresentationPart extends XmlPart {
8
34
  constructor(partName = '/ppt/presentation.xml', contentType = ContentTypes.PRESENTATIONML_MAIN) {
9
35
  super(partName, contentType, Namespaces.PRESENTATIONML_MAIN, { namespaceURI: P, localPart: 'presentation' });
10
36
  }
11
37
  setPartShortcut(part, relationshipType) {
12
- if (relationshipType === Namespaces.THEME) {
13
- this.themePart = part;
14
- return true;
38
+ switch (relationshipType) {
39
+ case Namespaces.THEME:
40
+ this.themePart = part;
41
+ return true;
42
+ case Namespaces.PRESENTATIONML_NOTES_MASTER:
43
+ this.notesMasterPart = part;
44
+ return true;
45
+ case Namespaces.PRESENTATIONML_COMMENT_AUTHORS:
46
+ this.commentAuthorsPart = part;
47
+ return true;
48
+ case Namespaces.PRESENTATIONML_PRES_PROPS:
49
+ this.presentationPropertiesPart = part;
50
+ return true;
51
+ case Namespaces.PRESENTATIONML_VIEW_PROPS:
52
+ this.viewPropertiesPart = part;
53
+ return true;
54
+ case Namespaces.PRESENTATIONML_TABLE_STYLES:
55
+ this.tableStylesPart = part;
56
+ return true;
57
+ default: return false;
15
58
  }
16
- return false;
17
59
  }
60
+ /**
61
+ * The slides, in `p:sldIdLst` order (docx4j `getSlideParts()`), once the part is unmarshalled;
62
+ * before that, in relationship order, which is the order they were added in.
63
+ */
18
64
  get slideParts() {
65
+ var _a;
19
66
  const rp = this.relationshipsPart;
20
67
  if (!rp)
21
68
  return [];
69
+ if (this.isUnmarshalled) {
70
+ const entries = (_a = this.contents.sldIdLst) === null || _a === void 0 ? void 0 : _a.sldId;
71
+ if (entries)
72
+ return partsByRelId(entries, rp, SlidePart);
73
+ }
22
74
  return rp.getRelationshipsByType(Namespaces.PRESENTATIONML_SLIDE).map((r) => rp.getPart(r)).filter((p) => p instanceof SlidePart);
23
75
  }
76
+ /** The slides in `p:sldIdLst` order, unmarshalling the part first (docx4j `getSlideParts()`). */
77
+ async getSlideParts() {
78
+ await this.getContents();
79
+ return this.slideParts;
80
+ }
81
+ /** The slide masters, in `p:sldMasterIdLst` order once the part is unmarshalled. */
82
+ get slideMasterParts() {
83
+ var _a;
84
+ const rp = this.relationshipsPart;
85
+ if (!rp)
86
+ return [];
87
+ if (this.isUnmarshalled) {
88
+ const entries = (_a = this.contents.sldMasterIdLst) === null || _a === void 0 ? void 0 : _a.sldMasterId;
89
+ if (entries)
90
+ return partsByRelId(entries, rp, SlideMasterPart);
91
+ }
92
+ return rp.getRelationshipsByType(Namespaces.PRESENTATIONML_SLIDE_MASTER).map((r) => rp.getPart(r)).filter((p) => p instanceof SlideMasterPart);
93
+ }
94
+ /** The slide at an index of `p:sldIdLst` (docx4j `getSlide(int)`). */
95
+ getSlide(index) {
96
+ const slides = this.slideParts;
97
+ const slide = slides[index];
98
+ if (!slide)
99
+ throw new Pptx4jException(`No slide at index ${index}. (There are ${slides.length} slides)`);
100
+ return slide;
101
+ }
102
+ /** docx4j `getSlideCount()`. */
103
+ get slideCount() {
104
+ var _a, _b, _c;
105
+ return (_c = (_b = (_a = this.contents.sldIdLst) === null || _a === void 0 ? void 0 : _a.sldId) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
106
+ }
107
+ /**
108
+ * Adds a slide part as a target and appends a `p:sldId` for it (docx4j
109
+ * `addSlideIdListEntry(SlidePart)`); the part must be unmarshalled.
110
+ */
111
+ addSlideIdListEntry(slidePart, mode = 'OVERWRITE_IF_NAME_EXISTS') {
112
+ const rel = this.addTargetPart(slidePart, mode);
113
+ const entry = createPresentationSldIdLstSldId({ id: nextSlideId(), rid: rel.id });
114
+ this.sldIdLst().sldId.push(entry);
115
+ return entry;
116
+ }
117
+ /**
118
+ * docx4j `addSlide(SlidePart)` / `addSlide(int, SlidePart)`: appends the slide, or inserts it
119
+ * at `index`, renaming the part if the name is taken (PowerPoint cannot open a package in which
120
+ * two relationships target the same slide, so a slide is never added twice).
121
+ *
122
+ * `layoutPart`, when given, becomes the slide's layout relationship, as a slide needs one.
123
+ */
124
+ addSlide(slidePart, index, layoutPart) {
125
+ const sldId = this.sldIdLst().sldId;
126
+ if (index !== undefined && (index < 0 || index > sldId.length)) {
127
+ throw new Pptx4jException(`Can't add slide at index ${index}. (There are ${sldId.length} slides) `);
128
+ }
129
+ const rel = this.addTargetPart(slidePart, 'RENAME_IF_NAME_EXISTS');
130
+ const entry = createPresentationSldIdLstSldId({ id: nextSlideId(), rid: rel.id });
131
+ if (index === undefined)
132
+ sldId.push(entry);
133
+ else
134
+ sldId.splice(index, 0, entry);
135
+ if (layoutPart)
136
+ slidePart.addTargetPart(layoutPart);
137
+ return entry;
138
+ }
139
+ /** docx4j `addSlideMasterIdListEntry(SlideMasterPart)`. */
140
+ addSlideMasterIdListEntry(masterPart) {
141
+ var _a, _b;
142
+ var _c;
143
+ const rel = this.addTargetPart(masterPart);
144
+ const entry = createPresentationSldMasterIdLstSldMasterId({ id: nextSlideLayoutOrMasterId(), rid: rel.id });
145
+ const lst = ((_a = (_c = this.contents).sldMasterIdLst) !== null && _a !== void 0 ? _a : (_c.sldMasterIdLst = { sldMasterId: [] }));
146
+ ((_b = lst.sldMasterId) !== null && _b !== void 0 ? _b : (lst.sldMasterId = [])).push(entry);
147
+ return entry;
148
+ }
149
+ /** docx4j `removeSlide(int)`: the `p:sldId`, the relationship and the part. */
150
+ removeSlide(index) {
151
+ const sldId = this.sldIdLst().sldId;
152
+ const entry = sldId[index];
153
+ if (!entry)
154
+ throw new Pptx4jException(`No slide at index ${index}. (There are ${sldId.length} slides) `);
155
+ sldId.splice(index, 1);
156
+ const rp = this.relationshipsPart;
157
+ const part = rp.getPart(entry.rid);
158
+ rp.removePart(part.partName);
159
+ return part;
160
+ }
161
+ sldIdLst() {
162
+ var _a, _b;
163
+ const contents = this.contents;
164
+ const lst = ((_a = contents.sldIdLst) !== null && _a !== void 0 ? _a : (contents.sldIdLst = { sldId: [] }));
165
+ (_b = lst.sldId) !== null && _b !== void 0 ? _b : (lst.sldId = []);
166
+ return lst;
167
+ }
24
168
  }
25
169
  export class SlidePart extends XmlPart {
26
- constructor(partName) {
170
+ constructor(partName = '/ppt/slides/slide1.xml') {
27
171
  super(partName, ContentTypes.PRESENTATIONML_SLIDE, Namespaces.PRESENTATIONML_SLIDE, { namespaceURI: P, localPart: 'sld' });
28
172
  }
173
+ setPartShortcut(part, relationshipType) {
174
+ switch (relationshipType) {
175
+ case Namespaces.PRESENTATIONML_SLIDE_LAYOUT:
176
+ this.slideLayoutPart = part;
177
+ return true;
178
+ case Namespaces.PRESENTATIONML_NOTES_SLIDE:
179
+ this.notesSlidePart = part;
180
+ return true;
181
+ case Namespaces.PRESENTATIONML_COMMENTS:
182
+ this.commentsPart = part;
183
+ return true;
184
+ default: return false;
185
+ }
186
+ }
29
187
  }
30
188
  export class SlideLayoutPart extends XmlPart {
31
- constructor(partName) {
189
+ constructor(partName = '/ppt/slideLayouts/slideLayout1.xml') {
32
190
  super(partName, ContentTypes.PRESENTATIONML_SLIDE_LAYOUT, Namespaces.PRESENTATIONML_SLIDE_LAYOUT, { namespaceURI: P, localPart: 'sldLayout' });
33
191
  }
192
+ setPartShortcut(part, relationshipType) {
193
+ if (relationshipType === Namespaces.PRESENTATIONML_SLIDE_MASTER) {
194
+ this.slideMasterPart = part;
195
+ return true;
196
+ }
197
+ return false;
198
+ }
34
199
  }
35
200
  export class SlideMasterPart extends XmlPart {
36
- constructor(partName) {
201
+ constructor(partName = '/ppt/slideMasters/slideMaster1.xml') {
37
202
  super(partName, ContentTypes.PRESENTATIONML_SLIDE_MASTER, Namespaces.PRESENTATIONML_SLIDE_MASTER, { namespaceURI: P, localPart: 'sldMaster' });
38
203
  }
204
+ setPartShortcut(part, relationshipType) {
205
+ if (relationshipType === Namespaces.THEME) {
206
+ this.themePart = part;
207
+ return true;
208
+ }
209
+ return false;
210
+ }
211
+ /**
212
+ * Adds a layout part as a target and appends a `p:sldLayoutId` for it (docx4j
213
+ * `addSlideLayoutIdListEntry`); the master must be unmarshalled.
214
+ */
215
+ addSlideLayoutIdListEntry(slideLayoutPart) {
216
+ var _a, _b;
217
+ var _c;
218
+ const rel = this.addTargetPart(slideLayoutPart);
219
+ const entry = createSlideLayoutIdListSldLayoutId({ id: nextSlideLayoutOrMasterId(), rid: rel.id });
220
+ const lst = ((_a = (_c = this.contents).sldLayoutIdLst) !== null && _a !== void 0 ? _a : (_c.sldLayoutIdLst = { sldLayoutId: [] }));
221
+ ((_b = lst.sldLayoutId) !== null && _b !== void 0 ? _b : (lst.sldLayoutId = [])).push(entry);
222
+ return entry;
223
+ }
224
+ /** This master's layouts, in `p:sldLayoutIdLst` order once the master is unmarshalled. */
225
+ get slideLayoutParts() {
226
+ var _a;
227
+ const rp = this.relationshipsPart;
228
+ if (!rp)
229
+ return [];
230
+ if (this.isUnmarshalled) {
231
+ const entries = (_a = this.contents.sldLayoutIdLst) === null || _a === void 0 ? void 0 : _a.sldLayoutId;
232
+ if (entries)
233
+ return partsByRelId(entries, rp, SlideLayoutPart);
234
+ }
235
+ return rp.getRelationshipsByType(Namespaces.PRESENTATIONML_SLIDE_LAYOUT).map((r) => rp.getPart(r)).filter((p) => p instanceof SlideLayoutPart);
236
+ }
39
237
  }
40
238
  export class NotesSlidePart extends XmlPart {
41
239
  constructor(partName) {
@@ -88,3 +286,4 @@ export class FontDataPart extends BinaryPart {
88
286
  super(partName, ContentTypes.PRESENTATIONML_FONT_DATA, Namespaces.PRESENTATIONML_FONT_DATA);
89
287
  }
90
288
  }
289
+ export { placeholderGeometry, placeholderShape, slidePlaceholders, layoutPlaceholders, addShapes, bodyLines, placeholdersOf, slidePlaceholdersFor, } from './placeholders.mjs';
@@ -0,0 +1,71 @@
1
+ import type * as pml from '@docx4j/generated-objects-ts/modules/org_pptx4j_pml';
2
+ /** The text of a created slide's placeholders; `body` is one paragraph per line, or per entry. */
3
+ export interface SlideTextOptions {
4
+ /** The title placeholder's text; the placeholder is left empty (its prompt) when absent. */
5
+ title?: string;
6
+ /** The body placeholder's text: a string (split on newlines) or one string per paragraph. */
7
+ body?: string | string[];
8
+ }
9
+ /** A rectangle in EMU, as `a:xfrm` carries it. */
10
+ export interface Rect {
11
+ x: number;
12
+ y: number;
13
+ cx: number;
14
+ cy: number;
15
+ }
16
+ /**
17
+ * Where the title and body placeholders sit, as fractions of the slide: PowerPoint's own
18
+ * Title and Content layout at 4:3 (title 685800, 457200, 7772400 x 1143000; body 685800,
19
+ * 1600200, 7772400 x 4525963 of 9144000 x 6858000), so any slide size is laid out the same way.
20
+ */
21
+ export declare function placeholderGeometry(sldSz: {
22
+ cx?: number;
23
+ cy?: number;
24
+ } | undefined): {
25
+ title: Rect;
26
+ body: Rect;
27
+ };
28
+ /** The body text as paragraphs: a string is split on newlines, as Office JS's `insertText` does. */
29
+ export declare function bodyLines(body: string | string[] | undefined): string[];
30
+ /**
31
+ * One placeholder shape (docx4j's `SAMPLE_SHAPE` in `PresentationMLPackage`, and the layout
32
+ * markup of its `SlidePlaceholder` sample): `p:sp` with `a:spLocks noGrp`, the `p:ph`, an
33
+ * optional `a:xfrm` and a `p:txBody` of the lines given.
34
+ */
35
+ export declare function placeholderShape(options: {
36
+ id: number;
37
+ name: string;
38
+ type?: pml.STPlaceholderType;
39
+ idx?: number;
40
+ xfrm?: Rect;
41
+ lines?: string[];
42
+ }): pml.Shape;
43
+ /**
44
+ * The title (`p:ph type="title"`) and body (`p:ph idx="1"`) shapes a created **slide** carries,
45
+ * with no geometry of their own: each inherits the layout's, which is what a placeholder is for.
46
+ */
47
+ export declare function slidePlaceholders(text?: SlideTextOptions): pml.Shape[];
48
+ /**
49
+ * The same pair for the **layout**, with the geometry the slides inherit and PowerPoint's own
50
+ * prompt text. Without these the slide's placeholders would have nothing to inherit from and
51
+ * PowerPoint would draw them at the origin with no size.
52
+ */
53
+ export declare function layoutPlaceholders(sldSz: {
54
+ cx?: number;
55
+ cy?: number;
56
+ } | undefined): pml.Shape[];
57
+ /** The placeholder shapes of a slide, layout or master, in shape-tree order. */
58
+ export declare function placeholdersOf(cSld: pml.CommonSlideData | undefined): {
59
+ shape: pml.Shape;
60
+ ph: pml.CTPlaceholder;
61
+ }[];
62
+ /**
63
+ * The placeholders a new slide on this layout carries: one shape per placeholder the layout
64
+ * defines (bar the date, footer and slide-number ones), with the layout's `type` and `idx` so
65
+ * that each inherits that layout shape's position and text style, and with the text given in the
66
+ * first title and the first body one. A layout that defines none - docx4j's own - gets the
67
+ * default title and body pair.
68
+ */
69
+ export declare function slidePlaceholdersFor(layout: pml.CommonSlideData | undefined, text?: SlideTextOptions): pml.Shape[];
70
+ /** Puts shapes into a slide's or layout's shape tree (docx4j `cSld.getSpTree().getSpOrGrpSpOrGraphicFrame().add(...)`). */
71
+ export declare function addShapes(spTree: pml.GroupShape, shapes: pml.Shape[]): void;