[Libreoffice-commits] core.git: 8 commits - chart2/source cppcanvas/source drawinglayer/source filter/source include/drawinglayer include/oox include/svx include/tools svx/inc svx/source tools/inc tools/source vcl/inc vcl/source
Matteo Casalin
matteo.casalin at yahoo.com
Thu Nov 5 11:33:49 PST 2015
chart2/source/inc/CommonConverters.hxx | 1
cppcanvas/source/mtfrenderer/textaction.hxx | 1
drawinglayer/source/primitive2d/textlayoutdevice.cxx | 1
filter/source/flash/swfwriter.hxx | 7 +
include/drawinglayer/primitive2d/textlayoutdevice.hxx | 2
include/oox/export/drawingml.hxx | 5 -
include/svx/sdggaitm.hxx | 2
include/tools/poly.hxx | 31 ++-----
svx/inc/svdibrow.hxx | 10 +-
svx/source/svdraw/svdibrow.cxx | 77 ++++++++----------
tools/inc/poly.h | 4
tools/source/generic/poly.cxx | 51 +++++------
tools/source/generic/poly2.cxx | 31 +++----
vcl/inc/openglgdiimpl.hxx | 7 +
vcl/inc/regband.hxx | 2
vcl/source/gdi/impvect.hxx | 3
vcl/source/gdi/region.cxx | 1
17 files changed, 114 insertions(+), 122 deletions(-)
New commits:
commit 13d927267535c0dca3139a50ebf8d5bcfc0df484
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Nov 5 18:58:49 2015 +0100
(Poly)Polygons: sal_uIntPtr to sal_uInt32/sdt::size_t/enum
Change-Id: I167d656f419ddbeb72960b8510fb8084605d4d5c
diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx
index 33cfb5d..0471a68 100644
--- a/include/tools/poly.hxx
+++ b/include/tools/poly.hxx
@@ -89,7 +89,7 @@ public:
const sal_uInt8* pFlagAry = NULL );
Polygon( const Rectangle& rRect );
Polygon( const Rectangle& rRect,
- sal_uIntPtr nHorzRound, sal_uIntPtr nVertRound );
+ sal_uInt32 nHorzRound, sal_uInt32 nVertRound );
Polygon( const Point& rCenter,
long nRadX, long nRadY,
sal_uInt16 nPoints = 0 );
@@ -190,7 +190,13 @@ class TOOLS_DLLPUBLIC SAL_WARN_UNUSED PolyPolygon
private:
ImplPolyPolygon* mpImplPolyPolygon;
- TOOLS_DLLPRIVATE void ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult, sal_uIntPtr nOperation ) const;
+ enum class PolyClipOp {
+ INTERSECT,
+ UNION,
+ DIFF,
+ XOR
+ };
+ TOOLS_DLLPRIVATE void ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult, PolyClipOp nOperation ) const;
public:
PolyPolygon( sal_uInt16 nInitSize = 16, sal_uInt16 nResize = 16 );
diff --git a/tools/inc/poly.h b/tools/inc/poly.h
index 7805873..f15f01f 100644
--- a/tools/inc/poly.h
+++ b/tools/inc/poly.h
@@ -29,7 +29,7 @@ public:
Point* mpPointAry;
sal_uInt8* mpFlagAry;
sal_uInt16 mnPoints;
- sal_uIntPtr mnRefCount;
+ sal_uInt32 mnRefCount;
};
class SAL_WARN_UNUSED ImplPolygon : public ImplPolygonData
@@ -55,7 +55,7 @@ class SAL_WARN_UNUSED ImplPolyPolygon
{
public:
tools::Polygon** mpPolyAry;
- sal_uIntPtr mnRefCount;
+ sal_uInt32 mnRefCount;
sal_uInt16 mnCount;
sal_uInt16 mnSize;
sal_uInt16 mnResize;
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 539178c..0788894 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -62,8 +62,9 @@ ImplPolygon::ImplPolygon( sal_uInt16 nInitSize, bool bFlags )
{
if ( nInitSize )
{
- mpPointAry = reinterpret_cast<Point*>(new char[(sal_uIntPtr)nInitSize*sizeof(Point)]);
- memset( mpPointAry, 0, (sal_uIntPtr)nInitSize*sizeof(Point) );
+ const std::size_t nSz(static_cast<std::size_t>(nInitSize)*sizeof(Point));
+ mpPointAry = reinterpret_cast<Point*>(new char[nSz]);
+ memset( mpPointAry, 0, nSz );
}
else
mpPointAry = NULL;
@@ -84,8 +85,9 @@ ImplPolygon::ImplPolygon( const ImplPolygon& rImpPoly )
{
if ( rImpPoly.mnPoints )
{
- mpPointAry = reinterpret_cast<Point*>(new char[(sal_uIntPtr)rImpPoly.mnPoints*sizeof(Point)]);
- memcpy( mpPointAry, rImpPoly.mpPointAry, (sal_uIntPtr)rImpPoly.mnPoints*sizeof(Point) );
+ const std::size_t nSz(static_cast<std::size_t>(rImpPoly.mnPoints)*sizeof(Point));
+ mpPointAry = reinterpret_cast<Point*>(new char[nSz]);
+ memcpy( mpPointAry, rImpPoly.mpPointAry, nSz );
if( rImpPoly.mpFlagAry )
{
@@ -109,8 +111,9 @@ ImplPolygon::ImplPolygon( sal_uInt16 nInitSize, const Point* pInitAry, const sal
{
if ( nInitSize )
{
- mpPointAry = reinterpret_cast<Point*>(new char[(sal_uIntPtr)nInitSize*sizeof(Point)]);
- memcpy( mpPointAry, pInitAry, (sal_uIntPtr)nInitSize*sizeof( Point ) );
+ const std::size_t nSz(static_cast<std::size_t>(nInitSize)*sizeof(Point));
+ mpPointAry = reinterpret_cast<Point*>(new char[nSz]);
+ memcpy( mpPointAry, pInitAry, nSz );
if( pInitFlags )
{
@@ -150,7 +153,8 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize )
if ( nNewSize )
{
- pNewAry = reinterpret_cast<Point*>(new char[(sal_uIntPtr)nNewSize*sizeof(Point)]);
+ const std::size_t nNewSz(static_cast<std::size_t>(nNewSize)*sizeof(Point));
+ pNewAry = reinterpret_cast<Point*>(new char[nNewSz]);
if ( bResize )
{
@@ -158,14 +162,15 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize )
if ( mnPoints < nNewSize )
{
// New points initialized to zero
- memset( pNewAry+mnPoints, 0, (sal_uIntPtr)(nNewSize-mnPoints)*sizeof(Point) );
+ const std::size_t nOldSz(static_cast<std::size_t>(mnPoints)*sizeof(Point));
+ memset( pNewAry+mnPoints, 0, nNewSz-nOldSz );
if ( mpPointAry )
- memcpy( pNewAry, mpPointAry, mnPoints*sizeof(Point) );
+ memcpy( pNewAry, mpPointAry, nOldSz );
}
else
{
if ( mpPointAry )
- memcpy( pNewAry, mpPointAry, (sal_uIntPtr)nNewSize*sizeof(Point) );
+ memcpy( pNewAry, mpPointAry, nNewSz );
}
}
}
@@ -210,13 +215,12 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize )
void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pInitPoly )
{
- const sal_uIntPtr nSpaceSize = nSpace * sizeof( Point );
-
//Can't fit this in :-(, throw ?
if (mnPoints + nSpace > USHRT_MAX)
return;
const sal_uInt16 nNewSize = mnPoints + nSpace;
+ const std::size_t nSpaceSize = static_cast<std::size_t>(nSpace) * sizeof(Point);
if( nPos >= mnPoints )
{
@@ -237,7 +241,7 @@ void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pI
const sal_uInt16 nSecPos = nPos + nSpace;
const sal_uInt16 nRest = mnPoints - nPos;
- Point* pNewAry = reinterpret_cast<Point*>(new char[ (sal_uIntPtr) nNewSize * sizeof( Point ) ]);
+ Point* pNewAry = reinterpret_cast<Point*>(new char[ static_cast<std::size_t>(nNewSize) * sizeof(Point) ]);
memcpy( pNewAry, mpPointAry, nPos * sizeof( Point ) );
@@ -542,7 +546,7 @@ Polygon::Polygon( sal_uInt16 nPoints, const Point* pPtAry, const sal_uInt8* pFla
Polygon::Polygon( const tools::Polygon& rPoly )
{
- DBG_ASSERT( rPoly.mpImplPolygon->mnRefCount < 0xFFFFFFFE, "Polygon: RefCount overflow" );
+ DBG_ASSERT( rPoly.mpImplPolygon->mnRefCount < (SAL_MAX_UINT32-1), "Polygon: RefCount overflow" );
mpImplPolygon = rPoly.mpImplPolygon;
if ( mpImplPolygon->mnRefCount )
@@ -565,7 +569,7 @@ Polygon::Polygon( const Rectangle& rRect )
}
}
-Polygon::Polygon( const Rectangle& rRect, sal_uIntPtr nHorzRound, sal_uIntPtr nVertRound )
+Polygon::Polygon( const Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVertRound )
{
if ( rRect.IsEmpty() )
mpImplPolygon = static_cast<ImplPolygon*>(&aStaticImplPolygon);
@@ -574,8 +578,8 @@ Polygon::Polygon( const Rectangle& rRect, sal_uIntPtr nHorzRound, sal_uIntPtr nV
Rectangle aRect( rRect );
aRect.Justify(); // SJ: i9140
- nHorzRound = std::min( nHorzRound, (sal_uIntPtr) labs( aRect.GetWidth() >> 1 ) );
- nVertRound = std::min( nVertRound, (sal_uIntPtr) labs( aRect.GetHeight() >> 1 ) );
+ nHorzRound = std::min( nHorzRound, static_cast<sal_uInt32>(labs( aRect.GetWidth() >> 1 )) );
+ nVertRound = std::min( nVertRound, static_cast<sal_uInt32>(labs( aRect.GetHeight() >> 1 )) );
if( !nHorzRound && !nVertRound )
{
@@ -925,7 +929,7 @@ void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
{
tools::Polygon aNewPoly;
const Point& rFirst = mpImplPolygon->mpPointAry[ 0 ];
- const sal_uIntPtr nReduce = ( nOptimizeFlags & PolyOptimizeFlags::REDUCE ) ? 4 : 0;
+ const long nReduce = ( nOptimizeFlags & PolyOptimizeFlags::REDUCE ) ? 4 : 0;
while( nSize && ( mpImplPolygon->mpPointAry[ nSize - 1 ] == rFirst ) )
nSize--;
@@ -940,7 +944,7 @@ void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
for( sal_uInt16 i = 1; i < nSize; i++ )
{
if( ( mpImplPolygon->mpPointAry[ i ] != mpImplPolygon->mpPointAry[ nLast ] ) &&
- ( !nReduce || ( nReduce < (sal_uIntPtr) FRound( CalcDistance( nLast, i ) ) ) ) )
+ ( !nReduce || ( nReduce < FRound( CalcDistance( nLast, i ) ) ) ) )
{
aNewPoly[ nNewCount++ ] = mpImplPolygon->mpPointAry[ nLast = i ];
}
diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx
index 7622c6f..eddce4d 100644
--- a/tools/source/generic/poly2.cxx
+++ b/tools/source/generic/poly2.cxx
@@ -17,11 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#define POLY_CLIP_INT 0
-#define POLY_CLIP_UNION 1
-#define POLY_CLIP_DIFF 2
-#define POLY_CLIP_XOR 3
-
#include <rtl/math.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
@@ -99,7 +94,7 @@ PolyPolygon::PolyPolygon( const tools::Polygon& rPoly )
PolyPolygon::PolyPolygon( const tools::PolyPolygon& rPolyPoly )
{
- DBG_ASSERT( rPolyPoly.mpImplPolyPolygon->mnRefCount < 0xFFFFFFFE, "PolyPolygon: RefCount overflow" );
+ DBG_ASSERT( rPolyPoly.mpImplPolyPolygon->mnRefCount < (SAL_MAX_UINT32-1), "PolyPolygon: RefCount overflow" );
mpImplPolyPolygon = rPolyPoly.mpImplPolyPolygon;
mpImplPolyPolygon->mnRefCount++;
@@ -312,15 +307,15 @@ tools::PolyPolygon PolyPolygon::SubdivideBezier( const tools::PolyPolygon& rPoly
void PolyPolygon::GetIntersection( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult ) const
{
- ImplDoOperation( rPolyPoly, rResult, POLY_CLIP_INT );
+ ImplDoOperation( rPolyPoly, rResult, PolyClipOp::INTERSECT );
}
void PolyPolygon::GetUnion( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult ) const
{
- ImplDoOperation( rPolyPoly, rResult, POLY_CLIP_UNION );
+ ImplDoOperation( rPolyPoly, rResult, PolyClipOp::UNION );
}
-void PolyPolygon::ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult, sal_uIntPtr nOperation ) const
+void PolyPolygon::ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::PolyPolygon& rResult, PolyClipOp nOperation ) const
{
// Convert to B2DPolyPolygon, temporarily. It might be
// advantageous in the future, to have a tools::PolyPolygon adaptor that
@@ -337,21 +332,21 @@ void PolyPolygon::ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::P
{
// All code extracted from svx/source/svdraw/svedtv2.cxx
- case POLY_CLIP_UNION:
+ case PolyClipOp::UNION:
{
// merge A and B (OR)
aMergePolyPolygonA = basegfx::tools::solvePolygonOperationOr(aMergePolyPolygonA, aMergePolyPolygonB);
break;
}
- case POLY_CLIP_DIFF:
+ case PolyClipOp::DIFF:
{
// subtract B from A (DIFF)
aMergePolyPolygonA = basegfx::tools::solvePolygonOperationDiff(aMergePolyPolygonA, aMergePolyPolygonB);
break;
}
- case POLY_CLIP_XOR:
+ case PolyClipOp::XOR:
{
// compute XOR between poly A and B
aMergePolyPolygonA = basegfx::tools::solvePolygonOperationXor(aMergePolyPolygonA, aMergePolyPolygonB);
@@ -359,7 +354,7 @@ void PolyPolygon::ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::P
}
default:
- case POLY_CLIP_INT:
+ case PolyClipOp::INTERSECT:
{
// cut poly 1 against polys 2..n (AND)
aMergePolyPolygonA = basegfx::tools::solvePolygonOperationAnd(aMergePolyPolygonA, aMergePolyPolygonB);
@@ -528,7 +523,7 @@ PolyPolygon& PolyPolygon::operator=( const tools::PolyPolygon& rPolyPoly )
if (this == &rPolyPoly)
return *this;
- DBG_ASSERT( rPolyPoly.mpImplPolyPolygon->mnRefCount < 0xFFFFFFFE, "PolyPolygon: RefCount overflow" );
+ DBG_ASSERT( rPolyPoly.mpImplPolyPolygon->mnRefCount < (SAL_MAX_UINT32-1), "PolyPolygon: RefCount overflow" );
rPolyPoly.mpImplPolyPolygon->mnRefCount++;
commit 48a3359070db7ffbf25b5e4c0cf1840a4673ca3c
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Nov 5 11:41:37 2015 +0100
Reduce scope of #include <tools/poly.hxx>
Change-Id: I0d64393c029d27c8e6f3b6d360d2509dad16d860
diff --git a/chart2/source/inc/CommonConverters.hxx b/chart2/source/inc/CommonConverters.hxx
index 7c779c9..7b42b7f 100644
--- a/chart2/source/inc/CommonConverters.hxx
+++ b/chart2/source/inc/CommonConverters.hxx
@@ -19,7 +19,6 @@
#ifndef INCLUDED_CHART2_SOURCE_INC_COMMONCONVERTERS_HXX
#define INCLUDED_CHART2_SOURCE_INC_COMMONCONVERTERS_HXX
-#include <tools/poly.hxx>
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/awt/Size.hpp>
diff --git a/cppcanvas/source/mtfrenderer/textaction.hxx b/cppcanvas/source/mtfrenderer/textaction.hxx
index 8c1270e..79260b1 100644
--- a/cppcanvas/source/mtfrenderer/textaction.hxx
+++ b/cppcanvas/source/mtfrenderer/textaction.hxx
@@ -25,7 +25,6 @@
#include <action.hxx>
#include <cppcanvas/canvas.hxx>
#include <cppcanvas/renderer.hxx>
-#include <tools/poly.hxx>
class VirtualDevice;
class Point;
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index 4ba2fde..700d724 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -24,6 +24,7 @@
#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/unique_disposing_ptr.hxx>
+#include <tools/gen.hxx>
#include <vcl/timer.hxx>
#include <vcl/virdev.hxx>
#include <vcl/font.hxx>
diff --git a/filter/source/flash/swfwriter.hxx b/filter/source/flash/swfwriter.hxx
index b649035..2ef8ba2 100644
--- a/filter/source/flash/swfwriter.hxx
+++ b/filter/source/flash/swfwriter.hxx
@@ -29,7 +29,6 @@
#include <vcl/vclptr.hxx>
#include <unotools/tempfile.hxx>
#include <tools/color.hxx>
-#include <tools/poly.hxx>
#include <tools/gen.hxx>
#include <tools/stream.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
@@ -41,12 +40,16 @@
class GDIMetaFile;
class BitmapEx;
-namespace tools { class PolyPolygon; }
class Gradient;
class SvtGraphicFill;
class SvtGraphicStroke;
class LineInfo;
namespace basegfx { class B2DPolygon; }
+namespace tools
+{
+ class Polygon;
+ class PolyPolygon;
+}
inline sal_uInt16 _uInt16( sal_Int32 nValue )
{
diff --git a/include/drawinglayer/primitive2d/textlayoutdevice.hxx b/include/drawinglayer/primitive2d/textlayoutdevice.hxx
index 720a273..e606f09 100644
--- a/include/drawinglayer/primitive2d/textlayoutdevice.hxx
+++ b/include/drawinglayer/primitive2d/textlayoutdevice.hxx
@@ -22,7 +22,6 @@
#include <drawinglayer/drawinglayerdllapi.h>
-#include <tools/poly.hxx>
#include <basegfx/range/b2drange.hxx>
#include <vector>
#include <com/sun/star/lang/Locale.hpp>
@@ -36,6 +35,7 @@ namespace rtl {
};
class OutputDevice;
class GDIMetaFile;
+class Rectangle;
enum class DrawTextFlags;
namespace drawinglayer { namespace attribute {
class FontAttribute;
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index b7eafa3..a58f4f7 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -26,7 +26,6 @@
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/uno/XReference.hpp>
-#include <tools/poly.hxx>
#include <filter/msfilter/escherex.hxx>
#include "oox/drawingml/drawingmltypes.hxx"
#include <oox/token/tokens.hxx>
@@ -60,6 +59,10 @@ namespace io {
class OutlinerParaObject;
+namespace tools {
+ class PolyPolygon;
+}
+
namespace oox {
namespace core {
class XmlFilterBase;
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 6e82b87..917cf01 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -29,7 +29,6 @@
#include "opengl/texture.hxx"
#include "regionband.hxx"
-#include <tools/poly.hxx>
#include <vcl/opengl/OpenGLContext.hxx>
class SalFrame;
@@ -41,6 +40,12 @@ namespace basegfx
class B2DTrapezoid;
};
+namespace tools
+{
+ class Polygon;
+ class PolyPolygon;
+}
+
struct TextureCombo
{
std::unique_ptr<OpenGLTexture> mpTexture;
diff --git a/vcl/inc/regband.hxx b/vcl/inc/regband.hxx
index 6908882..205626a 100644
--- a/vcl/inc/regband.hxx
+++ b/vcl/inc/regband.hxx
@@ -20,7 +20,7 @@
#ifndef INCLUDED_VCL_INC_REGBAND_HXX
#define INCLUDED_VCL_INC_REGBAND_HXX
-#include <tools/poly.hxx>
+#include <sal/types.h>
/*
diff --git a/vcl/source/gdi/impvect.hxx b/vcl/source/gdi/impvect.hxx
index 235b6f5..7ad02ea 100644
--- a/vcl/source/gdi/impvect.hxx
+++ b/vcl/source/gdi/impvect.hxx
@@ -20,9 +20,10 @@
#ifndef INCLUDED_VCL_SOURCE_GDI_IMPVECT_HXX
#define INCLUDED_VCL_SOURCE_GDI_IMPVECT_HXX
-#include <tools/poly.hxx>
#include <vcl/gdimtf.hxx>
+namespace tools { class PolyPolygon; }
+
// - Vectorizer -
namespace ImplVectorizer
{
diff --git a/vcl/source/gdi/region.cxx b/vcl/source/gdi/region.cxx
index 4dc3c04..243c530 100644
--- a/vcl/source/gdi/region.cxx
+++ b/vcl/source/gdi/region.cxx
@@ -32,6 +32,7 @@
#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <tools/poly.hxx>
namespace
{
commit e35ef2502974c74f85c89a9dbc93b1137defcf48
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Thu Nov 5 10:32:19 2015 +0100
class PolyOptimizeData is never instantiated
Change-Id: I136b3b1d572e4401d89d50f543150d71dbe44d16
diff --git a/include/tools/poly.hxx b/include/tools/poly.hxx
index 99481a7..33cfb5d 100644
--- a/include/tools/poly.hxx
+++ b/include/tools/poly.hxx
@@ -57,23 +57,6 @@ enum PolyFlags
POLY_SYMMTR
};
-class SAL_WARN_UNUSED PolyOptimizeData
-{
-private:
-
- enum DataType { DATA_NONE = 0, DATA_ABSOLUT = 1, DATA_PERCENT = 2 };
- DataType eType;
- union { sal_uIntPtr mnAbsolut; sal_uInt16 mnPercent; };
-
-public:
- PolyOptimizeData() : eType( DATA_NONE ) {}
- PolyOptimizeData( sal_uIntPtr nAbsolut ) : eType( DATA_ABSOLUT ), mnAbsolut( nAbsolut ) {}
- PolyOptimizeData( sal_uInt16 nPercent ) : eType( DATA_PERCENT ), mnPercent( nPercent ) {}
-
- sal_uIntPtr GetAbsValue() const { (void) eType; DBG_ASSERT( eType == DATA_ABSOLUT, "Wrong data type" ); return mnAbsolut; }
- sal_uInt16 GetPercentValue() const { (void) eType; DBG_ASSERT( eType == DATA_PERCENT, "Wrong data type" ); return mnPercent; }
-};
-
class SvStream;
class ImplPolygon;
class ImplPolyPolygon;
@@ -141,7 +124,7 @@ public:
bool IsRightOrientated() const;
double CalcDistance( sal_uInt16 nPt1, sal_uInt16 nPt2 );
void Clip( const Rectangle& rRect, bool bPolygon = true );
- void Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData* pData = NULL );
+ void Optimize( PolyOptimizeFlags nOptimizeFlags );
/** Adaptive subdivision of polygons with curves
@@ -227,7 +210,7 @@ public:
sal_uInt16 Count() const;
Rectangle GetBoundRect() const;
void Clip( const Rectangle& rRect );
- void Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData* pData = NULL );
+ void Optimize( PolyOptimizeFlags nOptimizeFlags );
/** Adaptive subdivision of polygons with curves
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index f53dbf1..539178c 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -904,7 +904,7 @@ double Polygon::CalcDistance( sal_uInt16 nP1, sal_uInt16 nP2 )
return sqrt( fDx * fDx + fDy * fDy );
}
-void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData* pData )
+void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
{
DBG_ASSERT( !mpImplPolygon->mpFlagAry, "Optimizing could fail with beziers!" );
@@ -916,7 +916,7 @@ void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData
{
const Rectangle aBound( GetBoundRect() );
const double fArea = ( aBound.GetWidth() + aBound.GetHeight() ) * 0.5;
- const sal_uInt16 nPercent = pData ? pData->GetPercentValue() : 50;
+ const sal_uInt16 nPercent = 50;
Optimize( PolyOptimizeFlags::NO_SAME );
ImplReduceEdges( *this, fArea, nPercent );
@@ -925,12 +925,7 @@ void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData
{
tools::Polygon aNewPoly;
const Point& rFirst = mpImplPolygon->mpPointAry[ 0 ];
- sal_uIntPtr nReduce;
-
- if( nOptimizeFlags & ( PolyOptimizeFlags::REDUCE ) )
- nReduce = pData ? pData->GetAbsValue() : 4UL;
- else
- nReduce = 0UL;
+ const sal_uIntPtr nReduce = ( nOptimizeFlags & PolyOptimizeFlags::REDUCE ) ? 4 : 0;
while( nSize && ( mpImplPolygon->mpPointAry[ nSize - 1 ] == rFirst ) )
nSize--;
diff --git a/tools/source/generic/poly2.cxx b/tools/source/generic/poly2.cxx
index 7005a56..7622c6f 100644
--- a/tools/source/generic/poly2.cxx
+++ b/tools/source/generic/poly2.cxx
@@ -224,7 +224,7 @@ void PolyPolygon::Clear()
}
}
-void PolyPolygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimizeData* pData )
+void PolyPolygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
{
if(bool(nOptimizeFlags) && Count())
{
@@ -245,7 +245,7 @@ void PolyPolygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimize
tools::PolyPolygon aPolyPoly;
AdaptiveSubdivide(aPolyPoly);
- aPolyPoly.Optimize(nOptimizeFlags, pData);
+ aPolyPoly.Optimize(nOptimizeFlags);
*this = aPolyPoly;
}
else
@@ -259,7 +259,7 @@ void PolyPolygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimize
const Rectangle aBound( GetBoundRect() );
fArea = ( aBound.GetWidth() + aBound.GetHeight() ) * 0.5;
- nPercent = pData ? pData->GetPercentValue() : 50;
+ nPercent = 50;
nOptimizeFlags &= ~PolyOptimizeFlags::EDGES;
}
@@ -280,7 +280,7 @@ void PolyPolygon::Optimize( PolyOptimizeFlags nOptimizeFlags, const PolyOptimize
}
if( bool(nOptimizeFlags) )
- mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( nOptimizeFlags, pData );
+ mpImplPolyPolygon->mpPolyAry[ i ]->Optimize( nOptimizeFlags );
}
}
}
commit e8d81c0240a66821ebd9ead3718f32d97ecc416d
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Nov 4 20:29:50 2015 +0100
_SdrItemBrowserControl: reuse BreakChangeEntry in EndChangeEntry
Change-Id: I96667dc89a25455819898b68c2366c4ecef17e6d
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
index 125c007..0029a8fb 100644
--- a/svx/source/svdraw/svdibrow.cxx
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -532,18 +532,12 @@ bool _SdrItemBrowserControl::BeginChangeEntry(std::size_t nPos)
bool _SdrItemBrowserControl::EndChangeEntry()
{
- bool bRet = false;
- if (pEditControl!=nullptr) {
- aEntryChangedHdl.Call(*this);
- pEditControl.disposeAndClear();
- delete pAktChangeEntry;
- pAktChangeEntry=NULL;
- vcl::Window* pParent=GetParent();
- pParent->SetText(aWNamMerk);
- SetMode(MYBROWSEMODE);
- bRet = true;
- }
- return bRet;
+ if (!pEditControl)
+ return false;
+
+ aEntryChangedHdl.Call(*this);
+ BreakChangeEntry();
+ return true;
}
void _SdrItemBrowserControl::BreakChangeEntry()
commit 8a8623d819b3323fb978fccc4b01ec34bc6adaff
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Nov 4 20:17:22 2015 +0100
Use more proper integer types
Change-Id: I9e1ac9f9a8d1954f570594df58c6421de13c79db
diff --git a/svx/inc/svdibrow.hxx b/svx/inc/svdibrow.hxx
index d492a9d..bc1a0fb 100644
--- a/svx/inc/svdibrow.hxx
+++ b/svx/inc/svdibrow.hxx
@@ -51,12 +51,12 @@ friend class ImpItemEdit;
private:
void ImpCtor();
- void ImpSetEntry(const ImpItemListRow& rEntry, sal_uIntPtr nEntryNum);
- ImpItemListRow* ImpGetEntry(sal_uIntPtr nPos) const { return aList[nPos]; }
+ void ImpSetEntry(const ImpItemListRow& rEntry, std::size_t nEntryNum);
+ ImpItemListRow* ImpGetEntry(std::size_t nPos) const { return aList[nPos]; }
void ImpSaveWhich();
void ImpRestoreWhich();
- sal_uIntPtr GetCurrentPos() const;
- bool BeginChangeEntry(sal_uIntPtr nPos);
+ std::size_t GetCurrentPos() const;
+ bool BeginChangeEntry(std::size_t nPos);
protected:
virtual long GetRowCount() const override;
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
index db7ee26..125c007 100644
--- a/svx/source/svdraw/svdibrow.cxx
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -18,6 +18,7 @@
*/
#include <stdlib.h>
+#include <limits>
#include "editeng/fontitem.hxx"
#include "svdibrow.hxx"
@@ -63,6 +64,8 @@ using namespace com::sun::star;
#define ITEMBROWSER_NAMECOL_ID 4
#define ITEMBROWSER_VALUECOL_ID 5
+#define ITEM_NOT_FOUND std::numeric_limits<std::size_t>::max()
+
enum ItemType {
ITEM_DONTKNOW, ITEM_BYTE, ITEM_INT16, ITEM_UINT16, ITEM_INT32, ITEM_UINT32,
ITEM_ENUM, ITEM_BOOL, ITEM_FLAG, ITEM_STRING, ITEM_POINT, ITEM_RECT, ITEM_RANGE, ITEM_LRANGE,
@@ -279,8 +282,8 @@ void _SdrItemBrowserControl::ImpCtor()
void _SdrItemBrowserControl::Clear()
{
- sal_uIntPtr nCount=aList.size();
- for (sal_uIntPtr nNum=0; nNum<nCount; nNum++) {
+ const std::size_t nCount=aList.size();
+ for (std::size_t nNum=0; nNum<nCount; ++nNum) {
delete ImpGetEntry(nNum);
}
aList.clear();
@@ -342,7 +345,7 @@ OUString _SdrItemBrowserControl::GetCellText(long _nRow, sal_uInt16 _nColId) con
void _SdrItemBrowserControl::PaintField(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId) const
{
- if (nAktPaintRow<0 || (sal_uIntPtr)nAktPaintRow>=aList.size()) {
+ if (nAktPaintRow<0 || static_cast<std::size_t>(nAktPaintRow)>=aList.size()) {
return;
}
Rectangle aR(rRect);
@@ -366,13 +369,13 @@ void _SdrItemBrowserControl::PaintField(OutputDevice& rDev, const Rectangle& rRe
}
}
-sal_uIntPtr _SdrItemBrowserControl::GetCurrentPos() const
+std::size_t _SdrItemBrowserControl::GetCurrentPos() const
{
- sal_uIntPtr nRet=CONTAINER_ENTRY_NOTFOUND;
+ std::size_t nRet=ITEM_NOT_FOUND;
if (GetSelectRowCount()==1) {
long nPos=static_cast<BrowseBox*>(const_cast<_SdrItemBrowserControl *>(this))->FirstSelectedRow();
- if (nPos>=0 && (sal_uIntPtr)nPos<aList.size()) {
- nRet=(sal_uIntPtr)nPos;
+ if (nPos>=0 && static_cast<std::size_t>(nPos)<aList.size()) {
+ nRet = static_cast<std::size_t>(nPos);
}
}
return nRet;
@@ -381,8 +384,8 @@ sal_uIntPtr _SdrItemBrowserControl::GetCurrentPos() const
sal_uInt16 _SdrItemBrowserControl::GetCurrentWhich() const
{
sal_uInt16 nRet=0;
- sal_uIntPtr nPos=GetCurrentPos();
- if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ const std::size_t nPos=GetCurrentPos();
+ if (nPos!=ITEM_NOT_FOUND) {
nRet=ImpGetEntry(nPos)->nWhichId;
}
return nRet;
@@ -390,8 +393,8 @@ sal_uInt16 _SdrItemBrowserControl::GetCurrentWhich() const
void _SdrItemBrowserControl::DoubleClick(const BrowserMouseEvent&)
{
- sal_uIntPtr nPos=GetCurrentPos();
- if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ const std::size_t nPos=GetCurrentPos();
+ if (nPos!=ITEM_NOT_FOUND) {
BeginChangeEntry(nPos);
}
}
@@ -400,8 +403,8 @@ void _SdrItemBrowserControl::KeyInput(const KeyEvent& rKEvt)
{
sal_uInt16 nKeyCode=rKEvt.GetKeyCode().GetCode()+rKEvt.GetKeyCode().GetModifier();
bool bAusgewertet = false;
- sal_uIntPtr nPos=GetCurrentPos();
- if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ const std::size_t nPos=GetCurrentPos();
+ if (nPos!=ITEM_NOT_FOUND) {
if (nKeyCode==KEY_RETURN) {
if (BeginChangeEntry(nPos)) bAusgewertet = true;
} else if (nKeyCode==KEY_ESCAPE) {
@@ -468,8 +471,8 @@ void _SdrItemBrowserControl::ImpRestoreWhich()
{
if (nLastWhich!=0) {
bool bFnd = false;
- sal_uIntPtr nCount=aList.size();
- sal_uIntPtr nNum;
+ const std::size_t nCount=aList.size();
+ std::size_t nNum;
for (nNum=0; nNum<nCount && !bFnd; nNum++) {
ImpItemListRow* pEntry=ImpGetEntry(nNum);
if (!pEntry->bComment) {
@@ -488,7 +491,7 @@ void _SdrItemBrowserControl::ImpRestoreWhich()
}
}
-bool _SdrItemBrowserControl::BeginChangeEntry(sal_uIntPtr nPos)
+bool _SdrItemBrowserControl::BeginChangeEntry(std::size_t nPos)
{
BreakChangeEntry();
bool bRet = false;
@@ -555,7 +558,7 @@ void _SdrItemBrowserControl::BreakChangeEntry()
}
}
-void _SdrItemBrowserControl::ImpSetEntry(const ImpItemListRow& rEntry, sal_uIntPtr nEntryNum)
+void _SdrItemBrowserControl::ImpSetEntry(const ImpItemListRow& rEntry, std::size_t nEntryNum)
{
SAL_WARN_IF(nEntryNum > aList.size(), "svx", "trying to set item " << nEntryNum << "in a vector of size " << aList.size());
if (nEntryNum >= aList.size()) {
@@ -1164,7 +1167,7 @@ IMPL_LINK_TYPED(SdrItemBrowser, ChangedHdl, _SdrItemBrowserControl&, rBrowse, vo
if (!bDel) {
SfxPoolItem* pNewItem=aSet.Get(pEntry->nWhichId).Clone();
- long nLongVal = aNewText.toInt32();
+ sal_Int32 nLongVal = aNewText.toInt32();
if (pEntry->bCanNum) {
if (nLongVal>pEntry->nMax) nLongVal=pEntry->nMax;
if (nLongVal<pEntry->nMin) nLongVal=pEntry->nMin;
@@ -1194,9 +1197,9 @@ IMPL_LINK_TYPED(SdrItemBrowser, ChangedHdl, _SdrItemBrowserControl&, rBrowse, vo
{
aNewText = aNewText.replace(',', '.');
double nVal = aNewText.toFloat();
- nLongVal = (long)(nVal * 100 + 0.5);
+ nLongVal = static_cast<sal_Int32>(nVal * 100.0 + 0.5);
}
- static_cast<SfxInt32Item *>(pNewItem)->SetValue((sal_Int32)nLongVal);
+ static_cast<SfxInt32Item *>(pNewItem)->SetValue(nLongVal);
} break;
case ITEM_UINT32: static_cast<SfxUInt32Item*>(pNewItem)->SetValue(aNewText.toInt32()); break;
case ITEM_ENUM : static_cast<SfxEnumItemInterface*>(pNewItem)->SetEnumValue((sal_uInt16)nLongVal); break;
@@ -1233,12 +1236,12 @@ IMPL_LINK_TYPED(SdrItemBrowser, ChangedHdl, _SdrItemBrowserControl&, rBrowse, vo
static_cast<SvxFontItem*>(pNewItem)->SetStyleName(OUString());
} break;
case ITEM_FONTHEIGHT: {
- sal_uIntPtr nHgt=0;
+ sal_uInt32 nHgt=0;
sal_uInt16 nProp=100;
if (aNewText.indexOf('%') != -1) {
- nProp=(sal_uInt16)nLongVal;
+ nProp=static_cast<sal_uInt16>(nLongVal);
} else {
- nHgt=nLongVal;
+ nHgt=static_cast<sal_uInt32>(nLongVal);
}
static_cast<SvxFontHeightItem*>(pNewItem)->SetHeight(nHgt,nProp);
} break;
commit 117ff6534ccf402cd323061104a4e8f7ecfa0850
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Nov 4 11:20:51 2015 +0100
Expand some prefixes ('Brk' to 'Break', 'Beg' to 'Begin')
Change-Id: Id4047b656ce53cf754c35fab13216587884da199
diff --git a/svx/inc/svdibrow.hxx b/svx/inc/svdibrow.hxx
index cbf8d52..d492a9d 100644
--- a/svx/inc/svdibrow.hxx
+++ b/svx/inc/svdibrow.hxx
@@ -56,7 +56,7 @@ private:
void ImpSaveWhich();
void ImpRestoreWhich();
sal_uIntPtr GetCurrentPos() const;
- bool BegChangeEntry(sal_uIntPtr nPos);
+ bool BeginChangeEntry(sal_uIntPtr nPos);
protected:
virtual long GetRowCount() const override;
@@ -76,7 +76,7 @@ public:
void SetAttributes(const SfxItemSet* pAttr, const SfxItemSet* p2ndSet=NULL);
sal_uInt16 GetCurrentWhich() const;
bool EndChangeEntry();
- void BrkChangeEntry();
+ void BreakChangeEntry();
/** GetCellText returns the text at the given position
@param _nRow
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
index 97ea6b7..db7ee26 100644
--- a/svx/source/svdraw/svdibrow.cxx
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -187,7 +187,7 @@ void ImpItemEdit::KeyInput(const KeyEvent& rKEvt)
}
else if(nKeyCode == KEY_ESCAPE)
{
- pBrowseMerk->BrkChangeEntry();
+ pBrowseMerk->BreakChangeEntry();
pBrowseMerk->GrabFocus();
}
else if(nKeyCode == KEY_UP || nKeyCode == KEY_DOWN)
@@ -392,7 +392,7 @@ void _SdrItemBrowserControl::DoubleClick(const BrowserMouseEvent&)
{
sal_uIntPtr nPos=GetCurrentPos();
if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
- BegChangeEntry(nPos);
+ BeginChangeEntry(nPos);
}
}
@@ -403,7 +403,7 @@ void _SdrItemBrowserControl::KeyInput(const KeyEvent& rKEvt)
sal_uIntPtr nPos=GetCurrentPos();
if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
if (nKeyCode==KEY_RETURN) {
- if (BegChangeEntry(nPos)) bAusgewertet = true;
+ if (BeginChangeEntry(nPos)) bAusgewertet = true;
} else if (nKeyCode==KEY_ESCAPE) {
} else if (rKEvt.GetKeyCode().GetModifier()==KEY_SHIFT+KEY_MOD1+KEY_MOD2) { // Ctrl
@@ -488,9 +488,9 @@ void _SdrItemBrowserControl::ImpRestoreWhich()
}
}
-bool _SdrItemBrowserControl::BegChangeEntry(sal_uIntPtr nPos)
+bool _SdrItemBrowserControl::BeginChangeEntry(sal_uIntPtr nPos)
{
- BrkChangeEntry();
+ BreakChangeEntry();
bool bRet = false;
ImpItemListRow* pEntry=ImpGetEntry(nPos);
if (pEntry!=NULL && !pEntry->bComment) {
@@ -543,7 +543,7 @@ bool _SdrItemBrowserControl::EndChangeEntry()
return bRet;
}
-void _SdrItemBrowserControl::BrkChangeEntry()
+void _SdrItemBrowserControl::BreakChangeEntry()
{
if (pEditControl!=nullptr) {
pEditControl.disposeAndClear();
commit 45a2bb97a19dc599abda5e4dce620f2b75491d0f
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Nov 4 10:38:51 2015 +0100
Privatize _SdrItemBrowserControl::GetCurrentPos|BegChangeEntry
Change-Id: Iea2e8353f4d48e792e3ff8d6e4544df35bea9461
diff --git a/svx/inc/svdibrow.hxx b/svx/inc/svdibrow.hxx
index b59a85f..cbf8d52 100644
--- a/svx/inc/svdibrow.hxx
+++ b/svx/inc/svdibrow.hxx
@@ -55,6 +55,8 @@ private:
ImpItemListRow* ImpGetEntry(sal_uIntPtr nPos) const { return aList[nPos]; }
void ImpSaveWhich();
void ImpRestoreWhich();
+ sal_uIntPtr GetCurrentPos() const;
+ bool BegChangeEntry(sal_uIntPtr nPos);
protected:
virtual long GetRowCount() const override;
@@ -72,9 +74,7 @@ public:
virtual void dispose() override;
void Clear();
void SetAttributes(const SfxItemSet* pAttr, const SfxItemSet* p2ndSet=NULL);
- sal_uIntPtr GetCurrentPos() const;
sal_uInt16 GetCurrentWhich() const;
- bool BegChangeEntry(sal_uIntPtr nPos);
bool EndChangeEntry();
void BrkChangeEntry();
commit 17a3f759777d66f34f49ead04368ad6219e1c7ba
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date: Wed Oct 28 14:21:14 2015 +0100
sal_uIntPtr to sal_uInt32
Change-Id: Ia0830dda74ab312fd1ca42297b43d48777374eb7
diff --git a/include/svx/sdggaitm.hxx b/include/svx/sdggaitm.hxx
index 16e3078..ad6fbcc 100644
--- a/include/svx/sdggaitm.hxx
+++ b/include/svx/sdggaitm.hxx
@@ -34,7 +34,7 @@ public:
TYPEINFO_OVERRIDE();
- SdrGrafGamma100Item( sal_uIntPtr nGamma100 = 100 ) : SfxUInt32Item( SDRATTR_GRAFGAMMA, nGamma100 ) {}
+ SdrGrafGamma100Item( sal_uInt32 nGamma100 = 100 ) : SfxUInt32Item( SDRATTR_GRAFGAMMA, nGamma100 ) {}
SdrGrafGamma100Item( SvStream& rIn ) : SfxUInt32Item( SDRATTR_GRAFGAMMA, rIn ) {}
virtual SfxPoolItem* Clone( SfxItemPool* pPool = NULL ) const override;
More information about the Libreoffice-commits
mailing list