rodf 0.3.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +132 -62
- data/Rakefile +4 -19
- data/lib/{odf → rodf}/cell.rb +48 -27
- data/lib/{odf → rodf}/column.rb +1 -2
- data/lib/{odf → rodf}/compatibility.rb +0 -0
- data/lib/{odf → rodf}/container.rb +1 -4
- data/lib/{odf → rodf}/data_style.rb +3 -5
- data/lib/{odf → rodf}/document.rb +4 -6
- data/lib/{odf → rodf}/hyperlink.rb +2 -3
- data/lib/{odf → rodf}/master_page.rb +1 -2
- data/lib/{odf → rodf}/page_layout.rb +3 -4
- data/lib/{odf → rodf}/paragraph.rb +2 -3
- data/lib/{odf → rodf}/paragraph_container.rb +2 -3
- data/lib/{odf → rodf}/property.rb +9 -10
- data/lib/{odf → rodf}/row.rb +3 -4
- data/lib/{odf → rodf}/skeleton/manifest.xml.erb +0 -0
- data/lib/{odf → rodf}/skeleton/styles.pxml +0 -0
- data/lib/{odf → rodf}/skeleton.rb +1 -1
- data/lib/{odf → rodf}/span.rb +5 -4
- data/lib/{odf → rodf}/spreadsheet.rb +7 -12
- data/lib/{odf → rodf}/style.rb +4 -5
- data/lib/{odf → rodf}/style_section.rb +1 -3
- data/lib/{odf → rodf}/tab.rb +2 -3
- data/lib/{odf → rodf}/table.rb +4 -5
- data/lib/{odf → rodf}/text.rb +8 -10
- data/lib/rodf/version.rb +3 -0
- data/lib/rodf.rb +6 -0
- metadata +85 -108
- data/CHANGELOG +0 -17
- data/Gemfile +0 -9
- data/Manifest +0 -48
- data/rodf.gemspec +0 -48
- data/spec/cell_spec.rb +0 -189
- data/spec/data_style_spec.rb +0 -61
- data/spec/file_storage_spec.rb +0 -47
- data/spec/hyperlink_spec.rb +0 -62
- data/spec/master_page_spec.rb +0 -35
- data/spec/page_layout_spec.rb +0 -45
- data/spec/paragraph_spec.rb +0 -75
- data/spec/property_spec.rb +0 -270
- data/spec/row_spec.rb +0 -59
- data/spec/skeleton_spec.rb +0 -33
- data/spec/span_spec.rb +0 -65
- data/spec/spec_helper.rb +0 -23
- data/spec/spreadsheet_spec.rb +0 -123
- data/spec/style_section_spec.rb +0 -42
- data/spec/style_spec.rb +0 -109
- data/spec/tab_spec.rb +0 -34
- data/spec/table_spec.rb +0 -90
- data/spec/text_spec.rb +0 -79
data/spec/property_spec.rb
DELETED
@@ -1,270 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'odf/property'
|
21
|
-
|
22
|
-
describe ODF::Property do
|
23
|
-
it "should accept either strings or symbols as keys" do
|
24
|
-
property = ODF::Property.new :text, :color=>'#4c4c4c', 'font-weight'=>'bold'
|
25
|
-
elem = Hpricot(property.xml).at('style:text-properties')
|
26
|
-
elem['fo:color'].should == '#4c4c4c'
|
27
|
-
elem['fo:font-weight'].should == 'bold'
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should prefix style properties with looked up namespace" do
|
31
|
-
Hpricot(ODF::Property.new(:cell, 'rotation-angle' => '-90').xml).
|
32
|
-
at('//style:table-cell-properties')['style:rotation-angle'].should == '-90'
|
33
|
-
Hpricot(ODF::Property.new(:row, 'row-height' => '2cm').xml).
|
34
|
-
at('//style:table-row-properties')['style:row-height'].should == '2cm'
|
35
|
-
Hpricot(ODF::Property.new(:column, 'column-width' => '2cm').xml).
|
36
|
-
at('//style:table-column-properties')['style:column-width'].should == '2cm'
|
37
|
-
Hpricot(ODF::Property.new(:text, 'text-underline-type' => 'single').xml).
|
38
|
-
at('style:text-properties')['style:text-underline-type'].should == 'single'
|
39
|
-
Hpricot(ODF::Property.new(:paragraph, 'tab-stop-distance' => '0.4925in').xml).
|
40
|
-
at('style:paragraph-properties')['style:tab-stop-distance'].should == '0.4925in'
|
41
|
-
Hpricot(ODF::Property.new(:page_layout, 'border-line-width' => '2px').xml).
|
42
|
-
at('style:page-layout-properties')['style:border-line-width'].should == '2px'
|
43
|
-
Hpricot(ODF::Property.new(:header_footer, 'border-line-width' => '2px').xml).
|
44
|
-
at('style:header-footer-properties')['style:border-line-width'].should == '2px'
|
45
|
-
Hpricot(ODF::Property.new(:ruby, 'ruby-position' => 'above').xml).
|
46
|
-
at('style:ruby-properties')['style:ruby-position'].should == 'above'
|
47
|
-
Hpricot(ODF::Property.new(:section, 'editable' => true).xml).
|
48
|
-
at('style:section-properties')['style:editable'].should == 'true'
|
49
|
-
Hpricot(ODF::Property.new(:table, 'align' => 'left').xml).
|
50
|
-
at('style:table-properties')['table:align'].should == 'left'
|
51
|
-
Hpricot(ODF::Property.new(:list_level, 'space-before' => '2em').xml).
|
52
|
-
at('style:list-level-properties')['text:space-before'].should == '2em'
|
53
|
-
# style:graphic-properties
|
54
|
-
# style:chart-properties
|
55
|
-
# style:drawing-page-properties
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should generate row properties tag" do
|
59
|
-
property = ODF::Property.new :row, 'background-color' => '#f5f57a'
|
60
|
-
|
61
|
-
property.xml.should have_tag('//style:table-row-properties')
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should accept full perimeter border specs" do
|
65
|
-
property = ODF::Property.new :cell, :border => "0.025in solid #000000"
|
66
|
-
|
67
|
-
Hpricot(property.xml).at('//style:table-cell-properties')['fo:border'].
|
68
|
-
should == "0.025in solid #000000"
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should accept splited full perimeter border specs" do
|
72
|
-
property = ODF::Property.new :cell, :border_width => '0.025in',
|
73
|
-
:border_color => '#000000',
|
74
|
-
:border_style => 'solid'
|
75
|
-
|
76
|
-
Hpricot(property.xml).at('//style:table-cell-properties')['fo:border'].
|
77
|
-
should == "0.025in solid #000000"
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should use the first value for vertical and second for horizontal border side specs" do
|
81
|
-
property = ODF::Property.new :cell, :border_width => '0.025in 0.3in',
|
82
|
-
:border_color => '#ff0000 #0000ff',
|
83
|
-
:border_style => 'solid'
|
84
|
-
|
85
|
-
elem= Hpricot(property.xml).at('//style:table-cell-properties')
|
86
|
-
elem['fo:border-top'].should == "0.025in solid #ff0000"
|
87
|
-
elem['fo:border-right'].should == "0.3in solid #0000ff"
|
88
|
-
elem['fo:border-bottom'].should == "0.025in solid #ff0000"
|
89
|
-
elem['fo:border-left'].should == "0.3in solid #0000ff"
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should use the third value for bottom border specs when present" do
|
93
|
-
property = ODF::Property.new :cell, :border_width => '0.025in 0.3in 0.4in',
|
94
|
-
:border_color => '#ff0000 #0000ff',
|
95
|
-
:border_style => 'dotted solid solid'
|
96
|
-
|
97
|
-
elem = Hpricot(property.xml).at('//style:table-cell-properties')
|
98
|
-
elem['fo:border-bottom'].should == "0.4in solid #ff0000"
|
99
|
-
|
100
|
-
property = ODF::Property.new :cell, :border_width => '0.025in',
|
101
|
-
:border_color => '#ff0000 #0000ff #00ff00',
|
102
|
-
:border_style => 'dotted solid'
|
103
|
-
|
104
|
-
elem = Hpricot(property.xml).at('//style:table-cell-properties')
|
105
|
-
elem['fo:border-bottom'].should == "0.025in dotted #00ff00"
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should cascade left border specs from fourth to second to first" do
|
109
|
-
property = ODF::Property.new :cell, :border_width => '0.1in 0.2in 0.3in 0.4in',
|
110
|
-
:border_color => '#ff0000 #0000ff #00ff00',
|
111
|
-
:border_style => 'dotted solid'
|
112
|
-
|
113
|
-
elem = Hpricot(property.xml).at('//style:table-cell-properties')
|
114
|
-
elem['fo:border-left'].should == "0.4in solid #0000ff"
|
115
|
-
|
116
|
-
property = ODF::Property.new :cell, :border_width => '0.1in 0.2in 0.3in',
|
117
|
-
:border_color => '#ff0000 #0000ff',
|
118
|
-
:border_style => 'dotted'
|
119
|
-
|
120
|
-
elem = Hpricot(property.xml).at('//style:table-cell-properties')
|
121
|
-
elem['fo:border-left'].should == "0.2in dotted #0000ff"
|
122
|
-
|
123
|
-
property = ODF::Property.new :cell, :border_width => '0.1in 0.2in',
|
124
|
-
:border_color => '#ff0000',
|
125
|
-
:border_style => 'dotted solid dashed double'
|
126
|
-
|
127
|
-
elem = Hpricot(property.xml).at('//style:table-cell-properties')
|
128
|
-
elem['fo:border-left'].should == "0.2in double #ff0000"
|
129
|
-
|
130
|
-
property = ODF::Property.new :cell, :border_width => '0.1in',
|
131
|
-
:border_color => '#ff0000 #0000ff #00ff00 #ffff00',
|
132
|
-
:border_style => 'dotted solid dashed'
|
133
|
-
|
134
|
-
elem = Hpricot(property.xml).at('//style:table-cell-properties')
|
135
|
-
elem['fo:border-left'].should == "0.1in solid #ffff00"
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should support paragraph properties" do
|
139
|
-
ODF::Property.new(:paragraph).xml.
|
140
|
-
should have_tag('style:paragraph-properties')
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should know the namespace for style:text-properties style properties" do
|
144
|
-
#see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416402_253892949
|
145
|
-
['country-asian', 'country-complex', 'font-charset', 'font-charset-asian',
|
146
|
-
'font-charset-complex', 'font-family-asian', 'font-family-complex', 'font-family-generic',
|
147
|
-
'font-family-generic-asian', 'font-family-generic-complex', 'font-name', 'font-name-asian',
|
148
|
-
'font-name-complex', 'font-pitch', 'font-pitch-asian', 'font-pitch-complex', 'font-relief',
|
149
|
-
'font-size-asian', 'font-size-complex', 'font-size-rel', 'font-size-rel-asian',
|
150
|
-
'font-size-rel-complex', 'font-style-asian', 'font-style-complex', 'font-style-name',
|
151
|
-
'font-style-name-asian', 'font-style-name-complex', 'font-weight-asian', 'font-weight-complex',
|
152
|
-
'language-asian', 'language-complex', 'letter-kerning', 'rfc-language-tag',
|
153
|
-
'rfc-language-tag-asian', 'rfc-language-tag-complex', 'script-asian', 'script-complex',
|
154
|
-
'script-type', 'text-blinking', 'text-combine', 'text-combine-end-char',
|
155
|
-
'text-combine-start-char', 'text-emphasize', 'text-line-through-color',
|
156
|
-
'text-line-through-mode', 'text-line-through-style', 'text-line-through-text',
|
157
|
-
'text-line-through-text-style', 'text-line-through-type', 'text-line-through-width',
|
158
|
-
'text-outline', 'text-overline-color', 'text-overline-mode', 'text-overline-style',
|
159
|
-
'text-overline-type', 'text-overline-width', 'text-position', 'text-rotation-angle',
|
160
|
-
'text-rotation-scale', 'text-scale', 'text-underline-color', 'text-underline-mode',
|
161
|
-
'text-underline-style', 'text-underline-type', 'text-underline-width', 'use-window-font-color'].
|
162
|
-
each do |prop|
|
163
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
it "should know the namespace for style:table-cell-properties style properties" do
|
168
|
-
#see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416518_253892949
|
169
|
-
['border-line-width', 'border-line-width-bottom', 'border-line-width-left',
|
170
|
-
'border-line-width-right', 'border-line-width-top', 'cell-protect', 'decimal-places',
|
171
|
-
'diagonal-bl-tr', 'diagonal-bl-tr-widths', 'diagonal-tl-br', 'diagonal-tl-br-widths',
|
172
|
-
'direction', 'glyph-orientation-vertical', 'print-content', 'repeat-content',
|
173
|
-
'rotation-align', 'rotation-angle', 'shadow', 'shrink-to-fit', 'text-align-source',
|
174
|
-
'vertical-align', 'writing-mode'].
|
175
|
-
each do |prop|
|
176
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
it "should know the namespace for style:table-cell-properties style properties" do
|
181
|
-
#see http://docs.oasis-open.org/office/v1.2/os/opendocument-v1.2-os-part1.html#__refheading__1416516_253892949
|
182
|
-
['min-row-height', 'row-height', 'use-optimal-row-height'].each do |prop|
|
183
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
it "should know the namespace for style:table-row-properties style properties" do
|
188
|
-
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416514_253892949
|
189
|
-
['column-width', 'rel-column-width', 'use-optimal-column-width'].each do |prop|
|
190
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
it "should know the namespace for style:paragraph-properties style properties" do
|
195
|
-
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416494_253892949
|
196
|
-
['auto-text-indent', 'background-transparency', 'border-line-width', 'border-line-width-bottom',
|
197
|
-
'border-line-width-left', 'border-line-width-right', 'border-line-width-top',
|
198
|
-
'font-independent-line-spacing', 'join-border', 'justify-single-word', 'line-break',
|
199
|
-
'line-height-at-least', 'line-spacing', 'page-number', 'punctuation-wrap', 'register-true',
|
200
|
-
'shadow', 'snap-to-layout-grid', 'tab-stop-distance', 'text-autospace', 'vertical-align',
|
201
|
-
'writing-mode', 'writing-mode-automatic'].
|
202
|
-
each do |prop|
|
203
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
it "should know the namespace for style:page-layout-properties style properties" do
|
208
|
-
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416486_253892949
|
209
|
-
['border-line-width', 'border-line-width-bottom', 'border-line-width-left', 'border-line-width-right',
|
210
|
-
'border-line-width-top', 'first-page-number', 'footnote-max-height', 'layout-grid-base-height',
|
211
|
-
'layout-grid-base-width', 'layout-grid-color', 'layout-grid-display', 'layout-grid-lines',
|
212
|
-
'layout-grid-mode', 'layout-grid-print', 'layout-grid-ruby-below', 'layout-grid-ruby-height',
|
213
|
-
'layout-grid-snap-to', 'layout-grid-standard-mode', 'num-format', 'num-letter-sync',
|
214
|
-
'num-prefix', 'num-suffix', 'paper-tray-name', 'print', 'print-orientation', 'print-page-order',
|
215
|
-
'register-truth-ref-style-name', 'scale-to', 'scale-to-pages', 'shadow', 'table-centering',
|
216
|
-
'writing-mode'].
|
217
|
-
each do |prop|
|
218
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should know the namespace for style:header-footer-properties style and svg properties" do
|
223
|
-
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416492_253892949
|
224
|
-
['border-line-width', 'border-line-width-bottom', 'border-line-width-left', 'border-line-width-right',
|
225
|
-
'border-line-width-top', 'dynamic-spacing', 'shadow'].
|
226
|
-
each do |prop|
|
227
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
228
|
-
end
|
229
|
-
ODF::Property.lookup_namespace_for('height').should == 'svg'
|
230
|
-
end
|
231
|
-
|
232
|
-
it "should know the namespace for style:ruby-properties style properties" do
|
233
|
-
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1416502_253892949
|
234
|
-
['ruby-align', 'ruby-position'].each do |prop|
|
235
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
it "should know the namespace for style:section-properties style and text properties" do
|
240
|
-
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#element-style_section-properties
|
241
|
-
['editable', 'protect', 'writing-mode'].each do |prop|
|
242
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
243
|
-
end
|
244
|
-
ODF::Property.lookup_namespace_for('dont-balance-text-columns').should == 'text'
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should know the namespace for style:table-properties style and table properties" do
|
248
|
-
# see http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#element-style_table-properties
|
249
|
-
['may-break-between-rows', 'page-number', 'rel-width', 'shadow', 'width', 'writing-mode'].
|
250
|
-
each do |prop|
|
251
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
252
|
-
end
|
253
|
-
['align', 'border-model', 'display'].each do |prop|
|
254
|
-
ODF::Property.lookup_namespace_for(prop).should == 'table'
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
it "should know the namespace for style:list-level-properties style, svg and text properties" do
|
259
|
-
['font-name', 'vertical-pos', 'vertical-rel'].each do |prop|
|
260
|
-
ODF::Property.lookup_namespace_for(prop).should == 'style'
|
261
|
-
end
|
262
|
-
ODF::Property.lookup_namespace_for('y').should == 'svg'
|
263
|
-
['list-level-position-and-space-mode', 'min-label-distance', 'min-label-width',
|
264
|
-
'space-before'].
|
265
|
-
each do |prop|
|
266
|
-
ODF::Property.lookup_namespace_for(prop).should == 'text'
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
data/spec/row_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'odf/row'
|
21
|
-
|
22
|
-
describe ODF::Row do
|
23
|
-
it "should allow cells to be added" do
|
24
|
-
output = ODF::Row.create
|
25
|
-
output.should have_tag('//table:table-row')
|
26
|
-
output.should_not have_tag('//table:table-row/*')
|
27
|
-
|
28
|
-
output = ODF::Row.create {|r|
|
29
|
-
r.cell
|
30
|
-
r.cell
|
31
|
-
}
|
32
|
-
output.should have_tag('//table:table-row/*', :count => 2)
|
33
|
-
output.should have_tag('//table:table-cell')
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should accept parameterless blocks" do
|
37
|
-
output = ODF::Row.create do
|
38
|
-
cell
|
39
|
-
cell
|
40
|
-
end
|
41
|
-
output.should have_tag('//table:table-row/*', :count => 2)
|
42
|
-
output.should have_tag('//table:table-cell')
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should be stylable in the initialization" do
|
46
|
-
output = ODF::Row.create 0, :style => 'dark' do
|
47
|
-
cell
|
48
|
-
end
|
49
|
-
Hpricot(output).at('table:table-row')['table:style-name'].
|
50
|
-
should == 'dark'
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should be attr_writer stylable" do
|
54
|
-
row = ODF::Row.new
|
55
|
-
row.style = 'dark'
|
56
|
-
Hpricot(row.xml).at('table:table-row')['table:style-name'].
|
57
|
-
should == 'dark'
|
58
|
-
end
|
59
|
-
end
|
data/spec/skeleton_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Copyright (c) 2012 Foivos Zakkak
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'odf/skeleton'
|
21
|
-
|
22
|
-
describe ODF::Skeleton do
|
23
|
-
it "should have the expected structure" do
|
24
|
-
output = ODF::Skeleton.new.styles
|
25
|
-
output.should have_tag('//office:document-styles/*')
|
26
|
-
output.should have_tag('//office:font-face-decls')
|
27
|
-
output.should have_tag('//office:styles', :count => 1)
|
28
|
-
output.should have_tag('//style:style', :count => 1)
|
29
|
-
output.should have_tag('//number:number-style', :count => 2)
|
30
|
-
output.should have_tag('//number:date-style', :count => 1)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
data/spec/span_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'odf/span'
|
21
|
-
|
22
|
-
describe ODF::Span do
|
23
|
-
it "should print non-styled spans in pure text" do
|
24
|
-
ODF::Span.new('no style').xml.should == 'no style'
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should wrap styled output in span tags" do
|
28
|
-
output = ODF::Span.new(:italics, 'styled text').xml
|
29
|
-
output.should have_tag('text:span')
|
30
|
-
span = Hpricot(output).at('text:span')
|
31
|
-
span['text:style-name'].should == 'italics'
|
32
|
-
span.innerHTML.should == 'styled text'
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should allow nesting" do
|
36
|
-
output = ODF::Span.create :bold do |s|
|
37
|
-
s.italics 'highlighted text'
|
38
|
-
end
|
39
|
-
|
40
|
-
output.should have_tag('//text:span/*', :count => 2)
|
41
|
-
Hpricot(output).search('//text:span')[1].
|
42
|
-
innerHTML.should == 'highlighted text'
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should allow links" do
|
46
|
-
output = ODF::Span.create :bold do |s|
|
47
|
-
s.link 'there', 'http://www.example.org/'
|
48
|
-
s << ' and '
|
49
|
-
s.a 'back again', 'http://www.example.com/'
|
50
|
-
end
|
51
|
-
|
52
|
-
output.should have_tag('//text:a', :count => 2)
|
53
|
-
elem = Hpricot(output)
|
54
|
-
|
55
|
-
links = elem.search('//text:a')
|
56
|
-
links.first.innerHTML.should == 'there'
|
57
|
-
links.last.innerHTML.should == 'back again'
|
58
|
-
|
59
|
-
elem.at('//text:span').children[1].to_plain_text.should == " and "
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should escape entities" do
|
63
|
-
ODF::Span.create('Fish & Chips').should == 'Fish & Chips'
|
64
|
-
end
|
65
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
19
|
-
|
20
|
-
require 'rubygems'
|
21
|
-
|
22
|
-
require 'rspec_hpricot_matchers'
|
23
|
-
include RspecHpricotMatchers
|
data/spec/spreadsheet_spec.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
# Copyright (c) 2008 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'odf/spreadsheet'
|
21
|
-
|
22
|
-
describe ODF::SpreadSheet do
|
23
|
-
it "should have the expected structure" do
|
24
|
-
output = ODF::SpreadSheet.create {|s| }
|
25
|
-
output.should have_tag('//office:document-content/*')
|
26
|
-
output.should have_tag('//office:body/*')
|
27
|
-
output.should have_tag('//office:spreadsheet')
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be empty if no tables were added" do
|
31
|
-
output = ODF::SpreadSheet.create {|s| }
|
32
|
-
output.should_not have_tag('//office:spreadsheet/*')
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should include tables when asked to" do
|
36
|
-
output = ODF::SpreadSheet.create { |s|
|
37
|
-
s.table 'Example'
|
38
|
-
}
|
39
|
-
output.should have_tag('//office:spreadsheet/*', :count => 1)
|
40
|
-
output.should have_tag('//table:table', :count => 1)
|
41
|
-
Hpricot(output).at('//table:table')['table:name'].should == 'Example'
|
42
|
-
|
43
|
-
output = ODF::SpreadSheet.create { |s|
|
44
|
-
s.table 'First table'
|
45
|
-
s.table 'Second table'
|
46
|
-
}
|
47
|
-
output.should have_tag('//office:spreadsheet/*', :count => 2)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should allow rows to be added inside tables" do
|
51
|
-
output = ODF::SpreadSheet.create do |s|
|
52
|
-
s.table('My table') do |t|
|
53
|
-
t.row
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
output.should have_tag('//table:table/*')
|
58
|
-
output.should have_tag('//table:table-row')
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should allow styles to be added" do
|
62
|
-
ODF::SpreadSheet.create.should_not have_tag('//office:automatic-styles')
|
63
|
-
output = ODF::SpreadSheet.create do |s|
|
64
|
-
s.style 'even-row-cell', :family => :cell
|
65
|
-
end
|
66
|
-
|
67
|
-
output.should have_tag('//office:automatic-styles/*', :count => 1)
|
68
|
-
output.should have_tag('//style:style')
|
69
|
-
Hpricot(output).at('//style:style')['style:name'].should == 'even-row-cell'
|
70
|
-
Hpricot(output).at('//style:style')['style:family'].should == 'table-cell'
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should have data styles" do
|
74
|
-
output = ODF::SpreadSheet.create do |ss|
|
75
|
-
ss.data_style 'year-to-day-long', :date
|
76
|
-
end
|
77
|
-
output.should have_tag('//office:automatic-styles/*', :count => 1)
|
78
|
-
output.should have_tag('//number:date-style')
|
79
|
-
end
|
80
|
-
|
81
|
-
it "should allow conditional styles to be added" do
|
82
|
-
output = ODF::SpreadSheet.create do |s|
|
83
|
-
s.style 'cond-cell', :family => :cell do
|
84
|
-
property :conditional,
|
85
|
-
'condition' => 'cell-content()!=0',
|
86
|
-
'apply-style-name' => 'red-cell'
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
output.should have_tag('//style:map')
|
91
|
-
Hpricot(output).at('//style:map')['style:apply-style-name'].should == 'red-cell'
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should allow office styles to be added" do
|
95
|
-
spread = ODF::SpreadSheet.new
|
96
|
-
spread.office_style 'red-cell', :family => :cell
|
97
|
-
|
98
|
-
output = spread.office_styles_xml
|
99
|
-
|
100
|
-
output.should have_tag('//style:style')
|
101
|
-
Hpricot(output).at('//style:style')['style:name'].should == 'red-cell'
|
102
|
-
spread.xml.should_not have_tag('//style:style')
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should support mixed office and conditional styles to be added" do
|
106
|
-
spread = ODF::SpreadSheet.new
|
107
|
-
spread.office_style 'red-cell', :family => :cell
|
108
|
-
spread.style 'cond-cell', :family => :cell do
|
109
|
-
property :conditional,
|
110
|
-
'condition' => 'cell-content()!=0',
|
111
|
-
'apply-style-name' => 'red-cell'
|
112
|
-
end
|
113
|
-
|
114
|
-
output = spread.styles_xml
|
115
|
-
output.should have_tag('//style:map')
|
116
|
-
Hpricot(output).at('//style:map')['style:apply-style-name'].should == 'red-cell'
|
117
|
-
|
118
|
-
output = spread.office_styles_xml
|
119
|
-
output.should have_tag('//style:style')
|
120
|
-
Hpricot(output).at('//style:style')['style:name'].should == 'red-cell'
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
data/spec/style_section_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010 Thiago Arrais
|
2
|
-
#
|
3
|
-
# This file is part of rODF.
|
4
|
-
#
|
5
|
-
# rODF is free software: you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU Lesser General Public License as
|
7
|
-
# published by the Free Software Foundation, either version 3 of
|
8
|
-
# the License, or (at your option) any later version.
|
9
|
-
|
10
|
-
# rODF is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU Lesser General Public License for more details.
|
14
|
-
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License
|
16
|
-
# along with rODF. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
19
|
-
|
20
|
-
require 'odf/style_section'
|
21
|
-
|
22
|
-
describe ODF::StyleSection do
|
23
|
-
it "should allow style attribute" do
|
24
|
-
output = ODF::StyleSection.new(:year, :style => 'long').xml
|
25
|
-
output.should have_tag('number:year')
|
26
|
-
Hpricot(output).at('number:year')['number:style'].should == 'long'
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should allow textual flag" do
|
30
|
-
output = ODF::StyleSection.new(:month, :textual => true).xml
|
31
|
-
Hpricot(output).at('number:month')['number:textual'].should == 'true'
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should allow text to be inserted" do
|
35
|
-
Hpricot(ODF::StyleSection.new(:text, 'content').xml).
|
36
|
-
at('number:text').innerHTML.should == 'content'
|
37
|
-
|
38
|
-
Hpricot(ODF::StyleSection.new(:day).xml).
|
39
|
-
at('number:day').innerHTML.should == ''
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|