Sha256: 5b545e7a3ce0afc80b6352367bd453cd52b3a9b13ceba77cea3066cbfc5b11e0
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 KB
Contents
require_relative 'shape/shape_properties' module OoxmlParser class Shape < OOXMLDocumentObject attr_accessor :type, :properties, :elements def initialize(type = nil, properties = ShapeProperties.new, elements = []) @type = type @properties = properties @elements = elements end def self.parse(shape_node, type) shape = Shape.new shape.type = type shape_node.attribute('style').value.to_s.split(';').each do |property| if property.include?('margin-top') shape.properties.margins.top = property.split(':').last elsif property.include?('margin-left') shape.properties.margins.left = property.split(':').last elsif property.include?('margin-right') shape.properties.margins.right = property.split(':').last elsif property.include?('width') shape.properties.size.width = property.split(':').last elsif property.include?('height') shape.properties.size.height = property.split(':').last elsif property.include?('z-index') shape.properties.z_index = property.split(':').last elsif property.include?('position') shape.properties.position = property.split(':').last end end shape.properties.fill_color = Color.from_int16(shape_node.attribute('fillcolor').value.to_s.sub('#', '').split(' ').first) unless shape_node.attribute('fillcolor').nil? shape.properties.stroke.weight = shape_node.attribute('strokeweight').value unless shape_node.attribute('strokeweight').nil? shape.properties.stroke.color = Color.from_int16(shape_node.attribute('strokecolor').value.to_s.sub('#', '').split(' ').first) unless shape_node.attribute('strokecolor').nil? shape.elements = TextBox.parse_list(shape_node.xpath('v:textbox').first) unless shape_node.xpath('v:textbox').first.nil? shape end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ooxml_parser-0.1.2 | lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/docx_paragraph_run/shape.rb |