Class: SiSU_XML_ODF_ODT_Format::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/xml_odf_odt_format.rb

Constant Summary collapse

@@table_counter =
0
@@tablefoot =

watch

[]
@@fns =
''

Instance Method Summary collapse

Constructor Details

#initialize(md, dob, p_num) ⇒ Table

Returns a new instance of Table.



166
167
168
169
170
171
172
173
# 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

Instance Method Details

#break_lineObject



174
175
176
177
# File 'lib/sisu/xml_odf_odt_format.rb', line 174

def break_line
  (@md.opt.act[:maintenance][:set]==:on) \
  ? "\n" : ''
end

#tableObject



252
253
254
255
256
257
258
259
260
261
# 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 = '') ⇒ Object



203
204
205
206
# 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) ⇒ Object



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# 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) ⇒ Object



239
240
241
242
243
244
245
246
247
248
249
250
251
# 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) ⇒ Object



207
208
209
210
211
212
213
214
215
216
217
218
219
# 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) ⇒ Object



220
221
222
223
224
# 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) ⇒ Object



225
226
227
228
229
230
231
232
233
234
235
236
237
238
# 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