[Libreoffice-commits] .: 2 commits - filter/inc filter/source svl/source sw/source

Michael Stahl mst at kemper.freedesktop.org
Fri Jul 27 11:12:53 PDT 2012


 filter/inc/filter/msfilter/msdffimp.hxx |   14 ++++++++--
 filter/source/msfilter/msdffimp.cxx     |   42 ++++++++++++--------------------
 svl/source/svdde/ddesvr.cxx             |   25 +++++++++++--------
 sw/source/filter/ww8/ww8par.cxx         |    6 ++--
 4 files changed, 45 insertions(+), 42 deletions(-)

New commits:
commit 5dbbe223c8586bd653685d27c664aa8395632e4a
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Jul 27 20:03:08 2012 +0200

    convert DdeItemImp to std::vector
    
    ... with some fixes from the committer.
    
    Change-Id: I51e0c14222a90e7826711b6bc02a6b70eef887b5

diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx
index 0e4dbd1..ea221a7 100644
--- a/svl/source/svdde/ddesvr.cxx
+++ b/svl/source/svdde/ddesvr.cxx
@@ -23,9 +23,9 @@
 #include <algorithm>
 #include <comphelper/string.hxx>
 #include <svl/svdde.hxx>
-#include <svl/svarray.hxx>
 #include <tools/debug.hxx>
 #include <osl/thread.h>
+#include <o3tl/sorted_vector.hxx>
 
 enum DdeItemType
 {
@@ -41,8 +41,7 @@ struct DdeItemImpData
     DdeItemImpData( sal_uLong nH ) : nHCnv( nH ), nCnt( 1 ) {}
 };
 
-SV_DECL_VARARR( DdeItemImp, DdeItemImpData, 1 )
-SV_IMPL_VARARR( DdeItemImp, DdeItemImpData )
+class DdeItemImp : public std::vector<DdeItemImpData> {};
 
 // --- DdeInternat::SvrCallback() ----------------------------------
 
@@ -864,7 +863,7 @@ void DdeItem::IncMonitor( sal_uLong nHCnv )
     }
     else
     {
-        for( sal_uInt16 n = pImpData->Count(); n; )
+        for( sal_uInt16 n = pImpData->size(); n; )
             if( (*pImpData)[ --n ].nHCnv == nHCnv )
             {
                 ++(*pImpData)[ n ].nHCnv;
@@ -872,7 +871,7 @@ void DdeItem::IncMonitor( sal_uLong nHCnv )
             }
     }
 
-    pImpData->Insert( DdeItemImpData( nHCnv ), pImpData->Count() );
+    pImpData->push_back( DdeItemImpData( nHCnv ) );
 }
 
 // --- DdeItem::DecMonitor() ------------------------------------------
@@ -881,14 +880,17 @@ void DdeItem::DecMonitor( sal_uLong nHCnv )
 {
     if( pImpData )
     {
-        DdeItemImpData* pData = (DdeItemImpData*)pImpData->GetData();
-        for( sal_uInt16 n = pImpData->Count(); n; --n, ++pData )
+        for( sal_uInt16 n = 0; n < pImpData->size(); ++n )
+        {
+            DdeItemImpData* pData = &(*pImpData)[n];
             if( pData->nHCnv == nHCnv )
             {
                 if( !pData->nCnt || !--pData->nCnt )
                 {
-                    if( 1 < pImpData->Count() )
-                        pImpData->Remove( pImpData->Count() - n );
+                    if( 1 < pImpData->size() )
+                    {
+                        pImpData->erase(pImpData->begin() + n);
+                    }
                     else
                     {
                         delete pImpData, pImpData = 0;
@@ -898,6 +900,7 @@ void DdeItem::DecMonitor( sal_uLong nHCnv )
                 }
                 return ;
             }
+        }
     }
 }
 
@@ -907,8 +910,10 @@ short DdeItem::GetLinks()
 {
     short nCnt = 0;
     if( pImpData )
-        for( sal_uInt16 n = pImpData->Count(); n; )
+        for( sal_uInt16 n = pImpData->size(); n; )
+        {
             nCnt = nCnt + (*pImpData)[ --n ].nCnt;
+        }
     return nCnt;
 }
 
commit 3ae618f9e4c34d5f6f10d953e3fb074018001748
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Jul 27 19:57:22 2012 +0200

    convert SvxMSDffShapeInfos to sorted_vector
    
    ... with some fixes from the committer.
    
    Change-Id: I9408d8b7c80aff1d1fdb23b852b79bfee7dc4c95

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index e127aa8..6b20aaa 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -32,7 +32,6 @@
 #include <com/sun/star/uno/Reference.h>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <tools/solar.h>
-#include <svl/svarray.hxx>
 #include <tools/color.hxx>
 #include <tools/gen.hxx>
 #include <svx/msdffdef.hxx>
@@ -46,6 +45,7 @@
 #include <set>
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/ptr_container/ptr_set.hpp>
+#include <o3tl/sorted_vector.hxx>
 
 class Graphic;
 class SvStream;
@@ -177,7 +177,6 @@ public:
 
 #define COL_DEFAULT RGB_COLORDATA( 0xFA, 0xFB, 0xFC )
 
-typedef SvxMSDffShapeInfo* SvxMSDffShapeInfo_Ptr;
 typedef ::std::map< sal_Int32, SdrObject* > SvxMSDffShapeIdContainer;
 
 #define SVEXT_PERSIST_STREAM "\002OlePres000"
@@ -191,7 +190,16 @@ public:
 };
 
 // the following will be sorted explicitly:
