diff options
author | Noel <noelgrandin@gmail.com> | 2020-09-30 09:38:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-09-30 12:32:18 +0200 |
commit | 9373320fc88c1582a2ad25bda9c5264c7c58a97e (patch) | |
tree | ee2df8944d7af2080498b991ed46429e0a020947 /sw/source/uibase | |
parent | 37b81dd54a915223780a6b5efa54ce45db332604 (diff) |
loplugin:reducevarscope in sw
Change-Id: Ifed7220c6acf7049b2985f1911a806b37a54d794
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103646
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/app/docsh2.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/docvw/srcedtw.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/fldui/fldmgr.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/shells/drawdlg.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 9 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageColumnControl.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageMarginControl.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/PageSizeControl.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uiview/pview.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 2 |
12 files changed, 18 insertions, 24 deletions
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index fa2b9ac9d63e..13c15a461832 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -520,7 +520,6 @@ void SwDocShell::Execute(SfxRequest& rReq) static bool bPage = false; static bool bNum = false; static bool bMerge = false; - sal_uInt16 nRet = USHRT_MAX; SfxTemplateFlags nFlags = bFrame ? SfxTemplateFlags::LOAD_FRAME_STYLES : SfxTemplateFlags::NONE; if(bPage) @@ -550,7 +549,7 @@ void SwDocShell::Execute(SfxRequest& rReq) SfxNewFileDialog aNewFileDlg(GetView()->GetFrameWeld(), SfxNewFileDialogMode::LoadTemplate); aNewFileDlg.SetTemplateFlags(nFlags); - nRet = aNewFileDlg.run(); + sal_uInt16 nRet = aNewFileDlg.run(); if(RET_TEMPLATE_LOAD == nRet) { FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE, diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index cf1150f72a55..e4f398a42ac4 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -1169,11 +1169,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, std::unique_ptr< utl::TempFile > aTempFile; sal_uInt16 nStartingPageNo = 0; - vcl::Window *pSourceWindow = nullptr; std::shared_ptr<weld::GenericDialogController> xProgressDlg; try { + vcl::Window *pSourceWindow = nullptr; if( !bIsMergeSilent ) { // construct the process dialog @@ -1317,12 +1317,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, } } - OUString sPasswordColumnData; uno::Sequence< beans::PropertyValue > aSaveToFilterDataOptions( rMergeDescriptor.aSaveToFilterData ); if( bMT_EMAIL || bPasswordColumnName ) { - sPasswordColumnData = GetDBField( xPasswordColumnProp, aColumnDBFormat ); + OUString sPasswordColumnData = GetDBField( xPasswordColumnProp, aColumnDBFormat ); lcl_PrepareSaveFilterDataOptions( rMergeDescriptor.aSaveToFilterData, aSaveToFilterDataOptions, sPasswordColumnData ); } diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 745731327a09..c530bca6d61f 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -1391,7 +1391,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt { SwPasteContext aPasteContext(rSh); - sal_uInt8 nEventAction, nAction=0; + sal_uInt8 nAction=0; SotExchangeDest nDestination = SwTransferable::GetSotDestination( rSh ); SotClipboardFormatId nFormat = SotClipboardFormatId::NONE; SotExchangeActionFlags nActionFlags = SotExchangeActionFlags::NONE; @@ -1411,6 +1411,7 @@ bool SwTransferable::Paste(SwWrtShell& rSh, TransferableDataHelper& rData, RndSt ? EXCHG_IN_ACTION_COPY : EXCHG_IN_ACTION_MOVE); uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() ); + sal_uInt8 nEventAction; nAction = SotExchange::GetExchangeAction( rData.GetDataFlavorExVector(), nDestination, @@ -3308,9 +3309,10 @@ bool SwTransferable::PasteFormat( SwWrtShell& rSh, bool SwTransferable::TestAllowedFormat( const TransferableDataHelper& rData, SotClipboardFormatId nFormat, SotExchangeDest nDestination ) { - sal_uInt8 nAction = EXCHG_INOUT_ACTION_NONE, nEventAction; + sal_uInt8 nAction = EXCHG_INOUT_ACTION_NONE; if( rData.HasFormat( nFormat )) { uno::Reference<XTransferable> xTransferable( rData.GetXTransferable() ); + sal_uInt8 nEventAction; nAction = SotExchange::GetExchangeAction( rData.GetDataFlavorExVector(), nDestination, EXCHG_IN_ACTION_COPY, diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx index 59d4e2555d97..d103de0b74f4 100644 --- a/sw/source/uibase/docvw/srcedtw.cxx +++ b/sw/source/uibase/docvw/srcedtw.cxx @@ -87,9 +87,9 @@ static void lcl_Highlight(const OUString& rSource, TextPortions& aPortionList) TextPortion aText; while(nActPos < nStrLen) { - svtools::ColorConfigEntry eFoundType = svtools::HTMLUNKNOWN; if((nActPos < nStrLen - 2) && (rSource[nActPos] == cOpenBracket)) { + svtools::ColorConfigEntry eFoundType = svtools::HTMLUNKNOWN; // insert 'empty' portion if(nPortEnd < nActPos - 1 ) { diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx index 96fe6e375627..a761111bacb5 100644 --- a/sw/source/uibase/fldui/fldmgr.cxx +++ b/sw/source/uibase/fldui/fldmgr.cxx @@ -1217,13 +1217,12 @@ bool SwFieldMgr::InsertField( // extract DBName from rData.m_sPar1. Format: DBName.TableName.CommandType.ExpStrg sal_Int32 nTablePos = rData.m_sPar1.indexOf(DB_DELIM); - sal_Int32 nCmdTypePos = -1; sal_Int32 nExpPos = -1; if (nTablePos>=0) { aDBData.sDataSource = rData.m_sPar1.copy(0, nTablePos++); - nCmdTypePos = rData.m_sPar1.indexOf(DB_DELIM, nTablePos); + sal_Int32 nCmdTypePos = rData.m_sPar1.indexOf(DB_DELIM, nTablePos); if (nCmdTypePos>=0) { aDBData.sCommand = rData.m_sPar1.copy(nTablePos, nCmdTypePos++ - nTablePos); diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx index 36d231bc4dde..80fb24123c8f 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -212,12 +212,11 @@ namespace void lcl_convertStringArguments(sal_uInt16 nSlot, std::unique_ptr<SfxItemSet>& pArgs) { Color aColor; - OUString sColor; const SfxPoolItem* pItem = nullptr; if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pItem)) { - sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); + OUString sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); if (sColor == "transparent") aColor = COL_TRANSPARENT; diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 2a4ff0a32f2e..09a0017e3ec3 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1182,7 +1182,6 @@ void SwTextShell::Execute(SfxRequest &rReq) case SID_ATTR_CHAR_COLOR2: { Color aSet; - OUString sColor; const SfxPoolItem* pColorStringItem = nullptr; bool bHasItem = false; @@ -1193,7 +1192,7 @@ void SwTextShell::Execute(SfxRequest &rReq) } else if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem)) { - sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); + OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); aSet = Color(sColor.toInt32(16)); bHasItem = true; } @@ -1220,12 +1219,11 @@ void SwTextShell::Execute(SfxRequest &rReq) case SID_ATTR_CHAR_COLOR_EXT: { Color aSet; - OUString sColor; const SfxPoolItem* pColorStringItem = nullptr; if (pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem)) { - sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); + OUString sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); if (sColor == "transparent") aSet = COL_TRANSPARENT; else @@ -2053,10 +2051,9 @@ void SwTextShell::GetState( SfxItemSet &rSet ) case FN_OUTLINE_RULE_INDEX: { SwNumRule* pCurRule = const_cast<SwNumRule*>(GetShell().GetNumRuleAtCurrCursorPos()); - sal_uInt16 nActNumLvl = USHRT_MAX; if( pCurRule ) { - nActNumLvl = GetShell().GetNumLevel(); + sal_uInt16 nActNumLvl = GetShell().GetNumLevel(); if( nActNumLvl < MAXLEVEL ) { nActNumLvl = 1<<nActNumLvl; diff --git a/sw/source/uibase/sidebar/PageColumnControl.cxx b/sw/source/uibase/sidebar/PageColumnControl.cxx index 1675867acd8d..8b979af19668 100644 --- a/sw/source/uibase/sidebar/PageColumnControl.cxx +++ b/sw/source/uibase/sidebar/PageColumnControl.cxx @@ -37,9 +37,9 @@ PageColumnControl::PageColumnControl(PageColumnPopup* pControl, weld::Widget* pP , m_xControl(pControl) { bool bLandscape = false; - const SfxPoolItem *pItem; if ( SfxViewFrame::Current() ) { + const SfxPoolItem *pItem; SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); } diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx index 065588eda318..2ef8b200aae4 100644 --- a/sw/source/uibase/sidebar/PageMarginControl.cxx +++ b/sw/source/uibase/sidebar/PageMarginControl.cxx @@ -127,12 +127,12 @@ PageMarginControl::PageMarginControl(PageMarginPopup* pControl, weld::Widget* pP SetFieldUnit( *m_xWidthHeightField, lcl_GetFieldUnit() ); bool bLandscape = false; - const SfxPoolItem* pItem; const SvxSizeItem* pSize = nullptr; const SvxLongLRSpaceItem* pLRItem = nullptr; const SvxLongULSpaceItem* pULItem = nullptr; if ( SfxViewFrame::Current() ) { + const SfxPoolItem* pItem; SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); bLandscape = static_cast<const SvxPageItem*>( pItem )->IsLandscape(); m_bMirrored = static_cast<const SvxPageItem*>( pItem )->GetPageUsage() == SvxPageUsage::Mirror; diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx index 00bcfc0a6a3d..7fa49f4f75c3 100644 --- a/sw/source/uibase/sidebar/PageSizeControl.cxx +++ b/sw/source/uibase/sidebar/PageSizeControl.cxx @@ -120,10 +120,10 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, weld::Widget* pParent) } bool bLandscape = false; - const SfxPoolItem* pItem; const SvxSizeItem* pSize = nullptr; if ( SfxViewFrame::Current() ) { + const SfxPoolItem* pItem; SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem ); bLandscape = static_cast<const SvxPageItem*>(pItem)->IsLandscape(); SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pItem ); diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index cb8c44e143c1..362b08bfc54d 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -839,11 +839,10 @@ void SwPagePreview::Execute( SfxRequest &rReq ) } case SID_JUMP_TO_SPECIFIC_PAGE: { - sal_uInt16 nPageNum = 1; const SfxItemSet *pArgs = rReq.GetArgs(); if( pArgs && pArgs->Count()) { - nPageNum = static_cast<const SfxUInt16Item &>(pArgs->Get(SID_JUMP_TO_SPECIFIC_PAGE)).GetValue(); + sal_uInt16 nPageNum = static_cast<const SfxUInt16Item &>(pArgs->Get(SID_JUMP_TO_SPECIFIC_PAGE)).GetValue(); if( nPageNum > 0 && nPageNum <= mnPageCount ) { diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 422133559c45..88f9f0979919 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -2369,9 +2369,9 @@ void SwContentTree::ToggleToRoot() { std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator()); bool bEntry = m_xTreeView->get_cursor(xEntry.get()); - const SwContentType* pCntType; if (bEntry) { + const SwContentType* pCntType; if (lcl_IsContentType(*xEntry, *m_xTreeView)) { assert(dynamic_cast<SwContentType*>(reinterpret_cast<SwTypeNumber*>(m_xTreeView->get_id(*xEntry).toInt64()))); |