[Libreoffice-commits] .: sc/qa

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 4 16:12:47 PST 2012


 sc/qa/unit/subsequent_export-test.cxx |   57 +++++++++-------------------------
 1 file changed, 16 insertions(+), 41 deletions(-)

New commits:
commit 75e4c6fc621e57734a1dddaccc7e3cbe3ba03d8e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Dec 4 19:12:27 2012 -0500

    Remove duplicate code blocks.
    
    Change-Id: If44f44ad076313ab67968fd70f244d781356028d

diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index c7930b4..7fcbd67 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -90,6 +90,10 @@ private:
     rtl::OUString m_aBaseString;
     uno::Reference<uno::XInterface> m_xCalcComponent;
 
+    ScDocShellRef load(
+        const OUString& rURL, const OUString& rFilter, const OUString &rUserData,
+        const OUString& rTypeName, sal_Int32 nFormat, sal_uLong nFormatType );
+
     ScDocShellRef saveAndReload( ScDocShell* pShell, sal_Int32 nFormat );
     ScDocShellRef loadDocument( const rtl::OUString& rFileNameBase, sal_Int32 nFormat );
     void createFileURL( const rtl::OUString& aFileBase, const rtl::OUString& rFileExtension, rtl::OUString& rFilePath);
@@ -146,27 +150,8 @@ ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const rtl:
     sal_uInt32 nFormat = 0;
     if (nFormatType)
         nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
-    SfxFilter* pFilter = new SfxFilter(
-        rFilter,
-        rtl::OUString(), nFormatType, nFormat, rTypeName, 0, rtl::OUString(),
-        rUserData, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) );
-    pFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
 
-    ScDocShellRef xDocShRef = new ScDocShell;
-    xDocShRef->GetDocument()->EnableUserInteraction(false);
-    SfxMedium* pSrcMed = new SfxMedium(aTempFile.GetURL(), STREAM_STD_READ);
-    pSrcMed->UseInteractionHandler(false);
-    SfxItemSet* pSet = pSrcMed->GetItemSet();
-    pSet->Put(SfxStringItem(SID_PASSWORD, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test"))));
-    pSrcMed->SetFilter(pFilter);
-    if (!xDocShRef->DoLoad(pSrcMed))
-    {
-        xDocShRef->DoClose();
-        // load failed.
-        xDocShRef.Clear();
-    }
-
-    return xDocShRef;
+    return load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, nFormat, nFormatType);
 }
 
 ScDocShellRef ScExportTest::saveAndReload(ScDocShell* pShell, const rtl::OUString &rFilter,
@@ -193,15 +178,23 @@ ScDocShellRef ScExportTest::saveAndReload(ScDocShell* pShell, const rtl::OUStrin
     sal_uInt32 nFormat = 0;
     if (nFormatType)
         nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
+
+    return load(aTempFile.GetURL(), rFilter, rUserData, rTypeName, nFormat, nFormatType);
+}
+
+ScDocShellRef ScExportTest::load(
+    const OUString& rURL, const OUString& rFilter, const OUString &rUserData,
+    const OUString& rTypeName, sal_Int32 nFormat, sal_uLong nFormatType )
+{
     SfxFilter* pFilter = new SfxFilter(
         rFilter,
         rtl::OUString(), nFormatType, nFormat, rTypeName, 0, rtl::OUString(),
-        rUserData, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) );
+        rUserData, OUString("private:factory/scalc*"));
     pFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
 
     ScDocShellRef xDocShRef = new ScDocShell;
     xDocShRef->GetDocument()->EnableUserInteraction(false);
-    SfxMedium* pSrcMed = new SfxMedium(aTempFile.GetURL(), STREAM_STD_READ);
+    SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
     pSrcMed->SetFilter(pFilter);
     pSrcMed->UseInteractionHandler(false);
     if (!xDocShRef->DoLoad(pSrcMed))
@@ -235,25 +228,7 @@ ScDocShellRef ScExportTest::loadDocument(const rtl::OUString& rFileName, sal_Int
     unsigned int nFormatType = aFileFormats[nFormat].nFormatType;
     unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
 
-    SfxFilter* pFilter = new SfxFilter(
-        aFilterName,
-        rtl::OUString(), nFormatType, nClipboardId, aFilterType, 0, rtl::OUString(),
-        rtl::OUString(), rtl::OUString("private:factory/scalc*") );
-    pFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
-
-    ScDocShellRef xDocShRef = new ScDocShell;
-    xDocShRef->GetDocument()->EnableUserInteraction(false);
-    SfxMedium* pSrcMed = new SfxMedium(aFileName, STREAM_STD_READ);
-    pSrcMed->SetFilter(pFilter);
-    pSrcMed->UseInteractionHandler(false);
-    if (!xDocShRef->DoLoad(pSrcMed))
-    {
-        xDocShRef->DoClose();
-        // load failed.
-        xDocShRef.Clear();
-    }
-
-    return xDocShRef;
+    return load(aFileName, aFilterName, OUString(), aFilterType, nClipboardId, nFormatType);
 }
 
 void ScExportTest::test()


More information about the Libreoffice-commits mailing list