Tag: cws_src680_oj14 User: oj Date: 2006/07/04 00:34:03 Modified: dba/dbaccess/source/core/dataaccess/databasedocument.cxx
Log: RESYNC: (1.25-1.29); FILE MERGED File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: databasedocument.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.cxx?r1=1.22.4.3&r2=1.22.4.4 Delta lines: +65 -58 --------------------- --- databasedocument.cxx 20 Mar 2006 13:48:33 -0000 1.22.4.3 +++ databasedocument.cxx 4 Jul 2006 07:34:00 -0000 1.22.4.4 @@ -105,6 +105,9 @@ #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#include <cppuhelper/exc_hlp.hxx> +#endif #ifndef BOOST_BIND_HPP_INCLUDED #include <boost/bind.hpp> @@ -172,17 +175,6 @@ { DBG_CTOR(ODatabaseDocument,NULL); - // adjust our readonly flag - try - { - m_xDocEventBroadcaster.set(m_pImpl->m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.GlobalEventBroadcaster"))), - UNO_QUERY); - } - catch(Exception) - { - OSL_ENSURE(0,"Could not create GlobalEventBroadcaster!"); - } - osl_incrementInterlockedCount( &m_refCount ); { impl_reparent_nothrow( m_xForms ); @@ -251,10 +243,10 @@ if ( m_pImpl->m_bOwnStorage ) ::comphelper::disposeComponent(m_pImpl->m_xStorage); - impl_clearObjectContainer( m_xForms ); - impl_clearObjectContainer( m_xReports ); - impl_clearObjectContainer( m_pImpl->m_xTableDefinitions ); - impl_clearObjectContainer( m_pImpl->m_xCommandDefinitions ); + clearObjectContainer( m_xForms); + clearObjectContainer( m_xReports); + clearObjectContainer( m_pImpl->m_xTableDefinitions); + clearObjectContainer( m_pImpl->m_xCommandDefinitions); m_pImpl->m_aContainer.clear(); m_pImpl->lateInit(); @@ -315,7 +307,7 @@ { return sal_False; } - if ( m_pImpl->m_pDBContext ) + if ( m_pImpl->m_pDBContext && m_pImpl->m_sRealFileURL.getLength() ) { m_pImpl->m_pDBContext->registerPrivate(m_pImpl->m_sRealFileURL,m_pImpl); m_pImpl->setModified(sal_False); @@ -355,6 +347,20 @@ m_pImpl->m_aControllers.erase(::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController),m_pImpl->m_aControllers.end()); if ( m_pImpl->m_xCurrentController == _xController ) m_pImpl->m_xCurrentController = NULL; + + if ( m_pImpl->m_aControllers.empty() ) + { + // if this was the last view, close the document as a whole + // #i51157# / 2006-03-16 / [EMAIL PROTECTED] + try + { + close( sal_True ); + } + catch( const CloseVetoException& ) + { + // okay, somebody vetoed and took ownership + } + } } // ----------------------------------------------------------------------------- void SAL_CALL ODatabaseDocument::lockControllers( ) throw (RuntimeException) @@ -456,9 +462,7 @@ if ( m_pImpl->m_bDocumentReadOnly ) throw IOException(); - m_bCommitMasterStorage = sal_False; m_pImpl->commitStorages(); - m_bCommitMasterStorage = sal_True; Reference<XStorage> xMyStorage = m_pImpl->getStorage(); OSL_ENSURE( xMyStorage.is(), "ODatabaseDocument::storeToURL: no own storage?" ); @@ -495,16 +499,39 @@ Sequence<Any> aParam(2); aParam[0] <<= _rURL; aParam[1] <<= ElementModes::READWRITE | ElementModes::TRUNCATE; + Reference<XStorage> xStorage; + ::rtl::OUString sOriginalExceptionType; + ::rtl::OUString sOriginalExceptionMessage; try { xStorage.set(xStorageFactory->createInstanceWithArguments( aParam ),UNO_QUERY); } - catch(Exception&) + catch ( const Exception& e ) { + Any aException( ::cppu::getCaughtException() ); + sOriginalExceptionType = aException.getValueTypeName(); + sOriginalExceptionMessage = e.Message; } + if ( !xStorage.is() ) - throw IOException(); + { + // TODO: localize this + ::rtl::OUString sMessage = ::rtl::OUString::createFromAscii( "Could not store the database document to '" ); + sMessage += _rURL; + sMessage += ::rtl::OUString::createFromAscii( "'." ); + if ( sOriginalExceptionMessage.getLength() ) + { + sMessage += ::rtl::OUString::createFromAscii( "\noriginal error message: " ); + sMessage += sOriginalExceptionMessage; + } + if ( sOriginalExceptionType.getLength() ) + { + sMessage += ::rtl::OUString::createFromAscii( "\noriginal error type: " ); + sMessage += sOriginalExceptionType; + } + throw IOException( sMessage, *this ); + } if ( m_pImpl->isEmbeddedDatabase() ) m_pImpl->clearConnections(); @@ -660,15 +687,18 @@ // ::com::sun::star::view::XPrintable Sequence< PropertyValue > SAL_CALL ODatabaseDocument::getPrinter( ) throw (RuntimeException) { + DBG_ERROR( "ODatabaseDocument::getPrinter: not supported!" ); return Sequence< PropertyValue >(); } // ----------------------------------------------------------------------------- -void SAL_CALL ODatabaseDocument::setPrinter( const Sequence< PropertyValue >& aPrinter ) throw (IllegalArgumentException, RuntimeException) +void SAL_CALL ODatabaseDocument::setPrinter( const Sequence< PropertyValue >& /*aPrinter*/ ) throw (IllegalArgumentException, RuntimeException) { + DBG_ERROR( "ODatabaseDocument::setPrinter: not supported!" ); } // ----------------------------------------------------------------------------- -void SAL_CALL ODatabaseDocument::print( const Sequence< PropertyValue >& xOptions ) throw (IllegalArgumentException, RuntimeException) +void SAL_CALL ODatabaseDocument::print( const Sequence< PropertyValue >& /*xOptions*/ ) throw (IllegalArgumentException, RuntimeException) { + DBG_ERROR( "ODatabaseDocument::print: not supported!" ); } // ----------------------------------------------------------------------------- void ODatabaseDocument::impl_reparent_nothrow( const WeakReference< XNameAccess >& _rxContainer ) @@ -678,18 +708,15 @@ xChild->setParent( *this ); } // ----------------------------------------------------------------------------- -void ODatabaseDocument::impl_clearObjectContainer( WeakReference< XNameAccess >& _rxContainer, bool _bResetAndRelease ) +void ODatabaseDocument::clearObjectContainer( WeakReference< XNameAccess >& _rxContainer) { Reference< XNameAccess > xContainer = _rxContainer; ::comphelper::disposeComponent( xContainer ); - if ( _bResetAndRelease ) - { Reference< XChild > xChild( _rxContainer.get(),UNO_QUERY ); if ( xChild.is() ) xChild->setParent( NULL ); _rxContainer = Reference< XNameAccess >(); - } } // ----------------------------------------------------------------------------- Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType _eType ) @@ -757,7 +784,6 @@ aGuard.reset(); } - DBG_ASSERT( m_pImpl->m_aControllers.empty(), "ODatabaseDocument::close: aren't controllers expected to veto the closing?" ); impl_closeControllerFrames( _bDeliverOwnership ); { @@ -832,17 +858,15 @@ if( bPlainStream ) { - ::rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("Compressed") ); sal_Bool bFalse = sal_False; aAny.setValue( &bFalse, ::getBooleanCppuType() ); - xStreamProp->setPropertyValue( aPropName, aAny ); + xStreamProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Compressed") ), aAny ); } else { - ::rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ); sal_Bool bTrue = sal_True; aAny.setValue( &bTrue, ::getBooleanCppuType() ); - xStreamProp->setPropertyValue( aPropName, aAny ); + xStreamProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Encrypted") ), aAny ); } @@ -1034,21 +1058,7 @@ try { css::document::EventObject aEvt(*this, _sEventName); - Reference< XEventListener > xDocEventBroadcaster; - /// TODO: this code has to be deleted after AS' cws will be integrated - try - { - xDocEventBroadcaster = xDocEventBroadcaster.query( m_pImpl->m_xServiceFactory->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.GlobalEventBroadcaster" ) ) ) ); - } - catch(Exception) - { - OSL_ENSURE(0,"Could not create GlobalEventBroadcaster!"); - } - _rGuard.clear(); - if ( xDocEventBroadcaster.is() ) - xDocEventBroadcaster->notifyEvent(aEvt); m_aDocEventListeners.notifyEach( &css::document::XEventListener::notifyEvent, aEvt ); } catch(Exception&) @@ -1066,8 +1076,8 @@ } DBG_ASSERT( m_pImpl->m_aControllers.empty(), "ODatabaseDocument::disposing: there still are controllers!" ); - // normally, nobody should explicitly dispose, but only XCloseable::close the document. And controllers - // are expected to veto the closing, so when we're here, there shouldn't be any controllers anymore. + // normally, nobody should explicitly dispose, but only XCloseable::close the document.An upon + // closing, our controllers are closed, too m_pImpl->m_aControllers.clear(); Reference< XModel > xHoldAlive( this ); @@ -1082,13 +1092,10 @@ m_aCloseListener.disposeAndClear( aDisposeEvent ); m_aDocEventListeners.disposeAndClear( aDisposeEvent ); - m_xDocEventBroadcaster = NULL; m_xUIConfigurationManager = NULL; - impl_clearObjectContainer( m_xForms, true ); - impl_clearObjectContainer( m_xReports, true ); - impl_clearObjectContainer( m_pImpl->m_xTableDefinitions, true ); - impl_clearObjectContainer( m_pImpl->m_xCommandDefinitions, true ); + clearObjectContainer( m_xForms); + clearObjectContainer( m_xReports); m_pImpl->modelIsDisposing( ODatabaseModelImpl::ResetModelAccess() ); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
