[Libreoffice-commits] .: svtools/source

Joseph Powers jpowers at kemper.freedesktop.org
Sat Jul 23 05:29:45 PDT 2011


 svtools/source/filter/wmf/enhwmf.cxx |   51 +++++++++++++++++++++++++++--------
 svtools/source/filter/wmf/winmtf.cxx |   28 +++++++++----------
 svtools/source/filter/wmf/winmtf.hxx |   15 ++++------
 svtools/source/filter/wmf/winwmf.cxx |   25 ++++++++++-------
 4 files changed, 77 insertions(+), 42 deletions(-)

New commits:
commit a2f0686140ec30495934285e6f14080fea72cecd
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Sat Jul 23 05:27:53 2011 -0700

    Replace List with std::vector< BSaveStruct* >

diff --git a/svtools/source/filter/wmf/enhwmf.cxx b/svtools/source/filter/wmf/enhwmf.cxx
index 22cecd2..2b65495 100644
--- a/svtools/source/filter/wmf/enhwmf.cxx
+++ b/svtools/source/filter/wmf/enhwmf.cxx
@@ -376,8 +376,11 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
             break;
         }
 
-        if( aBmpSaveList.Count() && ( nRecType != EMR_STRETCHBLT ) && ( nRecType != EMR_STRETCHDIBITS ) )
-                pOut->ResolveBitmapActions( aBmpSaveList );
+        if(  !aBmpSaveList.empty()
+          && ( nRecType != EMR_STRETCHBLT )
+          && ( nRecType != EMR_STRETCHDIBITS )
+          )
+            pOut->ResolveBitmapActions( aBmpSaveList );
 
         bFlag = sal_False;
 
@@ -1016,7 +1019,7 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
                     /* Pseudocomment to add more context so that make patch.unapply
                      * works better. Ha!
                      */
-                    aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ), LIST_APPEND );
+                    aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
                     }
                 }
             }
@@ -1029,8 +1032,20 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
                 sal_uInt32	nStart = pWMF->Tell() - 8;
 
                 pWMF->SeekRel( 0x10 );
-                *pWMF >> xDest >> yDest >> xSrc >> ySrc >> cxSrc >> cySrc >> offBmiSrc >> cbBmiSrc >> offBitsSrc
-                    >> cbBitsSrc >> iUsageSrc >> dwRop >> cxDest >> cyDest;
+                *pWMF >> xDest
+                      >> yDest
+                      >> xSrc
+                      >> ySrc
+                      >> cxSrc
+                      >> cySrc
+                      >> offBmiSrc
+                      >> cbBmiSrc
+                      >> offBitsSrc
+                      >> cbBitsSrc
+                      >> iUsageSrc
+                      >> dwRop
+                      >> cxDest
+                      >> cyDest;
 
                 Bitmap		aBitmap;
                 Rectangle	aRect( Point( xDest, yDest ), Size( cxDest+1, cyDest+1 ) );
@@ -1038,8 +1053,12 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
                 cxDest = abs( (int)cxDest );		// sj: i37894, size can be negative
                 cyDest = abs( (int)cyDest );		// and also 122889
 
-                if ( (cbBitsSrc > (SAL_MAX_UINT32 - 14)) || ((SAL_MAX_UINT32 - 14) - cbBitsSrc < cbBmiSrc) )
+                if (  ((SAL_MAX_UINT32 - 14)             < cbBitsSrc)
+                   || ((SAL_MAX_UINT32 - 14) - cbBitsSrc < cbBmiSrc )
+                   )
+                {
                     bStatus = sal_False;
+                }
                 else
                 {
                     sal_uInt32 nSize = cbBmiSrc + cbBitsSrc + 14;
@@ -1071,7 +1090,7 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
                             aBitmap.Crop( aCropRect );
                         }
                     /* Another pseudocomment to make make patch.unapply work better */
-                    aBmpSaveList.Insert( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ), LIST_APPEND );
+                    aBmpSaveList.push_back( new BSaveStruct( aBitmap, aRect, dwRop, pOut->GetFillStyle () ) );
                     }
                 }
             }
