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

Joseph Powers jpowers at kemper.freedesktop.org
Wed May 11 21:47:34 PDT 2011


 vcl/inc/vcl/gdimtf.hxx    |   51 ++++++++++++-----------
 vcl/source/gdi/gdimtf.cxx |   98 ++++++++++++++++++++++++++++++++--------------
 2 files changed, 97 insertions(+), 52 deletions(-)

New commits:
commit 067196fc0fd02dba18f41acc0cfd7e209713f9d8
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Wed May 11 21:42:16 2011 -0700

    Remove the List dependance from ImpLabelList

diff --git a/vcl/inc/vcl/gdimtf.hxx b/vcl/inc/vcl/gdimtf.hxx
index db00bf8..9cb5933 100644
--- a/vcl/inc/vcl/gdimtf.hxx
+++ b/vcl/inc/vcl/gdimtf.hxx
@@ -150,13 +150,13 @@ public:
                     GDIMetaFile( const GDIMetaFile& rMtf );
     virtual			~GDIMetaFile();
 
-    GDIMetaFile&        operator=( const GDIMetaFile& rMtf );
-    sal_Bool			operator==( const GDIMetaFile& rMtf ) const;
-    sal_Bool			operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
+    GDIMetaFile&    operator=( const GDIMetaFile& rMtf );
+    sal_Bool        operator==( const GDIMetaFile& rMtf ) const;
+    sal_Bool        operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); }
 
     void            Clear();
-    sal_Bool		IsEqual( const GDIMetaFile& rMtf ) const;
-    sal_Bool            Mirror( sal_uLong nMirrorFlags );
+    sal_Bool        IsEqual( const GDIMetaFile& rMtf ) const;
+    sal_Bool        Mirror( sal_uLong nMirrorFlags );
     void            Move( long nX, long nY );
     // additional Move method getting specifics how to handle MapMode( MAP_PIXEL )
     void            Move( long nX, long nY, long nDPIX, long nDPIY );
@@ -173,18 +173,21 @@ public:
     */
     Rectangle       GetBoundRect( OutputDevice& i_rReference );
 
-    void			Adjust( short nLuminancePercent = 0, short nContrastPercent = 0,
-                            short nChannelRPercent = 0, short nChannelGPercent = 0,
-                            short nChannelBPercent = 0, double fGamma = 1.0, sal_Bool bInvert = sal_False );
-    void			Convert( MtfConversion eConversion );
-    void			ReplaceColors( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol = 0 );
-    void			ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors,
+    void            Adjust( short nLuminancePercent = 0, short nContrastPercent = 0,
+                            short nChannelRPercent = 0,  short nChannelGPercent = 0,
+                            short nChannelBPercent = 0,  double fGamma = 1.0,
+                            sal_Bool bInvert = sal_False
+                    );
+
+    void            Convert( MtfConversion eConversion );
+    void            ReplaceColors( const Color& rSearchColor,  const Color& rReplaceColor, sal_uLong nTol = 0 );
+    void            ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors,
                                    sal_uLong nColorCount, sal_uLong* pTols = NULL );
 
     GDIMetaFile     GetMonochromeMtf( const Color& rCol ) const;
 
     void            Record( OutputDevice* pOutDev );
-    sal_Bool            IsRecord() const { return bRecord; }
+    sal_Bool        IsRecord() const { return bRecord; }
 
     void            Play( GDIMetaFile& rMtf, size_t nPos = GDI_METAFILE_END );
     void            Play( OutputDevice* pOutDev, size_t nPos = GDI_METAFILE_END );
@@ -192,7 +195,7 @@ public:
                           const Size& rSize, size_t nPos = GDI_METAFILE_END );
 
     void            Pause( sal_Bool bPause );
-    sal_Bool            IsPause() const { return bPause; }
+    sal_Bool        IsPause() const { return bPause; }
 
     void            Stop();
 
@@ -217,13 +220,13 @@ public:
     MetaAction*     GetCurAction() const { return GetAction( nCurrentActionElement ); }
     MetaAction*     ReplaceAction( MetaAction* pAction, size_t nAction );
 
-    sal_Bool            InsertLabel( const String& rLabel, sal_uLong nActionPos );
+    sal_Bool        InsertLabel( const String& rLabel, size_t nActionPos );
     void            RemoveLabel( const String& rLabel );
     void            RenameLabel( const String& rLabel, const String& rNewLabel );
