odf.js 2.0.0 → 2.2.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 CHANGED
@@ -51,7 +51,7 @@ This package is under active development. What's built and shipped:
51
51
  - **Namespaces, media types, mimetype, manifest** (`src/ns.ts`, `src/media-type.ts`, `src/mimetype.ts`, `src/manifest.ts`) — full read *and* write, including `META-INF/manifest.xml`'s exhaustive per-part enumeration and the mimetype part's mandatory first-entry/stored/uncompressed byte layout, verified against real LibreOffice-produced output.
52
52
  - **Style interning** (`src/styles/`) — `StyleRegistry`: adopts a part's existing automatic styles on construction, finds-or-mints on `intern()`, fingerprints on canonical serialized properties plus parent style name (never `JSON.stringify`), and is collision-checked across all four style containers a document can have.
53
53
  - **Shared typed primitives** (`src/typed/shared/`) — ODF length-unit parsing (`cm`/`mm`/`in`/`pt`/`pc`/`px`), A1-style spreadsheet cell-reference computation with repeat-count cursor advancement, colour/geometry/master-page-size parsing into `document-schema.js`'s own types, ODF's `text:s`/`text:tab`/`text:line-break` whitespace-run decoding, the read-side style cascade (`style:default-style` → parent chain → the referenced style — one layer shorter than OOXML's, since ODF has no separate direct-formatting layer on top), the shared `text:p` → `ContentParagraph`/`ContentRun` and `table:table` → `ContentTable` readers (`readOdfParagraph`/`readOdfTable`) every typed reader below builds on, the `draw:transform`/`draw:g` group-flattening geometry resolver, an `svg:d`/`draw:points` vector-path grammar parser, and `meta.xml` reading.
54
- - **Typed readers** — `readOdt` (wordprocessing), `readOdp` (presentation slides: `draw:frame`/`draw:g` text/image/table content), `readOdg` (drawing pages: every vector primitive — `draw:rect`/`draw:ellipse`/`draw:circle`/`draw:line`/`draw:path`/`draw:polygon`/`draw:polyline`, plus a recognised `draw:custom-shape` preset subset — in real `draw:z-index`-aware paint order), and `readOds` (spreadsheets: geometry- and print-settings-rich, every `office:value-type` variant with its own OpenFormula string) each resolve a `Package` into `document-schema.js`'s own `ContentSection`/`ContentSlide`/`ContentDrawPage`/`ContentSheet` shapes.
54
+ - **Typed readers** — `readOdt` (wordprocessing), `readOdp` (presentation slides: `draw:frame`/`draw:g` text/image/table content), `readOdg` (drawing pages: every vector primitive — `draw:rect`/`draw:ellipse`/`draw:circle`/`draw:line`/`draw:path`/`draw:polygon`/`draw:polyline`, plus a recognised `draw:custom-shape` preset subset — in real `draw:z-index`-aware paint order), and `readOds` (spreadsheets: geometry- and print-settings-rich, every `office:value-type` variant with its own OpenFormula string, plus cell- and page-anchored `draw:frame` images and embedded ODF sub-documents) each resolve a `Package` into `document-schema.js`'s own `ContentSection`/`ContentSlide`/`ContentDrawPage`/`ContentSheet` shapes.
55
55
  - **`readOdfFormula`** resolves a standalone or embedded `.odf` formula's `content.xml` — bare MathML with no `office:document-content` wrapper, confirmed against real LibreOffice output — into its raw MathML nodes plus, when present, the formula's own native StarMath annotation string, in this reader's own bespoke `OdfFormulaDocument` shape. **`readOdfFormulaDocument`** wraps that same result into a real `document-schema.js` `ContentDocument` of kind `'formula'` — `document-schema.js` 2.0.0 added a `MathMlNode`/`ContentFormula` pivot shape for exactly this, a structural mirror of this package's own `XmlNode` that `readOdfFormula`'s real output assigns to with zero cast.
56
56
  - **`readOdm`** resolves a `.odm` master document's own `content.xml` into an ordered list of chapter references (`{ name, href, filterName? }`, one per top-level linked `text:section`) without opening the external `.odt` files those references point at. A master document's chapters are genuinely external files by ODF design, not embedded package sub-documents — confirmed against real LibreOffice output, which never caches a chapter's own content inside the master document itself (see `src/typed/odm/read.ts`'s own top-of-file note).
57
57
  - **`readOdbInventory`** resolves a `.odb` database front-end package into connection info, its table *names*, its query *definitions* (name, real `db:command` SQL text, and `db:escape-processing` when declared), and its forms/reports as `{ name, href }` pairs. Confirmed against real LibreOffice output that `office:database` lives directly in the package's ordinary `content.xml` (no separate `database/connection.xml` part, contrary to the OASIS schema's own chapter layout suggesting one), that queries are declared inline (`db:queries/db:query`, no manifest part of their own), and that a live engine's own tables have no ODF-level manifest listing at all. A form's/report's sub-document directory is named after an opaque *persistent* name (`forms/Obj11`), **not** after the form/report — the user-visible name lives only in `content.xml`'s own `db:forms`/`db:reports` registry, which is where this reader takes both the name and the href from. See `src/typed/odb/read.ts`'s own top-of-file note for the full findings.
@@ -126,7 +126,7 @@ Layered from a lossless core outward, mirroring `ooxml.js`'s own structure:
126
126
  - **`src/manifest.ts`** — unlike `ooxml.js` (which only ever *reads* OPC relationships, leaving writing to `documents.js`), `odf.js` owns manifest read **and** write, since the manifest is ODF's one mandatory part and its correctness is exhaustive.
