summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet/worksheet_comments.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-07-17 09:30:05 +0900
committerRandy Morgan <[email protected]>2012-07-17 09:30:05 +0900
commit40fdb054a0f31a12870d2d12be3928075c738ebf (patch)
tree493baeffb6ca578cf438f066bb348a62bc66121d /lib/axlsx/workbook/worksheet/worksheet_comments.rb
parentaeb2d164c3db46d4d2d6e05fd34eba4e2193d28a (diff)
downloadcaxlsx-40fdb054a0f31a12870d2d12be3928075c738ebf.tar.gz
caxlsx-40fdb054a0f31a12870d2d12be3928075c738ebf.zip
MOAR cleanup for worksheet.
Diffstat (limited to 'lib/axlsx/workbook/worksheet/worksheet_comments.rb')
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet_comments.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/axlsx/workbook/worksheet/worksheet_comments.rb b/lib/axlsx/workbook/worksheet/worksheet_comments.rb
new file mode 100644
index 00000000..25ddb024
--- /dev/null
+++ b/lib/axlsx/workbook/worksheet/worksheet_comments.rb
@@ -0,0 +1,38 @@
+module Axlsx
+
+ #A wraper class for comments that defines its on worksheet
+ #serailization
+ class WorksheetComments
+
+ def initialize(worksheet)
+ raise ArugumentError, 'You must provide a worksheet' unless worksheet.is_a?(Worksheet)
+ @worksheet = worksheet
+ end
+ attr_reader :worksheet
+
+ def comments
+ @comments ||= Comments.new(worksheet)
+ end
+
+ def add_comment(options={})
+ comments.add_comment(options)
+ end
+
+ def relationships
+ return [] unless has_comments?
+ comments.relationships
+ end
+
+ def has_comments?
+ !comments.empty?
+ end
+
+ def index
+ worksheet.relationships.index { |r| r.Type == VML_DRAWING_R } + 1
+ end
+ def to_xml_string(str = '')
+ return unless has_comments?
+ str << "<legacyDrawing r:id='rId#{index}' />"
+ end
+ end
+end