diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-10-18 13:59:22 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-10-19 08:09:38 +0200 |
commit | f3e010829ab9d6b0b0ef48b67661774dd19f6de0 (patch) | |
tree | 4eb61dfc0c6cf4a2f9109b1f537d80f9cc928a80 /sd/source/ui | |
parent | 1c15934170341bbcfb4671fdbb01c2259265b3e1 (diff) |
use more SdrObjList::begin/end in sd
Change-Id: If39b6c561525bbf66d34edfbff0f1a3ef4531f85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158129
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/source/ui')
-rw-r--r-- | sd/source/ui/app/sdxfer.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/dlg/animobjs.cxx | 3 | ||||
-rw-r--r-- | sd/source/ui/docshell/docshel3.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/tools/GraphicSizeCheck.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/uitest/uiobject.cxx | 18 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unopage.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/DocumentRenderer.cxx | 16 | ||||
-rw-r--r-- | sd/source/ui/view/drawview.cxx | 16 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/view/outlview.cxx | 12 |
10 files changed, 33 insertions, 69 deletions
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx index 11fc9017f64d..74728dd0e64a 100644 --- a/sd/source/ui/app/sdxfer.cxx +++ b/sd/source/ui/app/sdxfer.cxx @@ -316,11 +316,8 @@ void SdTransferable::CreateData() Point aOrigin( maVisArea.TopLeft() ); Size aVector( -aOrigin.X(), -aOrigin.Y() ); - for( size_t nObj = 0, nObjCount = pPage->GetObjCount(); nObj < nObjCount; ++nObj ) - { - SdrObject* pObj = pPage->GetObj( nObj ); + for (const rtl::Reference<SdrObject>& pObj : *pPage) pObj->NbcMove( aVector ); - } } else maVisArea.SetSize( pPage->GetSize() ); diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx index 0174855e1825..1ab24e241c5a 100644 --- a/sd/source/ui/dlg/animobjs.cxx +++ b/sd/source/ui/dlg/animobjs.cxx @@ -759,9 +759,8 @@ void AnimationWindow::AddObj (::sd::View& rView ) // several objects SdrObjList* pObjList = static_cast<SdrObjGroup*>(pObject)->GetSubList(); - for( size_t nObject = 0; nObject < pObjList->GetObjCount(); ++nObject ) + for (const rtl::Reference<SdrObject>& pSnapShot : *pObjList) { - SdrObject* pSnapShot(pObjList->GetObj(nObject)); BitmapEx aBitmapEx(SdrExchangeView::GetObjGraphic(*pSnapShot).GetBitmapEx()); size_t nIndex = m_nCurrentFrame + 1; m_FrameList.insert( diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx index 19ae6796841c..f286cd3fc189 100644 --- a/sd/source/ui/docshell/docshel3.cxx +++ b/sd/source/ui/docshell/docshel3.cxx @@ -118,13 +118,9 @@ static void lcl_setLanguage( const SdDrawDocument *pDoc, std::u16string_view rLa for( sal_uInt16 nPage = 0; nPage < nPageCount; nPage++ ) { const SdrPage *pPage = pDoc->GetPage( nPage ); - const size_t nObjCount = pPage->GetObjCount(); - for( size_t nObj = 0; nObj < nObjCount; ++nObj ) - { - SdrObject *pObj = pPage->GetObj( nObj ); + for (const rtl::Reference<SdrObject>& pObj : *pPage) if (pObj->GetObjIdentifier() != SdrObjKind::Page) - lcl_setLanguageForObj( pObj, nLang, bLanguageNone ); - } + lcl_setLanguageForObj( pObj.get(), nLang, bLanguageNone ); } } diff --git a/sd/source/ui/tools/GraphicSizeCheck.cxx b/sd/source/ui/tools/GraphicSizeCheck.cxx index 492a2d70b23e..68bd33a3e194 100644 --- a/sd/source/ui/tools/GraphicSizeCheck.cxx +++ b/sd/source/ui/tools/GraphicSizeCheck.cxx @@ -62,15 +62,11 @@ public: SdrPage* pPage = m_pDocument->GetPage(nPage); if (pPage) { - for (size_t nObject = 0; nObject < pPage->GetObjCount(); ++nObject) + for (const rtl::Reference<SdrObject>& pObject : *pPage) { - SdrObject* pObject = pPage->GetObj(nObject); - if (pObject) + for (auto& pNodeHandler : m_pNodeHandler) { - for (auto& pNodeHandler : m_pNodeHandler) - { - pNodeHandler->handleSdrObject(pObject); - } + pNodeHandler->handleSdrObject(pObject.get()); } } } diff --git a/sd/source/ui/uitest/uiobject.cxx b/sd/source/ui/uitest/uiobject.cxx index 403aa8555ca1..00884fc90d6f 100644 --- a/sd/source/ui/uitest/uiobject.cxx +++ b/sd/source/ui/uitest/uiobject.cxx @@ -58,13 +58,9 @@ SdrObject* getObject(const VclPtr<sd::Window>& xWindow, std::u16string_view rNam if (!pPage) return nullptr; - size_t nObjs = pPage->GetObjCount(); - for (size_t i = 0; i < nObjs; ++i) - { - SdrObject* pObj = pPage->GetObj(i); - if (rName == getObjectName(pObj)) - return pObj; - } + for (const rtl::Reference<SdrObject>& pObj : *pPage) + if (rName == getObjectName(pObj.get())) + return pObj.get(); return nullptr; } @@ -162,12 +158,8 @@ std::set<OUString> ImpressWindowUIObject::get_children() const if (!pPage) return aRet; - size_t nObjs = pPage->GetObjCount(); - for (size_t i = 0; i < nObjs; ++i) - { - SdrObject* pObject = pPage->GetObj(i); - aRet.insert(getObjectName(pObject)); - } + for (const rtl::Reference<SdrObject>& pObject : *pPage) + aRet.insert(getObjectName(pObject.get())); return aRet; } diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index d39b0ea596b1..9abea2e5b801 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2595,10 +2595,8 @@ SdNavigationOrderAccess::SdNavigationOrderAccess( SdrPage const * pPage ) { if( pPage ) { - const size_t nCount = pPage->GetObjCount(); - for( size_t nIndex = 0; nIndex < nCount; ++nIndex ) + for (const rtl::Reference<SdrObject>& pObj : *pPage) { - SdrObject* pObj = pPage->GetObj( nIndex ); sal_uInt32 nNavPos = pObj->GetNavigationPosition(); DBG_ASSERT( !maShapes[nNavPos].is(), "sd::SdNavigationOrderAccess::SdNavigationOrderAccess(), duplicate navigation positions from core!" ); maShapes[nNavPos].set( pObj->getUnoShape(), UNO_QUERY ); diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index fb7cec583aff..8a797c066479 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -1634,15 +1634,15 @@ private: continue; SdrTextObj* pTextObj = nullptr; - size_t nObj (0); - while (pTextObj==nullptr && nObj < pPage->GetObjCount()) + for (const rtl::Reference<SdrObject>& pObj : *pPage) { - SdrObject* pObj = pPage->GetObj(nObj++); if (pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == SdrObjKind::TitleText) { - pTextObj = DynCastSdrTextObj(pObj); + pTextObj = DynCastSdrTextObj(pObj.get()); + if (pTextObj) + break; } } @@ -1658,15 +1658,15 @@ private: pOutliner->Insert(OUString()); pTextObj = nullptr; - nObj = 0; - while (pTextObj==nullptr && nObj<pPage->GetObjCount()) + for (const rtl::Reference<SdrObject>& pObj : *pPage) { - SdrObject* pObj = pPage->GetObj(nObj++); if (pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == SdrObjKind::OutlineText) { - pTextObj = DynCastSdrTextObj(pObj); + pTextObj = DynCastSdrTextObj(pObj.get()); + if (pTextObj) + break; } } diff --git a/sd/source/ui/view/drawview.cxx b/sd/source/ui/view/drawview.cxx index bd454bec194b..69555bb7419d 100644 --- a/sd/source/ui/view/drawview.cxx +++ b/sd/source/ui/view/drawview.cxx @@ -117,24 +117,16 @@ bool DrawView::SetAttributes(const SfxItemSet& rSet, SfxStyleSheetBasePool* pStShPool = mrDoc.GetStyleSheetPool(); SdPage& rPage = *mpDrawViewShell->getCurrentPage(); SdrPage& rMasterPage = rPage.TRG_GetMasterPage(); - size_t nObjCount = rMasterPage.GetObjCount(); - for (size_t nObj = 0; nObj < nObjCount; ++nObj) - { - SdrObject* pObject = rMasterPage.GetObj(nObj); - SetMasterAttributes(pObject, rPage, rSet, pStShPool, bOk, bMaster, bSlide); - } + for (const rtl::Reference<SdrObject>& pObject : rMasterPage) + SetMasterAttributes(pObject.get(), rPage, rSet, pStShPool, bOk, bMaster, bSlide); return bOk; } if (mpDrawViewShell && bSlide) { SfxStyleSheetBasePool* pStShPool = mrDoc.GetStyleSheetPool(); SdPage& rPage = *mpDrawViewShell->getCurrentPage(); - size_t nObjCount = rPage.GetObjCount(); - for (size_t nObj = 0; nObj < nObjCount; ++nObj) - { - SdrObject* pObject = rPage.GetObj(nObj); - SetMasterAttributes(pObject, rPage, rSet, pStShPool, bOk, bMaster, bSlide); - } + for (const rtl::Reference<SdrObject>& pObject : rPage) + SetMasterAttributes(pObject.get(), rPage, rSet, pStShPool, bOk, bMaster, bSlide); return bOk; } diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 4dc14204b53d..d7fefcecae72 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -338,10 +338,9 @@ public: for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex) { SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard); - for (size_t nObject = 0; nObject < pMasterPage->GetObjCount(); ++nObject) + for (const rtl::Reference<SdrObject>& pObject : *pMasterPage) { - SdrObject* pObject = pMasterPage->GetObj(nObject); - SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject); + SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject.get()); if (pRectObject && pRectObject->GetTextKind() == SdrObjKind::Text) { OutlinerParaObject* pOutlinerParagraphObject = pRectObject->GetOutlinerParaObject(); @@ -377,10 +376,9 @@ private: for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex) { SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard); - for (size_t nObject = 0; nObject < pMasterPage->GetObjCount(); ++nObject) + for (const rtl::Reference<SdrObject>& pObject : *pMasterPage) { - SdrObject* pObject = pMasterPage->GetObj(nObject); - SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject); + SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject.get()); if (pRectObject && pRectObject->GetTextKind() == SdrObjKind::Text) { OutlinerParaObject* pOutlinerParagraphObject = pRectObject->GetOutlinerParaObject(); diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index 8ce0a5dcb874..ab994e235813 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -857,16 +857,14 @@ IMPL_LINK( OutlineView, EndMovingHdl, ::Outliner *, pOutliner, void ) */ SdrTextObj* OutlineView::GetTitleTextObject(SdrPage const * pPage) { - const size_t nObjectCount = pPage->GetObjCount(); SdrTextObj* pResult = nullptr; - for (size_t nObject = 0; nObject < nObjectCount; ++nObject) + for (const rtl::Reference<SdrObject>& pObject : *pPage) { - SdrObject* pObject = pPage->GetObj(nObject); if (pObject->GetObjInventor() == SdrInventor::Default && pObject->GetObjIdentifier() == SdrObjKind::TitleText) { - pResult = static_cast<SdrTextObj*>(pObject); + pResult = static_cast<SdrTextObj*>(pObject.get()); break; } } @@ -878,16 +876,14 @@ SdrTextObj* OutlineView::GetTitleTextObject(SdrPage const * pPage) */ SdrTextObj* OutlineView::GetOutlineTextObject(SdrPage const * pPage) { - const size_t nObjectCount = pPage->GetObjCount(); SdrTextObj* pResult = nullptr; - for (size_t nObject = 0; nObject < nObjectCount; ++nObject) + for (const rtl::Reference<SdrObject>& pObject : *pPage) { - SdrObject* pObject = pPage->GetObj(nObject); if (pObject->GetObjInventor() == SdrInventor::Default && pObject->GetObjIdentifier() == SdrObjKind::OutlineText) { - pResult = static_cast<SdrTextObj*>(pObject); + pResult = static_cast<SdrTextObj*>(pObject.get()); break; } } |