Tag: cws_src680_odbmacros2
User: fs      
Date: 2008-01-26 21:19:47+0000
Modified:
   dba/dbaccess/source/ui/app/AppController.cxx
   dba/dbaccess/source/ui/app/AppController.hxx
   dba/dbaccess/source/ui/app/app.src

Log:
 #i49133# when connecting to a document which contains macros/scripts in a 
form/report, then show a warning

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.50.2.3&r2=1.50.2.4
Delta lines:  +80 -3
--------------------
--- AppController.cxx   2008-01-24 10:33:50+0000        1.50.2.3
+++ AppController.cxx   2008-01-26 21:19:45+0000        1.50.2.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: AppController.cxx,v $
  *
- *  $Revision: 1.50.2.3 $
+ *  $Revision: 1.50.2.4 $
  *
- *  last change: $Author: fs $ $Date: 2008/01/24 10:33:50 $
+ *  last change: $Author: fs $ $Date: 2008/01/26 21:19:45 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -69,6 +69,7 @@
 #include <com/sun/star/util/XNumberFormatter.hpp>
 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
 #include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/frame/XModel2.hpp>
 /** === end UNO includes === **/
 
 #ifndef _TOOLS_DEBUG_HXX
@@ -212,9 +213,13 @@
 #ifndef _COMPHELPER_SEQUENCE_HXX_
 #include <comphelper/sequence.hxx>
 #endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
 #ifndef _DBACCESS_SLOTID_HRC_
 #include "dbaccess_slotid.hrc"
 #endif
+
 #include <boost/mem_fn.hpp>
 #include <boost/bind.hpp>
 #include <boost/utility.hpp>
@@ -300,9 +305,9 @@
     ,m_aTableCopyHelper(this)
        ,m_pClipbordNotifier(NULL)
        ,m_nAsyncDrop(0)
+    ,m_aControllerConnectedEvent( LINK( this, OApplicationController, 
OnFirstControllerConnected ) )
        ,m_ePreviewMode(E_PREVIEWNONE)
        ,m_eOldType(E_NONE)
-       ,m_bPreviewEnabled(sal_True)
        ,m_bNeedToReconnect(sal_False)
     ,m_bSuspended( sal_False )
 {
@@ -355,6 +360,8 @@
 //--------------------------------------------------------------------
 void SAL_CALL OApplicationController::disposing()
 {
+    m_aControllerConnectedEvent.CancelCall();
+
        
::std::for_each(m_aCurrentContainers.begin(),m_aCurrentContainers.end(),XContainerFunctor(this));
        m_aCurrentContainers.clear();
 
@@ -2399,6 +2406,73 @@
 {
        return m_xModel;
 }
+
+// 
-----------------------------------------------------------------------------
+void OApplicationController::onConnectedModel()
+{
+    sal_Int32 nConnectedControllers( 0 );
+    try
+    {
+        Reference< XModel2 > xModel( m_xModel, UNO_QUERY_THROW );
+        Reference< XEnumeration > xEnumControllers( xModel->getControllers(), 
UNO_SET_THROW );
+        while ( xEnumControllers->hasMoreElements() )
+        {
+            Reference< XController > xController( 
xEnumControllers->nextElement(), UNO_QUERY_THROW );
+            ++nConnectedControllers;
+        }
+    }
+    catch( const Exception& )
+    {
+       DBG_UNHANDLED_EXCEPTION();
+    }
+
+    if ( nConnectedControllers > 1 )
+    {   // we are not the first connected controller, there were already others
+        return;
+    }
+
+    m_aControllerConnectedEvent.Call();
+}
+
+// 
-----------------------------------------------------------------------------
+IMPL_LINK( OApplicationController, OnFirstControllerConnected, void*, /**/ )
+{
+    // if we have forms or reports which contain macros/scripts, then show a 
warning
+    // which suggests the user to migrate them to the database document
+
+    Reference< XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY );
+    if ( xDocumentScripts.is() )
+    {
+        // no need to show this warning, obviously the document supports 
embedding scripts
+        // into itself, so there are no "old-style" forms/reports which have 
macros/scripts
+        // themselves
+        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 ) );
+        Reference< XExecutableDialog > xDialog(
+            aContext.createComponentWithArguments( 
"com.sun.star.sdb.ErrorMessageDialog", aArgs ),
+            UNO_QUERY_THROW );
+        xDialog->execute();
+    }
+    catch( const Exception& )
+    {
+       DBG_UNHANDLED_EXCEPTION();
+    }
+
+    return 1L;
+}
+
 // 
