Skip to content

Commit

Permalink
Merge pull request #16 from nationalarchives/fix/ewhc_pat_2024_1664
Browse files Browse the repository at this point in the history
CLP-11783 fix for mutated images within tables
  • Loading branch information
jurisdatum authored Jun 28, 2024
2 parents cb8521e + 11d3341 commit aa3a381
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
24 changes: 12 additions & 12 deletions src/model2/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class WTable : ITable {
internal TableProperties Properties { get; private init; }
internal TableGrid Grid { get; private init; }

public IEnumerable<WRow> TypedRows { get; private init; }
public List<WRow> TypedRows { get; private init; }
public IEnumerable<IRow> Rows { get => TypedRows; }

public List<float> ColumnWidthsIns {
Expand All @@ -27,18 +27,18 @@ public WTable(MainDocumentPart main, Table table) {
Properties = table.ChildElements.OfType<TableProperties>().FirstOrDefault();
Grid = table.ChildElements.OfType<TableGrid>().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<WRow> rows) {
Main = main;
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<WRow> ParseTableContents(WTable table, IEnumerable<OpenXmlElement> elements) {
private static IEnumerable<WRow> ParseTableContents(WTable table, IEnumerable<OpenXmlElement> elements) {
return elements.Select(e => ParseTableChild(table, e)).Where(e => e is not null);
}

Expand Down Expand Up @@ -73,25 +73,25 @@ public bool IsHeader { get {
return DOCX.Util.OnOffToBool(tblHeader.Val) ?? true;
} }

public IEnumerable<WCell> TypedCells { get; private init; }
public List<WCell> TypedCells { get; private init; }
public IEnumerable<ICell> Cells { get => TypedCells; }

internal WRow(WTable table, TableRow row) {
Main = table.Main;
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<WCell> 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<WCell> ParseRowContents(WRow row, IEnumerable<OpenXmlElement> elements) {
private static IEnumerable<WCell> ParseRowContents(WRow row, IEnumerable<OpenXmlElement> elements) {
return elements.Select(e => ParseRowChild(row, e)).Where(e => e is not null);
}

Expand Down Expand Up @@ -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<IBlock> contents) {
Main = row.Main;
Row = row;
Props = props;
Contents = contents;
Contents = contents.ToList();
}

public VerticalMerge? VMerge { get {
Expand Down Expand Up @@ -261,11 +261,11 @@ public VerticalAlignment? VAlignment { get {
throw new Exception(valign.ToString());
} }

internal static IEnumerable<IBlock> ParseCellContents(WCell cell, IEnumerable<OpenXmlElement> elements) {
private static IEnumerable<IBlock> ParseCellContents(WCell cell, IEnumerable<OpenXmlElement> elements) {
return elements.SelectMany(e => ParseCellChild(cell, e));
}

internal static IEnumerable<IBlock> ParseCellChild(WCell cell, OpenXmlElement e) {
private static IEnumerable<IBlock> ParseCellChild(WCell cell, OpenXmlElement e) {
if (e is TableCellProperties)
return Enumerable.Empty<IBlock>();
if (e is BookmarkStart || e is BookmarkEnd)
Expand Down
8 changes: 4 additions & 4 deletions test/judgments/test20.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<FRBRManifestation>
<FRBRthis value="https://caselaw.nationalarchives.gov.uk/ewhc/ipec/2022/941/data.xml" />
<FRBRuri value="https://caselaw.nationalarchives.gov.uk/ewhc/ipec/2022/941/data.xml" />
<FRBRdate date="2024-05-27T19:34:32" name="transform" />
<FRBRdate date="2024-06-28T16:57:48" name="transform" />
<FRBRauthor href="#tna" />
<FRBRformat value="application/xml" />
</FRBRManifestation>
Expand All @@ -47,7 +47,7 @@
<uk:year>2022</uk:year>
<uk:number>941</uk:number>
<uk:cite>[2022] EWHC 941 (IPEC)</uk:cite>
<uk:parser>0.24.0</uk:parser>
<uk:parser>0.25.2</uk:parser>
<uk:hash>dac04b11c8c1a0d8ace73b7d428599aefc8f8c7e4eccd5b3ea1dfd90f9c9974e</uk:hash>
</proprietary>
<presentation source="#">
Expand Down Expand Up @@ -228,7 +228,7 @@
</tr>
<tr>
<td style="border:0.5pt solid #000000;background-color:initial">
<p class="TE11pt"><img src="image2.png" style="width:67.56pt;height:23.53pt" /></p>
<p class="TE11pt"><img src="image2.change1.png" style="width:67.56pt;height:23.53pt" /></p>
</td>
<td style="border:0.5pt solid #000000;background-color:initial">
<p class="TE11pt"><span style="font-family:'Times New Roman'">3 March 2015 </span></p>
Expand Down Expand Up @@ -999,7 +999,7 @@
<p><span style="font-family:'Times New Roman'">13</span></p>
</td>
<td style="border:0.5pt solid #000000;background-color:initial;vertical-align:middle">
<p style="text-align:center"><img src="image22.png" style="width:124.26pt;height:55.89pt" /></p>
<p style="text-align:center"><img src="image22.change1.png" style="width:124.26pt;height:55.89pt" /></p>
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion version.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<VersionPrefix>0.25.1</VersionPrefix>
<VersionPrefix>0.25.2</VersionPrefix>
</PropertyGroup>

</Project>

0 comments on commit aa3a381

Please sign in to comment.