127
127
  - **`src/styles/`** — `properties.ts` (the property-bag shape + real ODF attribute parsing), `serialize.ts` (canonical, deterministic property-bag → XML attributes), `registry.ts` (`StyleRegistry`, ODF's mandatory style-interning layer, no OOXML equivalent), `span.ts` (character-range wrapping into a formattable `text:span`, correctly splitting `text:s`/`text:tab` elements that straddle a boundary).
128
128
  - **`src/typed/shared/`** — the ODF-specific typed primitives every future format reader builds on: `units.ts`, `a1.ts`, `color.ts`/`geometry.ts` (parsing into `document-schema.js`'s own types, never redefining them), `style.ts` (a thin re-export — ODF's style-properties concern is fully covered by `styles/properties.ts` and the cascade below), `text.ts` (whitespace-run decoding), `cascade.ts` (the read-side style-resolution walk), `paragraph.ts`/`table.ts` (`readOdfParagraph`/`readOdfTable`, the shared `text:p` → `ContentParagraph`/`ContentRun` and `table:table` → `ContentTable` readers `readOdt`, `readOds`, and `typed/draw/shapes.ts` all call), `transform.ts` (the `draw:transform`/`draw:g` group-flattening geometry resolver), `masterpage.ts` (master-page → page-layout page-size/print-settings resolution, shared by a `draw:page`'s own size and a spreadsheet's print settings), `path.ts` (an `svg:d`/`draw:points` vector-path grammar parser), `metadata.ts` (`meta.xml` reading).
129
- - **`src/typed/odt/`, `src/typed/odp/`, `src/typed/odg/`, `src/typed/ods/`** — the built `readOdt`/`readOdp`/`readOdg`/`readOds` readers; **`src/typed/draw/`** — the `draw:frame`/`draw:g`/vector-primitive shape vocabulary `readOdp` and `readOdg` both share; **`src/typed/formula/`, `src/typed/odm/`** — `readOdfFormula`/`readOdfFormulaDocument` (raw MathML, and the `document-schema.js` `ContentDocument` 'formula'-kind pivot built on top of it) and `readOdm` (a `.odm` master document's own external chapter references — name/href/filter-name per linked `text:section`, never the linked content itself); **`src/typed/odb/`** — `readOdbInventory` (a `.odb` package's own connection info, table/query/form/report registry, never the database engine's own storage), plus `readOdbForm`/`readOdbReport` (static, execution-free structure extraction from a form's or report's own ODF sub-document) and `subDocumentPackage` (the synthetic sub-`Package` view they read those sub-documents through).
129
+ - **`src/typed/odt/`, `src/typed/odp/`, `src/typed/odg/`, `src/typed/ods/`** — the built `readOdt`/`readOdp`/`readOdg`/`readOds` readers; **`src/typed/draw/`** — the `draw:frame`/`draw:g`/vector-primitive shape vocabulary `readOdp` and `readOdg` both share (`shapes.ts`), plus `embedded.ts`'s `readDrawObjectReference`, the `draw:object` embedded-sub-document counterpart `readOds` resolves a sheet's anchored OLE objects through; **`src/typed/formula/`, `src/typed/odm/`** — `readOdfFormula`/`readOdfFormulaDocument` (raw MathML, and the `document-schema.js` `ContentDocument` 'formula'-kind pivot built on top of it) and `readOdm` (a `.odm` master document's own external chapter references — name/href/filter-name per linked `text:section`, never the linked content itself); **`src/typed/odb/`** — `readOdbInventory` (a `.odb` package's own connection info, table/query/form/report registry, never the database engine's own storage), plus `readOdbForm`/`readOdbReport` (static, execution-free structure extraction from a form's or report's own ODF sub-document) and `subDocumentPackage` (the synthetic sub-`Package` view they read those sub-documents through).
130
130
 
131
131
  ## Why no `ooxml.js` dependency
132
132
 
@@ -149,8 +149,12 @@ See the top of this README — the short version: `ooxml.js`'s branding and sign
149
149
  - **ODF cells carry no explicit cell-reference attribute at all** (unlike xlsx's `r="B7"`) — `typed/shared/a1.ts` computes A1-style references from a running column/row cursor as a reader walks cells in document order.
150
150
  - **A rotated `draw:rect`/`draw:ellipse`/`draw:path`/`draw:custom-shape` vector primitive now reads its own `rotationDeg`, not just its unrotated bounding frame.** `resolveVectorGeometry` (`typed/draw/shapes.ts`) replaces the old frame-only `resolveVectorFrame`, reusing the exact same `resolveOdfShapeGeometry`/`composeOdfGroupTransform` machinery `draw:frame` already resolved rotation through, including composing an enclosing `draw:g`'s own rotation the same way it already did for a frame. `ContentVectorSchema`'s rect/ellipse/path variants already carried a `rotationDeg` field before this change — it was being discarded on the read side, not missing from the schema.
151
151
  - **Every `ContentShape`/`ContentVector` a drawing or presentation reader produces is now stamped with its own resolved `paintOrder`, not merely sorted by it and discarded.** `walkDrawPageContent` (odg) and `walkDrawShapes` (odp) both compute a real z-index per element — an explicit `draw:z-index` when present, otherwise a monotonic document-encounter counter — purely to order their own output arrays; that value is now attached to each produced value via the same single counter threaded across the whole walk. Because `shapes` and `vectors` are stamped from the identical counter, a caller can recover their true relative paint order across the two independently-ordered arrays by comparing `paintOrder` directly — closing the cross-array ordering gap `documents.js`'s own README previously described as unrecoverable, even though `ContentDrawPageSchema` itself still keeps the two arrays with no shared ordering field of its own.
152
- - **`svg:fill-rule` (`nonzero`/`evenodd`) and `draw:stroke`'s `solid`/`dash` enumeration are now read and mapped onto `ContentVector`'s path-variant `fillRule` and `ContentStroke.style`.** Both mappings are confirmed against the OASIS schema reference rather than only against real-world producer output — `typed/draw/shapes.ts`'s own comment notes that a live-LibreOffice re-verification of `svg:fill-rule` specifically was blocked by the same headless-`soffice`-hang constraint `documents.js`'s own README documents. A genuinely dotted (as opposed to dashed) stroke pattern, and a `"double"` stroke style ODF's own vector-stroke model has no concept of at all, both remain unread — real, permanent boundaries rather than oversights (see that file's own comment for why each).
152
+ - **`svg:fill-rule` (`nonzero`/`evenodd`) and `draw:stroke`'s `solid`/`dash` enumeration are now read and mapped onto `ContentVector`'s path-variant `fillRule` and `ContentStroke.style`.** Both mappings are confirmed against the OASIS schema reference rather than only against real-world producer output — `typed/draw/shapes.ts`'s own comment notes that a live-LibreOffice re-verification of `svg:fill-rule` specifically was blocked by the same headless-`soffice`-hang constraint `documents.js`'s own README documents. A genuinely dotted (as opposed to dashed) stroke pattern, and a `"double"` stroke style ODF's own vector-stroke model has no concept of at all, both remain unread — real, permanent boundaries rather than oversights (see that file's own comment for why each). The original test coverage for `svg:fill-rule` only ever exercised a single-loop `svg:d`, which cannot actually distinguish the two rules — there is nothing for `evenodd`'s alternating parity to differ from `nonzero`'s winding count with only one contour. `shapes.test.ts` now also covers a genuine two-subpath "letter O" donut shape (an outer square and an inner square hole, both wound in the same rotational direction), the real-world case the attribute exists for: `nonzero` would fill the hole solid (winding number 2, still non-zero) while `evenodd` correctly punches it (parity toggles to 0 inside), and the test confirms both subpaths, their `closed` flags, and the inner subpath's scaled points are read correctly alongside `fillRule` itself.
153
153
  - **`readOds` and the shared `readTableCell` (odt/odp table cells) now resolve `fo:background-color`, the `fo:border`/`fo:border-(left|right|top|bottom)` shorthand-and-per-edge-override chain, `style:vertical-align`, and a cell style's own `style:paragraph-properties` `fo:text-align` from the real ODF style cascade**, populating `ContentSheetCell`/`ContentTableCell`'s `background`/`borders` (plus `ContentSheetCell`'s own `alignment`/`verticalAlignment`) rather than leaving them unpopulated. `readCellStyleDecoration` (`typed/shared/table.ts`) is the one fold both callers share: `readOds` resolves it over the full root-to-target `style:parent-style-name` chain (`resolveStyleElementChain`, confirmed against this package's own `kitchen-sink.ods` fixture's real `ce1`..`ce5` → `Default` chain), `readTableCell` over the single style element `findStyleElement` already resolves. An explicit `fo:border-*` override of `"none"`/`"hidden"` genuinely clears an inherited edge rather than merely leaving it unmentioned.
154
+ - **`readOds` now reads drawings anchored to a sheet, populating `ContentSheet.images` (previously hardcoded `[]`) and `ContentSheet.embeddedObjects` (previously never set), through the same `typed/draw/shapes.ts` primitives `readOdp`/`readOdg` already use.** ODF has exactly two spreadsheet anchoring conventions, both confirmed against real LibreOffice 26.2 output (`src/typed/ods/fixtures/sheet-anchors.ods`, built via a Java UNO client and never hand-edited): a **cell-anchored** `draw:frame` is a *direct child of the `table:table-cell` it is anchored to*, with `svg:x`/`svg:y` measured from **that cell's own top-left corner**; a **page-anchored** one sits in a `table:shapes` element (a child of `table:table` preceding its column definitions) with absolute sheet coordinates. The anchor cell reference is not read from any attribute at all — ODF cells have none (see the cursor gotchas above) — it is the same running `TableCursor` position `ContentSheetCell.row`/`column` already come from; a page-anchored image is reported against cell `(0, 0)`, whose own top-left *is* the sheet origin, so its absolute offsets carry through exactly rather than being approximated. A `draw:g` group is walked through, composing its own `draw:transform` via `readDrawFrame`'s existing `groupFunctions` parameter. What a sheet cannot carry is anything `ContentSheetSchema` has nowhere to put — a floating text box or table frame (no `shapes` array), a bare vector primitive (no `vectors` array), and an embedded **chart** object (`ContentEmbeddedObjectKind` has no `chart` member to map one onto) — each skipped rather than mapped onto an approximation of a different kind. An embedded **formula** object is no longer among them; see the bullet below.
155
+ - **`readDrawObjectReference` (`typed/draw/embedded.ts`) is the new shared `draw:object` counterpart to `shapes.ts`'s existing `draw:image` handling**, resolving a frame's embedded-object reference into the sub-`Package` it names (via `subDocumentPackage`) plus the `ContentEmbeddedObjectKind` that sub-document actually is, read from its own `content.xml` (the `office:body` content child, or — for a formula — a bare MathML root) rather than from the manifest's declared media type — one signal, so the reported kind and the reader that produced the content agree by construction. It deliberately stops short of calling `readOdt`/`readOds`/`readOdp`/`readOdg` itself: doing so would import `readOds`, which imports this module. A real embedded-object frame also carries a `draw:image` preview of its own object (an `ObjectReplacements/` GDI metafile), so `draw:object` must be checked *before* a frame's image content — the same ordering, for the same reason, that `readDrawFrameContent` already applies to a table frame's preview image.
156
+ - **An embedded LibreOffice Math object anchored to a spreadsheet cell now reads as a real `ContentEmbeddedObject` of `objectKind: 'formula'`, carrying a genuine `ContentDocument` formula payload rather than being skipped.** A formula sub-document is the one embedded kind with no `office:body` at all — its `content.xml` root *is* the MathML root — so `readDrawObjectReference` falls back to `typed/formula/read.ts`'s own `findMathRoot` (reused, not restated) whenever the `office:body` path resolves nothing, and `readOds` dispatches the resulting reference to `readOdfFormulaDocument`, the same function the standalone `.odf` path already uses. `document-schema.js` 2.2.0 is what makes this representable at all: its `ContentDocument` union carries a real `'formula'` variant, and its `ContentEmbeddedObject` gained the same `anchorRow`/`anchorColumn`/`offsetXPt`/`offsetYPt` quartet `ContentSheetImage` already had — so an embedded object's anchor cell is now recorded exactly as an anchored image's is, for *every* embedded kind, not just formulas. Confirmed against real, unmodified LibreOffice 26.2 output (`src/typed/ods/fixtures/sheet-formula.ods`, a Calc sheet built via a Java UNO client with a `com.sun.star.drawing.OLE2Shape` carrying Math's own CLSID and a real StarMath `Formula` property, anchored to cell C4, never hand-edited): the outer manifest declares `Object 1/` as `application/vnd.oasis.opendocument.formula`, that sub-document ships **no `meta.xml` of its own**, and its `content.xml` is the same bare `<math>` root with a default MathML `xmlns` `typed/formula/read.ts` already documents for a standalone `.odf`.
157
+ - **A `draw:frame`'s alternative text (`svg:title`, falling back to `svg:desc`) is now read into `ContentImageBlock.altText` for every format**, not just spreadsheets. Both are plain-text *child elements* of `draw:frame` itself, not attributes — confirmed against real LibreOffice output, where a Calc image's UNO `Title`/`Description` properties round-trip as `<svg:title>`/`<svg:desc>` siblings of the frame's own `draw:image`.
154
158
  - **`readOdfFormulaDocument` now wraps a formula's raw MathML into a real `document-schema.js` `ContentDocument` of kind `'formula'`**, alongside (not instead of) this package's own pre-existing bespoke `OdfFormulaDocument` shape from `readOdfFormula`, which is unchanged. `document-schema.js` 2.0.0 added the `MathMlNode`/`ContentFormula` pivot specifically for this — a structural mirror of this package's own `XmlNode` that `readOdfFormula`'s existing return value assigns into with zero cast.
155
159
  - **`readOdbInventory`'s `queries` now carry each query's real `db:command` SQL text (plus `db:escape-processing` when declared) instead of only a bare name.** `OdbInventory.queries` is now `OdbQueryInfo[]` (`{ name, command, escapeProcessing? }`), a breaking rename from the previous `string[]` — a query's own `db:command` is already inline in `content.xml`, unlike a form/report/table's real content, which lives in a separate sub-document or database engine this reader never opens, so the "content lives elsewhere, only names are read" rule that correctly applies to those does not hold for a query. `db:command` is entity-decoded before being returned, matching every other typed reader's convention.
156
160
  - **`.odb` Form/Report structure extraction is real and working, grounded in a genuine LibreOffice-generated fixture, not blocked.** `readOdbForm`/`readOdbReport` open a form's or report's own sub-document (via `subDocumentPackage`, a synthetic sub-`Package` view over its directory) and extract its complete static structure — command bindings, control trees, nested sub-forms, the band/group hierarchy, bound and computed expressions — executing nothing. See the Architecture section above and `src/typed/odb/form.ts`/`report.ts`'s own top-of-file notes for the two real shapes this fixture caught that an assumed reading would have got wrong. **A SQL/`rpt:` rendering engine to actually execute a query or evaluate a report's own totals against real data is deliberately not attempted**, not merely unstarted — that is a materially different, larger undertaking (reimplementing a slice of HSQLDB's/Firebird's own query semantics) with its own unreviewed licensing question, gated on the requesting engineer's explicit sign-off after reading the relevant engine source. See the bounded-SQL-subset assessment immediately below for exactly how far the *reading* side alone gets you.
package/dist/index.cjs CHANGED
@@ -34,14 +34,15 @@ const require_typed_shared_transform = require("./typed/shared/transform.cjs");
34
34
  const require_typed_shared_masterpage = require("./typed/shared/masterpage.cjs");
35
35
  const require_typed_shared_path = require("./typed/shared/path.cjs");
36
36
  const require_typed_draw_shapes = require("./typed/draw/shapes.cjs");
37
+ const require_typed_formula_read = require("./typed/formula/read.cjs");
38
+ const require_typed_odb_subdocument = require("./typed/odb/subdocument.cjs");
39
+ const require_typed_draw_embedded = require("./typed/draw/embedded.cjs");
37
40
  const require_typed_odp_read = require("./typed/odp/read.cjs");
38
41
  const require_typed_odt_read = require("./typed/odt/read.cjs");
39
42
  const require_typed_odg_read = require("./typed/odg/read.cjs");
40
43
  const require_typed_ods_read = require("./typed/ods/read.cjs");
41
- const require_typed_formula_read = require("./typed/formula/read.cjs");
42
44
  const require_typed_odm_read = require("./typed/odm/read.cjs");
43
45
  const require_typed_odb_read = require("./typed/odb/read.cjs");
44
- const require_typed_odb_subdocument = require("./typed/odb/subdocument.cjs");
45
46
  const require_typed_odb_form = require("./typed/odb/form.cjs");
46
47
  const require_typed_odb_report = require("./typed/odb/report.cjs");
47
48
  let document_schema_js = require("document-schema.js");
@@ -130,6 +131,7 @@ exports.parseTextProperties = require_styles_properties.parseTextProperties;
130
131
  exports.parseXml = require_xml_parse.parseXml;
131
132
  exports.rawSubpathFromPoints = require_typed_shared_path.rawSubpathFromPoints;
132
133
  exports.readDrawFrame = require_typed_draw_shapes.readDrawFrame;
134
+ exports.readDrawObjectReference = require_typed_draw_embedded.readDrawObjectReference;
133
135
  exports.readDrawPageContent = require_typed_draw_shapes.readDrawPageContent;
134
136
  exports.readManifest = require_manifest.readManifest;
135
137
  exports.readMimetype = require_mimetype.readMimetype;
package/dist/index.d.cts CHANGED
@@ -33,6 +33,7 @@ import { OdfPoint, OdfShapeGeometry, OdfTransformFunction, applyOdfTransform, co
33
33
  import { resolveDrawPageSize, resolvePageLayoutProperties } from "./typed/shared/masterpage.cjs";
34
34
  import { OdfRawPoint, OdfRawSegment, OdfRawSubpath, OdfViewBox, buildOdfSubpaths, parseOdfPathData, parseOdfPointsList, parseOdfViewBox, rawSubpathFromPoints, scaleOdfRawPoint } from "./typed/shared/path.cjs";
35
35
  import { DrawPageContent, readDrawFrame, readDrawPageContent, walkDrawShapes } from "./typed/draw/shapes.cjs";
36
+ import { EmbeddedDocumentKind, EmbeddedDrawObject, readDrawObjectReference } from "./typed/draw/embedded.cjs";
36
37
  import { OdpDocument, readOdp } from "./typed/odp/read.cjs";
37
38
  import { OdtDocument, readOdt } from "./typed/odt/read.cjs";
38
39
  import { OdgDocument, readOdg } from "./typed/odg/read.cjs";
@@ -43,4 +44,4 @@ import { OdbComponentInfo, OdbConnectionInfo, OdbInventory, OdbQueryInfo, readOd
43
44
  import { SubDocumentPackageOptions, subDocumentPackage } from "./typed/odb/subdocument.cjs";
44
45
  import { OdbForm, OdbFormControl, OdbFormDefinition, readOdbForm } from "./typed/odb/form.cjs";
45
46
  import { OdbReport, OdbReportBand, OdbReportElement, OdbReportFunction, OdbReportGroup, readOdbReport } from "./typed/odb/report.cjs";
46
- export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, type OdbComponentInfo, type OdbConnectionInfo, type OdbForm, type OdbFormControl, type OdbFormDefinition, type OdbInventory, type OdbQueryInfo, type OdbReport, type OdbReportBand, type OdbReportElement, type OdbReportFunction, type OdbReportGroup, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type SubDocumentPackageOptions, TableCursor, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
47
+ export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, type EmbeddedDocumentKind, type EmbeddedDrawObject, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, type OdbComponentInfo, type OdbConnectionInfo, type OdbForm, type OdbFormControl, type OdbFormDefinition, type OdbInventory, type OdbQueryInfo, type OdbReport, type OdbReportBand, type OdbReportElement, type OdbReportFunction, type OdbReportGroup, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type SubDocumentPackageOptions, TableCursor, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawObjectReference, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
package/dist/index.d.ts CHANGED
@@ -33,6 +33,7 @@ import { OdfPoint, OdfShapeGeometry, OdfTransformFunction, applyOdfTransform, co
33
33
  import { resolveDrawPageSize, resolvePageLayoutProperties } from "./typed/shared/masterpage.js";
34
34
  import { OdfRawPoint, OdfRawSegment, OdfRawSubpath, OdfViewBox, buildOdfSubpaths, parseOdfPathData, parseOdfPointsList, parseOdfViewBox, rawSubpathFromPoints, scaleOdfRawPoint } from "./typed/shared/path.js";
35
35
  import { DrawPageContent, readDrawFrame, readDrawPageContent, walkDrawShapes } from "./typed/draw/shapes.js";
36
+ import { EmbeddedDocumentKind, EmbeddedDrawObject, readDrawObjectReference } from "./typed/draw/embedded.js";
36
37
  import { OdpDocument, readOdp } from "./typed/odp/read.js";
37
38
  import { OdtDocument, readOdt } from "./typed/odt/read.js";
38
39
  import { OdgDocument, readOdg } from "./typed/odg/read.js";
@@ -43,4 +44,4 @@ import { OdbComponentInfo, OdbConnectionInfo, OdbInventory, OdbQueryInfo, readOd
43
44
  import { SubDocumentPackageOptions, subDocumentPackage } from "./typed/odb/subdocument.js";
44
45
  import { OdbForm, OdbFormControl, OdbFormDefinition, readOdbForm } from "./typed/odb/form.js";
45
46
  import { OdbReport, OdbReportBand, OdbReportElement, OdbReportFunction, OdbReportGroup, readOdbReport } from "./typed/odb/report.js";
46
- export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, type OdbComponentInfo, type OdbConnectionInfo, type OdbForm, type OdbFormControl, type OdbFormDefinition, type OdbInventory, type OdbQueryInfo, type OdbReport, type OdbReportBand, type OdbReportElement, type OdbReportFunction, type OdbReportGroup, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type SubDocumentPackageOptions, TableCursor, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
47
+ export { type Alignment, AlignmentSchema, type Attribute, AttributeSchema, type BinaryPart, BinaryPartSchema, type BuildManifestOptions, type CascadeDiagnostic, type DrawPageContent, type EmbeddedDocumentKind, type EmbeddedDrawObject, type ImageFormat, type InternRequest, type LengthUnit, MANIFEST_PART, META_PART, MIMETYPE_PART, type Manifest, type ManifestEntry, ManifestEntrySchema, type ManifestProblem, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, type OdbComponentInfo, type OdbConnectionInfo, type OdbForm, type OdbFormControl, type OdbFormDefinition, type OdbInventory, type OdbQueryInfo, type OdbReport, type OdbReportBand, type OdbReportElement, type OdbReportFunction, type OdbReportGroup, type OdfExtension, type OdfFormulaDocument, type OdfNamespacePrefix, type OdfPoint, type OdfRawPoint, type OdfRawSegment, type OdfRawSubpath, type OdfShapeGeometry, type OdfTransformFunction, type OdfViewBox, type OdgDocument, type OdmDocument, type OdmSection, type OdpDocument, type OdsDocument, type OdtDocument, type OtherPartRef, type Package, PackageSchema, type ParsedProperties, type Part, PartSchema, STYLE_FAMILIES, type StyleCascadeResult, type StyleElementChainResult, type StyleFamily, type StyleProperties, StylePropertiesSchema, StyleRegistry, type StyleRegistryOptions, type SubDocumentPackageOptions, TableCursor, type XmlCdata, XmlCdataSchema, type XmlComment, XmlCommentSchema, type XmlDeclaration, XmlDeclarationSchema, type XmlElement, XmlElementSchema, type XmlNode, XmlNodeSchema, type XmlPart, XmlPartSchema, type XmlPi, XmlPiSchema, type XmlText, XmlTextSchema, type ZipEntry, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawObjectReference, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
package/dist/index.js CHANGED
@@ -33,14 +33,15 @@ import { applyOdfTransform, composeOdfGroupTransform, netRotationDeg, parseOdfTr
33
33
  import { resolveDrawPageSize, resolvePageLayoutProperties } from "./typed/shared/masterpage.js";
34
34
  import { buildOdfSubpaths, parseOdfPathData, parseOdfPointsList, parseOdfViewBox, rawSubpathFromPoints, scaleOdfRawPoint } from "./typed/shared/path.js";
35
35
  import { readDrawFrame, readDrawPageContent, walkDrawShapes } from "./typed/draw/shapes.js";
36
+ import { readOdfFormula, readOdfFormulaDocument } from "./typed/formula/read.js";
37
+ import { subDocumentPackage } from "./typed/odb/subdocument.js";
38
+ import { readDrawObjectReference } from "./typed/draw/embedded.js";
36
39
  import { readOdp } from "./typed/odp/read.js";
37
40
  import { readOdt } from "./typed/odt/read.js";
38
41
  import { readOdg } from "./typed/odg/read.js";
39
42
  import { readOds } from "./typed/ods/read.js";
40
- import { readOdfFormula, readOdfFormulaDocument } from "./typed/formula/read.js";
41
43
  import { readOdm } from "./typed/odm/read.js";
42
44
  import { readOdbInventory, resolveOdbComponent } from "./typed/odb/read.js";
43
- import { subDocumentPackage } from "./typed/odb/subdocument.js";
44
45
  import { readOdbForm } from "./typed/odb/form.js";
45
46
  import { readOdbReport } from "./typed/odb/report.js";
46
- export { AlignmentSchema, AttributeSchema, BinaryPartSchema, MANIFEST_PART, META_PART, MIMETYPE_PART, ManifestEntrySchema, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, PackageSchema, PartSchema, STYLE_FAMILIES, StylePropertiesSchema, StyleRegistry, TableCursor, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
47
+ export { AlignmentSchema, AttributeSchema, BinaryPartSchema, MANIFEST_PART, META_PART, MIMETYPE_PART, ManifestEntrySchema, ManifestProblemSchema, ManifestSchema, ODF_MEDIA_TYPES, ODF_NAMESPACES, PackageSchema, PartSchema, STYLE_FAMILIES, StylePropertiesSchema, StyleRegistry, TableCursor, XmlCdataSchema, XmlCommentSchema, XmlDeclarationSchema, XmlElementSchema, XmlNodeSchema, XmlPartSchema, XmlPiSchema, XmlTextSchema, applyOdfTransform, attrValue, base64ToBytes, buildManifest, buildOdfSubpaths, buildStylePropertyElements, buildXml, bytesToBase64, canonicalPropertiesString, cellReference, childrenWithTag, columnIndexToLetters, columnLettersToIndex, composeOdfGroupTransform, decodeOdfText, decodePackage, decodeXmlText, el, elementsWithTag, encodePackage, encodeXmlText, ensureSpan, findChildElement, findStyleElement, formatOdfColor, formatOdfLength, formatPercentageMultiplier, formatPt, getOdfSpaceCount, isStyleFamily, isXmlNode, measureOdfNodeLength, mediaTypeForExtension, netRotationDeg, packageCodec, paragraphPropertiesToAttributes, parseBox, parseCellReference, parseOdfLength as parseLength, parseOdfLength, parseLinePoints, parseMargins, parseOdfColor, parseOdfPathData, parseOdfPointsList, parseOdfTransform, parseOdfViewBox, parsePackage, parsePageSize, parseParagraphProperties, parseStyleElementProperties, parseTextProperties, parseXml, rawSubpathFromPoints, readDrawFrame, readDrawObjectReference, readDrawPageContent, readManifest, readMimetype, readOdbForm, readOdbInventory, readOdbReport, readOdfFormula, readOdfFormulaDocument, readOdfMetadata, readOdfParagraph, readOdfTable, readOdg, readOdm, readOdp, readOds, readOdt, resolveDrawPageSize, resolveOdbComponent, resolveOdfShapeGeometry, resolvePageLayoutProperties, resolveStyle, resolveStyleElementChain, rootElement, scaleOdfRawPoint, serializePackage, setDocumentMediaType, sniffImageFormat, subDocumentPackage, sumOdfNodeLength, syncManifest, textPropertiesToAttributes, txt, unzipPackage, validateManifest, walkDrawShapes, writeManifest, writeMimetype, xmlCodec, xmlnsAttributes, zipPackage };
@@ -0,0 +1,48 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_query = require("../../xml/query.cjs");
3
+ const require_typed_formula_read = require("../formula/read.cjs");
4
+ const require_typed_odb_subdocument = require("../odb/subdocument.cjs");
5
+ //#region src/typed/draw/embedded.ts
6
+ const CONTENT_PART = "content.xml";
7
+ function embeddedKindFor(bodyChildTag) {
8
+ switch (bodyChildTag) {
9
+ case "office:text": return "wordprocessing";
10
+ case "office:spreadsheet": return "spreadsheet";
11
+ case "office:presentation": return "presentation";
12
+ case "office:drawing": return "drawing";
13
+ default: return;
14
+ }
15
+ }
16
+ function subDocumentKind(nodes) {
17
+ const root = require_xml_query.rootElement(nodes);
18
+ const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
19
+ const bodyChild = body === void 0 ? void 0 : require_xml_query.rootElement(body.children);
20
+ const bodyKind = bodyChild === void 0 ? void 0 : embeddedKindFor(bodyChild.tag);
21
+ if (bodyKind !== void 0) return bodyKind;
22
+ return require_typed_formula_read.findMathRoot(nodes) === void 0 ? void 0 : "formula";
23
+ }
24
+ function normaliseObjectHref(raw) {
25
+ const withoutPrefix = raw.startsWith("./") ? raw.slice(2) : raw;
26
+ const trimmed = withoutPrefix.endsWith("/") ? withoutPrefix.slice(0, -1) : withoutPrefix;
27
+ if (trimmed.length === 0 || trimmed.startsWith("..") || trimmed.startsWith("/") || trimmed.includes("://")) return;
28
+ return trimmed;
29
+ }
30
+ function readDrawObjectReference(frame, pkg) {
31
+ const object = require_xml_query.childrenWithTag(frame, "draw:object")[0];
32
+ if (object === void 0) return;
33
+ const rawHref = require_xml_query.attrValue(object, "xlink:href");
34
+ const href = rawHref === void 0 ? void 0 : normaliseObjectHref(rawHref);
35
+ if (href === void 0) return;
36
+ const subPackage = require_typed_odb_subdocument.subDocumentPackage(pkg, href, { allowMissingContent: true });
37
+ const contentPart = subPackage.parts[CONTENT_PART];
38
+ if (contentPart?.kind !== "xml") return;
39
+ const objectKind = subDocumentKind(contentPart.nodes);
40
+ if (objectKind === void 0) return;
41
+ return {
42
+ objectKind,
43
+ package: subPackage,
44
+ href
45
+ };
46
+ }
47
+ //#endregion
48
+ exports.readDrawObjectReference = readDrawObjectReference;
@@ -0,0 +1,13 @@
1
+ import { l as XmlElement } from "../../node-CkBWRjNR.cjs";
2
+ import { Package } from "../../model/package.cjs";
3
+ import { ContentEmbeddedObjectKind } from "document-schema.js";
4
+ //#region src/typed/draw/embedded.d.ts
5
+ type EmbeddedDocumentKind = ContentEmbeddedObjectKind;
6
+ interface EmbeddedDrawObject {
7
+ objectKind: EmbeddedDocumentKind;
8
+ package: Package;
9
+ href: string;
10
+ }
11
+ declare function readDrawObjectReference(frame: XmlElement, pkg: Package): EmbeddedDrawObject | undefined;
12
+ //#endregion
13
+ export { EmbeddedDocumentKind, EmbeddedDrawObject, readDrawObjectReference };
@@ -0,0 +1,13 @@
1
+ import { l as XmlElement } from "../../node-CkBWRjNR.js";
2
+ import { Package } from "../../model/package.js";
3
+ import { ContentEmbeddedObjectKind } from "document-schema.js";
4
+ //#region src/typed/draw/embedded.d.ts
5
+ type EmbeddedDocumentKind = ContentEmbeddedObjectKind;
6
+ interface EmbeddedDrawObject {
7
+ objectKind: EmbeddedDocumentKind;
8
+ package: Package;
9
+ href: string;
10
+ }
11
+ declare function readDrawObjectReference(frame: XmlElement, pkg: Package): EmbeddedDrawObject | undefined;
12
+ //#endregion
13
+ export { EmbeddedDocumentKind, EmbeddedDrawObject, readDrawObjectReference };
@@ -0,0 +1,47 @@
1
+ import { attrValue, childrenWithTag, findChildElement, rootElement } from "../../xml/query.js";
2
+ import { findMathRoot } from "../formula/read.js";
3
+ import { subDocumentPackage } from "../odb/subdocument.js";
4
+ //#region src/typed/draw/embedded.ts
5
+ const CONTENT_PART = "content.xml";
6
+ function embeddedKindFor(bodyChildTag) {
7
+ switch (bodyChildTag) {
8
+ case "office:text": return "wordprocessing";
9
+ case "office:spreadsheet": return "spreadsheet";
10
+ case "office:presentation": return "presentation";
11
+ case "office:drawing": return "drawing";
12
+ default: return;
13
+ }
14
+ }
15
+ function subDocumentKind(nodes) {
16
+ const root = rootElement(nodes);
17
+ const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
18
+ const bodyChild = body === void 0 ? void 0 : rootElement(body.children);
19
+ const bodyKind = bodyChild === void 0 ? void 0 : embeddedKindFor(bodyChild.tag);
20
+ if (bodyKind !== void 0) return bodyKind;
21
+ return findMathRoot(nodes) === void 0 ? void 0 : "formula";
22
+ }
23
+ function normaliseObjectHref(raw) {
24
+ const withoutPrefix = raw.startsWith("./") ? raw.slice(2) : raw;
25
+ const trimmed = withoutPrefix.endsWith("/") ? withoutPrefix.slice(0, -1) : withoutPrefix;
26
+ if (trimmed.length === 0 || trimmed.startsWith("..") || trimmed.startsWith("/") || trimmed.includes("://")) return;
27
+ return trimmed;
28
+ }
29
+ function readDrawObjectReference(frame, pkg) {
30
+ const object = childrenWithTag(frame, "draw:object")[0];
31
+ if (object === void 0) return;
32
+ const rawHref = attrValue(object, "xlink:href");
33
+ const href = rawHref === void 0 ? void 0 : normaliseObjectHref(rawHref);
34
+ if (href === void 0) return;
35
+ const subPackage = subDocumentPackage(pkg, href, { allowMissingContent: true });
36
+ const contentPart = subPackage.parts[CONTENT_PART];
37
+ if (contentPart?.kind !== "xml") return;
38
+ const objectKind = subDocumentKind(contentPart.nodes);
39
+ if (objectKind === void 0) return;
40
+ return {
41
+ objectKind,
42
+ package: subPackage,
43
+ href
44
+ };
45
+ }
46
+ //#endregion
47
+ export { readDrawObjectReference };
@@ -4,6 +4,7 @@ const require_image_sniff = require("../../image/sniff.cjs");
4
4
  const require_typed_shared_units = require("../shared/units.cjs");
5
5
  const require_typed_shared_color = require("../shared/color.cjs");
6
6
  const require_xml_query = require("../../xml/query.cjs");
7
+ const require_typed_shared_text = require("../shared/text.cjs");
7
8
  const require_typed_shared_geometry = require("../shared/geometry.cjs");
8
9
  const require_typed_shared_cascade = require("../shared/cascade.cjs");
9
10
  const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
@@ -37,20 +38,31 @@ function readFrameInsets(frame, pkg) {
37
38
  }
38
39
  return insets;
39
40
  }
40
- function readDrawImageBlock(image, frameBox, pkg) {
41
+ function readFrameAltText(frame) {
42
+ const title = require_xml_query.childrenWithTag(frame, "svg:title")[0];
43
+ const decodedTitle = title === void 0 ? void 0 : require_typed_shared_text.decodeOdfText(title);
44
+ if (decodedTitle !== void 0 && decodedTitle.length > 0) return decodedTitle;
45
+ const description = require_xml_query.childrenWithTag(frame, "svg:desc")[0];
46
+ const decodedDescription = description === void 0 ? void 0 : require_typed_shared_text.decodeOdfText(description);
47
+ return decodedDescription !== void 0 && decodedDescription.length > 0 ? decodedDescription : void 0;
48
+ }
49
+ function readDrawImageBlock(image, frame, frameBox, pkg) {
41
50
  const href = require_xml_query.attrValue(image, "xlink:href");
42
51
  const part = href === void 0 ? void 0 : pkg.parts[href];
43
52
  if (part?.kind !== "binary") return;
44
53
  const bytes = require_util_base64.base64ToBytes(part.base64);
45
54
  const format = require_image_sniff.sniffImageFormat(bytes);
46
55
  if (format === void 0) return;
47
- return {
56
+ const block = {
48
57
  kind: "image",
49
58
  format,
50
59
  base64: part.base64,
51
60
  widthPt: frameBox.widthPt,
52
61
  heightPt: frameBox.heightPt
53
62
  };
63
+ const altText = readFrameAltText(frame);
64
+ if (altText !== void 0) block.altText = altText;
65
+ return block;
54
66
  }
55
67
  function readDrawFrameContent(frame, frameBox, pkg) {
56
68
  const table = require_xml_query.childrenWithTag(frame, "table:table")[0];
@@ -59,7 +71,7 @@ function readDrawFrameContent(frame, frameBox, pkg) {
59
71
  if (textBox !== void 0) return require_xml_query.elementsWithTag(textBox.children, "text:p").map((p) => require_typed_shared_paragraph.readOdfParagraph(p, pkg));
60
72
  const image = require_xml_query.childrenWithTag(frame, "draw:image")[0];
61
73
  if (image !== void 0) {
62
- const block = readDrawImageBlock(image, frameBox, pkg);
74
+ const block = readDrawImageBlock(image, frame, frameBox, pkg);
63
75
  return block === void 0 ? [] : [block];
64
76
  }
65
77
  return [];
@@ -3,6 +3,7 @@ import { sniffImageFormat } from "../../image/sniff.js";
3
3
  import { parseOdfLength } from "../shared/units.js";
4
4
  import { parseOdfColor } from "../shared/color.js";
5
5
  import { attrValue, childrenWithTag, elementsWithTag } from "../../xml/query.js";
6
+ import { decodeOdfText } from "../shared/text.js";
6
7
  import { parseLinePoints } from "../shared/geometry.js";
7
8
  import { resolveStyleElementChain } from "../shared/cascade.js";
8
9
  import { readOdfParagraph } from "../shared/paragraph.js";
@@ -36,20 +37,31 @@ function readFrameInsets(frame, pkg) {
36
37
  }
37
38
  return insets;
38
39
  }
39
- function readDrawImageBlock(image, frameBox, pkg) {
40
+ function readFrameAltText(frame) {
41
+ const title = childrenWithTag(frame, "svg:title")[0];
42
+ const decodedTitle = title === void 0 ? void 0 : decodeOdfText(title);
43
+ if (decodedTitle !== void 0 && decodedTitle.length > 0) return decodedTitle;
44
+ const description = childrenWithTag(frame, "svg:desc")[0];
45
+ const decodedDescription = description === void 0 ? void 0 : decodeOdfText(description);
46
+ return decodedDescription !== void 0 && decodedDescription.length > 0 ? decodedDescription : void 0;
47
+ }
48
+ function readDrawImageBlock(image, frame, frameBox, pkg) {
40
49
  const href = attrValue(image, "xlink:href");
41
50
  const part = href === void 0 ? void 0 : pkg.parts[href];
42
51
  if (part?.kind !== "binary") return;
43
52
  const bytes = base64ToBytes(part.base64);
44
53
  const format = sniffImageFormat(bytes);
45
54
  if (format === void 0) return;
46
- return {
55
+ const block = {
47
56
  kind: "image",
48
57
  format,
49
58
  base64: part.base64,
50
59
  widthPt: frameBox.widthPt,
51
60
  heightPt: frameBox.heightPt
52
61
  };
62
+ const altText = readFrameAltText(frame);
63
+ if (altText !== void 0) block.altText = altText;
64
+ return block;
53
65
  }
54
66
  function readDrawFrameContent(frame, frameBox, pkg) {
55
67
  const table = childrenWithTag(frame, "table:table")[0];
@@ -58,7 +70,7 @@ function readDrawFrameContent(frame, frameBox, pkg) {
58
70
  if (textBox !== void 0) return elementsWithTag(textBox.children, "text:p").map((p) => readOdfParagraph(p, pkg));
59
71
  const image = childrenWithTag(frame, "draw:image")[0];
60
72
  if (image !== void 0) {
61
- const block = readDrawImageBlock(image, frameBox, pkg);
73
+ const block = readDrawImageBlock(image, frame, frameBox, pkg);
62
74
  return block === void 0 ? [] : [block];
63
75
  }
64
76
  return [];
@@ -58,5 +58,6 @@ function readOdfFormulaDocument(pkg) {
58
58
  };
59
59
  }
60
60
  //#endregion
61
+ exports.findMathRoot = findMathRoot;
61
62
  exports.readOdfFormula = readOdfFormula;
62
63
  exports.readOdfFormulaDocument = readOdfFormulaDocument;
@@ -1,4 +1,4 @@
1
- import { d as XmlNode } from "../../node-CkBWRjNR.cjs";
1
+ import { d as XmlNode, l as XmlElement } from "../../node-CkBWRjNR.cjs";
2
2
  import { Package } from "../../model/package.cjs";
3
3
  import { ContentDocument, LayoutMetadata } from "document-schema.js";
4
4
  //#region src/typed/formula/read.d.ts
@@ -7,7 +7,8 @@ interface OdfFormulaDocument {
7
7
  mathml: XmlNode[];
8
8
  metadata: LayoutMetadata;
9
9
  }
10
+ declare function findMathRoot(nodes: readonly XmlNode[]): XmlElement | undefined;
10
11
  declare function readOdfFormula(pkg: Package): OdfFormulaDocument;
11
12
  declare function readOdfFormulaDocument(pkg: Package): ContentDocument;
12
13
  //#endregion
13
- export { OdfFormulaDocument, readOdfFormula, readOdfFormulaDocument };
14
+ export { OdfFormulaDocument, findMathRoot, readOdfFormula, readOdfFormulaDocument };
@@ -1,4 +1,4 @@
1
- import { d as XmlNode } from "../../node-CkBWRjNR.js";
1
+ import { d as XmlNode, l as XmlElement } from "../../node-CkBWRjNR.js";
2
2
  import { Package } from "../../model/package.js";
3
3
  import { ContentDocument, LayoutMetadata } from "document-schema.js";
4
4
  //#region src/typed/formula/read.d.ts
@@ -7,7 +7,8 @@ interface OdfFormulaDocument {
7
7
  mathml: XmlNode[];
8
8
  metadata: LayoutMetadata;
9
9
  }
10
+ declare function findMathRoot(nodes: readonly XmlNode[]): XmlElement | undefined;
10
11
  declare function readOdfFormula(pkg: Package): OdfFormulaDocument;
11
12
  declare function readOdfFormulaDocument(pkg: Package): ContentDocument;
12
13
  //#endregion
13
- export { OdfFormulaDocument, readOdfFormula, readOdfFormulaDocument };
14
+ export { OdfFormulaDocument, findMathRoot, readOdfFormula, readOdfFormulaDocument };
@@ -57,4 +57,4 @@ function readOdfFormulaDocument(pkg) {
57
57
  };
58
58
  }
59
59
  //#endregion
60
- export { readOdfFormula, readOdfFormulaDocument };
60
+ export { findMathRoot, readOdfFormula, readOdfFormulaDocument };
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_xml_entities = require("../../xml/entities.cjs");
3
3
  const require_xml_query = require("../../xml/query.cjs");
4
+ const require_typed_odb_subdocument = require("./subdocument.cjs");
4
5
  const require_typed_odt_read = require("../odt/read.cjs");
5
6
  const require_typed_odb_read = require("./read.cjs");
6
- const require_typed_odb_subdocument = require("./subdocument.cjs");
7
7
  //#region src/typed/odb/form.ts
8
8
  const CONTENT_PART = "content.xml";
9
9
  const FORM_ELEMENT_TAG = "form:form";
@@ -1,8 +1,8 @@
1
1
  import { decodeXmlText } from "../../xml/entities.js";
2
2
  import { attrValue, findChildElement, rootElement } from "../../xml/query.js";
3
+ import { subDocumentPackage } from "./subdocument.js";
3
4
  import { readOdt } from "../odt/read.js";
4
5
  import { resolveOdbComponent } from "./read.js";
5
- import { subDocumentPackage } from "./subdocument.js";
6
6
  //#region src/typed/odb/form.ts
7
7
  const CONTENT_PART = "content.xml";
8
8
  const FORM_ELEMENT_TAG = "form:form";
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_xml_entities = require("../../xml/entities.cjs");
3
3
  const require_xml_query = require("../../xml/query.cjs");
4
- const require_typed_odb_read = require("./read.cjs");
5
4
  const require_typed_odb_subdocument = require("./subdocument.cjs");
5
+ const require_typed_odb_read = require("./read.cjs");
6
6
  //#region src/typed/odb/report.ts
7
7
  const CONTENT_PART = "content.xml";
8
8
  const GROUP_TAG = "rpt:group";
@@ -1,7 +1,7 @@
1
1
  import { decodeXmlText } from "../../xml/entities.js";
2
2
  import { attrValue, findChildElement, rootElement } from "../../xml/query.js";
3
- import { resolveOdbComponent } from "./read.js";
4
3
  import { subDocumentPackage } from "./subdocument.js";
4
+ import { resolveOdbComponent } from "./read.js";
5
5
  //#region src/typed/odb/report.ts
6
6
  const CONTENT_PART = "content.xml";
7
7
  const GROUP_TAG = "rpt:group";
@@ -7,7 +7,14 @@ const require_typed_shared_cascade = require("../shared/cascade.cjs");
7
7
  const require_typed_shared_metadata = require("../shared/metadata.cjs");
8
8
  const require_typed_shared_paragraph = require("../shared/paragraph.cjs");
9
9
  const require_typed_shared_table = require("../shared/table.cjs");
10
+ const require_typed_shared_transform = require("../shared/transform.cjs");
10
11
  const require_typed_shared_masterpage = require("../shared/masterpage.cjs");
12
+ const require_typed_draw_shapes = require("../draw/shapes.cjs");
13
+ const require_typed_formula_read = require("../formula/read.cjs");
14
+ const require_typed_draw_embedded = require("../draw/embedded.cjs");
15
+ const require_typed_odp_read = require("../odp/read.cjs");
16
+ const require_typed_odt_read = require("../odt/read.cjs");
17
+ const require_typed_odg_read = require("../odg/read.cjs");
11
18
  let document_schema_js = require("document-schema.js");
12
19
  //#region src/typed/ods/read.ts
13
20
  const CONTENT_PART = "content.xml";
@@ -156,10 +163,89 @@ function parseNonNegativeInteger(value) {
156
163
  const parsed = Number.parseInt(value, 10);
157
164
  return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
158
165
  }
166
+ function readEmbeddedObjectDocument(reference) {
167
+ switch (reference.objectKind) {
168
+ case "wordprocessing": {
169
+ const { metadata, sections } = require_typed_odt_read.readOdt(reference.package);
170
+ return {
171
+ kind: "wordprocessing",
172
+ formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
173
+ metadata,
174
+ sections
175
+ };
176
+ }
177
+ case "presentation": {
178
+ const { metadata, slides } = require_typed_odp_read.readOdp(reference.package);
179
+ return {
180
+ kind: "presentation",
181
+ formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
182
+ metadata,
183
+ slides
184
+ };
185
+ }
186
+ case "drawing": {
187
+ const { metadata, pages } = require_typed_odg_read.readOdg(reference.package);
188
+ return {
189
+ kind: "drawing",
190
+ formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
191
+ metadata,
192
+ pages
193
+ };
194
+ }
195
+ case "spreadsheet": {
196
+ const { metadata, sheets } = readOds(reference.package);
197
+ return {
198
+ kind: "spreadsheet",
199
+ formatVersion: document_schema_js.CONTENT_FORMAT_VERSION,
200
+ metadata,
201
+ sheets
202
+ };
203
+ }
204
+ case "formula": return require_typed_formula_read.readOdfFormulaDocument(reference.package);
205
+ }
206
+ }
207
+ function collectAnchoredFrame(frameElement, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
208
+ const shape = require_typed_draw_shapes.readDrawFrame(frameElement, groupFunctions, pkg);
209
+ if (shape === void 0) return;
210
+ const reference = require_typed_draw_embedded.readDrawObjectReference(frameElement, pkg);
211
+ if (reference !== void 0) {
212
+ embeddedObjects.push({
213
+ objectKind: reference.objectKind,
214
+ document: readEmbeddedObjectDocument(reference),
215
+ frame: shape.frame,
216
+ anchorRow,
217
+ anchorColumn,
218
+ offsetXPt: shape.frame.xPt,
219
+ offsetYPt: shape.frame.yPt
220
+ });
221
+ return;
222
+ }
223
+ for (const block of shape.blocks) if (block.kind === "image") images.push({
224
+ ...block,
225
+ anchorRow,
226
+ anchorColumn,
227
+ offsetXPt: shape.frame.xPt,
228
+ offsetYPt: shape.frame.yPt
229
+ });
230
+ }
231
+ function collectAnchoredFrames(children, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
232
+ for (const child of children) {
233
+ if (child.type !== "element") continue;
234
+ if (child.tag === "draw:frame") collectAnchoredFrame(child, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects);
235
+ else if (child.tag === "draw:g") {
236
+ const ownValue = require_xml_query.attrValue(child, "draw:transform");
237
+ const ownFunctions = ownValue === void 0 ? [] : require_typed_shared_transform.parseOdfTransform(ownValue);
238
+ const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
239
+ collectAnchoredFrames(child.children, nested, pkg, anchorRow, anchorColumn, images, embeddedObjects);
240
+ }
241
+ }
242
+ }
159
243
  function readTable(tableElement, pkg) {
160
244
  const columns = [];
161
245
  const rows = [];
162
246
  const cells = [];
247
+ const images = [];
248
+ const embeddedObjects = [];
163
249
  const manualBreakRows = [];
164
250
  const manualBreakColumns = [];
165
251
  let repeatColumns;
@@ -184,6 +270,7 @@ function readTable(tableElement, pkg) {
184
270
  const columnIndex = cursor.columnIndex;
185
271
  const rowIndex = cursor.rowIndex;
186
272
  cursor.nextCell(readRepeatCount(child, "table:number-columns-repeated"));
273
+ collectAnchoredFrames(child.children, [], pkg, rowIndex, columnIndex, images, embeddedObjects);
187
274
  const formula = require_xml_query.attrValue(child, "table:formula");
188
275
  const { runs, displayText } = readCellText(child, pkg);
189
276
  if (!(require_xml_query.attrValue(child, "office:value-type") !== void 0) && formula === void 0 && displayText.length === 0) continue;
@@ -225,7 +312,8 @@ function readTable(tableElement, pkg) {
225
312
  }
226
313
  for (const child of tableElement.children) {
227
314
  if (child.type !== "element") continue;
228
- if (child.tag === "table:table-column") processColumn(child);
315
+ if (child.tag === "table:shapes") collectAnchoredFrames(child.children, [], pkg, 0, 0, images, embeddedObjects);
316
+ else if (child.tag === "table:table-column") processColumn(child);
229
317
  else if (child.tag === "table:table-header-columns") {
230
318
  const startIndex = columnCursor;
231
319
  for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-column") processColumn(headerChild);
@@ -247,6 +335,8 @@ function readTable(tableElement, pkg) {
247
335
  columns,
248
336
  rows,
249
337
  cells,
338
+ images,
339
+ embeddedObjects,
250
340
  repeatColumns,
251
341
  repeatRows,
252
342
  manualBreakRows,
@@ -296,15 +386,17 @@ function readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualB
296
386
  function readSheet(tableElement, pkg) {
297
387
  const name = require_xml_query.attrValue(tableElement, "table:name");
298
388
  if (name === void 0) return;
299
- const { columns, rows, cells, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
300
- return {
389
+ const { columns, rows, cells, images, embeddedObjects, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
390
+ const sheet = {
301
391
  name,
302
392
  cells,
303
393
  columns,
304
394
  rows,
305
- images: [],
395
+ images,
306
396
  printSettings: readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns)
307
397
  };
398
+ if (embeddedObjects.length > 0) sheet.embeddedObjects = embeddedObjects;
399
+ return sheet;
308
400
  }
309
401
  function readOds(pkg) {
310
402
  const contentPart = pkg.parts[CONTENT_PART];
@@ -6,8 +6,15 @@ import { findStyleElement, resolveStyleElementChain } from "../shared/cascade.js
6
6
  import { readOdfMetadata } from "../shared/metadata.js";
7
7
  import { readOdfParagraph } from "../shared/paragraph.js";
8
8
  import { readCellStyleDecoration } from "../shared/table.js";
9
+ import { parseOdfTransform } from "../shared/transform.js";
9
10
  import { resolvePageLayoutProperties } from "../shared/masterpage.js";
10
- import { PAGE_SIZE_A4 } from "document-schema.js";
11
+ import { readDrawFrame } from "../draw/shapes.js";
12
+ import { readOdfFormulaDocument } from "../formula/read.js";
13
+ import { readDrawObjectReference } from "../draw/embedded.js";
14
+ import { readOdp } from "../odp/read.js";
15
+ import { readOdt } from "../odt/read.js";
16
+ import { readOdg } from "../odg/read.js";
17
+ import { CONTENT_FORMAT_VERSION, PAGE_SIZE_A4 } from "document-schema.js";
11
18
  //#region src/typed/ods/read.ts
12
19
  const CONTENT_PART = "content.xml";
13
20
  function parseKnownOdfLength(value) {
@@ -155,10 +162,89 @@ function parseNonNegativeInteger(value) {
155
162
  const parsed = Number.parseInt(value, 10);
156
163
  return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
157
164
  }
165
+ function readEmbeddedObjectDocument(reference) {
166
+ switch (reference.objectKind) {
167
+ case "wordprocessing": {
168
+ const { metadata, sections } = readOdt(reference.package);
169
+ return {
170
+ kind: "wordprocessing",
171
+ formatVersion: CONTENT_FORMAT_VERSION,
172
+ metadata,
173
+ sections
174
+ };
175
+ }
176
+ case "presentation": {
177
+ const { metadata, slides } = readOdp(reference.package);
178
+ return {
179
+ kind: "presentation",
180
+ formatVersion: CONTENT_FORMAT_VERSION,
181
+ metadata,
182
+ slides
183
+ };
184
+ }
185
+ case "drawing": {
186
+ const { metadata, pages } = readOdg(reference.package);
187
+ return {
188
+ kind: "drawing",
189
+ formatVersion: CONTENT_FORMAT_VERSION,
190
+ metadata,
191
+ pages
192
+ };
193
+ }
194
+ case "spreadsheet": {
195
+ const { metadata, sheets } = readOds(reference.package);
196
+ return {
197
+ kind: "spreadsheet",
198
+ formatVersion: CONTENT_FORMAT_VERSION,
199
+ metadata,
200
+ sheets
201
+ };
202
+ }
203
+ case "formula": return readOdfFormulaDocument(reference.package);
204
+ }
205
+ }
206
+ function collectAnchoredFrame(frameElement, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
207
+ const shape = readDrawFrame(frameElement, groupFunctions, pkg);
208
+ if (shape === void 0) return;
209
+ const reference = readDrawObjectReference(frameElement, pkg);
210
+ if (reference !== void 0) {
211
+ embeddedObjects.push({
212
+ objectKind: reference.objectKind,
213
+ document: readEmbeddedObjectDocument(reference),
214
+ frame: shape.frame,
215
+ anchorRow,
216
+ anchorColumn,
217
+ offsetXPt: shape.frame.xPt,
218
+ offsetYPt: shape.frame.yPt
219
+ });
220
+ return;
221
+ }
222
+ for (const block of shape.blocks) if (block.kind === "image") images.push({
223
+ ...block,
224
+ anchorRow,
225
+ anchorColumn,
226
+ offsetXPt: shape.frame.xPt,
227
+ offsetYPt: shape.frame.yPt
228
+ });
229
+ }
230
+ function collectAnchoredFrames(children, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects) {
231
+ for (const child of children) {
232
+ if (child.type !== "element") continue;
233
+ if (child.tag === "draw:frame") collectAnchoredFrame(child, groupFunctions, pkg, anchorRow, anchorColumn, images, embeddedObjects);
234
+ else if (child.tag === "draw:g") {
235
+ const ownValue = attrValue(child, "draw:transform");
236
+ const ownFunctions = ownValue === void 0 ? [] : parseOdfTransform(ownValue);
237
+ const nested = ownFunctions.length === 0 ? groupFunctions : [...ownFunctions, ...groupFunctions];
238
+ collectAnchoredFrames(child.children, nested, pkg, anchorRow, anchorColumn, images, embeddedObjects);
239
+ }
240
+ }
241
+ }
158
242
  function readTable(tableElement, pkg) {
159
243
  const columns = [];
160
244
  const rows = [];
161
245
  const cells = [];
246
+ const images = [];
247
+ const embeddedObjects = [];
162
248
  const manualBreakRows = [];
163
249
  const manualBreakColumns = [];
164
250
  let repeatColumns;
@@ -183,6 +269,7 @@ function readTable(tableElement, pkg) {
183
269
  const columnIndex = cursor.columnIndex;
184
270
  const rowIndex = cursor.rowIndex;
185
271
  cursor.nextCell(readRepeatCount(child, "table:number-columns-repeated"));
272
+ collectAnchoredFrames(child.children, [], pkg, rowIndex, columnIndex, images, embeddedObjects);
186
273
  const formula = attrValue(child, "table:formula");
187
274
  const { runs, displayText } = readCellText(child, pkg);
188
275
  if (!(attrValue(child, "office:value-type") !== void 0) && formula === void 0 && displayText.length === 0) continue;
@@ -224,7 +311,8 @@ function readTable(tableElement, pkg) {
224
311
  }
225
312
  for (const child of tableElement.children) {
226
313
  if (child.type !== "element") continue;
227
- if (child.tag === "table:table-column") processColumn(child);
314
+ if (child.tag === "table:shapes") collectAnchoredFrames(child.children, [], pkg, 0, 0, images, embeddedObjects);
315
+ else if (child.tag === "table:table-column") processColumn(child);
228
316
  else if (child.tag === "table:table-header-columns") {
229
317
  const startIndex = columnCursor;
230
318
  for (const headerChild of child.children) if (headerChild.type === "element" && headerChild.tag === "table:table-column") processColumn(headerChild);
@@ -246,6 +334,8 @@ function readTable(tableElement, pkg) {
246
334
  columns,
247
335
  rows,
248
336
  cells,
337
+ images,
338
+ embeddedObjects,
249
339
  repeatColumns,
250
340
  repeatRows,
251
341
  manualBreakRows,
@@ -295,15 +385,17 @@ function readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualB
295
385
  function readSheet(tableElement, pkg) {
296
386
  const name = attrValue(tableElement, "table:name");
297
387
  if (name === void 0) return;
298
- const { columns, rows, cells, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
299
- return {
388
+ const { columns, rows, cells, images, embeddedObjects, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns } = readTable(tableElement, pkg);
389
+ const sheet = {
300
390
  name,
301
391
  cells,
302
392
  columns,
303
393
  rows,
304
- images: [],
394
+ images,
305
395
  printSettings: readPrintSettings(tableElement, pkg, repeatColumns, repeatRows, manualBreakRows, manualBreakColumns)
306
396
  };
397
+ if (embeddedObjects.length > 0) sheet.embeddedObjects = embeddedObjects;
398
+ return sheet;
307
399
  }
308
400
  function readOds(pkg) {
309
401
  const contentPart = pkg.parts[CONTENT_PART];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "odf.js",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Type-safe, lossless round-trip conversion between OpenDocument Format packages (odt, ods, odp) and JSON, hand-written and dependency-minimal, built on Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -69,7 +69,7 @@
69
69
  "license": "MIT",
70
70
  "packageManager": "pnpm@11.6.0",
71
71
  "dependencies": {
72
- "document-schema.js": "^2.0.0",
72
+ "document-schema.js": "^2.2.0",
73
73
  "fast-xml-parser": "^5.10.1",
74
74
  "fflate": "^0.8.3",
75
75
  "zod": "^4.4.3"