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

Joseph Powers jpowers at kemper.freedesktop.org
Wed Jul 13 06:59:44 PDT 2011


 svtools/inc/svtools/taskbar.hxx     |   41 +++++----
 svtools/source/control/taskmisc.cxx |  161 ++++++++++++++++--------------------
 2 files changed, 101 insertions(+), 101 deletions(-)

New commits:
commit eb70732c0fc510005515354ecdeda38fd1b5ef46
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Wed Jul 13 06:58:16 2011 -0700

    Replace List with std::vector< Window* >
    
    I also removed the unused Dummy class members.

diff --git a/svtools/inc/svtools/taskbar.hxx b/svtools/inc/svtools/taskbar.hxx
index 4fb126e..36b625e 100644
--- a/svtools/inc/svtools/taskbar.hxx
+++ b/svtools/inc/svtools/taskbar.hxx
@@ -440,30 +440,39 @@ class ImplWindowArrangeList;
 // - class WindowArrange -
 // -----------------------
 
+typedef ::std::vector< Window* > WindowList_impl;
+
 class SVT_DLLPUBLIC WindowArrange
 {
 private:
-    List*                   mpWinList;
-    void*                   mpDummy;
-    sal_uLong                   mnDummy;
+    WindowList_impl     maWinList;
 
 #ifdef _TASKBAR_CXX
-    SVT_DLLPRIVATE void                    ImplTile( const Rectangle& rRect );
-    SVT_DLLPRIVATE void                    ImplHorz( const Rectangle& rRect );
-    SVT_DLLPRIVATE void                    ImplVert( const Rectangle& rRect );
-    SVT_DLLPRIVATE void                    ImplCascade( const Rectangle& rRect );
+    SVT_DLLPRIVATE void ImplTile( const Rectangle& rRect );
+    SVT_DLLPRIVATE void ImplHorz( const Rectangle& rRect );
+    SVT_DLLPRIVATE void ImplVert( const Rectangle& rRect );
+    SVT_DLLPRIVATE void ImplCascade( const Rectangle& rRect );
 #endif
 
 public:
-                            WindowArrange();
-                            ~WindowArrange();
-
-    void                    AddWindow( Window* pWindow, sal_uLong nPos = LIST_APPEND )
-                                { mpWinList->Insert( (void*)pWindow, nPos ); }
-    void                    RemoveAllWindows()
-                                { mpWinList->Clear(); }
-
-    void                    Arrange( sal_uInt16 nType, const Rectangle& rRect );
+                        WindowArrange();
+                        ~WindowArrange();
+
+    void                AddWindow( Window* pWindow, size_t nPos = size_t(-1) )
+                        {
+                            if ( nPos < maWinList.size() ) {
+                                maWinList.insert( maWinList.begin() + nPos, pWindow );
+                            } else {
+                                maWinList.push_back( pWindow );
+                            }
+                        }
+
+    void                RemoveAllWindows()
+                        {
+                            maWinList.clear();
+                        }
+
+    void                Arrange( sal_uInt16 nType, const Rectangle& rRect );
 };
 
 #endif  // _TASKBAR_HXX
diff --git a/svtools/source/control/taskmisc.cxx b/svtools/source/control/taskmisc.cxx
index c9ed88e..246d107 100644
--- a/svtools/source/control/taskmisc.cxx
+++ b/svtools/source/control/taskmisc.cxx
@@ -61,14 +61,13 @@ void TaskButtonBar::RequestHelp( const HelpEvent& rHEvt )
 
 WindowArrange::WindowArrange()
 {
-    mpWinList = new List;
 }
 
 // -----------------------------------------------------------------------
 
 WindowArrange::~WindowArrange()
 {
-    delete mpWinList;
+    maWinList.clear();
 }
 
 // -----------------------------------------------------------------------