-----------------------------------------------------------------------------
 sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel 
> & _rxModel) throw( RuntimeException )
 {
@@ -2416,7 +2490,10 @@
 
     m_xModel = _rxModel;
     if ( _rxModel.is() )
+    {
         m_aModelConnector = ModelControllerConnector( _rxModel, this );
+        onConnectedModel();
+    }
     else
         m_aModelConnector.clear();
 

File [changed]: AppController.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.hxx?r1=1.22.2.3&r2=1.22.2.4
Delta lines:  +13 -4
--------------------
--- AppController.hxx   2008-01-24 10:09:35+0000        1.22.2.3
+++ AppController.hxx   2008-01-26 21:19:45+0000        1.22.2.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: AppController.hxx,v $
  *
- *  $Revision: 1.22.2.3 $
+ *  $Revision: 1.22.2.4 $
  *
- *  last change: $Author: fs $ $Date: 2008/01/24 10:09:35 $
+ *  last change: $Author: fs $ $Date: 2008/01/26 21:19:45 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -130,12 +130,13 @@
                                                                
m_pClipbordNotifier;            // notifier for changes in the clipboard
                mutable ::rtl::OUString m_sDatabaseName;
                sal_Int32                               m_nAsyncDrop;
+        OAsyncronousLink        m_aControllerConnectedEvent;
                PreviewMode                             m_ePreviewMode;         
                // the mode of the preview
                ElementType                             m_eOldType;
-               sal_Bool                                m_bPreviewEnabled;      
                // true when the preview should enabled
                sal_Bool                                m_bNeedToReconnect;     
                // true when the settings of the data source were modified and 
the connection is no longer up to date
-               sal_Bool                                m_bSuspended            
: 1;    // is true when the controller was already suspended
+               sal_Bool                                m_bSuspended;           
    // is true when the controller was already suspended
 
+    private:
 
                OApplicationView*               getContainer() const;
 
@@ -416,6 +417,13 @@
         */
         void selectEntry(const ElementType _eType,const ::rtl::OUString& 
_sName);
 
+        /** called when we just connected to a new, non-NULL model
+
+            In particular, this is called *after* the controller has been 
announced to the model
+            (XModel::connectController)
+        */
+        void onConnectedModel();
+
         /// determines whether the given table name denotes a view which can 
be altered
         bool    impl_isAlterableView_nothrow( const ::rtl::OUString& 
_rTableOrViewName ) const;
 
@@ -531,6 +539,7 @@
                DECL_LINK( OnClipboardChanged, void* );
                DECL_LINK( OnAsyncDrop, void* );
                DECL_LINK( OnCreateWithPilot, void* );
+        DECL_LINK( OnFirstControllerConnected, void* );
 
                // IContainerFoundListener
                virtual void containerFound( const 
::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& 
_xContainer);

File [changed]: app.src
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/app.src?r1=1.15&r2=1.15.2.1
Delta lines:  +17 -6
--------------------
--- app.src     2007-11-20 19:23:20+0000        1.15
+++ app.src     2008-01-26 21:19:45+0000        1.15.2.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: app.src,v $
  *
- *  $Revision: 1.15 $
+ *  $Revision: 1.15.2.1 $
  *
- *  last change: $Author: ihi $ $Date: 2007/11/20 19:23:20 $
+ *  last change: $Author: fs $ $Date: 2008/01/26 21:19:45 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -454,8 +454,19 @@
        Text [ en-US ] = "F~older name" ;
 };
 
-String RID_STR_ERROR_NO_REPORT_INSTALLED
+String STR_SUB_DOCS_WITH_SCRIPTS
 {
-       Text [ de ] ="Es wurde keine Report Designer Erweiterung gefunden, 
bitte installieren." ;
-       Text [ en-US ] = "There is no report designer extension found, please 
install." ;
+       Text [ en-US ] = "The document contains forms and/or reports with 
macros and/or scripts embedded.";
+};
+
+String STR_SUB_DOCS_WITH_SCRIPTS_DETAIL
+{
+    Text [ en-US ] = "Scripts and macros should nowadays be embedded into the 
database document itself.\n\n"
+
+                    "You can continue to use your document as before, however, 
you are encouraged to migrate "
+                    "your scripts and macros. The menu item 'Tools / Migrate 
Scripts and Macros ...' will "
+                    "assist you with this.\n\n"
+
+                    "Note that you won't be able to embed macros or scripts 
into the database document until "
+                    "this migration is done. ";
 };




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

Reply via email to