Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Partial cell margins start from the padding their neighbours get

KnifeLemon3fcc7564e938
diff --git a/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Tables.cs b/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Tables.cs
index 14a72948..8db41c84 100644
--- a/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Tables.cs
+++ b/src/Filee.Engines/Hwp/Hwpx/Docx/DocxReader.Tables.cs
@@ -1,5 +1,5 @@
// DOCX tables: grid column widths, merged cells (gridSpan / vMerge), borders from the table style, the table and
-// each cell, cell shading, vertical alignment, row heights and repeated header rows.
+// each cell, cell shading, cell margins, vertical alignment, row heights and repeated header rows.
using System.Xml.Linq;
@@ -96,8 +96,9 @@ internal sealed partial class DocxReader
.Concat(r == 0 ? firstRowStyles.Select(s => s.Element(W + "tcPr")) : [])
.Append(tcPr))
{
+ // Sides a cell leaves out keep the padding its neighbours get: the table's, else the HWPX default.
if (properties?.Element(W + "tcMar") is { } cellMar)
- cell.CellMargin = CellMargins(cellMar, cell.CellMargin ?? table.CellMargin);
+ cell.CellMargin = CellMargins(cellMar, cell.CellMargin ?? table.CellMargin ?? new HInsets(510, 510, 141, 141));
ApplyBorders(properties?.Element(W + "tcBorders"), cellBorders);
if (properties?.Element(W + "shd") is { } shd)
fill = ShadingColor(shd) ?? fill;
diff --git a/src/Filee.Engines/Hwp/Hwpx/HwpxReader.Body.cs b/src/Filee.Engines/Hwp/Hwpx/HwpxReader.Body.cs
index abe3d872..45182eb1 100644
--- a/src/Filee.Engines/Hwp/Hwpx/HwpxReader.Body.cs
+++ b/src/Filee.Engines/Hwp/Hwpx/HwpxReader.Body.cs
@@ -535,7 +535,7 @@ internal sealed partial class HwpxReader
table.Rows.Add(row);
}
- // The model has one cell padding per table: cells with their own margins (hasMargin) win when they all agree.
+ // Cells with their own margins (hasMargin) set the table's padding when they all agree.
if (cellMargins.Count == 1 && cellMargins.Single() is { } shared)
table.CellMargin = shared;
table.ColumnCount = Math.Max(table.ColumnCount, widths.Select(w => w.Column + w.Span).DefaultIfEmpty(1).Max());