Class: Uniword::Styles::ParagraphStyleDefinition

Inherits:
StyleDefinition show all
Defined in:
lib/uniword/wordprocessingml/styles/paragraph_style_definition.rb

Overview

Paragraph style definition

Responsibility: Hold paragraph-specific style properties Single Responsibility: Paragraph style configuration only

Defines formatting properties for paragraphs including alignment, spacing, indentation, and default run properties.

Direct Known Subclasses

SemanticStyle

Instance Attribute Summary collapse

Attributes inherited from StyleDefinition

#base_style, #name

Instance Method Summary collapse

Methods inherited from StyleDefinition

#properties

Constructor Details

#initialize(config) ⇒ ParagraphStyleDefinition

Returns a new instance of ParagraphStyleDefinition.



15
16
17
18
19
# File 'lib/uniword/wordprocessingml/styles/paragraph_style_definition.rb', line 15

def initialize(config)
  super
  @next_style = config[:next_style]
  @run_properties = config[:run_properties] || {}
end

Instance Attribute Details

#next_styleObject (readonly)

Returns the value of attribute next_style.



13
14
15
# File 'lib/uniword/wordprocessingml/styles/paragraph_style_definition.rb', line 13

def next_style
  @next_style
end

#run_propertiesObject (readonly)

Returns the value of attribute run_properties.



13
14
15
# File 'lib/uniword/wordprocessingml/styles/paragraph_style_definition.rb', line 13

def run_properties
  @run_properties
end

Instance Method Details

#full_propertiesHash

Get all properties including run properties

Returns:

  • (Hash)

    All style properties



41
42
43
44
45
46
# File 'lib/uniword/wordprocessingml/styles/paragraph_style_definition.rb', line 41

def full_properties
  {
    properties: properties,
    run_properties: @run_properties,
  }
end

#resolve_inheritance(library = nil) ⇒ Hash

Resolve inherited properties including run properties

Parameters:

  • library (StyleLibrary) (defaults to: nil)

    The style library to resolve base styles from

Returns:

  • (Hash)

    Merged properties including base style properties



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/uniword/wordprocessingml/styles/paragraph_style_definition.rb', line 25

def resolve_inheritance(library = nil)
  return full_properties unless @base_style && library

  base_def = library.paragraph_style(@base_style)
  base_props = base_def.resolve_inheritance(library)

  {
    properties: merge_properties(base_props[:properties], properties),
    run_properties: merge_properties(base_props[:run_properties],
                                     @run_properties),
  }
end