sc/qa/unit/helper/qahelper.cxx         |   21 ++++++++-------------
 sc/qa/unit/helper/qahelper.hxx         |    3 +--
 sc/qa/unit/subsequent_export_test.cxx  |    5 +++--
 sc/qa/unit/subsequent_export_test2.cxx |    4 ++--
 4 files changed, 14 insertions(+), 19 deletions(-)

New commits:
commit 8ba430f6edc2a09a3f600a8a52152cc26def14fe
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Feb 22 17:32:08 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Feb 22 21:54:48 2022 +0100

    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 <xiscofa...@libreoffice.org>

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);

Reply via email to