Class: Uniword::FindReplace::StylesScope

Inherits:
Scope
  • Object
show all
Defined in:
lib/uniword/find_replace/styles_scope.rb

Overview

Styles scope: text in style display names (<w:name w:val=...> inside word/styles.xml).

Style identifiers (w:styleId) are deliberately not touched — renaming a styleId breaks every reference. Use DocumentRoot#rename_style for that, which keeps references intact.

Instance Method Summary collapse

Methods inherited from Scope

#initialize

Constructor Details

This class inherits a constructor from Uniword::FindReplace::Scope

Instance Method Details

#each_text_node {|name_element, accessor| ... } ⇒ Object

Yield Parameters:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/uniword/find_replace/styles_scope.rb', line 20

def each_text_node
  styles = @document.styles_configuration&.styles
  return unless styles

  styles.each do |style|
    name_element = style.name
    next unless name_element
    next unless name_element.val

    accessor = TextAccessor.new(
      -> { name_element.val },
      ->(value) { name_element.val = value },
    )
    yield name_element, accessor
  end
end

#nameSymbol

Returns:

  • (Symbol)


14
15
16
# File 'lib/uniword/find_replace/styles_scope.rb', line 14

def name
  :styles
end