From fd451cdb2dd1f6305d199054501dd84f716d15ce Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 12 Aug 2012 23:42:31 +0900 Subject: Release prep --- README.md | 5 +++-- lib/axlsx/version.rb | 2 +- lib/axlsx/workbook/worksheet/worksheet.rb | 7 ++++++- lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb | 14 +++++++++++++- test/workbook/worksheet/tc_worksheet_hyperlink.rb | 4 ++++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5e4aea33..48e6103c 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Axlsx: Office Open XML Spreadsheet Generation **Rubinius Version**: rubinius 2.0.0dev * lower versions may run, this gem always tests against head. -**Release Date**: August 5th 2012 +**Release Date**: August 12th 2012 If you are working in rails, or with active record see: * http://github.com/randym/acts_as_xlsx @@ -145,8 +145,9 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem, #Change log --------- -- **August.?.12**: 1.2.1 +- **August.12.12**: 1.2.1 - Add support for hyperlinks in worksheets + - Fix example that was using old style cell merging with concact. - Fix bug that occurs when calculating the font_size for cells that use a user specified style which does not define sz - **August.5.12**: 1.2.0 - rebuilt worksheet serialization to clean up the code base a bit. diff --git a/lib/axlsx/version.rb b/lib/axlsx/version.rb index 4bffcb8d..bb914f7a 100644 --- a/lib/axlsx/version.rb +++ b/lib/axlsx/version.rb @@ -1,5 +1,5 @@ # encoding: UTF-8 module Axlsx # The current version - VERSION="1.2.0" + VERSION="1.2.1" end diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index ea34620a..ea3a0d1a 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -71,6 +71,8 @@ module Axlsx @tables ||= Tables.new self end + # A typed collection of hyperlinks associated with this worksheet + # @return [WorksheetHyperlinks] def hyperlinks @hyperlinks ||= WorksheetHyperlinks.new self end @@ -509,9 +511,12 @@ module Axlsx r end + # identifies the index of an object withing the collections used in generating relationships for the worksheet + # @param [Any] object the object to search for + # @return [Integer] The index of the object def relationships_index_of(object) objects = [tables.to_a, worksheet_comments.comments.to_a, hyperlinks.to_a, worksheet_drawing.drawing].flatten.compact || [] - objects.index(object) || 0 + objects.index(object) end # Returns the cell or cells defined using excel style A1:B3 references. diff --git a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb index 64c1949d..5de0a6d2 100644 --- a/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +++ b/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb @@ -36,7 +36,7 @@ module Axlsx end # Sets the cell location of this hyperlink in the worksheet - # @param [String|Cell] The string reference or cell that defines where this hyperlink shows in the worksheet. + # @param [String|Cell] cell_reference The string reference or cell that defines where this hyperlink shows in the worksheet. def ref=(cell_reference) cell_reference = cell_reference.r if cell_reference.is_a?(Cell) @@ -61,21 +61,33 @@ module Axlsx } end + # The relationship required by this hyperlink when the taget is :external + # @return [Relationship] def relationship return unless @target == :external Relationship.new HYPERLINK_R, location, :target_mode => :External end + # The id of the relationship for this object + # @return [String] def id + return unless @target == :external "rId#{(@worksheet.relationships_index_of(self)+1)}" end + # Seralize the object + # @param [String] str + # @return [String] def to_xml_string(str='') str << '' end + # The values to be used in serialization based on the target. + # location should only be specified for non-external targets. + # r:id should only be specified for external targets. + # @return [Hash] def serialization_values h = instance_values.reject { |key, value| !%w(display ref tooltip).include?(key) } if @target == :external diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb index 66e5eea1..ad993e62 100644 --- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb +++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb @@ -33,7 +33,11 @@ class TestWorksheetHyperlink < Test::Unit::TestCase end def test_id + @a.target = :external + assert_equal("rId1", @a.id) + @a.target = :internal + assert_equal(nil, @a.id) end -- cgit v1.2.3