diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-02-22 17:32:08 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-02-22 21:54:48 +0100 |
commit | 8ba430f6edc2a09a3f600a8a52152cc26def14fe (patch) | |
tree | 3dcb30248c937f263f15a76a5d8557441af238f0 /sc | |
parent | d2941516a6c133bd2b67f80bc54538e474610f4e (diff) |
sc: qahelper: combine saveAs and exportTo
Change-Id: I75667249cce2a03e23bb2e0af080c935d5f15eb5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130362
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/helper/qahelper.cxx | 21 | ||||
-rw-r--r-- | sc/qa/unit/helper/qahelper.hxx | 3 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export_test.cxx | 5 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export_test2.cxx | 4 |
4 files changed, 14 insertions, 19 deletions
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 8308cdf0b982..76a6cf839c20 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -778,7 +778,7 @@ ScDocShellRef ScBootstrapFixture::saveAndReloadNoClose( ScDocShell& rShell, sal_ return xDocSh; } -std::shared_ptr<utl::TempFile> ScBootstrapFixture::saveAs( ScDocShell& rShell, sal_Int32 nFormat ) +std::shared_ptr<utl::TempFile> ScBootstrapFixture::exportTo( ScDocShell& rShell, sal_Int32 nFormat, bool bValidate ) { OUString aFilterName(aFileFormats[nFormat].pFilterName, strlen(aFileFormats[nFormat].pFilterName), RTL_TEXTENCODING_UTF8) ; OUString aFilterType(aFileFormats[nFormat].pTypeName, strlen(aFileFormats[nFormat].pTypeName), RTL_TEXTENCODING_UTF8); @@ -797,20 +797,15 @@ std::shared_ptr<utl::TempFile> ScBootstrapFixture::saveAs( ScDocShell& rShell, s pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); aStoreMedium.SetFilter(pExportFilter); rShell.DoSaveAs( aStoreMedium ); - - return pTempFile; -} - -std::shared_ptr<utl::TempFile> ScBootstrapFixture::exportTo( ScDocShell& rShell, sal_Int32 nFormat ) -{ - std::shared_ptr<utl::TempFile> pTempFile = saveAs(rShell, nFormat); rShell.DoClose(); - SfxFilterFlags nFormatType = aFileFormats[nFormat].nFormatType; - if(nFormatType == XLSX_FORMAT_TYPE) - validate(pTempFile->GetFileName(), test::OOXML); - else if (nFormatType == ODS_FORMAT_TYPE) - validate(pTempFile->GetFileName(), test::ODF); + if(bValidate) + { + if(nFormatType == XLSX_FORMAT_TYPE) + validate(pTempFile->GetFileName(), test::OOXML); + else if (nFormatType == ODS_FORMAT_TYPE) + validate(pTempFile->GetFileName(), test::ODF); + } return pTempFile; } diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx index 130875371bcb..204ec020c7a8 100644 --- a/sc/qa/unit/helper/qahelper.hxx +++ b/sc/qa/unit/helper/qahelper.hxx @@ -222,8 +222,7 @@ public: ScDocShellRef saveAndReloadPassword( ScDocShell& rShell, sal_Int32 nFormat, std::shared_ptr<utl::TempFile>* pTempFile = nullptr ); ScDocShellRef saveAndReloadNoClose( ScDocShell& rShell, sal_Int32 nFormat, std::shared_ptr<utl::TempFile>* pTempFile = nullptr ); - std::shared_ptr<utl::TempFile> saveAs(ScDocShell& rShell, sal_Int32 nFormat); - std::shared_ptr<utl::TempFile> exportTo(ScDocShell& rShell, sal_Int32 nFormat); + std::shared_ptr<utl::TempFile> exportTo(ScDocShell& rShell, sal_Int32 nFormat, bool bValidate = true); void miscRowHeightsTest( TestParam const * aTestValues, unsigned int numElems ); }; diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx index 0417edb08768..e92db37038a6 100644 --- a/sc/qa/unit/subsequent_export_test.cxx +++ b/sc/qa/unit/subsequent_export_test.cxx @@ -1134,7 +1134,8 @@ void ScExportTest::testODF13() officecfg::Office::Common::Save::ODF::DefaultVersion::set(9, pBatch); pBatch->commit(); - std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::saveAs(*pShell, FORMAT_ODS); + std::shared_ptr<utl::TempFile> pXPathFile + = exportTo(*pShell, FORMAT_ODS, /*bValidate*/ false); pShell->DoClose(); // check XML @@ -1163,7 +1164,7 @@ void ScExportTest::testODF13() officecfg::Office::Common::Save::ODF::DefaultVersion::set(4, pBatch); pBatch->commit(); - std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::saveAs(*pShell, FORMAT_ODS); + std::shared_ptr<utl::TempFile> pXPathFile = exportTo(*pShell, FORMAT_ODS); pShell->DoClose(); // check XML diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index be3382af0ce6..fa6b002f558e 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -1297,7 +1297,7 @@ void ScExportTest2::testPivotCacheAfterExportXLSX() CPPUNIT_ASSERT(xDocSh.is()); // export only - std::shared_ptr<utl::TempFile> pTemp = saveAs(*xDocSh, FORMAT_XLSX); + std::shared_ptr<utl::TempFile> pTemp = exportTo(*xDocSh, FORMAT_XLSX); ScDocument& rDoc = xDocSh->GetDocument(); CPPUNIT_ASSERT(rDoc.HasPivotTable()); @@ -1739,7 +1739,7 @@ void ScExportTest2::testRotatedImageODS() ScDocShellRef xDocSh = loadDoc(u"tdf103092_RotatedImage.", FORMAT_ODS, true); CPPUNIT_ASSERT(xDocSh.is()); - std::shared_ptr<utl::TempFile> pTemp = saveAs(*xDocSh, FORMAT_ODS); + std::shared_ptr<utl::TempFile> pTemp = exportTo(*xDocSh, FORMAT_ODS); CPPUNIT_ASSERT(pTemp); xmlDocUniquePtr pXmlDoc = XPathHelper::parseExport(pTemp, m_xSFactory, "content.xml"); CPPUNIT_ASSERT(pXmlDoc); |