Kaydet (Commit) 1ed3387a authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Made similar change to SetData() of ScEditCell.

Change-Id: Ie1475eb19a4ad41e5eac1ca00419a1af5c207b12
üst 0585322e
...@@ -262,8 +262,32 @@ public: ...@@ -262,8 +262,32 @@ public:
// for line breaks // for line breaks
ScEditCell( const rtl::OUString& rString, ScDocument* ); ScEditCell( const rtl::OUString& rString, ScDocument* );
void SetData( const EditTextObject* pObject, /**
const SfxItemPool* pFromPool /* = NULL */ ); * Remove the text data as well as string cache.
*/
void ClearData();
/**
* Set new text data. This method clones the passed text data and stores
* the clone; the caller is responsible for deleting the text data
* instance after the call.
*
* @param rObject text object to clone from.
* @param pFromPool pointer to SfxItemPool instance that the new text
* object that is to be stored in the cell instance
* should use. If it's NULL, it uses the default pool
* for edit cells from the document instance (one
* returned from GetEditPool()).
*/
void SetData(const EditTextObject& rObject, const SfxItemPool* pFromPool);
/**
* Set new text data. The passed text data instance will be owned by the
* cell. The caller must ensure that the text data uses the SfxItemPool
* instance returned from ScDocument::GetEditPool().
*/
void SetData(EditTextObject* pObject);
rtl::OUString GetString() const; rtl::OUString GetString() const;
const EditTextObject* GetData() const; const EditTextObject* GetData() const;
......
...@@ -96,16 +96,24 @@ ScEditCell::~ScEditCell() ...@@ -96,16 +96,24 @@ ScEditCell::~ScEditCell()
#endif #endif
} }
void ScEditCell::SetData( const EditTextObject* pObject, void ScEditCell::ClearData()
const SfxItemPool* pFromPool )
{ {
if ( pString ) delete pString;
{ pString = NULL;
delete pString;
pString = NULL;
}
delete pData; delete pData;
SetTextObject( pObject, pFromPool ); pData = NULL;
}
void ScEditCell::SetData(const EditTextObject& rObject, const SfxItemPool* pFromPool)
{
ClearData();
SetTextObject(&rObject, pFromPool);
}
void ScEditCell::SetData(EditTextObject* pObject)
{
ClearData();
pData = pObject;
} }
rtl::OUString ScEditCell::GetString() const rtl::OUString ScEditCell::GetString() const
......
...@@ -908,9 +908,7 @@ void ScColumn::RemoveAutoSpellObj() ...@@ -908,9 +908,7 @@ void ScColumn::RemoveAutoSpellObj()
ScEditAttrTester aTester( pEngine ); ScEditAttrTester aTester( pEngine );
if ( aTester.NeedsObject() ) // only remove spelling errors if ( aTester.NeedsObject() ) // only remove spelling errors
{ {
EditTextObject* pNewData = pEngine->CreateTextObject(); // without BIGOBJ pOldCell->SetData(pEngine->CreateTextObject());
pOldCell->SetData( pNewData, pEngine->GetEditTextObjectPool() );
delete pNewData;
} }
else // create a string else // create a string
{ {
...@@ -975,9 +973,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) ...@@ -975,9 +973,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow )
sal_uInt32 nWantBig = bSpellErrors ? EE_CNTRL_ALLOWBIGOBJS : 0; sal_uInt32 nWantBig = bSpellErrors ? EE_CNTRL_ALLOWBIGOBJS : 0;
if ( ( nCtrl & EE_CNTRL_ALLOWBIGOBJS ) != nWantBig ) if ( ( nCtrl & EE_CNTRL_ALLOWBIGOBJS ) != nWantBig )
pEngine->SetControlWord( (nCtrl & ~EE_CNTRL_ALLOWBIGOBJS) | nWantBig ); pEngine->SetControlWord( (nCtrl & ~EE_CNTRL_ALLOWBIGOBJS) | nWantBig );
EditTextObject* pNewData = pEngine->CreateTextObject(); pOldCell->SetData(pEngine->CreateTextObject());
pOldCell->SetData( pNewData, pEngine->GetEditTextObjectPool() );
delete pNewData;
} }
else // create String else // create String
{ {
......
...@@ -741,15 +741,12 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe ...@@ -741,15 +741,12 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
if ( bNeedEdit ) if ( bNeedEdit )
{ {
SAL_WNODEPRECATED_DECLARATIONS_PUSH
std::auto_ptr<EditTextObject> pNewData(pEngine->CreateTextObject());
SAL_WNODEPRECATED_DECLARATIONS_POP
if ( eType == CELLTYPE_EDIT ) if ( eType == CELLTYPE_EDIT )
// SetData will create a clone of pNewData and stores the clone. // The cell will take ownership of pNewData.
static_cast<ScEditCell*>(pCell)->SetData(pNewData.get(), pEngine->GetEditTextObjectPool()); static_cast<ScEditCell*>(pCell)->SetData(pEngine->CreateTextObject());
else else
// The cell will take ownership of pNewData. // The cell will take ownership of pNewData.
PutCell(nCol, nRow, nTab, new ScEditCell(pNewData.release(), this)); PutCell(nCol, nRow, nTab, new ScEditCell(pEngine->CreateTextObject(), this));
} }
else // einfacher String else // einfacher String
PutCell( nCol, nRow, nTab, new ScStringCell( pEngine->GetText() ) ); PutCell( nCol, nRow, nTab, new ScStringCell( pEngine->GetText() ) );
......
...@@ -444,9 +444,19 @@ void ScUndoSelectionAttr::ChangeEditData( const bool bUndo ) ...@@ -444,9 +444,19 @@ void ScUndoSelectionAttr::ChangeEditData( const bool bUndo )
ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell); ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
if (bUndo) if (bUndo)
pEditCell->SetData(pItem->GetOldData(), NULL); {
if (pItem->GetOldData())
pEditCell->SetData(*pItem->GetOldData(), NULL);
else
pEditCell->ClearData();
}
else else
pEditCell->SetData(pItem->GetNewData(), NULL); {
if (pItem->GetNewData())
pEditCell->SetData(*pItem->GetNewData(), NULL);
else
pEditCell->ClearData();
}
} }
} }
......
...@@ -103,8 +103,8 @@ void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const share ...@@ -103,8 +103,8 @@ void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const share
ScBaseCell* pCell; ScBaseCell* pCell;
pDoc->GetCell(nCol, nRow, nTab, pCell); pDoc->GetCell(nCol, nRow, nTab, pCell);
if (pCell && pCell->GetCellType() == CELLTYPE_EDIT && pEditData.get()) if (pCell && pCell->GetCellType() == CELLTYPE_EDIT && pEditData)
static_cast<ScEditCell*>(pCell)->SetData(pEditData.get(), NULL); static_cast<ScEditCell*>(pCell)->SetData(*pEditData, NULL);
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
if (pViewShell) if (pViewShell)
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#include "globstr.hrc" #include "globstr.hrc"
#include "markdata.hxx" #include "markdata.hxx"
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star; using namespace ::com::sun::star;
ScConversionEngineBase::ScConversionEngineBase( ScConversionEngineBase::ScConversionEngineBase(
...@@ -118,8 +120,8 @@ bool ScConversionEngineBase::FindNextConversionCell() ...@@ -118,8 +120,8 @@ bool ScConversionEngineBase::FindNextConversionCell()
if( pCell ) if( pCell )
{ {
ScEditCell* pEditCell = static_cast< ScEditCell* >( pCell ); ScEditCell* pEditCell = static_cast< ScEditCell* >( pCell );
::std::auto_ptr< EditTextObject > pEditObj( CreateTextObject() ); boost::scoped_ptr<EditTextObject> pEditObj(CreateTextObject());
pEditCell->SetData( pEditObj.get(), GetEditTextObjectPool() ); pEditCell->SetData(*pEditObj, GetEditTextObjectPool());
} }
} }
else else
......
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