LibreOffice Module ucb (master)  1
contentresultsetwrapper.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_CACHER_CONTENTRESULTSETWRAPPER_HXX
21 #define INCLUDED_UCB_SOURCE_CACHER_CONTENTRESULTSETWRAPPER_HXX
22 
23 #include <rtl/ustring.hxx>
24 #include <rtl/ref.hxx>
25 #include <osl/mutex.hxx>
26 #include <cppuhelper/weak.hxx>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/sdbc/XCloseable.hpp>
29 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
30 #include <com/sun/star/sdbc/XResultSet.hpp>
31 #include <com/sun/star/sdbc/XRow.hpp>
32 #include <com/sun/star/ucb/XContentAccess.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <memory>
37 
38 
41  : public cppu::OWeakObject
42  , public css::lang::XComponent
43  , public css::sdbc::XCloseable
44  , public css::sdbc::XResultSetMetaDataSupplier
45  , public css::beans::XPropertySet
46  , public css::ucb::XContentAccess
47  , public css::sdbc::XResultSet
48  , public css::sdbc::XRow
49 {
50 protected:
53 
54  //members
55 
56  //my Mutex
57  osl::Mutex m_aMutex;
58 
59  //different Interfaces from Origin:
60  css::uno::Reference< css::sdbc::XResultSet >
62  css::uno::Reference< css::sdbc::XRow >
63  m_xRowOrigin; //XRow-interface from m_xOrigin
65  css::uno::Reference< css::ucb::XContentAccess >
66  m_xContentAccessOrigin; //XContentAccess-interface from m_xOrigin
68  css::uno::Reference< css::beans::XPropertySet >
69  m_xPropertySetOrigin; //XPropertySet-interface from m_xOrigin
71 
72  css::uno::Reference< css::beans::XPropertySetInfo >
74  //call impl_initPropertySetInfo() bevor you access this member
75 
76  sal_Int32 m_nForwardOnly;
77 
78 private:
81 
82  css::uno::Reference< css::sdbc::XResultSetMetaData >
83  m_xMetaDataFromOrigin; //XResultSetMetaData from m_xOrigin
84 
85  //management of listeners
86  bool m_bDisposed;
88  osl::Mutex m_aContainerMutex;
89  std::unique_ptr<comphelper::OInterfaceContainerHelper2>
91  std::unique_ptr<PropertyChangeListenerContainer_Impl>
93  std::unique_ptr<PropertyChangeListenerContainer_Impl>
95 
96 
97  //methods:
98 private:
99  void
101 
102  void
104 
105  void verifyGet();
106 
107 protected:
108 
109 
110  ContentResultSetWrapper( css::uno::Reference< css::sdbc::XResultSet > const & xOrigin );
111 
112  virtual ~ContentResultSetWrapper() override;
113 
114  void impl_init();
115  void impl_deinit();
116 
117  //--
118 
119  void impl_init_xRowOrigin();
122 
123  //--
124 
125  virtual void impl_initPropertySetInfo(); //helping XPropertySet
126 
129  void
131 
132  void
134  const css::beans::PropertyChangeEvent& rEvt );
135 
138  void
140  const css::beans::PropertyChangeEvent& rEvt );
141 
142  bool impl_isForwardOnly();
143 
144 public:
145 
146 
147  // XInterface
148 
149  virtual css::uno::Any SAL_CALL
150  queryInterface( const css::uno::Type & rType ) override;
151 
152 
153  // XComponent
154 
155  virtual void SAL_CALL
156  dispose() override;
157 
158  virtual void SAL_CALL
159  addEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
160 
161  virtual void SAL_CALL
162  removeEventListener( const css::uno::Reference< css::lang::XEventListener >& Listener ) override;
163 
164 
165  //XCloseable
166 
167  virtual void SAL_CALL
168  close() override;
169 
170 
171  //XResultSetMetaDataSupplier
172 
173  virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
174  getMetaData() override;
175 
176 
177  // XPropertySet
178 
179  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
180  getPropertySetInfo() override;
181 
182  virtual void SAL_CALL
183  setPropertyValue( const OUString& aPropertyName,
184  const css::uno::Any& aValue ) override;
185 
186  virtual css::uno::Any SAL_CALL
187  getPropertyValue( const OUString& PropertyName ) override;
188 
189  virtual void SAL_CALL
190  addPropertyChangeListener( const OUString& aPropertyName,
191  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
192 
193  virtual void SAL_CALL
194  removePropertyChangeListener( const OUString& aPropertyName,
195  const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
196 
197  virtual void SAL_CALL
198  addVetoableChangeListener( const OUString& PropertyName,
199  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
200 
201  virtual void SAL_CALL
202  removeVetoableChangeListener( const OUString& PropertyName,
203  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
204 
205 
206  // own methods
207 
209  virtual void
210  impl_disposing( const css::lang::EventObject& Source );
211 
213  virtual void
214  impl_propertyChange( const css::beans::PropertyChangeEvent& evt );
215 
218  virtual void
219  impl_vetoableChange( const css::beans::PropertyChangeEvent& aEvent );
220 
221 
222  // XContentAccess
223 
224  virtual OUString SAL_CALL
225  queryContentIdentifierString() override;
226 
227  virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
228  queryContentIdentifier() override;
229 
230  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
231  queryContent() override;
232 
233 
234  // XResultSet
235 
236  virtual sal_Bool SAL_CALL
237  next() override;
238  virtual sal_Bool SAL_CALL
239  isBeforeFirst() override;
240  virtual sal_Bool SAL_CALL
241  isAfterLast() override;
242  virtual sal_Bool SAL_CALL
243  isFirst() override;
244  virtual sal_Bool SAL_CALL
245  isLast() override;
246  virtual void SAL_CALL
247  beforeFirst() override;
248  virtual void SAL_CALL
249  afterLast() override;
250  virtual sal_Bool SAL_CALL
251  first() override;
252  virtual sal_Bool SAL_CALL
253  last() override;
254  virtual sal_Int32 SAL_CALL
255  getRow() override;
256  virtual sal_Bool SAL_CALL
257  absolute( sal_Int32 row ) override;
258  virtual sal_Bool SAL_CALL
259  relative( sal_Int32 rows ) override;
260  virtual sal_Bool SAL_CALL
261  previous() override;
262  virtual void SAL_CALL
263  refreshRow() override;
264  virtual sal_Bool SAL_CALL
265  rowUpdated() override;
266  virtual sal_Bool SAL_CALL
267  rowInserted() override;
268  virtual sal_Bool SAL_CALL
269  rowDeleted() override;
270  virtual css::uno::Reference<
271  css::uno::XInterface > SAL_CALL
272  getStatement() override;
273 
274 
275  // XRow
276 
277  virtual sal_Bool SAL_CALL
278  wasNull() override;
279 
280  virtual OUString SAL_CALL
281  getString( sal_Int32 columnIndex ) override;
282 
283  virtual sal_Bool SAL_CALL
284  getBoolean( sal_Int32 columnIndex ) override;
285 
286  virtual sal_Int8 SAL_CALL
287  getByte( sal_Int32 columnIndex ) override;
288 
289  virtual sal_Int16 SAL_CALL
290  getShort( sal_Int32 columnIndex ) override;
291 
292  virtual sal_Int32 SAL_CALL
293  getInt( sal_Int32 columnIndex ) override;
294 
295  virtual sal_Int64 SAL_CALL
296  getLong( sal_Int32 columnIndex ) override;
297 
298  virtual float SAL_CALL
299  getFloat( sal_Int32 columnIndex ) override;
300 
301  virtual double SAL_CALL
302  getDouble( sal_Int32 columnIndex ) override;
303 
304  virtual css::uno::Sequence< sal_Int8 > SAL_CALL
305  getBytes( sal_Int32 columnIndex ) override;
306 
307  virtual css::util::Date SAL_CALL
308  getDate( sal_Int32 columnIndex ) override;
309 
310  virtual css::util::Time SAL_CALL
311  getTime( sal_Int32 columnIndex ) override;
312 
313  virtual css::util::DateTime SAL_CALL
314  getTimestamp( sal_Int32 columnIndex ) override;
315 
316  virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
317  getBinaryStream( sal_Int32 columnIndex ) override;
318 
319  virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
320  getCharacterStream( sal_Int32 columnIndex ) override;
321 
322  virtual css::uno::Any SAL_CALL
323  getObject( sal_Int32 columnIndex,
324  const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
325 
326  virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL
327  getRef( sal_Int32 columnIndex ) override;
328 
329  virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL
330  getBlob( sal_Int32 columnIndex ) override;
331 
332  virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL
333  getClob( sal_Int32 columnIndex ) override;
334 
335  virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL
336  getArray( sal_Int32 columnIndex ) override;
337 };
338 
339 
341  : public cppu::OWeakObject
342  , public css::beans::XPropertyChangeListener
343  , public css::beans::XVetoableChangeListener
344 {
346 
347 public:
349 
350  virtual ~ContentResultSetWrapperListener() override;
351 
352 
353  // XInterface
354  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
355  virtual void SAL_CALL acquire()
356  throw() override;
357  virtual void SAL_CALL release()
358  throw() override;
359 
360  //XEventListener
361 
362  virtual void SAL_CALL
363  disposing( const css::lang::EventObject& Source ) override;
364 
365 
366  //XPropertyChangeListener
367 
368  virtual void SAL_CALL
369  propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
370 
371 
372  //XVetoableChangeListener
373 
374  virtual void SAL_CALL
375  vetoableChange( const css::beans::PropertyChangeEvent& aEvent ) override;
376 
377 
378  // own methods:
379  void impl_OwnerDies();
380 };
381 
382 #endif
383 
384 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
virtual void impl_disposing(const css::lang::EventObject &Source)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
void impl_notifyPropertyChangeListeners(const css::beans::PropertyChangeEvent &rEvt)
ContentResultSetWrapper(css::uno::Reference< css::sdbc::XResultSet > const &xOrigin)
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
signed char sal_Int8
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaDataFromOrigin
void impl_notifyVetoableChangeListeners(const css::beans::PropertyChangeEvent &rEvt)
virtual sal_Bool SAL_CALL rowDeleted() override
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL rowUpdated() override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL vetoableChange(const css::beans::PropertyChangeEvent &aEvent) override
virtual sal_Bool SAL_CALL first() override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual sal_Bool SAL_CALL isAfterLast() override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
ContentResultSetWrapperListener(ContentResultSetWrapper *pOwner)
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual sal_Int32 SAL_CALL getRow() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
bool m_bInDispose
Dispose call ready.
virtual sal_Bool SAL_CALL last() override
virtual void SAL_CALL acquire() override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &Listener) override
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
std::unique_ptr< PropertyChangeListenerContainer_Impl > m_pVetoableChangeListeners
css::uno::Reference< css::ucb::XContentAccess > m_xContentAccessOrigin
! call impl_init_xRowOrigin() bevor you access this member
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &evt) override
virtual void SAL_CALL release() override
virtual sal_Bool SAL_CALL isFirst() override
virtual sal_Bool SAL_CALL previous() override
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL next() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pDisposeEventListeners
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
cppu::OMultiTypeInterfaceContainerHelperVar< OUString > PropertyChangeListenerContainer_Impl
virtual void SAL_CALL afterLast() override
virtual void SAL_CALL refreshRow() override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent() override
css::uno::Reference< css::sdbc::XRow > m_xRowOrigin
unsigned char sal_Bool
virtual sal_Bool SAL_CALL rowInserted() override
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL queryContentIdentifier() override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
std::unique_ptr< PropertyChangeListenerContainer_Impl > m_pPropertyChangeListeners
virtual void impl_vetoableChange(const css::beans::PropertyChangeEvent &aEvent)
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual void SAL_CALL beforeFirst() override
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual void SAL_CALL close() override
css::uno::Reference< css::beans::XPropertySet > m_xPropertySetOrigin
! call impl_init_xContentAccessOrigin() bevor you access this member
virtual void SAL_CALL dispose() override
virtual void impl_propertyChange(const css::beans::PropertyChangeEvent &evt)
rtl::Reference< ContentResultSetWrapperListener > m_xMyListenerImpl
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
css::uno::Reference< css::sdbc::XResultSet > m_xResultSetOrigin
css::uno::Reference< css::beans::XPropertySetInfo > m_xPropertySetInfo
! call impl_init_xPropertySetOrigin() bevor you access this member
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual sal_Bool SAL_CALL isBeforeFirst() override
osl::Mutex m_aContainerMutex
In dispose call.
virtual OUString SAL_CALL queryContentIdentifierString() override
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
virtual ~ContentResultSetWrapper() override
virtual sal_Bool SAL_CALL isLast() override
virtual sal_Bool SAL_CALL wasNull() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override