Sha256: f196831809dc0df7d475919d9095fb446d564ba884493ca6431793eac8c06310

Contents?: true

Size: 1.08 KB

Versions: 32

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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'
      super
    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

32 entries across 32 versions & 1 rubygems

Version Path
ooxml_parser-0.14.2 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.14.1-mingw32 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.14.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.14.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.13.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.12.2 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.12.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.12.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.11.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.10.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.9.1 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb
ooxml_parser-0.9.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/document_background.rb