@@ -1083,9 +1102,19 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
                 if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
                 {
                     LOGFONTW aLogFont;
-                    *pWMF >> aLogFont.lfHeight >> aLogFont.lfWidth >> aLogFont.lfEscapement >> aLogFont.lfOrientation >> aLogFont.lfWeight >> aLogFont.lfItalic
-                                >> aLogFont.lfUnderline >> aLogFont.lfStrikeOut	>> aLogFont.lfCharSet >> aLogFont.lfOutPrecision >> aLogFont.lfClipPrecision
-                                    >> aLogFont.lfQuality >> aLogFont.lfPitchAndFamily;
+                    *pWMF >> aLogFont.lfHeight
+                          >> aLogFont.lfWidth
+                          >> aLogFont.lfEscapement
+                          >> aLogFont.lfOrientation
+                          >> aLogFont.lfWeight
+                          >> aLogFont.lfItalic
+                          >> aLogFont.lfUnderline
+                          >> aLogFont.lfStrikeOut
+                          >> aLogFont.lfCharSet
+                          >> aLogFont.lfOutPrecision
+                          >> aLogFont.lfClipPrecision
+                          >> aLogFont.lfQuality
+                          >> aLogFont.lfPitchAndFamily;
 
                     sal_Unicode lfFaceName[ LF_FACESIZE ];
 
@@ -1451,7 +1480,7 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
         }
         pWMF->Seek( nNextPos );
     }
-    if( aBmpSaveList.Count() )
+    if( !aBmpSaveList.empty() )
         pOut->ResolveBitmapActions( aBmpSaveList );
 
     if ( bStatus )
diff --git a/svtools/source/filter/wmf/winmtf.cxx b/svtools/source/filter/wmf/winmtf.cxx
index 8bcca1b..428c0a7 100644
--- a/svtools/source/filter/wmf/winmtf.cxx
+++ b/svtools/source/filter/wmf/winmtf.cxx
@@ -1682,27 +1682,28 @@ void WinMtfOutput::ImplDrawBitmap( const Point& rPos, const Size& rSize, const B
 
 //-----------------------------------------------------------------------------------
 
-void WinMtfOutput::ResolveBitmapActions( List& rSaveList )
+void WinMtfOutput::ResolveBitmapActions( BSaveStructList_impl& rSaveList )
 {
     UpdateClipRegion();
 
-    sal_uInt32 nObjects		= rSaveList.Count();
-    sal_uInt32 nObjectsLeft	= nObjects;
+    size_t nObjects		= rSaveList.size();
+    size_t nObjectsLeft	= nObjects;
 
     while ( nObjectsLeft )
     {
-        sal_uInt32		i, nObjectsOfSameSize = 0;
-        sal_uInt32		nObjectStartIndex = nObjects - nObjectsLeft;
+        size_t          i;
+        size_t          nObjectsOfSameSize = 0;
+        size_t          nObjectStartIndex = nObjects - nObjectsLeft;
 
-        BSaveStruct*	pSave = (BSaveStruct*)rSaveList.GetObject( nObjectStartIndex );
-        Rectangle		aRect( pSave->aOutRect );
+        BSaveStruct*    pSave = rSaveList[ nObjectStartIndex ];
+        Rectangle       aRect( pSave->aOutRect );
 
         for ( i = nObjectStartIndex; i < nObjects; )
         {
             nObjectsOfSameSize++;
             if ( ++i < nObjects )
             {
-                pSave = (BSaveStruct*)rSaveList.GetObject( i );
+                pSave = rSaveList[ i ];
                 if ( pSave->aOutRect != aRect )
                     break;
             }
@@ -1712,7 +1713,7 @@ void WinMtfOutput::ResolveBitmapActions( List& rSaveList )
 
         for ( i = nObjectStartIndex; i < ( nObjectStartIndex + nObjectsOfSameSize ); i++ )
         {
-            pSave = (BSaveStruct*)rSaveList.GetObject( i );
+            pSave = rSaveList[ i ];
 
             sal_uInt32	nWinRop = pSave->nWinRop;
             sal_uInt8	nRasterOperation = (sal_uInt8)( nWinRop >> 16 );
@@ -1740,7 +1741,7 @@ void WinMtfOutput::ResolveBitmapActions( List& rSaveList )
                 {
                     if ( nObjectsOfSameSize == 2 )
                     {
-                        BSaveStruct* pSave2 = (BSaveStruct*)rSaveList.GetObject( i + 1 );
+                        BSaveStruct* pSave2 = rSaveList[ i + 1 ];
                         if ( ( pSave->aBmp.GetPrefSize() == pSave2->aBmp.GetPrefSize() ) &&
                              ( pSave->aBmp.GetPrefMapMode() == pSave2->aBmp.GetPrefMapMode() ) )
                         {
@@ -1900,10 +1901,9 @@ void WinMtfOutput::ResolveBitmapActions( List& rSaveList )
         nObjectsLeft -= nObjectsOfSameSize;
     }
 
-    void* pPtr;
-    for ( pPtr = rSaveList.First(); pPtr; pPtr = rSaveList.Next() )
-        delete (BSaveStruct*)pPtr;
-    rSaveList.Clear();
+    for( size_t i = 0, n = rSaveList.size(); i < n; ++i )
+        delete rSaveList[ i ];
+    rSaveList.clear();
 }
 
 //-----------------------------------------------------------------------------------
diff --git a/svtools/source/filter/wmf/winmtf.hxx b/svtools/source/filter/wmf/winmtf.hxx
index 270af93..cd9e82b 100644
--- a/svtools/source/filter/wmf/winmtf.hxx
+++ b/svtools/source/filter/wmf/winmtf.hxx
@@ -537,6 +537,8 @@ struct BSaveStruct
         {}
 };
 
+typedef ::std::vector< BSaveStruct* > BSaveStructList_impl;
+
 // -----------------------------------------------------------------------------
 
 enum GDIObjectType {
@@ -754,7 +756,7 @@ public:
                             sal_Bool bRecordPath = sal_False,
                             sal_Int32 nGraphicsMode = GM_COMPATIBLE
                         );
-    void                ResolveBitmapActions( List& rSaveList );
+    void                ResolveBitmapActions( BSaveStructList_impl& rSaveList );
 
     void                IntersectClipRect( const Rectangle& rRect );
     void                ExcludeClipRect( const Rectangle& rRect );
@@ -780,11 +782,11 @@ class WinMtf
 {
 protected:
 
-    WinMtfOutput*       pOut;                   //
-    SvStream*           pWMF;                   // Die einzulesende WMF/EMF-Datei
+    WinMtfOutput*           pOut;
+    SvStream*               pWMF;               // Die einzulesende WMF/EMF-Datei
 
-    sal_uInt32          nStartPos, nEndPos;
-    List                aBmpSaveList;
+    sal_uInt32              nStartPos, nEndPos;
+    BSaveStructList_impl    aBmpSaveList;
 
     FilterConfigItem*   pFilterConfigItem;
 
@@ -801,9 +803,6 @@ protected:
                             FilterConfigItem* pConfigItem = NULL
                         );
                         ~WinMtf();
-
-public:
-
 };
 
 //============================ EMFReader ==================================
diff --git a/svtools/source/filter/wmf/winwmf.cxx b/svtools/source/filter/wmf/winwmf.cxx
index 14d9f00..a3ad407 100644
--- a/svtools/source/filter/wmf/winwmf.cxx
+++ b/svtools/source/filter/wmf/winwmf.cxx
@@ -571,7 +571,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
                         aBmp.Crop( aCropRect );
                     }
                     Rectangle aDestRect( aPoint, Size( nSxe, nSye ) );
-                    aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ), LIST_APPEND );
+                    aBmpSaveList.push_back( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ) );
                 }
             }
         }