-SV_DECL_PTRARR_SORT_DEL_VISIBILITY( SvxMSDffShapeInfos, SvxMSDffShapeInfo_Ptr, 16, MSFILTER_DLLPUBLIC )
+class SvxMSDffShapeInfos
+    : public o3tl::sorted_vector<SvxMSDffShapeInfo*,
+                o3tl::less_ptr_to<SvxMSDffShapeInfo> >
+{
+public:
+    ~SvxMSDffShapeInfos()
+    {
+        DeleteAndDestroyAll();
+    }
+};
 
 #define SVXMSDFF_SETTINGS_CROP_BITMAPS      1
 #define SVXMSDFF_SETTINGS_IMPORT_PPT        2
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index d29e0db..9e10b63 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5362,10 +5362,10 @@ SdrObject* SvxMSDffManager::ProcessObj(SvStream& rSt,
                 SvxMSDffShapeInfo aTmpRec( 0, pImpRec->nShapeId );
                 aTmpRec.bSortByShapeId = sal_True;
 
-                sal_uInt16 nFound;
-                if( pShapeInfos->Seek_Entry( &aTmpRec, &nFound ) )
+                SvxMSDffShapeInfos::const_iterator it = pShapeInfos->find( &aTmpRec );
+                if( it != pShapeInfos->end() )
                 {
-                    SvxMSDffShapeInfo& rInfo = *pShapeInfos->GetObject(nFound);
+                    SvxMSDffShapeInfo& rInfo = **it;
                     pTextImpRec->bReplaceByFly   = rInfo.bReplaceByFly;
                     pTextImpRec->bLastBoxInChain = rInfo.bLastBoxInChain;
                 }
@@ -5715,13 +5715,6 @@ void SvxMSDffManager::RemoveFromShapeOrder( SdrObject* pObject ) const
 
 
 //---------------------------------------------------------------------------
-//  Hilfs Deklarationen
-//---------------------------------------------------------------------------
-
-SV_IMPL_OP_PTRARR_SORT( SvxMSDffShapeInfos,     SvxMSDffShapeInfo_Ptr   );
-
-
-//---------------------------------------------------------------------------
 //  exported class: Public Methods
 //---------------------------------------------------------------------------
 
@@ -5896,10 +5889,8 @@ void SvxMSDffManager::GetFidclData( sal_uInt32 nOffsDggL )
 void SvxMSDffManager::CheckTxBxStoryChain()
 {
     SvxMSDffShapeInfos* pOld = pShapeInfos;
-    sal_uInt16 nCnt             = pOld->Count();
-    pShapeInfos             = new SvxMSDffShapeInfos( (nCnt < 255)
-                                                     ? nCnt
-                                                     : 255 );
+    sal_uInt16 nCnt             = pOld->size();
+    pShapeInfos             = new SvxMSDffShapeInfos;
     // altes Info-Array ueberarbeiten
     // (ist sortiert nach nTxBxComp)
     sal_uLong nChain    = ULONG_MAX;
@@ -5908,7 +5899,7 @@ void SvxMSDffManager::CheckTxBxStoryChain()
     sal_uInt16 nObj;
     for( nObj = 0; nObj < nCnt; ++nObj )
     {
-        SvxMSDffShapeInfo* pObj = pOld->GetObject( nObj );
+        SvxMSDffShapeInfo* pObj = (*pOld)[nObj];
         if( pObj->nTxBxComp )
         {
             pObj->bLastBoxInChain = sal_False;
@@ -5921,7 +5912,7 @@ void SvxMSDffManager::CheckTxBxStoryChain()
             {
                 // voriger war letzter seiner Gruppe
                 if( nObj )
-                    pOld->GetObject( nObj-1 )->bLastBoxInChain = sal_True;
+                    (*pOld)[ nObj-1 ]->bLastBoxInChain = sal_True;
                 // Merker und Hilfs-Flag zuruecksetzen
                 nObjMark = nObj;
                 nChain = pObj->nTxBxComp;
@@ -5935,7 +5926,7 @@ void SvxMSDffManager::CheckTxBxStoryChain()
                 bSetReplaceFALSE = sal_True;
                 // ggfs Flag in Anfang der Gruppe austragen
                 for( sal_uInt16 nObj2 = nObjMark; nObj2 < nObj; ++nObj2 )
-                    pOld->GetObject( nObj2 )->bReplaceByFly = sal_False;
+                    (*pOld)[ nObj2 ]->bReplaceByFly = sal_False;
             }
 
             if( bSetReplaceFALSE )
@@ -5947,13 +5938,13 @@ void SvxMSDffManager::CheckTxBxStoryChain()
         // (aber nach nShapeId sortieren)
         pObj->bSortByShapeId = sal_True;
         pObj->nTxBxComp = pObj->nTxBxComp & 0xFFFF0000;
-        pShapeInfos->Insert( pObj );
+        pShapeInfos->insert( pObj );
     }
     // voriger war letzter seiner Gruppe
     if( nObj )
-        pOld->GetObject( nObj-1 )->bLastBoxInChain = sal_True;
+        (*pOld)[ nObj-1 ]->bLastBoxInChain = sal_True;
     // urspruengliches Array freigeben, ohne Objekte zu zerstoeren
-    pOld->Remove((sal_uInt16)0, nCnt);
+    pOld->clear();
     delete pOld;
 }
 
@@ -6357,7 +6348,7 @@ sal_Bool SvxMSDffManager::GetShapeContainerData( SvStream& rSt,
         {
             aInfo.bReplaceByFly = sal_True;
         }
-        pShapeInfos->Insert(  new SvxMSDffShapeInfo(  aInfo          ) );
+        pShapeInfos->insert(  new SvxMSDffShapeInfo(  aInfo          ) );
         pShapeOrders->push_back( new SvxMSDffShapeOrder( aInfo.nShapeId ) );
     }
 
@@ -6379,11 +6370,9 @@ sal_Bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*&         rpShape,
     SvxMSDffShapeInfo aTmpRec(0, nId);
     aTmpRec.bSortByShapeId = sal_True;
 
-    sal_uInt16 nFound;
-    if( pShapeInfos->Seek_Entry(&aTmpRec, &nFound) )
+    SvxMSDffShapeInfos::const_iterator it = pShapeInfos->find( &aTmpRec );
+    if( it != pShapeInfos->end() )
     {
-        SvxMSDffShapeInfo& rInfo = *pShapeInfos->GetObject( nFound );
-
         // eventuell altes Errorflag loeschen
         if( rStCtrl.GetError() )
             rStCtrl.ResetError();
@@ -6391,7 +6380,8 @@ sal_Bool SvxMSDffManager::GetShape(sal_uLong nId, SdrObject*&         rpShape,
         sal_uLong nOldPosCtrl = rStCtrl.Tell();
         sal_uLong nOldPosData = pStData ? pStData->Tell() : nOldPosCtrl;
         // das Shape im Steuer Stream anspringen
-        bool bSeeked = (rInfo.nFilePos == rStCtrl.Seek(rInfo.nFilePos));
+        sal_uLong const nFilePos((*it)->nFilePos);
+        bool bSeeked = (nFilePos == rStCtrl.Seek(nFilePos));
 
         // Falls missglueckt, den Fehlerstatus zuruecksetzen und Pech gehabt!
         if (!bSeeked || rStCtrl.GetError())
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 292b4fb..1512cc0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -594,10 +594,10 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt,
                 SvxMSDffShapeInfo aTmpRec( 0, pImpRec->nShapeId );
                 aTmpRec.bSortByShapeId = sal_True;
 
-                sal_uInt16 nFound;
-                if( GetShapeInfos()->Seek_Entry( &aTmpRec, &nFound ) )
+                SvxMSDffShapeInfos::const_iterator it = GetShapeInfos()->find( &aTmpRec );
+                if( it != GetShapeInfos()->end() )
                 {
-                    SvxMSDffShapeInfo& rInfo = *GetShapeInfos()->GetObject(nFound);
+                    SvxMSDffShapeInfo& rInfo = **it;
                     pImpRec->bReplaceByFly   = rInfo.bReplaceByFly;
                     pImpRec->bLastBoxInChain = rInfo.bLastBoxInChain;
                 }


More information about the Libreoffice-commits mailing list