sfx2/source/appl/appdispatchprovider.cxx | 3 +-- sfx2/source/appl/sfxhelp.cxx | 2 +- sfx2/source/bastyp/fltfnc.cxx | 2 +- sfx2/source/control/unoctitm.cxx | 2 +- sfx2/source/dialog/filedlghelper.cxx | 13 +++---------- sfx2/source/dialog/filedlgimpl.hxx | 3 +-- sfx2/source/doc/DocumentMetadataAccess.cxx | 4 ++-- sfx2/source/doc/docfile.cxx | 2 +- sfx2/source/doc/guisaveas.cxx | 3 +-- sfx2/source/doc/objcont.cxx | 5 ++--- sfx2/source/doc/objxtor.cxx | 3 --- sfx2/source/doc/sfxbasemodel.cxx | 5 ++--- sfx2/source/notebookbar/SfxNotebookBar.cxx | 2 +- sfx2/source/view/lokhelper.cxx | 4 +--- sfx2/source/view/sfxbasecontroller.cxx | 2 +- sfx2/source/view/viewsh.cxx | 5 ++--- 16 files changed, 21 insertions(+), 39 deletions(-)
New commits: commit 46da549a68003ef5a35aedf4621482cb2b54e930 Author: Noel <noelgran...@gmail.com> AuthorDate: Wed Sep 30 12:08:47 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 30 14:56:06 2020 +0200 loplugin:reducevarscope in sfx2 Change-Id: I63ee19bfe7ad01ff4ad8c941bffadd9406101c6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103678 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sfx2/source/appl/appdispatchprovider.cxx b/sfx2/source/appl/appdispatchprovider.cxx index 2cec473fc748..a62872a9a420 100644 --- a/sfx2/source/appl/appdispatchprovider.cxx +++ b/sfx2/source/appl/appdispatchprovider.cxx @@ -108,7 +108,6 @@ Reference < XDispatch > SAL_CALL SfxAppDispatchProvider::queryDispatch( { SolarMutexGuard guard; - sal_uInt16 nId( 0 ); bool bMasterCommand( false ); Reference < XDispatch > xDisp; const SfxSlot* pSlot = nullptr; @@ -118,7 +117,7 @@ Reference < XDispatch > SAL_CALL SfxAppDispatchProvider::queryDispatch( SfxDispatcher* pAppDisp = pApp->GetAppDispatcher_Impl(); if ( aURL.Protocol == "slot:" || aURL.Protocol == "commandId:" ) { - nId = static_cast<sal_uInt16>(aURL.Path.toInt32()); + sal_uInt16 nId = static_cast<sal_uInt16>(aURL.Path.toInt32()); SfxShell* pShell; pAppDisp->GetShellAndSlot_Impl( nId, &pShell, &pSlot, true, true ); } diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index da46da4274d5..9cd627dd1f0c 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -287,13 +287,13 @@ void AppendConfigToken( OUStringBuffer& rURL, bool bQuestionMark ) static bool GetHelpAnchor_Impl( const OUString& _rURL, OUString& _rAnchor ) { bool bRet = false; - OUString sAnchor; try { ::ucbhelper::Content aCnt( INetURLObject( _rURL ).GetMainURL( INetURLObject::DecodeMechanism::NONE ), Reference< css::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() ); + OUString sAnchor; if ( aCnt.getPropertyValue("AnchorName") >>= sAnchor ) { diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index 56d3ebf1296f..f1d3ac399f27 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -371,7 +371,6 @@ ErrCode SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, std: if (!xDetection.is()) return ERRCODE_ABORT; - OUString sTypeName; try { // open the stream one times only ... @@ -380,6 +379,7 @@ ErrCode SfxFilterMatcher::GuessFilterControlDefaultUI( SfxMedium& rMedium, std: OUString sURL( rMedium.GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); uno::Reference< io::XInputStream > xInStream = rMedium.GetInputStream(); OUString aFilterName; + OUString sTypeName; // stream exists => deep detection (with preselection ... if possible) if (xInStream.is()) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index be3b79d1d421..d51e5f3b443f 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1273,11 +1273,11 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra } else if (aEvent.FeatureURL.Path == "LanguageStatus") { - OUString sValue; css::uno::Sequence< OUString > aSeq; if (aEvent.IsEnabled) { + OUString sValue; if (aEvent.State >>= sValue) { aBuffer.append(sValue); diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index afcdfa0d5dd6..bfc4c893b739 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1322,17 +1322,10 @@ static void lcl_saveLastURLs(std::vector<OUString>& rpURLList, lLastURLs.push_back(url); } -void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterface >& xPicker, std::vector<OUString>& rpURLList, const std::shared_ptr<const SfxFilter>& pFilter) +void FileDialogHelper_Impl::implGetAndCacheFiles(const uno::Reference< XInterface >& xPicker, std::vector<OUString>& rpURLList) { rpURLList.clear(); - OUString sExtension; - if (pFilter) - { - sExtension = pFilter->GetDefaultExtension (); - sExtension = sExtension.replaceAll("*", "").replaceAll(".", ""); - } - // a) the new way (optional!) uno::Reference< XFilePicker3 > xPickNew(xPicker, UNO_QUERY); if (xPickNew.is()) @@ -1493,7 +1486,7 @@ ErrCode FileDialogHelper_Impl::execute( std::vector<OUString>& rpURLList, std::shared_ptr<const SfxFilter> pCurrentFilter = getCurentSfxFilter(); // fill the rpURLList - implGetAndCacheFiles( mxFileDlg, rpURLList, pCurrentFilter ); + implGetAndCacheFiles( mxFileDlg, rpURLList ); if ( rpURLList.empty() ) return ERRCODE_ABORT; @@ -1968,13 +1961,13 @@ void FileDialogHelper_Impl::saveConfig() if ( mbHasPreview ) { SvtViewOptions aDlgOpt( EViewType::Dialog, IMPGRF_CONFIGNAME ); - OUString aUserData(GRF_CONFIG_STR); try { aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0 ); bool bValue = false; aValue >>= bValue; + OUString aUserData(GRF_CONFIG_STR); SetToken( aUserData, 1, ' ', OUString::number( static_cast<sal_Int32>(bValue) ) ); INetURLObject aObj( getPath() ); diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx index 4fb74cd14943..c755bcc9f26f 100644 --- a/sfx2/source/dialog/filedlgimpl.hxx +++ b/sfx2/source/dialog/filedlgimpl.hxx @@ -137,8 +137,7 @@ namespace sfx2 void verifyPath( ); void implGetAndCacheFiles( const css::uno::Reference< XInterface >& xPicker , - std::vector<OUString>& rpURLList, - const std::shared_ptr<const SfxFilter>& pFilter ); + std::vector<OUString>& rpURLList ); DECL_LINK( TimeOutHdl_Impl, Timer *, void); DECL_LINK( InitControls, void*, void ); diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index 12ccdcce6882..730c64e28cb0 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -580,9 +580,9 @@ readStream(struct DocumentMetadataAccess_Impl & i_rImpl, OUString const & i_rPath, OUString const & i_rBaseURI) { - OUString dir; - OUString rest; try { + OUString dir; + OUString rest; if (!splitPath(i_rPath, dir, rest)) throw uno::RuntimeException(); if (dir.isEmpty()) { if (!i_xStorage->isStreamElement(i_rPath)) { diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 588568af05d0..488f7ccbbbfc 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -1878,7 +1878,6 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, const INetURLObject& aDest, const Reference< css::ucb::XCommandEnvironment >& xComEnv ) { - bool bResult = false; Reference< css::ucb::XCommandEnvironment > xDummyEnv; ::ucbhelper::Content aOriginalContent; @@ -1924,6 +1923,7 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, bool bTransactStarted = false; const SfxBoolItem* pOverWrite = SfxItemSet::GetItem<SfxBoolItem>(GetItemSet(), SID_OVERWRITE, false); bool bOverWrite = !pOverWrite || pOverWrite->GetValue(); + bool bResult = false; try { diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index 84909c1bab13..33e04bdd39d4 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -213,10 +213,9 @@ public: xDocSettingsSupplier->createInstance( "com.sun.star.document.Settings" ), uno::UNO_QUERY_THROW ); - OUString aLoadReadonlyString( "LoadReadonly" ); - try { + OUString aLoadReadonlyString( "LoadReadonly" ); m_xDocumentSettings->getPropertyValue( aLoadReadonlyString ) >>= m_bPreserveReadOnly; m_xDocumentSettings->setPropertyValue( aLoadReadonlyString, uno::makeAny( bReadOnly ) ); m_bReadOnlySupported = true; diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 3055a52cc3d0..0a98bab1263d 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -213,7 +213,6 @@ void SfxObjectShell::UpdateTime_Impl( // Initialize some local member! It's necessary for follow operations! DateTime aNow( DateTime::SYSTEM ); // Date and time at current moment tools::Time n24Time (24,0,0,0) ; // Time-value for 24 hours - see follow calculation - sal_Int32 nDays = 0 ; // Count of days between now and last editing tools::Time nAddTime (0) ; // Value to add on aOldTime // Save impossible cases! @@ -224,8 +223,8 @@ void SfxObjectShell::UpdateTime_Impl( // Else add a time of 0 to aOldTime... !!! if (aNow.GetDate()>=pImpl->nTime.GetDate()) { - // Get count of days last editing. - nDays = aNow.GetSecFromDateTime(Date(pImpl->nTime.GetDate()))/86400 ; + // Count of days between now and last editing + sal_Int32 nDays = aNow.GetSecFromDateTime(Date(pImpl->nTime.GetDate()))/86400 ; if (nDays==0) { diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 35c43e821248..d97731486ccf 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -916,12 +916,9 @@ OUString SfxObjectShell::GetServiceNameFromFactory( const OUString& rFact ) if ( aFact.startsWith( aPrefix ) ) aFact = aFact.copy( aPrefix.getLength() ); sal_Int32 nPos = aFact.indexOf( '?' ); - OUString aParam; if ( nPos != -1 ) { - aParam = aFact.copy( nPos ); aFact = aFact.copy( 0, nPos ); - aParam = aParam.copy(1); } aFact = aFact.replaceAll("4", ""); aFact = aFact.toAsciiLowerCase(); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index e0b657a928d8..d1390a74bc6a 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3505,11 +3505,10 @@ static void ConvertSlotsToCommands( SfxObjectShell const * pDoc, Reference< cont for ( sal_Int32 i = 0; i < rToolbarDefinition->getCount(); i++ ) { - sal_Int32 nIndex( -1 ); - OUString aCommand; - if ( rToolbarDefinition->getByIndex( i ) >>= aSeqPropValue ) { + OUString aCommand; + sal_Int32 nIndex( -1 ); GetCommandFromSequence( aCommand, nIndex, aSeqPropValue ); if ( nIndex >= 0 && aCommand.startsWith( "slot:" ) ) { diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index bacaf48e56f4..4c5ccbe8a063 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -63,9 +63,9 @@ static void NotebookbarAddonValues( bool isBigImage = true; for (const auto& rProp : rExtensionVal) { - OUString sImage; if (rProp.Name == MERGE_NOTEBOOKBAR_URL) { + OUString sImage; rProp.Value >>= sImage; aImage = Image(framework::AddonsOptions().GetImageFromURL(sImage, isBigImage)); } diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 67097c444990..fa5b7e0bcb2d 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -363,12 +363,10 @@ namespace { const SfxSlot* pSlot = SfxSlotPool::GetSlotPool(pShell->GetFrame()).GetSlot(nWhich); if (pSlot) { - OUStringBuffer sUnoCommand(".uno:"); const char* pName = pSlot->GetUnoName(); if (pName) { - sUnoCommand.append(OStringToOUString(pName, RTL_TEXTENCODING_ASCII_US)); - return sUnoCommand.makeStringAndClear(); + return ".uno:" + OStringToOUString(pName, RTL_TEXTENCODING_ASCII_US); } } } diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 8f4ba77305db..95f2a1cfd683 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -621,10 +621,10 @@ sal_Bool SAL_CALL SfxBaseController::suspend( sal_Bool bSuspend ) uno::Any SfxBaseController::getViewData() { uno::Any aAny; - OUString sData; SolarMutexGuard aGuard; if ( m_pData->m_pViewShell ) { + OUString sData; m_pData->m_pViewShell->WriteUserData( sData ) ; aAny <<= sData ; } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 00a10e62a3c6..9679487a718e 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -529,8 +529,6 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case SID_WEBHTML: { - const sal_Int32 FILTERFLAG_EXPORT = 0x00000002; - css::uno::Reference< lang::XMultiServiceFactory > xSMGR(::comphelper::getProcessServiceFactory(), css::uno::UNO_SET_THROW); css::uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext(), css::uno::UNO_SET_THROW); css::uno::Reference< css::frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() ); @@ -577,7 +575,8 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) css::uno::UNO_QUERY_THROW ); // Retrieve filter from type - sal_Int32 nFilterFlags = FILTERFLAG_EXPORT; + + sal_Int32 nFilterFlags = 0x00000002; // export aFilterName = impl_retrieveFilterNameFromTypeAndModule( xContainerQuery, aTypeName, aModule, nFilterFlags ); if ( aFilterName.isEmpty() ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits