diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-30 17:46:35 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-12-01 12:39:53 +0100 |
commit | 29dad1e4545c877bcf8e9bb23359d4eb39251938 (patch) | |
tree | f6891e7be42537efed1d0219348e0057ed673297 | |
parent | 0d9231f2133def9254e0220b8033a46e5fc17658 (diff) |
sc: move test back where it belongs
This test was moved from sc/qa/unit/subsequent_filters_test2.cxx
to sc/qa/unit/filters-test.cxx in ad40ad91c5400391a0848832e91c596be8fbd811
"CppunitTest_sc_subsequent_filters_test2: inherit from UnoApiXmlTest".
As the commit message says:
I couldn't find a way to test testTooManyColsRows,
move it to sc/qa/unit/filters-test.cxx for the
time being
The problem is that using loadFromDestkop resets the Error in
sfx2/source/doc/sfxbasemodel.cxx:2005 - m_pData->m_pObjectShell->ResetError();
so add a way to log the WarningError in SfxMedium
Change-Id: Ieda9bdc9de856b75d4b162248da41d637305e28d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143506
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | include/sfx2/docfile.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/filters-test.cxx | 25 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_filters_test2.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 2 |
5 files changed, 40 insertions, 25 deletions
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx index ff3ea024e19b..15ec85a5f928 100644 --- a/include/sfx2/docfile.hxx +++ b/include/sfx2/docfile.hxx @@ -146,9 +146,11 @@ public: ErrCode GetErrorCode() const; ErrCode GetError() const { return GetErrorCode().IgnoreWarning(); } + ErrCode GetWarningError() const; ErrCode const & GetLastStorageCreationState() const; void SetError(ErrCode nError); + void SetWarningError(ErrCode nWarningError); void CloseInStream(); void CloseOutStream(); diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx index c165869a1afb..63ae46860c4d 100644 --- a/sc/qa/unit/filters-test.cxx +++ b/sc/qa/unit/filters-test.cxx @@ -53,13 +53,11 @@ public: void testCVEs(); void testContentofz9704(); - void testTooManyColsRows(); void testTdf90299(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testCVEs); CPPUNIT_TEST(testContentofz9704); - CPPUNIT_TEST(testTooManyColsRows); CPPUNIT_TEST(testTdf90299); CPPUNIT_TEST_SUITE_END(); @@ -133,29 +131,6 @@ void ScFiltersTest::testContentofz9704() TestImportWKS(aFileStream); } -void ScFiltersTest::testTooManyColsRows() -{ - // The intentionally doc has cells beyond our MAXROW/MAXCOL, so there - // should be a warning on load. - OUString aFileName; - createFileURL(u"too-many-cols-rows.", u"ods", aFileName ); - ScDocShellRef xDocSh = loadDoc(aFileName, "calc8", OUString(), OUString(), - ODS_FORMAT_TYPE, SotClipboardFormatId::STARCALC_8); - - CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW - || xDocSh->GetErrorCode() == SCWARN_IMPORT_COLUMN_OVERFLOW); - xDocSh->DoClose(); - - createFileURL(u"too-many-cols-rows.", u"xlsx", aFileName ); - xDocSh = loadDoc( - aFileName, "Calc Office Open XML", OUString(), OUString(), - XLSX_FORMAT_TYPE, SotClipboardFormatId::STARCALC_8); - - CPPUNIT_ASSERT(xDocSh->GetErrorCode() == SCWARN_IMPORT_ROW_OVERFLOW - || xDocSh->GetErrorCode() == SCWARN_IMPORT_COLUMN_OVERFLOW); - xDocSh->DoClose(); -} - void ScFiltersTest::testTdf90299() { const OUString aTmpDirectory1URL = utl::CreateTempURL(nullptr, true); diff --git a/sc/qa/unit/subsequent_filters_test2.cxx b/sc/qa/unit/subsequent_filters_test2.cxx index fbaef3eb464f..e917d56ba836 100644 --- a/sc/qa/unit/subsequent_filters_test2.cxx +++ b/sc/qa/unit/subsequent_filters_test2.cxx @@ -14,6 +14,7 @@ #include <test/unoapixml_test.hxx> #include <osl/thread.h> +#include <sfx2/docfile.hxx> #include <svl/numformat.hxx> #include <svl/zformat.hxx> #include <svx/svdograf.hxx> @@ -187,6 +188,7 @@ public: void testTdf139763ShapeAnchor(); void testAutofilterNamedRangesXLSX(); void testInvalidBareBiff5(); + void testTooManyColsRows(); void testTdf83671_SmartArt_import(); void testTdf83671_SmartArt_import2(); void testTdf151818_SmartArtFontColor(); @@ -306,6 +308,7 @@ public: CPPUNIT_TEST(testTdf139763ShapeAnchor); CPPUNIT_TEST(testAutofilterNamedRangesXLSX); CPPUNIT_TEST(testInvalidBareBiff5); + CPPUNIT_TEST(testTooManyColsRows); CPPUNIT_TEST(testTdf83671_SmartArt_import); CPPUNIT_TEST(testTdf83671_SmartArt_import2); CPPUNIT_TEST(testTdf151818_SmartArtFontColor); @@ -2873,6 +2876,27 @@ void ScFiltersTest2::testInvalidBareBiff5() CPPUNIT_ASSERT_EQUAL(OUString(), pDoc->GetString(aPos)); } +void ScFiltersTest2::testTooManyColsRows() +{ + // The intentionally doc has cells beyond our MAXROW/MAXCOL, so there + // should be a warning on load. + createScDoc("ods/too-many-cols-rows.ods"); + + ScDocShell* pDocSh = getScDocShell(); + SfxMedium* pMedium = pDocSh->GetMedium(); + + CPPUNIT_ASSERT(pMedium->GetWarningError() == SCWARN_IMPORT_ROW_OVERFLOW + || pMedium->GetWarningError() == SCWARN_IMPORT_COLUMN_OVERFLOW); + + createScDoc("xlsx/too-many-cols-rows.xlsx"); + + pDocSh = getScDocShell(); + pMedium = pDocSh->GetMedium(); + + CPPUNIT_ASSERT(pMedium->GetWarningError() == SCWARN_IMPORT_ROW_OVERFLOW + || pMedium->GetWarningError() == SCWARN_IMPORT_COLUMN_OVERFLOW); +} + void ScFiltersTest2::testTdf83671_SmartArt_import() { // The example doc contains a diagram (SmartArt). Such should be imported as group object. diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 2f773fca6e62..c81b79e8ec4e 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -348,6 +348,7 @@ class SfxMedium_Impl public: StreamMode m_nStorOpenMode; ErrCode m_eError; + ErrCode m_eWarningError; ::ucbhelper::Content aContent; bool bUpdatePickList:1; @@ -437,6 +438,7 @@ public: SfxMedium_Impl::SfxMedium_Impl() : m_nStorOpenMode(SFX_STREAM_READWRITE), m_eError(ERRCODE_NONE), + m_eWarningError(ERRCODE_NONE), bUpdatePickList(true), bIsTemp( false ), bDownloadDone( true ), @@ -487,6 +489,11 @@ void SfxMedium::ResetError() pImpl->m_pOutStream->ResetError(); } +ErrCode SfxMedium::GetWarningError() const +{ + return pImpl->m_eWarningError; +} + ErrCode const & SfxMedium::GetLastStorageCreationState() const { return pImpl->nLastStorageError; @@ -497,6 +504,11 @@ void SfxMedium::SetError(ErrCode nError) pImpl->m_eError = nError; } +void SfxMedium::SetWarningError(ErrCode nWarningError) +{ + pImpl->m_eWarningError = nWarningError; +} + ErrCode SfxMedium::GetErrorCode() const { ErrCode lError = pImpl->m_eError; diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index ebfa497aaef1..9948aadf0d37 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2802,6 +2802,8 @@ SfxMedium* SfxBaseModel::handleLoadError( ErrCode nError, SfxMedium* pMedium ) "SfxBaseModel::handleLoadError: 0x" + nError.toString(), Reference< XInterface >(), sal_uInt32(nError)); } + else + pMedium->SetWarningError(nError); return pMedium; } |