Kaydet (Commit) d69d9cdc authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SvxUnoTextRangeBase

Change-Id: I2f416e415ec388d1fac334b997f25427f6c1750f
Reviewed-on: https://gerrit.libreoffice.org/49175Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst cb226e26
...@@ -219,7 +219,7 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxEditSource* pSource, const Svx ...@@ -219,7 +219,7 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxEditSource* pSource, const Svx
DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!"); DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
mpEditSource = pSource->Clone(); mpEditSource.reset( pSource->Clone() );
if (mpEditSource != nullptr) if (mpEditSource != nullptr)
{ {
ESelection aSelection; ESelection aSelection;
...@@ -244,7 +244,7 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxUnoTextRangeBase& rRange) ...@@ -244,7 +244,7 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxUnoTextRangeBase& rRange)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
mpEditSource = rRange.mpEditSource ? rRange.mpEditSource->Clone() : nullptr; mpEditSource.reset( rRange.mpEditSource ? rRange.mpEditSource->Clone() : nullptr );
SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
if( pForwarder ) if( pForwarder )
...@@ -261,8 +261,6 @@ SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw() ...@@ -261,8 +261,6 @@ SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw()
{ {
if( mpEditSource ) if( mpEditSource )
mpEditSource->removeRange( this ); mpEditSource->removeRange( this );
delete mpEditSource;
} }
void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw() void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw()
...@@ -270,7 +268,7 @@ 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(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
DBG_ASSERT(mpEditSource==nullptr,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" ); DBG_ASSERT(mpEditSource==nullptr,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" );
mpEditSource = pSource; mpEditSource.reset( pSource );
maSelection.nStartPara = EE_PARA_MAX_COUNT; maSelection.nStartPara = EE_PARA_MAX_COUNT;
...@@ -300,7 +298,7 @@ void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw() ...@@ -300,7 +298,7 @@ void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw()
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
maSelection = rSelection; maSelection = rSelection;
CheckSelection( maSelection, mpEditSource ); CheckSelection( maSelection, mpEditSource.get() );
} }
// Interface XTextRange ( XText ) // Interface XTextRange ( XText )
...@@ -1313,7 +1311,7 @@ uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( con ...@@ -1313,7 +1311,7 @@ uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( con
// internal // internal
void SvxUnoTextRangeBase::CollapseToStart() throw() void SvxUnoTextRangeBase::CollapseToStart() throw()
{ {
CheckSelection( maSelection, mpEditSource ); CheckSelection( maSelection, mpEditSource.get() );
maSelection.nEndPara = maSelection.nStartPara; maSelection.nEndPara = maSelection.nStartPara;
maSelection.nEndPos = maSelection.nStartPos; maSelection.nEndPos = maSelection.nStartPos;
...@@ -1321,7 +1319,7 @@ void SvxUnoTextRangeBase::CollapseToStart() throw() ...@@ -1321,7 +1319,7 @@ void SvxUnoTextRangeBase::CollapseToStart() throw()
void SvxUnoTextRangeBase::CollapseToEnd() throw() void SvxUnoTextRangeBase::CollapseToEnd() throw()
{ {
CheckSelection( maSelection, mpEditSource ); CheckSelection( maSelection, mpEditSource.get() );
maSelection.nStartPara = maSelection.nEndPara; maSelection.nStartPara = maSelection.nEndPara;
maSelection.nStartPos = maSelection.nEndPos; maSelection.nStartPos = maSelection.nEndPos;
...@@ -1329,7 +1327,7 @@ void SvxUnoTextRangeBase::CollapseToEnd() throw() ...@@ -1329,7 +1327,7 @@ void SvxUnoTextRangeBase::CollapseToEnd() throw()
bool SvxUnoTextRangeBase::IsCollapsed() throw() bool SvxUnoTextRangeBase::IsCollapsed() throw()
{ {
CheckSelection( maSelection, mpEditSource ); CheckSelection( maSelection, mpEditSource.get() );
return ( maSelection.nStartPara == maSelection.nEndPara && return ( maSelection.nStartPara == maSelection.nEndPara &&
maSelection.nStartPos == maSelection.nEndPos ); maSelection.nStartPos == maSelection.nEndPos );
...@@ -1337,7 +1335,7 @@ bool SvxUnoTextRangeBase::IsCollapsed() throw() ...@@ -1337,7 +1335,7 @@ bool SvxUnoTextRangeBase::IsCollapsed() throw()
bool SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount, bool Expand) 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) // #75098# use end position, as in Writer (start is anchor, end is cursor)
sal_uInt16 nNewPos = maSelection.nEndPos; sal_uInt16 nNewPos = maSelection.nEndPos;
...@@ -1423,7 +1421,7 @@ void SvxUnoTextRangeBase::GotoStart(bool Expand) throw() ...@@ -1423,7 +1421,7 @@ void SvxUnoTextRangeBase::GotoStart(bool Expand) throw()
void SvxUnoTextRangeBase::GotoEnd(bool Expand) throw() void SvxUnoTextRangeBase::GotoEnd(bool Expand) throw()
{ {
CheckSelection( maSelection, mpEditSource ); CheckSelection( maSelection, mpEditSource.get() );
SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
if( pForwarder ) if( pForwarder )
......
...@@ -253,7 +253,7 @@ class EDITENG_DLLPUBLIC SvxUnoTextRangeBase : public css::text::XTextRange, ...@@ -253,7 +253,7 @@ class EDITENG_DLLPUBLIC SvxUnoTextRangeBase : public css::text::XTextRange,
const SvxItemPropertySet* mpPropSet; const SvxItemPropertySet* mpPropSet;
protected: protected:
SvxEditSource* mpEditSource; std::unique_ptr<SvxEditSource> mpEditSource;
ESelection maSelection; ESelection maSelection;
/// @throws css::beans::UnknownPropertyException /// @throws css::beans::UnknownPropertyException
...@@ -327,7 +327,7 @@ public: ...@@ -327,7 +327,7 @@ public:
//const SfxItemPropertyMapEntry* getPropertyMapEntries() const throw() { return maPropSet.getPropertyMapEntries(); } //const SfxItemPropertyMapEntry* getPropertyMapEntries() const throw() { return maPropSet.getPropertyMapEntries(); }
const SvxItemPropertySet* getPropertySet() const throw() { return mpPropSet; } 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 ); static bool SetPropertyValueHelper( const SfxItemPropertySimpleEntry* pMap, const css::uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection = nullptr, SvxEditSource* pEditSource = nullptr );
/// @throws css::uno::RuntimeException /// @throws css::uno::RuntimeException
......
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