LibreOffice Module ucb (master) 1
sortdynres.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
23#include <com/sun/star/sdbc/XResultSet.hpp>
24#include <com/sun/star/ucb/XDynamicResultSet.hpp>
25#include <com/sun/star/ucb/XDynamicResultSetListener.hpp>
26#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
30#include <memory>
31#include "sortresult.hxx"
32
33
34
36
37class SortedDynamicResultSet: public cppu::WeakImplHelper <
38 css::lang::XServiceInfo,
39 css::ucb::XDynamicResultSet >
40{
41 std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::lang::XEventListener>> mpDisposeEventListeners;
42
43 css::uno::Reference < css::ucb::XDynamicResultSetListener > mxListener;
44
45 css::uno::Reference < css::ucb::XDynamicResultSet > mxOriginal;
46 css::uno::Sequence < css::ucb::NumberedSortingInfo > maOptions;
47 css::uno::Reference < css::ucb::XAnyCompareFactory > mxCompFac;
48 css::uno::Reference < css::uno::XComponentContext > m_xContext;
49
53
55 osl::Mutex maMutex;
57 bool mbUseOne:1;
58 bool mbStatic:1;
59
60private:
61 void SendNotify();
62
63public:
64 SortedDynamicResultSet( const css::uno::Reference < css::ucb::XDynamicResultSet > &xOriginal,
65 const css::uno::Sequence < css::ucb::NumberedSortingInfo > &aOptions,
66 const css::uno::Reference < css::ucb::XAnyCompareFactory > &xCompFac,
67 const css::uno::Reference < css::uno::XComponentContext > &rxContext );
68
69 virtual ~SortedDynamicResultSet() override;
70
71
72 // XServiceInfo
73
74 virtual OUString SAL_CALL getImplementationName() override;
75 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
76 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
77
78 // XComponent
79
80 virtual void SAL_CALL dispose() override;
81
82 virtual void SAL_CALL
83 addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
84
85 virtual void SAL_CALL
86 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
87
88
89 // XDynamicResultSet
90
91 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getStaticResultSet() override;
92
93 virtual void SAL_CALL
94 setListener( const css::uno::Reference< css::ucb::XDynamicResultSetListener >& Listener ) override;
95
96 virtual void SAL_CALL
97 connectToCache( const css::uno::Reference< css::ucb::XDynamicResultSet > & xCache ) override;
98
99 virtual sal_Int16 SAL_CALL
100 getCapabilities() override;
101
102
103 // own methods:
104
106 void impl_disposing();
107
109 void impl_notify( const css::ucb::ListEvent& Changes );
110};
111
112class SortedDynamicResultSetListener: public cppu::WeakImplHelper <
113 css::ucb::XDynamicResultSetListener >
114{
116 osl::Mutex maMutex;
117
118public:
120 virtual ~SortedDynamicResultSetListener() override;
121
122 // XEventListener ( base of XDynamicResultSetListener )
123
124 virtual void SAL_CALL
125 disposing( const css::lang::EventObject& Source ) override;
126
127 // XDynamicResultSetListener
128
129 virtual void SAL_CALL notify( const css::ucb::ListEvent& Changes ) override;
130
131 // own methods:
132
133 void impl_OwnerDies();
134};
135
136
137class SortedDynamicResultSetFactory: public cppu::WeakImplHelper <
138 css::lang::XServiceInfo,
139 css::ucb::XSortedDynamicResultSetFactory >
140{
141
142 css::uno::Reference< css::uno::XComponentContext > m_xContext;
143
144public:
146 const css::uno::Reference< css::uno::XComponentContext > & rxContext);
147
148 virtual ~SortedDynamicResultSetFactory() override;
149
150
151 // XServiceInfo
152 virtual OUString SAL_CALL getImplementationName() override;
153 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
154 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
155
156 // XSortedDynamicResultSetFactory
157 virtual css::uno::Reference< css::ucb::XDynamicResultSet > SAL_CALL
159 const css::uno::Reference< css::ucb::XDynamicResultSet > & Source,
160 const css::uno::Sequence< css::ucb::NumberedSortingInfo > & Info,
161 const css::uno::Reference< css::ucb::XAnyCompareFactory > & CompareFactory ) override;
162};
163
164/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::ucb::XDynamicResultSet > SAL_CALL createSortedDynamicResultSet(const css::uno::Reference< css::ucb::XDynamicResultSet > &Source, const css::uno::Sequence< css::ucb::NumberedSortingInfo > &Info, const css::uno::Reference< css::ucb::XAnyCompareFactory > &CompareFactory) override
Definition: sortdynres.cxx:445
SortedDynamicResultSetFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: sortdynres.cxx:405
virtual ~SortedDynamicResultSetFactory() override
Definition: sortdynres.cxx:412
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: sortdynres.cxx:429
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: sortdynres.hxx:142
virtual OUString SAL_CALL getImplementationName() override
Definition: sortdynres.cxx:419
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: sortdynres.cxx:424
SortedDynamicResultSetListener(SortedDynamicResultSet *mOwner)
Definition: sortdynres.cxx:473
virtual ~SortedDynamicResultSetListener() override
Definition: sortdynres.cxx:480
SortedDynamicResultSet * mpOwner
Definition: sortdynres.hxx:115
virtual void SAL_CALL notify(const css::ucb::ListEvent &Changes) override
Definition: sortdynres.cxx:499
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: sortdynres.cxx:487
SortedDynamicResultSet(const css::uno::Reference< css::ucb::XDynamicResultSet > &xOriginal, const css::uno::Sequence< css::ucb::NumberedSortingInfo > &aOptions, const css::uno::Reference< css::ucb::XAnyCompareFactory > &xCompFac, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: sortdynres.cxx:50
virtual OUString SAL_CALL getImplementationName() override
Definition: sortdynres.cxx:84
css::uno::Reference< css::ucb::XAnyCompareFactory > mxCompFac
Definition: sortdynres.hxx:47
virtual sal_Int16 SAL_CALL getCapabilities() override
Definition: sortdynres.cxx:212
rtl::Reference< SortedResultSet > mxOne
Definition: sortdynres.hxx:50
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: sortdynres.hxx:48
virtual ~SortedDynamicResultSet() override
Definition: sortdynres.cxx:70
virtual void SAL_CALL dispose() override
Definition: sortdynres.cxx:101
rtl::Reference< SortedDynamicResultSetListener > mxOwnListener
Definition: sortdynres.hxx:52
virtual void SAL_CALL setListener(const css::uno::Reference< css::ucb::XDynamicResultSetListener > &Listener) override
Definition: sortdynres.cxx:164
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: sortdynres.cxx:131
css::uno::Reference< css::ucb::XDynamicResultSetListener > mxListener
Definition: sortdynres.hxx:43
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: sortdynres.cxx:94
rtl::Reference< SortedResultSet > mxTwo
Definition: sortdynres.hxx:51
std::unique_ptr< comphelper::OInterfaceContainerHelper3< css::lang::XEventListener > > mpDisposeEventListeners
Definition: sortdynres.hxx:41
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: sortdynres.cxx:119
css::uno::Sequence< css::ucb::NumberedSortingInfo > maOptions
Definition: sortdynres.hxx:46
virtual void SAL_CALL connectToCache(const css::uno::Reference< css::ucb::XDynamicResultSet > &xCache) override
Definition: sortdynres.cxx:181
void impl_notify(const css::ucb::ListEvent &Changes)
In the first notify-call the listener gets the two <type>XResultSet</type>s and has to hold them.
Definition: sortdynres.cxx:245
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getStaticResultSet() override
Definition: sortdynres.cxx:144
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: sortdynres.cxx:89
css::uno::Reference< css::ucb::XDynamicResultSet > mxOriginal
Definition: sortdynres.hxx:45
unsigned char sal_Bool