rubyXL-git-ref-6002046 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +63 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +197 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/lib/rubyXL.rb +21 -0
- data/lib/rubyXL/cell.rb +325 -0
- data/lib/rubyXL/generic_storage.rb +40 -0
- data/lib/rubyXL/objects/border.rb +53 -0
- data/lib/rubyXL/objects/cell_style.rb +73 -0
- data/lib/rubyXL/objects/color.rb +23 -0
- data/lib/rubyXL/objects/column_range.rb +88 -0
- data/lib/rubyXL/objects/data_validation.rb +31 -0
- data/lib/rubyXL/objects/defined_name.rb +27 -0
- data/lib/rubyXL/objects/fill.rb +42 -0
- data/lib/rubyXL/objects/font.rb +109 -0
- data/lib/rubyXL/objects/formula.rb +8 -0
- data/lib/rubyXL/objects/ooxml_object.rb +177 -0
- data/lib/rubyXL/objects/reference.rb +98 -0
- data/lib/rubyXL/objects/sheet_view.rb +62 -0
- data/lib/rubyXL/objects/worksheet.rb +11 -0
- data/lib/rubyXL/parser.rb +307 -0
- data/lib/rubyXL/private_class.rb +95 -0
- data/lib/rubyXL/shared_strings.rb +35 -0
- data/lib/rubyXL/workbook.rb +342 -0
- data/lib/rubyXL/worksheet.rb +1118 -0
- data/lib/rubyXL/writer/app_writer.rb +51 -0
- data/lib/rubyXL/writer/calc_chain_writer.rb +18 -0
- data/lib/rubyXL/writer/content_types_writer.rb +113 -0
- data/lib/rubyXL/writer/core_writer.rb +34 -0
- data/lib/rubyXL/writer/generic_writer.rb +33 -0
- data/lib/rubyXL/writer/root_rels_writer.rb +17 -0
- data/lib/rubyXL/writer/shared_strings_writer.rb +21 -0
- data/lib/rubyXL/writer/styles_writer.rb +64 -0
- data/lib/rubyXL/writer/theme_writer.rb +337 -0
- data/lib/rubyXL/writer/workbook_rels_writer.rb +43 -0
- data/lib/rubyXL/writer/workbook_writer.rb +73 -0
- data/lib/rubyXL/writer/worksheet_writer.rb +164 -0
- data/lib/rubyXL/zip.rb +20 -0
- data/rdoc/created.rid +36 -0
- data/rdoc/fonts.css +167 -0
- data/rdoc/fonts/Lato-Light.ttf +0 -0
- data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc/fonts/Lato-Regular.ttf +0 -0
- data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/js/darkfish.js +140 -0
- data/rdoc/js/jquery.js +18 -0
- data/rdoc/js/navigation.js +142 -0
- data/rdoc/js/search.js +109 -0
- data/rdoc/js/search_index.js +1 -0
- data/rdoc/js/searcher.js +228 -0
- data/rdoc/rdoc.css +580 -0
- data/rubyXL-git-ref-6002046.gemspec +143 -0
- data/spec/lib/cell_spec.rb +407 -0
- data/spec/lib/color_spec.rb +14 -0
- data/spec/lib/parser_spec.rb +80 -0
- data/spec/lib/workbook_spec.rb +73 -0
- data/spec/lib/worksheet_spec.rb +1789 -0
- metadata +231 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
module RubyXL
|
2
|
+
class GenericStorage < Hash
|
3
|
+
attr_reader :local_dir_path
|
4
|
+
|
5
|
+
def initialize(local_dir_path)
|
6
|
+
@local_dir_path = local_dir_path
|
7
|
+
@mode = 'r'
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def binary
|
12
|
+
@mode = 'rb'
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_dir(root_dir)
|
17
|
+
dirpath = File.join(root_dir, @local_dir_path)
|
18
|
+
if File.directory?(dirpath) then
|
19
|
+
(Dir.new(dirpath).entries - ['.', '..', '.DS_Store', '_rels']).each { |filename|
|
20
|
+
self[filename] = File.open(File.join(dirpath, filename), @mode).read
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_file(root_dir, filename)
|
28
|
+
filepath = File.join(root_dir, @local_dir_path, filename)
|
29
|
+
self[filename] = File.open(filepath, @mode).read if File.readable?(filepath)
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_to_zip(zipfile)
|
34
|
+
each_pair { |filename, data|
|
35
|
+
zipfile.get_output_stream(File.join(@local_dir_path, filename)) { |f| f << data }
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
class BorderEdge < OOXMLObject
|
4
|
+
define_attribute(:style, :string)
|
5
|
+
define_child_node(RubyXL::Color, :default => 'none', :values =>
|
6
|
+
%w{ none thin medium dashed dotted thick double hair
|
7
|
+
mediumDashed dashDot mediumDashDot dashDotDot slantDashDot } )
|
8
|
+
|
9
|
+
def ==(other)
|
10
|
+
style == other.style
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_border-2.html
|
15
|
+
class Border < OOXMLObject
|
16
|
+
define_attribute(:diagonalUp, :bool)
|
17
|
+
define_attribute(:diagonalDown, :bool)
|
18
|
+
define_attribute(:outline, :bool, :default => true)
|
19
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :left)
|
20
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :right)
|
21
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :top)
|
22
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :bottom)
|
23
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :diagonal)
|
24
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :vertical)
|
25
|
+
define_child_node(RubyXL::BorderEdge, :node_name => :horizontal)
|
26
|
+
define_element_name 'border'
|
27
|
+
set_countable
|
28
|
+
|
29
|
+
def get_edge_style(direction)
|
30
|
+
edge = self.send(direction)
|
31
|
+
edge && edge.style
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_edge_style(direction, style)
|
35
|
+
self.send("#{direction}=", RubyXL::BorderEdge.new(:style => style))
|
36
|
+
end
|
37
|
+
|
38
|
+
def ==(other)
|
39
|
+
(diagonal_up == other.diagonal_up) &&
|
40
|
+
(diagonal_down == other.diagonal_down) &&
|
41
|
+
(outline == other.outline) &&
|
42
|
+
(left == other.left) &&
|
43
|
+
(right == other.right) &&
|
44
|
+
(top == other.top) &&
|
45
|
+
(bottom == other.bottom) &&
|
46
|
+
(diagonal == other.diagonal) &&
|
47
|
+
(vertical == other.vertical) &&
|
48
|
+
(horizontal == other.horizontal)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_cellStyle-1.html
|
4
|
+
class CellStyle < OOXMLObject
|
5
|
+
define_attribute(:name, :string)
|
6
|
+
define_attribute(:xfId, :int, :required => true)
|
7
|
+
define_attribute(:builtinId, :int)
|
8
|
+
define_attribute(:iLevel, :int)
|
9
|
+
define_attribute(:hidden, :bool)
|
10
|
+
define_attribute(:customBuiltin, :bool)
|
11
|
+
define_element_name 'cellStyle'
|
12
|
+
end
|
13
|
+
|
14
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_alignment-1.html
|
15
|
+
class Alignment < OOXMLObject
|
16
|
+
define_attribute(:horizontal, :string,
|
17
|
+
:values => %w{general left center right fill justify centerContinuous distributed})
|
18
|
+
define_attribute(:vertical, :string,
|
19
|
+
:values => %w{top center bottom justify distributed})
|
20
|
+
define_attribute(:textRotation, :int)
|
21
|
+
define_attribute(:wrapText, :bool)
|
22
|
+
define_attribute(:indent, :int)
|
23
|
+
define_attribute(:relativeIndent, :int)
|
24
|
+
define_attribute(:justifyLastLine, :bool)
|
25
|
+
define_attribute(:shrinkToFit, :bool)
|
26
|
+
define_attribute(:readingOrder, :int)
|
27
|
+
define_element_name 'alignment'
|
28
|
+
end
|
29
|
+
|
30
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_protection-1.html
|
31
|
+
class Protection < OOXMLObject
|
32
|
+
define_attribute(:locked, :bool)
|
33
|
+
define_attribute(:hidden, :bool)
|
34
|
+
define_element_name 'protection'
|
35
|
+
end
|
36
|
+
|
37
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_xf-1.html
|
38
|
+
class XF < OOXMLObject
|
39
|
+
define_attribute(:numFmtId, :int)
|
40
|
+
define_attribute(:fontId, :int)
|
41
|
+
define_attribute(:fillId, :int)
|
42
|
+
define_attribute(:borderId, :int)
|
43
|
+
define_attribute(:xfId, :int)
|
44
|
+
define_attribute(:quotePrefix, :bool, :default => false )
|
45
|
+
define_attribute(:pivotButton, :bool, :default => false )
|
46
|
+
define_attribute(:applyNumberFormat, :bool)
|
47
|
+
define_attribute(:applyFont, :bool)
|
48
|
+
define_attribute(:applyFill, :bool)
|
49
|
+
define_attribute(:applyBorder, :bool)
|
50
|
+
define_attribute(:applyAlignment, :bool)
|
51
|
+
define_attribute(:applyProtection, :bool)
|
52
|
+
define_child_node(RubyXL::Alignment)
|
53
|
+
define_child_node(RubyXL::Protection)
|
54
|
+
define_element_name 'xf'
|
55
|
+
set_countable
|
56
|
+
|
57
|
+
def ==(other)
|
58
|
+
(self.num_fmt_id == other.num_fmt_id) &&
|
59
|
+
(self.font_id == other.font_id) &&
|
60
|
+
(self.fill_id == other.fill_id) &&
|
61
|
+
(self.border_id == other.border_id) &&
|
62
|
+
(self.xf_id == other.xf_id)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_numFmt-1.html
|
67
|
+
class NumFmt < OOXMLObject
|
68
|
+
define_attribute(:numFmtId, :int, :required => true)
|
69
|
+
define_attribute(:formatCode, :string, :required => true)
|
70
|
+
define_element_name 'numFmt'
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_color-4.html
|
4
|
+
class Color < OOXMLObject
|
5
|
+
define_attribute(:auto, :bool)
|
6
|
+
define_attribute(:indexed, :int)
|
7
|
+
define_attribute(:rgb, :string)
|
8
|
+
define_attribute(:theme, :int)
|
9
|
+
define_attribute(:tint, :float)
|
10
|
+
define_element_name 'color'
|
11
|
+
|
12
|
+
#validates hex color code, no '#' allowed
|
13
|
+
def self.validate_color(color)
|
14
|
+
if color =~ /^([a-f]|[A-F]|[0-9]){6}$/
|
15
|
+
return true
|
16
|
+
else
|
17
|
+
raise 'invalid color'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
class ColumnRange
|
4
|
+
# +min+ and +max+ are column 0-based indices, as opposed to Excel's 1-based column numbers
|
5
|
+
attr_accessor :min, :max, :width, :custom_width, :style_index
|
6
|
+
|
7
|
+
def initialize(attrs = {})
|
8
|
+
@min = attrs['min']
|
9
|
+
@max = attrs['max']
|
10
|
+
@width = attrs['width']
|
11
|
+
@custom_width = attrs['customWidth']
|
12
|
+
@style_index = attrs['style']
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.parse(node)
|
16
|
+
range = self.new
|
17
|
+
range.min = RubyXL::Parser.attr_int(node, 'min') - 1
|
18
|
+
range.max = RubyXL::Parser.attr_int(node, 'max') - 1
|
19
|
+
range.width = RubyXL::Parser.attr_float(node, 'width')
|
20
|
+
range.custom_width = RubyXL::Parser.attr_int(node, 'customWidth')
|
21
|
+
range.style_index = RubyXL::Parser.attr_int(node, 'style')
|
22
|
+
range
|
23
|
+
end
|
24
|
+
|
25
|
+
def delete_column(col)
|
26
|
+
self.min -=1 if min >= col
|
27
|
+
self.max -=1 if max >= col
|
28
|
+
end
|
29
|
+
|
30
|
+
def insert_column(col)
|
31
|
+
self.min +=1 if min >= col
|
32
|
+
self.max +=1 if max >= col - 1
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.insert_column(col_index, ranges)
|
36
|
+
ranges.each { |range| range.insert_column(col_index) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def include?(col_index)
|
40
|
+
(min..max).include?(col_index)
|
41
|
+
end
|
42
|
+
|
43
|
+
# This method is used to change attributes on a column range, which may involve
|
44
|
+
# splitting existing column range into multiples.
|
45
|
+
def self.update(col_index, ranges, attrs)
|
46
|
+
|
47
|
+
old_range = RubyXL::ColumnRange.find(col_index, ranges)
|
48
|
+
|
49
|
+
if old_range.nil? then
|
50
|
+
new_range = RubyXL::ColumnRange.new(attrs.merge({ 'min' => col_index, 'max' => col_index }))
|
51
|
+
ranges << new_range
|
52
|
+
return new_range
|
53
|
+
elsif old_range.min == col_index &&
|
54
|
+
old_range.max == col_index then # Single column range, OK to change in place
|
55
|
+
|
56
|
+
old_range.width = attrs['width'] if attrs['width']
|
57
|
+
old_range.custom_width = attrs['customWidth'] if attrs['customWidth']
|
58
|
+
old_range.style_index = attrs['style'] if attrs['style']
|
59
|
+
return old_range
|
60
|
+
else
|
61
|
+
raise "Range splitting not implemented yet"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.find(col_index, ranges)
|
66
|
+
ranges.find { |range| range.include?(col_index) }
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.ref2ind(ref)
|
70
|
+
col = 0
|
71
|
+
ref.each_byte { |chr| col = col * 26 + (chr - 64) }
|
72
|
+
col - 1
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.ind2ref(ind)
|
76
|
+
str = ''
|
77
|
+
|
78
|
+
loop do
|
79
|
+
x = ind % 26
|
80
|
+
str = ('A'.ord + x).chr + str
|
81
|
+
ind = (ind / 26).floor - 1
|
82
|
+
return str if ind < 0
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RubyXL
|
2
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_dataValidation-1.html
|
3
|
+
class DataValidation < OOXMLObject
|
4
|
+
define_attribute(:type, :string, :default => 'none',
|
5
|
+
:values => %w{ none whole decimal list date time textLength custom })
|
6
|
+
define_attribute(:errorStyle, :string, :default => 'stop',
|
7
|
+
:values => %w{ stop warning information })
|
8
|
+
define_attribute(:imeMode, :string, :default => 'noControl',
|
9
|
+
:values => %w{ noControl off on disabled hiragana fullKatakana halfKatakana
|
10
|
+
fullAlpha halfAlpha fullHangul halfHangul })
|
11
|
+
define_attribute(:operator, :string, :default => 'between',
|
12
|
+
:values => %w{ between notBetween equal notEqual lessThan lessThanOrEqual
|
13
|
+
greaterThan greaterThanOrEqual })
|
14
|
+
define_attribute(:allowBlank, :bool, :default => 'false')
|
15
|
+
define_attribute(:showDropDown, :bool, :default => 'false')
|
16
|
+
define_attribute(:showInputMessage, :bool, :default => 'false')
|
17
|
+
define_attribute(:showErrorMessage, :bool, :default => 'false')
|
18
|
+
define_attribute(:errorTitle, :string)
|
19
|
+
define_attribute(:error, :string)
|
20
|
+
define_attribute(:promptTitle, :string)
|
21
|
+
define_attribute(:prompt, :string)
|
22
|
+
define_attribute(:sqref, :sqref, :required => true)
|
23
|
+
|
24
|
+
|
25
|
+
define_child_node(RubyXL::Formula, :node_name => :formula1)
|
26
|
+
define_child_node(RubyXL::Formula, :node_name => :formula2)
|
27
|
+
define_element_name 'dataValidation'
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_definedName-2.html
|
4
|
+
class DefinedName < OOXMLObject
|
5
|
+
define_attribute(:name, :string, :required => true)
|
6
|
+
define_attribute(:comment, :string)
|
7
|
+
define_attribute(:customMenu, :string)
|
8
|
+
define_attribute(:description, :string)
|
9
|
+
define_attribute(:help, :string)
|
10
|
+
define_attribute(:description, :string)
|
11
|
+
define_attribute(:localSheetId, :string)
|
12
|
+
|
13
|
+
define_attribute(:hidden, :bool, :default => false)
|
14
|
+
define_attribute(:function, :bool, :default => false)
|
15
|
+
define_attribute(:vbProcedure, :bool, :default => false)
|
16
|
+
define_attribute(:xlm, :bool, :default => false)
|
17
|
+
|
18
|
+
define_attribute(:functionGroupId, :int)
|
19
|
+
define_attribute(:shortcutKey, :string)
|
20
|
+
define_attribute(:publishToServer, :bool, :default => false)
|
21
|
+
define_attribute(:workbookParameter, :bool, :default => false)
|
22
|
+
|
23
|
+
define_attribute(:_, :string, :accessor => :reference)
|
24
|
+
define_element_name 'definedName'
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_gradientFill-1.html
|
4
|
+
class Stop < OOXMLObject
|
5
|
+
define_attribute(:position, :float)
|
6
|
+
define_child_node(RubyXL::Color)
|
7
|
+
define_element_name 'stop'
|
8
|
+
end
|
9
|
+
|
10
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_patternFill-1.html
|
11
|
+
class PatternFill < OOXMLObject
|
12
|
+
define_attribute(:patternType, :string, :values =>
|
13
|
+
%w{ none solid mediumGray darkGray lightGray
|
14
|
+
darkHorizontal darkVertical darkDown darkUp darkGrid darkTrellis
|
15
|
+
lightHorizontal lightVertical lightDown lightUp lightGrid lightTrellis
|
16
|
+
gray125 gray0625 })
|
17
|
+
define_child_node(RubyXL::Color, :node_name => :fgColor )
|
18
|
+
define_child_node(RubyXL::Color, :node_name => :bgColor )
|
19
|
+
define_element_name 'patternFill'
|
20
|
+
end
|
21
|
+
|
22
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_gradientFill-1.html
|
23
|
+
class GradientFill < OOXMLObject
|
24
|
+
define_attribute(:type, :string, :values => %w{ linear path }, :default => 'linear')
|
25
|
+
define_attribute(:degree, :float, :default => 0)
|
26
|
+
define_attribute(:left, :float, :default => 0)
|
27
|
+
define_attribute(:right, :float, :default => 0)
|
28
|
+
define_attribute(:top, :float, :default => 0)
|
29
|
+
define_attribute(:bottom, :float, :default => 0)
|
30
|
+
define_child_node(RubyXL::Stop, :collection => true)
|
31
|
+
define_element_name 'gradientFill'
|
32
|
+
end
|
33
|
+
|
34
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_fill-1.html
|
35
|
+
class Fill < OOXMLObject
|
36
|
+
define_child_node(RubyXL::PatternFill)
|
37
|
+
define_child_node(RubyXL::GradientFill)
|
38
|
+
define_element_name 'fill'
|
39
|
+
set_countable
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
class BooleanValue < OOXMLObject
|
4
|
+
define_attribute(:val, :bool, :required => true, :default => true)
|
5
|
+
end
|
6
|
+
|
7
|
+
class StringValue < OOXMLObject
|
8
|
+
define_attribute(:val, :string, :required => true)
|
9
|
+
end
|
10
|
+
|
11
|
+
class IntegerValue < OOXMLObject
|
12
|
+
define_attribute(:val, :int, :required => true)
|
13
|
+
end
|
14
|
+
|
15
|
+
class FloatValue < OOXMLObject
|
16
|
+
define_attribute(:val, :float, :required => true)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# http://www.schemacentral.com/sc/ooxml/e-ssml_font-1.html
|
21
|
+
class Font < OOXMLObject
|
22
|
+
define_child_node(RubyXL::StringValue, :node_name => :name)
|
23
|
+
define_child_node(RubyXL::IntegerValue, :node_name => :charset)
|
24
|
+
define_child_node(RubyXL::IntegerValue, :node_name => :family)
|
25
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :b)
|
26
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :i)
|
27
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :strike)
|
28
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :outline)
|
29
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :shadow)
|
30
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :condense)
|
31
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :extend)
|
32
|
+
define_child_node(RubyXL::Color)
|
33
|
+
define_child_node(RubyXL::FloatValue, :node_name => :sz)
|
34
|
+
define_child_node(RubyXL::BooleanValue, :node_name => :u)
|
35
|
+
define_child_node(RubyXL::StringValue, :node_name => :vertAlign)
|
36
|
+
define_child_node(RubyXL::StringValue, :node_name => :scheme)
|
37
|
+
define_element_name 'font'
|
38
|
+
set_countable
|
39
|
+
|
40
|
+
def ==(other)
|
41
|
+
(!(self.i && self.i.val) == !(other.i && other.i.val)) &&
|
42
|
+
(!(self.b && self.b.val) == !(other.b && other.b.val)) &&
|
43
|
+
(!(self.u && self.u.val) == !(other.u && other.u.val)) &&
|
44
|
+
(!(self.strike && self.strike.val) == !(other.strike && other.strike.val)) &&
|
45
|
+
((self.name && self.name.val) == (other.name && other.name.val)) &&
|
46
|
+
((self.sz && self.sz.val) == (other.sz && other.sz.val)) &&
|
47
|
+
(self.color == other.color) # Need to write proper comparison for color
|
48
|
+
end
|
49
|
+
|
50
|
+
def is_italic
|
51
|
+
i && i.val
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_italic(val)
|
55
|
+
self.i = RubyXL::BooleanValue.new(:val => val)
|
56
|
+
end
|
57
|
+
|
58
|
+
def is_bold
|
59
|
+
b && b.val
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_bold(val)
|
63
|
+
self.b = RubyXL::BooleanValue.new(:val => val)
|
64
|
+
end
|
65
|
+
|
66
|
+
def is_underlined
|
67
|
+
u && u.val
|
68
|
+
end
|
69
|
+
|
70
|
+
def set_underline(val)
|
71
|
+
self.u = RubyXL::BooleanValue.new(:val => val)
|
72
|
+
end
|
73
|
+
|
74
|
+
def is_strikethrough
|
75
|
+
strike && strike.val
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_strikethrough(val)
|
79
|
+
self.strike = RubyXL::BooleanValue.new(:val => val)
|
80
|
+
end
|
81
|
+
|
82
|
+
def get_name
|
83
|
+
name && name.val
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_name(val)
|
87
|
+
self.name = RubyXL::StringValue.new(:val => val)
|
88
|
+
end
|
89
|
+
|
90
|
+
def get_size
|
91
|
+
sz && sz.val
|
92
|
+
end
|
93
|
+
|
94
|
+
def set_size(val)
|
95
|
+
self.sz = RubyXL::FloatValue.new(:val => val)
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_rgb_color
|
99
|
+
color && color.rgb
|
100
|
+
end
|
101
|
+
|
102
|
+
# Helper method to modify the font color
|
103
|
+
def set_rgb_color(font_color)
|
104
|
+
self.color = RubyXL::Color.new(:rgb => font_color.to_s)
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|