sc/qa/unit/ucalc.cxx | 25 +++++++++++++++++++++++++ sc/qa/unit/ucalc.hxx | 2 ++ sc/source/core/data/column4.cxx | 4 ++++ 3 files changed, 31 insertions(+)
New commits: commit bc7e0967be52f5eb7948fbb1c30edc7dd5acc18d Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri May 16 23:06:33 2014 -0400 fdo#77735: Don't proceed when all cells in the range are empty. That means there is nothing to delete, and proceeding would cause Calc to freeze. Change-Id: I2a8fb5736870ba459082873c8f864283d8b9c664 diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx index c5465c6..4acb374 100644 --- a/sc/source/core/data/column4.cxx +++ b/sc/source/core/data/column4.cxx @@ -59,6 +59,10 @@ void ScColumn::DeleteBeforeCopyFromClip( sc::CopyFromClipContext& rCxt, const Sc sc::SingleColumnSpanSet::SpansType aSpans; aSpanSet.getSpans(aSpans); + if (aSpans.empty()) + // All cells in the range in the clip are empty. Nothing to delete. + return; + // Translate the clip column spans into the destination column, and repeat as needed. std::vector<sc::RowSpan> aDestSpans; SCROW nDestOffset = aRange.mnRow1 - nClipRow1; commit 30cc43a56d63ba9ffd588ebc589e3576483d7141 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Fri May 16 23:05:40 2014 -0400 fdo#77735: Write test for this. This test will freeze with the bug present. Change-Id: I7b7e67fe2ee59b57ce74f8303d30bebc84f6b0d0 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 14a323b..b086711 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -3706,6 +3706,31 @@ void Test::testCopyPasteSkipEmpty() m_pDoc->DeleteTab(0); } +void Test::testCopyPasteSkipEmpty2() +{ + m_pDoc->InsertTab(0, "Test"); + + m_pDoc->SetString(ScAddress(0,0,0), "A"); + m_pDoc->SetString(ScAddress(2,0,0), "C"); + + // Copy A1:C1 to clipboard. + ScDocument aClipDoc(SCDOCMODE_CLIP); + aClipDoc.ResetClip(m_pDoc, static_cast<SCTAB>(0)); + copyToClip(m_pDoc, ScRange(0,0,0,2,0,0), &aClipDoc); + + // Paste to A3 with the skip empty option set. This used to freeze. (fdo#77735) + ScRange aDestRange(0,2,0,2,2,0); + ScMarkData aMark; + aMark.SetMarkArea(aDestRange); + m_pDoc->CopyFromClip(aDestRange, aMark, IDF_ALL, NULL, &aClipDoc, false, false, true, true); + + CPPUNIT_ASSERT_EQUAL(OUString("A"), m_pDoc->GetString(ScAddress(0,2,0))); + CPPUNIT_ASSERT_MESSAGE("B3 should be empty.", m_pDoc->GetCellType(ScAddress(1,2,0)) == CELLTYPE_NONE); + CPPUNIT_ASSERT_EQUAL(OUString("C"), m_pDoc->GetString(ScAddress(2,2,0))); + + m_pDoc->DeleteTab(0); +} + void Test::testCopyPasteSkipEmptyConditionalFormatting() { m_pDoc->InsertTab(0, "Test"); diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 35d57ce..66fbfd5 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -273,6 +273,7 @@ public: void testCopyPasteTranspose(); void testCopyPasteMultiRange(); void testCopyPasteSkipEmpty(); + void testCopyPasteSkipEmpty2(); void testCopyPasteSkipEmptyConditionalFormatting(); void testCutPasteRefUndo(); void testUndoCut(); @@ -469,6 +470,7 @@ public: CPPUNIT_TEST(testCopyPasteTranspose); CPPUNIT_TEST(testCopyPasteMultiRange); CPPUNIT_TEST(testCopyPasteSkipEmpty); + CPPUNIT_TEST(testCopyPasteSkipEmpty2); //CPPUNIT_TEST(testCopyPasteSkipEmptyConditionalFormatting); CPPUNIT_TEST(testCutPasteRefUndo); CPPUNIT_TEST(testUndoCut); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits