class SiSU_XML_ODF_ODT_Format::Table

Public Class Methods

new(md,dob,p_num) click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 166
def initialize(md,dob,p_num)
  @md,@dob,@p_num=md,dob,p_num
  @txt=dob.obj
  if @md.fns != @@fns
    @@table_counter=0
    @@fns=@md.fns
  end
end

Public Instance Methods

break_line() click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 174
def break_line
  (@md.opt.act[:maintenance][:set]==:on) \
  ? "\n" : ''
end
table() click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 252
def table
  @@table_counter+=1
  table_head_open(@@table_counter)
  @table=[]
  @dob.obj.split(/\s*#{Mx[:tc_c]}/).each_with_index do |r,i|
    @table << table_row(r,i)
  end
  @dob.obj= table_head_open(@@table_counter) + @table.join + table_close
  @dob
end
table_close(tablefoot='') click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 203
def table_close(tablefoot='')
  '</table:table>' \
  + %{<text:p text:style-name="P_group">#{@p_num[:display]}</text:p>}
end
table_head_open(count) click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 178
def table_head_open(count)
  type=(@dob.head_) \
  ? 1
  : 2
  alpha=case @dob.cols
  when  1 then 'A'
  when  2 then 'B'
  when  3 then 'C'
  when  4 then 'D'
  when  5 then 'E'
  when  6 then 'F'
  when  7 then 'G'
  when  8 then 'H'
  when  9 then 'I'
  when 10 then 'J'
  when 11 then 'K'
  when 12 then 'L'
  when 13 then 'M'
  when 14 then 'N'
  else         'D'
  end
  tag=SiSU_XML_ODF_ODT_Format::Tags.new.set_bookmark_tag(@dob)
  %{<table:table table:name="Table#{count}" table:style-name="Table#{type}">#{@p_num[:set_ref]}#{tag}#{break_line}} +
  %{<table:table-column table:style-name="Table#{type}.#{alpha}" table:number-columns-repeated="#{@dob.cols}"/>#{break_line}}
end
table_row(row,i) click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 239
def table_row(row,i)
  row='' if row =~/^<!$/
  m=row[/<!f(.+?)!>/,1]
  @@tablefoot << m if m
  row=row.gsub(/<!f.+?!>/,'')
  @cells=[]
  row.split(/\s*#{Mx[:tc_p]}/).each do |cell|
    @cells << table_tag_cell(cell,i)
  end
  row=@cells.join
  row=table_tag_row(row,i)
  row
end
table_tag_cell(str,i) click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 207
def table_tag_cell(str,i)
  txt_name_cell=if i==0 \
  and @dob.head_
    'Table_Heading'
  else 'P_table_cell'
  end
  str=str.gsub(/^~$/,'') # tilde / empty cell
  %{<table:table-cell office:value-type="string">#{break_line}} +
  %{<text:p text:style-name="#{txt_name_cell}">#{break_line}} +
  %{#{str}} +
  %{</text:p>#{break_line}} +
  %{</table:table-cell>#{break_line}}
end
table_tag_row(str,i) click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 220
def table_tag_row(str,i)
  %{<table:table-row>#{break_line}} +
  %{#{str}} +
  %{</table:table-row>#{break_line}}
end
table_tag_row_dump(str,i) click to toggle source
# File lib/sisu/xml_odf_odt_format.rb, line 225
def table_tag_row_dump(str,i)
  txt_name_row=if i==0 \
  and @dob.head_
    'Table_Heading'
  else 'P_table_cell'
  end
  %{<table:table-row>#{break_line}} +
  %{<table:table-cell office:value-type="string">#{break_line}} +
  %{<text:p text:style-name="#{txt_name_row}">#{break_line}} +
  %{#{str}} +
  %{</text:p>#{break_line}} +
  %{</table:table-cell>#{break_line}} +
  %{</table:table-row>#{break_line}}
end