wizport 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,8 +26,8 @@ module Wizport
26
26
  Wizport::Rtf::Text.new(self, str, styles)
27
27
  end
28
28
 
29
- def table(rows = [], &block)
30
- Wizport::Rtf::Table.new(self, rows, &block)
29
+ def table(rows = [],options = {}, &block)
30
+ Wizport::Rtf::Table.new(self, rows, options, &block)
31
31
  end
32
32
 
33
33
 
@@ -10,6 +10,7 @@ module Wizport
10
10
  def initialize(rtf, rows = [], options = {}, &block)
11
11
  super(rtf)
12
12
  @row_spans = {}
13
+ @column_widths = options[:column_widths] || 800
13
14
  rows.each_index do |index|
14
15
  add_row rows[index]
15
16
  end
@@ -21,6 +22,7 @@ module Wizport
21
22
  cmd :trautofit1
22
23
  cmd :intbl
23
24
  @col_offset = 1
25
+ @right_width = 0
24
26
  cells.each do |cell|
25
27
  if row_spanned? @col_offset
26
28
  add_cell ""
@@ -49,17 +51,18 @@ module Wizport
49
51
  cmd :celld
50
52
  if rowspan > 1
51
53
  cmd :clvmgf
52
- @col_offset += colspan
53
54
  elsif row_spanned? @col_offset
54
55
  cmd :clvmrg
55
56
  @row_spans[@col_offset][:rowspan] -= 1
56
- @col_offset += row_spans_with_colspan
57
- else
58
- @col_offset += colspan
57
+ colspan = @row_spans[@col_offset][:colspan]
59
58
  end
60
- cmd :cellx, (@col_offset - 1)* 2000
59
+ colspan.times do |i|
60
+ @right_width += column_width(@col_offset + i)
61
+ end
62
+ cmd :cellx, @right_width
61
63
  txt content
62
64
  cmd :cell
65
+ @col_offset += colspan
63
66
  end
64
67
 
65
68
  def row_spanned?(offset)
@@ -70,6 +73,11 @@ module Wizport
70
73
  return @row_spans[@col_offset][:colspan] || 1
71
74
  end
72
75
 
76
+ def column_width(offset)
77
+ return @column_widths[offset] || 800 if @column_widths.is_a?(Hash)
78
+ @column_widths
79
+ end
80
+
73
81
  end
74
82
  end
75
83
  end
@@ -1,3 +1,3 @@
1
1
  module Wizport
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -7,7 +7,7 @@ describe Wizport::Rtf::Document do
7
7
  it "a simple example of Rtf" do
8
8
  rtf = Wizport::Rtf::Document.new do
9
9
  text "学生综合素质评价"
10
- table [[1,{content:'1',colspan:2}],[3,{content:'4',rowspan:2,colspan:2}],[11]] do
10
+ table [[1,{content:'1',colspan:2}],[3,{content:'4',rowspan:2,colspan:2}],[11]],column_widths:{1=>2000,2=>1000,3=>1000} do
11
11
  add_row [1,1,1]
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wizport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-12 00:00:00.000000000 Z
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec