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 #ifndef INCLUDED_UCB_SOURCE_SORTER_SORTDYNRES_HXX
21 #define INCLUDED_UCB_SOURCE_SORTER_SORTDYNRES_HXX
22 
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"
32 
33 
34 namespace comphelper {
35  class OInterfaceContainerHelper2;
36 }
37 
38 #define DYNAMIC_RESULTSET_SERVICE_NAME "com.sun.star.ucb.SortedDynamicResultSet"
39 #define DYNAMIC_RESULTSET_FACTORY_NAME "com.sun.star.ucb.SortedDynamicResultSetFactory"
40 
42 
43 class SortedDynamicResultSet: public cppu::WeakImplHelper <
44  css::lang::XServiceInfo,
45  css::ucb::XDynamicResultSet >
46 {
47  std::unique_ptr<comphelper::OInterfaceContainerHelper2> mpDisposeEventListeners;
48 
49  css::uno::Reference < css::ucb::XDynamicResultSetListener > mxListener;
50 
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;
55 
59 
61  osl::Mutex maMutex;
62  bool mbGotWelcome:1;
63  bool mbUseOne:1;
64  bool mbStatic:1;
65 
66 private:
67  void SendNotify();
68 
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 );
74 
75  virtual ~SortedDynamicResultSet() override;
76 
77 
78  // XServiceInfo
79 
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;
83 
84  // XComponent
85 
86  virtual void SAL_CALL dispose() override;
87 
88  virtual void SAL_CALL
89  addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
90 
91  virtual void SAL_CALL
92  removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
93 
94 
95  // XDynamicResultSet
96 
97  virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getStaticResultSet() override;
98 
99  virtual void SAL_CALL
100  setListener( const css::uno::Reference< css::ucb::XDynamicResultSetListener >& Listener ) override;
101 
102  virtual void SAL_CALL
103  connectToCache( const css::uno::Reference< css::ucb::XDynamicResultSet > & xCache ) override;
104 
105  virtual sal_Int16 SAL_CALL
106  getCapabilities() override;
107 
108 
109  // own methods:
110 
112  void impl_disposing();
113 
115  void impl_notify( const css::ucb::ListEvent& Changes );
116 };
117 
118 class SortedDynamicResultSetListener: public cppu::WeakImplHelper <
119  css::ucb::XDynamicResultSetListener >
120 {
122  osl::Mutex maMutex;
123 
124 public:
126  virtual ~SortedDynamicResultSetListener() override;
127 
128  // XEventListener ( base of XDynamicResultSetListener )
129 
130  virtual void SAL_CALL
131  disposing( const css::lang::EventObject& Source ) override;
132 
133  // XDynamicResultSetListener
134 
135  virtual void SAL_CALL notify( const css::ucb::ListEvent& Changes ) override;
136 
137  // own methods:
138 
139  void impl_OwnerDies();
140 };
141 
142 
143 class SortedDynamicResultSetFactory: public cppu::WeakImplHelper <
144  css::lang::XServiceInfo,
145  css::ucb::XSortedDynamicResultSetFactory >
146 {
147 
148  css::uno::Reference< css::uno::XComponentContext > m_xContext;
149 
150 public:
152  const css::uno::Reference< css::uno::XComponentContext > & rxContext);
153 
154  virtual ~SortedDynamicResultSetFactory() override;
155 
156 
157  // XServiceInfo
158 
159  static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory(
160  const css::uno::Reference< css::lang::XMultiServiceFactory >& rxServiceMgr );
161 
162  // XSortedDynamicResultSetFactory
163 
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();
169 
170  virtual css::uno::Reference< css::ucb::XDynamicResultSet > SAL_CALL
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;
175 };
176 
177 #endif
178 
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: sortdynres.hxx:54
SortedDynamicResultSet * mpOwner
Definition: sortdynres.hxx:121
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
Definition: sortdynres.cxx:449
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > mpDisposeEventListeners
Definition: sortdynres.hxx:47
void impl_notify(const css::ucb::ListEvent &Changes)
In the first notify-call the listener gets the two XResultSets and has to hold them...
Definition: sortdynres.cxx:246
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: sortdynres.cxx:430
css::uno::Reference< css::ucb::XDynamicResultSetListener > mxListener
Definition: sortdynres.hxx:49
virtual ~SortedDynamicResultSetListener() override
Definition: sortdynres.cxx:505
css::uno::Reference< css::ucb::XAnyCompareFactory > mxCompFac
Definition: sortdynres.hxx:53
virtual ~SortedDynamicResultSet() override
Definition: sortdynres.cxx:71
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getStaticResultSet() override
Definition: sortdynres.cxx:145
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: sortdynres.cxx:132
virtual OUString SAL_CALL getImplementationName() override
Definition: sortdynres.cxx:85
virtual sal_Int16 SAL_CALL getCapabilities() override
Definition: sortdynres.cxx:213
css::uno::Sequence< css::ucb::NumberedSortingInfo > maOptions
Definition: sortdynres.hxx:52
virtual void SAL_CALL dispose() override
Definition: sortdynres.cxx:102
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: sortdynres.cxx:512
unsigned char sal_Bool
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: sortdynres.cxx:435
virtual OUString SAL_CALL getImplementationName() override
Definition: sortdynres.cxx:420
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:51
rtl::Reference< SortedResultSet > mxOne
Definition: sortdynres.hxx:56
virtual void SAL_CALL notify(const css::ucb::ListEvent &Changes) override
Definition: sortdynres.cxx:524
static OUString getImplementationName_Static()
Definition: sortdynres.cxx:425
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
Definition: sortdynres.cxx:120
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:470
rtl::Reference< SortedResultSet > mxTwo
Definition: sortdynres.hxx:57
SortedDynamicResultSetListener(SortedDynamicResultSet *mOwner)
Definition: sortdynres.cxx:498
virtual ~SortedDynamicResultSetFactory() override
Definition: sortdynres.cxx:413
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: sortdynres.cxx:95
css::uno::Reference< css::ucb::XDynamicResultSet > mxOriginal
Definition: sortdynres.hxx:51
virtual void SAL_CALL connectToCache(const css::uno::Reference< css::ucb::XDynamicResultSet > &xCache) override
Definition: sortdynres.cxx:182
SortedDynamicResultSetFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: sortdynres.cxx:406
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: sortdynres.cxx:90
rtl::Reference< SortedDynamicResultSetListener > mxOwnListener
Definition: sortdynres.hxx:58
static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxServiceMgr)
Definition: sortdynres.cxx:458
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: sortdynres.hxx:148
virtual void SAL_CALL setListener(const css::uno::Reference< css::ucb::XDynamicResultSetListener > &Listener) override
Definition: sortdynres.cxx:165