Class: Docxtor::Document::TableOfContents

Inherits:
Element
  • Object
show all
Defined in:
lib/docxtor/document/table_of_contents.rb

Constant Summary collapse

STYLE =
'defprnRUSSelStyle'
PARAGRAPH_STYLE =
'10'

Instance Attribute Summary

Attributes inherited from Element

#elements, #xml

Instance Method Summary collapse

Methods inherited from Element

#initialize, map

Constructor Details

This class inherits a constructor from Docxtor::Document::Element

Instance Method Details

#after_initialize(text) ⇒ Object



7
8
9
10
# File 'lib/docxtor/document/table_of_contents.rb', line 7

def after_initialize(text)
  create_params({:style => STYLE})
  @text = text
end

#render(xml) ⇒ Object

TODO: Add support for extended styling & properties



14
15
16
17
18
19
20
21
22
23
24
25
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
59
# File 'lib/docxtor/document/table_of_contents.rb', line 14

def render(xml)
  super

  xml.w :sdt, "xmlns:w" => "http://schemas.openxmlformats.org/wordprocessingml/2006/main" do

    write_properties

    xml.w :sdtContent do

      write_heading

      xml.w :p do
        xml.w :pPr do
          xml.w :pStyle, "w:val" => PARAGRAPH_STYLE
          xml.w :tabs do
            xml.w :tab, "w:val" => "right", "w:leader" => "dot", "w:pos" => 9350
          end
          xml.w :rPr do
            xml.w :noProof
          end
        end
        xml.w :r do
          xml.w :fldChar, "w:fldCharType" => "begin", "w:dirty" => true
        end

        write_instruct

        xml.w :r do
          xml.w :fldChar, "w:fldCharType" => "separate"
        end
      end

      xml.w :p do
        xml.w :r do
          # xml.w :rPr do
          #   xml.w :b
          #   xml.w :bCs
          #   xml.w :noProof
          # end
          xml.w :fldChar, "w:fldCharType" => "end"
        end
      end

    end
  end
end