uniword 1.0.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.
Files changed (1269) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +428 -0
  3. data/CONTRIBUTING.md +479 -0
  4. data/LICENSE.txt +25 -0
  5. data/README.adoc +2186 -0
  6. data/exe/uniword +6 -0
  7. data/lib/uniword/accessibility/accessibility_checker.rb +115 -0
  8. data/lib/uniword/accessibility/accessibility_profile.rb +133 -0
  9. data/lib/uniword/accessibility/accessibility_report.rb +212 -0
  10. data/lib/uniword/accessibility/accessibility_rule.rb +93 -0
  11. data/lib/uniword/accessibility/accessibility_violation.rb +80 -0
  12. data/lib/uniword/accessibility/rules/color_usage_rule.rb +30 -0
  13. data/lib/uniword/accessibility/rules/contrast_ratio_rule.rb +31 -0
  14. data/lib/uniword/accessibility/rules/descriptive_headings_rule.rb +99 -0
  15. data/lib/uniword/accessibility/rules/document_title_rule.rb +64 -0
  16. data/lib/uniword/accessibility/rules/heading_structure_rule.rb +127 -0
  17. data/lib/uniword/accessibility/rules/image_alt_text_rule.rb +89 -0
  18. data/lib/uniword/accessibility/rules/language_specification_rule.rb +55 -0
  19. data/lib/uniword/accessibility/rules/list_structure_rule.rb +33 -0
  20. data/lib/uniword/accessibility/rules/reading_order_rule.rb +30 -0
  21. data/lib/uniword/accessibility/rules/table_headers_rule.rb +61 -0
  22. data/lib/uniword/accessibility/rules.rb +18 -0
  23. data/lib/uniword/accessibility.rb +12 -0
  24. data/lib/uniword/assembly/assembly_manifest.rb +189 -0
  25. data/lib/uniword/assembly/component_registry.rb +260 -0
  26. data/lib/uniword/assembly/cross_reference_resolver.rb +241 -0
  27. data/lib/uniword/assembly/document_assembler.rb +296 -0
  28. data/lib/uniword/assembly/toc.rb +227 -0
  29. data/lib/uniword/assembly/toc_entry.rb +124 -0
  30. data/lib/uniword/assembly/toc_instruction.rb +92 -0
  31. data/lib/uniword/assembly/variable_substitutor.rb +238 -0
  32. data/lib/uniword/assembly.rb +14 -0
  33. data/lib/uniword/batch/batch_result.rb +244 -0
  34. data/lib/uniword/batch/document_processor.rb +339 -0
  35. data/lib/uniword/batch/processing_stage.rb +92 -0
  36. data/lib/uniword/batch/stages/compress_images_stage.rb +187 -0
  37. data/lib/uniword/batch/stages/convert_format_stage.rb +117 -0
  38. data/lib/uniword/batch/stages/normalize_styles_stage.rb +174 -0
  39. data/lib/uniword/batch/stages/quality_check_stage.rb +149 -0
  40. data/lib/uniword/batch/stages/update_metadata_stage.rb +103 -0
  41. data/lib/uniword/batch/stages/validate_links_stage.rb +203 -0
  42. data/lib/uniword/batch.rb +16 -0
  43. data/lib/uniword/bibliography/author.rb +80 -0
  44. data/lib/uniword/bibliography/city.rb +22 -0
  45. data/lib/uniword/bibliography/corporate.rb +22 -0
  46. data/lib/uniword/bibliography/day.rb +22 -0
  47. data/lib/uniword/bibliography/edition.rb +22 -0
  48. data/lib/uniword/bibliography/first.rb +22 -0
  49. data/lib/uniword/bibliography/first_name.rb +22 -0
  50. data/lib/uniword/bibliography/guid.rb +22 -0
  51. data/lib/uniword/bibliography/issue.rb +22 -0
  52. data/lib/uniword/bibliography/last.rb +22 -0
  53. data/lib/uniword/bibliography/last_name.rb +22 -0
  54. data/lib/uniword/bibliography/lcid.rb +22 -0
  55. data/lib/uniword/bibliography/locale_id.rb +22 -0
  56. data/lib/uniword/bibliography/month.rb +22 -0
  57. data/lib/uniword/bibliography/name_list.rb +23 -0
  58. data/lib/uniword/bibliography/pages.rb +22 -0
  59. data/lib/uniword/bibliography/person.rb +27 -0
  60. data/lib/uniword/bibliography/publisher.rb +22 -0
  61. data/lib/uniword/bibliography/ref_order.rb +22 -0
  62. data/lib/uniword/bibliography/source.rb +169 -0
  63. data/lib/uniword/bibliography/source_tag.rb +22 -0
  64. data/lib/uniword/bibliography/source_type.rb +22 -0
  65. data/lib/uniword/bibliography/sources.rb +29 -0
  66. data/lib/uniword/bibliography/tag.rb +22 -0
  67. data/lib/uniword/bibliography/title.rb +22 -0
  68. data/lib/uniword/bibliography/url.rb +22 -0
  69. data/lib/uniword/bibliography/volume_number.rb +22 -0
  70. data/lib/uniword/bibliography/year.rb +22 -0
  71. data/lib/uniword/bibliography.rb +45 -0
  72. data/lib/uniword/bookmark.rb +103 -0
  73. data/lib/uniword/builder/bibliography_builder.rb +188 -0
  74. data/lib/uniword/builder/chart_builder.rb +365 -0
  75. data/lib/uniword/builder/comment_builder.rb +54 -0
  76. data/lib/uniword/builder/document_builder.rb +548 -0
  77. data/lib/uniword/builder/footnote_builder.rb +102 -0
  78. data/lib/uniword/builder/header_footer_builder.rb +79 -0
  79. data/lib/uniword/builder/image_builder.rb +316 -0
  80. data/lib/uniword/builder/list_builder.rb +51 -0
  81. data/lib/uniword/builder/numbering_builder.rb +42 -0
  82. data/lib/uniword/builder/paragraph_builder.rb +228 -0
  83. data/lib/uniword/builder/run_builder.rb +285 -0
  84. data/lib/uniword/builder/sdt_builder.rb +205 -0
  85. data/lib/uniword/builder/section_builder.rb +170 -0
  86. data/lib/uniword/builder/style_builder.rb +129 -0
  87. data/lib/uniword/builder/table_builder.rb +111 -0
  88. data/lib/uniword/builder/table_cell_builder.rb +138 -0
  89. data/lib/uniword/builder/table_row_builder.rb +65 -0
  90. data/lib/uniword/builder/theme_builder.rb +98 -0
  91. data/lib/uniword/builder/toc_builder.rb +54 -0
  92. data/lib/uniword/builder/watermark_builder.rb +95 -0
  93. data/lib/uniword/builder.rb +232 -0
  94. data/lib/uniword/chart/area3_d_chart.rb +35 -0
  95. data/lib/uniword/chart/area_chart.rb +33 -0
  96. data/lib/uniword/chart/auto_title_deleted.rb +22 -0
  97. data/lib/uniword/chart/axis_id.rb +22 -0
  98. data/lib/uniword/chart/axis_position.rb +22 -0
  99. data/lib/uniword/chart/bar3_d_chart.rb +39 -0
  100. data/lib/uniword/chart/bar_chart.rb +37 -0
  101. data/lib/uniword/chart/bubble_chart.rb +37 -0
  102. data/lib/uniword/chart/bubble_size.rb +25 -0
  103. data/lib/uniword/chart/cat_ax.rb +45 -0
  104. data/lib/uniword/chart/category_axis_data.rb +29 -0
  105. data/lib/uniword/chart/chart.rb +33 -0
  106. data/lib/uniword/chart/chart_reference.rb +24 -0
  107. data/lib/uniword/chart/chart_space.rb +35 -0
  108. data/lib/uniword/chart/color_map_override.rb +22 -0
  109. data/lib/uniword/chart/data_label.rb +35 -0
  110. data/lib/uniword/chart/data_labels.rb +41 -0
  111. data/lib/uniword/chart/date_ax.rb +45 -0
  112. data/lib/uniword/chart/diagram_reference.rb +24 -0
  113. data/lib/uniword/chart/doughnut_chart.rb +31 -0
  114. data/lib/uniword/chart/drop_lines.rb +23 -0
  115. data/lib/uniword/chart/error_bar_type.rb +22 -0
  116. data/lib/uniword/chart/error_bars.rb +37 -0
  117. data/lib/uniword/chart/error_direction.rb +22 -0
  118. data/lib/uniword/chart/explosion.rb +22 -0
  119. data/lib/uniword/chart/gap_width.rb +22 -0
  120. data/lib/uniword/chart/hi_low_lines.rb +23 -0
  121. data/lib/uniword/chart/index.rb +22 -0
  122. data/lib/uniword/chart/layout.rb +23 -0
  123. data/lib/uniword/chart/legend.rb +33 -0
  124. data/lib/uniword/chart/legend_entry.rb +27 -0
  125. data/lib/uniword/chart/legend_position.rb +22 -0
  126. data/lib/uniword/chart/line3_d_chart.rb +35 -0
  127. data/lib/uniword/chart/line_chart.rb +41 -0
  128. data/lib/uniword/chart/major_gridlines.rb +23 -0
  129. data/lib/uniword/chart/marker.rb +27 -0
  130. data/lib/uniword/chart/marker_size.rb +22 -0
  131. data/lib/uniword/chart/marker_style.rb +22 -0
  132. data/lib/uniword/chart/minor_gridlines.rb +23 -0
  133. data/lib/uniword/chart/number_reference.rb +25 -0
  134. data/lib/uniword/chart/numbering_format.rb +24 -0
  135. data/lib/uniword/chart/order.rb +22 -0
  136. data/lib/uniword/chart/orientation.rb +22 -0
  137. data/lib/uniword/chart/pie3_d_chart.rb +27 -0
  138. data/lib/uniword/chart/pie_chart.rb +29 -0
  139. data/lib/uniword/chart/plot_area.rb +35 -0
  140. data/lib/uniword/chart/plot_vis_only.rb +22 -0
  141. data/lib/uniword/chart/radar_chart.rb +31 -0
  142. data/lib/uniword/chart/scaling.rb +29 -0
  143. data/lib/uniword/chart/scatter_chart.rb +31 -0
  144. data/lib/uniword/chart/ser_ax.rb +43 -0
  145. data/lib/uniword/chart/series.rb +29 -0
  146. data/lib/uniword/chart/series_text.rb +25 -0
  147. data/lib/uniword/chart/shape_properties.rb +22 -0
  148. data/lib/uniword/chart/show_category_name.rb +22 -0
  149. data/lib/uniword/chart/show_legend_key.rb +22 -0
  150. data/lib/uniword/chart/show_value.rb +22 -0
  151. data/lib/uniword/chart/smooth.rb +22 -0
  152. data/lib/uniword/chart/stock_chart.rb +33 -0
  153. data/lib/uniword/chart/style.rb +22 -0
  154. data/lib/uniword/chart/surface3_d_chart.rb +29 -0
  155. data/lib/uniword/chart/surface_chart.rb +29 -0
  156. data/lib/uniword/chart/text_properties.rb +22 -0
  157. data/lib/uniword/chart/tick_label_position.rb +22 -0
  158. data/lib/uniword/chart/title.rb +31 -0
  159. data/lib/uniword/chart/trendline.rb +35 -0
  160. data/lib/uniword/chart/trendline_type.rb +22 -0
  161. data/lib/uniword/chart/up_down_bars.rb +27 -0
  162. data/lib/uniword/chart/val_ax.rb +49 -0
  163. data/lib/uniword/chart/values.rb +25 -0
  164. data/lib/uniword/chart/x_values.rb +25 -0
  165. data/lib/uniword/chart/y_values.rb +25 -0
  166. data/lib/uniword/chart.rb +105 -0
  167. data/lib/uniword/cli.rb +737 -0
  168. data/lib/uniword/column_configuration.rb +111 -0
  169. data/lib/uniword/comment.rb +147 -0
  170. data/lib/uniword/comment_range.rb +122 -0
  171. data/lib/uniword/comments_part.rb +130 -0
  172. data/lib/uniword/configuration/configuration_loader.rb +168 -0
  173. data/lib/uniword/configuration.rb +7 -0
  174. data/lib/uniword/content_types/default.rb +24 -0
  175. data/lib/uniword/content_types/override.rb +24 -0
  176. data/lib/uniword/content_types/types.rb +26 -0
  177. data/lib/uniword/content_types.rb +76 -0
  178. data/lib/uniword/customxml/custom_xml.rb +29 -0
  179. data/lib/uniword/customxml/custom_xml_attribute.rb +26 -0
  180. data/lib/uniword/customxml/custom_xml_block.rb +29 -0
  181. data/lib/uniword/customxml/custom_xml_cell.rb +29 -0
  182. data/lib/uniword/customxml/custom_xml_del_range_start.rb +26 -0
  183. data/lib/uniword/customxml/custom_xml_ins_range_end.rb +22 -0
  184. data/lib/uniword/customxml/custom_xml_ins_range_start.rb +26 -0
  185. data/lib/uniword/customxml/custom_xml_move_from_range_end.rb +22 -0
  186. data/lib/uniword/customxml/custom_xml_move_from_range_start.rb +26 -0
  187. data/lib/uniword/customxml/custom_xml_move_to_range_end.rb +22 -0
  188. data/lib/uniword/customxml/custom_xml_move_to_range_start.rb +26 -0
  189. data/lib/uniword/customxml/custom_xml_properties.rb +27 -0
  190. data/lib/uniword/customxml/custom_xml_row.rb +29 -0
  191. data/lib/uniword/customxml/custom_xml_run.rb +29 -0
  192. data/lib/uniword/customxml/data_binding.rb +26 -0
  193. data/lib/uniword/customxml/data_store_item.rb +24 -0
  194. data/lib/uniword/customxml/element_name.rb +22 -0
  195. data/lib/uniword/customxml/name.rb +22 -0
  196. data/lib/uniword/customxml/namespace_uri.rb +22 -0
  197. data/lib/uniword/customxml/placeholder.rb +22 -0
  198. data/lib/uniword/customxml/placeholder_text.rb +22 -0
  199. data/lib/uniword/customxml/prefix_mappings.rb +22 -0
  200. data/lib/uniword/customxml/schema_reference.rb +41 -0
  201. data/lib/uniword/customxml/showing_placeholder.rb +24 -0
  202. data/lib/uniword/customxml/showing_placeholder_header.rb +22 -0
  203. data/lib/uniword/customxml/smart_tag.rb +29 -0
  204. data/lib/uniword/customxml/smart_tag_attribute.rb +24 -0
  205. data/lib/uniword/customxml/smart_tag_element.rb +22 -0
  206. data/lib/uniword/customxml/smart_tag_name.rb +22 -0
  207. data/lib/uniword/customxml/smart_tag_properties.rb +23 -0
  208. data/lib/uniword/customxml/smart_tag_type.rb +26 -0
  209. data/lib/uniword/customxml/smart_tag_uri.rb +22 -0
  210. data/lib/uniword/customxml/store_item_id.rb +22 -0
  211. data/lib/uniword/customxml/x_path.rb +22 -0
  212. data/lib/uniword/customxml/x_path_expression.rb +22 -0
  213. data/lib/uniword/customxml.rb +53 -0
  214. data/lib/uniword/document_factory.rb +214 -0
  215. data/lib/uniword/document_properties/app_version.rb +22 -0
  216. data/lib/uniword/document_properties/application.rb +22 -0
  217. data/lib/uniword/document_properties/bool_value.rb +22 -0
  218. data/lib/uniword/document_properties/company.rb +22 -0
  219. data/lib/uniword/document_properties/custom_properties.rb +23 -0
  220. data/lib/uniword/document_properties/custom_property.rb +37 -0
  221. data/lib/uniword/document_properties/doc_security.rb +22 -0
  222. data/lib/uniword/document_properties/extended_properties.rb +41 -0
  223. data/lib/uniword/document_properties/file_time.rb +22 -0
  224. data/lib/uniword/document_properties/heading_pairs.rb +23 -0
  225. data/lib/uniword/document_properties/hyperlinks_changed.rb +22 -0
  226. data/lib/uniword/document_properties/i4.rb +22 -0
  227. data/lib/uniword/document_properties/links_up_to_date.rb +22 -0
  228. data/lib/uniword/document_properties/lpw_str.rb +22 -0
  229. data/lib/uniword/document_properties/manager.rb +22 -0
  230. data/lib/uniword/document_properties/scale_crop.rb +22 -0
  231. data/lib/uniword/document_properties/shared_doc.rb +22 -0
  232. data/lib/uniword/document_properties/titles_of_parts.rb +23 -0
  233. data/lib/uniword/document_properties/variant.rb +25 -0
  234. data/lib/uniword/document_properties/vector.rb +27 -0
  235. data/lib/uniword/document_properties.rb +32 -0
  236. data/lib/uniword/document_variables/data_type.rb +22 -0
  237. data/lib/uniword/document_variables/default_value.rb +22 -0
  238. data/lib/uniword/document_variables/doc_var.rb +24 -0
  239. data/lib/uniword/document_variables/doc_vars.rb +23 -0
  240. data/lib/uniword/document_variables/read_only.rb +24 -0
  241. data/lib/uniword/document_variables/variable_binding.rb +26 -0
  242. data/lib/uniword/document_variables/variable_collection.rb +25 -0
  243. data/lib/uniword/document_variables/variable_expression.rb +22 -0
  244. data/lib/uniword/document_variables/variable_format.rb +22 -0
  245. data/lib/uniword/document_variables/variable_scope.rb +22 -0
  246. data/lib/uniword/document_variables.rb +23 -0
  247. data/lib/uniword/document_writer.rb +157 -0
  248. data/lib/uniword/drawingml/adjust_value_list.rb +22 -0
  249. data/lib/uniword/drawingml/alpha.rb +22 -0
  250. data/lib/uniword/drawingml/alpha_bi_level.rb +22 -0
  251. data/lib/uniword/drawingml/alpha_modulation.rb +22 -0
  252. data/lib/uniword/drawingml/alpha_modulation_fixed.rb +22 -0
  253. data/lib/uniword/drawingml/alpha_offset.rb +22 -0
  254. data/lib/uniword/drawingml/arc_to.rb +28 -0
  255. data/lib/uniword/drawingml/background_color.rb +24 -0
  256. data/lib/uniword/drawingml/bevel_top.rb +26 -0
  257. data/lib/uniword/drawingml/bi_level.rb +22 -0
  258. data/lib/uniword/drawingml/blip.rb +30 -0
  259. data/lib/uniword/drawingml/blip_fill.rb +28 -0
  260. data/lib/uniword/drawingml/blue.rb +22 -0
  261. data/lib/uniword/drawingml/blur.rb +24 -0
  262. data/lib/uniword/drawingml/body_properties.rb +22 -0
  263. data/lib/uniword/drawingml/camera.rb +24 -0
  264. data/lib/uniword/drawingml/close_path.rb +18 -0
  265. data/lib/uniword/drawingml/color_scheme.rb +381 -0
  266. data/lib/uniword/drawingml/complex_script_font.rb +24 -0
  267. data/lib/uniword/drawingml/custom_dash.rb +22 -0
  268. data/lib/uniword/drawingml/custom_geometry.rb +24 -0
  269. data/lib/uniword/drawingml/dash_stop.rb +24 -0
  270. data/lib/uniword/drawingml/default_paragraph_properties.rb +24 -0
  271. data/lib/uniword/drawingml/duotone.rb +22 -0
  272. data/lib/uniword/drawingml/east_asian_font.rb +24 -0
  273. data/lib/uniword/drawingml/effect_container.rb +22 -0
  274. data/lib/uniword/drawingml/effect_list.rb +30 -0
  275. data/lib/uniword/drawingml/extension.rb +53 -0
  276. data/lib/uniword/drawingml/extension_list.rb +25 -0
  277. data/lib/uniword/drawingml/extents.rb +24 -0
  278. data/lib/uniword/drawingml/extra_color_scheme_list.rb +20 -0
  279. data/lib/uniword/drawingml/fill_overlay.rb +22 -0
  280. data/lib/uniword/drawingml/fill_to_rect.rb +28 -0
  281. data/lib/uniword/drawingml/font_reference.rb +23 -0
  282. data/lib/uniword/drawingml/font_scheme.rb +241 -0
  283. data/lib/uniword/drawingml/foreground_color.rb +24 -0
  284. data/lib/uniword/drawingml/format_scheme.rb +141 -0
  285. data/lib/uniword/drawingml/gamma.rb +18 -0
  286. data/lib/uniword/drawingml/geometry_guide.rb +24 -0
  287. data/lib/uniword/drawingml/glow.rb +26 -0
  288. data/lib/uniword/drawingml/gradient_fill.rb +29 -0
  289. data/lib/uniword/drawingml/gradient_stop.rb +26 -0
  290. data/lib/uniword/drawingml/gradient_stop_list.rb +23 -0
  291. data/lib/uniword/drawingml/graphic.rb +21 -0
  292. data/lib/uniword/drawingml/graphic_data.rb +27 -0
  293. data/lib/uniword/drawingml/grayscale.rb +18 -0
  294. data/lib/uniword/drawingml/green.rb +22 -0
  295. data/lib/uniword/drawingml/group_locking.rb +35 -0
  296. data/lib/uniword/drawingml/group_shape_properties.rb +21 -0
  297. data/lib/uniword/drawingml/gvml.rb +26 -0
  298. data/lib/uniword/drawingml/gvml_connector.rb +25 -0
  299. data/lib/uniword/drawingml/gvml_connector_non_visual.rb +23 -0
  300. data/lib/uniword/drawingml/gvml_graphic_frame_non_visual.rb +23 -0
  301. data/lib/uniword/drawingml/gvml_graphical_object_frame.rb +25 -0
  302. data/lib/uniword/drawingml/gvml_group_shape.rb +36 -0
  303. data/lib/uniword/drawingml/gvml_group_shape_non_visual.rb +23 -0
  304. data/lib/uniword/drawingml/gvml_picture.rb +27 -0
  305. data/lib/uniword/drawingml/gvml_picture_non_visual.rb +23 -0
  306. data/lib/uniword/drawingml/gvml_shape.rb +27 -0
  307. data/lib/uniword/drawingml/gvml_shape_non_visual.rb +23 -0
  308. data/lib/uniword/drawingml/gvml_text_shape.rb +25 -0
  309. data/lib/uniword/drawingml/gvml_use_shape_rectangle.rb +17 -0
  310. data/lib/uniword/drawingml/hue.rb +22 -0
  311. data/lib/uniword/drawingml/hue_modulation.rb +22 -0
  312. data/lib/uniword/drawingml/hue_offset.rb +22 -0
  313. data/lib/uniword/drawingml/inner_shadow.rb +30 -0
  314. data/lib/uniword/drawingml/inverse_gamma.rb +18 -0
  315. data/lib/uniword/drawingml/level1_paragraph_properties.rb +24 -0
  316. data/lib/uniword/drawingml/level2_paragraph_properties.rb +24 -0
  317. data/lib/uniword/drawingml/level3_paragraph_properties.rb +24 -0
  318. data/lib/uniword/drawingml/light_rig.rb +26 -0
  319. data/lib/uniword/drawingml/line_defaults.rb +27 -0
  320. data/lib/uniword/drawingml/line_join_miter.rb +22 -0
  321. data/lib/uniword/drawingml/line_join_round.rb +18 -0
  322. data/lib/uniword/drawingml/line_properties.rb +36 -0
  323. data/lib/uniword/drawingml/line_to.rb +22 -0
  324. data/lib/uniword/drawingml/linear_gradient.rb +24 -0
  325. data/lib/uniword/drawingml/list_style.rb +28 -0
  326. data/lib/uniword/drawingml/luminance.rb +22 -0
  327. data/lib/uniword/drawingml/luminance_modulation.rb +22 -0
  328. data/lib/uniword/drawingml/luminance_offset.rb +22 -0
  329. data/lib/uniword/drawingml/move_to.rb +22 -0
  330. data/lib/uniword/drawingml/no_fill.rb +18 -0
  331. data/lib/uniword/drawingml/non_visual_connector_properties.rb +21 -0
  332. data/lib/uniword/drawingml/non_visual_drawing_properties.rb +24 -0
  333. data/lib/uniword/drawingml/non_visual_graphic_frame_properties.rb +21 -0
  334. data/lib/uniword/drawingml/non_visual_group_drawing_shape_properties.rb +21 -0
  335. data/lib/uniword/drawingml/non_visual_picture_properties.rb +25 -0
  336. data/lib/uniword/drawingml/non_visual_shape_properties.rb +22 -0
  337. data/lib/uniword/drawingml/object_defaults.rb +23 -0
  338. data/lib/uniword/drawingml/office_art_extension.rb +21 -0
  339. data/lib/uniword/drawingml/office_art_extension_list.rb +21 -0
  340. data/lib/uniword/drawingml/offset.rb +24 -0
  341. data/lib/uniword/drawingml/outer_shadow.rb +38 -0
  342. data/lib/uniword/drawingml/path_gradient.rb +24 -0
  343. data/lib/uniword/drawingml/path_list.rb +22 -0
  344. data/lib/uniword/drawingml/pattern_fill.rb +26 -0
  345. data/lib/uniword/drawingml/picture_locking.rb +35 -0
  346. data/lib/uniword/drawingml/preset_dash.rb +22 -0
  347. data/lib/uniword/drawingml/preset_geometry.rb +24 -0
  348. data/lib/uniword/drawingml/preset_shadow.rb +26 -0
  349. data/lib/uniword/drawingml/red.rb +22 -0
  350. data/lib/uniword/drawingml/red_modulation.rb +22 -0
  351. data/lib/uniword/drawingml/red_offset.rb +22 -0
  352. data/lib/uniword/drawingml/reflection.rb +36 -0
  353. data/lib/uniword/drawingml/relative_rect.rb +27 -0
  354. data/lib/uniword/drawingml/rotation.rb +26 -0
  355. data/lib/uniword/drawingml/saturation.rb +22 -0
  356. data/lib/uniword/drawingml/saturation_modulation.rb +22 -0
  357. data/lib/uniword/drawingml/saturation_offset.rb +22 -0
  358. data/lib/uniword/drawingml/scene_3d.rb +24 -0
  359. data/lib/uniword/drawingml/scheme_color.rb +43 -0
  360. data/lib/uniword/drawingml/shade.rb +22 -0
  361. data/lib/uniword/drawingml/shape.rb +24 -0
  362. data/lib/uniword/drawingml/shape_3d.rb +28 -0
  363. data/lib/uniword/drawingml/shape_defaults.rb +27 -0
  364. data/lib/uniword/drawingml/shape_properties.rb +24 -0
  365. data/lib/uniword/drawingml/shape_style.rb +27 -0
  366. data/lib/uniword/drawingml/soft_edge.rb +22 -0
  367. data/lib/uniword/drawingml/solid_fill.rb +24 -0
  368. data/lib/uniword/drawingml/source_rect.rb +28 -0
  369. data/lib/uniword/drawingml/srgb_color.rb +43 -0
  370. data/lib/uniword/drawingml/stretch.rb +18 -0
  371. data/lib/uniword/drawingml/style_matrix.rb +27 -0
  372. data/lib/uniword/drawingml/style_matrix_reference.rb +25 -0
  373. data/lib/uniword/drawingml/style_reference.rb +23 -0
  374. data/lib/uniword/drawingml/text_body.rb +25 -0
  375. data/lib/uniword/drawingml/text_character_properties.rb +33 -0
  376. data/lib/uniword/drawingml/text_defaults.rb +27 -0
  377. data/lib/uniword/drawingml/text_font.rb +24 -0
  378. data/lib/uniword/drawingml/text_paragraph.rb +23 -0
  379. data/lib/uniword/drawingml/text_paragraph_properties.rb +26 -0
  380. data/lib/uniword/drawingml/text_run.rb +23 -0
  381. data/lib/uniword/drawingml/theme.rb +263 -0
  382. data/lib/uniword/drawingml/tile.rb +32 -0
  383. data/lib/uniword/drawingml/tile_rect.rb +28 -0
  384. data/lib/uniword/drawingml/tint.rb +22 -0
  385. data/lib/uniword/drawingml/transform2_d.rb +24 -0
  386. data/lib/uniword/drawingml.rb +190 -0
  387. data/lib/uniword/element.rb +52 -0
  388. data/lib/uniword/element_registry.rb +111 -0
  389. data/lib/uniword/endnote.rb +66 -0
  390. data/lib/uniword/errors.rb +140 -0
  391. data/lib/uniword/field.rb +76 -0
  392. data/lib/uniword/footer.rb +41 -0
  393. data/lib/uniword/footnote.rb +65 -0
  394. data/lib/uniword/format_converter.rb +350 -0
  395. data/lib/uniword/format_detector.rb +142 -0
  396. data/lib/uniword/glossary/auto_text.rb +24 -0
  397. data/lib/uniword/glossary/category_name.rb +22 -0
  398. data/lib/uniword/glossary/doc_part.rb +25 -0
  399. data/lib/uniword/glossary/doc_part_behavior.rb +22 -0
  400. data/lib/uniword/glossary/doc_part_behaviors.rb +23 -0
  401. data/lib/uniword/glossary/doc_part_body.rb +30 -0
  402. data/lib/uniword/glossary/doc_part_category.rb +25 -0
  403. data/lib/uniword/glossary/doc_part_description.rb +22 -0
  404. data/lib/uniword/glossary/doc_part_gallery.rb +22 -0
  405. data/lib/uniword/glossary/doc_part_id.rb +22 -0
  406. data/lib/uniword/glossary/doc_part_name.rb +22 -0
  407. data/lib/uniword/glossary/doc_part_properties.rb +35 -0
  408. data/lib/uniword/glossary/doc_part_type.rb +22 -0
  409. data/lib/uniword/glossary/doc_part_types.rb +25 -0
  410. data/lib/uniword/glossary/doc_parts.rb +22 -0
  411. data/lib/uniword/glossary/equation.rb +24 -0
  412. data/lib/uniword/glossary/glossary_document.rb +32 -0
  413. data/lib/uniword/glossary/style_id.rb +22 -0
  414. data/lib/uniword/glossary/text_box.rb +24 -0
  415. data/lib/uniword/glossary.rb +33 -0
  416. data/lib/uniword/header.rb +41 -0
  417. data/lib/uniword/html_importer.rb +55 -0
  418. data/lib/uniword/hyperlink.rb +76 -0
  419. data/lib/uniword/image.rb +244 -0
  420. data/lib/uniword/infrastructure/mime_packager.rb +155 -0
  421. data/lib/uniword/infrastructure/mime_parser.rb +195 -0
  422. data/lib/uniword/infrastructure/xml_namespace_normalizer.rb +105 -0
  423. data/lib/uniword/infrastructure/zip_extractor.rb +133 -0
  424. data/lib/uniword/infrastructure/zip_packager.rb +249 -0
  425. data/lib/uniword/infrastructure.rb +10 -0
  426. data/lib/uniword/lazy_loader.rb +118 -0
  427. data/lib/uniword/line_numbering.rb +129 -0
  428. data/lib/uniword/loggable.rb +57 -0
  429. data/lib/uniword/logger.rb +75 -0
  430. data/lib/uniword/math/accent.rb +25 -0
  431. data/lib/uniword/math/accent_properties.rb +25 -0
  432. data/lib/uniword/math/argument_properties.rb +22 -0
  433. data/lib/uniword/math/bar.rb +25 -0
  434. data/lib/uniword/math/bar_properties.rb +25 -0
  435. data/lib/uniword/math/begin_char.rb +22 -0
  436. data/lib/uniword/math/border_box.rb +25 -0
  437. data/lib/uniword/math/border_box_properties.rb +39 -0
  438. data/lib/uniword/math/box.rb +25 -0
  439. data/lib/uniword/math/box_properties.rb +33 -0
  440. data/lib/uniword/math/char.rb +22 -0
  441. data/lib/uniword/math/control_properties.rb +27 -0
  442. data/lib/uniword/math/degree.rb +26 -0
  443. data/lib/uniword/math/delimiter.rb +25 -0
  444. data/lib/uniword/math/delimiter_properties.rb +33 -0
  445. data/lib/uniword/math/denominator.rb +26 -0
  446. data/lib/uniword/math/element.rb +56 -0
  447. data/lib/uniword/math/end_char.rb +22 -0
  448. data/lib/uniword/math/equation_array.rb +25 -0
  449. data/lib/uniword/math/equation_array_properties.rb +33 -0
  450. data/lib/uniword/math/fraction.rb +27 -0
  451. data/lib/uniword/math/fraction_properties.rb +25 -0
  452. data/lib/uniword/math/function.rb +27 -0
  453. data/lib/uniword/math/function_name.rb +26 -0
  454. data/lib/uniword/math/function_properties.rb +23 -0
  455. data/lib/uniword/math/group_char.rb +25 -0
  456. data/lib/uniword/math/group_char_properties.rb +29 -0
  457. data/lib/uniword/math/lim.rb +26 -0
  458. data/lib/uniword/math/lower_limit.rb +27 -0
  459. data/lib/uniword/math/lower_limit_properties.rb +23 -0
  460. data/lib/uniword/math/math_break.rb +22 -0
  461. data/lib/uniword/math/math_font.rb +22 -0
  462. data/lib/uniword/math/math_properties.rb +53 -0
  463. data/lib/uniword/math/math_run.rb +42 -0
  464. data/lib/uniword/math/math_run_properties.rb +37 -0
  465. data/lib/uniword/math/math_simple_int_val.rb +24 -0
  466. data/lib/uniword/math/math_simple_val.rb +24 -0
  467. data/lib/uniword/math/math_style.rb +22 -0
  468. data/lib/uniword/math/math_text.rb +23 -0
  469. data/lib/uniword/math/matrix.rb +25 -0
  470. data/lib/uniword/math/matrix_column.rb +23 -0
  471. data/lib/uniword/math/matrix_column_properties.rb +24 -0
  472. data/lib/uniword/math/matrix_columns.rb +23 -0
  473. data/lib/uniword/math/matrix_properties.rb +37 -0
  474. data/lib/uniword/math/matrix_row.rb +23 -0
  475. data/lib/uniword/math/nary.rb +29 -0
  476. data/lib/uniword/math/nary_properties.rb +33 -0
  477. data/lib/uniword/math/numerator.rb +26 -0
  478. data/lib/uniword/math/o_math.rb +54 -0
  479. data/lib/uniword/math/o_math_para.rb +25 -0
  480. data/lib/uniword/math/o_math_para_properties.rb +22 -0
  481. data/lib/uniword/math/phantom.rb +25 -0
  482. data/lib/uniword/math/phantom_properties.rb +33 -0
  483. data/lib/uniword/math/plurimath_adapter.rb +289 -0
  484. data/lib/uniword/math/pre_sub_superscript.rb +29 -0
  485. data/lib/uniword/math/pre_sub_superscript_properties.rb +23 -0
  486. data/lib/uniword/math/radical.rb +27 -0
  487. data/lib/uniword/math/radical_properties.rb +25 -0
  488. data/lib/uniword/math/separator_char.rb +22 -0
  489. data/lib/uniword/math/sub.rb +26 -0
  490. data/lib/uniword/math/sub_superscript.rb +29 -0
  491. data/lib/uniword/math/sub_superscript_properties.rb +25 -0
  492. data/lib/uniword/math/subscript.rb +27 -0
  493. data/lib/uniword/math/subscript_properties.rb +23 -0
  494. data/lib/uniword/math/sup.rb +26 -0
  495. data/lib/uniword/math/superscript.rb +27 -0
  496. data/lib/uniword/math/superscript_properties.rb +23 -0
  497. data/lib/uniword/math/upper_limit.rb +27 -0
  498. data/lib/uniword/math/upper_limit_properties.rb +23 -0
  499. data/lib/uniword/math.rb +90 -0
  500. data/lib/uniword/math_equation.rb +158 -0
  501. data/lib/uniword/metadata/metadata.rb +345 -0
  502. data/lib/uniword/metadata/metadata_extractor.rb +403 -0
  503. data/lib/uniword/metadata/metadata_index.rb +455 -0
  504. data/lib/uniword/metadata/metadata_manager.rb +334 -0
  505. data/lib/uniword/metadata/metadata_updater.rb +243 -0
  506. data/lib/uniword/metadata/metadata_validator.rb +326 -0
  507. data/lib/uniword/metadata.rb +12 -0
  508. data/lib/uniword/mhtml/css_number_formatter.rb +127 -0
  509. data/lib/uniword/mhtml/document.rb +160 -0
  510. data/lib/uniword/mhtml/header_footer_part.rb +12 -0
  511. data/lib/uniword/mhtml/html_part.rb +108 -0
  512. data/lib/uniword/mhtml/image_part.rb +29 -0
  513. data/lib/uniword/mhtml/math_converter.rb +153 -0
  514. data/lib/uniword/mhtml/metadata/document_properties.rb +65 -0
  515. data/lib/uniword/mhtml/metadata/latent_styles.rb +33 -0
  516. data/lib/uniword/mhtml/metadata/office_document_settings.rb +22 -0
  517. data/lib/uniword/mhtml/metadata/word_document_settings.rb +47 -0
  518. data/lib/uniword/mhtml/metadata.rb +12 -0
  519. data/lib/uniword/mhtml/mhtml_package.rb +67 -0
  520. data/lib/uniword/mhtml/mime_part.rb +68 -0
  521. data/lib/uniword/mhtml/namespaces.rb +31 -0
  522. data/lib/uniword/mhtml/numbering_configuration.rb +49 -0
  523. data/lib/uniword/mhtml/styles_configuration.rb +57 -0
  524. data/lib/uniword/mhtml/theme.rb +50 -0
  525. data/lib/uniword/mhtml/theme_part.rb +19 -0
  526. data/lib/uniword/mhtml/word_css.rb +220 -0
  527. data/lib/uniword/mhtml/wordstyle.css +998 -0
  528. data/lib/uniword/mhtml/xml_part.rb +18 -0
  529. data/lib/uniword/mhtml.rb +31 -0
  530. data/lib/uniword/office/bottom.rb +22 -0
  531. data/lib/uniword/office/brightness.rb +22 -0
  532. data/lib/uniword/office/button.rb +26 -0
  533. data/lib/uniword/office/callout.rb +36 -0
  534. data/lib/uniword/office/callout_anchor.rb +22 -0
  535. data/lib/uniword/office/checkbox.rb +24 -0
  536. data/lib/uniword/office/color_menu.rb +24 -0
  537. data/lib/uniword/office/color_mru.rb +24 -0
  538. data/lib/uniword/office/complex.rb +22 -0
  539. data/lib/uniword/office/diagram.rb +36 -0
  540. data/lib/uniword/office/diffusity.rb +22 -0
  541. data/lib/uniword/office/document_protection.rb +26 -0
  542. data/lib/uniword/office/document_view.rb +22 -0
  543. data/lib/uniword/office/edge.rb +24 -0
  544. data/lib/uniword/office/extrusion.rb +54 -0
  545. data/lib/uniword/office/extrusion_color.rb +24 -0
  546. data/lib/uniword/office/extrusion_color_mode.rb +22 -0
  547. data/lib/uniword/office/extrusion_ok.rb +22 -0
  548. data/lib/uniword/office/field.rb +24 -0
  549. data/lib/uniword/office/forms.rb +22 -0
  550. data/lib/uniword/office/id_map.rb +24 -0
  551. data/lib/uniword/office/ink.rb +24 -0
  552. data/lib/uniword/office/ink_annotation.rb +24 -0
  553. data/lib/uniword/office/left.rb +22 -0
  554. data/lib/uniword/office/lock.rb +30 -0
  555. data/lib/uniword/office/metal.rb +22 -0
  556. data/lib/uniword/office/proof_state.rb +24 -0
  557. data/lib/uniword/office/regroup.rb +22 -0
  558. data/lib/uniword/office/regroup_table.rb +22 -0
  559. data/lib/uniword/office/relation_table.rb +22 -0
  560. data/lib/uniword/office/right.rb +22 -0
  561. data/lib/uniword/office/rules.rb +22 -0
  562. data/lib/uniword/office/shape_defaults.rb +29 -0
  563. data/lib/uniword/office/shape_layout.rb +25 -0
  564. data/lib/uniword/office/signature_line.rb +40 -0
  565. data/lib/uniword/office/skew.rb +28 -0
  566. data/lib/uniword/office/specularity.rb +22 -0
  567. data/lib/uniword/office/top.rb +22 -0
  568. data/lib/uniword/office/writing_style.rb +28 -0
  569. data/lib/uniword/office/zoom.rb +22 -0
  570. data/lib/uniword/office.rb +57 -0
  571. data/lib/uniword/ooxml/additional_characteristics.rb +43 -0
  572. data/lib/uniword/ooxml/app_properties.rb +130 -0
  573. data/lib/uniword/ooxml/core_properties.rb +69 -0
  574. data/lib/uniword/ooxml/custom_properties.rb +132 -0
  575. data/lib/uniword/ooxml/docx_package.rb +989 -0
  576. data/lib/uniword/ooxml/dotx_package.rb +247 -0
  577. data/lib/uniword/ooxml/namespaces.rb +363 -0
  578. data/lib/uniword/ooxml/package_file.rb +227 -0
  579. data/lib/uniword/ooxml/relationships/hyperlink_relationship.rb +24 -0
  580. data/lib/uniword/ooxml/relationships/image_relationship.rb +22 -0
  581. data/lib/uniword/ooxml/relationships/office_document_relationship.rb +24 -0
  582. data/lib/uniword/ooxml/relationships/package_relationship.rb +29 -0
  583. data/lib/uniword/ooxml/relationships/package_relationships.rb +51 -0
  584. data/lib/uniword/ooxml/relationships/relationship.rb +30 -0
  585. data/lib/uniword/ooxml/relationships/relationships.rb +43 -0
  586. data/lib/uniword/ooxml/relationships.rb +24 -0
  587. data/lib/uniword/ooxml/schema/attribute_definition.rb +159 -0
  588. data/lib/uniword/ooxml/schema/child_definition.rb +125 -0
  589. data/lib/uniword/ooxml/schema/element_definition.rb +155 -0
  590. data/lib/uniword/ooxml/schema/element_serializer.rb +319 -0
  591. data/lib/uniword/ooxml/schema/ooxml_schema.rb +226 -0
  592. data/lib/uniword/ooxml/schema.rb +16 -0
  593. data/lib/uniword/ooxml/schema_library.rb +38 -0
  594. data/lib/uniword/ooxml/styleset_package.rb +122 -0
  595. data/lib/uniword/ooxml/theme_package.rb +222 -0
  596. data/lib/uniword/ooxml/thmx_package.rb +127 -0
  597. data/lib/uniword/ooxml/types/cp_description_type.rb +17 -0
  598. data/lib/uniword/ooxml/types/cp_keywords_type.rb +17 -0
  599. data/lib/uniword/ooxml/types/cp_last_modified_by_type.rb +17 -0
  600. data/lib/uniword/ooxml/types/cp_revision_type.rb +17 -0
  601. data/lib/uniword/ooxml/types/dc_creator_type.rb +17 -0
  602. data/lib/uniword/ooxml/types/dc_subject_type.rb +17 -0
  603. data/lib/uniword/ooxml/types/dc_title_type.rb +17 -0
  604. data/lib/uniword/ooxml/types/dcterms_created_type.rb +24 -0
  605. data/lib/uniword/ooxml/types/dcterms_modified_type.rb +24 -0
  606. data/lib/uniword/ooxml/types/dcterms_w3cdtf_type.rb +49 -0
  607. data/lib/uniword/ooxml/types/mc_ignorable_type.rb +18 -0
  608. data/lib/uniword/ooxml/types/on_off_type.rb +64 -0
  609. data/lib/uniword/ooxml/types/ooxml_boolean.rb +49 -0
  610. data/lib/uniword/ooxml/types/ooxml_boolean_optional.rb +57 -0
  611. data/lib/uniword/ooxml/types/variant_types.rb +308 -0
  612. data/lib/uniword/ooxml/types.rb +76 -0
  613. data/lib/uniword/ooxml.rb +40 -0
  614. data/lib/uniword/page_borders.rb +117 -0
  615. data/lib/uniword/paragraph_border.rb +113 -0
  616. data/lib/uniword/picture/fill_rect.rb +28 -0
  617. data/lib/uniword/picture/non_visual_picture_drawing_properties.rb +25 -0
  618. data/lib/uniword/picture/non_visual_picture_properties.rb +25 -0
  619. data/lib/uniword/picture/picture.rb +27 -0
  620. data/lib/uniword/picture/picture_blip_fill.rb +27 -0
  621. data/lib/uniword/picture/picture_locks.rb +24 -0
  622. data/lib/uniword/picture/picture_shape_properties.rb +27 -0
  623. data/lib/uniword/picture/picture_source_rect.rb +28 -0
  624. data/lib/uniword/picture/picture_stretch.rb +23 -0
  625. data/lib/uniword/picture/tile.rb +30 -0
  626. data/lib/uniword/picture.rb +25 -0
  627. data/lib/uniword/presentationml/audio.rb +26 -0
  628. data/lib/uniword/presentationml/body_properties.rb +30 -0
  629. data/lib/uniword/presentationml/break.rb +22 -0
  630. data/lib/uniword/presentationml/color_map.rb +28 -0
  631. data/lib/uniword/presentationml/common_slide_data.rb +27 -0
  632. data/lib/uniword/presentationml/common_time_node.rb +33 -0
  633. data/lib/uniword/presentationml/connection_shape.rb +25 -0
  634. data/lib/uniword/presentationml/embed.rb +22 -0
  635. data/lib/uniword/presentationml/embedded_font.rb +24 -0
  636. data/lib/uniword/presentationml/end_conditions_list.rb +23 -0
  637. data/lib/uniword/presentationml/end_paragraph_run_properties.rb +26 -0
  638. data/lib/uniword/presentationml/extension.rb +22 -0
  639. data/lib/uniword/presentationml/extension_list.rb +23 -0
  640. data/lib/uniword/presentationml/field.rb +31 -0
  641. data/lib/uniword/presentationml/graphic_frame.rb +27 -0
  642. data/lib/uniword/presentationml/group_shape.rb +29 -0
  643. data/lib/uniword/presentationml/handout_master.rb +25 -0
  644. data/lib/uniword/presentationml/handout_master_id_list.rb +22 -0
  645. data/lib/uniword/presentationml/list_style.rb +29 -0
  646. data/lib/uniword/presentationml/non_visual_shape_properties.rb +27 -0
  647. data/lib/uniword/presentationml/notes.rb +27 -0
  648. data/lib/uniword/presentationml/notes_master_id_list.rb +22 -0
  649. data/lib/uniword/presentationml/notes_size.rb +24 -0
  650. data/lib/uniword/presentationml/ole_object.rb +26 -0
  651. data/lib/uniword/presentationml/paragraph.rb +31 -0
  652. data/lib/uniword/presentationml/paragraph_properties.rb +30 -0
  653. data/lib/uniword/presentationml/parallel_time_node.rb +23 -0
  654. data/lib/uniword/presentationml/picture.rb +27 -0
  655. data/lib/uniword/presentationml/presentation.rb +39 -0
  656. data/lib/uniword/presentationml/run.rb +25 -0
  657. data/lib/uniword/presentationml/run_properties.rb +34 -0
  658. data/lib/uniword/presentationml/sequence_time_node.rb +27 -0
  659. data/lib/uniword/presentationml/shape.rb +27 -0
  660. data/lib/uniword/presentationml/shape_properties.rb +31 -0
  661. data/lib/uniword/presentationml/shape_tree.rb +35 -0
  662. data/lib/uniword/presentationml/slide.rb +33 -0
  663. data/lib/uniword/presentationml/slide_id.rb +24 -0
  664. data/lib/uniword/presentationml/slide_id_list.rb +23 -0
  665. data/lib/uniword/presentationml/slide_layout.rb +33 -0
  666. data/lib/uniword/presentationml/slide_master.rb +33 -0
  667. data/lib/uniword/presentationml/slide_master_id.rb +24 -0
  668. data/lib/uniword/presentationml/slide_master_id_list.rb +23 -0
  669. data/lib/uniword/presentationml/slide_size.rb +26 -0
  670. data/lib/uniword/presentationml/start_conditions_list.rb +23 -0
  671. data/lib/uniword/presentationml/text_body.rb +27 -0
  672. data/lib/uniword/presentationml/time_node_list.rb +25 -0
  673. data/lib/uniword/presentationml/timing.rb +25 -0
  674. data/lib/uniword/presentationml/transition.rb +33 -0
  675. data/lib/uniword/presentationml/video.rb +24 -0
  676. data/lib/uniword/presentationml.rb +67 -0
  677. data/lib/uniword/properties/alignment.rb +26 -0
  678. data/lib/uniword/properties/bold.rb +40 -0
  679. data/lib/uniword/properties/boolean_formatting.rb +214 -0
  680. data/lib/uniword/properties/border.rb +48 -0
  681. data/lib/uniword/properties/borders.rb +39 -0
  682. data/lib/uniword/properties/cell_vertical_align.rb +32 -0
  683. data/lib/uniword/properties/cell_width.rb +28 -0
  684. data/lib/uniword/properties/character_spacing.rb +34 -0
  685. data/lib/uniword/properties/color_value.rb +57 -0
  686. data/lib/uniword/properties/contextual_spacing.rb +32 -0
  687. data/lib/uniword/properties/emphasis_mark.rb +35 -0
  688. data/lib/uniword/properties/font_size.rb +26 -0
  689. data/lib/uniword/properties/highlight.rb +28 -0
  690. data/lib/uniword/properties/indentation.rb +28 -0
  691. data/lib/uniword/properties/italic.rb +40 -0
  692. data/lib/uniword/properties/kerning.rb +34 -0
  693. data/lib/uniword/properties/language.rb +39 -0
  694. data/lib/uniword/properties/margin.rb +22 -0
  695. data/lib/uniword/properties/numbering_id.rb +26 -0
  696. data/lib/uniword/properties/numbering_level.rb +26 -0
  697. data/lib/uniword/properties/numbering_properties.rb +25 -0
  698. data/lib/uniword/properties/outline.rb +33 -0
  699. data/lib/uniword/properties/outline_level.rb +26 -0
  700. data/lib/uniword/properties/position.rb +33 -0
  701. data/lib/uniword/properties/run_fonts.rb +38 -0
  702. data/lib/uniword/properties/shading.rb +41 -0
  703. data/lib/uniword/properties/spacing.rb +28 -0
  704. data/lib/uniword/properties/style_reference.rb +81 -0
  705. data/lib/uniword/properties/tab_stop.rb +45 -0
  706. data/lib/uniword/properties/table_cell_margin.rb +33 -0
  707. data/lib/uniword/properties/table_indent.rb +23 -0
  708. data/lib/uniword/properties/table_justification.rb +22 -0
  709. data/lib/uniword/properties/table_look.rb +36 -0
  710. data/lib/uniword/properties/table_width.rb +28 -0
  711. data/lib/uniword/properties/tabs.rb +64 -0
  712. data/lib/uniword/properties/text_fill.rb +38 -0
  713. data/lib/uniword/properties/text_outline.rb +34 -0
  714. data/lib/uniword/properties/underline.rb +32 -0
  715. data/lib/uniword/properties/vertical_align.rb +26 -0
  716. data/lib/uniword/properties/width_scale.rb +34 -0
  717. data/lib/uniword/properties.rb +71 -0
  718. data/lib/uniword/quality/document_checker.rb +150 -0
  719. data/lib/uniword/quality/quality_report.rb +317 -0
  720. data/lib/uniword/quality/quality_rule.rb +153 -0
  721. data/lib/uniword/quality/rules/heading_hierarchy_rule.rb +83 -0
  722. data/lib/uniword/quality/rules/image_alt_text_rule.rb +87 -0
  723. data/lib/uniword/quality/rules/link_validation_rule.rb +136 -0
  724. data/lib/uniword/quality/rules/paragraph_length_rule.rb +77 -0
  725. data/lib/uniword/quality/rules/style_consistency_rule.rb +116 -0
  726. data/lib/uniword/quality/rules/table_header_rule.rb +69 -0
  727. data/lib/uniword/quality.rb +16 -0
  728. data/lib/uniword/resource/cache.rb +82 -0
  729. data/lib/uniword/resource/cache_paths.rb +29 -0
  730. data/lib/uniword/resource/cache_version.rb +49 -0
  731. data/lib/uniword/resource/color_transformer.rb +134 -0
  732. data/lib/uniword/resource/font_substitutor.rb +60 -0
  733. data/lib/uniword/resource/importer.rb +114 -0
  734. data/lib/uniword/resource/resource_location.rb +35 -0
  735. data/lib/uniword/resource/resource_resolver.rb +100 -0
  736. data/lib/uniword/resource/theme_processor.rb +107 -0
  737. data/lib/uniword/resource.rb +19 -0
  738. data/lib/uniword/revision.rb +200 -0
  739. data/lib/uniword/schema/model_generator.rb +182 -0
  740. data/lib/uniword/schema/schema_loader.rb +90 -0
  741. data/lib/uniword/schema.rb +8 -0
  742. data/lib/uniword/section.rb +183 -0
  743. data/lib/uniword/section_properties.rb +180 -0
  744. data/lib/uniword/serialization/ooxml_serializer.rb +30 -0
  745. data/lib/uniword/shading.rb +109 -0
  746. data/lib/uniword/shared_types/angle.rb +22 -0
  747. data/lib/uniword/shared_types/boolean_value.rb +24 -0
  748. data/lib/uniword/shared_types/decimal_number.rb +22 -0
  749. data/lib/uniword/shared_types/emu_measure.rb +22 -0
  750. data/lib/uniword/shared_types/fixed_percentage.rb +22 -0
  751. data/lib/uniword/shared_types/hex_color.rb +22 -0
  752. data/lib/uniword/shared_types/on_off.rb +24 -0
  753. data/lib/uniword/shared_types/percent_value.rb +22 -0
  754. data/lib/uniword/shared_types/pixel_measure.rb +22 -0
  755. data/lib/uniword/shared_types/point_measure.rb +22 -0
  756. data/lib/uniword/shared_types/positive_percentage.rb +22 -0
  757. data/lib/uniword/shared_types/string_type.rb +22 -0
  758. data/lib/uniword/shared_types/text_alignment.rb +22 -0
  759. data/lib/uniword/shared_types/twips_measure.rb +22 -0
  760. data/lib/uniword/shared_types/vertical_alignment.rb +22 -0
  761. data/lib/uniword/shared_types.rb +31 -0
  762. data/lib/uniword/spreadsheetml/alignment.rb +32 -0
  763. data/lib/uniword/spreadsheetml/authors.rb +23 -0
  764. data/lib/uniword/spreadsheetml/auto_filter.rb +25 -0
  765. data/lib/uniword/spreadsheetml/bold.rb +22 -0
  766. data/lib/uniword/spreadsheetml/book_views.rb +23 -0
  767. data/lib/uniword/spreadsheetml/border.rb +31 -0
  768. data/lib/uniword/spreadsheetml/borders.rb +25 -0
  769. data/lib/uniword/spreadsheetml/calc_properties.rb +26 -0
  770. data/lib/uniword/spreadsheetml/cell.rb +31 -0
  771. data/lib/uniword/spreadsheetml/cell_format.rb +41 -0
  772. data/lib/uniword/spreadsheetml/cell_formats.rb +25 -0
  773. data/lib/uniword/spreadsheetml/cell_formula.rb +28 -0
  774. data/lib/uniword/spreadsheetml/cell_style.rb +31 -0
  775. data/lib/uniword/spreadsheetml/cell_style_xfs.rb +23 -0
  776. data/lib/uniword/spreadsheetml/cell_styles.rb +23 -0
  777. data/lib/uniword/spreadsheetml/cell_value.rb +22 -0
  778. data/lib/uniword/spreadsheetml/chartsheet.rb +25 -0
  779. data/lib/uniword/spreadsheetml/col.rb +32 -0
  780. data/lib/uniword/spreadsheetml/col_breaks.rb +25 -0
  781. data/lib/uniword/spreadsheetml/color.rb +28 -0
  782. data/lib/uniword/spreadsheetml/color_filter.rb +23 -0
  783. data/lib/uniword/spreadsheetml/colors.rb +21 -0
  784. data/lib/uniword/spreadsheetml/cols.rb +23 -0
  785. data/lib/uniword/spreadsheetml/comment.rb +27 -0
  786. data/lib/uniword/spreadsheetml/comment_list.rb +23 -0
  787. data/lib/uniword/spreadsheetml/comments.rb +25 -0
  788. data/lib/uniword/spreadsheetml/conditional_formatting.rb +25 -0
  789. data/lib/uniword/spreadsheetml/conditional_formatting_rule.rb +27 -0
  790. data/lib/uniword/spreadsheetml/custom_filter.rb +23 -0
  791. data/lib/uniword/spreadsheetml/custom_filters.rb +23 -0
  792. data/lib/uniword/spreadsheetml/custom_workbook_views.rb +23 -0
  793. data/lib/uniword/spreadsheetml/data_validation.rb +43 -0
  794. data/lib/uniword/spreadsheetml/data_validations.rb +25 -0
  795. data/lib/uniword/spreadsheetml/date_group_item.rb +33 -0
  796. data/lib/uniword/spreadsheetml/defined_name.rb +28 -0
  797. data/lib/uniword/spreadsheetml/defined_names.rb +23 -0
  798. data/lib/uniword/spreadsheetml/dimension.rb +22 -0
  799. data/lib/uniword/spreadsheetml/drawing.rb +22 -0
  800. data/lib/uniword/spreadsheetml/dynamic_filter.rb +25 -0
  801. data/lib/uniword/spreadsheetml/external_reference.rb +21 -0
  802. data/lib/uniword/spreadsheetml/external_references.rb +23 -0
  803. data/lib/uniword/spreadsheetml/file_sharing.rb +22 -0
  804. data/lib/uniword/spreadsheetml/file_version.rb +24 -0
  805. data/lib/uniword/spreadsheetml/fill.rb +23 -0
  806. data/lib/uniword/spreadsheetml/fills.rb +25 -0
  807. data/lib/uniword/spreadsheetml/filter.rb +21 -0
  808. data/lib/uniword/spreadsheetml/filter_column.rb +37 -0
  809. data/lib/uniword/spreadsheetml/filters.rb +27 -0
  810. data/lib/uniword/spreadsheetml/font.rb +31 -0
  811. data/lib/uniword/spreadsheetml/font_name.rb +22 -0
  812. data/lib/uniword/spreadsheetml/font_size.rb +22 -0
  813. data/lib/uniword/spreadsheetml/fonts.rb +25 -0
  814. data/lib/uniword/spreadsheetml/hyperlink.rb +30 -0
  815. data/lib/uniword/spreadsheetml/hyperlinks.rb +23 -0
  816. data/lib/uniword/spreadsheetml/icon_filter.rb +23 -0
  817. data/lib/uniword/spreadsheetml/italic.rb +22 -0
  818. data/lib/uniword/spreadsheetml/legacy_drawing.rb +22 -0
  819. data/lib/uniword/spreadsheetml/merge_cell.rb +22 -0
  820. data/lib/uniword/spreadsheetml/merge_cells.rb +25 -0
  821. data/lib/uniword/spreadsheetml/number_format.rb +24 -0
  822. data/lib/uniword/spreadsheetml/number_formats.rb +25 -0
  823. data/lib/uniword/spreadsheetml/ole_object.rb +24 -0
  824. data/lib/uniword/spreadsheetml/ole_objects.rb +23 -0
  825. data/lib/uniword/spreadsheetml/ole_size.rb +21 -0
  826. data/lib/uniword/spreadsheetml/pattern_fill.rb +27 -0
  827. data/lib/uniword/spreadsheetml/phonetic_pr.rb +35 -0
  828. data/lib/uniword/spreadsheetml/phonetic_properties.rb +24 -0
  829. data/lib/uniword/spreadsheetml/pivot_caches.rb +23 -0
  830. data/lib/uniword/spreadsheetml/pivot_table.rb +24 -0
  831. data/lib/uniword/spreadsheetml/pivot_table_definition.rb +26 -0
  832. data/lib/uniword/spreadsheetml/protected_ranges.rb +23 -0
  833. data/lib/uniword/spreadsheetml/query_table.rb +24 -0
  834. data/lib/uniword/spreadsheetml/rich_text_run.rb +25 -0
  835. data/lib/uniword/spreadsheetml/row.rb +33 -0
  836. data/lib/uniword/spreadsheetml/row_breaks.rb +25 -0
  837. data/lib/uniword/spreadsheetml/run_properties.rb +29 -0
  838. data/lib/uniword/spreadsheetml/scenarios.rb +27 -0
  839. data/lib/uniword/spreadsheetml/shared_string_table.rb +27 -0
  840. data/lib/uniword/spreadsheetml/sheet.rb +28 -0
  841. data/lib/uniword/spreadsheetml/sheet_data.rb +23 -0
  842. data/lib/uniword/spreadsheetml/sheet_format_pr.rb +33 -0
  843. data/lib/uniword/spreadsheetml/sheet_protection.rb +28 -0
  844. data/lib/uniword/spreadsheetml/sheet_view.rb +30 -0
  845. data/lib/uniword/spreadsheetml/sheet_views.rb +23 -0
  846. data/lib/uniword/spreadsheetml/sheets.rb +23 -0
  847. data/lib/uniword/spreadsheetml/sort_condition.rb +33 -0
  848. data/lib/uniword/spreadsheetml/sort_state.rb +23 -0
  849. data/lib/uniword/spreadsheetml/sparkline_group.rb +24 -0
  850. data/lib/uniword/spreadsheetml/sparkline_groups.rb +23 -0
  851. data/lib/uniword/spreadsheetml/string_item.rb +27 -0
  852. data/lib/uniword/spreadsheetml/table.rb +35 -0
  853. data/lib/uniword/spreadsheetml/table_column.rb +24 -0
  854. data/lib/uniword/spreadsheetml/table_columns.rb +25 -0
  855. data/lib/uniword/spreadsheetml/table_formula.rb +23 -0
  856. data/lib/uniword/spreadsheetml/table_parts.rb +23 -0
  857. data/lib/uniword/spreadsheetml/table_style_info.rb +30 -0
  858. data/lib/uniword/spreadsheetml/table_styles.rb +23 -0
  859. data/lib/uniword/spreadsheetml/text.rb +24 -0
  860. data/lib/uniword/spreadsheetml/top10.rb +27 -0
  861. data/lib/uniword/spreadsheetml/workbook.rb +31 -0
  862. data/lib/uniword/spreadsheetml/workbook_properties.rb +26 -0
  863. data/lib/uniword/spreadsheetml/workbook_protection.rb +24 -0
  864. data/lib/uniword/spreadsheetml/workbook_view.rb +26 -0
  865. data/lib/uniword/spreadsheetml/worksheet/sheet_format_pr.rb +35 -0
  866. data/lib/uniword/spreadsheetml/worksheet.rb +33 -0
  867. data/lib/uniword/spreadsheetml.rb +121 -0
  868. data/lib/uniword/streaming_parser.rb +277 -0
  869. data/lib/uniword/styles.rb +14 -0
  870. data/lib/uniword/styleset.rb +166 -0
  871. data/lib/uniword/stylesets/package.rb +107 -0
  872. data/lib/uniword/stylesets/styleset_importer.rb +96 -0
  873. data/lib/uniword/stylesets/yaml_styleset_loader.rb +58 -0
  874. data/lib/uniword/stylesets.rb +9 -0
  875. data/lib/uniword/tab_stop.rb +85 -0
  876. data/lib/uniword/table_border.rb +87 -0
  877. data/lib/uniword/template/helpers/conditional_helper.rb +107 -0
  878. data/lib/uniword/template/helpers/filter_helper.rb +124 -0
  879. data/lib/uniword/template/helpers/loop_helper.rb +119 -0
  880. data/lib/uniword/template/helpers/variable_helper.rb +85 -0
  881. data/lib/uniword/template/helpers.rb +12 -0
  882. data/lib/uniword/template/template.rb +147 -0
  883. data/lib/uniword/template/template_context.rb +103 -0
  884. data/lib/uniword/template/template_marker.rb +121 -0
  885. data/lib/uniword/template/template_parser.rb +186 -0
  886. data/lib/uniword/template/template_renderer.rb +204 -0
  887. data/lib/uniword/template/template_validator.rb +202 -0
  888. data/lib/uniword/template/variable_resolver.rb +195 -0
  889. data/lib/uniword/template.rb +14 -0
  890. data/lib/uniword/text_box.rb +55 -0
  891. data/lib/uniword/text_frame.rb +168 -0
  892. data/lib/uniword/theme/media_file.rb +128 -0
  893. data/lib/uniword/theme/theme_applicator.rb +141 -0
  894. data/lib/uniword/theme/theme_loader.rb +107 -0
  895. data/lib/uniword/theme/theme_package_reader.rb +102 -0
  896. data/lib/uniword/theme/theme_variant.rb +87 -0
  897. data/lib/uniword/theme/theme_xml_parser.rb +239 -0
  898. data/lib/uniword/theme_writer.rb +58 -0
  899. data/lib/uniword/themes/theme.rb +159 -0
  900. data/lib/uniword/themes/theme_importer.rb +138 -0
  901. data/lib/uniword/themes/theme_transformation.rb +202 -0
  902. data/lib/uniword/themes.rb +23 -0
  903. data/lib/uniword/tracked_changes.rb +231 -0
  904. data/lib/uniword/transformation/html_to_ooxml_converter.rb +541 -0
  905. data/lib/uniword/transformation/hyperlink_transformation_rule.rb +72 -0
  906. data/lib/uniword/transformation/image_transformation_rule.rb +69 -0
  907. data/lib/uniword/transformation/ooxml_to_html_converter.rb +172 -0
  908. data/lib/uniword/transformation/ooxml_to_mhtml_converter.rb +1406 -0
  909. data/lib/uniword/transformation/paragraph_transformation_rule.rb +166 -0
  910. data/lib/uniword/transformation/run_transformation_rule.rb +76 -0
  911. data/lib/uniword/transformation/table_transformation_rule.rb +120 -0
  912. data/lib/uniword/transformation/transformation_rule.rb +91 -0
  913. data/lib/uniword/transformation/transformation_rule_registry.rb +133 -0
  914. data/lib/uniword/transformation/transformer.rb +386 -0
  915. data/lib/uniword/transformation.rb +18 -0
  916. data/lib/uniword/validation/checkers/external_link_checker.rb +200 -0
  917. data/lib/uniword/validation/checkers/file_reference_checker.rb +196 -0
  918. data/lib/uniword/validation/checkers/footnote_reference_checker.rb +178 -0
  919. data/lib/uniword/validation/checkers/internal_link_checker.rb +181 -0
  920. data/lib/uniword/validation/checkers.rb +12 -0
  921. data/lib/uniword/validation/document_validator.rb +272 -0
  922. data/lib/uniword/validation/layer_validation_result.rb +157 -0
  923. data/lib/uniword/validation/layer_validator.rb +104 -0
  924. data/lib/uniword/validation/link_checker.rb +94 -0
  925. data/lib/uniword/validation/link_validator.rb +318 -0
  926. data/lib/uniword/validation/validation_report.rb +409 -0
  927. data/lib/uniword/validation/validation_result.rb +215 -0
  928. data/lib/uniword/validation/validators/content_type_validator.rb +159 -0
  929. data/lib/uniword/validation/validators/document_semantics_validator.rb +152 -0
  930. data/lib/uniword/validation/validators/file_structure_validator.rb +101 -0
  931. data/lib/uniword/validation/validators/ooxml_part_validator.rb +128 -0
  932. data/lib/uniword/validation/validators/relationship_validator.rb +146 -0
  933. data/lib/uniword/validation/validators/xml_schema_validator.rb +120 -0
  934. data/lib/uniword/validation/validators/zip_integrity_validator.rb +110 -0
  935. data/lib/uniword/validation/validators.rb +15 -0
  936. data/lib/uniword/validation.rb +15 -0
  937. data/lib/uniword/validators/element_validator.rb +97 -0
  938. data/lib/uniword/validators/paragraph_validator.rb +122 -0
  939. data/lib/uniword/validators/table_validator.rb +140 -0
  940. data/lib/uniword/validators.rb +9 -0
  941. data/lib/uniword/version.rb +5 -0
  942. data/lib/uniword/visitor/base_visitor.rb +81 -0
  943. data/lib/uniword/visitor/text_extractor.rb +119 -0
  944. data/lib/uniword/visitor.rb +8 -0
  945. data/lib/uniword/vml/arc.rb +41 -0
  946. data/lib/uniword/vml/background.rb +33 -0
  947. data/lib/uniword/vml/curve.rb +36 -0
  948. data/lib/uniword/vml/fill.rb +32 -0
  949. data/lib/uniword/vml/formula.rb +23 -0
  950. data/lib/uniword/vml/formulas.rb +24 -0
  951. data/lib/uniword/vml/group.rb +30 -0
  952. data/lib/uniword/vml/handle.rb +39 -0
  953. data/lib/uniword/vml/handles.rb +24 -0
  954. data/lib/uniword/vml/image.rb +47 -0
  955. data/lib/uniword/vml/imagedata.rb +34 -0
  956. data/lib/uniword/vml/line.rb +34 -0
  957. data/lib/uniword/vml/oval.rb +34 -0
  958. data/lib/uniword/vml/path.rb +28 -0
  959. data/lib/uniword/vml/polyline.rb +32 -0
  960. data/lib/uniword/vml/rect.rb +34 -0
  961. data/lib/uniword/vml/roundrect.rb +39 -0
  962. data/lib/uniword/vml/shadow.rb +33 -0
  963. data/lib/uniword/vml/shape.rb +73 -0
  964. data/lib/uniword/vml/shapetype.rb +32 -0
  965. data/lib/uniword/vml/stroke.rb +34 -0
  966. data/lib/uniword/vml/textbox.rb +28 -0
  967. data/lib/uniword/vml/textpath.rb +25 -0
  968. data/lib/uniword/vml/wrap.rb +24 -0
  969. data/lib/uniword/vml.rb +39 -0
  970. data/lib/uniword/vml_office/vml_anchor_lock.rb +22 -0
  971. data/lib/uniword/vml_office/vml_bottom.rb +24 -0
  972. data/lib/uniword/vml_office/vml_callout.rb +35 -0
  973. data/lib/uniword/vml_office/vml_clip_path.rb +24 -0
  974. data/lib/uniword/vml_office/vml_color_mru.rb +24 -0
  975. data/lib/uniword/vml_office/vml_column.rb +24 -0
  976. data/lib/uniword/vml_office/vml_complex.rb +22 -0
  977. data/lib/uniword/vml_office/vml_complex_extension.rb +24 -0
  978. data/lib/uniword/vml_office/vml_diagram.rb +32 -0
  979. data/lib/uniword/vml_office/vml_entry.rb +24 -0
  980. data/lib/uniword/vml_office/vml_extrusion.rb +43 -0
  981. data/lib/uniword/vml_office/vml_id_map.rb +24 -0
  982. data/lib/uniword/vml_office/vml_ink.rb +26 -0
  983. data/lib/uniword/vml_office/vml_left.rb +24 -0
  984. data/lib/uniword/vml_office/vml_lock.rb +37 -0
  985. data/lib/uniword/vml_office/vml_office_fill.rb +32 -0
  986. data/lib/uniword/vml_office/vml_proxy.rb +28 -0
  987. data/lib/uniword/vml_office/vml_regroup.rb +22 -0
  988. data/lib/uniword/vml_office/vml_relation_table.rb +24 -0
  989. data/lib/uniword/vml_office/vml_right.rb +24 -0
  990. data/lib/uniword/vml_office/vml_rule.rb +26 -0
  991. data/lib/uniword/vml_office/vml_rules.rb +24 -0
  992. data/lib/uniword/vml_office/vml_shape_defaults.rb +53 -0
  993. data/lib/uniword/vml_office/vml_shape_layout.rb +70 -0
  994. data/lib/uniword/vml_office/vml_signature_line.rb +38 -0
  995. data/lib/uniword/vml_office/vml_skew.rb +29 -0
  996. data/lib/uniword/vml_office/vml_top.rb +24 -0
  997. data/lib/uniword/vml_office/vml_wrap_block.rb +24 -0
  998. data/lib/uniword/vml_office/vml_wrap_coords.rb +22 -0
  999. data/lib/uniword/vml_office.rb +47 -0
  1000. data/lib/uniword/vml_word/border_bottom.rb +29 -0
  1001. data/lib/uniword/vml_word/border_left.rb +29 -0
  1002. data/lib/uniword/vml_word/border_right.rb +29 -0
  1003. data/lib/uniword/vml_word/border_top.rb +29 -0
  1004. data/lib/uniword/vml_word.rb +17 -0
  1005. data/lib/uniword/warnings/warning.rb +130 -0
  1006. data/lib/uniword/warnings/warning_collector.rb +229 -0
  1007. data/lib/uniword/warnings/warning_report.rb +159 -0
  1008. data/lib/uniword/warnings.rb +9 -0
  1009. data/lib/uniword/word2010_ext/wrap.rb +26 -0
  1010. data/lib/uniword/word2010_ext.rb +14 -0
  1011. data/lib/uniword/word_implementation.rb +58 -0
  1012. data/lib/uniword/word_implementation_factory.rb +15 -0
  1013. data/lib/uniword/word_implementation_linux.rb +42 -0
  1014. data/lib/uniword/word_implementation_macos.rb +41 -0
  1015. data/lib/uniword/word_implementation_null.rb +34 -0
  1016. data/lib/uniword/word_implementation_windows.rb +75 -0
  1017. data/lib/uniword/wordprocessing_group.rb +29 -0
  1018. data/lib/uniword/wordprocessing_shape.rb +48 -0
  1019. data/lib/uniword/wordprocessingml/abstract_num.rb +27 -0
  1020. data/lib/uniword/wordprocessingml/abstract_num_id.rb +22 -0
  1021. data/lib/uniword/wordprocessingml/alternate_content.rb +24 -0
  1022. data/lib/uniword/wordprocessingml/anchor.rb +35 -0
  1023. data/lib/uniword/wordprocessingml/based_on.rb +22 -0
  1024. data/lib/uniword/wordprocessingml/body.rb +95 -0
  1025. data/lib/uniword/wordprocessingml/bookmark_end.rb +22 -0
  1026. data/lib/uniword/wordprocessingml/bookmark_start.rb +24 -0
  1027. data/lib/uniword/wordprocessingml/border.rb +30 -0
  1028. data/lib/uniword/wordprocessingml/break.rb +24 -0
  1029. data/lib/uniword/wordprocessingml/carriage_return.rb +17 -0
  1030. data/lib/uniword/wordprocessingml/character_style.rb +199 -0
  1031. data/lib/uniword/wordprocessingml/choice.rb +24 -0
  1032. data/lib/uniword/wordprocessingml/cnf_style.rb +52 -0
  1033. data/lib/uniword/wordprocessingml/columns.rb +26 -0
  1034. data/lib/uniword/wordprocessingml/comment_range_end.rb +22 -0
  1035. data/lib/uniword/wordprocessingml/comment_range_start.rb +22 -0
  1036. data/lib/uniword/wordprocessingml/comment_reference.rb +22 -0
  1037. data/lib/uniword/wordprocessingml/compat.rb +35 -0
  1038. data/lib/uniword/wordprocessingml/compat_setting.rb +26 -0
  1039. data/lib/uniword/wordprocessingml/deleted_text.rb +29 -0
  1040. data/lib/uniword/wordprocessingml/doc_defaults.rb +25 -0
  1041. data/lib/uniword/wordprocessingml/doc_grid.rb +25 -0
  1042. data/lib/uniword/wordprocessingml/doc_pr.rb +26 -0
  1043. data/lib/uniword/wordprocessingml/document_root.rb +251 -0
  1044. data/lib/uniword/wordprocessingml/drawing.rb +24 -0
  1045. data/lib/uniword/wordprocessingml/emboss.rb +24 -0
  1046. data/lib/uniword/wordprocessingml/endnote.rb +27 -0
  1047. data/lib/uniword/wordprocessingml/endnote_ref.rb +20 -0
  1048. data/lib/uniword/wordprocessingml/endnote_reference.rb +22 -0
  1049. data/lib/uniword/wordprocessingml/endnotes.rb +23 -0
  1050. data/lib/uniword/wordprocessingml/extent.rb +24 -0
  1051. data/lib/uniword/wordprocessingml/fallback.rb +24 -0
  1052. data/lib/uniword/wordprocessingml/field_char.rb +24 -0
  1053. data/lib/uniword/wordprocessingml/font.rb +110 -0
  1054. data/lib/uniword/wordprocessingml/font_table.rb +30 -0
  1055. data/lib/uniword/wordprocessingml/fonts.rb +23 -0
  1056. data/lib/uniword/wordprocessingml/footer.rb +25 -0
  1057. data/lib/uniword/wordprocessingml/footer_reference.rb +27 -0
  1058. data/lib/uniword/wordprocessingml/footnote.rb +27 -0
  1059. data/lib/uniword/wordprocessingml/footnote_ref.rb +20 -0
  1060. data/lib/uniword/wordprocessingml/footnote_reference.rb +22 -0
  1061. data/lib/uniword/wordprocessingml/footnotes.rb +23 -0
  1062. data/lib/uniword/wordprocessingml/graphic.rb +23 -0
  1063. data/lib/uniword/wordprocessingml/graphic_data.rb +22 -0
  1064. data/lib/uniword/wordprocessingml/grid_after.rb +17 -0
  1065. data/lib/uniword/wordprocessingml/grid_before.rb +17 -0
  1066. data/lib/uniword/wordprocessingml/grid_col.rb +22 -0
  1067. data/lib/uniword/wordprocessingml/header.rb +25 -0
  1068. data/lib/uniword/wordprocessingml/header_reference.rb +27 -0
  1069. data/lib/uniword/wordprocessingml/hyperlink.rb +73 -0
  1070. data/lib/uniword/wordprocessingml/imprint.rb +24 -0
  1071. data/lib/uniword/wordprocessingml/inline.rb +27 -0
  1072. data/lib/uniword/wordprocessingml/instr_text.rb +32 -0
  1073. data/lib/uniword/wordprocessingml/last_rendered_page_break.rb +16 -0
  1074. data/lib/uniword/wordprocessingml/latent_styles.rb +59 -0
  1075. data/lib/uniword/wordprocessingml/level.rb +103 -0
  1076. data/lib/uniword/wordprocessingml/link.rb +22 -0
  1077. data/lib/uniword/wordprocessingml/lvl_jc.rb +22 -0
  1078. data/lib/uniword/wordprocessingml/lvl_text.rb +22 -0
  1079. data/lib/uniword/wordprocessingml/mc_requires.rb +11 -0
  1080. data/lib/uniword/wordprocessingml/multi_level_type.rb +22 -0
  1081. data/lib/uniword/wordprocessingml/next.rb +22 -0
  1082. data/lib/uniword/wordprocessingml/no_break_hyphen.rb +17 -0
  1083. data/lib/uniword/wordprocessingml/no_wrap.rb +16 -0
  1084. data/lib/uniword/wordprocessingml/num.rb +25 -0
  1085. data/lib/uniword/wordprocessingml/num_fmt.rb +22 -0
  1086. data/lib/uniword/wordprocessingml/numbering.rb +25 -0
  1087. data/lib/uniword/wordprocessingml/numbering_configuration.rb +173 -0
  1088. data/lib/uniword/wordprocessingml/numbering_definition.rb +155 -0
  1089. data/lib/uniword/wordprocessingml/numbering_elements.rb +78 -0
  1090. data/lib/uniword/wordprocessingml/numbering_instance.rb +55 -0
  1091. data/lib/uniword/wordprocessingml/numbering_level.rb +90 -0
  1092. data/lib/uniword/wordprocessingml/object.rb +24 -0
  1093. data/lib/uniword/wordprocessingml/outline.rb +24 -0
  1094. data/lib/uniword/wordprocessingml/p_pr_default.rb +23 -0
  1095. data/lib/uniword/wordprocessingml/page_margins.rb +34 -0
  1096. data/lib/uniword/wordprocessingml/page_numbering.rb +24 -0
  1097. data/lib/uniword/wordprocessingml/page_size.rb +26 -0
  1098. data/lib/uniword/wordprocessingml/paragraph.rb +197 -0
  1099. data/lib/uniword/wordprocessingml/paragraph_borders.rb +58 -0
  1100. data/lib/uniword/wordprocessingml/paragraph_properties.rb +339 -0
  1101. data/lib/uniword/wordprocessingml/paragraph_style.rb +163 -0
  1102. data/lib/uniword/wordprocessingml/pict.rb +23 -0
  1103. data/lib/uniword/wordprocessingml/picture.rb +27 -0
  1104. data/lib/uniword/wordprocessingml/position_tab.rb +26 -0
  1105. data/lib/uniword/wordprocessingml/proof_err.rb +20 -0
  1106. data/lib/uniword/wordprocessingml/r_pr_default.rb +23 -0
  1107. data/lib/uniword/wordprocessingml/recipient_data.rb +25 -0
  1108. data/lib/uniword/wordprocessingml/recipients.rb +21 -0
  1109. data/lib/uniword/wordprocessingml/run.rb +254 -0
  1110. data/lib/uniword/wordprocessingml/run_properties.rb +701 -0
  1111. data/lib/uniword/wordprocessingml/section_properties.rb +55 -0
  1112. data/lib/uniword/wordprocessingml/semi_hidden.rb +27 -0
  1113. data/lib/uniword/wordprocessingml/settings.rb +606 -0
  1114. data/lib/uniword/wordprocessingml/shading.rb +30 -0
  1115. data/lib/uniword/wordprocessingml/shadow.rb +24 -0
  1116. data/lib/uniword/wordprocessingml/shape.rb +26 -0
  1117. data/lib/uniword/wordprocessingml/simple_field.rb +27 -0
  1118. data/lib/uniword/wordprocessingml/simple_pos.rb +24 -0
  1119. data/lib/uniword/wordprocessingml/soft_hyphen.rb +17 -0
  1120. data/lib/uniword/wordprocessingml/start.rb +22 -0
  1121. data/lib/uniword/wordprocessingml/structured_document_tag/alias.rb +21 -0
  1122. data/lib/uniword/wordprocessingml/structured_document_tag/appearance.rb +22 -0
  1123. data/lib/uniword/wordprocessingml/structured_document_tag/bibliography.rb +18 -0
  1124. data/lib/uniword/wordprocessingml/structured_document_tag/content.rb +32 -0
  1125. data/lib/uniword/wordprocessingml/structured_document_tag/data_binding.rb +27 -0
  1126. data/lib/uniword/wordprocessingml/structured_document_tag/date.rb +75 -0
  1127. data/lib/uniword/wordprocessingml/structured_document_tag/doc_part_obj.rb +57 -0
  1128. data/lib/uniword/wordprocessingml/structured_document_tag/end_properties.rb +24 -0
  1129. data/lib/uniword/wordprocessingml/structured_document_tag/id.rb +21 -0
  1130. data/lib/uniword/wordprocessingml/structured_document_tag/placeholder.rb +33 -0
  1131. data/lib/uniword/wordprocessingml/structured_document_tag/run_properties.rb +83 -0
  1132. data/lib/uniword/wordprocessingml/structured_document_tag/showing_placeholder_header.rb +18 -0
  1133. data/lib/uniword/wordprocessingml/structured_document_tag/tag.rb +21 -0
  1134. data/lib/uniword/wordprocessingml/structured_document_tag/temporary.rb +19 -0
  1135. data/lib/uniword/wordprocessingml/structured_document_tag/text.rb +18 -0
  1136. data/lib/uniword/wordprocessingml/structured_document_tag.rb +62 -0
  1137. data/lib/uniword/wordprocessingml/structured_document_tag_properties.rb +53 -0
  1138. data/lib/uniword/wordprocessingml/style.rb +383 -0
  1139. data/lib/uniword/wordprocessingml/style_name.rb +45 -0
  1140. data/lib/uniword/wordprocessingml/styles/character_style_definition.rb +45 -0
  1141. data/lib/uniword/wordprocessingml/styles/list_style_definition.rb +74 -0
  1142. data/lib/uniword/wordprocessingml/styles/paragraph_style_definition.rb +54 -0
  1143. data/lib/uniword/wordprocessingml/styles/semantic_style.rb +58 -0
  1144. data/lib/uniword/wordprocessingml/styles/style_definition.rb +61 -0
  1145. data/lib/uniword/wordprocessingml/styles/style_library.rb +207 -0
  1146. data/lib/uniword/wordprocessingml/styles/table_style_definition.rb +60 -0
  1147. data/lib/uniword/wordprocessingml/styles.rb +13 -0
  1148. data/lib/uniword/wordprocessingml/styles_configuration.rb +352 -0
  1149. data/lib/uniword/wordprocessingml/symbol.rb +24 -0
  1150. data/lib/uniword/wordprocessingml/tab.rb +23 -0
  1151. data/lib/uniword/wordprocessingml/tab_stop.rb +58 -0
  1152. data/lib/uniword/wordprocessingml/table.rb +72 -0
  1153. data/lib/uniword/wordprocessingml/table_borders.rb +33 -0
  1154. data/lib/uniword/wordprocessingml/table_cell.rb +80 -0
  1155. data/lib/uniword/wordprocessingml/table_cell_borders.rb +29 -0
  1156. data/lib/uniword/wordprocessingml/table_cell_margin.rb +29 -0
  1157. data/lib/uniword/wordprocessingml/table_cell_properties.rb +60 -0
  1158. data/lib/uniword/wordprocessingml/table_grid.rb +23 -0
  1159. data/lib/uniword/wordprocessingml/table_properties.rb +352 -0
  1160. data/lib/uniword/wordprocessingml/table_row.rb +79 -0
  1161. data/lib/uniword/wordprocessingml/table_row_properties.rb +58 -0
  1162. data/lib/uniword/wordprocessingml/table_style.rb +20 -0
  1163. data/lib/uniword/wordprocessingml/text.rb +81 -0
  1164. data/lib/uniword/wordprocessingml/text_box_content.rb +27 -0
  1165. data/lib/uniword/wordprocessingml/text_direction.rb +19 -0
  1166. data/lib/uniword/wordprocessingml/tr_height.rb +21 -0
  1167. data/lib/uniword/wordprocessingml/ui_priority.rb +22 -0
  1168. data/lib/uniword/wordprocessingml/val_int.rb +18 -0
  1169. data/lib/uniword/wordprocessingml/w14_attributes.rb +47 -0
  1170. data/lib/uniword/wordprocessingml/web_settings.rb +43 -0
  1171. data/lib/uniword/wordprocessingml/width_after.rb +19 -0
  1172. data/lib/uniword/wordprocessingml/width_before.rb +19 -0
  1173. data/lib/uniword/wordprocessingml/zoom.rb +22 -0
  1174. data/lib/uniword/wordprocessingml.rb +237 -0
  1175. data/lib/uniword/wordprocessingml_2010/checkbox.rb +27 -0
  1176. data/lib/uniword/wordprocessingml_2010/checked_state.rb +24 -0
  1177. data/lib/uniword/wordprocessingml_2010/conditional_format_style.rb +30 -0
  1178. data/lib/uniword/wordprocessingml_2010/conflict_deletion.rb +26 -0
  1179. data/lib/uniword/wordprocessingml_2010/conflict_insertion.rb +26 -0
  1180. data/lib/uniword/wordprocessingml_2010/conflict_mode.rb +22 -0
  1181. data/lib/uniword/wordprocessingml_2010/custom_xml_conflict_insertion.rb +24 -0
  1182. data/lib/uniword/wordprocessingml_2010/doc_id.rb +22 -0
  1183. data/lib/uniword/wordprocessingml_2010/doc_part_gallery.rb +22 -0
  1184. data/lib/uniword/wordprocessingml_2010/doc_part_obj.rb +27 -0
  1185. data/lib/uniword/wordprocessingml_2010/entity_picker.rb +22 -0
  1186. data/lib/uniword/wordprocessingml_2010/ligatures.rb +22 -0
  1187. data/lib/uniword/wordprocessingml_2010/number_form.rb +22 -0
  1188. data/lib/uniword/wordprocessingml_2010/para_id.rb +22 -0
  1189. data/lib/uniword/wordprocessingml_2010/props3d.rb +26 -0
  1190. data/lib/uniword/wordprocessingml_2010/sdt_content.rb +23 -0
  1191. data/lib/uniword/wordprocessingml_2010/sdt_properties.rb +27 -0
  1192. data/lib/uniword/wordprocessingml_2010/structured_document_tag.rb +25 -0
  1193. data/lib/uniword/wordprocessingml_2010/text_fill.rb +27 -0
  1194. data/lib/uniword/wordprocessingml_2010/text_glow.rb +25 -0
  1195. data/lib/uniword/wordprocessingml_2010/text_id.rb +22 -0
  1196. data/lib/uniword/wordprocessingml_2010/text_outline.rb +28 -0
  1197. data/lib/uniword/wordprocessingml_2010/text_reflection.rb +28 -0
  1198. data/lib/uniword/wordprocessingml_2010/text_shadow.rb +28 -0
  1199. data/lib/uniword/wordprocessingml_2010/unchecked_state.rb +24 -0
  1200. data/lib/uniword/wordprocessingml_2010.rb +44 -0
  1201. data/lib/uniword/wordprocessingml_2013/chart_props.rb +25 -0
  1202. data/lib/uniword/wordprocessingml_2013/chart_tracking_ref_based.rb +22 -0
  1203. data/lib/uniword/wordprocessingml_2013/comment_author.rb +26 -0
  1204. data/lib/uniword/wordprocessingml_2013/comment_collapsed.rb +22 -0
  1205. data/lib/uniword/wordprocessingml_2013/comment_done.rb +22 -0
  1206. data/lib/uniword/wordprocessingml_2013/comment_ex.rb +26 -0
  1207. data/lib/uniword/wordprocessingml_2013/comments_ids.rb +23 -0
  1208. data/lib/uniword/wordprocessingml_2013/doc_part_anchor.rb +22 -0
  1209. data/lib/uniword/wordprocessingml_2013/document_part.rb +22 -0
  1210. data/lib/uniword/wordprocessingml_2013/footnote_columns.rb +22 -0
  1211. data/lib/uniword/wordprocessingml_2013/people_group.rb +25 -0
  1212. data/lib/uniword/wordprocessingml_2013/person.rb +26 -0
  1213. data/lib/uniword/wordprocessingml_2013/presence_info.rb +24 -0
  1214. data/lib/uniword/wordprocessingml_2013/repeating_section.rb +25 -0
  1215. data/lib/uniword/wordprocessingml_2013/repeating_section_item.rb +22 -0
  1216. data/lib/uniword/wordprocessingml_2013/sdt_appearance.rb +22 -0
  1217. data/lib/uniword/wordprocessingml_2013/sdt_color.rb +22 -0
  1218. data/lib/uniword/wordprocessingml_2013/sdt_data_binding.rb +24 -0
  1219. data/lib/uniword/wordprocessingml_2013/web_extension.rb +22 -0
  1220. data/lib/uniword/wordprocessingml_2013/web_extension_linked.rb +22 -0
  1221. data/lib/uniword/wordprocessingml_2013.rb +38 -0
  1222. data/lib/uniword/wordprocessingml_2016/cell_rsid.rb +22 -0
  1223. data/lib/uniword/wordprocessingml_2016/chart_color_style.rb +22 -0
  1224. data/lib/uniword/wordprocessingml_2016/chart_style2016.rb +22 -0
  1225. data/lib/uniword/wordprocessingml_2016/comments_ext.rb +24 -0
  1226. data/lib/uniword/wordprocessingml_2016/conflict_mode2016.rb +22 -0
  1227. data/lib/uniword/wordprocessingml_2016/content_id.rb +22 -0
  1228. data/lib/uniword/wordprocessingml_2016/data_binding2016.rb +26 -0
  1229. data/lib/uniword/wordprocessingml_2016/extension.rb +25 -0
  1230. data/lib/uniword/wordprocessingml_2016/extension_list.rb +23 -0
  1231. data/lib/uniword/wordprocessingml_2016/persistent_document_id.rb +22 -0
  1232. data/lib/uniword/wordprocessingml_2016/row_rsid.rb +22 -0
  1233. data/lib/uniword/wordprocessingml_2016/sdt_appearance2016.rb +22 -0
  1234. data/lib/uniword/wordprocessingml_2016/separator_extension.rb +22 -0
  1235. data/lib/uniword/wordprocessingml_2016/table_rsid.rb +22 -0
  1236. data/lib/uniword/wordprocessingml_2016/web_video_property.rb +24 -0
  1237. data/lib/uniword/wordprocessingml_2016.rb +33 -0
  1238. data/lib/uniword/wp_drawing/align.rb +22 -0
  1239. data/lib/uniword/wp_drawing/allow_overlap.rb +22 -0
  1240. data/lib/uniword/wp_drawing/anchor.rb +80 -0
  1241. data/lib/uniword/wp_drawing/behind_doc.rb +22 -0
  1242. data/lib/uniword/wp_drawing/c_nv_graphic_frame_pr.rb +23 -0
  1243. data/lib/uniword/wp_drawing/doc_pr.rb +30 -0
  1244. data/lib/uniword/wp_drawing/doc_properties.rb +27 -0
  1245. data/lib/uniword/wp_drawing/effect_extent.rb +28 -0
  1246. data/lib/uniword/wp_drawing/extent.rb +24 -0
  1247. data/lib/uniword/wp_drawing/hidden.rb +22 -0
  1248. data/lib/uniword/wp_drawing/inline.rb +38 -0
  1249. data/lib/uniword/wp_drawing/layout_in_cell.rb +22 -0
  1250. data/lib/uniword/wp_drawing/line_to.rb +24 -0
  1251. data/lib/uniword/wp_drawing/locked.rb +22 -0
  1252. data/lib/uniword/wp_drawing/non_visual_drawing_props.rb +20 -0
  1253. data/lib/uniword/wp_drawing/pos_offset.rb +22 -0
  1254. data/lib/uniword/wp_drawing/position_h.rb +27 -0
  1255. data/lib/uniword/wp_drawing/position_v.rb +27 -0
  1256. data/lib/uniword/wp_drawing/relative_height.rb +22 -0
  1257. data/lib/uniword/wp_drawing/simple_pos.rb +24 -0
  1258. data/lib/uniword/wp_drawing/size_rel_h.rb +25 -0
  1259. data/lib/uniword/wp_drawing/size_rel_v.rb +25 -0
  1260. data/lib/uniword/wp_drawing/start.rb +24 -0
  1261. data/lib/uniword/wp_drawing/wrap_none.rb +18 -0
  1262. data/lib/uniword/wp_drawing/wrap_polygon.rb +27 -0
  1263. data/lib/uniword/wp_drawing/wrap_square.rb +33 -0
  1264. data/lib/uniword/wp_drawing/wrap_through.rb +29 -0
  1265. data/lib/uniword/wp_drawing/wrap_tight.rb +29 -0
  1266. data/lib/uniword/wp_drawing/wrap_top_and_bottom.rb +27 -0
  1267. data/lib/uniword/wp_drawing.rb +55 -0
  1268. data/lib/uniword.rb +295 -0
  1269. metadata +1386 -0
