loplugin:useuniqueptr in ImpEditEngine
Change-Id: I5afc846c803f5191bb5e04590923059e88434b76 Reviewed-on: https://gerrit.libreoffice.org/49176 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
12726ee86f
commit
987cd20a33
6 changed files with 41 additions and 46 deletions
|
@ -213,6 +213,9 @@ void UseUniquePtr::CheckDeleteExpr(const CXXDestructorDecl* destructorDecl, cons
|
|||
// not sure how the node management is working here
|
||||
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/i18npool/source/localedata/saxparser.cxx"))
|
||||
return;
|
||||
// has a pointer that it only sometimes owns
|
||||
if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/editeng/source/editeng/impedit.hxx"))
|
||||
return;
|
||||
|
||||
report(
|
||||
DiagnosticsEngine::Warning,
|
||||
|
|
|
@ -523,7 +523,7 @@ void EditEngine::SetPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon, const b
|
|||
}
|
||||
|
||||
TextRanger* pRanger = new TextRanger( rPolyPolygon, pLinePolyPolygon, 30, 2, 2, bSimple, true );
|
||||
pImpEditEngine->SetTextRanger( pRanger );
|
||||
pImpEditEngine->SetTextRanger( std::unique_ptr<TextRanger>(pRanger) );
|
||||
pImpEditEngine->SetPaperSize( pRanger->GetBoundRect().GetSize() );
|
||||
}
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ private:
|
|||
EditEngine* pEditEngine;
|
||||
ViewsType aEditViews;
|
||||
EditView* pActiveView;
|
||||
TextRanger* pTextRanger;
|
||||
std::unique_ptr<TextRanger> pTextRanger;
|
||||
|
||||
SfxStyleSheetPool* pStylePool;
|
||||
SfxItemPool* pTextObjectPool;
|
||||
|
@ -446,13 +446,13 @@ private:
|
|||
VclPtr<VirtualDevice> mpOwnDev;
|
||||
|
||||
svtools::ColorConfig maColorConfig;
|
||||
mutable SvtCTLOptions* pCTLOptions;
|
||||
mutable std::unique_ptr<SvtCTLOptions> pCTLOptions;
|
||||
|
||||
std::unique_ptr<SfxItemSet> pEmptyItemSet;
|
||||
EditUndoManager* pUndoManager;
|
||||
ESelection* pUndoMarkSelection;
|
||||
|
||||
ImplIMEInfos* mpIMEInfos;
|
||||
std::unique_ptr<ImplIMEInfos> mpIMEInfos;
|
||||
|
||||
std::vector<EENotify> aNotifyCache;
|
||||
|
||||
|
@ -474,7 +474,7 @@ private:
|
|||
sal_Int32 nBigTextObjectStart;
|
||||
css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller;
|
||||
css::uno::Reference< css::linguistic2::XHyphenator > xHyphenator;
|
||||
SpellInfo* pSpellInfo;
|
||||
std::unique_ptr<SpellInfo> pSpellInfo;
|
||||
mutable css::uno::Reference < css::i18n::XBreakIterator > xBI;
|
||||
mutable css::uno::Reference < css::i18n::XExtendedInputSequenceChecker > xISC;
|
||||
|
||||
|
@ -708,7 +708,7 @@ private:
|
|||
void ImplUpdateOverflowingParaNum( sal_uInt32 );
|
||||
void ImplUpdateOverflowingLineNum( sal_uInt32, sal_uInt32, sal_uInt32 );
|
||||
|
||||
SpellInfo * CreateSpellInfo( bool bMultipleDocs );
|
||||
void CreateSpellInfo( bool bMultipleDocs );
|
||||
/// Obtains a view shell ID from the active EditView.
|
||||
ViewShellId CreateViewShellId();
|
||||
|
||||
|
@ -758,8 +758,8 @@ public:
|
|||
sal_uInt8 GetRightToLeft( sal_Int32 nPara, sal_Int32 nChar, sal_Int32* pStart = nullptr, sal_Int32* pEnd = nullptr );
|
||||
bool HasDifferentRTLLevels( const ContentNode* pNode );
|
||||
|
||||
void SetTextRanger( TextRanger* pRanger );
|
||||
TextRanger* GetTextRanger() const { return pTextRanger; }
|
||||
void SetTextRanger( std::unique_ptr<TextRanger> pRanger );
|
||||
TextRanger* GetTextRanger() const { return pTextRanger.get(); }
|
||||
|
||||
const Size& GetMinAutoPaperSize() const { return aMinAutoPaperSize; }
|
||||
void SetMinAutoPaperSize( const Size& rSz ) { aMinAutoPaperSize = rSz; }
|
||||
|
@ -942,7 +942,7 @@ public:
|
|||
void GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) const;
|
||||
void SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& rRanges );
|
||||
|
||||
SpellInfo* GetSpellInfo() const { return pSpellInfo; }
|
||||
SpellInfo* GetSpellInfo() const { return pSpellInfo.get(); }
|
||||
|
||||
void SetDefaultLanguage( LanguageType eLang ) { eDefLanguage = eLang; }
|
||||
LanguageType GetDefaultLanguage() const { return eDefLanguage; }
|
||||
|
|
|
@ -198,10 +198,10 @@ ImpEditEngine::~ImpEditEngine()
|
|||
// before destroying the ImpEditEngine!
|
||||
assert(!pUndoManager || typeid(*pUndoManager) == typeid(EditUndoManager));
|
||||
delete pUndoManager;
|
||||
delete pTextRanger;
|
||||
delete mpIMEInfos;
|
||||
delete pCTLOptions;
|
||||
delete pSpellInfo;
|
||||
pTextRanger.reset();
|
||||
mpIMEInfos.reset();
|
||||
pCTLOptions.reset();
|
||||
pSpellInfo.reset();
|
||||
}
|
||||
|
||||
void ImpEditEngine::SetRefDevice( OutputDevice* pRef )
|
||||
|
@ -359,13 +359,13 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
|
|||
if ( rCEvt.GetCommand() == CommandEventId::StartExtTextInput )
|
||||
{
|
||||
pView->DeleteSelected();
|
||||
delete mpIMEInfos;
|
||||
mpIMEInfos.reset();
|
||||
EditPaM aPaM = pView->GetImpEditView()->GetEditSelection().Max();
|
||||
OUString aOldTextAfterStartPos = aPaM.GetNode()->Copy( aPaM.GetIndex() );
|
||||
sal_Int32 nMax = aOldTextAfterStartPos.indexOf( CH_FEATURE );
|
||||
if ( nMax != -1 ) // don't overwrite features!
|
||||
aOldTextAfterStartPos = aOldTextAfterStartPos.copy( 0, nMax );
|
||||
mpIMEInfos = new ImplIMEInfos( aPaM, aOldTextAfterStartPos );
|
||||
mpIMEInfos.reset( new ImplIMEInfos( aPaM, aOldTextAfterStartPos ) );
|
||||
mpIMEInfos->bWasCursorOverwrite = !pView->IsInsertMode();
|
||||
UndoActionStart( EDITUNDO_INSERT );
|
||||
}
|
||||
|
@ -400,8 +400,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
|
|||
|
||||
bool bWasCursorOverwrite = mpIMEInfos->bWasCursorOverwrite;
|
||||
|
||||
delete mpIMEInfos;
|
||||
mpIMEInfos = nullptr;
|
||||
mpIMEInfos.reset();
|
||||
|
||||
FormatAndUpdate( pView );
|
||||
|
||||
|
@ -1590,7 +1589,7 @@ bool ImpEditEngine::IsInputSequenceCheckingRequired( sal_Unicode nChar, const Ed
|
|||
{
|
||||
uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
|
||||
if (!pCTLOptions)
|
||||
pCTLOptions = new SvtCTLOptions;
|
||||
pCTLOptions.reset( new SvtCTLOptions );
|
||||
|
||||
// get the index that really is first
|
||||
const sal_Int32 nFirstPos = std::min(rCurSel.Min().GetIndex(), rCurSel.Max().GetIndex());
|
||||
|
@ -2616,7 +2615,7 @@ EditPaM ImpEditEngine::InsertTextUserInput( const EditSelection& rCurSel,
|
|||
{
|
||||
uno::Reference < i18n::XExtendedInputSequenceChecker > _xISC( ImplGetInputSequenceChecker() );
|
||||
if (!pCTLOptions)
|
||||
pCTLOptions = new SvtCTLOptions;
|
||||
pCTLOptions.reset( new SvtCTLOptions );
|
||||
|
||||
if (_xISC.is() || pCTLOptions)
|
||||
{
|
||||
|
@ -3453,8 +3452,7 @@ void ImpEditEngine::SetActiveView( EditView* pView )
|
|||
|
||||
if ( !pView && mpIMEInfos )
|
||||
{
|
||||
delete mpIMEInfos;
|
||||
mpIMEInfos = nullptr;
|
||||
mpIMEInfos.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4355,7 +4353,7 @@ bool ImpEditEngine::IsVisualCursorTravelingEnabled()
|
|||
bool bVisualCursorTravaling = false;
|
||||
|
||||
if( !pCTLOptions )
|
||||
pCTLOptions = new SvtCTLOptions;
|
||||
pCTLOptions.reset( new SvtCTLOptions );
|
||||
|
||||
if ( pCTLOptions->IsCTLFontEnabled() && ( pCTLOptions->GetCTLCursorMovement() == SvtCTLOptions::MOVEMENT_VISUAL ) )
|
||||
{
|
||||
|
|
|
@ -2610,25 +2610,21 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
|
|||
#endif
|
||||
}
|
||||
|
||||
void ImpEditEngine::SetTextRanger( TextRanger* pRanger )
|
||||
void ImpEditEngine::SetTextRanger( std::unique_ptr<TextRanger> pRanger )
|
||||
{
|
||||
if ( pTextRanger != pRanger )
|
||||
pTextRanger = std::move(pRanger);
|
||||
|
||||
for ( sal_Int32 nPara = 0; nPara < GetParaPortions().Count(); nPara++ )
|
||||
{
|
||||
delete pTextRanger;
|
||||
pTextRanger = pRanger;
|
||||
|
||||
for ( sal_Int32 nPara = 0; nPara < GetParaPortions().Count(); nPara++ )
|
||||
{
|
||||
ParaPortion* pParaPortion = GetParaPortions()[nPara];
|
||||
pParaPortion->MarkSelectionInvalid( 0 );
|
||||
pParaPortion->GetLines().Reset();
|
||||
}
|
||||
|
||||
FormatFullDoc();
|
||||
UpdateViews( GetActiveView() );
|
||||
if ( GetUpdateMode() && GetActiveView() )
|
||||
pActiveView->ShowCursor(false, false);
|
||||
ParaPortion* pParaPortion = GetParaPortions()[nPara];
|
||||
pParaPortion->MarkSelectionInvalid( 0 );
|
||||
pParaPortion->GetLines().Reset();
|
||||
}
|
||||
|
||||
FormatFullDoc();
|
||||
UpdateViews( GetActiveView() );
|
||||
if ( GetUpdateMode() && GetActiveView() )
|
||||
pActiveView->ShowCursor(false, false);
|
||||
}
|
||||
|
||||
void ImpEditEngine::SetVertical( bool bVertical, bool bTopToBottom)
|
||||
|
@ -4353,7 +4349,7 @@ LanguageType ImpEditEngine::ImplCalcDigitLang(LanguageType eCurLang) const
|
|||
// #114278# Also setting up digit language from Svt options
|
||||
// (cannot reliably inherit the outdev's setting)
|
||||
if( !pCTLOptions )
|
||||
pCTLOptions = new SvtCTLOptions;
|
||||
pCTLOptions.reset( new SvtCTLOptions );
|
||||
|
||||
LanguageType eLang = eCurLang;
|
||||
const SvtCTLOptions::TextNumerals nCTLTextNumerals = pCTLOptions->GetCTLTextNumerals();
|
||||
|
|
|
@ -1426,10 +1426,10 @@ Reference< XSpellChecker1 > const & ImpEditEngine::GetSpeller()
|
|||
}
|
||||
|
||||
|
||||
SpellInfo * ImpEditEngine::CreateSpellInfo( bool bMultipleDocs )
|
||||
void ImpEditEngine::CreateSpellInfo( bool bMultipleDocs )
|
||||
{
|
||||
if (!pSpellInfo)
|
||||
pSpellInfo = new SpellInfo;
|
||||
pSpellInfo.reset( new SpellInfo );
|
||||
else
|
||||
*pSpellInfo = SpellInfo(); // reset to default values
|
||||
|
||||
|
@ -1439,7 +1439,6 @@ SpellInfo * ImpEditEngine::CreateSpellInfo( bool bMultipleDocs )
|
|||
// further changes elsewhere to work properly)
|
||||
pSpellInfo->aSpellStart = EPaM();
|
||||
pSpellInfo->aSpellTo = EPaM( EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND );
|
||||
return pSpellInfo;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1459,7 +1458,7 @@ EESpellState ImpEditEngine::Spell( EditView* pEditView, bool bMultipleDoc )
|
|||
}
|
||||
|
||||
EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() );
|
||||
pSpellInfo = CreateSpellInfo( bMultipleDoc );
|
||||
CreateSpellInfo( bMultipleDoc );
|
||||
|
||||
bool bIsStart = false;
|
||||
if ( bMultipleDoc )
|
||||
|
@ -1483,8 +1482,7 @@ EESpellState ImpEditEngine::Spell( EditView* pEditView, bool bMultipleDoc )
|
|||
pEditView->ShowCursor( true, false );
|
||||
}
|
||||
EESpellState eState = pSpellInfo->eState;
|
||||
delete pSpellInfo;
|
||||
pSpellInfo = nullptr;
|
||||
pSpellInfo.reset();
|
||||
return eState;
|
||||
}
|
||||
|
||||
|
@ -1928,7 +1926,7 @@ bool ImpEditEngine::SpellSentence(EditView const & rEditView,
|
|||
bool bRet = false;
|
||||
EditSelection aCurSel( rEditView.pImpEditView->GetEditSelection() );
|
||||
if(!pSpellInfo)
|
||||
pSpellInfo = CreateSpellInfo( true );
|
||||
CreateSpellInfo( true );
|
||||
pSpellInfo->aCurSentenceStart = aCurSel.Min();
|
||||
DBG_ASSERT( xSpeller.is(), "No spell checker set!" );
|
||||
pSpellInfo->aLastSpellPortions.clear();
|
||||
|
|
Loading…
Reference in a new issue