xref: /aoo42x/main/sd/source/ui/unoidl/unocpres.hxx (revision c45d927a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SD_UNOCPRES_HXX
24 #define _SD_UNOCPRES_HXX
25 
26 #include <com/sun/star/lang/XComponent.hpp>
27 #include <com/sun/star/container/XIndexContainer.hpp>
28 #include <com/sun/star/container/XNamed.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <cppuhelper/interfacecontainer.h>
32 #include <osl/mutex.hxx>
33 
34 #include <cppuhelper/implbase5.hxx>
35 #include <comphelper/servicehelper.hxx>
36 
37 ///////////////////////////////////////////////////////////////////////////////
38 
39 class SdXImpressDocument;
40 class SdView;
41 class SdDrawViewShell;
42 class SdCustomShow;
43 
44 class SdXCustomPresentation :	public ::cppu::WeakImplHelper5< ::com::sun::star::container::XIndexContainer,
45 																::com::sun::star::container::XNamed,
46 																::com::sun::star::lang::XUnoTunnel,
47 																::com::sun::star::lang::XComponent,
48 																::com::sun::star::lang::XServiceInfo >
49 {
50 private:
51 	SdCustomShow* 		mpSdCustomShow;
52 	SdXImpressDocument*	mpModel;
53 
54 	// for xComponent
55 	::osl::Mutex aDisposeContainerMutex;
56 	::cppu::OInterfaceContainerHelper aDisposeListeners;
57 	sal_Bool bDisposing;
58 
59 public:
60 	SdXCustomPresentation() throw();
61 	SdXCustomPresentation( SdCustomShow* mpSdCustomShow, SdXImpressDocument* pMyModel) throw();
62 	virtual ~SdXCustomPresentation() throw();
63 
64 	// internal
65 	void Invalidate() { mpSdCustomShow = NULL; }
66 	SdCustomShow* GetSdCustomShow() const throw() { return mpSdCustomShow; }
67 	void SetSdCustomShow( SdCustomShow* pShow ) throw() { mpSdCustomShow = pShow; }
68 	SdXImpressDocument* GetModel() const throw() { return mpModel; }
69 
70 	// uno helper
71 	UNO3_GETIMPLEMENTATION_DECL(SdXCustomPresentation)
72 
73 	// XServiceInfo
74     virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
75     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
76     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
77 
78 	// XIndexContainer
79     virtual void SAL_CALL insertByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
80     virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
81 
82 	// XIndexReplace
83     virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const ::com::sun::star::uno::Any& Element ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
84 
85 	// XElementAccess
86     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
87     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
88 
89 	// XIndexAccess
90     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
91     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
92 
93 	// XNamed
94     virtual ::rtl::OUString SAL_CALL getName(  ) throw(::com::sun::star::uno::RuntimeException);
95     virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
96 
97 	// XComponent
98     virtual void SAL_CALL dispose(  ) throw(::com::sun::star::uno::RuntimeException);
99     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
100     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException);
101 };
102 
103 // --------------------------------------------------------------------------
104 #include <com/sun/star/container/XNameContainer.hpp>
105 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
106 
107 #include <cppuhelper/implbase3.hxx>
108 
109 #include "unomodel.hxx"
110 #include "drawdoc.hxx"
111 
112 class List;
113 
114 class SdXCustomPresentationAccess : public ::cppu::WeakImplHelper3<	::com::sun::star::container::XNameContainer,
115 																	::com::sun::star::lang::XSingleServiceFactory,
116 																	::com::sun::star::lang::XServiceInfo >
117 {
118 private:
119 	SdXImpressDocument& mrModel;
120 
121 	// intern
122 	inline List* GetCustomShowList() const throw();
123 	SdCustomShow * getSdCustomShow( const ::rtl::OUString& Name ) const throw();
124 
125 public:
126 	SdXCustomPresentationAccess(SdXImpressDocument& rMyModel) throw();
127 	~SdXCustomPresentationAccess() throw();
128 
129 	// XServiceInfo
130     virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
131     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
132     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
133 
134 	// XSingleServiceFactory
135     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance(  ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
136     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
137 
138 	// XNameContainer
139     virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
140     virtual void SAL_CALL removeByName( const ::rtl::OUString& Name ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
141 
142 	// XNameReplace
143     virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
144 
145 	// XNameAccess
146     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
147     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException);
148     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
149 
150 	// XElementAccess
151     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
152     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
153 };
154 
155 inline List * SdXCustomPresentationAccess::GetCustomShowList() const throw()
156 {
157 	if(mrModel.GetDoc())
158 		return mrModel.GetDoc()->GetCustomShowList(sal_False);
159 	else
160 		return NULL;
161 };
162 
163 #endif
164 
165 
166