basctl/source/dlged/propbrw.cxx | 8 +++--- editeng/source/misc/svxacorr.cxx | 2 - include/editeng/svxacorr.hxx | 9 +++---- linguistic/source/spelldsp.cxx | 18 +++++++------- linguistic/source/spelldsp.hxx | 5 ++- reportdesign/source/ui/report/propbrw.cxx | 8 +++--- sc/inc/ChartTools.hxx | 3 +- sc/source/ui/unoobj/ChartTools.cxx | 8 +++--- sd/inc/drawdoc.hxx | 9 +++---- sd/source/core/drawdoc.cxx | 4 +-- sd/source/ui/dlg/custsdlg.cxx | 2 - sd/source/ui/inc/OutlinerIteratorImpl.hxx | 6 ++-- sd/source/ui/view/OutlinerIterator.cxx | 38 +++++++++++++++--------------- svx/source/form/fmshimp.cxx | 8 +++--- sw/source/core/edit/autofmt.cxx | 8 +++--- sw/source/core/inc/txmsrt.hxx | 5 ++- sw/source/core/tox/txmsrt.cxx | 8 +++--- 17 files changed, 77 insertions(+), 72 deletions(-)
New commits: commit 5dc82f62d54fbd6299b4a1dc677e714e92f2f88c Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri May 12 22:07:54 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat May 13 14:56:06 2023 +0200 use more optional for CharClass Change-Id: I67984321b8f38928bfab9fb0b624620e7d286a11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151722 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 68743034e66b..6b759415b52b 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -359,7 +359,7 @@ SvxAutoCorrect::~SvxAutoCorrect() void SvxAutoCorrect::GetCharClass_( LanguageType eLang ) { - pCharClass.reset( new CharClass( LanguageTag( eLang)) ); + moCharClass.emplace( LanguageTag( eLang) ); eCharClassLang = eLang; } diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index b2eaeff9f9e3..b7372a431865 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -28,14 +28,15 @@ #include <tools/date.hxx> #include <editeng/swafopt.hxx> #include <editeng/editengdllapi.h> +#include <unotools/charclass.hxx> #include <optional> #include <map> #include <memory> +#include <optional> #include <string_view> #include <utility> -class CharClass; class SfxPoolItem; class SotStorage; class SvxAutoCorrect; @@ -255,7 +256,7 @@ class EDITENG_DLLPUBLIC SvxAutoCorrect // all languages in a table std::map<LanguageTag, SvxAutoCorrectLanguageLists> m_aLangTable; std::map<LanguageTag, sal_Int64> aLastFileTable; - std::unique_ptr<CharClass> pCharClass; + std::optional<CharClass> moCharClass; LanguageType eCharClassLang; @@ -440,9 +441,9 @@ public: CharClass& GetCharClass( LanguageType eLang ) { - if( !pCharClass || eLang != eCharClassLang ) + if( !moCharClass || eLang != eCharClassLang ) GetCharClass_( eLang ); - return *pCharClass; + return *moCharClass; } }; diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx index c1b309b00adf..92b2d4c3efbd 100644 --- a/linguistic/source/spelldsp.cxx +++ b/linguistic/source/spelldsp.cxx @@ -394,9 +394,9 @@ bool SpellCheckerDispatcher::isValid_Impl( bRes = !xTmp->isNegative(); } else { setCharClass(LanguageTag(nLanguage)); - CapType ct = capitalType(aChkWord, m_pCharClass.get()); + CapType ct = capitalType(aChkWord, m_oCharClass ? &*m_oCharClass : nullptr); if (ct == CapType::INITCAP || ct == CapType::ALLCAP) { - Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_pCharClass.get()), nLanguage ) ); + Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_oCharClass), nLanguage ) ); if (xTmp2.is()) { bRes = !xTmp2->isNegative(); } @@ -635,10 +635,10 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl( else { setCharClass(LanguageTag(nLanguage)); - CapType ct = capitalType(aChkWord, m_pCharClass.get()); + CapType ct = capitalType(aChkWord, m_oCharClass ? &*m_oCharClass : nullptr); if (ct == CapType::INITCAP || ct == CapType::ALLCAP) { - Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_pCharClass.get()), nLanguage ) ); + Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, m_oCharClass), nLanguage ) ); if (xTmp2.is()) { if (xTmp2->isNegative()) // negative entry found @@ -655,10 +655,10 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl( switch ( ct ) { case CapType::INITCAP: - aProposalList.Prepend( m_pCharClass->titlecase(aAddRplcTxt) ); + aProposalList.Prepend( m_oCharClass->titlecase(aAddRplcTxt) ); break; case CapType::ALLCAP: - aProposalList.Prepend( m_pCharClass->uppercase(aAddRplcTxt) ); + aProposalList.Prepend( m_oCharClass->uppercase(aAddRplcTxt) ); break; default: /* can't happen because of if ct == above */ @@ -813,13 +813,13 @@ void SpellCheckerDispatcher::FlushSpellCache() void SpellCheckerDispatcher::setCharClass(const LanguageTag& rLanguageTag) { - if (m_pCharClass && m_pCharClass->getLanguageTag() == rLanguageTag) + if (m_oCharClass && m_oCharClass->getLanguageTag() == rLanguageTag) return; - m_pCharClass.reset( new CharClass(rLanguageTag) ); + m_oCharClass.emplace( rLanguageTag ); } -OUString SpellCheckerDispatcher::makeLowerCase(const OUString& aTerm, CharClass const * pCC) +OUString SpellCheckerDispatcher::makeLowerCase(const OUString& aTerm, const std::optional<CharClass> & pCC) { if (pCC) return pCC->lowercase(aTerm); diff --git a/linguistic/source/spelldsp.hxx b/linguistic/source/spelldsp.hxx index c93560441333..73fe59579ff3 100644 --- a/linguistic/source/spelldsp.hxx +++ b/linguistic/source/spelldsp.hxx @@ -31,6 +31,7 @@ #include <map> #include <memory> +#include <optional> #include <unotools/charclass.hxx> class LngSvcMgr; @@ -53,7 +54,7 @@ class SpellCheckerDispatcher : LngSvcMgr &m_rMgr; mutable std::unique_ptr<linguistic::SpellCache> m_pCache; // Spell Cache (holds known words) - std::unique_ptr<CharClass> m_pCharClass; + std::optional<CharClass> m_oCharClass; SpellCheckerDispatcher(const SpellCheckerDispatcher &) = delete; SpellCheckerDispatcher & operator = (const SpellCheckerDispatcher &) = delete; @@ -105,7 +106,7 @@ public: private: void setCharClass(const LanguageTag& rLanguageTag); - static OUString makeLowerCase(const OUString&, CharClass const *); + static OUString makeLowerCase(const OUString&, const std::optional<CharClass> &); }; diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx index c0a01c548be0..50a5e2f09ca3 100644 --- a/sd/inc/drawdoc.hxx +++ b/sd/inc/drawdoc.hxx @@ -22,11 +22,13 @@ #include <com/sun/star/text/WritingMode.hpp> #include <svl/style.hxx> #include <svx/fmmodel.hxx> +#include <unotools/charclass.hxx> #include <vcl/prntypes.hxx> #include <xmloff/autolayout.hxx> #include <vector> #include <memory> +#include <optional> #include <string_view> #include "sddllapi.h" @@ -51,7 +53,6 @@ struct SpellCallbackInfo; class SdCustomShowList; class SdUndoGroup; class SdrObject; -class CharClass; class Idle; class ImageMap; class Outliner; @@ -162,8 +163,8 @@ private: ::sd::DrawDocShellRef mxAllocedDocShRef; // => AllocModel() bool mbAllocDocSh; // => AllocModel() DocumentType meDocType; - std::unique_ptr<CharClass> - mpCharClass; + std::optional<CharClass> + moCharClass; ::std::unique_ptr<ImpDrawPageListWatcher> mpDrawPageListWatcher; ::std::unique_ptr<ImpMasterPageListWatcher> mpMasterPageListWatcher; @@ -464,7 +465,7 @@ public: static SdAnimationInfo* GetShapeUserData(SdrObject& rObject, bool bCreate = false ); - SAL_DLLPRIVATE CharClass* GetCharClass() const { return mpCharClass.get(); } + SAL_DLLPRIVATE const std::optional<CharClass>& GetCharClass() const { return moCharClass; } SAL_DLLPRIVATE void UpdateAllLinks(); diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 89d5bdefa714..3adb91275784 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -199,7 +199,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) } LanguageType eRealLanguage = MsLangId::getRealLanguage( meLanguage ); - mpCharClass.reset(new CharClass( LanguageTag( eRealLanguage) )); + moCharClass.emplace(LanguageTag( eRealLanguage)); // If the current application language is a language that uses right-to-left text... LanguageType eRealCTLLanguage = Application::GetSettings().GetLanguageTag().getLanguageType(); @@ -367,7 +367,7 @@ SdDrawDocument::~SdDrawDocument() mpCustomShowList.reset(); mpOutliner.reset(); mpInternalOutliner.reset(); - mpCharClass.reset(); + moCharClass.reset(); } void SdDrawDocument::adaptSizeAndBorderForAllPages( diff --git a/sd/source/ui/dlg/custsdlg.cxx b/sd/source/ui/dlg/custsdlg.cxx index 1774b62d0211..6628a9ac9c8e 100644 --- a/sd/source/ui/dlg/custsdlg.cxx +++ b/sd/source/ui/dlg/custsdlg.cxx @@ -195,7 +195,7 @@ void SdCustomShowDlg::SelectHdl(void const *p) { // replace number by a number increased by 1 - const CharClass* pCharClass = rDoc.GetCharClass(); + const std::optional<CharClass>& pCharClass = rDoc.GetCharClass(); while( pCharClass->isDigit( aStr, nStrPos ) ) aStr = aStr.replaceAt( nStrPos, 1, u"" ); aStr = aStr.subView( 0, nStrPos) + OUString::number( ++nNum ) + aStr.subView( nStrPos); diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 74c3518a0a24..f8bcfebe9875 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -98,7 +98,7 @@ class SwAutoFormat SwTextFrame* m_pCurTextFrame; // frame of the current TextNode bool m_bIsRightToLeft; // text direction of the current frame SwNodeOffset m_nEndNdIdx; // for the percentage-display - mutable std::unique_ptr<CharClass> m_pCharClass; // Character classification + mutable std::optional<CharClass> m_oCharClass; // Character classification mutable LanguageType m_eCharClassLang; sal_uInt16 m_nRedlAutoFormatSeqId; @@ -121,12 +121,12 @@ class SwAutoFormat CharClass& GetCharClass( LanguageType eLang ) const { - if( !m_pCharClass || eLang != m_eCharClassLang ) + if( !m_oCharClass || eLang != m_eCharClassLang ) { - m_pCharClass.reset( new CharClass( LanguageTag( eLang ) ) ); + m_oCharClass.emplace( LanguageTag( eLang ) ); m_eCharClassLang = eLang; } - return *m_pCharClass; + return *m_oCharClass; } static bool IsSpace( const sal_Unicode c ) diff --git a/sw/source/core/inc/txmsrt.hxx b/sw/source/core/inc/txmsrt.hxx index 018457a06e94..324f88a90f23 100644 --- a/sw/source/core/inc/txmsrt.hxx +++ b/sw/source/core/inc/txmsrt.hxx @@ -20,13 +20,14 @@ #define INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX #include <i18nlangtag/lang.h> +#include <unotools/charclass.hxx> #include <nodeoffset.hxx> #include <tox.hxx> #include <com/sun/star/lang/Locale.hpp> +#include <optional> #include <utility> -class CharClass; class SwContentNode; class SwTextNode; class SwTextTOXMark; @@ -73,7 +74,7 @@ struct TextAndReading class SwTOXInternational { std::unique_ptr<IndexEntrySupplierWrapper> m_pIndexWrapper; - std::unique_ptr<CharClass> m_pCharClass; + std::optional<CharClass> m_oCharClass; LanguageType m_eLang; OUString m_sSortAlgorithm; SwTOIOptions m_nOptions; diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index de3ff3949912..4dcbd49fe70b 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -91,24 +91,24 @@ void SwTOXInternational::Init() else m_pIndexWrapper->LoadAlgorithm( aLcl, m_sSortAlgorithm, SW_COLLATOR_IGNORES ); - m_pCharClass.reset( new CharClass( LanguageTag( aLcl )) ); + m_oCharClass.emplace( LanguageTag( aLcl ) ); } SwTOXInternational::~SwTOXInternational() { - m_pCharClass.reset(); + m_oCharClass.reset(); m_pIndexWrapper.reset(); } OUString SwTOXInternational::ToUpper( const OUString& rStr, sal_Int32 nPos ) const { - return m_pCharClass->uppercase( rStr, nPos, 1 ); + return m_oCharClass->uppercase( rStr, nPos, 1 ); } bool SwTOXInternational::IsNumeric( const OUString& rStr ) const { - return m_pCharClass->isNumeric( rStr ); + return m_oCharClass->isNumeric( rStr ); } sal_Int32 SwTOXInternational::Compare( const TextAndReading& rTaR1, commit 3168d1ab07239789cd36a5960cef2d13ae29c9de Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Fri May 12 19:47:05 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat May 13 14:55:56 2023 +0200 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.gran...@collabora.co.uk> diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx index f95157d4f7d7..1bdc03811958 100644 --- a/basctl/source/dlged/propbrw.cxx +++ b/basctl/source/dlged/propbrw.cxx @@ -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; } } diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx index 41893a9a35ed..60e45e1fefc2 100644 --- a/reportdesign/source/ui/report/propbrw.cxx +++ b/reportdesign/source/ui/report/propbrw.cxx @@ -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()); diff --git a/sc/inc/ChartTools.hxx b/sc/inc/ChartTools.hxx index 4738c669390e..4f1accb1bbf8 100644 --- a/sc/inc/ChartTools.hxx +++ b/sc/inc/ChartTools.hxx @@ -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); diff --git a/sc/source/ui/unoobj/ChartTools.cxx b/sc/source/ui/unoobj/ChartTools.cxx index 6ce72bd9e792..e9fdc996a386 100644 --- a/sc/source/ui/unoobj/ChartTools.cxx +++ b/sc/source/ui/unoobj/ChartTools.cxx @@ -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; } 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 ============================================ diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 3b5d896cd0a0..8e7278f7e3fe 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -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; } } }