Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index



From e8e1873508e13201689c8ef12eb2b83cefd18fe7 Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Tue, 24 May 2011 09:21:40 -0430
Subject: [PATCH] Replace List for std::map<sal_uInt32,ByteString>.

---
 filter/inc/filter/msfilter/msdffimp.hxx |    6 ++--
 filter/source/msfilter/msdffimp.cxx     |   57 +++++++++----------------------
 2 files changed, 19 insertions(+), 44 deletions(-)

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index c1a0294..1fee4cb 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -503,7 +503,7 @@ protected :
 
     bool ReadGraphic( SvStream& rSt, sal_uLong nIndex, Graphic& rGraphic ) const;
     SdrObject* ImportFontWork( SvStream&, SfxItemSet&, Rectangle& rBoundRect ) const;
-    SdrObject* ImportGraphic( SvStream&, SfxItemSet&, const DffObjData& ) const;
+    SdrObject* ImportGraphic( SvStream&, SfxItemSet&, const DffObjData& );
     // #i32596# - pass <nCalledByGroup> to method
     // Needed in the Writer Microsoft Word import to avoid import of OLE objects
     // inside groups. Instead a graphic object is created.
@@ -560,7 +560,7 @@ public:
     void*                              pSvxMSDffDummy1;
     void*                              pSvxMSDffDummy2;
     void*                              pSvxMSDffDummy3;
-    List*                              pEscherBlipCache;
+    std::map<sal_uInt32,ByteString> aEscherBlipCache;
 
     DffRecordManager   maShapeRecords;
     ColorData                  mnDefaultColor;
@@ -650,7 +650,7 @@ public:
 
     Rueckgabewert: sal_True, im Erfolgsfalls, sal_False bei Fehler
 */
-    sal_Bool GetBLIP( sal_uLong nIdx, Graphic& rData, Rectangle* pVisArea = NULL ) const;
+    sal_Bool GetBLIP( sal_uLong nIdx, Graphic& rData, Rectangle* pVisArea = NULL );
 
 /*
     GetBLIPDirect()            -Einlesen eines BLIP aus schon positioniertem Stream
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 31c8582..279551b 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -1867,7 +1867,7 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, 
co
             {
                 Graphic aGraf;
                 // first try to get BLIP from cache
-                sal_Bool bOK = rManager.GetBLIP( GetPropertyValue( DFF_Prop_fillBlip ), aGraf, 
NULL );
+                sal_Bool bOK = const_cast<SvxMSDffManager&>(rManager).GetBLIP( GetPropertyValue( 
DFF_Prop_fillBlip ), aGraf, NULL );
                 // then try directly from stream (i.e. Excel chart hatches/bitmaps)
                 if ( !bOK )
                     bOK = SeekToContent( DFF_Prop_fillBlip, rIn ) && rManager.GetBLIPDirect( rIn, 
aGraf, NULL );
@@ -3400,16 +3400,6 @@ DffRecordHeader* DffRecordManager::GetRecordHeader( sal_uInt16 nRecId, 
DffSeekTo
 //  private Methoden
 //---------------------------------------------------------------------------
 
-struct EscherBlipCacheEntry
-{
-    ByteString aUniqueID;
-    sal_uInt32  nBlip;
-
-    EscherBlipCacheEntry( sal_uInt32 nBlipId, const ByteString& rUniqueID ) :
-        aUniqueID( rUniqueID ),
-        nBlip( nBlipId ) {}
-};
-
 void SvxMSDffManager::Scale( sal_Int32& rVal ) const
 {
     if ( bNeedMap )
@@ -4334,7 +4324,7 @@ static void lcl_ApplyCropping( const DffPropSet& rPropSet, SfxItemSet* pSet, 
Gra
     }
 }
 
-SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, const DffObjData& 
rObjData ) const
+SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, const DffObjData& 
rObjData )
 {
     SdrObject*  pRet = NULL;
     String      aFilename;
@@ -6040,7 +6030,6 @@ SvxMSDffManager::SvxMSDffManager(SvStream& rStCtrl_,
      pStData2( pStData2_ ),
      nSvxMSDffSettings( 0 ),
      nSvxMSDffOLEConvFlags( 0 ),
-     pEscherBlipCache( NULL ),
      mnDefaultColor( mnDefaultColor_),
      mpTracer( pTracer ),
      mbTracing( sal_False )
@@ -6092,7 +6081,6 @@ SvxMSDffManager::SvxMSDffManager( SvStream& rStCtrl_, const String& rBaseURL, 
MS
      pStData2( 0 ),
      nSvxMSDffSettings( 0 ),
      nSvxMSDffOLEConvFlags( 0 ),
-     pEscherBlipCache( NULL ),
      mnDefaultColor( COL_DEFAULT ),
      mpTracer( pTracer ),
      mbTracing( sal_False )
@@ -6107,13 +6095,6 @@ SvxMSDffManager::SvxMSDffManager( SvStream& rStCtrl_, const String& 
rBaseURL, MS
 
 SvxMSDffManager::~SvxMSDffManager()
 {
-    if ( pEscherBlipCache )
-    {
-        void* pPtr;
-        for ( pPtr = pEscherBlipCache->First(); pPtr; pPtr = pEscherBlipCache->Next() )
-            delete (EscherBlipCacheEntry*)pPtr;
-        delete pEscherBlipCache;
-    }
     delete pBLIPInfos;
     delete pShapeInfos;
     delete pShapeOrders;
@@ -6716,29 +6697,26 @@ sal_Bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*&         
rpShape,
 /*      Zugriff auf ein BLIP zur Laufzeit (bei bereits bekannter Blip-Nr)
     ---------------------------------
 ******************************************************************************/
