Class: OoxmlParser::DocxDrawingProperties

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb

Overview

Docx Drawing Properties

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#distance_from_textDocxDrawingDistanceFromText (readonly)

Returns distance from text.

Returns:



12
13
14
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 12

def distance_from_text
  @distance_from_text
end

#horizontal_positionDocxDrawingPosition (readonly)

Returns horizontal position.

Returns:



24
25
26
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 24

def horizontal_position
  @horizontal_position
end

#object_sizeOOXMLCoordinates (readonly)

Returns size of object.

Returns:



20
21
22
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 20

def object_size
  @object_size
end

#relative_heightInteger (readonly)

Returns relative height of object.

Returns:

  • (Integer)

    relative height of object



16
17
18
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 16

def relative_height
  @relative_height
end

#simple_positionOOXMLCoordinates (readonly)

Returns simple position of object.

Returns:



18
19
20
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 18

def simple_position
  @simple_position
end

#size_relative_horizontalSizeRelativeHorizontal (readonly)

Returns size of drawing relative to horizontal.

Returns:



26
27
28
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 26

def size_relative_horizontal
  @size_relative_horizontal
end

#size_relative_verticalSizeRelativeVertical (readonly)

Returns size of drawing relative to vertical.

Returns:



28
29
30
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 28

def size_relative_vertical
  @size_relative_vertical
end

#vertical_positionDocxDrawingPosition (readonly)

Returns vertical position.

Returns:



22
23
24
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 22

def vertical_position
  @vertical_position
end

#wrapDocxWrapDrawing (readonly)

Returns wrap of drawing.

Returns:



14
15
16
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 14

def wrap
  @wrap
end

Instance Method Details

#parse(node) ⇒ DocxDrawingProperties

Parse DocxDrawingProperties

Parameters:

  • node (Nokogiri::XML:Node)

    with DocxDrawingProperties

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_drawing_properties.rb', line 33

def parse(node)
  @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node)
  @wrap = DocxWrapDrawing.new(parent: self).parse(node)

  node.attributes.each do |key, value|
    case key
    when 'relativeHeight'
      @relative_height = value.value.to_i
    end
  end

  node.xpath('*').each do |content_node_child|
    case content_node_child.name
    when 'simplePos'
      @simple_position = OOXMLCoordinates.new(parent: self).parse(content_node_child)
    when 'extent'
      @object_size = OOXMLCoordinates.new(parent: self)
                                     .parse(content_node_child,
                                            x_attr: 'cx',
                                            y_attr: 'cy',
                                            unit: :emu)
    when 'positionV'
      @vertical_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
    when 'positionH'
      @horizontal_position = DocxDrawingPosition.new(parent: self).parse(content_node_child)
    when 'sizeRelH'
      @size_relative_horizontal = SizeRelativeHorizontal.new(parent: self).parse(content_node_child)
    when 'sizeRelV'
      @size_relative_vertical = SizeRelativeVertical.new(parent: self).parse(content_node_child)
    end
  end
  self
end