Sha256: 97071d7fad7ef3ae34c0c9591acefb0d4c6cc13b7bd0a7b852419fa317e84d1d

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module OoxmlParser
  # Class for describing Document Background `w:background`
  class DocumentBackground < OOXMLDocumentObject
    attr_reader :color1, :size, :color2, :type
    # @return [FileReference] image structure
    attr_reader :file_reference
    # @return [Fill] fill data
    attr_reader :fill

    def initialize(parent: nil)
      @color1 = nil
      @type = 'simple'
      @parent = parent
    end

    # Parse DocumentBackground object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [DocumentBackground] result of parsing
    def parse(node)
      @color1 = Color.new(parent: self).parse_hex_string(node.attribute('color').value)
      node.xpath('v:background').each do |second_color|
        @size = second_color.attribute('targetscreensize').value.sub(',', 'x') unless second_color.attribute('targetscreensize').nil?
        second_color.xpath('*').each do |node_child|
          case node_child.name
          when 'fill'
            @fill = Fill.new(parent: self).parse(node_child)
          end
        end
      end
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ooxml_parser-0.4.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.4.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.3.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb