Sha256: b903e467c4b108810328b6ef2dde6aa213013fbb8bc6493a565a3926bbe9df6d

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

# Docx Shape Size
module OoxmlParser
  class DocxShapeSize
    attr_accessor :rotation, :flip_horizontal, :flip_vertical, :offset, :extent

    alias extents extent

    def self.parse(xfrm_node)
      shape_size = DocxShapeSize.new
      xfrm_node.attributes.each do |key, value|
        case key
        when 'rot'
          shape_size.rotation = value.value.to_f
        when 'flipH'
          shape_size.flip_horizontal = value.value.to_f
        when 'flipV'
          shape_size.flip_vertical = value.value.to_f
        end
      end
      xfrm_node.xpath('*').each do |xfrm_node_child|
        case xfrm_node_child.name
        when 'off'
          shape_size.offset = OOXMLCoordinates.parse(xfrm_node_child)
        when 'ext'
          shape_size.extent = OOXMLCoordinates.parse(xfrm_node_child, x_attr: 'cx', y_attr: 'cy')
        end
      end
      shape_size
    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/docx_shape_size.rb
ooxml_parser-0.1.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_size.rb