Tag: cws_src680_hsqldb9 User: oj Date: 2006/08/02 23:43:47 Modified: dba/dbaccess/source/ui/misc/UITools.cxx
Log: RESYNC: (1.60-1.61); FILE MERGED File Changes: Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: UITools.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/UITools.cxx?r1=1.60.2.1&r2=1.60.2.2 Delta lines: +140 -103 ----------------------- --- UITools.cxx 2 Aug 2006 06:51:37 -0000 1.60.2.1 +++ UITools.cxx 3 Aug 2006 06:43:45 -0000 1.60.2.2 @@ -54,9 +54,15 @@ #ifndef DBAUI_DBTREELISTBOX_HXX #include "dbtreelistbox.hxx" #endif +#ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX +#include "defaultobjectnamecheck.hxx" +#endif #ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> #endif +#ifndef _COM_SUN_STAR_SDB_XSINGLESELECTQUERYANALYZER_HPP_ +#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp> +#endif #ifndef _COM_SUN_STAR_SDB_XCOMPLETEDCONNECTION_HPP_ #include <com/sun/star/sdb/XCompletedConnection.hpp> #endif @@ -277,6 +283,9 @@ #ifndef _URLOBJ_HXX #include <tools/urlobj.hxx> #endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif #ifndef _NUMUNO_HXX #include <svtools/numuno.hxx> #endif @@ -924,7 +933,7 @@ { sSchema = _xMetaData->getUserName(); } - ::dbtools::composeTableName(_xMetaData,sCatalog,sSchema,_sName,sCompsedName,sal_False,::dbtools::eInDataManipulation); + sCompsedName = ::dbtools::composeTableName( _xMetaData, sCatalog, sSchema, _sName, sal_False, ::dbtools::eInDataManipulation ); sDefaultName = ::dbtools::createUniqueName(_xTables,sCompsedName); } catch(const SQLException&) @@ -1375,7 +1384,7 @@ // ----------------------------------------------------------------------------- sal_Bool isAppendTableAliasEnabled(const Reference<XConnection>& _xConnection) { - return ::dbtools::isDataSourcePropertyEnabled(_xConnection,INFO_APPEND_TABLE_ALIAS,sal_True); + return ::dbtools::isDataSourcePropertyEnabled(_xConnection,INFO_APPEND_TABLE_ALIAS,sal_False); } // ----------------------------------------------------------------------------- @@ -1671,6 +1680,28 @@ } return aAsk.Execute(); } + +// ----------------------------------------------------------------------------- +namespace +{ + static ::rtl::OUString lcl_createSDBCLevelStatement( const ::rtl::OUString& _rStatement, const Reference< XConnection >& _rxConnection ) + { + ::rtl::OUString sSDBCLevelStatement( _rStatement ); + try + { + Reference< XMultiServiceFactory > xAnalyzerFactory( _rxConnection, UNO_QUERY_THROW ); + Reference< XSingleSelectQueryAnalyzer > xAnalyzer( xAnalyzerFactory->createInstance( SERVICE_NAME_SINGLESELECTQUERYCOMPOSER ), UNO_QUERY_THROW ); + xAnalyzer->setQuery( _rStatement ); + sSDBCLevelStatement = xAnalyzer->getQueryWithSubstitution(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sSDBCLevelStatement; + } +} + // ----------------------------------------------------------------------------- Reference<XPropertySet> createView( const ::rtl::OUString& _sName ,const Reference< ::com::sun::star::sdbc::XConnection >& _xConnection @@ -1705,13 +1736,16 @@ if(_xSourceObject->getPropertySetInfo()->hasPropertyByName(PROPERTY_COMMAND)) { _xSourceObject->getPropertyValue(PROPERTY_COMMAND) >>= sCommand; + + sal_Bool bEscapeProcessing( sal_False ); + OSL_VERIFY( _xSourceObject->getPropertyValue( PROPERTY_USE_ESCAPE_PROCESSING ) >>= bEscapeProcessing ); + if ( bEscapeProcessing ) + sCommand = lcl_createSDBCLevelStatement( sCommand, _xConnection ); } else { sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT * FROM ")); - sal_Bool bUseCatalogInSelect = ::dbtools::isDataSourcePropertyEnabled(_xConnection,PROPERTY_USECATALOGINSELECT,sal_True); - sal_Bool bUseSchemaInSelect = ::dbtools::isDataSourcePropertyEnabled(_xConnection,PROPERTY_USESCHEMAINSELECT,sal_True); - sCommand += ::dbaui::composeTableName(_xConnection->getMetaData(),_xSourceObject,sal_True,::dbtools::eInDataManipulation,bUseCatalogInSelect,bUseSchemaInSelect); + sCommand += composeTableNameForSelect( _xConnection, _xSourceObject ); } xView->setPropertyValue(PROPERTY_COMMAND,makeAny(sCommand)); @@ -1815,17 +1849,19 @@ } } // ----------------------------------------------------------------------------- -sal_Bool insertHierachyElement(Window* _pParent - ,const Reference<XHierarchicalNameContainer>& _xNames - ,const String& _sParentFolder - ,sal_Bool _bForm - ,sal_Bool _bCollection - ,const Reference<XContent>& _xContent - ,sal_Bool _bMove) +sal_Bool insertHierachyElement( Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB, + const Reference<XHierarchicalNameContainer>& _xNames, + const String& _sParentFolder, + sal_Bool _bForm, + sal_Bool _bCollection, + const Reference<XContent>& _xContent, + sal_Bool _bMove) { - if ( _xNames.is() ) - { - Reference<XNameAccess> xNameAccess(_xNames,UNO_QUERY); + OSL_ENSURE( _xNames.is(), "insertHierachyElement: illegal name container!" ); + if ( !_xNames.is() ) + return sal_False; + + Reference<XNameAccess> xNameAccess( _xNames, UNO_QUERY ); ::rtl::OUString sName = _sParentFolder; if ( _xNames->hasByHierarchicalName(sName) ) { @@ -1835,8 +1871,10 @@ xNameAccess.set(xChild->getParent(),UNO_QUERY); } - if ( xNameAccess.is() ) - { + OSL_ENSURE( xNameAccess.is(), "insertHierachyElement: could not find the proper name container!" ); + if ( !xNameAccess.is() ) + return sal_False; + ::rtl::OUString sNewName; Reference<XPropertySet> xProp(_xContent,UNO_QUERY); if ( xProp.is() ) @@ -1856,12 +1894,13 @@ // here we have everything needed to create a new query object ... + HierarchicalNameCheck aNameChecker( _xNames.get(), sName ); // ... ehm, except a new name OSaveAsDlg aAskForName( _pParent, - _xNames.get(), + _rxORB, sTargetName, sLabel, - sName, + aNameChecker, SAD_ADDITIONAL_DESCRIPTION | SAD_TITLE_PASTE_AS); if ( RET_OK != aAskForName.Execute() ) // cancelled by the user @@ -1872,13 +1911,13 @@ } else if ( xNameAccess->hasByName(sNewName) ) { - String sError(ModuleRes(STR_OBJECT_ALREADY_EXISTS)); + String sError(ModuleRes(STR_NAME_ALREADY_EXISTS)); sError.SearchAndReplaceAscii("#",sNewName); throw SQLException(sError,NULL,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")) ,0,Any()); } - if ( sNewName.getLength() ) - { + if ( !sNewName.getLength() ) + return sal_False; try { Reference<XMultiServiceFactory> xORB(xNameAccess,UNO_QUERY); @@ -1911,12 +1950,10 @@ } catch(Exception&) { - OSL_ENSURE(0,"OApplicationController::OApplicationController -> exception catched"); + DBG_UNHANDLED_EXCEPTION(); return sal_False; } - } - } - } + return sal_True; } // ----------------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