@@ -103,37 +102,36 @@ static void ImplPosSizeWindow( Window* pWindow,
 
 void WindowArrange::ImplTile( const Rectangle& rRect )
 {
-    sal_uInt16 nCount = (sal_uInt16)mpWinList->Count();
+    size_t nCount = maWinList.size();
     if ( nCount < 3 )
     {
         ImplVert( rRect );
         return;
     }
 
-    sal_uInt16		i;
-    sal_uInt16		j;
-    sal_uInt16		nCols;
-    sal_uInt16		nRows;
-    sal_uInt16		nActRows;
-    sal_uInt16		nOffset;
-    long		nOverWidth;
-    long		nOverHeight;
-    Window* 	pWindow;
-    long		nX = rRect.Left();
-    long		nY = rRect.Top();
-    long		nWidth = rRect.GetWidth();
-    long		nHeight = rRect.GetHeight();
-    long		nRectY = nY;
-    long		nRectWidth = nWidth;
-    long		nRectHeight = nHeight;
-    long		nTempWidth;
-    long		nTempHeight;
-
-    nCols	= ImplCeilSqareRoot( nCount );
+    sal_uInt16  i;
+    sal_uInt16  j;
+    sal_uInt16  nCols;
+    sal_uInt16  nRows;
+    sal_uInt16  nActRows;
+    sal_uInt16  nOffset;
+    long        nOverWidth;
+    long        nOverHeight;
+    long        nX = rRect.Left();
+    long        nY = rRect.Top();
+    long        nWidth = rRect.GetWidth();
+    long        nHeight = rRect.GetHeight();
+    long        nRectY = nY;
+    long        nRectWidth = nWidth;
+    long        nRectHeight = nHeight;
+    long        nTempWidth;
+    long        nTempHeight;
+
+    nCols   = ImplCeilSqareRoot( nCount );
     nOffset = (nCols*nCols) - nCount;
     if ( nOffset >= nCols )
     {
-        nRows	 = nCols -1;
+        nRows    = nCols -1;
         nOffset = nOffset - nCols;
     }
     else
@@ -144,7 +142,7 @@ void WindowArrange::ImplTile( const Rectangle& rRect )
         nWidth = 1;
     nOverWidth = nRectWidth-(nWidth*nCols);
 
-    pWindow = (Window*)mpWinList->First();
+    WindowList_impl::iterator it = maWinList.begin();
     for ( i = 0; i < nCols; i++ )
     {
         if ( i < nOffset )
@@ -172,18 +170,17 @@ void WindowArrange::ImplTile( const Rectangle& rRect )
                 nTempHeight++;
                 nOverHeight--;
             }
-            ImplPosSizeWindow( pWindow, nX, nY, nTempWidth, nTempHeight );
+            ImplPosSizeWindow( *it, nX, nY, nTempWidth, nTempHeight );
             nY += nTempHeight;
 
-            pWindow = (Window*)mpWinList->Next();
-            if ( !pWindow )
+            if ( ++it == maWinList.end() )
                 break;
         }
 
         nX += nWidth;
         nY = nRectY;
 
-        if ( !pWindow )
+        if ( it == maWinList.end() )
             break;
     }
 }
@@ -192,23 +189,23 @@ void WindowArrange::ImplTile( const Rectangle& rRect )
 
 void WindowArrange::ImplHorz( const Rectangle& rRect )
 {
-    long		nCount = (long)mpWinList->Count();
-    long		nX = rRect.Left();
-    long		nY = rRect.Top();
-    long		nWidth = rRect.GetWidth();
-    long		nHeight = rRect.GetHeight();
-    long		nRectHeight = nHeight;
-    long		nOver;
-    long		nTempHeight;
-    Window* 	pWindow;
+    size_t      nCount = maWinList.size();
+    long        nX = rRect.Left();
+    long        nY = rRect.Top();
+    long        nWidth = rRect.GetWidth();
+    long        nHeight = rRect.GetHeight();
+    long        nRectHeight = nHeight;
+    long        nOver;
+    long        nTempHeight;
+    Window*     pWindow;
 
     nHeight /= nCount;
     if ( nHeight < 1 )
         nHeight = 1;
     nOver = nRectHeight - (nCount*nHeight);
-    pWindow = (Window*)mpWinList->First();
-    while ( pWindow )
+    for( size_t index = 0; index < nCount; ++index )
     {
+        pWindow = maWinList[ index ];
         nTempHeight = nHeight;
         if ( nOver > 0 )
         {
@@ -217,8 +214,6 @@ void WindowArrange::ImplHorz( const Rectangle& rRect )
         }
         ImplPosSizeWindow( pWindow, nX, nY, nWidth, nTempHeight );
         nY += nTempHeight;
-
-        pWindow = (Window*)mpWinList->Next();
     }
 }
 
