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