From 5a7157d319477830426797532e02ac39d3b859f4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:29:03 +0200 Subject: Merging upstream version 4:24.2.1. Signed-off-by: Daniel Baumann --- sw/qa/extras/odfimport/data/tdf123968.odt | Bin 9591 -> 8904 bytes .../extras/odfimport/data/unreferenced_stream.odt | Bin 0 -> 10311 bytes sw/qa/extras/odfimport/odfimport.cxx | 27 +++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 sw/qa/extras/odfimport/data/unreferenced_stream.odt (limited to 'sw/qa/extras/odfimport') diff --git a/sw/qa/extras/odfimport/data/tdf123968.odt b/sw/qa/extras/odfimport/data/tdf123968.odt index 1c081619ea..cd1ec8a385 100644 Binary files a/sw/qa/extras/odfimport/data/tdf123968.odt and b/sw/qa/extras/odfimport/data/tdf123968.odt differ diff --git a/sw/qa/extras/odfimport/data/unreferenced_stream.odt b/sw/qa/extras/odfimport/data/unreferenced_stream.odt new file mode 100644 index 0000000000..0cdba0d485 Binary files /dev/null and b/sw/qa/extras/odfimport/data/unreferenced_stream.odt differ diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 6ccc8cce3b..70c6452e3d 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -1167,9 +1167,21 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf123968) SwTextNode& rStart = dynamic_cast(pShellCursor->Start()->GetNode()); // The field is now editable like any text, thus the field content "New value" shows up for the cursor. + // This field's variable is declared as string and used as string - typical. CPPUNIT_ASSERT_EQUAL(OUString("inputfield: " + OUStringChar(CH_TXT_ATR_INPUTFIELDSTART) + "New value" + OUStringChar(CH_TXT_ATR_INPUTFIELDEND)), rStart.GetText()); + + // This field's variable is declared as float and used as string - not + // typical; this can easily happen if the input field is in a header/footer, + // because only content.xml contains the variable-decls, styles.xml is + // imported before content.xml, and apparently the default variable type is + // numeric. + SwTextNode& rEnd = dynamic_cast(pShellCursor->End()->GetNode()); + CPPUNIT_ASSERT_EQUAL(OUString("inputfield: " + OUStringChar(CH_TXT_ATR_INPUTFIELDSTART) + + "String input for num variable" + OUStringChar(CH_TXT_ATR_INPUTFIELDEND)), + rEnd.GetText()); + } CPPUNIT_TEST_FIXTURE(Test, testTdf133459) @@ -1534,5 +1546,20 @@ CPPUNIT_TEST_FIXTURE(Test, testEmptyTrailingSpans) CPPUNIT_ASSERT_DOUBLES_EQUAL(184, height2, 1); // allow a bit of room for rounding just in case } +CPPUNIT_TEST_FIXTURE(Test, testBrokenPackage_Tdf159474) +{ + // Given an invalid ODF having a stream not referenced in manifest.xml + const OUString url = createFileURL(u"unreferenced_stream.odt"); + // It expectedly fails to load normally: + CPPUNIT_ASSERT_ASSERTION_FAIL(loadFromDesktop(url, {}, {})); + // importing it must succeed with RepairPackage set to true. + mxComponent + = loadFromDesktop(url, {}, { comphelper::makePropertyValue(u"RepairPackage"_ustr, true) }); + // The document imports in repair mode; the original broken package is used as a template, + // and the loaded document has no URL: + CPPUNIT_ASSERT(mxComponent.queryThrow()->getURL().isEmpty()); + CPPUNIT_ASSERT_EQUAL(u"Empty document"_ustr, getParagraph(1)->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3