Kaydet (Commit) d7d9edb2 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in PolyPolygon

Also
- convert to o3tl::cow_wrapper
- drop the second param to the constructor and just
  let vector use it's own resize logic
- bump MAX_POLYGONS from 0x3FF0 to 0xffff so that the
  ios2met filter can load it's files properly.

Change-Id: I9db19e4f7b4f946e801ea07c31d2d0ded7837a0e
Reviewed-on: https://gerrit.libreoffice.org/47789Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst dacb12d2
......@@ -595,7 +595,7 @@ namespace emfio
if ( mpInputStream->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( nEndPos - mpInputStream->Tell() ) )
{
// Get polygon points
tools::PolyPolygon aPolyPoly(nPoly, nPoly);
tools::PolyPolygon aPolyPoly(nPoly);
for (sal_uInt32 i = 0; i < nPoly && mpInputStream->good(); ++i)
{
const sal_uInt16 nPointCount(aPoints[i]);
......
......@@ -393,7 +393,7 @@ namespace emfio
// Number of points of each polygon. Determine total number of points
std::unique_ptr<sal_uInt16[]> xPolygonPointCounts(new sal_uInt16[nPolyCount]);
sal_uInt16* pnPoints = xPolygonPointCounts.get();
tools::PolyPolygon aPolyPoly(nPolyCount, nPolyCount);
tools::PolyPolygon aPolyPoly(nPolyCount);
sal_uInt16 nPoints = 0;
for (sal_uInt16 a = 0; a < nPolyCount && mpInputStream->good(); ++a)
{
......
......@@ -60,7 +60,7 @@ enum class PolyFlags : sal_uInt8
class SvStream;
class ImplPolygon;
class ImplPolyPolygon;
struct ImplPolyPolygon;
namespace tools { class PolyPolygon; }
namespace basegfx
......@@ -189,7 +189,7 @@ public:
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC PolyPolygon
{
private:
ImplPolyPolygon* mpImplPolyPolygon;
o3tl::cow_wrapper<ImplPolyPolygon> mpImplPolyPolygon;
enum class PolyClipOp {
INTERSECT,
......@@ -198,7 +198,7 @@ private:
TOOLS_DLLPRIVATE void ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult, PolyClipOp nOperation ) const;
public:
PolyPolygon( sal_uInt16 nInitSize = 16, sal_uInt16 nResize = 16 );
PolyPolygon( sal_uInt16 nInitSize = 16 );
PolyPolygon( const tools::Polygon& rPoly );
PolyPolygon( const tools::PolyPolygon& rPolyPoly );
~PolyPolygon();
......
......@@ -235,7 +235,7 @@ void ContourWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
if (aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom())
{
tools::PolyPolygon _aPolyPoly(2, 2);
tools::PolyPolygon _aPolyPoly(2);
rTarget.Push(PushFlags::FILLCOLOR);
_aPolyPoly.Insert(tools::Rectangle(Point(), GetGraphicSize()));
_aPolyPoly.Insert(aWorkRect);
......
......@@ -53,27 +53,37 @@ public:
bool ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon const * pInitPoly = nullptr );
};
#define MAX_POLYGONS ((sal_uInt16)0x3FF0)
#define MAX_POLYGONS SAL_MAX_UINT16
namespace tools {
class Polygon;
}
class SAL_WARN_UNUSED ImplPolyPolygon
struct ImplPolyPolygon
{
public:
tools::Polygon** mpPolyAry;
sal_uInt32 mnRefCount;
sal_uInt16 mnCount;
sal_uInt16 mnSize;
sal_uInt16 mnResize;
std::vector<tools::Polygon> mvPolyAry;
ImplPolyPolygon( sal_uInt16 nInitSize )
{
if ( !nInitSize )
nInitSize = 1;
mvPolyAry.reserve(nInitSize);
}
ImplPolyPolygon( const tools::Polygon& rPoly )
{
if ( rPoly.GetSize() )
mvPolyAry.push_back(rPoly);
else
mvPolyAry.reserve(16);
}
ImplPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
ImplPolyPolygon( sal_uInt16 nInitSize, sal_uInt16 nResize )
{ mpPolyAry = nullptr; mnCount = 0; mnRefCount = 1;
mnSize = nInitSize; mnResize = nResize; }
ImplPolyPolygon( sal_uInt16 nInitSize );
ImplPolyPolygon( const ImplPolyPolygon& rImplPolyPoly );
~ImplPolyPolygon();
bool operator==(ImplPolyPolygon const & other) const
{
return mvPolyAry == other.mvPolyAry;
}
};
#endif
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment