bump product version to 7.6.3.2-android
[LibreOffice.git] / ucb / source / cacher / cacheddynamicresultset.cxx
blobacb00ef6799f26b820949c29d297fe689884eca0
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/macros.hxx>
27 using namespace com::sun::star::lang;
28 using namespace com::sun::star::sdbc;
29 using namespace com::sun::star::ucb;
30 using namespace com::sun::star::uno;
33 CachedDynamicResultSet::CachedDynamicResultSet(
34 Reference< XDynamicResultSet > const & xOrigin
35 , const Reference< XContentIdentifierMapping > & xContentMapping
36 , const Reference< XComponentContext > & xContext )
37 : DynamicResultSetWrapper( xOrigin, xContext )
38 , m_xContentIdentifierMapping( xContentMapping )
40 impl_init();
43 CachedDynamicResultSet::~CachedDynamicResultSet()
45 impl_deinit();
48 //virtual
49 void CachedDynamicResultSet
50 ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
52 DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
53 OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
55 Reference< XResultSet > xCache(
56 new CachedContentResultSet( m_xContext, m_xSourceResultOne, m_xContentIdentifierMapping ) );
58 std::unique_lock aGuard( m_aMutex );
59 m_xMyResultOne = xCache;
62 //virtual
63 void CachedDynamicResultSet
64 ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
66 DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
67 OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
69 Reference< XResultSet > xCache(
70 new CachedContentResultSet( m_xContext, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
72 std::unique_lock aGuard( m_aMutex );
73 m_xMyResultTwo = xCache;
77 // XInterface methods.
78 void SAL_CALL CachedDynamicResultSet::acquire()
79 noexcept
81 OWeakObject::acquire();
84 void SAL_CALL CachedDynamicResultSet::release()
85 noexcept
87 OWeakObject::release();
90 Any SAL_CALL CachedDynamicResultSet
91 ::queryInterface( const Type& rType )
93 //list all interfaces inclusive baseclasses of interfaces
95 Any aRet = DynamicResultSetWrapper::queryInterface( rType );
96 if( aRet.hasValue() )
97 return aRet;
99 aRet = cppu::queryInterface( rType,
100 static_cast< XTypeProvider* >( this )
101 , static_cast< XServiceInfo* >( this )
103 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
107 // XTypeProvider methods.
109 //list all interfaces exclusive baseclasses
110 XTYPEPROVIDER_IMPL_4( CachedDynamicResultSet
111 , XTypeProvider
112 , XServiceInfo
113 , XDynamicResultSet
114 , XSourceInitialization
118 // XServiceInfo methods.
120 OUString SAL_CALL CachedDynamicResultSet::getImplementationName()
122 return "com.sun.star.comp.ucb.CachedDynamicResultSet";
125 sal_Bool SAL_CALL CachedDynamicResultSet::supportsService( const OUString& ServiceName )
127 return cppu::supportsService( this, ServiceName );
130 css::uno::Sequence< OUString > SAL_CALL CachedDynamicResultSet::getSupportedServiceNames()
132 return { "com.sun.star.ucb.CachedDynamicResultSet" };
136 // own methods. ( inherited )
138 //virtual
139 void CachedDynamicResultSet
140 ::impl_disposing( const EventObject& Source )
142 DynamicResultSetWrapper::impl_disposing( Source );
143 m_xContentIdentifierMapping.clear();
149 CachedDynamicResultSetFactory::CachedDynamicResultSetFactory(
150 const Reference< XComponentContext > & xContext )
152 m_xContext = xContext;
155 CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory()
160 // CachedDynamicResultSetFactory XServiceInfo methods.
162 OUString SAL_CALL CachedDynamicResultSetFactory::getImplementationName()
164 return "com.sun.star.comp.ucb.CachedDynamicResultSetFactory";
166 sal_Bool SAL_CALL CachedDynamicResultSetFactory::supportsService( const OUString& ServiceName )
168 return cppu::supportsService( this, ServiceName );
170 css::uno::Sequence< OUString > SAL_CALL CachedDynamicResultSetFactory::getSupportedServiceNames()
172 return { "com.sun.star.ucb.CachedDynamicResultSetFactory" };
175 // Service factory implementation.
179 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
180 ucb_CachedDynamicResultSetFactory_get_implementation(
181 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
183 return cppu::acquire(new CachedDynamicResultSetFactory(context));
186 // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
189 //virtual
190 Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
191 ::createCachedDynamicResultSet(
192 const Reference< XDynamicResultSet > & SourceStub
193 , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
195 Reference< XDynamicResultSet > xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xContext );
196 return xRet;
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */