Update ooo320-m1
[ooovba.git] / ucb / source / sorter / sortdynres.hxx
blob6f46e545b5464290d339b6fa5b33d66bbb774e11
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sortdynres.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SORTDYNRES_HXX
32 #define _SORTDYNRES_HXX
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/lang/XTypeProvider.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/lang/XComponent.hpp>
38 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
39 #include <com/sun/star/sdbc/XResultSet.hpp>
40 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
41 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
42 #include <com/sun/star/ucb/ListenerAlreadySetException.hpp>
43 #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
44 #include <cppuhelper/weak.hxx>
45 #include <osl/mutex.hxx>
46 #include <ucbhelper/macros.hxx>
47 #include "sortresult.hxx"
49 namespace cppu {
50 class OInterfaceContainerHelper;
53 //-----------------------------------------------------------------------------
55 #define NUMBERED_SORTINGINFO com::sun::star::ucb::NumberedSortingInfo
56 #define RUNTIMEEXCEPTION com::sun::star::uno::RuntimeException
57 #define REFERENCE com::sun::star::uno::Reference
58 #define SEQUENCE com::sun::star::uno::Sequence
59 #define EVENTOBJECT com::sun::star::lang::EventObject
60 #define XEVENTLISTENER com::sun::star::lang::XEventListener
61 #define XMULTISERVICEFACTORY com::sun::star::lang::XMultiServiceFactory
62 #define XRESULTSET com::sun::star::sdbc::XResultSet
63 #define SQLEXCEPTION com::sun::star::sdbc::SQLException
64 #define XANYCOMPAREFACTORY com::sun::star::ucb::XAnyCompareFactory
65 #define XDYNAMICRESULTSET com::sun::star::ucb::XDynamicResultSet
66 #define XDYNAMICRESULTSETLISTENER com::sun::star::ucb::XDynamicResultSetListener
67 #define LISTENERALREADYSETEXCEPTION com::sun::star::ucb::ListenerAlreadySetException
69 #define DYNAMIC_RESULTSET_SERVICE_NAME "com.sun.star.ucb.SortedDynamicResultSet"
70 #define DYNAMIC_RESULTSET_FACTORY_NAME "com.sun.star.ucb.SortedDynamicResultSetFactory"
72 //-----------------------------------------------------------------------------
73 class SortedDynamicResultSetListener;
75 class SortedDynamicResultSet:
76 public cppu::OWeakObject,
77 public com::sun::star::lang::XTypeProvider,
78 public com::sun::star::lang::XServiceInfo,
79 public com::sun::star::ucb::XDynamicResultSet
81 cppu::OInterfaceContainerHelper *mpDisposeEventListeners;
83 REFERENCE < XDYNAMICRESULTSETLISTENER > mxListener;
84 REFERENCE < XDYNAMICRESULTSETLISTENER > mxOwnListener;
86 REFERENCE < XRESULTSET > mxOne;
87 REFERENCE < XRESULTSET > mxTwo;
88 REFERENCE < XDYNAMICRESULTSET > mxOriginal;
89 SEQUENCE < NUMBERED_SORTINGINFO > maOptions;
90 REFERENCE < XANYCOMPAREFACTORY > mxCompFac;
91 REFERENCE < XMULTISERVICEFACTORY > mxSMgr;
93 SortedResultSet* mpOne;
94 SortedResultSet* mpTwo;
95 SortedDynamicResultSetListener* mpOwnListener;
97 EventList maActions;
98 osl::Mutex maMutex;
99 sal_Bool mbGotWelcome :1;
100 sal_Bool mbUseOne :1;
101 sal_Bool mbStatic :1;
103 private:
105 void SendNotify();
107 public:
108 SortedDynamicResultSet( const REFERENCE < XDYNAMICRESULTSET > &xOriginal,
109 const SEQUENCE < NUMBERED_SORTINGINFO > &aOptions,
110 const REFERENCE < XANYCOMPAREFACTORY > &xCompFac,
111 const REFERENCE < XMULTISERVICEFACTORY > &xSMgr );
113 ~SortedDynamicResultSet();
115 //-----------------------------------------------------------------
116 // XInterface
117 //-----------------------------------------------------------------
118 XINTERFACE_DECL()
120 //-----------------------------------------------------------------
121 // XTypeProvider
122 //-----------------------------------------------------------------
123 XTYPEPROVIDER_DECL()
125 //-----------------------------------------------------------------
126 // XServiceInfo
127 //-----------------------------------------------------------------
128 XSERVICEINFO_NOFACTORY_DECL()
130 //-----------------------------------------------------------------
131 // XComponent
132 //-----------------------------------------------------------------
133 virtual void SAL_CALL
134 dispose() throw( RUNTIME_EXCEPTION );
136 virtual void SAL_CALL
137 addEventListener( const REFERENCE< XEVENTLISTENER >& Listener )
138 throw( RUNTIME_EXCEPTION );
140 virtual void SAL_CALL
141 removeEventListener( const REFERENCE< XEVENTLISTENER >& Listener )
142 throw( RUNTIME_EXCEPTION );
144 //-----------------------------------------------------------------
145 // XDynamicResultSet
146 //-----------------------------------------------------------------
147 virtual REFERENCE< XRESULTSET > SAL_CALL
148 getStaticResultSet( )
149 throw( LISTENERALREADYSETEXCEPTION, RUNTIMEEXCEPTION );
151 virtual void SAL_CALL
152 setListener( const REFERENCE< XDYNAMICRESULTSETLISTENER >& Listener )
153 throw( LISTENERALREADYSETEXCEPTION, RUNTIMEEXCEPTION );
155 virtual void SAL_CALL
156 connectToCache( const REFERENCE< XDYNAMICRESULTSET > & xCache )
157 throw( LISTENERALREADYSETEXCEPTION,
158 com::sun::star::ucb::AlreadyInitializedException,
159 com::sun::star::ucb::ServiceNotFoundException,
160 RUNTIMEEXCEPTION );
162 virtual sal_Int16 SAL_CALL
163 getCapabilities()
164 throw( RUNTIMEEXCEPTION );
166 //-----------------------------------------------------------------
167 // own methods:
168 //-----------------------------------------------------------------
169 virtual void SAL_CALL
170 impl_disposing( const EVENTOBJECT& Source )
171 throw( RUNTIMEEXCEPTION );
173 virtual void SAL_CALL
174 impl_notify( const ::com::sun::star::ucb::ListEvent& Changes )
175 throw( RUNTIMEEXCEPTION );
178 //-----------------------------------------------------------------------------
180 class SortedDynamicResultSetListener:
181 public cppu::OWeakObject,
182 public com::sun::star::ucb::XDynamicResultSetListener
184 SortedDynamicResultSet *mpOwner;
185 osl::Mutex maMutex;
187 public:
188 SortedDynamicResultSetListener( SortedDynamicResultSet *mOwner );
189 ~SortedDynamicResultSetListener();
191 //-----------------------------------------------------------------
192 // XInterface
193 //-----------------------------------------------------------------
194 XINTERFACE_DECL()
196 //-----------------------------------------------------------------
197 // XEventListener ( base of XDynamicResultSetListener )
198 //-----------------------------------------------------------------
199 virtual void SAL_CALL
200 disposing( const EVENTOBJECT& Source )
201 throw( RUNTIMEEXCEPTION );
203 //-----------------------------------------------------------------
204 // XDynamicResultSetListener
205 //-----------------------------------------------------------------
206 virtual void SAL_CALL
207 notify( const ::com::sun::star::ucb::ListEvent& Changes )
208 throw( RUNTIMEEXCEPTION );
210 //-----------------------------------------------------------------
211 // own methods:
212 //-----------------------------------------------------------------
213 void SAL_CALL impl_OwnerDies();
216 //-----------------------------------------------------------------------------
218 class SortedDynamicResultSetFactory:
219 public cppu::OWeakObject,
220 public com::sun::star::lang::XTypeProvider,
221 public com::sun::star::lang::XServiceInfo,
222 public com::sun::star::ucb::XSortedDynamicResultSetFactory
225 REFERENCE< XMULTISERVICEFACTORY > mxSMgr;
227 public:
229 SortedDynamicResultSetFactory(
230 const REFERENCE< XMULTISERVICEFACTORY > & rSMgr);
232 ~SortedDynamicResultSetFactory();
234 //-----------------------------------------------------------------
235 // XInterface
236 //-----------------------------------------------------------------
237 XINTERFACE_DECL()
239 //-----------------------------------------------------------------
240 // XTypeProvider
241 //-----------------------------------------------------------------
242 XTYPEPROVIDER_DECL()
244 //-----------------------------------------------------------------
245 // XServiceInfo
246 //-----------------------------------------------------------------
247 XSERVICEINFO_DECL()
249 //-----------------------------------------------------------------
250 // XSortedDynamicResultSetFactory
252 virtual REFERENCE< XDYNAMICRESULTSET > SAL_CALL
253 createSortedDynamicResultSet(
254 const REFERENCE< XDYNAMICRESULTSET > & Source,
255 const SEQUENCE< NUMBERED_SORTINGINFO > & Info,
256 const REFERENCE< XANYCOMPAREFACTORY > & CompareFactory )
257 throw( RUNTIMEEXCEPTION );
260 #endif