Class: Uniword::Wordprocessingml::DocumentRoot
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Uniword::Wordprocessingml::DocumentRoot
- Includes:
- DocumentInput, FeatureFacade
- Defined in:
- lib/uniword/wordprocessingml/document_root.rb,
lib/uniword/wordprocessingml/document_root/feature_facade.rb
Overview
Root element of a WordprocessingML document
Generated from OOXML schema: wordprocessingml.yml Element: <w:document>
Defined Under Namespace
Modules: FeatureFacade
Instance Attribute Summary collapse
-
#allocator ⇒ Object
Central ID allocator — preserves IDs across build/save cycle.
-
#app_properties ⇒ Uniword::Ooxml::AppProperties
Get app_properties (lazy initialization).
-
#bibliography_sources ⇒ Object
Bibliography sources for sources.xml.
-
#bookmarks ⇒ Hash{String => Object}
Get bookmarks from document paragraphs.
-
#comments ⇒ Object
Additional attributes for DOCX metadata (not part of document.xml) These are stored in separate files within the DOCX package.
-
#content_types ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#core_properties ⇒ Uniword::Ooxml::CoreProperties
Get core_properties (lazy initialization).
-
#custom_properties ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#custom_xml_items ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#document_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#endnotes ⇒ Object
Footnotes and endnotes (separate XML parts in DOCX package).
-
#endnotes_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#font_table ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#footnotes ⇒ Object
Footnotes and endnotes (separate XML parts in DOCX package).
-
#footnotes_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#image_parts ⇒ Object
Image parts to embed in the DOCX package Hash: r_id => { path: String, data: String, content_type: String, target: String }.
-
#numbering_configuration ⇒ Object
Accessor for numbering_configuration (lazy init for builder API).
-
#package_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#raw_html ⇒ Object
Additional attributes for DOCX metadata (not part of document.xml) These are stored in separate files within the DOCX package.
-
#revisions ⇒ Object
Additional attributes for DOCX metadata (not part of document.xml) These are stored in separate files within the DOCX package.
-
#settings ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#settings_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#styles_configuration ⇒ Object
Lazy initialization for styles_configuration.
-
#theme ⇒ Object
Additional attributes for DOCX metadata (not part of document.xml) These are stored in separate files within the DOCX package.
-
#theme_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load).
-
#web_settings ⇒ Object
Round-trip parts (copied from DocxPackage during load).
Instance Method Summary collapse
-
#apply_color_scheme(name) ⇒ self
Apply a bundled color scheme to the document's theme.
-
#apply_font_scheme(name) ⇒ self
Apply a bundled font scheme to the document's theme.
-
#apply_page_setup(size: nil, orientation: nil, margins: nil, top: nil, right: nil, bottom: nil, left: nil) ⇒ Integer
Apply uniform page setup to every section of the document.
-
#apply_styles_from(source_path, strategy: :keep_existing) ⇒ self
Apply styles from another document.
-
#apply_styleset(name, strategy: :keep_existing) ⇒ self
Apply StyleSet to document.
-
#apply_template(template_path, strategy: :keep_existing) ⇒ self
Apply both theme and styles from a template document.
-
#apply_theme(name, **options) ⇒ self
Apply theme to document.
-
#apply_theme_file(path, variant: nil) ⇒ self
Apply theme from .thmx file.
-
#apply_theme_from(source_path) ⇒ self
Apply theme from another document.
-
#auto_transition_theme ⇒ Hash?
Auto-transition from MS theme to Uniword equivalent.
-
#chart_parts ⇒ Docx::PartCollection
Chart parts to embed in the DOCX package, keyed by rId.
-
#chart_parts=(value) ⇒ Object
Bulk-assign chart parts (Hash of rId => ChartPart/hash; nil clears).
-
#document_stats ⇒ Hash
Document statistics (paragraphs, tables, images).
-
#embeddings ⇒ Docx::PartCollection
OLE/embedded object binaries (word/embeddings/*), keyed by target.
-
#embeddings=(value) ⇒ Object
Bulk-assign embeddings (Hash of target => Part/binary; nil clears).
-
#footers ⇒ Docx::HeaderFooterView
Footers view over the unified store.
-
#footers=(value) ⇒ Object
Bulk-assign footers (see #headers=).
-
#header_footer_parts ⇒ Docx::HeaderFooterPartCollection
Unified header/footer part store — the single storage path for both round-tripped and builder-created headers/footers.
-
#header_footer_parts=(parts) ⇒ Object
Replace the whole store (accepts HeaderFooterPart objects and legacy part hashes).
-
#headers ⇒ Docx::HeaderFooterView
Headers view over the unified store (Hash-style by sectPr type, Array-style over parts).
-
#headers=(value) ⇒ Object
Bulk-assign headers (nil clears; Hash of type => model; Array of models/parts).
-
#images ⇒ Array<Drawing>
Get all drawings (image references) from the document.
-
#inspect ⇒ String
Custom inspect for readable output.
-
#numbering_configuration_loaded? ⇒ Boolean
Whether numbering_configuration was explicitly loaded from source (vs lazily created for builder API).
-
#paragraphs ⇒ Array<Paragraph>
Get all paragraphs (convenience accessor).
-
#remove_style(style_id) ⇒ Boolean
Remove one style from the document's style definitions.
-
#remove_unused_styles ⇒ Array<String>
Remove every style that no content references — Word's Styles-pane decluttering as one call.
-
#rename_style(identifier, new_name) ⇒ Style?
Rename a style's display name (w:name) — Word's style rename.
-
#replace_font(from:, to:) ⇒ Integer
Replace one font family with another across the document.
-
#save(path, format: :auto, profile: nil, validate: nil) ⇒ void
Save document to file.
-
#tables ⇒ Array<Table>
Get all tables (convenience accessor).
-
#text ⇒ String
Get all paragraph text.
-
#title ⇒ Object
Get document title (delegates to core_properties).
-
#to_file(path, profile: nil, validate: nil) ⇒ void
Save document to DOCX file using DocxPackage.
-
#to_html_document ⇒ String
Convert OOXML document to HTML document.
-
#to_xml(options = {}) ⇒ Object
Override to_xml to sync element_order on child collections before serialization.
-
#valid? ⇒ Boolean
Check if document structure is valid.
-
#validation_errors ⇒ Array<String>
Get structural validation errors.
-
#validation_warnings ⇒ Array<String>
Get structural validation warnings.
Methods included from FeatureFacade
#accept_all_changes, #add_comment, #add_footer, #add_header, #add_watermark, #clear_comments, #diff, #extract_images, #generate_toc, #insert_image, #insert_toc, #list_comments, #list_footers, #list_headers, #list_images, #list_watermarks, #protect, #protection_active?, #protection_info, #reject_all_changes, #remove_footers, #remove_headers, #remove_image, #remove_watermark, #spellcheck, #unprotect, #update_toc, #watermark?
Instance Attribute Details
#allocator ⇒ Object
Central ID allocator — preserves IDs across build/save cycle
109 110 111 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 109 def allocator @allocator end |
#app_properties ⇒ Uniword::Ooxml::AppProperties
Get app_properties (lazy initialization)
184 185 186 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 184 def app_properties @app_properties ||= Uniword::Ooxml::AppProperties.new end |
#bibliography_sources ⇒ Object
Bibliography sources for sources.xml
103 104 105 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 103 def bibliography_sources @bibliography_sources end |
#bookmarks ⇒ Hash{String => Object}
Get bookmarks from document paragraphs
316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 316 def bookmarks result = {} return result unless body&.paragraphs body.paragraphs.each do |para| para.bookmark_starts&.each do |bs| result[bs.name.to_s] = bs if bs.name end end result end |
#comments ⇒ Object
Additional attributes for DOCX metadata (not part of document.xml) These are stored in separate files within the DOCX package
96 97 98 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 96 def comments @comments end |
#content_types ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def content_types @content_types end |
#core_properties ⇒ Uniword::Ooxml::CoreProperties
Get core_properties (lazy initialization)
205 206 207 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 205 def core_properties @core_properties ||= Uniword::Ooxml::CoreProperties.new end |
#custom_properties ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def custom_properties @custom_properties end |
#custom_xml_items ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def custom_xml_items @custom_xml_items end |
#document_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def document_rels @document_rels end |
#endnotes ⇒ Object
Footnotes and endnotes (separate XML parts in DOCX package)
98 99 100 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 98 def endnotes @endnotes end |
#endnotes_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def endnotes_rels @endnotes_rels end |
#font_table ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def font_table @font_table end |
#footnotes ⇒ Object
Footnotes and endnotes (separate XML parts in DOCX package)
98 99 100 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 98 def footnotes @footnotes end |
#footnotes_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def footnotes_rels @footnotes_rels end |
#image_parts ⇒ Object
Image parts to embed in the DOCX package Hash: r_id => { path: String, data: String, content_type: String, target: String }
101 102 103 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 101 def image_parts @image_parts end |
#numbering_configuration ⇒ Object
Accessor for numbering_configuration (lazy init for builder API)
189 190 191 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 189 def numbering_configuration @numbering_configuration ||= NumberingConfiguration.new end |
#package_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def package_rels @package_rels end |
#raw_html ⇒ Object
Additional attributes for DOCX metadata (not part of document.xml) These are stored in separate files within the DOCX package
96 97 98 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 96 def raw_html @raw_html end |
#revisions ⇒ Object
Additional attributes for DOCX metadata (not part of document.xml) These are stored in separate files within the DOCX package
96 97 98 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 96 def revisions @revisions end |
#settings ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def settings @settings end |
#settings_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def settings_rels @settings_rels end |
#styles_configuration ⇒ Object
Lazy initialization for styles_configuration
215 216 217 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 215 def styles_configuration @styles_configuration ||= StylesConfiguration.new end |
#theme ⇒ Object
Additional attributes for DOCX metadata (not part of document.xml) These are stored in separate files within the DOCX package
96 97 98 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 96 def theme @theme end |
#theme_rels ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def theme_rels @theme_rels end |
#web_settings ⇒ Object
Round-trip parts (copied from DocxPackage during load)
105 106 107 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 105 def web_settings @web_settings end |
Instance Method Details
#apply_color_scheme(name) ⇒ self
Apply a bundled color scheme to the document's theme
Mirrors Word's Design → Colors gallery: replaces only the theme's clrScheme — fonts and formats are untouched. Creates the theme part from the bundled Office theme when the document has none.
406 407 408 409 410 411 412 413 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 406 def apply_color_scheme(name) colors = Resource::ColorSchemeLoader.load(name.to_s) transformation = Themes::ThemeTransformation.new ensure_theme!(transformation) theme.theme_elements.clr_scheme = transformation.build_color_scheme(colors) self end |
#apply_font_scheme(name) ⇒ self
Apply a bundled font scheme to the document's theme
Mirrors Word's Design → Fonts gallery: replaces only the theme's fontScheme — colors and formats are untouched. Creates the theme part from the bundled Office theme when the document has none.
388 389 390 391 392 393 394 395 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 388 def apply_font_scheme(name) fonts = Resource::FontSchemeLoader.load(name.to_s) transformation = Themes::ThemeTransformation.new ensure_theme!(transformation) theme.theme_elements.font_scheme = transformation.build_font_scheme(fonts) self end |
#apply_page_setup(size: nil, orientation: nil, margins: nil, top: nil, right: nil, bottom: nil, left: nil) ⇒ Integer
Apply uniform page setup to every section of the document
Mirrors Word's Layout dialog: named paper sizes, orientation (with Word-style dimension swap), and margins.
444 445 446 447 448 449 450 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 444 def apply_page_setup(size: nil, orientation: nil, margins: nil, top: nil, right: nil, bottom: nil, left: nil) setup = PageSetup.new(size: size, orientation: orientation, margins: margins, top: top, right: right, bottom: bottom, left: left) setup.apply(self) end |
#apply_styles_from(source_path, strategy: :keep_existing) ⇒ self
Apply styles from another document
515 516 517 518 519 520 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 515 def apply_styles_from(source_path, strategy: :keep_existing) source_doc = Uniword.load(source_path) styles_configuration.merge(source_doc.styles_configuration, conflict_resolution: strategy) self end |
#apply_styleset(name, strategy: :keep_existing) ⇒ self
Apply StyleSet to document
373 374 375 376 377 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 373 def apply_styleset(name, strategy: :keep_existing) styleset = Uniword::Stylesets::YamlStyleSetLoader.load_bundled(name.to_s) styleset.apply_to(self, strategy: strategy) self end |
#apply_template(template_path, strategy: :keep_existing) ⇒ self
Apply both theme and styles from a template document
527 528 529 530 531 532 533 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 527 def apply_template(template_path, strategy: :keep_existing) template_doc = Uniword.load(template_path) self.theme = template_doc.theme.dup if template_doc.theme styles_configuration.merge(template_doc.styles_configuration, conflict_resolution: strategy) self end |
#apply_theme(name, **options) ⇒ self
Apply theme to document
Applies a Uniword theme by name, updating doc defaults and built-in heading/hyperlink styles to reference the theme.
339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 339 def apply_theme(name, **) friendly = Themes::Theme.load(name.to_s) [:colors]&.each do |key, value| friendly.color_scheme[key.to_s] = value end friendly.font_scheme.major_font = [:major_font] if [:major_font] friendly.font_scheme.minor_font = [:minor_font] if [:minor_font] word_theme = Themes::ThemeTransformation.new.to_word(friendly) Themes::ThemeApplicator.new.apply(word_theme, self) self end |
#apply_theme_file(path, variant: nil) ⇒ self
Apply theme from .thmx file
358 359 360 361 362 363 364 365 366 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 358 def apply_theme_file(path, variant: nil) loader = Themes::ThemeLoader.new self.theme = if variant loader.load_with_variant(path, variant) else loader.load(path) end self end |
#apply_theme_from(source_path) ⇒ self
Apply theme from another document
504 505 506 507 508 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 504 def apply_theme_from(source_path) source_doc = Uniword.load(source_path) self.theme = source_doc.theme.dup if source_doc.theme self end |
#auto_transition_theme ⇒ Hash?
Auto-transition from MS theme to Uniword equivalent
Detects the MS theme in the document's embedded theme and replaces it with the corresponding Uniword theme (font-substituted, renamed).
496 497 498 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 496 def auto_transition_theme Resource::ThemeTransition.auto_transition!(self) end |
#chart_parts ⇒ Docx::PartCollection
Chart parts to embed in the DOCX package, keyed by rId.
160 161 162 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 160 def chart_parts @chart_parts ||= Docx::PartCollection.new(:r_id, Docx::ChartPart) end |
#chart_parts=(value) ⇒ Object
Bulk-assign chart parts (Hash of rId => ChartPart/hash; nil clears).
165 166 167 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 165 def chart_parts=(value) chart_parts.replace_all(value) end |
#document_stats ⇒ Hash
Returns Document statistics (paragraphs, tables, images).
282 283 284 285 286 287 288 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 282 def document_stats { paragraphs: paragraphs.count, tables: tables.count, images: images.count, } end |
#embeddings ⇒ Docx::PartCollection
OLE/embedded object binaries (word/embeddings/*), keyed by target.
172 173 174 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 172 def @embeddings ||= Docx::PartCollection.new(:target, Docx::Part) end |
#embeddings=(value) ⇒ Object
Bulk-assign embeddings (Hash of target => Part/binary; nil clears).
177 178 179 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 177 def (value) .replace_all(value) end |
#footers ⇒ Docx::HeaderFooterView
Footers view over the unified store.
147 148 149 150 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 147 def @footers ||= Docx::HeaderFooterView.new(, :footer) end |
#footers=(value) ⇒ Object
Bulk-assign footers (see #headers=).
153 154 155 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 153 def (value) .replace(value) end |
#header_footer_parts ⇒ Docx::HeaderFooterPartCollection
Unified header/footer part store — the single storage path for both round-tripped and builder-created headers/footers.
119 120 121 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 119 def @header_footer_parts ||= Docx::HeaderFooterPartCollection.new end |
#header_footer_parts=(parts) ⇒ Object
Replace the whole store (accepts HeaderFooterPart objects and legacy part hashes).
125 126 127 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 125 def (parts) .replace_all(parts) end |
#headers ⇒ Docx::HeaderFooterView
Headers view over the unified store (Hash-style by sectPr type, Array-style over parts).
133 134 135 136 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 133 def headers @headers ||= Docx::HeaderFooterView.new(, :header) end |
#headers=(value) ⇒ Object
Bulk-assign headers (nil clears; Hash of type => model; Array of models/parts).
140 141 142 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 140 def headers=(value) headers.replace(value) end |
#images ⇒ Array<Drawing>
Get all drawings (image references) from the document. Walks all paragraphs and collects Drawing elements from runs.
273 274 275 276 277 278 279 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 273 def images return [] unless body&.paragraphs body.paragraphs.flat_map do |para| (para.runs || []).flat_map(&:drawings) end.compact end |
#inspect ⇒ String
Custom inspect for readable output
538 539 540 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 538 def inspect "#<#{self.class} @body=...>" end |
#numbering_configuration_loaded? ⇒ Boolean
Whether numbering_configuration was explicitly loaded from source (vs lazily created for builder API)
198 199 200 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 198 def numbering_configuration_loaded? !!@numbering_configuration end |
#paragraphs ⇒ Array<Paragraph>
Get all paragraphs (convenience accessor)
258 259 260 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 258 def paragraphs body&.paragraphs || [] end |
#remove_style(style_id) ⇒ Boolean
Remove one style from the document's style definitions
Default styles (w:default="1") are never removed.
458 459 460 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 458 def remove_style(style_id) StyleCleanup.new(self).remove?(style_id) end |
#remove_unused_styles ⇒ Array<String>
Remove every style that no content references — Word's Styles-pane decluttering as one call. Default styles are kept.
482 483 484 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 482 def remove_unused_styles StyleCleanup.new(self).remove_unused end |
#rename_style(identifier, new_name) ⇒ Style?
Rename a style's display name (w:name) — Word's style rename. References (pStyle/rStyle/tblStyle) target the styleId, so they keep working unchanged.
470 471 472 473 474 475 476 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 470 def rename_style(identifier, new_name) style = styles_configuration.style(identifier) return unless style style.name = StyleName.new(val: new_name) style end |
#replace_font(from:, to:) ⇒ Integer
Replace one font family with another across the document
Mirrors Word's Home → Replace → Replace Fonts: rewrites rFonts references in styles and defaults, body content, headers, footers, notes, comments, and numbering. Theme font references (asciiTheme etc.) are untouched — use #apply_font_scheme for those.
426 427 428 429 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 426 def replace_font(from:, to:) replacer = FontReplacer.new(from: from, to: to) replacer.replace(self) end |
#save(path, format: :auto, profile: nil, validate: nil) ⇒ void
This method returns an undefined value.
Save document to file
230 231 232 233 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 230 def save(path, format: :auto, profile: nil, validate: nil) writer = DocumentWriter.new(self) writer.save(path, format: format, profile: profile, validate: validate) end |
#tables ⇒ Array<Table>
Get all tables (convenience accessor)
265 266 267 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 265 def tables body&.tables || [] end |
#text ⇒ String
Get all paragraph text
249 250 251 252 253 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 249 def text return "" unless body&.paragraphs body.paragraphs.map(&:text).join("\n") end |
#title ⇒ Object
Get document title (delegates to core_properties)
210 211 212 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 210 def title core_properties.title end |
#to_file(path, profile: nil, validate: nil) ⇒ void
This method returns an undefined value.
Save document to DOCX file using DocxPackage
242 243 244 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 242 def to_file(path, profile: nil, validate: nil) Docx::Package.to_file(self, path, profile: profile, validate: validate) end |
#to_html_document ⇒ String
Convert OOXML document to HTML document
545 546 547 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 545 def to_html_document Uniword::Transformation::OoxmlToHtmlConverter.document_to_html(self) end |
#to_xml(options = {}) ⇒ Object
Override to_xml to sync element_order on child collections before serialization. lutaml-model's compiled serializer may bypass child #to_xml when serializing nested elements, so we sync here at the DocumentRoot level.
87 88 89 90 91 92 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 87 def to_xml( = {}) body&.sync_element_order_for_serialization footnotes&.sync_element_order if footnotes endnotes&.sync_element_order if endnotes super end |
#valid? ⇒ Boolean
Check if document structure is valid. Runs model-level validation rules via Validation::Engine. Use the verify CLI command for full OPC + XSD + semantic validation.
295 296 297 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 295 def valid? validation_errors.empty? end |
#validation_errors ⇒ Array<String>
Get structural validation errors.
302 303 304 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 302 def validation_errors structural_issues.select(&:error?).map(&:message) end |
#validation_warnings ⇒ Array<String>
Get structural validation warnings.
309 310 311 |
# File 'lib/uniword/wordprocessingml/document_root.rb', line 309 def validation_warnings structural_issues.reject(&:error?).map(&:message) end |