Class: Uniword::Wordprocessingml::Style

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/wordprocessingml/style.rb

Overview

Style definition

Generated from OOXML schema: wordprocessingml.yml Element: <w:style>

Instance Method Summary collapse

Instance Method Details

#alignmentObject



169
170
171
# File 'lib/uniword/wordprocessingml/style.rb', line 169

def alignment
  pPr&.alignment
end

#based_onObject



137
138
139
# File 'lib/uniword/wordprocessingml/style.rb', line 137

def based_on
  basedOn&.val
end

#boldObject



201
202
203
204
205
206
207
208
209
# File 'lib/uniword/wordprocessingml/style.rb', line 201

def bold
  return nil unless rPr

  val = rPr.bold
  return nil if val.nil?

  val = val.value if val.is_a?(Uniword::Properties::BooleanElement)
  val == true
end

#character_style?Boolean

Returns:

  • (Boolean)


235
236
237
# File 'lib/uniword/wordprocessingml/style.rb', line 235

def character_style?
  type == "character"
end

#custom?Boolean

Returns:

  • (Boolean)


227
228
229
# File 'lib/uniword/wordprocessingml/style.rb', line 227

def custom?
  customStyle == true
end

#font_colorObject



215
216
217
# File 'lib/uniword/wordprocessingml/style.rb', line 215

def font_color
  rPr&.color&.value
end

#font_color_themeObject



219
220
221
# File 'lib/uniword/wordprocessingml/style.rb', line 219

def font_color_theme
  rPr&.color&.theme_color
end

#font_color_theme_tintObject



223
224
225
# File 'lib/uniword/wordprocessingml/style.rb', line 223

def font_color_theme_tint
  rPr&.color&.theme_shade || rPr&.color&.theme_tint
end

#font_familyObject



197
198
199
# File 'lib/uniword/wordprocessingml/style.rb', line 197

def font_family
  rPr&.fonts&.ascii || rPr&.font
end

#font_sizeObject



211
212
213
# File 'lib/uniword/wordprocessingml/style.rb', line 211

def font_size
  rPr&.size&.value&.to_i
end

#idObject

Convenience read-only accessors (aliases for lutaml-model attributes)



129
130
131
# File 'lib/uniword/wordprocessingml/style.rb', line 129

def id
  styleId
end

#keep_linesObject



183
184
185
186
187
188
189
190
191
# File 'lib/uniword/wordprocessingml/style.rb', line 183

def keep_lines
  return false unless pPr

  val = pPr.keep_lines_wrapper
  return false if val.nil?

  val = val.value if val.is_a?(Uniword::Properties::BooleanElement)
  val == true
end

#keep_nextObject



173
174
175
176
177
178
179
180
181
# File 'lib/uniword/wordprocessingml/style.rb', line 173

def keep_next
  return false unless pPr

  val = pPr.keep_next_wrapper
  return false if val.nil?

  val = val.value if val.is_a?(Uniword::Properties::BooleanElement)
  val == true
end

#linked_styleObject



145
146
147
# File 'lib/uniword/wordprocessingml/style.rb', line 145

def linked_style
  link&.val
end

#next_styleObject



141
142
143
# File 'lib/uniword/wordprocessingml/style.rb', line 141

def next_style
  nextStyle&.val
end

#numbering_style?Boolean

Returns:

  • (Boolean)


243
244
245
# File 'lib/uniword/wordprocessingml/style.rb', line 243

def numbering_style?
  type == "numbering"
end

#outline_levelObject



193
194
195
# File 'lib/uniword/wordprocessingml/style.rb', line 193

def outline_level
  pPr&.outline_level&.value&.to_i
end

#paragraph_propertiesObject



247
248
249
# File 'lib/uniword/wordprocessingml/style.rb', line 247

def paragraph_properties
  pPr
end

#paragraph_style?Boolean

Returns:

  • (Boolean)


231
232
233
# File 'lib/uniword/wordprocessingml/style.rb', line 231

def paragraph_style?
  type == "paragraph"
end

#quick_formatObject



153
154
155
156
157
158
159
# File 'lib/uniword/wordprocessingml/style.rb', line 153

def quick_format
  val = qFormat
  return true if val == true

  val = val.value if val.is_a?(Uniword::Properties::BooleanElement)
  val == true
