[Libreoffice-commits] .: 4 commits - sd/source

Katarina Machalkova bubli at kemper.freedesktop.org
Thu Apr 28 02:16:45 PDT 2011


 sd/source/filter/ppt/pptin.cxx    |    7 -
 sd/source/filter/ppt/propread.cxx |  187 +++++++-------------------------------
 sd/source/filter/ppt/propread.hxx |   49 +++++----
 3 files changed, 67 insertions(+), 176 deletions(-)

New commits:
commit 68edaff924ff2bf5b688269dc1781bf699c9d22c
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Mar 26 08:59:49 2011 -0430

    Remove tools/list.hxx include

diff --git a/sd/source/filter/ppt/propread.hxx b/sd/source/filter/ppt/propread.hxx
index 9d546fe..e0d6b97 100644
--- a/sd/source/filter/ppt/propread.hxx
+++ b/sd/source/filter/ppt/propread.hxx
@@ -35,7 +35,6 @@
 #include <tools/solar.h>
 #include <sot/storage.hxx>
 #include <tools/gen.hxx>
-#include <tools/list.hxx>
 #include <tools/stream.hxx>
 #include <tools/datetime.hxx>
 
commit 508b0dd311c8c8842d58f9537efef2a5a64f2fd5
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Mar 26 08:58:51 2011 -0430

    Change Dictionary for std::map<String,sal_uInt32>

diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index c406682..c28ea7b 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -389,10 +389,11 @@ sal_Bool ImplSdPPTImport::Import()
                 Dictionary aDict;
                 if ( pSection->GetDictionary( aDict ) )
                 {
-                    sal_uInt32 nPropId = aDict.GetProperty( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_PID_HLINKS" )));
-                    if ( nPropId )
+                    Dictionary::const_iterator iter = aDict.find( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_PID_HLINKS" )));
+
+                    if ( iter != aDict.end() )
                     {
-                        if ( pSection->GetProperty( nPropId, aPropItem ) )
+                        if ( pSection->GetProperty( iter->second, aPropItem ) )
                         {
                             aPropItem.Seek( STREAM_SEEK_TO_BEGIN );
                             aPropItem >> nType;
diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx
index c73ad68..3867f4f 100644
--- a/sd/source/filter/ppt/propread.cxx
+++ b/sd/source/filter/ppt/propread.cxx
@@ -202,72 +202,6 @@ PropItem& PropItem::operator=( PropItem& rPropItem )
 
 //	-----------------------------------------------------------------------
 
-struct Dict
-{
-    sal_uInt32	mnId;
-    String		aString;
-
-            Dict( sal_uInt32 nId, String rString ) { mnId = nId; aString = rString; };
-};
-
-//	-----------------------------------------------------------------------
-
-Dictionary::~Dictionary()
-{
-    for ( void* pPtr = First(); pPtr; pPtr = Next() )
-        delete (Dict*)pPtr;
-}
-
-//	-----------------------------------------------------------------------
-
-void Dictionary::AddProperty( sal_uInt32 nId, const String& rString )
-{
-    if ( rString.Len() )		// eindeutige namen bei properties
-    {
-        // pruefen, ob es die Propertybeschreibung in der Dictionary schon gibt
-        for ( Dict* pDict = (Dict*)First(); pDict; pDict = (Dict*)Next() )
-        {
-            if ( pDict->mnId == nId )
-            {
-                pDict->aString = rString;
-                return;
-            }
-        }
-        Insert( new Dict( nId, rString ), LIST_APPEND );
-    }
-}
-
-//	-----------------------------------------------------------------------
-
-sal_uInt32 Dictionary::GetProperty( const String& rString )
-{
-    for ( Dict* pDict = (Dict*)First(); pDict; pDict = (Dict*)Next() )
-    {
-        if ( pDict->aString == rString )
-            return pDict->mnId;
-    }
-    return 0;
-}
-
-//	-----------------------------------------------------------------------
-
-Dictionary& Dictionary::operator=( Dictionary& rDictionary )
-{
-    void* pPtr;
-
-    if ( this != &rDictionary )
-    {
-        for ( pPtr = First(); pPtr; pPtr = Next() )
-            delete (Dict*)pPtr;
-
-        for ( pPtr = rDictionary.First(); pPtr; pPtr = rDictionary.Next() )
-            Insert( new Dict( ((Dict*)pPtr)->mnId, ((Dict*)pPtr)->aString ), LIST_APPEND );
-    }
-    return *this;
-}
-
-//	-----------------------------------------------------------------------
-
 Section::Section( const Section& rSection )
     : mnTextEnc(rSection.mnTextEnc),
     maEntries(rSection.maEntries.clone())
@@ -343,7 +277,6 @@ sal_Bool Section::GetDictionary( Dictionary& rDict )
 {
     sal_Bool bRetValue = sal_False;
 
-    Dictionary aDict;
     boost::ptr_vector<PropEntry>::iterator iter;
     for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
     {
@@ -387,12 +320,11 @@ sal_Bool Section::GetDictionary( Dictionary& rDict )
                 }
                 if ( !aString.Len() )
                     break;
-                aDict.AddProperty( nId, aString );
+                rDict.insert( std::make_pair(aString,nId) );
             }
             bRetValue = sal_True;
         }
     }
-    rDict = aDict;
     return bRetValue;
 }
 
diff --git a/sd/source/filter/ppt/propread.hxx b/sd/source/filter/ppt/propread.hxx
index e14ce9d..9d546fe 100644
--- a/sd/source/filter/ppt/propread.hxx
+++ b/sd/source/filter/ppt/propread.hxx
@@ -29,6 +29,7 @@
 #ifndef _PROPREAD_HXX_
 #define _PROPREAD_HXX_
 
+#include <map>
 #include <boost/ptr_container/ptr_vector.hpp>
 
 #include <tools/solar.h>
@@ -110,6 +111,8 @@
 
 // ------------------------------------------------------------------------
 
+typedef std::map<String,sal_uInt32> Dictionary;
+
 struct PropEntry
 {
     sal_uInt32	mnId;
@@ -141,21 +144,6 @@ class PropItem : public SvMemoryStream
 
 // ------------------------------------------------------------------------
 
-class Dictionary : protected List
-{
-    friend class Section;
-
-        void		AddProperty( sal_uInt32 nId, const String& rString );
-
-    public :
-                    Dictionary(){};
-                    ~Dictionary();
-        Dictionary& operator=( Dictionary& rDictionary );
-        sal_uInt32		GetProperty( const String& rPropName );
-};
-
-// ------------------------------------------------------------------------
-
 class Section
 {
         sal_uInt16				mnTextEnc;
commit 7a2a078f016fe08b87576aa09b754bdb457c32b8
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Mar 26 08:48:07 2011 -0430

    Remove deprecated List container in PropRead
    
    Moved PropEntry to header.

diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx
index 614adca..c73ad68 100644
--- a/sd/source/filter/ppt/propread.cxx
+++ b/sd/source/filter/ppt/propread.cxx
@@ -34,22 +34,6 @@
 #include "rtl/tencinfo.h"
 #include "rtl/textenc.h"
 
-// ------------------------------------------------------------------------
-
-struct PropEntry
-{
-    sal_uInt32	mnId;
-    sal_uInt32	mnSize;
-    sal_uInt16	mnTextEnc;
-    sal_uInt8*	mpBuf;
-
-                        PropEntry( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize, sal_uInt16 nTextEnc );
-                        PropEntry( const PropEntry& rProp );
-                        ~PropEntry() { delete[] mpBuf; } ;
-
-    const PropEntry&	operator=(const PropEntry& rPropEntry);
-};
-
 PropEntry::PropEntry( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize, sal_uInt16 nTextEnc ) :
     mnId		( nId ),
     mnSize		( nBufSize ),
@@ -631,38 +615,28 @@ PropRead::PropRead( SvStorage& rStorage, const String& rName ) :
 
 void PropRead::AddSection( Section& rSection )
 {
-    Insert( new Section( rSection ), LIST_APPEND );
+    maSections.push_back( new Section( rSection ) );
 }
 
 //	-----------------------------------------------------------------------
 
 const Section* PropRead::GetSection( const sal_uInt8* pFMTID )
 {
-    Section* pSection;
-
-    for ( pSection = (Section*)First(); pSection; pSection = (Section*)Next() )
+    boost::ptr_vector<Section>::iterator it;
+    for ( it = maSections.begin(); it != maSections.end(); ++it)
     {
-        if ( memcmp( pSection->GetFMTID(), pFMTID, 16 ) == 0 )
-            break;
+        if ( memcmp( it->GetFMTID(), pFMTID, 16 ) == 0 )
+            return &(*it);
     }
-    return pSection;
-}
-
-//	-----------------------------------------------------------------------
-
-PropRead::~PropRead()
-{
-    for ( Section* pSection = (Section*)First(); pSection; pSection = (Section*)Next() )
-        delete pSection;
+    return NULL;
 }
 
 //	-----------------------------------------------------------------------
 
 void PropRead::Read()
 {
-    for ( Section* pSection = (Section*)First(); pSection; pSection = (Section*)Next() )
-        delete pSection;
-    Clear();
+    maSections.clear();
+
     if ( mbStatus )
     {
         sal_uInt32	nSections;
@@ -696,10 +670,8 @@ void PropRead::Read()
 
 //	-----------------------------------------------------------------------
 
-PropRead& PropRead::operator=( PropRead& rPropRead )
+PropRead& PropRead::operator=( const PropRead& rPropRead )
 {
-    Section* pSection;
-
     if ( this != &rPropRead )
     {
         mbStatus = rPropRead.mbStatus;
@@ -711,11 +683,7 @@ PropRead& PropRead::operator=( PropRead& rPropRead )
         mnVersionHi = rPropRead.mnVersionHi;
         memcpy( mApplicationCLSID, rPropRead.mApplicationCLSID, 16 );
 
-        for ( pSection = (Section*)First(); pSection; pSection = (Section*)Next() )
-            delete pSection;
-        Clear();
-        for ( pSection = (Section*)rPropRead.First(); pSection; pSection = (Section*)rPropRead.Next() )
-            Insert( new Section( *pSection ), LIST_APPEND );
+        maSections = rPropRead.maSections.clone();
     }
     return *this;
 }
diff --git a/sd/source/filter/ppt/propread.hxx b/sd/source/filter/ppt/propread.hxx
index b29b5f1..e14ce9d 100644
--- a/sd/source/filter/ppt/propread.hxx
+++ b/sd/source/filter/ppt/propread.hxx
@@ -110,7 +110,19 @@
 
 // ------------------------------------------------------------------------
 
-class PropEntry;
+struct PropEntry
+{
+    sal_uInt32	mnId;
+    sal_uInt32	mnSize;
+    sal_uInt16	mnTextEnc;
+    sal_uInt8*	mpBuf;
+
+    PropEntry( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBufSize, sal_uInt16 nTextEnc );
+    PropEntry( const PropEntry& rProp );
+    ~PropEntry() { delete[] mpBuf; } ;
+
+    const PropEntry& operator=(const PropEntry& rPropEntry);
+};
 
 class PropItem : public SvMemoryStream
 {
@@ -168,7 +180,7 @@ class Section
 
 // ------------------------------------------------------------------------
 
-class PropRead : private List
+class PropRead
 {
         sal_Bool				mbStatus;
         SvStorageStreamRef		mpSvStream;
@@ -178,14 +190,14 @@ class PropRead : private List
         sal_uInt16				mnVersionLo;
         sal_uInt16				mnVersionHi;
         sal_uInt8				mApplicationCLSID[ 16 ];
+        boost::ptr_vector<Section> maSections;
 
         void					AddSection( Section& rSection );
 
     public:
                                 PropRead( SvStorage& rSvStorage, const String& rName );
-                                ~PropRead();
 
-        PropRead&				operator=( PropRead& rPropRead );
+        PropRead&				operator=( const PropRead& rPropRead );
         const Section*			GetSection( const sal_uInt8* pFMTID );
         sal_Bool				IsValid() const { return mbStatus; };
         void					Read();
commit b5154cc71ac8cb49e80f64a431efde6a6a883f40
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Mar 26 08:44:54 2011 -0430

    Remove deprecated List container from Section.

diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx
index e9d0fbf..614adca 100644
--- a/sd/source/filter/ppt/propread.cxx
+++ b/sd/source/filter/ppt/propread.cxx
@@ -284,14 +284,12 @@ Dictionary& Dictionary::operator=( Dictionary& rDictionary )
 
 //	-----------------------------------------------------------------------
 
-Section::Section( Section& rSection )
-: List()
+Section::Section( const Section& rSection )
+    : mnTextEnc(rSection.mnTextEnc),
+    maEntries(rSection.maEntries.clone())
 {
-    mnTextEnc = rSection.mnTextEnc;
     for ( int i = 0; i < 16; i++ )
         aFMTID[ i ] = rSection.aFMTID[ i ];
-    for ( PropEntry* pProp = (PropEntry*)rSection.First(); pProp; pProp = (PropEntry*)rSection.Next() )
-        Insert( new PropEntry( *pProp ), LIST_APPEND );
 }
 
 //	-----------------------------------------------------------------------
@@ -307,19 +305,20 @@ Section::Section( const sal_uInt8* pFMTID )
 
 sal_Bool Section::GetProperty( sal_uInt32 nId, PropItem& rPropItem )
 {
-    PropEntry* pProp;
     if ( nId )
     {
-        for ( pProp = (PropEntry*)First(); pProp; pProp = (PropEntry*)Next() )
+        boost::ptr_vector<PropEntry>::const_iterator iter;
+        for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
         {
-            if ( pProp->mnId == nId )
+            if (iter->mnId == nId)
                 break;
         }
-        if ( pProp )
+
+        if (iter != maEntries.end())
         {
             rPropItem.Clear();
             rPropItem.SetTextEncoding( mnTextEnc );
-            rPropItem.Write( pProp->mpBuf, pProp->mnSize );
+            rPropItem.Write( iter->mpBuf,iter->mnSize );
             rPropItem.Seek( STREAM_SEEK_TO_BEGIN );
             return sal_True;
         }
@@ -339,18 +338,19 @@ void Section::AddProperty( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBu
         nId = 0;
 
     // keine doppelten PropId's zulassen, sortieren
-    for ( sal_uInt32 i = 0; i < Count(); i++ )
+    boost::ptr_vector<PropEntry>::iterator iter;
+    for ( iter = maEntries.begin(); iter != maEntries.end(); ++iter )
     {
-        PropEntry* pPropEntry = (PropEntry*)GetObject( i );
-        if ( pPropEntry->mnId == nId )
-            delete (PropEntry*)Replace( new PropEntry( nId, pBuf, nBufSize, mnTextEnc ), i );
-        else if ( pPropEntry->mnId > nId )
-            Insert( new PropEntry( nId, pBuf, nBufSize, mnTextEnc ), i );
+        if ( iter->mnId == nId )
+            maEntries.replace( iter, new PropEntry( nId, pBuf, nBufSize, mnTextEnc ));
+        else if ( iter->mnId > nId )
+            maEntries.insert( iter, new PropEntry( nId, pBuf, nBufSize, mnTextEnc ));
         else
             continue;
         return;
     }
-    Insert( new PropEntry( nId, pBuf, nBufSize, mnTextEnc ), LIST_APPEND );
+
+    maEntries.push_back( new PropEntry( nId, pBuf, nBufSize, mnTextEnc ) );
 }
 
 //	-----------------------------------------------------------------------
@@ -360,17 +360,17 @@ sal_Bool Section::GetDictionary( Dictionary& rDict )
     sal_Bool bRetValue = sal_False;
 
     Dictionary aDict;
-    PropEntry* pProp;
-
-    for ( pProp = (PropEntry*)First(); pProp; pProp = (PropEntry*)Next() )
+    boost::ptr_vector<PropEntry>::iterator iter;
+    for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
     {
-        if ( pProp->mnId == 0 )
+        if ( iter->mnId == 0 )
             break;
     }
-    if ( pProp )
+
+    if ( iter != maEntries.end() )
     {
         sal_uInt32 nDictCount, nId, nSize, nPos;
-        SvMemoryStream aStream( (sal_Int8*)pProp->mpBuf, pProp->mnSize, STREAM_READ );
+        SvMemoryStream aStream( (sal_Int8*)iter->mpBuf, iter->mnSize, STREAM_READ );
         aStream.Seek( STREAM_SEEK_TO_BEGIN );
         aStream >> nDictCount;
         for ( sal_uInt32 i = 0; i < nDictCount; i++ )
@@ -414,14 +414,6 @@ sal_Bool Section::GetDictionary( Dictionary& rDict )
 
 //	-----------------------------------------------------------------------
 
-Section::~Section()
-{
-    for ( PropEntry* pProp = (PropEntry*)First(); pProp; pProp = (PropEntry*)Next() )
-        delete pProp;
-}
-
-//	-----------------------------------------------------------------------
-
 void Section::Read( SvStorageStream *pStrm )
 {
     sal_uInt32 i, nSecOfs, nSecSize, nPropCount, nPropId, nPropOfs, nPropType, nPropSize, nCurrent, nVectorCount, nTemp, nStrmSize;
@@ -603,18 +595,13 @@ void Section::Read( SvStorageStream *pStrm )
 
 //	-----------------------------------------------------------------------
 
-Section& Section::operator=( Section& rSection )
+Section& Section::operator=( const Section& rSection )
 {
-    PropEntry* pProp;
-
     if ( this != &rSection )
     {
         memcpy( (void*)aFMTID, (void*)rSection.aFMTID, 16 );
-        for ( pProp = (PropEntry*)First(); pProp; pProp = (PropEntry*)Next() )
-            delete pProp;
-        Clear();
-        for ( pProp = (PropEntry*)rSection.First(); pProp; pProp = (PropEntry*)rSection.Next() )
-            Insert( new PropEntry( *pProp ), LIST_APPEND );
+
+        maEntries = rSection.maEntries.clone();
     }
     return *this;
 }
diff --git a/sd/source/filter/ppt/propread.hxx b/sd/source/filter/ppt/propread.hxx
index d0ac10a..b29b5f1 100644
--- a/sd/source/filter/ppt/propread.hxx
+++ b/sd/source/filter/ppt/propread.hxx
@@ -29,6 +29,8 @@
 #ifndef _PROPREAD_HXX_
 #define _PROPREAD_HXX_
 
+#include <boost/ptr_container/ptr_vector.hpp>
+
 #include <tools/solar.h>
 #include <sot/storage.hxx>
 #include <tools/gen.hxx>
@@ -108,6 +110,8 @@
 
 // ------------------------------------------------------------------------
 
+class PropEntry;
+
 class PropItem : public SvMemoryStream
 {
         sal_uInt16		mnTextEnc;
@@ -140,9 +144,10 @@ class Dictionary : protected List
 
 // ------------------------------------------------------------------------
 
-class Section : private List
+class Section
 {
         sal_uInt16				mnTextEnc;
+        boost::ptr_vector<PropEntry> maEntries;
 
     protected:
 
@@ -152,10 +157,9 @@ class Section : private List
 
     public:
                                 Section( const sal_uInt8* pFMTID );
-                                Section( Section& rSection );
-                                ~Section();
+                                Section( const Section& rSection );
 
-        Section&				operator=( Section& rSection );
+        Section&				operator=( const Section& rSection );
         sal_Bool				GetProperty( sal_uInt32 nId, PropItem& rPropItem );
         sal_Bool				GetDictionary( Dictionary& rDict );
         const sal_uInt8* 		GetFMTID() const { return aFMTID; };


More information about the Libreoffice-commits mailing list