rodf 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +61 -18
- data/LICENSE +7 -0
- data/README.md +94 -50
- data/Rakefile +1 -1
- data/lib/rodf.rb +2 -2
- data/lib/rodf/cell.rb +54 -37
- data/lib/rodf/column.rb +0 -14
- data/lib/rodf/compatibility.rb +0 -12
- data/lib/rodf/container.rb +53 -35
- data/lib/rodf/data_style.rb +4 -15
- data/lib/rodf/document.rb +9 -18
- data/lib/rodf/hyperlink.rb +3 -15
- data/lib/rodf/master_page.rb +0 -14
- data/lib/rodf/page_layout.rb +4 -16
- data/lib/rodf/paragraph.rb +3 -14
- data/lib/rodf/paragraph_container.rb +1 -15
- data/lib/rodf/property.rb +0 -14
- data/lib/rodf/row.rb +4 -16
- data/lib/rodf/skeleton.rb +0 -13
- data/lib/rodf/span.rb +4 -16
- data/lib/rodf/spreadsheet.rb +5 -18
- data/lib/rodf/style.rb +4 -16
- data/lib/rodf/style_section.rb +9 -15
- data/lib/rodf/tab.rb +1 -14
- data/lib/rodf/table.rb +24 -19
- data/lib/rodf/text.rb +6 -19
- data/lib/rodf/version.rb +1 -1
- metadata +13 -13
- data/LICENSE.LGPL +0 -166
data/lib/rodf/column.rb
CHANGED
@@ -1,19 +1,6 @@
|
|
1
1
|
# Copyright (c) 2008 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
@@ -29,4 +16,3 @@ module RODF
|
|
29
16
|
end
|
30
17
|
end
|
31
18
|
end
|
32
|
-
|
data/lib/rodf/compatibility.rb
CHANGED
@@ -1,19 +1,7 @@
|
|
1
1
|
# Copyright (c) 2010-2012 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
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
5
|
require 'builder'
|
18
6
|
|
19
7
|
if !String.method_defined? :to_xs
|
data/lib/rodf/container.rb
CHANGED
@@ -1,54 +1,72 @@
|
|
1
1
|
# Copyright (c) 2008 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
|
-
require '
|
5
|
+
require 'dry/inflector'
|
19
6
|
|
20
7
|
module RODF
|
21
8
|
class Container
|
9
|
+
INFLECTOR = Dry::Inflector.new.freeze
|
10
|
+
|
22
11
|
def self.contains(*stuffs_array)
|
23
12
|
stuffs_array.map {|sym| sym.to_s}.each do |stuffs|
|
24
|
-
stuff = stuffs.to_s
|
25
|
-
stuff_class =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
@#{stuffs}
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
13
|
+
stuff = INFLECTOR.singularize(stuffs.to_s)
|
14
|
+
stuff_class = RODF.const_get(INFLECTOR.camelize(stuff))
|
15
|
+
|
16
|
+
module_for_stuff.instance_exec do
|
17
|
+
define_method stuffs do
|
18
|
+
instance_variable_name = :"@#{stuffs}"
|
19
|
+
|
20
|
+
if instance_variable_defined?(instance_variable_name)
|
21
|
+
return instance_variable_get(instance_variable_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
instance_variable_set(instance_variable_name, [])
|
25
|
+
end
|
26
|
+
|
27
|
+
define_method stuff do |*args, &contents|
|
28
|
+
c = stuff_class.new(*args, &contents)
|
29
|
+
public_send(stuffs) << c
|
37
30
|
c
|
38
|
-
end
|
31
|
+
end
|
32
|
+
|
33
|
+
define_method "add_#{stuffs}" do |*elements|
|
34
|
+
elements = elements.first if elements.first.is_a?(Array)
|
35
|
+
elements.each do |element|
|
36
|
+
public_send(stuff, element)
|
37
|
+
end
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
define_method "#{stuffs}_xml" do
|
41
|
+
public_send(stuffs).map(&:xml).join
|
42
|
+
end
|
43
|
+
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def self.module_for_stuff
|
48
|
+
if const_defined?(:StuffMethods, false)
|
49
|
+
mod = const_get(:StuffMethods)
|
50
|
+
else
|
51
|
+
mod = const_set(:StuffMethods, Module.new)
|
52
|
+
include mod
|
53
|
+
end
|
54
|
+
mod
|
55
|
+
end
|
56
|
+
|
47
57
|
def self.create(*args, &contents)
|
48
|
-
container =
|
49
|
-
container.instance_eval(&contents) if block_given?
|
58
|
+
container = new(*args, &contents)
|
50
59
|
container.xml
|
51
60
|
end
|
61
|
+
|
62
|
+
def initialize(*_args, &contents)
|
63
|
+
return unless contents
|
64
|
+
|
65
|
+
if contents.arity.zero?
|
66
|
+
instance_exec(self, &contents)
|
67
|
+
else
|
68
|
+
yield(self)
|
69
|
+
end
|
70
|
+
end
|
52
71
|
end
|
53
72
|
end
|
54
|
-
|
data/lib/rodf/data_style.rb
CHANGED
@@ -1,24 +1,11 @@
|
|
1
1
|
# Copyright (c) 2010 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
20
|
-
|
21
|
-
|
7
|
+
require_relative 'container'
|
8
|
+
require_relative 'style_section'
|
22
9
|
|
23
10
|
module RODF
|
24
11
|
class DataStyle < Container
|
@@ -27,6 +14,8 @@ module RODF
|
|
27
14
|
alias section style_section
|
28
15
|
|
29
16
|
def initialize(name, type)
|
17
|
+
super
|
18
|
+
|
30
19
|
@type, @name = type, name
|
31
20
|
end
|
32
21
|
|
data/lib/rodf/document.rb
CHANGED
@@ -1,32 +1,24 @@
|
|
1
1
|
# Copyright (c) 2010 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'zip'
|
19
6
|
|
20
|
-
|
21
|
-
|
22
|
-
|
7
|
+
require_relative 'container'
|
8
|
+
require_relative 'skeleton'
|
9
|
+
require_relative 'style'
|
23
10
|
|
24
11
|
module RODF
|
25
12
|
class Document < Container
|
26
13
|
contains :styles, :default_styles, :office_styles
|
27
14
|
|
28
15
|
def self.file(ods_file_name, &contents)
|
29
|
-
|
16
|
+
doc = new
|
17
|
+
if contents.arity.zero?
|
18
|
+
contents.call(doc)
|
19
|
+
else
|
20
|
+
doc.instance_exec(doc, &contents)
|
21
|
+
end
|
30
22
|
doc.write_to ods_file_name
|
31
23
|
end
|
32
24
|
|
@@ -62,4 +54,3 @@ module RODF
|
|
62
54
|
end
|
63
55
|
end
|
64
56
|
end
|
65
|
-
|
data/lib/rodf/hyperlink.rb
CHANGED
@@ -1,27 +1,16 @@
|
|
1
1
|
# Copyright (c) 2010 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
20
|
-
|
7
|
+
require_relative 'paragraph_container'
|
21
8
|
|
22
9
|
module RODF
|
23
10
|
class Hyperlink < ParagraphContainer
|
24
11
|
def initialize(first, second = {})
|
12
|
+
super
|
13
|
+
|
25
14
|
if second.instance_of?(Hash) && second.empty?
|
26
15
|
@href = first
|
27
16
|
else
|
@@ -47,4 +36,3 @@ module RODF
|
|
47
36
|
alias a link
|
48
37
|
end
|
49
38
|
end
|
50
|
-
|
data/lib/rodf/master_page.rb
CHANGED
@@ -1,19 +1,6 @@
|
|
1
1
|
# Copyright (c) 2010 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
@@ -29,4 +16,3 @@ module RODF
|
|
29
16
|
end
|
30
17
|
end
|
31
18
|
end
|
32
|
-
|
data/lib/rodf/page_layout.rb
CHANGED
@@ -1,30 +1,19 @@
|
|
1
1
|
# Copyright (c) 2010 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
20
|
-
|
21
|
-
|
7
|
+
require_relative 'container'
|
8
|
+
require_relative 'property'
|
22
9
|
|
23
10
|
module RODF
|
24
11
|
class PageLayout < Container
|
25
12
|
contains :properties
|
26
13
|
|
27
14
|
def initialize(name)
|
15
|
+
super
|
16
|
+
|
28
17
|
@name = name
|
29
18
|
end
|
30
19
|
|
@@ -35,4 +24,3 @@ module RODF
|
|
35
24
|
end
|
36
25
|
end
|
37
26
|
end
|
38
|
-
|
data/lib/rodf/paragraph.rb
CHANGED
@@ -1,27 +1,16 @@
|
|
1
1
|
# Copyright (c) 2010 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
20
|
-
|
7
|
+
require_relative 'paragraph_container'
|
21
8
|
|
22
9
|
module RODF
|
23
10
|
class Paragraph < ParagraphContainer
|
24
11
|
def initialize(fst = nil, snd = {})
|
12
|
+
super
|
13
|
+
|
25
14
|
first_is_hash = fst.instance_of? Hash
|
26
15
|
span(fst) unless first_is_hash
|
27
16
|
@elem_attrs = make_element_attributes(first_is_hash ? fst : snd)
|
@@ -1,23 +1,10 @@
|
|
1
1
|
# Copyright (c) 2010 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
20
|
-
|
7
|
+
require_relative 'container'
|
21
8
|
|
22
9
|
module RODF
|
23
10
|
# Container for all kinds of paragraph content
|
@@ -31,4 +18,3 @@ module RODF
|
|
31
18
|
end
|
32
19
|
end
|
33
20
|
end
|
34
|
-
|
data/lib/rodf/property.rb
CHANGED
@@ -1,19 +1,6 @@
|
|
1
1
|
# Copyright (c) 2008 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
@@ -127,4 +114,3 @@ module RODF
|
|
127
114
|
end
|
128
115
|
end
|
129
116
|
end
|
130
|
-
|
data/lib/rodf/row.rb
CHANGED
@@ -1,24 +1,11 @@
|
|
1
1
|
# Copyright (c) 2008 Thiago Arrais
|
2
2
|
#
|
3
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
4
|
|
18
5
|
require 'builder'
|
19
6
|
|
20
|
-
|
21
|
-
|
7
|
+
require_relative 'container'
|
8
|
+
require_relative 'cell'
|
22
9
|
|
23
10
|
module RODF
|
24
11
|
class Row < Container
|
@@ -29,6 +16,8 @@ module RODF
|
|
29
16
|
def initialize(number=0, opts={})
|
30
17
|
@number = number
|
31
18
|
@style = opts[:style]
|
19
|
+
|
20
|
+
super
|
32
21
|
end
|
33
22
|
|
34
23
|
def xml
|
@@ -40,4 +29,3 @@ module RODF
|
|
40
29
|
end
|
41
30
|
end
|
42
31
|
end
|
43
|
-
|