@@ -226,23 +221,23 @@ void WindowArrange::ImplHorz( const Rectangle& rRect )
 
 void WindowArrange::ImplVert( const Rectangle& rRect )
 {
-    long		nCount = (long)mpWinList->Count();
-    long		nX = rRect.Left();
-    long		nY = rRect.Top();
-    long		nWidth = rRect.GetWidth();
-    long		nHeight = rRect.GetHeight();
-    long		nRectWidth = nWidth;
-    long		nOver;
-    long		nTempWidth;
-    Window* 	pWindow;
+    size_t      nCount = maWinList.size();
+    long        nX = rRect.Left();
+    long        nY = rRect.Top();
+    long        nWidth = rRect.GetWidth();
+    long        nHeight = rRect.GetHeight();
+    long        nRectWidth = nWidth;
+    long        nOver;
+    long        nTempWidth;
+    Window*     pWindow;
 
     nWidth /= nCount;
     if ( nWidth < 1 )
         nWidth = 1;
     nOver = nRectWidth - (nCount*nWidth);
-    pWindow = (Window*)mpWinList->First();
-    while ( pWindow )
+    for( size_t index = 0; index < nCount; ++index )
     {
+        pWindow = maWinList[ index ];
         nTempWidth = nWidth;
         if ( nOver > 0 )
         {
@@ -251,8 +246,6 @@ void WindowArrange::ImplVert( const Rectangle& rRect )
         }
         ImplPosSizeWindow( pWindow, nX, nY, nTempWidth, nHeight );
         nX += nTempWidth;
-
-        pWindow = (Window*)mpWinList->Next();
     }
 }
 
@@ -260,32 +253,32 @@ void WindowArrange::ImplVert( const Rectangle& rRect )
 
 void WindowArrange::ImplCascade( const Rectangle& rRect )
 {
-    long		nX = rRect.Left();
-    long		nY = rRect.Top();
-    long		nWidth = rRect.GetWidth();
-    long		nHeight = rRect.GetHeight();
-    long		nRectWidth = nWidth;
-    long		nRectHeight = nHeight;
-    long		nOff;
-    long		nCascadeWins;
-    sal_Int32	nLeftBorder;
-    sal_Int32	nTopBorder;
-    sal_Int32	nRightBorder;
-    sal_Int32	nBottomBorder;
-    long		nStartOverWidth;
-    long		nStartOverHeight;
-    long		nOverWidth = 0;
-    long		nOverHeight = 0;
-    long		nTempX;
-    long		nTempY;
-    long		nTempWidth;
-    long		nTempHeight;
-    long		i;
-    Window* 	pWindow;
-    Window* 	pTempWindow;
+    long        nX = rRect.Left();
+    long        nY = rRect.Top();
+    long        nWidth = rRect.GetWidth();
+    long        nHeight = rRect.GetHeight();
+    long        nRectWidth = nWidth;
+    long        nRectHeight = nHeight;
+    long        nOff;
+    long        nCascadeWins;
+    sal_Int32   nLeftBorder;
+    sal_Int32   nTopBorder;
+    sal_Int32   nRightBorder;
+    sal_Int32   nBottomBorder;
+    long        nStartOverWidth;
+    long        nStartOverHeight;
+    long        nOverWidth = 0;
+    long        nOverHeight = 0;
+    long        nTempX;
+    long        nTempY;
+    long        nTempWidth;
+    long        nTempHeight;
+    long        i;
+    Window*     pWindow;
+    Window*     pTempWindow;
 
     // Border-Fenster suchen um den Versatz zu ermitteln
-    pTempWindow = (Window*)mpWinList->First();
+    pTempWindow = maWinList.front();
     pTempWindow->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
     while ( !nTopBorder )
     {
@@ -302,7 +295,7 @@ void WindowArrange::ImplCascade( const Rectangle& rRect )
     nCascadeWins = nRectHeight / 3 / nOff;
     if ( !nCascadeWins )
         nCascadeWins = 1;
-    nWidth	 -= nCascadeWins*nOff;
+    nWidth   -= nCascadeWins*nOff;
     nHeight  -= nCascadeWins*nOff;
     if ( nWidth < 1 )
         nWidth = 1;
@@ -313,9 +306,9 @@ void WindowArrange::ImplCascade( const Rectangle& rRect )
     nStartOverHeight = nRectHeight-(nHeight+(nCascadeWins*nOff));
 
     i = 0;
-    pWindow = (Window*)mpWinList->First();
-    while ( pWindow )
+    for( size_t index = 0, count = maWinList.size(); index < count; ++index )
     {
+        pWindow = maWinList[ index ];
         if ( !i )
         {
             nOverWidth = nStartOverWidth;
@@ -346,8 +339,6 @@ void WindowArrange::ImplCascade( const Rectangle& rRect )
             i++;
         else
             i = 0;
-
-        pWindow = (Window*)mpWinList->Next();
     }
 }
 
@@ -355,7 +346,7 @@ void WindowArrange::ImplCascade( const Rectangle& rRect )
 
 void WindowArrange::Arrange( sal_uInt16 nType, const Rectangle& rRect )
 {
-    if ( !mpWinList->Count() )
+    if ( maWinList.empty() )
         return;
 
     switch ( nType )


More information about the Libreoffice-commits mailing list