@@ -0,0 +1,989 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+ require 'lutaml/model'
5
+
6
+ module Uniword
7
+ module Ooxml
8
+ # DOCX Package - Complete OOXML package model
9
+ #
10
+ # Represents the entire .docx file structure as a lutaml-model object.
11
+ # Each XML file within the ZIP is a separate lutaml-model class.
12
+ #
13
+ # This is the CORRECT OOP approach:
14
+ # - ONE model class for the container (DocxPackage)
15
+ # - Each XML part is a proper model attribute (content_types, document, styles, etc.)
16
+ # - No serializer/deserializer anti-pattern
17
+ #
18
+ # @example Load DOCX
19
+ # package = DocxPackage.from_file('document.docx')
20
+ # package.core_properties.title = 'New Title'
21
+ # package.to_file('output.docx')
22
+ #
23
+ # @example Access document content
24
+ # package = DocxPackage.from_file('document.docx')
25
+ # package.document.body.paragraphs.each { |p| puts p.text }
26
+ class DocxPackage < Lutaml::Model::Serializable
27
+ # === Package Structure (OOXML Part 2: OPC) ===
28
+ # Content Types ([Content_Types].xml)
29
+ attribute :content_types, Uniword::ContentTypes::Types
30
+
31
+ # Package-level relationships (_rels/.rels)
32
+ attribute :package_rels, Relationships::PackageRelationships
33
+
34
+ # === Document Properties (docProps/) ===
35
+ # Core document metadata (docProps/core.xml)
36
+ attribute :core_properties, CoreProperties
37
+
38
+ # Extended application properties (docProps/app.xml)
39
+ attribute :app_properties, AppProperties
40
+
41
+ # Custom document properties (docProps/custom.xml)
42
+ attribute :custom_properties, CustomProperties
43
+
44
+ # Custom XML data items (customXml/item*.xml)
45
+ attr_accessor :custom_xml_items
46
+
47
+ # === Document Parts (word/) ===
48
+ # Main document content (word/document.xml)
49
+ attribute :document, Uniword::Wordprocessingml::DocumentRoot
50
+
51
+ # Document styles (word/styles.xml)
52
+ attribute :styles, Uniword::Wordprocessingml::StylesConfiguration
53
+
54
+ # Document numbering (word/numbering.xml)
55
+ attribute :numbering, Uniword::Wordprocessingml::NumberingConfiguration
56
+
57
+ # Document settings (word/settings.xml)
58
+ attribute :settings, Uniword::Wordprocessingml::Settings
59
+
60
+ # Document font table (word/fontTable.xml)
61
+ attribute :font_table, Uniword::Wordprocessingml::FontTable
62
+
63
+ # Document web settings (word/webSettings.xml)
64
+ attribute :web_settings, Uniword::Wordprocessingml::WebSettings
65
+
66
+ # Document-level relationships (word/_rels/document.xml.rels)
67
+ attribute :document_rels, Relationships::PackageRelationships
68
+
69
+ # === Theme (word/theme/) ===
70
+ # Document theme (word/theme/theme1.xml)
71
+ attribute :theme, Drawingml::Theme
72
+
73
+ # Theme-level relationships (word/theme/_rels/theme1.xml.rels)
74
+ attribute :theme_rels, Relationships::PackageRelationships
75
+
76
+ # === Footnotes and Endnotes (word/) ===
77
+ # Footnotes (word/footnotes.xml)
78
+ attribute :footnotes, Uniword::Wordprocessingml::Footnotes
79
+
80
+ # Endnotes (word/endnotes.xml)
81
+ attribute :endnotes, Uniword::Wordprocessingml::Endnotes
82
+
83
+ # Non-serialized attributes (DOCX packaging helpers)
84
+ attr_accessor :chart_parts, :bibliography_sources
85
+
86
+ # Load DOCX package from file
87
+ #
88
+ # @param path [String] Path to .docx file
89
+ # @return [DocxPackage] Package with all parts loaded
90
+ def self.from_file(path)
91
+ extractor = Infrastructure::ZipExtractor.new
92
+ zip_content = extractor.extract(path)
93
+ from_zip_content(zip_content, path)
94
+ end
95
+
96
+ # Create package from extracted ZIP content
97
+ #
98
+ # @param zip_content [Hash] Extracted ZIP files
99
+ # @param zip_path [String, nil] Original ZIP path for binary re-extraction
100
+ # @return [DocxPackage] Package object
101
+ def self.from_zip_content(zip_content, zip_path = nil)
102
+ package = new
103
+
104
+ # Parse Content Types
105
+ if zip_content['[Content_Types].xml']
106
+ package.content_types = Uniword::ContentTypes::Types.from_xml(
107
+ zip_content['[Content_Types].xml']
108
+ )
109
+ end
110
+
111
+ # Parse Package Relationships
112
+ if zip_content['_rels/.rels']
113
+ package.package_rels = Relationships::PackageRelationships.from_xml(
114
+ zip_content['_rels/.rels']
115
+ )
116
+ end
117
+
118
+ # Find the main document path from officeDocument relationship
119
+ main_doc_path = find_main_document_path(package.package_rels)
120
+ main_doc_rels_path = find_document_rels_path(main_doc_path)
121
+
122
+ # Parse Document Properties
123
+ if zip_content['docProps/core.xml']
124
+ package.core_properties = CoreProperties.from_xml(
125
+ zip_content['docProps/core.xml']
126
+ )
127
+ end
128
+
129
+ if zip_content['docProps/app.xml']
130
+ package.app_properties = AppProperties.from_xml(
131
+ zip_content['docProps/app.xml']
132
+ )
133
+ end
134
+
135
+ # Parse Custom Properties
136
+ if zip_content['docProps/custom.xml']
137
+ package.custom_properties = CustomProperties.from_xml(
138
+ zip_content['docProps/custom.xml']
139
+ )
140
+ end
141
+
142
+ # Parse Custom XML Data items (customXml/item*.xml)
143
+ custom_xml_files = zip_content.keys.grep(%r{^customXml/item(\d+)\.xml$})
144
+ if custom_xml_files.any?
145
+ package.custom_xml_items = []
146
+ custom_xml_files.sort_by { |f| f[/item(\d+)/, 1].to_i }.each do |item_path|
147
+ index = item_path[/item(\d+)/, 1].to_i
148
+ item = {
149
+ index: index,
150
+ xml_content: zip_content[item_path]
151
+ }
152
+
153
+ # Parse itemProps
154
+ props_path = "customXml/itemProps#{index}.xml"
155
+ if zip_content[props_path]
156
+ item[:props_xml] = zip_content[props_path]
157
+ end
158
+
159
+ # Parse item relationships
160
+ rels_path = "customXml/_rels/item#{index}.xml.rels"
161
+ if zip_content[rels_path]
162
+ item[:rels_xml] = zip_content[rels_path]
163
+ end
164
+
165
+ package.custom_xml_items << item
166
+ end
167
+ end
168
+
169
+ # Parse Document Parts - use dynamic path from package relationships
170
+ if main_doc_path && zip_content[main_doc_path]
171
+ package.document = Uniword::Wordprocessingml::DocumentRoot.from_xml(
172
+ zip_content[main_doc_path]
173
+ )
174
+ elsif zip_content['word/document.xml']
175
+ # Fallback to standard path
176
+ package.document = Uniword::Wordprocessingml::DocumentRoot.from_xml(
177
+ zip_content['word/document.xml']
178
+ )
179
+ end
180
+
181
+ if zip_content['word/styles.xml']
182
+ package.styles = Uniword::Wordprocessingml::StylesConfiguration.from_xml(
183
+ zip_content['word/styles.xml']
184
+ )
185
+ end
186
+
187
+ if zip_content['word/numbering.xml']
188
+ package.numbering = Uniword::Wordprocessingml::NumberingConfiguration.from_xml(
189
+ zip_content['word/numbering.xml']
190
+ )
191
+ end
192
+
193
+ if zip_content['word/settings.xml']
194
+ package.settings = Uniword::Wordprocessingml::Settings.from_xml(
195
+ zip_content['word/settings.xml']
196
+ )
197
+ end
198
+
199
+ if zip_content['word/fontTable.xml']
200
+ package.font_table = Uniword::Wordprocessingml::FontTable.from_xml(
201
+ zip_content['word/fontTable.xml']
202
+ )
203
+ end
204
+
205
+ if zip_content['word/webSettings.xml']
206
+ package.web_settings = Uniword::Wordprocessingml::WebSettings.from_xml(
207
+ zip_content['word/webSettings.xml']
208
+ )
209
+ end
210
+
211
+ # Parse document relationships - use dynamic path based on main document
212
+ if main_doc_rels_path && zip_content[main_doc_rels_path]
213
+ package.document_rels = Relationships::PackageRelationships.from_xml(
214
+ zip_content[main_doc_rels_path]
215
+ )
216
+ elsif zip_content['word/_rels/document.xml.rels']
217
+ # Fallback to standard path
218
+ package.document_rels = Relationships::PackageRelationships.from_xml(
219
+ zip_content['word/_rels/document.xml.rels']
220
+ )
221
+ end
222
+
223
+ # Parse Theme
224
+ if zip_content['word/theme/theme1.xml']
225
+ package.theme = Drawingml::Theme.from_xml(
226
+ zip_content['word/theme/theme1.xml']
227
+ )
228
+
229
+ # Extract theme media files from word/theme/media/ directory
230
+ theme_media = extract_theme_media(zip_content)
231
+ package.theme.media_files = theme_media if theme_media.any?
232
+ end
233
+
234
+ if zip_content['word/theme/_rels/theme1.xml.rels']
235
+ package.theme_rels = Relationships::PackageRelationships.from_xml(
236
+ zip_content['word/theme/_rels/theme1.xml.rels']
237
+ )
238
+ end
239
+
240
+ # Parse Footnotes
241
+ if zip_content['word/footnotes.xml']
242
+ package.footnotes = Uniword::Wordprocessingml::Footnotes.from_xml(
243
+ zip_content['word/footnotes.xml']
244
+ )
245
+ end
246
+
247
+ # Parse Endnotes
248
+ if zip_content['word/endnotes.xml']
249
+ package.endnotes = Uniword::Wordprocessingml::Endnotes.from_xml(
250
+ zip_content['word/endnotes.xml']
251
+ )
252
+ end
253
+
254
+ # Parse Chart parts
255
+ # Find all word/charts/chart*.xml files and match with relationships
256
+ chart_files = zip_content.keys.grep(%r{^word/charts/chart\d+\.xml$})
257
+ if chart_files.any? && package.document_rels
258
+ package.document.chart_parts ||= {}
259
+ chart_files.each do |chart_path|
260
+ # Find the relationship that points to this chart
261
+ chart_target = chart_path.sub('word/', '')
262
+ rel = package.document_rels.relationships.find do |r|
263
+ r.target == chart_target &&
264
+ r.type.to_s.include?('officeDocument/2006/relationships/chart')
265
+ end
266
+ next unless rel
267
+
268
+ package.document.chart_parts[rel.id] = {
269
+ xml: zip_content[chart_path],
270
+ target: chart_target
271
+ }
272
+ end
273
+ end
274
+
275
+ # Extract image parts from word/media/ directory
276
+ # Pass zip_path for binary re-extraction to avoid UTF-8 corruption
277
+ extract_image_parts(zip_content, package, zip_path)
278
+
279
+ package
280
+ end
281
+
282
+ # Extract image files from word/media/ directory in DOCX
283
+ #
284
+ # @param zip_content [Hash] Extracted ZIP content (may have corrupted binary)
285
+ # @param package [DocxPackage] Package to populate
286
+ # @param zip_path [String, nil] Original ZIP path for binary re-extraction
287
+ def self.extract_image_parts(zip_content, package, zip_path = nil)
288
+ return unless package.document
289
+
290
+ # Find all media files
291
+ media_files = zip_content.keys.grep(%r{^word/media/.+$})
292
+ return if media_files.empty?
293
+
294
+ package.document.image_parts ||= {}
295
+
296
+ media_files.each do |media_path|
297
+ # Get filename for the key
298
+ filename = File.basename(media_path)
299
+ # Determine content type from extension
300
+ ext = File.extname(filename).delete('.').downcase
301
+ content_type = case ext
302
+ when 'jpg', 'jpeg' then 'image/jpeg'
303
+ when 'png' then 'image/png'
304
+ when 'gif' then 'image/gif'
305
+ when 'bmp' then 'image/bmp'
306
+ when 'tiff', 'tif' then 'image/tiff'
307
+ when 'svg' then 'image/svg+xml'
308
+ else "image/#{ext}"
309
+ end
310
+
311
+ # Generate a unique rId for this image
312
+ r_id = "rIdImg#{package.document.image_parts.size + 1}"
313
+
314
+ # Re-extract binary data directly from ZIP to avoid UTF-8 corruption
315
+ # Use zip_path if available, otherwise fall back to corrupted content
316
+ binary_data = if zip_path
317
+ read_binary_from_zip(zip_path, media_path)
318
+ else
319
+ zip_content[media_path]
320
+ end
321
+
322
+ package.document.image_parts[r_id] = {
323
+ data: binary_data,
324
+ target: "media/#{filename}",
325
+ content_type: content_type
326
+ }
327
+ end
328
+ end
329
+
330
+ # Read binary data directly from ZIP file without UTF-8 encoding
331
+ #
332
+ # @param zip_path [String] Path to ZIP file
333
+ # @param entry_path [String] Path within ZIP
334
+ # @return [String] Binary data
335
+ def self.read_binary_from_zip(zip_path, entry_path)
336
+ require 'zip'
337
+ Zip::File.open(zip_path) do |zip_file|
338
+ entry = zip_file.find_entry(entry_path)
339
+ return nil unless entry
340
+
341
+ entry.get_input_stream.read
342
+ end
343
+ end
344
+
345
+ # Save document to file (class method for DocumentWriter compatibility)
346
+ #
347
+ # @param document [DocumentRoot] The document to save
348
+ # @param path [String] Output path
349
+ def self.to_file(document, path)
350
+ package = new
351
+ package.document = document
352
+ # Copy parts from document for round-trip preservation
353
+ copy_document_parts_to_package(document, package)
354
+ # Initialize minimal required parts for a valid DOCX
355
+ package.content_types ||= minimal_content_types
356
+ package.package_rels ||= minimal_package_rels
357
+ package.document_rels ||= minimal_document_rels
358
+ # Ensure all relationship targets have corresponding parts
359
+ package.settings ||= Uniword::Wordprocessingml::Settings.new
360
+ package.font_table ||= Uniword::Wordprocessingml::FontTable.new
361
+ package.web_settings ||= Uniword::Wordprocessingml::WebSettings.new
362
+ package.footnotes ||= Uniword::Wordprocessingml::Footnotes.new
363
+ package.endnotes ||= Uniword::Wordprocessingml::Endnotes.new
364
+ package.to_file(path)
365
+ end
366
+
367
+ # Copy parts from document to package for round-trip preservation
368
+ #
369
+ # @param document [DocumentRoot] The source document
370
+ # @param package [DocxPackage] The target package
371
+ # @return [void]
372
+ def self.copy_document_parts_to_package(document, package)
373
+ return unless document.is_a?(Uniword::Wordprocessingml::DocumentRoot)
374
+
375
+ package.styles = document.styles_configuration if document.styles_configuration
376
+ package.numbering = document.numbering_configuration if document.numbering_configuration
377
+ package.settings = document.settings if document.settings
378
+ package.font_table = document.font_table if document.font_table
379
+ package.web_settings = document.web_settings if document.web_settings
380
+ package.theme = document.theme if document.theme
381
+ package.core_properties = document.core_properties if document.core_properties
382
+ package.app_properties = document.app_properties if document.app_properties
383
+ package.custom_properties = document.custom_properties if document.custom_properties
384
+ package.document_rels = document.document_rels if document.document_rels
385
+ package.theme_rels = document.theme_rels if document.theme_rels
386
+ package.package_rels = document.package_rels if document.package_rels
387
+ package.content_types = document.content_types if document.content_types
388
+ package.footnotes = document.footnotes if document.footnotes
389
+ package.endnotes = document.endnotes if document.endnotes
390
+ package.chart_parts = document.chart_parts if document.chart_parts
391
+ package.custom_xml_items = document.custom_xml_items if document.custom_xml_items
392
+ return unless document.bibliography_sources
393
+
394
+ package.bibliography_sources = document.bibliography_sources
395
+ end
396
+
397
+ # Extract media files from word/theme/media/ directory in DOCX
398
+ #
399
+ # @param zip_content [Hash] Extracted ZIP content
400
+ # @return [Hash] filename => MediaFile objects
401
+ def self.extract_theme_media(zip_content)
402
+ media = {}
403
+
404
+ zip_content.each_key do |file_path|
405
+ # Match pattern: word/theme/media/{filename}
406
+ next unless file_path =~ %r{^word/theme/media/(.+)$}
407
+
408
+ filename = Regexp.last_match(1)
409
+ media[filename] = Uniword::Themes::MediaFile.new(
410
+ filename: filename,
411
+ content: zip_content[file_path],
412
+ source_path: file_path
413
+ )
414
+ end
415
+
416
+ media
417
+ end
418
+
419
+ # Create minimal content types for a valid DOCX
420
+ def self.minimal_content_types
421
+ ct = Uniword::ContentTypes::Types.new
422
+ # Add default entries
423
+ ct.defaults ||= []
424
+ ct.defaults << Uniword::ContentTypes::Default.new(
425
+ extension: 'rels',
426
+ content_type: 'application/vnd.openxmlformats-package.relationships+xml'
427
+ )
428
+ ct.defaults << Uniword::ContentTypes::Default.new(
429
+ extension: 'xml',
430
+ content_type: 'application/xml'
431
+ )
432
+ # Image extension defaults
433
+ ct.defaults << Uniword::ContentTypes::Default.new(
434
+ extension: 'png',
435
+ content_type: 'image/png'
436
+ )
437
+ ct.defaults << Uniword::ContentTypes::Default.new(
438
+ extension: 'jpeg',
439
+ content_type: 'image/jpeg'
440
+ )
441
+ ct.defaults << Uniword::ContentTypes::Default.new(
442
+ extension: 'jpg',
443
+ content_type: 'image/jpeg'
444
+ )
445
+ ct.defaults << Uniword::ContentTypes::Default.new(
446
+ extension: 'gif',
447
+ content_type: 'image/gif'
448
+ )
449
+ ct.defaults << Uniword::ContentTypes::Default.new(
450
+ extension: 'bmp',
451
+ content_type: 'image/bmp'
452
+ )
453
+ ct.defaults << Uniword::ContentTypes::Default.new(
454
+ extension: 'tif',
455
+ content_type: 'image/tiff'
456
+ )
457
+ ct.defaults << Uniword::ContentTypes::Default.new(
458
+ extension: 'tiff',
459
+ content_type: 'image/tiff'
460
+ )
461
+ ct.defaults << Uniword::ContentTypes::Default.new(
462
+ extension: 'svg',
463
+ content_type: 'image/svg+xml'
464
+ )
465
+ # Add required overrides
466
+ ct.overrides ||= []
467
+ ct.overrides << Uniword::ContentTypes::Override.new(
468
+ part_name: '/word/document.xml',
469
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
470
+ )
471
+ ct.overrides << Uniword::ContentTypes::Override.new(
472
+ part_name: '/word/styles.xml',
473
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml'
474
+ )
475
+ ct.overrides << Uniword::ContentTypes::Override.new(
476
+ part_name: '/word/fontTable.xml',
477
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml'
478
+ )
479
+ ct.overrides << Uniword::ContentTypes::Override.new(
480
+ part_name: '/word/settings.xml',
481
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml'
482
+ )
483
+ ct.overrides << Uniword::ContentTypes::Override.new(
484
+ part_name: '/word/webSettings.xml',
485
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml'
486
+ )
487
+ ct.overrides << Uniword::ContentTypes::Override.new(
488
+ part_name: '/word/numbering.xml',
489
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml'
490
+ )
491
+ ct.overrides << Uniword::ContentTypes::Override.new(
492
+ part_name: '/docProps/app.xml',
493
+ content_type: 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
494
+ )
495
+ ct.overrides << Uniword::ContentTypes::Override.new(
496
+ part_name: '/docProps/core.xml',
497
+ content_type: 'application/vnd.openxmlformats-package.core-properties+xml'
498
+ )
499
+ ct.overrides << Uniword::ContentTypes::Override.new(
500
+ part_name: '/word/footnotes.xml',
501
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml'
502
+ )
503
+ ct.overrides << Uniword::ContentTypes::Override.new(
504
+ part_name: '/word/endnotes.xml',
505
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml'
506
+ )
507
+ ct
508
+ end
509
+
510
+ # Create minimal package relationships for a valid DOCX
511
+ def self.minimal_package_rels
512
+ rels = Relationships::PackageRelationships.new
513
+ rels.relationships ||= []
514
+ rels.relationships << Relationships::Relationship.new(
515
+ id: 'rId1',
516
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
517
+ target: 'word/document.xml'
518
+ )
519
+ rels.relationships << Relationships::Relationship.new(
520
+ id: 'rId2',
521
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
522
+ target: 'docProps/app.xml'
523
+ )
524
+ rels.relationships << Relationships::Relationship.new(
525
+ id: 'rId3',
526
+ type: 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
527
+ target: 'docProps/core.xml'
528
+ )
529
+ rels
530
+ end
531
+
532
+ # Create minimal document relationships for a valid DOCX
533
+ def self.minimal_document_rels
534
+ rels = Relationships::PackageRelationships.new
535
+ rels.relationships ||= []
536
+ rels.relationships << Relationships::Relationship.new(
537
+ id: 'rId1',
538
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
539
+ target: 'styles.xml'
540
+ )
541
+ rels.relationships << Relationships::Relationship.new(
542
+ id: 'rId2',
543
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
544
+ target: 'fontTable.xml'
545
+ )
546
+ rels.relationships << Relationships::Relationship.new(
547
+ id: 'rId3',
548
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
549
+ target: 'settings.xml'
550
+ )
551
+ rels.relationships << Relationships::Relationship.new(
552
+ id: 'rId4',
553
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
554
+ target: 'webSettings.xml'
555
+ )
556
+ rels.relationships << Relationships::Relationship.new(
557
+ id: 'rId5',
558
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
559
+ target: 'numbering.xml'
560
+ )
561
+ rels.relationships << Relationships::Relationship.new(
562
+ id: 'rId6',
563
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes',
564
+ target: 'footnotes.xml'
565
+ )
566
+ rels.relationships << Relationships::Relationship.new(
567
+ id: 'rId7',
568
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes',
569
+ target: 'endnotes.xml'
570
+ )
571
+ rels
572
+ end
573
+
574
+ # Save package to file
575
+ #
576
+ # @param path [String] Output path
577
+ def to_file(path)
578
+ zip_content = to_zip_content
579
+ packager = Infrastructure::ZipPackager.new
580
+ packager.package(zip_content, path)
581
+ end
582
+
583
+ # Generate ZIP content hash
584
+ #
585
+ # @return [Hash] File paths => content
586
+ def to_zip_content
587
+ content = {}
588
+
589
+ # Initialize content types and relationships from model attributes
590
+ # or fall back to minimal defaults
591
+ content_types = self.content_types || self.class.minimal_content_types
592
+ package_rels = self.package_rels || self.class.minimal_package_rels
593
+ document_rels = self.document_rels || self.class.minimal_document_rels
594
+
595
+ # Ensure all relationship targets have corresponding parts
596
+ self.settings ||= Uniword::Wordprocessingml::Settings.new
597
+ self.font_table ||= Uniword::Wordprocessingml::FontTable.new
598
+ self.web_settings ||= Uniword::Wordprocessingml::WebSettings.new
599
+ self.footnotes ||= Uniword::Wordprocessingml::Footnotes.new
600
+ self.endnotes ||= Uniword::Wordprocessingml::Endnotes.new
601
+
602
+ # --- Pre-serialization: inject image/chart/bibliography into content_types and document_rels ---
603
+
604
+ # Image parts: add content types and relationships
605
+ if document&.image_parts && !document.image_parts.empty?
606
+ document.image_parts.each_value do |image_data|
607
+ ext = File.extname(image_data[:target]).delete('.')
608
+ next if content_types.defaults.any? { |d| d.extension == ext }
609
+
610
+ content_types.defaults << Uniword::ContentTypes::Default.new(
611
+ extension: ext,
612
+ content_type: image_data[:content_type]
613
+ )
614
+ end
615
+
616
+ # Image relationships are added after finding unique rIds
617
+ document.image_parts.each do |r_id, image_data|
618
+ content["word/#{image_data[:target]}"] = image_data[:data]
619
+ document_rels.relationships << Relationships::Relationship.new(
620
+ id: r_id,
621
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
622
+ target: image_data[:target]
623
+ )
624
+ end
625
+ end
626
+
627
+ # Chart parts: add content type and relationships
628
+ if document&.chart_parts && !document.chart_parts.empty?
629
+ unless content_types.overrides.any? { |o| o.part_name&.start_with?('/word/charts/') }
630
+ content_types.overrides << Uniword::ContentTypes::Override.new(
631
+ part_name: '/word/charts/chart1.xml',
632
+ content_type: 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml'
633
+ )
634
+ end
635
+
636
+ document.chart_parts.each do |r_id, chart_data|
637
+ content["word/#{chart_data[:target]}"] = chart_data[:xml]
638
+ document_rels.relationships << Relationships::Relationship.new(
639
+ id: r_id,
640
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
641
+ target: chart_data[:target]
642
+ )
643
+ end
644
+ end
645
+
646
+ # Bibliography sources: add content type and relationship
647
+ if document&.bibliography_sources
648
+ unless content_types.overrides.any? { |o| o.part_name == '/word/sources.xml' }
649
+ content_types.overrides << Uniword::ContentTypes::Override.new(
650
+ part_name: '/word/sources.xml',
651
+ content_type: 'application/vnd.openxmlformats-officedocument.bibliography+xml'
652
+ )
653
+ end
654
+
655
+ unless document_rels.relationships.any? { |r| r.target == 'sources.xml' }
656
+ document_rels.relationships << Relationships::Relationship.new(
657
+ id: "rIdSrc#{SecureRandom.hex(4)}",
658
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography',
659
+ target: 'sources.xml'
660
+ )
661
+ end
662
+ end
663
+
664
+ # Custom properties: add content type and relationship
665
+ if custom_properties && !custom_properties.properties.empty?
666
+ unless content_types.overrides.any? { |o| o.part_name == '/docProps/custom.xml' }
667
+ content_types.overrides << Uniword::ContentTypes::Override.new(
668
+ part_name: '/docProps/custom.xml',
669
+ content_type: 'application/vnd.openxmlformats-officedocument.custom-properties+xml'
670
+ )
671
+ end
672
+
673
+ unless package_rels.relationships.any? { |r|
674
+ r.type.to_s.include?('officeDocument/2006/relationships/custom-properties')
675
+ }
676
+ package_rels.relationships << Relationships::Relationship.new(
677
+ id: "rIdCustProps",
678
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
679
+ target: 'docProps/custom.xml'
680
+ )
681
+ end
682
+ end
683
+
684
+ # Custom XML data: add content types
685
+ if custom_xml_items && !custom_xml_items.empty?
686
+ custom_xml_items.each do |item|
687
+ idx = item[:index]
688
+ unless content_types.overrides.any? { |o| o.part_name == "/customXml/itemProps#{idx}.xml" }
689
+ content_types.overrides << Uniword::ContentTypes::Override.new(
690
+ part_name: "/customXml/itemProps#{idx}.xml",
691
+ content_type: 'application/vnd.openxmlformats-officedocument.customXmlProperties+xml'
692
+ )
693
+ end
694
+ end
695
+ end
696
+
697
+ # Headers and footers: inject content types, relationships, section refs
698
+ header_counter = 0
699
+ footer_counter = 0
700
+
701
+ if document&.headers && !document.headers.empty?
702
+ document.headers.each_key do |type|
703
+ header_counter += 1
704
+ r_id = "rIdHeader#{header_counter}"
705
+
706
+ content_types.overrides << Uniword::ContentTypes::Override.new(
707
+ part_name: "/word/header#{header_counter}.xml",
708
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml'
709
+ )
710
+
711
+ document_rels.relationships << Relationships::Relationship.new(
712
+ id: r_id,
713
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/header',
714
+ target: "header#{header_counter}.xml"
715
+ )
716
+
717
+ # Wire into section properties
718
+ sect_pr = document.body.section_properties ||= Wordprocessingml::SectionProperties.new
719
+ existing = sect_pr.header_references&.find { |r| r.type == type }
720
+ if existing
721
+ existing.r_id = r_id
722
+ else
723
+ sect_pr.header_references << Wordprocessingml::HeaderReference.new(
724
+ type: type, r_id: r_id
725
+ )
726
+ end
727
+ end
728
+ end
729
+
730
+ if document&.footers && !document.footers.empty?
731
+ document.footers.each_key do |type|
732
+ footer_counter += 1
733
+ r_id = "rIdFooter#{footer_counter}"
734
+
735
+ content_types.overrides << Uniword::ContentTypes::Override.new(
736
+ part_name: "/word/footer#{footer_counter}.xml",
737
+ content_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml'
738
+ )
739
+
740
+ document_rels.relationships << Relationships::Relationship.new(
741
+ id: r_id,
742
+ type: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer',
743
+ target: "footer#{footer_counter}.xml"
744
+ )
745
+
746
+ # Wire into section properties
747
+ sect_pr = document.body.section_properties ||= Wordprocessingml::SectionProperties.new
748
+ existing = sect_pr.footer_references&.find { |r| r.type == type }
749
+ if existing
750
+ existing.r_id = r_id
751
+ else
752
+ sect_pr.footer_references << Wordprocessingml::FooterReference.new(
753
+ type: type, r_id: r_id
754
+ )
755
+ end
756
+ end
757
+ end
758
+
759
+ # Serialize Content Types
760
+ content['[Content_Types].xml'] = content_types.to_xml(
761
+ encoding: 'UTF-8', declaration: true
762
+ )
763
+
764
+ # Serialize Package Relationships
765
+ content['_rels/.rels'] = package_rels.to_xml(
766
+ encoding: 'UTF-8', declaration: true
767
+ )
768
+
769
+ # Serialize Document Properties
770
+ if core_properties
771
+ content['docProps/core.xml'] = core_properties.to_xml(
772
+ encoding: 'UTF-8', prefix: false
773
+ )
774
+ end
775
+
776
+ if app_properties
777
+ content['docProps/app.xml'] = app_properties.to_xml(
778
+ encoding: 'UTF-8', prefix: false
779
+ )
780
+ end
781
+
782
+ if custom_properties
783
+ content['docProps/custom.xml'] = custom_properties.to_xml(
784
+ encoding: 'UTF-8', prefix: false
785
+ )
786
+ end
787
+
788
+ # Serialize Custom XML Data items
789
+ if custom_xml_items && !custom_xml_items.empty?
790
+ custom_xml_items.each do |item|
791
+ idx = item[:index]
792
+ content["customXml/item#{idx}.xml"] = item[:xml_content]
793
+ content["customXml/itemProps#{idx}.xml"] = item[:props_xml] if item[:props_xml]
794
+ content["customXml/_rels/item#{idx}.xml.rels"] = item[:rels_xml] if item[:rels_xml]
795
+ end
796
+ end
797
+
798
+ # Serialize Document Parts
799
+ if document
800
+ content['word/document.xml'] = document.to_xml(
801
+ encoding: 'UTF-8', prefix: true, fix_boolean_elements: true
802
+ )
803
+ end
804
+
805
+ if styles
806
+ content['word/styles.xml'] = styles.to_xml(
807
+ encoding: 'UTF-8', prefix: true, fix_boolean_elements: true
808
+ )
809
+ end
810
+
811
+ if numbering
812
+ content['word/numbering.xml'] = numbering.to_xml(
813
+ encoding: 'UTF-8', prefix: true, fix_boolean_elements: true
814
+ )
815
+ end
816
+
817
+ if settings
818
+ content['word/settings.xml'] = settings.to_xml(
819
+ encoding: 'UTF-8', prefix: true
820
+ )
821
+ end
822
+
823
+ if font_table
824
+ content['word/fontTable.xml'] = font_table.to_xml(
825
+ encoding: 'UTF-8', prefix: true
826
+ )
827
+ end
828
+
829
+ if web_settings
830
+ content['word/webSettings.xml'] = web_settings.to_xml(
831
+ encoding: 'UTF-8', prefix: true
832
+ )
833
+ end
834
+
835
+ if document_rels
836
+ content['word/_rels/document.xml.rels'] = document_rels.to_xml(
837
+ encoding: 'UTF-8', declaration: true
838
+ )
839
+ end
840
+
841
+ # Serialize Theme
842
+ if theme
843
+ content['word/theme/theme1.xml'] = theme.to_xml(
844
+ encoding: 'UTF-8', prefix: true
845
+ )
846
+ end
847
+
848
+ if theme_rels
849
+ content['word/theme/_rels/theme1.xml.rels'] = theme_rels.to_xml(
850
+ encoding: 'UTF-8', declaration: true
851
+ )
852
+ end
853
+
854
+ # Serialize Footnotes
855
+ if footnotes
856
+ content['word/footnotes.xml'] = footnotes.to_xml(
857
+ encoding: 'UTF-8', prefix: true, fix_boolean_elements: true
858
+ )
859
+ end
860
+
861
+ # Serialize Endnotes
862
+ if endnotes
863
+ content['word/endnotes.xml'] = endnotes.to_xml(
864
+ encoding: 'UTF-8', prefix: true, fix_boolean_elements: true
865
+ )
866
+ end
867
+
868
+ # Serialize Bibliography Sources
869
+ if document&.bibliography_sources
870
+ content['word/sources.xml'] = document.bibliography_sources.to_xml(
871
+ encoding: 'UTF-8', declaration: true
872
+ )
873
+ end
874
+
875
+ # Serialize Headers
876
+ if document&.headers && !document.headers.empty?
877
+ h_idx = 0
878
+ document.headers.each_value do |header_obj|
879
+ h_idx += 1
880
+ content["word/header#{h_idx}.xml"] = header_obj.to_xml(
881
+ encoding: 'UTF-8', prefix: true, fix_boolean_elements: true
882
+ )
883
+ end
884
+ end
885
+
886
+ # Serialize Footers
887
+ if document&.footers && !document.footers.empty?
888
+ f_idx = 0
889
+ document.footers.each_value do |footer_obj|
890
+ f_idx += 1
891
+ content["word/footer#{f_idx}.xml"] = footer_obj.to_xml(
892
+ encoding: 'UTF-8', prefix: true, fix_boolean_elements: true
893
+ )
894
+ end
895
+ end
896
+
897
+ content
898
+ end
899
+
900
+ # Delegate common DocumentRoot methods for API compatibility
901
+ # This allows code using Uniword.load() to work with DocxPackage seamlessly
902
+
903
+ # Get all paragraphs from the document body
904
+ #
905
+ # @return [Array<Paragraph>] All paragraphs
906
+ def paragraphs
907
+ document&.paragraphs || []
908
+ end
909
+
910
+ # Get all tables from the document body
911
+ #
912
+ # @return [Array<Table>] All tables
913
+ def tables
914
+ document&.tables || []
915
+ end
916
+
917
+ # Get the document body
918
+ #
919
+ # @return [Body, nil] The document body
920
+ def body
921
+ document&.body
922
+ end
923
+
924
+ # Get document text content
925
+ #
926
+ # @return [String] Combined text from all paragraphs
927
+ def text
928
+ document&.text || ''
929
+ end
930
+
931
+ # Get document body paragraphs as enumerable
932
+ #
933
+ # @return [Enumerator, Array<Paragraph>] Paragraph enumerator
934
+ def each_paragraph(&)
935
+ paragraphs.each(&)
936
+ end
937
+
938
+ # Alias for to_file (API compatibility)
939
+ alias save to_file
940
+
941
+ # Get charts from document
942
+ def charts
943
+ document&.charts || []
944
+ end
945
+
946
+ # Get styles configuration from document
947
+ def styles_configuration
948
+ document&.styles_configuration
949
+ end
950
+
951
+ # Find the main document path from package relationships
952
+ #
953
+ # The officeDocument relationship type is:
954
+ # http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument
955
+ #
956
+ # @param package_rels [PackageRelationships, nil] Parsed package relationships
957
+ # @return [String, nil] Normalized document path (e.g., 'word/document.xml')
958
+ def self.find_main_document_path(package_rels)
959
+ return nil unless package_rels&.relationships
960
+
961
+ rel = package_rels.relationships.find do |r|
962
+ r.type.to_s.include?('officeDocument/2006/relationships/officeDocument')
963
+ end
964
+ return nil unless rel&.target
965
+
966
+ # Normalize path - strip leading slash if present
967
+ path = rel.target.dup
968
+ path.sub!(%r{^/}, '')
969
+ path
970
+ end
971
+
972
+ # Find the document relationships path from the main document path
973
+ #
974
+ # For 'word/document.xml' returns 'word/_rels/document.xml.rels'
975
+ # For 'word/document2.xml' returns 'word/_rels/document2.xml.rels'
976
+ #
977
+ # @param doc_path [String, nil] Main document path
978
+ # @return [String, nil] Document relationships path
979
+ def self.find_document_rels_path(doc_path)
980
+ return nil unless doc_path
981
+
982
+ # Extract directory and filename
983
+ dir = File.dirname(doc_path)
984
+ basename = File.basename(doc_path)
985
+ File.join(dir, '_rels', "#{basename}.rels")
986
+ end
987
+ end
988
+ end
989
+ end