uniword 1.7.7 → 1.7.9
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.
- checksums.yaml +4 -4
- data/lib/uniword/builder/base_builder.rb +4 -2
- data/lib/uniword/builder/footnote_builder.rb +12 -0
- data/lib/uniword/builder/image_builder.rb +7 -5
- data/lib/uniword/builder/table_builder.rb +2 -1
- data/lib/uniword/builder/table_cell_builder.rb +2 -1
- data/lib/uniword/cli/main.rb +1 -1
- data/lib/uniword/converter/plain_text.rb +0 -1
- data/lib/uniword/docx/document_statistics.rb +1 -0
- data/lib/uniword/docx/id_allocator.rb +1 -1
- data/lib/uniword/docx/reconciler/notes.rb +20 -9
- data/lib/uniword/docx/reconciler/package_structure.rb +4 -4
- data/lib/uniword/docx/reconciler/parts.rb +39 -39
- data/lib/uniword/docx/reconciler/tables.rb +12 -7
- data/lib/uniword/docx/reconciler/theme.rb +3 -1
- data/lib/uniword/docx/reconciler.rb +2 -1
- data/lib/uniword/infrastructure/zip_packager.rb +90 -70
- data/lib/uniword/math_equation.rb +2 -2
- data/lib/uniword/ooxml/dotx_package.rb +3 -1
- data/lib/uniword/ooxml/namespaces.rb +7 -3
- data/lib/uniword/transformation/mhtml_element_renderer.rb +0 -1
- data/lib/uniword/transformation/ooxml_to_mhtml_converter.rb +1 -3
- data/lib/uniword/transformation/yaml_css_generator.rb +28 -25
- data/lib/uniword/validation/rules/core_properties_namespace_rule.rb +5 -1
- data/lib/uniword/validation/rules/mc_ignorable_namespace_rule.rb +5 -1
- data/lib/uniword/validation/rules/numbering_preservation_rule.rb +5 -1
- data/lib/uniword/validation/rules/relationship_integrity_rule.rb +5 -1
- data/lib/uniword/validation/rules/rsid_rule.rb +5 -1
- data/lib/uniword/validation/rules/settings_values_rule.rb +5 -1
- data/lib/uniword/validation/rules/theme_completeness_rule.rb +5 -1
- data/lib/uniword/version.rb +1 -1
- data/lib/uniword/wordprocessingml/body.rb +5 -5
- data/lib/uniword/wordprocessingml/instr_text.rb +4 -1
- data/lib/uniword/wordprocessingml/page_defaults.rb +1 -1
- data/lib/uniword/wordprocessingml/paragraph_properties.rb +2 -1
- data/lib/uniword/wordprocessingml/run_properties/conversion.rb +0 -2
- data/lib/uniword/wordprocessingml/update_fields.rb +1 -1
- data/lib/uniword.rb +12 -0
- metadata +20 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 06711e3879a7ef26b9e433fd0385b0c3d25bc23061ea8527ef0954f3a5b03f6c
|
|
4
|
+
data.tar.gz: c473820f6894ac19ee21ef8ce36e229f0486cdfeebff18a3eaec76297437f1fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3bd1973b1dc8d91639ab93baa310e11d02dc8a59d2c187b4fe335d9ed2ac81df4b346284172cadecdd101fade943135cc473c625a1fe7157172159e7fd11231b
|
|
7
|
+
data.tar.gz: 6041e14afc2bd9369d5d31c2bc2f6849cf51a76862dd4832a80ba5549d4c20bd934f9737d5c014b7d58b022a07b2813d9279fd97f0afa85d90f7e86271ff0f1b
|
|
@@ -57,11 +57,13 @@ module Uniword
|
|
|
57
57
|
|
|
58
58
|
def ensure_properties_in_order
|
|
59
59
|
return unless @model.element_order
|
|
60
|
-
return if @model.element_order.any?
|
|
60
|
+
return if @model.element_order.any? do |e|
|
|
61
|
+
e.element? && e.name == properties_tag
|
|
62
|
+
end
|
|
61
63
|
return unless @model.properties
|
|
62
64
|
|
|
63
65
|
@model.element_order.unshift(
|
|
64
|
-
Lutaml::Xml::Element.new("Element", properties_tag)
|
|
66
|
+
Lutaml::Xml::Element.new("Element", properties_tag),
|
|
65
67
|
)
|
|
66
68
|
end
|
|
67
69
|
end
|
|
@@ -107,9 +107,21 @@ module Uniword
|
|
|
107
107
|
# number marker (<w:footnoteRef/> / <w:endnoteRef/>); Word renders
|
|
108
108
|
# the note's number from this marker. Without it the footnote pane
|
|
109
109
|
# shows the body text with no number label.
|
|
110
|
+
#
|
|
111
|
+
# The marker run is prepended to BOTH the runs collection and
|
|
112
|
+
# element_order: builder-built paragraphs carry an element_order
|
|
113
|
+
# ("r" per appended run), and consumers that walk element_order —
|
|
114
|
+
# the MHTML renderer's paragraph_content_to_html — would otherwise
|
|
115
|
+
# render only the first "r" entry (the marker) and silently drop
|
|
116
|
+
# the note body's runs.
|
|
110
117
|
def prepend_ref_marker(paragraph, attr, marker_class)
|
|
111
118
|
marker = Wordprocessingml::Run.new(attr => marker_class.new)
|
|
112
119
|
paragraph.runs.unshift(marker)
|
|
120
|
+
if paragraph.element_order.is_a?(Array)
|
|
121
|
+
paragraph.element_order.unshift(
|
|
122
|
+
Lutaml::Xml::Element.new("Element", "r"),
|
|
123
|
+
)
|
|
124
|
+
end
|
|
113
125
|
end
|
|
114
126
|
end
|
|
115
127
|
end
|
|
@@ -50,10 +50,10 @@ module Uniword
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
content_type = case File.extname(path).downcase
|
|
53
|
-
when ".png"
|
|
53
|
+
when ".png" then "image/png"
|
|
54
54
|
when ".jpg", ".jpeg" then "image/jpeg"
|
|
55
|
-
when ".gif"
|
|
56
|
-
when ".bmp"
|
|
55
|
+
when ".gif" then "image/gif"
|
|
56
|
+
when ".bmp" then "image/bmp"
|
|
57
57
|
when ".tiff", ".tif" then "image/tiff"
|
|
58
58
|
when ".svg" then "image/svg+xml"
|
|
59
59
|
else "application/octet-stream"
|
|
@@ -141,9 +141,11 @@ alt_text: nil)
|
|
|
141
141
|
|
|
142
142
|
drawing = Wordprocessingml::Drawing.new
|
|
143
143
|
|
|
144
|
-
inline = WpDrawing::Inline.new(dist_t: 0, dist_b: 0, dist_l: 0,
|
|
144
|
+
inline = WpDrawing::Inline.new(dist_t: 0, dist_b: 0, dist_l: 0,
|
|
145
|
+
dist_r: 0)
|
|
145
146
|
inline.extent = WpDrawing::Extent.new(cx: w, cy: h)
|
|
146
|
-
inline.effect_extent = WpDrawing::EffectExtent.new(l: 0, t: 0, r: 0,
|
|
147
|
+
inline.effect_extent = WpDrawing::EffectExtent.new(l: 0, t: 0, r: 0,
|
|
148
|
+
b: 0)
|
|
147
149
|
inline.doc_properties = WpDrawing::DocProperties.new(
|
|
148
150
|
id: deterministic_id("inline", path),
|
|
149
151
|
name: File.basename(path, ".*"),
|
|
@@ -67,7 +67,8 @@ module Uniword
|
|
|
67
67
|
|
|
68
68
|
def ensure_table_structure
|
|
69
69
|
ensure_properties
|
|
70
|
-
@model.properties.table_width ||= Properties::TableWidth.new(w: 0,
|
|
70
|
+
@model.properties.table_width ||= Properties::TableWidth.new(w: 0,
|
|
71
|
+
type: "auto")
|
|
71
72
|
@model.properties.table_look ||= Wordprocessingml::TableDefaults.default_table_look
|
|
72
73
|
end
|
|
73
74
|
|
|
@@ -106,7 +106,8 @@ module Uniword
|
|
|
106
106
|
|
|
107
107
|
def ensure_cell_structure
|
|
108
108
|
ensure_properties
|
|
109
|
-
@model.properties.cell_width ||= Properties::CellWidth.new(w: 0,
|
|
109
|
+
@model.properties.cell_width ||= Properties::CellWidth.new(w: 0,
|
|
110
|
+
type: "auto")
|
|
110
111
|
end
|
|
111
112
|
end
|
|
112
113
|
end
|
data/lib/uniword/cli/main.rb
CHANGED
|
@@ -223,7 +223,7 @@ module Uniword
|
|
|
223
223
|
end
|
|
224
224
|
|
|
225
225
|
register_rid(rel.id, target: rel.target, type: rel.type,
|
|
226
|
-
|
|
226
|
+
target_mode: rel.target_mode, scope: scope)
|
|
227
227
|
end
|
|
228
228
|
|
|
229
229
|
# Whether an rId string is already registered within a scope.
|
|
@@ -10,7 +10,7 @@ module Uniword
|
|
|
10
10
|
# invalid types.
|
|
11
11
|
module Notes
|
|
12
12
|
def reconcile_note_references
|
|
13
|
-
[
|
|
13
|
+
%i[footnote endnote].each do |type|
|
|
14
14
|
ref_ids = collect_note_ids(type)
|
|
15
15
|
next if ref_ids.empty?
|
|
16
16
|
|
|
@@ -32,8 +32,8 @@ module Uniword
|
|
|
32
32
|
id: id,
|
|
33
33
|
paragraphs: [Wordprocessingml::Paragraph.new(
|
|
34
34
|
runs: [Wordprocessingml::Run.new(
|
|
35
|
-
text: Wordprocessingml::Text.new(content: " ")
|
|
36
|
-
)]
|
|
35
|
+
text: Wordprocessingml::Text.new(content: " "),
|
|
36
|
+
)],
|
|
37
37
|
)],
|
|
38
38
|
)
|
|
39
39
|
end
|
|
@@ -141,11 +141,11 @@ module Uniword
|
|
|
141
141
|
spacing: Properties::Spacing.new(after: 0, line: 240,
|
|
142
142
|
line_rule: "auto"),
|
|
143
143
|
),
|
|
144
|
-
runs: [sep_run]
|
|
144
|
+
runs: [sep_run],
|
|
145
145
|
)
|
|
146
146
|
end
|
|
147
147
|
|
|
148
|
-
def ensure_separators(
|
|
148
|
+
def ensure_separators(_notes, type, entries)
|
|
149
149
|
entries.each do |entry|
|
|
150
150
|
next unless %w[separator continuationSeparator].include?(entry.type)
|
|
151
151
|
next if entry.paragraphs.empty?
|
|
@@ -162,7 +162,9 @@ module Uniword
|
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
def ensure_separator_run(para, type)
|
|
165
|
-
has_sep = para.runs.any?
|
|
165
|
+
has_sep = para.runs.any? do |r|
|
|
166
|
+
r.separator_char || r.continuation_separator_char
|
|
167
|
+
end
|
|
166
168
|
return if has_sep
|
|
167
169
|
|
|
168
170
|
sep = if type == "separator"
|
|
@@ -216,14 +218,18 @@ module Uniword
|
|
|
216
218
|
return if ref_order.empty?
|
|
217
219
|
|
|
218
220
|
structural = entries.select { |e| VALID_NOTE_TYPES.include?(e.type) }
|
|
219
|
-
user_entries = entries.reject
|
|
221
|
+
user_entries = entries.reject do |e|
|
|
222
|
+
VALID_NOTE_TYPES.include?(e.type)
|
|
223
|
+
end
|
|
220
224
|
return if user_entries.size <= 1
|
|
221
225
|
|
|
222
226
|
by_id = user_entries.group_by(&:id)
|
|
223
227
|
reordered = ref_order.filter_map { |id| by_id[id]&.first }
|
|
224
228
|
|
|
225
229
|
referenced_ids = ref_order.to_set
|
|
226
|
-
unreferenced = user_entries.reject
|
|
230
|
+
unreferenced = user_entries.reject do |e|
|
|
231
|
+
referenced_ids.include?(e.id)
|
|
232
|
+
end
|
|
227
233
|
reordered.concat(unreferenced)
|
|
228
234
|
|
|
229
235
|
return if reordered == user_entries
|
|
@@ -238,7 +244,9 @@ module Uniword
|
|
|
238
244
|
end
|
|
239
245
|
|
|
240
246
|
def renumber_notes(entries, type)
|
|
241
|
-
user_entries = entries.reject
|
|
247
|
+
user_entries = entries.reject do |e|
|
|
248
|
+
VALID_NOTE_TYPES.include?(e.type)
|
|
249
|
+
end
|
|
242
250
|
return if user_entries.size <= 1
|
|
243
251
|
|
|
244
252
|
id_map = {}
|
|
@@ -246,6 +254,7 @@ module Uniword
|
|
|
246
254
|
old_id = entry.id
|
|
247
255
|
new_id = (idx + 1).to_s
|
|
248
256
|
next if old_id == new_id
|
|
257
|
+
|
|
249
258
|
id_map[old_id] = new_id
|
|
250
259
|
entry.id = new_id
|
|
251
260
|
end
|
|
@@ -258,6 +267,7 @@ module Uniword
|
|
|
258
267
|
para.runs.each do |run|
|
|
259
268
|
ref = note_reference_from_run(run, type)
|
|
260
269
|
next unless ref && ref.id && id_map.key?(ref.id)
|
|
270
|
+
|
|
261
271
|
ref.id = id_map[ref.id]
|
|
262
272
|
end
|
|
263
273
|
end
|
|
@@ -274,6 +284,7 @@ module Uniword
|
|
|
274
284
|
para.runs.each do |run|
|
|
275
285
|
ref = note_reference_from_run(run, type)
|
|
276
286
|
next unless ref && ref.id
|
|
287
|
+
|
|
277
288
|
seen << ref.id unless seen.include?(ref.id)
|
|
278
289
|
end
|
|
279
290
|
end
|
|
@@ -74,7 +74,7 @@ module Uniword
|
|
|
74
74
|
kept << build_rel(
|
|
75
75
|
allocator.alloc_rid(target: defn.target, type: defn.rel_type,
|
|
76
76
|
scope: :package),
|
|
77
|
-
defn.rel_type, defn.target
|
|
77
|
+
defn.rel_type, defn.target
|
|
78
78
|
)
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -187,7 +187,7 @@ module Uniword
|
|
|
187
187
|
|
|
188
188
|
kept << build_rel(
|
|
189
189
|
alloc.alloc_rid(target: defn.target, type: defn.rel_type),
|
|
190
|
-
defn.rel_type, defn.target
|
|
190
|
+
defn.rel_type, defn.target
|
|
191
191
|
)
|
|
192
192
|
kept_targets << defn.target
|
|
193
193
|
end
|
|
@@ -204,7 +204,7 @@ module Uniword
|
|
|
204
204
|
|
|
205
205
|
kept << build_rel(
|
|
206
206
|
entry[:id], entry[:type], entry[:target],
|
|
207
|
-
target_mode: entry[:target_mode]
|
|
207
|
+
target_mode: entry[:target_mode]
|
|
208
208
|
)
|
|
209
209
|
kept_targets << entry[:target]
|
|
210
210
|
end
|
|
@@ -225,7 +225,7 @@ module Uniword
|
|
|
225
225
|
# is not in the store points at a part that will not be
|
|
226
226
|
# serialized and must be treated as stale.
|
|
227
227
|
def header_footer_target_present?(target)
|
|
228
|
-
header_like = target.start_with?("header"
|
|
228
|
+
header_like = target.start_with?("header", "footer")
|
|
229
229
|
if header_like && target.end_with?(".xml")
|
|
230
230
|
parts = package.document&.header_footer_parts
|
|
231
231
|
return false unless parts
|
|
@@ -251,20 +251,20 @@ module Uniword
|
|
|
251
251
|
|
|
252
252
|
old_cp = package.core_properties
|
|
253
253
|
package.core_properties = if old_cp
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
254
|
+
Ooxml::CoreProperties.new(
|
|
255
|
+
title: old_cp.title,
|
|
256
|
+
subject: old_cp.subject,
|
|
257
|
+
creator: old_cp.creator,
|
|
258
|
+
keywords: old_cp.keywords,
|
|
259
|
+
description: old_cp.description,
|
|
260
|
+
last_modified_by: old_cp.last_modified_by,
|
|
261
|
+
revision: old_cp.revision,
|
|
262
|
+
created: old_cp.created,
|
|
263
|
+
modified: old_cp.modified,
|
|
264
|
+
)
|
|
265
|
+
else
|
|
266
|
+
Ooxml::CoreProperties.new
|
|
267
|
+
end
|
|
268
268
|
cp = package.core_properties
|
|
269
269
|
|
|
270
270
|
if profile.user_name && !profile.user_name.empty?
|
|
@@ -333,7 +333,7 @@ module Uniword
|
|
|
333
333
|
end
|
|
334
334
|
|
|
335
335
|
def build_rsids(rsid)
|
|
336
|
-
root = "00#{hex_derive(
|
|
336
|
+
root = "00#{hex_derive('rsid_root', 3)}"
|
|
337
337
|
Wordprocessingml::Rsids.new(
|
|
338
338
|
rsid_root: Wordprocessingml::RsidRoot.new(val: root),
|
|
339
339
|
rsid: [Wordprocessingml::Rsid.new(val: rsid)],
|
|
@@ -429,21 +429,21 @@ module Uniword
|
|
|
429
429
|
|
|
430
430
|
unless style_ids.include?("Normal")
|
|
431
431
|
styles.add_style(Wordprocessingml::Style.new(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
432
|
+
type: "paragraph", default: true, styleId: "Normal",
|
|
433
|
+
name: Wordprocessingml::StyleName.new(val: "Normal"),
|
|
434
|
+
qFormat: Properties::QuickFormat.new
|
|
435
|
+
))
|
|
436
436
|
end
|
|
437
437
|
|
|
438
438
|
unless style_ids.include?("DefaultParagraphFont")
|
|
439
439
|
styles.add_style(Wordprocessingml::Style.new(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
440
|
+
type: "character", default: true,
|
|
441
|
+
styleId: "DefaultParagraphFont",
|
|
442
|
+
name: Wordprocessingml::StyleName.new(val: "Default Paragraph Font"),
|
|
443
|
+
uiPriority: Wordprocessingml::UiPriority.new(val: 1),
|
|
444
|
+
semiHidden: Wordprocessingml::SemiHidden.new,
|
|
445
|
+
unhideWhenUsed: Wordprocessingml::UnhideWhenUsed.new
|
|
446
|
+
))
|
|
447
447
|
end
|
|
448
448
|
|
|
449
449
|
dpf = styles.styles.find { |s| s.id == "DefaultParagraphFont" }
|
|
@@ -467,24 +467,24 @@ module Uniword
|
|
|
467
467
|
)
|
|
468
468
|
|
|
469
469
|
styles.add_style(Wordprocessingml::Style.new(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
470
|
+
type: "table", default: true, styleId: "TableNormal",
|
|
471
|
+
name: Wordprocessingml::StyleName.new(val: "Normal Table"),
|
|
472
|
+
uiPriority: Wordprocessingml::UiPriority.new(val: 99),
|
|
473
|
+
semiHidden: Wordprocessingml::SemiHidden.new,
|
|
474
|
+
unhideWhenUsed: Wordprocessingml::UnhideWhenUsed.new,
|
|
475
|
+
tblPr: tbl_pr
|
|
476
|
+
))
|
|
477
477
|
end
|
|
478
478
|
|
|
479
479
|
return if style_ids.include?("NoList")
|
|
480
480
|
|
|
481
481
|
styles.add_style(Wordprocessingml::Style.new(
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
482
|
+
type: "numbering", default: true, styleId: "NoList",
|
|
483
|
+
name: Wordprocessingml::StyleName.new(val: "No List"),
|
|
484
|
+
uiPriority: Wordprocessingml::UiPriority.new(val: 99),
|
|
485
|
+
semiHidden: Wordprocessingml::SemiHidden.new,
|
|
486
|
+
unhideWhenUsed: Wordprocessingml::UnhideWhenUsed.new
|
|
487
|
+
))
|
|
488
488
|
end
|
|
489
489
|
|
|
490
490
|
def font_names_for_profile
|
|
@@ -28,7 +28,7 @@ module Uniword
|
|
|
28
28
|
# Builder-managed path: builders create complete tables.
|
|
29
29
|
# Only fix element order issues, default gridCol widths, and
|
|
30
30
|
# calculate gridAfter.
|
|
31
|
-
def reconcile_table_cell_order_only(tbl,
|
|
31
|
+
def reconcile_table_cell_order_only(tbl, _idx)
|
|
32
32
|
tbl.rows&.each do |row|
|
|
33
33
|
row.cells&.each do |cell|
|
|
34
34
|
reconcile_table_cell_order(cell)
|
|
@@ -48,7 +48,8 @@ module Uniword
|
|
|
48
48
|
|
|
49
49
|
tw = tbl.properties.table_width
|
|
50
50
|
if tw.nil?
|
|
51
|
-
tbl.properties.table_width = Properties::TableWidth.new(w: 0,
|
|
51
|
+
tbl.properties.table_width = Properties::TableWidth.new(w: 0,
|
|
52
|
+
type: "auto")
|
|
52
53
|
fixed = true
|
|
53
54
|
elsif tw.w.nil? || tw.type.nil?
|
|
54
55
|
tw.w ||= 0
|
|
@@ -83,23 +84,27 @@ module Uniword
|
|
|
83
84
|
|
|
84
85
|
reconcile_grid_col_widths(tbl)
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
if fixed
|
|
88
|
+
record_fix(FixCodes::TABLE_STRUCTURE_RECONCILED,
|
|
89
|
+
"Reconciled table structure for table #{idx}",
|
|
90
|
+
part: "word/document.xml")
|
|
91
|
+
end
|
|
89
92
|
|
|
90
93
|
tbl.rows&.each do |row|
|
|
91
94
|
row.cells&.each do |cell|
|
|
92
95
|
tc_pr = cell.properties
|
|
93
96
|
if tc_pr.nil?
|
|
94
97
|
cell.properties = Wordprocessingml::TableCellProperties.new(
|
|
95
|
-
cell_width: Uniword::Properties::CellWidth.new(w: 0,
|
|
98
|
+
cell_width: Uniword::Properties::CellWidth.new(w: 0,
|
|
99
|
+
type: "auto"),
|
|
96
100
|
)
|
|
97
101
|
insert_element_order(cell, "tcPr", 0)
|
|
98
102
|
record_fix(FixCodes::TABLE_CELL_DEFAULTS,
|
|
99
103
|
"Added missing tcPr with tcW to table cell",
|
|
100
104
|
part: "word/document.xml")
|
|
101
105
|
elsif tc_pr.cell_width.nil?
|
|
102
|
-
tc_pr.cell_width = Uniword::Properties::CellWidth.new(w: 0,
|
|
106
|
+
tc_pr.cell_width = Uniword::Properties::CellWidth.new(w: 0,
|
|
107
|
+
type: "auto")
|
|
103
108
|
record_fix(FixCodes::TABLE_CELL_DEFAULTS,
|
|
104
109
|
"Added missing tcW to table cell",
|
|
105
110
|
part: "word/document.xml")
|
|
@@ -75,11 +75,13 @@ module Uniword
|
|
|
75
75
|
|
|
76
76
|
def count_line_styles(lst)
|
|
77
77
|
return 0 unless lst
|
|
78
|
+
|
|
78
79
|
(lst.lines || []).size
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
def count_effect_styles(lst)
|
|
82
83
|
return 0 unless lst
|
|
84
|
+
|
|
83
85
|
(lst.effect_styles || []).size
|
|
84
86
|
end
|
|
85
87
|
|
|
@@ -104,7 +106,7 @@ module Uniword
|
|
|
104
106
|
while fills.size < 2
|
|
105
107
|
fills << Drawingml::SolidFill.new(
|
|
106
108
|
scheme_clr: Drawingml::SchemeColor.new(
|
|
107
|
-
val: "accent#{fills.size + 1}"
|
|
109
|
+
val: "accent#{fills.size + 1}",
|
|
108
110
|
),
|
|
109
111
|
)
|
|
110
112
|
end
|
|
@@ -14,7 +14,8 @@ module Uniword
|
|
|
14
14
|
autoload :FixCodes, "#{__dir__}/reconciler/fix_codes"
|
|
15
15
|
autoload :Helpers, "#{__dir__}/reconciler/helpers"
|
|
16
16
|
autoload :Notes, "#{__dir__}/reconciler/notes"
|
|
17
|
-
autoload :ReferentialIntegrity,
|
|
17
|
+
autoload :ReferentialIntegrity,
|
|
18
|
+
"#{__dir__}/reconciler/referential_integrity"
|
|
18
19
|
autoload :Tables, "#{__dir__}/reconciler/tables"
|
|
19
20
|
autoload :Theme, "#{__dir__}/reconciler/theme"
|
|
20
21
|
autoload :Parts, "#{__dir__}/reconciler/parts"
|
|
@@ -35,49 +35,9 @@ module Uniword
|
|
|
35
35
|
validate_content(content)
|
|
36
36
|
validate_output_path(output_path)
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# Use Zip::OutputStream directly (not Zip::File) so that Entry objects
|
|
42
|
-
# with internal_file_attributes=0 are preserved through serialization.
|
|
43
|
-
# Zip::File wraps entries in StreamableStream which is NOT kind_of?(Entry),
|
|
44
|
-
# causing put_next_entry to discard our Entry and create a fresh one.
|
|
45
|
-
temp_path = "#{output_path}.#{Process.pid}.tmp"
|
|
46
|
-
|
|
47
|
-
ordered_content = order_content(content)
|
|
48
|
-
fixed_time = deterministic_timestamp
|
|
49
|
-
|
|
50
|
-
was_zip64 = Zip.write_zip64_support
|
|
51
|
-
Zip.write_zip64_support = false
|
|
52
|
-
begin
|
|
53
|
-
Zip::OutputStream.open(temp_path) do |zos|
|
|
54
|
-
ordered_content.each do |entry_path, entry_content|
|
|
55
|
-
entry = Zip::Entry.new(temp_path, entry_path.to_s)
|
|
56
|
-
entry.internal_file_attributes = 0
|
|
57
|
-
entry.external_file_attributes = 0
|
|
58
|
-
entry.fstype = Zip::FSTYPE_FAT
|
|
59
|
-
entry.time = fixed_time if fixed_time
|
|
60
|
-
|
|
61
|
-
zos.put_next_entry(entry)
|
|
62
|
-
|
|
63
|
-
final_content =
|
|
64
|
-
if entry_content.encoding == Encoding::ASCII_8BIT
|
|
65
|
-
entry_content
|
|
66
|
-
else
|
|
67
|
-
entry_content.encode(
|
|
68
|
-
"UTF-8", invalid: :replace, undef: :replace
|
|
69
|
-
)
|
|
70
|
-
end
|
|
71
|
-
zos.write(final_content)
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
ensure
|
|
75
|
-
Zip.write_zip64_support = was_zip64
|
|
38
|
+
with_deflate_flake_retry do
|
|
39
|
+
write_archive(content, output_path)
|
|
76
40
|
end
|
|
77
|
-
|
|
78
|
-
move_temp_to_output(temp_path, output_path)
|
|
79
|
-
ensure
|
|
80
|
-
remove_temp_file(temp_path)
|
|
81
41
|
end
|
|
82
42
|
|
|
83
43
|
# Add a file to an existing ZIP archive.
|
|
@@ -149,6 +109,87 @@ module Uniword
|
|
|
149
109
|
|
|
150
110
|
private
|
|
151
111
|
|
|
112
|
+
# Retry once on Zlib::BufError with a completely fresh archive
|
|
113
|
+
# write. Ruby's zlib wrapper raises this spuriously when the
|
|
114
|
+
# GVL-released deflate run is interrupted by a signal; no released
|
|
115
|
+
# Ruby or zlib gem carries the fix (ruby/ruby d848052e is
|
|
116
|
+
# master-only, uniword#105). The archive is rebuilt from the
|
|
117
|
+
# content hash, so a retry cannot mask real defects: genuinely
|
|
118
|
+
# unserializable content fails identically on the second attempt.
|
|
119
|
+
def with_deflate_flake_retry
|
|
120
|
+
yield
|
|
121
|
+
rescue Zlib::BufError => e
|
|
122
|
+
Uniword.logger.warn(
|
|
123
|
+
"ZipPackager: Zlib::BufError (#{e.message}); retrying with " \
|
|
124
|
+
"a fresh deflate stream",
|
|
125
|
+
)
|
|
126
|
+
yield
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Write the archive to a temp file, then move it into place.
|
|
130
|
+
#
|
|
131
|
+
# @param content [Hash<String, String>] paths to contents
|
|
132
|
+
# @param output_path [String] final archive path
|
|
133
|
+
# @return [void]
|
|
134
|
+
def write_archive(content, output_path)
|
|
135
|
+
# Ensure output directory exists
|
|
136
|
+
FileUtils.mkdir_p(File.dirname(output_path))
|
|
137
|
+
|
|
138
|
+
# Use Zip::OutputStream directly (not Zip::File) so that Entry objects
|
|
139
|
+
# with internal_file_attributes=0 are preserved through serialization.
|
|
140
|
+
# Zip::File wraps entries in StreamableStream which is NOT kind_of?(Entry),
|
|
141
|
+
# causing put_next_entry to discard our Entry and create a fresh one.
|
|
142
|
+
temp_path = "#{output_path}.#{Process.pid}.tmp"
|
|
143
|
+
|
|
144
|
+
ordered_content = order_content(content)
|
|
145
|
+
fixed_time = deterministic_timestamp
|
|
146
|
+
|
|
147
|
+
begin
|
|
148
|
+
write_entries_to_stream(temp_path, ordered_content, fixed_time)
|
|
149
|
+
|
|
150
|
+
move_temp_to_output(temp_path, output_path)
|
|
151
|
+
ensure
|
|
152
|
+
remove_temp_file(temp_path)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Stream every entry into a fresh Zip::OutputStream.
|
|
157
|
+
#
|
|
158
|
+
# @param temp_path [String] archive being written
|
|
159
|
+
# @param entries [Hash<String, String>] paths to contents
|
|
160
|
+
# @param fixed_time [Time, nil] deterministic timestamp, or nil
|
|
161
|
+
# @return [void]
|
|
162
|
+
def write_entries_to_stream(temp_path, entries, fixed_time)
|
|
163
|
+
was_zip64 = Zip.write_zip64_support
|
|
164
|
+
Zip.write_zip64_support = false
|
|
165
|
+
begin
|
|
166
|
+
Zip::OutputStream.open(temp_path) do |zos|
|
|
167
|
+
entries.each do |entry_path, entry_content|
|
|
168
|
+
entry = Zip::Entry.new(temp_path, entry_path.to_s)
|
|
169
|
+
entry.internal_file_attributes = 0
|
|
170
|
+
entry.external_file_attributes = 0
|
|
171
|
+
entry.fstype = Zip::FSTYPE_FAT
|
|
172
|
+
entry.time = fixed_time if fixed_time
|
|
173
|
+
|
|
174
|
+
zos.put_next_entry(entry)
|
|
175
|
+
zos.write(encode_entry_content(entry_content))
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
ensure
|
|
179
|
+
Zip.write_zip64_support = was_zip64
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# @param entry_content [String]
|
|
184
|
+
# @return [String] UTF-8 content, or binary content unchanged
|
|
185
|
+
def encode_entry_content(entry_content)
|
|
186
|
+
if entry_content.encoding == Encoding::ASCII_8BIT
|
|
187
|
+
entry_content
|
|
188
|
+
else
|
|
189
|
+
entry_content.encode("UTF-8", invalid: :replace, undef: :replace)
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
152
193
|
# When `Uniword.configuration.deterministic_output` is true,
|
|
153
194
|
# reorder entries (priority for OPC-required first, alphabetical
|
|
154
195
|
# for the rest). Otherwise return content unchanged (insertion
|
|
@@ -180,38 +221,17 @@ module Uniword
|
|
|
180
221
|
# @param output_path [String] The path for the output ZIP file
|
|
181
222
|
# @return [void]
|
|
182
223
|
def write_to_zip_file(content, output_path)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
was_zip64 = Zip.write_zip64_support
|
|
186
|
-
Zip.write_zip64_support = false
|
|
187
|
-
begin
|
|
188
|
-
Zip::OutputStream.open(temp_path) do |zos|
|
|
189
|
-
content.each do |entry_path, entry_content|
|
|
190
|
-
entry = Zip::Entry.new(temp_path, entry_path.to_s)
|
|
191
|
-
entry.internal_file_attributes = 0
|
|
192
|
-
entry.external_file_attributes = 0
|
|
193
|
-
entry.fstype = Zip::FSTYPE_FAT
|
|
224
|
+
with_deflate_flake_retry do
|
|
225
|
+
temp_path = "#{output_path}.#{Process.pid}.#{rand(1000)}.tmp"
|
|
194
226
|
|
|
195
|
-
|
|
227
|
+
begin
|
|
228
|
+
write_entries_to_stream(temp_path, content, nil)
|
|
196
229
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
else
|
|
201
|
-
entry_content.encode(
|
|
202
|
-
"UTF-8", invalid: :replace, undef: :replace
|
|
203
|
-
)
|
|
204
|
-
end
|
|
205
|
-
zos.write(final_content)
|
|
206
|
-
end
|
|
230
|
+
move_temp_to_output(temp_path, output_path)
|
|
231
|
+
ensure
|
|
232
|
+
remove_temp_file(temp_path)
|
|
207
233
|
end
|
|
208
|
-
ensure
|
|
209
|
-
Zip.write_zip64_support = was_zip64
|
|
210
234
|
end
|
|
211
|
-
|
|
212
|
-
move_temp_to_output(temp_path, output_path)
|
|
213
|
-
ensure
|
|
214
|
-
remove_temp_file(temp_path)
|
|
215
235
|
end
|
|
216
236
|
|
|
217
237
|
def move_temp_to_output(temp_path, output_path)
|
|
@@ -152,9 +152,9 @@ module Uniword
|
|
|
152
152
|
# If present, it should be a Plurimath formula
|
|
153
153
|
return true if formula.nil?
|
|
154
154
|
|
|
155
|
-
return false unless defined?(Plurimath::Formula)
|
|
155
|
+
return false unless defined?(Plurimath::Math::Formula)
|
|
156
156
|
|
|
157
|
-
formula.is_a?(Plurimath::Formula)
|
|
157
|
+
formula.is_a?(Plurimath::Math::Formula)
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
160
|
end
|
|
@@ -267,7 +267,9 @@ module Uniword
|
|
|
267
267
|
|
|
268
268
|
raise Uniword::ValidationError.new(
|
|
269
269
|
self,
|
|
270
|
-
issues.map { |issue|
|
|
270
|
+
issues.map { |issue|
|
|
271
|
+
"#{issue.code} (#{issue.part}): #{issue.message}"
|
|
272
|
+
},
|
|
271
273
|
issues: issues,
|
|
272
274
|
)
|
|
273
275
|
end
|
|
@@ -561,16 +561,20 @@ module Uniword
|
|
|
561
561
|
EXTENSION_NAMESPACES = [
|
|
562
562
|
Word2010, Word2012, Word2015Symex, Word2016Cid,
|
|
563
563
|
Word2018, Word2018Cex, Word2023Du, Word2020SdtDataHash,
|
|
564
|
-
Word2024SdtFormatLock
|
|
564
|
+
Word2024SdtFormatLock
|
|
565
565
|
].freeze
|
|
566
566
|
|
|
567
567
|
# mc:Ignorable prefixes for settings/fontTable/styles/webSettings
|
|
568
568
|
# (document-level parts without wp14). Sorted for canonical output.
|
|
569
|
-
EXTENSION_PREFIXES = EXTENSION_NAMESPACES.map
|
|
569
|
+
EXTENSION_PREFIXES = EXTENSION_NAMESPACES.map do |ns|
|
|
570
|
+
ns.new.prefix
|
|
571
|
+
end.sort.join(" ").freeze
|
|
570
572
|
|
|
571
573
|
# mc:Ignorable prefixes for document body parts that also include
|
|
572
574
|
# the wp14 (Word 2010 Drawing) namespace. Sorted for canonical output.
|
|
573
|
-
FULL_IGNORABLE_PREFIXES = (EXTENSION_NAMESPACES + [Word2010Drawing]).map
|
|
575
|
+
FULL_IGNORABLE_PREFIXES = (EXTENSION_NAMESPACES + [Word2010Drawing]).map do |ns|
|
|
576
|
+
ns.new.prefix
|
|
577
|
+
end.sort.join(" ").freeze
|
|
574
578
|
end
|
|
575
579
|
end
|
|
576
580
|
end
|
|
@@ -304,7 +304,7 @@ document_name = nil)
|
|
|
304
304
|
return [] unless footnotes.is_a?(Uniword::Wordprocessingml::Footnotes)
|
|
305
305
|
|
|
306
306
|
footnotes.footnote_entries.reject do |entry|
|
|
307
|
-
|
|
307
|
+
["separator", "continuationSeparator"].include?(entry.type)
|
|
308
308
|
end
|
|
309
309
|
end
|
|
310
310
|
|
|
@@ -316,8 +316,6 @@ document_name = nil)
|
|
|
316
316
|
"<div style='mso-element:footnote' id=\"ftn#{entry.id}\">\n#{html}\n</div>"
|
|
317
317
|
end
|
|
318
318
|
|
|
319
|
-
private
|
|
320
|
-
|
|
321
319
|
def section_divs(sections)
|
|
322
320
|
section_divs = sections.each_with_index.map do |section_elements, idx|
|
|
323
321
|
elements_html = section_elements.map do |element|
|
|
@@ -157,7 +157,8 @@ module Uniword
|
|
|
157
157
|
@doc_defaults = doc_defaults["run_properties"] || {}
|
|
158
158
|
@numbering = numbering
|
|
159
159
|
@defaults = resolve_defaults
|
|
160
|
-
@normal_spacing_after =
|
|
160
|
+
@normal_spacing_after = @para_styles.dig("Normal",
|
|
161
|
+
"paragraph_properties", "spacing", "after") || "6.0"
|
|
161
162
|
end
|
|
162
163
|
|
|
163
164
|
# Generate complete CSS string for MHTML output.
|
|
@@ -204,11 +205,11 @@ module Uniword
|
|
|
204
205
|
next if font.nil? || font.empty?
|
|
205
206
|
|
|
206
207
|
face = FONT_FACE_LIBRARY[font]
|
|
207
|
-
if face
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
faces << if face
|
|
209
|
+
face.strip
|
|
210
|
+
else
|
|
211
|
+
generic_font_face(font)
|
|
212
|
+
end
|
|
212
213
|
end
|
|
213
214
|
"/* Font Definitions */\n#{faces.join("\n")}" unless faces.empty?
|
|
214
215
|
end
|
|
@@ -377,17 +378,17 @@ module Uniword
|
|
|
377
378
|
spacing = para_props["spacing"] || {}
|
|
378
379
|
before = spacing["before"]
|
|
379
380
|
after = spacing["after"]
|
|
380
|
-
if before
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
381
|
+
lines << if before
|
|
382
|
+
" margin-top: #{pt_value(before)};"
|
|
383
|
+
else
|
|
384
|
+
" margin-top: 0cm;"
|
|
385
|
+
end
|
|
385
386
|
lines << " margin-right: 0cm;"
|
|
386
|
-
if after
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
387
|
+
lines << if after
|
|
388
|
+
" margin-bottom: #{pt_value(after)};"
|
|
389
|
+
else
|
|
390
|
+
" margin-bottom: #{pt_value(@normal_spacing_after)};"
|
|
391
|
+
end
|
|
391
392
|
lines << " margin-left: 0cm;"
|
|
392
393
|
|
|
393
394
|
# Indent
|
|
@@ -473,7 +474,7 @@ module Uniword
|
|
|
473
474
|
lines << " border-#{side}: #{border_str};"
|
|
474
475
|
lines << " mso-border-#{side}-alt: solid ##{color} #{pt_value(sz)};" if color && sz
|
|
475
476
|
if space
|
|
476
|
-
|
|
477
|
+
["top", "bottom"].include?(side) ? "top" : "left"
|
|
477
478
|
lines << " padding: #{pt_value(space)};"
|
|
478
479
|
end
|
|
479
480
|
end
|
|
@@ -481,11 +482,11 @@ module Uniword
|
|
|
481
482
|
|
|
482
483
|
# Font size
|
|
483
484
|
font_size = run_props["font_size"]
|
|
484
|
-
if font_size
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
485
|
+
lines << if font_size
|
|
486
|
+
" font-size: #{pt_value(font_size)};"
|
|
487
|
+
else
|
|
488
|
+
" font-size: #{pt_value(@defaults[:font_size])};"
|
|
489
|
+
end
|
|
489
490
|
|
|
490
491
|
# Font family
|
|
491
492
|
fonts = run_props["fonts"] || {}
|
|
@@ -704,7 +705,7 @@ module Uniword
|
|
|
704
705
|
return "" unless @numbering
|
|
705
706
|
|
|
706
707
|
definitions = @numbering["definitions"] || []
|
|
707
|
-
|
|
708
|
+
@numbering["instances"] || []
|
|
708
709
|
|
|
709
710
|
return "" if definitions.empty?
|
|
710
711
|
|
|
@@ -717,7 +718,7 @@ module Uniword
|
|
|
717
718
|
end
|
|
718
719
|
|
|
719
720
|
def generate_list_definition(idx, defn)
|
|
720
|
-
|
|
721
|
+
defn["abstract_num_id"]
|
|
721
722
|
levels = defn["levels"] || []
|
|
722
723
|
parts = ["@list l#{idx} {"]
|
|
723
724
|
|
|
@@ -733,7 +734,7 @@ module Uniword
|
|
|
733
734
|
"upperLetter" => "mso-level-number-format: alpha-upper;",
|
|
734
735
|
"lowerLetter" => "mso-level-number-format: alpha-lower;",
|
|
735
736
|
"upperRoman" => "mso-level-number-format: roman-upper;",
|
|
736
|
-
"lowerRoman" => "mso-level-number-format: roman-lower;"
|
|
737
|
+
"lowerRoman" => "mso-level-number-format: roman-lower;"
|
|
737
738
|
}
|
|
738
739
|
parts << " #{fmt_map[fmt]}" if fmt_map[fmt]
|
|
739
740
|
end
|
|
@@ -789,6 +790,7 @@ module Uniword
|
|
|
789
790
|
# Format a value as points (e.g., "11.0" → "11pt")
|
|
790
791
|
def pt_value(val)
|
|
791
792
|
return "0pt" unless val
|
|
793
|
+
|
|
792
794
|
v = val.to_f
|
|
793
795
|
v == v.to_i ? "#{v.to_i}pt" : "#{v}pt"
|
|
794
796
|
end
|
|
@@ -796,6 +798,7 @@ module Uniword
|
|
|
796
798
|
# Format a value as centimeters (e.g., "0.71" → "0.71cm")
|
|
797
799
|
def cm_value(val)
|
|
798
800
|
return "0cm" unless val
|
|
801
|
+
|
|
799
802
|
v = val.to_f
|
|
800
803
|
v == v.to_i ? "#{v.to_i}cm" : "#{v}cm"
|
|
801
804
|
end
|
|
@@ -16,7 +16,11 @@ module Uniword
|
|
|
16
16
|
|
|
17
17
|
def code = "DOC-105"
|
|
18
18
|
def validity_rule = "R14"
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
def description
|
|
21
|
+
"Core properties must have dc/dcterms/xsi namespaces and xsi:type on dates"
|
|
22
|
+
end
|
|
23
|
+
|
|
20
24
|
def category = :core_properties
|
|
21
25
|
def severity = "error"
|
|
22
26
|
|
|
@@ -12,7 +12,11 @@ module Uniword
|
|
|
12
12
|
|
|
13
13
|
def code = "DOC-100"
|
|
14
14
|
def validity_rule = "R1"
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
def description
|
|
17
|
+
"mc:Ignorable prefixes must have xmlns declarations in scope"
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
def category = :namespaces
|
|
17
21
|
def severity = "error"
|
|
18
22
|
|
|
@@ -15,7 +15,11 @@ module Uniword
|
|
|
15
15
|
|
|
16
16
|
def code = "DOC-103"
|
|
17
17
|
def validity_rule = "R4"
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
def description
|
|
20
|
+
"Numbering level elements and lvlOverride/startOverride are properly structured"
|
|
21
|
+
end
|
|
22
|
+
|
|
19
23
|
def category = :numbering
|
|
20
24
|
def severity = "warning"
|
|
21
25
|
|
|
@@ -16,7 +16,11 @@ module Uniword
|
|
|
16
16
|
|
|
17
17
|
def code = "DOC-108"
|
|
18
18
|
def validity_rule = "R6"
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
def description
|
|
21
|
+
"All rId references must resolve through .rels files to existing parts"
|
|
22
|
+
end
|
|
23
|
+
|
|
20
24
|
def category = :relationships
|
|
21
25
|
def severity = "error"
|
|
22
26
|
|
|
@@ -12,7 +12,11 @@ module Uniword
|
|
|
12
12
|
|
|
13
13
|
def code = "DOC-109"
|
|
14
14
|
def validity_rule = "R12"
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
def description
|
|
17
|
+
"Paragraphs should have rsidR and rsidRDefault attributes"
|
|
18
|
+
end
|
|
19
|
+
|
|
16
20
|
def category = :structure
|
|
17
21
|
def severity = "warning"
|
|
18
22
|
|
|
@@ -16,7 +16,11 @@ module Uniword
|
|
|
16
16
|
|
|
17
17
|
def code = "DOC-101"
|
|
18
18
|
def validity_rule = "R2"
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
def description
|
|
21
|
+
"Settings value formats (w15:docId GUID, w14:docId hex)"
|
|
22
|
+
end
|
|
23
|
+
|
|
20
24
|
def category = :settings
|
|
21
25
|
def severity = "error"
|
|
22
26
|
|
|
@@ -19,7 +19,11 @@ module Uniword
|
|
|
19
19
|
|
|
20
20
|
def code = "DOC-102"
|
|
21
21
|
def validity_rule = "R3"
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
def description
|
|
24
|
+
"Theme fmtScheme must have minimum content in each style list"
|
|
25
|
+
end
|
|
26
|
+
|
|
23
27
|
def category = :theme
|
|
24
28
|
def severity = "error"
|
|
25
29
|
|
data/lib/uniword/version.rb
CHANGED
|
@@ -110,11 +110,11 @@ module Uniword
|
|
|
110
110
|
# interleaving paragraphs, tables, and SDTs.
|
|
111
111
|
def append_to_element_order(element_name)
|
|
112
112
|
entry = Lutaml::Xml::Element.new("Element", element_name)
|
|
113
|
-
if element_order.nil? || element_order.empty?
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
self.element_order = if element_order.nil? || element_order.empty?
|
|
114
|
+
[entry]
|
|
115
|
+
else
|
|
116
|
+
element_order + [entry]
|
|
117
|
+
end
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
private
|
|
@@ -25,7 +25,10 @@ module Uniword
|
|
|
25
25
|
if attrs.is_a?(Hash)
|
|
26
26
|
text_val = attrs.delete(:text) || attrs[:content]
|
|
27
27
|
if text_val.is_a?(String)
|
|
28
|
-
|
|
28
|
+
if Text.preserve_whitespace?(text_val)
|
|
29
|
+
attrs[:xml_space] =
|
|
30
|
+
"preserve"
|
|
31
|
+
end
|
|
29
32
|
attrs[:content] = [text_val] unless attrs.key?(:content)
|
|
30
33
|
end
|
|
31
34
|
end
|
|
@@ -195,7 +195,8 @@ module Uniword
|
|
|
195
195
|
end
|
|
196
196
|
|
|
197
197
|
def yaml_page_break_before_to(instance, doc)
|
|
198
|
-
yaml_put(doc, "page_break_before",
|
|
198
|
+
yaml_put(doc, "page_break_before",
|
|
199
|
+
instance.page_break_before_wrapper&.on?)
|
|
199
200
|
end
|
|
200
201
|
|
|
201
202
|
def yaml_widow_control_from(instance, value)
|
data/lib/uniword.rb
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Prime the Moxml adapter selection BEFORE lutaml-model loads it, so the
|
|
4
|
+
# default is resolved deterministically from a clean load state. moxml
|
|
5
|
+
# memoizes its first verdict: Leptris when the engine's capability probe
|
|
6
|
+
# passes, otherwise the first loaded XML library (Nokogiri > Ox > Oga).
|
|
7
|
+
# When another gem in the bundle loads Ox early (e.g. Plurimath's chain
|
|
8
|
+
# on Ruby 4.0, where the Leptris probe legitimately fails per
|
|
9
|
+
# leptris-ruby#1966), an unpinned process silently runs the whole OOXML
|
|
10
|
+
# stack under the deprecated Ox adapter, whose serialization semantics
|
|
11
|
+
# differ (XSD round-trip attribute losses). Requiring our gemspec
|
|
12
|
+
# runtime dependency here freezes: Leptris when usable, else moxml's
|
|
13
|
+
# Nokogiri fallback - the contract documented below and validated in CI.
|
|
14
|
+
require "leptris"
|
|
3
15
|
require "lutaml/model"
|
|
4
16
|
require "zip"
|
|
5
17
|
|
metadata
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uniword
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.7.
|
|
4
|
+
version: 1.7.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: leptris
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 1.9.425
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 1.9.425
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: logger
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: '0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: lutaml-model
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.8.
|
|
47
|
+
version: 0.8.175
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.8.
|
|
54
|
+
version: 0.8.175
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: omml
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0.2.
|
|
61
|
+
version: 0.2.11
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0.2.
|
|
68
|
+
version: 0.2.11
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rainbow
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,28 +86,28 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '3.
|
|
89
|
+
version: '3.7'
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '3.
|
|
96
|
+
version: '3.7'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: thor
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '1.
|
|
103
|
+
version: '1.5'
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '1.
|
|
110
|
+
version: '1.5'
|
|
111
111
|
description: Comprehensive Ruby library for creating and manipulating Microsoft Word
|
|
112
112
|
documents in DOCX and MHTML formats. Features include full formatting support, tables,
|
|
113
113
|
lists, images, headers/footers, styles, and bidirectional format conversion.
|