[Libreoffice-commits] .: sfx2/inc sfx2/source

Joseph Powers jpowers at kemper.freedesktop.org
Sun Jan 2 13:51:58 PST 2011


 sfx2/inc/sfx2/styfitem.hxx      |   10 ++++----
 sfx2/source/dialog/mgetempl.cxx |    4 +--
 sfx2/source/dialog/styfitem.cxx |   26 ++++++++-------------
 sfx2/source/dialog/templdlg.cxx |   49 +++++++++++++++++++---------------------
 4 files changed, 41 insertions(+), 48 deletions(-)

New commits:
commit 7855cf6ee670ee6289c73eba9a62a0ea914dc44b
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Sun Jan 2 13:40:43 2011 -0800

    Remove DECLARE_LIST(SfxStyleFamilyList, SfxStyleFamilyItem*)

diff --git a/sfx2/inc/sfx2/styfitem.hxx b/sfx2/inc/sfx2/styfitem.hxx
index 5ccf9b4..2d0abc8 100644
--- a/sfx2/inc/sfx2/styfitem.hxx
+++ b/sfx2/inc/sfx2/styfitem.hxx
@@ -71,7 +71,7 @@ public:
     void			SetImage( const Image& _rImg ) { aImage = _rImg; }
 };
 
-DECLARE_LIST(SfxStyleFamilyList, SfxStyleFamilyItem*)
+typedef ::std::vector< SfxStyleFamilyItem* > SfxStyleFamilyList;
 
 class SFX2_DLLPUBLIC SfxStyleFamilies: public Resource
 {
@@ -85,11 +85,11 @@ public:
                         SfxStyleFamilies( ) {};
                         ~SfxStyleFamilies();
 
-    USHORT              Count() const
-                        { return (USHORT)aEntryList.Count(); }
+    size_t              size() const
+                        { return aEntryList.size(); }
 
-    const SfxStyleFamilyItem* GetObject(ULONG nIdx) const
-                        { return (SfxStyleFamilyItem*)aEntryList.GetObject(nIdx); }
+    const SfxStyleFamilyItem* at(size_t nIdx) const
+                        { return (SfxStyleFamilyItem*)(aEntryList.empty() ? NULL : aEntryList[nIdx]); }
 
     /** updates the images of all single SfxStyleFamilyItems with new images from the given resource
 
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index 8e2ef06..b76fddf 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -194,11 +194,11 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage( Window* pParent, const SfxItem
         aBaseLb.Disable();
     }
 
-    size_t nCount = pFamilies->Count();
+    size_t nCount = pFamilies->size();
     size_t i;
     for ( i = 0; i < nCount; ++i )
     {
-        pItem = pFamilies->GetObject(i);
+        pItem = pFamilies->at( i );
 
         if ( pItem->GetFamily() == pStyle->GetFamily() )
             break;
diff --git a/sfx2/source/dialog/styfitem.cxx b/sfx2/source/dialog/styfitem.cxx
index 36f3235..4567d34 100644
--- a/sfx2/source/dialog/styfitem.cxx
+++ b/sfx2/source/dialog/styfitem.cxx
@@ -110,9 +110,7 @@ SfxStyleFamilyItem::~SfxStyleFamilyItem()
 // Implementierung des Resource-Konstruktors
 
 SfxStyleFamilies::SfxStyleFamilies( const ResId& rResId ) :
-
-    Resource( rResId.SetRT( RSC_SFX_STYLE_FAMILIES ).SetAutoRelease( FALSE ) ),
-    aEntryList( 4, 1 )
+    Resource( rResId.SetRT( RSC_SFX_STYLE_FAMILIES ).SetAutoRelease( FALSE ) )
 {
     ULONG nCount = ReadLongRes();
     for( ULONG i = 0; i < nCount; i++ )
@@ -120,7 +118,7 @@ SfxStyleFamilies::SfxStyleFamilies( const ResId& rResId ) :
         const ResId aResId((RSHEADER_TYPE *)GetClassRes(), *rResId.GetResMgr());
         SfxStyleFamilyItem *pItem = new SfxStyleFamilyItem(aResId);
         IncrementRes( GetObjSizeRes( (RSHEADER_TYPE *)GetClassRes() ) );
-        aEntryList.Insert(pItem, LIST_APPEND);
+        aEntryList.push_back( pItem );
     }
 
     FreeResource();
@@ -134,13 +132,9 @@ SfxStyleFamilies::SfxStyleFamilies( const ResId& rResId ) :
 
 SfxStyleFamilies::~SfxStyleFamilies()
 {
-    SfxStyleFamilyItem *pItem = aEntryList.First();
-
-    while(pItem)
-    {
-        delete pItem;
-        pItem = aEntryList.Next();
-    }
+    for ( size_t i = 0, n = aEntryList.size(); i < n; ++i )
+        delete aEntryList[ i ];
+    aEntryList.clear();
 }
 
 
@@ -163,14 +157,14 @@ sal_Bool SfxStyleFamilies::updateImages( const ResId& _rId )
 
             // number of styles items/images
             sal_uInt16 nCount = aImages.GetImageCount( );
-            DBG_ASSERT( Count() == nCount, "SfxStyleFamilies::updateImages: found the image list, but missing some bitmaps!" );
-            if ( nCount > Count() )
-                nCount = Count();
+            DBG_ASSERT( aEntryList.size() == nCount, "SfxStyleFamilies::updateImages: found the image list, but missing some bitmaps!" );
+            if ( nCount > aEntryList.size() )
+                nCount = aEntryList.size();
 
             // set the images on the items
-            for ( sal_uInt16 i = 0; i < nCount; ++i )
+            for ( size_t i = 0; i < nCount; ++i )
             {
-                SfxStyleFamilyItem* pItem = static_cast< SfxStyleFamilyItem* >( aEntryList.GetObject( i ) );
+                SfxStyleFamilyItem* pItem = aEntryList[ i ];
                 pItem->SetImage( aImages.GetImage( aImages.GetImageId( i ) ) );
             }
 
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 2c80e86..691c163 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -827,7 +827,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Mod
 
 USHORT SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(USHORT nId)
 {
-    const SfxStyleFamilyItem *pItem=pStyleFamilies->GetObject(nId);
+    const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nId );
     return SfxFamilyIdToNId(pItem->GetFamily())-1;
 }
 
@@ -845,8 +845,8 @@ void SfxTemplateDialog_Impl::EnableEdit(BOOL bEnable)
 
 USHORT SfxCommonTemplateDialog_Impl::InfoOffsetToStyleNr(USHORT nId)
 {
-    for ( USHORT i=0;i<pStyleFamilies->Count();i++ )
-        if ( SfxFamilyIdToNId(pStyleFamilies->GetObject(i)->GetFamily()) == nId+1 )
+    for ( size_t i = 0; i < pStyleFamilies->size(); i++ )
+        if ( SfxFamilyIdToNId(pStyleFamilies->at( i )->GetFamily()) == nId+1 )
             return i;
     DBG_ERROR("Style Nummer nicht gefunden");
     return 0;
@@ -858,8 +858,7 @@ USHORT SfxCommonTemplateDialog_Impl::InfoOffsetToStyleNr(USHORT nId)
 void SfxCommonTemplateDialog_Impl::ReadResource()
 {
     // globale Benutzer-Resource auslesen
-    USHORT i;
-    for(i = 0; i < MAX_FAMILIES; ++i)
+    for(USHORT i = 0; i < MAX_FAMILIES; ++i)
         pFamilyState[i] = 0;
 
     SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
@@ -880,14 +879,15 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
 
         // Einfuegen in die Toolbox
         // umgekehrte Reihenfolge, da immer vorne eingefuegt wird.
-    USHORT nCount = pStyleFamilies->Count();
+    size_t nCount = pStyleFamilies->size();
 
     pBindings->ENTERREGISTRATIONS();
 
+    size_t i;
     for(i = 0; i < nCount; ++i)
     {
         USHORT nSlot = 0;
-        switch((USHORT)pStyleFamilies->GetObject(i)->GetFamily())
+        switch( (USHORT)pStyleFamilies->at( i )->GetFamily() )
         {
             case SFX_STYLE_FAMILY_CHAR: nSlot = SID_STYLE_FAMILY1; break;
             case SFX_STYLE_FAMILY_PARA: nSlot = SID_STYLE_FAMILY2; break;
@@ -938,7 +938,7 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
 
     for( ; nCount--; )
     {
-        const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject( nCount );
+        const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nCount );
         USHORT nId = SfxFamilyIdToNId( pItem->GetFamily() );
         InsertFamilyItem( nId, pItem );
     }
@@ -1052,11 +1052,10 @@ void SfxCommonTemplateDialog_Impl::SetAutomaticFilter()
 // Hilfsfunktion: Zugriff auf aktuelles Family-Item
 const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() const
 {
-    const USHORT nCount = pStyleFamilies->Count();
-    for(USHORT i = 0; i < nCount; ++i)
+    const size_t nCount = pStyleFamilies->size();
+    for(size_t i = 0; i < nCount; ++i)
     {
-        const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject(i);
-//        if(!pItem)continue;
+        const SfxStyleFamilyItem *pItem = pStyleFamilies->at( i );
         USHORT nId = SfxFamilyIdToNId(pItem->GetFamily());
         if(nId == nActFamily)
             return pItem;
@@ -1238,14 +1237,14 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(USHORT nFlags)     // Flags
     {
         // Ist beim Vorlagenkatalog der Fall
         SfxTemplateItem **ppItem = pFamilyState;
-        const USHORT nFamilyCount = pStyleFamilies->Count();
-        USHORT n;
-        for(n=0;n<nFamilyCount;n++)
-            if(ppItem[StyleNrToInfoOffset(n)])break;
+        const size_t nFamilyCount = pStyleFamilies->size();
+        size_t n;
+        for( n = 0; n < nFamilyCount; n++ )
+            if( ppItem[ StyleNrToInfoOffset(n) ] ) break;
         if ( n == nFamilyCount )
             // passiert gelegentlich bei Beichten, Formularen etc.; weiss der Teufel warum
             return;
-        ppItem+=StyleNrToInfoOffset(n);
+        ppItem += StyleNrToInfoOffset(n);
         nAppFilter = (*ppItem)->GetValue();
         FamilySelect(  StyleNrToInfoOffset(n)+1 );
         pItem = GetFamilyItem_Impl();
@@ -1389,9 +1388,9 @@ void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem *pItem)
 
 //Waehrend Giesskannenmodus Statusupdates ignorieren.
 
-    USHORT nCount=pStyleFamilies->Count();
+    size_t nCount = pStyleFamilies->size();
     pBindings->EnterRegistrations();
-    for(USHORT n=0; n<nCount; n++)
+    for(size_t n = 0; n < nCount; n++)
     {
         SfxControllerItem *pCItem=pBoundItems[n];
         BOOL bChecked = pItem && pItem->GetValue();
@@ -1478,10 +1477,10 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
      {
          CheckItem(nActFamily, FALSE);
          SfxTemplateItem **ppItem = pFamilyState;
-         const USHORT nFamilyCount = pStyleFamilies->Count();
-         USHORT n;
-         for(n=0;n<nFamilyCount;n++)
-             if(ppItem[StyleNrToInfoOffset(n)])break;
+         const size_t nFamilyCount = pStyleFamilies->size();
+         size_t n;
+         for( n = 0; n < nFamilyCount; n++ )
+             if( ppItem[ StyleNrToInfoOffset(n) ] ) break;
          ppItem+=StyleNrToInfoOffset(n);
 
          nAppFilter = (*ppItem)->GetValue();
@@ -2338,10 +2337,10 @@ void SfxTemplateDialog_Impl::updateFamilyImages()
     pStyleFamilies->updateImages( *m_pStyleFamiliesId );
 
     // and set the new images on our toolbox
-    USHORT nLoop = pStyleFamilies->Count();
+    size_t nLoop = pStyleFamilies->size();
     for( ; nLoop--; )
     {
-        const SfxStyleFamilyItem *pItem = pStyleFamilies->GetObject( nLoop );
+        const SfxStyleFamilyItem *pItem = pStyleFamilies->at( nLoop );
         USHORT nId = SfxFamilyIdToNId( pItem->GetFamily() );
         m_aActionTbL.SetItemImage( nId, pItem->GetImage() );
     }


More information about the Libreoffice-commits mailing list