-    sal_uLong           GetLabelCount() const;
-    String          GetLabel( sal_uLong nLabel );
+    size_t          GetLabelCount() const;
+    String          GetLabel( size_t nLabel );
 
-    sal_Bool            SaveStatus();
+    sal_Bool        SaveStatus();
 
     const Size&     GetPrefSize() const { return aPrefSize; }
     void            SetPrefSize( const Size& rSize ) { aPrefSize = rSize; }
@@ -234,23 +237,23 @@ public:
     void            SetHookHdl( const Link& rLink ) { aHookHdlLink = rLink; }
     const Link&     GetHookHdl() const { return aHookHdlLink; }
 
-    sal_uLong			GetChecksum() const;
-    sal_uLong           GetSizeBytes() const;
+    sal_uLong       GetChecksum() const;
+    sal_uLong       GetSizeBytes() const;
 
     // Methoden zum Lesen und Schreiben des neuen Formats;
     // die Read-Methode kann auch das alte Format lesen
-    SvStream&		Read( SvStream& rIStm );
-    SvStream&		Write( SvStream& rOStm );
+    SvStream&       Read( SvStream& rIStm );
+    SvStream&       Write( SvStream& rOStm );
 
     // Stream-Operatoren schreiben das alte Format (noch)
     // und lesen sowohl das alte wie auch das neue Format
     friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, GDIMetaFile& rGDIMetaFile );
     friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile );
 
-    sal_Bool           CreateThumbnail( sal_uInt32 nMaximumExtent, BitmapEx& rBmpEx, const BitmapEx* pOverlay = NULL, const Rectangle* pOverlayRect = NULL ) const;
+    sal_Bool        CreateThumbnail( sal_uInt32 nMaximumExtent, BitmapEx& rBmpEx, const BitmapEx* pOverlay = NULL, const Rectangle* pOverlayRect = NULL ) const;
 
