summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-11-22 13:53:46 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-11-22 17:04:24 +0100
commit2a16decdcccf36f9fa4a1764f68e59c33517b892 (patch)
treed014921671c5f90295f419b0512ad0ec9ffa3846
parent017c6150e94a3a621f6f3e789fe72cac90a7bf11 (diff)
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@collabora.com>
-rw-r--r--sc/qa/unit/bugfix-test.cxx28
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx9
-rw-r--r--sc/source/ui/unoobj/servuno.cxx3
3 files changed, 38 insertions, 2 deletions
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 8696bda0a8ff..d8a12d386390 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6568,8 +6568,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 ac0409d1cf15..b0173e1904f6 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: