ddn.odf.document
Core ODF document types and the main OdfDocument class.
This module defines the central document abstraction for reading and writing OpenDocument files.
Supported document types
All ODF document families are supported: text (ODT), spreadsheet (ODS), drawing (ODG), presentation (ODP), chart (ODC), formula (ODF), image (ODI), and database (ODB). Template variants and flat XML formats are also supported.
Examples
Open an existing document
import ddn.odf.document;
auto doc = openOdfDocument("report.odt");Create a new document
import ddn.odf.document;
auto doc = createOdfDocument(OdfDocumentType.TEXT);Types 10
Enumeration of OpenDocument document types.
All document families have full read/write support including typed editing, round-trip preservation, and creation APIs.
Template, master-document, and flat XML variants are separate entries because they have distinct MIME types and package structures.
Represents an opened ODT text document with typed access to body, styles, metadata, and settings.
Use openOdfTextDocument to create instances from .odt files.
OdfDocumentType documentType() @property const @safe pure nothrow @nogcReturns the document type (TEXT, TEXT_TEMPLATE, TEXT_MASTER, or TEXT_WEB).const(OdfStyles) styles() @property ref const @safe pure nothrow @nogcReturns the parsed document styles.const(OdfMetadata) metadata() @property ref const @safe pure nothrow @nogcReturns the parsed document metadata.const(OdfSettings) settings() @property ref const @safe pure nothrow @nogcReturns the parsed document settings.const(OdfContent) content() @property ref const @safe pure nothrow @nogcReturns the parsed content model.void save(string path)Saves this text document to the given file path.Represents an OpenDocument file.
An OdfDocument wraps the ZIP container and provides access to the embedded XML streams (content, styles, metadata, manifest).
void save(string path)Saves the document to the given file path.Represents an opened ODS spreadsheet document with typed access to sheets, styles, metadata, and settings.
Use openOdfSpreadsheetDocument to create instances from .ods files.
OdfDocumentType documentType() @property const @safe pure nothrow @nogcReturns the document type (SPREADSHEET or SPREADSHEET_TEMPLATE).const(OdfSpreadsheetBody) body() @property ref const @safe pure nothrow @nogcReturns the parsed spreadsheet body.const(OdfMetadata) metadata() @property ref const @safe pure nothrow @nogcReturns the parsed metadata.const(OdfSettings) settings() @property ref const @safe pure nothrow @nogcReturns the parsed document settings.void save(string path)Saves this spreadsheet document to the given file path.Represents an opened ODG drawing document with typed access to pages, shapes, styles, metadata, and settings.
Use openOdfDrawingDocument to create instances from .odg files.
OdfDocumentType documentType() @property const @safe pure nothrow @nogcReturns the document type (DRAWING or DRAWING_TEMPLATE).const(OdfDrawingBody) body() @property ref const @safe pure nothrow @nogcReturns the parsed drawing body.const(OdfMetadata) metadata() @property ref const @safe pure nothrow @nogcReturns the parsed metadata.const(OdfSettings) settings() @property ref const @safe pure nothrow @nogcReturns the parsed document settings.void save(string path)Saves this drawing document to the given file path.Represents an opened ODP presentation document with typed access to slides, styles, metadata, and settings.
Use openOdfPresentationDocument to create instances from .odp files.
OdfDocumentType documentType() @property const @safe pure nothrow @nogcReturns the document type (PRESENTATION or PRESENTATION_TEMPLATE).const(OdfPresentationBody) body() @property ref const @safe pure nothrow @nogcReturns the parsed presentation body.const(OdfMetadata) metadata() @property ref const @safe pure nothrow @nogcReturns the parsed metadata.const(OdfSettings) settings() @property ref const @safe pure nothrow @nogcReturns the parsed document settings.void save(string path)Saves this presentation document to the given file path.Represents an opened ODC chart document with typed access to chart content, styles, metadata, and settings.
const(OdfSettings) settings() @property ref const @safe pure nothrow @nogcReturns the parsed document settings.void save(string path)Represents an opened ODF formula document (.odf).
Formula documents contain MathML markup representing mathematical formulas. Use openOdfFormulaDocument to create instances from .odf files.
const(OdfSettings) settings() @property ref const @safe pure nothrow @nogcReturns the parsed document settings.void save(string path)Represents an opened ODF image document (.odi).
Image documents wrap a single raster or vector image inside an ODF package. Use openOdfImageDocument to create instances from .odi files.
void save(string path)Represents an opened ODF database document (.odb).
Database documents store connection settings, queries, and table definitions in a preservation-first model. Use openOdfDatabaseDocument to create instances from .odb files.
const(OdfSettings) settings() @property ref const @safe pure nothrow @nogcReturns the parsed document settings.void save(string path)Functions 24
OdfTextDocument openOdfTextDocument(string path,
OdfReadOptions options, ref OdfDiagnosticCollector diagnostics)Opens an ODT text document with read options and version-aware compatibility reporting.OdfSpreadsheetDocument openOdfSpreadsheetDocument(string path,
OdfReadOptions options, ref OdfDiagnosticCollector diagnostics)Opens an ODS spreadsheet document with read options and version-aware compatibility reporting.OdfTextDocument createTextDocument(TextNode[] nodes...)Creates a new `OdfTextDocument` with the given body nodes.OdfTextDocument createTextTemplate(TextNode[] nodes...)Creates a new `OdfTextDocument` as a text template (`.ott`).OdfSpreadsheetDocument openOdfSpreadsheetDocument(string path)Opens an ODS spreadsheet document from a file path.OdfSpreadsheetDocument createSpreadsheetDocument(
SpreadsheetSheet[] sheets...)Creates a new `OdfSpreadsheetDocument` with the given sheets.OdfSpreadsheetDocument createSpreadsheetTemplate(
SpreadsheetSheet[] sheets...)Creates a new `OdfSpreadsheetDocument` as a spreadsheet template (`.ots`).OdfDrawingDocument openOdfDrawingDocument(string path)Opens an ODG drawing document from a file path.OdfDrawingDocument createDrawingDocument(DrawPage[] pages...)Creates a new `OdfDrawingDocument` with the given pages.OdfDrawingDocument createDrawingTemplate(DrawPage[] pages...)Creates a new `OdfDrawingDocument` as a drawing template (`.otg`).OdfPresentationDocument openOdfPresentationDocument(string path)Opens an ODP presentation document from a file path.OdfPresentationDocument createPresentationDocument(
PresentationSlide[] slides...)Creates a new `OdfPresentationDocument` with the given slides.OdfPresentationDocument createPresentationTemplate(
PresentationSlide[] slides...)Creates a new `OdfPresentationDocument` as a presentation template (`.otp`).OdfChartDocument createChartDocument(OdfChartBody chartBody)Creates a new `OdfChartDocument` with the given chart body.OdfFormulaDocument openOdfFormulaDocument(string path)Opens an ODF formula document from a file path.OdfFormulaDocument createFormulaDocument(OdfFormulaBody formulaBody)Creates a new `OdfFormulaDocument` with the given formula body.OdfImageDocument createImageDocument(OdfImageBody imgBody)Creates a new `OdfImageDocument` with the given image body.OdfDatabaseDocument openOdfDatabaseDocument(string path)Opens an ODF database document from a file path.OdfDocument createOdfDocument(OdfDocumentType docType) @safe pureCreates a new empty ODF document of the given type.