1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10*5b190011SAndrew Rist * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5b190011SAndrew Rist * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19*5b190011SAndrew Rist * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 27cdf0e10cSrcweir #include <osl/mutex.hxx> 28cdf0e10cSrcweir #include <vos/mutex.hxx> 29cdf0e10cSrcweir #include <vcl/svapp.hxx> 30cdf0e10cSrcweir #include <svx/svdpage.hxx> 31cdf0e10cSrcweir #include <comphelper/extract.hxx> 32cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "unohelp.hxx" 35cdf0e10cSrcweir #include "unomodel.hxx" 36cdf0e10cSrcweir #include "drawdoc.hxx" 37cdf0e10cSrcweir #include "unocpres.hxx" 38cdf0e10cSrcweir #include "cusshow.hxx" 39cdf0e10cSrcweir #include "unopage.hxx" 40cdf0e10cSrcweir 41cdf0e10cSrcweir using namespace ::rtl; 42cdf0e10cSrcweir using namespace ::vos; 43cdf0e10cSrcweir using namespace ::com::sun::star; 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir uno::Reference< uno::XInterface > createUnoCustomShow( SdCustomShow* pShow ) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir return (cppu::OWeakObject*)new SdXCustomPresentation( pShow, NULL ); 49cdf0e10cSrcweir } 50cdf0e10cSrcweir 51cdf0e10cSrcweir SdXCustomPresentation::SdXCustomPresentation() throw() 52cdf0e10cSrcweir : mpSdCustomShow(NULL), mpModel(NULL), 53cdf0e10cSrcweir aDisposeListeners( aDisposeContainerMutex ), 54cdf0e10cSrcweir bDisposing( sal_False ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir SdXCustomPresentation::SdXCustomPresentation( SdCustomShow* pShow, SdXImpressDocument* pMyModel) throw() 59cdf0e10cSrcweir : mpSdCustomShow(pShow), mpModel(pMyModel), 60cdf0e10cSrcweir aDisposeListeners( aDisposeContainerMutex ), 61cdf0e10cSrcweir bDisposing( sal_False ) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir SdXCustomPresentation::~SdXCustomPresentation() throw() 66cdf0e10cSrcweir { 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SdXCustomPresentation ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir // XServiceInfo 72cdf0e10cSrcweir OUString SAL_CALL SdXCustomPresentation::getImplementationName() 73cdf0e10cSrcweir throw(uno::RuntimeException) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM("SdXCustomPresentation") ); 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir sal_Bool SAL_CALL SdXCustomPresentation::supportsService( const OUString& ServiceName ) 79cdf0e10cSrcweir throw(uno::RuntimeException) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SdXCustomPresentation::getSupportedServiceNames() 85cdf0e10cSrcweir throw(uno::RuntimeException) 86cdf0e10cSrcweir { 87cdf0e10cSrcweir OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.CustomPresentation") ); 88cdf0e10cSrcweir uno::Sequence< OUString > aSeq( &aSN, 1 ); 89cdf0e10cSrcweir return aSeq; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir // XIndexContainer 93cdf0e10cSrcweir void SAL_CALL SdXCustomPresentation::insertByIndex( sal_Int32 Index, const uno::Any& Element ) 94cdf0e10cSrcweir throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir if( bDisposing ) 99cdf0e10cSrcweir throw lang::DisposedException(); 100cdf0e10cSrcweir 101cdf0e10cSrcweir if( Index < 0 || Index > (sal_Int32)( mpSdCustomShow ? mpSdCustomShow->Count() : 0 ) ) 102cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 103cdf0e10cSrcweir 104cdf0e10cSrcweir uno::Reference< drawing::XDrawPage > xPage; 105cdf0e10cSrcweir Element >>= xPage; 106cdf0e10cSrcweir 107cdf0e10cSrcweir if(!xPage.is()) 108cdf0e10cSrcweir throw lang::IllegalArgumentException(); 109cdf0e10cSrcweir 110cdf0e10cSrcweir SdDrawPage* pPage = SdDrawPage::getImplementation( xPage ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir if(pPage) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir if( NULL == mpModel ) 115cdf0e10cSrcweir mpModel = pPage->GetModel(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir if( NULL != mpModel && NULL == mpSdCustomShow && mpModel->GetDoc() ) 118cdf0e10cSrcweir mpSdCustomShow = new SdCustomShow( mpModel->GetDoc() ); 119cdf0e10cSrcweir 120cdf0e10cSrcweir mpSdCustomShow->Insert(pPage->GetSdrPage(), Index); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir if( mpModel ) 124cdf0e10cSrcweir mpModel->SetModified(); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir void SAL_CALL SdXCustomPresentation::removeByIndex( sal_Int32 Index ) 128cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 131cdf0e10cSrcweir 132cdf0e10cSrcweir if( bDisposing ) 133cdf0e10cSrcweir throw lang::DisposedException(); 134cdf0e10cSrcweir 135cdf0e10cSrcweir if(mpSdCustomShow) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir uno::Reference< drawing::XDrawPage > xPage; 138cdf0e10cSrcweir getByIndex( Index ) >>= xPage; 139cdf0e10cSrcweir 140cdf0e10cSrcweir if( xPage.is() ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir SvxDrawPage* pPage = SvxDrawPage::getImplementation( xPage ); 143cdf0e10cSrcweir if(pPage) 144cdf0e10cSrcweir mpSdCustomShow->Remove(pPage->GetSdrPage()); 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir if( mpModel ) 149cdf0e10cSrcweir mpModel->SetModified(); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir // XIndexReplace 153cdf0e10cSrcweir void SAL_CALL SdXCustomPresentation::replaceByIndex( sal_Int32 Index, const uno::Any& Element ) 154cdf0e10cSrcweir throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir removeByIndex( Index ); 157cdf0e10cSrcweir insertByIndex( Index, Element ); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir // XElementAccess 161cdf0e10cSrcweir uno::Type SAL_CALL SdXCustomPresentation::getElementType() 162cdf0e10cSrcweir throw(uno::RuntimeException) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir return ITYPE( drawing::XDrawPage ); 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir sal_Bool SAL_CALL SdXCustomPresentation::hasElements() 168cdf0e10cSrcweir throw(uno::RuntimeException) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 171cdf0e10cSrcweir 172cdf0e10cSrcweir if( bDisposing ) 173cdf0e10cSrcweir throw lang::DisposedException(); 174cdf0e10cSrcweir 175cdf0e10cSrcweir return getCount() > 0; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir // XIndexAccess 179cdf0e10cSrcweir sal_Int32 SAL_CALL SdXCustomPresentation::getCount() 180cdf0e10cSrcweir throw(uno::RuntimeException) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 183cdf0e10cSrcweir if( bDisposing ) 184cdf0e10cSrcweir throw lang::DisposedException(); 185cdf0e10cSrcweir 186cdf0e10cSrcweir return mpSdCustomShow?mpSdCustomShow->Count():0; 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir uno::Any SAL_CALL SdXCustomPresentation::getByIndex( sal_Int32 Index ) 190cdf0e10cSrcweir throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 193cdf0e10cSrcweir 194cdf0e10cSrcweir if( bDisposing ) 195cdf0e10cSrcweir throw lang::DisposedException(); 196cdf0e10cSrcweir 197cdf0e10cSrcweir if( Index < 0 || Index >= (sal_Int32)mpSdCustomShow->Count() ) 198cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 199cdf0e10cSrcweir 200cdf0e10cSrcweir uno::Any aAny; 201cdf0e10cSrcweir if(mpSdCustomShow ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir SdrPage* pPage = (SdrPage*)mpSdCustomShow->GetObject(Index); 204cdf0e10cSrcweir 205cdf0e10cSrcweir if( pPage ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir uno::Reference< drawing::XDrawPage > xRef( pPage->getUnoPage(), uno::UNO_QUERY ); 208cdf0e10cSrcweir aAny <<= xRef; 209cdf0e10cSrcweir } 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir return aAny; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir // XNamed 216cdf0e10cSrcweir OUString SAL_CALL SdXCustomPresentation::getName() 217cdf0e10cSrcweir throw(uno::RuntimeException) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir if( bDisposing ) 222cdf0e10cSrcweir throw lang::DisposedException(); 223cdf0e10cSrcweir 224cdf0e10cSrcweir if(mpSdCustomShow) 225cdf0e10cSrcweir return mpSdCustomShow->GetName(); 226cdf0e10cSrcweir 227cdf0e10cSrcweir return OUString(); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir 230cdf0e10cSrcweir void SAL_CALL SdXCustomPresentation::setName( const OUString& aName ) 231cdf0e10cSrcweir throw(uno::RuntimeException) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir if( bDisposing ) 236cdf0e10cSrcweir throw lang::DisposedException(); 237cdf0e10cSrcweir 238cdf0e10cSrcweir if(mpSdCustomShow) 239cdf0e10cSrcweir mpSdCustomShow->SetName( aName ); 240cdf0e10cSrcweir } 241cdf0e10cSrcweir 242cdf0e10cSrcweir // XComponent 243cdf0e10cSrcweir void SAL_CALL SdXCustomPresentation::dispose() throw(uno::RuntimeException) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir if( bDisposing ) 248cdf0e10cSrcweir return; // catched a recursion 249cdf0e10cSrcweir 250cdf0e10cSrcweir bDisposing = sal_True; 251cdf0e10cSrcweir 252cdf0e10cSrcweir uno::Reference< uno::XInterface > xSource( (cppu::OWeakObject*)this ); 253cdf0e10cSrcweir 254cdf0e10cSrcweir lang::EventObject aEvt; 255cdf0e10cSrcweir aEvt.Source = xSource; 256cdf0e10cSrcweir aDisposeListeners.disposeAndClear(aEvt); 257cdf0e10cSrcweir 258cdf0e10cSrcweir mpSdCustomShow = NULL; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir //---------------------------------------------------------------------- 262cdf0e10cSrcweir void SAL_CALL SdXCustomPresentation::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) 263cdf0e10cSrcweir throw(uno::RuntimeException) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir if( bDisposing ) 266cdf0e10cSrcweir throw lang::DisposedException(); 267cdf0e10cSrcweir 268cdf0e10cSrcweir aDisposeListeners.addInterface(xListener); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir //---------------------------------------------------------------------- 272cdf0e10cSrcweir void SAL_CALL SdXCustomPresentation::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) throw(uno::RuntimeException) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir if( !bDisposing ) 275cdf0e10cSrcweir aDisposeListeners.removeInterface(aListener); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir /*===========================================================================* 279cdf0e10cSrcweir * class SdXCustomPresentationAccess : public XCustomPresentationAccess, * 280cdf0e10cSrcweir * public UsrObject * 281cdf0e10cSrcweir *===========================================================================*/ 282cdf0e10cSrcweir 283cdf0e10cSrcweir SdXCustomPresentationAccess::SdXCustomPresentationAccess(SdXImpressDocument& rMyModel) throw() 284cdf0e10cSrcweir : mrModel(rMyModel) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir } 287cdf0e10cSrcweir 288cdf0e10cSrcweir SdXCustomPresentationAccess::~SdXCustomPresentationAccess() throw() 289cdf0e10cSrcweir { 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir // XServiceInfo 293cdf0e10cSrcweir OUString SAL_CALL SdXCustomPresentationAccess::getImplementationName() 294cdf0e10cSrcweir throw(uno::RuntimeException) 295cdf0e10cSrcweir { 296cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM("SdXCustomPresentationAccess") ); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir sal_Bool SAL_CALL SdXCustomPresentationAccess::supportsService( const OUString& ServiceName ) 300cdf0e10cSrcweir throw(uno::RuntimeException) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SdXCustomPresentationAccess::getSupportedServiceNames() 306cdf0e10cSrcweir throw(uno::RuntimeException) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir const OUString aNS( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.CustomPresentationAccess") ); 309cdf0e10cSrcweir uno::Sequence< OUString > aSeq( &aNS, 1 ); 310cdf0e10cSrcweir return aSeq; 311cdf0e10cSrcweir } 312cdf0e10cSrcweir 313cdf0e10cSrcweir // XSingleServiceFactory 314cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SdXCustomPresentationAccess::createInstance() 315cdf0e10cSrcweir throw(uno::Exception, uno::RuntimeException) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir uno::Reference< uno::XInterface > xRef( (::cppu::OWeakObject*)new SdXCustomPresentation() ); 318cdf0e10cSrcweir return xRef; 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL SdXCustomPresentationAccess::createInstanceWithArguments( const uno::Sequence< uno::Any >& ) 322cdf0e10cSrcweir throw(uno::Exception, uno::RuntimeException) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir return createInstance(); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir 327cdf0e10cSrcweir // XNameContainer 328cdf0e10cSrcweir void SAL_CALL SdXCustomPresentationAccess::insertByName( const OUString& aName, const uno::Any& aElement ) 329cdf0e10cSrcweir throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 332cdf0e10cSrcweir 333cdf0e10cSrcweir // get the documents custom show list 334cdf0e10cSrcweir List* pList = 0; 335cdf0e10cSrcweir if(mrModel.GetDoc()) 336cdf0e10cSrcweir pList = mrModel.GetDoc()->GetCustomShowList(sal_True); 337cdf0e10cSrcweir 338cdf0e10cSrcweir // no list, no cookies 339cdf0e10cSrcweir if( NULL == pList) 340cdf0e10cSrcweir throw uno::RuntimeException(); 341cdf0e10cSrcweir 342cdf0e10cSrcweir // do we have an container::XIndexContainer? 343cdf0e10cSrcweir SdXCustomPresentation* pXShow = NULL; 344cdf0e10cSrcweir 345cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xContainer; 346cdf0e10cSrcweir if( (aElement >>= xContainer) && xContainer.is() ) 347cdf0e10cSrcweir pXShow = SdXCustomPresentation::getImplementation(xContainer); 348cdf0e10cSrcweir 349cdf0e10cSrcweir if( NULL == pXShow ) 350cdf0e10cSrcweir throw lang::IllegalArgumentException(); 351cdf0e10cSrcweir 352cdf0e10cSrcweir // get the internal custom show from the api wrapper 353cdf0e10cSrcweir SdCustomShow* pShow = pXShow->GetSdCustomShow(); 354cdf0e10cSrcweir if( NULL == pShow ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir pShow = new SdCustomShow( mrModel.GetDoc(), xContainer ); 357cdf0e10cSrcweir pXShow->SetSdCustomShow( pShow ); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir else 360cdf0e10cSrcweir { 361cdf0e10cSrcweir if( NULL == pXShow->GetModel() || *pXShow->GetModel() != mrModel ) 362cdf0e10cSrcweir throw lang::IllegalArgumentException(); 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir // give it a name 366cdf0e10cSrcweir pShow->SetName( aName); 367cdf0e10cSrcweir 368cdf0e10cSrcweir // check if this or another customshow with the same name already exists 369cdf0e10cSrcweir for( SdCustomShow* pCompare = (SdCustomShow*)pList->First(); 370cdf0e10cSrcweir pCompare; 371cdf0e10cSrcweir pCompare = (SdCustomShow*)pList->Next() ) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir if( pCompare == pShow || pCompare->GetName() == pShow->GetName() ) 374cdf0e10cSrcweir throw container::ElementExistException(); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir pList->Insert(pShow); 378cdf0e10cSrcweir 379cdf0e10cSrcweir mrModel.SetModified(); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir void SAL_CALL SdXCustomPresentationAccess::removeByName( const OUString& Name ) 383cdf0e10cSrcweir throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 386cdf0e10cSrcweir 387cdf0e10cSrcweir SdCustomShow* pShow = getSdCustomShow(Name); 388cdf0e10cSrcweir 389cdf0e10cSrcweir List* pList = GetCustomShowList(); 390cdf0e10cSrcweir if(pList && pShow) 391cdf0e10cSrcweir delete (SdCustomShow*)pList->Remove( pShow ); 392cdf0e10cSrcweir else 393cdf0e10cSrcweir throw container::NoSuchElementException(); 394cdf0e10cSrcweir 395cdf0e10cSrcweir mrModel.SetModified(); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir // XNameReplace 399cdf0e10cSrcweir void SAL_CALL SdXCustomPresentationAccess::replaceByName( const OUString& aName, const uno::Any& aElement ) 400cdf0e10cSrcweir throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir removeByName( aName ); 403cdf0e10cSrcweir insertByName( aName, aElement ); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir // XNameAccess 407cdf0e10cSrcweir uno::Any SAL_CALL SdXCustomPresentationAccess::getByName( const OUString& aName ) 408cdf0e10cSrcweir throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 409cdf0e10cSrcweir { 410cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 411cdf0e10cSrcweir 412cdf0e10cSrcweir uno::Any aAny; 413cdf0e10cSrcweir 414cdf0e10cSrcweir SdCustomShow* pShow = getSdCustomShow(aName); 415cdf0e10cSrcweir if(pShow) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir uno::Reference< container::XIndexContainer > xRef( pShow->getUnoCustomShow(), uno::UNO_QUERY ); 418cdf0e10cSrcweir aAny <<= xRef; 419cdf0e10cSrcweir } 420cdf0e10cSrcweir else 421cdf0e10cSrcweir { 422cdf0e10cSrcweir throw container::NoSuchElementException(); 423cdf0e10cSrcweir } 424cdf0e10cSrcweir 425cdf0e10cSrcweir return aAny; 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SdXCustomPresentationAccess::getElementNames() 429cdf0e10cSrcweir throw(uno::RuntimeException) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 432cdf0e10cSrcweir 433cdf0e10cSrcweir List* pList = GetCustomShowList(); 434cdf0e10cSrcweir const sal_uInt32 nCount = pList?pList->Count():0; 435cdf0e10cSrcweir 436cdf0e10cSrcweir uno::Sequence< OUString > aSequence( nCount ); 437cdf0e10cSrcweir OUString* pStringList = aSequence.getArray(); 438cdf0e10cSrcweir 439cdf0e10cSrcweir sal_uInt32 nIdx = 0; 440cdf0e10cSrcweir while( nIdx < nCount ) 441cdf0e10cSrcweir { 442cdf0e10cSrcweir const SdCustomShow* pShow = (const SdCustomShow*)pList->GetObject(nIdx); 443cdf0e10cSrcweir pStringList[nIdx] = pShow->GetName(); 444cdf0e10cSrcweir nIdx++; 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir return aSequence; 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir 451cdf0e10cSrcweir sal_Bool SAL_CALL SdXCustomPresentationAccess::hasByName( const OUString& aName ) 452cdf0e10cSrcweir throw(uno::RuntimeException) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 455cdf0e10cSrcweir return getSdCustomShow(aName) != NULL; 456cdf0e10cSrcweir } 457cdf0e10cSrcweir 458cdf0e10cSrcweir // XElementAccess 459cdf0e10cSrcweir uno::Type SAL_CALL SdXCustomPresentationAccess::getElementType() 460cdf0e10cSrcweir throw(uno::RuntimeException) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir return ITYPE( container::XIndexContainer ); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465cdf0e10cSrcweir sal_Bool SAL_CALL SdXCustomPresentationAccess::hasElements() 466cdf0e10cSrcweir throw(uno::RuntimeException) 467cdf0e10cSrcweir { 468cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 469cdf0e10cSrcweir 470cdf0e10cSrcweir List* pList = GetCustomShowList(); 471cdf0e10cSrcweir return pList && pList->Count() > 0; 472cdf0e10cSrcweir } 473cdf0e10cSrcweir 474cdf0e10cSrcweir SdCustomShow * SdXCustomPresentationAccess::getSdCustomShow( const OUString& Name ) const throw() 475cdf0e10cSrcweir { 476cdf0e10cSrcweir sal_uInt32 nIdx = 0; 477cdf0e10cSrcweir 478cdf0e10cSrcweir List* pList = GetCustomShowList(); 479cdf0e10cSrcweir const sal_uInt32 nCount = pList?pList->Count():0; 480cdf0e10cSrcweir 481cdf0e10cSrcweir const String aName( Name ); 482cdf0e10cSrcweir 483cdf0e10cSrcweir while( nIdx < nCount ) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir SdCustomShow* pShow = (SdCustomShow*)pList->GetObject(nIdx); 486cdf0e10cSrcweir if( pShow->GetName() == aName ) 487cdf0e10cSrcweir return pShow; 488cdf0e10cSrcweir nIdx++; 489cdf0e10cSrcweir } 490cdf0e10cSrcweir return NULL; 491cdf0e10cSrcweir } 492