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_SORTER_SORTDYNRES_HXX
21 #define INCLUDED_UCB_SOURCE_SORTER_SORTDYNRES_HXX
23 #include <com/sun/star/ucb/NumberedSortingInfo.hpp>
24 #include <com/sun/star/sdbc/XResultSet.hpp>
25 #include <com/sun/star/ucb/XDynamicResultSet.hpp>
26 #include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
27 #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
28 #include <cppuhelper/factory.hxx>
29 #include <cppuhelper/implbase.hxx>
31 #include "sortresult.hxx"
34 namespace comphelper
{
35 class OInterfaceContainerHelper2
;
38 #define DYNAMIC_RESULTSET_SERVICE_NAME "com.sun.star.ucb.SortedDynamicResultSet"
39 #define DYNAMIC_RESULTSET_FACTORY_NAME "com.sun.star.ucb.SortedDynamicResultSetFactory"
41 class SortedDynamicResultSetListener
;
43 class SortedDynamicResultSet
: public cppu::WeakImplHelper
<
44 css::lang::XServiceInfo
,
45 css::ucb::XDynamicResultSet
>
47 std::unique_ptr
<comphelper::OInterfaceContainerHelper2
> mpDisposeEventListeners
;
49 css::uno::Reference
< css::ucb::XDynamicResultSetListener
> mxListener
;
51 css::uno::Reference
< css::ucb::XDynamicResultSet
> mxOriginal
;
52 css::uno::Sequence
< css::ucb::NumberedSortingInfo
> maOptions
;
53 css::uno::Reference
< css::ucb::XAnyCompareFactory
> mxCompFac
;
54 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
56 rtl::Reference
<SortedResultSet
> mxOne
;
57 rtl::Reference
<SortedResultSet
> mxTwo
;
58 rtl::Reference
<SortedDynamicResultSetListener
> mxOwnListener
;
70 SortedDynamicResultSet( const css::uno::Reference
< css::ucb::XDynamicResultSet
> &xOriginal
,
71 const css::uno::Sequence
< css::ucb::NumberedSortingInfo
> &aOptions
,
72 const css::uno::Reference
< css::ucb::XAnyCompareFactory
> &xCompFac
,
73 const css::uno::Reference
< css::uno::XComponentContext
> &rxContext
);
75 virtual ~SortedDynamicResultSet() override
;
80 virtual OUString SAL_CALL
getImplementationName() override
;
81 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
82 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
86 virtual void SAL_CALL
dispose() override
;
89 addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
92 removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& Listener
) override
;
97 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
getStaticResultSet() override
;
100 setListener( const css::uno::Reference
< css::ucb::XDynamicResultSetListener
>& Listener
) override
;
102 virtual void SAL_CALL
103 connectToCache( const css::uno::Reference
< css::ucb::XDynamicResultSet
> & xCache
) override
;
105 virtual sal_Int16 SAL_CALL
106 getCapabilities() override
;
111 /// @throws css::uno::RuntimeException
112 void impl_disposing();
114 /// @throws css::uno::RuntimeException
115 void impl_notify( const css::ucb::ListEvent
& Changes
);
118 class SortedDynamicResultSetListener
: public cppu::WeakImplHelper
<
119 css::ucb::XDynamicResultSetListener
>
121 SortedDynamicResultSet
*mpOwner
;
125 SortedDynamicResultSetListener( SortedDynamicResultSet
*mOwner
);
126 virtual ~SortedDynamicResultSetListener() override
;
128 // XEventListener ( base of XDynamicResultSetListener )
130 virtual void SAL_CALL
131 disposing( const css::lang::EventObject
& Source
) override
;
133 // XDynamicResultSetListener
135 virtual void SAL_CALL
notify( const css::ucb::ListEvent
& Changes
) override
;
139 void impl_OwnerDies();
143 class SortedDynamicResultSetFactory
: public cppu::WeakImplHelper
<
144 css::lang::XServiceInfo
,
145 css::ucb::XSortedDynamicResultSetFactory
>
148 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
151 SortedDynamicResultSetFactory(
152 const css::uno::Reference
< css::uno::XComponentContext
> & rxContext
);
154 virtual ~SortedDynamicResultSetFactory() override
;
159 static css::uno::Reference
< css::lang::XSingleServiceFactory
> createServiceFactory(
160 const css::uno::Reference
< css::lang::XMultiServiceFactory
>& rxServiceMgr
);
162 // XSortedDynamicResultSetFactory
164 virtual OUString SAL_CALL
getImplementationName() override
;
165 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
166 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
167 static OUString
getImplementationName_Static();
168 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static();
170 virtual css::uno::Reference
< css::ucb::XDynamicResultSet
> SAL_CALL
171 createSortedDynamicResultSet(
172 const css::uno::Reference
< css::ucb::XDynamicResultSet
> & Source
,
173 const css::uno::Sequence
< css::ucb::NumberedSortingInfo
> & Info
,
174 const css::uno::Reference
< css::ucb::XAnyCompareFactory
> & CompareFactory
) override
;
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */