tdf#153526 writerfilter: catch exception from no NumberingRules

This fixes a LO 7.5 regression (well, exposed some other flaws) from
commit cf02b94bc5.

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>
This commit is contained in:
Justin Luth
2023-02-22 11:19:40 -05:00
parent 681f8e6e97
commit dbbfcb7e09
3 changed files with 14 additions and 4 deletions

View File

@@ -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());
}
DECLARE_OOXMLEXPORT_TEST(testTdf153042_largeTab, "tdf153042_largeTab.docx")
{
// This is not the greatest test because it is slightly weird, and has a different layout

View File

@@ -2332,11 +2332,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);
if (xPreviousNumberingRules.is())
aPreviousNumberingName = xPreviousNumberingRules->getName();
uno::Reference<container::XNamed> xPreviousNumberingRules(m_xPreviousParagraph->getPropertyValue("NumberingRules"), uno::UNO_QUERY_THROW);
aPreviousNumberingName = xPreviousNumberingRules->getName();
}
catch (const uno::Exception&)
{
TOOLS_WARN_EXCEPTION("writerfilter", "DomainMapper_Impl::finishParagraph NumberingRules");
}
}
else if ( m_xPreviousParagraph->getPropertySetInfo()->hasPropertyByName("NumberingStyleName") &&