1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <algorithm> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "unogaltheme.hxx" 34*cdf0e10cSrcweir #include "unogalitem.hxx" 35*cdf0e10cSrcweir #include "svx/galtheme.hxx" 36*cdf0e10cSrcweir #include "svx/gallery1.hxx" 37*cdf0e10cSrcweir #include "svx/galmisc.hxx" 38*cdf0e10cSrcweir #include <svx/fmmodel.hxx> 39*cdf0e10cSrcweir #include <rtl/uuid.h> 40*cdf0e10cSrcweir #include <vos/mutex.hxx> 41*cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX_ 42*cdf0e10cSrcweir #include <vcl/svapp.hxx> 43*cdf0e10cSrcweir #endif 44*cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir using namespace ::com::sun::star; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir namespace unogallery { 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir // ----------------- 51*cdf0e10cSrcweir // - GalleryTheme - 52*cdf0e10cSrcweir // ----------------- 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir GalleryTheme::GalleryTheme( const ::rtl::OUString& rThemeName ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir mpGallery = ::Gallery::GetGalleryInstance(); 57*cdf0e10cSrcweir mpTheme = ( mpGallery ? mpGallery->AcquireTheme( rThemeName, *this ) : NULL ); 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir if( mpGallery ) 60*cdf0e10cSrcweir StartListening( *mpGallery ); 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir GalleryTheme::~GalleryTheme() 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir DBG_ASSERT( !mpTheme || mpGallery, "Theme is living without Gallery" ); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir implReleaseItems( NULL ); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir if( mpGallery ) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir EndListening( *mpGallery ); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir if( mpTheme ) 78*cdf0e10cSrcweir mpGallery->ReleaseTheme( mpTheme, *this ); 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir ::rtl::OUString GalleryTheme::getImplementationName_Static() 85*cdf0e10cSrcweir throw() 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.gallery.GalleryTheme" ) ); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > GalleryTheme::getSupportedServiceNames_Static() 93*cdf0e10cSrcweir throw() 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSeq( 1 ); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir aSeq.getArray()[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.gallery.GalleryTheme" ) ); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir return aSeq; 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir ::rtl::OUString SAL_CALL GalleryTheme::getImplementationName() 105*cdf0e10cSrcweir throw( uno::RuntimeException ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir return getImplementationName_Static(); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir sal_Bool SAL_CALL GalleryTheme::supportsService( const ::rtl::OUString& ServiceName ) 113*cdf0e10cSrcweir throw( uno::RuntimeException ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() ); 116*cdf0e10cSrcweir const ::rtl::OUString* pArray = aSNL.getConstArray(); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir for( int i = 0; i < aSNL.getLength(); i++ ) 119*cdf0e10cSrcweir if( pArray[i] == ServiceName ) 120*cdf0e10cSrcweir return true; 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir return false; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL GalleryTheme::getSupportedServiceNames() 128*cdf0e10cSrcweir throw( uno::RuntimeException ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir return getSupportedServiceNames_Static(); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL GalleryTheme::getTypes() 136*cdf0e10cSrcweir throw(uno::RuntimeException) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir uno::Sequence< uno::Type > aTypes( 5 ); 139*cdf0e10cSrcweir uno::Type* pTypes = aTypes.getArray(); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0); 142*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0); 143*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< container::XElementAccess>*)0); 144*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< container::XIndexAccess>*)0); 145*cdf0e10cSrcweir *pTypes++ = ::getCppuType((const uno::Reference< gallery::XGalleryTheme>*)0); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir return aTypes; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL GalleryTheme::getImplementationId() 153*cdf0e10cSrcweir throw(uno::RuntimeException) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir const vos::OGuard aGuard( Application::GetSolarMutex() ); 156*cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aId; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir if( aId.getLength() == 0 ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir aId.realloc( 16 ); 161*cdf0e10cSrcweir rtl_createUuid( reinterpret_cast< sal_uInt8* >( aId.getArray() ), 0, sal_True ); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir return aId; 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir uno::Type SAL_CALL GalleryTheme::getElementType() 170*cdf0e10cSrcweir throw (uno::RuntimeException) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir return ::getCppuType( (const uno::Reference< gallery::XGalleryItem >*) 0); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir sal_Bool SAL_CALL GalleryTheme::hasElements() 178*cdf0e10cSrcweir throw (uno::RuntimeException) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir return( ( mpTheme != NULL ) && ( mpTheme->GetObjectCount() > 0 ) ); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir sal_Int32 SAL_CALL GalleryTheme::getCount() 188*cdf0e10cSrcweir throw (uno::RuntimeException) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir return( mpTheme ? mpTheme->GetObjectCount() : 0 ); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir uno::Any SAL_CALL GalleryTheme::getByIndex( ::sal_Int32 nIndex ) 198*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 201*cdf0e10cSrcweir uno::Any aRet; 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir if( mpTheme ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir if( ( nIndex < 0 ) || ( nIndex >= getCount() ) ) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir else 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir const GalleryObject* pObj = mpTheme->ImplGetGalleryObject( nIndex ); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir if( pObj ) 214*cdf0e10cSrcweir aRet = uno::makeAny( uno::Reference< gallery::XGalleryItem >( new GalleryItem( *this, *pObj ) ) ); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir return aRet; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir ::rtl::OUString SAL_CALL GalleryTheme::getName( ) 224*cdf0e10cSrcweir throw (uno::RuntimeException) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 227*cdf0e10cSrcweir ::rtl::OUString aRet; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir if( mpTheme ) 230*cdf0e10cSrcweir aRet = mpTheme->GetName(); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir return aRet; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir void SAL_CALL GalleryTheme::update( ) 238*cdf0e10cSrcweir throw (uno::RuntimeException) 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir if( mpTheme ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir const Link aDummyLink; 245*cdf0e10cSrcweir mpTheme->Actualize( aDummyLink ); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir ::sal_Int32 SAL_CALL GalleryTheme::insertURLByIndex( 252*cdf0e10cSrcweir const ::rtl::OUString& rURL, ::sal_Int32 nIndex ) 253*cdf0e10cSrcweir throw (lang::WrappedTargetException, uno::RuntimeException) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 256*cdf0e10cSrcweir sal_Int32 nRet = -1; 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir if( mpTheme ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir try 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir const INetURLObject aURL( rURL ); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) ); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir if( ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) && mpTheme->InsertURL( aURL, nIndex ) ) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir const GalleryObject* pObj = mpTheme->ImplGetGalleryObject( aURL ); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir if( pObj ) 271*cdf0e10cSrcweir nRet = mpTheme->ImplGetGalleryObjectPos( pObj ); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir catch( ... ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir return nRet; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir ::sal_Int32 SAL_CALL GalleryTheme::insertGraphicByIndex( 285*cdf0e10cSrcweir const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nIndex ) 286*cdf0e10cSrcweir throw (lang::WrappedTargetException, uno::RuntimeException) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 289*cdf0e10cSrcweir sal_Int32 nRet = -1; 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir if( mpTheme ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir try 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir const Graphic aGraphic( rxGraphic ); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) ); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir if( mpTheme->InsertGraphic( aGraphic, nIndex ) ) 300*cdf0e10cSrcweir nRet = nIndex; 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir catch( ... ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir return nRet; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir ::sal_Int32 SAL_CALL GalleryTheme::insertDrawingByIndex( 313*cdf0e10cSrcweir const uno::Reference< lang::XComponent >& Drawing, sal_Int32 nIndex ) 314*cdf0e10cSrcweir throw (lang::WrappedTargetException, uno::RuntimeException) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 317*cdf0e10cSrcweir sal_Int32 nRet = -1; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir if( mpTheme ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing ); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir if( pModel && pModel->GetDoc() && pModel->GetDoc()->ISA( FmFormModel ) ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) ); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc() ), nIndex ) ) 328*cdf0e10cSrcweir nRet = nIndex; 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir return nRet; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir void SAL_CALL GalleryTheme::removeByIndex( sal_Int32 nIndex ) 338*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir if( mpTheme ) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir if( ( nIndex < 0 ) || ( nIndex >= getCount() ) ) 345*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 346*cdf0e10cSrcweir else 347*cdf0e10cSrcweir mpTheme->RemoveObject( nIndex ); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir void GalleryTheme::Notify( SfxBroadcaster&, const SfxHint& rHint ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 356*cdf0e10cSrcweir const GalleryHint& rGalleryHint = static_cast< const GalleryHint& >( rHint ); 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir switch( rGalleryHint.GetType() ) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir case( GALLERY_HINT_CLOSE_THEME ): 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir DBG_ASSERT( !mpTheme || mpGallery, "Theme is living without Gallery" ); 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir implReleaseItems( NULL ); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir if( mpGallery && mpTheme ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir mpGallery->ReleaseTheme( mpTheme, *this ); 369*cdf0e10cSrcweir mpTheme = NULL; 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir break; 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir case( GALLERY_HINT_CLOSE_OBJECT ): 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir GalleryObject* pObj = reinterpret_cast< GalleryObject* >( rGalleryHint.GetData1() ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir if( pObj ) 379*cdf0e10cSrcweir implReleaseItems( pObj ); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir break; 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir default: 384*cdf0e10cSrcweir break; 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir void GalleryTheme::implReleaseItems( GalleryObject* pObj ) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir for( GalleryItemList::iterator aIter = maItemList.begin(); aIter != maItemList.end(); ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir if( !pObj || ( (*aIter)->implGetObject() == pObj ) ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir (*aIter)->implSetInvalid(); 399*cdf0e10cSrcweir aIter = maItemList.erase( aIter ); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir else 402*cdf0e10cSrcweir ++aIter; 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir ::GalleryTheme* GalleryTheme::implGetTheme() const 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir return mpTheme; 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir void GalleryTheme::implRegisterGalleryItem( ::unogallery::GalleryItem& rItem ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir // DBG_ASSERT( maItemList.find( &rItem ) == maItemList.end(), "Item already registered" ); 420*cdf0e10cSrcweir maItemList.push_back( &rItem ); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir // ------------------------------------------------------------------------------ 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir void GalleryTheme::implDeregisterGalleryItem( ::unogallery::GalleryItem& rItem ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir const ::vos::OGuard aGuard( Application::GetSolarMutex() ); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir // DBG_ASSERT( maItemList.find( &rItem ) != maItemList.end(), "Item is not registered" ); 430*cdf0e10cSrcweir maItemList.remove( &rItem ); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir } 434