Included Modules

ReportBuilder::Table::RtfBuilder

Public Instance Methods

add_hr_on_bottom(row_i) click to toggle source
    # File lib/reportbuilder/table/rtfbuilder.rb, line 49
49:       def add_hr_on_bottom(row_i)
50:         (0...@t.n_columns).each {|i|
51:           @table[row_i][i].bottom_border_width=@builder.options[:table_hr_width]
52:         }
53:       end
add_hr_on_top(row_i) click to toggle source
    # File lib/reportbuilder/table/rtfbuilder.rb, line 44
44:       def add_hr_on_top(row_i)
45:         (0...@t.n_columns).each {|i|
46:           @table[row_i][i].top_border_width=@builder.options[:table_hr_width]
47:         }
48:       end
generate() click to toggle source
    # File lib/reportbuilder/table/rtfbuilder.rb, line 5
 5:       def generate()
 6:         @t=@element
 7:         @rtf=@builder.rtf
 8: 
 9:         # Title
10: 
11:         @builder.header(6,@t.name)
12: 
13:         max_cols=@t.calculate_widths
14:         n_rows=@t.n_rows_no_hr+(@t.header.size>0 ? 1: 0)
15:         args=[n_rows, @t.n_columns]+max_cols.map{|m| m*@builder.options[:font_size]*10}
16:         @table=@rtf.table(*args)
17:         @table.border_width=@builder.options[:table_border_width]
18:         @rowspans=[]
19:         row_i=0
20:         if @t.header.size>0
21:           row_i=1
22:           @t.header.each_with_index do |th,i|
23:             @table[0][i] << th
24:           end
25:           add_hr_on_bottom(0)
26:         end
27:         next_with_hr=false
28: 
29:         @t.rows.each_with_index{|row|
30:           if row==:hr
31:             next_with_hr=true
32:             # Nothing
33:           else
34:             parse_row(row,row_i)
35:             if next_with_hr
36:               add_hr_on_top(row_i)
37:               next_with_hr=false
38:             end
39:             row_i+=1
40:           end
41:         }
42: 
43:       end
parse_row(row,row_i) click to toggle source
    # File lib/reportbuilder/table/rtfbuilder.rb, line 55
55:       def parse_row(row,row_i)
56:         t=@element
57:         row_ary=[]
58:         real_i=0
59:         colspan_i=0
60:         row.each_index do |i|
61:           extra=1
62:           while !@rowspans[real_i].nil? and @rowspans[real_i]>0
63:             @rowspans[real_i]-=1
64:             real_i+=1
65:           end
66:           if row[i].is_a? Table::Colspan
67:             @table[row_i][real_i] << row[i].data
68:             colspan_i=row[i].cols-1
69:             extra=row[i].cols
70:           elsif row[i].nil?
71:             @table[row_i][i] << ""
72:           elsif row[i].is_a? Table::Rowspan
73:             @table[row_i][real_i] << row[i].data
74:             @rowspans[real_i]=row[i].rows-1
75:           else
76:             @table[row_i][real_i] << row[i].to_s
77:           end
78:           real_i+=extra
79:         end
80:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.