From 17bf5a92596d297c22293700df73d43613484d25 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Fri, 12 Mar 2021 18:55:01 +0100 Subject: [PATCH] Fix splitting lists in table cell --- .../w2phtml/pageSplitters/TableCellSplitter.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/w2phtml/pageSplitters/TableCellSplitter.java b/src/main/java/w2phtml/pageSplitters/TableCellSplitter.java index a0654b6..e2f5bc7 100644 --- a/src/main/java/w2phtml/pageSplitters/TableCellSplitter.java +++ b/src/main/java/w2phtml/pageSplitters/TableCellSplitter.java @@ -9,6 +9,7 @@ import static w2phtml.office.XMLString.TEXT_SOFT_PAGE_BREAK; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import pro.litvinovg.xml.Debug; import w2phtml.office.OfficeReader; public class TableCellSplitter extends BasicSplitter implements ISplitter { @@ -40,10 +41,16 @@ public class TableCellSplitter extends BasicSplitter implements ISplitter { results.setDataMoved(true); } } else if (nodeName.equals(TEXT_LIST)) { - if (factory.split(cellChildNode).isDataMoved()){ - cellFirstPart.appendChild(cellChildNode.getPreviousSibling()); + SplitResults listSplitResults = factory.split(cellChildNode); + if (listSplitResults.isDataMoved()){ + //Debug.prettyPrintXml(cellNode.getOwnerDocument()); + cellFirstPart.appendChild(listSplitResults.getFirstPart()); results.setDataMoved(true); + //Debug.prettyPrintXml(cellNode.getOwnerDocument()); } + if (!cellChildNode.hasChildNodes()) { + cellNode.removeChild(cellChildNode); + } } else if (nodeName.equals(TABLE_TABLE)) { if (factory.split(cellChildNode).isDataMoved()){ cellFirstPart.appendChild(cellChildNode.getPreviousSibling()); @@ -69,6 +76,8 @@ public class TableCellSplitter extends BasicSplitter implements ISplitter { if (results.isDataMoved()) { parent.insertBefore(cellFirstPart, cellNode); } + //Debug.prettyPrintXml(cellNode.getOwnerDocument()); + return results; }