summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorHossein <hossein@libreoffice.org>2022-05-20 15:20:40 +0200
committerAndras Timar <andras.timar@collabora.com>2022-05-25 11:47:01 +0200
commit3907f5392dbf04b219639bff624f8386cb13d2cb (patch)
tree8a90cff5723d187e33f05ec2f65c061d9cf4dc33 /sw/qa/extras/uiwriter
parente4032e96e14b96f267238314b2e66196c315085b (diff)
tdf#149184 DOCX: fix crash removing footer, then saving to doc
When openeing the simplefooter.docx, after removing the footer and exporting to .doc, LibreOffice crashes. This regression was introduced with 88e6a1bfeac86e0c89d2ff08c908c2b5ae061177 which is titled: "DOCX: export hidden (shared) headers/footers". The current patch fixes this problem by checking to see if the header or footer text is there or not. A unit test is added to avoid this problem in the future. One can run the test with: make CPPUNIT_TEST_NAME="testTdf149184" -sr CppunitTest_sw_uiwriter7 Change-Id: I5586561677b3c490e49b4b10bd987aecdf3fc134 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134684 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134829
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/data/simplefooter.docxbin0 -> 18174 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx22
2 files changed, 22 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/simplefooter.docx b/sw/qa/extras/uiwriter/data/simplefooter.docx
new file mode 100644
index 000000000000..006c85ab7cc8
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/simplefooter.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index b7593759971b..0aea38d4bbe7 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -50,6 +50,7 @@
#include <com/sun/star/awt/FontUnderline.hpp>
#include <vcl/TypeSerializer.hxx>
+#include <svx/hdft.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
#include <svl/itemiter.hxx>
@@ -290,6 +291,7 @@ public:
void testTdf92648();
void testTdf103978_backgroundTextShape();
void testTdf117225();
+ void testTdf149184();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -411,6 +413,7 @@ public:
CPPUNIT_TEST(testTdf92648);
CPPUNIT_TEST(testTdf103978_backgroundTextShape);
CPPUNIT_TEST(testTdf117225);
+ CPPUNIT_TEST(testTdf149184);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4691,6 +4694,25 @@ void SwUiWriterTest::testTdf117225()
CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
}
+void SwUiWriterTest::testTdf149184()
+{
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "simplefooter.docx");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ // Removing the footer for all styles
+ pWrtShell->ChangeHeaderOrFooter(u"", false, false, false);
+ // export to simplefooter.doc
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aStoreProps = comphelper::InitPropertySequence({
+ { "FilterName", uno::Any(OUString("MS Word 97")) },
+ });
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ // Without the fix in place, the test fails with:
+ // [CUT] sw_uiwriter7
+ // Segmentation fault (core dumped)
+ // [_RUN_____] testTdf149184::TestBody
+ xStorable->storeToURL(aTempFile.GetURL(), aStoreProps);
+}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();