Sha256: da9dd84b00749e5d2c9fba250e2be5108f51cbd4ff90a06c70461d114891d881

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# DOCX Color Scheme
module OoxmlParser
  class DocxColorScheme < OOXMLDocumentObject
    attr_accessor :color, :type

    def initialize
      @color = Color.new
      @type = :unknown
    end

    def self.parse(color_scheme_node)
      color_scheme = DocxColorScheme.new
      color_scheme_node.xpath('*').each do |color_scheme_node_child|
        case color_scheme_node_child.name
        when 'solidFill'
          color_scheme.type = :solid
          color_scheme.color = Color.parse_color_model(color_scheme_node_child)
        when 'gradFill'
          color_scheme.type = :gradient
          color_scheme.color = GradientColor.parse(color_scheme_node_child)
        when 'noFill'
          color_scheme.color = :none
          color_scheme.type = :none
        when 'srgbClr'
          color_scheme.color = Color.from_int16(color_scheme_node_child.attribute('val').value)
        when 'schemeClr'
          color_scheme.color = Color.parse_scheme_color(color_scheme_node_child)
        end
      end
      color_scheme
    end

    def to_s
      "Color: #{@color}, type: #{type}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ooxml_parser-0.1.2 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb
ooxml_parser-0.1.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/color/docx_color_scheme.rb