-sal_Bool SvxMSDffManager::GetBLIP( sal_uLong nIdx_, Graphic& rData, Rectangle* pVisArea ) const
+sal_Bool SvxMSDffManager::GetBLIP( sal_uLong nIdx_, Graphic& rData, Rectangle* pVisArea )
 {
     sal_Bool bOk = sal_False;       // Ergebnisvariable initialisieren
     if ( pStData )
     {
         // check if a graphic for this blipId is already imported
-        if ( nIdx_ && pEscherBlipCache )
+        if ( nIdx_)
         {
-            EscherBlipCacheEntry* pEntry;
-            for ( pEntry = (EscherBlipCacheEntry*)pEscherBlipCache->First(); pEntry;
-                    pEntry = (EscherBlipCacheEntry*)pEscherBlipCache->Next() )
+            std::map<sal_uInt32,ByteString>::iterator iter = aEscherBlipCache.find(nIdx_);
+
+            if (iter != aEscherBlipCache.end())
             {
-                if ( pEntry->nBlip == nIdx_ )
-                {      /* if this entry is available, then it should be possible
-                    to get the Graphic via GraphicObject */
-                    GraphicObject aGraphicObject( pEntry->aUniqueID );
-                    rData = aGraphicObject.GetGraphic();
-                    if ( rData.GetType() != GRAPHIC_NONE )
-                        bOk = sal_True;
-                    else
-                        delete (EscherBlipCacheEntry*)pEscherBlipCache->Remove();
-                    break;
-                }
+                /* if this entry is available, then it should be possible
+                to get the Graphic via GraphicObject */
+                GraphicObject aGraphicObject( iter->second );
+                rData = aGraphicObject.GetGraphic();
+                if ( rData.GetType() != GRAPHIC_NONE )
+                    bOk = sal_True;
+                else
+                    aEscherBlipCache.erase(iter);
             }
         }
         if ( !bOk )
@@ -6793,10 +6771,7 @@ sal_Bool SvxMSDffManager::GetBLIP( sal_uLong nIdx_, Graphic& rData, 
Rectangle* p
             {
                 // create new BlipCacheEntry for this graphic
                 GraphicObject aGraphicObject( rData );
-                if ( !pEscherBlipCache )
-                    const_cast <SvxMSDffManager*> (this)->pEscherBlipCache = new List();
-                EscherBlipCacheEntry* pNewEntry = new EscherBlipCacheEntry( nIdx_, 
aGraphicObject.GetUniqueID() );
-                pEscherBlipCache->Insert( pNewEntry, LIST_APPEND );
+                aEscherBlipCache.insert(std::make_pair(nIdx_,aGraphicObject.GetUniqueID()));
             }
         }
     }
-- 
1.7.3.4

From a00a6d3c14323d9afa532cc2f44e1127ce56e758 Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Tue, 24 May 2011 09:22:21 -0430
Subject: [PATCH] Replace List for std::map<sal_uInt32,ByteString>.

---
 sw/source/filter/ww8/ww8par.cxx |   12 ++++++------
 sw/source/filter/ww8/ww8par.hxx |    2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 2d5eca7..be2c2b0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -340,7 +340,7 @@ SwMSDffManager::SwMSDffManager( SwWW8ImplReader& rRdr )
     : SvxMSDffManager(*rRdr.pTableStream, rRdr.GetBaseURL(), rRdr.pWwFib->fcDggInfo,
         rRdr.pDataStream, 0, 0, COL_WHITE, 12, rRdr.pStrm,
         rRdr.maTracer.GetTrace()),
-    rReader(rRdr), pFallbackStream(0), pOldEscherBlipCache(0)
+    rReader(rRdr), pFallbackStream(0)
 {
     SetSvxMSDffSettings( GetSvxMSDffSettings() );
     nSvxMSDffOLEConvFlags = SwMSDffManager::GetFilterFlags();
@@ -413,19 +413,19 @@ SdrObject* SwMSDffManager::ImportOLE( long nOLEId,
 
 void SwMSDffManager::DisableFallbackStream()
 {
-    OSL_ENSURE(!pFallbackStream || !pOldEscherBlipCache,
+    OSL_ENSURE(!pFallbackStream,
         "if you're recursive, you're broken");
     pFallbackStream = pStData2;
-    pOldEscherBlipCache = pEscherBlipCache;
-    pEscherBlipCache = 0;
+    aOldEscherBlipCache = aEscherBlipCache;
+    aEscherBlipCache.clear();
     pStData2 = 0;
 }
 
 void SwMSDffManager::EnableFallbackStream()
 {
     pStData2 = pFallbackStream;
-    pEscherBlipCache = pOldEscherBlipCache;
-    pOldEscherBlipCache = 0;
+    aEscherBlipCache = aOldEscherBlipCache;
+    aOldEscherBlipCache.clear();
     pFallbackStream = 0;
 }
 
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 0ab33fc..96c8d37 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -559,7 +559,7 @@ class SwMSDffManager : public SvxMSDffManager
 private:
     SwWW8ImplReader& rReader;
     SvStream *pFallbackStream;
-    List *pOldEscherBlipCache;
+    std::map<sal_uInt32,ByteString> aOldEscherBlipCache;
 
     virtual sal_Bool GetOLEStorageName( long nOLEId, String& rStorageName,
         SvStorageRef& rSrcStorage, com::sun::star::uno::Reference < 
com::sun::star::embed::XStorage >& rDestStorage ) const;
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.