rodf 0.3.7 → 1.2.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.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +77 -0
  3. data/LICENSE +7 -0
  4. data/README.md +244 -64
  5. data/Rakefile +9 -17
  6. data/lib/rodf/cell.rb +171 -0
  7. data/lib/rodf/column.rb +21 -0
  8. data/lib/rodf/container.rb +18 -0
  9. data/lib/rodf/data_style.rb +46 -0
  10. data/lib/rodf/document.rb +133 -0
  11. data/lib/rodf/hyperlink.rb +33 -0
  12. data/lib/rodf/master_page.rb +11 -0
  13. data/lib/rodf/page_layout.rb +41 -0
  14. data/lib/rodf/paragraph.rb +28 -0
  15. data/lib/rodf/paragraph_container.rb +30 -0
  16. data/lib/rodf/property.rb +138 -0
  17. data/lib/rodf/row.rb +56 -0
  18. data/lib/{odf → rodf}/skeleton/manifest.xml.erb +0 -0
  19. data/lib/{odf → rodf}/skeleton/styles.pxml +0 -0
  20. data/lib/rodf/skeleton.rb +17 -0
  21. data/lib/rodf/span.rb +45 -0
  22. data/lib/rodf/spreadsheet.rb +113 -0
  23. data/lib/rodf/style.rb +77 -0
  24. data/lib/rodf/style_section.rb +33 -0
  25. data/lib/rodf/tab.rb +17 -0
  26. data/lib/rodf/table.rb +95 -0
  27. data/lib/rodf/text.rb +126 -0
  28. data/lib/rodf/version.rb +3 -0
  29. data/lib/rodf.rb +31 -0
  30. metadata +76 -115
  31. data/CHANGELOG +0 -17
  32. data/Gemfile +0 -9
  33. data/LICENSE.LGPL +0 -166
  34. data/Manifest +0 -48
  35. data/lib/odf/cell.rb +0 -104
  36. data/lib/odf/column.rb +0 -33
  37. data/lib/odf/compatibility.rb +0 -25
  38. data/lib/odf/container.rb +0 -57
  39. data/lib/odf/data_style.rb +0 -45
  40. data/lib/odf/document.rb +0 -67
  41. data/lib/odf/hyperlink.rb +0 -51
  42. data/lib/odf/master_page.rb +0 -33
  43. data/lib/odf/page_layout.rb +0 -39
  44. data/lib/odf/paragraph.rb +0 -46
  45. data/lib/odf/paragraph_container.rb +0 -35
  46. data/lib/odf/property.rb +0 -131
  47. data/lib/odf/row.rb +0 -44
  48. data/lib/odf/skeleton.rb +0 -34
  49. data/lib/odf/span.rb +0 -70
  50. data/lib/odf/spreadsheet.rb +0 -64
  51. data/lib/odf/style.rb +0 -65
  52. data/lib/odf/style_section.rb +0 -42
  53. data/lib/odf/tab.rb +0 -38
  54. data/lib/odf/table.rb +0 -50
  55. data/lib/odf/text.rb +0 -66
  56. data/rodf.gemspec +0 -48
  57. data/spec/cell_spec.rb +0 -189
  58. data/spec/data_style_spec.rb +0 -61
  59. data/spec/file_storage_spec.rb +0 -47
  60. data/spec/hyperlink_spec.rb +0 -62
  61. data/spec/master_page_spec.rb +0 -35
  62. data/spec/page_layout_spec.rb +0 -45
  63. data/spec/paragraph_spec.rb +0 -75
  64. data/spec/property_spec.rb +0 -270
  65. data/spec/row_spec.rb +0 -59
  66. data/spec/skeleton_spec.rb +0 -33
  67. data/spec/span_spec.rb +0 -65
  68. data/spec/spec_helper.rb +0 -23
  69. data/spec/spreadsheet_spec.rb +0 -123
  70. data/spec/style_section_spec.rb +0 -42
  71. data/spec/style_spec.rb +0 -109
  72. data/spec/tab_spec.rb +0 -34
  73. data/spec/table_spec.rb +0 -90
  74. data/spec/text_spec.rb +0 -79
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
@@ -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
-
@@ -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
-
data/spec/style_spec.rb DELETED
@@ -1,109 +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/style'
21
-
22
- describe ODF::Style do
23
- it "should output properties when they're added" do
24
- ODF::Style.create.should_not have_tag('//style:style/*')
25
-
26
- output = ODF::Style.create 'odd-row-cell', :family => :cell do |s|
27
- s.property :cell, 'background-color' => '#b3b3b3',
28
- 'border' => '0.002cm solid #000000'
29
- s.property :text, 'color' => '#4c4c4c', 'font-weight' => 'bold'
30
- end
31
-
32
- output.should have_tag('//style:style/*', :count => 2)
33
- output.should have_tag('//style:table-cell-properties')
34
- output.should have_tag('//style:text-properties')
35
-
36
- cell_elem = Hpricot(output).at('style:table-cell-properties')
37
- cell_elem['fo:background-color'].should == '#b3b3b3'
38
- cell_elem['fo:border'].should == '0.002cm solid #000000'
39
-
40
- text_elem = Hpricot(output).at('style:text-properties')
41
- text_elem['fo:color'].should == '#4c4c4c'
42
- text_elem['fo:font-weight'].should == 'bold'
43
- end
44
-
45
- it "should allow data styles" do
46
- xml = ODF::Style.create 'my-style', :family => :cell,
47
- :data_style => 'currency-grouped'
48
-
49
- style = Hpricot(xml).at('//style:style')
50
- style['style:data-style-name'].should == 'currency-grouped'
51
- end
52
-
53
- it "should allow parent styles" do
54
- xml = ODF::Style.create 'child-style', :family => :cell,
55
- :parent => 'cell-default'
56
-
57
- style = Hpricot(xml).at('//style:style')
58
- style['style:parent-style-name'].should == 'cell-default'
59
-
60
- cell_style = ODF::Style.new('cell-default', :family => :cell)
61
- xml = ODF::Style.create 'child-style', :family => :cell,
62
- :parent => cell_style
63
-
64
- style = Hpricot(xml).at('//style:style')
65
- style['style:parent-style-name'].should == 'cell-default'
66
- end
67
-
68
- it "should allow master pages" do
69
- xml = ODF::Style.create 'standard',
70
- :family => :paragraph,
71
- :master_page => 'letter'
72
-
73
- Hpricot(xml).at('//style:style')['style:master-page-name'].should == 'letter'
74
- end
75
-
76
- it "should be able to describe column styles" do
77
- xml = ODF::Style.create 'column-style', :family => :column do |style|
78
- style.property :column, 'column-width' => '2cm'
79
- end
80
-
81
- Hpricot(xml).at('//style:style')['style:family'].should == 'table-column'
82
- xml.should have_tag('//style:style/*', :count => 1)
83
- xml.should have_tag('//style:table-column-properties')
84
- end
85
-
86
- it "should be able to describe row styles" do
87
- xml = ODF::Style.create 'column-style', :family => :row do |style|
88
- end
89
-
90
- Hpricot(xml).at('//style:style')['style:family'].should == 'table-row'
91
- end
92
-
93
- it "should accept other families" do
94
- Hpricot(ODF::Style.create('text-style', :family => :text)).
95
- at('//style:style')['style:family'].should == 'text'
96
-
97
- Hpricot(ODF::Style.create('text-style', :family => :paragraph)).
98
- at('//style:style')['style:family'].should == 'paragraph'
99
- end
100
-
101
- it "should accept parameterless blocks" do
102
- output = ODF::Style.create 'odd-row-cell', :family => :cell do
103
- property :text, 'color' => '#4c4c4c', 'font-weight' => 'bold'
104
- end
105
-
106
- output.should have_tag('//style:style/*')
107
- end
108
- end
109
-
data/spec/tab_spec.rb DELETED
@@ -1,34 +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/paragraph'
21
- require 'odf/tab'
22
-
23
- describe ODF::Tab do
24
- it "should be placed inside paragraphs" do
25
- output = ODF::Paragraph.create {|p|
26
- p << "Tab"
27
- p.tab
28
- p << "test"
29
- }
30
- output.should have_tag("//text:p/*", :count => 3)
31
- output.should have_tag("//text:tab")
32
- end
33
- end
34
-
data/spec/table_spec.rb DELETED
@@ -1,90 +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/table'
21
-
22
- describe ODF::Table do
23
- it "should allow rows to be added" do
24
- output = ODF::Table.create('Example') {|t| }
25
- output.should have_tag('//table:table')
26
- output.should_not have_tag('//table:table/*')
27
-
28
- output = ODF::Table.create('MyTable') {|t| t.row }
29
- output.should have_tag('//table:table/*', :count => 1)
30
- output.should have_tag('//table:table-row')
31
-
32
- output = ODF::Table.create('MyTable') {|t|
33
- t.row
34
- t.row
35
- }
36
- output.should have_tag('//table:table/*', :count => 2)
37
- output.should have_tag('//table:table-row')
38
- end
39
-
40
- it "should provide row numbers" do
41
- output = ODF::Table.create('Row letter table') {|t|
42
- t.row {|row| row.cell}
43
- t.row {|row| row.cell(row.number)}
44
- }
45
- output.should have_tag('text:p')
46
- Hpricot(output).at('text:p').innerHTML.should == '2'
47
- end
48
-
49
- it "should allow column style specifications" do
50
- xml = ODF::Table.create('Styles columns table') do |t|
51
- t.column :style => 'wide'
52
- end
53
-
54
- xml.should have_tag('table:table-column')
55
- column = Hpricot(xml).at('table:table-column')
56
- column['table:style-name'].should == 'wide'
57
- end
58
-
59
- it "should accept parameterless block" do
60
- output = ODF::Table.create('MyTable') {
61
- row
62
- row
63
- }
64
- output.should have_tag('//table:table/*', :count => 2)
65
- output.should have_tag('//table:table-row')
66
- end
67
-
68
- it "should have children that accept parameterless blocks too" do
69
- output = ODF::Table.create('MyTable') {
70
- row {cell}
71
- row
72
- }
73
- output.should have_tag('//table:table/*', :count => 2)
74
- output.should have_tag('//table:table-row')
75
- output.should have_tag('//table:table-cell')
76
- end
77
-
78
- it "should have allow row styles" do
79
- output = ODF::Table.create('MyTable') do
80
- row style: :bold do
81
- cell
82
- end
83
- row style: :underline do
84
- cell
85
- end
86
- end
87
- output.should include('table:table-row table:style-name="bold"')
88
- output.should include('table:table-row table:style-name="underline"')
89
- end
90
- end
data/spec/text_spec.rb DELETED
@@ -1,79 +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/text'
21
-
22
- describe ODF::Text do
23
- it "should have the expected structure" do
24
- output = ODF::Text.create
25
- output.should have_tag('//office:document-content/*')
26
- output.should have_tag('//office:body/*')
27
- output.should have_tag('//office:text')
28
- end
29
-
30
- it "should have paragraphs" do
31
- output = ODF::Text.create { |doc|
32
- doc.paragraph "Hello"
33
- doc.p "World!"
34
- }
35
- output.should have_tag('//office:text/*')
36
- output.should have_tag('//text:p')
37
- ps = Hpricot(output).search('text:p')
38
- ps.size.should == 2
39
- ps.first.innerHTML.should == 'Hello'
40
- ps.last.innerHTML.should == 'World!'
41
- end
42
-
43
- it "should allow styles" do
44
- ODF::Text.create.should_not have_tag('//office:automatic-styles')
45
- output = ODF::Text.create { |doc|
46
- doc.style('bold', :family => 'text') {|s|
47
- s.property(:text, 'font-weight' => 'bold') }
48
- doc.style('italic', :family => 'text') {|s|
49
- s.property(:text, 'font-weight' => 'italic') }
50
- }
51
- output.should have_tag('//office:automatic-styles/*', :count => 2)
52
- output.should have_tag('//style:style')
53
- end
54
-
55
- it "should support page layout as auto-style" do
56
- output = ODF::Text.create { |doc|
57
- doc.page_layout 'main-layout'
58
- }
59
- output.should have_tag('//office:automatic-styles/*', :count => 1)
60
- output.should have_tag('//style:page-layout')
61
- end
62
-
63
- it "should support master pages" do
64
- output = ODF::Text.create do |doc|
65
- doc.master_page 'standard', :layout => 'letter'
66
- end
67
- output.should have_tag('//office:master-styles/*', :count => 1)
68
- output.should have_tag('//style:master-page')
69
- end
70
-
71
- it "should support default styles" do
72
- output = ODF::Text.create do |doc|
73
- doc.default_style :family => 'paragraph'
74
- end
75
- output.should have_tag('//office:styles/*', :count => 1)
76
- output.should have_tag('//style:default-style')
77
- end
78
- end
79
-