Sha256: 58a28b88b94f8c6dc6d9196944ebeb80b089ad98160f228ce057c1fa9baa2291

Contents?: true

Size: 1.66 KB

Versions: 34

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Docx Shape Size
  class DocxShapeSize < OOXMLDocumentObject
    # @return [OoxmlSize] rotation info
    attr_reader :rotation
    # @return [OOXMLCoordinates] offset info
    attr_reader :offset
    # @return [OOXMLCoordinates] extent info
    attr_reader :extent
    # @return [OOXMLCoordinates] child offset
    attr_reader :child_offset
    # @return [OOXMLCoordinates] child extent
    attr_reader :child_extent
    # @return [True, False] is image flipped horizontally
    attr_reader :flip_horizontal
    # @return [True, False] is image flipped vertically
    attr_reader :flip_vertical

    alias extents extent

    # Parse DocxShapeSize object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [DocxShapeSize] result of parsing
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'rot'
          @rotation = OoxmlSize.new(value.value.to_f, :one_60000th_degree)
        when 'flipH'
          @flip_horizontal = attribute_enabled?(value)
        when 'flipV'
          @flip_vertical = attribute_enabled?(value)
        end
      end
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'off'
          @offset = OOXMLCoordinates.parse(node_child, unit: :emu)
        when 'ext'
          @extent = OOXMLCoordinates.parse(node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
        when 'chOff'
          @child_offset = OOXMLCoordinates.parse(node_child, unit: :emu)
        when 'chExt'
          @child_extent = OOXMLCoordinates.parse(node_child, x_attr: 'cx', y_attr: 'cy', unit: :emu)
        end
      end
      self
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.22.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.21.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.20.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.19.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.18.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.18.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.17.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.16.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb
ooxml_parser-0.15.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb