Class: RODF::Text
Instance Method Summary
collapse
Methods inherited from Document
#add_default_styles, #add_office_styles, #add_styles, #bytes, #default_style, #default_styles, #default_styles_xml, file, #office_style, #office_styles, #office_styles_xml, #style, #styles, #styles_xml, #write_to
Methods inherited from Container
create, #initialize
Instance Method Details
#add_master_pages(*elements) ⇒ Object
115
116
117
118
119
120
121
122
123
|
# File 'lib/rodf/text.rb', line 115
def add_master_pages(*elements)
if elements.first.is_a?(Array)
elements = elements.first
end
elements.each do |element|
master_pages(element)
end
end
|
#add_page_layouts(*elements) ⇒ Object
89
90
91
92
93
94
95
96
97
|
# File 'lib/rodf/text.rb', line 89
def add_page_layouts(*elements)
if elements.first.is_a?(Array)
elements = elements.first
end
elements.each do |element|
page_layout(element)
end
end
|
#add_paragraphs(*elements) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/rodf/text.rb', line 63
def add_paragraphs(*elements)
if elements.first.is_a?(Array)
elements = elements.first
end
elements.each do |element|
paragraph(element)
end
end
|
#master_page(*args, &block) ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/rodf/text.rb', line 103
def master_page(*args, &block)
x = MasterPage.new(*args, &block)
master_pages << x
return x
end
|
#master_pages ⇒ Object
99
100
101
|
# File 'lib/rodf/text.rb', line 99
def master_pages
@master_pages ||= []
end
|
#master_pages_xml ⇒ Object
111
112
113
|
# File 'lib/rodf/text.rb', line 111
def master_pages_xml
master_pages.map(&:xml).join
end
|
#page_layout(*args, &block) ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/rodf/text.rb', line 77
def page_layout(*args, &block)
x = PageLayout.new(*args, &block)
page_layouts << x
return x
end
|
#page_layouts ⇒ Object
73
74
75
|
# File 'lib/rodf/text.rb', line 73
def page_layouts
@page_layouts ||= []
end
|
#page_layouts_xml ⇒ Object
85
86
87
|
# File 'lib/rodf/text.rb', line 85
def page_layouts_xml
page_layouts.map(&:xml).join
end
|
#paragraph(*args, &block) ⇒ Object
Also known as:
p
50
51
52
53
54
55
56
|
# File 'lib/rodf/text.rb', line 50
def paragraph(*args, &block)
x = Paragraph.new(*args, &block)
paragraphs << x
return x
end
|
#paragraphs ⇒ Object
46
47
48
|
# File 'lib/rodf/text.rb', line 46
def paragraphs
@paragraphs ||= []
end
|
#paragraphs_xml ⇒ Object
59
60
61
|
# File 'lib/rodf/text.rb', line 59
def paragraphs_xml
paragraphs.map(&:xml).join
end
|
#xml ⇒ Object
3
4
5
6
7
8
9
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
|
# File 'lib/rodf/text.rb', line 3
def xml
b = Builder::XmlMarkup.new
b.instruct! :xml, version: '1.0', encoding: 'UTF-8'
attrs = {
'xmlns:office' => "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
'xmlns:table' => "urn:oasis:names:tc:opendocument:xmlns:table:1.0",
'xmlns:text' => "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
'xmlns:oooc' => "http://openoffice.org/2004/calc",
'xmlns:style' => "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
'xmlns:fo' => "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",
'xmlns:xlink' => "http://www.w3.org/1999/xlink",
}
b.tag! 'office:document-content', attrs do |xml|
unless default_styles.empty?
xml.tag! 'office:styles' do
xml << default_styles_xml
end
end
unless styles.empty? && page_layouts.empty?
xml.tag! 'office:automatic-styles' do
xml << styles_xml
xml << page_layouts_xml
end
end
unless master_pages.empty?
xml.tag! 'office:master-styles' do
xml << master_pages_xml
end
end
xml.office:body do
xml.office:text do
xml << paragraphs_xml
end
end
end
end
|