summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2023-02-22 11:19:40 -0500
committerAndras Timar <andras.timar@collabora.com>2023-02-25 22:33:41 +0100
commit4c9dc9443787241b5e54b24783884b9fe17b97a0 (patch)
treece9a07c67c9e07035b12b17c7c494d5432f0d364
parent1f8554abc72d2e375d56a332bf4fbe8730dd471d (diff)
tdf#153526 writerfilter: catch exception from no NumberingRules
This fixes a LO 7.5 regression (well, exposed some other flaws) from commit cf02b94bc513ee1b742b4c5d7174632b568e8b72. I first tried testing if hasPropertyByName, but that returns true(????), even though this is an editeng component. Well, ignoring the fundamental issues at play here (and there are many - like having a comment take over m_xPreviousParagraph) the issue is easily solved with a try/catch instead of a redundant if clause. Change-Id: I4f27fce3e2984235df19dc3ed4be558891b28a90 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147486 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147494 Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docxbin0 -> 8910 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport18.cxx7
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx11
3 files changed, 14 insertions, 4 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx b/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx
new file mode 100644
index 000000000000..f26240092c10
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf153526_commentInNumbering.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 4efc1a5e8052..47992f819bf6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -80,6 +80,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf147646, "tdf147646_mergedCellNumbering.docx")
CPPUNIT_ASSERT_EQUAL(OUString("2."),parseDump("/root/page/body/tab/row[4]/cell/txt/SwParaPortion/SwLineLayout/child::*[@type='PortionType::Number']","expand"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf153526_commentInNumbering, "tdf153526_commentInNumbering.docx")
+{
+ // an exception was prematurely ending finishParagraph, losing numbering and CRs
+ // so before the patch, this was 6.
+ CPPUNIT_ASSERT_EQUAL(13, getParagraphs());
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert)
{
// Given a docx document with a shape with vert="mongolianVert".
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d0a11cd47988..7550cc6ff0f7 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2329,11 +2329,14 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
uno::Reference<container::XNamed> xCurrentNumberingRules(itNumberingRules->Value, uno::UNO_QUERY);
if (xCurrentNumberingRules.is())
aCurrentNumberingName = xCurrentNumberingRules->getName();
- if (m_xPreviousParagraph.is())
+ try
+ {
+ uno::Reference<container::XNamed> xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"), uno::UNO_QUERY_THROW);
+ aPreviousNumberingName = xPreviousNumberingRules->getName();
+ }
+ catch (const uno::Exception&)
{
- uno::Reference<container::XNamed> xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
- if (xPreviousNumberingRules.is())
- aPreviousNumberingName = xPreviousNumberingRules->getName();
+ TOOLS_WARN_EXCEPTION("writerfilter", "DomainMapper_Impl::finishParagraph NumberingRules");
}
}
else if ( m_xPreviousParagraph->getPropertySetInfo()->hasPropertyByName("NumberingStyleName") &&