odf.js 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/codec.cjs +28 -0
- package/dist/codec.d.cts +72 -0
- package/dist/codec.d.ts +72 -0
- package/dist/codec.js +24 -0
- package/dist/image/sniff.cjs +28 -0
- package/dist/image/sniff.d.cts +5 -0
- package/dist/image/sniff.d.ts +5 -0
- package/dist/image/sniff.js +27 -0
- package/dist/index.cjs +156 -3242
- package/dist/index.d.cts +42 -679
- package/dist/index.d.ts +42 -679
- package/dist/index.js +42 -3129
- package/dist/manifest.cjs +252 -0
- package/dist/manifest.d.cts +41 -0
- package/dist/manifest.d.ts +41 -0
- package/dist/manifest.js +242 -0
- package/dist/media-type.cjs +27 -0
- package/dist/media-type.d.cts +20 -0
- package/dist/media-type.d.ts +20 -0
- package/dist/media-type.js +25 -0
- package/dist/mimetype.cjs +19 -0
- package/dist/mimetype.d.cts +7 -0
- package/dist/mimetype.d.ts +7 -0
- package/dist/mimetype.js +16 -0
- package/dist/model/node.cjs +67 -0
- package/dist/model/node.d.cts +2 -0
- package/dist/model/node.d.ts +2 -0
- package/dist/model/node.js +58 -0
- package/dist/model/package.cjs +19 -0
- package/dist/model/package.d.cts +114 -0
- package/dist/model/package.d.ts +114 -0
- package/dist/model/package.js +15 -0
- package/dist/node-CkBWRjNR.d.cts +83 -0
- package/dist/node-CkBWRjNR.d.ts +83 -0
- package/dist/ns.cjs +37 -0
- package/dist/ns.d.cts +32 -0
- package/dist/ns.d.ts +32 -0
- package/dist/ns.js +35 -0
- package/dist/package-io/read.cjs +35 -0
- package/dist/package-io/read.d.cts +5 -0
- package/dist/package-io/read.d.ts +5 -0
- package/dist/package-io/read.js +34 -0
- package/dist/package-io/write.cjs +36 -0
- package/dist/package-io/write.d.cts +7 -0
- package/dist/package-io/write.d.ts +7 -0
- package/dist/package-io/write.js +33 -0
- package/dist/styles/properties.cjs +286 -0
- package/dist/styles/properties.d.cts +45 -0
- package/dist/styles/properties.d.ts +45 -0
- package/dist/styles/properties.js +277 -0
- package/dist/styles/registry.cjs +212 -0
- package/dist/styles/registry.d.cts +37 -0
- package/dist/styles/registry.d.ts +37 -0
- package/dist/styles/registry.js +209 -0
- package/dist/styles/serialize.cjs +23 -0
- package/dist/styles/serialize.d.cts +7 -0
- package/dist/styles/serialize.d.ts +7 -0
- package/dist/styles/serialize.js +21 -0
- package/dist/styles/span.cjs +114 -0
- package/dist/styles/span.d.cts +5 -0
- package/dist/styles/span.d.ts +5 -0
- package/dist/styles/span.js +113 -0
- package/dist/typed/draw/shapes.cjs +314 -0
- package/dist/typed/draw/shapes.d.cts +14 -0
- package/dist/typed/draw/shapes.d.ts +14 -0
- package/dist/typed/draw/shapes.js +311 -0
- package/dist/typed/formula/read.cjs +48 -0
- package/dist/typed/formula/read.d.cts +12 -0
- package/dist/typed/formula/read.d.ts +12 -0
- package/dist/typed/formula/read.js +47 -0
- package/dist/typed/odb/read.cjs +112 -0
- package/dist/typed/odb/read.d.cts +17 -0
- package/dist/typed/odb/read.d.ts +17 -0
- package/dist/typed/odb/read.js +111 -0
- package/dist/typed/odg/read.cjs +30 -0
- package/dist/typed/odg/read.d.cts +10 -0
- package/dist/typed/odg/read.d.ts +10 -0
- package/dist/typed/odg/read.js +29 -0
- package/dist/typed/odm/read.cjs +37 -0
- package/dist/typed/odm/read.d.cts +15 -0
- package/dist/typed/odm/read.d.ts +15 -0
- package/dist/typed/odm/read.js +36 -0
- package/dist/typed/odp/read.cjs +39 -0
- package/dist/typed/odp/read.d.cts +10 -0
- package/dist/typed/odp/read.d.ts +10 -0
- package/dist/typed/odp/read.js +38 -0
- package/dist/typed/ods/read.cjs +318 -0
- package/dist/typed/ods/read.d.cts +10 -0
- package/dist/typed/ods/read.d.ts +10 -0
- package/dist/typed/ods/read.js +317 -0
- package/dist/typed/odt/read.cjs +112 -0
- package/dist/typed/odt/read.d.cts +10 -0
- package/dist/typed/odt/read.d.ts +10 -0
- package/dist/typed/odt/read.js +111 -0
- package/dist/typed/shared/a1.cjs +68 -0
- package/dist/typed/shared/a1.d.cts +18 -0
- package/dist/typed/shared/a1.d.ts +18 -0
- package/dist/typed/shared/a1.js +63 -0
- package/dist/typed/shared/cascade.cjs +102 -0
- package/dist/typed/shared/cascade.d.cts +22 -0
- package/dist/typed/shared/cascade.d.ts +22 -0
- package/dist/typed/shared/cascade.js +99 -0
- package/dist/typed/shared/color.cjs +14 -0
- package/dist/typed/shared/color.d.cts +6 -0
- package/dist/typed/shared/color.d.ts +6 -0
- package/dist/typed/shared/color.js +12 -0
- package/dist/typed/shared/geometry.cjs +79 -0
- package/dist/typed/shared/geometry.d.cts +12 -0
- package/dist/typed/shared/geometry.d.ts +12 -0
- package/dist/typed/shared/geometry.js +75 -0
- package/dist/typed/shared/masterpage.cjs +39 -0
- package/dist/typed/shared/masterpage.d.cts +8 -0
- package/dist/typed/shared/masterpage.d.ts +8 -0
- package/dist/typed/shared/masterpage.js +37 -0
- package/dist/typed/shared/metadata.cjs +42 -0
- package/dist/typed/shared/metadata.d.cts +7 -0
- package/dist/typed/shared/metadata.d.ts +7 -0
- package/dist/typed/shared/metadata.js +40 -0
- package/dist/typed/shared/paragraph.cjs +57 -0
- package/dist/typed/shared/paragraph.d.cts +7 -0
- package/dist/typed/shared/paragraph.d.ts +7 -0
- package/dist/typed/shared/paragraph.js +56 -0
- package/dist/typed/shared/path.cjs +261 -0
- package/dist/typed/shared/path.d.cts +34 -0
- package/dist/typed/shared/path.d.ts +34 -0
- package/dist/typed/shared/path.js +255 -0
- package/dist/typed/shared/style.cjs +8 -0
- package/dist/typed/shared/style.d.cts +2 -0
- package/dist/typed/shared/style.d.ts +2 -0
- package/dist/typed/shared/style.js +2 -0
- package/dist/typed/shared/table.cjs +84 -0
- package/dist/typed/shared/table.d.cts +7 -0
- package/dist/typed/shared/table.d.ts +7 -0
- package/dist/typed/shared/table.js +83 -0
- package/dist/typed/shared/text.cjs +43 -0
- package/dist/typed/shared/text.d.cts +8 -0
- package/dist/typed/shared/text.d.ts +8 -0
- package/dist/typed/shared/text.js +39 -0
- package/dist/typed/shared/transform.cjs +112 -0
- package/dist/typed/shared/transform.d.cts +26 -0
- package/dist/typed/shared/transform.d.ts +26 -0
- package/dist/typed/shared/transform.js +107 -0
- package/dist/typed/shared/units.cjs +35 -0
- package/dist/typed/shared/units.d.cts +2 -0
- package/dist/typed/shared/units.d.ts +2 -0
- package/dist/typed/shared/units.js +33 -0
- package/dist/units-7pCiECuP.d.cts +6 -0
- package/dist/units-7pCiECuP.d.ts +6 -0
- package/dist/util/base64.cjs +48 -0
- package/dist/util/base64.d.cts +5 -0
- package/dist/util/base64.d.ts +5 -0
- package/dist/util/base64.js +46 -0
- package/dist/xml/build.cjs +46 -0
- package/dist/xml/build.d.cts +5 -0
- package/dist/xml/build.d.ts +5 -0
- package/dist/xml/build.js +46 -0
- package/dist/xml/entities.cjs +19 -0
- package/dist/xml/entities.d.cts +5 -0
- package/dist/xml/entities.d.ts +5 -0
- package/dist/xml/entities.js +17 -0
- package/dist/xml/fragment.cjs +22 -0
- package/dist/xml/fragment.d.cts +6 -0
- package/dist/xml/fragment.d.ts +6 -0
- package/dist/xml/fragment.js +20 -0
- package/dist/xml/parse.cjs +88 -0
- package/dist/xml/parse.d.cts +5 -0
- package/dist/xml/parse.d.ts +5 -0
- package/dist/xml/parse.js +88 -0
- package/dist/xml/query.cjs +33 -0
- package/dist/xml/query.d.cts +9 -0
- package/dist/xml/query.d.ts +9 -0
- package/dist/xml/query.js +28 -0
- package/dist/zip.cjs +15 -0
- package/dist/zip.d.cts +9 -0
- package/dist/zip.d.ts +9 -0
- package/dist/zip.js +13 -0
- package/package.json +9 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_entities = require("../../xml/entities.cjs");
|
|
3
|
+
const require_xml_query = require("../../xml/query.cjs");
|
|
4
|
+
const require_typed_shared_metadata = require("../shared/metadata.cjs");
|
|
5
|
+
//#region src/typed/formula/read.ts
|
|
6
|
+
const CONTENT_PART = "content.xml";
|
|
7
|
+
const MATH_ROOT_TAGS = ["math", "math:math"];
|
|
8
|
+
const ANNOTATION_TAGS = ["annotation", "math:annotation"];
|
|
9
|
+
const STARMATH_ENCODING_PREFIX = "StarMath";
|
|
10
|
+
function findMathRoot(nodes) {
|
|
11
|
+
const root = require_xml_query.rootElement(nodes);
|
|
12
|
+
if (root === void 0) return;
|
|
13
|
+
if (MATH_ROOT_TAGS.includes(root.tag)) return root;
|
|
14
|
+
for (const tag of MATH_ROOT_TAGS) {
|
|
15
|
+
const [found] = require_xml_query.elementsWithTag(root.children, tag);
|
|
16
|
+
if (found !== void 0) return found;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function annotationText(element) {
|
|
20
|
+
let text = "";
|
|
21
|
+
for (const child of element.children) if (child.type === "text") text += require_xml_entities.decodeXmlText(child.value);
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
function findStarMathAnnotation(mathRoot) {
|
|
25
|
+
for (const tag of ANNOTATION_TAGS) for (const annotation of require_xml_query.elementsWithTag(mathRoot.children, tag)) {
|
|
26
|
+
if (!require_xml_query.attrValue(annotation, "encoding")?.startsWith(STARMATH_ENCODING_PREFIX)) continue;
|
|
27
|
+
const text = annotationText(annotation);
|
|
28
|
+
if (text.length > 0) return text;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function readOdfFormula(pkg) {
|
|
32
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
33
|
+
if (contentPart?.kind !== "xml") throw new Error(`readOdfFormula: package has no ${CONTENT_PART} part`);
|
|
34
|
+
const mathRoot = findMathRoot(contentPart.nodes);
|
|
35
|
+
if (mathRoot === void 0) throw new Error(`readOdfFormula: ${CONTENT_PART} has no MathML root element`);
|
|
36
|
+
const metadata = require_typed_shared_metadata.readOdfMetadata(pkg);
|
|
37
|
+
const starMath = findStarMathAnnotation(mathRoot);
|
|
38
|
+
return starMath === void 0 ? {
|
|
39
|
+
mathml: mathRoot.children,
|
|
40
|
+
metadata
|
|
41
|
+
} : {
|
|
42
|
+
starMath,
|
|
43
|
+
mathml: mathRoot.children,
|
|
44
|
+
metadata
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.readOdfFormula = readOdfFormula;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { d as XmlNode } from "../../node-CkBWRjNR.cjs";
|
|
2
|
+
import { Package } from "../../model/package.cjs";
|
|
3
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
4
|
+
//#region src/typed/formula/read.d.ts
|
|
5
|
+
interface OdfFormulaDocument {
|
|
6
|
+
starMath?: string;
|
|
7
|
+
mathml: XmlNode[];
|
|
8
|
+
metadata: LayoutMetadata;
|
|
9
|
+
}
|
|
10
|
+
declare function readOdfFormula(pkg: Package): OdfFormulaDocument;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { OdfFormulaDocument, readOdfFormula };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { d as XmlNode } from "../../node-CkBWRjNR.js";
|
|
2
|
+
import { Package } from "../../model/package.js";
|
|
3
|
+
import { LayoutMetadata } from "document-schema.js";
|
|
4
|
+
//#region src/typed/formula/read.d.ts
|
|
5
|
+
interface OdfFormulaDocument {
|
|
6
|
+
starMath?: string;
|
|
7
|
+
mathml: XmlNode[];
|
|
8
|
+
metadata: LayoutMetadata;
|
|
9
|
+
}
|
|
10
|
+
declare function readOdfFormula(pkg: Package): OdfFormulaDocument;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { OdfFormulaDocument, readOdfFormula };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { decodeXmlText } from "../../xml/entities.js";
|
|
2
|
+
import { attrValue, elementsWithTag, rootElement } from "../../xml/query.js";
|
|
3
|
+
import { readOdfMetadata } from "../shared/metadata.js";
|
|
4
|
+
//#region src/typed/formula/read.ts
|
|
5
|
+
const CONTENT_PART = "content.xml";
|
|
6
|
+
const MATH_ROOT_TAGS = ["math", "math:math"];
|
|
7
|
+
const ANNOTATION_TAGS = ["annotation", "math:annotation"];
|
|
8
|
+
const STARMATH_ENCODING_PREFIX = "StarMath";
|
|
9
|
+
function findMathRoot(nodes) {
|
|
10
|
+
const root = rootElement(nodes);
|
|
11
|
+
if (root === void 0) return;
|
|
12
|
+
if (MATH_ROOT_TAGS.includes(root.tag)) return root;
|
|
13
|
+
for (const tag of MATH_ROOT_TAGS) {
|
|
14
|
+
const [found] = elementsWithTag(root.children, tag);
|
|
15
|
+
if (found !== void 0) return found;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function annotationText(element) {
|
|
19
|
+
let text = "";
|
|
20
|
+
for (const child of element.children) if (child.type === "text") text += decodeXmlText(child.value);
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
function findStarMathAnnotation(mathRoot) {
|
|
24
|
+
for (const tag of ANNOTATION_TAGS) for (const annotation of elementsWithTag(mathRoot.children, tag)) {
|
|
25
|
+
if (!attrValue(annotation, "encoding")?.startsWith(STARMATH_ENCODING_PREFIX)) continue;
|
|
26
|
+
const text = annotationText(annotation);
|
|
27
|
+
if (text.length > 0) return text;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function readOdfFormula(pkg) {
|
|
31
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
32
|
+
if (contentPart?.kind !== "xml") throw new Error(`readOdfFormula: package has no ${CONTENT_PART} part`);
|
|
33
|
+
const mathRoot = findMathRoot(contentPart.nodes);
|
|
34
|
+
if (mathRoot === void 0) throw new Error(`readOdfFormula: ${CONTENT_PART} has no MathML root element`);
|
|
35
|
+
const metadata = readOdfMetadata(pkg);
|
|
36
|
+
const starMath = findStarMathAnnotation(mathRoot);
|
|
37
|
+
return starMath === void 0 ? {
|
|
38
|
+
mathml: mathRoot.children,
|
|
39
|
+
metadata
|
|
40
|
+
} : {
|
|
41
|
+
starMath,
|
|
42
|
+
mathml: mathRoot.children,
|
|
43
|
+
metadata
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { readOdfFormula };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_manifest = require("../../manifest.cjs");
|
|
3
|
+
const require_xml_query = require("../../xml/query.cjs");
|
|
4
|
+
//#region src/typed/odb/read.ts
|
|
5
|
+
const CONTENT_PART = "content.xml";
|
|
6
|
+
const EMBEDDED_URL_PREFIX = "sdbc:embedded:";
|
|
7
|
+
const SUBDOCUMENT_CONTENT_SUFFIX = "/content.xml";
|
|
8
|
+
function isXmlMediaType(mediaType) {
|
|
9
|
+
return mediaType === "text/xml" || mediaType === "application/xml" || mediaType.endsWith("+xml");
|
|
10
|
+
}
|
|
11
|
+
function formatServerDatabaseUrl(serverDatabase) {
|
|
12
|
+
const dbType = require_xml_query.attrValue(serverDatabase, "db:type");
|
|
13
|
+
if (dbType === void 0) return;
|
|
14
|
+
const hostname = require_xml_query.attrValue(serverDatabase, "db:hostname");
|
|
15
|
+
const port = require_xml_query.attrValue(serverDatabase, "db:port");
|
|
16
|
+
const localSocketName = require_xml_query.attrValue(serverDatabase, "db:local-socket-name");
|
|
17
|
+
const databaseName = require_xml_query.attrValue(serverDatabase, "db:database-name");
|
|
18
|
+
const host = hostname === void 0 ? localSocketName : `${hostname}${port === void 0 ? "" : `:${port}`}`;
|
|
19
|
+
if (host === void 0) return databaseName === void 0 ? `${dbType}://` : `${dbType}:///${databaseName}`;
|
|
20
|
+
return databaseName === void 0 ? `${dbType}://${host}` : `${dbType}://${host}/${databaseName}`;
|
|
21
|
+
}
|
|
22
|
+
function readConnectionInfo(databaseElement) {
|
|
23
|
+
const dataSource = require_xml_query.findChildElement(databaseElement.children, "db:data-source");
|
|
24
|
+
const connectionData = dataSource === void 0 ? void 0 : require_xml_query.findChildElement(dataSource.children, "db:connection-data");
|
|
25
|
+
if (connectionData === void 0) return;
|
|
26
|
+
const resource = require_xml_query.findChildElement(connectionData.children, "db:connection-resource");
|
|
27
|
+
if (resource !== void 0) {
|
|
28
|
+
const url = require_xml_query.attrValue(resource, "xlink:href");
|
|
29
|
+
if (url === void 0) return;
|
|
30
|
+
return {
|
|
31
|
+
type: url.startsWith(EMBEDDED_URL_PREFIX) ? "embedded" : "external",
|
|
32
|
+
url
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const description = require_xml_query.findChildElement(connectionData.children, "db:database-description");
|
|
36
|
+
if (description === void 0) return;
|
|
37
|
+
const fileBased = require_xml_query.findChildElement(description.children, "db:file-based-database");
|
|
38
|
+
if (fileBased !== void 0) {
|
|
39
|
+
const url = require_xml_query.attrValue(fileBased, "xlink:href");
|
|
40
|
+
return url === void 0 ? { type: "external" } : {
|
|
41
|
+
type: "external",
|
|
42
|
+
url
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const serverDatabase = require_xml_query.findChildElement(description.children, "db:server-database");
|
|
46
|
+
if (serverDatabase !== void 0) {
|
|
47
|
+
const url = formatServerDatabaseUrl(serverDatabase);
|
|
48
|
+
return url === void 0 ? { type: "external" } : {
|
|
49
|
+
type: "external",
|
|
50
|
+
url
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function collectQueryNames(container, names) {
|
|
55
|
+
for (const child of container.children) {
|
|
56
|
+
if (child.type !== "element") continue;
|
|
57
|
+
if (child.tag === "db:query") {
|
|
58
|
+
const name = require_xml_query.attrValue(child, "db:name");
|
|
59
|
+
if (name !== void 0) names.push(name);
|
|
60
|
+
} else if (child.tag === "db:query-collection") collectQueryNames(child, names);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function collectTableNames(databaseElement) {
|
|
64
|
+
const names = [];
|
|
65
|
+
const seen = /* @__PURE__ */ new Set();
|
|
66
|
+
const pushName = (name) => {
|
|
67
|
+
if (name !== void 0 && !seen.has(name)) {
|
|
68
|
+
seen.add(name);
|
|
69
|
+
names.push(name);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const representations = require_xml_query.findChildElement(databaseElement.children, "db:table-representations");
|
|
73
|
+
if (representations !== void 0) for (const representation of require_xml_query.childrenWithTag(representations, "db:table-representation")) pushName(require_xml_query.attrValue(representation, "db:name"));
|
|
74
|
+
const schemaDefinition = require_xml_query.findChildElement(databaseElement.children, "db:schema-definition");
|
|
75
|
+
const tableDefinitions = schemaDefinition === void 0 ? void 0 : require_xml_query.findChildElement(schemaDefinition.children, "db:table-definitions");
|
|
76
|
+
if (tableDefinitions !== void 0) for (const definition of require_xml_query.childrenWithTag(tableDefinitions, "db:table-definition")) pushName(require_xml_query.attrValue(definition, "db:name"));
|
|
77
|
+
return names;
|
|
78
|
+
}
|
|
79
|
+
function subdocumentNamesUnderPrefix(entries, prefix) {
|
|
80
|
+
const names = [];
|
|
81
|
+
for (const entry of entries) {
|
|
82
|
+
if (!entry.fullPath.startsWith(prefix) || !entry.fullPath.endsWith(SUBDOCUMENT_CONTENT_SUFFIX) || !isXmlMediaType(entry.mediaType)) continue;
|
|
83
|
+
const withoutSuffix = entry.fullPath.slice(0, entry.fullPath.length - 12);
|
|
84
|
+
const lastSlash = withoutSuffix.lastIndexOf("/");
|
|
85
|
+
const name = lastSlash === -1 ? withoutSuffix.slice(prefix.length) : withoutSuffix.slice(lastSlash + 1);
|
|
86
|
+
if (name.length > 0) names.push(name);
|
|
87
|
+
}
|
|
88
|
+
return names;
|
|
89
|
+
}
|
|
90
|
+
function readOdbInventory(pkg) {
|
|
91
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
92
|
+
if (contentPart?.kind !== "xml") throw new Error(`readOdbInventory: package has no ${CONTENT_PART} part`);
|
|
93
|
+
const contentRoot = require_xml_query.rootElement(contentPart.nodes);
|
|
94
|
+
const body = contentRoot === void 0 ? void 0 : require_xml_query.findChildElement(contentRoot.children, "office:body");
|
|
95
|
+
const databaseElement = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:database");
|
|
96
|
+
if (databaseElement === void 0) throw new Error(`readOdbInventory: ${CONTENT_PART} has no office:body/office:database element`);
|
|
97
|
+
const connection = readConnectionInfo(databaseElement);
|
|
98
|
+
const queries = [];
|
|
99
|
+
const queriesElement = require_xml_query.findChildElement(databaseElement.children, "db:queries");
|
|
100
|
+
if (queriesElement !== void 0) collectQueryNames(queriesElement, queries);
|
|
101
|
+
const tables = collectTableNames(databaseElement);
|
|
102
|
+
const manifest = require_manifest.readManifest(pkg);
|
|
103
|
+
return {
|
|
104
|
+
connection,
|
|
105
|
+
tables,
|
|
106
|
+
queries,
|
|
107
|
+
forms: subdocumentNamesUnderPrefix(manifest.entries, "forms/"),
|
|
108
|
+
reports: subdocumentNamesUnderPrefix(manifest.entries, "reports/")
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
exports.readOdbInventory = readOdbInventory;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Package } from "../../model/package.cjs";
|
|
2
|
+
//#region src/typed/odb/read.d.ts
|
|
3
|
+
interface OdbConnectionInfo {
|
|
4
|
+
type: 'embedded' | 'external';
|
|
5
|
+
driverClass?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
8
|
+
interface OdbInventory {
|
|
9
|
+
connection: OdbConnectionInfo | undefined;
|
|
10
|
+
tables: string[];
|
|
11
|
+
queries: string[];
|
|
12
|
+
forms: string[];
|
|
13
|
+
reports: string[];
|
|
14
|
+
}
|
|
15
|
+
declare function readOdbInventory(pkg: Package): OdbInventory;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { OdbConnectionInfo, OdbInventory, readOdbInventory };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Package } from "../../model/package.js";
|
|
2
|
+
//#region src/typed/odb/read.d.ts
|
|
3
|
+
interface OdbConnectionInfo {
|
|
4
|
+
type: 'embedded' | 'external';
|
|
5
|
+
driverClass?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
8
|
+
interface OdbInventory {
|
|
9
|
+
connection: OdbConnectionInfo | undefined;
|
|
10
|
+
tables: string[];
|
|
11
|
+
queries: string[];
|
|
12
|
+
forms: string[];
|
|
13
|
+
reports: string[];
|
|
14
|
+
}
|
|
15
|
+
declare function readOdbInventory(pkg: Package): OdbInventory;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { OdbConnectionInfo, OdbInventory, readOdbInventory };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { readManifest } from "../../manifest.js";
|
|
2
|
+
import { attrValue, childrenWithTag, findChildElement, rootElement } from "../../xml/query.js";
|
|
3
|
+
//#region src/typed/odb/read.ts
|
|
4
|
+
const CONTENT_PART = "content.xml";
|
|
5
|
+
const EMBEDDED_URL_PREFIX = "sdbc:embedded:";
|
|
6
|
+
const SUBDOCUMENT_CONTENT_SUFFIX = "/content.xml";
|
|
7
|
+
function isXmlMediaType(mediaType) {
|
|
8
|
+
return mediaType === "text/xml" || mediaType === "application/xml" || mediaType.endsWith("+xml");
|
|
9
|
+
}
|
|
10
|
+
function formatServerDatabaseUrl(serverDatabase) {
|
|
11
|
+
const dbType = attrValue(serverDatabase, "db:type");
|
|
12
|
+
if (dbType === void 0) return;
|
|
13
|
+
const hostname = attrValue(serverDatabase, "db:hostname");
|
|
14
|
+
const port = attrValue(serverDatabase, "db:port");
|
|
15
|
+
const localSocketName = attrValue(serverDatabase, "db:local-socket-name");
|
|
16
|
+
const databaseName = attrValue(serverDatabase, "db:database-name");
|
|
17
|
+
const host = hostname === void 0 ? localSocketName : `${hostname}${port === void 0 ? "" : `:${port}`}`;
|
|
18
|
+
if (host === void 0) return databaseName === void 0 ? `${dbType}://` : `${dbType}:///${databaseName}`;
|
|
19
|
+
return databaseName === void 0 ? `${dbType}://${host}` : `${dbType}://${host}/${databaseName}`;
|
|
20
|
+
}
|
|
21
|
+
function readConnectionInfo(databaseElement) {
|
|
22
|
+
const dataSource = findChildElement(databaseElement.children, "db:data-source");
|
|
23
|
+
const connectionData = dataSource === void 0 ? void 0 : findChildElement(dataSource.children, "db:connection-data");
|
|
24
|
+
if (connectionData === void 0) return;
|
|
25
|
+
const resource = findChildElement(connectionData.children, "db:connection-resource");
|
|
26
|
+
if (resource !== void 0) {
|
|
27
|
+
const url = attrValue(resource, "xlink:href");
|
|
28
|
+
if (url === void 0) return;
|
|
29
|
+
return {
|
|
30
|
+
type: url.startsWith(EMBEDDED_URL_PREFIX) ? "embedded" : "external",
|
|
31
|
+
url
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const description = findChildElement(connectionData.children, "db:database-description");
|
|
35
|
+
if (description === void 0) return;
|
|
36
|
+
const fileBased = findChildElement(description.children, "db:file-based-database");
|
|
37
|
+
if (fileBased !== void 0) {
|
|
38
|
+
const url = attrValue(fileBased, "xlink:href");
|
|
39
|
+
return url === void 0 ? { type: "external" } : {
|
|
40
|
+
type: "external",
|
|
41
|
+
url
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const serverDatabase = findChildElement(description.children, "db:server-database");
|
|
45
|
+
if (serverDatabase !== void 0) {
|
|
46
|
+
const url = formatServerDatabaseUrl(serverDatabase);
|
|
47
|
+
return url === void 0 ? { type: "external" } : {
|
|
48
|
+
type: "external",
|
|
49
|
+
url
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function collectQueryNames(container, names) {
|
|
54
|
+
for (const child of container.children) {
|
|
55
|
+
if (child.type !== "element") continue;
|
|
56
|
+
if (child.tag === "db:query") {
|
|
57
|
+
const name = attrValue(child, "db:name");
|
|
58
|
+
if (name !== void 0) names.push(name);
|
|
59
|
+
} else if (child.tag === "db:query-collection") collectQueryNames(child, names);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function collectTableNames(databaseElement) {
|
|
63
|
+
const names = [];
|
|
64
|
+
const seen = /* @__PURE__ */ new Set();
|
|
65
|
+
const pushName = (name) => {
|
|
66
|
+
if (name !== void 0 && !seen.has(name)) {
|
|
67
|
+
seen.add(name);
|
|
68
|
+
names.push(name);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const representations = findChildElement(databaseElement.children, "db:table-representations");
|
|
72
|
+
if (representations !== void 0) for (const representation of childrenWithTag(representations, "db:table-representation")) pushName(attrValue(representation, "db:name"));
|
|
73
|
+
const schemaDefinition = findChildElement(databaseElement.children, "db:schema-definition");
|
|
74
|
+
const tableDefinitions = schemaDefinition === void 0 ? void 0 : findChildElement(schemaDefinition.children, "db:table-definitions");
|
|
75
|
+
if (tableDefinitions !== void 0) for (const definition of childrenWithTag(tableDefinitions, "db:table-definition")) pushName(attrValue(definition, "db:name"));
|
|
76
|
+
return names;
|
|
77
|
+
}
|
|
78
|
+
function subdocumentNamesUnderPrefix(entries, prefix) {
|
|
79
|
+
const names = [];
|
|
80
|
+
for (const entry of entries) {
|
|
81
|
+
if (!entry.fullPath.startsWith(prefix) || !entry.fullPath.endsWith(SUBDOCUMENT_CONTENT_SUFFIX) || !isXmlMediaType(entry.mediaType)) continue;
|
|
82
|
+
const withoutSuffix = entry.fullPath.slice(0, entry.fullPath.length - 12);
|
|
83
|
+
const lastSlash = withoutSuffix.lastIndexOf("/");
|
|
84
|
+
const name = lastSlash === -1 ? withoutSuffix.slice(prefix.length) : withoutSuffix.slice(lastSlash + 1);
|
|
85
|
+
if (name.length > 0) names.push(name);
|
|
86
|
+
}
|
|
87
|
+
return names;
|
|
88
|
+
}
|
|
89
|
+
function readOdbInventory(pkg) {
|
|
90
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
91
|
+
if (contentPart?.kind !== "xml") throw new Error(`readOdbInventory: package has no ${CONTENT_PART} part`);
|
|
92
|
+
const contentRoot = rootElement(contentPart.nodes);
|
|
93
|
+
const body = contentRoot === void 0 ? void 0 : findChildElement(contentRoot.children, "office:body");
|
|
94
|
+
const databaseElement = body === void 0 ? void 0 : findChildElement(body.children, "office:database");
|
|
95
|
+
if (databaseElement === void 0) throw new Error(`readOdbInventory: ${CONTENT_PART} has no office:body/office:database element`);
|
|
96
|
+
const connection = readConnectionInfo(databaseElement);
|
|
97
|
+
const queries = [];
|
|
98
|
+
const queriesElement = findChildElement(databaseElement.children, "db:queries");
|
|
99
|
+
if (queriesElement !== void 0) collectQueryNames(queriesElement, queries);
|
|
100
|
+
const tables = collectTableNames(databaseElement);
|
|
101
|
+
const manifest = readManifest(pkg);
|
|
102
|
+
return {
|
|
103
|
+
connection,
|
|
104
|
+
tables,
|
|
105
|
+
queries,
|
|
106
|
+
forms: subdocumentNamesUnderPrefix(manifest.entries, "forms/"),
|
|
107
|
+
reports: subdocumentNamesUnderPrefix(manifest.entries, "reports/")
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { readOdbInventory };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_query = require("../../xml/query.cjs");
|
|
3
|
+
const require_typed_shared_metadata = require("../shared/metadata.cjs");
|
|
4
|
+
const require_typed_shared_masterpage = require("../shared/masterpage.cjs");
|
|
5
|
+
const require_typed_draw_shapes = require("../draw/shapes.cjs");
|
|
6
|
+
let document_schema_js = require("document-schema.js");
|
|
7
|
+
//#region src/typed/odg/read.ts
|
|
8
|
+
const CONTENT_PART = "content.xml";
|
|
9
|
+
function readPage(page, pkg) {
|
|
10
|
+
const size = require_typed_shared_masterpage.resolveDrawPageSize(page, pkg) ?? document_schema_js.PAGE_SIZE_A4;
|
|
11
|
+
const { shapes, vectors } = require_typed_draw_shapes.readDrawPageContent(page.children, pkg);
|
|
12
|
+
return {
|
|
13
|
+
size,
|
|
14
|
+
shapes,
|
|
15
|
+
vectors
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function readOdg(pkg) {
|
|
19
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
20
|
+
const root = contentPart?.kind === "xml" ? require_xml_query.rootElement(contentPart.nodes) : void 0;
|
|
21
|
+
const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
|
|
22
|
+
const drawing = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:drawing");
|
|
23
|
+
const pages = drawing === void 0 ? [] : require_xml_query.childrenWithTag(drawing, "draw:page");
|
|
24
|
+
return {
|
|
25
|
+
metadata: require_typed_shared_metadata.readOdfMetadata(pkg),
|
|
26
|
+
pages: pages.map((page) => readPage(page, pkg))
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.readOdg = readOdg;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Package } from "../../model/package.cjs";
|
|
2
|
+
import { ContentDrawPage, LayoutMetadata } from "document-schema.js";
|
|
3
|
+
//#region src/typed/odg/read.d.ts
|
|
4
|
+
interface OdgDocument {
|
|
5
|
+
metadata: LayoutMetadata;
|
|
6
|
+
pages: ContentDrawPage[];
|
|
7
|
+
}
|
|
8
|
+
declare function readOdg(pkg: Package): OdgDocument;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { OdgDocument, readOdg };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Package } from "../../model/package.js";
|
|
2
|
+
import { ContentDrawPage, LayoutMetadata } from "document-schema.js";
|
|
3
|
+
//#region src/typed/odg/read.d.ts
|
|
4
|
+
interface OdgDocument {
|
|
5
|
+
metadata: LayoutMetadata;
|
|
6
|
+
pages: ContentDrawPage[];
|
|
7
|
+
}
|
|
8
|
+
declare function readOdg(pkg: Package): OdgDocument;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { OdgDocument, readOdg };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { childrenWithTag, findChildElement, rootElement } from "../../xml/query.js";
|
|
2
|
+
import { readOdfMetadata } from "../shared/metadata.js";
|
|
3
|
+
import { resolveDrawPageSize } from "../shared/masterpage.js";
|
|
4
|
+
import { readDrawPageContent } from "../draw/shapes.js";
|
|
5
|
+
import { PAGE_SIZE_A4 } from "document-schema.js";
|
|
6
|
+
//#region src/typed/odg/read.ts
|
|
7
|
+
const CONTENT_PART = "content.xml";
|
|
8
|
+
function readPage(page, pkg) {
|
|
9
|
+
const size = resolveDrawPageSize(page, pkg) ?? PAGE_SIZE_A4;
|
|
10
|
+
const { shapes, vectors } = readDrawPageContent(page.children, pkg);
|
|
11
|
+
return {
|
|
12
|
+
size,
|
|
13
|
+
shapes,
|
|
14
|
+
vectors
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function readOdg(pkg) {
|
|
18
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
19
|
+
const root = contentPart?.kind === "xml" ? rootElement(contentPart.nodes) : void 0;
|
|
20
|
+
const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
|
|
21
|
+
const drawing = body === void 0 ? void 0 : findChildElement(body.children, "office:drawing");
|
|
22
|
+
const pages = drawing === void 0 ? [] : childrenWithTag(drawing, "draw:page");
|
|
23
|
+
return {
|
|
24
|
+
metadata: readOdfMetadata(pkg),
|
|
25
|
+
pages: pages.map((page) => readPage(page, pkg))
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { readOdg };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_query = require("../../xml/query.cjs");
|
|
3
|
+
//#region src/typed/odm/read.ts
|
|
4
|
+
const CONTENT_PART = "content.xml";
|
|
5
|
+
function readSection(element) {
|
|
6
|
+
const sourceElement = require_xml_query.findChildElement(element.children, "text:section-source");
|
|
7
|
+
if (sourceElement === void 0) return;
|
|
8
|
+
const name = require_xml_query.attrValue(element, "text:name");
|
|
9
|
+
const href = require_xml_query.attrValue(sourceElement, "xlink:href");
|
|
10
|
+
if (name === void 0 || href === void 0) return;
|
|
11
|
+
const filterName = require_xml_query.attrValue(sourceElement, "text:filter-name");
|
|
12
|
+
return filterName === void 0 ? {
|
|
13
|
+
name,
|
|
14
|
+
href
|
|
15
|
+
} : {
|
|
16
|
+
name,
|
|
17
|
+
href,
|
|
18
|
+
filterName
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function readOdm(pkg) {
|
|
22
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
23
|
+
if (contentPart?.kind !== "xml") throw new Error(`readOdm: package has no ${CONTENT_PART} part`);
|
|
24
|
+
const contentRoot = require_xml_query.rootElement(contentPart.nodes);
|
|
25
|
+
const body = contentRoot === void 0 ? void 0 : require_xml_query.findChildElement(contentRoot.children, "office:body");
|
|
26
|
+
const textElement = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:text");
|
|
27
|
+
if (textElement === void 0) throw new Error(`readOdm: ${CONTENT_PART} has no office:body/office:text element`);
|
|
28
|
+
const sections = [];
|
|
29
|
+
for (const node of textElement.children) {
|
|
30
|
+
if (node.type !== "element" || node.tag !== "text:section") continue;
|
|
31
|
+
const section = readSection(node);
|
|
32
|
+
if (section !== void 0) sections.push(section);
|
|
33
|
+
}
|
|
34
|
+
return { sections };
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.readOdm = readOdm;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { d as XmlNode } from "../../node-CkBWRjNR.cjs";
|
|
2
|
+
import { Package } from "../../model/package.cjs";
|
|
3
|
+
//#region src/typed/odm/read.d.ts
|
|
4
|
+
interface OdmSection {
|
|
5
|
+
name: string;
|
|
6
|
+
href: string;
|
|
7
|
+
filterName?: string;
|
|
8
|
+
inlineContent?: readonly XmlNode[];
|
|
9
|
+
}
|
|
10
|
+
interface OdmDocument {
|
|
11
|
+
sections: readonly OdmSection[];
|
|
12
|
+
}
|
|
13
|
+
declare function readOdm(pkg: Package): OdmDocument;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { OdmDocument, OdmSection, readOdm };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { d as XmlNode } from "../../node-CkBWRjNR.js";
|
|
2
|
+
import { Package } from "../../model/package.js";
|
|
3
|
+
//#region src/typed/odm/read.d.ts
|
|
4
|
+
interface OdmSection {
|
|
5
|
+
name: string;
|
|
6
|
+
href: string;
|
|
7
|
+
filterName?: string;
|
|
8
|
+
inlineContent?: readonly XmlNode[];
|
|
9
|
+
}
|
|
10
|
+
interface OdmDocument {
|
|
11
|
+
sections: readonly OdmSection[];
|
|
12
|
+
}
|
|
13
|
+
declare function readOdm(pkg: Package): OdmDocument;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { OdmDocument, OdmSection, readOdm };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { attrValue, findChildElement, rootElement } from "../../xml/query.js";
|
|
2
|
+
//#region src/typed/odm/read.ts
|
|
3
|
+
const CONTENT_PART = "content.xml";
|
|
4
|
+
function readSection(element) {
|
|
5
|
+
const sourceElement = findChildElement(element.children, "text:section-source");
|
|
6
|
+
if (sourceElement === void 0) return;
|
|
7
|
+
const name = attrValue(element, "text:name");
|
|
8
|
+
const href = attrValue(sourceElement, "xlink:href");
|
|
9
|
+
if (name === void 0 || href === void 0) return;
|
|
10
|
+
const filterName = attrValue(sourceElement, "text:filter-name");
|
|
11
|
+
return filterName === void 0 ? {
|
|
12
|
+
name,
|
|
13
|
+
href
|
|
14
|
+
} : {
|
|
15
|
+
name,
|
|
16
|
+
href,
|
|
17
|
+
filterName
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function readOdm(pkg) {
|
|
21
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
22
|
+
if (contentPart?.kind !== "xml") throw new Error(`readOdm: package has no ${CONTENT_PART} part`);
|
|
23
|
+
const contentRoot = rootElement(contentPart.nodes);
|
|
24
|
+
const body = contentRoot === void 0 ? void 0 : findChildElement(contentRoot.children, "office:body");
|
|
25
|
+
const textElement = body === void 0 ? void 0 : findChildElement(body.children, "office:text");
|
|
26
|
+
if (textElement === void 0) throw new Error(`readOdm: ${CONTENT_PART} has no office:body/office:text element`);
|
|
27
|
+
const sections = [];
|
|
28
|
+
for (const node of textElement.children) {
|
|
29
|
+
if (node.type !== "element" || node.tag !== "text:section") continue;
|
|
30
|
+
const section = readSection(node);
|
|
31
|
+
if (section !== void 0) sections.push(section);
|
|
32
|
+
}
|
|
33
|
+
return { sections };
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { readOdm };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_query = require("../../xml/query.cjs");
|
|
3
|
+
const require_typed_shared_text = require("../shared/text.cjs");
|
|
4
|
+
const require_typed_shared_metadata = require("../shared/metadata.cjs");
|
|
5
|
+
const require_typed_shared_masterpage = require("../shared/masterpage.cjs");
|
|
6
|
+
const require_typed_draw_shapes = require("../draw/shapes.cjs");
|
|
7
|
+
let document_schema_js = require("document-schema.js");
|
|
8
|
+
//#region src/typed/odp/read.ts
|
|
9
|
+
const CONTENT_PART = "content.xml";
|
|
10
|
+
function readSlideSize(page, pkg) {
|
|
11
|
+
return require_typed_shared_masterpage.resolveDrawPageSize(page, pkg) ?? document_schema_js.SLIDE_SIZE_WIDESCREEN;
|
|
12
|
+
}
|
|
13
|
+
function readSlideNotes(page) {
|
|
14
|
+
const notes = require_xml_query.childrenWithTag(page, "presentation:notes")[0];
|
|
15
|
+
if (notes === void 0) return "";
|
|
16
|
+
return require_xml_query.elementsWithTag(notes.children, "text:p").map(require_typed_shared_text.decodeOdfText).join("\n");
|
|
17
|
+
}
|
|
18
|
+
function readSlide(page, pkg) {
|
|
19
|
+
const shapes = [];
|
|
20
|
+
require_typed_draw_shapes.walkDrawShapes(page.children, [], pkg, shapes);
|
|
21
|
+
return {
|
|
22
|
+
size: readSlideSize(page, pkg),
|
|
23
|
+
shapes,
|
|
24
|
+
notes: readSlideNotes(page)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function readOdp(pkg) {
|
|
28
|
+
const contentPart = pkg.parts[CONTENT_PART];
|
|
29
|
+
const root = contentPart?.kind === "xml" ? require_xml_query.rootElement(contentPart.nodes) : void 0;
|
|
30
|
+
const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
|
|
31
|
+
const presentation = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:presentation");
|
|
32
|
+
const pages = presentation === void 0 ? [] : require_xml_query.childrenWithTag(presentation, "draw:page");
|
|
33
|
+
return {
|
|
34
|
+
metadata: require_typed_shared_metadata.readOdfMetadata(pkg),
|
|
35
|
+
slides: pages.map((page) => readSlide(page, pkg))
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.readOdp = readOdp;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Package } from "../../model/package.cjs";
|
|
2
|
+
import { ContentSlide, LayoutMetadata } from "document-schema.js";
|
|
3
|
+
//#region src/typed/odp/read.d.ts
|
|
4
|
+
interface OdpDocument {
|
|
5
|
+
metadata: LayoutMetadata;
|
|
6
|
+
slides: ContentSlide[];
|
|
7
|
+
}
|
|
8
|
+
declare function readOdp(pkg: Package): OdpDocument;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { OdpDocument, readOdp };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Package } from "../../model/package.js";
|
|
2
|
+
import { ContentSlide, LayoutMetadata } from "document-schema.js";
|
|
3
|
+
//#region src/typed/odp/read.d.ts
|
|
4
|
+
interface OdpDocument {
|
|
5
|
+
metadata: LayoutMetadata;
|
|
6
|
+
slides: ContentSlide[];
|
|
7
|
+
}
|
|
8
|
+
declare function readOdp(pkg: Package): OdpDocument;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { OdpDocument, readOdp };
|