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>
This commit is contained in:
committed by
Noel Grandin
parent
5351b87898
commit
3168d1ab07
@@ -242,11 +242,11 @@ Sequence< Reference< XInterface > >
|
||||
{
|
||||
SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj();
|
||||
|
||||
std::unique_ptr<SdrObjListIter> pGroupIterator;
|
||||
std::optional<SdrObjListIter> oGroupIterator;
|
||||
if (pCurrent->IsGroupObject())
|
||||
{
|
||||
pGroupIterator.reset(new SdrObjListIter(pCurrent->GetSubList()));
|
||||
pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
|
||||
oGroupIterator.emplace(pCurrent->GetSubList());
|
||||
pCurrent = oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr;
|
||||
}
|
||||
|
||||
while (pCurrent)
|
||||
@@ -259,7 +259,7 @@ Sequence< Reference< XInterface > >
|
||||
}
|
||||
|
||||
// next element
|
||||
pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
|
||||
pCurrent = oGroupIterator && oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,11 +274,11 @@ uno::Sequence< Reference<uno::XInterface> > PropBrw::CreateCompPropSet(const Sdr
|
||||
{
|
||||
SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj();
|
||||
|
||||
::std::unique_ptr<SdrObjListIter> pGroupIterator;
|
||||
::std::optional<SdrObjListIter> oGroupIterator;
|
||||
if (pCurrent->IsGroupObject())
|
||||
{
|
||||
pGroupIterator.reset(new SdrObjListIter(pCurrent->GetSubList()));
|
||||
pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
|
||||
oGroupIterator.emplace(pCurrent->GetSubList());
|
||||
pCurrent = oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr;
|
||||
}
|
||||
|
||||
while (pCurrent)
|
||||
@@ -288,7 +288,7 @@ uno::Sequence< Reference<uno::XInterface> > PropBrw::CreateCompPropSet(const Sdr
|
||||
aSets.push_back(CreateComponentPair(pObj));
|
||||
|
||||
// next element
|
||||
pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
|
||||
pCurrent = oGroupIterator && oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr;
|
||||
}
|
||||
}
|
||||
return uno::Sequence< Reference<uno::XInterface> >(aSets.data(), aSets.size());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <svx/svditer.hxx>
|
||||
#include <tools/long.hxx>
|
||||
#include "types.hxx"
|
||||
#include <optional>
|
||||
|
||||
class ScDocShell;
|
||||
class SdrOle2Obj;
|
||||
@@ -32,7 +33,7 @@ enum class ChartSourceType
|
||||
class ChartIterator
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<SdrObjListIter> m_pIterator;
|
||||
std::optional<SdrObjListIter> m_oIterator;
|
||||
ChartSourceType m_eChartSourceType;
|
||||
public:
|
||||
ChartIterator(ScDocShell* pDocShell, SCTAB nTab, ChartSourceType eChartSourceType);
|
||||
|
||||
@@ -67,15 +67,15 @@ ChartIterator::ChartIterator(ScDocShell* pDocShell, SCTAB nTab, ChartSourceType
|
||||
SdrPage* pPage = pDrawLayer->GetPage(sal_uInt16(nTab));
|
||||
if (!pPage)
|
||||
return;
|
||||
m_pIterator.reset(new SdrObjListIter(pPage, SdrIterMode::DeepNoGroups));
|
||||
m_oIterator.emplace(pPage, SdrIterMode::DeepNoGroups);
|
||||
}
|
||||
|
||||
SdrOle2Obj* ChartIterator::next()
|
||||
{
|
||||
if (!m_pIterator)
|
||||
if (!m_oIterator)
|
||||
return nullptr;
|
||||
|
||||
SdrObject* pObject = m_pIterator->Next();
|
||||
SdrObject* pObject = m_oIterator->Next();
|
||||
while (pObject)
|
||||
{
|
||||
if (pObject->GetObjIdentifier() == SdrObjKind::OLE2 && ScDocument::IsChart(pObject))
|
||||
@@ -90,7 +90,7 @@ SdrOle2Obj* ChartIterator::next()
|
||||
else if (!xPivotTableDataProvider.is() && m_eChartSourceType == ChartSourceType::CELL_RANGE)
|
||||
return pOleObject;
|
||||
}
|
||||
pObject = m_pIterator->Next();
|
||||
pObject = m_oIterator->Next();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 ============================================
|
||||
|
||||
@@ -286,11 +286,11 @@ namespace
|
||||
{
|
||||
SdrObject* pCurrent = _rMarkList.GetMark( i )->GetMarkedSdrObj();
|
||||
|
||||
std::unique_ptr<SdrObjListIter> pGroupIterator;
|
||||
std::optional<SdrObjListIter> oGroupIterator;
|
||||
if ( pCurrent->IsGroupObject() )
|
||||
{
|
||||
pGroupIterator.reset(new SdrObjListIter( pCurrent->GetSubList() ));
|
||||
pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
|
||||
oGroupIterator.emplace( pCurrent->GetSubList() );
|
||||
pCurrent = oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr;
|
||||
}
|
||||
|
||||
while ( pCurrent )
|
||||
@@ -306,7 +306,7 @@ namespace
|
||||
}
|
||||
|
||||
// next element
|
||||
pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : nullptr;
|
||||
pCurrent = oGroupIterator && oGroupIterator->IsMore() ? oGroupIterator->Next() : nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user