[Libreoffice-commits] core.git: 2 commits - sc/qa sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Fri Apr 15 12:48:18 UTC 2016
sc/qa/unit/mark_test.cxx | 43 +++++++++++++++++++++++++++++++++++++++
sc/source/core/data/markdata.cxx | 27 ++++++++++++++++--------
2 files changed, 61 insertions(+), 9 deletions(-)
New commits:
commit 4a2be39af5697356f2f4c0ae773f4b2530b2d9df
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Apr 15 13:08:49 2016 +0200
add test for tdf#72240
Change-Id: Ia27b84094e21758286422921e2bd017f9874dc06
Reviewed-on: https://gerrit.libreoffice.org/24104
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/qa/unit/mark_test.cxx b/sc/qa/unit/mark_test.cxx
index 41e0903..957d5fe 100644
--- a/sc/qa/unit/mark_test.cxx
+++ b/sc/qa/unit/mark_test.cxx
@@ -92,12 +92,21 @@ public:
void testMultiMark_FourRanges();
void testMultiMark_NegativeMarking();
+ void testInsertTabBeforeSelected();
+ void testInsertTabAfterSelected();
+ void testDeleteTabBeforeSelected();
+ void testDeleteTabAfterSelected();
+
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testSimpleMark_Simple);
CPPUNIT_TEST(testSimpleMark_Column);
CPPUNIT_TEST(testSimpleMark_Row);
CPPUNIT_TEST(testMultiMark_FourRanges);
CPPUNIT_TEST(testMultiMark_NegativeMarking);
+ CPPUNIT_TEST(testInsertTabBeforeSelected);
+ CPPUNIT_TEST(testInsertTabAfterSelected);
+ CPPUNIT_TEST(testDeleteTabBeforeSelected);
+ CPPUNIT_TEST(testDeleteTabAfterSelected);
CPPUNIT_TEST_SUITE_END();
private:
@@ -801,7 +810,41 @@ void Test::testMultiMark_NegativeMarking()
testMultiMark( aData );
}
+void Test::testInsertTabBeforeSelected()
+{
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ aMark.InsertTab(0);
+ CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
+ CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetFirstSelected());
+}
+
+void Test::testInsertTabAfterSelected()
+{
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ aMark.InsertTab(1);
+ CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
+ CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
+}
+void Test::testDeleteTabBeforeSelected()
+{
+ ScMarkData aMark;
+ aMark.SelectOneTable(1);
+ aMark.DeleteTab(0);
+ CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
+ CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
+}
+
+void Test::testDeleteTabAfterSelected()
+{
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ aMark.DeleteTab(1);
+ CPPUNIT_ASSERT_EQUAL(SCTAB(1), aMark.GetSelectCount());
+ CPPUNIT_ASSERT_EQUAL(SCTAB(0), aMark.GetFirstSelected());
+}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
commit 67abc250e5f30844797996e09e66e61c2ef214db
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Apr 15 13:07:54 2016 +0200
fix InsertTab and DeleteTab in ScMarkData, tdf#72240
Change-Id: Id3168e4cac6c52b36833b454518cce55b51e36b4
Reviewed-on: https://gerrit.libreoffice.org/24103
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index 154a693..53a5023 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -512,20 +512,29 @@ bool ScMarkData::HasAnyMultiMarks() const
void ScMarkData::InsertTab( SCTAB nTab )
{
- std::set<SCTAB> tabMarked(maTabMarked.begin(), maTabMarked.upper_bound(nTab));
- std::set<SCTAB>::iterator it = maTabMarked.upper_bound(nTab);
- for (; it != maTabMarked.end(); ++it)
- tabMarked.insert(*it + 1);
+ std::set<SCTAB> tabMarked;
+ for (auto itr = maTabMarked.begin(), itrEnd = maTabMarked.end();
+ itr != itrEnd; ++itr)
+ {
+ if (*itr < nTab)
+ tabMarked.insert(*itr);
+ else if (*itr >= nTab)
+ tabMarked.insert(*itr + 1);
+ }
maTabMarked.swap(tabMarked);
}
void ScMarkData::DeleteTab( SCTAB nTab )
{
- std::set<SCTAB> tabMarked(maTabMarked.begin(), maTabMarked.find(nTab));
- tabMarked.erase( nTab );
- std::set<SCTAB>::iterator it = maTabMarked.find(nTab);
- for (; it != maTabMarked.end(); ++it)
- tabMarked.insert(*it + 1);
+ std::set<SCTAB> tabMarked;
+ for (auto itr = maTabMarked.begin(), itrEnd = maTabMarked.end();
+ itr != itrEnd; ++itr)
+ {
+ if (*itr < nTab)
+ tabMarked.insert(*itr);
+ else if (*itr > nTab)
+ tabMarked.insert(*itr - 1);
+ }
maTabMarked.swap(tabMarked);
}
More information about the Libreoffice-commits
mailing list