summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-29 11:14:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-02-05 07:50:46 +0100
commitd69d9cdc40d7a2f3d80688ab519fcf4c932b8f7b (patch)
treea0df01c7c885da35c068fed5be5a74f1597a0436
parentcb226e26cbdfe29bc97aba101d3d524f13482876 (diff)
loplugin:useuniqueptr in SvxUnoTextRangeBase
Change-Id: I2f416e415ec388d1fac334b997f25427f6c1750f Reviewed-on: https://gerrit.libreoffice.org/49175 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--editeng/source/uno/unotext.cxx20
-rw-r--r--include/editeng/unotext.hxx4
2 files changed, 11 insertions, 13 deletions
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 6b6127c92ec8..93dbfd6c0aef 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -219,7 +219,7 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxEditSource* pSource, const Svx
DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
- mpEditSource = pSource->Clone();
+ mpEditSource.reset( pSource->Clone() );
if (mpEditSource != nullptr)
{
ESelection aSelection;
@@ -244,7 +244,7 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxUnoTextRangeBase& rRange)
{
SolarMutexGuard aGuard;
- mpEditSource = rRange.mpEditSource ? rRange.mpEditSource->Clone() : nullptr;
+ mpEditSource.reset( rRange.mpEditSource ? rRange.mpEditSource->Clone() : nullptr );
SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
if( pForwarder )
@@ -261,8 +261,6 @@ SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw()
{
if( mpEditSource )
mpEditSource->removeRange( this );
-
- delete mpEditSource;
}
void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw()
@@ -270,7 +268,7 @@ void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw()
DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
DBG_ASSERT(mpEditSource==nullptr,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" );
- mpEditSource = pSource;
+ mpEditSource.reset( pSource );
maSelection.nStartPara = EE_PARA_MAX_COUNT;
@@ -300,7 +298,7 @@ void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw()
SolarMutexGuard aGuard;
maSelection = rSelection;
- CheckSelection( maSelection, mpEditSource );
+ CheckSelection( maSelection, mpEditSource.get() );
}
// Interface XTextRange ( XText )
@@ -1313,7 +1311,7 @@ uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( con
// internal
void SvxUnoTextRangeBase::CollapseToStart() throw()
{
- CheckSelection( maSelection, mpEditSource );
+ CheckSelection( maSelection, mpEditSource.get() );
maSelection.nEndPara = maSelection.nStartPara;
maSelection.nEndPos = maSelection.nStartPos;
@@ -1321,7 +1319,7 @@ void SvxUnoTextRangeBase::CollapseToStart() throw()
void SvxUnoTextRangeBase::CollapseToEnd() throw()
{
- CheckSelection( maSelection, mpEditSource );
+ CheckSelection( maSelection, mpEditSource.get() );
maSelection.nStartPara = maSelection.nEndPara;
maSelection.nStartPos = maSelection.nEndPos;
@@ -1329,7 +1327,7 @@ void SvxUnoTextRangeBase::CollapseToEnd() throw()
bool SvxUnoTextRangeBase::IsCollapsed() throw()
{
- CheckSelection( maSelection, mpEditSource );
+ CheckSelection( maSelection, mpEditSource.get() );
return ( maSelection.nStartPara == maSelection.nEndPara &&
maSelection.nStartPos == maSelection.nEndPos );
@@ -1337,7 +1335,7 @@ bool SvxUnoTextRangeBase::IsCollapsed() throw()
bool SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount, bool Expand) throw()
{
- CheckSelection( maSelection, mpEditSource );
+ CheckSelection( maSelection, mpEditSource.get() );
// #75098# use end position, as in Writer (start is anchor, end is cursor)
sal_uInt16 nNewPos = maSelection.nEndPos;
@@ -1423,7 +1421,7 @@ void SvxUnoTextRangeBase::GotoStart(bool Expand) throw()
void SvxUnoTextRangeBase::GotoEnd(bool Expand) throw()
{
- CheckSelection( maSelection, mpEditSource );
+ CheckSelection( maSelection, mpEditSource.get() );
SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
if( pForwarder )
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 514f83e8b6dd..1e15f8d5e033 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -253,7 +253,7 @@ class EDITENG_DLLPUBLIC SvxUnoTextRangeBase : public css::text::XTextRange,
const SvxItemPropertySet* mpPropSet;
protected:
- SvxEditSource* mpEditSource;
+ std::unique_ptr<SvxEditSource> mpEditSource;
ESelection maSelection;
/// @throws css::beans::UnknownPropertyException
@@ -327,7 +327,7 @@ public:
//const SfxItemPropertyMapEntry* getPropertyMapEntries() const throw() { return maPropSet.getPropertyMapEntries(); }
const SvxItemPropertySet* getPropertySet() const throw() { return mpPropSet; }
- SvxEditSource* GetEditSource() const throw() { return mpEditSource; }
+ SvxEditSource* GetEditSource() const throw() { return mpEditSource.get(); }
static bool SetPropertyValueHelper( const SfxItemPropertySimpleEntry* pMap, const css::uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection = nullptr, SvxEditSource* pEditSource = nullptr );
/// @throws css::uno::RuntimeException