xref: /aoo41x/main/ucb/source/core/provprox.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _PROVPROX_HXX
29 #define _PROVPROX_HXX
30 
31 #include <osl/mutex.hxx>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/lang/XTypeProvider.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/ucb/XContentProviderFactory.hpp>
36 #include <com/sun/star/ucb/XContentProvider.hpp>
37 #include <com/sun/star/ucb/XParameterizedContentProvider.hpp>
38 #include <com/sun/star/ucb/XContentProviderSupplier.hpp>
39 #include <cppuhelper/weak.hxx>
40 #include <ucbhelper/macros.hxx>
41 
42 //=========================================================================
43 
44 #define PROVIDER_FACTORY_SERVICE_NAME \
45 							"com.sun.star.ucb.ContentProviderProxyFactory"
46 #define PROVIDER_PROXY_SERVICE_NAME \
47 							"com.sun.star.ucb.ContentProviderProxy"
48 
49 //============================================================================
50 //
51 // class UcbContentProviderProxyFactory.
52 //
53 //============================================================================
54 
55 class UcbContentProviderProxyFactory :
56 				public cppu::OWeakObject,
57 				public com::sun::star::lang::XTypeProvider,
58 				public com::sun::star::lang::XServiceInfo,
59 				public com::sun::star::ucb::XContentProviderFactory
60 {
61 	com::sun::star::uno::Reference<	com::sun::star::lang::XMultiServiceFactory >
62 								m_xSMgr;
63 
64 public:
65 	UcbContentProviderProxyFactory(
66 			const com::sun::star::uno::Reference<
67 				com::sun::star::lang::XMultiServiceFactory >& rxSMgr );
68 	virtual ~UcbContentProviderProxyFactory();
69 
70 	// XInterface
71 	XINTERFACE_DECL()
72 
73 	// XTypeProvider
74 	XTYPEPROVIDER_DECL()
75 
76     // XServiceInfo
77 	XSERVICEINFO_DECL()
78 
79 	// XContentProviderFactory
80     virtual ::com::sun::star::uno::Reference<
81 		::com::sun::star::ucb::XContentProvider > SAL_CALL
82 	createContentProvider( const ::rtl::OUString& Service )
83 		throw( ::com::sun::star::uno::RuntimeException );
84 };
85 
86 //============================================================================
87 //
88 // class UcbContentProviderProxy.
89 //
90 //============================================================================
91 
92 class UcbContentProviderProxy :
93 				public cppu::OWeakObject,
94 				public com::sun::star::lang::XTypeProvider,
95 				public com::sun::star::lang::XServiceInfo,
96 				public com::sun::star::ucb::XContentProviderSupplier,
97 				public com::sun::star::ucb::XContentProvider,
98 				public com::sun::star::ucb::XParameterizedContentProvider
99 {
100 	::osl::Mutex 	m_aMutex;
101 	::rtl::OUString m_aService;
102 	::rtl::OUString m_aTemplate;
103 	::rtl::OUString m_aArguments;
104 	sal_Bool		m_bReplace;
105 	sal_Bool		m_bRegister;
106 
107 	com::sun::star::uno::Reference<	com::sun::star::lang::XMultiServiceFactory >
108 								m_xSMgr;
109 	com::sun::star::uno::Reference<	com::sun::star::ucb::XContentProvider >
110 								m_xProvider;
111 	com::sun::star::uno::Reference<	com::sun::star::ucb::XContentProvider >
112 								m_xTargetProvider;
113 
114 public:
115 	UcbContentProviderProxy(
116 			const com::sun::star::uno::Reference<
117 				com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
118 			const ::rtl::OUString& Service );
119 	virtual ~UcbContentProviderProxy();
120 
121 	// XInterface
122 	XINTERFACE_DECL()
123 
124 	// XTypeProvider
125 	XTYPEPROVIDER_DECL()
126 
127     // XServiceInfo
128 	XSERVICEINFO_NOFACTORY_DECL()
129 
130 	// XContentProviderSupplier
131     virtual ::com::sun::star::uno::Reference<
132 		::com::sun::star::ucb::XContentProvider > SAL_CALL
133 	getContentProvider()
134 		throw( ::com::sun::star::uno::RuntimeException );
135 
136 	// XContentProvider
137     virtual ::com::sun::star::uno::Reference<
138 		::com::sun::star::ucb::XContent > SAL_CALL
139 	queryContent( const ::com::sun::star::uno::Reference<
140 					::com::sun::star::ucb::XContentIdentifier >& Identifier )
141 		throw( ::com::sun::star::ucb::IllegalIdentifierException,
142 			   ::com::sun::star::uno::RuntimeException );
143     virtual sal_Int32 SAL_CALL
144 	compareContentIds( const ::com::sun::star::uno::Reference<
145 						::com::sun::star::ucb::XContentIdentifier >& Id1,
146 					   const ::com::sun::star::uno::Reference<
147 					   	::com::sun::star::ucb::XContentIdentifier >& Id2 )
148 		throw( ::com::sun::star::uno::RuntimeException );
149 
150 	// XParameterizedContentProvider
151     virtual ::com::sun::star::uno::Reference<
152 		::com::sun::star::ucb::XContentProvider > SAL_CALL
153 	registerInstance( const ::rtl::OUString& Template,
154 					  const ::rtl::OUString& Arguments,
155 					  sal_Bool ReplaceExisting )
156 		throw( ::com::sun::star::lang::IllegalArgumentException,
157 			   ::com::sun::star::uno::RuntimeException );
158     virtual ::com::sun::star::uno::Reference<
159 		::com::sun::star::ucb::XContentProvider > SAL_CALL
160 	deregisterInstance( const ::rtl::OUString& Template,
161 						const ::rtl::OUString& Arguments )
162 		throw( ::com::sun::star::lang::IllegalArgumentException,
163 			   ::com::sun::star::uno::RuntimeException );
164 };
165 
166 #endif /* !_PROVPROX_HXX */
167