diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-01 15:36:40 -0400 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-08-02 13:22:54 +0000 |
commit | be4c731bd680cf531633890b913302dacd5e01b8 (patch) | |
tree | 368da1b256ace18db272ef7f00d3387df39f6850 | |
parent | e0df4fa62162b023b29a323ed4c70594a8ec47c4 (diff) |
fdo#67489: Don't stop range search even when the first cell is empty.
Because we aren't supposed to. Think of those formula cells that follow
the empty one.
Change-Id: I2cd04833d5e6c561e9ab6d83a984dbdceefa2e71
Reviewed-on: https://gerrit.libreoffice.org/5233
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 36 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 3 |
2 files changed, 37 insertions, 2 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 93d8dd56c240..0bda2a4d9707 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -218,6 +218,7 @@ public: void testDataArea(); void testAutofilter(); void testCopyPaste(); + void testCopyPasteRelativeFormula(); void testMergedCells(); void testUpdateReference(); @@ -322,6 +323,7 @@ public: CPPUNIT_TEST(testToggleRefFlag); CPPUNIT_TEST(testAutofilter); CPPUNIT_TEST(testCopyPaste); + CPPUNIT_TEST(testCopyPasteRelativeFormula); CPPUNIT_TEST(testMergedCells); CPPUNIT_TEST(testUpdateReference); CPPUNIT_TEST(testJumpToPrecedentsDependents); @@ -5964,6 +5966,40 @@ void Test::testCopyPaste() m_pDoc->DeleteTab(0); } +void Test::testCopyPasteRelativeFormula() +{ + m_pDoc->InsertTab(0, "Formula"); + + AutoCalcSwitch aACSwitch(m_pDoc, true); + + // Insert values to A2 and A4. + m_pDoc->SetValue(ScAddress(0,1,0), 1); + m_pDoc->SetValue(ScAddress(0,3,0), 2); + + // Insert formula to B4. + m_pDoc->SetString(ScAddress(1,3,0), "=A4"); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,3,0))); + + // Select and copy B3:B4 to the clipboard. + ScRange aRange(1,2,0,1,3,0); + ScClipParam aClipParam(aRange, false); + ScMarkData aMark; + aMark.SetMarkArea(aRange); + ScDocument aClipDoc(SCDOCMODE_CLIP); + m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark); + + // Paste it to B1:B2. + sal_uInt16 nFlags = IDF_ALL; + ScRange aDestRange(1,0,0,1,1,0); + aMark.SetMarkArea(aDestRange); + m_pDoc->CopyFromClip(aDestRange, aMark, nFlags, NULL, &aClipDoc); + + // B2 references A2, so the value should be 1. + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(1,1,0))); + + m_pDoc->DeleteTab(0); +} + void Test::testMergedCells() { //test merge and unmerge diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 4c688ef4e419..2a242207ede1 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -1150,8 +1150,7 @@ void ScColumn::BroadcastInArea( SCROW nRow1, SCROW nRow2 ) SCROW nRow; SCSIZE nIndex; - if (!Search(nRow1, nIndex)) - return; + Search(nRow1, nIndex); while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRow2 ) { |