LibreOffice Module ucb (master)  1
cacheddynamicresultset.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 <osl/diagnose.h>
26 #include <ucbhelper/macros.hxx>
27 
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;
32 
33 
35  Reference< XDynamicResultSet > const & xOrigin
36  , const Reference< XContentIdentifierMapping > & xContentMapping
37  , const Reference< XComponentContext > & xContext )
38  : DynamicResultSetWrapper( xOrigin, xContext )
39  , m_xContentIdentifierMapping( xContentMapping )
40 {
41  impl_init();
42 }
43 
45 {
46  impl_deinit();
47 }
48 
49 //virtual
50 void CachedDynamicResultSet
51  ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
52 {
54  OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
55 
57  new CachedContentResultSet( m_xContext, m_xSourceResultOne, m_xContentIdentifierMapping ) );
58 
59  osl::Guard< osl::Mutex > aGuard( m_aMutex );
60  m_xMyResultOne = xCache;
61 }
62 
63 //virtual
64 void CachedDynamicResultSet
65  ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
66 {
68  OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
69 
71  new CachedContentResultSet( m_xContext, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
72 
73  osl::Guard< osl::Mutex > aGuard( m_aMutex );
74  m_xMyResultTwo = xCache;
75 }
76 
77 
78 // XInterface methods.
80  throw()
81 {
82  OWeakObject::acquire();
83 }
84 
86  throw()
87 {
88  OWeakObject::release();
89 }
90 
91 Any SAL_CALL CachedDynamicResultSet
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  , XSourceInitialization
116  );
117 
118 
119 // XServiceInfo methods.
120 
122 {
123  return "com.sun.star.comp.ucb.CachedDynamicResultSet";
124 }
125 
126 sal_Bool SAL_CALL CachedDynamicResultSet::supportsService( const OUString& ServiceName )
127 {
128  return cppu::supportsService( this, ServiceName );
129 }
130 
131 css::uno::Sequence< OUString > SAL_CALL CachedDynamicResultSet::getSupportedServiceNames()
132 {
133  return { CACHED_DRS_SERVICE_NAME };
134 }
135 
136 
137 // own methods. ( inherited )
138 
139 //virtual
140 void CachedDynamicResultSet
141  ::impl_disposing( const EventObject& Source )
142 {
144  m_xContentIdentifierMapping.clear();
145 }
146 
147 
148 // class CachedDynamicResultSetFactory
149 
150 
152  const Reference< XComponentContext > & xContext )
153 {
154  m_xContext = xContext;
155 }
156 
158 {
159 }
160 
161 
162 // CachedDynamicResultSetFactory XServiceInfo methods.
163 
165  "com.sun.star.comp.ucb.CachedDynamicResultSetFactory" )
167 static css::uno::Reference< css::uno::XInterface >
168 CachedDynamicResultSetFactory_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
169 {
170  css::lang::XServiceInfo* pX = new CachedDynamicResultSetFactory( ucbhelper::getComponentContext(rSMgr) );
171  return css::uno::Reference< css::uno::XInterface >::query( pX );
172 }
173 
174 css::uno::Sequence< OUString >
176 {
177  css::uno::Sequence< OUString > aSNS { CACHED_DRS_FACTORY_NAME };
178  return aSNS;
179 }
180 
181 // Service factory implementation.
182 
183 
185 
186 
187 // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
188 
189 
190 //virtual
191 Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
192  ::createCachedDynamicResultSet(
193  const Reference< XDynamicResultSet > & SourceStub
194  , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
195 {
196  Reference< XDynamicResultSet > xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xContext );
197  return xRet;
198 }
199 
200 
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void impl_InitResultSetTwo(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)
Type
#define CACHED_DRS_SERVICE_NAME
::osl::Mutex m_aMutex
CachedDynamicResultSetFactory(const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL release() override
ONE_INSTANCE_SERVICE_FACTORY_IMPL(CachedDynamicResultSetFactory)
UCBHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > getComponentContext(css::uno::Reference< css::lang::XMultiServiceFactory > const &factory)
virtual void impl_disposing(const css::lang::EventObject &Source)
virtual void SAL_CALL acquire() override
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
CachedDynamicResultSet(css::uno::Reference< css::ucb::XDynamicResultSet > const &xOrigin, const css::uno::Reference< css::ucb::XContentIdentifierMapping > &xContentMapping, const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void impl_InitResultSetOne(const css::uno::Reference< css::sdbc::XResultSet > &xResultSet)
XSERVICEINFO_COMMOM_IMPL(CachedDynamicResultSetFactory,"com.sun.star.comp.ucb.CachedDynamicResultSetFactory") static css
virtual ~CachedDynamicResultSet() override
unsigned char sal_Bool
#define CACHED_DRS_FACTORY_NAME
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~CachedDynamicResultSetFactory() override
XTYPEPROVIDER_IMPL_4(CachedDynamicResultSet, XTypeProvider, XServiceInfo, XDynamicResultSet, XSourceInitialization)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
const uno::Reference< uno::XComponentContext > m_xContext