summaryrefslogtreecommitdiff
path: root/svx/source/gallery2/galtheme.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/gallery2/galtheme.cxx')
-rw-r--r--svx/source/gallery2/galtheme.cxx163
1 files changed, 91 insertions, 72 deletions
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index eb3098d968..60f1fcfb91 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -76,7 +77,7 @@ using namespace ::com::sun::star;
GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry ) :
pParent ( pGallery ),
pThm ( pThemeEntry ),
- mnThemeLockCount ( 0 ),
+ mnThemeLockCount ( 0 ),
mnBroadcasterLockCount( 0 ),
nDragPos ( 0 ),
bDragging ( FALSE )
@@ -93,12 +94,14 @@ GalleryTheme::~GalleryTheme()
{
ImplWrite();
- for( GalleryObject* pEntry = aObjectList.First(); pEntry; pEntry = aObjectList.Next() )
+ for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
{
+ GalleryObject* pEntry = aObjectList[ i ];
Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
delete pEntry;
Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
}
+ aObjectList.clear();
}
// ------------------------------------------------------------------------
@@ -109,7 +112,7 @@ void GalleryTheme::ImplCreateSvDrawStorage()
{
aSvDrawStorageRef = new SvStorage( FALSE, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), pThm->IsReadOnly() ? STREAM_READ : STREAM_STD_READWRITE );
// #i50423# ReadOnly may not been set though the file can't be written (because of security reasons)
- if ( ( aSvDrawStorageRef->GetError() != ERRCODE_NONE ) && !pThm->IsReadOnly() )
+ if ( ( aSvDrawStorageRef->GetError() != ERRCODE_NONE ) && !pThm->IsReadOnly() )
aSvDrawStorageRef = new SvStorage( FALSE, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
}
else
@@ -118,7 +121,7 @@ void GalleryTheme::ImplCreateSvDrawStorage()
// ------------------------------------------------------------------------
-BOOL GalleryTheme::ImplWriteSgaObject( const SgaObject& rObj, ULONG nPos, GalleryObject* pExistentEntry )
+BOOL GalleryTheme::ImplWriteSgaObject( const SgaObject& rObj, size_t nPos, GalleryObject* pExistentEntry )
{
SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
BOOL bRet = FALSE;
@@ -136,7 +139,14 @@ BOOL GalleryTheme::ImplWriteSgaObject( const SgaObject& rObj, ULONG nPos, Galler
if( !pExistentEntry )
{
pEntry = new GalleryObject;
- aObjectList.Insert( pEntry, nPos );
+ if ( nPos < aObjectList.size() )
+ {
+ GalleryObjectList::iterator it = aObjectList.begin();
+ ::std::advance( it, nPos );
+ aObjectList.insert( it, pEntry );
+ }
+ else
+ aObjectList.push_back( pEntry );
}
else
pEntry = pExistentEntry;
@@ -250,14 +260,10 @@ void GalleryTheme::ImplWrite()
const GalleryObject* GalleryTheme::ImplGetGalleryObject( const INetURLObject& rURL )
{
- GalleryObject* pEntry = aObjectList.First();
- GalleryObject* pFoundEntry = NULL;
-
- for( ; pEntry && !pFoundEntry; pEntry = aObjectList.Next() )
- if( pEntry->aURL == rURL )
- pFoundEntry = pEntry;
-
- return pFoundEntry;
+ for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
+ if ( aObjectList[ i ]->aURL == rURL )
+ return aObjectList[ i ];
+ return NULL;
}
// ------------------------------------------------------------------------
@@ -344,9 +350,12 @@ INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, ULONG nFor
bExists = FALSE;
- for( GalleryObject* pEntry = aObjectList.First(); pEntry && !bExists; pEntry = aObjectList.Next() )
- if( pEntry->aURL == aNewURL )
+ for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
+ if ( aObjectList[ i ]->aURL == aNewURL )
+ {
bExists = TRUE;
+ break;
+ }
}
else
{
@@ -393,15 +402,15 @@ void GalleryTheme::ImplBroadcast( ULONG nUpdatePos )
BOOL GalleryTheme::UnlockTheme()
{
DBG_ASSERT( mnThemeLockCount, "Theme is not locked" );
-
+
BOOL bRet = FALSE;
-
+
if( mnThemeLockCount )
{
--mnThemeLockCount;
bRet = TRUE;
}
-
+
return bRet;
}
@@ -423,12 +432,16 @@ BOOL GalleryTheme::InsertObject( const SgaObject& rObj, ULONG nInsertPos )
if( rObj.IsValid() )
{
- GalleryObject* pEntry = aObjectList.First();
GalleryObject* pFoundEntry = NULL;
-
- for( ; pEntry && !pFoundEntry; pEntry = aObjectList.Next() )
- if( pEntry->aURL == rObj.GetURL() )
- pFoundEntry = pEntry;
+ size_t iFoundPos = 0;
+ for ( size_t n = aObjectList.size(); iFoundPos < n; ++iFoundPos )
+ {
+ if ( aObjectList[ iFoundPos ]->aURL == rObj.GetURL() )
+ {
+ pFoundEntry = aObjectList[ iFoundPos ];
+ break;
+ }
+ }
if( pFoundEntry )
{
@@ -455,7 +468,7 @@ BOOL GalleryTheme::InsertObject( const SgaObject& rObj, ULONG nInsertPos )
ImplWriteSgaObject( rObj, nInsertPos, NULL );
ImplSetModified( bRet = TRUE );
- ImplBroadcast( pFoundEntry ? aObjectList.GetPos( pFoundEntry ) : nInsertPos );
+ ImplBroadcast( pFoundEntry ? iFoundPos : nInsertPos );
}
return bRet;
@@ -463,9 +476,9 @@ BOOL GalleryTheme::InsertObject( const SgaObject& rObj, ULONG nInsertPos )
// ------------------------------------------------------------------------
-SgaObject* GalleryTheme::AcquireObject( ULONG nPos )
+SgaObject* GalleryTheme::AcquireObject( size_t nPos )
{
- return ImplReadSgaObject( aObjectList.GetObject( nPos ) );
+ return ImplReadSgaObject( aObjectList[ nPos ] );
}
// ------------------------------------------------------------------------
@@ -477,11 +490,18 @@ void GalleryTheme::ReleaseObject( SgaObject* pObject )
// ------------------------------------------------------------------------
-BOOL GalleryTheme::RemoveObject( ULONG nPos )
+BOOL GalleryTheme::RemoveObject( size_t nPos )
{
- GalleryObject* pEntry = aObjectList.Remove( nPos );
+ GalleryObject* pEntry = NULL;
+ if ( nPos < aObjectList.size() )
+ {
+ GalleryObjectList::iterator it = aObjectList.begin();
+ ::std::advance( it, nPos );
+ pEntry = *it;
+ aObjectList.erase( it );
+ }
- if( !aObjectList.Count() )
+ if( aObjectList.empty() )
KillFile( GetSdgURL() );
if( pEntry )
@@ -502,25 +522,28 @@ BOOL GalleryTheme::RemoveObject( ULONG nPos )
// ------------------------------------------------------------------------
-BOOL GalleryTheme::ChangeObjectPos( ULONG nOldPos, ULONG nNewPos )
+BOOL GalleryTheme::ChangeObjectPos( size_t nOldPos, size_t nNewPos )
{
BOOL bRet = FALSE;
- if( nOldPos != nNewPos )
+ if( nOldPos != nNewPos
+ && nOldPos < aObjectList.size()
+ )
{
- GalleryObject* pEntry = aObjectList.GetObject( nOldPos );
+ GalleryObject* pEntry = aObjectList[ nOldPos ];
- if( pEntry )
- {
- aObjectList.Insert( pEntry, nNewPos );
+ GalleryObjectList::iterator it = aObjectList.begin();
+ ::std::advance( it, nNewPos );
+ aObjectList.insert( it, pEntry );
- if( nNewPos < nOldPos )
- nOldPos++;
+ if( nNewPos < nOldPos ) nOldPos++;
- aObjectList.Remove( nOldPos );
- ImplSetModified( bRet = TRUE );
- ImplBroadcast( ( nNewPos < nOldPos ) ? nNewPos : ( nNewPos - 1 ) );
- }
+ it = aObjectList.begin();
+ ::std::advance( it, nOldPos );
+ aObjectList.erase( it );
+
+ ImplSetModified( bRet = TRUE );
+ ImplBroadcast( ( nNewPos < nOldPos ) ? nNewPos : ( nNewPos - 1 ) );
}
return bRet;
@@ -535,22 +558,21 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
Graphic aGraphic;
String aFormat;
GalleryObject* pEntry;
- const ULONG nCount = aObjectList.Count();
- ULONG i;
+ const size_t nCount = aObjectList.size();
LockBroadcaster();
bAbortActualize = FALSE;
// LoeschFlag zuruecksetzen
- for ( i = 0; i < nCount; i++ )
- aObjectList.GetObject( i )->bDummy = FALSE;
+ for (size_t i = 0; i < nCount; i++)
+ aObjectList[ i ]->bDummy = FALSE;
- for( i = 0; ( i < nCount ) && !bAbortActualize; i++ )
+ for(size_t i = 0; ( i < nCount ) && !bAbortActualize; i++)
{
if( pProgress )
pProgress->Update( i, nCount - 1 );
- pEntry = aObjectList.GetObject( i );
+ pEntry = aObjectList[ i ];
const INetURLObject aURL( pEntry->aURL );
@@ -615,19 +637,19 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
}
// remove all entries with set flag
- pEntry = aObjectList.First();
- while( pEntry )
+ for ( size_t i = 0; i < aObjectList.size(); )
{
+ pEntry = aObjectList[ i ];
if( pEntry->bDummy )
{
Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
- delete aObjectList.Remove( pEntry );
+ GalleryObjectList::iterator it = aObjectList.begin();
+ ::std::advance( it, i );
+ aObjectList.erase( it );
+ delete pEntry;
Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
-
- pEntry = aObjectList.GetCurObject();
}
- else
- pEntry = aObjectList.Next();
+ else ++i;
}
// update theme
@@ -643,19 +665,18 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
if( pIStm && pTmpStm )
{
- pEntry = aObjectList.First();
-
- while( pEntry )
+ for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
{
+ pEntry = aObjectList[ i ];
SgaObject* pObj;
switch( pEntry->eObjKind )
{
- case( SGA_OBJ_BMP ): pObj = new SgaObjectBmp(); break;
- case( SGA_OBJ_ANIM ): pObj = new SgaObjectAnim(); break;
- case( SGA_OBJ_INET ): pObj = new SgaObjectINet(); break;
- case( SGA_OBJ_SVDRAW ): pObj = new SgaObjectSvDraw(); break;
- case (SGA_OBJ_SOUND): pObj = new SgaObjectSound(); break;
+ case( SGA_OBJ_BMP ): pObj = new SgaObjectBmp(); break;
+ case( SGA_OBJ_ANIM ): pObj = new SgaObjectAnim(); break;
+ case( SGA_OBJ_INET ): pObj = new SgaObjectINet(); break;
+ case( SGA_OBJ_SVDRAW ): pObj = new SgaObjectSvDraw(); break;
+ case (SGA_OBJ_SOUND): pObj = new SgaObjectSound(); break;
default:
pObj = NULL;
@@ -670,8 +691,6 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
*pTmpStm << *pObj;
delete pObj;
}
-
- pEntry = aObjectList.Next();
}
}
else
@@ -722,7 +741,6 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, BO
if( pIStm )
{
String aThemeName;
- sal_uInt32 nThemeId = 0;
sal_uInt16 nVersion;
BOOL bThemeNameFromResource = FALSE;
@@ -730,6 +748,7 @@ GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, BO
if( nVersion <= 0x00ff )
{
+ sal_uInt32 nThemeId = 0;
ByteString aTmpStr;
*pIStm >> aTmpStr; aThemeName = String( aTmpStr.GetBuffer(), RTL_TEXTENCODING_UTF8 );
@@ -1004,7 +1023,7 @@ BOOL GalleryTheme::InsertModel( const FmFormModel& rModel, ULONG nInsertPos )
FmFormModel* pFormModel = (FmFormModel*) &rModel;
pFormModel->BurnInStyleSheetAttributes();
-
+
{
uno::Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( aMemStm ) );
@@ -1180,12 +1199,12 @@ BOOL GalleryTheme::InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, ULONG
::ucbhelper::Content aCnt( rFileOrDirURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >() );
sal_Bool bFolder = false;
- aCnt.getPropertyValue( OUString::createFromAscii( "IsFolder" ) ) >>= bFolder;
+ aCnt.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsFolder")) ) >>= bFolder;
if( bFolder )
{
uno::Sequence< OUString > aProps( 1 );
- aProps.getArray()[ 0 ] = OUString::createFromAscii( "Url" );
+ aProps.getArray()[ 0 ] = OUString(RTL_CONSTASCII_USTRINGPARAM("Url"));
uno::Reference< sdbc::XResultSet > xResultSet( aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
if( xResultSet.is() )
@@ -1455,14 +1474,14 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
sal_uInt32 nId1, nId2;
BOOL bRel;
- for( pObj = aObjectList.First(); pObj; pObj = aObjectList.Next() )
+ for( size_t i = 0, n = aObjectList.size(); i < n; ++i )
{
+ pObj = aObjectList[ i ];
Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< ULONG >( pObj ) ) );
delete pObj;
Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< ULONG >( pObj ) ) );
}
-
- aObjectList.Clear();
+ aObjectList.clear();
for( sal_uInt32 i = 0; i < nCount; i++ )
{
@@ -1526,7 +1545,7 @@ SvStream& GalleryTheme::ReadData( SvStream& rIStm )
}
}
- aObjectList.Insert( pObj, LIST_APPEND );
+ aObjectList.push_back( pObj );
}
rIStm >> nId1 >> nId2;