Tag: cws_dev300_odbmacros3
User: fs      
Date: 2008-05-11 21:13:32+0000
Modified:
   dba/dbaccess/source/ext/macromigration/macromigrationdialog.cxx

Log:
 also cache the XModel2 interfaction of the DBDoc

File Changes:

Directory: /dba/dbaccess/source/ext/macromigration/
===================================================

File [changed]: macromigrationdialog.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ext/macromigration/macromigrationdialog.cxx?r1=1.3.2.5&r2=1.3.2.6
Delta lines:  +15 -16
---------------------
--- macromigrationdialog.cxx    2008-05-08 10:10:39+0000        1.3.2.5
+++ macromigrationdialog.cxx    2008-05-11 21:13:30+0000        1.3.2.6
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: macromigrationdialog.cxx,v $
- * $Revision: 1.3.2.5 $
+ * $Revision: 1.3.2.6 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -45,7 +45,6 @@
 #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
 #include <com/sun/star/frame/XModel2.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
-#include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/util/XCloseable.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/util/XModifiable.hpp>
@@ -91,7 +90,6 @@
     using ::com::sun::star::frame::XStorable;
     using ::com::sun::star::uno::Sequence;
     using ::com::sun::star::beans::PropertyValue;
-    using ::com::sun::star::frame::XModel;
     using ::com::sun::star::frame::XFrame;
     using ::com::sun::star::awt::XWindow;
     using ::com::sun::star::util::XCloseable;
@@ -106,12 +104,11 @@
        //= helper
        //====================================================================
     //--------------------------------------------------------------------
-    static void lcl_getControllers_throw( const Reference< 
XOfficeDatabaseDocument >& _rxDocument,
+    static void lcl_getControllers_throw( const Reference< XModel2 >& 
_rxDocument,
         ::std::list< Reference< XController2 > >& _out_rControllers )
     {
         _out_rControllers.clear();
-        Reference< XModel2 > xDocument( _rxDocument, UNO_QUERY_THROW );
-        Reference< XEnumeration > xControllerEnum( 
xDocument->getControllers(), UNO_SET_THROW );
+        Reference< XEnumeration > xControllerEnum( 
_rxDocument->getControllers(), UNO_SET_THROW );
         while ( xControllerEnum->hasMoreElements() )
             _out_rControllers.push_back( Reference< XController2 >( 
xControllerEnum->nextElement(), UNO_QUERY_THROW ) );
     }
@@ -124,6 +121,7 @@
         ::comphelper::ComponentContext          aContext;
         MigrationLog                            aLogger;
         Reference< XOfficeDatabaseDocument >    xDocument;
+        Reference< XModel2 >                    xDocumentModel;
         ::rtl::OUString                         sSuccessfulBackupLocation;
         bool                                    bMigrationIsRunning;
         bool                                    bMigrationFailure;
@@ -135,6 +133,7 @@
             :aContext( _rContext )
             ,aLogger()
             ,xDocument( _rxDocument )
+            ,xDocumentModel( _rxDocument, UNO_QUERY )
             ,bMigrationIsRunning( false )
             ,bMigrationFailure( false )
             ,bMigrationSuccess( false )
@@ -173,7 +172,7 @@
         enableButtons( WZB_FINISH, true );
         ActivatePage();
 
-        OSL_PRECOND( m_pData->xDocument.is(), 
"MacroMigrationDialog::MacroMigrationDialog: illegal document!" );
+        OSL_PRECOND( m_pData->xDocumentModel.is(), 
"MacroMigrationDialog::MacroMigrationDialog: illegal document!" );
     }
 
        //--------------------------------------------------------------------
@@ -373,7 +372,7 @@
         {
             // collect all controllers of our document
             ::std::list< Reference< XController2 > > aControllers;
-            lcl_getControllers_throw( m_pData->xDocument, aControllers );
+            lcl_getControllers_throw( m_pData->xDocumentModel, aControllers );
 
             // close all sub documents of all controllers
             for (   ::std::list< Reference< XController2 > >::const_iterator 
pos = aControllers.begin();
@@ -426,7 +425,8 @@
         }
 
         // display the error to the user
-        DocumentErrorHandling::reportError( m_pData->aContext, 
m_pData->xDocument, aError );
+        InteractionHandler aHandler( m_pData->aContext, 
m_pData->xDocumentModel.get() );
+        aHandler.reportError( aError );
 
         m_pData->aLogger.logFailure( MigrationError(
             ERR_DOCUMENT_BACKUP_FAILED,
@@ -445,17 +445,15 @@
 
         try
         {
-            Reference< XModel2 > xDocument( m_pData->xDocument, 
UNO_QUERY_THROW );
-
             // the information which is necessary to reload the document
-            ::rtl::OUString                     sDocumentURL ( 
xDocument->getURL()  );
-            ::comphelper::NamedValueCollection  aDocumentArgs( 
xDocument->getArgs() );
+            ::rtl::OUString                     sDocumentURL ( 
m_pData->xDocumentModel->getURL()  );
+            ::comphelper::NamedValueCollection  aDocumentArgs( 
m_pData->xDocumentModel->getArgs() );
             if ( !_bMigrationSuccess )
             {
                 // if the migration was not successful, then reload from the 
backup
                 aDocumentArgs.put( "SalvagedFile", 
m_pData->sSuccessfulBackupLocation );
                 // reset the modified flag of the document, so the controller 
can be suspended later
-                Reference< XModifiable > xModify( xDocument, UNO_QUERY_THROW );
+                Reference< XModifiable > xModify( m_pData->xDocument, 
UNO_QUERY_THROW );
                 xModify->setModified( sal_False );
                 // after this reload, don't show the migration warning, again
                 aDocumentArgs.put( "SuppressMigrationWarning", 
sal_Bool(sal_True) );
@@ -470,7 +468,7 @@
 
             // collect all controllers of our document
             ::std::list< Reference< XController2 > > aControllers;
-            lcl_getControllers_throw( m_pData->xDocument, aControllers );
+            lcl_getControllers_throw( m_pData->xDocumentModel, aControllers );
 
             // close all those controllers
             while ( !aControllers.empty() )
@@ -516,7 +514,7 @@
                     aDocumentArgs.getPropertyValues()
                 ) );
 
-                OSL_ENSURE( xReloaded != xDocument,
+                OSL_ENSURE( xReloaded != m_pData->xDocumentModel,
                     "MacroMigrationDialog::impl_reloadDocument_nothrow: this 
should have been a new instance!" );
                     // this would be unexpected, but recoverable: The loader 
should at least have done
                     // this: really *load* the document, even if it loaded it 
into the old document instance
@@ -536,6 +534,7 @@
             }
 
             m_pData->xDocument = xNewDocument;
+            m_pData->xDocumentModel.set( xNewDocument, UNO_QUERY );
 
             // finally, now that the document has been reloaded - if the 
migration was not successful,
             // then it was reloaded from the backup, but the real document 
still is broken. So, save




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

Reply via email to