[Libreoffice-commits] core.git: 4 commits - filter/source

Caolán McNamara caolanm at redhat.com
Sun Apr 2 14:27:42 UTC 2017


 filter/source/graphicfilter/icgm/actimpr.cxx |   31 ++++++++++++---------------
 filter/source/graphicfilter/icgm/cgm.cxx     |    6 ++---
 filter/source/graphicfilter/icgm/class1.cxx  |    2 -
 filter/source/graphicfilter/icgm/outact.hxx  |    5 +---
 4 files changed, 20 insertions(+), 24 deletions(-)

New commits:
commit 66147965d538bfce810598f34b272a85067d759b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Apr 2 15:07:18 2017 +0100

    ofz: drop hard-coded limit
    
    Change-Id: I175b2db73a29c7e83003ad0638818e7876d552d4

diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx
index fea8420bf8c8..755f6b8b9afe 100644
--- a/filter/source/graphicfilter/icgm/actimpr.cxx
+++ b/filter/source/graphicfilter/icgm/actimpr.cxx
@@ -60,10 +60,7 @@ CGMImpressOutAct::CGMImpressOutAct( CGM& rCGM, const uno::Reference< frame::XMod
     mnCurrentPage = 0;
     mnGroupActCount = mnGroupLevel = 0;
     mpGroupLevel = new sal_uInt32[CGM_OUTACT_MAX_GROUP_LEVEL] ();
-    maPoints.resize(0x2000);
-    maFlags.resize(0x2000);
 
-    mnIndex = 0;
     mpGradient = nullptr;
 
     if ( mpCGM->mbStatus )
@@ -893,16 +890,17 @@ void CGMImpressOutAct::AppendText( char* pString, sal_uInt32 /*nSize*/, FinalFla
 
 void CGMImpressOutAct::BeginFigure()
 {
-    if ( mnIndex )
+    if (!maPoints.empty())
         EndFigure();
 
     BeginGroup();
-    mnIndex = 0;
+    maPoints.clear();
+    maFlags.clear();
 }
 
 void CGMImpressOutAct::CloseRegion()
 {
-    if ( mnIndex > 2 )
+    if (maPoints.size() > 2)
     {
         NewRegion();
         DrawPolyPolygon( maPolyPolygon );
@@ -912,12 +910,13 @@ void CGMImpressOutAct::CloseRegion()
 
 void CGMImpressOutAct::NewRegion()
 {
-    if ( mnIndex > 2 )
+    if (maPoints.size() > 2)
     {
-        tools::Polygon aPolygon(mnIndex, maPoints.data(), maFlags.data());
+        tools::Polygon aPolygon(maPoints.size(), maPoints.data(), maFlags.data());
         maPolyPolygon.Insert( aPolygon );
     }
-    mnIndex = 0;
+    maPoints.clear();
+    maFlags.clear();
 }
 
 void CGMImpressOutAct::EndFigure()
@@ -926,7 +925,8 @@ void CGMImpressOutAct::EndFigure()
     DrawPolyPolygon( maPolyPolygon );
     maPolyPolygon.Clear();
     EndGroup();
-    mnIndex = 0;
+    maPoints.clear();
+    maFlags.clear();
 }
 
 void CGMImpressOutAct::RegPolyLine( tools::Polygon& rPolygon, bool bReverse )
@@ -938,19 +938,18 @@ void CGMImpressOutAct::RegPolyLine( tools::Polygon& rPolygon, bool bReverse )
         {
             for ( sal_uInt16 i = 0; i <  nPoints; i++ )
             {
-                maPoints[ mnIndex + i ] = rPolygon.GetPoint( nPoints - i - 1 );
-                maFlags[ mnIndex + i ] = rPolygon.GetFlags( nPoints - i - 1 );
+                maPoints.push_back(rPolygon.GetPoint(nPoints - i - 1));
+                maFlags.push_back(rPolygon.GetFlags(nPoints - i - 1));
             }
         }
         else
         {
             for ( sal_uInt16 i = 0; i <  nPoints; i++ )
             {
-                maPoints[ mnIndex + i ] = rPolygon.GetPoint( i );
-                maFlags[ mnIndex + i ] = rPolygon.GetFlags( i );
+                maPoints.push_back(rPolygon.GetPoint(i));
+                maFlags.push_back(rPolygon.GetFlags(i));
             }
         }
-        mnIndex = mnIndex + nPoints;
     }
 }
 
diff --git a/filter/source/graphicfilter/icgm/outact.hxx b/filter/source/graphicfilter/icgm/outact.hxx
index 8b8b62f61ccc..3a8d7e8b91fa 100644
--- a/filter/source/graphicfilter/icgm/outact.hxx
+++ b/filter/source/graphicfilter/icgm/outact.hxx
@@ -45,7 +45,6 @@ class CGMImpressOutAct
     sal_uInt32                  mnGroupLevel;
     sal_uInt32*                 mpGroupLevel;
 
-    sal_uInt16                  mnIndex;                // figure
     std::vector<PolyFlags>      maFlags;
     std::vector<Point>          maPoints;
     tools::PolyPolygon          maPolyPolygon;
commit 4cd4ec2855fd51bb97812e90dc469c55882933f4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Apr 2 15:01:10 2017 +0100

    convert to std::vector
    
    Change-Id: Icd442975cbc084a67bdd3e7f24113f499981db60

diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx
index 66ff8df07ba9..fea8420bf8c8 100644
--- a/filter/source/graphicfilter/icgm/actimpr.cxx
+++ b/filter/source/graphicfilter/icgm/actimpr.cxx
@@ -60,8 +60,8 @@ CGMImpressOutAct::CGMImpressOutAct( CGM& rCGM, const uno::Reference< frame::XMod
     mnCurrentPage = 0;
     mnGroupActCount = mnGroupLevel = 0;
     mpGroupLevel = new sal_uInt32[CGM_OUTACT_MAX_GROUP_LEVEL] ();
-    mpPoints = new Point[ 0x2000 ];
-    mpFlags = new PolyFlags[ 0x2000 ];
+    maPoints.resize(0x2000);
+    maFlags.resize(0x2000);
 
     mnIndex = 0;
     mpGradient = nullptr;
@@ -91,8 +91,6 @@ CGMImpressOutAct::CGMImpressOutAct( CGM& rCGM, const uno::Reference< frame::XMod
 
 CGMImpressOutAct::~CGMImpressOutAct()
 {
-    delete[] mpPoints;
-    delete[] mpFlags;
     delete[] mpGroupLevel;
     delete mpGradient;
 }
@@ -916,7 +914,7 @@ void CGMImpressOutAct::NewRegion()
 {
     if ( mnIndex > 2 )
     {
-        tools::Polygon aPolygon( mnIndex, mpPoints, mpFlags );
+        tools::Polygon aPolygon(mnIndex, maPoints.data(), maFlags.data());
         maPolyPolygon.Insert( aPolygon );
     }
     mnIndex = 0;
@@ -940,16 +938,16 @@ void CGMImpressOutAct::RegPolyLine( tools::Polygon& rPolygon, bool bReverse )
         {
             for ( sal_uInt16 i = 0; i <  nPoints; i++ )
             {
-                mpPoints[ mnIndex + i ] = rPolygon.GetPoint( nPoints - i - 1 );
-                mpFlags[ mnIndex + i ] = rPolygon.GetFlags( nPoints - i - 1 );
+                maPoints[ mnIndex + i ] = rPolygon.GetPoint( nPoints - i - 1 );
+                maFlags[ mnIndex + i ] = rPolygon.GetFlags( nPoints - i - 1 );
             }
         }
         else
         {
             for ( sal_uInt16 i = 0; i <  nPoints; i++ )
             {
-                mpPoints[ mnIndex + i ] = rPolygon.GetPoint( i );
-                mpFlags[ mnIndex + i ] = rPolygon.GetFlags( i );
+                maPoints[ mnIndex + i ] = rPolygon.GetPoint( i );
+                maFlags[ mnIndex + i ] = rPolygon.GetFlags( i );
             }
         }
         mnIndex = mnIndex + nPoints;
diff --git a/filter/source/graphicfilter/icgm/outact.hxx b/filter/source/graphicfilter/icgm/outact.hxx
index a83d3b199635..8b8b62f61ccc 100644
--- a/filter/source/graphicfilter/icgm/outact.hxx
+++ b/filter/source/graphicfilter/icgm/outact.hxx
@@ -46,8 +46,8 @@ class CGMImpressOutAct
     sal_uInt32*                 mpGroupLevel;
 
     sal_uInt16                  mnIndex;                // figure
-    PolyFlags*                  mpFlags;
-    Point*                      mpPoints;
+    std::vector<PolyFlags>      maFlags;
+    std::vector<Point>          maPoints;
     tools::PolyPolygon          maPolyPolygon;
     css::awt::Gradient*         mpGradient;
 
commit 9e0bcd809a5ea7b93201172a1ce000d133484d1b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Apr 2 14:59:01 2017 +0100

    drop the weird casting
    
    Change-Id: I62d4eb8c3bdc9026484242463dc278094f8941f4

diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx
index 6d7b1364b22b..66ff8df07ba9 100644
--- a/filter/source/graphicfilter/icgm/actimpr.cxx
+++ b/filter/source/graphicfilter/icgm/actimpr.cxx
@@ -60,7 +60,7 @@ CGMImpressOutAct::CGMImpressOutAct( CGM& rCGM, const uno::Reference< frame::XMod
     mnCurrentPage = 0;
     mnGroupActCount = mnGroupLevel = 0;
     mpGroupLevel = new sal_uInt32[CGM_OUTACT_MAX_GROUP_LEVEL] ();
-    mpPoints = reinterpret_cast<Point*>(new sal_Int8[ 0x2000 * sizeof( Point ) ]);
+    mpPoints = new Point[ 0x2000 ];
     mpFlags = new PolyFlags[ 0x2000 ];
 
     mnIndex = 0;
@@ -91,7 +91,7 @@ CGMImpressOutAct::CGMImpressOutAct( CGM& rCGM, const uno::Reference< frame::XMod
 
 CGMImpressOutAct::~CGMImpressOutAct()
 {
-    delete[] reinterpret_cast<sal_Int8*>(mpPoints);
+    delete[] mpPoints;
     delete[] mpFlags;
     delete[] mpGroupLevel;
     delete mpGradient;
commit 67bf8ecc6fb0018bf196bc59df736d2cbda7d053
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Apr 2 15:25:24 2017 +0100

    signed/unsigned comparison warnings
    
    Change-Id: Ibc091869529ad290f3af3d87c82a5489ba22cc6f

diff --git a/filter/source/graphicfilter/icgm/cgm.cxx b/filter/source/graphicfilter/icgm/cgm.cxx
index 6f0d171abfa5..714c4d73757e 100644
--- a/filter/source/graphicfilter/icgm/cgm.cxx
+++ b/filter/source/graphicfilter/icgm/cgm.cxx
@@ -113,7 +113,7 @@ sal_uInt8 CGM::ImplGetByte( sal_uInt32 nSource, sal_uInt32 nPrecision )
 sal_Int32 CGM::ImplGetI( sal_uInt32 nPrecision )
 {
     sal_uInt8* pSource = mpSource + mnParaSize;
-    if (mpEndValidSource - pSource < nPrecision)
+    if (static_cast<sal_uIntPtr>(mpEndValidSource - pSource) < nPrecision)
         throw css::uno::Exception("attempt to read past end of input", nullptr);
     mnParaSize += nPrecision;
     switch( nPrecision )
@@ -145,7 +145,7 @@ sal_Int32 CGM::ImplGetI( sal_uInt32 nPrecision )
 sal_uInt32 CGM::ImplGetUI( sal_uInt32 nPrecision )
 {
     sal_uInt8* pSource = mpSource + mnParaSize;
-    if (mpEndValidSource - pSource < nPrecision)
+    if (static_cast<sal_uIntPtr>(mpEndValidSource - pSource) < nPrecision)
         throw css::uno::Exception("attempt to read past end of input", nullptr);
     mnParaSize += nPrecision;
     switch( nPrecision )
@@ -200,7 +200,7 @@ double CGM::ImplGetFloat( RealPrecision eRealPrecision, sal_uInt32 nRealSize )
     const bool bCompatible = false;
 #endif
 
-    if (mpEndValidSource - (mpSource + mnParaSize) < nRealSize)
+    if (static_cast<sal_uIntPtr>(mpEndValidSource - (mpSource + mnParaSize)) < nRealSize)
         throw css::uno::Exception("attempt to read past end of input", nullptr);
 
     if ( bCompatible )
diff --git a/filter/source/graphicfilter/icgm/class1.cxx b/filter/source/graphicfilter/icgm/class1.cxx
index 4d41add2448c..0d297bbe0a10 100644
--- a/filter/source/graphicfilter/icgm/class1.cxx
+++ b/filter/source/graphicfilter/icgm/class1.cxx
@@ -178,7 +178,7 @@ void CGM::ImplDoClass1()
             {
                 sal_uInt32 nSize = ImplGetUI(1);
 
-                if (mpEndValidSource - (mpSource + mnParaSize) < nSize)
+                if (static_cast<sal_uIntPtr>(mpEndValidSource - (mpSource + mnParaSize)) < nSize)
                     throw css::uno::Exception("attempt to read past end of input", nullptr);
 
                 pElement->aFontList.InsertName( mpSource + mnParaSize, nSize );


More information about the Libreoffice-commits mailing list