diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf134606.docx | bin | 0 -> 21603 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 7 | ||||
-rw-r--r-- | writerfilter/source/dmapper/TableManager.cxx | 45 |
3 files changed, 37 insertions, 15 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf134606.docx b/sw/qa/extras/ooxmlexport/data/tdf134606.docx Binary files differnew file mode 100644 index 000000000000..c5b95cef3236 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf134606.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 13d6f679bbae..ebb3d8cf4e2b 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -617,6 +617,13 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_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 + xmlDocUniquePtr pXmlDoc = parseExport(); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:tbl"); +} + DECLARE_OOXMLEXPORT_TEST(testMsoBrightnessContrast, "msobrightnesscontrast.docx") { uno::Reference<drawing::XShape> image = getShape(1); diff --git a/writerfilter/source/dmapper/TableManager.cxx b/writerfilter/source/dmapper/TableManager.cxx index 651922fc3998..582b4d4705a6 100644 --- a/writerfilter/source/dmapper/TableManager.cxx +++ b/writerfilter/source/dmapper/TableManager.cxx @@ -441,23 +441,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); + } } } |