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