merge the formfield patch from ooo-build
[ooovba.git] / ucb / source / cacher / cacheddynamicresultset.cxx
blob7415ceb6c30bac1bd87f19802776055ab8cedf32
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: cacheddynamicresultset.cxx,v $
10 * $Revision: 1.7 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
34 #include <cacheddynamicresultset.hxx>
35 #include <com/sun/star/sdbc/XResultSet.hpp>
36 #include <cachedcontentresultset.hxx>
37 #include <osl/diagnose.h>
39 using namespace com::sun::star::lang;
40 using namespace com::sun::star::sdbc;
41 using namespace com::sun::star::ucb;
42 using namespace com::sun::star::uno;
43 using namespace rtl;
45 CachedDynamicResultSet::CachedDynamicResultSet(
46 Reference< XDynamicResultSet > xOrigin
47 , const Reference< XContentIdentifierMapping > & xContentMapping
48 , const Reference< XMultiServiceFactory > & xSMgr )
49 : DynamicResultSetWrapper( xOrigin, xSMgr )
50 , m_xContentIdentifierMapping( xContentMapping )
52 impl_init();
55 CachedDynamicResultSet::~CachedDynamicResultSet()
57 impl_deinit();
60 //virtual
61 void SAL_CALL CachedDynamicResultSet
62 ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
64 DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
65 OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
67 Reference< XResultSet > xCache(
68 new CachedContentResultSet( m_xSMgr, m_xSourceResultOne, m_xContentIdentifierMapping ) );
70 osl::Guard< osl::Mutex > aGuard( m_aMutex );
71 m_xMyResultOne = xCache;
74 //virtual
75 void SAL_CALL CachedDynamicResultSet
76 ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
78 DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
79 OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
81 Reference< XResultSet > xCache(
82 new CachedContentResultSet( m_xSMgr, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
84 osl::Guard< osl::Mutex > aGuard( m_aMutex );
85 m_xMyResultTwo = xCache;
88 //--------------------------------------------------------------------------
89 // XInterface methods.
90 //--------------------------------------------------------------------------
91 XINTERFACE_COMMON_IMPL( CachedDynamicResultSet )
93 Any SAL_CALL CachedDynamicResultSet
94 ::queryInterface( const Type& rType )
95 throw ( RuntimeException )
97 //list all interfaces inclusive baseclasses of interfaces
99 Any aRet = DynamicResultSetWrapper::queryInterface( rType );
100 if( aRet.hasValue() )
101 return aRet;
103 aRet = cppu::queryInterface( rType,
104 static_cast< XTypeProvider* >( this )
105 , static_cast< XServiceInfo* >( this )
107 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
110 //--------------------------------------------------------------------------
111 // XTypeProvider methods.
112 //--------------------------------------------------------------------------
113 //list all interfaces exclusive baseclasses
114 XTYPEPROVIDER_IMPL_4( CachedDynamicResultSet
115 , XTypeProvider
116 , XServiceInfo
117 , XDynamicResultSet
118 , XSourceInitialization
121 //--------------------------------------------------------------------------
122 // XServiceInfo methods.
123 //--------------------------------------------------------------------------
125 XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSet,
126 OUString::createFromAscii(
127 "com.sun.star.comp.ucb.CachedDynamicResultSet" ),
128 OUString::createFromAscii(
129 CACHED_DRS_SERVICE_NAME ) );
131 //--------------------------------------------------------------------------
132 // own methds. ( inherited )
133 //--------------------------------------------------------------------------
134 //virtual
135 void SAL_CALL CachedDynamicResultSet
136 ::impl_disposing( const EventObject& Source )
137 throw( RuntimeException )
139 DynamicResultSetWrapper::impl_disposing( Source );
140 m_xContentIdentifierMapping.clear();
143 //--------------------------------------------------------------------------
144 //--------------------------------------------------------------------------
145 // class CachedDynamicResultSetFactory
146 //--------------------------------------------------------------------------
147 //--------------------------------------------------------------------------
149 CachedDynamicResultSetFactory::CachedDynamicResultSetFactory(
150 const Reference< XMultiServiceFactory > & rSMgr )
152 m_xSMgr = rSMgr;
155 CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory()
159 //--------------------------------------------------------------------------
160 // CachedDynamicResultSetFactory XInterface methods.
161 //--------------------------------------------------------------------------
163 XINTERFACE_IMPL_3( CachedDynamicResultSetFactory,
164 XTypeProvider,
165 XServiceInfo,
166 XCachedDynamicResultSetFactory );
168 //--------------------------------------------------------------------------
169 // CachedDynamicResultSetFactory XTypeProvider methods.
170 //--------------------------------------------------------------------------
172 XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetFactory,
173 XTypeProvider,
174 XServiceInfo,
175 XCachedDynamicResultSetFactory );
177 //--------------------------------------------------------------------------
178 // CachedDynamicResultSetFactory XServiceInfo methods.
179 //--------------------------------------------------------------------------
181 XSERVICEINFO_IMPL_1( CachedDynamicResultSetFactory,
182 OUString::createFromAscii(
183 "com.sun.star.comp.ucb.CachedDynamicResultSetFactory" ),
184 OUString::createFromAscii(
185 CACHED_DRS_FACTORY_NAME ) );
187 //--------------------------------------------------------------------------
188 // Service factory implementation.
189 //--------------------------------------------------------------------------
191 ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetFactory );
193 //--------------------------------------------------------------------------
194 // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
195 //--------------------------------------------------------------------------
197 //virtual
198 Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
199 ::createCachedDynamicResultSet(
200 const Reference< XDynamicResultSet > & SourceStub
201 , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
202 throw( RuntimeException )
204 Reference< XDynamicResultSet > xRet;
205 xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xSMgr );
206 return xRet;