diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2018-10-14 22:09:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-15 07:56:00 +0200 |
commit | 40bc840da261fcc5652e5278dc2566b61f990884 (patch) | |
tree | 7d472b8f69bfa7bf6b8c67585d74b6dee4f5bcc4 /svx | |
parent | 2da25cb43f4af8d094b01de1073eee2e2023c029 (diff) |
use range based loops over B2DPolyPolygon in svx
avoid copy when adapting polygon in SdrPathObj::ImpForceKind()
Change-Id: Ifd830ecd181563102ee269c6a609ef8ebeab670c
Reviewed-on: https://gerrit.libreoffice.org/61767
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/sdr/contact/viewcontactofe3dlathe.cxx | 6 | ||||
-rw-r--r-- | svx/source/sdr/contact/viewcontactofsdrpathobj.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/sdrpagewindow.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svddrgmt.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdopath.cxx | 29 | ||||
-rw-r--r-- | svx/source/svdraw/svdotextpathdecomposition.cxx | 4 | ||||
-rw-r--r-- | svx/source/xoutdev/_xpoly.cxx | 5 |
8 files changed, 25 insertions, 36 deletions
diff --git a/svx/source/sdr/contact/viewcontactofe3dlathe.cxx b/svx/source/sdr/contact/viewcontactofe3dlathe.cxx index d3bba8823edf..aee851a80bc6 100644 --- a/svx/source/sdr/contact/viewcontactofe3dlathe.cxx +++ b/svx/source/sdr/contact/viewcontactofe3dlathe.cxx @@ -56,13 +56,11 @@ namespace sdr // calculate texture size. Use the polygon length of the longest polygon for // height and the rotated radius for width (using polygon center) to get a good // texture mapping - const sal_uInt32 nPolygonCount(aPolyPolygon.count()); double fPolygonMaxLength(0.0); - for(sal_uInt32 a(0); a < nPolygonCount; a++) + for(auto const& rCandidate : aPolyPolygon) { - const basegfx::B2DPolygon aCandidate(aPolyPolygon.getB2DPolygon(a)); - const double fPolygonLength(basegfx::utils::getLength(aCandidate)); + const double fPolygonLength(basegfx::utils::getLength(rCandidate)); fPolygonMaxLength = std::max(fPolygonMaxLength, fPolygonLength); } diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx index 9cf85e52d530..9005b67a3fb4 100644 --- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx @@ -46,9 +46,9 @@ namespace sdr sal_uInt32 nPolyCount(rUnitPolyPolygon.count()); sal_uInt32 nPointCount(0); - for(sal_uInt32 a(0); a < nPolyCount; a++) + for(auto const& rPolygon : rUnitPolyPolygon) { - nPointCount += rUnitPolyPolygon.getB2DPolygon(a).count(); + nPointCount += rPolygon.count(); } if(!nPointCount) diff --git a/svx/source/svdraw/sdrpagewindow.cxx b/svx/source/svdraw/sdrpagewindow.cxx index 31ac45130533..c722fa883e49 100644 --- a/svx/source/svdraw/sdrpagewindow.cxx +++ b/svx/source/svdraw/sdrpagewindow.cxx @@ -280,13 +280,13 @@ namespace // poly b being closed. basegfx::B2DPolyPolygon aResult(basegfx::utils::clipPolyPolygonOnPolyPolygon(aPolyB, aPolyA)); - for(sal_uInt32 a(0); a < aResult.count(); a++) + for(auto const& rPolygon : aResult) { int nR = comphelper::rng::uniform_int_distribution(0, 254); int nG = comphelper::rng::uniform_int_distribution(0, 254); int nB = comphelper::rng::uniform_int_distribution(0, 254); Color aColor(nR, nG, nB); - impPaintStrokePolygon(aResult.getB2DPolygon(a), rOutDev, aColor); + impPaintStrokePolygon(rPolygon, rOutDev, aColor); } } } diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index 32a945f956bc..43f951527d8c 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -423,9 +423,9 @@ void SdrDragMethod::createSdrDragEntries_PolygonDrag() { const basegfx::B2DPolyPolygon aNewPolyPolygon(pM->GetMarkedSdrObj()->TakeXorPoly()); - for(sal_uInt32 b(0); b < aNewPolyPolygon.count(); b++) + for(auto const& rPolygon : aNewPolyPolygon) { - nPointCount += aNewPolyPolygon.getB2DPolygon(b).count(); + nPointCount += rPolygon.count(); } if(nPointCount > SdrDragView::GetDragXorPointLimit()) diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index f57376e7c3e9..fbbf0ff2d008 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -1788,15 +1788,14 @@ void SdrObject::PaintMacro(OutputDevice& rOut, const tools::Rectangle& , const S { const RasterOp eRop(rOut.GetRasterOp()); const basegfx::B2DPolyPolygon aPolyPolygon(TakeXorPoly()); - const sal_uInt32 nCount(aPolyPolygon.count()); rOut.SetLineColor(COL_BLACK); rOut.SetFillColor(); rOut.SetRasterOp(RasterOp::Invert); - for(sal_uInt32 a(0); a < nCount; a++) + for(auto const& rPolygon : aPolyPolygon) { - rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a)); + rOut.DrawPolyLine(rPolygon); } rOut.SetRasterOp(eRop); diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index 441a85e4ce73..20dd65125d2e 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -1751,25 +1751,21 @@ void SdrPathObj::ImpForceKind() // #i75974# adapt polygon state to object type. This may include a reinterpretation // of a closed geometry as open one, but with identical first and last point - for(sal_uInt32 a(0); a < maPathPolygon.count(); a++) + for(auto& rPolygon : maPathPolygon) { - basegfx::B2DPolygon aCandidate(maPathPolygon.getB2DPolygon(a)); - - if(IsClosed() != aCandidate.isClosed()) + if(IsClosed() != rPolygon.isClosed()) { // #i80213# really change polygon geometry; else e.g. the last point which // needs to be identical with the first one will be missing when opening // due to OBJ_PATH type - if(aCandidate.isClosed()) + if(rPolygon.isClosed()) { - basegfx::utils::openWithGeometryChange(aCandidate); + basegfx::utils::openWithGeometryChange(rPolygon); } else { - basegfx::utils::closeWithGeometryChange(aCandidate); + basegfx::utils::closeWithGeometryChange(rPolygon); } - - maPathPolygon.setB2DPolygon(a, aCandidate); } } } @@ -1900,11 +1896,10 @@ OUString SdrPathObj::TakeObjNameSingul() const { // get point count sal_uInt32 nPointCount(0); - const sal_uInt32 nPolyCount(GetPathPoly().count()); - for(sal_uInt32 a(0); a < nPolyCount; a++) + for(auto const& rPolygon : GetPathPoly()) { - nPointCount += GetPathPoly().getB2DPolygon(a).count(); + nPointCount += rPolygon.count(); } if(bClosed) @@ -1974,11 +1969,10 @@ basegfx::B2DPolyPolygon SdrPathObj::TakeXorPoly() const sal_uInt32 SdrPathObj::GetHdlCount() const { sal_uInt32 nRetval(0); - const sal_uInt32 nPolyCount(GetPathPoly().count()); - for(sal_uInt32 a(0); a < nPolyCount; a++) + for(auto const& rPolygon : GetPathPoly()) { - nRetval += GetPathPoly().getB2DPolygon(a).count(); + nRetval += rPolygon.count(); } return nRetval; @@ -2408,12 +2402,11 @@ bool SdrPathObj::IsPolyObj() const sal_uInt32 SdrPathObj::GetPointCount() const { - const sal_uInt32 nPolyCount(GetPathPoly().count()); sal_uInt32 nRetval(0); - for(sal_uInt32 a(0); a < nPolyCount; a++) + for(auto const& rPolygon : GetPathPoly()) { - nRetval += GetPathPoly().getB2DPolygon(a).count(); + nRetval += rPolygon.count(); } return nRetval; diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx index 45e01138f885..9346c9f86c58 100644 --- a/svx/source/svdraw/svdotextpathdecomposition.cxx +++ b/svx/source/svdraw/svdotextpathdecomposition.cxx @@ -573,12 +573,12 @@ namespace basegfx::B2DPolyPolygon aB2DPolyPolygon = *aPolygon; aB2DPolyPolygon.transform(rTransform); - for(sal_uInt32 a(0); a < aB2DPolyPolygon.count(); a++) + for(auto const& rPolygon : aB2DPolyPolygon) { // create one primitive per polygon drawinglayer::primitive2d::PolygonStrokePrimitive2D* pNew = new drawinglayer::primitive2d::PolygonStrokePrimitive2D( - aB2DPolyPolygon.getB2DPolygon(a), rLineAttribute, rStrokeAttribute); + rPolygon, rLineAttribute, rStrokeAttribute); rTarget.push_back(pNew); } } diff --git a/svx/source/xoutdev/_xpoly.cxx b/svx/source/xoutdev/_xpoly.cxx index 286d8c9ea834..74980ecdc994 100644 --- a/svx/source/xoutdev/_xpoly.cxx +++ b/svx/source/xoutdev/_xpoly.cxx @@ -855,10 +855,9 @@ XPolyPolygon::XPolyPolygon( XPolyPolygon&& ) = default; XPolyPolygon::XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon) : pImpXPolyPolygon() { - for(sal_uInt32 a(0); a < rPolyPolygon.count(); a++) + for(auto const& rCandidate : rPolyPolygon) { - const basegfx::B2DPolygon aCandidate = rPolyPolygon.getB2DPolygon(a); - Insert(XPolygon(aCandidate)); + Insert(XPolygon(rCandidate)); } } |