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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 5 12:50:47 UTC 2020


 vbahelper/source/msforms/vbacontrols.cxx        |    5 ++---
 vbahelper/source/vbahelper/vbadialogbase.cxx    |    3 +--
 vbahelper/source/vbahelper/vbapagesetupbase.cxx |    8 ++++----
 3 files changed, 7 insertions(+), 9 deletions(-)

New commits:
commit 349099b4e0fa59c3f340d3a1fb175db04220708a
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Thu Nov 5 11:22:20 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Nov 5 13:50:05 2020 +0100

    loplugin:reducevarscope in vbahelper
    
    Change-Id: I4cc99067ab39fb95aec2d608e3240340749f2bf9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105330
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx
index 7c56bd2bbff4..2b7c92374fcf 100644
--- a/vbahelper/source/msforms/vbacontrols.cxx
+++ b/vbahelper/source/msforms/vbacontrols.cxx
@@ -424,11 +424,10 @@ uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& St
 
 void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex )
 {
-    OUString aControlName;
-    sal_Int32 nIndex = -1;
-
     try
     {
+        OUString aControlName;
+        sal_Int32 nIndex = -1;
         if ( !mxDialog.is() )
             throw uno::RuntimeException();
 
diff --git a/vbahelper/source/vbahelper/vbadialogbase.cxx b/vbahelper/source/vbahelper/vbadialogbase.cxx
index 605a9c76f7eb..6e5ae97857b1 100644
--- a/vbahelper/source/vbahelper/vbadialogbase.cxx
+++ b/vbahelper/source/vbahelper/vbadialogbase.cxx
@@ -25,10 +25,9 @@ using namespace ::com::sun::star;
 
 void SAL_CALL VbaDialogBase::Show()
 {
-    OUString aURL;
     if ( m_xModel.is() )
     {
-        aURL = mapIndexToName( mnIndex );
+        OUString aURL = mapIndexToName( mnIndex );
         if( aURL.isEmpty() )
             throw uno::RuntimeException( "Unable to open the specified dialog" );
 
diff --git a/vbahelper/source/vbahelper/vbapagesetupbase.cxx b/vbahelper/source/vbahelper/vbapagesetupbase.cxx
index c29b166c69ca..d50fe188c193 100644
--- a/vbahelper/source/vbahelper/vbapagesetupbase.cxx
+++ b/vbahelper/source/vbahelper/vbapagesetupbase.cxx
@@ -38,7 +38,6 @@ double SAL_CALL VbaPageSetupBase::getTopMargin()
     try
     {
         bool headerOn = false;
-        sal_Int32 headerHeight = 0;
 
         uno::Any aValue = mxPageProps->getPropertyValue( "HeaderIsOn" );
         aValue >>= headerOn;
@@ -48,6 +47,7 @@ double SAL_CALL VbaPageSetupBase::getTopMargin()
 
         if( headerOn )
         {
+            sal_Int32 headerHeight = 0;
             aValue = mxPageProps->getPropertyValue( "HeaderHeight" );
             aValue >>= headerHeight;
             topMargin = topMargin + headerHeight;
@@ -67,13 +67,13 @@ void SAL_CALL VbaPageSetupBase::setTopMargin( double margin )
     try
     {
         bool headerOn = false;
-        sal_Int32 headerHeight = 0;
 
         uno::Any aValue = mxPageProps->getPropertyValue( "HeaderIsOn" );
         aValue >>= headerOn;
 
         if( headerOn )
         {
+            sal_Int32 headerHeight = 0;
             aValue = mxPageProps->getPropertyValue( "HeaderHeight" );
             aValue >>= headerHeight;
             topMargin -= headerHeight;
@@ -93,7 +93,6 @@ double SAL_CALL VbaPageSetupBase::getBottomMargin()
     try
     {
         bool footerOn = false;
-        sal_Int32 footerHeight = 0;
 
         uno::Any aValue = mxPageProps->getPropertyValue( "FooterIsOn" );
         aValue >>= footerOn;
@@ -103,6 +102,7 @@ double SAL_CALL VbaPageSetupBase::getBottomMargin()
 
         if( footerOn )
         {
+            sal_Int32 footerHeight = 0;
             aValue = mxPageProps->getPropertyValue( "FooterHeight" );
             aValue >>= footerHeight;
             bottomMargin += footerHeight;
@@ -122,13 +122,13 @@ void SAL_CALL VbaPageSetupBase::setBottomMargin( double margin )
     try
     {
         bool footerOn = false;
-        sal_Int32 footerHeight = 0;
 
         uno::Any aValue = mxPageProps->getPropertyValue( "FooterIsOn" );
         aValue >>= footerOn;
 
         if( footerOn )
         {
+            sal_Int32 footerHeight = 0;
             aValue = mxPageProps->getPropertyValue( "FooterHeight" );
             aValue >>= footerHeight;
             bottomMargin -= footerHeight;


More information about the Libreoffice-commits mailing list