Tag: cws_dev300_odbmacros3
User: fs      
Date: 2008-05-08 13:07:03+0000
Modified:
   dba/dbaccess/source/ui/app/AppController.cxx

Log:
 during #i49133#: catch and display exceptions during store/ToURL

File Changes:

Directory: /dba/dbaccess/source/ui/app/
=======================================

File [changed]: AppController.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.cxx?r1=1.56.6.3&r2=1.56.6.4
Delta lines:  +74 -31
---------------------
--- AppController.cxx   2008-05-08 10:08:12+0000        1.56.6.3
+++ AppController.cxx   2008-05-08 13:07:00+0000        1.56.6.4
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: AppController.cxx,v $
- * $Revision: 1.56.6.3 $
+ * $Revision: 1.56.6.4 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -73,6 +73,7 @@
 #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
 #include "com/sun/star/beans/NamedValue.hpp"
 #include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
 /** === end UNO includes === **/
 
 #ifndef _TOOLS_DEBUG_HXX
@@ -87,6 +88,9 @@
 #ifndef _COMPHELPER_TYPES_HXX_
 #include <comphelper/types.hxx>
 #endif
+#ifndef _COMPHELPER_INTERACTION_HXX_
+#include <comphelper/interaction.hxx>
+#endif
 #ifndef COMPHELPER_COMPONENTCONTEXT_HXX
 #include <comphelper/componentcontext.hxx>
 #endif
@@ -256,6 +260,7 @@
 using namespace ::com::sun::star::sdbcx;
 using namespace ::com::sun::star::datatransfer;
 using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::task;
 using ::com::sun::star::document::XEmbeddedScripts;
 
 
//------------------------------------------------------------------------------
@@ -983,6 +988,38 @@
        }
        return aReturn;
 }
+
+// 
-----------------------------------------------------------------------------
+namespace
+{
+    bool lcl_handleException_nothrow( const Reference< XModel >& _rxDocument, 
const Any& _rException )
+    {
+        bool bHandled = false;
+
+        // try handling the error with an interaction handler
+        ::comphelper::NamedValueCollection aArgs( _rxDocument->getArgs() );
+        Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( 
"InteractionHandler", Reference< XInteractionHandler >() ) );
+        if ( xHandler.is() )
+        {
+            ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( 
new ::comphelper::OInteractionRequest( _rException ) );
+            ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( 
new ::comphelper::OInteractionApprove );
+            pRequest->addContinuation( pApprove.get() );
+
+            try
+            {
+                xHandler->handle( pRequest.get() );
+            }
+            catch( const Exception& )
+            {
+                DBG_UNHANDLED_EXCEPTION();
+            }
+
+            bHandled = pApprove->wasSelected();
+        }
+        return bHandled;
+    }
+}
+
 // 
-----------------------------------------------------------------------------
 void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< 
PropertyValue >& aArgs)
 {
@@ -1113,11 +1150,18 @@
                                break;
                        case ID_BROWSER_SAVEDOC:
                                {
-                                       Reference<XStorable> 
xStore(m_xModel,UNO_QUERY);
-                                       if ( xStore.is() )
+                                       Reference< XStorable > xStore( 
m_xModel, UNO_QUERY_THROW );
+                    try
+                    {
                                                xStore->store();
                                }
+                    catch( const Exception& )
+                    {
+                        lcl_handleException_nothrow( m_xModel, 
::cppu::getCaughtException() );
+                    }
+                               }
                                break;
+
                        case ID_BROWSER_SAVEASDOC:
                                {
                                        WinBits nBits(WB_STDMODAL|WB_SAVEAS);
@@ -1137,15 +1181,20 @@
                                                
aFileDlg.SetCurrentFilter(pFilter->GetUIName());
                                        }
 
-                                       if ( aFileDlg.Execute() == ERRCODE_NONE 
)
-                                       {
-                                               Reference<XStorable> 
xStore(m_xModel,UNO_QUERY);
-                                               if ( xStore.is() )
-                                               {
+                                       if ( aFileDlg.Execute() != ERRCODE_NONE 
)
+                        break;
+
+                    Reference<XStorable> xStore( m_xModel, UNO_QUERY_THROW );
                                                        INetURLObject aURL( 
aFileDlg.GetPath() );
-                                                       if( aURL.GetProtocol() 
!= INET_PROT_NOT_VALID )
+                    try
+                    {
+                        xStore->storeAsURL( aURL.GetMainURL( 
INetURLObject::NO_DECODE ), Sequence< PropertyValue >() );
+                    }
+                    catch( const Exception& )
                                                        {
-                                                               
xStore->storeAsURL(aURL.GetMainURL( INetURLObject::NO_DECODE 
),Sequence<PropertyValue>());
+                        lcl_handleException_nothrow( m_xModel, 
::cppu::getCaughtException() );
+                    }
+
                                                                m_sDatabaseName 
= ::rtl::OUString();
                                                                
/*updateTitle();*/
                                                                
m_bCurrentlyModified = sal_False;
@@ -1156,9 +1205,6 @@
                                     getContainer()->selectContainer(E_TABLE);
                                 }
                                                        }
-                                               }
-                                       }
-                               }
                                break;
                        case ID_BROWSER_SORTUP:
                                getContainer()->sortUp();
@@ -1700,8 +1746,7 @@
 
                InvalidateAll();
                EventObject aEvent(*this);
-        m_aSelectionListeners.forEach<XSelectionChangeListener>(
-                   
::boost::bind(&XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent)));
+        m_aSelectionListeners.notifyEach( 
&XSelectionChangeListener::selectionChanged, aEvent );
        }
        m_eCurrentType = _eType;
 
@@ -2120,8 +2165,7 @@
 {
        InvalidateAll();
     EventObject aEvent(*this);
-    m_aSelectionListeners.forEach<XSelectionChangeListener>(
-               
::boost::bind(&XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent)));
+    m_aSelectionListeners.notifyEach( 
&XSelectionChangeListener::selectionChanged, aEvent );
 }
 // 
-----------------------------------------------------------------------------
 void OApplicationController::onEntrySelect(SvLBoxEntry* _pEntry)
@@ -2139,8 +2183,7 @@
         }
 
         EventObject aEvent(*this);
-        m_aSelectionListeners.forEach<XSelectionChangeListener>(
-                       
::boost::bind(&XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent)));
+        m_aSelectionListeners.notifyEach( 
&XSelectionChangeListener::selectionChanged, aEvent );
        }
 }
 // 
-----------------------------------------------------------------------------




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

Reply via email to