xref: /aoo4110/main/ucb/source/core/provprox.hxx (revision b1cdbd2c)
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 
24 #ifndef _PROVPROX_HXX
25 #define _PROVPROX_HXX
26 
27 #include <osl/mutex.hxx>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/lang/XTypeProvider.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/ucb/XContentProviderFactory.hpp>
32 #include <com/sun/star/ucb/XContentProvider.hpp>
33 #include <com/sun/star/ucb/XParameterizedContentProvider.hpp>
34 #include <com/sun/star/ucb/XContentProviderSupplier.hpp>
35 #include <cppuhelper/weak.hxx>
36 #include <ucbhelper/macros.hxx>
37 
38 //=========================================================================
39 
40 #define PROVIDER_FACTORY_SERVICE_NAME \
41 							"com.sun.star.ucb.ContentProviderProxyFactory"
42 #define PROVIDER_PROXY_SERVICE_NAME \
43 							"com.sun.star.ucb.ContentProviderProxy"
44 
45 //============================================================================
46 //
47 // class UcbContentProviderProxyFactory.
48 //
49 //============================================================================
50 
51 class UcbContentProviderProxyFactory :
52 				public cppu::OWeakObject,
53 				public com::sun::star::lang::XTypeProvider,
54 				public com::sun::star::lang::XServiceInfo,
55 				public com::sun::star::ucb::XContentProviderFactory
56 {
57 	com::sun::star::uno::Reference<	com::sun::star::lang::XMultiServiceFactory >
58 								m_xSMgr;
59 
60 public:
61 	UcbContentProviderProxyFactory(
62 			const com::sun::star::uno::Reference<
63 				com::sun::star::lang::XMultiServiceFactory >& rxSMgr );
64 	virtual ~UcbContentProviderProxyFactory();
65 
66 	// XInterface
67 	XINTERFACE_DECL()
68 
69 	// XTypeProvider
70 	XTYPEPROVIDER_DECL()
71 
72     // XServiceInfo
73 	XSERVICEINFO_DECL()
74 
75 	// XContentProviderFactory
76     virtual ::com::sun::star::uno::Reference<
77 		::com::sun::star::ucb::XContentProvider > SAL_CALL
78 	createContentProvider( const ::rtl::OUString& Service )
79 		throw( ::com::sun::star::uno::RuntimeException );
80 };
81 
82 //============================================================================
83 //
84 // class UcbContentProviderProxy.
85 //
86 //============================================================================
87 
88 class UcbContentProviderProxy :
89 				public cppu::OWeakObject,
90 				public com::sun::star::lang::XTypeProvider,
91 				public com::sun::star::lang::XServiceInfo,
92 				public com::sun::star::ucb::XContentProviderSupplier,
93 				public com::sun::star::ucb::XContentProvider,
94 				public com::sun::star::ucb::XParameterizedContentProvider
95 {
96 	::osl::Mutex 	m_aMutex;
97 	::rtl::OUString m_aService;
98 	::rtl::OUString m_aTemplate;
99 	::rtl::OUString m_aArguments;
100 	sal_Bool		m_bReplace;
101 	sal_Bool		m_bRegister;
102 
103 	com::sun::star::uno::Reference<	com::sun::star::lang::XMultiServiceFactory >
104 								m_xSMgr;
105 	com::sun::star::uno::Reference<	com::sun::star::ucb::XContentProvider >
106 								m_xProvider;
107 	com::sun::star::uno::Reference<	com::sun::star::ucb::XContentProvider >
108 								m_xTargetProvider;
109 
110 public:
111 	UcbContentProviderProxy(
112 			const com::sun::star::uno::Reference<
113 				com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
114 			const ::rtl::OUString& Service );
115 	virtual ~UcbContentProviderProxy();
116 
117 	// XInterface
118 	XINTERFACE_DECL()
119 
120 	// XTypeProvider
121 	XTYPEPROVIDER_DECL()
122 
123     // XServiceInfo
124 	XSERVICEINFO_NOFACTORY_DECL()
125 
126 	// XContentProviderSupplier
127     virtual ::com::sun::star::uno::Reference<
128 		::com::sun::star::ucb::XContentProvider > SAL_CALL
129 	getContentProvider()
130 		throw( ::com::sun::star::uno::RuntimeException );
131 
132 	// XContentProvider
133     virtual ::com::sun::star::uno::Reference<
134 		::com::sun::star::ucb::XContent > SAL_CALL
135 	queryContent( const ::com::sun::star::uno::Reference<
136 					::com::sun::star::ucb::XContentIdentifier >& Identifier )
137 		throw( ::com::sun::star::ucb::IllegalIdentifierException,
138 			   ::com::sun::star::uno::RuntimeException );
139     virtual sal_Int32 SAL_CALL
140 	compareContentIds( const ::com::sun::star::uno::Reference<
141 						::com::sun::star::ucb::XContentIdentifier >& Id1,
142 					   const ::com::sun::star::uno::Reference<
143 					   	::com::sun::star::ucb::XContentIdentifier >& Id2 )
144 		throw( ::com::sun::star::uno::RuntimeException );
145 
146 	// XParameterizedContentProvider
147     virtual ::com::sun::star::uno::Reference<
148 		::com::sun::star::ucb::XContentProvider > SAL_CALL
149 	registerInstance( const ::rtl::OUString& Template,
150 					  const ::rtl::OUString& Arguments,
151 					  sal_Bool ReplaceExisting )
152 		throw( ::com::sun::star::lang::IllegalArgumentException,
153 			   ::com::sun::star::uno::RuntimeException );
154     virtual ::com::sun::star::uno::Reference<
155 		::com::sun::star::ucb::XContentProvider > SAL_CALL
156 	deregisterInstance( const ::rtl::OUString& Template,
157 						const ::rtl::OUString& Arguments )
158 		throw( ::com::sun::star::lang::IllegalArgumentException,
159 			   ::com::sun::star::uno::RuntimeException );
160 };
161 
162 #endif /* !_PROVPROX_HXX */
163