[Libreoffice-commits] .: 2 commits - sc/qa
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Fri Jul 20 14:50:28 PDT 2012
sc/qa/unit/ucalc.cxx | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 142 insertions(+)
New commits:
commit d039b0070d62a54740b3f88d52debe3d5f4d664c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jul 20 23:46:00 2012 +0200
second test for ScDocument::FindAreaPos
Change-Id: I215a33d6a1e38ad3edcb92e160e90f7d04db08f1
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 6a479f0..8753a40 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -216,6 +216,7 @@ public:
void testCopyPasteFormulasExternalDoc();
void testFindAreaPosRowDown();
+ void testFindAreaPosColRight();
CPPUNIT_TEST_SUITE(Test);
#if 0
@@ -262,6 +263,7 @@ public:
CPPUNIT_TEST(testCopyPasteFormulasExternalDoc);
#endif
CPPUNIT_TEST(testFindAreaPosRowDown);
+ CPPUNIT_TEST(testFindAreaPosColRight);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4593,7 +4595,7 @@ void Test::testCopyPasteFormulasExternalDoc()
void Test::testFindAreaPosRowDown()
{
const char* aData[][2] = {
- { "", "" },
+ { "", "1" },
{ "1", "" },
{ "1", "1" },
{ "", "1" },
@@ -4660,6 +4662,71 @@ void Test::testFindAreaPosRowDown()
pDoc->DeleteTab(0);
}
+void Test::testFindAreaPosColRight()
+{
+ const char* aData[][7] = {
+ { "", "1", "1", "", "1", "1", "1" },
+ { "", "", "1", "1", "1", "", "1" }, };
+
+ ScDocument* pDoc = m_xDocShRef->GetDocument();
+ rtl::OUString aTabName1("test1");
+ pDoc->InsertTab(0, aTabName1);
+ clearRange( pDoc, ScRange(0, 0, 0, 7, SAL_N_ELEMENTS(aData), 0));
+ ScAddress aPos(0,0,0);
+ ScRange aDataRange = insertRangeData( pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
+ CPPUNIT_ASSERT_MESSAGE("failed to insert range data at correct position", aDataRange.aStart == aPos);
+
+ pDoc->SetColHidden(4,4,0,true);
+ bool bHidden = pDoc->ColHidden(4,0);
+ CPPUNIT_ASSERT(bHidden);
+
+ SCCOL nCol = 0;
+ SCROW nRow = 0;
+ pDoc->FindAreaPos(nCol, nRow, 0, 1, 0);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 1, 0);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(2), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 1, 0);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), nRow);
+ // BUG! This returns right now 4 because FindAreaPos does
+ // not yet work correctly with hidden rows
+ //CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(5), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 1, 0);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(6), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 1, 0);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(0), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(MAXCOL), nCol);
+
+ nCol = 2;
+ nRow = 1;
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 1, 0);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), nRow);
+ // BUG! This returns right now 4 because FindAreaPos does
+ // not yet work correctly with hidden rows
+ //CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(3), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 1, 0);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(6), nCol);
+
+ pDoc->DeleteTab(0);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
commit 40cfaaa73887045230f9508e8330ce267390fe6b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jul 20 22:59:10 2012 +0200
first test for ScDocument::FindAreaPos
This is the first step into fixing the cursor navigation.
ScDocument::FindAreaPos contains still bugs in the handling of hidden
rows and hidden columns. This test checks only problems with rows and
moving downwards.
Change-Id: I204064a96a1abdb8ab5f46e395f8f7c391fb4824
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 79cda88..6a479f0 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -215,7 +215,10 @@ public:
void testCopyPasteFormulas();
void testCopyPasteFormulasExternalDoc();
+ void testFindAreaPosRowDown();
+
CPPUNIT_TEST_SUITE(Test);
+#if 0
CPPUNIT_TEST(testCollator);
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testCellFunctions);
@@ -257,6 +260,8 @@ public:
CPPUNIT_TEST(testAutoFill);
CPPUNIT_TEST(testCopyPasteFormulas);
CPPUNIT_TEST(testCopyPasteFormulasExternalDoc);
+#endif
+ CPPUNIT_TEST(testFindAreaPosRowDown);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4585,6 +4590,76 @@ void Test::testCopyPasteFormulasExternalDoc()
CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$ExtSheet2.$B$2"));
}
+void Test::testFindAreaPosRowDown()
+{
+ const char* aData[][2] = {
+ { "", "" },
+ { "1", "" },
+ { "1", "1" },
+ { "", "1" },
+ { "1", "1" },
+ { "1", "" },
+ { "1", "1" }, };
+
+ ScDocument* pDoc = m_xDocShRef->GetDocument();
+ rtl::OUString aTabName1("test1");
+ pDoc->InsertTab(0, aTabName1);
+ clearRange( pDoc, ScRange(0, 0, 0, 1, SAL_N_ELEMENTS(aData), 0));
+ ScAddress aPos(0,0,0);
+ ScRange aDataRange = insertRangeData( pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
+ CPPUNIT_ASSERT_MESSAGE("failed to insert range data at correct position", aDataRange.aStart == aPos);
+
+ pDoc->SetRowHidden(4,4,0,true);
+ bool bHidden = pDoc->RowHidden(4,0);
+ CPPUNIT_ASSERT(bHidden);
+
+ SCCOL nCol = 0;
+ SCROW nRow = 0;
+ pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
+
+ // BUG! This returns right now 4 because FindAreaPos does
+ // not yet work correctly with hidden rows
+ //CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(5), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(6), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(MAXROW), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
+
+ nCol = 1;
+ nRow = 2;
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
+
+ // BUG! This returns right now 4 because FindAreaPos does
+ // not yet work correctly with hidden rows
+ //CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCol);
+
+ pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(6), nRow);
+ CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCol);
+
+ pDoc->DeleteTab(0);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
More information about the Libreoffice-commits
mailing list