summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2022-12-28 23:52:10 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-12-29 22:39:55 +0000
commitd5a9722874871576b864feb7bd815f9f8bfaac48 (patch)
tree80ef8068f32f5558a284fc9055167cf6d0761977 /sw
parent37723413115baafdc7d13ad26d11aa5f917c2036 (diff)
ms format import: better handling for invalid styles
If referred paragraph style is not found or it is not a paragraph style, this can lead to exceptions in writer core and thus current paragraph can be not corretly initialized. For example, numbering can be not applied because of exception of not found style earlier. This is not a critical error, we should just not apply a style we could not resolve. Of course such documents are invalid but bit more tolerance to errors will not harm. Change-Id: I9150786e6357a7d6098440bac29ec501fc6aa802 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144852 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/invalidParagraphStyle.rtf14
-rw-r--r--sw/qa/extras/rtfexport/rtfexport3.cxx9
2 files changed, 23 insertions, 0 deletions
diff --git a/sw/qa/extras/rtfexport/data/invalidParagraphStyle.rtf b/sw/qa/extras/rtfexport/data/invalidParagraphStyle.rtf
new file mode 100644
index 000000000000..cb5ec80eb3cf
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/invalidParagraphStyle.rtf
@@ -0,0 +1,14 @@
+{\rtf1
+
+{\stylesheet
+{\cs30\fs72 Super Duper Style;}}
+
+{\*\listtable
+{\list
+{\listlevel\levelstartat1{\leveltext\'02\'00.;}{\levelnumbers\'01;}}
+{\listname ;}\listid1235362366}}
+{\*\listoverridetable{\listoverride\listid1235362366\listoverridecount0\ls1}}
+
+\pard\s30\ls1\fs24 AAA BBB CCC\par
+
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx
index 90adb69f2bf7..6c1a4d524b7f 100644
--- a/sw/qa/extras/rtfexport/rtfexport3.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport3.cxx
@@ -514,6 +514,15 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf127806)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(635), aSize.Width);
}
+DECLARE_RTFEXPORT_TEST(testInvalidParagraphStyle, "invalidParagraphStyle.rtf")
+{
+ // Given test has character style #30, but referred as paragraph style #30
+ // This was causing exception in finishParagraph(), so numbering and other
+ // properties were not applied. Ensure numbering is still here
+ sal_Int16 numFormat = getNumberingTypeOfParagraph(1);
+ CPPUNIT_ASSERT_EQUAL(style::NumberingType::ARABIC, numFormat);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */