summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/misc/databaseobjectview.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/misc/databaseobjectview.cxx')
-rw-r--r--dbaccess/source/ui/misc/databaseobjectview.cxx129
1 files changed, 46 insertions, 83 deletions
diff --git a/dbaccess/source/ui/misc/databaseobjectview.cxx b/dbaccess/source/ui/misc/databaseobjectview.cxx
index 5d0df2d69bcd..68f702b11d75 100644
--- a/dbaccess/source/ui/misc/databaseobjectview.cxx
+++ b/dbaccess/source/ui/misc/databaseobjectview.cxx
@@ -46,7 +46,6 @@
#include <comphelper/extract.hxx>
#include <comphelper/sequence.hxx>
-#include <comphelper/namedvaluecollection.hxx>
#include <connectivity/dbtools.hxx>
#include <osl/diagnose.h>
#include <toolkit/helper/vclunohelper.hxx>
@@ -75,11 +74,11 @@ namespace dbaui
const Reference< XDatabaseDocumentUI >& _rxApplication,
const Reference< XFrame >& _rxParentFrame,
const ::rtl::OUString& _rComponentURL )
- :m_xORB ( _rxORB )
- ,m_xParentFrame ( _rxParentFrame )
- ,m_xFrameLoader ( )
- ,m_xApplication ( _rxApplication )
- ,m_sComponentURL( _rComponentURL )
+ :m_xORB ( _rxORB )
+ ,m_xParentFrame ( _rxParentFrame )
+ ,m_xFrameLoader ( )
+ ,m_xApplication ( _rxApplication )
+ ,m_sComponentURL ( _rComponentURL )
{
OSL_ENSURE( m_xORB.is(), "DatabaseObjectView::DatabaseObjectView: invalid service factory!" );
OSL_ENSURE( m_xApplication.is(), "DatabaseObjectView::DatabaseObjectView: invalid connection!" );
@@ -95,32 +94,33 @@ namespace dbaui
}
//----------------------------------------------------------------------
- Reference< XComponent > DatabaseObjectView::createNew(const Reference< XDataSource >& _xDataSource )
+ Reference< XComponent > DatabaseObjectView::createNew( const Reference< XDataSource >& _xDataSource, const ::comphelper::NamedValueCollection& i_rDispatchArgs )
{
- return doCreateView( makeAny( _xDataSource ), ::rtl::OUString(), Sequence< PropertyValue >() );
+ return doCreateView( makeAny( _xDataSource ), ::rtl::OUString(), i_rDispatchArgs );
}
//----------------------------------------------------------------------
- Reference< XComponent > DatabaseObjectView::openExisting( const Any& _rDataSource, const ::rtl::OUString& _rName, const Sequence< PropertyValue >& _rArgs )
+ Reference< XComponent > DatabaseObjectView::openExisting( const Any& _rDataSource, const ::rtl::OUString& _rName,
+ const ::comphelper::NamedValueCollection& i_rDispatchArgs )
{
- return doCreateView( _rDataSource, _rName, _rArgs );
+ return doCreateView( _rDataSource, _rName, i_rDispatchArgs );
}
//----------------------------------------------------------------------
Reference< XComponent > DatabaseObjectView::doCreateView( const Any& _rDataSource, const ::rtl::OUString& _rObjectName,
- const Sequence< PropertyValue >& _rCreationArgs )
+ const ::comphelper::NamedValueCollection& i_rCreationArgs )
{
- Sequence< PropertyValue > aDispatchArgs;
- fillDispatchArgs( aDispatchArgs, _rDataSource, _rObjectName );
+ ::comphelper::NamedValueCollection aDispatchArgs;
- ::comphelper::NamedValueCollection aDispArgs( aDispatchArgs );
- aDispArgs.merge( _rCreationArgs, true );
+ aDispatchArgs.merge( i_rCreationArgs, false ); // false => do not overwrite
+ fillDispatchArgs( aDispatchArgs, _rDataSource, _rObjectName );
+ aDispatchArgs.merge( i_rCreationArgs, true ); // true => do overwrite
- return doDispatch( aDispArgs.getPropertyValues() );
+ return doDispatch( aDispatchArgs );
}
//----------------------------------------------------------------------
- Reference< XComponent > DatabaseObjectView::doDispatch( const Sequence< PropertyValue >& _rArgs )
+ Reference< XComponent > DatabaseObjectView::doDispatch( const ::comphelper::NamedValueCollection& i_rDispatchArgs )
{
Reference< XComponent > xReturn;
if ( m_xORB.is() )
@@ -160,7 +160,7 @@ namespace dbaui
m_sComponentURL,
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_self")),
0,
- _rArgs
+ i_rDispatchArgs.getPropertyValues()
);
if ( !xReturn.is() )
@@ -176,29 +176,23 @@ namespace dbaui
//----------------------------------------------------------------------
void DatabaseObjectView::fillDispatchArgs(
- Sequence< PropertyValue >& _rDispatchArguments,
+ ::comphelper::NamedValueCollection& i_rDispatchArgs,
const Any& _aDataSource,
const ::rtl::OUString& /* _rName */
)
{
- sal_Int32 nPos = _rDispatchArguments.getLength();
- _rDispatchArguments.realloc( nPos + 2 );
-
::rtl::OUString sDataSource;
Reference<XDataSource> xDataSource;
if ( _aDataSource >>= sDataSource )
{
- _rDispatchArguments[nPos ].Name = PROPERTY_DATASOURCENAME;
- _rDispatchArguments[nPos++].Value <<= sDataSource;
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_DATASOURCENAME, sDataSource );
}
else if ( _aDataSource >>= xDataSource )
{
- _rDispatchArguments[nPos ].Name = PROPERTY_DATASOURCE;
- _rDispatchArguments[nPos++].Value <<= xDataSource;
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_DATASOURCE, xDataSource );
}
- _rDispatchArguments[nPos ].Name = PROPERTY_ACTIVE_CONNECTION;
- _rDispatchArguments[nPos++].Value <<= getConnection();
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ACTIVE_CONNECTION, getConnection() );
}
//======================================================================
@@ -206,48 +200,32 @@ namespace dbaui
//======================================================================
//----------------------------------------------------------------------
QueryDesigner::QueryDesigner( const Reference< XMultiServiceFactory >& _rxORB, const Reference< XDatabaseDocumentUI >& _rxApplication,
- const Reference< XFrame >& _rxParentFrame,
- bool _bCreateView, sal_Bool _bPreferSQLView )
- :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, static_cast< ::rtl::OUString >( _bCreateView ? URL_COMPONENT_VIEWDESIGN : URL_COMPONENT_QUERYDESIGN ) )
+ const Reference< XFrame >& _rxParentFrame, bool _bCreateView )
+ :DatabaseObjectView( _rxORB, _rxApplication, _rxParentFrame, _bCreateView ? URL_COMPONENT_VIEWDESIGN : URL_COMPONENT_QUERYDESIGN )
,m_nCommandType( _bCreateView ? CommandType::TABLE : CommandType::QUERY )
- ,m_bPreferSQLView( _bPreferSQLView )
{
}
//----------------------------------------------------------------------
- void QueryDesigner::fillDispatchArgs( Sequence< PropertyValue >& _rDispatchArguments, const Any& _aDataSource,
+ void QueryDesigner::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
const ::rtl::OUString& _rObjectName )
{
- DatabaseObjectView::fillDispatchArgs( _rDispatchArguments, _aDataSource, _rObjectName );
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rObjectName );
- bool bIncludeQueryName = 0 != _rObjectName.getLength();
- bool bEditViewAsSQLCommand = ( m_nCommandType == CommandType::TABLE ) && m_bPreferSQLView;
+ const bool bIncludeQueryName = 0 != _rObjectName.getLength();
+ const bool bGraphicalDesign = i_rDispatchArgs.getOrDefault( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, sal_True );
+ const bool bEditViewAsSQLCommand = ( m_nCommandType == CommandType::TABLE ) && !bGraphicalDesign;
- sal_Int32 nPos = _rDispatchArguments.getLength();
-
- sal_Int32 nNewLen = _rDispatchArguments.getLength() + 2;
- if ( bIncludeQueryName )
- ++nNewLen;
- if ( bEditViewAsSQLCommand )
- ++nNewLen;
- _rDispatchArguments.realloc( nNewLen );
-
- _rDispatchArguments[nPos ].Name = PROPERTY_GRAPHICAL_DESIGN;
- _rDispatchArguments[nPos++].Value <<= ::cppu::bool2any( !m_bPreferSQLView );
-
- _rDispatchArguments[nPos ].Name = PROPERTY_COMMAND_TYPE;
- _rDispatchArguments[nPos++].Value <<= m_nCommandType;
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND_TYPE, m_nCommandType );
if ( bIncludeQueryName )
{
- _rDispatchArguments[nPos ].Name = PROPERTY_COMMAND;
- _rDispatchArguments[nPos++].Value <<= _rObjectName;
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND, _rObjectName );
}
if ( bEditViewAsSQLCommand )
{
- _rDispatchArguments[nPos ].Name = PROPERTY_ESCAPE_PROCESSING;
- _rDispatchArguments[nPos++].Value <<= sal_Bool( sal_False );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, sal_False );
}
}
@@ -261,24 +239,20 @@ namespace dbaui
}
//----------------------------------------------------------------------
- void TableDesigner::fillDispatchArgs( Sequence< PropertyValue >& _rDispatchArguments, const Any& _aDataSource,
+ void TableDesigner::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
const ::rtl::OUString& _rObjectName )
{
- DatabaseObjectView::fillDispatchArgs( _rDispatchArguments, _aDataSource, _rObjectName );
- sal_Bool bIncludeName = 0 != _rObjectName.getLength();
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rObjectName );
- if (bIncludeName)
+ if ( 0 != _rObjectName.getLength() )
{
- sal_Int32 nPos = _rDispatchArguments.getLength();
- _rDispatchArguments.realloc(_rDispatchArguments.getLength() + 1);
- _rDispatchArguments[nPos ].Name = PROPERTY_CURRENTTABLE;
- _rDispatchArguments[nPos++].Value <<= _rObjectName;
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_CURRENTTABLE, _rObjectName );
}
}
//----------------------------------------------------------------------
Reference< XComponent > TableDesigner::doCreateView( const Any& _rDataSource, const ::rtl::OUString& _rObjectName,
- const Sequence< PropertyValue >& _rCreationArgs )
+ const ::comphelper::NamedValueCollection& i_rCreationArgs )
{
bool bIsNewDesign = ( _rObjectName.getLength() == 0 );
@@ -288,7 +262,7 @@ namespace dbaui
xDesigner = impl_getConnectionProvidedDesigner_nothrow( _rObjectName );
if ( !xDesigner.is() )
- return DatabaseObjectView::doCreateView( _rDataSource, _rObjectName, _rCreationArgs );
+ return DatabaseObjectView::doCreateView( _rDataSource, _rObjectName, i_rCreationArgs );
// try whether the designer is a dialog
Reference< XExecutableDialog > xDialog( xDesigner, UNO_QUERY_THROW );
@@ -333,10 +307,10 @@ namespace dbaui
}
//----------------------------------------------------------------------
- void ResultSetBrowser::fillDispatchArgs(Sequence< PropertyValue >& _rDispatchArguments, const Any& _aDataSource,
+ void ResultSetBrowser::fillDispatchArgs( ::comphelper::NamedValueCollection& i_rDispatchArgs, const Any& _aDataSource,
const ::rtl::OUString& _rQualifiedName)
{
- DatabaseObjectView::fillDispatchArgs( _rDispatchArguments, _aDataSource, _rQualifiedName );
+ DatabaseObjectView::fillDispatchArgs( i_rDispatchArgs, _aDataSource, _rQualifiedName );
OSL_ENSURE( 0 != _rQualifiedName.getLength(),"A Table name must be set");
::rtl::OUString sCatalog;
::rtl::OUString sSchema;
@@ -344,26 +318,15 @@ namespace dbaui
if ( m_bTable )
::dbtools::qualifiedNameComponents( getConnection()->getMetaData(), _rQualifiedName, sCatalog, sSchema, sTable, ::dbtools::eInDataManipulation );
- sal_Int32 nPos = _rDispatchArguments.getLength();
- _rDispatchArguments.realloc( _rDispatchArguments.getLength() + 3 + ( m_bTable ? 3 : 0 ) );
-
- _rDispatchArguments[nPos ].Name = PROPERTY_COMMAND_TYPE;
- _rDispatchArguments[nPos++].Value <<= (m_bTable ? CommandType::TABLE : CommandType::QUERY);
-
- _rDispatchArguments[nPos ].Name = PROPERTY_COMMAND;
- _rDispatchArguments[nPos++].Value <<= _rQualifiedName;
-
- _rDispatchArguments[nPos ].Name = PROPERTY_ENABLE_BROWSER;
- _rDispatchArguments[nPos++].Value <<= sal_False;
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND_TYPE, (m_bTable ? CommandType::TABLE : CommandType::QUERY) );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_COMMAND, _rQualifiedName );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_ENABLE_BROWSER, sal_False );
if ( m_bTable )
{
- _rDispatchArguments[nPos ].Name = PROPERTY_UPDATE_CATALOGNAME;
- _rDispatchArguments[nPos++].Value <<= sCatalog;
- _rDispatchArguments[nPos ].Name = PROPERTY_UPDATE_SCHEMANAME;
- _rDispatchArguments[nPos++].Value <<= sSchema;
- _rDispatchArguments[nPos ].Name = PROPERTY_UPDATE_TABLENAME;
- _rDispatchArguments[nPos++].Value <<= sTable;
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_CATALOGNAME, sCatalog );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_SCHEMANAME, sSchema );
+ i_rDispatchArgs.put( (::rtl::OUString)PROPERTY_UPDATE_TABLENAME, sTable );
}
}