Class: Rubyword::Writer::Part::Document
- Inherits:
-
Base
- Object
- Base
- Rubyword::Writer::Part::Document
show all
- Includes:
- Toc
- Defined in:
- lib/rubyword/writer/part/document.rb
Constant Summary
collapse
- DOCUMENT_ATTR =
{
'xmlns:ve' => "http://schemas.openxmlformats.org/markup-compatibility/2006",
'xmlns:o' => "urn:schemas-microsoft-com:office:office",
'xmlns:r' => "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
'xmlns:m' => "http://schemas.openxmlformats.org/officeDocument/2006/math",
'xmlns:v' => "urn:schemas-microsoft-com:vml",
'xmlns:wp' => "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
'xmlns:w10' => "urn:schemas-microsoft-com:office:word",
'xmlns:w' => "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
'xmlns:wne' => "http://schemas.microsoft.com/office/word/2006/wordml"
}
Instance Attribute Summary
Attributes inherited from Base
#rubyword, #section
Instance Method Summary
collapse
Methods included from Toc
#write_toc
Methods inherited from Base
#initialize
Instance Method Details
#section_write(xml) ⇒ Object
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/rubyword/writer/part/document.rb', line 30
def section_write(xml)
@object_blocks = []
sections_count = @rubyword.sections.count
current_section = 0
write_toc(@rubyword, xml)
@rubyword.sections.each do |section|
current_section = current_section + 1
section.objects.each{|object|
object.write(section, xml)
}
if current_section == sections_count
Style::Section.new(section, xml, @rubyword).write
else
xml.send('w:p') {
xml.send('w:pPr') {
Style::Section.new(section, xml, @rubyword).write
}
}
end
end
if @rubyword.sections.empty?
Style::Section.new(section, xml, @rubyword).write
end
end
|
#write ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rubyword/writer/part/document.rb', line 19
def write
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.send('w:document', DOCUMENT_ATTR) {
xml.send('w:body') {
section_write(xml)
}
}
end
builder.to_xml
end
|