summaryrefslogtreecommitdiff
path: root/filter/source/graphicfilter/icgm/bitmap.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/graphicfilter/icgm/bitmap.cxx')
-rw-r--r--filter/source/graphicfilter/icgm/bitmap.cxx38
1 files changed, 24 insertions, 14 deletions
diff --git a/filter/source/graphicfilter/icgm/bitmap.cxx b/filter/source/graphicfilter/icgm/bitmap.cxx
index cb319cb038e0..ed163206641a 100644
--- a/filter/source/graphicfilter/icgm/bitmap.cxx
+++ b/filter/source/graphicfilter/icgm/bitmap.cxx
@@ -19,7 +19,7 @@
#include <sal/log.hxx>
-#include <unotools/configmgr.hxx>
+#include <comphelper/configuration.hxx>
#include <vcl/BitmapTools.hxx>
#include <memory>
@@ -34,14 +34,13 @@ Color BMCOL(sal_uInt32 _col) {
}
-CGMBitmap::CGMBitmap( CGM& rCGM ) :
- mpCGM ( &rCGM ),
- pCGMBitmapDescriptor ( new CGMBitmapDescriptor )
+CGMBitmap::CGMBitmap(CGM& rCGM)
+ : mpCGM(&rCGM)
+ , pCGMBitmapDescriptor(new CGMBitmapDescriptor)
{
ImplGetBitmap( *pCGMBitmapDescriptor );
};
-
CGMBitmap::~CGMBitmap()
{
}
@@ -216,17 +215,17 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
double nX = rDesc.mnR.X - rDesc.mnQ.X;
double nY = rDesc.mnR.Y - rDesc.mnQ.Y;
- rDesc.mndy = sqrt( nX * nX + nY * nY );
+ rDesc.mndy = std::hypot(nX, nY);
nX = rDesc.mnR.X - rDesc.mnP.X;
nY = rDesc.mnR.Y - rDesc.mnP.Y;
- rDesc.mndx = sqrt( nX * nX + nY * nY );
+ rDesc.mndx = std::hypot(nX, nY);
nX = rDesc.mnR.X - rDesc.mnP.X;
nY = rDesc.mnR.Y - rDesc.mnP.Y;
- double fSqrt = sqrt(nX * nX + nY * nY);
+ double fSqrt = std::hypot(nX, nY);
rDesc.mnOrientation = fSqrt != 0.0 ? basegfx::rad2deg(acos(nX / fSqrt)) : 0.0;
if ( nY > 0 )
rDesc.mnOrientation = 360 - rDesc.mnOrientation;
@@ -240,7 +239,7 @@ void CGMBitmap::ImplGetBitmap( CGMBitmapDescriptor& rDesc )
nX = fCos * nX + fSin * nY;
nY = -( fSin * nX - fCos * nY );
- fSqrt = sqrt(nX * nX + nY * nY);
+ fSqrt = std::hypot(nX, nY);
fAngle = fSqrt != 0.0 ? basegfx::rad2deg(acos(nX / fSqrt)) : 0.0;
if ( nY > 0 )
fAngle = 360 - fAngle;
@@ -375,15 +374,26 @@ bool CGMBitmap::ImplGetDimensions( CGMBitmapDescriptor& rDesc )
void CGMBitmap::ImplInsert( CGMBitmapDescriptor const & rSource, CGMBitmapDescriptor& rDest )
{
- if (utl::ConfigManager::IsFuzzing() && rDest.mxBitmap.GetSizePixel().Height() + rSource.mnY > SAL_MAX_UINT16)
+ ++mpCGM->mnBitmapInserts;
+ static const bool bFuzzing = comphelper::IsFuzzing();
+ if (bFuzzing)
{
- SAL_WARN("filter.icgm", "bitmap would expand too much");
- rDest.mbStatus = false;
- return;
+ if (rDest.mxBitmap.GetSizePixel().Height() + rSource.mnY > SAL_MAX_UINT16)
+ {
+ SAL_WARN("filter.icgm", "bitmap would expand too much");
+ rDest.mbStatus = false;
+ return;
+ }
+ if (mpCGM->mnBitmapInserts > 1024)
+ {
+ SAL_WARN("filter.icgm", "too many inserts");
+ rDest.mbStatus = false;
+ return;
+ }
}
rDest.mxBitmap.Expand( 0, rSource.mnY );
rDest.mxBitmap.CopyPixel( tools::Rectangle( Point( 0, rDest.mnY ), Size( rSource.mnX, rSource.mnY ) ),
- tools::Rectangle( Point( 0, 0 ), Size( rSource.mnX, rSource.mnY ) ), &rSource.mxBitmap );
+ tools::Rectangle( Point( 0, 0 ), Size( rSource.mnX, rSource.mnY ) ), rSource.mxBitmap );
if ( ( rSource.mnR.Y == rDest.mnQ.Y ) && ( rSource.mnR.X == rDest.mnQ.X ) )
{ // Insert on Bottom