Kaydet (Commit) f7855e85 authored tarafından Jens-Heiner Rechtien's avatar Jens-Heiner Rechtien

INTEGRATION: CWS insight01 (1.12.214); FILE MERGED

2004/02/20 11:17:55 oj 1.12.214.1: #i25414# extend the datadescriptor for database location and connection resource
üst 4974b85a
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: dbaexchange.cxx,v $ * $RCSfile: dbaexchange.cxx,v $
* *
* $Revision: 1.12 $ * $Revision: 1.13 $
* *
* last change: $Author: vg $ $Date: 2003-04-15 17:30:26 $ * last change: $Author: hr $ $Date: 2004-08-02 16:42:17 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -95,6 +95,9 @@ ...@@ -95,6 +95,9 @@
#ifndef _SVX_FMPROP_HRC #ifndef _SVX_FMPROP_HRC
#include "fmprop.hrc" #include "fmprop.hrc"
#endif #endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
//........................................................................ //........................................................................
namespace svx namespace svx
...@@ -116,11 +119,15 @@ namespace svx ...@@ -116,11 +119,15 @@ namespace svx
//= OColumnTransferable //= OColumnTransferable
//==================================================================== //====================================================================
//-------------------------------------------------------------------- //--------------------------------------------------------------------
OColumnTransferable::OColumnTransferable(const ::rtl::OUString& _rDatasource, const sal_Int32 _nCommandType, OColumnTransferable::OColumnTransferable(const ::rtl::OUString& _rDatasource
const ::rtl::OUString& _rCommand, const ::rtl::OUString& _rFieldName, sal_Int32 _nFormats) ,const ::rtl::OUString& _rConnectionResource
,const sal_Int32 _nCommandType
,const ::rtl::OUString& _rCommand
,const ::rtl::OUString& _rFieldName
,sal_Int32 _nFormats)
:m_nFormatFlags(_nFormats) :m_nFormatFlags(_nFormats)
{ {
implConstruct(_rDatasource, _nCommandType, _rCommand, _rFieldName); implConstruct(_rDatasource,_rConnectionResource,_nCommandType, _rCommand, _rFieldName);
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
...@@ -133,7 +140,7 @@ namespace svx ...@@ -133,7 +140,7 @@ namespace svx
// collect the necessary information from the form // collect the necessary information from the form
::rtl::OUString sCommand; ::rtl::OUString sCommand;
sal_Int32 nCommandType = CommandType::TABLE; sal_Int32 nCommandType = CommandType::TABLE;
::rtl::OUString sDatasource; ::rtl::OUString sDatasource,sURL;
sal_Bool bTryToParse = sal_True; sal_Bool bTryToParse = sal_True;
try try
...@@ -141,6 +148,7 @@ namespace svx ...@@ -141,6 +148,7 @@ namespace svx
_rxForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nCommandType; _rxForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nCommandType;
_rxForm->getPropertyValue(FM_PROP_COMMAND) >>= sCommand; _rxForm->getPropertyValue(FM_PROP_COMMAND) >>= sCommand;
_rxForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasource; _rxForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasource;
_rxForm->getPropertyValue(FM_PROP_URL) >>= sURL;
bTryToParse = ::cppu::any2bool(_rxForm->getPropertyValue(FM_PROP_ESCAPE_PROCESSING)); bTryToParse = ::cppu::any2bool(_rxForm->getPropertyValue(FM_PROP_ESCAPE_PROCESSING));
} }
catch(Exception&) catch(Exception&)
...@@ -188,7 +196,7 @@ namespace svx ...@@ -188,7 +196,7 @@ namespace svx
} }
} }
implConstruct(sDatasource, nCommandType, sCommand, _rFieldName); implConstruct(sDatasource, sURL,nCommandType, sCommand, _rFieldName);
if ((m_nFormatFlags & CTF_COLUMN_DESCRIPTOR) == CTF_COLUMN_DESCRIPTOR) if ((m_nFormatFlags & CTF_COLUMN_DESCRIPTOR) == CTF_COLUMN_DESCRIPTOR)
{ {
...@@ -212,8 +220,11 @@ namespace svx ...@@ -212,8 +220,11 @@ namespace svx
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
void OColumnTransferable::implConstruct(const ::rtl::OUString& _rDatasource, const sal_Int32 _nCommandType, void OColumnTransferable::implConstruct( const ::rtl::OUString& _rDatasource
const ::rtl::OUString& _rCommand, const ::rtl::OUString& _rFieldName) ,const ::rtl::OUString& _rConnectionResource
,const sal_Int32 _nCommandType
,const ::rtl::OUString& _rCommand
, const ::rtl::OUString& _rFieldName)
{ {
const sal_Unicode cSeparator = sal_Unicode(11); const sal_Unicode cSeparator = sal_Unicode(11);
const ::rtl::OUString sSeparator(&cSeparator, 1); const ::rtl::OUString sSeparator(&cSeparator, 1);
...@@ -244,7 +255,10 @@ namespace svx ...@@ -244,7 +255,10 @@ namespace svx
m_aDescriptor.clear(); m_aDescriptor.clear();
if ((m_nFormatFlags & CTF_COLUMN_DESCRIPTOR) == CTF_COLUMN_DESCRIPTOR) if ((m_nFormatFlags & CTF_COLUMN_DESCRIPTOR) == CTF_COLUMN_DESCRIPTOR)
{ {
m_aDescriptor[daDataSource] <<= _rDatasource; m_aDescriptor.setDataSource(_rDatasource);
if ( _rConnectionResource.getLength() )
m_aDescriptor[daConnectionResource] <<= _rConnectionResource;
m_aDescriptor[daCommand] <<= _rCommand; m_aDescriptor[daCommand] <<= _rCommand;
m_aDescriptor[daCommandType] <<= _nCommandType; m_aDescriptor[daCommandType] <<= _nCommandType;
m_aDescriptor[daColumnName] <<= _rFieldName; m_aDescriptor[daColumnName] <<= _rFieldName;
...@@ -332,14 +346,20 @@ namespace svx ...@@ -332,14 +346,20 @@ namespace svx
} }
// only the old (compatible) format exists -> use the other extract method ... // only the old (compatible) format exists -> use the other extract method ...
::rtl::OUString sDatasource, sCommand, sFieldName; ::rtl::OUString sDatasource, sCommand, sFieldName,sDatabaseLocation,sConnectionResource;
sal_Int32 nCommandType = CommandType::COMMAND; sal_Int32 nCommandType = CommandType::COMMAND;
ODataAccessDescriptor aDescriptor; ODataAccessDescriptor aDescriptor;
if (extractColumnDescriptor(_rData, sDatasource, nCommandType, sCommand, sFieldName)) if (extractColumnDescriptor(_rData, sDatasource, sDatabaseLocation,sConnectionResource,nCommandType, sCommand, sFieldName))
{ {
// and build an own descriptor // and build an own descriptor
aDescriptor[daDataSource] <<= sDatasource; if ( sDatasource.getLength() )
aDescriptor[daDataSource] <<= sDatasource;
if ( sDatabaseLocation.getLength() )
aDescriptor[daDatabaseLocation] <<= sDatabaseLocation;
if ( sConnectionResource.getLength() )
aDescriptor[daConnectionResource] <<= sConnectionResource;
aDescriptor[daCommand] <<= sCommand; aDescriptor[daCommand] <<= sCommand;
aDescriptor[daCommandType] <<= nCommandType; aDescriptor[daCommandType] <<= nCommandType;
aDescriptor[daColumnName] <<= sFieldName; aDescriptor[daColumnName] <<= sFieldName;
...@@ -348,16 +368,27 @@ namespace svx ...@@ -348,16 +368,27 @@ namespace svx
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
sal_Bool OColumnTransferable::extractColumnDescriptor(const TransferableDataHelper& _rData, sal_Bool OColumnTransferable::extractColumnDescriptor(const TransferableDataHelper& _rData
::rtl::OUString& _rDatasource, sal_Int32& _nCommandType, ::rtl::OUString& _rCommand, ::rtl::OUString& _rFieldName) ,::rtl::OUString& _rDatasource
,::rtl::OUString& _rDatabaseLocation
,::rtl::OUString& _rConnectionResource
,sal_Int32& _nCommandType
,::rtl::OUString& _rCommand
,::rtl::OUString& _rFieldName)
{ {
if (_rData.HasFormat(getDescriptorFormatId())) if ( _rData.HasFormat(getDescriptorFormatId()) )
{ {
ODataAccessDescriptor aDescriptor = extractColumnDescriptor(_rData); ODataAccessDescriptor aDescriptor = extractColumnDescriptor(_rData);
aDescriptor[daDataSource] >>= _rDatasource; if ( aDescriptor.has(daDataSource) )
aDescriptor[daCommand] >>= _rCommand; aDescriptor[daDataSource] >>= _rDatasource;
aDescriptor[daCommandType] >>= _nCommandType; if ( aDescriptor.has(daDatabaseLocation) )
aDescriptor[daColumnName] >>= _rFieldName; aDescriptor[daDatabaseLocation] >>= _rDatabaseLocation;
if ( aDescriptor.has(daConnectionResource) )
aDescriptor[daConnectionResource] >>= _rConnectionResource;
aDescriptor[daCommand] >>= _rCommand;
aDescriptor[daCommandType] >>= _nCommandType;
aDescriptor[daColumnName] >>= _rFieldName;
return sal_True; return sal_True;
} }
...@@ -406,29 +437,31 @@ namespace svx ...@@ -406,29 +437,31 @@ namespace svx
//= ODataAccessObjectTransferable //= ODataAccessObjectTransferable
//==================================================================== //====================================================================
ODataAccessObjectTransferable::ODataAccessObjectTransferable( ODataAccessObjectTransferable::ODataAccessObjectTransferable(
const ::rtl::OUString& _rDatasource, const ::rtl::OUString& _rDatasource
const sal_Int32 _nCommandType, ,const ::rtl::OUString& _rConnectionResource
const ::rtl::OUString& _rCommand ,const sal_Int32 _nCommandType
,const ::rtl::OUString& _rCommand
) )
{ {
construct(_rDatasource,_nCommandType,_rCommand,NULL,(CommandType::COMMAND == _nCommandType),_rCommand); construct(_rDatasource,_rConnectionResource,_nCommandType,_rCommand,NULL,(CommandType::COMMAND == _nCommandType),_rCommand);
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
ODataAccessObjectTransferable::ODataAccessObjectTransferable( ODataAccessObjectTransferable::ODataAccessObjectTransferable(
const ::rtl::OUString& _rDatasource, const ::rtl::OUString& _rDatasource
const sal_Int32 _nCommandType, ,const ::rtl::OUString& _rConnectionResource
const ::rtl::OUString& _rCommand, ,const sal_Int32 _nCommandType
const Reference< XConnection >& _rxConnection) ,const ::rtl::OUString& _rCommand
,const Reference< XConnection >& _rxConnection)
{ {
OSL_ENSURE(_rxConnection.is(),"Wrong ctor used.!"); OSL_ENSURE(_rxConnection.is(),"Wrong ctor used.!");
construct(_rDatasource,_nCommandType,_rCommand,_rxConnection,(CommandType::COMMAND == _nCommandType),_rCommand); construct(_rDatasource,_rConnectionResource,_nCommandType,_rCommand,_rxConnection,(CommandType::COMMAND == _nCommandType),_rCommand);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
ODataAccessObjectTransferable::ODataAccessObjectTransferable(const Reference< XPropertySet >& _rxLivingForm) ODataAccessObjectTransferable::ODataAccessObjectTransferable(const Reference< XPropertySet >& _rxLivingForm)
{ {
// collect some properties of the form // collect some properties of the form
::rtl::OUString sDatasourceName; ::rtl::OUString sDatasourceName,sConnectionResource;
sal_Int32 nObjectType = CommandType::COMMAND; sal_Int32 nObjectType = CommandType::COMMAND;
::rtl::OUString sObjectName; ::rtl::OUString sObjectName;
Reference< XConnection > xConnection; Reference< XConnection > xConnection;
...@@ -437,6 +470,7 @@ namespace svx ...@@ -437,6 +470,7 @@ namespace svx
_rxLivingForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nObjectType; _rxLivingForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nObjectType;
_rxLivingForm->getPropertyValue(FM_PROP_COMMAND) >>= sObjectName; _rxLivingForm->getPropertyValue(FM_PROP_COMMAND) >>= sObjectName;
_rxLivingForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasourceName; _rxLivingForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasourceName;
_rxLivingForm->getPropertyValue(FM_PROP_URL) >>= sConnectionResource;
_rxLivingForm->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConnection; _rxLivingForm->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConnection;
} }
catch(Exception&) catch(Exception&)
...@@ -485,6 +519,7 @@ namespace svx ...@@ -485,6 +519,7 @@ namespace svx
} }
construct( sDatasourceName construct( sDatasourceName
,sConnectionResource
,nObjectType ,nObjectType
,sObjectName,xConnection ,sObjectName,xConnection
,!((CommandType::QUERY == nObjectType) && !bHasFilterOrSort) ,!((CommandType::QUERY == nObjectType) && !bHasFilterOrSort)
...@@ -622,25 +657,28 @@ namespace svx ...@@ -622,25 +657,28 @@ namespace svx
m_aDescriptor.clear(); m_aDescriptor.clear();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ODataAccessObjectTransferable::construct( const ::rtl::OUString& _rDatasource, void ODataAccessObjectTransferable::construct( const ::rtl::OUString& _rDatasource
const sal_Int32 _nCommandType, ,const ::rtl::OUString& _rConnectionResource
const ::rtl::OUString& _rCommand, ,const sal_Int32 _nCommandType
const Reference< XConnection >& _rxConnection, ,const ::rtl::OUString& _rCommand
sal_Bool _bAddCommand, ,const Reference< XConnection >& _rxConnection
const ::rtl::OUString& _sActiveCommand) ,sal_Bool _bAddCommand
,const ::rtl::OUString& _sActiveCommand)
{ {
m_aDescriptor.setDataSource(_rDatasource);
// build the descriptor (the property sequence) // build the descriptor (the property sequence)
m_aDescriptor[daDataSource] <<= _rDatasource; if ( _rConnectionResource.getLength() )
m_aDescriptor[daConnectionResource] <<= _rConnectionResource;
if ( _rxConnection.is() ) if ( _rxConnection.is() )
m_aDescriptor[daConnection] <<= _rxConnection; m_aDescriptor[daConnection] <<= _rxConnection;
m_aDescriptor[daCommand] <<= _rCommand; m_aDescriptor[daCommand] <<= _rCommand;
m_aDescriptor[daCommandType] <<= _nCommandType; m_aDescriptor[daCommandType] <<= _nCommandType;
// extract the single values from the sequence // extract the single values from the sequence
::rtl::OUString sDatasourceName;
::rtl::OUString sObjectName; ::rtl::OUString sObjectName;
sal_Bool bEscapeProcessing = sal_True; sal_Bool bEscapeProcessing = sal_True;
sDatasourceName = _rDatasource; ::rtl::OUString sDatasourceName = _rDatasource;
sObjectName = _rCommand; sObjectName = _rCommand;
// for compatibility: create a string which can be used for the SOT_FORMATSTR_ID_SBA_DATAEXCHANGE format // for compatibility: create a string which can be used for the SOT_FORMATSTR_ID_SBA_DATAEXCHANGE format
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment