summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/stylesheet
diff options
context:
space:
mode:
authorJurriaan Pruis <[email protected]>2014-01-15 23:44:02 +0100
committerJurriaan Pruis <[email protected]>2014-02-26 20:09:21 +0100
commitbe8e00332c73439cf17083173ea74f1505100df9 (patch)
tree383ec2e23fc0a14aa5ad90e139648a79814eeded /lib/axlsx/stylesheet
parenta271a7d0f26ecb26d01aad00e094744d6fe8b0d2 (diff)
downloadcaxlsx-be8e00332c73439cf17083173ea74f1505100df9.tar.gz
caxlsx-be8e00332c73439cf17083173ea74f1505100df9.zip
Huge refactoring
Do not create huge strings Let Row inherit from SimpleTypedList Optimized sanitizing Optimized validation And more..
Diffstat (limited to 'lib/axlsx/stylesheet')
-rw-r--r--lib/axlsx/stylesheet/border_pr.rb4
-rw-r--r--lib/axlsx/stylesheet/cell_alignment.rb4
-rw-r--r--lib/axlsx/stylesheet/cell_protection.rb4
-rw-r--r--lib/axlsx/stylesheet/cell_style.rb4
-rw-r--r--lib/axlsx/stylesheet/color.rb4
-rw-r--r--lib/axlsx/stylesheet/font.rb2
-rw-r--r--lib/axlsx/stylesheet/gradient_stop.rb2
-rw-r--r--lib/axlsx/stylesheet/num_fmt.rb4
-rw-r--r--lib/axlsx/stylesheet/pattern_fill.rb2
-rw-r--r--lib/axlsx/stylesheet/styles.rb2
-rw-r--r--lib/axlsx/stylesheet/table_style_element.rb4
11 files changed, 12 insertions, 24 deletions
diff --git a/lib/axlsx/stylesheet/border_pr.rb b/lib/axlsx/stylesheet/border_pr.rb
index 12b20d09..cba0e475 100644
--- a/lib/axlsx/stylesheet/border_pr.rb
+++ b/lib/axlsx/stylesheet/border_pr.rb
@@ -62,9 +62,9 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<' << @name.to_s << ' style="' << @style.to_s << '">'
+ str << ('<' << @name.to_s << ' style="' << @style.to_s << '">')
@color.to_xml_string(str) if @color.is_a?(Color)
- str << '</' << @name.to_s << '>'
+ str << ('</' << @name.to_s << '>')
end
end
diff --git a/lib/axlsx/stylesheet/cell_alignment.rb b/lib/axlsx/stylesheet/cell_alignment.rb
index 95f171df..715a0b3e 100644
--- a/lib/axlsx/stylesheet/cell_alignment.rb
+++ b/lib/axlsx/stylesheet/cell_alignment.rb
@@ -125,9 +125,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<alignment '
- serialized_attributes str
- str << '/>'
+ serialized_tag('alignment', str)
end
end
diff --git a/lib/axlsx/stylesheet/cell_protection.rb b/lib/axlsx/stylesheet/cell_protection.rb
index 9f8093ae..ac32cb96 100644
--- a/lib/axlsx/stylesheet/cell_protection.rb
+++ b/lib/axlsx/stylesheet/cell_protection.rb
@@ -34,9 +34,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<protection '
- serialized_attributes str
- str << '/>'
+ serialized_tag('protection', str)
end
end
diff --git a/lib/axlsx/stylesheet/cell_style.rb b/lib/axlsx/stylesheet/cell_style.rb
index 202c0cc2..2e8da880 100644
--- a/lib/axlsx/stylesheet/cell_style.rb
+++ b/lib/axlsx/stylesheet/cell_style.rb
@@ -64,9 +64,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<cellStyle '
- serialized_attributes str
- str << '/>'
+ serialized_tag('cellStyle', str)
end
end
diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb
index e736af7f..2b6c126f 100644
--- a/lib/axlsx/stylesheet/color.rb
+++ b/lib/axlsx/stylesheet/color.rb
@@ -70,9 +70,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '', tag_name = 'color')
- str << "<" << tag_name << " "
- serialized_attributes str
- str << "/>"
+ serialized_tag('' + tag_name + '', str)
end
end
end
diff --git a/lib/axlsx/stylesheet/font.rb b/lib/axlsx/stylesheet/font.rb
index 03da52e5..6d77d58b 100644
--- a/lib/axlsx/stylesheet/font.rb
+++ b/lib/axlsx/stylesheet/font.rb
@@ -140,7 +140,7 @@ module Axlsx
def to_xml_string(str = '')
str << '<font>'
instance_values.each do |k, v|
- v.is_a?(Color) ? v.to_xml_string(str) : (str << '<' << k.to_s << ' val="' << v.to_s << '"/>')
+ v.is_a?(Color) ? v.to_xml_string(str) : (str << ('<' << k.to_s << ' val="' << v.to_s << '"/>'))
end
str << '</font>'
end
diff --git a/lib/axlsx/stylesheet/gradient_stop.rb b/lib/axlsx/stylesheet/gradient_stop.rb
index 94ca4795..a76da6a6 100644
--- a/lib/axlsx/stylesheet/gradient_stop.rb
+++ b/lib/axlsx/stylesheet/gradient_stop.rb
@@ -29,7 +29,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<stop position="' << position.to_s << '">'
+ str << ('<stop position="' << position.to_s << '">')
self.color.to_xml_string(str)
str << '</stop>'
end
diff --git a/lib/axlsx/stylesheet/num_fmt.rb b/lib/axlsx/stylesheet/num_fmt.rb
index 7016c989..8276ba18 100644
--- a/lib/axlsx/stylesheet/num_fmt.rb
+++ b/lib/axlsx/stylesheet/num_fmt.rb
@@ -70,9 +70,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<numFmt '
- serialized_attributes str
- str << '/>'
+ serialized_tag('numFmt', str)
end
end
diff --git a/lib/axlsx/stylesheet/pattern_fill.rb b/lib/axlsx/stylesheet/pattern_fill.rb
index 504624e6..059f15bb 100644
--- a/lib/axlsx/stylesheet/pattern_fill.rb
+++ b/lib/axlsx/stylesheet/pattern_fill.rb
@@ -59,7 +59,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<patternFill patternType="' << patternType.to_s << '">'
+ str << ('<patternFill patternType="' << patternType.to_s << '">')
if fgColor.is_a?(Color)
fgColor.to_xml_string str, "fgColor"
end
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb
index 7970e0c1..c7283324 100644
--- a/lib/axlsx/stylesheet/styles.rb
+++ b/lib/axlsx/stylesheet/styles.rb
@@ -362,7 +362,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<styleSheet xmlns="' << XML_NS << '">'
+ str << ('<styleSheet xmlns="' << XML_NS << '">')
[:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key|
self.instance_values[key.to_s].to_xml_string(str) unless self.instance_values[key.to_s].nil?
end
diff --git a/lib/axlsx/stylesheet/table_style_element.rb b/lib/axlsx/stylesheet/table_style_element.rb
index 2ffc8af1..593c5950 100644
--- a/lib/axlsx/stylesheet/table_style_element.rb
+++ b/lib/axlsx/stylesheet/table_style_element.rb
@@ -70,9 +70,7 @@ module Axlsx
# @param [String] str
# @return [String]
def to_xml_string(str = '')
- str << '<tableStyleElement '
- serialized_attributes str
- str << '/>'
+ serialized_tag('tableStyleElement', str)
end
end