LibreOffice Module ucb (master) 1
cacheddynamicresultsetstub.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
23#include <com/sun/star/ucb/ContentResultSetCapability.hpp>
24#include <com/sun/star/ucb/SortedDynamicResultSetFactory.hpp>
25#include <osl/diagnose.h>
26#include <ucbhelper/macros.hxx>
28
29using namespace com::sun::star::lang;
30using namespace com::sun::star::sdbc;
31using namespace com::sun::star::ucb;
32using namespace com::sun::star::uno;
33
34
36 Reference< XDynamicResultSet > const & xOrigin
37 , const Reference< XComponentContext > & rxContext )
38 : DynamicResultSetWrapper( xOrigin, rxContext )
39{
40 OSL_ENSURE( m_xContext.is(), "need Multiservicefactory to create stub" );
41 impl_init();
42}
43
45{
47}
48
49//virtual
52{
54 OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
55
58
59 osl::Guard< osl::Mutex > aGuard( m_aMutex );
60 m_xMyResultOne = xStub;
61}
62
63//virtual
66{
68 OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
69
72
73 osl::Guard< osl::Mutex > aGuard( m_aMutex );
74 m_xMyResultTwo = xStub;
75}
76
77
78// XInterface methods.
80 noexcept
81{
82 OWeakObject::acquire();
83}
84
86 noexcept
87{
88 OWeakObject::release();
89}
90
92 ::queryInterface( const Type& rType )
93{
94 //list all interfaces inclusive baseclasses of interfaces
95
97 if( aRet.hasValue() )
98 return aRet;
99
100 aRet = cppu::queryInterface( rType,
101 static_cast< XTypeProvider* >( this )
102 , static_cast< XServiceInfo* >( this )
103 );
104 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
105}
106
107
108// XTypeProvider methods.
109
110//list all interfaces exclusive baseclasses
112 , XTypeProvider
113 , XServiceInfo
114 , XDynamicResultSet
115 , XDynamicResultSetListener
116 , XSourceInitialization
117 );
118
119
120// XServiceInfo methods.
121
123{
124 return "com.sun.star.comp.ucb.CachedDynamicResultSetStub";
125}
126
127sal_Bool SAL_CALL CachedDynamicResultSetStub::supportsService( const OUString& ServiceName )
128{
129 return cppu::supportsService( this, ServiceName );
130}
131
132css::uno::Sequence< OUString > SAL_CALL CachedDynamicResultSetStub::getSupportedServiceNames()
133{
134 return { "com.sun.star.ucb.CachedDynamicResultSetStub" };
135}
136
137
138
139
140
142 const Reference< XComponentContext > & rxContext )
143{
144 m_xContext = rxContext;
145}
146
148{
149}
150
151// CachedDynamicResultSetStubFactory XServiceInfo methods.
152
154{
155 return "com.sun.star.comp.ucb.CachedDynamicResultSetStubFactory";
156}
158{
159 return cppu::supportsService( this, ServiceName );
160}
161css::uno::Sequence< OUString > SAL_CALL CachedDynamicResultSetStubFactory::getSupportedServiceNames()
162{
163 return { "com.sun.star.ucb.CachedDynamicResultSetStubFactory" };
164}
165
166// Service factory implementation.
167
168
169
170extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
172 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
173{
174 return cppu::acquire(new CachedDynamicResultSetStubFactory(context));
175}
176
177
178// CachedDynamicResultSetStubFactory XCachedDynamicResultSetStubFactory methods.
179
180
181//virtual
184 const Reference< XDynamicResultSet > & Source )
185{
187 return xRet;
188}
189
190//virtual
193 const Reference< XDynamicResultSet > & Source
194 , const Reference< XDynamicResultSet > & TargetCache
195 , const Sequence< NumberedSortingInfo > & SortingInfo
196 , const Reference< XAnyCompareFactory > & CompareFactory
197 )
198{
199 OSL_ENSURE( Source.is(), "a Source is needed" );
200 OSL_ENSURE( TargetCache.is(), "a TargetCache is needed" );
201
203 if( SortingInfo.hasElements() &&
204 !( xSource->getCapabilities() & ContentResultSetCapability::SORTED )
205 )
206 {
208 try
209 {
210 xSortFactory = SortedDynamicResultSetFactory::create( m_xContext );
211 }
212 catch ( Exception const & )
213 {
214 }
215
216 if( xSortFactory.is() )
217 {
219 xSortFactory->createSortedDynamicResultSet(
220 Source, SortingInfo, CompareFactory ) );
221 if( xSorted.is() )
222 xSource = xSorted;
223 }
224 }
225
227 new CachedDynamicResultSetStub( xSource, m_xContext ) );
228
229 Reference< XSourceInitialization > xTarget( TargetCache, UNO_QUERY );
230 OSL_ENSURE( xTarget.is(), "Target must have interface XSourceInitialization" );
231
232 xTarget->setSource( xStub );
233}
234
235/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XTYPEPROVIDER_IMPL_5(CachedDynamicResultSetStub, XTypeProvider, XServiceInfo, XDynamicResultSet, XDynamicResultSetListener, XSourceInitialization)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_CachedDynamicResultSetStubFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void SAL_CALL connectToCache(const css::uno::Reference< css::ucb::XDynamicResultSet > &Source, const css::uno::Reference< css::ucb::XDynamicResultSet > &TargetCache, const css::uno::Sequence< css::ucb::NumberedSortingInfo > &SortingInfo, const css::uno::Reference< css::ucb::XAnyCompareFactory > &CompareFactory) override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
CachedDynamicResultSetStubFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::ucb::XDynamicResultSet > SAL_CALL createCachedDynamicResultSetStub(const css::uno::Reference< css::ucb::XDynamicResultSet > &Source) override
virtual void impl_InitResultSetTwo(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL release() noexcept override
virtual void impl_InitResultSetOne(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL acquire() noexcept override
virtual OUString SAL_CALL getImplementationName() override
CachedDynamicResultSetStub(css::uno::Reference< css::ucb::XDynamicResultSet > const &xOrigin, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void impl_InitResultSetTwo(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
css::uno::Reference< css::sdbc::XResultSet > m_xMyResultOne
css::uno::Reference< css::sdbc::XResultSet > m_xSourceResultTwo
css::uno::Reference< css::sdbc::XResultSet > m_xSourceResultOne
css::uno::Reference< css::sdbc::XResultSet > m_xMyResultTwo
virtual void impl_InitResultSetOne(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)
Reference< XInterface > xTarget
@ Exception
Type
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool