[Libreoffice-commits] core.git: sc/qa sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Dec 27 14:43:47 PST 2013
sc/qa/unit/ucalc.cxx | 41 +++++++++++++++++++++++++++++++++++++++++
sc/qa/unit/ucalc.hxx | 2 ++
sc/source/core/data/column.cxx | 11 +++++++----
3 files changed, 50 insertions(+), 4 deletions(-)
New commits:
commit 21f053e2dd2867489a4d5823d9210c4368f4d115
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Dec 27 17:33:52 2013 -0500
fdo#72874: Strip const-ness from pointer value when setting it to storage.
Else the pointer type would get demoted to a boolean type which would cause
the boolean version of overloaded function to get picked.
Change-Id: Ided7e8c67ef84b4323c8ad1123e0a2c30ce37e01
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 2f7e52c..17c4123 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4106,6 +4106,47 @@ void Test::testSortWithFormulaRefs()
pDoc->DeleteTab(1);
}
+void Test::testSortWithStrings()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ ScFieldEditEngine& rEE = m_pDoc->GetEditEngine();
+ rEE.SetText("Val1");
+ m_pDoc->SetString(ScAddress(1,1,0), "Header");
+ m_pDoc->SetString(ScAddress(1,2,0), "Val2");
+ m_pDoc->SetEditText(ScAddress(1,3,0), rEE.CreateTextObject());
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Header"), m_pDoc->GetString(ScAddress(1,1,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Val2"), m_pDoc->GetString(ScAddress(1,2,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Val1"), m_pDoc->GetString(ScAddress(1,3,0)));
+
+ ScSortParam aParam;
+ aParam.nCol1 = 1;
+ aParam.nCol2 = 1;
+ aParam.nRow1 = 1;
+ aParam.nRow2 = 3;
+ aParam.bHasHeader = true;
+ aParam.maKeyState[0].bDoSort = true;
+ aParam.maKeyState[0].bAscending = true;
+ aParam.maKeyState[0].nField = 1;
+
+ m_pDoc->Sort(0, aParam, false, NULL);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Header"), m_pDoc->GetString(ScAddress(1,1,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Val1"), m_pDoc->GetString(ScAddress(1,2,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Val2"), m_pDoc->GetString(ScAddress(1,3,0)));
+
+ aParam.maKeyState[0].bAscending = false;
+
+ m_pDoc->Sort(0, aParam, false, NULL);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Header"), m_pDoc->GetString(ScAddress(1,1,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Val2"), m_pDoc->GetString(ScAddress(1,2,0)));
+ CPPUNIT_ASSERT_EQUAL(OUString("Val1"), m_pDoc->GetString(ScAddress(1,3,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testSort()
{
OUString aTabName1("test1");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 2af0e65..771a044 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -275,6 +275,7 @@ public:
void testFindAreaPosColRight();
void testSort();
void testSortWithFormulaRefs();
+ void testSortWithStrings();
void testShiftCells();
void testNoteDeleteRow();
void testNoteDeleteCol();
@@ -385,6 +386,7 @@ public:
CPPUNIT_TEST(testFindAreaPosColRight);
CPPUNIT_TEST(testSort);
CPPUNIT_TEST(testSortWithFormulaRefs);
+ CPPUNIT_TEST(testSortWithStrings);
CPPUNIT_TEST(testShiftCells);
CPPUNIT_TEST(testNoteDeleteRow);
CPPUNIT_TEST(testNoteDeleteCol);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index a8f4d91..921ff25 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -916,7 +916,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
break;
case CELLTYPE_EDIT:
{
- it1 = maCells.set(it1, nRow1, aCell2.mpEditText);
+ it1 = maCells.set(
+ it1, nRow1, const_cast<EditTextObject*>(aCell2.mpEditText));
EditTextObject* p;
maCells.release(it1, nRow2, p);
}
@@ -999,7 +1000,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
break;
case CELLTYPE_EDIT:
{
- it1 = maCells.set(it1, nRow1, aCell2.mpEditText);
+ it1 = maCells.set(
+ it1, nRow1, const_cast<EditTextObject*>(aCell2.mpEditText));
EditTextObject* p;
it1 = maCells.release(it1, nRow2, p);
}
@@ -1031,7 +1033,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
break;
case CELLTYPE_EDIT:
{
- it1 = maCells.set(it1, nRow1, aCell2.mpEditText);
+ it1 = maCells.set(
+ it1, nRow1, const_cast<EditTextObject*>(aCell2.mpEditText));
EditTextObject* p;
it1 = maCells.release(it1, nRow2, p); // prevent it being overwritten.
}
@@ -1079,7 +1082,7 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
;
}
- maCells.set(it1, nRow2, aCell1.mpEditText);
+ maCells.set(it1, nRow2, const_cast<EditTextObject*>(aCell1.mpEditText));
}
break;
case CELLTYPE_FORMULA:
More information about the Libreoffice-commits
mailing list