Sha256: 6a8933641da2a03b7953b66b1992325af541d6b370367f66b61da26e96b308f8
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
# encoding: utf-8 # WizRft: A gem for exporting Word Documents in ruby # using the Microsoft Rich Text Format (RTF) Specification # Copyright (C) 2015 by sgzhe@163.com module WizRtf class Row def initialize(table, cells = []) @table = table @cells = [] @col_offset = 1 @right_width = 0 cells.each do |cell| add_cell cell end end def add_cell(cell, merge = false) add_cell('', true) if !merge && row_spanned?(@col_offset) c = WizRtf::Cell.new(cell) @table.row_spans[@col_offset] = c if c.rowspan > 1 if c.rowspan > 1 c.v_merge = :clvmgf elsif row_spanned? @col_offset c.v_merge = :clvmrg @table.row_spans[@col_offset].rowspan -= 1 c.colspan = @table.row_spans[@col_offset].colspan || c.colspan end c.colspan.times do @right_width += column_width(@col_offset) @col_offset += 1 end c.right_width = @right_width @cells << c add_cell('', true) if row_spanned?(@col_offset) end def row_spanned?(offset) @table.row_spans[offset] && @table.row_spans[offset].rowspan > 1 end def column_width(offset) return 20 * (@table.column_widths[offset] || WizRtf::Table::DEFAULT_COLUMN_WIDTH) if @table.column_widths.is_a?(Hash) @table.column_widths * 20 end def render(io) io.cmd :trowd io.cmd :trbrdrt io.cmd :brdrs io.cmd :brdrw10 io.cmd :trbrdrl io.cmd :brdrs io.cmd :brdrw10 io.cmd :trbrdrb io.cmd :brdrs io.cmd :brdrw10 io.cmd :trbrdrr io.cmd :brdrs io.cmd :brdrw10 io.cmd :trautofit1 io.cmd :intbl @cells.each do |c| c.render(io) end io.cmd :row end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wiz_rtf-0.6.0 | lib/wiz_rtf/row.rb |
wiz_rtf-0.5.5 | lib/wiz_rtf/row.rb |
wiz_rtf-0.5.0 | lib/wiz_rtf/row.rb |