Class: OoxmlParser::DocxWrapDrawing

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

Overview

Docx Wrap Drawing

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ DocxWrapDrawing

Returns a new instance of DocxWrapDrawing.



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

def initialize(parent: nil)
  @wrap_text = :none
  super
end

Instance Attribute Details

#behind_docBoolean (readonly)

Returns Specifies whether this floating DrawingML object is displayed behind the text of the document when the document is displayed. When a DrawingML object is displayed within a WordprocessingML document, that object can intersect with text in the document. This attribute shall determine whether the text or the object is rendered on top in case of overlapping.

Returns:

  • (Boolean)

    Specifies whether this floating DrawingML object is displayed behind the text of the document when the document is displayed. When a DrawingML object is displayed within a WordprocessingML document, that object can intersect with text in the document. This attribute shall determine whether the text or the object is rendered on top in case of overlapping.



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

def behind_doc
  @behind_doc
end

#distance_from_textObject

Returns the value of attribute distance_from_text.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb', line 6

def distance_from_text
  @distance_from_text
end

#wrap_textObject

Returns the value of attribute wrap_text.



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb', line 6

def wrap_text
  @wrap_text
end

Instance Method Details

#parse(node) ⇒ DocxWrapDrawing

Parse DocxWrapDrawing object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



26
27
28
29
30
31
32
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
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/drawing_properties/docx_wrap_drawing.rb', line 26

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'behindDoc'
      @behind_doc = attribute_enabled?(value)
    end
  end

  @wrap_text = :behind if @behind_doc == true
  @wrap_text = :infront if @behind_doc == false

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'wrapSquare'
      @wrap_text = :square
      @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
      break
    when 'wrapTight'
      @wrap_text = :tight
      @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
      break
    when 'wrapThrough'
      @wrap_text = :through
      @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
      break
    when 'wrapTopAndBottom'
      @wrap_text = :topbottom
      @distance_from_text = DocxDrawingDistanceFromText.new(parent: self).parse(node_child)
      break
    end
  end
  self
end