Class: Docxtor2::Package::Document::TableOfContents

Inherits:
Element show all
Defined in:
lib/docxtor2/package/document/table_of_contents.rb

Instance Method Summary collapse

Methods included from ObjectUtils

#find_argument

Methods included from BlockEvaluator

#evaluate

Methods inherited from ElementList

map

Constructor Details

#initialize(text, &block) ⇒ TableOfContents

Returns a new instance of TableOfContents.



3
4
5
6
# File 'lib/docxtor2/package/document/table_of_contents.rb', line 3

def initialize(text, &block)
  super({ :style => Known::Styles::TOC }, &block)
  @text = text
end

Instance Method Details

#render(xml) ⇒ Object

TODO: Add support for extended styling & properties



10
11
12
13
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
# File 'lib/docxtor2/package/document/table_of_contents.rb', line 10

def render(xml)
  super(xml)

  @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" => Known::Styles::TOC_PARAGRAPH
          @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