diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-08 11:22:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-09 12:09:55 +0200 |
commit | f7ce839c7844f029c0a1ac83a5638e83356b4c4b (patch) | |
tree | c93a342a577133b384a3ccc088d7d0675d4fb9e3 /cui | |
parent | 4ba06560e33f17ca1ed72ad722c80eae5ffd4277 (diff) |
use unique_ptr in SfxUndoManager::AddUndoAction
Change-Id: I11483e3cece12a7373f4276972b4c899edf1ce15
Reviewed-on: https://gerrit.libreoffice.org/61566
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/SpellDialog.cxx | 45 | ||||
-rw-r--r-- | cui/source/inc/SpellDialog.hxx | 2 | ||||
-rw-r--r-- | cui/source/tabpages/transfrm.cxx | 9 |
3 files changed, 27 insertions, 29 deletions
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index d71f12a41ac6..c92ec7d4ee5b 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -577,11 +577,11 @@ IMPL_LINK_NOARG(SpellDialog, ChangeAllHdl, Button*, void) if(nAdded == DictionaryError::NONE) { - SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( - SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); + std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl( + SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink)); pAction->SetDictionary(aXDictionary); pAction->SetAddedWord(aOldWord); - m_pSentenceED->AddUndoAction(pAction); + m_pSentenceED->AddUndoAction(std::move(pAction)); } m_pSentenceED->ChangeMarkedWord(aString, eLang); @@ -623,11 +623,11 @@ IMPL_LINK( SpellDialog, IgnoreAllHdl, Button *, pButton, void ) OUString() ); if(nAdded == DictionaryError::NONE) { - SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( - SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); + std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl( + SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink)); pAction->SetDictionary(aXDictionary); pAction->SetAddedWord(sErrorText); - m_pSentenceED->AddUndoAction(pAction); + m_pSentenceED->AddUndoAction(std::move(pAction)); } } @@ -764,7 +764,7 @@ IMPL_LINK(SpellDialog, LanguageSelectHdl, ListBox&, rBox, void) SpellContinue_Impl(); } - m_pSentenceED->AddUndoAction(new SpellUndoAction_Impl(SPELLUNDO_CHANGE_LANGUAGE, aDialogUndoLink)); + m_pSentenceED->AddUndoAction(o3tl::make_unique<SpellUndoAction_Impl>(SPELLUNDO_CHANGE_LANGUAGE, aDialogUndoLink)); } SpellDialog::UpdateBoxes_Impl(); } @@ -889,11 +889,11 @@ void SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu const *p if (nAddRes == DictionaryError::NONE) { - SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( - SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); + std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl( + SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink)); pAction->SetDictionary( xDic ); pAction->SetAddedWord( aNewWord ); - m_pSentenceED->AddUndoAction( pAction ); + m_pSentenceED->AddUndoAction( std::move(pAction) ); } // failed because there is already an entry? if (DictionaryError::NONE != nAddRes && xDic->getEntry( aNewWord ).is()) @@ -919,7 +919,7 @@ IMPL_LINK(SpellDialog, ModifyHdl, Edit&, rEd, void) m_pSuggestionLB->Disable(); OUString sNewText( m_pSentenceED->GetText() ); m_pAutoCorrPB->Enable( sNewText != m_pSentenceED->GetText() ); - SpellUndoAction_Impl* pSpellAction = new SpellUndoAction_Impl(SPELLUNDO_CHANGE_TEXTENGINE, aDialogUndoLink); + std::unique_ptr<SpellUndoAction_Impl> pSpellAction(new SpellUndoAction_Impl(SPELLUNDO_CHANGE_TEXTENGINE, aDialogUndoLink)); if(!m_pChangeAllPB->IsEnabled()) { m_pChangeAllPB->Enable(); @@ -930,7 +930,7 @@ IMPL_LINK(SpellDialog, ModifyHdl, Edit&, rEd, void) m_pChangePB->Enable(); pSpellAction->SetEnableChangePB(); } - m_pSentenceED->AddUndoAction(pSpellAction); + m_pSentenceED->AddUndoAction(std::move(pSpellAction)); } }; @@ -1598,15 +1598,15 @@ bool SentenceEditWindow_Impl::MarkNextError( bool bIgnoreCurrentError, const css MoveErrorMarkTo(aCursor.GetIndex(), pNextError->GetEnd(), bGrammarError); bRet = true; //add an undo action - SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( - SPELLUNDO_CHANGE_NEXTERROR, GetSpellDialog()->aDialogUndoLink); + std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl( + SPELLUNDO_CHANGE_NEXTERROR, GetSpellDialog()->aDialogUndoLink)); pAction->SetErrorMove(nOldErrorStart, nOldErrorEnd); const SpellErrorAttrib* pOldAttrib = static_cast<const SpellErrorAttrib*>( pTextEngine->FindAttrib( TextPaM(0, nOldErrorStart), TEXTATTR_SPELL_ERROR )); pAction->SetErrorLanguageSelected(pOldAttrib && pOldAttrib->GetErrorDescription().aSuggestions.getLength() && LanguageTag( pOldAttrib->GetErrorDescription().aLocale).getLanguageType() == GetSpellDialog()->m_pLanguageLB->GetSelectedLanguage()); - AddUndoAction(pAction); + AddUndoAction(std::move(pAction)); } else m_nErrorStart = m_nErrorEnd = nTextLen; @@ -1688,10 +1688,10 @@ void SentenceEditWindow_Impl::ChangeMarkedWord(const OUString& rNewWord, Languag nEndTemp += nDiffLen; m_nErrorEnd = static_cast<sal_Int32>(nEndTemp); - SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( - SPELLUNDO_MOVE_ERROREND, GetSpellDialog()->aDialogUndoLink); + std::unique_ptr<SpellUndoAction_Impl> pAction(new SpellUndoAction_Impl( + SPELLUNDO_MOVE_ERROREND, GetSpellDialog()->aDialogUndoLink)); pAction->SetOffset(nDiffLen); - AddUndoAction(pAction); + AddUndoAction(std::move(pAction)); if(pSpellErrorDescription) SetAttrib( SpellErrorAttrib(*pSpellErrorDescription), 0, m_nErrorStart, m_nErrorEnd ); SetAttrib( SpellLanguageAttrib(eLanguage), 0, m_nErrorStart, m_nErrorEnd ); @@ -1931,10 +1931,10 @@ void SentenceEditWindow_Impl::ResetUndo() } -void SentenceEditWindow_Impl::AddUndoAction( SfxUndoAction *pAction ) +void SentenceEditWindow_Impl::AddUndoAction( std::unique_ptr<SfxUndoAction> pAction ) { SfxUndoManager& rUndoMgr = GetTextEngine()->GetUndoManager(); - rUndoMgr.AddUndoAction(pAction); + rUndoMgr.AddUndoAction(std::move(pAction)); GetSpellDialog()->m_pUndoPB->Enable(); } @@ -2002,9 +2002,8 @@ void SentenceEditWindow_Impl::SetUndoEditMode(bool bSet) pTextEngine->RemoveAttribs( 0, sal_uInt16(TEXTATTR_FONTWEIGHT) ); //put the appropriate action on the Undo-stack - SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( - SPELLUNDO_UNDO_EDIT_MODE, GetSpellDialog()->aDialogUndoLink); - AddUndoAction(pAction); + AddUndoAction( o3tl::make_unique<SpellUndoAction_Impl>( + SPELLUNDO_UNDO_EDIT_MODE, GetSpellDialog()->aDialogUndoLink) ); pSpellDialog->m_pChangePB->Enable(); } diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx index 41d68d99ba68..ab7f22b79bd4 100644 --- a/cui/source/inc/SpellDialog.hxx +++ b/cui/source/inc/SpellDialog.hxx @@ -110,7 +110,7 @@ public: void ResetUndo(); void Undo(); - void AddUndoAction( SfxUndoAction *pAction ); + void AddUndoAction( std::unique_ptr<SfxUndoAction> pAction ); size_t GetUndoActionCount(); void UndoActionStart( sal_uInt16 nId ); void UndoActionEnd(); diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx index 46c3d2570762..eac242eda649 100644 --- a/cui/source/tabpages/transfrm.cxx +++ b/cui/source/tabpages/transfrm.cxx @@ -526,10 +526,9 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) static_cast< SdrObjCustomShape& >( *pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj())); SdrModel& rModel(rSdrObjCustomShape.getSdrModelFromSdrObject()); - SdrUndoAction* pUndo( - rModel.IsUndoEnabled() - ? rModel.GetSdrUndoFactory().CreateUndoAttrObject(rSdrObjCustomShape) - : nullptr); + std::unique_ptr<SdrUndoAction> pUndo; + if (rModel.IsUndoEnabled()) + pUndo = rModel.GetSdrUndoFactory().CreateUndoAttrObject(rSdrObjCustomShape); if(pUndo) { @@ -561,7 +560,7 @@ bool SvxSlantTabPage::FillItemSet(SfxItemSet* rAttrs) if (pUndo) { - rModel.AddUndo(pUndo); + rModel.AddUndo(std::move(pUndo)); rModel.EndUndo(); } } |