Tag: cws_dev300_odbmacros3
User: fs      
Date: 2008-05-08 13:14:54+0000
Modified:
   dba/dbaccess/source/core/dataaccess/databasedocument.cxx
   dba/dbaccess/source/core/dataaccess/databasedocument.hxx

Log:
 #i49133# impl_createStorageFor now always throws in case of error, instead of 
silencing the error with an interaction handler

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.40.6.3&r2=1.40.6.4
Delta lines:  +6 -69
--------------------
--- databasedocument.cxx        2008-05-07 08:34:02+0000        1.40.6.3
+++ databasedocument.cxx        2008-05-08 13:14:51+0000        1.40.6.4
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: databasedocument.cxx,v $
- * $Revision: 1.40.6.3 $
+ * $Revision: 1.40.6.4 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -37,7 +37,6 @@
 #include "module_dba.hxx"
 
 #include <comphelper/documentconstants.hxx>
-#include <comphelper/interaction.hxx>
 #include <comphelper/namedvaluecollection.hxx>
 #include <comphelper/enumhelper.hxx>
 #include <comphelper/numberedcollection.hxx>
@@ -597,10 +596,7 @@
        if ( bLocationChanged )
        {
         // create storage for target URL
-        Reference< XStorage > xTargetStorage;
-        if ( !impl_createStorageFor_throw( _rURL, xTargetStorage ) )
-            // failed, but handled by an interaction handler
-            return;
+        Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( 
_rURL ) );
 
         if ( m_pImpl->isEmbeddedDatabase() )
             m_pImpl->clearConnections();
@@ -647,70 +643,14 @@
 }
 
 // 
-----------------------------------------------------------------------------
-bool ODatabaseDocument::impl_createStorageFor_throw( const ::rtl::OUString& 
_rURL, Reference< XStorage >& _out_rxStorage ) const
+Reference< XStorage > ODatabaseDocument::impl_createStorageFor_throw( const 
::rtl::OUString& _rURL ) const
 {
-    _out_rxStorage.clear();
-
     Sequence<Any> aParam(2);
        aParam[0] <<= _rURL;
        aParam[1] <<= ElementModes::READWRITE | ElementModes::TRUNCATE;
 
-    Any aOriginalError;
-       try
-       {
         Reference< XSingleServiceFactory > xStorageFactory( 
m_pImpl->createStorageFactory(), UNO_SET_THROW );
-               _out_rxStorage.set( 
xStorageFactory->createInstanceWithArguments( aParam ), UNO_QUERY_THROW );
-       }
-    catch ( const Exception& )
-       {
-        aOriginalError = ::cppu::getCaughtException();
-       }
-
-    if ( _out_rxStorage.is() )
-        return true;
-
-    // try handling the error with the interaction handler
-    ::comphelper::NamedValueCollection aArgs( m_pImpl->m_aArgs );
-    Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( 
"InteractionHandler", Reference< XInteractionHandler >() ) );
-    if ( xHandler.is() )
-    {
-        ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new 
::comphelper::OInteractionRequest( aOriginalError ) );
-        ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new 
::comphelper::OInteractionApprove );
-        pRequest->addContinuation( pApprove.get() );
-
-        try
-        {
-            xHandler->handle( pRequest.get() );
-        }
-        catch( const Exception& )
-        {
-            DBG_UNHANDLED_EXCEPTION();
-        }
-
-        if ( pApprove->wasSelected() )
-            return false;
-    }
-
-    Exception aException;
-    OSL_VERIFY( aOriginalError >>= aException );
-    ::rtl::OUString sOriginalExceptionType = aOriginalError.getValueTypeName();
-    ::rtl::OUString sOriginalExceptionMessage = aException.Message;
-
-    // TODO: resource
-    ::rtl::OUString sMessage = ::rtl::OUString::createFromAscii( "Could not 
create a storage for '" );
-    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, *const_cast< ODatabaseDocument* >( this ) 
);
+       return Reference< XStorage >( 
xStorageFactory->createInstanceWithArguments( aParam ), UNO_QUERY_THROW );
 }
 
 // 
-----------------------------------------------------------------------------
@@ -764,10 +704,7 @@
     ModifyLock aLock( *this );
 
     // create storage for target URL
-    Reference< XStorage > xTargetStorage;
-    if ( !impl_createStorageFor_throw( _rURL, xTargetStorage ) )
-        // failed, but handled by an interaction handler
-        return;
+    Reference< XStorage > xTargetStorage( impl_createStorageFor_throw( _rURL ) 
);
 
     // extend media descriptor with URL
     Sequence< PropertyValue > aMediaDescriptor( 
lcl_appendFileNameToDescriptor( _rArguments, _rURL ) );

File [changed]: databasedocument.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.hxx?r1=1.20.2.1&r2=1.20.2.2
Delta lines:  +8 -12
--------------------
--- databasedocument.hxx        2008-05-07 08:32:49+0000        1.20.2.1
+++ databasedocument.hxx        2008-05-08 13:14:51+0000        1.20.2.2
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: databasedocument.hxx,v $
- * $Revision: 1.20.2.1 $
+ * $Revision: 1.20.2.2 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -403,19 +403,15 @@
 
     /** creates a storage for the given URL, truncating it if a file with this 
name already exists
 
-        @throws IOException
-            if the storage could not be created, and the error causing this 
could not be handled
-            by the document's interaction handler. The message of the 
IOException will note the failure,
-            and also the message of the originally thrown exception.
+        @throws Exception
+            if creating the storage failed
 
         @return
-            <TRUE/> if and only if the storage could be created. If <FALSE/> 
is returned, then the storage
-            could not be created, but the error had successfully been handled 
by the document's
-            interaction handler.
+            the newly created storage for the file at the given URL
     */
-    bool    impl_createStorageFor_throw(
-                const ::rtl::OUString& _rURL,
-                ::com::sun::star::uno::Reference< 
::com::sun::star::embed::XStorage >& _out_rxStorage
+    ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+            impl_createStorageFor_throw(
+                const ::rtl::OUString& _rURL
             ) const;
 
     /** clears the guard before notifying.




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

Reply via email to