lib/roo/openoffice.rb in roo-1.1.0 vs lib/roo/openoffice.rb in roo-1.2.0

- old
+ new

@@ -14,35 +14,24 @@ # values for packed: :zip def initialize(filename, packed=nil, file_warning=:error) #, create = false) @file_warning = file_warning super() @tmpdir = "oo_"+$$.to_s + @tmpdir = File.join(ENV['ROO_TMP'], @tmpdir) if ENV['ROO_TMP'] unless File.exists?(@tmpdir) FileUtils::mkdir(@tmpdir) end filename = open_from_uri(filename) if filename[0,7] == "http://" filename = unzip(filename) if packed and packed == :zip - file_type_check(filename,'.ods','an openoffice') - # if File.extname(filename).downcase != ".ods" - # case @file_warning - # when :error - # raise TypeError, "#{filename} is not an openoffice file" - # when :warning - # warn "are you sure, this is an openoffice file?" - # when :ignore - # # ignore - # else - # raise "#{@file_warning} illegal state of file_warning" - # end - # end - #if create and ! File.exists?(filename) - # self.create_openoffice(filename) - #end - @cells_read = Hash.new - #TODO: @cells_read[:default] = false - @filename = filename begin + file_type_check(filename,'.ods','an openoffice') + #if create and ! File.exists?(filename) + # self.create_openoffice(filename) + #end + @cells_read = Hash.new + #TODO: @cells_read[:default] = false + @filename = filename unless File.file?(@filename) raise IOError, "file #{@filename} does not exist" end @@nr += 1 @file_nr = @@nr @@ -260,10 +249,10 @@ #++ def read_cells(sheet=nil) sheet = @default_sheet unless sheet sheet_found = false raise ArgumentError, "Error: sheet '#{sheet||'nil'}' not valid" if @default_sheet == nil and sheet==nil -raise RangeError unless self.sheets.include? sheet + raise RangeError unless self.sheets.include? sheet oo_document_count = 0 @doc.each_element do |oo_document| # @officeversion = oo_document.attributes['version'] oo_document_count += 1 oo_element_count = 0