diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-05 15:56:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-06 12:47:32 +0100 |
commit | f9c2bcc8b761f5e21354c0fb7bca6aa432d11ec2 (patch) | |
tree | a40dbc3e6d1b7476ad93cee29f19590103c4e756 /tools | |
parent | e1f479af4ddde90f9e80b5079ac759cb9f7743a1 (diff) |
simplify ImpXPolygon
just use a std::vector<std::pair<Point,PolyFlags>>
Change-Id: I85de832af9095a33bda1620781c3b231a345e07c
Reviewed-on: https://gerrit.libreoffice.org/49275
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/inc/poly.h | 1 | ||||
-rw-r--r-- | tools/source/generic/poly.cxx | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tools/inc/poly.h b/tools/inc/poly.h index 88da80ca1615..3c7b0c923465 100644 --- a/tools/inc/poly.h +++ b/tools/inc/poly.h @@ -35,6 +35,7 @@ public: ImplPolygon() : mnPoints(0) {} ImplPolygon( sal_uInt16 nInitSize, bool bFlags = false ); ImplPolygon( sal_uInt16 nPoints, const Point* pPtAry, const PolyFlags* pInitFlags ); + ImplPolygon( std::vector< std::pair<Point, PolyFlags> > const & ); ImplPolygon( const ImplPolygon& rImplPoly ); ImplPolygon( const tools::Rectangle& rRect ); ImplPolygon( const tools::Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound); diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 3c78b5a04bc8..b88c411a927b 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -100,6 +100,24 @@ ImplPolygon::ImplPolygon( sal_uInt16 nInitSize, const Point* pInitAry, const Pol mnPoints = nInitSize; } +ImplPolygon::ImplPolygon( std::vector< std::pair<Point, PolyFlags> > const & rPointsAndFlags ) +{ + auto nInitSize = rPointsAndFlags.size(); + if ( nInitSize ) + { + mxPointAry.reset(new Point[nInitSize]); + mxFlagAry.reset(new PolyFlags[nInitSize]); + int i = 0; + for (auto const & rPair : rPointsAndFlags) { + mxPointAry[i] = rPair.first; + mxFlagAry[i] = rPair.second; + ++i; + } + } + + mnPoints = nInitSize; +} + ImplPolygon::ImplPolygon( const tools::Rectangle& rRect ) { if ( !rRect.IsEmpty() ) @@ -868,6 +886,10 @@ Polygon::Polygon( sal_uInt16 nPoints, const Point* pPtAry, const PolyFlags* pFla { } +Polygon::Polygon( std::vector< std::pair<Point, PolyFlags> > const & rPointsAndFlags ) : mpImplPolygon(ImplPolygon(rPointsAndFlags)) +{ +} + Polygon::Polygon( const tools::Polygon& rPoly ) : mpImplPolygon(rPoly.mpImplPolygon) { } |