-    void           UseCanvas( sal_Bool _bUseCanvas );
-    sal_Bool           GetUseCanvas() const { return bUseCanvas; }
+    void            UseCanvas( sal_Bool _bUseCanvas );
+    sal_Bool        GetUseCanvas() const { return bUseCanvas; }
 };
 
 /** Create a special metaaction that delegates rendering to specified
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index bebc0d0..8932c74 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -31,7 +31,6 @@
 #include <rtl/crc.h>
 #include <tools/stream.hxx>
 #include <tools/vcompat.hxx>
-#include <tools/list.hxx>
 #include <vcl/metaact.hxx>
 #include <vcl/salbtype.hxx>
 #include <vcl/outdev.hxx>
@@ -152,52 +151,95 @@ struct ImpLabel
 // - LabelList -
 // -------------
 
-class ImpLabelList : private List
+typedef ::std::vector< ImpLabel* > ImpLabelVector;
+
+class ImpLabelList
 {
+private:
+    ImpLabelVector  aList;
+    size_t          nListPos;
+
 public:
 
-                ImpLabelList() : List( 8, 4, 4 ) {}
-                ImpLabelList( const ImpLabelList& rList );
-                ~ImpLabelList();
-
-    void		ImplInsert( ImpLabel* p ) { Insert( p, LIST_APPEND ); }
-    ImpLabel*	ImplRemove( sal_uLong nPos ) { return (ImpLabel*) Remove( nPos ); }
-    void		ImplReplace( ImpLabel* p ) { Replace( (void*)p ); }
-    ImpLabel*	ImplFirst() { return (ImpLabel*) First(); }
-    ImpLabel*	ImplNext() { return (ImpLabel*) Next(); }
-    ImpLabel*	ImplGetLabel( sal_uLong nPos ) const { return (ImpLabel*) GetObject( nPos ); }
-    sal_uLong		ImplGetLabelPos( const String& rLabelName );
-    sal_uLong		ImplCount() const { return Count(); }
+                   ImpLabelList() {}
+                    ImpLabelList( const ImpLabelList& rList );
+                    ~ImpLabelList();
+
+    void            ImplInsert( ImpLabel* p ) { aList.push_back( p ); }
+
+    ImpLabel*       ImplFirst();
+    ImpLabel*       ImplNext();
+    ImpLabel*       ImplGetLabel( size_t nPos ) const;
+    ImpLabel*       ImplRemove( size_t nPos );
+
+    size_t          ImplGetLabelPos( const String& rLabelName );
+    size_t          ImplCount() const { return aList.size(); }
 };
 
 // ------------------------------------------------------------------------
 
-ImpLabelList::ImpLabelList( const ImpLabelList& rList ) :
-        List( rList )
+ImpLabelList::ImpLabelList( const ImpLabelList& rList )
 {
-    for( ImpLabel* pLabel = ImplFirst(); pLabel; pLabel = ImplNext() )
-        ImplReplace( new ImpLabel( *pLabel ) );
+    for( size_t i = 0, n = rList.ImplCount(); i < n; ++i )
+        aList.push_back( new ImpLabel( *rList.ImplGetLabel( i ) ) );
+    nListPos = 0;
 }
 
 // ------------------------------------------------------------------------
 
 ImpLabelList::~ImpLabelList()
 {
-    for( ImpLabel* pLabel = ImplFirst(); pLabel; pLabel = ImplNext() )
-        delete pLabel;
+    for( size_t i = 0, n = aList.size(); i < n; ++i )
+        delete aList[ i ];
+    aList.clear();
+}
+
+// ------------------------------------------------------------------------
+ImpLabel* ImpLabelList::ImplFirst()
+{
+    nListPos = 0;
+    return ( aList.empty() ) ? NULL : aList[ nListPos ];
+}
+
+// ------------------------------------------------------------------------
+ImpLabel* ImpLabelList::ImplNext()
+{
+    return ( nListPos + 1 < aList.size() ) ? aList[ ++nListPos ] : NULL;
+}
+
+// ------------------------------------------------------------------------
+
+ImpLabel* ImpLabelList::ImplGetLabel( size_t nPos ) const
+{
+    return ( nPos < aList.size() ) ? aList[ nPos ] : NULL;
+}
+
+// ------------------------------------------------------------------------
+
+ImpLabel* ImpLabelList::ImplRemove( size_t nPos )
+{
+    ImpLabel* return_value = NULL;
+    if ( nPos < aList.size() )
+    {
+        ImpLabelVector::iterator it = aList.begin();
+        ::std::advance( it, nPos );
+        return_value = *it;
+        aList.erase( it );
+    }
+    return return_value;
 }
 
 // ------------------------------------------------------------------------
 
-sal_uLong ImpLabelList::ImplGetLabelPos( const String& rLabelName )
+size_t ImpLabelList::ImplGetLabelPos( const String& rLabelName )
 {
-    sal_uLong nLabelPos = METAFILE_LABEL_NOTFOUND;
+    size_t nLabelPos = METAFILE_LABEL_NOTFOUND;
 
-    for( ImpLabel* pLabel = ImplFirst(); pLabel; pLabel = ImplNext() )
+    for ( size_t i = 0, n = aList.size(); i < n; ++i )
     {
-        if ( rLabelName == pLabel->aLabelName )
+        if ( rLabelName == aList[ i ]->aLabelName )
         {
-            nLabelPos = GetCurPos();
+            nLabelPos = i;
             break;
         }
     }
@@ -925,7 +967,7 @@ size_t GDIMetaFile::GetActionPos( const String& rLabel )
 
 // ------------------------------------------------------------------------
 
-sal_Bool GDIMetaFile::InsertLabel( const String& rLabel, sal_uLong nActionPos )
+sal_Bool GDIMetaFile::InsertLabel( const String& rLabel, size_t nActionPos )
 {
     sal_Bool bRet = sal_False;
 
@@ -969,14 +1011,14 @@ void GDIMetaFile::RenameLabel( const String& rLabel, const String& rNewLabel )
 
 // ------------------------------------------------------------------------
 
-sal_uLong GDIMetaFile::GetLabelCount() const
+size_t GDIMetaFile::GetLabelCount() const
 {
     return( pLabelList ? pLabelList->ImplCount() : 0UL );
 }
 
 // ------------------------------------------------------------------------
 
-String GDIMetaFile::GetLabel( sal_uLong nLabel )
+String GDIMetaFile::GetLabel( size_t nLabel )
 {
     String aString;
 


More information about the Libreoffice-commits mailing list