LibreOffice Module ucb (master)  1
ftpresultsetbase.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 #ifndef INCLUDED_UCB_SOURCE_UCP_FTP_FTPRESULTSETBASE_HXX
20 #define INCLUDED_UCB_SOURCE_UCP_FTP_FTPRESULTSETBASE_HXX
21 
22 #include <vector>
23 #include <cppuhelper/weak.hxx>
25 #include <com/sun/star/lang/XComponent.hpp>
26 #include <com/sun/star/ucb/XContentAccess.hpp>
27 #include <com/sun/star/sdbc/XCloseable.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/sdbc/XResultSet.hpp>
30 #include <com/sun/star/sdbc/XRow.hpp>
31 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
32 #include <com/sun/star/ucb/XContentProvider.hpp>
33 #include <com/sun/star/ucb/XContentIdentifier.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/beans/Property.hpp>
36 
37 
38 namespace ftp {
39 
41  : public cppu::OWeakObject,
42  public css::lang::XComponent,
43  public css::sdbc::XRow,
44  public css::sdbc::XResultSet,
45  public css::sdbc::XCloseable,
46  public css::sdbc::XResultSetMetaDataSupplier,
47  public css::beans::XPropertySet,
48  public css::ucb::XContentAccess
49  {
50  public:
51 
52  ResultSetBase(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
53  const css::uno::Reference< css::ucb::XContentProvider >& xProvider,
54  const css::uno::Sequence< css::beans::Property >& seq);
55 
56  virtual ~ResultSetBase() override;
57 
58  // XInterface
59  virtual css::uno::Any SAL_CALL
60  queryInterface( const css::uno::Type& aType ) override;
61 
62  virtual void SAL_CALL
63  acquire()
64  throw() override;
65 
66  virtual void SAL_CALL
67  release()
68  throw() override;
69 
70  // XComponent
71  virtual void SAL_CALL
72  dispose() override;
73 
74  virtual void SAL_CALL
76  const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
77 
78  virtual void SAL_CALL
79  removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
80 
81 
82  // XRow
83  virtual sal_Bool SAL_CALL
84  wasNull() override
85  {
86  if( 0<= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
87  m_nWasNull = m_aItems[m_nRow]->wasNull();
88  else
89  m_nWasNull = true;
90  return m_nWasNull;
91  }
92 
93  virtual OUString SAL_CALL
94  getString( sal_Int32 columnIndex ) override
95  {
96  OUString ret;
97  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
98  ret = m_aItems[m_nRow]->getString( columnIndex );
99 
100  return ret;
101  }
102 
103  virtual sal_Bool SAL_CALL
104  getBoolean( sal_Int32 columnIndex ) override
105  {
106  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
107  return m_aItems[m_nRow]->getBoolean( columnIndex );
108  else
109  return false;
110  }
111 
112  virtual sal_Int8 SAL_CALL
113  getByte( sal_Int32 columnIndex ) override
114  {
115  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
116  return m_aItems[m_nRow]->getByte( columnIndex );
117  else
118  return sal_Int8( 0 );
119  }
120 
121  virtual sal_Int16 SAL_CALL
122  getShort( sal_Int32 columnIndex ) override
123  {
124  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
125  return m_aItems[m_nRow]->getShort( columnIndex );
126  else
127  return sal_Int16( 0 );
128  }
129 
130  virtual sal_Int32 SAL_CALL
131  getInt( sal_Int32 columnIndex ) override
132  {
133  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
134  return m_aItems[m_nRow]->getInt( columnIndex );
135  else
136  return 0;
137  }
138 
139  virtual sal_Int64 SAL_CALL
140  getLong( sal_Int32 columnIndex ) override
141  {
142  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
143  return m_aItems[m_nRow]->getLong( columnIndex );
144  else
145  return sal_Int64( 0 );
146  }
147 
148  virtual float SAL_CALL
149  getFloat( sal_Int32 columnIndex ) override
150  {
151  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
152  return m_aItems[m_nRow]->getFloat( columnIndex );
153  else
154  return float( 0 );
155  }
156 
157  virtual double SAL_CALL
158  getDouble( sal_Int32 columnIndex ) override
159  {
160  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
161  return m_aItems[m_nRow]->getDouble( columnIndex );
162  else
163  return double( 0 );
164  }
165 
166  virtual css::uno::Sequence< sal_Int8 > SAL_CALL
167  getBytes( sal_Int32 columnIndex ) override
168  {
169  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
170  return m_aItems[m_nRow]->getBytes( columnIndex );
171  else
172  return css::uno::Sequence< sal_Int8 >();
173  }
174 
175  virtual css::util::Date SAL_CALL
176  getDate( sal_Int32 columnIndex ) override
177  {
178  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
179  return m_aItems[m_nRow]->getDate( columnIndex );
180  else
181  return css::util::Date();
182  }
183 
184  virtual css::util::Time SAL_CALL
185  getTime( sal_Int32 columnIndex ) override
186  {
187  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
188  return m_aItems[m_nRow]->getTime( columnIndex );
189  else
190  return css::util::Time();
191  }
192 
193  virtual css::util::DateTime SAL_CALL
194  getTimestamp( sal_Int32 columnIndex ) override
195  {
196  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
197  return m_aItems[m_nRow]->getTimestamp( columnIndex );
198  else
199  return css::util::DateTime();
200  }
201 
202 
203  virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
204  getBinaryStream( sal_Int32 columnIndex ) override
205  {
206  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
207  return m_aItems[m_nRow]->getBinaryStream( columnIndex );
208  else
209  return css::uno::Reference< css::io::XInputStream >();
210  }
211 
212  virtual css::uno::Reference< css::io::XInputStream > SAL_CALL
213  getCharacterStream( sal_Int32 columnIndex ) override
214  {
215  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
216  return m_aItems[m_nRow]->getCharacterStream( columnIndex );
217  else
218  return css::uno::Reference< css::io::XInputStream >();
219  }
220 
221  virtual css::uno::Any SAL_CALL
222  getObject( sal_Int32 columnIndex,
223  const css::uno::Reference< css::container::XNameAccess >& typeMap ) override
224  {
225  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
226  return m_aItems[m_nRow]->getObject( columnIndex,typeMap );
227  else
228  return css::uno::Any();
229  }
230 
231  virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL
232  getRef( sal_Int32 columnIndex ) override
233  {
234  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
235  return m_aItems[m_nRow]->getRef( columnIndex );
236  else
237  return css::uno::Reference< css::sdbc::XRef >();
238  }
239 
240  virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL
241  getBlob( sal_Int32 columnIndex ) override
242  {
243  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
244  return m_aItems[m_nRow]->getBlob( columnIndex );
245  else
246  return css::uno::Reference< css::sdbc::XBlob >();
247  }
248 
249  virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL
250  getClob( sal_Int32 columnIndex ) override
251  {
252  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
253  return m_aItems[m_nRow]->getClob( columnIndex );
254  else
255  return css::uno::Reference< css::sdbc::XClob >();
256  }
257 
258  virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL
259  getArray( sal_Int32 columnIndex ) override
260  {
261  if( 0 <= m_nRow && m_nRow < sal::static_int_cast<sal_Int32>(m_aItems.size()) )
262  return m_aItems[m_nRow]->getArray( columnIndex );
263  else
264  return css::uno::Reference<
265  css::sdbc::XArray >();
266  }
267 
268 
269  // XResultSet
270 
271  virtual sal_Bool SAL_CALL
272  next() override;
273 
274  virtual sal_Bool SAL_CALL
275  isBeforeFirst() override;
276 
277  virtual sal_Bool SAL_CALL
278  isAfterLast() override;
279 
280  virtual sal_Bool SAL_CALL
281  isFirst() override;
282 
283  virtual sal_Bool SAL_CALL
284  isLast() override;
285 
286  virtual void SAL_CALL
287  beforeFirst() override;
288 
289  virtual void SAL_CALL
290  afterLast() override;
291 
292  virtual sal_Bool SAL_CALL
293  first() override;
294 
295  virtual sal_Bool SAL_CALL
296  last() override;
297 
298  virtual sal_Int32 SAL_CALL
299  getRow() override;
300 
301  virtual sal_Bool SAL_CALL
302  absolute(
303  sal_Int32 row ) override;
304 
305  virtual sal_Bool SAL_CALL
306  relative(
307  sal_Int32 rows ) override;
308 
309  virtual sal_Bool SAL_CALL
310  previous() override;
311 
312  virtual void SAL_CALL
313  refreshRow() override;
314 
315  virtual sal_Bool SAL_CALL
316  rowUpdated() override;
317 
318  virtual sal_Bool SAL_CALL
319  rowInserted() override;
320 
321  virtual sal_Bool SAL_CALL
322  rowDeleted() override;
323 
324 
325  virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
326  getStatement() override;
327 
328  // XCloseable
329 
330  virtual void SAL_CALL
331  close() override;
332 
333  // XContentAccess
334 
335  virtual OUString SAL_CALL
336  queryContentIdentifierString() override;
337 
338  virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL
339  queryContentIdentifier() override;
340 
341  virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
342  queryContent() override;
343 
344  // XResultSetMetaDataSupplier
345  virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL
346  getMetaData() override;
347 
348 
349  // XPropertySet
350  virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
351  getPropertySetInfo() override;
352 
353  virtual void SAL_CALL setPropertyValue(
354  const OUString& aPropertyName,
355  const css::uno::Any& aValue ) override;
356 
357  virtual css::uno::Any SAL_CALL
359  const OUString& PropertyName ) override;
360 
361  virtual void SAL_CALL
363  const OUString& aPropertyName,
364  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
365 
366  virtual void SAL_CALL
368  const OUString& aPropertyName,
369  const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
370 
371  virtual void SAL_CALL
373  const OUString& PropertyName,
374  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
375 
376  virtual void SAL_CALL removeVetoableChangeListener(
377  const OUString& PropertyName,
378  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
379 
380  protected:
381 
382  css::uno::Reference< css::uno::XComponentContext >
384  css::uno::Reference< css::ucb::XContentProvider >
386  sal_Int32 m_nRow;
388 
389  typedef std::vector< css::uno::Reference<css::ucb::XContentIdentifier > >
391  typedef std::vector< css::uno::Reference< css::sdbc::XRow > >
393 
396  std::vector<OUString> m_aPath;
397 
398  css::uno::Sequence< css::beans::Property > const
400 
401  osl::Mutex m_aMutex;
402  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pDisposeEventListeners;
403  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pRowCountListeners;
404  std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pIsFinalListeners;
405  };
406 
407 
408 } // end namespace fileaccess
409 
410 
411 #endif
412 
413 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL refreshRow() override
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pDisposeEventListeners
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
signed char sal_Int8
virtual sal_Bool SAL_CALL isLast() override
virtual sal_Bool SAL_CALL previous() override
virtual sal_Bool SAL_CALL isAfterLast() override
virtual css::uno::Reference< css::ucb::XContentIdentifier > SAL_CALL queryContentIdentifier() override
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
virtual OUString SAL_CALL queryContentIdentifierString() override
std::vector< OUString > m_aPath
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL acquire() override
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL rowInserted() override
virtual sal_Bool SAL_CALL last() override
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL isBeforeFirst() override
virtual sal_Bool SAL_CALL first() override
virtual sal_Bool SAL_CALL wasNull() override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pIsFinalListeners
virtual sal_Bool SAL_CALL rowUpdated() override
std::unique_ptr< comphelper::OInterfaceContainerHelper2 > m_pRowCountListeners
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL next() override
ResultSetBase(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::ucb::XContentProvider > &xProvider, const css::uno::Sequence< css::beans::Property > &seq)
std::vector< css::uno::Reference< css::sdbc::XRow > > ItemSet
virtual void SAL_CALL dispose() override
unsigned char sal_Bool
virtual sal_Bool SAL_CALL rowDeleted() override
virtual void SAL_CALL close() override
Definition of ftpcontentprovider.
virtual void SAL_CALL release() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
std::vector< css::uno::Reference< css::ucb::XContentIdentifier > > IdentSet
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual sal_Bool SAL_CALL isFirst() override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
css::uno::Reference< css::ucb::XContentProvider > m_xProvider
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL afterLast() override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
virtual ~ResultSetBase() override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent() override
css::uno::Sequence< css::beans::Property > const m_sProperty
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
virtual void SAL_CALL beforeFirst() override
virtual sal_Int32 SAL_CALL getRow() override