basctl/source/accessibility/accessibledialogwindow.cxx | 9 - basctl/source/dlged/dlged.cxx | 11 -- basctl/source/dlged/dlgedobj.cxx | 5 chart2/source/view/main/DrawModelWrapper.cxx | 14 -- filter/source/msfilter/msdffimp.cxx | 5 sc/source/core/data/drwlayer.cxx | 32 ++---- sc/source/filter/xml/xmlimprt.cxx | 10 - sc/source/ui/Accessibility/AccessibleDocument.cxx | 10 - sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx | 57 +++++------ sc/source/ui/drawfunc/drawsh.cxx | 5 sc/source/ui/unoobj/viewuno.cxx | 9 - sc/source/ui/view/drawview.cxx | 12 -- 12 files changed, 73 insertions(+), 106 deletions(-)
New commits: commit 358b480be5e3146ee8edead9aed5998f011925e2 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Oct 18 14:42:24 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Oct 19 09:06:06 2023 +0200 use more SdrObjList::begin/end in various Change-Id: If054626a10d3cbd3b168dd4e66ec7f08344d2c2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158131 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx index 9b17f3cf4caa..d5c702616d9f 100644 --- a/basctl/source/accessibility/accessibledialogwindow.cxx +++ b/basctl/source/accessibility/accessibledialogwindow.cxx @@ -85,11 +85,10 @@ AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWin return; SdrPage& rPage = m_pDialogWindow->GetPage(); - const size_t nCount = rPage.GetObjCount(); - for ( size_t i = 0; i < nCount; ++i ) + for (const rtl::Reference<SdrObject>& pObj : rPage) { - if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i))) + if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get())) { ChildDescriptor aDesc( pDlgEdObj ); if ( IsChildVisible( aDesc ) ) @@ -267,8 +266,8 @@ void AccessibleDialogWindow::UpdateChildren() if ( m_pDialogWindow ) { SdrPage& rPage = m_pDialogWindow->GetPage(); - for ( size_t i = 0, nCount = rPage.GetObjCount(); i < nCount; ++i ) - if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i))) + for (const rtl::Reference<SdrObject>& pObj : rPage) + if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get())) UpdateChild( ChildDescriptor( pDlgEdObj ) ); } } diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 1917e3ff4a56..873fb3792dd7 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -516,16 +516,13 @@ void DlgEditor::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle pDlgEdForm->StartListening(); // set position and size of controls - if (const size_t nObjCount = pDlgEdPage->GetObjCount()) + for (const rtl::Reference<SdrObject>& pObj : *pDlgEdPage) { - for (size_t i = 0 ; i < nObjCount ; ++i) + if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get())) { - if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pDlgEdPage->GetObj(i))) + if (!dynamic_cast<DlgEdForm*>(pDlgEdObj)) { - if (!dynamic_cast<DlgEdForm*>(pDlgEdObj)) - { - pDlgEdObj->SetRectFromProps(); - } + pDlgEdObj->SetRectFromProps(); } } } diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index 1f4421d5ca43..a3c2b396f791 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -1406,10 +1406,9 @@ void DlgEdForm::UpdateStep() if ( pSdrPage ) { - const size_t nObjCount = pSdrPage->GetObjCount(); - for ( size_t i = 0 ; i < nObjCount ; i++ ) + for (const rtl::Reference<SdrObject>& pObj : *pSdrPage) { - DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrPage->GetObj(i)); + DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get()); if (pDlgEdObj && !dynamic_cast<DlgEdForm*>(pDlgEdObj)) pDlgEdObj->UpdateStep(); } diff --git a/chart2/source/view/main/DrawModelWrapper.cxx b/chart2/source/view/main/DrawModelWrapper.cxx index 9b4a8b28a1ef..5593c9b59943 100644 --- a/chart2/source/view/main/DrawModelWrapper.cxx +++ b/chart2/source/view/main/DrawModelWrapper.cxx @@ -293,17 +293,13 @@ SdrObject* DrawModelWrapper::getNamedSdrObject( const OUString& rObjectCID, SdrO { if(!pSearchList || rObjectCID.isEmpty()) return nullptr; - const size_t nCount = pSearchList->GetObjCount(); - for( size_t nN=0; nN<nCount; ++nN ) + for (const rtl::Reference<SdrObject>& pObj : *pSearchList) { - SdrObject* pObj = pSearchList->GetObj(nN); - if(!pObj) - continue; if( ObjectIdentifier::areIdenticalObjects( rObjectCID, pObj->GetName() ) ) - return pObj; - pObj = DrawModelWrapper::getNamedSdrObject( rObjectCID, pObj->GetSubList() ); - if(pObj) - return pObj; + return pObj.get(); + SdrObject* pNamedObj = DrawModelWrapper::getNamedSdrObject( rObjectCID, pObj->GetSubList() ); + if(pNamedObj) + return pNamedObj; } return nullptr; } diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index e8164dacd6f0..058b61e1253d 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -5181,9 +5181,8 @@ void SvxMSDffManager::NotifyFreeObj(SvxMSDffClientData& rData, SdrObject* pObj) if (SdrObjGroup* pGroup = dynamic_cast<SdrObjGroup*>(pObj)) { SdrObjList* pSubList = pGroup->GetSubList(); - size_t nObjCount = pSubList->GetObjCount(); - for (size_t i = 0; i < nObjCount; ++i) - NotifyFreeObj(rData, pSubList->GetObj(i)); + for (const rtl::Reference<SdrObject>& pChildObj : *pSubList) + NotifyFreeObj(rData, pChildObj.get()); } rData.NotifyFreeObj(pObj); commit b1311dff66b83c6bb119cbb75231aa97f82fe994 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Oct 18 14:07:30 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Oct 19 09:05:56 2023 +0200 use more SdrObjList::begin/end in sc Change-Id: I6b8614e4e8917f71308cda4caaeb714ae18885f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158130 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index a909a9d11ad1..3f98fc770a6b 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -590,11 +590,9 @@ void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SC bool bNegativePage = pDoc && pDoc->IsNegativePage( nTab ); - const size_t nCount = pPage->GetObjCount(); - for ( size_t i = 0; i < nCount; ++i ) + for (const rtl::Reference<SdrObject>& pObj : *pPage) { - SdrObject* pObj = pPage->GetObj( i ); - ScDrawObjData* pData = GetObjDataTab( pObj, nTab ); + ScDrawObjData* pData = GetObjDataTab( pObj.get(), nTab ); if( pData ) { const ScAddress aOldStt = pData->maStart; @@ -614,11 +612,11 @@ void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SC } if (bChange) { - if ( dynamic_cast<const SdrRectObj*>( pObj) != nullptr && pData->maStart.IsValid() && pData->maEnd.IsValid() ) + if ( dynamic_cast<const SdrRectObj*>( pObj.get()) != nullptr && pData->maStart.IsValid() && pData->maEnd.IsValid() ) pData->maStart.PutInOrder( pData->maEnd ); // Update also an untransformed anchor that's what we stored ( and still do ) to xml - ScDrawObjData* pNoRotatedAnchor = GetNonRotatedObjData( pObj ); + ScDrawObjData* pNoRotatedAnchor = GetNonRotatedObjData( pObj.get() ); if ( pNoRotatedAnchor ) { const ScAddress aOldSttNoRotatedAnchor = pNoRotatedAnchor->maStart; @@ -635,8 +633,8 @@ void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SC } } - AddCalcUndo( std::make_unique<ScUndoObjData>( pObj, aOldStt, aOldEnd, pData->maStart, pData->maEnd ) ); - RecalcPos( pObj, *pData, bNegativePage, bUpdateNoteCaptionPos ); + AddCalcUndo( std::make_unique<ScUndoObjData>( pObj.get(), aOldStt, aOldEnd, pData->maStart, pData->maEnd ) ); + RecalcPos( pObj.get(), *pData, bNegativePage, bUpdateNoteCaptionPos ); } } } @@ -671,11 +669,9 @@ void ScDrawLayer::SetPageSize(sal_uInt16 nPageNo, const Size& rSize, bool bUpdat bool bWasLocked = isLocked(); setLock(true); - const size_t nCount = pPage->GetObjCount(); - for ( size_t i = 0; i < nCount; ++i ) + for (const rtl::Reference<SdrObject>& pObj : *pPage) { - SdrObject* pObj = pPage->GetObj( i ); - ScDrawObjData* pData = GetObjDataTab( pObj, static_cast<SCTAB>(nPageNo) ); + ScDrawObjData* pData = GetObjDataTab( pObj.get(), static_cast<SCTAB>(nPageNo) ); if( pData ) // cell anchored { if (pData->meType == ScDrawObjData::DrawingObject @@ -684,28 +680,28 @@ void ScDrawLayer::SetPageSize(sal_uInt16 nPageNo, const Size& rSize, bool bUpdat switch (eObjectHandling) { case ScObjectHandling::RecalcPosMode: - RecalcPos(pObj, *pData, bNegativePage, bUpdateNoteCaptionPos); + RecalcPos(pObj.get(), *pData, bNegativePage, bUpdateNoteCaptionPos); break; case ScObjectHandling::MoveRTLMode: - MoveRTL(pObj); + MoveRTL(pObj.get()); break; case ScObjectHandling::MirrorRTLMode: - MirrorRTL(pObj); + MirrorRTL(pObj.get()); break; } } else // DetectiveArrow and CellNote - RecalcPos(pObj, *pData, bNegativePage, bUpdateNoteCaptionPos); + RecalcPos(pObj.get(), *pData, bNegativePage, bUpdateNoteCaptionPos); } else // page anchored { switch (eObjectHandling) { case ScObjectHandling::MoveRTLMode: - MoveRTL(pObj); + MoveRTL(pObj.get()); break; case ScObjectHandling::MirrorRTLMode: - MirrorRTL(pObj); + MirrorRTL(pObj.get()); break; case ScObjectHandling::RecalcPosMode: // does not occur for page anchored shapes break; diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 78473c76b6a9..b440d5ca0392 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -1464,19 +1464,17 @@ void SAL_CALL ScXMLImport::endDocument() if (!pPage) continue; bool bNegativePage = pDoc->IsNegativePage(nTab); - const size_t nCount = pPage->GetObjCount(); - for (size_t i = 0; i < nCount; ++i) + for (const rtl::Reference<SdrObject>& pObj : *pPage) { - SdrObject* pObj = pPage->GetObj(i); ScDrawObjData* pData - = ScDrawLayer::GetObjDataTab(pObj, nTab); + = ScDrawLayer::GetObjDataTab(pObj.get(), nTab); // Existence of pData means, that it is a cell anchored object if (pData) { // Finish and correct import based on full size (no hidden row/col) and LTR - pDrawLayer->InitializeCellAnchoredObj(pObj, *pData); + pDrawLayer->InitializeCellAnchoredObj(pObj.get(), *pData); // Adapt object to hidden row/col and RTL - pDrawLayer->RecalcPos(pObj, *pData, bNegativePage, + pDrawLayer->RecalcPos(pObj.get(), *pData, bNegativePage, true /*bUpdateNoteCaptionPos*/); } } diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 5095dabd3097..3222cc289ed8 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -499,14 +499,10 @@ sal_Int32 ScChildrenShapes::GetCount() const { size_t nSdrObjCount = pDrawPage->GetObjCount(); maZOrderedShapes.reserve(nSdrObjCount + 1); // the table is always in - for (size_t i = 0; i < nSdrObjCount; ++i) + for (const rtl::Reference<SdrObject>& pObj : *pDrawPage) { - SdrObject* pObj = pDrawPage->GetObj(i); - if (pObj/* && (pObj->GetLayer() != SC_LAYER_INTERN)*/) - { - uno::Reference< drawing::XShape > xShape (pObj->getUnoShape(), uno::UNO_QUERY); - AddShape(xShape, false); //inserts in the correct order - } + uno::Reference< drawing::XShape > xShape (pObj->getUnoShape(), uno::UNO_QUERY); + AddShape(xShape, false); //inserts in the correct order } } return maZOrderedShapes.size(); diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx index 46dcdcfec8df..3161e2ba32b3 100644 --- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx @@ -1018,41 +1018,36 @@ void ScShapeChildren::FillShapes(const tools::Rectangle& aPixelPaintRect, const } ScIAccessibleViewForwarder aViewForwarder(mpViewShell, mpAccDoc, aMapMode); maShapeRanges[nRangeId].maViewForwarder = aViewForwarder; - const size_t nCount(pPage->GetObjCount()); - for (size_t i = 0; i < nCount; ++i) + for (const rtl::Reference<SdrObject>& pObj : *pPage) { - SdrObject* pObj = pPage->GetObj(i); - if (pObj) + uno::Reference< drawing::XShape > xShape(pObj->getUnoShape(), uno::UNO_QUERY); + if (xShape.is()) { - uno::Reference< drawing::XShape > xShape(pObj->getUnoShape(), uno::UNO_QUERY); - if (xShape.is()) + tools::Rectangle aRect(pWin->LogicToPixel( + tools::Rectangle(VCLPoint(xShape->getPosition()), VCLSize(xShape->getSize())), aMapMode)); + if(!aClippedPixelPaintRect.GetIntersection(aRect).IsEmpty()) { - tools::Rectangle aRect(pWin->LogicToPixel( - tools::Rectangle(VCLPoint(xShape->getPosition()), VCLSize(xShape->getSize())), aMapMode)); - if(!aClippedPixelPaintRect.GetIntersection(aRect).IsEmpty()) + ScShapeChild aShape; + aShape.mxShape = xShape; + aShape.mnRangeId = nRangeId; + if (pObj->GetLayer().anyOf(SC_LAYER_INTERN, SC_LAYER_FRONT)) { - ScShapeChild aShape; - aShape.mxShape = xShape; - aShape.mnRangeId = nRangeId; - if (pObj->GetLayer().anyOf(SC_LAYER_INTERN, SC_LAYER_FRONT)) - { - maShapeRanges[nRangeId].maForeShapes.push_back(std::move(aShape)); - bForeAdded = true; - } - else if (pObj->GetLayer() == SC_LAYER_BACK) - { - maShapeRanges[nRangeId].maBackShapes.push_back(std::move(aShape)); - bBackAdded = true; - } - else if (pObj->GetLayer() == SC_LAYER_CONTROLS) - { - maShapeRanges[nRangeId].maControls.push_back(std::move(aShape)); - bControlAdded = true; - } - else - { - OSL_FAIL("I don't know this layer."); - } + maShapeRanges[nRangeId].maForeShapes.push_back(std::move(aShape)); + bForeAdded = true; + } + else if (pObj->GetLayer() == SC_LAYER_BACK) + { + maShapeRanges[nRangeId].maBackShapes.push_back(std::move(aShape)); + bBackAdded = true; + } + else if (pObj->GetLayer() == SC_LAYER_CONTROLS) + { + maShapeRanges[nRangeId].maControls.push_back(std::move(aShape)); + bControlAdded = true; + } + else + { + OSL_FAIL("I don't know this layer."); } } } diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx index 2369ad0884c9..837cf4bc0222 100644 --- a/sc/source/ui/drawfunc/drawsh.cxx +++ b/sc/source/ui/drawfunc/drawsh.cxx @@ -458,10 +458,9 @@ void ScDrawShell::ExecuteMacroAssign(SdrObject* pObj, weld::Window* pWin) if ( pObj->IsGroupObject() ) { SdrObjList* pOL = pObj->GetSubList(); - const size_t nObj = pOL->GetObjCount(); - for ( size_t index=0; index<nObj; ++index ) + for (const rtl::Reference<SdrObject>& pChildObj : *pOL) { - pInfo = ScDrawLayer::GetMacroInfo( pOL->GetObj(index), true ); + pInfo = ScDrawLayer::GetMacroInfo( pChildObj.get(), true ); pInfo->SetMacro( sMacro ); } } diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index e139b4a59ec6..70f57dda89ca 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -1119,15 +1119,12 @@ uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rP double fHitLog = pActiveWin->PixelToLogic(Size(pDrawView->GetHitTolerancePixel(),0)).Width(); - const size_t nCount(pDrawPage->GetObjCount()); - bool bFound(false); - for (size_t i = 0; i < nCount && !bFound; ++i) + for (const rtl::Reference<SdrObject>& pObj : *pDrawPage) { - SdrObject* pObj = pDrawPage->GetObj(i); - if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, {fHitLog, fHitLog}, *pDrawView->GetSdrPageView(), nullptr, false)) + if (SdrObjectPrimitiveHit(*pObj, aPos, {fHitLog, fHitLog}, *pDrawView->GetSdrPageView(), nullptr, false)) { xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY); - bFound = true; + break; } } } diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 10dc7c990f3a..36e3777fed10 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -339,13 +339,9 @@ void ScDrawView::RecalcScale() if ( SdrPage* pPage = pPV->GetPage() ) { - const size_t nCount = pPage->GetObjCount(); - for ( size_t i = 0; i < nCount; ++i ) - { - SdrObject* pObj = pPage->GetObj( i ); + for (const rtl::Reference<SdrObject>& pObj : *pPage) // Align objects to nearest grid position - SyncForGrid( pObj ); - } + SyncForGrid( pObj.get() ); } } @@ -921,8 +917,8 @@ void ScDrawView::SyncForGrid( SdrObject* pObj ) if ( auto pObjGroup = dynamic_cast<const SdrObjGroup*>( pObj) ) { SdrObjList *pLst = pObjGroup->GetSubList(); - for ( size_t i = 0, nCount = pLst->GetObjCount(); i < nCount; ++i ) - SyncForGrid( pLst->GetObj( i ) ); + for (const rtl::Reference<SdrObject>& pChild : *pLst) + SyncForGrid( pChild.get() ); } ScSplitPos eWhich = pViewData->GetActivePart();