Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring to make fods (ODF Flat XML) file support easier #537

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/roo/open_office.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(filename, options = {})
file_warning = options[:file_warning] || :error

@only_visible_sheets = options[:only_visible_sheets]
file_type_check(filename, '.ods', 'an Roo::OpenOffice', file_warning, packed)
file_type_check(filename, supported_extension, 'an Roo::OpenOffice', file_warning, packed)
# NOTE: Create temp directory and allow Ruby to cleanup the temp directory
# when the object is garbage collected. Initially, the finalizer was
# created in the Roo::Tempdir module, but that led to a segfault
Expand Down Expand Up @@ -53,6 +53,10 @@ def initialize(filename, options = {})
raise
end

def supported_extension
'.ods'
end

def open_oo_file(options)
Zip::File.open(@filename) do |zip_file|
content_entry = zip_file.glob('content.xml').first
Expand Down Expand Up @@ -446,6 +450,10 @@ def set_cell_values(sheet, x, y, i, v, value_type, formula, table_cell, str_v, s
end
end

def cell_elements(table_element)
table_element.children
end

# read all cells in the selected sheet
#--
# the following construct means '4 blanks'
Expand All @@ -471,7 +479,7 @@ def read_cells(sheet = default_sheet)
skip_row = attribute(table_element, 'number-rows-repeated').to_s.to_i
row = row + skip_row - 1
end
table_element.children.each do |cell|
cell_elements(table_element).each do |cell|
skip_col = attribute(cell, 'number-columns-repeated')
formula = attribute(cell, 'formula')
value_type = attribute(cell, 'value-type')
Expand Down