diff options
Diffstat (limited to 'dbaccess/source')
32 files changed, 741 insertions, 743 deletions
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 290c88031349..302bae23c984 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -275,7 +275,6 @@ ORowSet::ORowSet( const Reference< ::com::sun::star::lang::XMultiServiceFactory ,m_bCanUpdateInsertedRows(sal_True) ,m_bOwnConnection(sal_False) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::ORowSet" ); m_nResultSetType = ResultSetType::SCROLL_SENSITIVE; m_nResultSetConcurrency = ResultSetConcurrency::UPDATABLE; m_pMySelf = this; @@ -341,7 +340,6 @@ ORowSet::~ORowSet() // ----------------------------------------------------------------------------- void ORowSet::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getPropertyDefaultByHandle" ); switch( _nHandle ) { case PROPERTY_ID_COMMAND_TYPE: @@ -377,6 +375,18 @@ void ORowSet::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) c case PROPERTY_ID_ESCAPE_PROCESSING: _rDefault <<= sal_True; break; + case PROPERTY_ID_MAXROWS: + _rDefault <<= sal_Int32( 0 ); + break; + case PROPERTY_ID_FILTER: + case PROPERTY_ID_HAVING_CLAUSE: + case PROPERTY_ID_GROUP_BY: + case PROPERTY_ID_ORDER: + case PROPERTY_ID_UPDATE_CATALOGNAME: + case PROPERTY_ID_UPDATE_SCHEMANAME: + case PROPERTY_ID_UPDATE_TABLENAME: + _rDefault <<= ::rtl::OUString(); + break; } } // ------------------------------------------------------------------------- @@ -384,7 +394,6 @@ void ORowSet::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) c void SAL_CALL ORowSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setFastPropertyValue_NoBroadcast" ); switch(nHandle) { case PROPERTY_ID_ISMODIFIED: @@ -474,7 +483,6 @@ void SAL_CALL ORowSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const // ------------------------------------------------------------------------- void SAL_CALL ORowSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getFastPropertyValue" ); if(m_pCache) { switch(nHandle) @@ -517,7 +525,6 @@ void SAL_CALL ORowSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const // com::sun::star::XTypeProvider Sequence< Type > SAL_CALL ORowSet::getTypes() throw (RuntimeException) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getTypes" ); OTypeCollection aTypes(::getCppuType( (const Reference< XPropertySet > *)0 ), ::getCppuType( (const Reference< XFastPropertySet > *)0 ), ::getCppuType( (const Reference< XMultiPropertySet > *)0 ), @@ -527,7 +534,6 @@ Sequence< Type > SAL_CALL ORowSet::getTypes() throw (RuntimeException) // ------------------------------------------------------------------------- Sequence< sal_Int8 > SAL_CALL ORowSet::getImplementationId() throw (RuntimeException) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getImplementationId" ); static OImplementationId * pId = 0; if (! pId) { @@ -545,7 +551,6 @@ Sequence< sal_Int8 > SAL_CALL ORowSet::getImplementationId() throw (RuntimeExcep // com::sun::star::XInterface Any SAL_CALL ORowSet::queryInterface( const Type & rType ) throw (RuntimeException) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::queryInterface" ); return ORowSet_BASE1::queryInterface( rType); } // ------------------------------------------------------------------------- @@ -563,7 +568,6 @@ void SAL_CALL ORowSet::release() throw() // com::sun::star::XUnoTunnel sal_Int64 SAL_CALL ORowSet::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getSomething" ); if (rId.getLength() == 16 && 0 == rtl_compareMemory(getImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) return reinterpret_cast<sal_Int64>(this); @@ -573,7 +577,6 @@ sal_Int64 SAL_CALL ORowSet::getSomething( const Sequence< sal_Int8 >& rId ) thro // com::sun::star::XAggregation Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) throw(RuntimeException) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::queryAggregation" ); Any aRet(ORowSetBase::queryInterface(rType)); if (!aRet.hasValue()) aRet = ORowSet_BASE1::queryAggregation(rType); @@ -582,26 +585,22 @@ Any SAL_CALL ORowSet::queryAggregation( const Type& rType ) throw(RuntimeExcepti //------------------------------------------------------------------------------ rtl::OUString ORowSet::getImplementationName_static( ) throw(RuntimeException) { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getImplementationName_static" ); return rtl::OUString::createFromAscii("com.sun.star.comp.dba.ORowSet"); } // ------------------------------------------------------------------------- // ::com::sun::star::XServiceInfo ::rtl::OUString SAL_CALL ORowSet::getImplementationName( ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getImplementationName" ); return getImplementationName_static(); } // ------------------------------------------------------------------------- sal_Bool SAL_CALL ORowSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::supportsService" ); return ::comphelper::findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0; } //------------------------------------------------------------------------------ Sequence< ::rtl::OUString > ORowSet::getSupportedServiceNames_static( ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getSupportedServiceNames_static" ); Sequence< rtl::OUString > aSNS( 5 ); aSNS[0] = SERVICE_SDBC_RESULTSET; aSNS[1] = SERVICE_SDBC_ROWSET; @@ -613,13 +612,11 @@ Sequence< ::rtl::OUString > ORowSet::getSupportedServiceNames_static( ) throw ( // ------------------------------------------------------------------------- Sequence< ::rtl::OUString > SAL_CALL ORowSet::getSupportedServiceNames( ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getSupportedServiceNames" ); return getSupportedServiceNames_static(); } //------------------------------------------------------------------------------ Reference< XInterface > ORowSet::Create(const Reference< XComponentContext >& _rxContext) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::Create" ); ::comphelper::ComponentContext aContext( _rxContext ); return ORowSet_CreateInstance( aContext.getLegacyServiceFactory() ); } @@ -627,7 +624,6 @@ Reference< XInterface > ORowSet::Create(const Reference< XComponentContext >& _r // OComponentHelper void SAL_CALL ORowSet::disposing() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::disposing" ); OPropertyStateContainer::disposing(); MutexGuard aGuard(m_aMutex); @@ -658,7 +654,6 @@ void SAL_CALL ORowSet::disposing() // ------------------------------------------------------------------------- void ORowSet::freeResources( bool _bComplete ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::freeResources" ); MutexGuard aGuard(m_aMutex); // free all clones @@ -712,7 +707,6 @@ void ORowSet::freeResources( bool _bComplete ) // ------------------------------------------------------------------------- void ORowSet::setActiveConnection( Reference< XConnection >& _rxNewConn, sal_Bool _bFireEvent ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setActiveConnection" ); if (_rxNewConn.get() == m_xActiveConnection.get()) // nothing to do return; @@ -760,7 +754,6 @@ void ORowSet::setActiveConnection( Reference< XConnection >& _rxNewConn, sal_Boo // ::com::sun::star::XEventListener void SAL_CALL ORowSet::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::disposing" ); // close rowset because the connection is going to be deleted (someone told me :-) Reference<XConnection> xCon(Source.Source,UNO_QUERY); if(m_xActiveConnection == xCon) @@ -778,7 +771,6 @@ void SAL_CALL ORowSet::disposing( const ::com::sun::star::lang::EventObject& Sou // XCloseable void SAL_CALL ORowSet::close( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::close" ); { MutexGuard aGuard( m_aMutex ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); @@ -790,7 +782,6 @@ void SAL_CALL ORowSet::close( ) throw(SQLException, RuntimeException) // comphelper::OPropertyArrayUsageHelper ::cppu::IPropertyArrayHelper* ORowSet::createArrayHelper( ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::createArrayHelper" ); Sequence< Property > aProps; describeProperties(aProps); return new ::cppu::OPropertyArrayHelper(aProps); @@ -799,14 +790,12 @@ void SAL_CALL ORowSet::close( ) throw(SQLException, RuntimeException) // cppu::OPropertySetHelper ::cppu::IPropertyArrayHelper& SAL_CALL ORowSet::getInfoHelper() { - //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getInfoHelper" ); typedef ::comphelper::OPropertyArrayUsageHelper<ORowSet> ORowSet_PROP; return *ORowSet_PROP::getArrayHelper(); } // ----------------------------------------------------------------------------- void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateValue" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( *m_pMutex ); @@ -824,85 +813,71 @@ void ORowSet::updateValue(sal_Int32 columnIndex,const ORowSetValue& x) // XRowUpdate void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateNull" ); updateValue(columnIndex,ORowSetValue()); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateBoolean" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateByte" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateShort" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateInt" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateLong" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateFloat" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateDouble" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateString" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateBytes" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateDate" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateTime" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateTimestamp" ); updateValue(columnIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateBinaryStream" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( *m_pMutex ); @@ -933,7 +908,6 @@ void SAL_CALL ORowSet::updateBinaryStream( sal_Int32 columnIndex, const Referenc // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateCharacterStream" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( *m_pMutex ); @@ -950,7 +924,6 @@ void SAL_CALL ORowSet::updateCharacterStream( sal_Int32 columnIndex, const Refer // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateObject" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( *m_pMutex ); @@ -999,7 +972,6 @@ void SAL_CALL ORowSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateNumericObject" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( *m_pMutex ); @@ -1018,7 +990,6 @@ void SAL_CALL ORowSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, // XResultSetUpdate void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::insertRow" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); // insertRow is not allowd when // standing not on the insert row nor @@ -1068,17 +1039,15 @@ void SAL_CALL ORowSet::insertRow( ) throw(SQLException, RuntimeException) // ------------------------------------------------------------------------- sal_Int32 SAL_CALL ORowSet::getRow( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getRow" ); ::osl::MutexGuard aGuard( *m_pMutex ); checkCache(); // check if we are inserting a row - return (m_pCache && ( m_pCache->m_bNew || m_bModified )) ? 0 : impl_getRow(); + return (m_pCache && ( m_pCache->m_bNew || m_bModified )) ? 0 : ORowSetBase::getRow(); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::updateRow" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); // not allowed when standing on insert row ::osl::ResettableMutexGuard aGuard( *m_pMutex ); @@ -1116,7 +1085,6 @@ void SAL_CALL ORowSet::updateRow( ) throw(SQLException, RuntimeException) // ------------------------------------------------------------------------- void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::deleteRow" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::ResettableMutexGuard aGuard( *m_pMutex ); @@ -1134,7 +1102,7 @@ void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException) if ( ( m_pCache->m_nPrivileges & Privilege::DELETE ) != Privilege::DELETE ) throwSQLException( "DELETE privilege not available.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); // TODO: resource - if ( impl_rowDeleted() ) + if ( rowDeleted() ) throwSQLException( "Current row already deleted.", SQL_FUNCTION_SEQUENCE_ERROR, *this ); // TODO: resource @@ -1173,7 +1141,6 @@ void SAL_CALL ORowSet::deleteRow( ) throw(SQLException, RuntimeException) // ------------------------------------------------------------------------- void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQLException, RuntimeException ) ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::implCancelRowUpdates" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( *m_pMutex ); @@ -1211,14 +1178,12 @@ void ORowSet::implCancelRowUpdates( sal_Bool _bNotifyModified ) SAL_THROW( ( SQL // ------------------------------------------------------------------------- void SAL_CALL ORowSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::cancelRowUpdates" ); implCancelRowUpdates( sal_True ); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::addRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::addRowSetListener" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( m_aColumnsMutex ); @@ -1228,7 +1193,6 @@ void SAL_CALL ORowSet::addRowSetListener( const Reference< XRowSetListener >& li // ------------------------------------------------------------------------- void SAL_CALL ORowSet::removeRowSetListener( const Reference< XRowSetListener >& listener ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::removeRowSetListener" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( m_aColumnsMutex ); @@ -1238,7 +1202,6 @@ void SAL_CALL ORowSet::removeRowSetListener( const Reference< XRowSetListener >& // ----------------------------------------------------------------------------- void ORowSet::notifyAllListeners(::osl::ResettableMutexGuard& _rGuard) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::notifyAllListeners" ); EventObject aEvt(*m_pMySelf); _rGuard.clear(); m_aRowsetListeners.notifyEach( &XRowSetListener::rowSetChanged, aEvt ); @@ -1247,7 +1210,6 @@ void ORowSet::notifyAllListeners(::osl::ResettableMutexGuard& _rGuard) // ------------------------------------------------------------------------- void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::notifyAllListenersCursorMoved" ); EventObject aEvt(*m_pMySelf); _rGuard.clear(); m_aRowsetListeners.notifyEach( &XRowSetListener::cursorMoved, aEvt ); @@ -1256,7 +1218,6 @@ void ORowSet::notifyAllListenersCursorMoved(::osl::ResettableMutexGuard& _rGuard // ------------------------------------------------------------------------- void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard, const EventObject& aEvt) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::notifyAllListenersRowChanged" ); _rGuard.clear(); m_aRowsetListeners.notifyEach( &XRowSetListener::rowChanged, aEvt ); _rGuard.reset(); @@ -1264,7 +1225,6 @@ void ORowSet::notifyAllListenersRowChanged(::osl::ResettableMutexGuard& _rGuard, // ------------------------------------------------------------------------- sal_Bool ORowSet::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard& _rGuard) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::notifyAllListenersCursorBeforeMove" ); EventObject aEvt(*m_pMySelf); NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveCursorMove); return bCheck; @@ -1272,7 +1232,6 @@ sal_Bool ORowSet::notifyAllListenersCursorBeforeMove(::osl::ResettableMutexGuard // ------------------------------------------------------------------------- void ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rGuard,const RowChangeEvent &aEvt) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::notifyAllListenersRowBeforeChange" ); NOTIFY_LISTERNERS_CHECK(m_aApproveListeners,XRowSetApproveListener,approveRowChange); if ( !bCheck ) m_aErrors.raiseTypedException( sdb::ErrorCondition::ROW_SET_OPERATION_VETOED, *this, ::cppu::UnoType< RowSetVetoException >::get() ); @@ -1280,7 +1239,6 @@ void ORowSet::notifyAllListenersRowBeforeChange(::osl::ResettableMutexGuard& _rG // ------------------------------------------------------------------------- void ORowSet::fireRowcount() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::fireRowcount" ); sal_Int32 nCurrentRowCount( impl_getRowCount() ); sal_Bool bCurrentRowCountFinal( m_pCache->m_bRowCountFinal ); @@ -1305,7 +1263,6 @@ void ORowSet::fireRowcount() // ------------------------------------------------------------------------- void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::moveToInsertRow" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::ResettableMutexGuard aGuard( *m_pMutex ); @@ -1363,7 +1320,6 @@ void SAL_CALL ORowSet::moveToInsertRow( ) throw(SQLException, RuntimeException) // ------------------------------------------------------------------------- void SAL_CALL ORowSet::moveToCurrentRow( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::moveToCurrentRow" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::ResettableMutexGuard aGuard( *m_pMutex ); @@ -1401,111 +1357,96 @@ void SAL_CALL ORowSet::moveToCurrentRow( ) throw(SQLException, RuntimeException // XRow sal_Bool SAL_CALL ORowSet::wasNull( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::wasNull" ); ::osl::MutexGuard aGuard( *m_pMutex ); checkCache(); - return ( m_pCache && isInsertRow() ) ? ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex].isNull() : impl_wasNull(); + return ( m_pCache && isInsertRow() ) ? ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex].isNull() : ORowSetBase::wasNull(); } // ----------------------------------------------------------------------------- const ORowSetValue& ORowSet::getInsertValue(sal_Int32 columnIndex) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getInsertValue" ); checkCache(); if ( m_pCache && isInsertRow() ) return ((*m_pCache->m_aInsertRow)->get())[m_nLastColumnIndex = columnIndex]; - return impl_getValue(columnIndex); + return getValue(columnIndex); } // ------------------------------------------------------------------------- ::rtl::OUString SAL_CALL ORowSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getString" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- sal_Bool SAL_CALL ORowSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getBoolean" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- sal_Int8 SAL_CALL ORowSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getByte" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- sal_Int16 SAL_CALL ORowSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getShort" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- sal_Int32 SAL_CALL ORowSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getInt" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- sal_Int64 SAL_CALL ORowSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getLong" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- float SAL_CALL ORowSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getFloat" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- double SAL_CALL ORowSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getDouble" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- Sequence< sal_Int8 > SAL_CALL ORowSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getBytes" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- ::com::sun::star::util::Date SAL_CALL ORowSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getDate" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- ::com::sun::star::util::Time SAL_CALL ORowSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getTime" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- ::com::sun::star::util::DateTime SAL_CALL ORowSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getTimestamp" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex); } // ------------------------------------------------------------------------- Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getBinaryStream" ); ::osl::MutexGuard aGuard( *m_pMutex ); if ( m_pCache && isInsertRow() ) { @@ -1518,7 +1459,6 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getBinaryStrea // ------------------------------------------------------------------------- Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getCharacterStream" ); ::osl::MutexGuard aGuard( *m_pMutex ); if(m_pCache && isInsertRow() ) { @@ -1531,38 +1471,32 @@ Reference< ::com::sun::star::io::XInputStream > SAL_CALL ORowSet::getCharacterSt // ------------------------------------------------------------------------- Any SAL_CALL ORowSet::getObject( sal_Int32 columnIndex, const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getObject" ); ::osl::MutexGuard aGuard( *m_pMutex ); return getInsertValue(columnIndex).makeAny(); } // ------------------------------------------------------------------------- Reference< XRef > SAL_CALL ORowSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getRef" ); return Reference< XRef >(); } // ------------------------------------------------------------------------- Reference< XBlob > SAL_CALL ORowSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getBlob" ); return Reference< XBlob >(); } // ------------------------------------------------------------------------- Reference< XClob > SAL_CALL ORowSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getClob" ); return Reference< XClob >(); } // ------------------------------------------------------------------------- Reference< XArray > SAL_CALL ORowSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getArray" ); return Reference< XArray >(); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandler >& _rxHandler ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::executeWithCompletion" ); if (!_rxHandler.is()) execute(); @@ -1588,7 +1522,14 @@ void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandl m_bRebuildConnOnExecute = sal_False; Reference< XSingleSelectQueryComposer > xComposer = getCurrentSettingsComposer( this, m_aContext.getLegacyServiceFactory() ); - ::dbtools::askForParameters( xComposer, this, m_xActiveConnection, _rxHandler ); + Reference<XParametersSupplier> xParameters(xComposer, UNO_QUERY); + + Reference<XIndexAccess> xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>(); + const sal_Int32 nParamCount = xParamsAsIndicies.is() ? xParamsAsIndicies->getCount() : 0; + if ( m_aParametersSet.size() < (size_t)nParamCount ) + m_aParametersSet.resize( nParamCount ,false); + + ::dbtools::askForParameters( xComposer, this, m_xActiveConnection, _rxHandler,m_aParametersSet ); } // ensure that only the allowed exceptions leave this block catch(SQLException&) @@ -1613,7 +1554,6 @@ void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandl // ------------------------------------------------------------------------- Reference< XIndexAccess > SAL_CALL ORowSet::getParameters( ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getParameters" ); ::osl::MutexGuard aGuard( *m_pMutex ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); @@ -1641,7 +1581,6 @@ Reference< XIndexAccess > SAL_CALL ORowSet::getParameters( ) throw (RuntimeExce // ------------------------------------------------------------------------- void ORowSet::approveExecution() throw (RowSetVetoException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::approveExecution" ); ::osl::MutexGuard aGuard( m_aColumnsMutex ); EventObject aEvt(*this); @@ -1672,7 +1611,6 @@ void ORowSet::approveExecution() throw (RowSetVetoException, RuntimeException) // ------------------------------------------------------------------------- void SAL_CALL ORowSet::execute( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::execute" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); // tell everybody that we will change the result set @@ -1698,7 +1636,6 @@ void SAL_CALL ORowSet::execute( ) throw(SQLException, RuntimeException) //------------------------------------------------------------------------------ void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxStatement, sal_Int32 _nDesiredResultSetType, sal_Int32 _nDesiredResultSetConcurrency ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setStatementResultSetType" ); OSL_ENSURE( _rxStatement.is(), "ORowSet::setStatementResultSetType: invalid statement - this will crash!" ); sal_Int32 nResultSetType( _nDesiredResultSetType ); @@ -1749,7 +1686,6 @@ void ORowSet::setStatementResultSetType( const Reference< XPropertySet >& _rxSta // ----------------------------------------------------------------------------- Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::impl_prepareAndExecute_throw" ); ::rtl::OUString sCommandToExecute; sal_Bool bUseEscapeProcessing = impl_initComposer_throw( sCommandToExecute ); @@ -1814,7 +1750,6 @@ Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw() // ----------------------------------------------------------------------------- void ORowSet::impl_initializeColumnSettings_nothrow( const Reference< XPropertySet >& _rxTemplateColumn, const Reference< XPropertySet >& _rxRowSetColumn ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::impl_initializeColumnSettings_nothrow" ); OSL_ENSURE( _rxTemplateColumn.is() && _rxRowSetColumn.is(), "ORowSet::impl_initializeColumnSettings_nothrow: this will crash!" ); @@ -2018,7 +1953,6 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi else { // create the rowset columns - const Reference< XDatabaseMetaData > xDatabaseMetaData( m_xActiveConnection->getMetaData() ); Reference< XResultSetMetaData > xMeta( getMetaData(), UNO_QUERY_THROW ); sal_Int32 nCount = xMeta->getColumnCount(); m_aDataColumns.reserve(nCount+1); @@ -2073,7 +2007,7 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi this, this, i, - xDatabaseMetaData, + m_xActiveConnection->getMetaData(), aDescription, m_aCurrentRow); aColumns->get().push_back(pColumn); @@ -2112,7 +2046,6 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi // XRowSetApproveBroadcaster void SAL_CALL ORowSet::addRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::addRowSetApproveListener" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( m_aColumnsMutex ); @@ -2122,7 +2055,6 @@ void SAL_CALL ORowSet::addRowSetApproveListener( const Reference< XRowSetApprove // ------------------------------------------------------------------------- void SAL_CALL ORowSet::removeRowSetApproveListener( const Reference< XRowSetApproveListener >& listener ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::removeRowSetApproveListener" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( m_aColumnsMutex ); @@ -2134,7 +2066,6 @@ void SAL_CALL ORowSet::removeRowSetApproveListener( const Reference< XRowSetAppr // XResultSetAccess Reference< XResultSet > SAL_CALL ORowSet::createResultSet( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::createResultSet" ); ::osl::MutexGuard aGuard( m_aColumnsMutex ); if(m_xStatement.is()) @@ -2151,7 +2082,6 @@ Reference< XResultSet > SAL_CALL ORowSet::createResultSet( ) throw(SQLException // ::com::sun::star::util::XCancellable void SAL_CALL ORowSet::cancel( ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::cancel" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); } // ------------------------------------------------------------------------- @@ -2159,7 +2089,6 @@ void SAL_CALL ORowSet::cancel( ) throw(RuntimeException) // ::com::sun::star::sdbcx::XDeleteRows Sequence< sal_Int32 > SAL_CALL ORowSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::deleteRows" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); if(!m_pCache || m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY) @@ -2213,7 +2142,6 @@ Sequence< sal_Int32 > SAL_CALL ORowSet::deleteRows( const Sequence< Any >& rows // ----------------------------------------------------------------------------- void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::notifyRowSetAndClonesRowDelete" ); // notify ourself onDeleteRow( _rBookmark ); // notify the clones @@ -2231,7 +2159,6 @@ void ORowSet::notifyRowSetAndClonesRowDelete( const Any& _rBookmark ) //------------------------------------------------------------------------------ void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 _nPos ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::notifyRowSetAndClonesRowDeleted" ); // notify ourself onDeletedRow( _rBookmark, _nPos ); // notify the clones @@ -2249,7 +2176,6 @@ void ORowSet::notifyRowSetAndClonesRowDeleted( const Any& _rBookmark, sal_Int32 //------------------------------------------------------------------------------ Reference< XConnection > ORowSet::calcConnection(const Reference< XInteractionHandler >& _rxHandler) throw( SQLException, RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::calcConnection" ); MutexGuard aGuard(m_aMutex); if (!m_xActiveConnection.is()) { @@ -2294,7 +2220,6 @@ Reference< XConnection > ORowSet::calcConnection(const Reference< XInteractionH //------------------------------------------------------------------------------ Reference< XNameAccess > ORowSet::impl_getTables_throw() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::impl_getTables_throw" ); Reference< XNameAccess > xTables; Reference< XTablesSupplier > xTablesAccess( m_xActiveConnection, UNO_QUERY ); @@ -2335,7 +2260,6 @@ Reference< XNameAccess > ORowSet::impl_getTables_throw() //------------------------------------------------------------------------------ void ORowSet::impl_resetTables_nothrow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::impl_resetTables_nothrow" ); if ( !m_pTables ) return; @@ -2354,7 +2278,6 @@ void ORowSet::impl_resetTables_nothrow() //------------------------------------------------------------------------------ sal_Bool ORowSet::impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecute ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::impl_initComposer_throw" ); sal_Bool bUseEscapeProcessing = impl_buildActiveCommand_throw( ); _out_rCommandToExecute = m_aActiveCommand; if ( !bUseEscapeProcessing ) @@ -2405,7 +2328,6 @@ sal_Bool ORowSet::impl_initComposer_throw( ::rtl::OUString& _out_rCommandToExecu //------------------------------------------------------------------------------ sal_Bool ORowSet::impl_buildActiveCommand_throw() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::impl_buildActiveCommand_throw" ); // create the sql command // from a table name or get the command out of a query (not a view) // the last use the command as it is @@ -2516,7 +2438,6 @@ sal_Bool ORowSet::impl_buildActiveCommand_throw() //------------------------------------------------------------------------------ void ORowSet::impl_initParametersContainer_nothrow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::impl_initParametersContainer_nothrow" ); OSL_PRECOND( !m_pParameters.is(), "ORowSet::impl_initParametersContainer_nothrow: already initialized the parameters!" ); m_pParameters = new param::ParameterWrapperContainer( m_xComposer.get() ); @@ -2531,7 +2452,6 @@ void ORowSet::impl_initParametersContainer_nothrow() //------------------------------------------------------------------------------ void ORowSet::impl_disposeParametersContainer_nothrow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::impl_disposeParametersContainer_nothrow" ); if ( !m_pParameters.is() ) return; @@ -2550,11 +2470,18 @@ void ORowSet::impl_disposeParametersContainer_nothrow() // ----------------------------------------------------------------------------- ORowSetValue& ORowSet::getParameterStorage(sal_Int32 parameterIndex) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::getParameterStorage" ); ::connectivity::checkDisposed( ORowSet_BASE1::rBHelper.bDisposed ); if ( parameterIndex < 1 ) throwInvalidIndexException( *this ); + if ( m_aParametersSet.size() < (size_t)parameterIndex ) + m_aParametersSet.resize( parameterIndex ,false); + m_aParametersSet[parameterIndex - 1] = true; + + if ( m_aParametersSet.size() < (size_t)parameterIndex ) + m_aParametersSet.resize( parameterIndex ,false); + m_aParametersSet[parameterIndex - 1] = true; + if ( m_pParameters.is() ) { if ( m_bCommandFacetsDirty ) @@ -2577,7 +2504,6 @@ ORowSetValue& ORowSet::getParameterStorage(sal_Int32 parameterIndex) // XParameters void SAL_CALL ORowSet::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setNull" ); ::osl::MutexGuard aGuard( m_aColumnsMutex ); getParameterStorage( parameterIndex ).setNull(); @@ -2585,13 +2511,11 @@ void SAL_CALL ORowSet::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setObjectNull" ); setNull( parameterIndex, sqlType ); } // ----------------------------------------------------------------------------- void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setParameter" ); ::osl::MutexGuard aGuard( m_aColumnsMutex ); getParameterStorage( parameterIndex ) = x; @@ -2600,79 +2524,66 @@ void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x) // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setBoolean" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setByte" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setShort" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setInt" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setLong" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setFloat" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setDouble" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setString" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setBytes" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setDate" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setTime" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setTimestamp" ); setParameter(parameterIndex,x); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setBinaryStream" ); ::osl::MutexGuard aGuard( m_aColumnsMutex ); ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) ); @@ -2691,7 +2602,6 @@ void SAL_CALL ORowSet::setBinaryStream( sal_Int32 parameterIndex, const Referenc // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setCharacterStream" ); ::osl::MutexGuard aGuard( m_aColumnsMutex ); ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) ); try @@ -2714,7 +2624,6 @@ void SAL_CALL ORowSet::setCharacterStream( sal_Int32 parameterIndex, const Refer // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setObject" ); if ( !::dbtools::implSetObject( this, parameterIndex, x ) ) { // there is no other setXXX call which can handle the value in x throw SQLException(); @@ -2723,7 +2632,6 @@ void SAL_CALL ORowSet::setObject( sal_Int32 parameterIndex, const Any& x ) throw // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 targetSqlType, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setObjectWithInfo" ); ::osl::MutexGuard aGuard( m_aColumnsMutex ); ORowSetValue& rParamValue( getParameterStorage( parameterIndex ) ); setObject( parameterIndex, x ); @@ -2732,31 +2640,26 @@ void SAL_CALL ORowSet::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setRef" ); ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this ); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setBlob" ); ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this ); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setClob" ); ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this ); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::setArray" ); ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this ); } // ------------------------------------------------------------------------- void SAL_CALL ORowSet::clearParameters( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::clearParameters" ); ::connectivity::checkDisposed(ORowSet_BASE1::rBHelper.bDisposed); ::osl::MutexGuard aGuard( m_aColumnsMutex ); @@ -2764,11 +2667,11 @@ void SAL_CALL ORowSet::clearParameters( ) throw(SQLException, RuntimeException) size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() ); for ( size_t i=1; i<=nParamCount; ++i ) getParameterStorage( (sal_Int32)i ).setNull(); + m_aParametersSet.clear(); } // ------------------------------------------------------------------------- void ORowSet::firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetValue& _rOldValue) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::firePropertyChange" ); OSL_ENSURE(_nPos < (sal_Int32)m_aDataColumns.size(),"nPos is invalid!"); m_aDataColumns[_nPos]->fireValueChange(_rOldValue); } @@ -2776,7 +2679,6 @@ void ORowSet::firePropertyChange(sal_Int32 _nPos,const ::connectivity::ORowSetVa // ----------------------------------------------------------------------------- void ORowSet::doCancelModification( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::doCancelModification" ); //OSL_ENSURE( isModification(), "ORowSet::doCancelModification: invalid call (no cache!)!" ); if ( isModification() ) m_pCache->cancelRowModification(); @@ -2786,28 +2688,24 @@ void ORowSet::doCancelModification( ) // ----------------------------------------------------------------------------- sal_Bool ORowSet::isModification( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::isModification" ); return isNew(); } // ----------------------------------------------------------------------------- sal_Bool ORowSet::isModified( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::isModified" ); return m_bModified; } // ----------------------------------------------------------------------------- sal_Bool ORowSet::isNew( ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::isNew" ); return m_bNew; } // ----------------------------------------------------------------------------- void ORowSet::checkUpdateIterator() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::checkUpdateIterator" ); if(!m_bModified && !m_bNew) { m_pCache->setUpdateIterator(m_aCurrentRow); @@ -2820,12 +2718,11 @@ void ORowSet::checkUpdateIterator() // ----------------------------------------------------------------------------- void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::checkUpdateConditions" ); checkCache(); if ( columnIndex <= 0 ) throwSQLException( "Invalid column index", SQL_INVALID_DESCRIPTOR_INDEX, *this ); // TODO: resource - if ( impl_rowDeleted() ) + if ( rowDeleted() ) throwSQLException( "Current row is deleted", SQL_INVALID_CURSOR_POSITION, *this ); // TODO: resource if ( m_aCurrentRow.isNull() ) @@ -2841,7 +2738,6 @@ void ORowSet::checkUpdateConditions(sal_Int32 columnIndex) // ----------------------------------------------------------------------------- void SAL_CALL ORowSet::refreshRow( ) throw(SQLException, RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "ORowSet::refreshRow" ); ORowSetNotifier aNotifier( this ); // this will call cancelRowModification on the cache if necessary @@ -2893,45 +2789,47 @@ ORowSetClone::ORowSetClone( const ::comphelper::ComponentContext& _rContext, ORo // Locale aLocale; // pConfigMgr->GetDirectConfigProperty(ConfigManager::LOCALE) >>= aLocale; Locale aLocale = SvtSysLocale().GetLocaleData().getLocale(); - const Reference<XDatabaseMetaData> xMetaData( rParent.m_xActiveConnection->getMetaData() ); - const Reference< XResultSetMetaData > xRowMetaData( rParent.getMetaData() ); - - Sequence< ::rtl::OUString> aSeq = rParent.m_pColumns->getElementNames(); - const ::rtl::OUString* pIter = aSeq.getConstArray(); - const ::rtl::OUString* pEnd = pIter + aSeq.getLength(); - aColumns->get().reserve(aSeq.getLength()+1); - for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i) - { - Reference<XPropertySet> xColumn; - rParent.m_pColumns->getByName(*pIter) >>= xColumn; - if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION)) - aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); - - ORowSetColumn* pColumn = new ORowSetColumn( xRowMetaData, - this, - i, - xMetaData, - aDescription, - m_aCurrentRow); - aColumns->get().push_back(pColumn); - pColumn->setName(*pIter); - aNames.push_back(*pIter); - m_aDataColumns.push_back(pColumn); - - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN)); - sal_Int32 nFormatKey = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT)); - if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is()) - nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey)); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION)); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH)); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN)); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLMODEL,xColumn->getPropertyValue(PROPERTY_CONTROLMODEL)); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HELPTEXT,xColumn->getPropertyValue(PROPERTY_HELPTEXT)); - pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLDEFAULT,xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT)); - - } - m_pColumns = new ORowSetDataColumns(xMetaData.is() && xMetaData->supportsMixedCaseQuotedIdentifiers(), + + if ( rParent.m_pColumns ) + { + Sequence< ::rtl::OUString> aSeq = rParent.m_pColumns->getElementNames(); + const ::rtl::OUString* pIter = aSeq.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aSeq.getLength(); + aColumns->get().reserve(aSeq.getLength()+1); + for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i) + { + Reference<XPropertySet> xColumn; + rParent.m_pColumns->getByName(*pIter) >>= xColumn; + if(xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_DESCRIPTION)) + aDescription = comphelper::getString(xColumn->getPropertyValue(PROPERTY_DESCRIPTION)); + + ORowSetColumn* pColumn = new ORowSetColumn( rParent.getMetaData(), + this, + i, + rParent.m_xActiveConnection->getMetaData(), + aDescription, + m_aCurrentRow); + aColumns->get().push_back(pColumn); + pColumn->setName(*pIter); + aNames.push_back(*pIter); + m_aDataColumns.push_back(pColumn); + + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_ALIGN,xColumn->getPropertyValue(PROPERTY_ALIGN)); + sal_Int32 nFormatKey = comphelper::getINT32(xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT)); + if(!nFormatKey && xColumn.is() && m_xNumberFormatTypes.is()) + nFormatKey = ::dbtools::getDefaultNumberFormat(xColumn,m_xNumberFormatTypes,aLocale); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_NUMBERFORMAT,makeAny(nFormatKey)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_RELATIVEPOSITION,xColumn->getPropertyValue(PROPERTY_RELATIVEPOSITION)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_WIDTH,xColumn->getPropertyValue(PROPERTY_WIDTH)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HIDDEN,xColumn->getPropertyValue(PROPERTY_HIDDEN)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLMODEL,xColumn->getPropertyValue(PROPERTY_CONTROLMODEL)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_HELPTEXT,xColumn->getPropertyValue(PROPERTY_HELPTEXT)); + pColumn->setFastPropertyValue_NoBroadcast(PROPERTY_ID_CONTROLDEFAULT,xColumn->getPropertyValue(PROPERTY_CONTROLDEFAULT)); + + } // for(sal_Int32 i=1;pIter != pEnd ;++pIter,++i) + } + Reference<XDatabaseMetaData> xMeta = rParent.m_xActiveConnection->getMetaData(); + m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(), aColumns,*this,m_aMutex,aNames); sal_Int32 nRT = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT; diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx index 843f970bcae5..b36608f1c495 100644 --- a/dbaccess/source/core/api/RowSet.hxx +++ b/dbaccess/source/core/api/RowSet.hxx @@ -131,6 +131,7 @@ namespace dbaccess (since we have not been executed, yet) */ ORowSetValueVector m_aPrematureParamValues; + ::std::bit_vector m_aParametersSet; ::cppu::OInterfaceContainerHelper m_aRowsetListeners; ::cppu::OInterfaceContainerHelper m_aApproveListeners; diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx index 59737c5fc5d3..7067cf50fce9 100644 --- a/dbaccess/source/core/api/tablecontainer.cxx +++ b/dbaccess/source/core/api/tablecontainer.cxx @@ -66,6 +66,9 @@ #ifndef TOOLS_DIAGNOSE_EX_H #include <tools/diagnose_ex.h> #endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif using namespace dbaccess; using namespace dbtools; @@ -164,6 +167,7 @@ void OTableContainer::removeMasterContainerListener() // XServiceInfo //------------------------------------------------------------------------------ IMPLEMENT_SERVICE_INFO2(OTableContainer, "com.sun.star.sdb.dbaccess.OTableContainer", SERVICE_SDBCX_CONTAINER, SERVICE_SDBCX_TABLES) + // ----------------------------------------------------------------------------- namespace { diff --git a/dbaccess/source/core/inc/DatabaseDataProvider.hxx b/dbaccess/source/core/inc/DatabaseDataProvider.hxx index 68d67808e921..2e3d43443b88 100644 --- a/dbaccess/source/core/inc/DatabaseDataProvider.hxx +++ b/dbaccess/source/core/inc/DatabaseDataProvider.hxx @@ -202,10 +202,11 @@ private: virtual void SAL_CALL disposing(); void impl_fillRowSet_throw(); - void impl_executeRowSet_nothrow(::osl::ResettableMutexGuard& _rClearForNotifies); + void impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies); bool impl_fillParameters_nothrow( ::osl::ResettableMutexGuard& _rClearForNotifies); - void impl_fillInternalDataProvider_throw(); + void impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories); void impl_invalidateParameter_nothrow(); + ::com::sun::star::uno::Any impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const; template <typename T> void set( const ::rtl::OUString& _sProperty ,const T& _Value @@ -214,14 +215,18 @@ private: BoundListeners l; { ::osl::MutexGuard aGuard(m_aMutex); - prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); - _member = _Value; + if ( _member != _Value ) + { + prepareSet(_sProperty, ::com::sun::star::uno::makeAny(_member), ::com::sun::star::uno::makeAny(_Value), &l); + _member = _Value; + } } l.notify(); } ::dbtools::ParameterManager m_aParameterManager; ::dbtools::FilterManager m_aFilterManager; + ::std::map< ::rtl::OUString, ::com::sun::star::uno::Any> m_aNumberFormats; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xActiveConnection; diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index 33c437f970b9..cd16eb68a5ee 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -43,6 +43,8 @@ #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/sdbc/XResultSet.hpp> +#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp> +#include <com/sun/star/sdbc/XResultSetMetaData.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart/XChartDataArray.hpp> @@ -57,12 +59,6 @@ using ::com::sun::star::sdbc::SQLException; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::RuntimeException; // ----------------------------------------------------------------------------- -::rtl::OUString lcl_getLabel() -{ - static const ::rtl::OUString s_sLabel(RTL_CONSTASCII_USTRINGPARAM("label ")); - return s_sLabel; -} -// ----------------------------------------------------------------------------- DatabaseDataProvider::DatabaseDataProvider(uno::Reference< uno::XComponentContext > const & context) : TDatabaseDataProvider(m_aMutex), ::cppu::PropertySetMixin< chart2::data::XDatabaseDataProvider >( @@ -74,7 +70,7 @@ DatabaseDataProvider::DatabaseDataProvider(uno::Reference< uno::XComponentContex m_CommandType(sdb::CommandType::COMMAND), // #i94114 m_RowLimit(0), m_EscapeProcessing(sal_True), - m_ApplyFilter(sal_False) + m_ApplyFilter(sal_True) { m_xInternal.set( m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart.InternalDataProvider")),m_xContext ), uno::UNO_QUERY ); m_xRangeConversion.set(m_xInternal,uno::UNO_QUERY); @@ -171,48 +167,87 @@ void SAL_CALL DatabaseDataProvider::initialize(const uno::Sequence< uno::Any > & // ----------------------------------------------------------------------------- // chart2::data::XDataProvider: -::sal_Bool SAL_CALL DatabaseDataProvider::createDataSourcePossible(const uno::Sequence< beans::PropertyValue > & /*aArguments*/) throw (uno::RuntimeException) +::sal_Bool SAL_CALL DatabaseDataProvider::createDataSourcePossible(const uno::Sequence< beans::PropertyValue > & _aArguments) throw (uno::RuntimeException) { - ::osl::ResettableMutexGuard aClearForNotifies(m_aMutex); - bool bRet = false; - if ( m_Command.getLength() != 0 && m_xActiveConnection.is() ) + //::osl::ResettableMutexGuard aClearForNotifies(m_aMutex); + const beans::PropertyValue* pArgIter = _aArguments.getConstArray(); + const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength(); + for(;pArgIter != pArgEnd;++pArgIter) { - try + if ( pArgIter->Name.equalsAscii("DataRowSource") ) { - impl_fillRowSet_throw(); - impl_executeRowSet_nothrow(aClearForNotifies); - impl_fillInternalDataProvider_throw(); - bRet = true; - } - catch(const uno::Exception& /*e*/) + ::com::sun::star::chart::ChartDataRowSource eRowSource = ::com::sun::star::chart::ChartDataRowSource_COLUMNS; + pArgIter->Value >>= eRowSource; + if ( eRowSource != ::com::sun::star::chart::ChartDataRowSource_COLUMNS ) + return sal_False; + } // if ( pArgIter->Name.equalsAscii("DataRowSource") ) + else if ( pArgIter->Name.equalsAscii("CellRangeRepresentation") ) { + ::rtl::OUString sRange; + pArgIter->Value >>= sRange; + if ( !sRange.equalsAscii("all") ) + return sal_False; } - } - if ( !bRet ) // no command set or an error occured, use Internal data handler - { - uno::Reference< lang::XInitialization> xIni(m_xInternal,uno::UNO_QUERY); - if ( xIni.is() ) + else if ( pArgIter->Name.equalsAscii("FirstCellAsLabel") ) { - uno::Sequence< uno::Any > aArgs(1); - beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True)); - aArgs[0] <<= aParam; - xIni->initialize(aArgs); + sal_Bool bFirstCellAsLabel = sal_True; + pArgIter->Value >>= bFirstCellAsLabel; + if ( !bFirstCellAsLabel ) + return sal_False; } } - - return bRet; + return sal_True; } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- uno::Reference< chart2::data::XDataSource > SAL_CALL DatabaseDataProvider::createDataSource(const uno::Sequence< beans::PropertyValue > & _aArguments) throw (uno::RuntimeException, lang::IllegalArgumentException) { - osl::MutexGuard g(m_aMutex); - createDataSourcePossible(_aArguments); + osl::ResettableMutexGuard aClearForNotifies(m_aMutex); + if ( createDataSourcePossible(_aArguments) ) + { + sal_Bool bHasCategories = sal_True; + const beans::PropertyValue* pArgIter = _aArguments.getConstArray(); + const beans::PropertyValue* pArgEnd = pArgIter + _aArguments.getLength(); + for(;pArgIter != pArgEnd;++pArgIter) + { + if ( pArgIter->Name.equalsAscii("HasCategories") ) + { + pArgIter->Value >>= bHasCategories; + break; + } + } + bool bRet = false; + if ( m_Command.getLength() != 0 && m_xActiveConnection.is() ) + { + try + { + impl_fillRowSet_throw(); + impl_executeRowSet_throw(aClearForNotifies); + impl_fillInternalDataProvider_throw(bHasCategories); + bRet = true; + } + catch(const uno::Exception& /*e*/) + { + } + } + if ( !bRet ) // no command set or an error occured, use Internal data handler + { + uno::Reference< lang::XInitialization> xIni(m_xInternal,uno::UNO_QUERY); + if ( xIni.is() ) + { + uno::Sequence< uno::Any > aArgs(1); + beans::NamedValue aParam(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),uno::makeAny(sal_True)); + aArgs[0] <<= aParam; + xIni->initialize(aArgs); + } + } + + } return m_xInternal->createDataSource(_aArguments); } // ----------------------------------------------------------------------------- -uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArguments(const uno::Reference< chart2::data::XDataSource > & /*xDataSource*/) throw (uno::RuntimeException) +uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArguments(const uno::Reference< chart2::data::XDataSource > & _xDataSource) throw (uno::RuntimeException) { uno::Sequence< beans::PropertyValue > aArguments( 4 ); aArguments[0] = beans::PropertyValue( @@ -224,8 +259,30 @@ uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArgum // internal data always contains labels and categories aArguments[2] = beans::PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); + sal_Bool bHasCategories = sal_False; + if( _xDataSource.is()) + { + uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences(_xDataSource->getDataSequences()); + const sal_Int32 nCount( aSequences.getLength()); + for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx ) + { + if( aSequences[nIdx].is() ) + { + uno::Reference< beans::XPropertySet > xSeqProp( aSequences[nIdx]->getValues(), uno::UNO_QUERY ); + ::rtl::OUString aRole; + if( xSeqProp.is() && + (xSeqProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole) && + aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) ) + { + bHasCategories = sal_True; + break; + } + } + } + } + aArguments[3] = beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")), -1, uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ); return aArguments; } // ----------------------------------------------------------------------------- @@ -235,11 +292,25 @@ uno::Sequence< beans::PropertyValue > SAL_CALL DatabaseDataProvider::detectArgum return sal_True; } // ----------------------------------------------------------------------------- - +uno::Any DatabaseDataProvider::impl_getNumberFormatKey_nothrow(const ::rtl::OUString & _sRangeRepresentation) const +{ + ::std::map< ::rtl::OUString,com::sun::star::uno::Any>::const_iterator aFind = m_aNumberFormats.find(_sRangeRepresentation); + if ( aFind != m_aNumberFormats.end() ) + return aFind->second; + return uno::makeAny(sal_Int32(0)); +} +// ----------------------------------------------------------------------------- uno::Reference< chart2::data::XDataSequence > SAL_CALL DatabaseDataProvider::createDataSequenceByRangeRepresentation(const ::rtl::OUString & _sRangeRepresentation) throw (uno::RuntimeException, lang::IllegalArgumentException) { osl::MutexGuard g(m_aMutex); - return m_xInternal->createDataSequenceByRangeRepresentation(_sRangeRepresentation); + uno::Reference< chart2::data::XDataSequence > xData = m_xInternal->createDataSequenceByRangeRepresentation(_sRangeRepresentation);; + uno::Reference<beans::XPropertySet> xProp(xData,uno::UNO_QUERY); + const static ::rtl::OUString s_sNumberFormatKey(RTL_CONSTASCII_USTRINGPARAM("NumberFormatKey")); + if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName(s_sNumberFormatKey) ) + { + xProp->setPropertyValue(s_sNumberFormatKey,impl_getNumberFormatKey_nothrow(_sRangeRepresentation)); + } + return xData; } // ----------------------------------------------------------------------------- @@ -499,19 +570,13 @@ void SAL_CALL DatabaseDataProvider::setDataSourceName(const ::rtl::OUString& the set(PROPERTY_DATASOURCENAME,the_value,m_DataSourceName); } // ----------------------------------------------------------------------------- -void DatabaseDataProvider::impl_executeRowSet_nothrow(::osl::ResettableMutexGuard& _rClearForNotifies) +void DatabaseDataProvider::impl_executeRowSet_throw(::osl::ResettableMutexGuard& _rClearForNotifies) { - try - { - if ( impl_fillParameters_nothrow(_rClearForNotifies) ) - m_xRowSet->execute(); - } - catch(const uno::Exception&) - { - } + if ( impl_fillParameters_nothrow(_rClearForNotifies) ) + m_xRowSet->execute(); } // ----------------------------------------------------------------------------- -void DatabaseDataProvider::impl_fillInternalDataProvider_throw() +void DatabaseDataProvider::impl_fillInternalDataProvider_throw(sal_Bool _bHasCategories) { // clear the data before fill the new one uno::Reference< chart::XChartDataArray> xChartData(m_xInternal,uno::UNO_QUERY); @@ -522,31 +587,57 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw() m_xInternal->deleteSequence(0); } - uno::Sequence< ::rtl::OUString > aColumns = ::dbtools::getFieldNamesByCommandDescriptor(getActiveConnection() - ,getCommandType() - ,m_Command); - + uno::Sequence< ::rtl::OUString > aColumns; + uno::Reference< sdbcx::XColumnsSupplier> xColSup(m_xRowSet,uno::UNO_QUERY_THROW); + uno::Reference< container::XNameAccess > xColumns = xColSup->getColumns(); + if ( xColumns.is() ) + aColumns = xColumns->getElementNames(); // fill the data uno::Reference< sdbc::XResultSet> xRes(m_xRowSet,uno::UNO_QUERY_THROW); uno::Reference< sdbc::XRow> xRow(m_xRowSet,uno::UNO_QUERY_THROW); + uno::Reference< sdbc::XResultSetMetaData> xResultSetMetaData = uno::Reference< sdbc::XResultSetMetaDataSupplier>(m_xRowSet,uno::UNO_QUERY)->getMetaData(); + ::std::vector<sal_Int32> aColumnTypes; uno::Sequence< uno::Any > aLabelArgs(1); const sal_Int32 nCount = aColumns.getLength(); + if ( nCount ) + aColumnTypes.push_back(xResultSetMetaData->getColumnType(1)); for (sal_Int32 i = 1; i < nCount; ++i) { - aLabelArgs[0] <<= aColumns[i]; // i == 0 is the category - const ::rtl::OUString sLabelRange = lcl_getLabel() + ::rtl::OUString::valueOf(i - 1); - m_xInternal->setDataByRangeRepresentation(sLabelRange,aLabelArgs); + aColumnTypes.push_back(xResultSetMetaData->getColumnType(i+1)); + } // for (sal_Int32 i = 1; i < nCount; ++i) + + const ::rtl::OUString* pIter = aColumns.getConstArray(); + const ::rtl::OUString* pEnd = pIter + aColumns.getLength(); + for(sal_Int32 k = 0;pIter != pEnd;++pIter,++k) + { + uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(*pIter),uno::UNO_QUERY); + if ( xColumn.is() ) + { + m_aNumberFormats.insert( ::std::map< ::rtl::OUString,uno::Any>::value_type(::rtl::OUString::valueOf(k),xColumn->getPropertyValue(PROPERTY_NUMBERFORMAT))); + } } - ::std::vector< ::std::vector< uno::Any > > aDataValues(nCount); + ::std::vector< ::rtl::OUString > aRowLabels; + ::std::vector< ::std::vector< double > > aDataValues; sal_Int32 nRowCount = 0; + ::connectivity::ORowSetValue aValue; while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) ) { ++nRowCount; - for (sal_Int32 j = 1; j <= nCount; ++j) - aDataValues[j-1].push_back(uno::makeAny(xRow->getString(j))); + + aValue.fill(1,aColumnTypes[0],xRow); + aRowLabels.push_back(aValue.getString()); + ::std::vector< double > aRow; + for (sal_Int32 j = _bHasCategories ? 2 : 1,i = 0; j <= nCount; ++j,++i) + { + aValue.fill(j,aColumnTypes[j-1],xRow); + aRow.push_back(aValue.getDouble()); + } // for (sal_Int32 j = 2,i = 0; j <= nCount; ++j,++i) + aDataValues.push_back(aRow); } // while( xRes->next() && (!m_RowLimit || nRowCount < m_RowLimit) ) + + // insert default data when no rows exist if ( !nRowCount ) { nRowCount = 3; @@ -555,30 +646,33 @@ void DatabaseDataProvider::impl_fillInternalDataProvider_throw() 2.40, 8.80, 9.65, 3.10, 1.50, 3.70, 4.30, 9.02, 6.20 }; - for (sal_Int32 j = 1,k = 0; j <= nCount; ++j,++k) + for(sal_Int32 h = 0,k = 0; h < nRowCount; ++h,++k ) { - sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]); - if ( k >= nSize ) - k = 0; - aDataValues[j-1].push_back(uno::makeAny(fDefaultData[k])); - } - } - ::std::vector< ::std::vector< uno::Any > >::iterator aDataValuesIter = aDataValues.begin(); - const ::std::vector< ::std::vector< uno::Any > >::iterator aDataValuesEnd = aDataValues.end(); - bool bFirst = true; - for (sal_Int32 nPos = 0;nRowCount && aDataValuesIter != aDataValuesEnd ; ++aDataValuesIter,++nPos) - { - if ( !aDataValuesIter->empty() ) - { - if ( bFirst ) + aRowLabels.push_back(::rtl::OUString::valueOf(h+1)); + ::std::vector< double > aRow; + const sal_Int32 nSize = sizeof(fDefaultData)/sizeof(fDefaultData[0]); + for (sal_Int32 j = 0; j < (nCount-1); ++j,++k) { - m_xInternal->setDataByRangeRepresentation(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("categories")),uno::Sequence< uno::Any >(&(*aDataValuesIter->begin()),aDataValuesIter->size())); - bFirst = false; - } - else - m_xInternal->setDataByRangeRepresentation(::rtl::OUString::valueOf(nPos-1),uno::Sequence< uno::Any >(&(*aDataValuesIter->begin()),aDataValuesIter->size())); + if ( k >= nSize ) + k = 0; + aRow.push_back(fDefaultData[k]); + } // for (sal_Int32 j = 0,k = 0; j < (nCount-1); ++j,++k) + aDataValues.push_back(aRow); } - } // for (sal_Int32 nPos = 0;nRowCount && aDataValuesIter != aDataValuesEnd ; ++aDataValuesIter,++nPos) + } // if ( !nRowCount ) + + uno::Reference< chart::XChartDataArray> xData(m_xInternal,uno::UNO_QUERY); + xData->setRowDescriptions(uno::Sequence< ::rtl::OUString >(&(*aRowLabels.begin()),aRowLabels.size())); + xData->setColumnDescriptions(uno::Sequence< ::rtl::OUString >(aColumns.getArray()+ (_bHasCategories ? 1 : 0),aColumns.getLength() - (_bHasCategories ? 1 : 0) )); + uno::Sequence< uno::Sequence< double > > aData(aDataValues.size()); + uno::Sequence< double >* pDataIter = aData.getArray(); + uno::Sequence< double >* pDataEnd = pDataIter + aData.getLength(); + for(sal_Int32 i= 0;pDataIter != pDataEnd; ++pDataIter,++i ) + { + if ( !aDataValues[i].empty() ) + *pDataIter = uno::Sequence< double >(&(*(aDataValues[i]).begin()),(aDataValues[i]).size()); + } + xData->setData(aData); } // ----------------------------------------------------------------------------- void DatabaseDataProvider::impl_fillRowSet_throw() @@ -743,7 +837,7 @@ void SAL_CALL DatabaseDataProvider::clearParameters() throw( SQLException, Runti void SAL_CALL DatabaseDataProvider::execute() throw( SQLException, RuntimeException ) { uno::Sequence< beans::PropertyValue > aEmpty; - createDataSourcePossible(aEmpty); + createDataSource(aEmpty); } //------------------------------------------------------------------------------ void SAL_CALL DatabaseDataProvider::addRowSetListener(const uno::Reference<sdbc::XRowSetListener>& _rListener) throw( RuntimeException ) @@ -886,4 +980,3 @@ void DatabaseDataProvider::impl_invalidateParameter_nothrow() } // ----------------------------------------------------------------------------- } // namespace dbaccess - diff --git a/dbaccess/source/ext/macromigration/makefile.mk b/dbaccess/source/ext/macromigration/makefile.mk index 880a62afc173..32be89263968 100644 --- a/dbaccess/source/ext/macromigration/makefile.mk +++ b/dbaccess/source/ext/macromigration/makefile.mk @@ -79,7 +79,8 @@ SHL1STDLIBS= \ $(SVLLIB) \ $(VCLLIB) \ $(SVXLIB) \ - $(UCBHELPERLIB) + $(UCBHELPERLIB) \ + $(XMLSCRIPTLIB) SHL1LIBS= $(SLB)$/$(TARGET).lib SHL1IMPLIB= i$(TARGET) diff --git a/dbaccess/source/ext/macromigration/migrationengine.cxx b/dbaccess/source/ext/macromigration/migrationengine.cxx index acb3cfcfca22..c1d1c41eca39 100644 --- a/dbaccess/source/ext/macromigration/migrationengine.cxx +++ b/dbaccess/source/ext/macromigration/migrationengine.cxx @@ -68,6 +68,8 @@ #include <com/sun/star/script/XEventAttacherManager.hpp> #include <com/sun/star/script/XLibraryContainerPassword.hpp> #include <com/sun/star/io/WrongFormatException.hpp> +#include <com/sun/star/script/XScriptEventsSupplier.hpp> +#include <com/sun/star/io/XInputStreamProvider.hpp> /** === end UNO includes === **/ #include <comphelper/documentinfo.hxx> @@ -82,6 +84,7 @@ #include <rtl/ustrbuf.hxx> #include <rtl/ref.hxx> #include <unotools/sharedunocomponent.hxx> +#include <xmlscript/xmldlg_imexp.hxx> #include <vector> #include <set> @@ -143,6 +146,9 @@ namespace dbmm using ::com::sun::star::script::ScriptEventDescriptor; using ::com::sun::star::script::XLibraryContainerPassword; using ::com::sun::star::io::WrongFormatException; + using ::com::sun::star::script::XScriptEventsSupplier; + using ::com::sun::star::io::XInputStreamProvider; + using ::com::sun::star::io::XInputStream; /** === end UNO using === **/ namespace ElementModes = ::com::sun::star::embed::ElementModes; @@ -925,6 +931,23 @@ namespace dbmm const PhaseID _nPhaseID ) const; + /** adjusts the events for the given dialog/element, taking into account the new names + of the moved libraries + */ + void impl_adjustDialogElementEvents_throw( + const Reference< XInterface >& _rxElement + ) const; + + /** adjusts the events in the given dialog, and its controls, taking into account the new names + of the moved libraries + */ + bool impl_adjustDialogEvents_nothrow( + Any& _inout_rDialogLibraryElement, + const ::rtl::OUString& _rDocName, + const ::rtl::OUString& _rDialogLibName, + const ::rtl::OUString& _rDialogName + ) const; + /** adjust the document-events which refer to macros/scripts in the document, taking into account the new names of the moved libraries */ @@ -1158,6 +1181,8 @@ namespace dbmm bSuccess = bSuccess && impl_migrateContainerLibraries_nothrow( aSubDocument, eBasic, aProgressMixer, PHASE_BASIC ) && impl_migrateContainerLibraries_nothrow( aSubDocument, eDialog, aProgressMixer, PHASE_DIALOGS ); + // order matters: First Basic scripts, then dialogs. So we can adjust references from the latter + // to the former // adjust the events in the document // (note that errors are ignored here - failure to convert a script reference @@ -1547,6 +1572,14 @@ namespace dbmm Any aElement = xSourceLib->getByName( *pSourceElementName ); OSL_ENSURE( aElement.hasValue(), "MigrationEngine_Impl::impl_migrateContainerLibraries_nothrow: invalid (empty) lib element!" ); + + // if this is a dialog, adjust the references to scripts + if ( _eScriptType == eDialog ) + { + impl_adjustDialogEvents_nothrow( aElement, lcl_getSubDocumentDescription( _rDocument ), + *pSourceLibName, *pSourceElementName ); + } + xTargetLib->insertByName( *pSourceElementName, aElement ); } @@ -1773,6 +1806,71 @@ namespace dbmm } //-------------------------------------------------------------------- + void MigrationEngine_Impl::impl_adjustDialogElementEvents_throw( const Reference< XInterface >& _rxElement ) const + { + Reference< XScriptEventsSupplier > xEventsSupplier( _rxElement, UNO_QUERY_THROW ); + Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW ); + Sequence< ::rtl::OUString > aEventNames( xEvents->getElementNames() ); + + const ::rtl::OUString* eventName = aEventNames.getArray(); + const ::rtl::OUString* eventNamesEnd = eventName + aEventNames.getLength(); + + ScriptEventDescriptor aScriptEvent; + for ( ; eventName != eventNamesEnd; ++eventName ) + { + OSL_VERIFY( xEvents->getByName( *eventName ) >>= aScriptEvent ); + + if ( !impl_adjustScriptLibrary_nothrow( aScriptEvent ) ) + continue; + + xEvents->replaceByName( *eventName, makeAny( aScriptEvent ) ); + } + } + + //-------------------------------------------------------------------- + bool MigrationEngine_Impl::impl_adjustDialogEvents_nothrow( Any& _inout_rDialogLibraryElement, + const ::rtl::OUString& _rDocName, const ::rtl::OUString& _rDialogLibName, const ::rtl::OUString& _rDialogName ) const + { + try + { + // load a dialog model from the stream describing it + Reference< XInputStreamProvider > xISP( _inout_rDialogLibraryElement, UNO_QUERY_THROW ); + Reference< XInputStream > xInput( xISP->createInputStream(), UNO_QUERY_THROW ); + + Reference< XNameContainer > xDialogModel( m_aContext.createComponent( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY_THROW ); + ::xmlscript::importDialogModel( xInput, xDialogModel, m_aContext.getUNOContext() ); + + // adjust the events of the dialog + impl_adjustDialogElementEvents_throw( xDialogModel ); + + // adjust the events of the controls + Sequence< ::rtl::OUString > aControlNames( xDialogModel->getElementNames() ); + const ::rtl::OUString* controlName = aControlNames.getConstArray(); + const ::rtl::OUString* controlNamesEnd = controlName + aControlNames.getLength(); + for ( ; controlName != controlNamesEnd; ++controlName ) + { + impl_adjustDialogElementEvents_throw( Reference< XInterface >( xDialogModel->getByName( *controlName ), UNO_QUERY ) ); + } + + // export dialog model + xISP = ::xmlscript::exportDialogModel( xDialogModel, m_aContext.getUNOContext() ); + _inout_rDialogLibraryElement <<= xISP; + } + catch( const Exception& ) + { + m_rLogger.logRecoverable( MigrationError( + ERR_ADJUSTING_DIALOG_EVENTS_FAILED, + _rDocName, + _rDialogLibName, + _rDialogName, + ::cppu::getCaughtException() + ) ); + return false; + } + return true; + } + + //-------------------------------------------------------------------- void MigrationEngine_Impl::impl_adjustFormComponentEvents_throw( const Reference< XIndexAccess >& _rxComponentContainer ) const { FormComponentIterator aCompIter( _rxComponentContainer ); diff --git a/dbaccess/source/ext/macromigration/migrationerror.hxx b/dbaccess/source/ext/macromigration/migrationerror.hxx index 84b972f0e9bf..fa7e058a5622 100644 --- a/dbaccess/source/ext/macromigration/migrationerror.hxx +++ b/dbaccess/source/ext/macromigration/migrationerror.hxx @@ -59,6 +59,7 @@ namespace dbmm ERR_SCRIPT_TRANSLATION_FAILURE, ERR_INVALID_SCRIPT_DESCRIPTOR_FORMAT, ERR_ADJUSTING_DOCUMENT_EVENTS_FAILED, + ERR_ADJUSTING_DIALOG_EVENTS_FAILED, ERR_ADJUSTING_FORMCOMP_EVENTS_FAILED, ERR_BIND_SCRIPT_STORAGE_FAILED, ERR_REMOVE_SCRIPTS_STORAGE_FAILED, @@ -136,6 +137,18 @@ namespace dbmm const MigrationErrorType _eType, const ::rtl::OUString& _rDetail1, const ::rtl::OUString& _rDetail2, + const ::rtl::OUString& _rDetail3, + const ::com::sun::star::uno::Any& _rCaughtException ) + :eType( _eType ) + ,aCaughtException( _rCaughtException ) + { + impl_constructDetails( _rDetail1, _rDetail2, _rDetail3 ); + } + + MigrationError( + const MigrationErrorType _eType, + const ::rtl::OUString& _rDetail1, + const ::rtl::OUString& _rDetail2, const ::rtl::OUString& _rDetail3 ) :eType( _eType ) { diff --git a/dbaccess/source/ext/macromigration/migrationlog.cxx b/dbaccess/source/ext/macromigration/migrationlog.cxx index 1b22367857aa..0d3cb09427b8 100644 --- a/dbaccess/source/ext/macromigration/migrationlog.cxx +++ b/dbaccess/source/ext/macromigration/migrationlog.cxx @@ -329,6 +329,13 @@ namespace dbmm aAsciiParameterNames.push_back( "#doc#" ); break; + case ERR_ADJUSTING_DIALOG_EVENTS_FAILED: + pAsciiErrorDescription = "adjusting events for dialog #lib#.#dlg# in document '#doc#' failed"; + aAsciiParameterNames.push_back( "#doc#" ); + aAsciiParameterNames.push_back( "#lib#" ); + aAsciiParameterNames.push_back( "#dlg#" ); + break; + case ERR_ADJUSTING_FORMCOMP_EVENTS_FAILED: pAsciiErrorDescription = "adjusting form component events for '#doc#' failed"; aAsciiParameterNames.push_back( "#doc#" ); diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx index 2570822ca6e2..0b1be1189bd4 100644 --- a/dbaccess/source/ui/app/AppControllerGen.cxx +++ b/dbaccess/source/ui/app/AppControllerGen.cxx @@ -619,7 +619,7 @@ void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, co try { - m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _xDocument ); + m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _rxDefinition.is() ? _rxDefinition : _xDocument ); if ( _rxDefinition.is() ) { diff --git a/dbaccess/source/ui/app/subcomponentmanager.cxx b/dbaccess/source/ui/app/subcomponentmanager.cxx index 59a552ffc7cf..8ef4f77f20c7 100644 --- a/dbaccess/source/ui/app/subcomponentmanager.cxx +++ b/dbaccess/source/ui/app/subcomponentmanager.cxx @@ -36,6 +36,8 @@ #include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/embed/XComponentSupplier.hpp> +#include <com/sun/star/ucb/XCommandProcessor.hpp> #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> /** === end UNO includes === **/ @@ -73,6 +75,9 @@ namespace dbaui using ::com::sun::star::container::XEnumeration; using ::com::sun::star::util::XCloseable; using ::com::sun::star::awt::XTopWindow; + using ::com::sun::star::embed::XComponentSupplier; + using ::com::sun::star::ucb::XCommandProcessor; + using ::com::sun::star::ucb::Command; using ::com::sun::star::document::XDocumentEventBroadcaster; /** === end UNO using === **/ @@ -84,11 +89,13 @@ namespace dbaui struct SubComponentDescriptor { /// the frame which the component resides in. Must not be <NULL/> - Reference< XFrame > xFrame; + Reference< XFrame > xFrame; /// the controller of the sub component. Must not be <NULL/> - Reference< XController > xController; + Reference< XController > xController; /// the model of the sub component. Might be <NULL/> - Reference< XModel > xModel; + Reference< XModel > xModel; + /// the document definition which holds the component, if any + Reference< XCommandProcessor > xComponentCommandProcessor; SubComponentDescriptor() :xFrame() @@ -99,28 +106,53 @@ namespace dbaui SubComponentDescriptor( const Reference< XComponent >& _rxComponent ) { - xModel.set( _rxComponent, UNO_QUERY ); + if ( !impl_constructFrom( _rxComponent ) ) + { + Reference< XComponentSupplier > xCompSupp( _rxComponent, UNO_QUERY_THROW ); + Reference< XComponent > xComponent( xCompSupp->getComponent(), UNO_QUERY_THROW ); + if ( !impl_constructFrom( xComponent ) ) + throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal component type." ) ), NULL ); + xComponentCommandProcessor.set( _rxComponent, UNO_QUERY_THROW ); + } + } + + inline bool is() const { return xFrame.is(); } + private: + bool impl_constructFrom( const Reference< XComponent >& _rxComponent ) + { + // is it a model? + xModel.set( _rxComponent, UNO_QUERY ); if ( xModel.is() ) + { xController.set( xModel->getCurrentController(), UNO_SET_THROW ); - else - xController.set( _rxComponent, UNO_QUERY ); - - if ( xController.is() ) xFrame.set( xController->getFrame(), UNO_SET_THROW ); + } else - xFrame.set( _rxComponent, UNO_QUERY_THROW ); + { + // is it a controller? + xController.set( _rxComponent, UNO_QUERY ); + if ( xController.is() ) + { + xFrame.set( xController->getFrame(), UNO_SET_THROW ); + } + else + { + // is it a frame? + xFrame.set( _rxComponent, UNO_QUERY ); + if ( !xFrame.is() ) + return false; - // if the given component was a frame, then ensure we have a controller - if ( xFrame.is() && !xController.is() ) - xController.set( xFrame->getController(), UNO_SET_THROW ); + // ensure we have a controller + xController.set( xFrame->getController(), UNO_SET_THROW ); + } - // if the component was a frame or a controller, then check wether there is a model (not required) - if ( !xModel.is() ) + // check wether there is a model (not required) xModel.set( xController->getModel() ); - } + } - inline bool is() const { return xFrame.is(); } + return true; + } }; struct SelectSubComponent : public ::std::unary_function< SubComponentDescriptor, Reference< XComponent > > @@ -260,8 +292,32 @@ namespace dbaui } //---------------------------------------------------------------- + bool lcl_closeComponent( const Reference< XCommandProcessor >& _rxCommandProcessor ) + { + bool bSuccess = false; + try + { + Reference< XCommandProcessor > xCommandProcessor( _rxCommandProcessor, UNO_SET_THROW ); + sal_Int32 nCommandIdentifier = xCommandProcessor->createCommandIdentifier(); + + Command aCommand; + aCommand.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "close" ) ); + xCommandProcessor->execute( aCommand, nCommandIdentifier, NULL ); + bSuccess = true; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return bSuccess; + } + + //---------------------------------------------------------------- bool lcl_closeComponent( const SubComponentDescriptor& _rComponent ) { + if ( _rComponent.xComponentCommandProcessor.is() ) + return lcl_closeComponent( _rComponent.xComponentCommandProcessor ); + Reference< XController > xController( _rComponent.xController ); OSL_ENSURE( xController.is(), "lcl_closeComponent: invalid controller!" ); diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index fad75416bb3c..a9c757a3cf70 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -37,111 +37,44 @@ #define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK #define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN -#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX #include "FieldDescControl.hxx" -#endif -#ifndef DBAUI_FIELDCONTROLS_HXX #include "FieldControls.hxx" -#endif -#ifndef _ZFORLIST_HXX //autogen -#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svtools/zforlist.hxx> -#include <svtools/zforlist.hxx> -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif -#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX +#include <tools/diagnose_ex.h> #include "TableDesignHelpBar.hxx" -#endif -#ifndef _SV_SCRBAR_HXX #include <vcl/scrbar.hxx> -#endif -#ifndef _SV_BUTTON_HXX #include <vcl/button.hxx> -#endif -#ifndef _SVX_NUMFMTSH_HXX -#include <svx/numfmtsh.hxx> -#endif -#ifndef _DBU_CONTROL_HRC_ -#include "dbu_control.hrc" -#endif -#ifndef _DBU_TBL_HRC_ -#include "dbu_tbl.hrc" -#endif - -#ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> -#endif -#ifndef _SV_FIXED_HXX #include <vcl/fixed.hxx> -#endif -#ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> -#endif -#ifndef _VECTOR_ #include <vector> -#endif -#ifndef DBAUI_FIELDDESCRIPTIONS_HXX #include "FieldDescriptions.hxx" -#endif -#ifndef _SFXITEMPOOL_HXX -#include <svtools/itempool.hxx> -#endif -#ifndef DBAUI_SBATTRDLG_HXX #include "dlgattr.hxx" -#endif -#ifndef _SVX_SVXIDS_HRC +#include <svx/numfmtsh.hxx> #include <svx/svxids.hrc> -#endif -#ifndef _SVX_ALGITEM_HXX #include <svx/algitem.hxx> -#endif -#ifndef _SFXRNGITEM_HXX +#include <svtools/itempool.hxx> +#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svtools/zforlist.hxx> +#include <svtools/zforlist.hxx> #include <svtools/rngitem.hxx> -#endif -#ifndef _SFXINTITEM_HXX #include <svtools/intitem.hxx> -#endif -#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <svtools/numuno.hxx> +#include <svtools/transfer.hxx> #include <com/sun/star/lang/XUnoTunnel.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ #include <com/sun/star/util/NumberFormat.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATPREVIEWER_HPP_ #include <com/sun/star/util/XNumberFormatPreviewer.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ #include <com/sun/star/util/XNumberFormatTypes.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> -#endif -#ifndef DBAUI_ENUMTYPES_HXX #include "QEnumTypes.hxx" -#endif -#ifndef _DBA_DBACCESS_HELPID_HRC_ #include "dbaccess_helpid.hrc" -#endif -#ifndef _NUMUNO_HXX -#include <svtools/numuno.hxx> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> -#endif -#ifndef _COMPHELPER_NUMBERS_HXX_ +#include <connectivity/dbconversion.hxx> #include <comphelper/numbers.hxx> -#endif -#ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" -#endif #include <memory> -#ifndef _DBHELPER_DBCONVERSION_HXX_ -#include <connectivity/dbconversion.hxx> -#endif -#ifndef _TRANSFER_HXX -#include <svtools/transfer.hxx> -#endif +#include "dbu_control.hrc" +#include "dbu_tbl.hrc" + using namespace dbaui; using namespace dbtools; @@ -156,7 +89,6 @@ using namespace ::com::sun::star::util; // fuer die Controls auf der OFieldDescGenPage #define CONTROL_SPACING_X 18 // 6 #define CONTROL_SPACING_Y 4 -#define CONTROL_HEIGHT 10 #define CONTROL_WIDTH_1 160 // 100 #define CONTROL_WIDTH_2 100 // 60 #define CONTROL_WIDTH_3 250 @@ -185,6 +117,20 @@ namespace return nValue; } // ----------------------------------------------------------------------------- + template< typename T1, typename T2> void lcl_HideAndDeleteControl(short& _nPos,T1** _pControl,T2** _pControlText) + { + if ( *_pControl ) + { + --_nPos; + (*_pControl)->Hide(); + (*_pControlText)->Hide(); + delete *_pControl; + delete *_pControlText; + (*_pControl) = NULL; + (*_pControlText) = NULL; + } + } + } //================================================================== @@ -241,22 +187,7 @@ OFieldDescControl::OFieldDescControl( Window* pParent, const ResId& rResId, OTab { DBG_CTOR(OFieldDescControl,NULL); - m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG); - m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG); - m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); - m_pHorzScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); - m_pVertScroll->Show(); - m_pHorzScroll->Show(); - - m_pVertScroll->EnableClipSiblings(); - m_pHorzScroll->EnableClipSiblings(); - - m_pVertScroll->SetLineSize(1); - m_pVertScroll->SetPageSize(1); - m_pHorzScroll->SetLineSize(1); - m_pHorzScroll->SetPageSize(1); - - m_nOldVThumb = m_nOldHThumb = 0; + Contruct(); } //------------------------------------------------------------------------------ OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar ) @@ -305,7 +236,11 @@ OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHel ,pActFieldDescr(NULL) { DBG_CTOR(OFieldDescControl,NULL); - + Contruct(); +} +// ----------------------------------------------------------------------------- +void OFieldDescControl::Contruct() +{ m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG); m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG); m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); @@ -322,7 +257,6 @@ OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHel m_pHorzScroll->SetPageSize(1); m_nOldVThumb = m_nOldHThumb = 0; - } //------------------------------------------------------------------------------ @@ -451,7 +385,7 @@ void OFieldDescControl::CheckScrollBars() sal_uInt16 nActive = CountActiveAggregates(); // welches ist das letzte, was ganz drauf passt ? sal_uInt16 nLastVisible; - const sal_Int32 nControlHeight = LogicToPixel(Size(0, CONTROL_HEIGHT),MAP_APPFONT).Height(); + const sal_Int32 nControlHeight = GetMaxControlHeight(); const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height(); if (bNeedHScrollBar) nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight)); @@ -536,7 +470,7 @@ void OFieldDescControl::ScrollAllAggregates() if (m_nOldVThumb != m_pVertScroll->GetThumbPos()) { - const sal_Int32 nControlHeight = LogicToPixel(Size(0, CONTROL_HEIGHT),MAP_APPFONT).Height(); + const sal_Int32 nControlHeight = GetMaxControlHeight(); const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height(); nDeltaY = (m_nOldVThumb - m_pVertScroll->GetThumbPos()) * (nControl_Spacing_y + nControlHeight); m_nOldVThumb = m_pVertScroll->GetThumbPos(); @@ -573,7 +507,23 @@ sal_uInt16 OFieldDescControl::CountActiveAggregates() const ++nVisibleAggregates; return nVisibleAggregates; } +//------------------------------------------------------------------------------ +sal_Int32 OFieldDescControl::GetMaxControlHeight() const +{ + Size aHeight; + Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue}; + for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i) + { + if ( ppAggregates[i] ) + { + const Size aTemp( ppAggregates[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) ); + if ( aTemp.Height() > aHeight.Height() ) + aHeight.Height() = aTemp.Height(); + } // if ( ppAggregates[i] ) + } + return aHeight.Height(); +} //------------------------------------------------------------------------------ void OFieldDescControl::SetReadOnly( sal_Bool bReadOnly ) { @@ -909,7 +859,8 @@ void OFieldDescControl::ArrangeAggregates() // die Z-Order so, dass die Controls auch wirklich in derselben Reihenfolge durchwandert werden koennen, in der sie // hier angeordnet wurden - adAggregates[i].pctrlInputControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST); + adAggregates[i].pctrlTextControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST); + adAggregates[i].pctrlInputControl->SetZOrder(adAggregates[i].pctrlTextControl, WINDOW_ZORDER_BEHIND ); pZOrderPredecessor = adAggregates[i].pctrlInputControl; if (adAggregates[i].pctrlInputControl == pFormatSample) @@ -947,36 +898,18 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) if( pDefault ) return; m_nPos++; - pDefaultText =new FixedText( this ); - pDefaultText->SetText( ModuleRes(STR_DEFAULT_VALUE) ); + pDefaultText = CreateText(STR_DEFAULT_VALUE); pDefault = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER ); - pDefault->SetHelpId(HID_TAB_ENT_DEFAULT); - // SetPosSize( (Control**)&pDefaultText, m_nPos, 0 ); - // SetPosSize( (Control**)&pDefault, m_nPos, 3 ); - - pDefault->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pDefault->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pDefaultText->EnableClipSiblings(); - pDefault->EnableClipSiblings(); + InitializeControl(pDefault,HID_TAB_ENT_DEFAULT,false); break; case tpAutoIncrementValue: if( m_pAutoIncrementValue || !isAutoIncrementValueEnabled() ) return; m_nPos++; - m_pAutoIncrementValueText =new FixedText( this ); - m_pAutoIncrementValueText->SetText( ModuleRes(STR_AUTOINCREMENT_VALUE) ); + m_pAutoIncrementValueText = CreateText(STR_AUTOINCREMENT_VALUE); m_pAutoIncrementValue = new OPropEditCtrl( this, STR_HELP_AUTOINCREMENT_VALUE, FIELD_PRPOERTY_AUTOINCREMENT, WB_BORDER ); - m_pAutoIncrementValue->SetHelpId(HID_TAB_AUTOINCREMENTVALUE); - // SetPosSize( (Control**)&m_pAutoIncrementValueText, m_nPos, 0 ); - // SetPosSize( (Control**)&m_pAutoIncrementValue, m_nPos, 3 ); - - m_pAutoIncrementValue->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - m_pAutoIncrementValue->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - m_pAutoIncrementValueText->EnableClipSiblings(); - m_pAutoIncrementValue->EnableClipSiblings(); m_pAutoIncrementValue->SetText( getAutoIncrementValue() ); + InitializeControl(m_pAutoIncrementValue,HID_TAB_AUTOINCREMENTVALUE,false); break; case tpRequired: @@ -988,21 +921,14 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) if(xMetaData.is() && xMetaData->supportsNonNullableColumns()) { m_nPos++; - pRequiredText =new FixedText( this ); - pRequiredText->SetText( ModuleRes(STR_FIELD_REQUIRED) ); + pRequiredText = CreateText(STR_FIELD_REQUIRED); pRequired = new OPropListBoxCtrl( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN); - pRequired->SetHelpId(HID_TAB_ENT_REQUIRED); pRequired->InsertEntry( aYes ); pRequired->InsertEntry( aNo ); pRequired->SelectEntryPos(1); - pRequired->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); - - pRequired->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pRequired->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - pRequiredText->EnableClipSiblings(); - pRequired->EnableClipSiblings(); + InitializeControl(pRequired,HID_TAB_ENT_REQUIRED,true); } } break; @@ -1011,53 +937,28 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) if( pAutoIncrement ) return; m_nPos++; - pAutoIncrementText =new FixedText( this ); - pAutoIncrementText->SetText( ModuleRes(STR_FIELD_AUTOINCREMENT) ); + pAutoIncrementText = CreateText(STR_FIELD_AUTOINCREMENT); pAutoIncrement = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN ); - pAutoIncrement->SetHelpId(HID_TAB_ENT_AUTOINCREMENT); - pAutoIncrement->InsertEntry( aYes ); pAutoIncrement->InsertEntry( aNo ); pAutoIncrement->SelectEntryPos(0); - pAutoIncrement->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); - - pAutoIncrement->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pAutoIncrement->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pAutoIncrementText->EnableClipSiblings(); - pAutoIncrement->EnableClipSiblings(); + InitializeControl(pAutoIncrement,HID_TAB_ENT_AUTOINCREMENT,true); } break; case tpTextLen: if( pTextLen ) return; m_nPos++; - pTextLenText =new FixedText( this ); - pTextLenText->SetText( ModuleRes(STR_TEXT_LENGTH) ); - - pTextLen = new OPropNumericEditCtrl( this, STR_HELP_TEXT_LENGTH, FIELD_PROPERTY_TEXTLEN, WB_BORDER ); - pTextLen->SetDecimalDigits(0); - pTextLen->SetMin(0); - pTextLen->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig - pTextLen->SetStrictFormat(TRUE); - - pTextLen->SetHelpId(HID_TAB_ENT_TEXT_LEN); - - pTextLen->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pTextLen->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pTextLenText->EnableClipSiblings(); - pTextLen->EnableClipSiblings(); + pTextLenText = CreateText(STR_TEXT_LENGTH); + pTextLen = CreateNumericControl(STR_HELP_TEXT_LENGTH, FIELD_PROPERTY_TEXTLEN,HID_TAB_ENT_TEXT_LEN); break; case tpType: if( m_pType) return; m_nPos++; - m_pTypeText =new FixedText( this ); - m_pTypeText->SetText( ModuleRes(STR_TAB_FIELD_DATATYPE) ); + m_pTypeText = CreateText(STR_TAB_FIELD_DATATYPE); m_pType = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PRPOERTY_TYPE, WB_DROPDOWN ); - m_pType->SetHelpId(HID_TAB_ENT_TYPE); m_pType->SetDropDownLineCount(20); { const OTypeInfoMap* pTypeInfo = getTypeInfo(); @@ -1066,50 +967,48 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) m_pType->InsertEntry( aIter->second->aUIName ); } m_pType->SelectEntryPos(0); - m_pType->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); - - m_pType->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - m_pType->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - m_pTypeText->EnableClipSiblings(); - m_pType->EnableClipSiblings(); + InitializeControl(m_pType,HID_TAB_ENT_TYPE,true); break; case tpColumnName: if( m_pColumnName ) return; m_nPos++; { - Reference< XDatabaseMetaData> xMetaData = getMetaData(); - sal_uInt32 nMax = xMetaData.is() ? xMetaData->getMaxColumnNameLength() : EDIT_NOLIMIT; - m_pColumnNameText =new FixedText( this ); - m_pColumnNameText->SetText( ModuleRes(STR_TAB_FIELD_NAME) ); - ::rtl::OUString aTmpString( xMetaData.is() ? xMetaData->getExtraNameCharacters() : ::rtl::OUString() ); + sal_uInt32 nMax = EDIT_NOLIMIT; + ::rtl::OUString aTmpString; + try + { + Reference< XDatabaseMetaData> xMetaData = getMetaData(); + if ( xMetaData.is() ) + { + nMax = xMetaData->getMaxColumnNameLength(); + aTmpString = xMetaData->getExtraNameCharacters(); + } + } + catch(Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_pColumnNameText = CreateText(STR_TAB_FIELD_NAME); m_pColumnName = new OPropColumnEditCtrl( this, aTmpString, STR_HELP_DEFAULT_VALUE, FIELD_PRPOERTY_COLUMNNAME, WB_BORDER ); - m_pColumnName->SetHelpId(HID_TAB_ENT_COLUMNNAME); m_pColumnName->SetMaxTextLen(xub_StrLen( nMax ? nMax : EDIT_NOLIMIT)); m_pColumnName->setCheck( isSQL92CheckEnabled(getConnection()) ); } - m_pColumnName->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - m_pColumnName->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - m_pColumnNameText->EnableClipSiblings(); - m_pColumnName->EnableClipSiblings(); + InitializeControl(m_pColumnName,HID_TAB_ENT_COLUMNNAME,false); break; case tpNumType: if( pNumType ) return; m_nPos++; - pNumTypeText =new FixedText( this ); - pNumTypeText->SetText( ModuleRes(STR_NUMERIC_TYPE) ); + pNumTypeText = CreateText(STR_NUMERIC_TYPE); pNumType = new OPropListBoxCtrl( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN ); pNumType->SetDropDownLineCount(5); - pNumType->SetHelpId(HID_TAB_ENT_NUMTYP); pNumType->InsertEntry( String::CreateFromAscii("Byte") ); pNumType->InsertEntry( String::CreateFromAscii("SmallInt") ); @@ -1117,84 +1016,41 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) pNumType->InsertEntry( String::CreateFromAscii("Single") ); pNumType->InsertEntry( String::CreateFromAscii("Double") ); pNumType->SelectEntryPos(2); - pNumType->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); - - pNumType->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pNumType->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pNumTypeText->EnableClipSiblings(); - pNumType->EnableClipSiblings(); + InitializeControl(pNumType,HID_TAB_ENT_NUMTYP,true); break; case tpLength: if( pLength ) return; m_nPos++; - pLengthText =new FixedText( this ); - pLengthText->SetText( ModuleRes(STR_LENGTH) ); - - pLength = new OPropNumericEditCtrl( this, STR_HELP_LENGTH, FIELD_PROPERTY_LENGTH, WB_BORDER ); - pLength->SetDecimalDigits(0); - pLength->SetMin(0); - pLength->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig - pLength->SetStrictFormat(TRUE); - - pLength->SetHelpId(HID_TAB_ENT_LEN); - - pLength->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pLength->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pLengthText->EnableClipSiblings(); - pLength->EnableClipSiblings(); + pLengthText = CreateText(STR_LENGTH); + pLength = CreateNumericControl(STR_HELP_LENGTH, FIELD_PROPERTY_LENGTH,HID_TAB_ENT_LEN); break; case tpScale: if( pScale ) return; m_nPos++; - pScaleText =new FixedText( this ); - pScaleText->SetText( ModuleRes(STR_SCALE) ); - pScale = new OPropNumericEditCtrl( this, STR_HELP_SCALE, FIELD_PROPERTY_SCALE, WB_BORDER ); - pScale->SetDecimalDigits(0); - pScale->SetMin(0); - pScale->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig - pScale->SetStrictFormat(TRUE); - - pScale->SetHelpId(HID_TAB_ENT_SCALE); - - pScale->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pScale->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pScaleText->EnableClipSiblings(); - pScale->EnableClipSiblings(); + pScaleText = CreateText(STR_SCALE); + pScale = CreateNumericControl(STR_HELP_SCALE, FIELD_PROPERTY_SCALE,HID_TAB_ENT_SCALE); break; case tpFormat: if (!pFormat) { m_nPos++; - pFormatText =new FixedText( this ); - pFormatText->SetText( ModuleRes(STR_FORMAT) ); + pFormatText = CreateText(STR_FORMAT); pFormatSample = new OPropEditCtrl( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER ); - pFormatSample->SetHelpId(HID_TAB_ENT_FORMAT_SAMPLE); pFormatSample->SetReadOnly(sal_True); pFormatSample->Enable(sal_False); + InitializeControl(pFormatSample,HID_TAB_ENT_FORMAT_SAMPLE,false); pFormat = new PushButton( this, ModuleRes(PB_FORMAT) ); - pFormat->SetHelpId(HID_TAB_ENT_FORMAT); - const sal_Int32 nControlHeight = LogicToPixel(Size(0, CONTROL_HEIGHT),MAP_APPFONT).Height(); + const sal_Int32 nControlHeight = GetMaxControlHeight(); pFormat->SetSizePixel(Size(nControlHeight, nControlHeight)); pFormat->SetClickHdl( LINK( this, OFieldDescControl, FormatClickHdl ) ); - - pFormatSample->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pFormatSample->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - pFormat->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pFormat->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pFormatText->EnableClipSiblings(); - pFormatSample->EnableClipSiblings(); - pFormat->EnableClipSiblings(); + InitializeControl(pFormat,HID_TAB_ENT_FORMAT,false); } UpdateFormatSample(pActFieldDescr); @@ -1204,25 +1060,49 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) return; m_nPos++; - pBoolDefaultText =new FixedText(this); - pBoolDefaultText->SetText(ModuleRes(STR_DEFAULT_VALUE)); + pBoolDefaultText = CreateText(STR_DEFAULT_VALUE); pBoolDefault = new OPropListBoxCtrl( this, STR_HELP_BOOL_DEFAULT, FIELD_PROPERTY_BOOL_DEFAULT, WB_DROPDOWN ); pBoolDefault->SetDropDownLineCount(3); pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE))); pBoolDefault->InsertEntry(aYes); pBoolDefault->InsertEntry(aNo); - pBoolDefault->SetHelpId(HID_TAB_ENT_BOOL_DEFAULT); - pBoolDefault->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pBoolDefault->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pBoolDefaultText->EnableClipSiblings(); - pBoolDefault->EnableClipSiblings(); + InitializeControl(pBoolDefault,HID_TAB_ENT_BOOL_DEFAULT,false); break; - } } +// ----------------------------------------------------------------------------- +void OFieldDescControl::InitializeControl(Control* _pControl,ULONG _nHelpId,bool _bAddChangeHandler) +{ + _pControl->SetHelpId(_nHelpId); + if ( _bAddChangeHandler ) + ((OPropListBoxCtrl*)_pControl)->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); + _pControl->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); + _pControl->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); + _pControl->EnableClipSiblings(); +} +// ----------------------------------------------------------------------------- +FixedText* OFieldDescControl::CreateText(USHORT _nTextRes) +{ + FixedText* pFixedText = new FixedText( this ); + pFixedText->SetText( ModuleRes(_nTextRes) ); + pFixedText->EnableClipSiblings(); + return pFixedText; +} +// ----------------------------------------------------------------------------- +OPropNumericEditCtrl* OFieldDescControl::CreateNumericControl(USHORT _nHelpStr,short _nProperty,ULONG _nHelpId) +{ + OPropNumericEditCtrl* pControl = new OPropNumericEditCtrl( this, _nHelpStr, _nProperty, WB_BORDER ); + pControl->SetDecimalDigits(0); + pControl->SetMin(0); + pControl->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig + pControl->SetStrictFormat(TRUE); + + InitializeControl(pControl,_nHelpId,false); + + return pControl; +} //------------------------------------------------------------------------------ void OFieldDescControl::DeactivateAggregate( EControlType eType ) { @@ -1233,150 +1113,58 @@ void OFieldDescControl::DeactivateAggregate( EControlType eType ) switch( eType ) { case tpDefault: - if( !pDefault ) - return; - m_nPos--; - pDefault->Hide(); - pDefaultText->Hide(); - delete pDefault; - delete pDefaultText; - pDefault = NULL; - pDefaultText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pDefault,&pDefaultText); break; case tpAutoIncrementValue: - if( !m_pAutoIncrementValue ) - return; - m_nPos--; - m_pAutoIncrementValue->Hide(); - m_pAutoIncrementValueText->Hide(); - delete m_pAutoIncrementValue; - delete m_pAutoIncrementValueText; - m_pAutoIncrementValue = NULL; - m_pAutoIncrementValueText =NULL; + lcl_HideAndDeleteControl(m_nPos,&m_pAutoIncrementValue,&m_pAutoIncrementValueText); break; case tpColumnName: - if( !m_pColumnName ) - return; - m_nPos--; - m_pColumnName->Hide(); - m_pColumnNameText->Hide(); - delete m_pColumnName; - delete m_pColumnNameText; - m_pColumnName = NULL; - m_pColumnNameText =NULL; + lcl_HideAndDeleteControl(m_nPos,&m_pColumnName,&m_pColumnNameText); break; case tpType: - if( !m_pType ) - return; - m_nPos--; - m_pType->Hide(); - m_pTypeText->Hide(); - delete m_pType; - delete m_pTypeText; - m_pType = NULL; - m_pTypeText =NULL; + lcl_HideAndDeleteControl(m_nPos,&m_pType,&m_pTypeText); break; case tpAutoIncrement: - if( !pAutoIncrement ) - return; - m_nPos--; - pAutoIncrement->Hide(); - pAutoIncrementText->Hide(); - delete pAutoIncrement; - delete pAutoIncrementText; - pAutoIncrement = NULL; - pAutoIncrementText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pAutoIncrement,&pAutoIncrementText); break; case tpRequired: - if( !pRequired ) - return; - m_nPos--; - pRequired->Hide(); - pRequiredText->Hide(); - delete pRequired; - delete pRequiredText; - pRequired = NULL; - pRequiredText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pRequired,&pRequiredText); break; case tpTextLen: - if( !pTextLen ) - return; - m_nPos--; - pTextLen->Hide(); - pTextLenText->Hide(); - delete pTextLen; - delete pTextLenText; - pTextLen = NULL; - pTextLenText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pTextLen,&pTextLenText); break; case tpNumType: - if( !pNumType ) - return; - m_nPos--; - pNumType->Hide(); - pNumTypeText->Hide(); - delete pNumType; - delete pNumTypeText; - pNumType = NULL; - pNumTypeText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pNumType,&pNumTypeText); break; case tpLength: - if( !pLength ) - return; - m_nPos--; - pLength->Hide(); - pLengthText->Hide(); - delete pLength; - delete pLengthText; - pLength = NULL; - pLengthText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pLength,&pLengthText); break; case tpScale: - if( !pScale ) - return; - m_nPos--; - pScale->Hide(); - pScaleText->Hide(); - delete pScale; - delete pScaleText; - pScale = NULL; - pScaleText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pScale,&pScaleText); break; case tpFormat: - if( !pFormat ) - return; - pFormatText->Hide(); - pFormatSample->Hide(); - pFormat->Hide(); - delete pFormatText; - delete pFormatSample; - delete pFormat; - pFormatText =NULL; - pFormatSample = NULL; - pFormat = NULL; + // TODO: we have to check if we have to increment m_nPos again + lcl_HideAndDeleteControl(m_nPos,&pFormat,&pFormatText); + if ( pFormatSample ) + { + pFormatSample->Hide(); + delete pFormatSample; + pFormatSample = NULL; + } break; case tpBoolDefault: - if (!pBoolDefault) - return; - m_nPos--; - pBoolDefault->Hide(); - pBoolDefaultText->Hide(); - delete pBoolDefault; - delete pBoolDefaultText; - pBoolDefault = NULL; - pBoolDefaultText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pBoolDefault,&pBoolDefaultText); break; - } } @@ -1387,48 +1175,28 @@ void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 n ////////////////////////////////////////////////////////////////////// // Groesse ermitteln - const sal_Int32 nControlHeight = LogicToPixel(Size(0, CONTROL_HEIGHT),MAP_APPFONT).Height(); - Size aSize; - switch( nCol ) + const sal_Int32 nControlHeight = GetMaxControlHeight(); + Size aSize(0,nControlHeight); + if ( isRightAligned() && nCol ) + aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); + else { - case 0: - aSize.Width() = CONTROL_WIDTH_1; - aSize.Height() = nControlHeight; - break; - case 1: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else - aSize.Width() = CONTROL_WIDTH_2; - aSize.Height() = nControlHeight; - break; - case 2: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else + switch( nCol ) + { + case 0: + default: + aSize.Width() = CONTROL_WIDTH_1; + break; + case 1: aSize.Width() = CONTROL_WIDTH_2; - aSize.Height() = long(1.5*nControlHeight); - break; - case 3: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else + break; + case 3: aSize.Width() = CONTROL_WIDTH_3; - aSize.Height() = nControlHeight; - break; - case 4: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else + break; + case 4: aSize.Width() = CONTROL_WIDTH_4; - aSize.Height() = nControlHeight; - break; - default: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else - aSize.Width() = CONTROL_WIDTH_1; - aSize.Height() = nControlHeight; + break; + } // switch( nCol ) } @@ -1442,7 +1210,6 @@ void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 n aPosition.Y() = 1; break; case 1: - case 2: case 3: case 4: if ( isRightAligned() ) @@ -1965,12 +1732,8 @@ void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr ) //------------------------------------------------------------------------------ void OFieldDescControl::UpdateFormatSample(OFieldDescription* pFieldDescr) { - if(!pFieldDescr) - return; - if(!pFormatSample) - return; - - pFormatSample->SetText(getControlDefault(pFieldDescr,sal_False)); + if ( pFieldDescr && pFormatSample ) + pFormatSample->SetText(getControlDefault(pFieldDescr,sal_False)); } //------------------------------------------------------------------------------ @@ -2169,8 +1932,3 @@ String OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldDes return sDefault; } // ----------------------------------------------------------------------------- - - - - - diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx index c65285cf414a..5b089f764337 100644 --- a/dbaccess/source/ui/control/opendoccontrols.cxx +++ b/dbaccess/source/ui/control/opendoccontrols.cxx @@ -300,14 +300,10 @@ namespace dbaui aURL.SetPass( sPassword ); if ( !sTitle.Len() ) - sTitle = aURL.getName(); + sTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS ); String sDecodedURL = aURL.GetMainURL( INetURLObject::NO_DECODE ); -// sTitle.AppendAscii( " (" ); -// sTitle += String( ::svt::OFileNotation( sDecodedURL ).get( ::svt::OFileNotation::N_SYSTEM ) ); -// sTitle.AppendAscii( ")" ); - USHORT nPos = InsertEntry( sTitle ); m_aURLs.insert( MapIndexToStringPair::value_type( nPos, StringPair( sDecodedURL, sFilter ) ) ); } diff --git a/dbaccess/source/ui/dlg/UserAdmin.hxx b/dbaccess/source/ui/dlg/UserAdmin.hxx index 57c7a59a140c..b4eae1591b3d 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.hxx +++ b/dbaccess/source/ui/dlg/UserAdmin.hxx @@ -79,7 +79,6 @@ protected: ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUsers; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB; ::com::sun::star::uno::Sequence< ::rtl::OUString> m_aUserNames; String m_UserName; @@ -93,8 +92,6 @@ protected: OUserAdmin( Window* pParent, const SfxItemSet& _rCoreAttrs); public: - void setServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB) { m_xORB = _xORB; } - static SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet ); ~OUserAdmin(); diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 80b8b389c45a..6df5537544a4 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -316,7 +316,7 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent if (pCollectionItem) m_pCollection = pCollectionItem->getCollection(); - DBG_ASSERT(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !"); + DBG_ASSERT(m_pCollection, "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !"); FreeResource(); diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index bd5a4c1e6392..cc8f01dd4daf 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -258,6 +258,14 @@ namespace ExceptionDisplayInfo( SQLExceptionInfo::TYPE _eType ) : eType( _eType ), bSubEntry( false ) { } }; + static bool lcl_hasDetails( const ExceptionDisplayInfo& _displayInfo ) + { + return ( _displayInfo.sErrorCode.Len() ) + || ( _displayInfo.sSQLState.Len() + && !_displayInfo.sSQLState.EqualsAscii( "S1000" ) + ); + } + typedef ::std::vector< ExceptionDisplayInfo > ExceptionDisplayChain; //------------------------------------------------------------------------------ @@ -303,11 +311,19 @@ namespace ExceptionDisplayInfo aDisplayInfo( aCurrentElement.getType() ); - aDisplayInfo.sMessage = pCurrentError->Message; + aDisplayInfo.sMessage = pCurrentError->Message.trim(); aDisplayInfo.sSQLState = pCurrentError->SQLState; if ( pCurrentError->ErrorCode ) aDisplayInfo.sErrorCode = String::CreateFromInt32( pCurrentError->ErrorCode ); + if ( !aDisplayInfo.sMessage.Len() + && !lcl_hasDetails( aDisplayInfo ) + ) + { + OSL_ENSURE( false, "lcl_buildExceptionChain: useles exception: no state, no error code, no message!" ); + continue; + } + aDisplayInfo.pImageProvider = _rFactory.getImageProvider( aCurrentElement.getType() ); aDisplayInfo.pLabelProvider = _rFactory.getLabelProvider( aCurrentElement.getType(), false ); @@ -685,7 +701,25 @@ void OSQLMessageBox::impl_createStandardButtons( WinBits _nStyle ) void OSQLMessageBox::impl_addDetailsButton() { size_t nFirstPageVisible = m_aMessage.IsVisible() ? 2 : 1; + bool bMoreDetailsAvailable = m_pImpl->aDisplayInfo.size() > nFirstPageVisible; + if ( !bMoreDetailsAvailable ) + { + // even if the text fits into what we can display, we might need to details button + // if there is more non-trivial information in the errors than the mere messages + for ( ExceptionDisplayChain::const_iterator error = m_pImpl->aDisplayInfo.begin(); + error != m_pImpl->aDisplayInfo.end(); + ++error + ) + { + if ( lcl_hasDetails( *error ) ) + { + bMoreDetailsAvailable = true; + break; + } + } + } + if ( bMoreDetailsAvailable ) { AddButton( BUTTON_MORE, BUTTONID_MORE, 0 ); diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx index ca0e411a09cd..c77942cd71c0 100644 --- a/dbaccess/source/ui/inc/FieldDescControl.hxx +++ b/dbaccess/source/ui/inc/FieldDescControl.hxx @@ -160,6 +160,10 @@ namespace dbaui void ScrollAllAggregates(); sal_Bool isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const; + void Contruct(); + OPropNumericEditCtrl* CreateNumericControl(USHORT _nHelpStr,short _nProperty,ULONG _nHelpId); + FixedText* CreateText(USHORT _nTextRes); + void InitializeControl(Control* _pControl,ULONG _nHelpId,bool _bAddChangeHandler); protected: inline void setRightAligned() { m_bRightAligned = true; } @@ -169,7 +173,8 @@ namespace dbaui inline OFieldDescription* getCurrentFieldDescData() { return pActFieldDescr; } inline void setCurrentFieldDescData( OFieldDescription* _pDesc ) { pActFieldDescr = _pDesc; } - USHORT CountActiveAggregates() const; + sal_uInt16 CountActiveAggregates() const; + sal_Int32 GetMaxControlHeight() const; virtual void ActivateAggregate( EControlType eType ); virtual void DeactivateAggregate( EControlType eType ); diff --git a/dbaccess/source/ui/inc/FieldDescriptions.hxx b/dbaccess/source/ui/inc/FieldDescriptions.hxx index 7b54d2617bc3..ee473b032853 100644 --- a/dbaccess/source/ui/inc/FieldDescriptions.hxx +++ b/dbaccess/source/ui/inc/FieldDescriptions.hxx @@ -123,6 +123,7 @@ namespace dbaui sal_Int32 GetFormatKey() const; SvxCellHorJustify GetHorJustify() const; TOTypeInfoSP getTypeInfo() const; + TOTypeInfoSP getSpecialTypeInfo() const; sal_Bool IsAutoIncrement() const; sal_Bool IsPrimaryKey() const; sal_Bool IsCurrency() const; diff --git a/dbaccess/source/ui/inc/dbu_rel.hrc b/dbaccess/source/ui/inc/dbu_rel.hrc index 1e0e2f3423da..c8d224cbdcad 100644 --- a/dbaccess/source/ui/inc/dbu_rel.hrc +++ b/dbaccess/source/ui/inc/dbu_rel.hrc @@ -41,9 +41,10 @@ #define STR_QUERY_REL_DELETE_WINDOW RID_STR_REL_START + 3 #define STR_QUERY_REL_EDIT RID_STR_REL_START + 4 #define STR_QUERY_REL_CREATE RID_STR_REL_START + 5 +#define STR_QUERY_REL_COULD_NOT_CREATE RID_STR_REL_START + 6 // please adjust checking before insert new strings -#if STR_QUERY_REL_DELETE_WINDOW > RID_STR_REL_END +#if STR_QUERY_REL_COULD_NOT_CREATE > RID_STR_REL_END #error Resource-Id Ueberlauf in #file, #line #endif diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index dc71f6588828..880bb91b3727 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -234,7 +234,7 @@ ODatabaseExport::ODatabaseExport(const SharedConnection& _rxConnection, sal_Int32 nType = aValue; ++nPos; - if( nType == DataType::VARCHAR) + if( nType == DataType::VARCHAR ) { m_pTypeInfo = TOTypeInfoSP(new OTypeInfo()); @@ -291,7 +291,9 @@ ODatabaseExport::ODatabaseExport(const SharedConnection& _rxConnection, break; } } - } + } // if(xSet.is()) + if ( !m_pTypeInfo ) + m_pTypeInfo = TOTypeInfoSP(new OTypeInfo()); SetColumnTypes(pList,_pInfoMap); } //--------------------------------------------------------------------------- @@ -432,10 +434,11 @@ sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOl if ( m_pFormatter && m_sNumToken.Len() ) { LanguageType eNumLang; - sal_uInt32 nNumberFormat2; - fOutNumber = SfxHTMLParser::GetTableDataOptionsValNum(nNumberFormat2,eNumLang,m_sTextToken,m_sNumToken,*m_pFormatter); + sal_uInt32 nFormatKey; + fOutNumber = SfxHTMLParser::GetTableDataOptionsValNum(nFormatKey,eNumLang,m_sTextToken,m_sNumToken,*m_pFormatter); //double fOutNumber2 = SfxHTMLParser::GetTableDataOptionsValNum(nNumberFormat2,eNumLang,m_sValToken,m_sNumToken,*m_pFormatter); - nNumberFormat = static_cast<sal_Int16>(nNumberFormat2); + Reference<XPropertySet> xProp = xFormats->getByKey(nFormatKey); + xProp->getPropertyValue(PROPERTY_TYPE) >>= nNumberFormat; } else { @@ -559,16 +562,15 @@ void ODatabaseExport::SetColumnTypes(const TColumnVector* _pList,const OTypeInfo DBG_CHKTHIS(ODatabaseExport,NULL); if(_pList && _pInfoMap) { + OSL_ENSURE(m_vNumberFormat.size() == m_vColumnSize.size() && m_vColumnSize.size() == _pList->size(),"Illegal columns in list"); Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier(); Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats(); TColumnVector::const_iterator aIter = _pList->begin(); TColumnVector::const_iterator aEnd = _pList->end(); - for(sal_Int32 i= 0;aIter != aEnd;++aIter,++i) + for(sal_Int32 i= 0;aIter != aEnd && (i) < static_cast<sal_Int32>(m_vNumberFormat.size()) && (i) < static_cast<sal_Int32>(m_vColumnSize.size()) ;++aIter,++i) { sal_Int32 nDataType; sal_Int32 nLength(0),nScale(0); - OSL_ENSURE((i) < static_cast<sal_Int32>(m_vNumberFormat.size()),"m_vFormatKey: Illegal index for vector"); - OSL_ENSURE((i) < static_cast<sal_Int32>(m_vColumnSize.size()),"m_vColumnSize: Illegal index for vector"); sal_Int16 nType = m_vNumberFormat[i]; switch ( nType ) diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index e38da91c606c..809f9c407e51 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -590,11 +590,11 @@ TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo, // -> drop the precision and the scale restriction, accept any type with the property // type id (nType) - OSL_ENSURE(sal_False, - ( ::rtl::OString("getTypeInfoFromType: did not find a matching type") - += ::rtl::OString(" (expected type name: ") - += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding()) - += ::rtl::OString(")! Defaulting to the first matching type.")).getStr()); + //OSL_ENSURE(sal_False, + // ( ::rtl::OString("getTypeInfoFromType: did not find a matching type") + // += ::rtl::OString(" (expected type name: ") + // += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding()) + // += ::rtl::OString(")! Defaulting to the first matching type.")).getStr()); for(aIter = aPair.first; aIter != aPair.second; ++aIter) { // search the best matching type (now comparing the local names) @@ -700,6 +700,7 @@ void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxCo nCount = 18; aTypes.reserve(nCount+1); aTypes.push_back(-1); + aNullable.push_back(sal_False); for (sal_Int32 j = 1; j <= nCount ; ++j) { aTypes.push_back(xResultSetMetaData->getColumnType(j)); diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index 2b4cd971ffa1..a6788ac1926f 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -216,6 +216,7 @@ sal_Bool OCopyTable::LeavePage() // first check if the table already exists in the database if( m_pParent->getOperation() != CopyTableOperation::AppendData ) { + m_pParent->clearDestColumns(); DynamicTableOrQueryNameCheck aNameCheck( m_pParent->m_xDestConnection, CommandType::TABLE ); SQLExceptionInfo aErrorInfo; if ( !aNameCheck.isNameValid( m_edTableName.GetText(), aErrorInfo ) ) @@ -342,7 +343,7 @@ sal_Bool OCopyTable::checkAppendData() { bNotConvert = sal_True; m_pParent->m_vColumnPos[i] = ODatabaseExport::TPositions::value_type(nPos,nPos); - TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getTypeInfo(),bNotConvert); + TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert); if ( !bNotConvert ) { m_pParent->showColumnTypeNotSupported((*aDestIter)->first); diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx index 0f3f036102d5..9b4ad13d8dc7 100644 --- a/dbaccess/source/ui/misc/WColumnSelect.cxx +++ b/dbaccess/source/ui/misc/WColumnSelect.cxx @@ -336,7 +336,7 @@ void OWizColumnSelect::createNewColumn( ListBox* _pListbox, OFieldDescription* pNewField = new OFieldDescription(*_pSrcField); pNewField->SetName(sConvertedName); sal_Bool bNotConvert = sal_True; - pNewField->SetType(m_pParent->convertType(_pSrcField->getTypeInfo(),bNotConvert)); + pNewField->SetType(m_pParent->convertType(_pSrcField->getSpecialTypeInfo(),bNotConvert)); if ( !m_pParent->supportsPrimaryKey() ) pNewField->SetPrimaryKey(sal_False); diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 0cd8ae2dbeb4..ca9aeacf73e4 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -860,7 +860,7 @@ sal_Bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) { OFieldDescription* pField = new OFieldDescription(*(*aSrcIter)->second); pField->SetName(convertColumnName(TExportColumnFindFunctor(&m_vDestColumns),(*aSrcIter)->first,sExtraChars,nMaxNameLen)); - TOTypeInfoSP pType = convertType((*aSrcIter)->second->getTypeInfo(),bRet); + TOTypeInfoSP pType = convertType((*aSrcIter)->second->getSpecialTypeInfo(),bRet); pField->SetType(pType); if ( !bPKeyAllowed ) pField->SetPrimaryKey(sal_False); diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx index 93feb3aa49b1..5325f0388cfc 100644 --- a/dbaccess/source/ui/misc/WNameMatch.cxx +++ b/dbaccess/source/ui/misc/WNameMatch.cxx @@ -206,7 +206,7 @@ sal_Bool OWizNameMatching::LeavePage() m_pParent->m_vColumnPos[nPos].first = ++nParamPos; m_pParent->m_vColumnPos[nPos].second = ::std::distance(pDestColumns->begin(),aDestIter) + 1; sal_Bool bNotConvert = sal_True; - TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getTypeInfo(),bNotConvert); + TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert); sal_Int32 nType = ::com::sun::star::sdbc::DataType::VARCHAR; if ( pTypeInfo.get() ) nType = pTypeInfo->nType; diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 2ae24b6f6423..440be631a3ae 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -740,6 +740,7 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes // second test if the name can be set as select columns in a pseudo statement // we have to look which entries we should quote + const ::rtl::OUString sFieldAlias = _pEntry->GetFieldAlias(); size_t nPass = 4; ::connectivity::OSQLParser& rParser( rController.getParser() ); OSQLParseNode* pParseNode = NULL; @@ -759,6 +760,11 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), _sFieldName ); else sSql += _sFieldName; + if ( sFieldAlias.getLength() ) + { // always quote the alias name there canbe no function in it + sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")); + sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), sFieldAlias ); + } sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x")); pParseNode = rParser.parseTree( sErrorMsg, sSql, bInternational ); diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx index 6e81b8b15088..f052003c2c58 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx @@ -30,42 +30,22 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBAUI_RTABLECONNECTIONDATA_HXX #include "RTableConnectionData.hxx" -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif -#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ #include <com/sun/star/sdbc/KeyRule.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ #include <com/sun/star/sdbcx/KeyType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XKeysSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ #include <com/sun/star/sdbcx/XAppend.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ #include <com/sun/star/sdbcx/XDrop.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ #include <com/sun/star/container/XIndexAccess.hpp> -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef DBAUI_TOOLS_HXX +#include "dbu_rel.hrc" #include "UITools.hxx" -#endif +#include "moduledbu.hxx" +#include <connectivity/dbexception.hxx> + using namespace dbaui; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; @@ -382,6 +362,7 @@ BOOL ORelationTableConnectionData::Update() // get the name of foreign key // search for columns m_aConnName = ::rtl::OUString(); xKey = NULL; + bool bDropRelation = false; for(sal_Int32 i=0;i<xKeys->getCount();++i) { xKeys->getByIndex(i) >>= xKey; @@ -426,6 +407,7 @@ BOOL ORelationTableConnectionData::Update() { xKey->getPropertyValue(PROPERTY_NAME) >>= sName; m_aConnName = sName; + bDropRelation = aNames.getLength() == 0; // the key contains no column, so it isn't valid and we have to drop it //here we already know our column structure so we don't have to recreate the table connection data xColSup.clear(); break; @@ -437,15 +419,20 @@ BOOL ORelationTableConnectionData::Update() } } xKey = NULL; + } // for(sal_Int32 i=0;i<xKeys->getCount();++i) + if ( bDropRelation ) + { + DropRelation(); + String sError(ModuleRes(STR_QUERY_REL_COULD_NOT_CREATE)); + ::dbtools::throwGenericSQLException(sError,NULL); } // OSL_ENSURE(xKey.is(),"No key found have insertion!"); + // The fields the relation marks may not be the same as our LineDatas mark after the relation has been updated if ( xColSup.is() ) { - // The fields the relation marks may not be the same as our LineDatas mark after the relation has been updated OConnectionLineDataVec().swap(m_vConnLineData); - Reference<XNameAccess> xColumns = xColSup->getColumns(); Sequence< ::rtl::OUString> aNames = xColumns->getElementNames(); const ::rtl::OUString* pIter = aNames.getConstArray(); @@ -470,7 +457,7 @@ BOOL ORelationTableConnectionData::Update() m_vConnLineData.push_back(pNewData); } } - } + } // if ( xColSup.is() ) // NOTE : the caller is resposible for updating any other objects referencing the old LineDatas (for instance a ConnLine) //////////////////////////////////////////////////////////// diff --git a/dbaccess/source/ui/relationdesign/relation.src b/dbaccess/source/ui/relationdesign/relation.src index e3fe71452fc8..391205223886 100644 --- a/dbaccess/source/ui/relationdesign/relation.src +++ b/dbaccess/source/ui/relationdesign/relation.src @@ -70,15 +70,15 @@ QueryBox RELATION_DESIGN_SAVEMODIFIED Message [ en-US ] = "The relation design has been changed.\nDo you want to save the changes?" ; }; -/* - The menubar resource has become obsolete - you can now find the menubar definition at: <project>/uiconfig/dbrelation/menubar/menubar.xml -*/ - String STR_QUERY_REL_DELETE_WINDOW { Text [ en-US ] = "When you delete this table all corresponding relations will be deleted as well. Continue?"; }; +String STR_QUERY_REL_COULD_NOT_CREATE +{ + Text [ en-US ] = "The datbase could not create the relation. May be foreign keys for this kind of table aren't supported.\nPlease check your documentation of the database."; +}; diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index a7ddd801fc51..4ece37f2fa51 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -578,6 +578,15 @@ TOTypeInfoSP OFieldDescription::getTypeInfo() const return m_pType; } // ----------------------------------------------------------------------------- +TOTypeInfoSP OFieldDescription::getSpecialTypeInfo() const +{ + TOTypeInfoSP pSpecialType( new OTypeInfo() ); + *pSpecialType = *m_pType; + pSpecialType->nPrecision = GetPrecision(); + pSpecialType->nMaximumScale = static_cast<sal_Int16>(GetScale()); + return pSpecialType; +} +// ----------------------------------------------------------------------------- sal_Bool OFieldDescription::IsAutoIncrement() const { if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT) ) diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 29a8ca4951b3..353ff0ea11d5 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -349,6 +349,16 @@ void OTableEditorCtrl::InitCellController() pTypeCell->SetHelpId(HID_TABDESIGN_TYPECELL); pDescrCell->SetHelpId(HID_TABDESIGN_COMMENTCELL); + Size aHeight; + const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell}; + for(sal_Size i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i) + { + const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) ); + if ( aTemp.Height() > aHeight.Height() ) + aHeight.Height() = aTemp.Height(); + } // for(int i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i + SetDataRowHeight(aHeight.Height()); + ClearModified(); } diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index d81cf5f9a5cf..f54c5104c955 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -1482,6 +1482,7 @@ void OTableController::alterColumns() // ----------------------------------------------------------------------------- void OTableController::dropPrimaryKey() { + SQLExceptionInfo aInfo; try { Reference<XKeysSupplier> xKeySup(m_xTable,UNO_QUERY); @@ -1506,11 +1507,24 @@ void OTableController::dropPrimaryKey() } } } + catch(const SQLContext& e) + { + aInfo = SQLExceptionInfo(e); + } + catch(const SQLWarning& e) + { + aInfo = SQLExceptionInfo(e); + } + catch(const SQLException& e) + { + aInfo = SQLExceptionInfo(e); + } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + showError(aInfo); } // ----------------------------------------------------------------------------- void OTableController::assignTable() diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src index c242fcecd3b1..af911ec85c07 100644 --- a/dbaccess/source/ui/tabledesign/table.src +++ b/dbaccess/source/ui/tabledesign/table.src @@ -96,7 +96,7 @@ String STR_TAB_FIELD_COLUMN_NAME }; String STR_TAB_FIELD_DATATYPE { - Text [ en-US ] = "Field type" ; + Text [ en-US ] = "Field ~type" ; }; String STR_TAB_FIELD_COLUMN_DATATYPE { |