User: obo     
Date: 06/03/29 04:33:50

Modified:
 /dba/dbaccess/source/core/dataaccess/
  databasedocument.cxx

Log:
 INTEGRATION: CWS dba203a (1.25.12); FILE MERGED
 2006/03/16 09:53:40 fs 1.25.12.2: #i63162# upon closing the last view, close 
the document automatically
 2006/02/17 12:40:43 fs 1.25.12.1: better exception message when storeTo fails

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.25&r2=1.26
Delta lines:  +46 -9
--------------------
--- databasedocument.cxx        7 Feb 2006 10:18:42 -0000       1.25
+++ databasedocument.cxx        29 Mar 2006 12:33:47 -0000      1.26
@@ -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>
@@ -355,6 +358,20 @@
     
m_pImpl->m_aControllers.erase(::std::find(m_pImpl->m_aControllers.begin(),m_pImpl->m_aControllers.end(),_xController));
        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 +473,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 +510,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();
@@ -757,7 +795,6 @@
         aGuard.reset();
     }
 
-    DBG_ASSERT( m_pImpl->m_aControllers.empty(), "ODatabaseDocument::close: 
aren't controllers expected to veto the closing?" );
     impl_closeControllerFrames( _bDeliverOwnership );
 
     {
@@ -1066,8 +1103,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 );




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to