[Libreoffice-commits] core.git: include/test test/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Mar 27 06:40:35 UTC 2019


 include/test/sheet/xspreadsheets2.hxx |    2 +-
 test/source/sheet/xspreadsheets2.cxx  |   29 ++++++++++-------------------
 2 files changed, 11 insertions(+), 20 deletions(-)

New commits:
commit 705558aa455403cd006993f95b5b13981fdb3483
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Mar 26 15:54:47 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Mar 27 07:40:12 2019 +0100

    condition always true in XSpreadsheets2::importSheetToCopy
    
    leftover from
        commit ed45c87896de74048708d51c050ecd42c9f4a0a0
        Date:   Mon Oct 20 21:08:54 2014 +0200
        sc: fix temp file leak in ScTableSheetsObj
    
    Change-Id: Ic108fb36cc0caccbe57f2b47f7fcbe80156842dc
    Reviewed-on: https://gerrit.libreoffice.org/69749
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/test/sheet/xspreadsheets2.hxx b/include/test/sheet/xspreadsheets2.hxx
index e3928d349efb..1340b80be216 100644
--- a/include/test/sheet/xspreadsheets2.hxx
+++ b/include/test/sheet/xspreadsheets2.hxx
@@ -46,7 +46,7 @@ protected:
     css::uno::Reference< css::sheet::XSpreadsheetDocument> xDocument;
 
 private:
-    css::uno::Reference< css::sheet::XSpreadsheetDocument> getDoc(const OUString&, css::uno::Reference< css::lang::XComponent >&);
+    css::uno::Reference< css::sheet::XSpreadsheetDocument> getDoc(const OUString&);
     static css::uno::Reference< css::sheet::XNamedRanges> getNamedRanges(css::uno::Reference< css::sheet::XSpreadsheetDocument > const &);
     void importSheetToCopy();
     static bool isExternalReference(const OUString& aDestContent, const OUString& aSrcContent );
diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx
index cea68e1cfad9..ab3ef3e75688 100644
--- a/test/source/sheet/xspreadsheets2.cxx
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -275,13 +275,12 @@ void XSpreadsheets2::testImportCellStyle()
     CPPUNIT_ASSERT_EQUAL_MESSAGE("New style: VertJustify not set", table::CellVertJustify_CENTER, static_cast<table::CellVertJustify>(aVertJustify));
 }
 
-uno::Reference< sheet::XSpreadsheetDocument> XSpreadsheets2::getDoc(const OUString& aFileBase, uno::Reference< lang::XComponent >& xComp)
+uno::Reference< sheet::XSpreadsheetDocument> XSpreadsheets2::getDoc(const OUString& aFileBase)
 {
     OUString aFileURL;
     createFileURL(aFileBase, aFileURL);
 
-    if (!xComp.is())
-        xComp = loadFromDesktop(aFileURL);
+    uno::Reference< lang::XComponent > xComp = loadFromDesktop(aFileURL);
 
     CPPUNIT_ASSERT(xComp.is());
 
@@ -301,22 +300,14 @@ void XSpreadsheets2::importSheetToCopy()
     uno::Reference< container::XNameAccess> xSrcNameAccess(init(),UNO_QUERY_THROW);
     xSrcSheet.set( xSrcNameAccess->getByName(gaSrcSheetName), UNO_QUERY_THROW);
 
-    uno::Reference< lang::XComponent > xDestComponent;
-    if (!xDestComponent.is())
-    {
-        xDestDoc = getDoc(gaDestFileBase, xDestComponent);
-        CPPUNIT_ASSERT(xDestDoc.is());
-
-        // import sheet
-        uno::Reference< sheet::XSpreadsheets2 > xDestSheets (xDestDoc->getSheets(), UNO_QUERY_THROW);
-        sal_Int32 nDestPos = 0;
-        sal_Int32 nDestPosEffective = xDestSheets->importSheet(xDocument, gaSrcSheetName, nDestPos);
-        CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet index", nDestPosEffective, nDestPos);
-    }
-    else
-    {
-        xDestDoc.set(xDestComponent,UNO_QUERY_THROW);
-    }
+    xDestDoc = getDoc(gaDestFileBase);
+    CPPUNIT_ASSERT(xDestDoc.is());
+
+    // import sheet
+    uno::Reference< sheet::XSpreadsheets2 > xDestSheets (xDestDoc->getSheets(), UNO_QUERY_THROW);
+    sal_Int32 nDestPos = 0;
+    sal_Int32 nDestPosEffective = xDestSheets->importSheet(xDocument, gaSrcSheetName, nDestPos);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong sheet index", nDestPosEffective, nDestPos);
 
     uno::Reference< container::XNameAccess > xDestSheetNameAccess (xDestDoc->getSheets(), UNO_QUERY_THROW);
     xDestSheet.set( xDestSheetNameAccess->getByName(gaSrcSheetName), UNO_QUERY_THROW);


More information about the Libreoffice-commits mailing list