end

#run_propertiesObject



251
252
253
# File 'lib/uniword/wordprocessingml/style.rb', line 251

def run_properties
  rPr
end

#spacing_afterObject



165
166
167
# File 'lib/uniword/wordprocessingml/style.rb', line 165

def spacing_after
  pPr&.spacing&.after || pPr&.spacing_after
end

#spacing_beforeObject



161
162
163
# File 'lib/uniword/wordprocessingml/style.rb', line 161

def spacing_before
  pPr&.spacing&.before || pPr&.spacing_before
end

#style_nameObject



133
134
135
# File 'lib/uniword/wordprocessingml/style.rb', line 133

def style_name
  @name&.val
end

#table_style?Boolean

Returns:

  • (Boolean)


239
240
241
# File 'lib/uniword/wordprocessingml/style.rb', line 239

def table_style?
  type == "table"
end

#to_xml(options = {}) ⇒ Object



255
256
257
# File 'lib/uniword/wordprocessingml/style.rb', line 255

def to_xml(options = {})
  super(options.merge(fix_boolean_elements: true))
end

#ui_priorityObject



149
150
151
# File 'lib/uniword/wordprocessingml/style.rb', line 149

def ui_priority
  uiPriority&.val&.to_i
end

#yaml_based_on_from(instance, value) ⇒ Object



69
70
71
# File 'lib/uniword/wordprocessingml/style.rb', line 69

def yaml_based_on_from(instance, value)
  instance.basedOn = BasedOn.new(val: value) if value
end

#yaml_based_on_to(instance, _doc) ⇒ Object



73
74
75
# File 'lib/uniword/wordprocessingml/style.rb', line 73

def yaml_based_on_to(instance, _doc)
  instance.basedOn&.val
end

#yaml_linked_style_from(instance, value) ⇒ Object



85
86
87
# File 'lib/uniword/wordprocessingml/style.rb', line 85

def yaml_linked_style_from(instance, value)
  instance.link = Link.new(val: value) if value
end

#yaml_linked_style_to(instance, _doc) ⇒ Object



89
90
91
# File 'lib/uniword/wordprocessingml/style.rb', line 89

def yaml_linked_style_to(instance, _doc)
  instance.link&.val
end

#yaml_name_from(instance, value) ⇒ Object

YAML transform methods (instance methods - called via send on an instance)



53
54
55
# File 'lib/uniword/wordprocessingml/style.rb', line 53

def yaml_name_from(instance, value)
  instance.name = StyleName.new(val: value) if value
end

#yaml_name_to(instance, _doc) ⇒ Object



57
58
59
# File 'lib/uniword/wordprocessingml/style.rb', line 57

def yaml_name_to(instance, _doc)
  instance.name&.val
end

#yaml_next_style_from(instance, value) ⇒ Object



77
78
79
# File 'lib/uniword/wordprocessingml/style.rb', line 77

def yaml_next_style_from(instance, value)
  instance.nextStyle = Next.new(val: value) if value
end

#yaml_next_style_to(instance, _doc) ⇒ Object



81
82
83
# File 'lib/uniword/wordprocessingml/style.rb', line 81

def yaml_next_style_to(instance, _doc)
  instance.nextStyle&.val
end

#yaml_quick_format_from(instance, value) ⇒ Object



61
62
63
# File 'lib/uniword/wordprocessingml/style.rb', line 61

def yaml_quick_format_from(instance, value)
  instance.qFormat = Properties::QuickFormat.new(value: value) unless value.nil?
end

#yaml_quick_format_to(instance, _doc) ⇒ Object



65
66
67
# File 'lib/uniword/wordprocessingml/style.rb', line 65

def yaml_quick_format_to(instance, _doc)
  instance.qFormat&.value
end

#yaml_ui_priority_from(instance, value) ⇒ Object



93
94
95
# File 'lib/uniword/wordprocessingml/style.rb', line 93

def yaml_ui_priority_from(instance, value)
  instance.uiPriority = UiPriority.new(val: value.to_s) if value
end

#yaml_ui_priority_to(instance, _doc) ⇒ Object



97
98
99
# File 'lib/uniword/wordprocessingml/style.rb', line 97

def yaml_ui_priority_to(instance, _doc)
  instance.uiPriority&.val&.to_i
end