22#include <com/sun/star/sdbc/FetchDirection.hpp>
23#include <com/sun/star/sdbc/SQLException.hpp>
24#include <com/sun/star/ucb/FetchError.hpp>
25#include <osl/diagnose.h>
41 , m_bColumnCountCached( false )
42 , m_bNeedToPropagateFetchSize( true )
43 , m_bFirstFetchSizePropagationDone( false )
44 , m_nLastFetchSize( 1 )
45 , m_bLastFetchDirection( true )
46 , m_aPropertyNameForFetchSize( OUString(
"FetchSize") )
47 , m_aPropertyNameForFetchDirection( OUString(
"FetchDirection") )
62 OWeakObject::acquire();
68 OWeakObject::release();
81 ,
static_cast< XTypeProvider*
>(
this )
82 ,
static_cast< XServiceInfo*
>(
this )
83 ,
static_cast< XFetchProvider*
>(
this )
84 ,
static_cast< XFetchProviderForContentAccess*
>(
this )
87 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
107 PropertyChangeEvent aEvt( rEvt );
109 aEvt.Further =
false;
128 PropertyChangeEvent aEvt( rEvt );
130 aEvt.Further =
false;
167 return "com.sun.star.comp.ucb.CachedContentResultSetStub";
177 return {
"com.sun.star.ucb.CachedContentResultSetStub" };
186 std::unique_lock<std::mutex>& rGuard,
187 sal_Int32 nRowStartPosition, sal_Int32 nRowCount,
bool bDirection,
188 std::function<
void( std::unique_lock<std::mutex>&, css::uno::Any& rRowContent)> impl_loadRow)
193 OSL_FAIL(
"broadcaster was disposed already" );
198 aRet.StartIndex = nRowStartPosition;
199 aRet.Orientation = bDirection;
200 aRet.FetchError = FetchError::SUCCESS;
204 if( nOldOriginal_Pos != nRowStartPosition )
207 aRet.FetchError = FetchError::EXCEPTION;
211 aRet.FetchError = FetchError::EXCEPTION;
213 aRet.Rows.realloc( 1 );
217 impl_loadRow( rGuard, aRet.Rows.getArray()[0] );
219 catch( SQLException& )
221 aRet.Rows.realloc( 0 );
222 aRet.FetchError = FetchError::EXCEPTION;
227 aRet.Rows.realloc( nRowCount );
228 auto pRows = aRet.Rows.getArray();
229 bool bOldOriginal_AfterLast =
false;
230 if( !nOldOriginal_Pos )
235 bool bValidNewPos =
false;
241 catch( SQLException& )
243 aRet.Rows.realloc( 0 );
244 aRet.FetchError = FetchError::EXCEPTION;
249 aRet.Rows.realloc( 0 );
250 aRet.FetchError = FetchError::EXCEPTION;
253 if( nOldOriginal_Pos )
255 else if( bOldOriginal_AfterLast )
262 for( ; nN <= nRowCount; )
264 impl_loadRow( rGuard, pRows[nN-1] );
266 if( nN <= nRowCount )
272 aRet.Rows.realloc( nN-1 );
273 aRet.FetchError = FetchError::ENDOFDATA;
281 aRet.Rows.realloc( nN-1 );
282 aRet.FetchError = FetchError::ENDOFDATA;
289 catch( SQLException& )
291 aRet.Rows.realloc( nN-1 );
292 aRet.FetchError = FetchError::EXCEPTION;
295 if( nOldOriginal_Pos )
297 else if( bOldOriginal_AfterLast )
305 ::fetch( sal_Int32 nRowStartPosition
306 , sal_Int32 nRowCount,
sal_Bool bDirection )
311 [&](std::unique_lock<std::mutex>& rGuard, css::uno::Any& rRowContent)
328 nCount = xMetaData->getColumnCount();
330 catch( SQLException& )
332 OSL_FAIL(
"couldn't determine the column count" );
348 auto aContentRange = asNonConstRange(aContent);
349 for( sal_Int32 nN = 1; nN <=
nCount; nN++ )
351 aContentRange[nN-1] = xRow->getObject( nN,
nullptr );
354 rRowContent <<= aContent;
373 bool bFirstPropagationDone;
381 if( nLastSize == nFetchSize
382 && bLastDirection == bFetchDirection
383 && bFirstPropagationDone )
386 if(!bFirstPropagationDone)
394 if(!bHasSize || !bHasDirection)
401 bool bSetSize = ( nLastSize !=nFetchSize ) || !bFirstPropagationDone;
402 bool bSetDirection = ( bLastDirection !=bFetchDirection ) || !bFirstPropagationDone;
411 aValue <<= nFetchSize;
416 catch( css::uno::Exception& ) {}
421 sal_Int32 nFetchDirection = FetchDirection::FORWARD;
422 if( !bFetchDirection )
423 nFetchDirection = FetchDirection::REVERSE;
425 aValue <<= nFetchDirection;
430 catch( css::uno::Exception& ) {}
441 rAny <<= xContentAccess->queryContentIdentifierString();
448 rAny <<= xContentAccess->queryContentIdentifier();
455 rAny <<= xContentAccess->queryContent();
461 , sal_Int32 nRowCount,
sal_Bool bDirection )
463 std::unique_lock aGuard(
m_aMutex );
466 [&](std::unique_lock<std::mutex>& rGuard, css::uno::Any& rRowContent)
473 , sal_Int32 nRowCount,
sal_Bool bDirection )
475 std::unique_lock aGuard(
m_aMutex );
478 [&](std::unique_lock<std::mutex>& rGuard, css::uno::Any& rRowContent)
485 , sal_Int32 nRowCount,
sal_Bool bDirection )
487 std::unique_lock aGuard(
m_aMutex );
490 [&](std::unique_lock<std::mutex>& rGuard, css::uno::Any& rRowContent)
510 return "com.sun.star.comp.ucb.CachedContentResultSetStubFactory";
518 return {
"com.sun.star.ucb.CachedContentResultSetStubFactory" };
524extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
526 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any>
const&)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_CachedContentResultSetStubFactory_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
virtual OUString SAL_CALL getImplementationName() override
virtual ~CachedContentResultSetStubFactory() override
CachedContentResultSetStubFactory()
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL createCachedContentResultSetStub(const css::uno::Reference< css::sdbc::XResultSet > &xSource) override
sal_Int32 m_nLastFetchSize
virtual void SAL_CALL acquire() noexcept override
bool m_bLastFetchDirection
virtual void impl_propertyChange(const css::beans::PropertyChangeEvent &evt) override
bool m_bColumnCountCached
virtual css::ucb::FetchResult SAL_CALL fetchContentIdentifierStrings(sal_Int32 nRowStartPosition, sal_Int32 nRowCount, sal_Bool bDirection) override
static void impl_getCurrentContentIdentifier(std::unique_lock< std::mutex > &rGuard, css::uno::Any &rAny, const css::uno::Reference< css::ucb::XContentAccess > &xContentAccess)
virtual void impl_vetoableChange(const css::beans::PropertyChangeEvent &aEvent) override
css::ucb::FetchResult impl_fetchHelper(std::unique_lock< std::mutex > &rGuard, sal_Int32 nRowStartPosition, sal_Int32 nRowCount, bool bDirection, std::function< void(std::unique_lock< std::mutex > &, css::uno::Any &rRowContent)> impl_loadRow)
static void impl_getCurrentContent(std::unique_lock< std::mutex > &rGuard, css::uno::Any &rAny, const css::uno::Reference< css::ucb::XContentAccess > &xContentAccess)
static void impl_getCurrentContentIdentifierString(std::unique_lock< std::mutex > &rGuard, css::uno::Any &rAny, const css::uno::Reference< css::ucb::XContentAccess > &xContentAccess)
virtual css::ucb::FetchResult SAL_CALL fetch(sal_Int32 nRowStartPosition, sal_Int32 nRowCount, sal_Bool bDirection) override
void impl_getCurrentRowContent(std::unique_lock< std::mutex > &rGuard, css::uno::Any &rRowContent, const css::uno::Reference< css::sdbc::XRow > &xRow)
virtual void SAL_CALL release() noexcept override
virtual ~CachedContentResultSetStub() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::ucb::FetchResult SAL_CALL fetchContents(sal_Int32 nRowStartPosition, sal_Int32 nRowCount, sal_Bool bDirection) override
const OUString m_aPropertyNameForFetchSize
void impl_propagateFetchSizeAndDirection(std::unique_lock< std::mutex > &rGuard, sal_Int32 nFetchSize, bool bFetchDirection)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::ucb::FetchResult SAL_CALL fetchContentIdentifiers(sal_Int32 nRowStartPosition, sal_Int32 nRowCount, sal_Bool bDirection) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
const OUString m_aPropertyNameForFetchDirection
sal_Int32 impl_getColumnCount(std::unique_lock< std::mutex > &)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
CachedContentResultSetStub(css::uno::Reference< css::sdbc::XResultSet > const &xOrigin)
bool m_bNeedToPropagateFetchSize
bool m_bFirstFetchSizePropagationDone
css::uno::Reference< css::sdbc::XResultSet > m_xResultSetOrigin
void impl_notifyVetoableChangeListeners(std::unique_lock< std::mutex > &rGuard, const css::beans::PropertyChangeEvent &rEvt)
void impl_EnsureNotDisposed(std::unique_lock< std::mutex > &rGuard)
virtual void setPropertyValueImpl(std::unique_lock< std::mutex > &rGuard, const OUString &aPropertyName, const css::uno::Any &aValue)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
css::uno::Reference< css::sdbc::XRow > m_xRowOrigin
bool impl_isForwardOnly(std::unique_lock< std::mutex > &rGuard)
void impl_init_xRowOrigin(std::unique_lock< std::mutex > &)
void impl_notifyPropertyChangeListeners(std::unique_lock< std::mutex > &rGuard, const css::beans::PropertyChangeEvent &rEvt)
void impl_init_xContentAccessOrigin(std::unique_lock< std::mutex > &)
css::uno::Reference< css::ucb::XContentAccess > m_xContentAccessOrigin
! call impl_init_xRowOrigin() bevor you access this member
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override final
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
class SAL_NO_VTABLE XPropertySet
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)
XTYPEPROVIDER_COMMON_IMPL(UcbContentProviderProxy)