[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sc/qa sc/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Sat Nov 23 05:41:35 UTC 2019


 sc/qa/unit/bugfix-test.cxx       |   28 ++++++++++++++++++++++++++++
 sc/source/ui/unoobj/cellsuno.cxx |    9 ++++++++-
 sc/source/ui/unoobj/servuno.cxx  |    3 ++-
 3 files changed, 38 insertions(+), 2 deletions(-)

New commits:
commit 7eac47252e03bd7072f62cc1a23d441171619d57
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Nov 22 13:53:46 2019 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Nov 23 06:40:51 2019 +0100

    tdf#128951: restore passing nullptr to ScTableSheetObj when not inserted yet
    
    This partially reverts 009e7a54f40ebacd9dd4a394504c277789699801
    
    Change-Id: I5a9605ff9d0ff1cd825968fb247b2a3bf4b2902a
    Reviewed-on: https://gerrit.libreoffice.org/83464
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 2a16decdcccf36f9fa4a1764f68e59c33517b892)
    Reviewed-on: https://gerrit.libreoffice.org/83516

diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx
index 994dbe2ad2e9..a23ba743d829 100644
--- a/sc/qa/unit/bugfix-test.cxx
+++ b/sc/qa/unit/bugfix-test.cxx
@@ -38,6 +38,7 @@ public:
     void testRhbz1390776();
     void testTdf104310();
     void testTdf31231();
+    void testTdf128951();
 
     CPPUNIT_TEST_SUITE(ScFiltersTest);
     CPPUNIT_TEST(testTdf64229);
@@ -53,6 +54,7 @@ public:
     CPPUNIT_TEST(testRhbz1390776);
     CPPUNIT_TEST(testTdf104310);
     CPPUNIT_TEST(testTdf31231);
+    CPPUNIT_TEST(testTdf128951);
     CPPUNIT_TEST_SUITE_END();
 private:
     uno::Reference<uno::XInterface> m_xCalcComponent;
@@ -297,6 +299,32 @@ void ScFiltersTest::testTdf31231()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testTdf128951()
+{
+    css::uno::Reference<css::frame::XDesktop2> xDesktop
+        = css::frame::Desktop::create(::comphelper::getProcessComponentContext());
+    CPPUNIT_ASSERT(xDesktop.is());
+
+    // 1. Create spreadsheet
+    css::uno::Sequence<css::beans::PropertyValue> aHiddenArgList(1);
+    aHiddenArgList[0].Name = "Hidden";
+    aHiddenArgList[0].Value <<= true;
+
+    css::uno::Reference<css::lang::XComponent> xComponent
+        = xDesktop->loadComponentFromURL("private:factory/scalc", "_blank", 0, aHiddenArgList);
+    CPPUNIT_ASSERT(xComponent.is());
+
+    // 2. Create a new sheet instance
+    css::uno::Reference<css::lang::XMultiServiceFactory> xFac(xComponent,
+                                                              css::uno::UNO_QUERY_THROW);
+    auto xSheet = xFac->createInstance("com.sun.star.sheet.Spreadsheet");
+
+    // 3. Insert sheet into the spreadsheet (was throwing IllegalArgumentException)
+    css::uno::Reference<css::sheet::XSpreadsheetDocument> xDoc(xComponent,
+                                                               css::uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_NO_THROW(xDoc->getSheets()->insertByName("mustNotThrow", css::uno::Any(xSheet)));
+}
+
 ScFiltersTest::ScFiltersTest()
       : ScBootstrapFixture( "sc/qa/unit/data" )
 {
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 34aba2fd2769..0f3bf54e3765 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6564,8 +6564,15 @@ sal_Int16 SAL_CALL ScCellObj::resetActionLocks()
     return nRet;
 }
 
+static ScRange MaxDocRange(ScDocShell* pDocSh, SCTAB nTab)
+{
+    const SCCOL nMaxcol = pDocSh ? pDocSh->GetDocument().MaxCol() : MAXCOL;
+    const SCROW nMaxRow = pDocSh ? pDocSh->GetDocument().MaxRow() : MAXROW;
+    return ScRange(0, 0, nTab, nMaxcol, nMaxRow, nTab);
+}
+
 ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
-    ScCellRangeObj( pDocSh, ScRange(0,0,nTab, pDocSh->GetDocument().MaxCol(), pDocSh->GetDocument().MaxRow(),nTab) ),
+    ScCellRangeObj( pDocSh, MaxDocRange(pDocSh, nTab) ),
     pSheetPropSet(lcl_GetSheetPropertySet())
 {
 }
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 23c7c4b93d27..e778247eaa4f 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -401,7 +401,8 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
     switch (nType)
     {
         case Type::SHEET:
-            xRet.set(static_cast<sheet::XSpreadsheet*>(new ScTableSheetObj(pDocShell,0)));
+            //  not inserted yet - DocShell=Null
+            xRet.set(static_cast<sheet::XSpreadsheet*>(new ScTableSheetObj(nullptr,0)));
             break;
         case Type::URLFIELD:
         case Type::PAGEFIELD:


More information about the Libreoffice-commits mailing list