uniword 1.0.8 → 1.0.10
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/data/themes/office_format_scheme.xml +137 -0
- data/data/themes/office_theme.xml +2 -0
- data/lib/uniword/builder/comment_builder.rb +2 -1
- data/lib/uniword/builder/footnote_builder.rb +4 -2
- data/lib/uniword/builder/run_builder.rb +5 -0
- data/lib/uniword/document_input.rb +7 -0
- data/lib/uniword/document_writer.rb +1 -5
- data/lib/uniword/docx/package.rb +18 -0
- data/lib/uniword/docx/package_serialization.rb +38 -0
- data/lib/uniword/docx/reconciler.rb +159 -4
- data/lib/uniword/format_converter.rb +4 -19
- data/lib/uniword/has_run_position.rb +9 -0
- data/lib/uniword/lazy_loader.rb +1 -1
- data/lib/uniword/math/o_math.rb +3 -0
- data/lib/uniword/mhtml/document.rb +18 -0
- data/lib/uniword/properties/bold.rb +3 -33
- data/lib/uniword/properties/boolean_element_factory.rb +66 -0
- data/lib/uniword/properties/boolean_formatting.rb +15 -215
- data/lib/uniword/properties/italic.rb +3 -33
- data/lib/uniword/properties.rb +8 -3
- data/lib/uniword/schema/schema_loader.rb +1 -1
- data/lib/uniword/transformation/mhtml_element_renderer.rb +1 -1
- data/lib/uniword/version.rb +1 -1
- data/lib/uniword/wordprocessingml/attached_template.rb +18 -0
- data/lib/uniword/wordprocessingml/body.rb +18 -36
- data/lib/uniword/wordprocessingml/brk_bin.rb +17 -0
- data/lib/uniword/wordprocessingml/brk_bin_sub.rb +17 -0
- data/lib/uniword/wordprocessingml/character_spacing_control.rb +17 -0
- data/lib/uniword/wordprocessingml/clr_scheme_mapping.rb +39 -0
- data/lib/uniword/wordprocessingml/compat.rb +16 -0
- data/lib/uniword/wordprocessingml/decimal_symbol.rb +17 -0
- data/lib/uniword/wordprocessingml/def_jc.rb +17 -0
- data/lib/uniword/wordprocessingml/default_tab_stop.rb +17 -0
- data/lib/uniword/wordprocessingml/disp_def.rb +14 -0
- data/lib/uniword/wordprocessingml/do_not_display_page_boundaries.rb +14 -0
- data/lib/uniword/wordprocessingml/do_not_include_subdocs_in_stats.rb +17 -0
- data/lib/uniword/wordprocessingml/doc_vars.rb +36 -0
- data/lib/uniword/wordprocessingml/document_root.rb +17 -5
- data/lib/uniword/wordprocessingml/endnote_pr.rb +18 -0
- data/lib/uniword/wordprocessingml/endnotes.rb +18 -0
- data/lib/uniword/wordprocessingml/even_and_odd_headers.rb +17 -0
- data/lib/uniword/wordprocessingml/footnote_pos.rb +17 -0
- data/lib/uniword/wordprocessingml/footnote_pr.rb +20 -0
- data/lib/uniword/wordprocessingml/footnotes.rb +18 -0
- data/lib/uniword/wordprocessingml/hdr_shape_defaults.rb +19 -0
- data/lib/uniword/wordprocessingml/hyperlink.rb +3 -0
- data/lib/uniword/wordprocessingml/hyphenation_zone.rb +20 -0
- data/lib/uniword/wordprocessingml/int_lim.rb +17 -0
- data/lib/uniword/wordprocessingml/l_margin.rb +17 -0
- data/lib/uniword/wordprocessingml/list_separator.rb +17 -0
- data/lib/uniword/wordprocessingml/math_font.rb +17 -0
- data/lib/uniword/wordprocessingml/math_pr.rb +49 -0
- data/lib/uniword/wordprocessingml/mirror_margins.rb +17 -0
- data/lib/uniword/wordprocessingml/nary_lim.rb +17 -0
- data/lib/uniword/wordprocessingml/proof_state.rb +19 -0
- data/lib/uniword/wordprocessingml/r_margin.rb +17 -0
- data/lib/uniword/wordprocessingml/rsid.rb +17 -0
- data/lib/uniword/wordprocessingml/rsid_root.rb +17 -0
- data/lib/uniword/wordprocessingml/rsids.rb +22 -0
- data/lib/uniword/wordprocessingml/settings.rb +45 -511
- data/lib/uniword/wordprocessingml/shape_defaults.rb +21 -0
- data/lib/uniword/wordprocessingml/small_frac.rb +17 -0
- data/lib/uniword/wordprocessingml/style_pane_format_filter.rb +50 -0
- data/lib/uniword/wordprocessingml/style_pane_sort_method.rb +20 -0
- data/lib/uniword/wordprocessingml/table_cell.rb +6 -0
- data/lib/uniword/wordprocessingml/table_row_properties.rb +2 -0
- data/lib/uniword/wordprocessingml/theme_font_lang.rb +19 -0
- data/lib/uniword/wordprocessingml/w14_doc_id.rb +17 -0
- data/lib/uniword/wordprocessingml/w15_chart_tracking_ref_based.rb +14 -0
- data/lib/uniword/wordprocessingml/w15_doc_id.rb +17 -0
- data/lib/uniword/wordprocessingml/wrap_indent.rb +17 -0
- data/lib/uniword/wordprocessingml.rb +42 -56
- data/lib/uniword.rb +12 -5
- metadata +52 -3
- data/lib/uniword/ooxml/types/on_off_type.rb +0 -64
|
@@ -1,40 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative "boolean_element_factory"
|
|
4
4
|
|
|
5
5
|
module Uniword
|
|
6
6
|
module Properties
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# OOXML: <w:b/> means bold=true (absence of val= means true)
|
|
10
|
-
# <w:b w:val="false"/> means bold=false
|
|
11
|
-
#
|
|
12
|
-
# Model: nil = true (no val attribute), 'false' = explicit false
|
|
13
|
-
class Bold < Lutaml::Model::Serializable
|
|
14
|
-
include Uniword::Properties::BooleanElement
|
|
15
|
-
|
|
16
|
-
attribute :val, :string, default: nil
|
|
17
|
-
include Uniword::Properties::BooleanValSetter
|
|
18
|
-
|
|
19
|
-
xml do
|
|
20
|
-
element "b"
|
|
21
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
22
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Complex script bold
|
|
27
|
-
class BoldCs < Lutaml::Model::Serializable
|
|
28
|
-
include Uniword::Properties::BooleanElement
|
|
29
|
-
|
|
30
|
-
attribute :val, :string, default: nil
|
|
31
|
-
include Uniword::Properties::BooleanValSetter
|
|
32
|
-
|
|
33
|
-
xml do
|
|
34
|
-
element "bCs"
|
|
35
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
36
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
37
|
-
end
|
|
38
|
-
end
|
|
7
|
+
BooleanElementFactory.define("b", "Bold")
|
|
8
|
+
BooleanElementFactory.define("bCs", "BoldCs")
|
|
39
9
|
end
|
|
40
10
|
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "lutaml/model"
|
|
4
|
+
|
|
5
|
+
module Uniword
|
|
6
|
+
module Properties
|
|
7
|
+
# OOXML boolean element mixin for value/val getter logic only.
|
|
8
|
+
# The val= setter must be defined AFTER attribute :val to override
|
|
9
|
+
# the generated setter.
|
|
10
|
+
module BooleanElement
|
|
11
|
+
def value
|
|
12
|
+
val != "false"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Helper to define val= override after attribute declaration.
|
|
17
|
+
module BooleanValSetter
|
|
18
|
+
def self.included(base)
|
|
19
|
+
base.define_method(:val=) do |v|
|
|
20
|
+
@val = case v
|
|
21
|
+
when nil then nil
|
|
22
|
+
when false, "false" then "false"
|
|
23
|
+
when true, "true" then nil
|
|
24
|
+
else v
|
|
25
|
+
end
|
|
26
|
+
value_set_for(:val)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Factory for OOXML boolean element classes.
|
|
32
|
+
#
|
|
33
|
+
# Generates a lutaml-model class that maps to an XML element like
|
|
34
|
+
# <w:b/> (true) or <w:b w:val="false"/> (false).
|
|
35
|
+
#
|
|
36
|
+
# @param element_name [String] XML element name (e.g. "b", "i", "strike")
|
|
37
|
+
# @param class_name [String] Ruby class name (e.g. "Bold", "Italic")
|
|
38
|
+
# @return [Class] The generated class, also assigned as a constant
|
|
39
|
+
#
|
|
40
|
+
# @example
|
|
41
|
+
# BooleanElementFactory.define("b", "Bold")
|
|
42
|
+
# BooleanElementFactory.define("bCs", "BoldCs")
|
|
43
|
+
module BooleanElementFactory
|
|
44
|
+
WML_NS = Uniword::Ooxml::Namespaces::WordProcessingML
|
|
45
|
+
|
|
46
|
+
def self.define(element_name, class_name)
|
|
47
|
+
klass = Class.new(Lutaml::Model::Serializable) do
|
|
48
|
+
include BooleanElement
|
|
49
|
+
|
|
50
|
+
attribute :val, :string, default: nil
|
|
51
|
+
include BooleanValSetter
|
|
52
|
+
|
|
53
|
+
xml do
|
|
54
|
+
element element_name
|
|
55
|
+
namespace WML_NS
|
|
56
|
+
map_attribute "val", to: :val, render_nil: false,
|
|
57
|
+
render_default: false
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Properties.const_set(class_name, klass)
|
|
62
|
+
klass
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -1,224 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative "boolean_element_factory"
|
|
4
4
|
|
|
5
5
|
module Uniword
|
|
6
6
|
module Properties
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
module BooleanValSetter
|
|
19
|
-
def self.included(base)
|
|
20
|
-
base.class_eval do
|
|
21
|
-
# Save the generated val= method
|
|
22
|
-
alias_method :__original_val_setter=, :val= if method_defined?(:val=)
|
|
23
|
-
# Override val= with our custom logic
|
|
24
|
-
define_method(:val=) do |v|
|
|
25
|
-
@val = if v.nil?
|
|
26
|
-
nil
|
|
27
|
-
elsif v == false || v.to_s == "false"
|
|
28
|
-
"false"
|
|
29
|
-
elsif v == true || v.to_s == "true"
|
|
30
|
-
nil
|
|
31
|
-
else
|
|
32
|
-
v
|
|
33
|
-
end
|
|
34
|
-
value_set_for(:val)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Strike-through formatting
|
|
41
|
-
class Strike < Lutaml::Model::Serializable
|
|
42
|
-
include BooleanElement
|
|
43
|
-
|
|
44
|
-
attribute :val, :string, default: nil
|
|
45
|
-
include BooleanValSetter
|
|
46
|
-
|
|
47
|
-
xml do
|
|
48
|
-
element "strike"
|
|
49
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
50
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Double strike-through formatting
|
|
55
|
-
class DoubleStrike < Lutaml::Model::Serializable
|
|
56
|
-
include BooleanElement
|
|
57
|
-
|
|
58
|
-
attribute :val, :string, default: nil
|
|
59
|
-
include BooleanValSetter
|
|
60
|
-
|
|
61
|
-
xml do
|
|
62
|
-
element "dstrike"
|
|
63
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
64
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Small caps formatting
|
|
69
|
-
class SmallCaps < Lutaml::Model::Serializable
|
|
70
|
-
include BooleanElement
|
|
71
|
-
|
|
72
|
-
attribute :val, :string, default: nil
|
|
73
|
-
include BooleanValSetter
|
|
74
|
-
|
|
75
|
-
xml do
|
|
76
|
-
element "smallCaps"
|
|
77
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
78
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# All caps formatting
|
|
83
|
-
class Caps < Lutaml::Model::Serializable
|
|
84
|
-
include BooleanElement
|
|
85
|
-
|
|
86
|
-
attribute :val, :string, default: nil
|
|
87
|
-
include BooleanValSetter
|
|
88
|
-
|
|
89
|
-
xml do
|
|
90
|
-
element "caps"
|
|
91
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
92
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Hidden text
|
|
97
|
-
class Vanish < Lutaml::Model::Serializable
|
|
98
|
-
include BooleanElement
|
|
99
|
-
|
|
100
|
-
attribute :val, :string, default: nil
|
|
101
|
-
include BooleanValSetter
|
|
102
|
-
|
|
103
|
-
xml do
|
|
104
|
-
element "vanish"
|
|
105
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
106
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# Web hidden text (hidden from web view)
|
|
111
|
-
class WebHidden < Lutaml::Model::Serializable
|
|
112
|
-
include BooleanElement
|
|
113
|
-
|
|
114
|
-
attribute :val, :string, default: nil
|
|
115
|
-
include BooleanValSetter
|
|
116
|
-
|
|
117
|
-
xml do
|
|
118
|
-
element "webHidden"
|
|
119
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
120
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# No proofing (disable spell/grammar check)
|
|
125
|
-
class NoProof < Lutaml::Model::Serializable
|
|
126
|
-
include BooleanElement
|
|
127
|
-
|
|
128
|
-
attribute :val, :string, default: nil
|
|
129
|
-
include BooleanValSetter
|
|
130
|
-
|
|
131
|
-
xml do
|
|
132
|
-
element "noProof"
|
|
133
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
134
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
# Shadow formatting
|
|
139
|
-
class Shadow < Lutaml::Model::Serializable
|
|
140
|
-
include BooleanElement
|
|
141
|
-
|
|
142
|
-
attribute :val, :string, default: nil
|
|
143
|
-
include BooleanValSetter
|
|
144
|
-
|
|
145
|
-
xml do
|
|
146
|
-
element "shadow"
|
|
147
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
148
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# Emboss formatting
|
|
153
|
-
class Emboss < Lutaml::Model::Serializable
|
|
154
|
-
include BooleanElement
|
|
155
|
-
|
|
156
|
-
attribute :val, :string, default: nil
|
|
157
|
-
include BooleanValSetter
|
|
158
|
-
|
|
159
|
-
xml do
|
|
160
|
-
element "emboss"
|
|
161
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
162
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
# Imprint formatting
|
|
167
|
-
class Imprint < Lutaml::Model::Serializable
|
|
168
|
-
include BooleanElement
|
|
169
|
-
|
|
170
|
-
attribute :val, :string, default: nil
|
|
171
|
-
include BooleanValSetter
|
|
172
|
-
|
|
173
|
-
xml do
|
|
174
|
-
element "imprint"
|
|
175
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
176
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
177
|
-
end
|
|
178
|
-
end
|
|
7
|
+
# Run-level boolean formatting elements
|
|
8
|
+
BooleanElementFactory.define("strike", "Strike")
|
|
9
|
+
BooleanElementFactory.define("dstrike", "DoubleStrike")
|
|
10
|
+
BooleanElementFactory.define("smallCaps", "SmallCaps")
|
|
11
|
+
BooleanElementFactory.define("caps", "Caps")
|
|
12
|
+
BooleanElementFactory.define("vanish", "Vanish")
|
|
13
|
+
BooleanElementFactory.define("webHidden", "WebHidden")
|
|
14
|
+
BooleanElementFactory.define("noProof", "NoProof")
|
|
15
|
+
BooleanElementFactory.define("shadow", "Shadow")
|
|
16
|
+
BooleanElementFactory.define("emboss", "Emboss")
|
|
17
|
+
BooleanElementFactory.define("imprint", "Imprint")
|
|
179
18
|
|
|
180
19
|
# Style-level boolean elements
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
include BooleanElement
|
|
185
|
-
|
|
186
|
-
attribute :val, :string, default: nil
|
|
187
|
-
include BooleanValSetter
|
|
188
|
-
|
|
189
|
-
xml do
|
|
190
|
-
element "qFormat"
|
|
191
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
192
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
# Keep with next paragraph
|
|
197
|
-
class KeepNext < Lutaml::Model::Serializable
|
|
198
|
-
include BooleanElement
|
|
199
|
-
|
|
200
|
-
attribute :val, :string, default: nil
|
|
201
|
-
include BooleanValSetter
|
|
202
|
-
|
|
203
|
-
xml do
|
|
204
|
-
element "keepNext"
|
|
205
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
206
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
# Keep lines together
|
|
211
|
-
class KeepLines < Lutaml::Model::Serializable
|
|
212
|
-
include BooleanElement
|
|
213
|
-
|
|
214
|
-
attribute :val, :string, default: nil
|
|
215
|
-
include BooleanValSetter
|
|
216
|
-
|
|
217
|
-
xml do
|
|
218
|
-
element "keepLines"
|
|
219
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
220
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
221
|
-
end
|
|
222
|
-
end
|
|
20
|
+
BooleanElementFactory.define("qFormat", "QuickFormat")
|
|
21
|
+
BooleanElementFactory.define("keepNext", "KeepNext")
|
|
22
|
+
BooleanElementFactory.define("keepLines", "KeepLines")
|
|
223
23
|
end
|
|
224
24
|
end
|
|
@@ -1,40 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative "boolean_element_factory"
|
|
4
4
|
|
|
5
5
|
module Uniword
|
|
6
6
|
module Properties
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# OOXML: <w:i/> means italic=true (absence of val= means true)
|
|
10
|
-
# <w:i w:val="false"/> means italic=false
|
|
11
|
-
#
|
|
12
|
-
# Model: nil = true (no val attribute), 'false' = explicit false
|
|
13
|
-
class Italic < Lutaml::Model::Serializable
|
|
14
|
-
include Uniword::Properties::BooleanElement
|
|
15
|
-
|
|
16
|
-
attribute :val, :string, default: nil
|
|
17
|
-
include Uniword::Properties::BooleanValSetter
|
|
18
|
-
|
|
19
|
-
xml do
|
|
20
|
-
element "i"
|
|
21
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
22
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Complex script italic
|
|
27
|
-
class ItalicCs < Lutaml::Model::Serializable
|
|
28
|
-
include Uniword::Properties::BooleanElement
|
|
29
|
-
|
|
30
|
-
attribute :val, :string, default: nil
|
|
31
|
-
include Uniword::Properties::BooleanValSetter
|
|
32
|
-
|
|
33
|
-
xml do
|
|
34
|
-
element "iCs"
|
|
35
|
-
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
36
|
-
map_attribute "val", to: :val, render_nil: false, render_default: false
|
|
37
|
-
end
|
|
38
|
-
end
|
|
7
|
+
BooleanElementFactory.define("i", "Italic")
|
|
8
|
+
BooleanElementFactory.define("iCs", "ItalicCs")
|
|
39
9
|
end
|
|
40
10
|
end
|
data/lib/uniword/properties.rb
CHANGED
|
@@ -23,10 +23,13 @@ module Uniword
|
|
|
23
23
|
autoload :NumberingProperties, "uniword/properties/numbering_properties"
|
|
24
24
|
autoload :Tabs, "uniword/properties/tabs"
|
|
25
25
|
|
|
26
|
+
# Boolean element infrastructure
|
|
27
|
+
autoload :BooleanElement, "uniword/properties/boolean_element_factory"
|
|
28
|
+
autoload :BooleanValSetter, "uniword/properties/boolean_element_factory"
|
|
29
|
+
autoload :BooleanElementFactory,
|
|
30
|
+
"uniword/properties/boolean_element_factory"
|
|
31
|
+
|
|
26
32
|
# Boolean formatting classes (from boolean_formatting.rb)
|
|
27
|
-
# Note: BooleanElement and BooleanValSetter are also in boolean_formatting.rb
|
|
28
|
-
autoload :BooleanElement, "uniword/properties/boolean_formatting"
|
|
29
|
-
autoload :BooleanValSetter, "uniword/properties/boolean_formatting"
|
|
30
33
|
autoload :Strike, "uniword/properties/boolean_formatting"
|
|
31
34
|
autoload :DoubleStrike, "uniword/properties/boolean_formatting"
|
|
32
35
|
autoload :SmallCaps, "uniword/properties/boolean_formatting"
|
|
@@ -49,7 +52,9 @@ module Uniword
|
|
|
49
52
|
|
|
50
53
|
# Bold and Italic (from bold.rb and italic.rb)
|
|
51
54
|
autoload :Bold, "uniword/properties/bold"
|
|
55
|
+
autoload :BoldCs, "uniword/properties/bold"
|
|
52
56
|
autoload :Italic, "uniword/properties/italic"
|
|
57
|
+
autoload :ItalicCs, "uniword/properties/italic"
|
|
53
58
|
|
|
54
59
|
# Complex objects
|
|
55
60
|
autoload :Spacing, "uniword/properties/spacing"
|
|
@@ -547,7 +547,7 @@ module Uniword
|
|
|
547
547
|
def build_position_map(elements, fallback_pos)
|
|
548
548
|
by_pos = {}
|
|
549
549
|
elements.each do |el|
|
|
550
|
-
pos = el.run_position if el.is_a?(Uniword::
|
|
550
|
+
pos = el.run_position if el.is_a?(Uniword::HasRunPosition)
|
|
551
551
|
pos ||= fallback_pos
|
|
552
552
|
by_pos[pos] ||= []
|
|
553
553
|
by_pos[pos] << el
|
data/lib/uniword/version.rb
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "lutaml/model"
|
|
4
|
+
require_relative "../properties/relationship_id"
|
|
5
|
+
|
|
6
|
+
module Uniword
|
|
7
|
+
module Wordprocessingml
|
|
8
|
+
class AttachedTemplate < Lutaml::Model::Serializable
|
|
9
|
+
attribute :r_id, Properties::RelationshipIdValue
|
|
10
|
+
|
|
11
|
+
xml do
|
|
12
|
+
element "attachedTemplate"
|
|
13
|
+
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
14
|
+
map_attribute "id", to: :r_id
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -71,48 +71,30 @@ module Uniword
|
|
|
71
71
|
def sync_element_order
|
|
72
72
|
return if element_order.nil? || element_order.empty?
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
ordered_tbl_count = element_order.count { |e| e.name == "tbl" }
|
|
77
|
-
ordered_sdt_count = element_order.count { |e| e.name == "sdt" }
|
|
78
|
-
ordered_bookmark_start_count = element_order.count do |e|
|
|
79
|
-
e.name == "bookmarkStart"
|
|
80
|
-
end
|
|
81
|
-
ordered_bookmark_end_count = element_order.count do |e|
|
|
82
|
-
e.name == "bookmarkEnd"
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Add missing paragraphs
|
|
86
|
-
(paragraphs.size - ordered_p_count).times do
|
|
87
|
-
element_order << Lutaml::Xml::Element.new("Element", "p")
|
|
74
|
+
counts = element_order.each_with_object(Hash.new(0)) do |e, h|
|
|
75
|
+
h[e.name] += 1
|
|
88
76
|
end
|
|
89
77
|
|
|
90
|
-
|
|
91
|
-
(tables.size -
|
|
92
|
-
|
|
93
|
-
|
|
78
|
+
append_missing_elements("p", paragraphs.size - counts["p"])
|
|
79
|
+
append_missing_elements("tbl", tables.size - counts["tbl"])
|
|
80
|
+
append_missing_elements("sdt",
|
|
81
|
+
structured_document_tags.size - counts["sdt"])
|
|
82
|
+
append_missing_elements("bookmarkStart",
|
|
83
|
+
bookmark_starts.size - counts["bookmarkStart"])
|
|
84
|
+
append_missing_elements("bookmarkEnd",
|
|
85
|
+
bookmark_ends.size - counts["bookmarkEnd"])
|
|
94
86
|
|
|
95
|
-
|
|
96
|
-
(structured_document_tags.size - ordered_sdt_count).times do
|
|
97
|
-
element_order << Lutaml::Xml::Element.new("Element", "sdt")
|
|
98
|
-
end
|
|
87
|
+
return unless section_properties && counts["sectPr"].zero?
|
|
99
88
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
element_order << Lutaml::Xml::Element.new("Element", "bookmarkStart")
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Add missing bookmark ends
|
|
106
|
-
(bookmark_ends.size - ordered_bookmark_end_count).times do
|
|
107
|
-
element_order << Lutaml::Xml::Element.new("Element", "bookmarkEnd")
|
|
108
|
-
end
|
|
89
|
+
element_order << build_order_element("sectPr")
|
|
90
|
+
end
|
|
109
91
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
end
|
|
92
|
+
def append_missing_elements(name, count)
|
|
93
|
+
count.times { element_order << build_order_element(name) }
|
|
94
|
+
end
|
|
114
95
|
|
|
115
|
-
|
|
96
|
+
def build_order_element(name)
|
|
97
|
+
Lutaml::Xml::Element.new("Element", name)
|
|
116
98
|
end
|
|
117
99
|
end
|
|
118
100
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "lutaml/model"
|
|
4
|
+
|
|
5
|
+
module Uniword
|
|
6
|
+
module Wordprocessingml
|
|
7
|
+
class BrkBin < Lutaml::Model::Serializable
|
|
8
|
+
attribute :val, :string
|
|
9
|
+
|
|
10
|
+
xml do
|
|
11
|
+
element "brkBin"
|
|
12
|
+
namespace Uniword::Ooxml::Namespaces::MathML
|
|
13
|
+
map_attribute "val", to: :val
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "lutaml/model"
|
|
4
|
+
|
|
5
|
+
module Uniword
|
|
6
|
+
module Wordprocessingml
|
|
7
|
+
class BrkBinSub < Lutaml::Model::Serializable
|
|
8
|
+
attribute :val, :string
|
|
9
|
+
|
|
10
|
+
xml do
|
|
11
|
+
element "brkBinSub"
|
|
12
|
+
namespace Uniword::Ooxml::Namespaces::MathML
|
|
13
|
+
map_attribute "val", to: :val
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "lutaml/model"
|
|
4
|
+
|
|
5
|
+
module Uniword
|
|
6
|
+
module Wordprocessingml
|
|
7
|
+
class CharacterSpacingControl < Lutaml::Model::Serializable
|
|
8
|
+
attribute :val, :string
|
|
9
|
+
|
|
10
|
+
xml do
|
|
11
|
+
element "characterSpacingControl"
|
|
12
|
+
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
13
|
+
map_attribute "val", to: :val
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "lutaml/model"
|
|
4
|
+
|
|
5
|
+
module Uniword
|
|
6
|
+
module Wordprocessingml
|
|
7
|
+
class ClrSchemeMapping < Lutaml::Model::Serializable
|
|
8
|
+
attribute :bg1, :string
|
|
9
|
+
attribute :t1, :string
|
|
10
|
+
attribute :bg2, :string
|
|
11
|
+
attribute :t2, :string
|
|
12
|
+
attribute :accent1, :string
|
|
13
|
+
attribute :accent2, :string
|
|
14
|
+
attribute :accent3, :string
|
|
15
|
+
attribute :accent4, :string
|
|
16
|
+
attribute :accent5, :string
|
|
17
|
+
attribute :accent6, :string
|
|
18
|
+
attribute :hyperlink, :string
|
|
19
|
+
attribute :followed_hyperlink, :string
|
|
20
|
+
|
|
21
|
+
xml do
|
|
22
|
+
element "clrSchemeMapping"
|
|
23
|
+
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
24
|
+
map_attribute "bg1", to: :bg1
|
|
25
|
+
map_attribute "t1", to: :t1
|
|
26
|
+
map_attribute "bg2", to: :bg2
|
|
27
|
+
map_attribute "t2", to: :t2
|
|
28
|
+
map_attribute "accent1", to: :accent1
|
|
29
|
+
map_attribute "accent2", to: :accent2
|
|
30
|
+
map_attribute "accent3", to: :accent3
|
|
31
|
+
map_attribute "accent4", to: :accent4
|
|
32
|
+
map_attribute "accent5", to: :accent5
|
|
33
|
+
map_attribute "accent6", to: :accent6
|
|
34
|
+
map_attribute "hyperlink", to: :hyperlink
|
|
35
|
+
map_attribute "followedHyperlink", to: :followed_hyperlink
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -14,12 +14,25 @@ module Uniword
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# Do not use HTML paragraph auto spacing (empty marker element)
|
|
18
|
+
#
|
|
19
|
+
# Element: <w:doNotUseHTMLParagraphAutoSpacing>
|
|
20
|
+
# Parent: <w:compat>
|
|
21
|
+
class DoNotUseHTMLParagraphAutoSpacing < Lutaml::Model::Serializable
|
|
22
|
+
xml do
|
|
23
|
+
element "doNotUseHTMLParagraphAutoSpacing"
|
|
24
|
+
namespace Uniword::Ooxml::Namespaces::WordProcessingML
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
17
28
|
# Compatibility settings
|
|
18
29
|
#
|
|
19
30
|
# Generated from OOXML schema: wordprocessingml.yml
|
|
20
31
|
# Element: <w:compat>
|
|
21
32
|
class Compat < Lutaml::Model::Serializable
|
|
22
33
|
attribute :use_fe_layout, UseFELayout
|
|
34
|
+
attribute :do_not_use_html_paragraph_auto_spacing,
|
|
35
|
+
DoNotUseHTMLParagraphAutoSpacing
|
|
23
36
|
attribute :compatSetting, CompatSetting, collection: true,
|
|
24
37
|
initialize_empty: true
|
|
25
38
|
|
|
@@ -29,6 +42,9 @@ module Uniword
|
|
|
29
42
|
mixed_content
|
|
30
43
|
|
|
31
44
|
map_element "useFELayout", to: :use_fe_layout, render_nil: false
|
|
45
|
+
map_element "doNotUseHTMLParagraphAutoSpacing",
|
|
46
|
+
to: :do_not_use_html_paragraph_auto_spacing,
|
|
47
|
+
render_nil: false
|
|
32
48
|
map_element "compatSetting", to: :compatSetting, render_nil: false
|
|
33
49
|
end
|
|
34
50
|
end
|