class Docxtor2::Package::Document::TableOfContents
Public Class Methods
new(text, &block)
click to toggle source
Calls superclass method
Docxtor2::Package::Document::Element::new
# File lib/docxtor2/package/document/table_of_contents.rb, line 3 def initialize(text, &block) super({ :style => Known::Styles::TOC }, &block) @text = text end
Public Instance Methods
render(xml)
click to toggle source
TODO: Add support for extended styling & properties
Calls superclass method
Docxtor2::Package::Document::Element#render
# 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
Private Instance Methods
write_heading()
click to toggle source
# File lib/docxtor2/package/document/table_of_contents.rb, line 68 def write_heading @xml.w :p do @xml.w :pPr do @xml.w :pStyle, "w:val" => @params[:style] end @xml.w :r do @xml.w :t do @xml.text! @text end end end end
write_instruct()
click to toggle source
# File lib/docxtor2/package/document/table_of_contents.rb, line 81 def write_instruct @xml.w :r do @xml.w :instrText, "xml:space" => "preserve" do @xml.text! " TOC \\o '1-3' \\h \\z \\u " end end end
write_properties()
click to toggle source
# File lib/docxtor2/package/document/table_of_contents.rb, line 59 def write_properties @xml.w :sdtPr do @xml.w :docPartObj do @xml.w :docPartGallery, "w:val" => "Table of Contents" @xml.w :docPartUnique end end end