summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-09-25 20:49:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-09-25 20:52:33 +0100
commit958f7a7b772cff53e441b02c322ffbd80decc9a0 (patch)
tree0e3287da17ef87515f3f2287d539ff7ebe9dd6eb
parent4563921f23d79f6e3e431a314064c6dd201cfee2 (diff)
impl this with a std::unique_ptr
Change-Id: Ia2a7971bf67bac2ed2c5dd3ef48a17f4f3d59a5d
-rw-r--r--sd/inc/OutlinerIterator.hxx2
-rw-r--r--sd/source/ui/view/OutlinerIterator.cxx31
2 files changed, 15 insertions, 18 deletions
diff --git a/sd/inc/OutlinerIterator.hxx b/sd/inc/OutlinerIterator.hxx
index b261ed4e5997..2fc5a6cd9647 100644
--- a/sd/inc/OutlinerIterator.hxx
+++ b/sd/inc/OutlinerIterator.hxx
@@ -135,7 +135,7 @@ public:
private:
/// The implementation object to which most of the methods are forwarded.
- IteratorImplBase* mpIterator;
+ std::unique_ptr<IteratorImplBase> mxIterator;
};
/** This class wraps the <type>Outliner</type> class and represents it as
diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx
index 65e3fd11ef30..4fd8df0e85ce 100644
--- a/sd/source/ui/view/OutlinerIterator.cxx
+++ b/sd/source/ui/view/OutlinerIterator.cxx
@@ -66,56 +66,53 @@ bool IteratorPosition::operator== (const IteratorPosition& aPosition) const
Iterator::Iterator()
{
- mpIterator = nullptr;
}
Iterator::Iterator (const Iterator& rIterator)
+ : mxIterator(rIterator.mxIterator ? rIterator.mxIterator->Clone() : nullptr)
{
- mpIterator = rIterator.mpIterator ? rIterator.mpIterator->Clone() : nullptr;
}
Iterator::Iterator (IteratorImplBase* pObject)
+ : mxIterator(pObject)
{
- mpIterator = pObject;
}
Iterator::~Iterator()
{
- delete mpIterator;
}
Iterator& Iterator::operator= (const Iterator& rIterator)
{
if (this != &rIterator)
{
- delete mpIterator;
- if (rIterator.mpIterator != nullptr)
- mpIterator = rIterator.mpIterator->Clone();
+ if (rIterator.mxIterator)
+ mxIterator.reset(rIterator.mxIterator->Clone());
else
- mpIterator = nullptr;
+ mxIterator.reset();
}
return *this;
}
const IteratorPosition& Iterator::operator* () const
{
- DBG_ASSERT (mpIterator!=nullptr, "::sd::outliner::Iterator::operator* : missing implementation object");
- return mpIterator->GetPosition();
+ DBG_ASSERT (mxIterator, "::sd::outliner::Iterator::operator* : missing implementation object");
+ return mxIterator->GetPosition();
}
Iterator& Iterator::operator++ ()
{
- if (mpIterator!=nullptr)
- mpIterator->GotoNextText();
+ if (mxIterator)
+ mxIterator->GotoNextText();
return *this;
}
bool Iterator::operator== (const Iterator& rIterator)
{
- if (mpIterator == nullptr || rIterator.mpIterator==nullptr)
- return mpIterator == rIterator.mpIterator;
+ if (!mxIterator || !rIterator.mxIterator)
+ return mxIterator.get() == rIterator.mxIterator.get();
else
- return *mpIterator == *rIterator.mpIterator;
+ return *mxIterator == *rIterator.mxIterator;
}
bool Iterator::operator!= (const Iterator& rIterator)
@@ -125,8 +122,8 @@ bool Iterator::operator!= (const Iterator& rIterator)
void Iterator::Reverse()
{
- if (mpIterator != nullptr)
- mpIterator->Reverse();
+ if (mxIterator)
+ mxIterator->Reverse();
}
//===== IteratorFactory =======================================================