Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <cacheddynamicresultset.hxx>
31 : : #include <com/sun/star/sdbc/XResultSet.hpp>
32 : : #include <cachedcontentresultset.hxx>
33 : : #include <osl/diagnose.h>
34 : :
35 : : using namespace com::sun::star::lang;
36 : : using namespace com::sun::star::sdbc;
37 : : using namespace com::sun::star::ucb;
38 : : using namespace com::sun::star::uno;
39 : :
40 : : using ::rtl::OUString;
41 : :
42 : 0 : CachedDynamicResultSet::CachedDynamicResultSet(
43 : : Reference< XDynamicResultSet > xOrigin
44 : : , const Reference< XContentIdentifierMapping > & xContentMapping
45 : : , const Reference< XMultiServiceFactory > & xSMgr )
46 : : : DynamicResultSetWrapper( xOrigin, xSMgr )
47 : 0 : , m_xContentIdentifierMapping( xContentMapping )
48 : : {
49 : 0 : impl_init();
50 : 0 : }
51 : :
52 : 0 : CachedDynamicResultSet::~CachedDynamicResultSet()
53 : : {
54 : 0 : impl_deinit();
55 : 0 : }
56 : :
57 : : //virtual
58 : 0 : void SAL_CALL CachedDynamicResultSet
59 : : ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
60 : : {
61 : 0 : DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
62 : : OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
63 : :
64 : : Reference< XResultSet > xCache(
65 : 0 : new CachedContentResultSet( m_xSMgr, m_xSourceResultOne, m_xContentIdentifierMapping ) );
66 : :
67 : 0 : osl::Guard< osl::Mutex > aGuard( m_aMutex );
68 : 0 : m_xMyResultOne = xCache;
69 : 0 : }
70 : :
71 : : //virtual
72 : 0 : void SAL_CALL CachedDynamicResultSet
73 : : ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
74 : : {
75 : 0 : DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
76 : : OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
77 : :
78 : : Reference< XResultSet > xCache(
79 : 0 : new CachedContentResultSet( m_xSMgr, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
80 : :
81 : 0 : osl::Guard< osl::Mutex > aGuard( m_aMutex );
82 : 0 : m_xMyResultTwo = xCache;
83 : 0 : }
84 : :
85 : : //--------------------------------------------------------------------------
86 : : // XInterface methods.
87 : : //--------------------------------------------------------------------------
88 : 0 : XINTERFACE_COMMON_IMPL( CachedDynamicResultSet )
89 : :
90 : 0 : Any SAL_CALL CachedDynamicResultSet
91 : : ::queryInterface( const Type& rType )
92 : : throw ( RuntimeException )
93 : : {
94 : : //list all interfaces inclusive baseclasses of interfaces
95 : :
96 : 0 : Any aRet = DynamicResultSetWrapper::queryInterface( rType );
97 : 0 : if( aRet.hasValue() )
98 : 0 : return aRet;
99 : :
100 : : aRet = cppu::queryInterface( rType,
101 : : static_cast< XTypeProvider* >( this )
102 : : , static_cast< XServiceInfo* >( this )
103 : 0 : );
104 : 0 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
105 : : }
106 : :
107 : : //--------------------------------------------------------------------------
108 : : // XTypeProvider methods.
109 : : //--------------------------------------------------------------------------
110 : : //list all interfaces exclusive baseclasses
111 : 0 : XTYPEPROVIDER_IMPL_4( CachedDynamicResultSet
112 : : , XTypeProvider
113 : : , XServiceInfo
114 : : , XDynamicResultSet
115 : : , XSourceInitialization
116 : : );
117 : :
118 : : //--------------------------------------------------------------------------
119 : : // XServiceInfo methods.
120 : : //--------------------------------------------------------------------------
121 : :
122 : 0 : XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSet,
123 : : OUString( "com.sun.star.comp.ucb.CachedDynamicResultSet" ),
124 : : OUString( CACHED_DRS_SERVICE_NAME ) );
125 : :
126 : : //--------------------------------------------------------------------------
127 : : // own methds. ( inherited )
128 : : //--------------------------------------------------------------------------
129 : : //virtual
130 : 0 : void SAL_CALL CachedDynamicResultSet
131 : : ::impl_disposing( const EventObject& Source )
132 : : throw( RuntimeException )
133 : : {
134 : 0 : DynamicResultSetWrapper::impl_disposing( Source );
135 : 0 : m_xContentIdentifierMapping.clear();
136 : 0 : }
137 : :
138 : : //--------------------------------------------------------------------------
139 : : //--------------------------------------------------------------------------
140 : : // class CachedDynamicResultSetFactory
141 : : //--------------------------------------------------------------------------
142 : : //--------------------------------------------------------------------------
143 : :
144 : 0 : CachedDynamicResultSetFactory::CachedDynamicResultSetFactory(
145 : 0 : const Reference< XMultiServiceFactory > & rSMgr )
146 : : {
147 : 0 : m_xSMgr = rSMgr;
148 : 0 : }
149 : :
150 : 0 : CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory()
151 : : {
152 : 0 : }
153 : :
154 : : //--------------------------------------------------------------------------
155 : : // CachedDynamicResultSetFactory XInterface methods.
156 : : //--------------------------------------------------------------------------
157 : :
158 : 0 : XINTERFACE_IMPL_3( CachedDynamicResultSetFactory,
159 : : XTypeProvider,
160 : : XServiceInfo,
161 : : XCachedDynamicResultSetFactory );
162 : :
163 : : //--------------------------------------------------------------------------
164 : : // CachedDynamicResultSetFactory XTypeProvider methods.
165 : : //--------------------------------------------------------------------------
166 : :
167 : 0 : XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetFactory,
168 : : XTypeProvider,
169 : : XServiceInfo,
170 : : XCachedDynamicResultSetFactory );
171 : :
172 : : //--------------------------------------------------------------------------
173 : : // CachedDynamicResultSetFactory XServiceInfo methods.
174 : : //--------------------------------------------------------------------------
175 : :
176 : 0 : XSERVICEINFO_IMPL_1( CachedDynamicResultSetFactory,
177 : : OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetFactory" ),
178 : 0 : OUString( CACHED_DRS_FACTORY_NAME ) );
179 : :
180 : : //--------------------------------------------------------------------------
181 : : // Service factory implementation.
182 : : //--------------------------------------------------------------------------
183 : :
184 : 0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetFactory );
185 : :
186 : : //--------------------------------------------------------------------------
187 : : // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
188 : : //--------------------------------------------------------------------------
189 : :
190 : : //virtual
191 : 0 : Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
192 : : ::createCachedDynamicResultSet(
193 : : const Reference< XDynamicResultSet > & SourceStub
194 : : , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
195 : : throw( RuntimeException )
196 : : {
197 : 0 : Reference< XDynamicResultSet > xRet;
198 : 0 : xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xSMgr );
199 : 0 : return xRet;
200 : : }
201 : :
202 : :
203 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|