[Libreoffice-commits] .: svtools/inc svtools/source
Joseph Powers
jpowers at kemper.freedesktop.org
Tue Jul 12 20:34:51 PDT 2011
svtools/inc/svtools/imap.hxx | 32 +++++++-------
svtools/source/misc/imap.cxx | 95 +++++++++++++++++++-----------------------
svtools/source/misc/imap2.cxx | 28 ++++++------
3 files changed, 76 insertions(+), 79 deletions(-)
New commits:
commit 478a012e875c90d5e793a7de9706852cc623ae23
Author: Joseph Powers <jpowers27 at cox.net>
Date: Tue Jul 12 20:06:36 2011 -0700
Replace List with std::vector< IMapObject* >
I also removed some unused methods.
diff --git a/svtools/inc/svtools/imap.hxx b/svtools/inc/svtools/imap.hxx
index 33ba540..4b285a2 100644
--- a/svtools/inc/svtools/imap.hxx
+++ b/svtools/inc/svtools/imap.hxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -32,6 +32,7 @@
#include "svtools/svtdllapi.h"
#include <tools/string.hxx>
#include <tools/stream.hxx>
+#include <vector>
class Point;
class Rectangle;
@@ -45,22 +46,26 @@ class IMapObject;
|*
\******************************************************************************/
+typedef ::std::vector< IMapObject* > IMapObjectList_impl;
+
class SVT_DLLPUBLIC ImageMap
{
- List maList;
- String aName;
+private:
+
+ IMapObjectList_impl maList;
+ String aName;
protected:
// Binaer laden/speichern
void ImpWriteImageMap( SvStream& rOStm, const String& ) const ;
- void ImpReadImageMap( SvStream& rIStm, sal_uInt16 nCount, const String& );
+ void ImpReadImageMap( SvStream& rIStm, size_t nCount, const String& );
// Im-/Export
void ImpWriteCERN( SvStream& rOStm, const String& rBaseURL ) const;
void ImpWriteNCSA( SvStream& rOStm, const String& rBaseURL ) const;
- sal_uLong ImpReadCERN( SvStream& rOStm, const String& rBaseURL );
- sal_uLong ImpReadNCSA( SvStream& rOStm, const String& rBaseURL );
+ sal_uLong ImpReadCERN( SvStream& rOStm, const String& rBaseURL );
+ sal_uLong ImpReadNCSA( SvStream& rOStm, const String& rBaseURL );
void ImpReadCERNLine( const ByteString& rLine, const String& rBaseURL );
Point ImpReadCERNCoords( const char** ppStr );
@@ -71,7 +76,7 @@ protected:
String ImpReadNCSAURL( const char** ppStr, const String& rBaseURL );
Point ImpReadNCSACoords( const char** ppStr );
- sal_uLong ImpDetectFormat( SvStream& rIStm );
+ sal_uLong ImpDetectFormat( SvStream& rIStm );
public:
@@ -98,11 +103,10 @@ public:
// Zugriff auf einzelne IMapObjekte; die Objekte
// duerfen von aussen _nicht_ zerstoert werden
- IMapObject* GetFirstIMapObject() { return (IMapObject*) maList.First(); }
- IMapObject* GetNextIMapObject() { return (IMapObject*) maList.Next(); }
- IMapObject* GetLastIMapObject() { return (IMapObject*) maList.Last(); }
- IMapObject* GetPrevIMapObject() { return (IMapObject*) maList.Prev(); }
- IMapObject* GetIMapObject( sal_uInt16 nPos ) const { return (IMapObject*) maList.GetObject( nPos ); }
+ IMapObject* GetIMapObject( size_t nPos ) const
+ {
+ return ( nPos < maList.size() ) ? maList[ nPos ] : NULL;
+ }
// Gibt das Objekt zurueck, das zuerst getroffen wurde oder NULL;
// Groessen- und Positionsangaben sind in 1/100mm;
@@ -116,13 +120,13 @@ public:
sal_uLong nFlags = 0 );
// Gibt die Gesamtanzahl der IMap-Objekte zurueck
- sal_uInt16 GetIMapObjectCount() const { return (sal_uInt16) maList.Count(); }
+ size_t GetIMapObjectCount() const { return maList.size(); }
// Loescht alle internen Objekte
void ClearImageMap();
// liefert die aktuelle Versionsnummer
- sal_uInt16 GetVersion() const;
+ sal_uInt16 GetVersion() const;
// liefert / setzt den Namen der ImageMap
const String& GetName() const { return aName; }
diff --git a/svtools/source/misc/imap.cxx b/svtools/source/misc/imap.cxx
index 634c447..d62f20a 100644
--- a/svtools/source/misc/imap.cxx
+++ b/svtools/source/misc/imap.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -719,8 +719,8 @@ sal_Bool IMapPolygonObject::IsEqual( const IMapPolygonObject& rEqObj )
|*
\******************************************************************************/
-ImageMap::ImageMap( const String& rName ) :
- aName ( rName )
+ImageMap::ImageMap( const String& rName )
+: aName( rName )
{
}
@@ -735,24 +735,24 @@ ImageMap::ImageMap( const ImageMap& rImageMap )
{
DBG_CTOR( ImageMap, NULL );
- sal_uInt16 nCount = rImageMap.GetIMapObjectCount();
+ size_t nCount = rImageMap.GetIMapObjectCount();
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( size_t i = 0; i < nCount; i++ )
{
IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
switch( pCopyObj->GetType() )
{
case( IMAP_OBJ_RECTANGLE ):
- maList.Insert( new IMapRectangleObject( *(IMapRectangleObject*) pCopyObj ), LIST_APPEND );
+ maList.push_back( new IMapRectangleObject( *(IMapRectangleObject*) pCopyObj ) );
break;
case( IMAP_OBJ_CIRCLE ):
- maList.Insert( new IMapCircleObject( *(IMapCircleObject*) pCopyObj ), LIST_APPEND );
+ maList.push_back( new IMapCircleObject( *(IMapCircleObject*) pCopyObj ) );
break;
case( IMAP_OBJ_POLYGON ):
- maList.Insert( new IMapPolygonObject( *(IMapPolygonObject*) pCopyObj ), LIST_APPEND );
+ maList.push_back( new IMapPolygonObject( *(IMapPolygonObject*) pCopyObj ) );
break;
default:
@@ -786,15 +786,9 @@ ImageMap::~ImageMap()
void ImageMap::ClearImageMap()
{
- IMapObject* pObj = (IMapObject*) maList.First();
-
- while ( pObj )
- {
- delete pObj;
- pObj = (IMapObject*) maList.Next();
- }
-
- maList.Clear();
+ for( size_t i = 0, n = maList.size(); i < n; ++i )
+ delete maList[ i ];
+ maList.clear();
aName = String();
}
@@ -808,26 +802,26 @@ void ImageMap::ClearImageMap()
ImageMap& ImageMap::operator=( const ImageMap& rImageMap )
{
- sal_uInt16 nCount = rImageMap.GetIMapObjectCount();
+ size_t nCount = rImageMap.GetIMapObjectCount();
ClearImageMap();
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( size_t i = 0; i < nCount; i++ )
{
IMapObject* pCopyObj = rImageMap.GetIMapObject( i );
switch( pCopyObj->GetType() )
{
case( IMAP_OBJ_RECTANGLE ):
- maList.Insert( new IMapRectangleObject( *(IMapRectangleObject*) pCopyObj ), LIST_APPEND );
+ maList.push_back( new IMapRectangleObject( *(IMapRectangleObject*) pCopyObj ) );
break;
case( IMAP_OBJ_CIRCLE ):
- maList.Insert( new IMapCircleObject( *(IMapCircleObject*) pCopyObj ), LIST_APPEND );
+ maList.push_back( new IMapCircleObject( *(IMapCircleObject*) pCopyObj ) );
break;
case( IMAP_OBJ_POLYGON ):
- maList.Insert( new IMapPolygonObject( *(IMapPolygonObject*) pCopyObj ), LIST_APPEND );
+ maList.push_back( new IMapPolygonObject( *(IMapPolygonObject*) pCopyObj ) );
break;
default:
@@ -849,17 +843,17 @@ ImageMap& ImageMap::operator=( const ImageMap& rImageMap )
sal_Bool ImageMap::operator==( const ImageMap& rImageMap )
{
- const sal_uInt16 nCount = (sal_uInt16) maList.Count();
- const sal_uInt16 nEqCount = rImageMap.GetIMapObjectCount();
- sal_Bool bRet = sal_False;
+ const size_t nCount = maList.size();
+ const size_t nEqCount = rImageMap.GetIMapObjectCount();
+ sal_Bool bRet = sal_False;
if ( nCount == nEqCount )
{
sal_Bool bDifferent = ( aName != rImageMap.aName );
- for ( sal_uInt16 i = 0; ( i < nCount ) && !bDifferent; i++ )
+ for ( size_t i = 0; ( i < nCount ) && !bDifferent; i++ )
{
- IMapObject* pObj = (IMapObject*) maList.GetObject( i );
+ IMapObject* pObj = maList[ i ];
IMapObject* pEqObj = rImageMap.GetIMapObject( i );
if ( pObj->GetType() == pEqObj->GetType() )
@@ -938,15 +932,15 @@ void ImageMap::InsertIMapObject( const IMapObject& rIMapObject )
switch( rIMapObject.GetType() )
{
case( IMAP_OBJ_RECTANGLE ):
- maList.Insert( new IMapRectangleObject( (IMapRectangleObject&) rIMapObject ), LIST_APPEND );
+ maList.push_back( new IMapRectangleObject( (IMapRectangleObject&) rIMapObject ) );
break;
case( IMAP_OBJ_CIRCLE ):
- maList.Insert( new IMapCircleObject( (IMapCircleObject&) rIMapObject ), LIST_APPEND );
+ maList.push_back( new IMapCircleObject( (IMapCircleObject&) rIMapObject ) );
break;
case( IMAP_OBJ_POLYGON ):
- maList.Insert( new IMapPolygonObject( (IMapPolygonObject&) rIMapObject ), LIST_APPEND );
+ maList.push_back( new IMapPolygonObject( (IMapPolygonObject&) rIMapObject ) );
break;
default:
@@ -981,13 +975,12 @@ IMapObject* ImageMap::GetHitIMapObject( const Size& rTotalSize,
}
// Alle Objekte durchlaufen und HitTest ausfuehren
- IMapObject* pObj = (IMapObject*) maList.First();
- while ( pObj )
- {
- if ( pObj->IsHit( aRelPoint ) )
+ IMapObject* pObj = NULL;
+ for( size_t i = 0, n = maList.size(); i < n; ++i ) {
+ if ( maList[ i ]->IsHit( aRelPoint ) ) {
+ pObj = maList[ i ];
break;
-
- pObj = (IMapObject*) maList.Next();
+ }
}
return( pObj ? ( pObj->IsActive() ? pObj : NULL ) : NULL );
@@ -1002,11 +995,11 @@ IMapObject* ImageMap::GetHitIMapObject( const Size& rTotalSize,
Rectangle ImageMap::GetBoundRect() const
{
- Rectangle aBoundRect;
- sal_uLong nCount = maList.Count();
+ Rectangle aBoundRect;
+ size_t nCount = maList.size();
- for ( sal_uLong i = 0; i < nCount; i++ )
- aBoundRect.Union( ( (IMapObject*) maList.GetObject( i ) )->GetBoundRect() );
+ for ( size_t i = 0; i < nCount; i++ )
+ aBoundRect.Union( maList[ i ]->GetBoundRect() );
return aBoundRect;
}
@@ -1020,11 +1013,11 @@ Rectangle ImageMap::GetBoundRect() const
void ImageMap::Scale( const Fraction& rFracX, const Fraction& rFracY )
{
- sal_uInt16 nCount = (sal_uInt16) maList.Count();
+ size_t nCount = maList.size();
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( size_t i = 0; i < nCount; i++ )
{
- IMapObject* pObj = GetIMapObject( i );
+ IMapObject* pObj = maList[ i ];
switch( pObj->GetType() )
{
@@ -1056,11 +1049,11 @@ void ImageMap::Scale( const Fraction& rFracX, const Fraction& rFracY )
void ImageMap::ImpWriteImageMap( SvStream& rOStm, const String& rBaseURL ) const
{
IMapObject* pObj;
- sal_uInt16 nCount = (sal_uInt16) maList.Count();
+ size_t nCount = maList.size();
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( size_t i = 0; i < nCount; i++ )
{
- pObj = (IMapObject*) maList.GetObject( i );
+ pObj = maList[ i ];
pObj->Write( rOStm, rBaseURL );
}
}
@@ -1072,10 +1065,10 @@ void ImageMap::ImpWriteImageMap( SvStream& rOStm, const String& rBaseURL ) const
|*
\******************************************************************************/
-void ImageMap::ImpReadImageMap( SvStream& rIStm, sal_uInt16 nCount, const String& rBaseURL )
+void ImageMap::ImpReadImageMap( SvStream& rIStm, size_t nCount, const String& rBaseURL )
{
// neue Objekte einlesen
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( size_t i = 0; i < nCount; i++ )
{
sal_uInt16 nType;
@@ -1088,7 +1081,7 @@ void ImageMap::ImpReadImageMap( SvStream& rIStm, sal_uInt16 nCount, const String
{
IMapRectangleObject* pObj = new IMapRectangleObject;
pObj->Read( rIStm, rBaseURL );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
break;
@@ -1096,7 +1089,7 @@ void ImageMap::ImpReadImageMap( SvStream& rIStm, sal_uInt16 nCount, const String
{
IMapCircleObject* pObj = new IMapCircleObject;
pObj->Read( rIStm, rBaseURL );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
break;
@@ -1104,7 +1097,7 @@ void ImageMap::ImpReadImageMap( SvStream& rIStm, sal_uInt16 nCount, const String
{
IMapPolygonObject* pObj = new IMapPolygonObject;
pObj->Read( rIStm, rBaseURL );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
break;
diff --git a/svtools/source/misc/imap2.cxx b/svtools/source/misc/imap2.cxx
index 8be37fd..e78767c 100644
--- a/svtools/source/misc/imap2.cxx
+++ b/svtools/source/misc/imap2.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -169,11 +169,11 @@ void ImageMap::Write( SvStream& rOStm, sal_uLong nFormat, const String& rBaseURL
void ImageMap::ImpWriteCERN( SvStream& rOStm, const String& rBaseURL ) const
{
IMapObject* pObj;
- sal_uInt16 nCount = (sal_uInt16) maList.Count();
+ size_t nCount = maList.size();
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( size_t i = 0; i < nCount; i++ )
{
- pObj = GetIMapObject( i );
+ pObj = maList[ i ];
switch( pObj->GetType() )
{
@@ -198,13 +198,13 @@ void ImageMap::ImpWriteCERN( SvStream& rOStm, const String& rBaseURL ) const
void ImageMap::ImpWriteNCSA( SvStream& rOStm, const String& rBaseURL ) const
{
IMapObject* pObj;
- sal_uInt16 nCount = (sal_uInt16) maList.Count();
+ size_t nCount = maList.size();
- for ( sal_uInt16 i = 0; i < nCount; i++ )
+ for ( size_t i = 0; i < nCount; i++ )
{
- pObj = GetIMapObject( i );
+ pObj = maList[ i ];
- switch( pObj->GetType() )
+ switch( pObj->GetType() )
{
case( IMAP_OBJ_RECTANGLE ):
( (IMapRectangleObject*) pObj )->WriteNCSA( rOStm, rBaseURL );
@@ -290,7 +290,7 @@ void ImageMap::ImpReadCERNLine( const ByteString& rLine, const String& rBaseURL
const Rectangle aRect( aTopLeft, aBottomRight );
IMapRectangleObject* pObj = new IMapRectangleObject( aRect, aURL, String(), String(), String(), String() );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
else if ( ( aToken == "circle" ) || ( aToken == "circ" ) )
{
@@ -299,7 +299,7 @@ void ImageMap::ImpReadCERNLine( const ByteString& rLine, const String& rBaseURL
const String aURL( ImpReadCERNURL( &pStr, rBaseURL ) );
IMapCircleObject* pObj = new IMapCircleObject( aCenter, nRadius, aURL, String(), String(), String(), String() );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
else if ( ( aToken == "polygon" ) || ( aToken == "poly" ) )
{
@@ -313,7 +313,7 @@ void ImageMap::ImpReadCERNLine( const ByteString& rLine, const String& rBaseURL
aURL = ImpReadCERNURL( &pStr, rBaseURL );
IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, String(), String(), String(), String() );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
}
}
@@ -433,7 +433,7 @@ void ImageMap::ImpReadNCSALine( const ByteString& rLine, const String& rBaseURL
const Rectangle aRect( aTopLeft, aBottomRight );
IMapRectangleObject* pObj = new IMapRectangleObject( aRect, aURL, String(), String(), String(), String() );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
else if ( aToken == "circle" )
{
@@ -444,7 +444,7 @@ void ImageMap::ImpReadNCSALine( const ByteString& rLine, const String& rBaseURL
(double) aDX.Y() * aDX.Y() );
IMapCircleObject* pObj = new IMapCircleObject( aCenter, nRadius, aURL, String(), String(), String(), String() );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
else if ( aToken == "poly" )
{
@@ -456,7 +456,7 @@ void ImageMap::ImpReadNCSALine( const ByteString& rLine, const String& rBaseURL
aPoly[ i ] = ImpReadNCSACoords( &pStr );
IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, String(), String(), String(), String() );
- maList.Insert( pObj, LIST_APPEND );
+ maList.push_back( pObj );
}
}
}
More information about the Libreoffice-commits
mailing list