[Libreoffice-commits] .: filter/source

Joseph Powers jpowers at kemper.freedesktop.org
Fri Jun 17 23:37:40 PDT 2011


 filter/source/msfilter/svdfppt.cxx |   65 +++++++++++++++++++------------------
 1 file changed, 34 insertions(+), 31 deletions(-)

New commits:
commit a7a16b8561796a11c5cc697601910251fbd09d33
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Fri Jun 17 07:48:04 2011 -0700

    Replace List with std::vector< PPTFieldEntry* >

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 79e9f62..3f32014 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -6581,7 +6581,7 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                             // now will search for possible textextensions such as date/time fields
                             // or ParaTabStops and append them on this textobj
                             rIn.Seek( nFilePos );
-                            List* pFieldList = NULL;
+                            ::std::vector< PPTFieldEntry* > FieldList;
                             while ( rIn.Tell() < aClientTextBoxHd.GetRecEndFilePos() )
                             {
                                 rIn >> aTextHd;
@@ -6753,20 +6753,23 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                 aTextHd.SeekToEndOfRecord( rIn );
                                 if ( pEntry )
                                 {
-                                    if ( !pFieldList )
-                                        pFieldList = new List;
-                                    sal_uInt32 n;
-                                    for ( n = 0; n < pFieldList->Count(); n++ )
-                                    {   // sorting fields ( hi >> lo )
-                                        if ( ( (PPTFieldEntry*)pFieldList->GetObject( n ) )->nPos < pEntry->nPos )
+                                    // sorting fields ( hi >> lo )
+                                    ::std::vector< PPTFieldEntry* >::iterator it = FieldList.begin();
+                                    for( ; it < FieldList.end(); ++it ) {
+                                        if ( (*it)->nPos < pEntry->nPos ) {
                                             break;
+                                        }
+                                    }
+                                    if ( it < FieldList.end() ) {
+                                        FieldList.insert( it, pEntry );
+                                    } else {
+                                        FieldList.push_back( pEntry );
                                     }
-                                    pFieldList->Insert( pEntry, (sal_uInt32)n );
                                 }
                             }
-                            if ( pFieldList )
+                            if ( !FieldList.empty() )
                             {
-                                PPTFieldEntry* pFE = (PPTFieldEntry*)pFieldList->First();
+                                ::std::vector< PPTFieldEntry* >::iterator FE = FieldList.begin();
                                 List& aCharPropList = aStyleTextPropReader.aCharPropList;
 
                                 sal_Int32   i = nParagraphs - 1;
@@ -6774,21 +6777,21 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
 
                                 // at this point we just have a list of textportions(aCharPropList)
                                 // the next while loop tries to resolve the list of fields(pFieldList)
-                                while( pFE && ( n >= 0 ) && ( i >= 0 ) )
+                                while( ( FE < FieldList.end() ) && ( n >= 0 ) && ( i >= 0 ) )
                                 {
-                                     PPTCharPropSet* pSet  = (PPTCharPropSet*)aCharPropList.GetObject( n );
+                                    PPTCharPropSet* pSet  = (PPTCharPropSet*)aCharPropList.GetObject( n );
                                     String aString( pSet->maString );
                                     sal_uInt32 nCount = aString.Len();
                                     sal_uInt32 nPos = pSet->mnOriginalTextPos + nCount;
-                                    while ( pFE && nCount-- )
+                                    while ( ( FE < FieldList.end() ) && nCount-- )
                                     {
                                         nPos--;
-                                        while ( pFE && ( pFE->nPos > nPos ) )
-                                            pFE = (PPTFieldEntry*)pFieldList->Next();
-                                        if ( !pFE )
+                                        while ( ( FE < FieldList.end() ) && ( (*FE)->nPos > nPos ) )
+                                            ++FE;
+                                        if ( !(FE < FieldList.end()) )
                                             break;
 
-                                        if ( pFE->nPos == nPos )
+                                        if ( (*FE)->nPos == nPos )
                                         {
                                             if ( aString.GetChar( (sal_uInt16)nCount ) == 0x2a )
                                             {
@@ -6800,10 +6803,10 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                                     pNewCPS->maString = String( aString, (sal_uInt16)nCount + 1, (sal_uInt16)nBehind );
                                                     aCharPropList.Insert( pNewCPS, n + 1 );
                                                 }
-                                                if ( pFE->pField2 )
+                                                if ( (*FE)->pField2 )
                                                 {
                                                     PPTCharPropSet* pNewCPS = new PPTCharPropSet( *pSet );
-                                                    pNewCPS->mpFieldItem = pFE->pField2, pFE->pField2 = NULL;
+                                                    pNewCPS->mpFieldItem = (*FE)->pField2, (*FE)->pField2 = NULL;
                                                     aCharPropList.Insert( pNewCPS, n + 1 );
 
                                                     pNewCPS = new PPTCharPropSet( *pSet );
@@ -6816,18 +6819,18 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                                     pNewCPS->maString = String( aString, (sal_uInt16)0, (sal_uInt16)nCount );
                                                     aCharPropList.Insert( pNewCPS, n++ );
                                                 }
-                                                if ( pFE->pField1 )
+                                                if ( (*FE)->pField1 )
                                                 {
-                                                    pSet->mpFieldItem = pFE->pField1, pFE->pField1 = NULL;
+                                                    pSet->mpFieldItem = (*FE)->pField1, (*FE)->pField1 = NULL;
                                                 }
-                                                else if ( pFE->pString )
-                                                    pSet->maString = *pFE->pString;
+                                                else if ( (*FE)->pString )
+                                                    pSet->maString = *(*FE)->pString;
                                             }
                                             else
                                             {
-                                                if ( pFE->nTextRangeEnd )   // text range hyperlink
+                                                if ( (*FE)->nTextRangeEnd )   // text range hyperlink
                                                 {
-                                                    sal_uInt32 nHyperLen = pFE->nTextRangeEnd - nPos;
+                                                    sal_uInt32 nHyperLen = (*FE)->nTextRangeEnd - nPos;
                                                     if ( nHyperLen )
                                                     {
                                                         PPTCharPropSet* pBefCPS = NULL;
@@ -6848,10 +6851,10 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                                             sal_Int32       nNextStringLen = pCurrent->maString.Len();
 
                                                             DBG_ASSERT( pFE->pField1, "missing field!" );
-                                                            if (!pFE->pField1)
+                                                            if (!(*FE)->pField1)
                                                                 break;
 
-                                                            const SvxURLField* pField = (const SvxURLField*)pFE->pField1->GetField();
+                                                            const SvxURLField* pField = (const SvxURLField*)(*FE)->pField1->GetField();
 
                                                             if ( pCurrent->mpFieldItem )
                                                             {
@@ -6893,7 +6896,7 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                                             }
                                                             nIdx++;
                                                         }
-                                                        delete pFE->pField1, pFE->pField1 = NULL;
+                                                        delete (*FE)->pField1, (*FE)->pField1 = NULL;
 
                                                         if ( pBefCPS )
                                                         {
@@ -6909,9 +6912,9 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                     }
                                     n--;
                                 }
-                                for ( void* pPtr = pFieldList->First(); pPtr; pPtr = pFieldList->Next() )
-                                    delete (PPTFieldEntry*)pPtr;
-                                delete pFieldList;
+                                for( size_t i = 0, n = FieldList.size(); i < n; ++i ) {
+                                    delete FieldList[ i ];
+                                }
                             }
                             mpImplTextObj->mpParagraphList = new PPTParagraphObj*[ nParagraphs ];
                             aStyleTextPropReader.aCharPropList.First();


More information about the Libreoffice-commits mailing list