rodf 0.3.7 → 1.2.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 +77 -0
- data/LICENSE +7 -0
- data/README.md +244 -64
- data/Rakefile +9 -17
- data/lib/rodf/cell.rb +171 -0
- data/lib/rodf/column.rb +21 -0
- data/lib/rodf/container.rb +18 -0
- data/lib/rodf/data_style.rb +46 -0
- data/lib/rodf/document.rb +133 -0
- data/lib/rodf/hyperlink.rb +33 -0
- data/lib/rodf/master_page.rb +11 -0
- data/lib/rodf/page_layout.rb +41 -0
- data/lib/rodf/paragraph.rb +28 -0
- data/lib/rodf/paragraph_container.rb +30 -0
- data/lib/rodf/property.rb +138 -0
- data/lib/rodf/row.rb +56 -0
- data/lib/{odf → rodf}/skeleton/manifest.xml.erb +0 -0
- data/lib/{odf → rodf}/skeleton/styles.pxml +0 -0
- data/lib/rodf/skeleton.rb +17 -0
- data/lib/rodf/span.rb +45 -0
- data/lib/rodf/spreadsheet.rb +113 -0
- data/lib/rodf/style.rb +77 -0
- data/lib/rodf/style_section.rb +33 -0
- data/lib/rodf/tab.rb +17 -0
- data/lib/rodf/table.rb +95 -0
- data/lib/rodf/text.rb +126 -0
- data/lib/rodf/version.rb +3 -0
- data/lib/rodf.rb +31 -0
- metadata +76 -115
- data/CHANGELOG +0 -17
- data/Gemfile +0 -9
- data/LICENSE.LGPL +0 -166
- data/Manifest +0 -48
- data/lib/odf/cell.rb +0 -104
- data/lib/odf/column.rb +0 -33
- data/lib/odf/compatibility.rb +0 -25
- data/lib/odf/container.rb +0 -57
- data/lib/odf/data_style.rb +0 -45
- data/lib/odf/document.rb +0 -67
- data/lib/odf/hyperlink.rb +0 -51
- data/lib/odf/master_page.rb +0 -33
- data/lib/odf/page_layout.rb +0 -39
- data/lib/odf/paragraph.rb +0 -46
- data/lib/odf/paragraph_container.rb +0 -35
- data/lib/odf/property.rb +0 -131
- data/lib/odf/row.rb +0 -44
- data/lib/odf/skeleton.rb +0 -34
- data/lib/odf/span.rb +0 -70
- data/lib/odf/spreadsheet.rb +0 -64
- data/lib/odf/style.rb +0 -65
- data/lib/odf/style_section.rb +0 -42
- data/lib/odf/tab.rb +0 -38
- data/lib/odf/table.rb +0 -50
- data/lib/odf/text.rb +0 -66
- 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/lib/odf/compatibility.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010-2012 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
|
-
require 'builder'
|
18
|
-
|
19
|
-
if !String.method_defined? :to_xs
|
20
|
-
class String
|
21
|
-
def to_xs
|
22
|
-
Builder::XChar.encode(self)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/odf/container.rb
DELETED
@@ -1,57 +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 'rubygems'
|
19
|
-
gem 'activesupport', '>= 3.0', '< 6.0'
|
20
|
-
|
21
|
-
require 'active_support/inflector'
|
22
|
-
|
23
|
-
module ODF
|
24
|
-
class Container
|
25
|
-
def self.contains(*stuffs_array)
|
26
|
-
stuffs_array.map {|sym| sym.to_s}.each do |stuffs|
|
27
|
-
stuff = stuffs.to_s.singularize
|
28
|
-
stuff_class = eval(stuff.camelize)
|
29
|
-
|
30
|
-
self.class_eval "
|
31
|
-
def #{stuffs}
|
32
|
-
@#{stuffs} ||= []
|
33
|
-
end"
|
34
|
-
|
35
|
-
self.class_eval "
|
36
|
-
def #{stuff}(*args, &contents)
|
37
|
-
c = #{stuff_class}.new(*args)
|
38
|
-
c.instance_eval(&contents) if block_given?
|
39
|
-
#{stuffs} << c
|
40
|
-
c
|
41
|
-
end"
|
42
|
-
|
43
|
-
self.class_eval "
|
44
|
-
def #{stuffs}_xml
|
45
|
-
#{stuffs}.map {|c| c.xml}.join
|
46
|
-
end"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.create(*args, &contents)
|
51
|
-
container = self.new(*args)
|
52
|
-
container.instance_eval(&contents) if block_given?
|
53
|
-
container.xml
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
data/lib/odf/data_style.rb
DELETED
@@ -1,45 +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 'rubygems'
|
19
|
-
|
20
|
-
require 'builder'
|
21
|
-
|
22
|
-
require 'odf/container'
|
23
|
-
require 'odf/style_section'
|
24
|
-
|
25
|
-
module ODF
|
26
|
-
class DataStyle < Container
|
27
|
-
contains :style_sections
|
28
|
-
|
29
|
-
alias section style_section
|
30
|
-
|
31
|
-
def initialize(name, type)
|
32
|
-
@type, @name = type, name
|
33
|
-
end
|
34
|
-
|
35
|
-
def xml
|
36
|
-
Builder::XmlMarkup.new.tag! "number:#{@type}-style", 'style:name' => @name do |xml|
|
37
|
-
xml << style_sections_xml
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def method_missing(name, *args)
|
42
|
-
section(name, *args)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/lib/odf/document.rb
DELETED
@@ -1,67 +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 'rubygems'
|
19
|
-
|
20
|
-
require 'zip'
|
21
|
-
|
22
|
-
require 'odf/container'
|
23
|
-
require 'odf/skeleton'
|
24
|
-
require 'odf/style'
|
25
|
-
|
26
|
-
module ODF
|
27
|
-
class Document < Container
|
28
|
-
contains :styles, :default_styles, :office_styles
|
29
|
-
|
30
|
-
def self.file(ods_file_name, &contents)
|
31
|
-
(doc = new).instance_eval(&contents)
|
32
|
-
doc.write_to ods_file_name
|
33
|
-
end
|
34
|
-
|
35
|
-
def write_to(ods_file_name)
|
36
|
-
File.open(ods_file_name, 'wb') { |f| f << self.bytes }
|
37
|
-
end
|
38
|
-
|
39
|
-
def bytes
|
40
|
-
buffer = Zip::OutputStream::write_buffer do |zio|
|
41
|
-
zio.put_next_entry('META-INF/manifest.xml')
|
42
|
-
zio << self.class.skeleton.manifest(self.class.doc_type)
|
43
|
-
|
44
|
-
zio.put_next_entry('styles.xml')
|
45
|
-
zio << self.class.skeleton.styles
|
46
|
-
zio << self.office_styles_xml unless self.office_styles.empty?
|
47
|
-
zio << "</office:styles> </office:document-styles>"
|
48
|
-
|
49
|
-
zio.put_next_entry('content.xml')
|
50
|
-
zio << self.xml
|
51
|
-
end
|
52
|
-
|
53
|
-
buffer.set_encoding('ASCII-8BIT')
|
54
|
-
buffer.rewind
|
55
|
-
buffer.sysread
|
56
|
-
end
|
57
|
-
private
|
58
|
-
def self.skeleton
|
59
|
-
@skeleton ||= Skeleton.new
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.doc_type
|
63
|
-
name.split('::').last.downcase
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
data/lib/odf/hyperlink.rb
DELETED
@@ -1,51 +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 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/paragraph_container'
|
22
|
-
|
23
|
-
module ODF
|
24
|
-
class Hyperlink < ParagraphContainer
|
25
|
-
def initialize(first, second = {})
|
26
|
-
if second.instance_of?(Hash) && second.empty?
|
27
|
-
@href = first
|
28
|
-
else
|
29
|
-
span(first)
|
30
|
-
@href = second.instance_of?(Hash) ? second[:href] : second
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def xml
|
35
|
-
Builder::XmlMarkup.new.text:a, 'xlink:href' => @href do |a|
|
36
|
-
a << content_parts_xml
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class ParagraphContainer < Container
|
42
|
-
def link(*args)
|
43
|
-
l = Hyperlink.new(*args)
|
44
|
-
yield l if block_given?
|
45
|
-
content_parts << l
|
46
|
-
l
|
47
|
-
end
|
48
|
-
alias a link
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
data/lib/odf/master_page.rb
DELETED
@@ -1,33 +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 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
module ODF
|
22
|
-
class MasterPage
|
23
|
-
def initialize(name, opts = {})
|
24
|
-
@name, @layout = name, opts[:layout]
|
25
|
-
end
|
26
|
-
|
27
|
-
def xml
|
28
|
-
Builder::XmlMarkup.new.tag! 'style:master-page',
|
29
|
-
'style:name' => @name, 'style:page-layout-name' => @layout
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
data/lib/odf/page_layout.rb
DELETED
@@ -1,39 +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 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/container'
|
22
|
-
require 'odf/property'
|
23
|
-
|
24
|
-
module ODF
|
25
|
-
class PageLayout < Container
|
26
|
-
contains :properties
|
27
|
-
|
28
|
-
def initialize(name)
|
29
|
-
@name = name
|
30
|
-
end
|
31
|
-
|
32
|
-
def xml
|
33
|
-
Builder::XmlMarkup.new.tag! 'style:page-layout', 'style:name' => @name do |b|
|
34
|
-
b << properties_xml
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
data/lib/odf/paragraph.rb
DELETED
@@ -1,46 +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 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/paragraph_container'
|
22
|
-
|
23
|
-
module ODF
|
24
|
-
class Paragraph < ParagraphContainer
|
25
|
-
def initialize(fst = nil, snd = {})
|
26
|
-
first_is_hash = fst.instance_of? Hash
|
27
|
-
span(fst) unless first_is_hash
|
28
|
-
@elem_attrs = make_element_attributes(first_is_hash ? fst : snd)
|
29
|
-
end
|
30
|
-
|
31
|
-
def xml
|
32
|
-
Builder::XmlMarkup.new.text:p, @elem_attrs do |xml|
|
33
|
-
xml << content_parts_xml
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def make_element_attributes(opts)
|
40
|
-
attrs = {}
|
41
|
-
attrs['text:style-name'] = opts[:style] unless opts[:style].nil?
|
42
|
-
attrs
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
@@ -1,35 +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 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/container'
|
22
|
-
|
23
|
-
module ODF
|
24
|
-
# Container for all kinds of paragraph content
|
25
|
-
class ParagraphContainer < Container
|
26
|
-
def content_parts
|
27
|
-
@content_parts ||= []
|
28
|
-
end
|
29
|
-
|
30
|
-
def content_parts_xml
|
31
|
-
content_parts.map {|p| p.xml}.join
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
data/lib/odf/property.rb
DELETED
@@ -1,131 +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 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
module ODF
|
22
|
-
class Property
|
23
|
-
PROPERTY_NAMES = {:cell => 'table-cell-properties',
|
24
|
-
:text => 'text-properties',
|
25
|
-
:column => 'table-column-properties',
|
26
|
-
:row => 'table-row-properties',
|
27
|
-
:page_layout => 'page-layout-properties',
|
28
|
-
:header_footer => 'header-footer-properties',
|
29
|
-
:list_level => 'list-level-properties',
|
30
|
-
:conditional => 'map'}
|
31
|
-
TRANSLATED_SPECS = [:border_color, :border_style, :border_width]
|
32
|
-
|
33
|
-
ATTRIBUTES_TO_NAMESPACES = [[
|
34
|
-
['column-width', 'rotation-angle', 'text-underline-type', 'tab-stop-distance',
|
35
|
-
'condition', 'apply-style-name', 'base-cell-address', 'row-height',
|
36
|
-
'country-asian', 'country-complex', 'font-charset', 'font-charset-asian',
|
37
|
-
'font-charset-complex', 'font-family-asian', 'font-family-complex', 'font-family-generic',
|
38
|
-
'font-family-generic-asian', 'font-family-generic-complex', 'font-name', 'font-name-asian',
|
39
|
-
'font-name-complex', 'font-pitch', 'font-pitch-asian', 'font-pitch-complex', 'font-relief',
|
40
|
-
'font-size-asian', 'font-size-complex', 'font-size-rel', 'font-size-rel-asian',
|
41
|
-
'font-size-rel-complex', 'font-style-asian', 'font-style-complex', 'font-style-name',
|
42
|
-
'font-style-name-asian', 'font-style-name-complex', 'font-weight-asian', 'font-weight-complex',
|
43
|
-
'language-asian', 'language-complex', 'letter-kerning', 'rfc-language-tag',
|
44
|
-
'rfc-language-tag-asian', 'rfc-language-tag-complex', 'script-asian', 'script-complex',
|
45
|
-
'script-type', 'text-blinking', 'text-combine', 'text-combine-end-char',
|
46
|
-
'text-combine-start-char', 'text-emphasize', 'text-line-through-color',
|
47
|
-
'text-line-through-mode', 'text-line-through-style', 'text-line-through-text',
|
48
|
-
'text-line-through-text-style', 'text-line-through-type', 'text-line-through-width',
|
49
|
-
'text-outline', 'text-overline-color', 'text-overline-mode', 'text-overline-style',
|
50
|
-
'text-overline-type', 'text-overline-width', 'text-position', 'text-rotation-angle',
|
51
|
-
'text-rotation-scale', 'text-scale', 'text-underline-color', 'text-underline-mode',
|
52
|
-
'text-underline-style', 'text-underline-width', 'use-window-font-color',
|
53
|
-
'border-line-width', 'border-line-width-bottom', 'border-line-width-left',
|
54
|
-
'border-line-width-right', 'border-line-width-top', 'cell-protect', 'decimal-places',
|
55
|
-
'diagonal-bl-tr', 'diagonal-bl-tr-widths', 'diagonal-tl-br', 'diagonal-tl-br-widths',
|
56
|
-
'direction', 'glyph-orientation-vertical', 'print-content', 'repeat-content',
|
57
|
-
'rotation-align', 'shadow', 'shrink-to-fit', 'text-align-source',
|
58
|
-
'vertical-align', 'writing-mode', 'min-row-height', 'use-optimal-row-height',
|
59
|
-
'rel-column-width', 'use-optimal-column-width', 'auto-text-indent', 'background-transparency',
|
60
|
-
'font-independent-line-spacing', 'join-border', 'justify-single-word', 'line-break',
|
61
|
-
'line-height-at-least', 'line-spacing', 'page-number', 'punctuation-wrap', 'register-true',
|
62
|
-
'snap-to-layout-grid', 'text-autospace',
|
63
|
-
'writing-mode-automatic',
|
64
|
-
'first-page-number', 'footnote-max-height', 'layout-grid-base-height', 'layout-grid-base-width',
|
65
|
-
'layout-grid-color', 'layout-grid-display', 'layout-grid-lines', 'layout-grid-mode',
|
66
|
-
'layout-grid-print', 'layout-grid-ruby-below', 'layout-grid-ruby-height', 'layout-grid-snap-to',
|
67
|
-
'layout-grid-standard-mode', 'num-format', 'num-letter-sync', 'num-prefix', 'num-suffix',
|
68
|
-
'paper-tray-name', 'print', 'print-orientation', 'print-page-order',
|
69
|
-
'register-truth-ref-style-name', 'scale-to', 'scale-to-pages', 'table-centering',
|
70
|
-
'dynamic-spacing',
|
71
|
-
'ruby-align', 'ruby-position',
|
72
|
-
'editable', 'protect',
|
73
|
-
'may-break-between-rows', 'rel-width', 'width',
|
74
|
-
'vertical-pos', 'vertical-rel'], 'style'],
|
75
|
-
[['height', 'y'], 'svg'],
|
76
|
-
[['dont-balance-text-columns', 'list-level-position-and-space-mode', 'min-label-distance',
|
77
|
-
'min-label-width', 'space-before'], 'text'],
|
78
|
-
[['align', 'border-model', 'display'], 'table']]
|
79
|
-
|
80
|
-
def initialize(type, specs={})
|
81
|
-
@name = 'style:' + (PROPERTY_NAMES[type] || "#{type}-properties")
|
82
|
-
@specs = translate(specs).map { |k, v| [k.to_s, v] }
|
83
|
-
end
|
84
|
-
|
85
|
-
def xml
|
86
|
-
specs = @specs.inject({}) do |acc, kv|
|
87
|
-
acc.merge Property.lookup_namespace_for(kv.first) + ':' + kv.first => kv.last
|
88
|
-
end
|
89
|
-
Builder::XmlMarkup.new.tag! @name, specs
|
90
|
-
end
|
91
|
-
|
92
|
-
class << self
|
93
|
-
def lookup_namespace_for(property_name)
|
94
|
-
as = ATTRIBUTES_TO_NAMESPACES.select {|a| a[0].include? property_name}
|
95
|
-
as.empty? ? 'fo' : as[0][1]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
private
|
99
|
-
def translate(specs)
|
100
|
-
result = specs.clone
|
101
|
-
tspecs = specs.select {|k, v| TRANSLATED_SPECS.include? k}
|
102
|
-
tspecs.map {|k, v| result.delete k}
|
103
|
-
tspecs = tspecs.inject({}) {|acc, e| acc.merge e.first => e.last}
|
104
|
-
if tspecs[:border_width] && tspecs[:border_style] && tspecs[:border_color] then
|
105
|
-
width = tspecs[:border_width].split
|
106
|
-
style = tspecs[:border_style].split
|
107
|
-
color = tspecs[:border_color].split
|
108
|
-
if width.length == 1 && style.length == 1 && color.length == 1 then
|
109
|
-
result[:border] = [width[0], style[0], color[0]].join(' ')
|
110
|
-
else
|
111
|
-
result['border-top'] = cascading_join(width, style, color, 0)
|
112
|
-
result['border-right'] = cascading_join(width, style, color, 1, 0)
|
113
|
-
result['border-bottom'] = cascading_join(width, style, color, 2, 0)
|
114
|
-
result['border-left'] = cascading_join(width, style, color, 3, 1, 0)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
result
|
118
|
-
end
|
119
|
-
|
120
|
-
def cascading_join(width_parts, style_parts, color_parts, *prefs)
|
121
|
-
[ cascade(width_parts, prefs),
|
122
|
-
cascade(style_parts, prefs),
|
123
|
-
cascade(color_parts, prefs)].join(' ')
|
124
|
-
end
|
125
|
-
|
126
|
-
def cascade(list, prefs)
|
127
|
-
prefs.inject(nil) {|acc, i| acc || list[i]}
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
data/lib/odf/row.rb
DELETED
@@ -1,44 +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 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/container'
|
22
|
-
require 'odf/cell'
|
23
|
-
|
24
|
-
module ODF
|
25
|
-
class Row < Container
|
26
|
-
contains :cells
|
27
|
-
attr_reader :number
|
28
|
-
attr_writer :style
|
29
|
-
|
30
|
-
def initialize(number=0, opts={})
|
31
|
-
@number = number
|
32
|
-
@style = opts[:style]
|
33
|
-
end
|
34
|
-
|
35
|
-
def xml
|
36
|
-
elem_attrs = {}
|
37
|
-
elem_attrs['table:style-name'] = @style unless @style.nil?
|
38
|
-
Builder::XmlMarkup.new.tag! 'table:table-row', elem_attrs do |xml|
|
39
|
-
xml << cells_xml
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
data/lib/odf/skeleton.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 'erb'
|
19
|
-
|
20
|
-
module ODF
|
21
|
-
class Skeleton
|
22
|
-
def manifest(document_type)
|
23
|
-
ERB.new(template('manifest.xml.erb')).result(binding)
|
24
|
-
end
|
25
|
-
|
26
|
-
def styles
|
27
|
-
template('styles.pxml')
|
28
|
-
end
|
29
|
-
private
|
30
|
-
def template(fname)
|
31
|
-
File.open(File.dirname(__FILE__) + '/skeleton/' + fname).read
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/odf/span.rb
DELETED
@@ -1,70 +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 'rubygems'
|
19
|
-
require 'builder'
|
20
|
-
|
21
|
-
require 'odf/compatibility'
|
22
|
-
require 'odf/paragraph_container'
|
23
|
-
|
24
|
-
module ODF
|
25
|
-
class TextNode
|
26
|
-
def initialize(content)
|
27
|
-
@content = content
|
28
|
-
end
|
29
|
-
|
30
|
-
def xml
|
31
|
-
@content.to_s.to_xs
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Span < ParagraphContainer
|
36
|
-
def initialize(first, second = nil)
|
37
|
-
if first.instance_of?(Symbol)
|
38
|
-
@style = first
|
39
|
-
content_parts << TextNode.new(second) unless second.nil?
|
40
|
-
else
|
41
|
-
content_parts << TextNode.new(first)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def xml
|
46
|
-
return content_parts_xml if @style.nil?
|
47
|
-
Builder::XmlMarkup.new.text:span, 'text:style-name' => @style do |xml|
|
48
|
-
xml << content_parts_xml
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class ParagraphContainer < Container
|
54
|
-
def span(*args)
|
55
|
-
s = Span.new(*args)
|
56
|
-
yield s if block_given?
|
57
|
-
content_parts << s
|
58
|
-
s
|
59
|
-
end
|
60
|
-
|
61
|
-
def <<(content)
|
62
|
-
span(content)
|
63
|
-
end
|
64
|
-
|
65
|
-
def method_missing(style, *args)
|
66
|
-
span(style, *args)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|