[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/qa writerfilter/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 31 09:41:36 UTC 2020
sw/qa/extras/ooxmlexport/data/tdf134606.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 7 ++++
writerfilter/source/dmapper/TableManager.cxx | 45 ++++++++++++++++++---------
3 files changed, 37 insertions(+), 15 deletions(-)
New commits:
commit b83741f401be35eb001b46bc18c215e1498c3f37
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Wed Jul 8 10:36:29 2020 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Fri Jul 31 11:41:04 2020 +0200
tdf#134606 DOCX table import: fix gridBefore + nesting
Nested tables in a table row with gridBefore could
result of broken outer table, if the row doesn't contain
text before the nested table, resulting invalid
TextRange for insertion of gridBefore cells.
Regression from commit 70274f86cdc1c023ffdd0130c262c1479262d76b
(tdf#116194 DOCX import: fix missing tables with w:gridBefore)
Change-Id: I6bb3948b6522d8785a1ea0ccf8d7c7f3c2bde189
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98320
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99604
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf134606.docx b/sw/qa/extras/ooxmlexport/data/tdf134606.docx
new file mode 100644
index 000000000000..c5b95cef3236
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf134606.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index ceb397b23388..6fbcbaaeeccc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -623,6 +623,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf116194, "tdf116194.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:tbl", 2);
}
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf134606, "tdf134606.docx")
+{
+ // The problem was that the importer lost the nested table structure with w:gridBefore
+ xmlDocPtr pXmlDoc = parseExport();
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:tbl");
+}
+
DECLARE_OOXMLEXPORT_TEST(testMsoBrightnessContrast, "msobrightnesscontrast.docx")
{
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/TableManager.cxx b/writerfilter/source/dmapper/TableManager.cxx
index 97e872f7f9b1..596d036a506a 100644
--- a/writerfilter/source/dmapper/TableManager.cxx
+++ b/writerfilter/source/dmapper/TableManager.cxx
@@ -425,23 +425,38 @@ void TableManager::endRow()
TableData::Pointer_t pTableData = mTableDataStack.top();
// Add borderless w:gridBefore cell(s) to the row
- if (pTableData)
+ sal_uInt32 nGridBefore = getCurrentGridBefore();
+ if (pTableData && nGridBefore > 0 && pTableData->getCurrentRow()->getCellCount() > 0)
{
- sal_uInt32 nGridBefore
- = mpTableDataHandler->getDomainMapperImpl().getTableManager().getCurrentGridBefore();
- for (unsigned int i = 0; i < nGridBefore; ++i)
+ const css::uno::Reference<css::text::XTextRange>& xRowStart
+ = pTableData->getCurrentRow()->getCellStart(0);
+ if (xRowStart.is())
{
- css::table::BorderLine2 aBorderLine;
- aBorderLine.Color = 0;
- aBorderLine.InnerLineWidth = 0;
- aBorderLine.OuterLineWidth = 0;
- TablePropertyMapPtr pCellProperties(new TablePropertyMap);
- pCellProperties->Insert(PROP_TOP_BORDER, css::uno::makeAny(aBorderLine));
- pCellProperties->Insert(PROP_LEFT_BORDER, css::uno::makeAny(aBorderLine));
- pCellProperties->Insert(PROP_BOTTOM_BORDER, css::uno::makeAny(aBorderLine));
- pCellProperties->Insert(PROP_RIGHT_BORDER, css::uno::makeAny(aBorderLine));
- pTableData->getCurrentRow()->addCell(pTableData->getCurrentRow()->getCellStart(0),
- pCellProperties, /*bAddBefore=*/true);
+ try
+ {
+ // valid TextRange for table creation (not a nested table)?
+ xRowStart->getText()->createTextCursorByRange(xRowStart);
+
+ for (unsigned int i = 0; i < nGridBefore; ++i)
+ {
+ css::table::BorderLine2 aBorderLine;
+ aBorderLine.Color = 0;
+ aBorderLine.InnerLineWidth = 0;
+ aBorderLine.OuterLineWidth = 0;
+ TablePropertyMapPtr pCellProperties(new TablePropertyMap);
+ pCellProperties->Insert(PROP_TOP_BORDER, css::uno::makeAny(aBorderLine));
+ pCellProperties->Insert(PROP_LEFT_BORDER, css::uno::makeAny(aBorderLine));
+ pCellProperties->Insert(PROP_BOTTOM_BORDER, css::uno::makeAny(aBorderLine));
+ pCellProperties->Insert(PROP_RIGHT_BORDER, css::uno::makeAny(aBorderLine));
+ pTableData->getCurrentRow()->addCell(xRowStart, pCellProperties,
+ /*bAddBefore=*/true);
+ }
+ }
+ catch (css::uno::Exception const&)
+ {
+ // don't add gridBefore cells in not valid TextRange
+ setCurrentGridBefore(0);
+ }
}
}
More information about the Libreoffice-commits
mailing list