@@ -621,7 +621,7 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
                         Rectangle aCropRect( Point( nSx, nSy ), Size( nSxe, nSye ) );
                         aBmp.Crop( aCropRect );
                     }
-                    aBmpSaveList.Insert( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ), LIST_APPEND );
+                    aBmpSaveList.push_back( new BSaveStruct( aBmp, aDestRect, nWinROP, pOut->GetFillStyle () ) );
                 }
             }
         }
@@ -1121,9 +1121,14 @@ void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
                 }
                 *pWMF >> nRecSize >> nFunction;
 
-                if( pWMF->GetError() || ( nRecSize < 3 ) || ( nRecSize==3 && nFunction==0 ) || pWMF->IsEof() )
+                if(  pWMF->GetError()
+                  || ( nRecSize < 3 )
+                  || (  nRecSize  == 3
+                     && nFunction == 0
+                     )
+                  || pWMF->IsEof()
+                  )
                 {
-
                     if( pWMF->IsEof() )
                         pWMF->SetError( SVSTREAM_FILEFORMAT_ERROR );
 
@@ -1131,13 +1136,15 @@ void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
                 }
                 if ( !bEMFAvailable )
                 {
-                    if( aBmpSaveList.Count() &&
-                        ( nFunction != W_META_STRETCHDIB ) &&
-                        ( nFunction != W_META_DIBBITBLT ) &&
-                        ( nFunction != W_META_DIBSTRETCHBLT ) )
+                    if(   !aBmpSaveList.empty()
+                      && ( nFunction != W_META_STRETCHDIB    )
+                      && ( nFunction != W_META_DIBBITBLT     )
+                      && ( nFunction != W_META_DIBSTRETCHBLT )
+                      )
                     {
                         pOut->ResolveBitmapActions( aBmpSaveList );
                     }
+
                     if ( !nSkipActions )
                         ReadRecordParams( nFunction );
                     else
@@ -1181,7 +1188,7 @@ void WMFReader::ReadWMF(WMF_APMFILEHEADER *pAPMHeader)
         else
             pWMF->SetError( SVSTREAM_GENERALERROR );
 
-        if( !pWMF->GetError() && aBmpSaveList.Count() )
+        if( !pWMF->GetError() && !aBmpSaveList.empty() )
             pOut->ResolveBitmapActions( aBmpSaveList );
     }
     if ( pWMF->GetError() )


More information about the Libreoffice-commits mailing list