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 .
22 #include "contentresultsetwrapper.hxx"
23 #include <com/sun/star/lang/XTypeProvider.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/ucb/XFetchProvider.hpp>
26 #include <com/sun/star/ucb/XFetchProviderForContentAccess.hpp>
27 #include <com/sun/star/ucb/XCachedContentResultSetStubFactory.hpp>
28 #include <cppuhelper/implbase.hxx>
30 class CachedContentResultSetStub
31 : public ContentResultSetWrapper
32 , public css::lang::XTypeProvider
33 , public css::lang::XServiceInfo
34 , public css::ucb::XFetchProvider
35 , public css::ucb::XFetchProviderForContentAccess
38 sal_Int32 m_nColumnCount
;
39 bool m_bColumnCountCached
;
41 //members to propagate fetchsize and direction:
42 bool m_bNeedToPropagateFetchSize
;
43 bool m_bFirstFetchSizePropagationDone
;
44 sal_Int32 m_nLastFetchSize
;
45 bool m_bLastFetchDirection
;
46 const OUString m_aPropertyNameForFetchSize
;
47 const OUString m_aPropertyNameForFetchDirection
;
49 /// @throws css::sdbc::SQLException
50 /// @throws css::uno::RuntimeException
52 impl_getCurrentRowContent(
53 std::unique_lock
<std::mutex
>& rGuard
,
54 css::uno::Any
& rRowContent
,
55 const css::uno::Reference
< css::sdbc::XRow
>& xRow
);
58 impl_getColumnCount(std::unique_lock
<std::mutex
>&);
60 /// @throws css::uno::RuntimeException
62 impl_getCurrentContentIdentifierString(
63 std::unique_lock
<std::mutex
>& rGuard
,
65 , const css::uno::Reference
< css::ucb::XContentAccess
>& xContentAccess
);
67 /// @throws css::uno::RuntimeException
69 impl_getCurrentContentIdentifier(
70 std::unique_lock
<std::mutex
>& rGuard
,
72 , const css::uno::Reference
< css::ucb::XContentAccess
>& xContentAccess
);
74 /// @throws css::uno::RuntimeException
76 impl_getCurrentContent(
77 std::unique_lock
<std::mutex
>& rGuard
,
79 , const css::uno::Reference
< css::ucb::XContentAccess
>& xContentAccess
);
81 /// @throws css::uno::RuntimeException
83 impl_propagateFetchSizeAndDirection( std::unique_lock
<std::mutex
>& rGuard
, sal_Int32 nFetchSize
, bool bFetchDirection
);
85 css::ucb::FetchResult
impl_fetchHelper(
86 std::unique_lock
<std::mutex
>& rGuard
,
87 sal_Int32 nRowStartPosition
, sal_Int32 nRowCount
, bool bDirection
,
88 std::function
<void(std::unique_lock
<std::mutex
>&, css::uno::Any
& rRowContent
)> impl_loadRow
);
91 CachedContentResultSetStub( css::uno::Reference
< css::sdbc::XResultSet
> const & xOrigin
);
93 virtual ~CachedContentResultSetStub() override
;
97 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
98 virtual void SAL_CALL
acquire()
100 virtual void SAL_CALL
release()
106 impl_propertyChange( const css::beans::PropertyChangeEvent
& evt
) override
;
109 impl_vetoableChange( const css::beans::PropertyChangeEvent
& aEvent
) override
;
113 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
114 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
117 virtual OUString SAL_CALL
getImplementationName() override
;
118 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
119 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
124 virtual css::ucb::FetchResult SAL_CALL
125 fetch( sal_Int32 nRowStartPosition
126 , sal_Int32 nRowCount
, sal_Bool bDirection
) override
;
129 // XFetchProviderForContentAccess
131 virtual css::ucb::FetchResult SAL_CALL
132 fetchContentIdentifierStrings( sal_Int32 nRowStartPosition
133 , sal_Int32 nRowCount
, sal_Bool bDirection
) override
;
135 virtual css::ucb::FetchResult SAL_CALL
136 fetchContentIdentifiers( sal_Int32 nRowStartPosition
137 , sal_Int32 nRowCount
, sal_Bool bDirection
) override
;
139 virtual css::ucb::FetchResult SAL_CALL
140 fetchContents( sal_Int32 nRowStartPosition
141 , sal_Int32 nRowCount
, sal_Bool bDirection
) override
;
145 class CachedContentResultSetStubFactory final
:
146 public cppu::WeakImplHelper
<
147 css::lang::XServiceInfo
,
148 css::ucb::XCachedContentResultSetStubFactory
>
152 CachedContentResultSetStubFactory();
154 virtual ~CachedContentResultSetStubFactory() override
;
157 virtual OUString SAL_CALL
getImplementationName() override
;
158 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
159 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
161 // XCachedContentResultSetStubFactory
163 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
164 createCachedContentResultSetStub(
165 const css::uno::Reference
< css::sdbc::XResultSet
> & xSource
) override
;
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */