diff options
-rw-r--r-- | include/xmloff/txtparae.hxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/odfexport/data/nestedTableInFooter.odt | bin | 0 -> 8611 bytes | |||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltble.cxx | 21 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 2 |
5 files changed, 37 insertions, 1 deletions
diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx index 5c09d2a782be..50e65990362b 100644 --- a/include/xmloff/txtparae.hxx +++ b/include/xmloff/txtparae.hxx @@ -365,6 +365,8 @@ protected: const css::uno::Reference< css::beans::XPropertySet> & i_xPortion, bool i_bAutoStyles, bool i_isProgress, bool & rPrevCharIsSpace); + bool isAutoStylesCollected() const { return mbCollected; } + virtual void exportTableAutoStyles(); public: diff --git a/sw/qa/extras/odfexport/data/nestedTableInFooter.odt b/sw/qa/extras/odfexport/data/nestedTableInFooter.odt Binary files differnew file mode 100644 index 000000000000..0356f04ee14e --- /dev/null +++ b/sw/qa/extras/odfexport/data/nestedTableInFooter.odt diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index e28ae2515f0b..ee25f99822fe 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -2585,5 +2585,18 @@ DECLARE_ODFEXPORT_TEST(tdf124470, "tdf124470TableAndEmbeddedUsedFonts.odt") assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='paragraph']", 1); } +DECLARE_ODFEXPORT_TEST(tdf135942, "nestedTableInFooter.odt") +{ + // All table autostyles should be collected, including nested, and must not crash. + + CPPUNIT_ASSERT_EQUAL(1, getPages()); + + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/office:document-styles/office:automatic-styles/style:style[@style:family='table']", 2); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 506c4fb2e22a..68dbde33016d 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -1199,8 +1199,27 @@ void SwXMLTextParagraphExport::exportTable( // During the flat XML export (used e.g. by .sdw-export) // ALL flags are set at the same time. const bool bExportStyles = bool( GetExport().getExportFlags() & SvXMLExportFlags::STYLES ); - if ( bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter( aIdx ) ) + if (!isAutoStylesCollected() + && (bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter(aIdx))) + { maTableNodes.push_back(pTableNd); + // Collect all tables inside cells of this table, too + const auto aCellNames = pXTable->getCellNames(); + for (const OUString& rCellName : aCellNames) + { + css::uno::Reference<css::container::XEnumerationAccess> xCell( + pXTable->getCellByName(rCellName), css::uno::UNO_QUERY); + if (!xCell) + continue; + auto xEnumeration = xCell->createEnumeration(); + while (xEnumeration->hasMoreElements()) + { + if (css::uno::Reference<css::text::XTextTable> xInnerTable{ + xEnumeration->nextElement(), css::uno::UNO_QUERY }) + exportTable(xInnerTable, bAutoStyles, _bProgress); + } + } + } } else { diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index a9354c0057c7..eead9e4f55e7 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3709,6 +3709,8 @@ void XMLTextParagraphExport::exportTableAutoStyles() {} void XMLTextParagraphExport::exportTextAutoStyles() { + // tdf#135942: do not collect styles during their export: this may modify iterated containers + mbCollected = true; exportTableAutoStyles(); GetAutoStylePool().exportXML( XmlStyleFamily::TEXT_PARAGRAPH ); |