summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-27 16:43:51 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-28 01:12:48 -0400
commit942589b455f3a765e8d5f789afb5973f9bf0e2b8 (patch)
tree435169c75f809a67a19a6d2bc22ed68145b7063b /sc
parent47924382cb823a32ae207e3df604b9d04fe3422e (diff)
More on killing direct use of ScEditCell (and some of ScBaseCell).
Change-Id: I65d530333213f8b3db38a269e74a0beabcd1ff89
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/dociter.hxx5
-rw-r--r--sc/source/core/data/dociter.cxx23
-rw-r--r--sc/source/core/data/documen8.cxx19
-rw-r--r--sc/source/ui/docshell/docsh.cxx24
-rw-r--r--sc/source/ui/docshell/docsh8.cxx12
5 files changed, 37 insertions, 46 deletions
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 5e9b16ddd400..c38f2001fbed 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -431,6 +431,7 @@ private:
SCSIZE* pNextIndices;
SCCOL nCol;
SCROW nRow;
+ ScRefCellValue maCurCell;
bool bMore;
public:
@@ -438,7 +439,7 @@ public:
SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
~ScHorizontalCellIterator();
- ScBaseCell* GetNext( SCCOL& rCol, SCROW& rRow );
+ ScRefCellValue* GetNext( SCCOL& rCol, SCROW& rRow );
bool ReturnNext( SCCOL& rCol, SCROW& rRow );
/// Set a(nother) sheet and (re)init.
void SetTab( SCTAB nTab );
@@ -524,7 +525,7 @@ private:
SCCOL nCellCol;
SCROW nCellRow;
- ScBaseCell* pCell;
+ ScRefCellValue* pCell;
SCCOL nAttrCol1;
SCCOL nAttrCol2;
SCROW nAttrRow;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index f64837ec9d96..c318e04c79c1 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1797,7 +1797,7 @@ void ScHorizontalCellIterator::SetTab( SCTAB nTabP )
Advance();
}
-ScBaseCell* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow )
+ScRefCellValue* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow )
{
if ( bMore )
{
@@ -1820,7 +1820,8 @@ ScBaseCell* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow )
}
Advance();
- return pCell;
+ maCurCell.assign(*pCell);
+ return &maCurCell;
}
else
return NULL;
@@ -1917,7 +1918,7 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr )
bool bFound = false;
while ( !bFound )
{
- ScBaseCell* pCell = pCellIter->GetNext( nCurCol, nCurRow );
+ ScRefCellValue* pCell = pCellIter->GetNext( nCurCol, nCurRow );
while ( !pCell )
{
if ( nCurTab < nEndTab )
@@ -1930,12 +1931,12 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr )
}
if ( !bSubTotal || !pDoc->maTabs[nCurTab]->RowFiltered( nCurRow ) )
{
- switch (pCell->GetCellType())
+ switch (pCell->meType)
{
case CELLTYPE_VALUE:
{
bNumValid = false;
- rValue = ((ScValueCell*)pCell)->GetValue();
+ rValue = pCell->mfValue;
rErr = 0;
if ( bCalcAsShown )
{
@@ -1949,12 +1950,12 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr )
break;
case CELLTYPE_FORMULA:
{
- if (!bSubTotal || !((ScFormulaCell*)pCell)->IsSubTotal())
+ if (!bSubTotal || !pCell->mpFormula->IsSubTotal())
{
- rErr = ((ScFormulaCell*)pCell)->GetErrCode();
- if ( rErr || ((ScFormulaCell*)pCell)->IsValue() )
+ rErr = pCell->mpFormula->GetErrCode();
+ if (rErr || pCell->mpFormula->IsValue())
{
- rValue = ((ScFormulaCell*)pCell)->GetValue();
+ rValue = pCell->mpFormula->GetValue();
bNumValid = false;
bFound = true;
}
@@ -2161,7 +2162,7 @@ bool ScUsedAreaIterator::GetNext()
if ( pCell && IsGreater( nNextCol, nNextRow, nCellCol, nCellRow ) )
pCell = aCellIter.GetNext( nCellCol, nCellRow );
- while ( pCell && pCell->IsBlank() )
+ while (pCell && pCell->isEmpty())
pCell = aCellIter.GetNext( nCellCol, nCellRow );
if ( pPattern && IsGreater( nNextCol, nNextRow, nAttrCol2, nAttrRow ) )
@@ -2215,7 +2216,7 @@ bool ScUsedAreaIterator::GetNext()
if ( bUseCell ) // Cell position
{
if (pCell)
- maFoundCell.assign(*pCell);
+ maFoundCell = *pCell;
else
maFoundCell.clear();
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 9a6c0fb3ab2a..3dda38c104c5 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -752,7 +752,7 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
ScHorizontalCellIterator aIter( this, nTab,
rSpellRange.aStart.Col(), nRow,
rSpellRange.aEnd.Col(), rSpellRange.aEnd.Row() );
- ScBaseCell* pCell = aIter.GetNext( nCol, nRow );
+ ScRefCellValue* pCell = aIter.GetNext( nCol, nRow );
// skip everything left of rSpellPos:
while ( pCell && nRow == rSpellPos.Row() && nCol < rSpellPos.Col() )
pCell = aIter.GetNext( nCol, nRow );
@@ -763,7 +763,7 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
// Don't spell check within pivot tables.
continue;
- CellType eType = pCell->GetCellType();
+ CellType eType = pCell->meType;
if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
{
if (!pEngine)
@@ -796,11 +796,12 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
if ( eType == CELLTYPE_STRING )
{
- rtl::OUString aText = static_cast<ScStringCell*>(pCell)->GetString();
- pEngine->SetText( aText );
+ pEngine->SetText(*pCell->mpString);
}
+ else if (pCell->mpEditText)
+ pEngine->SetText(*pCell->mpEditText);
else
- pEngine->SetText( *(static_cast<ScEditCell*>(pCell)->GetData() ) );
+ pEngine->SetText(EMPTY_OUSTRING);
aStatus.bModified = false;
pEngine->CompleteOnlineSpelling();
@@ -815,12 +816,8 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
if ( bNeedEdit )
{
- if ( eType == CELLTYPE_EDIT )
- // The cell will take ownership of pNewData.
- static_cast<ScEditCell*>(pCell)->SetData(pEngine->CreateTextObject());
- else
- // The cell will take ownership of pNewData.
- SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject());
+ // The cell will take ownership of pNewData.
+ SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject());
}
else
{
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 792c1b746ea9..f33a94c3d9df 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1820,7 +1820,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
ScHorizontalCellIterator aIter( &aDocument, nTab, nStartCol, nStartRow,
nEndCol, nEndRow );
- ScBaseCell* pCell;
+ ScRefCellValue* pCell;
while ( ( pCell = aIter.GetNext( nCol, nRow ) ) != NULL )
{
bool bProgress = false; // only upon line change
@@ -1879,7 +1879,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
else
nNextCol = nCol + 1;
- CellType eType = pCell->GetCellType();
+ CellType eType = pCell->meType;
ScAddress aPos(nCol, nRow, nTab);
if ( bTabProtect )
{
@@ -1904,15 +1904,15 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
sal_uInt16 nErrCode;
if ( bShowFormulas )
{
- ((ScFormulaCell*)pCell)->GetFormula( aString );
+ pCell->mpFormula->GetFormula(aString);
bString = true;
}
- else if ( ( nErrCode = ((ScFormulaCell*)pCell)->GetErrCode() ) != 0 )
+ else if ((nErrCode = pCell->mpFormula->GetErrCode()) != 0)
{
aString = ScGlobal::GetErrorString( nErrCode );
bString = true;
}
- else if ( ((ScFormulaCell*)pCell)->IsValue() )
+ else if (pCell->mpFormula->IsValue())
{
sal_uInt32 nFormat = aDocument.GetNumberFormat(aPos);
if ( bFixedWidth || bSaveAsShown )
@@ -1923,9 +1923,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
}
else
{
- ScRefCellValue aCell;
- aCell.assign(*pCell);
- ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter);
+ ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter);
bString = false;
}
}
@@ -1938,7 +1936,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
aString = ScCellFormat::GetString(aDocument, aPos, nFormat, &pDummy, rFormatter);
}
else
- aString = ((ScFormulaCell*)pCell)->GetString();
+ aString = pCell->mpFormula->GetString();
bString = true;
}
}
@@ -1951,12 +1949,12 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
aString = ScCellFormat::GetString(aDocument, aPos, nFormat, &pDummy, rFormatter);
}
else
- aString = ((ScStringCell*)pCell)->GetString();
+ aString = *pCell->mpString;
bString = true;
break;
case CELLTYPE_EDIT :
{
- const EditTextObject* pObj = static_cast<const ScEditCell*>(pCell)->GetData();
+ const EditTextObject* pObj = pCell->mpEditText;
EditEngine& rEngine = aDocument.GetEditEngine();
rEngine.SetText( *pObj);
aString = rEngine.GetText(); // including LF
@@ -1975,9 +1973,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
}
else
{
- ScRefCellValue aCell;
- aCell.assign(*pCell);
- ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter);
+ ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter);
bString = false;
}
}
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 2170b86d9fd3..e9d5cc8d169f 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -1081,7 +1081,7 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e
const sal_Int32* pColLengths = aColLengths.getConstArray();
ScHorizontalCellIterator aIter( &aDocument, nTab, nFirstCol,
nDocRow, nLastCol, nDocRow);
- ScBaseCell* pCell = NULL;
+ ScRefCellValue* pCell = NULL;
bool bTest = true;
while (bTest && ((pCell = aIter.GetNext( nDocCol, nDocRow)) != NULL))
{
@@ -1090,14 +1090,10 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e
{
case sdbc::DataType::LONGVARCHAR:
{
- if ( pCell->GetCellType() != CELLTYPE_NOTE )
+ if (pCell->meType != CELLTYPE_NOTE)
{
- if ( pCell->GetCellType() == CELLTYPE_EDIT )
- {
- ScRefCellValue aCell;
- aCell.assign(*pCell);
- lcl_getLongVarCharEditString(aString, aCell, aEditEngine);
- }
+ if (pCell->meType == CELLTYPE_EDIT)
+ lcl_getLongVarCharEditString(aString, *pCell, aEditEngine);
else
lcl_getLongVarCharString(
aString, aDocument, nDocCol, nDocRow, nTab, *pNumFmt);