[Libreoffice-commits] .: 3 commits - sd/source tools/Package_inc.mk tools/inc

Michael Stahl mst at kemper.freedesktop.org
Tue Aug 14 12:35:36 PDT 2012


 sd/source/ui/dlg/animobjs.cxx |  274 ++++++++++++++++++++----------------------
 sd/source/ui/inc/animobjs.hxx |    9 -
 tools/Package_inc.mk          |    1 
 tools/inc/tools/list.hxx      |   64 ---------
 4 files changed, 139 insertions(+), 209 deletions(-)

New commits:
commit 18f010bb6eb8c28bd737fec151189a84032b8d44
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 14 21:28:55 2012 +0200

    tools/list.hxx: Now that's what i call a dead parrot.
    
    Change-Id: Ice454bf28119c8291d3ed6b2bd8bf578acc63f3d

diff --git a/tools/Package_inc.mk b/tools/Package_inc.mk
index aed4274..5557b12 100644
--- a/tools/Package_inc.mk
+++ b/tools/Package_inc.mk
@@ -47,7 +47,6 @@ $(eval $(call gb_Package_add_file,tools_inc,inc/tools/inetstrm.hxx,tools/inetstr
 $(eval $(call gb_Package_add_file,tools_inc,inc/tools/line.hxx,tools/line.hxx))
 $(eval $(call gb_Package_add_file,tools_inc,inc/tools/lineend.hxx,tools/lineend.hxx))
 $(eval $(call gb_Package_add_file,tools_inc,inc/tools/link.hxx,tools/link.hxx))
-$(eval $(call gb_Package_add_file,tools_inc,inc/tools/list.hxx,tools/list.hxx))
 $(eval $(call gb_Package_add_file,tools_inc,inc/tools/mapunit.hxx,tools/mapunit.hxx))
 $(eval $(call gb_Package_add_file,tools_inc,inc/tools/mempool.hxx,tools/mempool.hxx))
 $(eval $(call gb_Package_add_file,tools_inc,inc/tools/multisel.hxx,tools/multisel.hxx))
diff --git a/tools/inc/tools/list.hxx b/tools/inc/tools/list.hxx
deleted file mode 100644
index 0027002..0000000
--- a/tools/inc/tools/list.hxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _LIST_HXX
-#define _LIST_HXX
-
-#include <tools/solar.h>
-#include <tools/contnr.hxx>
-
-#define LIST_APPEND           CONTAINER_APPEND
-#define LIST_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
-
-class List : private Container
-{
-public:
-            using Container::Insert;
-            using Container::Remove;
-            using Container::Replace;
-            using Container::Clear;
-            using Container::Count;
-            using Container::GetCurObject;
-            using Container::GetCurPos;
-            using Container::GetObject;
-            using Container::GetPos;
-            using Container::Seek;
-            using Container::First;
-            using Container::Last;
-            using Container::Next;
-            using Container::Prev;
-
-            List( sal_uInt16 _nInitSize = 16, sal_uInt16 _nReSize = 16 ) :
-                Container( 1024, _nInitSize, _nReSize ) {}
-            List( sal_uInt16 _nBlockSize, sal_uInt16 _nInitSize, sal_uInt16 _nReSize ) :
-                Container( _nBlockSize, _nInitSize, _nReSize ) {}
-            List( const List& rList ) : Container( rList ) {}
-
-    List&   operator =( const List& rList )
-                { Container::operator =( rList ); return *this; }
-
-    sal_Bool    operator ==( const List& rList ) const
-                { return Container::operator ==( rList ); }
-    sal_Bool    operator !=( const List& rList ) const
-                { return Container::operator !=( rList ); }
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 5a18ea20b4f35b17efb5dfacb4f24fa31f9dca97
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 14 21:23:20 2012 +0200

    AnimationWindow: remove pBitmapEx member
    
    ... as it is just the current bitmap in the list.  Also remove
    unnecessary position parameter to UpdateControl, which is always the
    current position in the list.
    
    Change-Id: Ib4cc19ecd15e144676764cfe3e728e340b58b742

diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx
index 357f134..1705a1a 100644
--- a/sd/source/ui/dlg/animobjs.cxx
+++ b/sd/source/ui/dlg/animobjs.cxx
@@ -163,7 +163,6 @@ AnimationWindow::AnimationWindow( SfxBindings* pInBindings,
 
         pWin                ( pParent ),
         m_nCurrentFrame     ( EMPTY_FRAMELIST ),
-        pBitmapEx           ( NULL ),
 
         bMovie              ( sal_False ),
         bAllObjects         ( sal_False ),
@@ -240,9 +239,8 @@ AnimationWindow::~AnimationWindow()
 
 IMPL_LINK_NOARG(AnimationWindow, ClickFirstHdl)
 {
-    pBitmapEx = (m_FrameList.empty()) ? 0 : m_FrameList.front().first;
-    m_nCurrentFrame = (pBitmapEx) ? 0 : EMPTY_FRAMELIST;
-    UpdateControl(m_nCurrentFrame);
+    m_nCurrentFrame = (m_FrameList.empty()) ? EMPTY_FRAMELIST : 0;
+    UpdateControl();
 
     return( 0L );
 }
@@ -311,9 +309,8 @@ IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
         // make list and view consistent
         assert(0 < i && i < m_FrameList.size());
         m_nCurrentFrame = i;
-        pBitmapEx = m_FrameList[i].first;
 
-        UpdateControl( i, bDisableCtrls );
+        UpdateControl(bDisableCtrls);
 
         if( aRbtBitmap.IsChecked() )
         {
@@ -359,7 +356,10 @@ IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
     // Um die Controls wieder zu enablen
     bMovie = sal_False;
     if (nCount > 0)
-        UpdateControl(i);
+    {
+        assert(i == m_nCurrentFrame);
+        UpdateControl();
+    }
 
     if( pProgress )
     {
@@ -378,9 +378,9 @@ IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
 
 IMPL_LINK_NOARG(AnimationWindow, ClickLastHdl)
 {
-    pBitmapEx = (m_FrameList.empty()) ? 0 : m_FrameList.back().first;
-    m_nCurrentFrame = (pBitmapEx) ? m_FrameList.size() - 1 : EMPTY_FRAMELIST;
-    UpdateControl(m_nCurrentFrame);
+    m_nCurrentFrame =
+        (m_FrameList.empty()) ? EMPTY_FRAMELIST : m_FrameList.size() - 1 ;
+    UpdateControl();
 
     return( 0L );
 }
@@ -389,7 +389,7 @@ IMPL_LINK_NOARG(AnimationWindow, ClickLastHdl)
 
 IMPL_LINK( AnimationWindow, ClickRbtHdl, void *, p )
 {
-    if( !pBitmapEx || p == &aRbtGroup || aRbtGroup.IsChecked() )
+    if (m_FrameList.empty() || p == &aRbtGroup || aRbtGroup.IsChecked())
     {
         aTimeField.SetText( String() );
         aTimeField.Enable( sal_False );
@@ -434,10 +434,8 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
 
     if( pBtn == &aBtnRemoveBitmap )
     {
-        pBitmapEx = m_FrameList[m_nCurrentFrame].first;
-        delete pBitmapEx;
-        Time *const pTime = m_FrameList[m_nCurrentFrame].second;
-        delete pTime;
+        delete m_FrameList[m_nCurrentFrame].first;
+        delete m_FrameList[m_nCurrentFrame].second;
         m_FrameList.erase(m_FrameList.begin() + m_nCurrentFrame);
 
         pObject = pPage->GetObj(m_nCurrentFrame);
@@ -468,8 +466,7 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
             for (size_t i = m_FrameList.size(); i > 0; )
             {
                 --i;
-                pBitmapEx = m_FrameList[i].first;
-                delete pBitmapEx;
+                delete m_FrameList[i].first;
 
                 pObject = pPage->GetObj( i );
                 if( pObject )
@@ -500,7 +497,7 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
     Fraction aFrac( GetScale() );
     aCtlDisplay.SetScale( aFrac );
 
-    UpdateControl(m_nCurrentFrame);
+    UpdateControl();
 
     return( 0L );
 }
@@ -529,9 +526,8 @@ IMPL_LINK_NOARG(AnimationWindow, ModifyBitmapHdl)
     }
 
     m_nCurrentFrame = nBmp - 1;
-    pBitmapEx = m_FrameList[m_nCurrentFrame].first;
 
-    UpdateControl(m_nCurrentFrame);
+    UpdateControl();
 
     return( 0L );
 }
@@ -551,16 +547,17 @@ IMPL_LINK_NOARG(AnimationWindow, ModifyTimeHdl)
 
 // -----------------------------------------------------------------------
 
-void AnimationWindow::UpdateControl( sal_uLong nListPos, sal_Bool bDisableCtrls )
+void AnimationWindow::UpdateControl(bool const bDisableCtrls)
 {
     String aString;
 
-    if( pBitmapEx )
+    if (!m_FrameList.empty())
     {
-        BitmapEx aBmp( *pBitmapEx );
+        BitmapEx aBmp(*m_FrameList[m_nCurrentFrame].first);
 
         SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
-        SdrObject* pObject = (SdrObject*) pPage->GetObj( (sal_uLong) nListPos );
+        SdrObject *const pObject =
+            static_cast<SdrObject*>(pPage->GetObj(m_nCurrentFrame));
         if( pObject )
         {
             VirtualDevice   aVD;
@@ -587,7 +584,7 @@ void AnimationWindow::UpdateControl( sal_uLong nListPos, sal_Bool bDisableCtrls
     }
     else
     {
-        aCtlDisplay.SetBitmapEx( pBitmapEx );
+        aCtlDisplay.SetBitmapEx(0);
     }
     aCtlDisplay.Invalidate();
     aCtlDisplay.Update();
@@ -595,9 +592,9 @@ void AnimationWindow::UpdateControl( sal_uLong nListPos, sal_Bool bDisableCtrls
     aFiCount.SetText(rtl::OUString::valueOf(
                 static_cast<sal_Int64>(m_FrameList.size())));
 
-    if( pBitmapEx && !bMovie )
+    if (!m_FrameList.empty() && !bMovie)
     {
-        aNumFldBitmap.SetValue( nListPos + 1 );
+        aNumFldBitmap.SetValue(m_nCurrentFrame + 1);
 
         // Wenn mind. 1 Objekt in der Liste ist
         aBtnFirst.Enable();
@@ -663,7 +660,7 @@ void AnimationWindow::ResetAttrs()
     // LoopCount
     aLbLoopCount.SelectEntryPos( aLbLoopCount.GetEntryCount() - 1);
 
-    UpdateControl( 0 );
+    UpdateControl();
 }
 
 // -----------------------------------------------------------------------
@@ -889,7 +886,8 @@ void AnimationWindow::AddObj (::sd::View& rView )
                     {
                         const AnimationBitmap& rAnimBmp = aAnimation.Get( i );
 
-                        pBitmapEx = new BitmapEx( rAnimBmp.aBmpEx );
+                        BitmapEx *const pBitmapEx =
+                            new BitmapEx(rAnimBmp.aBmpEx);
 
                         // LoopCount
                         if( i == 0 )
@@ -926,7 +924,9 @@ void AnimationWindow::AddObj (::sd::View& rView )
                 {
                     SdrObject* pSnapShot = (SdrObject*) pObjList->GetObj( (sal_uLong) nObject );
 
-                    pBitmapEx = new BitmapEx( SdrExchangeView::GetObjGraphic( pSnapShot->GetModel(), pSnapShot ).GetBitmapEx() );
+                    BitmapEx *const pBitmapEx = new BitmapEx(
+                        SdrExchangeView::GetObjGraphic(
+                            pSnapShot->GetModel(), pSnapShot).GetBitmapEx() );
 
                     Time* pTime = new Time( aTimeField.GetTime() );
 
@@ -946,7 +946,8 @@ void AnimationWindow::AddObj (::sd::View& rView )
         // Auch ein einzelnes animiertes Objekt
         if( !bAnimObj && !( bAllObjects && nMarkCount > 1 ) )
         {
-            pBitmapEx = new BitmapEx( rView.GetAllMarkedGraphic().GetBitmapEx() );
+            BitmapEx *const pBitmapEx =
+                new BitmapEx(rView.GetAllMarkedGraphic().GetBitmapEx());
 
             Time* pTime = new Time( aTimeField.GetTime() );
 
@@ -974,7 +975,9 @@ void AnimationWindow::AddObj (::sd::View& rView )
                     // Clone
                     SdrObject* pObject = rMarkList.GetMark( nObject )->GetMarkedSdrObj();
 
-                    pBitmapEx = new BitmapEx( SdrExchangeView::GetObjGraphic( pObject->GetModel(), pObject ).GetBitmapEx() );
+                    BitmapEx *const pBitmapEx = new BitmapEx(
+                        SdrExchangeView::GetObjGraphic(
+                            pObject->GetModel(), pObject).GetBitmapEx() );
 
                     Time* pTime = new Time( aTimeField.GetTime() );
 
@@ -1017,7 +1020,7 @@ void AnimationWindow::AddObj (::sd::View& rView )
         Fraction aFrac( GetScale() );
         aCtlDisplay.SetScale( aFrac );
 
-        UpdateControl(m_nCurrentFrame);
+        UpdateControl();
     }
 }
 
@@ -1072,7 +1075,7 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
             long  nTime = pTime->Get100Sec();
             nTime += pTime->GetSec() * 100;
 
-            pBitmapEx = m_FrameList[i].first;
+            BitmapEx const*const pBitmapEx = m_FrameList[i].first;
 
             // Offset fuer die gewuenschte Ausrichtung bestimmen
             const Size aBitmapSize( pBitmapEx->GetSizePixel() );
@@ -1247,7 +1250,7 @@ void AnimationWindow::DataChanged( const DataChangedEvent& rDCEvt )
 
     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     {
-        UpdateControl(m_nCurrentFrame);
+        UpdateControl();
     }
 }
 
diff --git a/sd/source/ui/inc/animobjs.hxx b/sd/source/ui/inc/animobjs.hxx
index 16379b0..1b7d36c 100644
--- a/sd/source/ui/inc/animobjs.hxx
+++ b/sd/source/ui/inc/animobjs.hxx
@@ -132,7 +132,6 @@ private:
     static const size_t EMPTY_FRAMELIST = ULONG_MAX;
     size_t          m_nCurrentFrame;
     SdDrawDocument* pMyDoc;
-    BitmapEx*       pBitmapEx;
 
     Size            aSize;
     Size            aFltWinSize;
@@ -158,7 +157,7 @@ private:
     DECL_LINK( ModifyBitmapHdl, void * );
     DECL_LINK( ModifyTimeHdl, void * );
 
-    void            UpdateControl( sal_uLong nPos, sal_Bool bDisableCtrls = sal_False );
+    void            UpdateControl(bool bDisableCtrls = false);
     void            ResetAttrs();
     void            WaitInEffect( sal_uLong nMilliSeconds, sal_uLong nTime,
                                         SfxProgress* pStbMgr ) const;
commit 3af368f0f8e6691aa2eef177ccfcfcb95885c84b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 14 21:03:04 2012 +0200

    AnimationWindow: convert List to std::vector
    
    Change-Id: I0b26906011e8986820c12d68bbe521f1f638f920

diff --git a/sd/source/ui/dlg/animobjs.cxx b/sd/source/ui/dlg/animobjs.cxx
index 5d2e7df..357f134 100644
--- a/sd/source/ui/dlg/animobjs.cxx
+++ b/sd/source/ui/dlg/animobjs.cxx
@@ -162,6 +162,7 @@ AnimationWindow::AnimationWindow( SfxBindings* pInBindings,
         aBtnCreateGroup     ( this, SdResId( BTN_CREATE_GROUP ) ),
 
         pWin                ( pParent ),
+        m_nCurrentFrame     ( EMPTY_FRAMELIST ),
         pBitmapEx           ( NULL ),
 
         bMovie              ( sal_False ),
@@ -221,19 +222,15 @@ AnimationWindow::AnimationWindow( SfxBindings* pInBindings,
 
 AnimationWindow::~AnimationWindow()
 {
-    sal_uLong i, nCount;
-
     delete pControllerItem;
 
-    // Bitmapliste bereinigen
-    for( i = 0, nCount = aBmpExList.Count(); i < nCount; i++ )
-        delete static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
-    aBmpExList.Clear();
-
-    // Timeliste bereinigen
-    for( i = 0, nCount = aTimeList.size(); i < nCount; i++ )
-        delete aTimeList[ i ];
-    aTimeList.clear();
+    for (size_t i = 0; i < m_FrameList.size(); ++i)
+    {
+        delete m_FrameList[i].first;
+        delete m_FrameList[i].second;
+    }
+    m_FrameList.clear();
+    m_nCurrentFrame = EMPTY_FRAMELIST;
 
     // die Clones loeschen
     delete pMyDoc;
@@ -243,9 +240,9 @@ AnimationWindow::~AnimationWindow()
 
 IMPL_LINK_NOARG(AnimationWindow, ClickFirstHdl)
 {
-    aBmpExList.First();
-    pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetCurObject() );
-    UpdateControl( aBmpExList.GetCurPos() );
+    pBitmapEx = (m_FrameList.empty()) ? 0 : m_FrameList.front().first;
+    m_nCurrentFrame = (pBitmapEx) ? 0 : EMPTY_FRAMELIST;
+    UpdateControl(m_nCurrentFrame);
 
     return( 0L );
 }
@@ -266,7 +263,7 @@ IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
 
     bMovie = sal_True;
     sal_Bool bDisableCtrls = sal_False;
-    sal_uLong nCount = aBmpExList.Count();
+    size_t const nCount = m_FrameList.size();
     sal_Bool bReverse = p == &aBtnReverse;
 
     // Kann spaeter schwer ermittelt werden
@@ -279,8 +276,10 @@ IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
     long nFullTime;
     if( aRbtBitmap.IsChecked() )
     {
-        for( sal_uLong i = 0; i < nCount; i++ )
-            aTime += *aTimeList[ i ];
+        for (size_t i = 0; i < nCount; ++i)
+        {
+            aTime += *m_FrameList[i].second;
+        }
         nFullTime  = aTime.GetMSFromTime();
     }
     else
@@ -301,25 +300,25 @@ IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
     }
 
     sal_uLong nTmpTime = 0;
-    long i = 0;
-    sal_Bool bCount = i < (long) nCount;
+    size_t i = 0;
+    sal_Bool bCount = i < nCount;
     if( bReverse )
     {
         i = nCount - 1;
-        bCount = i >= 0;
     }
     while( bCount && bMovie )
     {
-        // Um Konsistenz zwischen Liste und Anzeige zu erwirken
-        aBmpExList.Seek( i );
-        pBitmapEx = static_cast< BitmapEx* >(  aBmpExList.GetCurObject() );
+        // make list and view consistent
+        assert(0 < i && i < m_FrameList.size());
+        m_nCurrentFrame = i;
+        pBitmapEx = m_FrameList[i].first;
 
         UpdateControl( i, bDisableCtrls );
 
         if( aRbtBitmap.IsChecked() )
         {
-            Time* pTime = aTimeList[i];
-            DBG_ASSERT( pTime, "Keine Zeit gefunden!" );
+            Time *const pTime = m_FrameList[i].second;
+            assert(pTime);
 
             aTimeField.SetTime( *pTime );
             sal_uLong nTime = pTime->GetMSFromTime();
@@ -334,19 +333,20 @@ IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
         }
         if( bReverse )
         {
-            i--;
-            if (i < 0)
+            if (i == 0)
             {
                 // Terminate loop.
                 bCount = false;
-                // Move i back into valid range.
-                i = 0;
+            }
+            else
+            {
+                --i;
             }
         }
         else
         {
             i++;
-            if (i >= (long) nCount)
+            if (i >= nCount)
             {
                 // Terminate loop.
                 bCount = false;
@@ -378,9 +378,9 @@ IMPL_LINK( AnimationWindow, ClickPlayHdl, void *, p )
 
 IMPL_LINK_NOARG(AnimationWindow, ClickLastHdl)
 {
-    aBmpExList.Last();
-    pBitmapEx = static_cast< BitmapEx* >(  aBmpExList.GetCurObject() );
-    UpdateControl( aBmpExList.GetCurPos() );
+    pBitmapEx = (m_FrameList.empty()) ? 0 : m_FrameList.back().first;
+    m_nCurrentFrame = (pBitmapEx) ? m_FrameList.size() - 1 : EMPTY_FRAMELIST;
+    UpdateControl(m_nCurrentFrame);
 
     return( 0L );
 }
@@ -400,7 +400,7 @@ IMPL_LINK( AnimationWindow, ClickRbtHdl, void *, p )
         sal_uLong n = static_cast<sal_uLong>(aNumFldBitmap.GetValue());
         if( n > 0 )
         {
-            Time* pTime = aTimeList[ n - 1 ];
+            Time *const pTime = m_FrameList[n - 1].second;
             if( pTime )
                 aTimeField.SetTime( *pTime );
         }
@@ -434,32 +434,28 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
 
     if( pBtn == &aBtnRemoveBitmap )
     {
-        sal_uLong nPos = aBmpExList.GetCurPos();
-        pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetCurObject() );
-        if( pBitmapEx )
-        {
-            delete pBitmapEx;
-            aBmpExList.Remove();
-            pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetCurObject() );
-        }
-        Time* pTime = aTimeList[ nPos ];
-        if( pTime )
-        {
-            delete pTime;
-            aTimeList.erase( aTimeList.begin() + nPos );
-        }
+        pBitmapEx = m_FrameList[m_nCurrentFrame].first;
+        delete pBitmapEx;
+        Time *const pTime = m_FrameList[m_nCurrentFrame].second;
+        delete pTime;
+        m_FrameList.erase(m_FrameList.begin() + m_nCurrentFrame);
 
-        pObject = pPage->GetObj( nPos );
+        pObject = pPage->GetObj(m_nCurrentFrame);
         // Durch Uebernahme der AnimatedGIFs muessen nicht unbedingt
         // Objekte vorhanden sein.
         if( pObject )
         {
-            pObject = pPage->RemoveObject(nPos);
+            pObject = pPage->RemoveObject(m_nCurrentFrame);
             DBG_ASSERT(pObject, "Clone beim Loeschen nicht gefunden");
             SdrObject::Free( pObject );
             pPage->RecalcObjOrdNums();
         }
 
+        if (m_nCurrentFrame >= m_FrameList.size())
+        {
+            assert(m_FrameList.empty());
+            m_nCurrentFrame = EMPTY_FRAMELIST;
+        }
     }
     else // Alles loeschen
     {
@@ -468,13 +464,11 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
 
         if( nReturn == RET_YES )
         {
-            // Bitmapliste bereinigen
-            long nCount = aBmpExList.Count();
-            long i;
-
-            for( i = nCount - 1; i >= 0; i-- )
+            // clear frame list
+            for (size_t i = m_FrameList.size(); i > 0; )
             {
-                pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
+                --i;
+                pBitmapEx = m_FrameList[i].first;
                 delete pBitmapEx;
 
                 pObject = pPage->GetObj( i );
@@ -486,21 +480,15 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
                     //pPage->RecalcObjOrdNums();
                 }
 
+                delete m_FrameList[i].second;
             }
-            aBmpExList.Clear();
-
-            // Timeliste bereinigen
-            nCount = aTimeList.size();
-            for( i = 0; i < nCount; i++ )
-            {
-                delete aTimeList[ i ];
-            }
-            aTimeList.clear();
+            m_FrameList.clear();
+            m_nCurrentFrame = EMPTY_FRAMELIST;
         }
     }
 
     // kann noch eine Animationsgruppe erstellt werden?
-    if (aBmpExList.Count() == 0)
+    if (m_FrameList.empty())
     {
         aBtnCreateGroup.Disable();
         // Falls vorher durch Uebernahme von AnimatedGIFs disabled:
@@ -512,7 +500,7 @@ IMPL_LINK( AnimationWindow, ClickRemoveBitmapHdl, void *, pBtn )
     Fraction aFrac( GetScale() );
     aCtlDisplay.SetScale( aFrac );
 
-    UpdateControl( aBmpExList.GetCurPos() );
+    UpdateControl(m_nCurrentFrame);
 
     return( 0L );
 }
@@ -535,15 +523,15 @@ IMPL_LINK_NOARG(AnimationWindow, ModifyBitmapHdl)
 {
     sal_uLong nBmp = static_cast<sal_uLong>(aNumFldBitmap.GetValue());
 
-    if( nBmp > aBmpExList.Count() )
-        nBmp = aBmpExList.Count();
-
-    pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( nBmp - 1 ) );
+    if (nBmp > m_FrameList.size())
+    {
+        nBmp = m_FrameList.size();
+    }
 
-    // Positionieren in der Liste
-    aBmpExList.Seek( nBmp - 1 );
+    m_nCurrentFrame = nBmp - 1;
+    pBitmapEx = m_FrameList[m_nCurrentFrame].first;
 
-    UpdateControl( nBmp - 1 );
+    UpdateControl(m_nCurrentFrame);
 
     return( 0L );
 }
@@ -554,8 +542,7 @@ IMPL_LINK_NOARG(AnimationWindow, ModifyTimeHdl)
 {
     sal_uLong nPos = static_cast<sal_uLong>(aNumFldBitmap.GetValue() - 1);
 
-    Time* pTime = aTimeList[ nPos ];
-    DBG_ASSERT( pTime, "Zeit nicht gefunden!" );
+    Time *const pTime = m_FrameList[nPos].second;
 
     *pTime = aTimeField.GetTime();
 
@@ -605,7 +592,8 @@ void AnimationWindow::UpdateControl( sal_uLong nListPos, sal_Bool bDisableCtrls
     aCtlDisplay.Invalidate();
     aCtlDisplay.Update();
 
-    aFiCount.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(aBmpExList.Count())));
+    aFiCount.SetText(rtl::OUString::valueOf(
+                static_cast<sal_Int64>(m_FrameList.size())));
 
     if( pBitmapEx && !bMovie )
     {
@@ -652,11 +640,13 @@ void AnimationWindow::UpdateControl( sal_uLong nListPos, sal_Bool bDisableCtrls
     else
     {
         // 'Gruppenobjekt' nur dann enablen, wenn es kein Animated GIF ist
-        if (aBmpExList.Count() == 0)
+        if (m_FrameList.empty())
+        {
             aRbtGroup.Enable();
+        }
 
         aRbtBitmap.Enable();
-        aBtnCreateGroup.Enable(aBmpExList.Count() != 0);
+        aBtnCreateGroup.Enable(!m_FrameList.empty());
         aFtAdjustment.Enable( sal_True );
         aLbAdjustment.Enable( sal_True );
     }
@@ -702,16 +692,15 @@ void AnimationWindow::WaitInEffect( sal_uLong nMilliSeconds, sal_uLong nTime,
 Fraction AnimationWindow::GetScale()
 {
     Fraction aFrac;
-    sal_uLong nPos = aBmpExList.GetCurPos();
-    sal_uLong nCount = aBmpExList.Count();
-    if( nCount > 0 )
+    size_t const nCount = m_FrameList.size();
+    if (nCount > 0)
     {
         aBmpSize.Width() = 0;
         aBmpSize.Height() = 0;
-        for( sal_uLong i = 0; i < nCount; i++ )
+        for (size_t i = 0; i < nCount; i++)
         {
-            pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
-            Size aTempSize( pBitmapEx->GetBitmap().GetSizePixel() );
+            BitmapEx *const pBitmap = m_FrameList[i].first;
+            Size aTempSize( pBitmap->GetBitmap().GetSizePixel() );
             aBmpSize.Width() = Max( aBmpSize.Width(), aTempSize.Width() );
             aBmpSize.Height() = Max( aBmpSize.Height(), aTempSize.Height() );
         }
@@ -722,8 +711,6 @@ Fraction AnimationWindow::GetScale()
         aFrac = Fraction( std::min( (double)aDisplaySize.Width() / (double)aBmpSize.Width(),
                              (double)aDisplaySize.Height() / (double)aBmpSize.Height() ) );
     }
-    // Liste wieder auf alten Stand bringen
-    pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( nPos ) );
     return( aFrac );
 }
 
@@ -903,7 +890,6 @@ void AnimationWindow::AddObj (::sd::View& rView )
                         const AnimationBitmap& rAnimBmp = aAnimation.Get( i );
 
                         pBitmapEx = new BitmapEx( rAnimBmp.aBmpEx );
-                        aBmpExList.Insert( pBitmapEx, aBmpExList.GetCurPos() + 1 );
 
                         // LoopCount
                         if( i == 0 )
@@ -916,13 +902,14 @@ void AnimationWindow::AddObj (::sd::View& rView )
                                 aLbLoopCount.SelectEntry(rtl::OUString::valueOf( nLoopCount ) );
                         }
 
-                        // Time
                         long nTime = rAnimBmp.nWait;
                         Time* pTime = new Time( 0, 0, nTime / 100, nTime % 100 );
-                        aTimeList.insert( aTimeList.begin() + aBmpExList.GetCurPos() + 1, pTime );
+                        m_FrameList.insert(
+                                m_FrameList.begin() + m_nCurrentFrame + 1,
+                                ::std::make_pair(pBitmapEx, pTime));
 
-                        // Weiterschalten der BitmapListe
-                        aBmpExList.Next();
+                        // increment => next one inserted after this one
+                        ++m_nCurrentFrame;
                     }
                     // Nachdem ein animated GIF uebernommen wurde, kann auch nur ein solches erstellt werden
                     aRbtBitmap.Check();
@@ -940,17 +927,18 @@ void AnimationWindow::AddObj (::sd::View& rView )
                     SdrObject* pSnapShot = (SdrObject*) pObjList->GetObj( (sal_uLong) nObject );
 
                     pBitmapEx = new BitmapEx( SdrExchangeView::GetObjGraphic( pSnapShot->GetModel(), pSnapShot ).GetBitmapEx() );
-                    aBmpExList.Insert( pBitmapEx, aBmpExList.GetCurPos() + 1 );
 
-                    // Time
                     Time* pTime = new Time( aTimeField.GetTime() );
-                    aTimeList.insert( aTimeList.begin() + aBmpExList.GetCurPos() + 1, pTime );
 
-                    // Clone
-                    pPage->InsertObject( pSnapShot->Clone(), aBmpExList.GetCurPos() + 1 );
+                    m_FrameList.insert(
+                            m_FrameList.begin() + m_nCurrentFrame + 1,
+                            ::std::make_pair(pBitmapEx, pTime));
+
+                    // increment => next one inserted after this one
+                    ++m_nCurrentFrame;
 
-                    // Weiterschalten der BitmapListe
-                    aBmpExList.Next();
+                    // Clone
+                    pPage->InsertObject(pSnapShot->Clone(), m_nCurrentFrame);
                 }
                 bAnimObj = sal_True;
             }
@@ -959,12 +947,12 @@ void AnimationWindow::AddObj (::sd::View& rView )
         if( !bAnimObj && !( bAllObjects && nMarkCount > 1 ) )
         {
             pBitmapEx = new BitmapEx( rView.GetAllMarkedGraphic().GetBitmapEx() );
-            aBmpExList.Insert( pBitmapEx, aBmpExList.GetCurPos() + 1 );
 
-            // Time
             Time* pTime = new Time( aTimeField.GetTime() );
-            aTimeList.insert( aTimeList.begin() + aBmpExList.GetCurPos() + 1, pTime );
 
+            m_FrameList.insert(
+                    m_FrameList.begin() + m_nCurrentFrame + 1,
+                    ::std::make_pair(pBitmapEx, pTime));
         }
 
         // ein einzelnes Objekt
@@ -973,7 +961,7 @@ void AnimationWindow::AddObj (::sd::View& rView )
             SdrMark*    pMark   = rMarkList.GetMark(0);
             SdrObject*  pObject = pMark->GetMarkedSdrObj();
             SdrObject*  pClone  = pObject->Clone();
-            pPage->InsertObject(pClone, aBmpExList.GetCurPos() + 1);
+            pPage->InsertObject(pClone, m_nCurrentFrame + 1);
         }
         // mehrere Objekte: die Clones zu einer Gruppe zusammenfassen
         else if (nMarkCount > 1)
@@ -987,15 +975,17 @@ void AnimationWindow::AddObj (::sd::View& rView )
                     SdrObject* pObject = rMarkList.GetMark( nObject )->GetMarkedSdrObj();
 
                     pBitmapEx = new BitmapEx( SdrExchangeView::GetObjGraphic( pObject->GetModel(), pObject ).GetBitmapEx() );
-                    aBmpExList.Insert( pBitmapEx, aBmpExList.GetCurPos() + 1 );
 
-                    // Time
                     Time* pTime = new Time( aTimeField.GetTime() );
-                    aTimeList.insert( aTimeList.begin() + aBmpExList.GetCurPos() + 1, pTime );
 
-                    pPage->InsertObject( pObject->Clone(), aBmpExList.GetCurPos() + 1 );
+                    m_FrameList.insert(
+                        m_FrameList.begin() + m_nCurrentFrame + 1,
+                        ::std::make_pair(pBitmapEx, pTime));
+
+                    // increment => next one inserted after this one
+                    ++m_nCurrentFrame;
 
-                    aBmpExList.Next();
+                    pPage->InsertObject(pObject->Clone(), m_nCurrentFrame);
                 }
                 bAnimObj = sal_True; // damit nicht nochmal weitergeschaltet wird
             }
@@ -1007,23 +997,27 @@ void AnimationWindow::AddObj (::sd::View& rView )
                 for (sal_uLong nObject= 0; nObject < nMarkCount; nObject++)
                     pObjList->InsertObject(rMarkList.GetMark(nObject)->GetMarkedSdrObj()->Clone(), LIST_APPEND);
 
-                pPage->InsertObject(pCloneGroup, aBmpExList.GetCurPos() + 1);
+                pPage->InsertObject(pCloneGroup, m_nCurrentFrame + 1);
             }
         }
 
         if( !bAnimObj )
-            aBmpExList.Next();
+        {
+            ++m_nCurrentFrame;
+        }
 
         // wenn vorher nichts im Animator war und jetzt was da ist, kann eine
         // Animationsgruppe erstellt werden
-        if (nCloneCount == 0 && aBmpExList.Count() > 0)
+        if (nCloneCount == 0 && !m_FrameList.empty())
+        {
             aBtnCreateGroup.Enable();
+        }
 
         // Zoom fuer DisplayWin berechnen und setzen
         Fraction aFrac( GetScale() );
         aCtlDisplay.SetScale( aFrac );
 
-        UpdateControl( aBmpExList.GetCurPos() );
+        UpdateControl(m_nCurrentFrame);
     }
 }
 
@@ -1041,14 +1035,13 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
     Size                aTemp( pOutWin->GetOutputSizePixel() );
     const Point         aWindowCenter( pOutWin->PixelToLogic( Point( aTemp.Width() >> 1, aTemp.Height() >> 1 ) ) );
     const OutputDevice* pDefDev = Application::GetDefaultDevice();
-    const sal_uLong         nCount = aBmpExList.Count();
+    const size_t nCount = m_FrameList.size();
     BitmapAdjustment    eBA = (BitmapAdjustment) aLbAdjustment.GetSelectEntryPos();
-    sal_uLong               i;
 
     // Groesste Bitmap ermitteln
-    for( i = 0; i < nCount; i++ )
+    for (size_t i = 0; i < nCount; ++i)
     {
-        const BitmapEx& rBmpEx = *static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
+        const BitmapEx& rBmpEx = *m_FrameList[i].first;
         const Graphic   aGraphic( rBmpEx );
         Size            aTmpSizeLog;
         const Size      aTmpSizePix( rBmpEx.GetSizePixel() );
@@ -1073,13 +1066,13 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
         Animation   aAnimation;
         Point       aPt;
 
-        for( i = 0; i < nCount; i++ )
+        for (size_t i = 0; i < nCount; ++i)
         {
-            Time* pTime = aTimeList[i];
+            Time *const pTime = m_FrameList[i].second;
             long  nTime = pTime->Get100Sec();
             nTime += pTime->GetSec() * 100;
 
-            pBitmapEx = static_cast< BitmapEx* >( aBmpExList.GetObject( i ) );
+            pBitmapEx = m_FrameList[i].first;
 
             // Offset fuer die gewuenschte Ausrichtung bestimmen
             const Size aBitmapSize( pBitmapEx->GetSizePixel() );
@@ -1160,7 +1153,7 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
         SdrObject * pClone = NULL;
         SdPage* pPage = pMyDoc->GetSdPage(0, PK_STANDARD);
 
-        for(i = 0; i < nCount; i++)
+        for (size_t i = 0; i < nCount; ++i)
         {
             pClone = pPage->GetObj(i);
             Rectangle aRect( pClone->GetSnapRect() );
@@ -1217,7 +1210,7 @@ void AnimationWindow::CreateAnimObj (::sd::View& rView )
         SdrObjGroup* pGroup   = new SdrObjGroup;
         SdrObjList*  pObjList = pGroup->GetSubList();
 
-        for (i = 0; i < nCount; i++)
+        for (size_t i = 0; i < nCount; i++)
         {
             // der Clone verbleibt im Animator; in die Gruppe kommt ein Clone
             // des Clones
@@ -1254,7 +1247,7 @@ void AnimationWindow::DataChanged( const DataChangedEvent& rDCEvt )
 
     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     {
-        UpdateControl( aBmpExList.GetCurPos() );
+        UpdateControl(m_nCurrentFrame);
     }
 }
 
diff --git a/sd/source/ui/inc/animobjs.hxx b/sd/source/ui/inc/animobjs.hxx
index 7008edc..16379b0 100644
--- a/sd/source/ui/inc/animobjs.hxx
+++ b/sd/source/ui/inc/animobjs.hxx
@@ -25,7 +25,6 @@
 #include <svtools/stdctrl.hxx>
 #include <vcl/group.hxx>
 #include <sfx2/ctrlitem.hxx>
-#include <tools/list.hxx>
 
 #include <vcl/button.hxx>
 #include <vcl/field.hxx>
@@ -129,8 +128,9 @@ private:
     PushButton      aBtnCreateGroup;
 
     ::Window*       pWin;
-    List            aBmpExList;
-    std::vector<Time*> aTimeList;
+    ::std::vector< ::std::pair<BitmapEx*, Time*> > m_FrameList;
+    static const size_t EMPTY_FRAMELIST = ULONG_MAX;
+    size_t          m_nCurrentFrame;
     SdDrawDocument* pMyDoc;
     BitmapEx*       pBitmapEx;
 


More information about the Libreoffice-commits mailing list