Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / ucb / source / cacher / cacheddynamicresultset.cxx
blobf513bd79f3b9a1696764036bf8a2ef7d9129ecdd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "cacheddynamicresultset.hxx"
22 #include "cachedcontentresultset.hxx"
23 #include <osl/diagnose.h>
24 #include <cppuhelper/queryinterface.hxx>
25 #include <ucbhelper/getcomponentcontext.hxx>
26 #include <ucbhelper/macros.hxx>
28 using namespace com::sun::star::lang;
29 using namespace com::sun::star::sdbc;
30 using namespace com::sun::star::ucb;
31 using namespace com::sun::star::uno;
34 CachedDynamicResultSet::CachedDynamicResultSet(
35 Reference< XDynamicResultSet > const & xOrigin
36 , const Reference< XContentIdentifierMapping > & xContentMapping
37 , const Reference< XComponentContext > & xContext )
38 : DynamicResultSetWrapper( xOrigin, xContext )
39 , m_xContentIdentifierMapping( xContentMapping )
41 impl_init();
44 CachedDynamicResultSet::~CachedDynamicResultSet()
46 impl_deinit();
49 //virtual
50 void CachedDynamicResultSet
51 ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
53 DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
54 OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
56 Reference< XResultSet > xCache(
57 new CachedContentResultSet( m_xContext, m_xSourceResultOne, m_xContentIdentifierMapping ) );
59 osl::Guard< osl::Mutex > aGuard( m_aMutex );
60 m_xMyResultOne = xCache;
63 //virtual
64 void CachedDynamicResultSet
65 ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
67 DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
68 OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
70 Reference< XResultSet > xCache(
71 new CachedContentResultSet( m_xContext, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
73 osl::Guard< osl::Mutex > aGuard( m_aMutex );
74 m_xMyResultTwo = xCache;
78 // XInterface methods.
79 void SAL_CALL CachedDynamicResultSet::acquire()
80 throw()
82 OWeakObject::acquire();
85 void SAL_CALL CachedDynamicResultSet::release()
86 throw()
88 OWeakObject::release();
91 Any SAL_CALL CachedDynamicResultSet
92 ::queryInterface( const Type& rType )
94 //list all interfaces inclusive baseclasses of interfaces
96 Any aRet = DynamicResultSetWrapper::queryInterface( rType );
97 if( aRet.hasValue() )
98 return aRet;
100 aRet = cppu::queryInterface( rType,
101 static_cast< XTypeProvider* >( this )
102 , static_cast< XServiceInfo* >( this )
104 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
108 // XTypeProvider methods.
110 //list all interfaces exclusive baseclasses
111 XTYPEPROVIDER_IMPL_4( CachedDynamicResultSet
112 , XTypeProvider
113 , XServiceInfo
114 , XDynamicResultSet
115 , XSourceInitialization
119 // XServiceInfo methods.
121 OUString SAL_CALL CachedDynamicResultSet::getImplementationName()
123 return "com.sun.star.comp.ucb.CachedDynamicResultSet";
126 sal_Bool SAL_CALL CachedDynamicResultSet::supportsService( const OUString& ServiceName )
128 return cppu::supportsService( this, ServiceName );
131 css::uno::Sequence< OUString > SAL_CALL CachedDynamicResultSet::getSupportedServiceNames()
133 return { CACHED_DRS_SERVICE_NAME };
137 // own methods. ( inherited )
139 //virtual
140 void CachedDynamicResultSet
141 ::impl_disposing( const EventObject& Source )
143 DynamicResultSetWrapper::impl_disposing( Source );
144 m_xContentIdentifierMapping.clear();
148 // class CachedDynamicResultSetFactory
151 CachedDynamicResultSetFactory::CachedDynamicResultSetFactory(
152 const Reference< XComponentContext > & xContext )
154 m_xContext = xContext;
157 CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory()
162 // CachedDynamicResultSetFactory XServiceInfo methods.
164 XSERVICEINFO_COMMOM_IMPL( CachedDynamicResultSetFactory,
165 "com.sun.star.comp.ucb.CachedDynamicResultSetFactory" )
166 /// @throws css::uno::Exception
167 static css::uno::Reference< css::uno::XInterface >
168 CachedDynamicResultSetFactory_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
170 css::lang::XServiceInfo* pX = new CachedDynamicResultSetFactory( ucbhelper::getComponentContext(rSMgr) );
171 return css::uno::Reference< css::uno::XInterface >::query( pX );
174 css::uno::Sequence< OUString >
175 CachedDynamicResultSetFactory::getSupportedServiceNames_Static()
177 css::uno::Sequence< OUString > aSNS { CACHED_DRS_FACTORY_NAME };
178 return aSNS;
181 // Service factory implementation.
184 ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetFactory );
187 // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
190 //virtual
191 Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
192 ::createCachedDynamicResultSet(
193 const Reference< XDynamicResultSet > & SourceStub
194 , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
196 Reference< XDynamicResultSet > xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xContext );
197 return xRet;
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */