Support table and table column sizing
All checks were successful
CI Pipeline / build (pull_request) Successful in 13s

This commit is contained in:
2025-12-03 13:50:56 +01:00
parent 00cabb6dfb
commit 843466549a
13 changed files with 520 additions and 30 deletions

View File

@@ -32,6 +32,8 @@ module Notare
render_style(xml, style)
end
render_table_normal_style(xml) if @table_styles.any?
@table_styles.each_value do |style|
render_table_style(xml, style)
end
@@ -57,8 +59,12 @@ module Notare
xml["w"].pPr do
xml["w"].jc("w:val" => ALIGNMENT_MAP[style.align]) if style.align
xml["w"].ind("w:left" => style.indent.to_s) if style.indent
xml["w"].spacing("w:before" => style.spacing_before.to_s) if style.spacing_before
xml["w"].spacing("w:after" => style.spacing_after.to_s) if style.spacing_after
if style.spacing_before || style.spacing_after
spacing_attrs = {}
spacing_attrs["w:before"] = style.spacing_before.to_s if style.spacing_before
spacing_attrs["w:after"] = style.spacing_after.to_s if style.spacing_after
xml["w"].spacing(spacing_attrs)
end
end
end
@@ -75,9 +81,24 @@ module Notare
end
end
def render_table_normal_style(xml)
xml["w"].style("w:type" => "table", "w:default" => "1", "w:styleId" => "TableNormal") do
xml["w"].name("w:val" => "Normal Table")
xml["w"].tblPr do
xml["w"].tblCellMar do
xml["w"].top("w:w" => "0", "w:type" => "dxa")
xml["w"].left("w:w" => "108", "w:type" => "dxa")
xml["w"].bottom("w:w" => "0", "w:type" => "dxa")
xml["w"].right("w:w" => "108", "w:type" => "dxa")
end
end
end
end
def render_table_style(xml, style)
xml["w"].style("w:type" => "table", "w:styleId" => style.style_id) do
xml["w"].name("w:val" => style.display_name)
xml["w"].basedOn("w:val" => "TableNormal")
xml["w"].tblPr do
render_table_borders(xml, style.borders) if style.borders