1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sortdynres.hxx,v $
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"
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
;
99 sal_Bool mbGotWelcome
:1;
100 sal_Bool mbUseOne
:1;
101 sal_Bool mbStatic
:1;
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 //-----------------------------------------------------------------
117 //-----------------------------------------------------------------
120 //-----------------------------------------------------------------
122 //-----------------------------------------------------------------
125 //-----------------------------------------------------------------
127 //-----------------------------------------------------------------
128 XSERVICEINFO_NOFACTORY_DECL()
130 //-----------------------------------------------------------------
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 //-----------------------------------------------------------------
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
,
162 virtual sal_Int16 SAL_CALL
164 throw( RUNTIMEEXCEPTION
);
166 //-----------------------------------------------------------------
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
;
188 SortedDynamicResultSetListener( SortedDynamicResultSet
*mOwner
);
189 ~SortedDynamicResultSetListener();
191 //-----------------------------------------------------------------
193 //-----------------------------------------------------------------
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 //-----------------------------------------------------------------
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
;
229 SortedDynamicResultSetFactory(
230 const REFERENCE
< XMULTISERVICEFACTORY
> & rSMgr
);
232 ~SortedDynamicResultSetFactory();
234 //-----------------------------------------------------------------
236 //-----------------------------------------------------------------
239 //-----------------------------------------------------------------
241 //-----------------------------------------------------------------
244 //-----------------------------------------------------------------
246 //-----------------------------------------------------------------
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
);