sfx2/source/doc/objstor.cxx |   36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

New commits:
commit 1947730e9810cfbe5f1f7612aa48879b89c8ed6a
Author: Mike Kaganski <mike.kagan...@collabora.com>
Date:   Tue Jul 10 00:04:48 2018 +0200

    Use range-based for
    
    Change-Id: I2e598aa01d42ab4f67becdba3ee30f8dbe983aa2
    Reviewed-on: https://gerrit.libreoffice.org/57210
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 98435a9022d3..20c9d6bf1da6 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -3358,21 +3358,21 @@ bool SfxObjectShell::CopyStoragesOfUnknownMediaType( 
const uno::Reference< embed
 
     try
     {
-        uno::Sequence< OUString > aSubElements = xSource->getElementNames();
-        for ( sal_Int32 nInd = 0; nInd < aSubElements.getLength(); nInd++ )
+        for (const OUString& rSubElement : xSource->getElementNames())
         {
-            if ( aSubElements[nInd] == "Configurations" )
+            if (rSubElement == "Configurations")
             {
                 // The workaround for compatibility with SO7, "Configurations" 
substorage must be preserved
-                if ( xSource->isStorageElement( aSubElements[nInd] ) )
+                if (xSource->isStorageElement(rSubElement))
                 {
-                    OSL_ENSURE( !xTarget->hasByName( aSubElements[nInd] ),
-                                "The target storage is an output storage, the 
element should not exist in the target!" );
+                    OSL_ENSURE(!xTarget->hasByName(rSubElement), "The target 
storage is an output "
+                                                                 "storage, the 
element should not "
+                                                                 "exist in the 
target!");
 
-                    xSource->copyElementTo( aSubElements[nInd], xTarget, 
aSubElements[nInd] );
+                    xSource->copyElementTo(rSubElement, xTarget, rSubElement);
                 }
             }
-            else if ( xSource->isStorageElement( aSubElements[nInd] ) )
+            else if (xSource->isStorageElement(rSubElement))
             {
                 OUString aMediaType;
                 const OUString aMediaTypePropName( "MediaType"  );
@@ -3381,8 +3381,8 @@ bool SfxObjectShell::CopyStoragesOfUnknownMediaType( 
const uno::Reference< embed
                 try
                 {
                     uno::Reference< embed::XOptimizedStorage > xOptStorage( 
xSource, uno::UNO_QUERY_THROW );
-                    bGotMediaType =
-                        ( xOptStorage->getElementPropertyValue( 
aSubElements[nInd], aMediaTypePropName ) >>= aMediaType );
+                    bGotMediaType = 
(xOptStorage->getElementPropertyValue(rSubElement, aMediaTypePropName)
+                           >>= aMediaType);
                 }
                 catch( uno::Exception& )
                 {}
@@ -3391,7 +3391,8 @@ bool SfxObjectShell::CopyStoragesOfUnknownMediaType( 
const uno::Reference< embed
                 {
                     uno::Reference< embed::XStorage > xSubStorage;
                     try {
-                        xSubStorage = xSource->openStorageElement( 
aSubElements[nInd], embed::ElementModes::READ );
+                        xSubStorage
+                            = xSource->openStorageElement(rSubElement, 
embed::ElementModes::READ);
                     } catch( uno::Exception& )
                     {}
 
@@ -3401,7 +3402,7 @@ bool SfxObjectShell::CopyStoragesOfUnknownMediaType( 
const uno::Reference< embed
                         //             instead of the temporary storage; this 
substorage should be removed later
                         //             if the MimeType is wrong
                         xSubStorage = 
::comphelper::OStorageHelper::GetTemporaryStorage();
-                        xSource->copyStorageElementLastCommitTo( 
aSubElements[nInd], xSubStorage );
+                        xSource->copyStorageElementLastCommitTo(rSubElement, 
xSubStorage);
                     }
 
                     uno::Reference< beans::XPropertySet > xProps( xSubStorage, 
uno::UNO_QUERY_THROW );
@@ -3439,12 +3440,15 @@ bool SfxObjectShell::CopyStoragesOfUnknownMediaType( 
const uno::Reference< embed
 
                         default:
                         {
-                            OSL_ENSURE( aSubElements[nInd] == 
"Configurations2" || nFormat == SotClipboardFormatId::STARBASE_8 || 
!xTarget->hasByName( aSubElements[nInd] ),
-                                        "The target storage is an output 
storage, the element should not exist in the target!" );
+                            OSL_ENSURE(rSubElement == "Configurations2"
+                                           || nFormat == 
SotClipboardFormatId::STARBASE_8
+                                           || !xTarget->hasByName(rSubElement),
+                                       "The target storage is an output 
storage, the element "
+                                       "should not exist in the target!");
 
-                            if ( !xTarget->hasByName( aSubElements[nInd] ) )
+                            if (!xTarget->hasByName(rSubElement))
                             {
-                                xSource->copyElementTo( aSubElements[nInd], 
xTarget, aSubElements[nInd] );
+                                xSource->copyElementTo(rSubElement, xTarget, 
rSubElement);
                             }
                         }
                     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to