[Libreoffice-commits] core.git: desktop/source editeng/source emfio/source
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 2 08:47:29 UTC 2020
desktop/source/app/app.cxx | 2 +-
desktop/source/app/dispatchwatcher.cxx | 2 +-
desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 2 +-
desktop/source/deployment/gui/dp_gui_service.cxx | 2 +-
desktop/source/deployment/registry/help/dp_help.cxx | 2 +-
desktop/source/lib/init.cxx | 7 +++----
desktop/source/migration/services/oo3extensionmigration.cxx | 3 +--
desktop/source/splash/splash.cxx | 6 ++----
editeng/source/editeng/editdoc.cxx | 3 +--
editeng/source/misc/svxacorr.cxx | 5 ++---
editeng/source/outliner/outliner.cxx | 4 ++--
editeng/source/uno/unoedprx.cxx | 2 +-
editeng/source/uno/unofored.cxx | 3 +--
editeng/source/uno/unotext.cxx | 2 +-
emfio/source/reader/emfreader.cxx | 10 ++++------
emfio/source/reader/wmfreader.cxx | 6 ++----
16 files changed, 25 insertions(+), 36 deletions(-)
New commits:
commit 268a49f473c1830be269a7db5f561e3681134bbd
Author: Noel <noelgrandin at gmail.com>
AuthorDate: Fri Oct 2 09:36:35 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Oct 2 10:46:46 2020 +0200
loplugin:reducevarscope in desktop..emfio
Change-Id: I25ca760ae15114ada621d928997a7117401c75d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103811
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index dd38a74aa89e..1276a2c598f2 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -632,7 +632,6 @@ OUString Desktop::CreateErrorMsgString(
const OUString& aFileURL )
{
OUString aMsg;
- OUString aFilePath;
bool bFileInfo = true;
switch ( nFailureCode )
@@ -708,6 +707,7 @@ OUString Desktop::CreateErrorMsgString(
if ( bFileInfo )
{
OUString aMsgString( aMsg );
+ OUString aFilePath;
osl::File::getSystemPathFromFileURL( aFileURL, aFilePath );
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 450fd0e1e207..ec566181ce52 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -216,10 +216,10 @@ void scriptCat(const Reference< XModel >& xDoc )
{
OUString &rObjectName = aObjectNames[j];
- OUString aCodeString;
try
{
Any aCode = xContainer->getByName( rObjectName );
+ OUString aCodeString;
if (! (aCode >>= aCodeString ) )
std::cout << "[" << rObjectName << "] - error fetching code\n";
diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
index 89aaed148346..ccf546d713b7 100644
--- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
@@ -894,7 +894,6 @@ void ExtensionBox_Impl::addEventListenerOnce(
void ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage,
bool bLicenseMissing )
{
- long nPos = 0;
PackageState eState = TheExtensionManager::getPackageState( xPackage );
bool bLocked = m_pManager->isReadOnly( xPackage );
@@ -906,6 +905,7 @@ void ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &
{
osl::MutexGuard guard(m_entriesMutex);
+ long nPos = 0;
if (m_vEntries.empty())
{
addEventListenerOnce(xPackage);
diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx
index 0d0315f0daaa..fb36589e01c5 100644
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -140,9 +140,9 @@ ServiceImpl::ServiceImpl( Sequence<Any> const& args,
m_bShowUpdateOnly( false )
{
/* if true then this service is running in a unopkg process and not in an office process */
- std::optional<sal_Bool> unopkg;
std::optional<OUString> view;
try {
+ std::optional<sal_Bool> unopkg;
comphelper::unwrapArgs( args, m_parent, view, unopkg );
return;
} catch ( const css::lang::IllegalArgumentException & ) {
diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx
index 594196155db8..49be2a23f87d 100644
--- a/desktop/source/deployment/registry/help/dp_help.cxx
+++ b/desktop/source/deployment/registry/help/dp_help.cxx
@@ -507,9 +507,9 @@ void BackendImpl::implProcessHelp(
sal_Unicode const nCR = 13, nLF = 10;
sal_Int32 nSearchCR = aErrMsg.indexOf( nCR );
sal_Int32 nSearchLF = aErrMsg.indexOf( nLF );
- sal_Int32 nCopy;
if( nSearchCR != -1 || nSearchLF != -1 )
{
+ sal_Int32 nCopy;
if( nSearchCR == -1 )
nCopy = nSearchLF;
else if( nSearchLF == -1 )
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e56a925ccb39..d8a7f0b4291f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -317,7 +317,6 @@ static uno::Any jsonToUnoAny(const boost::property_tree::ptree& aTree)
uno::Any aAny;
uno::Any aValue;
sal_Int32 nFields;
- uno::TypeClass aTypeClass;
uno::Reference< reflection::XIdlField > aField;
boost::property_tree::ptree aNodeNull, aNodeValue, aNodeField;
const std::string& rType = aTree.get<std::string>("type", "");
@@ -327,7 +326,7 @@ static uno::Any jsonToUnoAny(const boost::property_tree::ptree& aTree)
css::reflection::theCoreReflection::get(comphelper::getProcessComponentContext())->forName(OUString::fromUtf8(rType.c_str()));
if (xIdlClass.is())
{
- aTypeClass = xIdlClass->getTypeClass();
+ uno::TypeClass aTypeClass = xIdlClass->getTypeClass();
xIdlClass->createObject(aAny);
aFields = xIdlClass->getFields();
nFields = aFields.getLength();
@@ -787,8 +786,7 @@ void ExecuteOrientationChange()
std::unique_ptr<SvxLongULSpaceItem> pPageULMarginItem(new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ));
// 1mm in twips rounded
// This should be in sync with MINBODY in sw/source/uibase/sidebar/PageMarginControl.hxx
- const long MINBODY = 56;
- bool bIsLandscape = false;
+ constexpr long MINBODY = 56;
css::uno::Reference< css::document::XUndoManager > mxUndoManager(
getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) );
@@ -815,6 +813,7 @@ void ExecuteOrientationChange()
{
+ bool bIsLandscape = false;
if ( pPageSizeItem->GetSize().Width() > pPageSizeItem->GetSize().Height())
bIsLandscape = true;
diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx
index a9e045ca0a77..6b68272db60a 100644
--- a/desktop/source/migration/services/oo3extensionmigration.cxx
+++ b/desktop/source/migration/services/oo3extensionmigration.cxx
@@ -118,12 +118,11 @@ OO3ExtensionMigration::ScanResult OO3ExtensionMigration::scanExtensionFolder( co
{
if (item.getFileStatus(fs) == osl::FileBase::E_None)
{
- OUString aDirEntryURL;
if (fs.getFileType() == osl::FileStatus::Directory)
aDirectories.push_back( fs.getFileURL() );
else
{
- aDirEntryURL = fs.getFileURL();
+ OUString aDirEntryURL = fs.getFileURL();
if ( aDirEntryURL.indexOf( "/description.xml" ) > 0 )
aResult = scanDescriptionXml( aDirEntryURL ) ? SCANRESULT_MIGRATE_EXTENSION : SCANRESULT_DONTMIGRATE_EXTENSION;
}
diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx
index 34c77e9bd827..a71224b985af 100644
--- a/desktop/source/splash/splash.cxx
+++ b/desktop/source/splash/splash.cxx
@@ -495,8 +495,6 @@ void SplashScreen::determineProgressRatioValues(
double& rXRelPos, double& rYRelPos,
double& rRelWidth, double& rRelHeight )
{
- sal_Int32 nWidth( 0 );
- sal_Int32 nHeight( 0 );
sal_Int32 nScreenRatio( 0 );
// determine desktop resolution
@@ -505,8 +503,8 @@ void SplashScreen::determineProgressRatioValues(
{
// retrieve size from first screen
tools::Rectangle aScreenArea = Application::GetScreenPosSizePixel(static_cast<unsigned int>(0));
- nWidth = aScreenArea.GetWidth();
- nHeight = aScreenArea.GetHeight();
+ sal_Int32 nWidth = aScreenArea.GetWidth();
+ sal_Int32 nHeight = aScreenArea.GetHeight();
nScreenRatio = nHeight ? sal_Int32( rtl::math::round( double( nWidth ) / double( nHeight ), 2 ) * 100 ) : 0;
}
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 0d5213355c5c..75b9ef827cb3 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1682,10 +1682,9 @@ void ContentNode::UnExpandPosition( sal_Int32 &rPos, bool bBiasStart )
if (nOffset >= rPos) // happens after the position
return;
- sal_Int32 nChunk = 0;
if (rAttr.Which() == EE_FEATURE_FIELD)
{
- nChunk += static_cast<const EditCharAttribField&>(rAttr).GetFieldValue().getLength();
+ sal_Int32 nChunk = static_cast<const EditCharAttribField&>(rAttr).GetFieldValue().getLength();
nChunk--; // Character representing the field in the string
if (nOffset + nChunk >= rPos) // we're inside the field
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index b51d34e6173d..ea7372f1e15d 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -1323,13 +1323,12 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
(IsAutoCorrFlag( ACFlags::ChgSglQuotes ) && bSingle );
if( bIsReplaceQuote )
{
- sal_Unicode cPrev;
bool bSttQuote = !nInsPos;
ACQuotes eType = ACQuotes::NONE;
const LanguageType eLang = GetDocLanguage( rDoc, nInsPos );
if (!bSttQuote)
{
- cPrev = rTxt[ nInsPos-1 ];
+ sal_Unicode cPrev = rTxt[ nInsPos-1 ];
bSttQuote = NonFieldWordDelim(cPrev) ||
lcl_IsInAsciiArr( "([{", cPrev ) ||
( cEmDash == cPrev ) ||
@@ -2775,10 +2774,10 @@ void SvxAutoCorrectLanguageLists::PutText( const OUString& rShort,
MakeUserStorage_Impl();
- OUString sLong;
try
{
uno::Reference < embed::XStorage > xStg = comphelper::OStorageHelper::GetStorageFromURL( sUserAutoCorrFile, embed::ElementModes::READWRITE );
+ OUString sLong;
bool bRet = rAutoCorrect.PutText( xStg, sUserAutoCorrFile, rShort, rShell, sLong );
xStg = nullptr;
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index ca97d103c012..5684c64a44a7 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -496,8 +496,6 @@ bool Outliner::ImpConvertEdtToOut( sal_Int32 nPara )
ESelection aDelSel;
OUString aName;
- OUString aHeading_US( "heading" );
- OUString aNumber_US( "Numbering" );
OUString aStr( pEditEngine->GetText( nPara ) );
const sal_Unicode* pPtr = aStr.getStr();
@@ -507,6 +505,8 @@ bool Outliner::ImpConvertEdtToOut( sal_Int32 nPara )
SfxStyleSheet* pStyle= pEditEngine->GetStyleSheet( nPara );
if( pStyle )
{
+ OUString aHeading_US( "heading" );
+ OUString aNumber_US( "Numbering" );
aName = pStyle->GetName();
sal_Int32 nSearch;
if ( ( nSearch = aName.indexOf( aHeading_US ) ) != -1 )
diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx
index 628570fdca74..8cf7d8e62417 100644
--- a/editeng/source/uno/unoedprx.cxx
+++ b/editeng/source/uno/unoedprx.cxx
@@ -953,7 +953,6 @@ sal_Int32 SvxAccessibleTextAdapter::GetLineLen( sal_Int32 nPara, sal_Int32 nLine
{
assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder");
- SvxAccessibleTextIndex aStartIndex;
SvxAccessibleTextIndex aEndIndex;
sal_Int32 nCurrLine;
sal_Int32 nCurrIndex, nLastIndex;
@@ -967,6 +966,7 @@ sal_Int32 SvxAccessibleTextAdapter::GetLineLen( sal_Int32 nPara, sal_Int32 nLine
aEndIndex.SetEEIndex( nPara, nCurrIndex, *this );
if( nLine > 0 )
{
+ SvxAccessibleTextIndex aStartIndex;
aStartIndex.SetEEIndex( nPara, nLastIndex, *this );
return aEndIndex.GetIndex() - aStartIndex.GetIndex();
diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx
index 8b0a55bde535..bde2a75e26ab 100644
--- a/editeng/source/uno/unofored.cxx
+++ b/editeng/source/uno/unofored.cxx
@@ -340,7 +340,6 @@ tools::Rectangle SvxEditEngineForwarder::GetParaBounds( sal_Int32 nPara ) const
const Point aPnt = rEditEngine.GetDocPosTopLeft( nPara );
sal_uLong nWidth;
sal_uLong nHeight;
- sal_uLong nTextWidth;
if( rEditEngine.IsVertical() )
{
@@ -349,7 +348,7 @@ tools::Rectangle SvxEditEngineForwarder::GetParaBounds( sal_Int32 nPara ) const
// don't rotate.
nWidth = rEditEngine.GetTextHeight( nPara );
nHeight = rEditEngine.GetTextHeight();
- nTextWidth = rEditEngine.GetTextHeight();
+ sal_uLong nTextWidth = rEditEngine.GetTextHeight();
return tools::Rectangle( nTextWidth - aPnt.Y() - nWidth, 0, nTextWidth - aPnt.Y(), nHeight );
}
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index d4a3364f44fa..f15e57c8f704 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -1734,9 +1734,9 @@ void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRan
if( !xRange.is() )
return;
- ESelection aSelection;
if (GetEditSource())
{
+ ESelection aSelection;
::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
SetSelection( aSelection );
}
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 2c932a440eeb..b47d0c86496f 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1202,15 +1202,13 @@ namespace emfio
case EMR_EXTCREATEPEN :
{
- sal_Int32 elpHatch;
- sal_uInt32 offBmi, cbBmi, offBits, cbBits, nStyle, nWidth, nBrushStyle, elpNumEntries;
- Color aColorRef;
-
mpInputStream->ReadUInt32( nIndex );
if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
{
+ sal_uInt32 offBmi, cbBmi, offBits, cbBits, nStyle, nWidth, nBrushStyle, elpNumEntries;
+ sal_Int32 elpHatch;
mpInputStream->ReadUInt32( offBmi ).ReadUInt32( cbBmi ).ReadUInt32( offBits ).ReadUInt32( cbBits ). ReadUInt32( nStyle ).ReadUInt32( nWidth ).ReadUInt32( nBrushStyle );
- aColorRef = ReadColor();
+ Color aColorRef = ReadColor();
mpInputStream->ReadInt32( elpHatch ).ReadUInt32( elpNumEntries );
LineInfo aLineInfo;
@@ -1292,10 +1290,10 @@ namespace emfio
case EMR_CREATEBRUSHINDIRECT :
{
- sal_uInt32 nStyle;
mpInputStream->ReadUInt32( nIndex );
if ( ( nIndex & ENHMETA_STOCK_OBJECT ) == 0 )
{
+ sal_uInt32 nStyle;
mpInputStream->ReadUInt32( nStyle );
CreateObjectIndexed(nIndex, std::make_unique<WinMtfFillStyle>( ReadColor(), ( nStyle == BS_HOLLOW ) ));
}
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx
index c18189cc9734..27c42bdc0171 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -1108,7 +1108,6 @@ namespace emfio
if ( Application::GetDefaultDevice()->IsFontAvailable( GetFont().GetFamilyName() ) )
{
Point aPt;
- OUString aString;
sal_uInt32 nStringLen, nDXCount;
std::unique_ptr<long[]> pDXAry;
SvMemoryStream aMemoryStream( nEscLen );
@@ -1123,8 +1122,7 @@ namespace emfio
if ( ( static_cast< sal_uInt64 >( nStringLen ) * sizeof( sal_Unicode ) ) < ( nEscLen - aMemoryStream.Tell() ) )
{
-
- aString = read_uInt16s_ToOUString(aMemoryStream, nStringLen);
+ OUString aString = read_uInt16s_ToOUString(aMemoryStream, nStringLen);
aMemoryStream.ReadUInt32( nDXCount );
if ( ( static_cast< sal_uInt64 >( nDXCount ) * sizeof( sal_Int32 ) ) >= ( nEscLen - aMemoryStream.Tell() ) )
nDXCount = 0;
@@ -1309,9 +1307,9 @@ namespace emfio
// The image size is not known so normalize the calculated bounds so that the
// resulting image is not too big
- const double fMaxWidth = static_cast<double>(aMaxWidth);
if (aPlaceableBound.GetWidth() > aMaxWidth)
{
+ const double fMaxWidth = static_cast<double>(aMaxWidth);
double fRatio = aPlaceableBound.GetWidth() / fMaxWidth;
aPlaceableBound = tools::Rectangle(
More information about the Libreoffice-commits
mailing list