[Libreoffice-commits] .: idl/inc tools/inc tools/source

Tor Lillqvist tml at kemper.freedesktop.org
Thu Mar 8 03:55:34 PST 2012


 idl/inc/types.hxx         |    1 +
 tools/inc/tools/pstm.hxx  |    7 ++++---
 tools/source/ref/pstm.cxx |   19 ++++++++++++-------
 3 files changed, 17 insertions(+), 10 deletions(-)

New commits:
commit e36a9a64f14581b2c7d567d17a72be6d3ea8dccc
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Mar 8 13:36:58 2012 +0200

    Convert tools/table.hxx to std::map
    
    Convert usage of tools/table.hxx to std::map in aPTable field of
    SvPersistStream class.

diff --git a/idl/inc/types.hxx b/idl/inc/types.hxx
index 09ff414..508f5a0 100644
--- a/idl/inc/types.hxx
+++ b/idl/inc/types.hxx
@@ -31,6 +31,7 @@
 
 #include <rtl/strbuf.hxx>
 #include <tools/ref.hxx>
+#include <tools/table.hxx>
 #include <basobj.hxx>
 
 struct SvSlotElement;
diff --git a/tools/inc/tools/pstm.hxx b/tools/inc/tools/pstm.hxx
index 6f1e8e9..c989977 100644
--- a/tools/inc/tools/pstm.hxx
+++ b/tools/inc/tools/pstm.hxx
@@ -31,12 +31,11 @@
 #include <boost/unordered_map.hpp>
 #include "tools/toolsdllapi.h"
 
-#include <tools/table.hxx>
-
 #include <tools/unqidx.hxx>
 #include <tools/ref.hxx>
 #include <tools/rtti.hxx>
 #include <tools/stream.hxx>
+#include <map>
 
 #define ERRCODE_IO_NOFACTORY ERRCODE_IO_WRONGFORMAT
 
@@ -150,6 +149,8 @@ SV_IMPL_PERSIST_LIST(ClassName,EntryName)
 
 DECLARE_UNIQUEINDEX( SvPersistUIdx,SvPersistBase *)
 
+typedef std::map<SvPersistBase*, sal_uIntPtr> PersistBaseMap;
+
 //=========================================================================
 class SvStream;
 class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
@@ -191,7 +192,7 @@ class TOOLS_DLLPUBLIC SvPersistStream : public SvStream
 {
     SvClassManager &        rClassMgr;
     SvStream *              pStm;
-    Table                   aPTable; // Pointer und Key gedreht
+    PersistBaseMap          aPTable; // Pointer und Key gedreht
     SvPersistUIdx           aPUIdx;
     sal_uIntPtr                   nStartIdx;
     const SvPersistStream * pRefStm;
diff --git a/tools/source/ref/pstm.cxx b/tools/source/ref/pstm.cxx
index 4c95a6f..cba5070 100644
--- a/tools/source/ref/pstm.cxx
+++ b/tools/source/ref/pstm.cxx
@@ -315,10 +315,15 @@ void SvPersistStream::FlushData()
 *************************************************************************/
 sal_uIntPtr SvPersistStream::GetIndex( SvPersistBase * pObj ) const
 {
-    sal_uIntPtr nId = (sal_uIntPtr)aPTable.Get( (sal_uIntPtr)pObj );
-    if( !nId && pRefStm )
-        return pRefStm->GetIndex( pObj );
-    return nId;
+    PersistBaseMap::const_iterator it = aPTable.find( pObj );
+    if( it == aPTable.end() )
+    {
+        if ( pRefStm )
+            return pRefStm->GetIndex( pObj );
+        else
+            return 0;
+    }
+    return it->second;
 }
 
 /*************************************************************************
@@ -653,7 +658,7 @@ SvPersistStream& SvPersistStream::WritePointer
         else
         {
             nId = aPUIdx.Insert( pObj );
-            aPTable.Insert( (sal_uIntPtr)pObj, (void *)nId );
+            aPTable[ pObj ] = nId;
             nP |= P_OBJ;
         }
         WriteId( *this, nP, nId, pObj->GetClassId() );
@@ -722,7 +727,7 @@ sal_uInt32 SvPersistStream::ReadObj
                 // unbedingt erst in Tabelle eintragen
                 sal_uIntPtr nNewId = aPUIdx.Insert( rpObj );
                 // um den gleichen Zustand, wie nach dem Speichern herzustellen
-                aPTable.Insert( (sal_uIntPtr)rpObj, (void *)nNewId );
+                aPTable[ rpObj ] = nNewId;
                 DBG_ASSERT( !(nHdr & P_DBGUTIL) || nId == nNewId,
                             "read write id conflict: not the same" );
             }
@@ -835,7 +840,7 @@ SvStream& operator >>
 
             // Die Id eines Objektes wird nie modifiziert
             rThis.aPUIdx.Insert( nId, pEle );
-            rThis.aPTable.Insert( (sal_uIntPtr)pEle, (void *)nId );
+            rThis.aPTable[ pEle ] = nId;
         }
     }
     else


More information about the Libreoffice-commits mailing list