summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-06-05 13:03:32 +0900
committerRandy Morgan <[email protected]>2012-06-05 13:03:32 +0900
commit2d6d18c2e0b8e1b68adae27500c002cfb4cd01b4 (patch)
tree32fc2c25a21bba50f10d610cdeb157dd04276793 /lib
parent705b92c0764452cfa8a2b8e4130cadb0bd83e798 (diff)
downloadcaxlsx-2d6d18c2e0b8e1b68adae27500c002cfb4cd01b4.tar.gz
caxlsx-2d6d18c2e0b8e1b68adae27500c002cfb4cd01b4.zip
fix chart title parsing to properly handle non-cell based text runs
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/drawing/chart.rb6
-rw-r--r--lib/axlsx/drawing/graphic_frame.rb2
-rw-r--r--lib/axlsx/drawing/title.rb30
3 files changed, 25 insertions, 13 deletions
diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb
index 0f26c551..f0f0185b 100644
--- a/lib/axlsx/drawing/chart.rb
+++ b/lib/axlsx/drawing/chart.rb
@@ -44,7 +44,7 @@ module Axlsx
# @option options [Array|String|Cell] start_at The X, Y coordinates defining the top left corner of the chart.
# @option options [Array|String|Cell] end_at The X, Y coordinates defining the bottom right corner of the chart.
def initialize(frame, options={})
- @style = 2
+ @style = 18
@view3D = nil
@graphic_frame=frame
@graphic_frame.anchor.drawing.worksheet.workbook.charts << self
@@ -120,13 +120,13 @@ module Axlsx
# @return [String]
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 << '">'
+ 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:style val="' << style.to_s << '"/>'
str << '<c:chart>'
@title.to_xml_string str
# do these need the c: namespace as well???
- str << '<c:autoTitleDeleted val="0"/>'
+ str << '<c:autoTitleDeleted val="' << (@title == nil).to_s << '"/>'
@view3D.to_xml_string(str) if @view3D
str << '<c:floor><c:thickness val="0"/></c:floor>'
str << '<c:sideWall><c:thickness val="0"/></c:sideWall>'
diff --git a/lib/axlsx/drawing/graphic_frame.rb b/lib/axlsx/drawing/graphic_frame.rb
index e36ae3f2..a829e5ea 100644
--- a/lib/axlsx/drawing/graphic_frame.rb
+++ b/lib/axlsx/drawing/graphic_frame.rb
@@ -35,7 +35,7 @@ module Axlsx
# macro attribute should be optional!
str << '<xdr:graphicFrame>'
str << '<xdr:nvGraphicFramePr>'
- str << '<xdr:cNvPr id="' << @anchor.drawing.worksheet.workbook.drawings.index(@anchor.drawing).to_s << '" name="' << chart.title.text << '"/>'
+ 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>'
diff --git a/lib/axlsx/drawing/title.rb b/lib/axlsx/drawing/title.rb
index a85d8e11..5292a177 100644
--- a/lib/axlsx/drawing/title.rb
+++ b/lib/axlsx/drawing/title.rb
@@ -46,15 +46,27 @@ module Axlsx
str << '<c:title>'
unless @text.empty?
str << '<c:tx>'
- str << '<c:strRef>'
- 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>' << @text << '</c:v>'
- str << '</c:pt>'
- str << '</c:strCache>'
- str << '</c:strRef>'
+ if @cell.is_a?(Cell)
+ str << '<c:strRef>'
+ 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>' << @text << '</c:v>'
+ str << '</c:pt>'
+ str << '</c:strCache>'
+ str << '</c:strRef>'
+ else
+ str << '<c:rich>'
+ str << '<a:bodyPr/>'
+ str << '<a:lstStyle/>'
+ str << '<a:p>'
+ str << '<a:r>'
+ str << '<a:t>' << @text.to_s << '</a:t>'
+ str << '</a:r>'
+ str << '</a:p>'
+ str << '</c:rich>'
+ end
str << '</c:tx>'
end
str << '<c:layout/>'