summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-01-07 19:09:24 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-01-07 19:11:34 -0500
commitd831f352ba4969f4e5ed0d1057a773d5a472d4aa (patch)
treedae9c1bf0c2d68aeeb5e205814f11755f503d640 /sc
parent834f7c51ea1a51c6022da25fad9d0389682c5d52 (diff)
More unit test code for drawing objects. Found another bug & fixed it.
Inserting a new sheet would not update the anchored sheet index. Fixed.
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx17
-rw-r--r--sc/source/core/data/drwlayer.cxx3
2 files changed, 19 insertions, 1 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1adc2bf0eb27..c9c6b4bd28f4 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -48,6 +48,7 @@
#include "attrib.hxx"
#include "dbdata.hxx"
#include "reftokenhelper.hxx"
+#include "userdat.hxx"
#include "docsh.hxx"
#include "docfunc.hxx"
@@ -2526,6 +2527,10 @@ void Test::testGraphicsOnSheetMove()
CPPUNIT_ASSERT_MESSAGE("There should be one object on the 1st sheet.", pPage->GetObjCount() == 1);
+ const ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj);
+ CPPUNIT_ASSERT_MESSAGE("Object meta-data doesn't exist.", pData);
+ CPPUNIT_ASSERT_MESSAGE("Wrong sheet ID in cell anchor data!", pData->maStart.Tab() == 0 && pData->maEnd.Tab() == 0);
+
pPage = pDrawLayer->GetPage(1);
CPPUNIT_ASSERT_MESSAGE("No page instance for the 2nd sheet.", pPage);
CPPUNIT_ASSERT_MESSAGE("2nd sheet shouldn't have any object.", pPage->GetObjCount() == 0);
@@ -2541,6 +2546,8 @@ void Test::testGraphicsOnSheetMove()
pPage = pDrawLayer->GetPage(2);
CPPUNIT_ASSERT_MESSAGE("3rd sheet should have no object.", pPage && pPage->GetObjCount() == 0);
+ CPPUNIT_ASSERT_MESSAGE("Wrong sheet ID in cell anchor data!", pData->maStart.Tab() == 1 && pData->maEnd.Tab() == 1);
+
// Now, delete the sheet that just got inserted. The object should be back
// on the 1st sheet.
m_pDoc->DeleteTab(0);
@@ -2549,6 +2556,16 @@ void Test::testGraphicsOnSheetMove()
CPPUNIT_ASSERT_MESSAGE("Size and position of the object shouldn't change.",
pObj->GetLogicRect() == aObjRect);
+ CPPUNIT_ASSERT_MESSAGE("Wrong sheet ID in cell anchor data!", pData->maStart.Tab() == 0 && pData->maEnd.Tab() == 0);
+
+ // Move the 1st sheet to the last position.
+ m_pDoc->MoveTab(0, 1);
+ pPage = pDrawLayer->GetPage(0);
+ CPPUNIT_ASSERT_MESSAGE("1st sheet should have no object.", pPage && pPage->GetObjCount() == 0);
+ pPage = pDrawLayer->GetPage(1);
+ CPPUNIT_ASSERT_MESSAGE("2nd sheet should have one object.", pPage && pPage->GetObjCount() == 1);
+ CPPUNIT_ASSERT_MESSAGE("Wrong sheet ID in cell anchor data!", pData->maStart.Tab() == 1 && pData->maEnd.Tab() == 1);
+
m_pDoc->DeleteTab(1);
m_pDoc->DeleteTab(0);
}
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 69f289aa0465..087d5102a3e5 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -390,7 +390,8 @@ sal_Bool ScDrawLayer::ScAddPage( SCTAB nTab )
if (bRecording)
AddCalcUndo(new SdrUndoNewPage(*pPage));
- return sal_True; // inserted
+ ResetTab(nTab, pDoc->GetTableCount()-1);
+ return true; // inserted
}
void ScDrawLayer::ScRemovePage( SCTAB nTab )