[Libreoffice-commits] core.git: dbaccess/source

Julien Nabet serval2412 at yahoo.fr
Sat Nov 18 06:52:58 UTC 2017


 dbaccess/source/ext/macromigration/macromigrationdialog.cxx |   42 +++++-------
 1 file changed, 19 insertions(+), 23 deletions(-)

New commits:
commit e36c468dab4006afcfae76b1676df7cedbb82f1d
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Fri Nov 17 21:03:24 2017 +0100

    Replace list by vector in macromigrationdialog (dbaccess)
    
    + use for range loops
    
    Change-Id: I676009baa7b7aeb8c26951a8786da22431b0bc81
    Reviewed-on: https://gerrit.libreoffice.org/44896
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx
index 7fffb394e49b..e30bd2652daf 100644
--- a/dbaccess/source/ext/macromigration/macromigrationdialog.cxx
+++ b/dbaccess/source/ext/macromigration/macromigrationdialog.cxx
@@ -44,7 +44,7 @@
 #include <ucbhelper/content.hxx>
 #include <vcl/layout.hxx>
 
-#include <list>
+#include <vector>
 
 namespace dbmm
 {
@@ -88,7 +88,7 @@ namespace dbmm
 
     // helper
     static void lcl_getControllers_throw(const Reference< XModel2 >& _rxDocument,
-        std::list< Reference< XController2 > >& _out_rControllers )
+        std::vector< Reference< XController2 > >& _out_rControllers )
     {
         _out_rControllers.clear();
         Reference< XEnumeration > xControllerEnum( _rxDocument->getControllers(), UNO_SET_THROW );
@@ -311,16 +311,13 @@ namespace dbmm
         try
         {
             // collect all controllers of our document
-            std::list< Reference< XController2 > > aControllers;
+            std::vector< Reference< XController2 > > 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();
-                    pos != aControllers.end() && bSuccess;
-                    ++pos
-                )
+            for (auto const& controller : aControllers)
             {
-                Reference< XDatabaseDocumentUI > xController( *pos, UNO_QUERY );
+                Reference< XDatabaseDocumentUI > xController( controller, UNO_QUERY );
                 OSL_ENSURE( xController.is(), "MacroMigrationDialog::impl_closeSubDocs_nothrow: unexpected: controller is missing an important interface!" );
                     // at the moment, only one implementation for a DBDoc's controller exists, which should
                     // support this interface
@@ -328,6 +325,8 @@ namespace dbmm
                     continue;
 
                 bSuccess = xController->closeSubComponents();
+                if (!bSuccess)
+                    break;
             }
         }
         catch( const Exception& )
@@ -423,7 +422,7 @@ namespace dbmm
     void MacroMigrationDialog::impl_reloadDocument_nothrow( bool _bMigrationSuccess )
     {
         typedef std::pair< Reference< XFrame >, OUString > ViewDescriptor;
-        std::list< ViewDescriptor > aViews;
+        std::vector< ViewDescriptor > aViews;
 
         try
         {
@@ -449,14 +448,13 @@ namespace dbmm
             aDocumentArgs.remove( "URL" );
 
             // collect all controllers of our document
-            std::list< Reference< XController2 > > aControllers;
+            std::vector< Reference< XController2 > > aControllers;
             lcl_getControllers_throw( m_pData->xDocumentModel, aControllers );
 
             // close all those controllers
-            while ( !aControllers.empty() )
+            for (auto const& controller : aControllers)
             {
-                Reference< XController2 > xController( aControllers.front(), UNO_SET_THROW );
-                aControllers.pop_front();
+                Reference< XController2 > xController( controller, UNO_SET_THROW );
 
                 Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
                 OUString sViewName( xController->getViewControllerName() );
@@ -474,6 +472,7 @@ namespace dbmm
                 xFrame->setComponent( nullptr, nullptr );
                 xController->dispose();
             }
+            aControllers.clear();
 
             // Note the document is closed now - disconnecting the last controller
             // closes it automatically.
@@ -481,14 +480,11 @@ namespace dbmm
             Reference< XOfficeDatabaseDocument > xNewDocument;
 
             // re-create the views
-            while ( !aViews.empty() )
+            for (auto const& view : aViews)
             {
-                ViewDescriptor aView( aViews.front() );
-                aViews.pop_front();
-
                 // load the document into this frame
-                Reference< XComponentLoader > xLoader( aView.first, UNO_QUERY_THROW );
-                aDocumentArgs.put( "ViewName", aView.second );
+                Reference< XComponentLoader > xLoader( view.first, UNO_QUERY_THROW );
+                aDocumentArgs.put( "ViewName", view.second );
                 Reference< XInterface > xReloaded( xLoader->loadComponentFromURL(
                     sDocumentURL,
                     "_self",
@@ -514,6 +510,7 @@ namespace dbmm
                 }
                 #endif
             }
+            aViews.clear();
 
             m_pData->xDocument = xNewDocument;
             m_pData->xDocumentModel.set( xNewDocument, UNO_QUERY );
@@ -537,13 +534,11 @@ namespace dbmm
 
         // close all frames from aViews - the respective controllers have been closed, but
         // reloading didn't work, so the frames are zombies now.
-        while ( !aViews.empty() )
+        for (auto const& view : aViews)
         {
-            ViewDescriptor aView( aViews.front() );
-            aViews.pop_front();
             try
             {
-                Reference< XCloseable > xFrameClose( aView.first, UNO_QUERY_THROW );
+                Reference< XCloseable > xFrameClose( view.first, UNO_QUERY_THROW );
                 xFrameClose->close( true );
             }
             catch( const Exception& )
@@ -551,6 +546,7 @@ namespace dbmm
                 DBG_UNHANDLED_EXCEPTION();
             }
         }
+        aViews.clear();
     }
 
 } // namespace dbmm


More information about the Libreoffice-commits mailing list