User: rt      
Date: 2008-06-06 14:06:51+0000
Modified:
   dba/dbaccess/source/ui/app/AppController.cxx

Log:
 INTEGRATION: CWS dba30c (1.60.2); FILE MERGED
 2008/05/19 05:50:55 fs 1.60.2.3: #i10000#
 2008/05/16 06:33:16 oj 1.60.2.2: remove a comment and return 0L
 2008/05/13 08:56:24 fs 1.60.2.1: joining changes from CWS odbmacros3 to CWS 
dba30c:

 2008/04/13 19:27:37 fs 1.56.6.1: #i49133# re-enable scripting support

 2008/04/15 13:11:38 fs 1.56.6.2: RESYNC: (1.56-1.59); FILE MERGED

 2008/05/08 10:08:12 fs 1.56.6.3: #i49133# no migration warning when the 
document is read-only, or the warning has been explicitly suppressed

 2008/05/08 13:07:00 fs 1.56.6.4: during #i49133#: catch and display exceptions 
during store/ToURL

 2008/05/08 13:09:07 fs 1.56.6.5: removed obsolete includes

 2008/05/09 09:26:57 fs 1.56.6.6: RESYNC: (1.59-1.60); FILE MERGED

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.60&r2=1.61
Delta lines:  +99 -49
---------------------
--- AppController.cxx   2008-05-05 15:51:14+0000        1.60
+++ AppController.cxx   2008-06-06 14:06:49+0000        1.61
@@ -68,12 +68,12 @@
 #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
 #include <com/sun/star/util/XModifyBroadcaster.hpp>
 #include <com/sun/star/util/XModifiable.hpp>
-#include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
 #include <com/sun/star/util/XFlushable.hpp>
 #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
@@ -88,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
@@ -227,9 +230,6 @@
 #include "dbaccess_slotid.hrc"
 #endif
 
-#include <boost/mem_fn.hpp>
-#include <boost/bind.hpp>
-#include <boost/utility.hpp>
 #include <algorithm>
 #include <functional>
 
@@ -257,6 +257,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;
 
 
//------------------------------------------------------------------------------
@@ -991,6 +992,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)
 {
@@ -1122,11 +1155,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);
@@ -1146,15 +1186,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;
@@ -1165,9 +1210,6 @@
                                     getContainer()->selectContainer(E_TABLE);
                                 }
                                                        }
-                                               }
-                                       }
-                               }
                                break;
                        case ID_BROWSER_SORTUP:
                                getContainer()->sortUp();
@@ -1709,8 +1751,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;
 
@@ -2136,8 +2177,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)
@@ -2155,8 +2195,7 @@
         }
                
         EventObject aEvent(*this);
-        m_aSelectionListeners.forEach<XSelectionChangeListener>(
-                       
::boost::bind(&XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent)));
+        m_aSelectionListeners.notifyEach( 
&XSelectionChangeListener::selectionChanged, aEvent );
        }
 }
 // 
-----------------------------------------------------------------------------
@@ -2505,14 +2544,25 @@
         return 0L;
     }
 
+    try
+    {
+        // If the migration just happened, but was not successful, the 
document is reloaded.
+        // In this case, we should not show the warning, again.
+        ::comphelper::NamedValueCollection aModelArgs( m_xModel->getArgs() );
+        if ( aModelArgs.getOrDefault( "SuppressMigrationWarning", sal_False ) )
+            return 0L;
+
+        // also, if the document is read-only, then no migration is possible, 
and the
+        // respective menu entry is hidden. So, don't show the warning in this 
case, too.
+        if ( Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly() 
)
+            return 0L;
+
     SQLWarning aWarning;
     aWarning.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS ) );
     SQLException aDetail;
     aDetail.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS_DETAIL ) );
     aWarning.NextException <<= aDetail;
 
-    try
-    {
         ::comphelper::ComponentContext aContext( getORB() );
         Sequence< Any > aArgs(1);
         aArgs[0] <<= NamedValue( PROPERTY_SQLEXCEPTION, makeAny( aWarning ) );




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

Reply via email to