diff options
Diffstat (limited to 'filter/source/graphicfilter')
-rw-r--r-- | filter/source/graphicfilter/icgm/actimpr.cxx | 11 | ||||
-rw-r--r-- | filter/source/graphicfilter/icgm/bitmap.cxx | 38 | ||||
-rw-r--r-- | filter/source/graphicfilter/icgm/bitmap.hxx | 6 | ||||
-rw-r--r-- | filter/source/graphicfilter/icgm/cgm.cxx | 11 | ||||
-rw-r--r-- | filter/source/graphicfilter/icgm/cgm.hxx | 1 | ||||
-rw-r--r-- | filter/source/graphicfilter/icgm/class1.cxx | 3 | ||||
-rw-r--r-- | filter/source/graphicfilter/icgm/class4.cxx | 46 |
7 files changed, 58 insertions, 58 deletions
diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx index bb17a380c3b2..e726db7a137c 100644 --- a/filter/source/graphicfilter/icgm/actimpr.cxx +++ b/filter/source/graphicfilter/icgm/actimpr.cxx @@ -47,7 +47,7 @@ #include <comphelper/processfactory.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <tools/helpers.hxx> -#include <unotools/configmgr.hxx> +#include <comphelper/configuration.hxx> #include "bitmap.hxx" #include "elements.hxx" @@ -110,7 +110,7 @@ bool CGMImpressOutAct::ImplInitPage() bool CGMImpressOutAct::ImplCreateShape( const OUString& rType ) { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return false; uno::Reference< uno::XInterface > xNewShape( maXMultiServiceFactory->createInstance( rType ) ); maXShape.set( xNewShape, uno::UNO_QUERY ); @@ -387,11 +387,10 @@ void CGMImpressOutAct::InsertPage() { if ( mnCurrentPage ) // one side is always existing, therefore the first side will be left out { - uno::Reference< drawing::XDrawPage > xPage = maXDrawPages->insertNewByIndex( 0xffff ); - maXDrawPage = xPage; + maXDrawPage = maXDrawPages->insertNewByIndex(0xffff); if ( !ImplInitPage() ) mpCGM->mbStatus = false; - if (mnCurrentPage > MAX_PAGES_FOR_FUZZING && utl::ConfigManager::IsFuzzing()) + if (mnCurrentPage > MAX_PAGES_FOR_FUZZING && comphelper::IsFuzzing()) { // ofz#21753 that's enough pages for fuzzing, we're not doing anything productive now mpCGM->mbStatus = false; @@ -791,7 +790,7 @@ void CGMImpressOutAct::DrawText(awt::Point const & rTextPos, awt::Size const & r maXShape->setSize( awt::Size( nWidth, nHeight ) ); double nX = mpCGM->pElement->nCharacterOrientation[ 2 ]; double nY = mpCGM->pElement->nCharacterOrientation[ 3 ]; - double fSqrt = sqrt(nX * nX + nY * nY); + double fSqrt = std::hypot(nX, nY); double nOrientation = fSqrt != 0.0 ? basegfx::rad2deg(acos(nX / fSqrt)) : 0.0; if ( nY < 0 ) nOrientation = 360 - nOrientation; 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 diff --git a/filter/source/graphicfilter/icgm/bitmap.hxx b/filter/source/graphicfilter/icgm/bitmap.hxx index 3e7b80f5177f..564284b22135 100644 --- a/filter/source/graphicfilter/icgm/bitmap.hxx +++ b/filter/source/graphicfilter/icgm/bitmap.hxx @@ -31,8 +31,8 @@ class CGMBitmapDescriptor sal_uInt8* mpBuf; sal_uInt8* mpEndBuf; BitmapEx mxBitmap; - bool mbStatus; - bool mbVMirror; + bool mbStatus; + bool mbVMirror; sal_uInt32 mnDstBitsPerPixel; sal_uInt32 mnScanSize; // bytes per line FloatPoint mnP, mnQ, mnR; @@ -42,7 +42,7 @@ class CGMBitmapDescriptor double mnOrientation; sal_uInt32 mnX, mnY; - tools::Long mnLocalColorPrecision; + tools::Long mnLocalColorPrecision; sal_uInt32 mnCompressionMode; CGMBitmapDescriptor() diff --git a/filter/source/graphicfilter/icgm/cgm.cxx b/filter/source/graphicfilter/icgm/cgm.cxx index 1cf7c7ca0b36..e8488328356d 100644 --- a/filter/source/graphicfilter/icgm/cgm.cxx +++ b/filter/source/graphicfilter/icgm/cgm.cxx @@ -17,9 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <com/sun/star/task/XStatusIndicator.hpp> #include <o3tl/safeint.hxx> #include <osl/endian.h> +#include <filter/importcgm.hxx> #include <tools/stream.hxx> #include "bitmap.hxx" #include "chart.hxx" @@ -27,7 +27,7 @@ #include "outact.hxx" #include <memory> #include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; @@ -53,6 +53,7 @@ CGM::CGM(uno::Reference< frame::XModel > const & rModel) , mbFirstOutPut(false) , mbInDefaultReplacement(false) , mnAct4PostReset(0) + , mnBitmapInserts(0) , mpOutAct(new CGMImpressOutAct(*this, rModel)) , mpSource(nullptr) , mpEndValidSource(nullptr) @@ -682,7 +683,7 @@ bool CGM::Write( SvStream& rIStm ) }; // GraphicImport - the exported function -extern "C" SAL_DLLPUBLIC_EXPORT sal_uInt32 +FILTER_DLLPUBLIC sal_uInt32 ImportCGM(SvStream& rIn, uno::Reference< frame::XModel > const & rXModel, css::uno::Reference<css::task::XStatusIndicator> const & aXStatInd) { @@ -700,7 +701,7 @@ ImportCGM(SvStream& rIn, uno::Reference< frame::XModel > const & rXModel, css::u sal_uInt64 const nInSize = rIn.remainingSize(); rIn.Seek(0); - sal_uInt32 nNext = 0; + sal_uInt64 nNext = 0; sal_uInt32 nAdd = nInSize / 20; bool bProgressBar = aXStatInd.is(); if ( bProgressBar ) @@ -710,7 +711,7 @@ ImportCGM(SvStream& rIn, uno::Reference< frame::XModel > const & rXModel, css::u { if ( bProgressBar ) { - sal_uInt32 nCurrentPos = rIn.Tell(); + sal_uInt64 nCurrentPos = rIn.Tell(); if ( nCurrentPos >= nNext ) { aXStatInd->setValue( nCurrentPos ); diff --git a/filter/source/graphicfilter/icgm/cgm.hxx b/filter/source/graphicfilter/icgm/cgm.hxx index b344cb22e707..e2281311e438 100644 --- a/filter/source/graphicfilter/icgm/cgm.hxx +++ b/filter/source/graphicfilter/icgm/cgm.hxx @@ -61,6 +61,7 @@ class CGM bool mbFirstOutPut; bool mbInDefaultReplacement; sal_uInt32 mnAct4PostReset; + int mnBitmapInserts; std::unique_ptr<CGMBitmap> mpBitmapInUse; std::unique_ptr<CGMChart> mpChart; // if sal_True->"SHWSLIDEREC" // otherwise "BEGINPIC" commands diff --git a/filter/source/graphicfilter/icgm/class1.cxx b/filter/source/graphicfilter/icgm/class1.cxx index 07a6fe253e4e..4304d142b5e5 100644 --- a/filter/source/graphicfilter/icgm/class1.cxx +++ b/filter/source/graphicfilter/icgm/class1.cxx @@ -151,9 +151,6 @@ void CGM::ImplDoClass1() } break; case 0x0a : /*Color Value Extent*/ - { - nI1 = 6; - } break; case 0x0b : /*MetaFile Element List */break; case 0x0c : /*MetaFile Default Replacement*/ diff --git a/filter/source/graphicfilter/icgm/class4.cxx b/filter/source/graphicfilter/icgm/class4.cxx index edf34970a27f..af66ff26ae09 100644 --- a/filter/source/graphicfilter/icgm/class4.cxx +++ b/filter/source/graphicfilter/icgm/class4.cxx @@ -36,7 +36,7 @@ double CGM::ImplGetOrientation( FloatPoint const & rCenter, FloatPoint const & r double nX = rPoint.X - rCenter.X; double nY = rPoint.Y - rCenter.Y; - double fSqrt = sqrt(nX * nX + nY * nY); + double fSqrt = std::hypot(nX, nY); double fOrientation = fSqrt != 0.0 ? basegfx::rad2deg(acos(nX / fSqrt)) : 0.0; if (nY > 0) fOrientation = 360 - fOrientation; @@ -89,10 +89,10 @@ bool CGM::ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rAng rAngle = ImplGetOrientation( rCenter, aPoint1 ); aPoint1.X -= rCenter.X; aPoint1.Y -= rCenter.Y; - rRadius.X = sqrt( aPoint1.X * aPoint1.X + aPoint1.Y * aPoint1.Y ); + rRadius.X = std::hypot(aPoint1.X, aPoint1.Y); aPoint2.X -= rCenter.X; aPoint2.Y -= rCenter.Y; - rRadius.Y = sqrt( aPoint2.X * aPoint2.X + aPoint2.Y * aPoint2.Y ); + rRadius.Y = std::hypot(aPoint2.X, aPoint2.Y); if ( fRot1 > fRot2 ) { @@ -276,29 +276,21 @@ void CGM::ImplDoClass4() if ( mbFigure ) mpOutAct->CloseRegion(); - sal_uInt16 nPoints = 0; - std::unique_ptr<Point[]> pPoints(new Point[ 0x4000 ]); - + std::vector<Point> aPoints; tools::PolyPolygon aPolyPolygon; FloatPoint aFloatPoint; - sal_uInt32 nEdgeFlag; + while ( mnParaSize < mnElementSize ) { ImplGetPoint( aFloatPoint, true ); - nEdgeFlag = ImplGetUI16(); - pPoints[ nPoints++ ] = Point( static_cast<tools::Long>(aFloatPoint.X), static_cast<tools::Long>(aFloatPoint.Y) ); + sal_uInt32 nEdgeFlag = ImplGetUI16(); + aPoints.push_back(Point(static_cast<tools::Long>(aFloatPoint.X), static_cast<tools::Long>(aFloatPoint.Y))); if ( ( nEdgeFlag & 2 ) || ( mnParaSize == mnElementSize ) ) { - tools::Polygon aPolygon( nPoints ); - for ( sal_uInt16 i = 0; i < nPoints; i++ ) - { - aPolygon.SetPoint( pPoints[ i ], i ); - } - aPolyPolygon.Insert( aPolygon ); - nPoints = 0; + aPolyPolygon.Insert(tools::Polygon(aPoints.size(), aPoints.data())); + aPoints.clear(); } } - pPoints.reset(); mpOutAct->DrawPolyPolygon( aPolyPolygon ); } break; @@ -418,7 +410,7 @@ void CGM::ImplDoClass4() fStartAngle = fEndAngle; fEndAngle = fG; } - double fRadius = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ; + double fRadius = std::hypot(aStartingPoint.X - aCenterPoint.X, aStartingPoint.Y - aCenterPoint.Y); if ( mbFigure ) { @@ -508,7 +500,7 @@ void CGM::ImplDoClass4() fEndAngle = fG; } FloatPoint fRadius; - fRadius.Y = fRadius.X = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ; + fRadius.Y = fRadius.X = std::hypot(aStartingPoint.X - aCenterPoint.X, aStartingPoint.Y - aCenterPoint.Y); sal_uInt32 nType = ImplGetUI16(); if ( nType == 0 ) @@ -548,9 +540,9 @@ void CGM::ImplDoClass4() bool bUseless = useless(vector[0]) || useless(vector[1]) || useless(vector[2]) || useless(vector[3]); if (!bUseless) { - const double fStartSqrt = sqrt(vector[0] * vector[ 0 ] + vector[1] * vector[1]); + const double fStartSqrt = std::hypot(vector[0], vector[1]); fStartAngle = fStartSqrt != 0.0 ? basegfx::rad2deg(acos(vector[0] / fStartSqrt)) : 0.0; - const double fEndSqrt = sqrt(vector[2] * vector[ 2 ] + vector[3] * vector[3]); + const double fEndSqrt = std::hypot(vector[2], vector[3]); fEndAngle = fEndSqrt != 0.0 ? basegfx::rad2deg(acos(vector[ 2 ] / fEndSqrt)) : 0.0; if ( vector[ 1 ] > 0 ) @@ -626,9 +618,9 @@ void CGM::ImplDoClass4() bool bUseless = useless(vector[0]) || useless(vector[1]) || useless(vector[2]) || useless(vector[3]); if (!bUseless) { - const double fStartSqrt = sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + const double fStartSqrt = std::hypot(vector[0], vector[1]); double fStartAngle = fStartSqrt ? basegfx::rad2deg(acos(vector[0] / fStartSqrt)) : 0.0; - const double fEndSqrt = sqrt(vector[2] * vector[2] + vector[3] * vector[3]); + const double fEndSqrt = std::hypot(vector[2], vector[3]); double fEndAngle = fEndSqrt ? basegfx::rad2deg(acos(vector[2] / fEndSqrt)) : 0.0; if ( vector[ 1 ] > 0 ) @@ -683,9 +675,9 @@ void CGM::ImplDoClass4() bool bUseless = useless(vector[0]) || useless(vector[1]) || useless(vector[2]) || useless(vector[3]); if (!bUseless) { - double fStartSqrt = sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + double fStartSqrt = std::hypot(vector[0], vector[1]); fStartAngle = fStartSqrt ? basegfx::rad2deg(acos(vector[0] / fStartSqrt)) : 0.0; - double fEndSqrt = sqrt(vector[2] * vector[2] + vector[3] * vector[3]); + double fEndSqrt = std::hypot(vector[2], vector[3]); fEndAngle = fEndSqrt ? basegfx::rad2deg(acos(vector[2] / fEndSqrt)) : 0.0; if ( vector[ 1 ] > 0 ) @@ -719,9 +711,9 @@ void CGM::ImplDoClass4() bool bUseless = useless(vector[0]) || useless(vector[1]) || useless(vector[2]) || useless(vector[3]); if (!bUseless) { - double fStartSqrt = sqrt(vector[0] * vector[0] + vector[1] * vector[1]); + double fStartSqrt = std::hypot(vector[0], vector[1]); fStartAngle = fStartSqrt ? basegfx::rad2deg(acos(vector[0] / fStartSqrt)) : 0.0; - double fEndSqrt = sqrt(vector[2] * vector[2] + vector[3] * vector[3]); + double fEndSqrt = std::hypot(vector[2], vector[3]); fEndAngle = fEndSqrt ? basegfx::rad2deg(acos(vector[2] / fEndSqrt)) : 0.0; if ( vector[ 1 ] > 0 ) |