Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / ucb / source / sorter / sortdynres.hxx
blob5a1e3770b6b3de5fc2dace0e9bb72fb998469660
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
30 #include <memory>
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;
60 EventList maActions;
61 osl::Mutex maMutex;
62 bool mbGotWelcome:1;
63 bool mbUseOne:1;
64 bool mbStatic:1;
66 private:
67 void SendNotify();
69 public:
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;
78 // XServiceInfo
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;
84 // XComponent
86 virtual void SAL_CALL dispose() override;
88 virtual void SAL_CALL
89 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
91 virtual void SAL_CALL
92 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
95 // XDynamicResultSet
97 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getStaticResultSet() override;
99 virtual void SAL_CALL
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;
109 // own methods:
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;
122 osl::Mutex maMutex;
124 public:
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;
137 // own methods:
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;
150 public:
151 SortedDynamicResultSetFactory(
152 const css::uno::Reference< css::uno::XComponentContext > & rxContext);
154 virtual ~SortedDynamicResultSetFactory() override;
157 // XServiceInfo
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;
177 #endif
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */