diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-12 12:10:26 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-12 12:33:00 -0500 |
commit | 1ed3387aad80b740b90b28eab2c60816b89e2222 (patch) | |
tree | 16f1f557b021ed7904d677dfe01d06f97b157541 /sc | |
parent | 0585322e70d3c0f1d26d6bd9c04a388a1ff55abf (diff) |
Made similar change to SetData() of ScEditCell.
Change-Id: Ie1475eb19a4ad41e5eac1ca00419a1af5c207b12
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/cell.hxx | 28 | ||||
-rw-r--r-- | sc/source/core/data/cell2.cxx | 24 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/documen8.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk3.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/spelleng.cxx | 6 |
7 files changed, 65 insertions, 28 deletions
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index a6d1480923e2..7d0b798fc9df 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -262,8 +262,32 @@ public: // for line breaks 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; const EditTextObject* GetData() const; diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx index 849fd698fdf1..58a7595eedf0 100644 --- a/sc/source/core/data/cell2.cxx +++ b/sc/source/core/data/cell2.cxx @@ -96,16 +96,24 @@ ScEditCell::~ScEditCell() #endif } -void ScEditCell::SetData( const EditTextObject* pObject, - const SfxItemPool* pFromPool ) +void ScEditCell::ClearData() { - if ( pString ) - { - delete pString; - pString = NULL; - } + delete pString; + pString = NULL; 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 diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 21f77840b623..d2a5ee78e5fb 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -908,9 +908,7 @@ void ScColumn::RemoveAutoSpellObj() ScEditAttrTester aTester( pEngine ); if ( aTester.NeedsObject() ) // only remove spelling errors { - EditTextObject* pNewData = pEngine->CreateTextObject(); // without BIGOBJ - pOldCell->SetData( pNewData, pEngine->GetEditTextObjectPool() ); - delete pNewData; + pOldCell->SetData(pEngine->CreateTextObject()); } else // create a string { @@ -975,9 +973,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) sal_uInt32 nWantBig = bSpellErrors ? EE_CNTRL_ALLOWBIGOBJS : 0; if ( ( nCtrl & EE_CNTRL_ALLOWBIGOBJS ) != nWantBig ) pEngine->SetControlWord( (nCtrl & ~EE_CNTRL_ALLOWBIGOBJS) | nWantBig ); - EditTextObject* pNewData = pEngine->CreateTextObject(); - pOldCell->SetData( pNewData, pEngine->GetEditTextObjectPool() ); - delete pNewData; + pOldCell->SetData(pEngine->CreateTextObject()); } else // create String { diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 2c9d62888298..46d160d40973 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -741,15 +741,12 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe if ( bNeedEdit ) { - SAL_WNODEPRECATED_DECLARATIONS_PUSH - std::auto_ptr<EditTextObject> pNewData(pEngine->CreateTextObject()); - SAL_WNODEPRECATED_DECLARATIONS_POP if ( eType == CELLTYPE_EDIT ) - // SetData will create a clone of pNewData and stores the clone. - static_cast<ScEditCell*>(pCell)->SetData(pNewData.get(), pEngine->GetEditTextObjectPool()); + // The cell will take ownership of pNewData. + static_cast<ScEditCell*>(pCell)->SetData(pEngine->CreateTextObject()); else // 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 PutCell( nCol, nRow, nTab, new ScStringCell( pEngine->GetText() ) ); diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx index 5157efd4c06a..969beb7da3b6 100644 --- a/sc/source/ui/undo/undoblk3.cxx +++ b/sc/source/ui/undo/undoblk3.cxx @@ -444,9 +444,19 @@ void ScUndoSelectionAttr::ChangeEditData( const bool bUndo ) ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell); if (bUndo) - pEditCell->SetData(pItem->GetOldData(), NULL); + { + if (pItem->GetOldData()) + pEditCell->SetData(*pItem->GetOldData(), NULL); + else + pEditCell->ClearData(); + } else - pEditCell->SetData(pItem->GetNewData(), NULL); + { + if (pItem->GetNewData()) + pEditCell->SetData(*pItem->GetNewData(), NULL); + else + pEditCell->ClearData(); + } } } diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index b1f7c98e37e4..3b935e7f521a 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -103,8 +103,8 @@ void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const share ScBaseCell* pCell; pDoc->GetCell(nCol, nRow, nTab, pCell); - if (pCell && pCell->GetCellType() == CELLTYPE_EDIT && pEditData.get()) - static_cast<ScEditCell*>(pCell)->SetData(pEditData.get(), NULL); + if (pCell && pCell->GetCellType() == CELLTYPE_EDIT && pEditData) + static_cast<ScEditCell*>(pCell)->SetData(*pEditData, NULL); ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); if (pViewShell) diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx index 6cb0cc5a8081..fffda6edbb4c 100644 --- a/sc/source/ui/view/spelleng.cxx +++ b/sc/source/ui/view/spelleng.cxx @@ -42,6 +42,8 @@ #include "globstr.hrc" #include "markdata.hxx" +#include <boost/scoped_ptr.hpp> + using namespace ::com::sun::star; ScConversionEngineBase::ScConversionEngineBase( @@ -118,8 +120,8 @@ bool ScConversionEngineBase::FindNextConversionCell() if( pCell ) { ScEditCell* pEditCell = static_cast< ScEditCell* >( pCell ); - ::std::auto_ptr< EditTextObject > pEditObj( CreateTextObject() ); - pEditCell->SetData( pEditObj.get(), GetEditTextObjectPool() ); + boost::scoped_ptr<EditTextObject> pEditObj(CreateTextObject()); + pEditCell->SetData(*pEditObj, GetEditTextObjectPool()); } } else |