diff options
| author | Paul Kmiec <[email protected]> | 2023-05-04 16:31:08 -0700 |
|---|---|---|
| committer | Paul Kmiec <[email protected]> | 2023-05-04 18:02:55 -0700 |
| commit | fabe8cb2571c8865270247ca78ddc01d493a9ee1 (patch) | |
| tree | 27fe0b0df8c9bec8f746d92a0d128cad197027b2 /lib/axlsx | |
| parent | fef93ec8ae2caf8a3f8310dbf8101c103e5905e4 (diff) | |
| download | caxlsx-fabe8cb2571c8865270247ca78ddc01d493a9ee1.tar.gz caxlsx-fabe8cb2571c8865270247ca78ddc01d493a9ee1.zip | |
Fix tests / code to work with frozen string literals
Diffstat (limited to 'lib/axlsx')
128 files changed, 323 insertions, 324 deletions
diff --git a/lib/axlsx/content_type/abstract_content_type.rb b/lib/axlsx/content_type/abstract_content_type.rb index dfb7dd91..58ca8b2c 100644 --- a/lib/axlsx/content_type/abstract_content_type.rb +++ b/lib/axlsx/content_type/abstract_content_type.rb @@ -22,7 +22,7 @@ module Axlsx alias :ContentType= :content_type= # Serialize the contenty type to xml - def to_xml_string(node_name = '', str = '') + def to_xml_string(node_name = '', str = +'') str << "<#{node_name} " str << Axlsx.instance_values_for(self).map { |key, value| Axlsx::camel(key) << '="' << value.to_s << '"' }.join(' ') str << '/>' diff --git a/lib/axlsx/content_type/content_type.rb b/lib/axlsx/content_type/content_type.rb index ead50713..15751b17 100644 --- a/lib/axlsx/content_type/content_type.rb +++ b/lib/axlsx/content_type/content_type.rb @@ -14,9 +14,9 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<Types xmlns="' << XML_NS_T << '">') + str << (+'<Types xmlns="' << XML_NS_T << '">') each { |type| type.to_xml_string(str) } str << '</Types>' end diff --git a/lib/axlsx/content_type/default.rb b/lib/axlsx/content_type/default.rb index ad215070..16189fc6 100644 --- a/lib/axlsx/content_type/default.rb +++ b/lib/axlsx/content_type/default.rb @@ -16,7 +16,7 @@ module Axlsx alias :Extension= :extension= # Serializes this object to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') super(NODE_NAME, str) end end diff --git a/lib/axlsx/content_type/override.rb b/lib/axlsx/content_type/override.rb index fd98a803..be45db3c 100644 --- a/lib/axlsx/content_type/override.rb +++ b/lib/axlsx/content_type/override.rb @@ -16,7 +16,7 @@ module Axlsx alias :PartName= :part_name= # Serializes this object to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') super(NODE_NAME, str) end end diff --git a/lib/axlsx/doc_props/app.rb b/lib/axlsx/doc_props/app.rb index fec0a899..3eae1e28 100644 --- a/lib/axlsx/doc_props/app.rb +++ b/lib/axlsx/doc_props/app.rb @@ -219,9 +219,9 @@ module Axlsx # Serialize the app.xml document # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">') + str << (+'<Properties xmlns="' << APP_NS << '" xmlns:vt="' << APP_NS_VT << '">') Axlsx.instance_values_for(self).each do |key, value| node_name = Axlsx.camel(key) str << "<#{node_name}>#{value}</#{node_name}>" diff --git a/lib/axlsx/doc_props/core.rb b/lib/axlsx/doc_props/core.rb index e7e53246..8d3292e9 100644 --- a/lib/axlsx/doc_props/core.rb +++ b/lib/axlsx/doc_props/core.rb @@ -22,13 +22,13 @@ module Axlsx # serializes the core.xml document # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ') - str << ('xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ') - str << ('xmlns:xsi="' << CORE_NS_XSI << '">') - str << ('<dc:creator>' << self.creator << '</dc:creator>') - str << ('<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>') + str << (+'<cp:coreProperties xmlns:cp="' << CORE_NS << '" xmlns:dc="' << CORE_NS_DC << '" ') + str << (+'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" ') + str << (+'xmlns:xsi="' << CORE_NS_XSI << '">') + str << (+'<dc:creator>' << self.creator << '</dc:creator>') + str << (+'<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>') str << '<cp:revision>0</cp:revision>' str << '</cp:coreProperties>' end diff --git a/lib/axlsx/drawing/area_chart.rb b/lib/axlsx/drawing/area_chart.rb index 9b948808..8339c255 100644 --- a/lib/axlsx/drawing/area_chart.rb +++ b/lib/axlsx/drawing/area_chart.rb @@ -74,16 +74,16 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do - str << ("<c:" << node_name << ">") - str << ('<c:grouping val="' << grouping.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+"<c:" << node_name << ">") + str << (+'<c:grouping val="' << grouping.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls yield if block_given? axes.to_xml_string(str, :ids => true) - str << ("</c:" << node_name << ">") + str << (+"</c:" << node_name << ">") axes.to_xml_string(str) end end diff --git a/lib/axlsx/drawing/area_series.rb b/lib/axlsx/drawing/area_series.rb index 55c391d9..9d87d078 100644 --- a/lib/axlsx/drawing/area_series.rb +++ b/lib/axlsx/drawing/area_series.rb @@ -71,15 +71,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do if color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln w="28800">' str << '<a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '</a:ln>' str << '<a:round/>' @@ -94,7 +94,7 @@ module Axlsx @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? - str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') + str << (+'<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') end end diff --git a/lib/axlsx/drawing/axes.rb b/lib/axlsx/drawing/axes.rb index c84b4378..0baad85f 100644 --- a/lib/axlsx/drawing/axes.rb +++ b/lib/axlsx/drawing/axes.rb @@ -29,11 +29,11 @@ module Axlsx # @option options ids # If the ids option is specified only the axis identifier is # serialized. Otherwise, each axis is serialized in full. - def to_xml_string(str = '', options = {}) + def to_xml_string(str = +'', options = {}) if options[:ids] # CatAxis must come first in the XML (for Microsoft Excel at least) sorted = axes.sort_by { |name, axis| axis.kind_of?(CatAxis) ? 0 : 1 } - sorted.each { |axis| str << ('<c:axId val="' << axis[1].id.to_s << '"/>') } + sorted.each { |axis| str << (+'<c:axId val="' << axis[1].id.to_s << '"/>') } else axes.each { |axis| axis[1].to_xml_string(str) } end diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb index 6ee2b9f4..38e57da5 100644 --- a/lib/axlsx/drawing/axis.rb +++ b/lib/axlsx/drawing/axis.rb @@ -148,11 +148,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<c:axId val="' << @id.to_s << '"/>') + def to_xml_string(str = +'') + str << (+'<c:axId val="' << @id.to_s << '"/>') @scaling.to_xml_string str - str << ('<c:delete val="' << @delete.to_s << '"/>') - str << ('<c:axPos val="' << @ax_pos.to_s << '"/>') + str << (+'<c:delete val="' << @delete.to_s << '"/>') + str << (+'<c:axPos val="' << @ax_pos.to_s << '"/>') str << '<c:majorGridlines>' # TODO: shape properties need to be extracted into a class if gridlines == false @@ -167,21 +167,21 @@ module Axlsx # Need to set sourceLinked to 0 if we're setting a format code on this row # otherwise it will never take, as it will always prefer the 'General' formatting # of the cells themselves - str << ('<c:numFmt formatCode="' << @format_code << '" sourceLinked="' << (@format_code.eql?('General') ? '1' : '0') << '"/>') + str << (+'<c:numFmt formatCode="' << @format_code << '" sourceLinked="' << (@format_code.eql?('General') ? '1' : '0') << '"/>') str << '<c:majorTickMark val="none"/>' str << '<c:minorTickMark val="none"/>' - str << ('<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>') + str << (+'<c:tickLblPos val="' << @tick_lbl_pos.to_s << '"/>') # TODO: this is also being used for series colors # time to extract this into a class spPr - Shape Properties if @color str << '<c:spPr><a:ln><a:solidFill>' - str << ('<a:srgbClr val="' << @color << '"/>') + str << (+'<a:srgbClr val="' << @color << '"/>') str << '</a:solidFill></a:ln></c:spPr>' end # some potential value in implementing this in full. Very detailed! - str << ('<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>') - str << ('<c:crossAx val="' << @cross_axis.id.to_s << '"/>') - str << ('<c:crosses val="' << @crosses.to_s << '"/>') + str << (+'<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>') + str << (+'<c:crossAx val="' << @cross_axis.id.to_s << '"/>') + str << (+'<c:crosses val="' << @crosses.to_s << '"/>') end end end diff --git a/lib/axlsx/drawing/bar_3D_chart.rb b/lib/axlsx/drawing/bar_3D_chart.rb index 0ba55eb2..37ac7dab 100644 --- a/lib/axlsx/drawing/bar_3D_chart.rb +++ b/lib/axlsx/drawing/bar_3D_chart.rb @@ -120,17 +120,17 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:bar3DChart>' - str << ('<c:barDir val="' << bar_dir.to_s << '"/>') - str << ('<c:grouping val="' << grouping.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:barDir val="' << bar_dir.to_s << '"/>') + str << (+'<c:grouping val="' << grouping.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls - str << ('<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? - str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil? - str << ('<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? + str << (+'<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? + str << (+'<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil? + str << (+'<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? axes.to_xml_string(str, :ids => true) str << '</c:bar3DChart>' axes.to_xml_string(str) diff --git a/lib/axlsx/drawing/bar_chart.rb b/lib/axlsx/drawing/bar_chart.rb index c3240f32..eca54dfc 100644 --- a/lib/axlsx/drawing/bar_chart.rb +++ b/lib/axlsx/drawing/bar_chart.rb @@ -110,17 +110,17 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:barChart>' - str << ('<c:barDir val="' << bar_dir.to_s << '"/>') - str << ('<c:grouping val="' << grouping.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:barDir val="' << bar_dir.to_s << '"/>') + str << (+'<c:grouping val="' << grouping.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls - str << ('<c:overlap val="' << @overlap.to_s << '"/>') unless @overlap.nil? - str << ('<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? - str << ('<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? + str << (+'<c:overlap val="' << @overlap.to_s << '"/>') unless @overlap.nil? + str << (+'<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? + str << (+'<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? axes.to_xml_string(str, :ids => true) str << '</c:barChart>' axes.to_xml_string(str) diff --git a/lib/axlsx/drawing/bar_series.rb b/lib/axlsx/drawing/bar_series.rb index 86ca4e88..c744175f 100644 --- a/lib/axlsx/drawing/bar_series.rb +++ b/lib/axlsx/drawing/bar_series.rb @@ -58,19 +58,19 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do colors.each_with_index do |c, index| str << '<c:dPt>' - str << ('<c:idx val="' << index.to_s << '"/>') + str << (+'<c:idx val="' << index.to_s << '"/>') str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << c << '"/>') + str << (+'<a:srgbClr val="' << c << '"/>') str << '</a:solidFill></c:spPr></c:dPt>' end if series_color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << series_color << '"/>') + str << (+'<a:srgbClr val="' << series_color << '"/>') str << '</a:solidFill>' str << '</c:spPr>' end @@ -78,7 +78,7 @@ module Axlsx @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? # this is actually only required for shapes other than box - str << ('<c:shape val="' << shape.to_s << '"></c:shape>') + str << (+'<c:shape val="' << shape.to_s << '"></c:shape>') end end diff --git a/lib/axlsx/drawing/bubble_chart.rb b/lib/axlsx/drawing/bubble_chart.rb index 73b74035..b4932042 100644 --- a/lib/axlsx/drawing/bubble_chart.rb +++ b/lib/axlsx/drawing/bubble_chart.rb @@ -35,10 +35,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:bubbleChart>' - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } d_lbls.to_xml_string(str) if @d_lbls axes.to_xml_string(str, :ids => true) diff --git a/lib/axlsx/drawing/bubble_series.rb b/lib/axlsx/drawing/bubble_series.rb index e44a3fd8..25335270 100644 --- a/lib/axlsx/drawing/bubble_series.rb +++ b/lib/axlsx/drawing/bubble_series.rb @@ -41,15 +41,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do # needs to override the super color here to push in ln/and something else! if color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') + str << (+'<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') str << '</c:spPr>' end @xData.to_xml_string(str) unless @xData.nil? diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb index 23568d6f..a36f62d1 100644 --- a/lib/axlsx/drawing/cat_axis.rb +++ b/lib/axlsx/drawing/cat_axis.rb @@ -68,14 +68,14 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:catAx>' super(str) - str << ('<c:auto val="' << @auto.to_s << '"/>') - str << ('<c:lblAlgn val="' << @lbl_algn.to_s << '"/>') - str << ('<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>') - str << ('<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') - str << ('<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') + str << (+'<c:auto val="' << @auto.to_s << '"/>') + str << (+'<c:lblAlgn val="' << @lbl_algn.to_s << '"/>') + str << (+'<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>') + str << (+'<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') + str << (+'<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') str << '</c:catAx>' end end diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index 636c1713..300a5086 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -204,15 +204,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '" xmlns:r="' << XML_NS_R << '">') - str << ('<c:date1904 val="' << Axlsx::Workbook.date1904.to_s << '"/>') - str << ('<c:roundedCorners val="' << rounded_corners.to_s << '"/>') - str << ('<c:style val="' << style.to_s << '"/>') + str << (+'<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '" xmlns:r="' << XML_NS_R << '">') + str << (+'<c:date1904 val="' << Axlsx::Workbook.date1904.to_s << '"/>') + str << (+'<c:roundedCorners val="' << rounded_corners.to_s << '"/>') + str << (+'<c:style val="' << style.to_s << '"/>') str << '<c:chart>' @title.to_xml_string(str) unless @title.empty? - str << ('<c:autoTitleDeleted val="' << @title.nil?.to_s << '"/>') + str << (+'<c:autoTitleDeleted val="' << @title.nil?.to_s << '"/>') @view_3D.to_xml_string(str) if @view_3D str << '<c:floor><c:thickness val="0"/></c:floor>' str << '<c:sideWall><c:thickness val="0"/></c:sideWall>' @@ -223,13 +223,13 @@ module Axlsx str << '</c:plotArea>' if @show_legend str << '<c:legend>' - str << ('<c:legendPos val="' << @legend_position.to_s << '"/>') + str << (+'<c:legendPos val="' << @legend_position.to_s << '"/>') str << '<c:layout/>' str << '<c:overlay val="0"/>' str << '</c:legend>' end - str << ('<c:plotVisOnly val="' << @plot_visible_only.to_s << '"/>') - str << ('<c:dispBlanksAs val="' << display_blanks_as.to_s << '"/>') + str << (+'<c:plotVisOnly val="' << @plot_visible_only.to_s << '"/>') + str << (+'<c:dispBlanksAs val="' << display_blanks_as.to_s << '"/>') str << '<c:showDLblsOverMax val="1"/>' str << '</c:chart>' if bg_color diff --git a/lib/axlsx/drawing/d_lbls.rb b/lib/axlsx/drawing/d_lbls.rb index cdccf327..4e2bd40c 100644 --- a/lib/axlsx/drawing/d_lbls.rb +++ b/lib/axlsx/drawing/d_lbls.rb @@ -71,7 +71,7 @@ module Axlsx # serializes the data labels # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') validate_attributes_for_chart_type str << '<c:dLbls>' instance_vals = Axlsx.instance_values_for(self) diff --git a/lib/axlsx/drawing/drawing.rb b/lib/axlsx/drawing/drawing.rb index d36e4349..7be169be 100644 --- a/lib/axlsx/drawing/drawing.rb +++ b/lib/axlsx/drawing/drawing.rb @@ -155,9 +155,9 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' - str << ('<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">') + str << (+'<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">') anchors.each { |anchor| anchor.to_xml_string(str) } str << '</xdr:wsDr>' end diff --git a/lib/axlsx/drawing/graphic_frame.rb b/lib/axlsx/drawing/graphic_frame.rb index e245b9ab..7d0e818c 100644 --- a/lib/axlsx/drawing/graphic_frame.rb +++ b/lib/axlsx/drawing/graphic_frame.rb @@ -31,11 +31,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') # macro attribute should be optional! str << '<xdr:graphicFrame>' str << '<xdr:nvGraphicFramePr>' - str << ('<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>') + str << (+'<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>') str << '<xdr:cNvGraphicFramePr/>' str << '</xdr:nvGraphicFramePr>' str << '<xdr:xfrm>' @@ -43,8 +43,8 @@ module Axlsx str << '<a:ext cx="0" cy="0"/>' str << '</xdr:xfrm>' str << '<a:graphic>' - str << ('<a:graphicData uri="' << XML_NS_C << '">') - str << ('<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="' << rId << '"/>') + str << (+'<a:graphicData uri="' << XML_NS_C << '">') + str << (+'<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="' << rId << '"/>') str << '</a:graphicData>' str << '</a:graphic>' str << '</xdr:graphicFrame>' diff --git a/lib/axlsx/drawing/hyperlink.rb b/lib/axlsx/drawing/hyperlink.rb index 1fd7fdd4..3fb97069 100644 --- a/lib/axlsx/drawing/hyperlink.rb +++ b/lib/axlsx/drawing/hyperlink.rb @@ -92,7 +92,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag 'a:hlinkClick', str, { :'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R } end end diff --git a/lib/axlsx/drawing/line_3D_chart.rb b/lib/axlsx/drawing/line_3D_chart.rb index 51beaa70..6a659550 100644 --- a/lib/axlsx/drawing/line_3D_chart.rb +++ b/lib/axlsx/drawing/line_3D_chart.rb @@ -57,9 +57,9 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do - str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil? + str << (+'<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil? end end end diff --git a/lib/axlsx/drawing/line_chart.rb b/lib/axlsx/drawing/line_chart.rb index 87757dbb..ab2012c7 100644 --- a/lib/axlsx/drawing/line_chart.rb +++ b/lib/axlsx/drawing/line_chart.rb @@ -74,16 +74,16 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do - str << ("<c:" << node_name << ">") - str << ('<c:grouping val="' << grouping.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+"<c:" << node_name << ">") + str << (+'<c:grouping val="' << grouping.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls yield if block_given? axes.to_xml_string(str, :ids => true) - str << ("</c:" << node_name << ">") + str << (+"</c:" << node_name << ">") axes.to_xml_string(str) end end diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb index b1e36bbe..42c86873 100644 --- a/lib/axlsx/drawing/line_series.rb +++ b/lib/axlsx/drawing/line_series.rb @@ -71,15 +71,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do if color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln w="28800">' str << '<a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '</a:ln>' str << '<a:round/>' @@ -94,7 +94,7 @@ module Axlsx @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? - str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') + str << (+'<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') end end diff --git a/lib/axlsx/drawing/marker.rb b/lib/axlsx/drawing/marker.rb index 0e728fc6..987af605 100644 --- a/lib/axlsx/drawing/marker.rb +++ b/lib/axlsx/drawing/marker.rb @@ -56,9 +56,9 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') [:col, :colOff, :row, :rowOff].each do |k| - str << ('<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>') + str << (+'<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>') end end diff --git a/lib/axlsx/drawing/num_data.rb b/lib/axlsx/drawing/num_data.rb index 5c4e832f..79108777 100644 --- a/lib/axlsx/drawing/num_data.rb +++ b/lib/axlsx/drawing/num_data.rb @@ -36,14 +36,14 @@ module Axlsx end # serialize the object - def to_xml_string(str = "") - str << ('<c:' << @tag_name.to_s << '>') - str << ('<c:formatCode>' << format_code.to_s << '</c:formatCode>') - str << ('<c:ptCount val="' << @pt.size.to_s << '"/>') + def to_xml_string(str = +'') + str << (+'<c:' << @tag_name.to_s << '>') + str << (+'<c:formatCode>' << format_code.to_s << '</c:formatCode>') + str << (+'<c:ptCount val="' << @pt.size.to_s << '"/>') @pt.each_with_index do |num_val, index| num_val.to_xml_string index, str end - str << ('</c:' << @tag_name.to_s << '>') + str << (+'</c:' << @tag_name.to_s << '>') end end end diff --git a/lib/axlsx/drawing/num_data_source.rb b/lib/axlsx/drawing/num_data_source.rb index 0159a9d6..af5e31ab 100644 --- a/lib/axlsx/drawing/num_data_source.rb +++ b/lib/axlsx/drawing/num_data_source.rb @@ -44,17 +44,17 @@ module Axlsx # serialize the object # @param [String] str - def to_xml_string(str = "") - str << ('<c:' << tag_name.to_s << '>') + def to_xml_string(str = +'') + str << (+'<c:' << tag_name.to_s << '>') if @f - str << ('<c:' << @ref_tag_name.to_s << '>') - str << ('<c:f>' << @f.to_s << '</c:f>') + str << (+'<c:' << @ref_tag_name.to_s << '>') + str << (+'<c:f>' << @f.to_s << '</c:f>') end @data.to_xml_string str if @f - str << ('</c:' << @ref_tag_name.to_s << '>') + str << (+'</c:' << @ref_tag_name.to_s << '>') end - str << ('</c:' << tag_name.to_s << '>') + str << (+'</c:' << tag_name.to_s << '>') end end end diff --git a/lib/axlsx/drawing/num_val.rb b/lib/axlsx/drawing/num_val.rb index 3ec9f87b..b614f561 100644 --- a/lib/axlsx/drawing/num_val.rb +++ b/lib/axlsx/drawing/num_val.rb @@ -23,10 +23,10 @@ module Axlsx end # serialize the object - def to_xml_string(idx, str = "") + def to_xml_string(idx, str = +'') Axlsx::validate_unsigned_int(idx) if !v.to_s.empty? - str << ('<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>') + str << (+'<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>') end end end diff --git a/lib/axlsx/drawing/one_cell_anchor.rb b/lib/axlsx/drawing/one_cell_anchor.rb index d9999be5..f98d65a1 100644 --- a/lib/axlsx/drawing/one_cell_anchor.rb +++ b/lib/axlsx/drawing/one_cell_anchor.rb @@ -74,12 +74,12 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<xdr:oneCellAnchor>' str << '<xdr:from>' from.to_xml_string(str) str << '</xdr:from>' - str << ('<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>') + str << (+'<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>') @object.to_xml_string(str) str << '<xdr:clientData/>' str << '</xdr:oneCellAnchor>' diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb index 1f37cd0f..eec92a9c 100644 --- a/lib/axlsx/drawing/pic.rb +++ b/lib/axlsx/drawing/pic.rb @@ -189,10 +189,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<xdr:pic>' str << '<xdr:nvPicPr>' - str << ('<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">') + str << (+'<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">') hyperlink.to_xml_string(str) if hyperlink.is_a?(Hyperlink) str << '</xdr:cNvPr><xdr:cNvPicPr>' picture_locking.to_xml_string(str) @@ -213,9 +213,9 @@ module Axlsx # Return correct xml relationship string portion def relationship_xml_portion if remote? - ('<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">') + (+'<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">') else - ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">') + (+'<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">') end end diff --git a/lib/axlsx/drawing/picture_locking.rb b/lib/axlsx/drawing/picture_locking.rb index 08ac4527..9511cb15 100644 --- a/lib/axlsx/drawing/picture_locking.rb +++ b/lib/axlsx/drawing/picture_locking.rb @@ -34,7 +34,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('a:picLocks', str) end end diff --git a/lib/axlsx/drawing/pie_3D_chart.rb b/lib/axlsx/drawing/pie_3D_chart.rb index be6e3ba7..1c68dbb7 100644 --- a/lib/axlsx/drawing/pie_3D_chart.rb +++ b/lib/axlsx/drawing/pie_3D_chart.rb @@ -31,10 +31,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:pie3DChart>' - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } d_lbls.to_xml_string(str) if @d_lbls str << '</c:pie3DChart>' diff --git a/lib/axlsx/drawing/pie_series.rb b/lib/axlsx/drawing/pie_series.rb index 9cc50aa2..52cd2b66 100644 --- a/lib/axlsx/drawing/pie_series.rb +++ b/lib/axlsx/drawing/pie_series.rb @@ -44,14 +44,14 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:explosion val="' + @explosion.to_s + '"/>' unless @explosion.nil? colors.each_with_index do |c, index| str << '<c:dPt>' - str << ('<c:idx val="' << index.to_s << '"/>') + str << (+'<c:idx val="' << index.to_s << '"/>') str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << c << '"/>') + str << (+'<a:srgbClr val="' << c << '"/>') str << '</a:solidFill></c:spPr></c:dPt>' end @labels.to_xml_string str unless @labels.nil? diff --git a/lib/axlsx/drawing/scaling.rb b/lib/axlsx/drawing/scaling.rb index 4443f880..fc4b9d10 100644 --- a/lib/axlsx/drawing/scaling.rb +++ b/lib/axlsx/drawing/scaling.rb @@ -47,12 +47,12 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:scaling>' - str << ('<c:logBase val="' << @logBase.to_s << '"/>') unless @logBase.nil? - str << ('<c:orientation val="' << @orientation.to_s << '"/>') unless @orientation.nil? - str << ('<c:min val="' << @min.to_s << '"/>') unless @min.nil? - str << ('<c:max val="' << @max.to_s << '"/>') unless @max.nil? + str << (+'<c:logBase val="' << @logBase.to_s << '"/>') unless @logBase.nil? + str << (+'<c:orientation val="' << @orientation.to_s << '"/>') unless @orientation.nil? + str << (+'<c:min val="' << @min.to_s << '"/>') unless @min.nil? + str << (+'<c:max val="' << @max.to_s << '"/>') unless @max.nil? str << '</c:scaling>' end end diff --git a/lib/axlsx/drawing/scatter_chart.rb b/lib/axlsx/drawing/scatter_chart.rb index 37d528ec..b518c594 100644 --- a/lib/axlsx/drawing/scatter_chart.rb +++ b/lib/axlsx/drawing/scatter_chart.rb @@ -49,11 +49,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do str << '<c:scatterChart>' - str << ('<c:scatterStyle val="' << scatter_style.to_s << '"/>') - str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') + str << (+'<c:scatterStyle val="' << scatter_style.to_s << '"/>') + str << (+'<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } d_lbls.to_xml_string(str) if @d_lbls axes.to_xml_string(str, :ids => true) diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb index 9ea9b8a7..e52306f5 100644 --- a/lib/axlsx/drawing/scatter_series.rb +++ b/lib/axlsx/drawing/scatter_series.rb @@ -80,22 +80,22 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') super(str) do # needs to override the super color here to push in ln/and something else! if color str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') + str << (+'<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') str << '</c:spPr>' str << '<c:marker>' str << '<c:spPr><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/>') + str << (+'<a:srgbClr val="' << color << '"/>') str << '</a:solidFill>' str << '<a:ln><a:solidFill>' - str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') + str << (+'<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>') str << '</c:spPr>' str << marker_symbol_xml str << '</c:marker>' @@ -110,7 +110,7 @@ module Axlsx end @xData.to_xml_string(str) unless @xData.nil? @yData.to_xml_string(str) unless @yData.nil? - str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') + str << (+'<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') end str end diff --git a/lib/axlsx/drawing/ser_axis.rb b/lib/axlsx/drawing/ser_axis.rb index 4834c355..63628b14 100644 --- a/lib/axlsx/drawing/ser_axis.rb +++ b/lib/axlsx/drawing/ser_axis.rb @@ -32,11 +32,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:serAx>' super(str) - str << ('<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') unless @tick_lbl_skip.nil? - str << ('<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') unless @tick_mark_skip.nil? + str << (+'<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>') unless @tick_lbl_skip.nil? + str << (+'<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>') unless @tick_mark_skip.nil? str << '</c:serAx>' end end diff --git a/lib/axlsx/drawing/series.rb b/lib/axlsx/drawing/series.rb index 17c5d24e..a468a6b7 100644 --- a/lib/axlsx/drawing/series.rb +++ b/lib/axlsx/drawing/series.rb @@ -57,10 +57,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:ser>' - str << ('<c:idx val="' << index.to_s << '"/>') - str << ('<c:order val="' << (order || index).to_s << '"/>') + str << (+'<c:idx val="' << index.to_s << '"/>') + str << (+'<c:order val="' << (order || index).to_s << '"/>') title.to_xml_string(str) unless title.nil? yield if block_given? str << '</c:ser>' diff --git a/lib/axlsx/drawing/series_title.rb b/lib/axlsx/drawing/series_title.rb index 124e30a0..2887495c 100644 --- a/lib/axlsx/drawing/series_title.rb +++ b/lib/axlsx/drawing/series_title.rb @@ -6,16 +6,16 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') clean_value = Axlsx::trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@text.to_s)) str << '<c:tx>' str << '<c:strRef>' - str << ('<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>') + str << (+'<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>') str << '<c:strCache>' str << '<c:ptCount val="1"/>' str << '<c:pt idx="0">' - str << ('<c:v>' << clean_value << '</c:v>') + str << (+'<c:v>' << clean_value << '</c:v>') str << '</c:pt>' str << '</c:strCache>' str << '</c:strRef>' diff --git a/lib/axlsx/drawing/str_data.rb b/lib/axlsx/drawing/str_data.rb index ab1c25ad..0765671f 100644 --- a/lib/axlsx/drawing/str_data.rb +++ b/lib/axlsx/drawing/str_data.rb @@ -27,13 +27,13 @@ module Axlsx end # serialize the object - def to_xml_string(str = "") - str << ('<c:' << @tag_name.to_s << '>') - str << ('<c:ptCount val="' << @pt.size.to_s << '"/>') + def to_xml_string(str = +'') + str << (+'<c:' << @tag_name.to_s << '>') + str << (+'<c:ptCount val="' << @pt.size.to_s << '"/>') @pt.each_with_index do |value, index| value.to_xml_string index, str end - str << ('</c:' << @tag_name.to_s << '>') + str << (+'</c:' << @tag_name.to_s << '>') end end end diff --git a/lib/axlsx/drawing/str_val.rb b/lib/axlsx/drawing/str_val.rb index f6d36d41..821c7037 100644 --- a/lib/axlsx/drawing/str_val.rb +++ b/lib/axlsx/drawing/str_val.rb @@ -23,10 +23,10 @@ module Axlsx end # serialize the object - def to_xml_string(idx, str = "") + def to_xml_string(idx, str = +'') Axlsx::validate_unsigned_int(idx) if !v.to_s.empty? - str << ('<c:pt idx="' << idx.to_s << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>') + str << (+'<c:pt idx="' << idx.to_s << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>') end end end diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb index 9fd90d29..7bd41b17 100644 --- a/lib/axlsx/drawing/title.rb +++ b/lib/axlsx/drawing/title.rb @@ -69,18 +69,18 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:title>' unless empty? clean_value = Axlsx::trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@text.to_s)) str << '<c:tx>' if @cell.is_a?(Cell) str << '<c:strRef>' - str << ('<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>') + str << (+'<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>') str << '<c:strCache>' str << '<c:ptCount val="1"/>' str << '<c:pt idx="0">' - str << ('<c:v>' << clean_value << '</c:v>') + str << (+'<c:v>' << clean_value << '</c:v>') str << '</c:pt>' str << '</c:strCache>' str << '</c:strRef>' @@ -90,8 +90,8 @@ module Axlsx str << '<a:lstStyle/>' str << '<a:p>' str << '<a:r>' - str << ('<a:rPr sz="' << @text_size.to_s << '"/>') - str << ('<a:t>' << clean_value << '</a:t>') + str << (+'<a:rPr sz="' << @text_size.to_s << '"/>') + str << (+'<a:t>' << clean_value << '</a:t>') str << '</a:r>' str << '</a:p>' str << '</c:rich>' diff --git a/lib/axlsx/drawing/two_cell_anchor.rb b/lib/axlsx/drawing/two_cell_anchor.rb index 7b01ae13..bebfd28c 100644 --- a/lib/axlsx/drawing/two_cell_anchor.rb +++ b/lib/axlsx/drawing/two_cell_anchor.rb @@ -81,7 +81,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<xdr:twoCellAnchor>' str << '<xdr:from>' from.to_xml_string str diff --git a/lib/axlsx/drawing/val_axis.rb b/lib/axlsx/drawing/val_axis.rb index 8ebdcc92..1200eb5d 100644 --- a/lib/axlsx/drawing/val_axis.rb +++ b/lib/axlsx/drawing/val_axis.rb @@ -26,10 +26,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:valAx>' super(str) - str << ('<c:crossBetween val="' << @cross_between.to_s << '"/>') + str << (+'<c:crossBetween val="' << @cross_between.to_s << '"/>') str << '</c:valAx>' end end diff --git a/lib/axlsx/drawing/view_3D.rb b/lib/axlsx/drawing/view_3D.rb index a414b46a..9b1b5cb2 100644 --- a/lib/axlsx/drawing/view_3D.rb +++ b/lib/axlsx/drawing/view_3D.rb @@ -96,7 +96,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<c:view3D>' %w(rot_x h_percent rot_y depth_percent r_ang_ax perspective).each do |key| str << element_for_attribute(key, 'c') diff --git a/lib/axlsx/drawing/vml_drawing.rb b/lib/axlsx/drawing/vml_drawing.rb index 0805421e..1da4e51a 100644 --- a/lib/axlsx/drawing/vml_drawing.rb +++ b/lib/axlsx/drawing/vml_drawing.rb @@ -20,7 +20,7 @@ module Axlsx # serialize the vml_drawing to xml. # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << <<BAD_PROGRAMMER <xml xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" diff --git a/lib/axlsx/drawing/vml_shape.rb b/lib/axlsx/drawing/vml_shape.rb index 4db280f3..5d225d2a 100644 --- a/lib/axlsx/drawing/vml_shape.rb +++ b/lib/axlsx/drawing/vml_shape.rb @@ -37,7 +37,7 @@ module Axlsx # serialize the shape to a string # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << <<SHAME_ON_YOU <v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto" diff --git a/lib/axlsx/rels/relationship.rb b/lib/axlsx/rels/relationship.rb index 3f296b82..d9393b15 100644 --- a/lib/axlsx/rels/relationship.rb +++ b/lib/axlsx/rels/relationship.rb @@ -102,10 +102,10 @@ module Axlsx # serialize relationship # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') h = Axlsx.instance_values_for(self).reject { |k, _| k == "source_obj" } str << '<Relationship ' - str << (h.map { |key, value| '' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"' }.join(' ')) + str << (h.map { |key, value| +'' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"' }.join(' ')) str << '/>' end diff --git a/lib/axlsx/rels/relationships.rb b/lib/axlsx/rels/relationships.rb index 64126ed7..ec5b16e9 100644 --- a/lib/axlsx/rels/relationships.rb +++ b/lib/axlsx/rels/relationships.rb @@ -21,9 +21,9 @@ module Axlsx # serialize relationships # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<Relationships xmlns="' << RELS_R << '">') + str << (+'<Relationships xmlns="' << RELS_R << '">') each { |rel| rel.to_xml_string(str) } str << '</Relationships>' end diff --git a/lib/axlsx/stylesheet/border.rb b/lib/axlsx/stylesheet/border.rb index ed172ba8..163479b1 100644 --- a/lib/axlsx/stylesheet/border.rb +++ b/lib/axlsx/stylesheet/border.rb @@ -56,7 +56,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<border ' serialized_attributes str str << '>' diff --git a/lib/axlsx/stylesheet/border_pr.rb b/lib/axlsx/stylesheet/border_pr.rb index 8c1d2ede..154b25f4 100644 --- a/lib/axlsx/stylesheet/border_pr.rb +++ b/lib/axlsx/stylesheet/border_pr.rb @@ -62,10 +62,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<' << @name.to_s << ' style="' << @style.to_s << '">') + def to_xml_string(str = +'') + 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 end diff --git a/lib/axlsx/stylesheet/cell_alignment.rb b/lib/axlsx/stylesheet/cell_alignment.rb index c5eb383e..4a0c0686 100644 --- a/lib/axlsx/stylesheet/cell_alignment.rb +++ b/lib/axlsx/stylesheet/cell_alignment.rb @@ -119,7 +119,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('alignment', str) end end diff --git a/lib/axlsx/stylesheet/cell_protection.rb b/lib/axlsx/stylesheet/cell_protection.rb index 3c75d509..caa01ced 100644 --- a/lib/axlsx/stylesheet/cell_protection.rb +++ b/lib/axlsx/stylesheet/cell_protection.rb @@ -33,7 +33,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('protection', str) end end diff --git a/lib/axlsx/stylesheet/cell_style.rb b/lib/axlsx/stylesheet/cell_style.rb index 3d198afd..5dc9a90d 100644 --- a/lib/axlsx/stylesheet/cell_style.rb +++ b/lib/axlsx/stylesheet/cell_style.rb @@ -63,7 +63,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('cellStyle', str) end end diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb index a1743cb2..47617da5 100644 --- a/lib/axlsx/stylesheet/color.rb +++ b/lib/axlsx/stylesheet/color.rb @@ -72,7 +72,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '', tag_name = 'color') + def to_xml_string(str = +'', tag_name = 'color') serialized_tag('' + tag_name + '', str) end end diff --git a/lib/axlsx/stylesheet/dxf.rb b/lib/axlsx/stylesheet/dxf.rb index 0bbae6ca..8c32a75f 100644 --- a/lib/axlsx/stylesheet/dxf.rb +++ b/lib/axlsx/stylesheet/dxf.rb @@ -64,7 +64,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<dxf>' # Dxf elements have no attributes. All of the instance variables # are child elements. diff --git a/lib/axlsx/stylesheet/fill.rb b/lib/axlsx/stylesheet/fill.rb index e6561e26..313a24a3 100644 --- a/lib/axlsx/stylesheet/fill.rb +++ b/lib/axlsx/stylesheet/fill.rb @@ -21,7 +21,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<fill>' @fill_type.to_xml_string(str) str << '</fill>' diff --git a/lib/axlsx/stylesheet/font.rb b/lib/axlsx/stylesheet/font.rb index 920f6f97..463b8fc0 100644 --- a/lib/axlsx/stylesheet/font.rb +++ b/lib/axlsx/stylesheet/font.rb @@ -148,10 +148,10 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<font>' Axlsx.instance_values_for(self).each do |k, v| - v.is_a?(Color) ? v.to_xml_string(str) : (str << ('<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>')) + v.is_a?(Color) ? v.to_xml_string(str) : (str << (+'<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>')) end str << '</font>' end diff --git a/lib/axlsx/stylesheet/gradient_fill.rb b/lib/axlsx/stylesheet/gradient_fill.rb index 1c58c12a..6cd0a052 100644 --- a/lib/axlsx/stylesheet/gradient_fill.rb +++ b/lib/axlsx/stylesheet/gradient_fill.rb @@ -92,7 +92,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<gradientFill ' serialized_attributes str str << '>' diff --git a/lib/axlsx/stylesheet/gradient_stop.rb b/lib/axlsx/stylesheet/gradient_stop.rb index fd53a41a..83f39a55 100644 --- a/lib/axlsx/stylesheet/gradient_stop.rb +++ b/lib/axlsx/stylesheet/gradient_stop.rb @@ -29,8 +29,8 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<stop position="' << position.to_s << '">') + def to_xml_string(str = +'') + 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 1864fcf2..1a7add0e 100644 --- a/lib/axlsx/stylesheet/num_fmt.rb +++ b/lib/axlsx/stylesheet/num_fmt.rb @@ -69,12 +69,12 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('numFmt', str) end # Override to avoid removing underscores - def serialized_attributes(str = '', additional_attributes = {}) + def serialized_attributes(str = +'', additional_attributes = {}) attributes = declared_attributes.merge! additional_attributes attributes.each do |key, value| str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.booleanize(value)}\" " diff --git a/lib/axlsx/stylesheet/pattern_fill.rb b/lib/axlsx/stylesheet/pattern_fill.rb index 5f89955d..cabce9f5 100644 --- a/lib/axlsx/stylesheet/pattern_fill.rb +++ b/lib/axlsx/stylesheet/pattern_fill.rb @@ -58,8 +58,8 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<patternFill patternType="' << patternType.to_s << '">') + def to_xml_string(str = +'') + 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 3cbe8f75..809630f2 100644 --- a/lib/axlsx/stylesheet/styles.rb +++ b/lib/axlsx/stylesheet/styles.rb @@ -485,8 +485,8 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<styleSheet xmlns="' << XML_NS << '">') + def to_xml_string(str = +'') + str << (+'<styleSheet xmlns="' << XML_NS << '">') instance_vals = Axlsx.instance_values_for(self) [:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key| instance_vals[key.to_s].to_xml_string(str) unless instance_vals[key.to_s].nil? diff --git a/lib/axlsx/stylesheet/table_style.rb b/lib/axlsx/stylesheet/table_style.rb index 24c441ce..4423c518 100644 --- a/lib/axlsx/stylesheet/table_style.rb +++ b/lib/axlsx/stylesheet/table_style.rb @@ -42,7 +42,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<tableStyle ' serialized_attributes str, { :count => self.size } str << '>' diff --git a/lib/axlsx/stylesheet/table_style_element.rb b/lib/axlsx/stylesheet/table_style_element.rb index c36ab838..2e64d9a3 100644 --- a/lib/axlsx/stylesheet/table_style_element.rb +++ b/lib/axlsx/stylesheet/table_style_element.rb @@ -69,7 +69,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('tableStyleElement', str) end end diff --git a/lib/axlsx/stylesheet/table_styles.rb b/lib/axlsx/stylesheet/table_styles.rb index 16cc7320..49f6e601 100644 --- a/lib/axlsx/stylesheet/table_styles.rb +++ b/lib/axlsx/stylesheet/table_styles.rb @@ -33,7 +33,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<tableStyles ' serialized_attributes str, { :count => self.size } str << '>' diff --git a/lib/axlsx/stylesheet/xf.rb b/lib/axlsx/stylesheet/xf.rb index d42880e0..45d362ca 100644 --- a/lib/axlsx/stylesheet/xf.rb +++ b/lib/axlsx/stylesheet/xf.rb @@ -134,7 +134,7 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<xf ' serialized_attributes str str << '>' diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index 04b33fa5..b7247e0d 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -49,7 +49,7 @@ module Axlsx # serialization to. # @param [Hash] additional_attributes An option key value hash for # defining values that are not serializable attributes list. - def serialized_attributes(str = '', additional_attributes = {}) + def serialized_attributes(str = +'', additional_attributes = {}) attributes = declared_attributes.merge! additional_attributes attributes.each do |key, value| str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.camel(Axlsx.booleanize(value), false)}\" " @@ -73,7 +73,7 @@ module Axlsx # @param [String] str The string instance to which serialized data is appended # @param [Array] additional_attributes An array of additional attribute names. # @return [String] The serialized output. - def serialized_element_attributes(str = '', additional_attributes = [], &block) + def serialized_element_attributes(str = +'', additional_attributes = [], &block) attrs = self.class.xml_element_attributes + additional_attributes values = Axlsx.instance_values_for(self) attrs.each do |attribute_name| diff --git a/lib/axlsx/util/simple_typed_list.rb b/lib/axlsx/util/simple_typed_list.rb index 1a8bbbec..2bd6b648 100644 --- a/lib/axlsx/util/simple_typed_list.rb +++ b/lib/axlsx/util/simple_typed_list.rb @@ -171,12 +171,12 @@ module Axlsx }, __FILE__, __LINE__ - 4 end - def to_xml_string(str = '') + def to_xml_string(str = +'') classname = @allowed_types[0].name.split('::').last el_name = serialize_as.to_s || (classname[0, 1].downcase + classname[1..-1]) - str << ('<' << el_name << ' count="' << size.to_s << '">') + str << (+'<' << el_name << ' count="' << size.to_s << '">') each { |item| item.to_xml_string(str) } - str << ('</' << el_name << '>') + str << (+'</' << el_name << '>') end end end diff --git a/lib/axlsx/workbook/defined_name.rb b/lib/axlsx/workbook/defined_name.rb index bcba47ee..4ddcff2c 100644 --- a/lib/axlsx/workbook/defined_name.rb +++ b/lib/axlsx/workbook/defined_name.rb @@ -120,12 +120,12 @@ module Axlsx serializable_attributes :short_cut_key, :status_bar, :help, :description, :custom_menu, :comment, :workbook_parameter, :publish_to_server, :xlm, :vb_proceedure, :function, :hidden, :local_sheet_id - def to_xml_string(str = '') + def to_xml_string(str = +'') raise ArgumentError, 'you must specify the name for this defined name. Please read the documentation for Axlsx::DefinedName for more details' unless name - str << ('<definedName ' << 'name="' << name << '" ') + str << (+'<definedName ' << 'name="' << name << '" ') serialized_attributes str - str << ('>' << @formula << '</definedName>') + str << (+'>' << @formula << '</definedName>') end end end diff --git a/lib/axlsx/workbook/defined_names.rb b/lib/axlsx/workbook/defined_names.rb index 9da776fd..e59acf4b 100644 --- a/lib/axlsx/workbook/defined_names.rb +++ b/lib/axlsx/workbook/defined_names.rb @@ -11,7 +11,7 @@ module Axlsx # Serialize to xml # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << '<definedNames>' diff --git a/lib/axlsx/workbook/shared_strings_table.rb b/lib/axlsx/workbook/shared_strings_table.rb index f0cbf04d..17007b08 100644 --- a/lib/axlsx/workbook/shared_strings_table.rb +++ b/lib/axlsx/workbook/shared_strings_table.rb @@ -36,7 +36,7 @@ module Axlsx @index = 0 @xml_space = xml_space @unique_cells = {} - @shared_xml_string = "" + @shared_xml_string = +'' shareable_cells = cells.flatten.select { |cell| cell.plain_string? || cell.contains_rich_text? } @count = shareable_cells.size resolve(shareable_cells) @@ -45,11 +45,11 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') Axlsx::sanitize(@shared_xml_string) - str << ('<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '"') - str << (' count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '"') - str << (' xml:space="' << xml_space.to_s << '">' << @shared_xml_string << '</sst>') + str << (+'<?xml version="1.0" encoding="UTF-8"?><sst xmlns="' << XML_NS << '"') + str << (+' count="' << @count.to_s << '" uniqueCount="' << unique_count.to_s << '"') + str << (+' xml:space="' << xml_space.to_s << '">' << @shared_xml_string << '</sst>') end private diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index bd70a836..ab16a4ed 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -405,11 +405,11 @@ module Axlsx # Serialize the workbook # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') add_worksheet(name: 'Sheet1') unless worksheets.size > 0 str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">') - str << ('<workbookPr date1904="' << @@date1904.to_s << '"/>') + str << (+'<workbook xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '">') + str << (+'<workbookPr date1904="' << @@date1904.to_s << '"/>') views.to_xml_string(str) str << '<sheets>' if is_reversed @@ -422,7 +422,7 @@ module Axlsx unless pivot_tables.empty? str << '<pivotCaches>' pivot_tables.each do |pivot_table| - str << ('<pivotCache cacheId="' << pivot_table.cache_definition.cache_id.to_s << '" r:id="' << pivot_table.cache_definition.rId << '"/>') + str << (+'<pivotCache cacheId="' << pivot_table.cache_definition.cache_id.to_s << '" r:id="' << pivot_table.cache_definition.rId << '"/>') end str << '</pivotCaches>' end diff --git a/lib/axlsx/workbook/workbook_view.rb b/lib/axlsx/workbook/workbook_view.rb index e992a65e..398563f9 100644 --- a/lib/axlsx/workbook/workbook_view.rb +++ b/lib/axlsx/workbook/workbook_view.rb @@ -68,7 +68,7 @@ module Axlsx # Serialize the WorkbookView # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<workbookView ' serialized_attributes str str << '></workbookView>' diff --git a/lib/axlsx/workbook/workbook_views.rb b/lib/axlsx/workbook/workbook_views.rb index 569533f8..45d146f1 100644 --- a/lib/axlsx/workbook/workbook_views.rb +++ b/lib/axlsx/workbook/workbook_views.rb @@ -11,7 +11,7 @@ module Axlsx # Serialize to xml # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << "<bookViews>" diff --git a/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb b/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb index 156d4ae8..5a74d79a 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb @@ -69,7 +69,7 @@ module Axlsx # serialize the object # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return unless range str << "<autoFilter ref='#{range}'>" diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb index 92884e97..f014eb18 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb @@ -87,7 +87,7 @@ module Axlsx end # Serialize the object to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<filterColumn #{serialized_attributes}>" @filter.to_xml_string(str) str << "</filterColumn>" diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb index 77cf7b17..0fc5c968 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/filters.rb @@ -76,7 +76,7 @@ module Axlsx end # Serialize the object to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<filters #{serialized_attributes}>" filter_items.each { |filter| filter.to_xml_string(str) } date_group_items.each { |date_group_item| date_group_item.to_xml_string(str) } @@ -120,7 +120,7 @@ module Axlsx # Serializes the filter value object # @param [String] str The string to concact the serialization information to. - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<filter val='#{@val}' />" end end @@ -237,7 +237,7 @@ module Axlsx # Serialize the object to xml # @param [String] str The string object this serialization will be concatenated to. - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('dateGroupItem', str) end end diff --git a/lib/axlsx/workbook/worksheet/break.rb b/lib/axlsx/workbook/worksheet/break.rb index c40503be..ca99a661 100644 --- a/lib/axlsx/workbook/worksheet/break.rb +++ b/lib/axlsx/workbook/worksheet/break.rb @@ -27,7 +27,7 @@ module Axlsx serializable_attributes :id, :min, :max, :man, :pt # serializes the break to xml - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('brk', str) end end diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 930356e5..929a7c28 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -388,7 +388,7 @@ module Axlsx # @param [Integer] c_index The cell index in the row. # @param [String] str The string index the cell content will be appended to. Defaults to empty string. # @return [String] xml text for the cell - def to_xml_string(r_index, c_index, str = '') + def to_xml_string(r_index, c_index, str = +'') CellSerializer.to_xml_string r_index, c_index, self, str end diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb index 3c8f87dc..b4c16b57 100644 --- a/lib/axlsx/workbook/worksheet/cell_serializer.rb +++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb @@ -9,8 +9,8 @@ module Axlsx # @param [Integer] column_index The index of the cell's column # @param [String] str The string to apend serialization to. # @return [String] - def to_xml_string(row_index, column_index, cell, str = '') - str << ('<c r="' << Axlsx::cell_r(column_index, row_index) << '" s="' << cell.style.to_s << '" ') + def to_xml_string(row_index, column_index, cell, str = +'') + str << (+'<c r="' << Axlsx::cell_r(column_index, row_index) << '" s="' << cell.style.to_s << '" ') return str << '/>' if cell.value.nil? method = cell.type @@ -21,7 +21,7 @@ module Axlsx # builds an xml text run based on this cells attributes. # @param [String] str The string instance this run will be concated to. # @return [String] - def run_xml_string(cell, str = '') + def run_xml_string(cell, str = +'') if cell.is_text_run? valid = RichTextRun::INLINE_STYLES - [:value, :type] data = Hash[Axlsx.instance_values_for(cell).map { |k, v| [k.to_sym, v] }] @@ -30,7 +30,7 @@ module Axlsx elsif cell.contains_rich_text? cell.value.to_xml_string(str) else - str << ('<t>' << cell.clean_value << '</t>') + str << (+'<t>' << cell.clean_value << '</t>') end str end @@ -39,7 +39,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def iso_8601(cell, str = '') + def iso_8601(cell, str = +'') value_serialization 'd', cell.value, str end @@ -47,7 +47,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def date(cell, str = '') + def date(cell, str = +'') value_serialization false, DateTimeConverter::date_to_serial(cell.value).to_s, str end @@ -55,7 +55,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def time(cell, str = '') + def time(cell, str = +'') value_serialization false, DateTimeConverter::time_to_serial(cell.value).to_s, str end @@ -63,7 +63,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def boolean(cell, str = '') + def boolean(cell, str = +'') value_serialization 'b', cell.value.to_s, str end @@ -71,7 +71,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def float(cell, str = '') + def float(cell, str = +'') numeric cell, str end @@ -79,7 +79,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def integer(cell, str = '') + def integer(cell, str = +'') numeric cell, str end @@ -87,25 +87,25 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def formula_serialization(cell, str = '') - str << ('t="str"><f>' << cell.clean_value.to_s.sub('=', '') << '</f>') - str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil? + def formula_serialization(cell, str = +'') + str << (+'t="str"><f>' << cell.clean_value.to_s.sub('=', '') << '</f>') + str << (+'<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil? end # Serializes cells that are type array formula # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def array_formula_serialization(cell, str = '') - str << ('t="str">' << '<f t="array" ref="' << cell.r << '">' << cell.clean_value.to_s.sub('{=', '').sub(/}$/, '') << '</f>') - str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil? + def array_formula_serialization(cell, str = +'') + str << (+'t="str">' << '<f t="array" ref="' << cell.r << '">' << cell.clean_value.to_s.sub('{=', '').sub(/}$/, '') << '</f>') + str << (+'<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil? end # Serializes cells that are type inline_string # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def inline_string_serialization(cell, str = '') + def inline_string_serialization(cell, str = +'') str << 't="inlineStr"><is>' run_xml_string cell, str str << '</is>' @@ -115,7 +115,7 @@ module Axlsx # @param [Cell] cell The cell that is being serialized # @param [String] str The string the serialized content will be appended to. # @return [String] - def string(cell, str = '') + def string(cell, str = +'') if cell.is_array_formula? array_formula_serialization cell, str elsif cell.is_formula? @@ -153,13 +153,13 @@ module Axlsx private - def numeric(cell, str = '') + def numeric(cell, str = +'') value_serialization 'n', cell.value, str end - def value_serialization(serialization_type, serialization_value, str = '') - str << ('t="' << serialization_type.to_s << '"') if serialization_type - str << ('><v>' << serialization_value.to_s << '</v>') + def value_serialization(serialization_type, serialization_value, str = +'') + str << (+'t="' << serialization_type.to_s << '"') if serialization_type + str << (+'><v>' << serialization_value.to_s << '</v>') end end end diff --git a/lib/axlsx/workbook/worksheet/cfvo.rb b/lib/axlsx/workbook/worksheet/cfvo.rb index 7feb933d..9aeb55ed 100644 --- a/lib/axlsx/workbook/worksheet/cfvo.rb +++ b/lib/axlsx/workbook/worksheet/cfvo.rb @@ -55,7 +55,7 @@ module Axlsx # serialize the Csvo object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('cfvo', str) end end diff --git a/lib/axlsx/workbook/worksheet/cfvos.rb b/lib/axlsx/workbook/worksheet/cfvos.rb index 5115577a..3c41953a 100644 --- a/lib/axlsx/workbook/worksheet/cfvos.rb +++ b/lib/axlsx/workbook/worksheet/cfvos.rb @@ -11,7 +11,7 @@ module Axlsx # Serialize the Cfvo object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') each { |cfvo| cfvo.to_xml_string(str) } end end diff --git a/lib/axlsx/workbook/worksheet/col.rb b/lib/axlsx/workbook/worksheet/col.rb index 10d421e8..539a6007 100644 --- a/lib/axlsx/workbook/worksheet/col.rb +++ b/lib/axlsx/workbook/worksheet/col.rb @@ -137,7 +137,7 @@ module Axlsx # Serialize this columns data to an xml string # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('col', str) end end diff --git a/lib/axlsx/workbook/worksheet/col_breaks.rb b/lib/axlsx/workbook/worksheet/col_breaks.rb index 4a7b7f94..2e176f0d 100644 --- a/lib/axlsx/workbook/worksheet/col_breaks.rb +++ b/lib/axlsx/workbook/worksheet/col_breaks.rb @@ -25,10 +25,10 @@ module Axlsx # <colBreaks count="1" manualBreakCount="1"> # <brk id="3" max="1048575" man="1"/> # </colBreaks> - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? - str << ('<colBreaks count="' << size.to_s << '" manualBreakCount="' << size.to_s << '">') + str << (+'<colBreaks count="' << size.to_s << '" manualBreakCount="' << size.to_s << '">') each { |brk| brk.to_xml_string(str) } str << '</colBreaks>' end diff --git a/lib/axlsx/workbook/worksheet/color_scale.rb b/lib/axlsx/workbook/worksheet/color_scale.rb index 222e2f4d..fb84668b 100644 --- a/lib/axlsx/workbook/worksheet/color_scale.rb +++ b/lib/axlsx/workbook/worksheet/color_scale.rb @@ -84,7 +84,7 @@ module Axlsx # Serialize this color_scale object data to an xml string # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<colorScale>' value_objects.to_xml_string(str) colors.each { |color| color.to_xml_string(str) } diff --git a/lib/axlsx/workbook/worksheet/cols.rb b/lib/axlsx/workbook/worksheet/cols.rb index 76e0fbf7..7dd3f175 100644 --- a/lib/axlsx/workbook/worksheet/cols.rb +++ b/lib/axlsx/workbook/worksheet/cols.rb @@ -14,7 +14,7 @@ module Axlsx # Serialize the Cols object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << '<cols>' diff --git a/lib/axlsx/workbook/worksheet/comment.rb b/lib/axlsx/workbook/worksheet/comment.rb index b0fd3e3b..1da779aa 100644 --- a/lib/axlsx/workbook/worksheet/comment.rb +++ b/lib/axlsx/workbook/worksheet/comment.rb @@ -61,17 +61,17 @@ module Axlsx # serialize the object # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') author = @comments.authors[author_index] - str << ('<comment ref="' << ref << '" authorId="' << author_index.to_s << '">') + str << (+'<comment ref="' << ref << '" authorId="' << author_index.to_s << '">') str << '<text>' unless author.to_s == "" str << '<r><rPr><b/><color indexed="81"/></rPr>' - str << ("<t>" << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>") + str << (+"<t>" << ::CGI.escapeHTML(author.to_s) << ":\n</t></r>") end str << '<r>' str << '<rPr><color indexed="81"/></rPr>' - str << ('<t>' << ::CGI.escapeHTML(text) << '</t></r></text>') + str << (+'<t>' << ::CGI.escapeHTML(text) << '</t></r></text>') str << '</comment>' end diff --git a/lib/axlsx/workbook/worksheet/comments.rb b/lib/axlsx/workbook/worksheet/comments.rb index 020b29f5..b121ccd7 100644 --- a/lib/axlsx/workbook/worksheet/comments.rb +++ b/lib/axlsx/workbook/worksheet/comments.rb @@ -64,11 +64,11 @@ module Axlsx # serialize the object # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<comments xmlns="' << XML_NS << '"><authors>') + str << (+'<comments xmlns="' << XML_NS << '"><authors>') authors.each do |author| - str << ('<author>' << author.to_s << '</author>') + str << (+'<author>' << author.to_s << '</author>') end str << '</authors><commentList>' each do |comment| diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting.rb b/lib/axlsx/workbook/worksheet/conditional_formatting.rb index d6293ca8..bd5f5bc6 100644 --- a/lib/axlsx/workbook/worksheet/conditional_formatting.rb +++ b/lib/axlsx/workbook/worksheet/conditional_formatting.rb @@ -74,8 +74,8 @@ module Axlsx # </conditionalFormatting> # @param [String] str # @return [String] - def to_xml_string(str = '') - str << ('<conditionalFormatting sqref="' << sqref << '">') + def to_xml_string(str = +'') + str << (+'<conditionalFormatting sqref="' << sqref << '">') str << rules.collect { |rule| rule.to_xml_string }.join(' ') str << '</conditionalFormatting>' end diff --git a/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb b/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb index d3693d7e..1845f327 100644 --- a/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +++ b/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb @@ -204,11 +204,11 @@ module Axlsx # Serializes the conditional formatting rule # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<cfRule ' serialized_attributes str str << '>' - str << ('<formula>' << [*self.formula].join('</formula><formula>') << '</formula>') if @formula + str << (+'<formula>' << [*self.formula].join('</formula><formula>') << '</formula>') if @formula @color_scale.to_xml_string(str) if @color_scale && @type == :colorScale @data_bar.to_xml_string(str) if @data_bar && @type == :dataBar @icon_set.to_xml_string(str) if @icon_set && @type == :iconSet diff --git a/lib/axlsx/workbook/worksheet/conditional_formattings.rb b/lib/axlsx/workbook/worksheet/conditional_formattings.rb index ba8c02a3..16ee1e99 100644 --- a/lib/axlsx/workbook/worksheet/conditional_formattings.rb +++ b/lib/axlsx/workbook/worksheet/conditional_formattings.rb @@ -16,7 +16,7 @@ module Axlsx attr_reader :worksheet # serialize the conditional formattings - def to_xml_string(str = "") + def to_xml_string(str = +'') return if empty? each { |item| item.to_xml_string(str) } diff --git a/lib/axlsx/workbook/worksheet/data_bar.rb b/lib/axlsx/workbook/worksheet/data_bar.rb index 0e505637..108a5c16 100644 --- a/lib/axlsx/workbook/worksheet/data_bar.rb +++ b/lib/axlsx/workbook/worksheet/data_bar.rb @@ -107,7 +107,7 @@ module Axlsx # Serialize this object to an xml string # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') serialized_tag('dataBar', str) do value_objects.to_xml_string(str) self.color.to_xml_string(str) diff --git a/lib/axlsx/workbook/worksheet/data_validation.rb b/lib/axlsx/workbook/worksheet/data_validation.rb index 82868071..1b9cb46a 100644 --- a/lib/axlsx/workbook/worksheet/data_validation.rb +++ b/lib/axlsx/workbook/worksheet/data_validation.rb @@ -233,16 +233,16 @@ module Axlsx # Serializes the data validation # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') valid_attributes = get_valid_attributes str << '<dataValidation ' str << Axlsx.instance_values_for(self).map do |key, value| - '' << key << '="' << Axlsx.booleanize(value).to_s << '"' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym)) + +'' << key << '="' << Axlsx.booleanize(value).to_s << '"' if (valid_attributes.include?(key.to_sym) && !CHILD_ELEMENTS.include?(key.to_sym)) end.join(' ') str << '>' - str << ('<formula1>' << self.formula1 << '</formula1>') if @formula1 and valid_attributes.include?(:formula1) - str << ('<formula2>' << self.formula2 << '</formula2>') if @formula2 and valid_attributes.include?(:formula2) + str << (+'<formula1>' << self.formula1 << '</formula1>') if @formula1 and valid_attributes.include?(:formula1) + str << (+'<formula2>' << self.formula2 << '</formula2>') if @formula2 and valid_attributes.include?(:formula2) str << '</dataValidation>' end diff --git a/lib/axlsx/workbook/worksheet/data_validations.rb b/lib/axlsx/workbook/worksheet/data_validations.rb index dd5f11b9..a8c2a5b3 100644 --- a/lib/axlsx/workbook/worksheet/data_validations.rb +++ b/lib/axlsx/workbook/worksheet/data_validations.rb @@ -16,7 +16,7 @@ module Axlsx attr_reader :worksheet # serialize the conditional formattings - def to_xml_string(str = "") + def to_xml_string(str = +'') return if empty? str << "<dataValidations count='#{size}'>" diff --git a/lib/axlsx/workbook/worksheet/dimension.rb b/lib/axlsx/workbook/worksheet/dimension.rb index 356c0396..42e02e72 100644 --- a/lib/axlsx/workbook/worksheet/dimension.rb +++ b/lib/axlsx/workbook/worksheet/dimension.rb @@ -36,7 +36,7 @@ module Axlsx # serialize the object # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if worksheet.rows.empty? str << "<dimension ref=\"%s\"></dimension>" % sqref diff --git a/lib/axlsx/workbook/worksheet/header_footer.rb b/lib/axlsx/workbook/worksheet/header_footer.rb index b80f4eeb..c60d6678 100644 --- a/lib/axlsx/workbook/worksheet/header_footer.rb +++ b/lib/axlsx/workbook/worksheet/header_footer.rb @@ -42,7 +42,7 @@ module Axlsx # Serializes the header/footer object. # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('headerFooter', str) do serialized_element_attributes(str) do |value| value = ::CGI.escapeHTML(value) diff --git a/lib/axlsx/workbook/worksheet/icon_set.rb b/lib/axlsx/workbook/worksheet/icon_set.rb index 0179cc5f..c4b5f2ff 100644 --- a/lib/axlsx/workbook/worksheet/icon_set.rb +++ b/lib/axlsx/workbook/worksheet/icon_set.rb @@ -63,7 +63,7 @@ module Axlsx # Serialize this object to an xml string # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') serialized_tag('iconSet', str) do @value_objects.each { |cfvo| cfvo.to_xml_string(str) } end diff --git a/lib/axlsx/workbook/worksheet/merged_cells.rb b/lib/axlsx/workbook/worksheet/merged_cells.rb index 5ecb1a4e..c0ca1ebe 100644 --- a/lib/axlsx/workbook/worksheet/merged_cells.rb +++ b/lib/axlsx/workbook/worksheet/merged_cells.rb @@ -28,7 +28,7 @@ module Axlsx # serialize the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << "<mergeCells count='#{size}'>" diff --git a/lib/axlsx/workbook/worksheet/outline_pr.rb b/lib/axlsx/workbook/worksheet/outline_pr.rb index fc301a76..4cfeea2d 100644 --- a/lib/axlsx/workbook/worksheet/outline_pr.rb +++ b/lib/axlsx/workbook/worksheet/outline_pr.rb @@ -27,7 +27,7 @@ module Axlsx # Serialize the object # @param [String] str serialized output will be appended to this object if provided. # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<outlinePr #{serialized_attributes} />" end end diff --git a/lib/axlsx/workbook/worksheet/page_margins.rb b/lib/axlsx/workbook/worksheet/page_margins.rb index 1e4a34e0..4d133c5a 100644 --- a/lib/axlsx/workbook/worksheet/page_margins.rb +++ b/lib/axlsx/workbook/worksheet/page_margins.rb @@ -92,7 +92,7 @@ module Axlsx # @return [String] # @note For compatibility, this is a noop unless custom margins have been specified. # @see #custom_margins_specified? - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('pageMargins', str) end end diff --git a/lib/axlsx/workbook/worksheet/page_set_up_pr.rb b/lib/axlsx/workbook/worksheet/page_set_up_pr.rb index d1c62c9e..9a2b778b 100644 --- a/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +++ b/lib/axlsx/workbook/worksheet/page_set_up_pr.rb @@ -37,8 +37,8 @@ module Axlsx end # serialize to xml - def to_xml_string(str = '') - str << ('<pageSetUpPr ' << serialized_attributes << '/>') + def to_xml_string(str = +'') + str << (+'<pageSetUpPr ' << serialized_attributes << '/>') end end end diff --git a/lib/axlsx/workbook/worksheet/page_setup.rb b/lib/axlsx/workbook/worksheet/page_setup.rb index fa49142d..0bd0cdb8 100644 --- a/lib/axlsx/workbook/worksheet/page_setup.rb +++ b/lib/axlsx/workbook/worksheet/page_setup.rb @@ -232,7 +232,7 @@ module Axlsx # Serializes the page settings element. # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('pageSetup', str) end end diff --git a/lib/axlsx/workbook/worksheet/pane.rb b/lib/axlsx/workbook/worksheet/pane.rb index f88b732c..a018dc74 100644 --- a/lib/axlsx/workbook/worksheet/pane.rb +++ b/lib/axlsx/workbook/worksheet/pane.rb @@ -122,7 +122,7 @@ module Axlsx # Serializes the data validation # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') finalize serialized_tag 'pane', str end diff --git a/lib/axlsx/workbook/worksheet/pivot_table.rb b/lib/axlsx/workbook/worksheet/pivot_table.rb index 8c6cb83e..e97b8119 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table.rb @@ -186,13 +186,13 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<pivotTableDefinition xmlns="' << XML_NS << '" name="' << name << '" cacheId="' << cache_definition.cache_id.to_s << '"' << (data.size <= 1 ? ' dataOnRows="1"' : '') << ' applyNumberFormats="0" applyBorderFormats="0" applyFontFormats="0" applyPatternFormats="0" applyAlignmentFormats="0" applyWidthHeightFormats="1" dataCaption="Data" showMultipleLabel="0" showMemberPropertyTips="0" useAutoFormatting="1" indent="0" compact="0" compactData="0" gridDropZones="1" multipleFieldFilters="0">') + str << (+'<pivotTableDefinition xmlns="' << XML_NS << '" name="' << name << '" cacheId="' << cache_definition.cache_id.to_s << '"' << (data.size <= 1 ? ' dataOnRows="1"' : '') << ' applyNumberFormats="0" applyBorderFormats="0" applyFontFormats="0" applyPatternFormats="0" applyAlignmentFormats="0" applyWidthHeightFormats="1" dataCaption="Data" showMultipleLabel="0" showMemberPropertyTips="0" useAutoFormatting="1" indent="0" compact="0" compactData="0" gridDropZones="1" multipleFieldFilters="0">') - str << ('<location firstDataCol="1" firstDataRow="1" firstHeaderRow="1" ref="' << ref << '"/>') - str << ('<pivotFields count="' << header_cells_count.to_s << '">') + str << (+'<location firstDataCol="1" firstDataRow="1" firstHeaderRow="1" ref="' << ref << '"/>') + str << (+'<pivotFields count="' << header_cells_count.to_s << '">') header_cell_values.each do |cell_value| subtotal = !no_subtotals_on_headers.include?(cell_value) @@ -205,12 +205,12 @@ module Axlsx str << '<rowFields count="1"><field x="-2"/></rowFields>' str << '<rowItems count="2"><i><x/></i> <i i="1"><x v="1"/></i></rowItems>' else - str << ('<rowFields count="' << rows.size.to_s << '">') + str << (+'<rowFields count="' << rows.size.to_s << '">') rows.each do |row_value| - str << ('<field x="' << header_index_of(row_value).to_s << '"/>') + str << (+'<field x="' << header_index_of(row_value).to_s << '"/>') end str << '</rowFields>' - str << ('<rowItems count="' << rows.size.to_s << '">') + str << (+'<rowItems count="' << rows.size.to_s << '">') rows.size.times do |i| str << '<i/>' end @@ -229,16 +229,16 @@ module Axlsx str << '<colItems count="1"><i/></colItems>' end else - str << ('<colFields count="' << columns.size.to_s << '">') + str << (+'<colFields count="' << columns.size.to_s << '">') columns.each do |column_value| - str << ('<field x="' << header_index_of(column_value).to_s << '"/>') + str << (+'<field x="' << header_index_of(column_value).to_s << '"/>') end str << '</colFields>' end unless pages.empty? - str << ('<pageFields count="' << pages.size.to_s << '">') + str << (+'<pageFields count="' << pages.size.to_s << '">') pages.each do |page_value| - str << ('<pageField fld="' << header_index_of(page_value).to_s << '"/>') + str << (+'<pageField fld="' << header_index_of(page_value).to_s << '"/>') end str << '</pageFields>' end diff --git a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb index 136e756e..d42c1fda 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb @@ -45,15 +45,15 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<pivotCacheDefinition xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '" invalid="1" refreshOnLoad="1" recordCount="0">') + str << (+'<pivotCacheDefinition xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '" invalid="1" refreshOnLoad="1" recordCount="0">') str << '<cacheSource type="worksheet">' - str << ('<worksheetSource ref="' << pivot_table.range << '" sheet="' << pivot_table.data_sheet.name << '"/>') + str << (+'<worksheetSource ref="' << pivot_table.range << '" sheet="' << pivot_table.data_sheet.name << '"/>') str << '</cacheSource>' - str << ('<cacheFields count="' << pivot_table.header_cells_count.to_s << '">') + str << (+'<cacheFields count="' << pivot_table.header_cells_count.to_s << '">') pivot_table.header_cells.each do |cell| - str << ('<cacheField name="' << cell.clean_value << '" numFmtId="0">') + str << (+'<cacheField name="' << cell.clean_value << '" numFmtId="0">') str << '<sharedItems count="0">' str << '</sharedItems>' str << '</cacheField>' diff --git a/lib/axlsx/workbook/worksheet/print_options.rb b/lib/axlsx/workbook/worksheet/print_options.rb index e2c73bfa..6e1b2bfd 100644 --- a/lib/axlsx/workbook/worksheet/print_options.rb +++ b/lib/axlsx/workbook/worksheet/print_options.rb @@ -33,7 +33,7 @@ module Axlsx # @note As all attributes default to "false" according to the xml schema definition, the generated xml includes only those attributes that are set to true. # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag 'printOptions', str end end diff --git a/lib/axlsx/workbook/worksheet/protected_range.rb b/lib/axlsx/workbook/worksheet/protected_range.rb index ac7d96f1..64a5795c 100644 --- a/lib/axlsx/workbook/worksheet/protected_range.rb +++ b/lib/axlsx/workbook/worksheet/protected_range.rb @@ -41,7 +41,7 @@ module Axlsx # @param [String] str if this string object is provided we append # our output to that object. Use this - it helps limit the number of # objects created during serialization - def to_xml_string(str = "") + def to_xml_string(str = +'') serialized_tag 'protectedRange', str end end diff --git a/lib/axlsx/workbook/worksheet/protected_ranges.rb b/lib/axlsx/workbook/worksheet/protected_ranges.rb index 1d214d3b..f8ce82c5 100644 --- a/lib/axlsx/workbook/worksheet/protected_ranges.rb +++ b/lib/axlsx/workbook/worksheet/protected_ranges.rb @@ -28,7 +28,7 @@ module Axlsx # Serializes the protected ranges # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << '<protectedRanges>' diff --git a/lib/axlsx/workbook/worksheet/rich_text.rb b/lib/axlsx/workbook/worksheet/rich_text.rb index 13febb0a..e1a3ad4b 100644 --- a/lib/axlsx/workbook/worksheet/rich_text.rb +++ b/lib/axlsx/workbook/worksheet/rich_text.rb @@ -47,7 +47,7 @@ module Axlsx # renders the RichTextRuns in this collection # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') each { |run| run.to_xml_string(str) } str end diff --git a/lib/axlsx/workbook/worksheet/rich_text_run.rb b/lib/axlsx/workbook/worksheet/rich_text_run.rb index 9b61806c..ee988318 100644 --- a/lib/axlsx/workbook/worksheet/rich_text_run.rb +++ b/lib/axlsx/workbook/worksheet/rich_text_run.rb @@ -205,7 +205,7 @@ module Axlsx # Serializes the RichTextRun # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') valid = RichTextRun::INLINE_STYLES data = Hash[Axlsx.instance_values_for(self).map { |k, v| [k.to_sym, v] }] data = data.select { |key, value| valid.include?(key) && !value.nil? } @@ -214,15 +214,15 @@ module Axlsx data.keys.each do |key| case key when :font_name - str << ('<rFont val="' << font_name << '"/>') + str << (+'<rFont val="' << font_name << '"/>') when :color str << data[key].to_xml_string else - str << ('<' << key.to_s << ' val="' << xml_value(data[key]) << '"/>') + str << (+'<' << key.to_s << ' val="' << xml_value(data[key]) << '"/>') end end clean_value = Axlsx::trust_input ? @value.to_s : ::CGI.escapeHTML(Axlsx::sanitize(@value.to_s)) - str << ('</rPr><t>' << clean_value << '</t></r>') + str << (+'</rPr><t>' << clean_value << '</t></r>') end private diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb index 50326aba..0c139164 100644 --- a/lib/axlsx/workbook/worksheet/row.rb +++ b/lib/axlsx/workbook/worksheet/row.rb @@ -88,10 +88,9 @@ module Axlsx # @param [Integer] r_index The row index, 0 based. # @param [String] str The string this rows xml will be appended to. # @return [String] - def to_xml_string(r_index, str = '') + def to_xml_string(r_index, str = +'') serialized_tag('row', str, :r => r_index + 1) do - tmp = '' # time / memory tradeoff, lots of calls to rubyzip costs more - # time.. + tmp = +'' # time / memory tradeoff, lots of calls to rubyzip costs more time.. each_with_index { |cell, c_index| cell.to_xml_string(r_index, c_index, tmp) } str << tmp end diff --git a/lib/axlsx/workbook/worksheet/row_breaks.rb b/lib/axlsx/workbook/worksheet/row_breaks.rb index 6d1b17c8..3e945b78 100644 --- a/lib/axlsx/workbook/worksheet/row_breaks.rb +++ b/lib/axlsx/workbook/worksheet/row_breaks.rb @@ -23,10 +23,10 @@ module Axlsx # <brk id="7" max="16383" man="1"/> # <brk id="13" max="16383" man="1"/> # </rowBreaks> - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? - str << ('<rowBreaks count="' << self.size.to_s << '" manualBreakCount="' << self.size.to_s << '">') + str << (+'<rowBreaks count="' << self.size.to_s << '" manualBreakCount="' << self.size.to_s << '">') each { |brk| brk.to_xml_string(str) } str << '</rowBreaks>' end diff --git a/lib/axlsx/workbook/worksheet/selection.rb b/lib/axlsx/workbook/worksheet/selection.rb index 377c0b25..556651e3 100644 --- a/lib/axlsx/workbook/worksheet/selection.rb +++ b/lib/axlsx/workbook/worksheet/selection.rb @@ -94,7 +94,7 @@ module Axlsx # Serializes the data validation # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag 'selection', str end end diff --git a/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb b/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb index bb78f92e..e85cbf2c 100644 --- a/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +++ b/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb @@ -23,7 +23,7 @@ module Axlsx # @param [String] str the string to append this objects serialized # content to. # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<sheetCalcPr #{serialized_attributes}/>" end end diff --git a/lib/axlsx/workbook/worksheet/sheet_data.rb b/lib/axlsx/workbook/worksheet/sheet_data.rb index 1531d5bf..611da1aa 100644 --- a/lib/axlsx/workbook/worksheet/sheet_data.rb +++ b/lib/axlsx/workbook/worksheet/sheet_data.rb @@ -16,7 +16,7 @@ module Axlsx # Serialize the sheet data # @param [String] str the string this objects serializaton will be concacted to. # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<sheetData>' worksheet.rows.each_with_index do |row, index| row.to_xml_string(index, str) diff --git a/lib/axlsx/workbook/worksheet/sheet_format_pr.rb b/lib/axlsx/workbook/worksheet/sheet_format_pr.rb index e9ef8f33..227b9037 100644 --- a/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +++ b/lib/axlsx/workbook/worksheet/sheet_format_pr.rb @@ -48,7 +48,7 @@ module Axlsx # serializes this object to an xml string # @param [String] str The string this objects serialization will be appended to # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << "<sheetFormatPr #{serialized_attributes}/>" end diff --git a/lib/axlsx/workbook/worksheet/sheet_pr.rb b/lib/axlsx/workbook/worksheet/sheet_pr.rb index 3bbb88d4..f90e7d6c 100644 --- a/lib/axlsx/workbook/worksheet/sheet_pr.rb +++ b/lib/axlsx/workbook/worksheet/sheet_pr.rb @@ -50,7 +50,7 @@ module Axlsx # Serialize the object # @param [String] str serialized output will be appended to this object if provided. # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') update_properties str << "<sheetPr #{serialized_attributes}>" tab_color.to_xml_string(str, 'tabColor') if tab_color diff --git a/lib/axlsx/workbook/worksheet/sheet_protection.rb b/lib/axlsx/workbook/worksheet/sheet_protection.rb index 1b9aff14..faf34f97 100644 --- a/lib/axlsx/workbook/worksheet/sheet_protection.rb +++ b/lib/axlsx/workbook/worksheet/sheet_protection.rb @@ -75,7 +75,7 @@ module Axlsx # Serialize the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('sheetProtection', str) end diff --git a/lib/axlsx/workbook/worksheet/sheet_view.rb b/lib/axlsx/workbook/worksheet/sheet_view.rb index 38b9593a..d06715fe 100644 --- a/lib/axlsx/workbook/worksheet/sheet_view.rb +++ b/lib/axlsx/workbook/worksheet/sheet_view.rb @@ -192,7 +192,7 @@ module Axlsx # Serializes the data validation # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<sheetViews>' str << '<sheetView ' serialized_attributes str diff --git a/lib/axlsx/workbook/worksheet/table.rb b/lib/axlsx/workbook/worksheet/table.rb index 70f27575..430ef489 100644 --- a/lib/axlsx/workbook/worksheet/table.rb +++ b/lib/axlsx/workbook/worksheet/table.rb @@ -73,14 +73,14 @@ module Axlsx # Serializes the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<?xml version="1.0" encoding="UTF-8"?>' - str << ('<table xmlns="' << XML_NS << '" id="' << (index + 1).to_s << '" name="' << @name << '" displayName="' << @name.gsub(/\s/, '_') << '" ') - str << ('ref="' << @ref << '" totalsRowShown="0">') - str << ('<autoFilter ref="' << @ref << '"/>') - str << ('<tableColumns count="' << header_cells.length.to_s << '">') + str << (+'<table xmlns="' << XML_NS << '" id="' << (index + 1).to_s << '" name="' << @name << '" displayName="' << @name.gsub(/\s/, '_') << '" ') + str << (+'ref="' << @ref << '" totalsRowShown="0">') + str << (+'<autoFilter ref="' << @ref << '"/>') + str << (+'<tableColumns count="' << header_cells.length.to_s << '">') header_cells.each_with_index do |cell, index| - str << ('<tableColumn id ="' << (index + 1).to_s << '" name="' << cell.clean_value << '"/>') + str << (+'<tableColumn id ="' << (index + 1).to_s << '" name="' << cell.clean_value << '"/>') end str << '</tableColumns>' table_style_info.to_xml_string(str) diff --git a/lib/axlsx/workbook/worksheet/table_style_info.rb b/lib/axlsx/workbook/worksheet/table_style_info.rb index 1af61d9f..3793d488 100644 --- a/lib/axlsx/workbook/worksheet/table_style_info.rb +++ b/lib/axlsx/workbook/worksheet/table_style_info.rb @@ -43,7 +43,7 @@ module Axlsx # seralizes this object to an xml string # @param [String] str the string to contact this objects serialization to. - def to_xml_string(str = '') + def to_xml_string(str = +'') serialized_tag('tableStyleInfo', str) end end diff --git a/lib/axlsx/workbook/worksheet/tables.rb b/lib/axlsx/workbook/worksheet/tables.rb index 41d3c658..121a0d7f 100644 --- a/lib/axlsx/workbook/worksheet/tables.rb +++ b/lib/axlsx/workbook/worksheet/tables.rb @@ -25,7 +25,7 @@ module Axlsx # renders the tables xml # @param [String] str # @return [String] - def to_xml_string(str = "") + def to_xml_string(str = +'') return if empty? str << "<tableParts count='#{size}'>" diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 1e8bf2e3..0a44027f 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -628,18 +628,18 @@ module Axlsx end # Returns a sheet node serialization for this sheet in the workbook. - def to_sheet_node_xml_string(str = '') + def to_sheet_node_xml_string(str = +'') add_autofilter_defined_name_to_workbook str << '<sheet ' serialized_attributes str - str << ('name="' << name << '" ') - str << ('r:id="' << rId << '"></sheet>') + str << (+'name="' << name << '" ') + str << (+'r:id="' << rId << '"></sheet>') end # Serializes the worksheet object to an xml string # This intentionally does not use nokogiri for performance reasons # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') add_autofilter_defined_name_to_workbook auto_filter.apply if auto_filter.range str << '<?xml version="1.0" encoding="UTF-8"?>' diff --git a/lib/axlsx/workbook/worksheet/worksheet_comments.rb b/lib/axlsx/workbook/worksheet/worksheet_comments.rb index 0f0355e7..c5f5ad13 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_comments.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_comments.rb @@ -51,7 +51,7 @@ module Axlsx # Seraalize the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return unless has_comments? str << "<legacyDrawing r:id='#{drawing_rId}' />" diff --git a/lib/axlsx/workbook/worksheet/worksheet_drawing.rb b/lib/axlsx/workbook/worksheet/worksheet_drawing.rb index ce7edc7c..18c7189a 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_drawing.rb @@ -52,7 +52,7 @@ module Axlsx # Serialize the drawing for the worksheet # @param [String] str - def to_xml_string(str = '') + def to_xml_string(str = +'') return unless has_drawing? str << "<drawing r:id='#{relationship.Id}'/>" diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb index f375582b..c4cb8983 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb @@ -58,7 +58,7 @@ module Axlsx # Seralize the object # @param [String] str # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') str << '<hyperlink ' serialized_attributes str, location_or_id str << '/>' diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb index a5b1a512..f19630f8 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb @@ -29,7 +29,7 @@ module Axlsx # seralize the collection of hyperlinks # @return [String] - def to_xml_string(str = '') + def to_xml_string(str = +'') return if empty? str << '<hyperlinks>' |
