Kaydet (Commit) 942589b4 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

More on killing direct use of ScEditCell (and some of ScBaseCell).

Change-Id: I65d530333213f8b3db38a269e74a0beabcd1ff89
üst 47924382
...@@ -431,6 +431,7 @@ private: ...@@ -431,6 +431,7 @@ private:
SCSIZE* pNextIndices; SCSIZE* pNextIndices;
SCCOL nCol; SCCOL nCol;
SCROW nRow; SCROW nRow;
ScRefCellValue maCurCell;
bool bMore; bool bMore;
public: public:
...@@ -438,7 +439,7 @@ public: ...@@ -438,7 +439,7 @@ public:
SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
~ScHorizontalCellIterator(); ~ScHorizontalCellIterator();
ScBaseCell* GetNext( SCCOL& rCol, SCROW& rRow ); ScRefCellValue* GetNext( SCCOL& rCol, SCROW& rRow );
bool ReturnNext( SCCOL& rCol, SCROW& rRow ); bool ReturnNext( SCCOL& rCol, SCROW& rRow );
/// Set a(nother) sheet and (re)init. /// Set a(nother) sheet and (re)init.
void SetTab( SCTAB nTab ); void SetTab( SCTAB nTab );
...@@ -524,7 +525,7 @@ private: ...@@ -524,7 +525,7 @@ private:
SCCOL nCellCol; SCCOL nCellCol;
SCROW nCellRow; SCROW nCellRow;
ScBaseCell* pCell; ScRefCellValue* pCell;
SCCOL nAttrCol1; SCCOL nAttrCol1;
SCCOL nAttrCol2; SCCOL nAttrCol2;
SCROW nAttrRow; SCROW nAttrRow;
......
...@@ -1797,7 +1797,7 @@ void ScHorizontalCellIterator::SetTab( SCTAB nTabP ) ...@@ -1797,7 +1797,7 @@ void ScHorizontalCellIterator::SetTab( SCTAB nTabP )
Advance(); Advance();
} }
ScBaseCell* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow ) ScRefCellValue* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow )
{ {
if ( bMore ) if ( bMore )
{ {
...@@ -1820,7 +1820,8 @@ ScBaseCell* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow ) ...@@ -1820,7 +1820,8 @@ ScBaseCell* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow )
} }
Advance(); Advance();
return pCell; maCurCell.assign(*pCell);
return &maCurCell;
} }
else else
return NULL; return NULL;
...@@ -1917,7 +1918,7 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr ) ...@@ -1917,7 +1918,7 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr )
bool bFound = false; bool bFound = false;
while ( !bFound ) while ( !bFound )
{ {
ScBaseCell* pCell = pCellIter->GetNext( nCurCol, nCurRow ); ScRefCellValue* pCell = pCellIter->GetNext( nCurCol, nCurRow );
while ( !pCell ) while ( !pCell )
{ {
if ( nCurTab < nEndTab ) if ( nCurTab < nEndTab )
...@@ -1930,12 +1931,12 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr ) ...@@ -1930,12 +1931,12 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr )
} }
if ( !bSubTotal || !pDoc->maTabs[nCurTab]->RowFiltered( nCurRow ) ) if ( !bSubTotal || !pDoc->maTabs[nCurTab]->RowFiltered( nCurRow ) )
{ {
switch (pCell->GetCellType()) switch (pCell->meType)
{ {
case CELLTYPE_VALUE: case CELLTYPE_VALUE:
{ {
bNumValid = false; bNumValid = false;
rValue = ((ScValueCell*)pCell)->GetValue(); rValue = pCell->mfValue;
rErr = 0; rErr = 0;
if ( bCalcAsShown ) if ( bCalcAsShown )
{ {
...@@ -1949,12 +1950,12 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr ) ...@@ -1949,12 +1950,12 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, sal_uInt16& rErr )
break; break;
case CELLTYPE_FORMULA: case CELLTYPE_FORMULA:
{ {
if (!bSubTotal || !((ScFormulaCell*)pCell)->IsSubTotal()) if (!bSubTotal || !pCell->mpFormula->IsSubTotal())
{ {
rErr = ((ScFormulaCell*)pCell)->GetErrCode(); rErr = pCell->mpFormula->GetErrCode();
if ( rErr || ((ScFormulaCell*)pCell)->IsValue() ) if (rErr || pCell->mpFormula->IsValue())
{ {
rValue = ((ScFormulaCell*)pCell)->GetValue(); rValue = pCell->mpFormula->GetValue();
bNumValid = false; bNumValid = false;
bFound = true; bFound = true;
} }
...@@ -2161,7 +2162,7 @@ bool ScUsedAreaIterator::GetNext() ...@@ -2161,7 +2162,7 @@ bool ScUsedAreaIterator::GetNext()
if ( pCell && IsGreater( nNextCol, nNextRow, nCellCol, nCellRow ) ) if ( pCell && IsGreater( nNextCol, nNextRow, nCellCol, nCellRow ) )
pCell = aCellIter.GetNext( nCellCol, nCellRow ); pCell = aCellIter.GetNext( nCellCol, nCellRow );
while ( pCell && pCell->IsBlank() ) while (pCell && pCell->isEmpty())
pCell = aCellIter.GetNext( nCellCol, nCellRow ); pCell = aCellIter.GetNext( nCellCol, nCellRow );
if ( pPattern && IsGreater( nNextCol, nNextRow, nAttrCol2, nAttrRow ) ) if ( pPattern && IsGreater( nNextCol, nNextRow, nAttrCol2, nAttrRow ) )
...@@ -2215,7 +2216,7 @@ bool ScUsedAreaIterator::GetNext() ...@@ -2215,7 +2216,7 @@ bool ScUsedAreaIterator::GetNext()
if ( bUseCell ) // Cell position if ( bUseCell ) // Cell position
{ {
if (pCell) if (pCell)
maFoundCell.assign(*pCell); maFoundCell = *pCell;
else else
maFoundCell.clear(); maFoundCell.clear();
......
...@@ -752,7 +752,7 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe ...@@ -752,7 +752,7 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
ScHorizontalCellIterator aIter( this, nTab, ScHorizontalCellIterator aIter( this, nTab,
rSpellRange.aStart.Col(), nRow, rSpellRange.aStart.Col(), nRow,
rSpellRange.aEnd.Col(), rSpellRange.aEnd.Row() ); rSpellRange.aEnd.Col(), rSpellRange.aEnd.Row() );
ScBaseCell* pCell = aIter.GetNext( nCol, nRow ); ScRefCellValue* pCell = aIter.GetNext( nCol, nRow );
// skip everything left of rSpellPos: // skip everything left of rSpellPos:
while ( pCell && nRow == rSpellPos.Row() && nCol < rSpellPos.Col() ) while ( pCell && nRow == rSpellPos.Row() && nCol < rSpellPos.Col() )
pCell = aIter.GetNext( nCol, nRow ); pCell = aIter.GetNext( nCol, nRow );
...@@ -763,7 +763,7 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe ...@@ -763,7 +763,7 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
// Don't spell check within pivot tables. // Don't spell check within pivot tables.
continue; continue;
CellType eType = pCell->GetCellType(); CellType eType = pCell->meType;
if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT ) if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
{ {
if (!pEngine) if (!pEngine)
...@@ -796,11 +796,12 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe ...@@ -796,11 +796,12 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
if ( eType == CELLTYPE_STRING ) if ( eType == CELLTYPE_STRING )
{ {
rtl::OUString aText = static_cast<ScStringCell*>(pCell)->GetString(); pEngine->SetText(*pCell->mpString);
pEngine->SetText( aText );
} }
else if (pCell->mpEditText)
pEngine->SetText(*pCell->mpEditText);
else else
pEngine->SetText( *(static_cast<ScEditCell*>(pCell)->GetData() ) ); pEngine->SetText(EMPTY_OUSTRING);
aStatus.bModified = false; aStatus.bModified = false;
pEngine->CompleteOnlineSpelling(); pEngine->CompleteOnlineSpelling();
...@@ -815,12 +816,8 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe ...@@ -815,12 +816,8 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
if ( bNeedEdit ) if ( bNeedEdit )
{ {
if ( eType == CELLTYPE_EDIT ) // The cell will take ownership of pNewData.
// The cell will take ownership of pNewData. SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject());
static_cast<ScEditCell*>(pCell)->SetData(pEngine->CreateTextObject());
else
// The cell will take ownership of pNewData.
SetEditText(ScAddress(nCol,nRow,nTab), pEngine->CreateTextObject());
} }
else else
{ {
......
...@@ -1820,7 +1820,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1820,7 +1820,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
ScHorizontalCellIterator aIter( &aDocument, nTab, nStartCol, nStartRow, ScHorizontalCellIterator aIter( &aDocument, nTab, nStartCol, nStartRow,
nEndCol, nEndRow ); nEndCol, nEndRow );
ScBaseCell* pCell; ScRefCellValue* pCell;
while ( ( pCell = aIter.GetNext( nCol, nRow ) ) != NULL ) while ( ( pCell = aIter.GetNext( nCol, nRow ) ) != NULL )
{ {
bool bProgress = false; // only upon line change bool bProgress = false; // only upon line change
...@@ -1879,7 +1879,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1879,7 +1879,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
else else
nNextCol = nCol + 1; nNextCol = nCol + 1;
CellType eType = pCell->GetCellType(); CellType eType = pCell->meType;
ScAddress aPos(nCol, nRow, nTab); ScAddress aPos(nCol, nRow, nTab);
if ( bTabProtect ) if ( bTabProtect )
{ {
...@@ -1904,15 +1904,15 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1904,15 +1904,15 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
sal_uInt16 nErrCode; sal_uInt16 nErrCode;
if ( bShowFormulas ) if ( bShowFormulas )
{ {
((ScFormulaCell*)pCell)->GetFormula( aString ); pCell->mpFormula->GetFormula(aString);
bString = true; bString = true;
} }
else if ( ( nErrCode = ((ScFormulaCell*)pCell)->GetErrCode() ) != 0 ) else if ((nErrCode = pCell->mpFormula->GetErrCode()) != 0)
{ {
aString = ScGlobal::GetErrorString( nErrCode ); aString = ScGlobal::GetErrorString( nErrCode );
bString = true; bString = true;
} }
else if ( ((ScFormulaCell*)pCell)->IsValue() ) else if (pCell->mpFormula->IsValue())
{ {
sal_uInt32 nFormat = aDocument.GetNumberFormat(aPos); sal_uInt32 nFormat = aDocument.GetNumberFormat(aPos);
if ( bFixedWidth || bSaveAsShown ) if ( bFixedWidth || bSaveAsShown )
...@@ -1923,9 +1923,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1923,9 +1923,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
} }
else else
{ {
ScRefCellValue aCell; ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter);
aCell.assign(*pCell);
ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter);
bString = false; bString = false;
} }
} }
...@@ -1938,7 +1936,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1938,7 +1936,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
aString = ScCellFormat::GetString(aDocument, aPos, nFormat, &pDummy, rFormatter); aString = ScCellFormat::GetString(aDocument, aPos, nFormat, &pDummy, rFormatter);
} }
else else
aString = ((ScFormulaCell*)pCell)->GetString(); aString = pCell->mpFormula->GetString();
bString = true; bString = true;
} }
} }
...@@ -1951,12 +1949,12 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1951,12 +1949,12 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
aString = ScCellFormat::GetString(aDocument, aPos, nFormat, &pDummy, rFormatter); aString = ScCellFormat::GetString(aDocument, aPos, nFormat, &pDummy, rFormatter);
} }
else else
aString = ((ScStringCell*)pCell)->GetString(); aString = *pCell->mpString;
bString = true; bString = true;
break; break;
case CELLTYPE_EDIT : case CELLTYPE_EDIT :
{ {
const EditTextObject* pObj = static_cast<const ScEditCell*>(pCell)->GetData(); const EditTextObject* pObj = pCell->mpEditText;
EditEngine& rEngine = aDocument.GetEditEngine(); EditEngine& rEngine = aDocument.GetEditEngine();
rEngine.SetText( *pObj); rEngine.SetText( *pObj);
aString = rEngine.GetText(); // including LF aString = rEngine.GetText(); // including LF
...@@ -1975,9 +1973,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt ...@@ -1975,9 +1973,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
} }
else else
{ {
ScRefCellValue aCell; ScCellFormat::GetInputString(*pCell, nFormat, aString, rFormatter);
aCell.assign(*pCell);
ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter);
bString = false; bString = false;
} }
} }
......
...@@ -1081,7 +1081,7 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e ...@@ -1081,7 +1081,7 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e
const sal_Int32* pColLengths = aColLengths.getConstArray(); const sal_Int32* pColLengths = aColLengths.getConstArray();
ScHorizontalCellIterator aIter( &aDocument, nTab, nFirstCol, ScHorizontalCellIterator aIter( &aDocument, nTab, nFirstCol,
nDocRow, nLastCol, nDocRow); nDocRow, nLastCol, nDocRow);
ScBaseCell* pCell = NULL; ScRefCellValue* pCell = NULL;
bool bTest = true; bool bTest = true;
while (bTest && ((pCell = aIter.GetNext( nDocCol, nDocRow)) != NULL)) while (bTest && ((pCell = aIter.GetNext( nDocCol, nDocRow)) != NULL))
{ {
...@@ -1090,14 +1090,10 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e ...@@ -1090,14 +1090,10 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e
{ {
case sdbc::DataType::LONGVARCHAR: case sdbc::DataType::LONGVARCHAR:
{ {
if ( pCell->GetCellType() != CELLTYPE_NOTE ) if (pCell->meType != CELLTYPE_NOTE)
{ {
if ( pCell->GetCellType() == CELLTYPE_EDIT ) if (pCell->meType == CELLTYPE_EDIT)
{ lcl_getLongVarCharEditString(aString, *pCell, aEditEngine);
ScRefCellValue aCell;
aCell.assign(*pCell);
lcl_getLongVarCharEditString(aString, aCell, aEditEngine);
}
else else
lcl_getLongVarCharString( lcl_getLongVarCharString(
aString, aDocument, nDocCol, nDocRow, nTab, *pNumFmt); aString, aDocument, nDocCol, nDocRow, nTab, *pNumFmt);
......
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