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/beans/XPropertySet.hpp>
23 #include <com/sun/star/sdb/CommandType.hpp>
24 #include <com/sun/star/sdbc/XConnection.hpp>
25 #include <com/sun/star/sdbcx/XTablesSupplier.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 
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 += OUStringChar(cCommandType);
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 
339  {
340  }
341 
343  const OUString& _rDatasource,
344  const sal_Int32 _nCommandType,
345  const OUString& _rCommand)
346  {
347  construct(_rDatasource,OUString(),_nCommandType,_rCommand,nullptr,(CommandType::COMMAND == _nCommandType),_rCommand);
348  }
349 
351  const OUString& _rDatasource,
352  const sal_Int32 _nCommandType,
353  const OUString& _rCommand,
354  const Reference< XConnection >& _rxConnection)
355  {
356  OSL_ENSURE(_rxConnection.is(), "Wrong Update used.!");
357  construct(_rDatasource,OUString(),_nCommandType,_rCommand,_rxConnection,(CommandType::COMMAND == _nCommandType),_rCommand);
358  }
359 
361  {
362  // collect some properties of the form
363  OUString sDatasourceName,sConnectionResource;
364  sal_Int32 nObjectType = CommandType::COMMAND;
365  OUString sObjectName;
366  Reference< XConnection > xConnection;
367  try
368  {
369  _rxLivingForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nObjectType;
370  _rxLivingForm->getPropertyValue(FM_PROP_COMMAND) >>= sObjectName;
371  _rxLivingForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasourceName;
372  _rxLivingForm->getPropertyValue(FM_PROP_URL) >>= sConnectionResource;
373  _rxLivingForm->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConnection;
374  }
375  catch(Exception&)
376  {
377  OSL_FAIL("ODataAccessObjectTransferable::ODataAccessObjectTransferable: could not collect essential form attributes !");
378  return;
379  }
380 
381  // check if the SQL-statement is modified
382  OUString sCompleteStatement;
383  try
384  {
385  _rxLivingForm->getPropertyValue(FM_PROP_ACTIVECOMMAND) >>= sCompleteStatement;
386  }
387  catch (const Exception&)
388  {
389  OSL_FAIL("ODataAccessObjectTransferable::ODataAccessObjectTransferable: could not collect essential form attributes (part two) !");
390  return;
391  }
392 
393  construct( sDatasourceName
394  ,sConnectionResource
395  ,nObjectType
396  ,sObjectName,xConnection
397  ,CommandType::QUERY != nObjectType
398  ,sCompleteStatement);
399  }
400 
401 
403  {
404  sal_Int32 nObjectType = CommandType::COMMAND;
406  switch (nObjectType)
407  {
408  case CommandType::TABLE:
409  AddFormat(SotClipboardFormatId::DBACCESS_TABLE);
410  break;
411  case CommandType::QUERY:
412  AddFormat(SotClipboardFormatId::DBACCESS_QUERY);
413  break;
414  case CommandType::COMMAND:
415  AddFormat(SotClipboardFormatId::DBACCESS_COMMAND);
416  break;
417  }
418 
419  if (!m_sCompatibleObjectDescription.isEmpty())
420  AddFormat(SotClipboardFormatId::SBA_DATAEXCHANGE);
421  }
422 
423 
424  bool ODataAccessObjectTransferable::GetData( const DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
425  {
426  SotClipboardFormatId nFormat = SotExchange::GetFormat(rFlavor);
427  switch (nFormat)
428  {
429  case SotClipboardFormatId::DBACCESS_TABLE:
430  case SotClipboardFormatId::DBACCESS_QUERY:
431  case SotClipboardFormatId::DBACCESS_COMMAND:
433 
434  case SotClipboardFormatId::SBA_DATAEXCHANGE:
435  return SetString(m_sCompatibleObjectDescription, rFlavor);
436  default: break;
437  }
438  return false;
439  }
440 
441 
443  {
444  return std::any_of(_rFlavors.begin(), _rFlavors.end(),
445  [](const DataFlavorEx& rCheck) {
446  return SotClipboardFormatId::DBACCESS_TABLE == rCheck.mnSotId
447  || SotClipboardFormatId::DBACCESS_QUERY == rCheck.mnSotId
448  || SotClipboardFormatId::DBACCESS_COMMAND == rCheck.mnSotId;
449  });
450  }
451 
452 
454  {
455  SotClipboardFormatId nKnownFormatId = SotClipboardFormatId::NONE;
456  if ( _rData.HasFormat( SotClipboardFormatId::DBACCESS_TABLE ) )
457  nKnownFormatId = SotClipboardFormatId::DBACCESS_TABLE;
458  if ( _rData.HasFormat( SotClipboardFormatId::DBACCESS_QUERY ) )
459  nKnownFormatId = SotClipboardFormatId::DBACCESS_QUERY;
460  if ( _rData.HasFormat( SotClipboardFormatId::DBACCESS_COMMAND ) )
461  nKnownFormatId = SotClipboardFormatId::DBACCESS_COMMAND;
462 
463  if (SotClipboardFormatId::NONE != nKnownFormatId)
464  {
465  // extract the any from the transferable
466  DataFlavor aFlavor;
467  bool bSuccess =
468  SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
469  OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
470 
471  Any aDescriptor = _rData.GetAny(aFlavor, OUString());
472 
473  // extract the property value sequence
474  Sequence< PropertyValue > aDescriptorProps;
475  bSuccess = aDescriptor >>= aDescriptorProps;
476  OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid clipboard format!");
477 
478  // build the real descriptor
479  return ODataAccessDescriptor(aDescriptorProps);
480  }
481 
482  OSL_FAIL( "OColumnTransferable::extractColumnDescriptor: unsupported formats only!" );
483  return ODataAccessDescriptor();
484  }
485 
486 
488  {
489  const sal_Unicode cSeparator(11);
490  const OUString sSeparator(&cSeparator, 1);
491 
492  for ( const Any& rSelRow : _rSelRows )
493  {
494  sal_Int32 nSelectedRow( 0 );
495  OSL_VERIFY( rSelRow >>= nSelectedRow );
496 
497  m_sCompatibleObjectDescription += OUString::number(nSelectedRow);
498  m_sCompatibleObjectDescription += sSeparator;
499  }
500  }
501 
502 
504  {
506  }
507 
508  void ODataAccessObjectTransferable::construct( const OUString& _rDatasource
509  ,const OUString& _rConnectionResource
510  ,const sal_Int32 _nCommandType
511  ,const OUString& _rCommand
512  ,const Reference< XConnection >& _rxConnection
513  ,bool _bAddCommand
514  ,const OUString& _sActiveCommand)
515  {
516  m_aDescriptor.setDataSource(_rDatasource);
517  // build the descriptor (the property sequence)
518  if ( !_rConnectionResource.isEmpty() )
520  if ( _rxConnection.is() )
524 
525  // extract the single values from the sequence
526 
527  OUString sObjectName = _rCommand;
528 
529  // for compatibility: create a string which can be used for the SotClipboardFormatId::SBA_DATAEXCHANGE format
530 
531  bool bTreatAsStatement = (CommandType::COMMAND == _nCommandType);
532  // statements are - in this old and ugly format - described as queries
533 
534  const sal_Unicode cSeparator = u'\x000B';
535  const OUString sSeparator(&cSeparator, 1);
536 
537  const sal_Unicode cTableMark = '1';
538  const sal_Unicode cQueryMark = '0';
539 
540  // build the descriptor string
541  m_sCompatibleObjectDescription += _rDatasource;
542  m_sCompatibleObjectDescription += sSeparator;
543  m_sCompatibleObjectDescription += bTreatAsStatement ? OUString() : sObjectName;
544  m_sCompatibleObjectDescription += sSeparator;
545  switch (_nCommandType)
546  {
547  case CommandType::TABLE:
548  m_sCompatibleObjectDescription += OUStringChar(cTableMark);
549  break;
550  case CommandType::QUERY:
551  m_sCompatibleObjectDescription += OUStringChar(cQueryMark);
552  break;
553  case CommandType::COMMAND:
554  m_sCompatibleObjectDescription += OUStringChar(cQueryMark);
555  // think of it as a query
556  break;
557  }
558  m_sCompatibleObjectDescription += sSeparator;
559  m_sCompatibleObjectDescription += _bAddCommand ? _sActiveCommand : OUString();
560  m_sCompatibleObjectDescription += sSeparator;
561  }
562 
564  {
565  }
566 
567  void OMultiColumnTransferable::setDescriptors(const Sequence< PropertyValue >& rDescriptors)
568  {
569  ClearFormats();
570  m_aDescriptors = rDescriptors;
571  }
572 
574  {
575  static SotClipboardFormatId s_nFormat = static_cast<SotClipboardFormatId>(-1);
576  if (static_cast<SotClipboardFormatId>(-1) == s_nFormat)
577  {
578  s_nFormat = SotExchange::RegisterFormatName("application/x-openoffice;windows_formatname=\"dbaccess.MultipleColumnDescriptorTransfer\"");
579  OSL_ENSURE(static_cast<SotClipboardFormatId>(-1) != s_nFormat, "OColumnTransferable::getDescriptorFormatId: bad exchange id!");
580  }
581  return s_nFormat;
582  }
583 
585  {
587  }
588 
589  bool OMultiColumnTransferable::GetData( const DataFlavor& _rFlavor, const OUString& /*rDestDoc*/ )
590  {
591  const SotClipboardFormatId nFormatId = SotExchange::GetFormat(_rFlavor);
592  if (nFormatId == getDescriptorFormatId())
593  {
594  return SetAny( makeAny( m_aDescriptors ) );
595  }
596 
597  return false;
598  }
599 
601  {
602  const SotClipboardFormatId nFormatId = getDescriptorFormatId();
603  return std::all_of(_rFlavors.begin(), _rFlavors.end(),
604  [&nFormatId](const DataFlavorEx& rCheck) { return nFormatId == rCheck.mnSotId; });
605  }
606 
608  {
609  Sequence< PropertyValue > aList;
610  if (_rData.HasFormat(getDescriptorFormatId()))
611  {
612  // extract the any from the transferable
613  DataFlavor aFlavor;
614  bool bSuccess =
616  OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
617 
618  _rData.GetAny(aFlavor, OUString()) >>= aList;
619  } // if (_rData.HasFormat(getDescriptorFormatId()))
620  return aList;
621  }
622 
624  {
625  m_aDescriptors.realloc(0);
626  }
627 }
628 
629 /* 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
ColumnTransferFormatFlags m_nFormatFlags
css::uno::Sequence< css::beans::PropertyValue > m_aDescriptors
#define FM_PROP_DATASOURCE
Definition: fmprop.hxx:78
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)
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
float u
virtual void AddSupportedFormats() override
virtual bool GetData(const css::datatransfer::DataFlavor &rFlavor, const OUString &rDestDoc) override
void Update(const OUString &_rDatasource, 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 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)