1*6df1ea1fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6df1ea1fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6df1ea1fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6df1ea1fSAndrew Rist * distributed with this work for additional information 6*6df1ea1fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6df1ea1fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6df1ea1fSAndrew Rist * "License"); you may not use this file except in compliance 9*6df1ea1fSAndrew Rist * with the License. You may obtain a copy of the License at 10*6df1ea1fSAndrew Rist * 11*6df1ea1fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*6df1ea1fSAndrew Rist * 13*6df1ea1fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6df1ea1fSAndrew Rist * software distributed under the License is distributed on an 15*6df1ea1fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6df1ea1fSAndrew Rist * KIND, either express or implied. See the License for the 17*6df1ea1fSAndrew Rist * specific language governing permissions and limitations 18*6df1ea1fSAndrew Rist * under the License. 19*6df1ea1fSAndrew Rist * 20*6df1ea1fSAndrew Rist *************************************************************/ 21*6df1ea1fSAndrew Rist 22*6df1ea1fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SORTDYNRES_HXX 25cdf0e10cSrcweir #define _SORTDYNRES_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 28cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 29cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 30cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 31cdf0e10cSrcweir #include <com/sun/star/ucb/NumberedSortingInfo.hpp> 32cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp> 33cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp> 34cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSetListener.hpp> 35cdf0e10cSrcweir #include <com/sun/star/ucb/ListenerAlreadySetException.hpp> 36cdf0e10cSrcweir #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp> 37cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 38cdf0e10cSrcweir #include <osl/mutex.hxx> 39cdf0e10cSrcweir #include <ucbhelper/macros.hxx> 40cdf0e10cSrcweir #include "sortresult.hxx" 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace cppu { 43cdf0e10cSrcweir class OInterfaceContainerHelper; 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir //----------------------------------------------------------------------------- 47cdf0e10cSrcweir 48cdf0e10cSrcweir #define NUMBERED_SORTINGINFO com::sun::star::ucb::NumberedSortingInfo 49cdf0e10cSrcweir #define RUNTIMEEXCEPTION com::sun::star::uno::RuntimeException 50cdf0e10cSrcweir #define REFERENCE com::sun::star::uno::Reference 51cdf0e10cSrcweir #define SEQUENCE com::sun::star::uno::Sequence 52cdf0e10cSrcweir #define EVENTOBJECT com::sun::star::lang::EventObject 53cdf0e10cSrcweir #define XEVENTLISTENER com::sun::star::lang::XEventListener 54cdf0e10cSrcweir #define XMULTISERVICEFACTORY com::sun::star::lang::XMultiServiceFactory 55cdf0e10cSrcweir #define XRESULTSET com::sun::star::sdbc::XResultSet 56cdf0e10cSrcweir #define SQLEXCEPTION com::sun::star::sdbc::SQLException 57cdf0e10cSrcweir #define XANYCOMPAREFACTORY com::sun::star::ucb::XAnyCompareFactory 58cdf0e10cSrcweir #define XDYNAMICRESULTSET com::sun::star::ucb::XDynamicResultSet 59cdf0e10cSrcweir #define XDYNAMICRESULTSETLISTENER com::sun::star::ucb::XDynamicResultSetListener 60cdf0e10cSrcweir #define LISTENERALREADYSETEXCEPTION com::sun::star::ucb::ListenerAlreadySetException 61cdf0e10cSrcweir 62cdf0e10cSrcweir #define DYNAMIC_RESULTSET_SERVICE_NAME "com.sun.star.ucb.SortedDynamicResultSet" 63cdf0e10cSrcweir #define DYNAMIC_RESULTSET_FACTORY_NAME "com.sun.star.ucb.SortedDynamicResultSetFactory" 64cdf0e10cSrcweir 65cdf0e10cSrcweir //----------------------------------------------------------------------------- 66cdf0e10cSrcweir class SortedDynamicResultSetListener; 67cdf0e10cSrcweir 68cdf0e10cSrcweir class SortedDynamicResultSet: 69cdf0e10cSrcweir public cppu::OWeakObject, 70cdf0e10cSrcweir public com::sun::star::lang::XTypeProvider, 71cdf0e10cSrcweir public com::sun::star::lang::XServiceInfo, 72cdf0e10cSrcweir public com::sun::star::ucb::XDynamicResultSet 73cdf0e10cSrcweir { 74cdf0e10cSrcweir cppu::OInterfaceContainerHelper *mpDisposeEventListeners; 75cdf0e10cSrcweir 76cdf0e10cSrcweir REFERENCE < XDYNAMICRESULTSETLISTENER > mxListener; 77cdf0e10cSrcweir REFERENCE < XDYNAMICRESULTSETLISTENER > mxOwnListener; 78cdf0e10cSrcweir 79cdf0e10cSrcweir REFERENCE < XRESULTSET > mxOne; 80cdf0e10cSrcweir REFERENCE < XRESULTSET > mxTwo; 81cdf0e10cSrcweir REFERENCE < XDYNAMICRESULTSET > mxOriginal; 82cdf0e10cSrcweir SEQUENCE < NUMBERED_SORTINGINFO > maOptions; 83cdf0e10cSrcweir REFERENCE < XANYCOMPAREFACTORY > mxCompFac; 84cdf0e10cSrcweir REFERENCE < XMULTISERVICEFACTORY > mxSMgr; 85cdf0e10cSrcweir 86cdf0e10cSrcweir SortedResultSet* mpOne; 87cdf0e10cSrcweir SortedResultSet* mpTwo; 88cdf0e10cSrcweir SortedDynamicResultSetListener* mpOwnListener; 89cdf0e10cSrcweir 90cdf0e10cSrcweir EventList maActions; 91cdf0e10cSrcweir osl::Mutex maMutex; 92cdf0e10cSrcweir sal_Bool mbGotWelcome :1; 93cdf0e10cSrcweir sal_Bool mbUseOne :1; 94cdf0e10cSrcweir sal_Bool mbStatic :1; 95cdf0e10cSrcweir 96cdf0e10cSrcweir private: 97cdf0e10cSrcweir 98cdf0e10cSrcweir void SendNotify(); 99cdf0e10cSrcweir 100cdf0e10cSrcweir public: 101cdf0e10cSrcweir SortedDynamicResultSet( const REFERENCE < XDYNAMICRESULTSET > &xOriginal, 102cdf0e10cSrcweir const SEQUENCE < NUMBERED_SORTINGINFO > &aOptions, 103cdf0e10cSrcweir const REFERENCE < XANYCOMPAREFACTORY > &xCompFac, 104cdf0e10cSrcweir const REFERENCE < XMULTISERVICEFACTORY > &xSMgr ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir ~SortedDynamicResultSet(); 107cdf0e10cSrcweir 108cdf0e10cSrcweir //----------------------------------------------------------------- 109cdf0e10cSrcweir // XInterface 110cdf0e10cSrcweir //----------------------------------------------------------------- 111cdf0e10cSrcweir XINTERFACE_DECL() 112cdf0e10cSrcweir 113cdf0e10cSrcweir //----------------------------------------------------------------- 114cdf0e10cSrcweir // XTypeProvider 115cdf0e10cSrcweir //----------------------------------------------------------------- 116cdf0e10cSrcweir XTYPEPROVIDER_DECL() 117cdf0e10cSrcweir 118cdf0e10cSrcweir //----------------------------------------------------------------- 119cdf0e10cSrcweir // XServiceInfo 120cdf0e10cSrcweir //----------------------------------------------------------------- 121cdf0e10cSrcweir XSERVICEINFO_NOFACTORY_DECL() 122cdf0e10cSrcweir 123cdf0e10cSrcweir //----------------------------------------------------------------- 124cdf0e10cSrcweir // XComponent 125cdf0e10cSrcweir //----------------------------------------------------------------- 126cdf0e10cSrcweir virtual void SAL_CALL 127cdf0e10cSrcweir dispose() throw( RUNTIME_EXCEPTION ); 128cdf0e10cSrcweir 129cdf0e10cSrcweir virtual void SAL_CALL 130cdf0e10cSrcweir addEventListener( const REFERENCE< XEVENTLISTENER >& Listener ) 131cdf0e10cSrcweir throw( RUNTIME_EXCEPTION ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir virtual void SAL_CALL 134cdf0e10cSrcweir removeEventListener( const REFERENCE< XEVENTLISTENER >& Listener ) 135cdf0e10cSrcweir throw( RUNTIME_EXCEPTION ); 136cdf0e10cSrcweir 137cdf0e10cSrcweir //----------------------------------------------------------------- 138cdf0e10cSrcweir // XDynamicResultSet 139cdf0e10cSrcweir //----------------------------------------------------------------- 140cdf0e10cSrcweir virtual REFERENCE< XRESULTSET > SAL_CALL 141cdf0e10cSrcweir getStaticResultSet( ) 142cdf0e10cSrcweir throw( LISTENERALREADYSETEXCEPTION, RUNTIMEEXCEPTION ); 143cdf0e10cSrcweir 144cdf0e10cSrcweir virtual void SAL_CALL 145cdf0e10cSrcweir setListener( const REFERENCE< XDYNAMICRESULTSETLISTENER >& Listener ) 146cdf0e10cSrcweir throw( LISTENERALREADYSETEXCEPTION, RUNTIMEEXCEPTION ); 147cdf0e10cSrcweir 148cdf0e10cSrcweir virtual void SAL_CALL 149cdf0e10cSrcweir connectToCache( const REFERENCE< XDYNAMICRESULTSET > & xCache ) 150cdf0e10cSrcweir throw( LISTENERALREADYSETEXCEPTION, 151cdf0e10cSrcweir com::sun::star::ucb::AlreadyInitializedException, 152cdf0e10cSrcweir com::sun::star::ucb::ServiceNotFoundException, 153cdf0e10cSrcweir RUNTIMEEXCEPTION ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir virtual sal_Int16 SAL_CALL 156cdf0e10cSrcweir getCapabilities() 157cdf0e10cSrcweir throw( RUNTIMEEXCEPTION ); 158cdf0e10cSrcweir 159cdf0e10cSrcweir //----------------------------------------------------------------- 160cdf0e10cSrcweir // own methods: 161cdf0e10cSrcweir //----------------------------------------------------------------- 162cdf0e10cSrcweir virtual void SAL_CALL 163cdf0e10cSrcweir impl_disposing( const EVENTOBJECT& Source ) 164cdf0e10cSrcweir throw( RUNTIMEEXCEPTION ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir virtual void SAL_CALL 167cdf0e10cSrcweir impl_notify( const ::com::sun::star::ucb::ListEvent& Changes ) 168cdf0e10cSrcweir throw( RUNTIMEEXCEPTION ); 169cdf0e10cSrcweir }; 170cdf0e10cSrcweir 171cdf0e10cSrcweir //----------------------------------------------------------------------------- 172cdf0e10cSrcweir 173cdf0e10cSrcweir class SortedDynamicResultSetListener: 174cdf0e10cSrcweir public cppu::OWeakObject, 175cdf0e10cSrcweir public com::sun::star::ucb::XDynamicResultSetListener 176cdf0e10cSrcweir { 177cdf0e10cSrcweir SortedDynamicResultSet *mpOwner; 178cdf0e10cSrcweir osl::Mutex maMutex; 179cdf0e10cSrcweir 180cdf0e10cSrcweir public: 181cdf0e10cSrcweir SortedDynamicResultSetListener( SortedDynamicResultSet *mOwner ); 182cdf0e10cSrcweir ~SortedDynamicResultSetListener(); 183cdf0e10cSrcweir 184cdf0e10cSrcweir //----------------------------------------------------------------- 185cdf0e10cSrcweir // XInterface 186cdf0e10cSrcweir //----------------------------------------------------------------- 187cdf0e10cSrcweir XINTERFACE_DECL() 188cdf0e10cSrcweir 189cdf0e10cSrcweir //----------------------------------------------------------------- 190cdf0e10cSrcweir // XEventListener ( base of XDynamicResultSetListener ) 191cdf0e10cSrcweir //----------------------------------------------------------------- 192cdf0e10cSrcweir virtual void SAL_CALL 193cdf0e10cSrcweir disposing( const EVENTOBJECT& Source ) 194cdf0e10cSrcweir throw( RUNTIMEEXCEPTION ); 195cdf0e10cSrcweir 196cdf0e10cSrcweir //----------------------------------------------------------------- 197cdf0e10cSrcweir // XDynamicResultSetListener 198cdf0e10cSrcweir //----------------------------------------------------------------- 199cdf0e10cSrcweir virtual void SAL_CALL 200cdf0e10cSrcweir notify( const ::com::sun::star::ucb::ListEvent& Changes ) 201cdf0e10cSrcweir throw( RUNTIMEEXCEPTION ); 202cdf0e10cSrcweir 203cdf0e10cSrcweir //----------------------------------------------------------------- 204cdf0e10cSrcweir // own methods: 205cdf0e10cSrcweir //----------------------------------------------------------------- 206cdf0e10cSrcweir void SAL_CALL impl_OwnerDies(); 207cdf0e10cSrcweir }; 208cdf0e10cSrcweir 209cdf0e10cSrcweir //----------------------------------------------------------------------------- 210cdf0e10cSrcweir 211cdf0e10cSrcweir class SortedDynamicResultSetFactory: 212cdf0e10cSrcweir public cppu::OWeakObject, 213cdf0e10cSrcweir public com::sun::star::lang::XTypeProvider, 214cdf0e10cSrcweir public com::sun::star::lang::XServiceInfo, 215cdf0e10cSrcweir public com::sun::star::ucb::XSortedDynamicResultSetFactory 216cdf0e10cSrcweir { 217cdf0e10cSrcweir 218cdf0e10cSrcweir REFERENCE< XMULTISERVICEFACTORY > mxSMgr; 219cdf0e10cSrcweir 220cdf0e10cSrcweir public: 221cdf0e10cSrcweir 222cdf0e10cSrcweir SortedDynamicResultSetFactory( 223cdf0e10cSrcweir const REFERENCE< XMULTISERVICEFACTORY > & rSMgr); 224cdf0e10cSrcweir 225cdf0e10cSrcweir ~SortedDynamicResultSetFactory(); 226cdf0e10cSrcweir 227cdf0e10cSrcweir //----------------------------------------------------------------- 228cdf0e10cSrcweir // XInterface 229cdf0e10cSrcweir //----------------------------------------------------------------- 230cdf0e10cSrcweir XINTERFACE_DECL() 231cdf0e10cSrcweir 232cdf0e10cSrcweir //----------------------------------------------------------------- 233cdf0e10cSrcweir // XTypeProvider 234cdf0e10cSrcweir //----------------------------------------------------------------- 235cdf0e10cSrcweir XTYPEPROVIDER_DECL() 236cdf0e10cSrcweir 237cdf0e10cSrcweir //----------------------------------------------------------------- 238cdf0e10cSrcweir // XServiceInfo 239cdf0e10cSrcweir //----------------------------------------------------------------- 240cdf0e10cSrcweir XSERVICEINFO_DECL() 241cdf0e10cSrcweir 242cdf0e10cSrcweir //----------------------------------------------------------------- 243cdf0e10cSrcweir // XSortedDynamicResultSetFactory 244cdf0e10cSrcweir 245cdf0e10cSrcweir virtual REFERENCE< XDYNAMICRESULTSET > SAL_CALL 246cdf0e10cSrcweir createSortedDynamicResultSet( 247cdf0e10cSrcweir const REFERENCE< XDYNAMICRESULTSET > & Source, 248cdf0e10cSrcweir const SEQUENCE< NUMBERED_SORTINGINFO > & Info, 249cdf0e10cSrcweir const REFERENCE< XANYCOMPAREFACTORY > & CompareFactory ) 250cdf0e10cSrcweir throw( RUNTIMEEXCEPTION ); 251cdf0e10cSrcweir }; 252cdf0e10cSrcweir 253cdf0e10cSrcweir #endif 254