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