summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-27 17:33:52 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-27 17:45:43 -0500
commitdbd8709af0545b0372c28c5ff36effba68bca580 (patch)
treeee4e81216d79bfd4ff08ed27d31c2f58ff09b60a
parent5f9c2a1f731d9e1e4708bb91b5e71bc0b4cc70e0 (diff)
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 (cherry picked from commit 21f053e2dd2867489a4d5823d9210c4368f4d115)
-rw-r--r--sc/qa/unit/ucalc.cxx41
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/source/core/data/column.cxx11
3 files changed, 50 insertions, 4 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 107825b48d66..2b04ea428304 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4096,6 +4096,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 1e2a4832bcf5..b877e02bfa3a 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();
@@ -384,6 +385,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 a8f4d913f075..921ff2528ca9 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: