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 #ifndef INCLUDED_UCB_SOURCE_CACHER_CACHEDCONTENTRESULTSETSTUB_HXX 21 #define INCLUDED_UCB_SOURCE_CACHER_CACHEDCONTENTRESULTSETSTUB_HXX 22 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> 32 33 #define CACHED_CRS_STUB_SERVICE_NAME "com.sun.star.ucb.CachedContentResultSetStub" 34 #define CACHED_CRS_STUB_FACTORY_NAME "com.sun.star.ucb.CachedContentResultSetStubFactory" 35 36 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 43 { 44 private: 45 sal_Int32 m_nColumnCount; 46 bool m_bColumnCountCached; 47 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; 55 56 /// @throws css::sdbc::SQLException 57 /// @throws css::uno::RuntimeException 58 void 59 impl_getCurrentRowContent( 60 css::uno::Any& rRowContent, 61 const css::uno::Reference< css::sdbc::XRow >& xRow ); 62 63 sal_Int32 64 impl_getColumnCount(); 65 66 /// @throws css::uno::RuntimeException 67 static void 68 impl_getCurrentContentIdentifierString( 69 css::uno::Any& rAny 70 , const css::uno::Reference< css::ucb::XContentAccess >& xContentAccess ); 71 72 /// @throws css::uno::RuntimeException 73 static void 74 impl_getCurrentContentIdentifier( 75 css::uno::Any& rAny 76 , const css::uno::Reference< css::ucb::XContentAccess >& xContentAccess ); 77 78 /// @throws css::uno::RuntimeException 79 static void 80 impl_getCurrentContent( 81 css::uno::Any& rAny 82 , const css::uno::Reference< css::ucb::XContentAccess >& xContentAccess ); 83 84 /// @throws css::uno::RuntimeException 85 void 86 impl_propagateFetchSizeAndDirection( sal_Int32 nFetchSize, bool bFetchDirection ); 87 88 css::ucb::FetchResult impl_fetchHelper(sal_Int32 nRowStartPosition, sal_Int32 nRowCount, bool bDirection, 89 std::function<void(css::uno::Any& rRowContent)> impl_loadRow); 90 91 public: 92 CachedContentResultSetStub( css::uno::Reference< css::sdbc::XResultSet > const & xOrigin ); 93 94 virtual ~CachedContentResultSetStub() override; 95 96 97 // XInterface 98 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; 99 virtual void SAL_CALL acquire() 100 throw() override; 101 virtual void SAL_CALL release() 102 throw() override; 103 104 // own inherited 105 106 virtual void 107 impl_propertyChange( const css::beans::PropertyChangeEvent& evt ) override; 108 109 virtual void 110 impl_vetoableChange( const css::beans::PropertyChangeEvent& aEvent ) override; 111 112 // XTypeProvider 113 114 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; 115 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; 116 117 // XServiceInfo 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; 121 122 // XFetchProvider 123 124 125 virtual css::ucb::FetchResult SAL_CALL 126 fetch( sal_Int32 nRowStartPosition 127 , sal_Int32 nRowCount, sal_Bool bDirection ) override; 128 129 130 // XFetchProviderForContentAccess 131 132 virtual css::ucb::FetchResult SAL_CALL 133 fetchContentIdentifierStrings( sal_Int32 nRowStartPosition 134 , sal_Int32 nRowCount, sal_Bool bDirection ) override; 135 136 virtual css::ucb::FetchResult SAL_CALL 137 fetchContentIdentifiers( sal_Int32 nRowStartPosition 138 , sal_Int32 nRowCount, sal_Bool bDirection ) override; 139 140 virtual css::ucb::FetchResult SAL_CALL 141 fetchContents( sal_Int32 nRowStartPosition 142 , sal_Int32 nRowCount, sal_Bool bDirection ) override; 143 }; 144 145 146 class CachedContentResultSetStubFactory final : 147 public cppu::WeakImplHelper< 148 css::lang::XServiceInfo, 149 css::ucb::XCachedContentResultSetStubFactory> 150 { 151 public: 152 153 CachedContentResultSetStubFactory(); 154 155 virtual ~CachedContentResultSetStubFactory() override; 156 157 // XServiceInfo 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; 161 162 static OUString getImplementationName_Static(); 163 static css::uno::Sequence< OUString > getSupportedServiceNames_Static(); 164 165 static css::uno::Reference< css::lang::XSingleServiceFactory > 166 createServiceFactory( const css::uno::Reference< 167 css::lang::XMultiServiceFactory >& rxServiceMgr ); 168 169 // XCachedContentResultSetStubFactory 170 171 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL 172 createCachedContentResultSetStub( 173 const css::uno::Reference< css::sdbc::XResultSet > & xSource ) override; 174 }; 175 176 #endif 177 178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 179