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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 2 08:28:37 UTC 2020


 cui/source/customize/CommandCategoryListBox.cxx |    2 +-
 cui/source/customize/cfg.cxx                    |    2 +-
 cui/source/dialogs/about.cxx                    |    2 +-
 cui/source/dialogs/cuicharmap.cxx               |   12 ++++--------
 cui/source/dialogs/insdlg.cxx                   |    2 +-
 cui/source/options/optaboutconfig.cxx           |    3 +--
 cui/source/options/optasian.cxx                 |    2 +-
 cui/source/options/optgdlg.cxx                  |    4 ++--
 cui/source/options/optupdt.cxx                  |    4 ++--
 cui/source/tabpages/measure.cxx                 |    8 ++++----
 cui/source/tabpages/numfmt.cxx                  |    6 +++---
 cui/source/tabpages/page.cxx                    |    3 +--
 cui/source/tabpages/textattr.cxx                |    8 ++++----
 cui/source/tabpages/tpgradnt.cxx                |    3 +--
 cui/source/tabpages/tpline.cxx                  |    3 +--
 15 files changed, 28 insertions(+), 36 deletions(-)

New commits:
commit ab6dbb228a703fb289733d285e93415521bc5202
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Fri Oct 2 09:35:37 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Oct 2 10:27:52 2020 +0200

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

diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx
index d9e3f57b1352..1337c3dd48dd 100644
--- a/cui/source/customize/CommandCategoryListBox.cxx
+++ b/cui/source/customize/CommandCategoryListBox.cxx
@@ -357,11 +357,11 @@ void CommandCategoryListBox::categorySelected(CuiConfigFunctionListBox* pFunctio
                 const css::uno::Sequence<css::uno::Reference<css::script::browse::XBrowseNode>> aChildNodes = rootNode->getChildNodes();
                 for ( auto const & childGroup : aChildNodes )
                 {
-                    OUString sUIName;
                     childGroup->acquire();
 
                     if ( childGroup->hasChildNodes() )
                     {
+                        OUString sUIName;
                         if ( childGroup->getName() == "user" )
                         {
                             sUIName = CuiResId( RID_SVXSTR_MYMACROS );
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 29f34e3f17a0..5418c4a9de7e 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -3090,7 +3090,6 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
     aMediaProps[0].Name = "URL";
 
     uno::Reference< graphic::XGraphic > xGraphic;
-    css::awt::Size aSize;
     aMediaProps[0].Value <<= aURL;
     try
     {
@@ -3103,6 +3102,7 @@ bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
         if ( xGraphic.is() )
         {
             bool bOK = true;
+            css::awt::Size aSize;
 
             a >>= aSize;
             if ( 0 == aSize.Width || 0 == aSize.Height )
diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx
index 558f54b3da0e..99729ee2f10d 100644
--- a/cui/source/dialogs/about.cxx
+++ b/cui/source/dialogs/about.cxx
@@ -71,8 +71,8 @@ AboutDialog::AboutDialog(weld::Window *pParent)
   m_pVersionLabel->set_label(GetVersionString());
 
   OUString sbuildId = GetBuildString();
-  const long nMaxChar = 25;
   if (IsStringValidGitHash(sbuildId)) {
+    const long nMaxChar = 25;
     m_pBuildLabel->set_uri("https://gerrit.libreoffice.org/gitweb?p=core.git;a=log;h="
                            + sbuildId);
     m_pBuildLabel->set_label(sbuildId.getLength() > nMaxChar ? sbuildId.replaceAt(
diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx
index 5042a2079210..28260d70cf4c 100644
--- a/cui/source/dialogs/cuicharmap.cxx
+++ b/cui/source/dialogs/cuicharmap.cxx
@@ -950,8 +950,6 @@ IMPL_LINK_NOARG(SvxCharacterMap, FavClickHdl, SvxShowCharSet*, void)
 IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void)
 {
     OUString aText;
-    OUString aHexText;
-    OUString aDecimalText;
     sal_UCS4 cChar = m_xShowSet->GetSelectCharacter();
     bool bSelect = (cChar > 0);
 
@@ -961,9 +959,9 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void)
         // using the new UCS4 constructor
         aText = OUString( &cChar, 1 );
         // Get the hexadecimal code
-        aHexText = OUString::number(cChar, 16).toAsciiUpperCase();
+        OUString aHexText = OUString::number(cChar, 16).toAsciiUpperCase();
         // Get the decimal code
-        aDecimalText = OUString::number(cChar);
+        OUString aDecimalText = OUString::number(cChar);
         setCharName(cChar);
 
         // Update the hex and decimal codes only if necessary
@@ -991,8 +989,6 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void)
 IMPL_LINK_NOARG(SvxCharacterMap, SearchCharHighlightHdl, SvxShowCharSet*, void)
 {
     OUString aText;
-    OUString aHexText;
-    OUString aDecimalText;
     sal_UCS4 cChar = m_xSearchSet->GetSelectCharacter();
     bool bSelect = (cChar > 0);
 
@@ -1001,9 +997,9 @@ IMPL_LINK_NOARG(SvxCharacterMap, SearchCharHighlightHdl, SvxShowCharSet*, void)
     {
         aText = OUString( &cChar, 1 );
         // Get the hexadecimal code
-        aHexText = OUString::number(cChar, 16).toAsciiUpperCase();
+        OUString aHexText = OUString::number(cChar, 16).toAsciiUpperCase();
         // Get the decimal code
-        aDecimalText = OUString::number(cChar);
+        OUString aDecimalText = OUString::number(cChar);
         setCharName(cChar);
 
         // Update the hex and decimal codes only if necessary
diff --git a/cui/source/dialogs/insdlg.cxx b/cui/source/dialogs/insdlg.cxx
index 273d3c065f73..dd89d0174774 100644
--- a/cui/source/dialogs/insdlg.cxx
+++ b/cui/source/dialogs/insdlg.cxx
@@ -160,12 +160,12 @@ short SvInsertOleDlg::run()
         m_xLbObjecttype->append_text((*m_pServers)[i].GetHumanName());
     m_xLbObjecttype->thaw();
     m_xLbObjecttype->select(0);
-    OUString aName;
 
     DBG_ASSERT( m_xStorage.is(), "No storage!");
     if ( m_xStorage.is() && ( nRet = InsertObjectDialog_Impl::run() ) == RET_OK )
     {
         OUString aFileName;
+        OUString aName;
         bool bCreateNew = IsCreateNew();
         if ( bCreateNew )
         {
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index f813c9a7c609..c6348f2023ef 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -586,7 +586,6 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void )
 
     bool bOpenDialog = true;
     OUString sDialogValue;
-    OUString sNewValue;
 
     if( sPropertyType == "boolean" )
     {
@@ -633,7 +632,7 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, weld::Button&, void )
 
             if (aValueDialog.run() == RET_OK )
             {
-                sNewValue = aValueDialog.getValue();
+                OUString sNewValue = aValueDialog.getValue();
                 bSaveChanges = true;
                 if ( sPropertyType == "short")
                 {
diff --git a/cui/source/options/optasian.cxx b/cui/source/options/optasian.cxx
index 6907eca46716..3e09e3779b81 100644
--- a/cui/source/options/optasian.cxx
+++ b/cui/source/options/optasian.cxx
@@ -205,11 +205,11 @@ void SvxAsianLayoutPage::Reset( const SfxItemSet* )
     }
     if( pImpl->xPrSet.is() )
         pImpl->xPrSetInfo = pImpl->xPrSet->getPropertySetInfo();
-    OUString sForbidden("ForbiddenCharacters");
     bool bKernWesternText = pImpl->aConfig.IsKerningWesternTextOnly();
     CharCompressType nCompress = pImpl->aConfig.GetCharDistanceCompression();
     if(pImpl->xPrSetInfo.is())
     {
+        OUString sForbidden("ForbiddenCharacters");
         if(pImpl->xPrSetInfo->hasPropertyByName(sForbidden))
         {
             Any aForbidden = pImpl->xPrSet->getPropertyValue(sForbidden);
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 743a64ad4b7f..812579c35b4a 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -1629,12 +1629,12 @@ void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet )
     LocaleSettingHdl(*m_xLocaleSettingLB->get_widget());
 
     // configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
-    OUString aAbbrev;
-    LanguageType eLang;
     const NfCurrencyEntry* pCurr = nullptr;
     OUString sCurrency = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
     if ( !sCurrency.isEmpty() )
     {
+        LanguageType eLang;
+        OUString aAbbrev;
         SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sCurrency );
         pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
     }
diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx
index 203e98949e5a..897f92505603 100644
--- a/cui/source/options/optupdt.cxx
+++ b/cui/source/options/optupdt.cxx
@@ -91,8 +91,6 @@ SvxOnlineUpdateTabPage::~SvxOnlineUpdateTabPage()
 
 void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
 {
-    OUString aDateStr;
-    OUString aTimeStr;
     OUString aText;
     sal_Int64 lastChecked = 0;
 
@@ -125,9 +123,11 @@ void SvxOnlineUpdateTabPage::UpdateLastCheckedText()
         const Date& rNullDate = pNumberFormatter->GetNullDate();
         sal_uInt32  nFormat = pNumberFormatter->GetStandardFormat( SvNumFormatType::DATE, eUILang );
 
+        OUString aDateStr;
         pNumberFormatter->GetOutputString( aDate - rNullDate, nFormat, aDateStr, &pColor );
 
         nFormat = pNumberFormatter->GetStandardFormat( SvNumFormatType::TIME, eUILang );
+        OUString aTimeStr;
         pNumberFormatter->GetOutputString( aTime.GetTimeInDays(), nFormat, aTimeStr, &pColor );
 
         pNumberFormatter.reset();
diff --git a/cui/source/tabpages/measure.cxx b/cui/source/tabpages/measure.cxx
index e7a7fbe12fdf..60e473d68494 100644
--- a/cui/source/tabpages/measure.cxx
+++ b/cui/source/tabpages/measure.cxx
@@ -432,8 +432,8 @@ bool SvxMeasurePage::FillItemSet( SfxItemSet* rAttrs)
     if( bPositionModified )
     {
         // Position
-        css::drawing::MeasureTextVertPos eVPos, eOldVPos;
-        css::drawing::MeasureTextHorzPos eHPos, eOldHPos;
+        css::drawing::MeasureTextVertPos eVPos;
+        css::drawing::MeasureTextHorzPos eHPos;
 
         RectPoint eRP = m_aCtlPosition.GetActualRP();
         switch( eRP )
@@ -466,7 +466,7 @@ bool SvxMeasurePage::FillItemSet( SfxItemSet* rAttrs)
 
         if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTVPOS ) != SfxItemState::DONTCARE )
         {
-            eOldVPos = rOutAttrs.Get(SDRATTR_MEASURETEXTVPOS).GetValue();
+            css::drawing::MeasureTextVertPos eOldVPos = rOutAttrs.Get(SDRATTR_MEASURETEXTVPOS).GetValue();
             if( eOldVPos != eVPos )
             {
                 rAttrs->Put( SdrMeasureTextVPosItem( eVPos ) );
@@ -481,7 +481,7 @@ bool SvxMeasurePage::FillItemSet( SfxItemSet* rAttrs)
 
         if ( rAttrs->GetItemState( SDRATTR_MEASURETEXTHPOS ) != SfxItemState::DONTCARE )
         {
-            eOldHPos = rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ).GetValue();
+            css::drawing::MeasureTextHorzPos eOldHPos = rOutAttrs.Get( SDRATTR_MEASURETEXTHPOS ).GetValue();
             if( eOldHPos != eHPos )
             {
                 rAttrs->Put( SdrMeasureTextHPosItem( eHPos ) );
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index c4a15bd6b70b..18df998b492c 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -1286,9 +1286,9 @@ IMPL_LINK( SvxNumberFormatTabPage, ClickHdl_Impl, weld::Button&, rIB, void)
 bool SvxNumberFormatTabPage::Click_Impl(weld::Button& rIB)
 {
     sal_uLong       nReturn = 0;
-    const sal_uLong nReturnChanged  = 0x1;  // THE boolean return value
-    const sal_uLong nReturnAdded    = 0x2;  // temp: format added
-    const sal_uLong nReturnOneArea  = 0x4;  // temp: one area but category changed => ignored
+    constexpr sal_uLong nReturnChanged  = 0x1;  // THE boolean return value
+    constexpr sal_uLong nReturnAdded    = 0x2;  // temp: format added
+    constexpr sal_uLong nReturnOneArea  = 0x4;  // temp: one area but category changed => ignored
 
     if (&rIB == m_xIbAdd.get())
     {   // Also called from FillItemSet() if a temporary currency format has
diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx
index c2de6652ec87..c0606c2f65be 100644
--- a/cui/source/tabpages/page.cxx
+++ b/cui/source/tabpages/page.cxx
@@ -1089,7 +1089,6 @@ void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet)
     }
 
     drawinglayer::attribute::SdrAllFillAttributesHelperPtr aPageFillAttributes;
-    const SfxPoolItem* pItem = nullptr;
 
     if(mbEnableDrawingLayerFillStyles)
     {
@@ -1098,7 +1097,7 @@ void SvxPageDescPage::ResetBackground_Impl(const SfxItemSet& rSet)
     }
     else
     {
-        pItem = GetItem(rSet, SID_ATTR_BRUSH);
+        const SfxPoolItem* pItem = GetItem(rSet, SID_ATTR_BRUSH);
 
         if(pItem)
         {
diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx
index c9eaf461c94d..43fea9f6c830 100644
--- a/cui/source/tabpages/textattr.cxx
+++ b/cui/source/tabpages/textattr.cxx
@@ -368,8 +368,8 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
 
     // centered
     RectPoint eRP = m_aCtlPosition.GetActualRP();
-    SdrTextVertAdjust eTVA, eOldTVA;
-    SdrTextHorzAdjust eTHA, eOldTHA;
+    SdrTextVertAdjust eTVA;
+    SdrTextHorzAdjust eTHA;
 
     switch( eRP )
     {
@@ -409,7 +409,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
 
         if ( rOutAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ) != SfxItemState::DONTCARE )
         {
-            eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue();
+            SdrTextVertAdjust eOldTVA = rOutAttrs.Get( SDRATTR_TEXT_VERTADJUST ).GetValue();
             if( eOldTVA != eTVA )
                 rAttrs->Put( SdrTextVertAdjustItem( eTVA ) );
         }
@@ -418,7 +418,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs)
 
         if ( rOutAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ) != SfxItemState::DONTCARE )
         {
-            eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue();
+            SdrTextHorzAdjust eOldTHA = rOutAttrs.Get( SDRATTR_TEXT_HORZADJUST ).GetValue();
             if( eOldTHA != eTHA )
                 rAttrs->Put( SdrTextHorzAdjustItem( eTHA ) );
         }
diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx
index 628c042ee709..dc54b084d085 100644
--- a/cui/source/tabpages/tpgradnt.cxx
+++ b/cui/source/tabpages/tpgradnt.cxx
@@ -180,12 +180,11 @@ DeactivateRC SvxGradientTabPage::DeactivatePage( SfxItemSet* _pSet )
 bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet )
 {
     std::unique_ptr<XGradient> pXGradient;
-    OUString      aString;
     size_t nPos = m_xGradientLB->IsNoSelection() ? VALUESET_ITEM_NOTFOUND : m_xGradientLB->GetSelectItemPos();
     if( nPos != VALUESET_ITEM_NOTFOUND )
     {
         pXGradient.reset(new XGradient( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetGradient() ));
-        aString = m_xGradientLB->GetItemText( m_xGradientLB->GetSelectedItemId() );
+        OUString aString = m_xGradientLB->GetItemText( m_xGradientLB->GetSelectedItemId() );
         rSet->Put( XFillGradientItem( aString, *pXGradient ) );
     }
     else
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index cec452121a47..00b32a5de5db 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -827,14 +827,13 @@ void SvxLineTabPage::Reset( const SfxItemSet* rAttrs )
         std::unique_ptr<SdrView> pView(new SdrView( *pModel, pVDev ));
         pView->hideMarkHandles();
         pView->ShowSdrPage(pPage);
-        SdrObject *pObj=nullptr;
         size_t nSymTmp = static_cast<size_t>(nSymType);
         if(m_pSymbolList)
         {
             if(m_pSymbolList->GetObjCount())
             {
                 nSymTmp %= m_pSymbolList->GetObjCount(); // Treat list as cyclic!
-                pObj=m_pSymbolList->GetObj(nSymTmp);
+                SdrObject *pObj=m_pSymbolList->GetObj(nSymTmp);
                 if(pObj)
                 {
                     // directly clone to target SdrModel


More information about the Libreoffice-commits mailing list