Kaydet (Commit) 21f053e2 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst 2e359fbb
......@@ -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");
......
......@@ -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);
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment