Tag: cws_src680_dba30 User: fs Date: 2006/07/19 06:18:29 Modified: dba/dbaccess/source/ui/tabledesign/TableController.cxx
Log: RESYNC: (1.103-1.105); FILE MERGED File Changes: Directory: /dba/dbaccess/source/ui/tabledesign/ =============================================== File [changed]: TableController.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/tabledesign/TableController.cxx?r1=1.99.16.6&r2=1.99.16.7 Delta lines: +36 -49 --------------------- --- TableController.cxx 8 May 2006 11:28:53 -0000 1.99.16.6 +++ TableController.cxx 19 Jul 2006 13:18:26 -0000 1.99.16.7 @@ -57,6 +57,9 @@ #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" #endif +#ifndef DBACCESS_SOURCE_UI_INC_DEFAULTOBJECTNAMECHECK_HXX +#include "defaultobjectnamecheck.hxx" +#endif #ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> #endif @@ -241,9 +244,9 @@ // ----------------------------------------------------------------------------- OTableController::OTableController(const Reference< XMultiServiceFactory >& _rM) : OTableController_BASE(_rM) ,m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES)) - ,m_bNew(sal_True) ,m_pTypeInfo() ,m_bAllowAutoIncrementValue(sal_False) + ,m_bNew(sal_True) { DBG_CTOR(OTableController,NULL); @@ -296,7 +299,7 @@ aReturn.bEnabled = sal_True; break; case ID_BROWSER_EDITDOC: - aReturn.aState = ::cppu::bool2any(isEditable()); + aReturn.bChecked = isEditable(); aReturn.bEnabled = m_bNew || isEditable();// the editable flag is set through this one -> || isAddAllowed() || isDropAllowed() || isAlterAllowed(); break; case ID_BROWSER_SAVEDOC: @@ -426,16 +429,15 @@ aDefaultName = ::dbaui::createDefaultName(getConnection()->getMetaData(),xTables,aName); } - OSaveAsDlg aDlg(getView(),CommandType::TABLE,xTables,getConnection()->getMetaData(),getConnection(),aDefaultName); - if(aDlg.Execute() == RET_OK) - { + DynamicTableOrQueryNameCheck aNameChecker( getConnection(), CommandType::TABLE ); + OSaveAsDlg aDlg( getView(), CommandType::TABLE, getORB(), getConnection(), aDefaultName, aNameChecker ); + if ( aDlg.Execute() != RET_OK ) + return sal_False; + m_sName = aDlg.getName(); sCatalog = aDlg.getCatalog(); sSchema = aDlg.getSchema(); } - else - return sal_False; - } // did we get a name if(!m_sName.getLength()) @@ -490,7 +492,7 @@ if(!m_xTable.is()) // correct name and try again { // it can be that someone inserted new data for us - m_sName = ::dbtools::composeTableName(getConnection()->getMetaData(),xTable,sal_False,::dbtools::eInDataManipulation); + m_sName = ::dbtools::composeTableName( getConnection()->getMetaData(), xTable, ::dbtools::eInDataManipulation, false, false, false ); assignTable(); } // now check if our datasource has set a tablefilter and if append the new table name to it @@ -517,9 +519,9 @@ } catch(const ElementExistException& ) { - String sText( ModuleRes(STR_OBJECT_ALREADY_EXISTS)); + String sText( ModuleRes( STR_NAME_ALREADY_EXISTS ) ); sText.SearchAndReplaceAscii( "#" , m_sName); - OSQLMessageBox aDlg(getView(), String(ModuleRes(STR_OBJECT_ALREADY_EXSISTS)), sText, WB_OK, OSQLMessageBox::Error); + OSQLMessageBox aDlg( getView(), String( ModuleRes( STR_ERROR_DURING_CREATION ) ), sText, WB_OK, OSQLMessageBox::Error ); aDlg.Execute(); bError = sal_True; @@ -603,35 +605,22 @@ } // ----------------------------------------------------------------------------- -void OTableController::impl_initialize( const Sequence< Any >& aArguments ) +void OTableController::impl_initialize() { try { - OTableController_BASE::impl_initialize(aArguments); + OTableController_BASE::impl_initialize(); - PropertyValue aValue; - const Any* pIter = aArguments.getConstArray(); - const Any* pEnd = pIter + aArguments.getLength(); + const NamedValueCollection& rArguments( getInitParams() ); - for(;pIter != pEnd;++pIter) - { - if (!(*pIter >>= aValue)) - throw Exception(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid type in argument list. PropertyValue expected.")),*this); - if ( 0 == aValue.Name.compareToAscii(PROPERTY_ACTIVECONNECTION) ) - { - Reference< XConnection > xConn; - if ( !(aValue.Value >>= xConn) ) - throw Exception(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid argument type for ActiveConnection.")),*this); - OSL_ENSURE( xConn.is(), "OTableController::initialize: invalid connection given!!" ); - if ( xConn.is() ) - initializeConnection( xConn ); - } - else if (0 == aValue.Name.compareToAscii(PROPERTY_CURRENTTABLE)) - { - if ( !(aValue.Value >>= m_sName) ) + Reference< XConnection > xConnection; + xConnection = rArguments.getOrDefault( (::rtl::OUString)PROPERTY_ACTIVECONNECTION, xConnection ); + if ( xConnection.is() ) + initializeConnection( xConnection ); + + if ( !rArguments.getIfExists_ensureType( (::rtl::OUString)PROPERTY_CURRENTTABLE, m_sName ) ) throw Exception(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid argument type for CurrentTable.")),*this); - } - } + // read autoincrement value set in the datasource ::dbaui::fillAutoIncrementValue(getDataSource(),m_bAllowAutoIncrementValue,m_sAutoIncrementValue); @@ -702,7 +691,7 @@ return sal_True; } // ----------------------------------------------------------------------------- -sal_Bool SAL_CALL OTableController::suspend(sal_Bool _bSuspend) throw( RuntimeException ) +sal_Bool SAL_CALL OTableController::suspend(sal_Bool /*_bSuspend*/) throw( RuntimeException ) { if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed ) return sal_True; @@ -1036,12 +1025,12 @@ for(;pKeyBegin != pKeyEnd;++pKeyBegin) { - ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_vRowList.begin(); - for(;aIter != m_vRowList.end();++aIter) + ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator rowIter = m_vRowList.begin(); + for(;rowIter != m_vRowList.end();++rowIter) { - if((*aIter)->GetActFieldDescr()->GetName() == *pKeyBegin) + if((*rowIter)->GetActFieldDescr()->GetName() == *pKeyBegin) { - (*aIter)->SetPrimaryKey(sal_True); + (*rowIter)->SetPrimaryKey(sal_True); break; } } @@ -1118,8 +1107,6 @@ if (pFieldDesc && pFieldDesc->GetName().getLength()) { bFoundPKey |= (*aIter)->IsPrimaryKey(); - sal_uInt16 nErrorRes = sal_uInt16(-1); - sal_uInt16 nFieldPos = sal_uInt16(-1); // first check for duplicate names ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter2 = aIter+1; for(;aIter2 != m_vRowList.end();++aIter2) @@ -1669,7 +1656,7 @@ if ( m_sName.getLength() && getConnection().is() ) { if ( m_xTable.is() ) - sTitle = ::dbtools::composeTableName(getConnection()->getMetaData(),m_xTable,sal_False,::dbtools::eInDataManipulation); + sTitle = ::dbtools::composeTableName( getConnection()->getMetaData(), m_xTable, ::dbtools::eInDataManipulation, false, false, false ); else sTitle = m_sName; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
