Class: Uniword::Styles::TableStyleDefinition

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

Overview

Table style definition

Responsibility: Hold table-specific style properties Single Responsibility: Table style configuration only

Defines formatting properties for tables including borders, cell spacing, cell padding, and conditional formatting.

Instance Attribute Summary collapse

Attributes inherited from StyleDefinition

#base_style, #name

Instance Method Summary collapse

Methods inherited from StyleDefinition

#properties

Constructor Details

#initialize(config) ⇒ TableStyleDefinition

Returns a new instance of TableStyleDefinition.



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

def initialize(config)
  super
  @table_properties = config[:table_properties] || {}
  @cell_properties = config[:cell_properties] || {}
  @conditional_formatting = config[:conditional_formatting] || {}
end

Instance Attribute Details

#cell_propertiesObject (readonly)

Returns the value of attribute cell_properties.



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

def cell_properties
  @cell_properties
end

#conditional_formattingObject (readonly)

Returns the value of attribute conditional_formatting.



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

def conditional_formatting
  @conditional_formatting
end

#table_propertiesObject (readonly)

Returns the value of attribute table_properties.



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

def table_properties
  @table_properties
end

Instance Method Details

#full_propertiesHash

Get all properties

Returns:

  • (Hash)

    All style properties



47
48
49
50
51
52
53
# File 'lib/uniword/wordprocessingml/styles/table_style_definition.rb', line 47

def full_properties
  {
    table_properties: @table_properties,
    cell_properties: @cell_properties,
    conditional_formatting: @conditional_formatting,
  }
end

#resolve_inheritance(library = nil) ⇒ Hash

Resolve inherited properties for tables

Parameters:

  • library (StyleLibrary) (defaults to: nil)

    The style library to resolve base styles from

Returns:

  • (Hash)

    Merged properties including base style properties



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/uniword/wordprocessingml/styles/table_style_definition.rb', line 26

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

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

  {
    table_properties: merge_properties(base_props[:table_properties],
                                       @table_properties),
    cell_properties: merge_properties(base_props[:cell_properties],
                                      @cell_properties),
    conditional_formatting: merge_properties(
      base_props[:conditional_formatting],
      @conditional_formatting,
    ),
  }
end