lib/caracal/renderers/document_renderer.rb in caracal-1.4.0 vs lib/caracal/renderers/document_renderer.rb in caracal-1.4.1

- old
+ new

@@ -349,11 +349,12 @@ end rowspan_hash = {} model.rows.each do |row| xml['w'].tr do - row.each_with_index do |tc, tc_index| + tc_index = 0 + row.each do |tc| xml['w'].tc do xml['w'].tcPr do xml['w'].shd({ 'w:fill' => tc.cell_background }) xml['w'].vAlign({ 'w:val' => tc.cell_vertical_align }) @@ -378,34 +379,17 @@ tc.contents.each do |m| method = render_method_for_model(m) send(method, xml, m) end end - end - end - # we need to adjust rowspan indexes as they depend on previous row colspans - adjusted_rowspan_hash = {} - rowspan_hash.each do |rowspan_cell_index, rowspan_value| - adjusted_rowspan_cell_index = rowspan_cell_index - row.each_with_index do |tc, tc_index| - if tc.cell_colspan && tc.cell_colspan >= 1 - if tc_index < rowspan_cell_index - adjusted_rowspan_cell_index += tc.cell_colspan - 1 - end - end + # adjust tc_index for next cell taking into account current cell's colspan + tc_index += (tc.cell_colspan && tc.cell_colspan > 0) ? tc.cell_colspan : 1 end - adjusted_rowspan_hash[adjusted_rowspan_cell_index] = rowspan_value end - - rowspan_hash = adjusted_rowspan_hash end end - - # don't know why this is needed, but it prevents a - # rendering error. - # render_paragraph(xml, Caracal::Core::Models::ParagraphModel.new) end #============= OPTIONS =================================== @@ -417,26 +401,9 @@ unless document.ignorables.empty? v = document.ignorables.join(' ') opts['mc:Ignorable'] = v end opts - # { - # 'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006', - # 'xmlns:o' => 'urn:schemas-microsoft-com:office:office', - # 'xmlns:r' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships', - # 'xmlns:m' => 'http://schemas.openxmlformats.org/officeDocument/2006/math', - # 'xmlns:v' => 'urn:schemas-microsoft-com:vml', - # 'xmlns:wp' => 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing', - # 'xmlns:w10' => 'urn:schemas-microsoft-com:office:word', - # 'xmlns:w' => 'http://schemas.openxmlformats.org/wordprocessingml/2006/main', - # 'xmlns:wne' => 'http://schemas.microsoft.com/office/word/2006/wordml', - # 'xmlns:sl' => 'http://schemas.openxmlformats.org/schemaLibrary/2006/main', - # 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main', - # 'xmlns:pic' => 'http://schemas.openxmlformats.org/drawingml/2006/picture', - # 'xmlns:c' => 'http://schemas.openxmlformats.org/drawingml/2006/chart', - # 'xmlns:lc' => 'http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas', - # 'xmlns:dgm' => 'http://schemas.openxmlformats.org/drawingml/2006/diagram' - # } end def page_margin_options { 'w:top' => document.page_margin_top,