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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 5 19:48:02 UTC 2019


 sdext/source/minimizer/optimizerdialog.cxx |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

New commits:
commit 7cefe392e37d82d5df9d7a0b1462b1121bd7ef1b
Author:     Matteo Casalin <matteo.casalin at yahoo.com>
AuthorDate: Sun Feb 10 16:28:30 2019 +0100
Commit:     Matteo Casalin <matteo.casalin at yahoo.com>
CommitDate: Tue Mar 5 20:47:37 2019 +0100

    OptimizerDialog: use local method to reduce OUString operations
    
    Change-Id: I356693ba9992c691c9079b3eaa2f26e57b005e1c
    Reviewed-on: https://gerrit.libreoffice.org/67640
    Tested-by: Jenkins
    Reviewed-by: Matteo Casalin <matteo.casalin at yahoo.com>

diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx
index 3da7dc6c2d93..eb9670a31464 100644
--- a/sdext/source/minimizer/optimizerdialog.cxx
+++ b/sdext/source/minimizer/optimizerdialog.cxx
@@ -711,6 +711,18 @@ void TextListenerFormattedField0Pg1::disposing( const css::lang::EventObject& /*
 {
 }
 
+namespace
+{
+
+bool lcl_mapResolution(OUString& rResolution, const OUString& rImageResolution)
+{
+    if (rImageResolution.getToken(1, ';')!=rResolution)
+        return false;
+    rResolution = rImageResolution.getToken(0, ';');
+    return true;
+}
+
+}
 
 void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ )
 {
@@ -719,17 +731,11 @@ void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ )
     if ( !(aAny >>= aString) )
         return;
 
-    sal_Int32 nI0, nI1, nI2, nI3, nI4;
-    nI0 = nI1 = nI2 = nI3 = nI4 = 0;
-
-    if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString )
-        aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 );
-    else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString )
-        aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 );
-    else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString )
-        aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 );
-    else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString )
-        aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 );
+    for (int nIR{ STR_IMAGE_RESOLUTION_0 }; nIR <= STR_IMAGE_RESOLUTION_3; ++nIR)
+    {
+        if (lcl_mapResolution(aString, mrOptimizerDialog.getString(static_cast<PPPOptimizerTokenEnum>(nIR))))
+            break;
+    }
 
     mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) );
 }


More information about the Libreoffice-commits mailing list