diff options
| author | Stefan Daschek <[email protected]> | 2013-07-05 04:22:35 +0200 |
|---|---|---|
| committer | Stefan Daschek <[email protected]> | 2013-07-08 14:15:59 +0200 |
| commit | 92b73ffb1e5cdfb001da684c463856f79aff6e11 (patch) | |
| tree | 69c6de36e9ee3eb7a4bb241d65f4ccdf1d604d3a /lib/axlsx/workbook/worksheet/worksheet_comments.rb | |
| parent | b7e14c242c0d9fc3af7b7ad969ec25df21475547 (diff) | |
| download | caxlsx-92b73ffb1e5cdfb001da684c463856f79aff6e11.tar.gz caxlsx-92b73ffb1e5cdfb001da684c463856f79aff6e11.zip | |
Make relationship ids more reliable.
Relationship instances now keep track of their own id – this should be much more reliable than the old way of more or less “guessing” the relationship id based on the position of some object in some array. Fixes https://github.com/randym/axlsx/issues/212, especially.
Each relationship now has its own, unique id – except for the cases when it doesn’t: Some relationships need to share the same id, see `Relation#should_use_same_id_as?` for the gory details.
All tests pass, and the full example.xlsx is generated without errors and looks fine in Excel for Mac 2011.
The pivot table example still has the problems mentioned in https://github.com/randym/axlsx/issues/168 – but as far as I can tell I didn’t make it worse (Excel is still be able to “repair” the file, and the repaired file then contains the pivot table).
Diffstat (limited to 'lib/axlsx/workbook/worksheet/worksheet_comments.rb')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet_comments.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/axlsx/workbook/worksheet/worksheet_comments.rb b/lib/axlsx/workbook/worksheet/worksheet_comments.rb index 8c700aa0..f9e4c8cd 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_comments.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_comments.rb @@ -40,10 +40,11 @@ module Axlsx !comments.empty? end - # The index in the worksheet's relationships for the VML drawing that will render the comments - # @return [Integer] - def index - worksheet.relationships.index { |r| r.Type == VML_DRAWING_R } + 1 + # The relationship id of the VML drawing that will render the comments. + # @see Relationship#Id + # @return [String] + def drawing_rId + comments.relationships.find{ |r| r.Type == VML_DRAWING_R }.Id end # Seraalize the object @@ -51,7 +52,7 @@ module Axlsx # @return [String] def to_xml_string(str = '') return unless has_comments? - str << "<legacyDrawing r:id='rId#{index}' />" + str << "<legacyDrawing r:id='#{drawing_rId}' />" end end end |
