summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2023-05-12 19:47:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-05-13 14:55:56 +0200
commit3168d1ab07239789cd36a5960cef2d13ae29c9de (patch)
tree344b92c257f9e70119d13b51e06abc74d12f40f3 /sd
parent5351b8789805154219fe57b92b41b17c0e0cd765 (diff)
use more optional for SdrObjListIter
Change-Id: Iffd99d820889a1a5be514d46191ffaa2a6fa6910 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151721 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/inc/OutlinerIteratorImpl.hxx6
-rw-r--r--sd/source/ui/view/OutlinerIterator.cxx38
2 files changed, 22 insertions, 22 deletions
diff --git a/sd/source/ui/inc/OutlinerIteratorImpl.hxx b/sd/source/ui/inc/OutlinerIteratorImpl.hxx
index 97249464dc03..84b11e47b636 100644
--- a/sd/source/ui/inc/OutlinerIteratorImpl.hxx
+++ b/sd/source/ui/inc/OutlinerIteratorImpl.hxx
@@ -19,12 +19,12 @@
#pragma once
+#include <svx/svditer.hxx>
#include <OutlinerIterator.hxx>
-#include <memory>
+#include <optional>
class SdDrawDocument;
class SdPage;
-class SdrObjListIter;
namespace sd {
@@ -199,7 +199,7 @@ private:
/// Pointer to the page associated with the current page index. May be NULL.
SdPage* mpPage;
/// Iterator of all objects on the current page.
- std::unique_ptr<SdrObjListIter> mpObjectIterator;
+ std::optional<SdrObjListIter> moObjectIterator;
// Don't use this operator.
ViewIteratorImpl& operator= (const ViewIteratorImpl&) = delete;
diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx
index ac3f1bc29601..a7cd6cf66bf2 100644
--- a/sd/source/ui/view/OutlinerIterator.cxx
+++ b/sd/source/ui/view/OutlinerIterator.cxx
@@ -544,17 +544,17 @@ IteratorImplBase* ViewIteratorImpl::Clone (IteratorImplBase* pObject) const
IteratorImplBase::Clone (pObject);
- if (mpObjectIterator != nullptr)
+ if (moObjectIterator)
{
- pIterator->mpObjectIterator.reset( new SdrObjListIter(mpPage, SdrIterMode::DeepNoGroups, !mbDirectionIsForward) );
+ pIterator->moObjectIterator.emplace(mpPage, SdrIterMode::DeepNoGroups, !mbDirectionIsForward);
// No direct way to set the object iterator to the current object.
pIterator->maPosition.mxObject = nullptr;
- while (pIterator->mpObjectIterator->IsMore() && pIterator->maPosition.mxObject.get()!=maPosition.mxObject.get())
- pIterator->maPosition.mxObject = pIterator->mpObjectIterator->Next();
+ while (pIterator->moObjectIterator->IsMore() && pIterator->maPosition.mxObject.get()!=maPosition.mxObject.get())
+ pIterator->maPosition.mxObject = pIterator->moObjectIterator->Next();
}
else
- pIterator->mpObjectIterator.reset();
+ pIterator->moObjectIterator.reset();
return pIterator;
}
@@ -578,8 +578,8 @@ void ViewIteratorImpl::GotoNextText()
}
}
- if (mpObjectIterator != nullptr && mpObjectIterator->IsMore())
- maPosition.mxObject = mpObjectIterator->Next();
+ if (moObjectIterator && moObjectIterator->IsMore())
+ maPosition.mxObject = moObjectIterator->Next();
else
maPosition.mxObject = nullptr;
@@ -591,9 +591,9 @@ void ViewIteratorImpl::GotoNextText()
SetPage (maPosition.mnPageIndex-1);
if (mpPage != nullptr)
- mpObjectIterator.reset( new SdrObjListIter(mpPage, SdrIterMode::DeepNoGroups, !mbDirectionIsForward) );
- if (mpObjectIterator!=nullptr && mpObjectIterator->IsMore())
- maPosition.mxObject = mpObjectIterator->Next();
+ moObjectIterator.emplace( mpPage, SdrIterMode::DeepNoGroups, !mbDirectionIsForward );
+ if (moObjectIterator && moObjectIterator->IsMore())
+ maPosition.mxObject = moObjectIterator->Next();
else
maPosition.mxObject = nullptr;
}
@@ -643,13 +643,13 @@ void ViewIteratorImpl::SetPage (sal_Int32 nPageIndex)
// Set up object list iterator.
if (mpPage != nullptr)
- mpObjectIterator.reset( new SdrObjListIter(mpPage, SdrIterMode::DeepNoGroups, ! mbDirectionIsForward) );
+ moObjectIterator.emplace(mpPage, SdrIterMode::DeepNoGroups, ! mbDirectionIsForward);
else
- mpObjectIterator.reset();
+ moObjectIterator.reset();
// Get object pointer.
- if (mpObjectIterator!=nullptr && mpObjectIterator->IsMore())
- maPosition.mxObject = mpObjectIterator->Next();
+ if (moObjectIterator && moObjectIterator->IsMore())
+ maPosition.mxObject = moObjectIterator->Next();
else
maPosition.mxObject = nullptr;
@@ -669,19 +669,19 @@ void ViewIteratorImpl::Reverse()
// Create reversed object list iterator.
if (mpPage != nullptr)
- mpObjectIterator.reset( new SdrObjListIter(mpPage, SdrIterMode::DeepNoGroups, ! mbDirectionIsForward) );
+ moObjectIterator.emplace(mpPage, SdrIterMode::DeepNoGroups, ! mbDirectionIsForward);
else
- mpObjectIterator.reset();
+ moObjectIterator.reset();
// Move iterator to the current object.
::unotools::WeakReference<SdrObject> xObject = std::move(maPosition.mxObject);
maPosition.mxObject = nullptr;
- if (!mpObjectIterator)
+ if (!moObjectIterator)
return;
- while (mpObjectIterator->IsMore() && maPosition.mxObject.get() != xObject.get())
- maPosition.mxObject = mpObjectIterator->Next();
+ while (moObjectIterator->IsMore() && maPosition.mxObject.get() != xObject.get())
+ maPosition.mxObject = moObjectIterator->Next();
}
//===== DocumentIteratorImpl ============================================