1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef INCLUDED_UCB_SOURCE_CACHER_CACHEDCONTENTRESULTSETSTUB_HXX
21 #define INCLUDED_UCB_SOURCE_CACHER_CACHEDCONTENTRESULTSETSTUB_HXX
23 #include "contentresultsetwrapper.hxx"
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/lang/XTypeProvider.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
28 #include <com/sun/star/ucb/XFetchProvider.hpp>
29 #include <com/sun/star/ucb/XFetchProviderForContentAccess.hpp>
30 #include <com/sun/star/ucb/XCachedContentResultSetStubFactory.hpp>
31 #include <cppuhelper/implbase.hxx>
33 #define CACHED_CRS_STUB_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSetStub"
34 #define CACHED_CRS_STUB_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetStubFactory"
37 class CachedContentResultSetStub
38 : public ContentResultSetWrapper
39 , public css::lang::XTypeProvider
40 , public css::lang::XServiceInfo
41 , public css::ucb::XFetchProvider
42 , public css::ucb::XFetchProviderForContentAccess
45 sal_Int32 m_nColumnCount
;
46 bool m_bColumnCountCached
;
48 //members to propagate fetchsize and direction:
49 bool m_bNeedToPropagateFetchSize
;
50 bool m_bFirstFetchSizePropagationDone
;
51 sal_Int32 m_nLastFetchSize
;
52 bool m_bLastFetchDirection
;
53 const OUString m_aPropertyNameForFetchSize
;
54 const OUString m_aPropertyNameForFetchDirection
;
56 /// @throws css::sdbc::SQLException
57 /// @throws css::uno::RuntimeException
59 impl_getCurrentRowContent(
60 css::uno::Any
& rRowContent
,
61 const css::uno::Reference
< css::sdbc::XRow
>& xRow
);
64 impl_getColumnCount();
66 /// @throws css::uno::RuntimeException
68 impl_getCurrentContentIdentifierString(
70 , const css::uno::Reference
< css::ucb::XContentAccess
>& xContentAccess
);
72 /// @throws css::uno::RuntimeException
74 impl_getCurrentContentIdentifier(
76 , const css::uno::Reference
< css::ucb::XContentAccess
>& xContentAccess
);
78 /// @throws css::uno::RuntimeException
80 impl_getCurrentContent(
82 , const css::uno::Reference
< css::ucb::XContentAccess
>& xContentAccess
);
84 /// @throws css::uno::RuntimeException
86 impl_propagateFetchSizeAndDirection( sal_Int32 nFetchSize
, bool bFetchDirection
);
88 css::ucb::FetchResult
impl_fetchHelper(sal_Int32 nRowStartPosition
, sal_Int32 nRowCount
, bool bDirection
,
89 std::function
<void(css::uno::Any
& rRowContent
)> impl_loadRow
);
92 CachedContentResultSetStub( css::uno::Reference
< css::sdbc::XResultSet
> const & xOrigin
);
94 virtual ~CachedContentResultSetStub() override
;
98 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
99 virtual void SAL_CALL
acquire()
101 virtual void SAL_CALL
release()
107 impl_propertyChange( const css::beans::PropertyChangeEvent
& evt
) override
;
110 impl_vetoableChange( const css::beans::PropertyChangeEvent
& aEvent
) override
;
114 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
115 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
118 virtual OUString SAL_CALL
getImplementationName() override
;
119 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
120 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
125 virtual css::ucb::FetchResult SAL_CALL
126 fetch( sal_Int32 nRowStartPosition
127 , sal_Int32 nRowCount
, sal_Bool bDirection
) override
;
130 // XFetchProviderForContentAccess
132 virtual css::ucb::FetchResult SAL_CALL
133 fetchContentIdentifierStrings( sal_Int32 nRowStartPosition
134 , sal_Int32 nRowCount
, sal_Bool bDirection
) override
;
136 virtual css::ucb::FetchResult SAL_CALL
137 fetchContentIdentifiers( sal_Int32 nRowStartPosition
138 , sal_Int32 nRowCount
, sal_Bool bDirection
) override
;
140 virtual css::ucb::FetchResult SAL_CALL
141 fetchContents( sal_Int32 nRowStartPosition
142 , sal_Int32 nRowCount
, sal_Bool bDirection
) override
;
146 class CachedContentResultSetStubFactory final
:
147 public cppu::WeakImplHelper
<
148 css::lang::XServiceInfo
,
149 css::ucb::XCachedContentResultSetStubFactory
>
153 CachedContentResultSetStubFactory();
155 virtual ~CachedContentResultSetStubFactory() override
;
158 virtual OUString SAL_CALL
getImplementationName() override
;
159 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
160 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
162 static OUString
getImplementationName_Static();
163 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
165 static css::uno::Reference
< css::lang::XSingleServiceFactory
>
166 createServiceFactory( const css::uno::Reference
<
167 css::lang::XMultiServiceFactory
>& rxServiceMgr
);
169 // XCachedContentResultSetStubFactory
171 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
172 createCachedContentResultSetStub(
173 const css::uno::Reference
< css::sdbc::XResultSet
> & xSource
) override
;
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */