LibreOffice Module svx (master)  1
dbaexchange.cxx
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 #include <svx/dbaexchange.hxx>
21 #include <osl/diagnose.h>
22 #include <com/sun/star/sdb/CommandType.hpp>
23 #include <com/sun/star/sdbc/XConnection.hpp>
24 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
25 #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
26 #include <fmprop.hxx>
27 #include <comphelper/extract.hxx>
28 #include <sot/formats.hxx>
29 #include <sot/exchange.hxx>
30 
31 
32 namespace svx
33 {
34 
35 
36  using namespace ::com::sun::star::uno;
37  using namespace ::com::sun::star::beans;
38  using namespace ::com::sun::star::sdb;
39  using namespace ::com::sun::star::sdbc;
40  using namespace ::com::sun::star::lang;
41  using namespace ::com::sun::star::sdbcx;
42  using namespace ::com::sun::star::container;
43  using namespace ::com::sun::star::datatransfer;
44 
46  : m_nFormatFlags(nFormats)
47  {
48  }
49 
51  {
52  ClearFormats();
53 
54  OUString sDataSource, sDatabaseLocation, sConnectionResource, sCommand, sFieldName;
55  if ( rDescriptor.has( DataAccessDescriptorProperty::DataSource ) ) rDescriptor[ DataAccessDescriptorProperty::DataSource ] >>= sDataSource;
56  if ( rDescriptor.has( DataAccessDescriptorProperty::DatabaseLocation ) ) rDescriptor[ DataAccessDescriptorProperty::DatabaseLocation ] >>= sDatabaseLocation;
57  if ( rDescriptor.has( DataAccessDescriptorProperty::ConnectionResource ) ) rDescriptor[ DataAccessDescriptorProperty::ConnectionResource ] >>= sConnectionResource;
58  if ( rDescriptor.has( DataAccessDescriptorProperty::Command ) ) rDescriptor[ DataAccessDescriptorProperty::Command ] >>= sCommand;
59  if ( rDescriptor.has( DataAccessDescriptorProperty::ColumnName ) ) rDescriptor[ DataAccessDescriptorProperty::ColumnName ] >>= sFieldName;
60 
61  sal_Int32 nCommandType = CommandType::TABLE;
62  OSL_VERIFY( rDescriptor[ DataAccessDescriptorProperty::CommandType ] >>= nCommandType );
63 
65  sDataSource.isEmpty() ? sDatabaseLocation : sDataSource,
66  sConnectionResource, nCommandType, sCommand, sFieldName );
67 
69  {
70  if ( rDescriptor.has( DataAccessDescriptorProperty::Connection ) )
74  }
75  }
76 
77  OColumnTransferable::OColumnTransferable(const Reference< XPropertySet >& _rxForm,
78  const OUString& _rFieldName, const Reference< XPropertySet >& _rxColumn,
79  const Reference< XConnection >& _rxConnection, ColumnTransferFormatFlags _nFormats)
80  :m_nFormatFlags(_nFormats)
81  {
82  OSL_ENSURE(_rxForm.is(), "OColumnTransferable::OColumnTransferable: invalid form!");
83  // collect the necessary information from the form
84  OUString sCommand;
85  sal_Int32 nCommandType = CommandType::TABLE;
86  OUString sDatasource,sURL;
87 
88  bool bTryToParse = true;
89  try
90  {
91  _rxForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nCommandType;
92  _rxForm->getPropertyValue(FM_PROP_COMMAND) >>= sCommand;
93  _rxForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasource;
94  _rxForm->getPropertyValue(FM_PROP_URL) >>= sURL;
95  bTryToParse = ::cppu::any2bool(_rxForm->getPropertyValue(FM_PROP_ESCAPE_PROCESSING));
96  }
97  catch(Exception&)
98  {
99  OSL_FAIL("OColumnTransferable::OColumnTransferable: could not collect essential data source attributes !");
100  }
101 
102  // If the data source is an SQL-statement and simple enough (means "select <field list> from <table> where...")
103  // we are able to fake the drag information we are about to create.
104  if (bTryToParse && (CommandType::COMMAND == nCommandType))
105  {
106  try
107  {
108  Reference< XTablesSupplier > xSupTab;
109  _rxForm->getPropertyValue("SingleSelectQueryComposer") >>= xSupTab;
110 
111  if(xSupTab.is())
112  {
113  Reference< XNameAccess > xNames = xSupTab->getTables();
114  if (xNames.is())
115  {
116  Sequence< OUString > aTables = xNames->getElementNames();
117  if (1 == aTables.getLength())
118  {
119  sCommand = aTables[0];
120  nCommandType = CommandType::TABLE;
121  }
122  }
123  }
124  }
125  catch(Exception&)
126  {
127  OSL_FAIL("OColumnTransferable::OColumnTransferable: could not collect essential data source attributes (part two) !");
128  }
129  }
130 
131  implConstruct(sDatasource, sURL,nCommandType, sCommand, _rFieldName);
132 
133  if ((m_nFormatFlags & ColumnTransferFormatFlags::COLUMN_DESCRIPTOR) == ColumnTransferFormatFlags::COLUMN_DESCRIPTOR)
134  {
135  if (_rxColumn.is())
137  if (_rxConnection.is())
139  }
140  }
141 
142 
144  {
145  static SotClipboardFormatId s_nFormat = static_cast<SotClipboardFormatId>(-1);
146  if (static_cast<SotClipboardFormatId>(-1) == s_nFormat)
147  {
148  s_nFormat = SotExchange::RegisterFormatName("application/x-openoffice;windows_formatname=\"dbaccess.ColumnDescriptorTransfer\"");
149  OSL_ENSURE(static_cast<SotClipboardFormatId>(-1) != s_nFormat, "OColumnTransferable::getDescriptorFormatId: bad exchange id!");
150  }
151  return s_nFormat;
152  }
153 
154 
155  void OColumnTransferable::implConstruct( const OUString& _rDatasource
156  ,const OUString& _rConnectionResource
157  ,const sal_Int32 _nCommandType
158  ,const OUString& _rCommand
159  , const OUString& _rFieldName)
160  {
161  const sal_Unicode cSeparator = u'\x000B';
162  const OUString sSeparator(&cSeparator, 1);
163 
164  m_sCompatibleFormat.clear();
165  m_sCompatibleFormat += _rDatasource;
166  m_sCompatibleFormat += sSeparator;
167  m_sCompatibleFormat += _rCommand;
168  m_sCompatibleFormat += sSeparator;
169 
170  sal_Unicode cCommandType;
171  switch (_nCommandType)
172  {
173  case CommandType::TABLE:
174  cCommandType = '0';
175  break;
176  case CommandType::QUERY:
177  cCommandType = '1';
178  break;
179  default:
180  cCommandType = '2';
181  break;
182  }
183  m_sCompatibleFormat += OUString(&cCommandType, 1);
184  m_sCompatibleFormat += sSeparator;
185  m_sCompatibleFormat += _rFieldName;
186 
188  if ((m_nFormatFlags & ColumnTransferFormatFlags::COLUMN_DESCRIPTOR) == ColumnTransferFormatFlags::COLUMN_DESCRIPTOR)
189  {
190  m_aDescriptor.setDataSource(_rDatasource);
191  if ( !_rConnectionResource.isEmpty() )
193 
197  }
198  }
199 
200 
202  {
204  AddFormat(SotClipboardFormatId::SBA_CTRLDATAEXCHANGE);
205 
206  if (ColumnTransferFormatFlags::FIELD_DESCRIPTOR & m_nFormatFlags)
207  AddFormat(SotClipboardFormatId::SBA_FIELDDATAEXCHANGE);
208 
209  if (ColumnTransferFormatFlags::COLUMN_DESCRIPTOR & m_nFormatFlags)
211  }
212 
213 
214  bool OColumnTransferable::GetData( const DataFlavor& _rFlavor, const OUString& /*rDestDoc*/ )
215  {
216  const SotClipboardFormatId nFormatId = SotExchange::GetFormat(_rFlavor);
217  switch (nFormatId)
218  {
219  case SotClipboardFormatId::SBA_FIELDDATAEXCHANGE:
220  case SotClipboardFormatId::SBA_CTRLDATAEXCHANGE:
221  return SetString(m_sCompatibleFormat, _rFlavor);
222  default: break;
223  }
224  if (nFormatId == getDescriptorFormatId())
226 
227  return false;
228  }
229 
230 
232  {
233  bool bFieldFormat = bool(_nFormats & ColumnTransferFormatFlags::FIELD_DESCRIPTOR);
234  bool bControlFormat = bool(_nFormats & ColumnTransferFormatFlags::CONTROL_EXCHANGE);
235  bool bDescriptorFormat = bool(_nFormats & ColumnTransferFormatFlags::COLUMN_DESCRIPTOR);
237  return std::any_of(_rFlavors.begin(), _rFlavors.end(),
238  [&](const DataFlavorEx& rCheck) {
239  return (bFieldFormat && (SotClipboardFormatId::SBA_FIELDDATAEXCHANGE == rCheck.mnSotId))
240  || (bControlFormat && (SotClipboardFormatId::SBA_CTRLDATAEXCHANGE == rCheck.mnSotId))
241  || (bDescriptorFormat && (nFormatId == rCheck.mnSotId));
242  });
243  }
244 
245 
247  {
248  if (_rData.HasFormat(getDescriptorFormatId()))
249  {
250  // the object has a real descriptor object (not just the old compatible format)
251 
252  // extract the any from the transferable
253  DataFlavor aFlavor;
254  bool bSuccess =
256  OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
257 
258  Any aDescriptor = _rData.GetAny(aFlavor, OUString());
259 
260  // extract the property value sequence
261  Sequence< PropertyValue > aDescriptorProps;
262  bSuccess = aDescriptor >>= aDescriptorProps;
263  OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid clipboard format!");
264 
265  // build the real descriptor
266  return ODataAccessDescriptor(aDescriptorProps);
267  }
268 
269  // only the old (compatible) format exists -> use the other extract method ...
270  OUString sDatasource, sCommand, sFieldName,sDatabaseLocation,sConnectionResource;
271  sal_Int32 nCommandType = CommandType::COMMAND;
272 
273  ODataAccessDescriptor aDescriptor;
274  if (extractColumnDescriptor(_rData, sDatasource, sDatabaseLocation,sConnectionResource,nCommandType, sCommand, sFieldName))
275  {
276  // and build an own descriptor
277  if ( !sDatasource.isEmpty() )
278  aDescriptor[DataAccessDescriptorProperty::DataSource] <<= sDatasource;
279  if ( !sDatabaseLocation.isEmpty() )
280  aDescriptor[DataAccessDescriptorProperty::DatabaseLocation] <<= sDatabaseLocation;
281  if ( !sConnectionResource.isEmpty() )
282  aDescriptor[DataAccessDescriptorProperty::ConnectionResource] <<= sConnectionResource;
283 
284  aDescriptor[DataAccessDescriptorProperty::Command] <<= sCommand;
285  aDescriptor[DataAccessDescriptorProperty::CommandType] <<= nCommandType;
286  aDescriptor[DataAccessDescriptorProperty::ColumnName] <<= sFieldName;
287  }
288  return aDescriptor;
289  }
290 
291 
293  ,OUString& _rDatasource
294  ,OUString& _rDatabaseLocation
295  ,OUString& _rConnectionResource
296  ,sal_Int32& _nCommandType
297  ,OUString& _rCommand
298  ,OUString& _rFieldName)
299  {
300  if ( _rData.HasFormat(getDescriptorFormatId()) )
301  {
302  ODataAccessDescriptor aDescriptor = extractColumnDescriptor(_rData);
304  aDescriptor[DataAccessDescriptorProperty::DataSource] >>= _rDatasource;
306  aDescriptor[DataAccessDescriptorProperty::DatabaseLocation] >>= _rDatabaseLocation;
308  aDescriptor[DataAccessDescriptorProperty::ConnectionResource] >>= _rConnectionResource;
309 
310  aDescriptor[DataAccessDescriptorProperty::Command] >>= _rCommand;
311  aDescriptor[DataAccessDescriptorProperty::CommandType] >>= _nCommandType;
312  aDescriptor[DataAccessDescriptorProperty::ColumnName] >>= _rFieldName;
313  return true;
314  }
315 
316  // check if we have a (string) format we can use...
317  SotClipboardFormatId nRecognizedFormat = SotClipboardFormatId::NONE;
318  if (_rData.HasFormat(SotClipboardFormatId::SBA_FIELDDATAEXCHANGE))
319  nRecognizedFormat = SotClipboardFormatId::SBA_FIELDDATAEXCHANGE;
320  if (_rData.HasFormat(SotClipboardFormatId::SBA_CTRLDATAEXCHANGE))
321  nRecognizedFormat = SotClipboardFormatId::SBA_CTRLDATAEXCHANGE;
322  if (nRecognizedFormat == SotClipboardFormatId::NONE)
323  return false;
324 
325  OUString sFieldDescription;
326  (void)const_cast<TransferableDataHelper&>(_rData).GetString(nRecognizedFormat, sFieldDescription);
327 
328  const sal_Unicode cSeparator = u'\x000B';
329  sal_Int32 nIdx{ 0 };
330  _rDatasource = sFieldDescription.getToken(0, cSeparator, nIdx);
331  _rCommand = sFieldDescription.getToken(0, cSeparator, nIdx);
332  _nCommandType = sFieldDescription.getToken(0, cSeparator, nIdx).toInt32();
333  _rFieldName = sFieldDescription.getToken(0, cSeparator, nIdx);
334 
335  return true;
336  }
337 
338 
340  const OUString& _rDatasource
341  ,const sal_Int32 _nCommandType
342  ,const OUString& _rCommand
343  )
344  {
345  construct(_rDatasource,OUString(),_nCommandType,_rCommand,nullptr,(CommandType::COMMAND == _nCommandType),_rCommand);
346  }
347 
349  const OUString& _rDatasource
350  ,const sal_Int32 _nCommandType
351  ,const OUString& _rCommand
352  ,const Reference< XConnection >& _rxConnection)
353  {
354  OSL_ENSURE(_rxConnection.is(),"Wrong ctor used.!");
355  construct(_rDatasource,OUString(),_nCommandType,_rCommand,_rxConnection,(CommandType::COMMAND == _nCommandType),_rCommand);
356  }
357 
358 
359  ODataAccessObjectTransferable::ODataAccessObjectTransferable(const Reference< XPropertySet >& _rxLivingForm)
360  {
361  // collect some properties of the form
362  OUString sDatasourceName,sConnectionResource;
363  sal_Int32 nObjectType = CommandType::COMMAND;
364  OUString sObjectName;
365  Reference< XConnection > xConnection;
366  try
367  {
368  _rxLivingForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nObjectType;
369  _rxLivingForm->getPropertyValue(FM_PROP_COMMAND) >>= sObjectName;
370  _rxLivingForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasourceName;
371  _rxLivingForm->getPropertyValue(FM_PROP_URL) >>= sConnectionResource;
372  _rxLivingForm->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConnection;
373  }
374  catch(Exception&)
375  {
376  OSL_FAIL("ODataAccessObjectTransferable::ODataAccessObjectTransferable: could not collect essential form attributes !");
377  return;
378  }
379 
380  // check if the SQL-statement is modified
381  OUString sCompleteStatement;
382  try
383  {
384  _rxLivingForm->getPropertyValue(FM_PROP_ACTIVECOMMAND) >>= sCompleteStatement;
385  }
386  catch (const Exception&)
387  {
388  OSL_FAIL("ODataAccessObjectTransferable::ODataAccessObjectTransferable: could not collect essential form attributes (part two) !");
389  return;
390  }
391 
392  construct( sDatasourceName
393  ,sConnectionResource
394  ,nObjectType
395  ,sObjectName,xConnection
396  ,CommandType::QUERY != nObjectType
397  ,sCompleteStatement);
398  }
399 
400 
402  {
403  sal_Int32 nObjectType = CommandType::COMMAND;
405  switch (nObjectType)
406  {
407  case CommandType::TABLE:
408  AddFormat(SotClipboardFormatId::DBACCESS_TABLE);
409  break;
410  case CommandType::QUERY:
411  AddFormat(SotClipboardFormatId::DBACCESS_QUERY);
412  break;
413  case CommandType::COMMAND:
414  AddFormat(SotClipboardFormatId::DBACCESS_COMMAND);
415  break;
416  }
417 
418  if (!m_sCompatibleObjectDescription.isEmpty())
419  AddFormat(SotClipboardFormatId::SBA_DATAEXCHANGE);
420  }
421 
422 
423  bool ODataAccessObjectTransferable::GetData( const DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
424  {
425  SotClipboardFormatId nFormat = SotExchange::GetFormat(rFlavor);
426  switch (nFormat)
427  {
428  case SotClipboardFormatId::DBACCESS_TABLE:
429  case SotClipboardFormatId::DBACCESS_QUERY:
430  case SotClipboardFormatId::DBACCESS_COMMAND:
432 
433  case SotClipboardFormatId::SBA_DATAEXCHANGE:
434  return SetString(m_sCompatibleObjectDescription, rFlavor);
435  default: break;
436  }
437  return false;
438  }
439 
440 
442  {
443  return std::any_of(_rFlavors.begin(), _rFlavors.end(),
444  [](const DataFlavorEx& rCheck) {
445  return SotClipboardFormatId::DBACCESS_TABLE == rCheck.mnSotId
446  || SotClipboardFormatId::DBACCESS_QUERY == rCheck.mnSotId
447  || SotClipboardFormatId::DBACCESS_COMMAND == rCheck.mnSotId;
448  });
449  }
450 
451 
453  {
454  SotClipboardFormatId nKnownFormatId = SotClipboardFormatId::NONE;
455  if ( _rData.HasFormat( SotClipboardFormatId::DBACCESS_TABLE ) )
456  nKnownFormatId = SotClipboardFormatId::DBACCESS_TABLE;
457  if ( _rData.HasFormat( SotClipboardFormatId::DBACCESS_QUERY ) )
458  nKnownFormatId = SotClipboardFormatId::DBACCESS_QUERY;
459  if ( _rData.HasFormat( SotClipboardFormatId::DBACCESS_COMMAND ) )
460  nKnownFormatId = SotClipboardFormatId::DBACCESS_COMMAND;
461 
462  if (SotClipboardFormatId::NONE != nKnownFormatId)
463  {
464  // extract the any from the transferable
465  DataFlavor aFlavor;
466  bool bSuccess =
467  SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
468  OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
469 
470  Any aDescriptor = _rData.GetAny(aFlavor, OUString());
471 
472  // extract the property value sequence
473  Sequence< PropertyValue > aDescriptorProps;
474  bSuccess = aDescriptor >>= aDescriptorProps;
475  OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid clipboard format!");
476 
477  // build the real descriptor
478  return ODataAccessDescriptor(aDescriptorProps);
479  }
480 
481  OSL_FAIL( "OColumnTransferable::extractColumnDescriptor: unsupported formats only!" );
482  return ODataAccessDescriptor();
483  }
484 
485 
487  {
488  const sal_Unicode cSeparator(11);
489  const OUString sSeparator(&cSeparator, 1);
490 
491  for ( const Any& rSelRow : _rSelRows )
492  {
493  sal_Int32 nSelectedRow( 0 );
494  OSL_VERIFY( rSelRow >>= nSelectedRow );
495 
496  m_sCompatibleObjectDescription += OUString::number(nSelectedRow);
497  m_sCompatibleObjectDescription += sSeparator;
498  }
499  }
500 
501 
503  {
505  }
506 
507  void ODataAccessObjectTransferable::construct( const OUString& _rDatasource
508  ,const OUString& _rConnectionResource
509  ,const sal_Int32 _nCommandType
510  ,const OUString& _rCommand
511  ,const Reference< XConnection >& _rxConnection
512  ,bool _bAddCommand
513  ,const OUString& _sActiveCommand)
514  {
515  m_aDescriptor.setDataSource(_rDatasource);
516  // build the descriptor (the property sequence)
517  if ( !_rConnectionResource.isEmpty() )
519  if ( _rxConnection.is() )
523 
524  // extract the single values from the sequence
525 
526  OUString sObjectName = _rCommand;
527 
528  // for compatibility: create a string which can be used for the SotClipboardFormatId::SBA_DATAEXCHANGE format
529 
530  bool bTreatAsStatement = (CommandType::COMMAND == _nCommandType);
531  // statements are - in this old and ugly format - described as queries
532 
533  const sal_Unicode cSeparator = u'\x000B';
534  const OUString sSeparator(&cSeparator, 1);
535 
536  const sal_Unicode cTableMark = '1';
537  const sal_Unicode cQueryMark = '0';
538 
539  // build the descriptor string
540  m_sCompatibleObjectDescription += _rDatasource;
541  m_sCompatibleObjectDescription += sSeparator;
542  m_sCompatibleObjectDescription += bTreatAsStatement ? OUString() : sObjectName;
543  m_sCompatibleObjectDescription += sSeparator;
544  switch (_nCommandType)
545  {
546  case CommandType::TABLE:
547  m_sCompatibleObjectDescription += OUString(&cTableMark, 1);
548  break;
549  case CommandType::QUERY:
550  m_sCompatibleObjectDescription += OUString(&cQueryMark, 1);
551  break;
552  case CommandType::COMMAND:
553  m_sCompatibleObjectDescription += OUString(&cQueryMark, 1);
554  // think of it as a query
555  break;
556  }
557  m_sCompatibleObjectDescription += sSeparator;
558  m_sCompatibleObjectDescription += _bAddCommand ? _sActiveCommand : OUString();
559  m_sCompatibleObjectDescription += sSeparator;
560  }
561 
563  {
564  }
565 
566  void OMultiColumnTransferable::setDescriptors(const Sequence< PropertyValue >& rDescriptors)
567  {
568  ClearFormats();
569  m_aDescriptors = rDescriptors;
570  }
571 
573  {
574  static SotClipboardFormatId s_nFormat = static_cast<SotClipboardFormatId>(-1);
575  if (static_cast<SotClipboardFormatId>(-1) == s_nFormat)
576  {
577  s_nFormat = SotExchange::RegisterFormatName("application/x-openoffice;windows_formatname=\"dbaccess.MultipleColumnDescriptorTransfer\"");
578  OSL_ENSURE(static_cast<SotClipboardFormatId>(-1) != s_nFormat, "OColumnTransferable::getDescriptorFormatId: bad exchange id!");
579  }
580  return s_nFormat;
581  }
582 
584  {
586  }
587 
588  bool OMultiColumnTransferable::GetData( const DataFlavor& _rFlavor, const OUString& /*rDestDoc*/ )
589  {
590  const SotClipboardFormatId nFormatId = SotExchange::GetFormat(_rFlavor);
591  if (nFormatId == getDescriptorFormatId())
592  {
593  return SetAny( makeAny( m_aDescriptors ) );
594  }
595 
596  return false;
597  }
598 
600  {
601  const SotClipboardFormatId nFormatId = getDescriptorFormatId();
602  return std::all_of(_rFlavors.begin(), _rFlavors.end(),
603  [&nFormatId](const DataFlavorEx& rCheck) { return nFormatId == rCheck.mnSotId; });
604  }
605 
607  {
608  Sequence< PropertyValue > aList;
609  if (_rData.HasFormat(getDescriptorFormatId()))
610  {
611  // extract the any from the transferable
612  DataFlavor aFlavor;
613  bool bSuccess =
615  OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
616 
617  _rData.GetAny(aFlavor, OUString()) >>= aList;
618  } // if (_rData.HasFormat(getDescriptorFormatId()))
619  return aList;
620  }
621 
623  {
624  m_aDescriptors.realloc(0);
625  }
626 }
627 
628 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setDescriptors(const css::uno::Sequence< css::beans::PropertyValue > &rDescriptors)
static SotClipboardFormatId RegisterFormatName(const OUString &rName)
ODataAccessDescriptor m_aDescriptor
css::uno::Any GetAny(SotClipboardFormatId nFormat, const OUString &rDestDoc) const
void setDataSource(const OUString &_sDataSourceNameOrLocation)
set the data source name, if it is not file URL
#define FM_PROP_COMMAND
Definition: fmprop.hxx:117
::std::vector< DataFlavorEx > DataFlavorExVector
css::uno::Sequence< css::beans::PropertyValue > m_aDescriptors
void setDescriptor(const ODataAccessDescriptor &rDescriptor)
construct the transferable from a data access descriptor
Definition: dbaexchange.cxx:50
css::uno::Sequence< css::beans::PropertyValue > const & createPropertyValueSequence()
returns the descriptor as property value sequence
bool HasFormat(SotClipboardFormatId nFormat) const
void AddFormat(SotClipboardFormatId nFormat)
sal_uInt16 sal_Unicode
OColumnTransferable(ColumnTransferFormatFlags nFormats)
Definition: dbaexchange.cxx:45
SVX_DLLPRIVATE void construct(const OUString &_rDatasourceOrLocation, const OUString &_rConnectionResource, const sal_Int32 _nCommandType, const OUString &_rCommand, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection, bool _bAddCommand, const OUString &_sActiveCommand)
ODataAccessObjectTransferable(const OUString &_rDatasourceOrLocation, const sal_Int32 _nCommandType, const OUString &_rCommand, const css::uno::Reference< css::sdbc::XConnection > &_rxConnection)
should be used copying and the connection is needed.
static bool extractColumnDescriptor(const TransferableDataHelper &_rData, OUString &_rDatasource, OUString &_rDatabaseLocation, OUString &_rConnectionResource, sal_Int32 &_nCommandType, OUString &_rCommand, OUString &_rFieldName)
extracts a column descriptor from the transferable given
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
SotClipboardFormatId
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
static bool canExtractColumnDescriptor(const DataFlavorExVector &_rFlavors, ColumnTransferFormatFlags _nFormats)
checks whether or not a column descriptor can be extracted from the data flavor vector given ...
#define FM_PROP_URL
Definition: fmprop.hxx:127
SVX_DLLPRIVATE void implConstruct(const OUString &_rDatasource, const OUString &_rConnectionResource, const sal_Int32 _nCommandType, const OUString &_rCommand, const OUString &_rFieldName)
void clear()
empties the descriptor
static bool canExtractObjectDescriptor(const DataFlavorExVector &_rFlavors)
checks whether or not an object descriptor can be extracted from the data flavor vector given ...
#define FM_PROP_ESCAPE_PROCESSING
Definition: fmprop.hxx:122
ColumnTransferFormatFlags const m_nFormatFlags
float u
virtual void AddSupportedFormats() override
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
static SotClipboardFormatId getDescriptorFormatId()
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
class encapsulating the css::sdb::DataAccessDescriptor service.
bool has(DataAccessDescriptorProperty _eWhich) const
checks whether or not a given property is present in the descriptor
#define FM_PROP_ACTIVE_CONNECTION
Definition: fmprop.hxx:128
static bool canExtractDescriptor(const DataFlavorExVector &_rFlavors)
checks whether or not an object descriptor can be extracted from the data flavor vector given ...
#define FM_PROP_ACTIVECOMMAND
Definition: fmprop.hxx:125
#define FM_PROP_COMMANDTYPE
Definition: fmprop.hxx:118
ODataAccessDescriptor m_aDescriptor
virtual void AddSupportedFormats() override
virtual void AddSupportedFormats() override
virtual void ObjectReleased() override
bool SetAny(const css::uno::Any &rAny)
static SotClipboardFormatId getDescriptorFormatId()
void addCompatibleSelectionDescription(const css::uno::Sequence< css::uno::Any > &_rSelRows)
static ODataAccessDescriptor extractObjectDescriptor(const TransferableDataHelper &_rData)
extracts an object descriptor from the transferable given
static css::uno::Sequence< css::beans::PropertyValue > extractDescriptor(const TransferableDataHelper &_rData)
extracts an object descriptor from the transferable given
bool SetString(const OUString &rString, const css::datatransfer::DataFlavor &rFlavor)
virtual void ObjectReleased() override
ColumnTransferFormatFlags
Definition: dbaexchange.hxx:36
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)