From 11d334117be25e2ab6655a79d40052525f70bc55 Mon Sep 17 00:00:00 2001 From: Jim Mangiafico Date: Fri, 28 Jun 2024 13:38:32 -0400 Subject: [PATCH] eager tables --- src/model2/Table.cs | 24 ++++++++++++------------ test/judgments/test20.xml | 8 ++++---- version.targets | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/model2/Table.cs b/src/model2/Table.cs index 28360eba..a66d8e71 100644 --- a/src/model2/Table.cs +++ b/src/model2/Table.cs @@ -15,7 +15,7 @@ class WTable : ITable { internal TableProperties Properties { get; private init; } internal TableGrid Grid { get; private init; } - public IEnumerable TypedRows { get; private init; } + public List TypedRows { get; private init; } public IEnumerable Rows { get => TypedRows; } public List ColumnWidthsIns { @@ -27,7 +27,7 @@ public WTable(MainDocumentPart main, Table table) { Properties = table.ChildElements.OfType().FirstOrDefault(); Grid = table.ChildElements.OfType().FirstOrDefault(); Style = Properties?.TableStyle?.Val?.Value; - TypedRows = ParseTableContents(this, table.ChildElements); + TypedRows = ParseTableContents(this, table.ChildElements).ToList(); } public WTable(MainDocumentPart main, TableProperties props, TableGrid grid, IEnumerable rows) { @@ -35,10 +35,10 @@ public WTable(MainDocumentPart main, TableProperties props, TableGrid grid, IEnu Properties = props; Grid = grid; Style = Properties?.TableStyle?.Val?.Value; - TypedRows = rows.Select(row => new WRow(this, row.TablePropertyExceptions, row.Properties, row.TypedCells)); + TypedRows = rows.Select(row => new WRow(this, row.TablePropertyExceptions, row.Properties, row.TypedCells)).ToList(); } - internal static IEnumerable ParseTableContents(WTable table, IEnumerable elements) { + private static IEnumerable ParseTableContents(WTable table, IEnumerable elements) { return elements.Select(e => ParseTableChild(table, e)).Where(e => e is not null); } @@ -73,7 +73,7 @@ public bool IsHeader { get { return DOCX.Util.OnOffToBool(tblHeader.Val) ?? true; } } - public IEnumerable TypedCells { get; private init; } + public List TypedCells { get; private init; } public IEnumerable Cells { get => TypedCells; } internal WRow(WTable table, TableRow row) { @@ -81,17 +81,17 @@ internal WRow(WTable table, TableRow row) { Table = table; TablePropertyExceptions = row.TablePropertyExceptions; Properties = row.TableRowProperties; - TypedCells = ParseRowContents(this, row.ChildElements); + TypedCells = ParseRowContents(this, row.ChildElements).ToList(); } internal WRow(WTable table, TablePropertyExceptions exceptions, TableRowProperties props, IEnumerable cells) { Main = table.Main; Table = table; TablePropertyExceptions = exceptions; Properties = props; - TypedCells = cells.Select(c => new WCell(this, c.Props, c.Contents)); + TypedCells = cells.Select(c => new WCell(this, c.Props, c.Contents)).ToList(); } - internal static IEnumerable ParseRowContents(WRow row, IEnumerable elements) { + private static IEnumerable ParseRowContents(WRow row, IEnumerable elements) { return elements.Select(e => ParseRowChild(row, e)).Where(e => e is not null); } @@ -140,13 +140,13 @@ internal WCell(WRow row, TableCell cell) { Main = row.Main; Row = row; Props = cell.TableCellProperties; - Contents = ParseCellContents(this, cell.ChildElements); + Contents = ParseCellContents(this, cell.ChildElements).ToList(); } internal WCell(WRow row, TableCellProperties props, IEnumerable contents) { Main = row.Main; Row = row; Props = props; - Contents = contents; + Contents = contents.ToList(); } public VerticalMerge? VMerge { get { @@ -261,11 +261,11 @@ public VerticalAlignment? VAlignment { get { throw new Exception(valign.ToString()); } } - internal static IEnumerable ParseCellContents(WCell cell, IEnumerable elements) { + private static IEnumerable ParseCellContents(WCell cell, IEnumerable elements) { return elements.SelectMany(e => ParseCellChild(cell, e)); } - internal static IEnumerable ParseCellChild(WCell cell, OpenXmlElement e) { + private static IEnumerable ParseCellChild(WCell cell, OpenXmlElement e) { if (e is TableCellProperties) return Enumerable.Empty(); if (e is BookmarkStart || e is BookmarkEnd) diff --git a/test/judgments/test20.xml b/test/judgments/test20.xml index fe7984d0..d7e910b2 100644 --- a/test/judgments/test20.xml +++ b/test/judgments/test20.xml @@ -22,7 +22,7 @@ - + @@ -47,7 +47,7 @@ 2022 941 [2022] EWHC 941 (IPEC) - 0.24.0 + 0.25.2 dac04b11c8c1a0d8ace73b7d428599aefc8f8c7e4eccd5b3ea1dfd90f9c9974e @@ -228,7 +228,7 @@ -

+

3 March 2015

@@ -999,7 +999,7 @@

13

-

+

diff --git a/version.targets b/version.targets index c936b56a..f8902dae 100644 --- a/version.targets +++ b/version.targets @@ -1,7 +1,7 @@ - 0.25.1 + 0.25.2