loplugin:reducevarscope in basctl,basic

Change-Id: I32595921bf5ed26699bced3637302692c407d624
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103760
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel
2020-10-01 14:01:16 +02:00
committed by Noel Grandin
parent 18d4e89fdd
commit 38786f1df9
6 changed files with 13 additions and 17 deletions

View File

@@ -302,10 +302,9 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ ) for( sal_Int32 i = 0 ; i < nLocaleCount ; i++ )
{ {
const Locale& rLocale = pLocales[ i ]; const Locale& rLocale = pLocales[ i ];
OUString aResStr;
try try
{ {
aResStr = xStringResourceManager->resolveStringForLocale OUString aResStr = xStringResourceManager->resolveStringForLocale
( aPureSourceIdStr, rLocale ); ( aPureSourceIdStr, rLocale );
xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale ); xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale );
xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale ); xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );
@@ -515,10 +514,9 @@ sal_Int32 LocalizationMgr::implHandleControlResourceProperties
{ {
const Locale& rLocale = pLocales[ iLocale ]; const Locale& rLocale = pLocales[ iLocale ];
OUString aResStr;
try try
{ {
aResStr = xStringResourceManager->resolveStringForLocale OUString aResStr = xStringResourceManager->resolveStringForLocale
( aPureSourceIdStr, rLocale ); ( aPureSourceIdStr, rLocale );
xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale ); xStringResourceManager->removeIdForLocale( aPureSourceIdStr, rLocale );
xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale ); xStringResourceManager->setStringForLocale( aPureIdStr, aResStr, rLocale );

View File

@@ -48,11 +48,11 @@ void MacroSnippet::LoadSourceFromFile( const OUString& sMacroFileURL )
if(aFile.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None) if(aFile.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None)
{ {
sal_uInt64 size; sal_uInt64 size;
sal_uInt64 size_read;
if(aFile.getSize(size) == osl::FileBase::E_None) if(aFile.getSize(size) == osl::FileBase::E_None)
{ {
void* buffer = calloc(1, size+1); void* buffer = calloc(1, size+1);
CPPUNIT_ASSERT(buffer); CPPUNIT_ASSERT(buffer);
sal_uInt64 size_read;
if(aFile.read( buffer, size, size_read) == osl::FileBase::E_None) if(aFile.read( buffer, size, size_read) == osl::FileBase::E_None)
{ {
if(size == size_read) if(size == size_read)

View File

@@ -117,15 +117,15 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
// Read Master-Record // Read Master-Record
r.ReadUInt16( nSign ).ReadUInt32( nLen ).ReadUInt16( nCount ); r.ReadUInt16( nSign ).ReadUInt32( nLen ).ReadUInt16( nCount );
sal_uInt64 nLast = r.Tell() + nLen; sal_uInt64 nLast = r.Tell() + nLen;
sal_uInt32 nCharSet; // System charset
sal_uInt32 lDimBase;
sal_uInt16 nReserved1;
sal_uInt32 nReserved2;
sal_uInt32 nReserved3;
bool bBadVer = false; bool bBadVer = false;
if( nSign == static_cast<sal_uInt16>( FileOffset::Module ) ) if( nSign == static_cast<sal_uInt16>( FileOffset::Module ) )
{ {
sal_uInt32 nCharSet; // System charset
sal_uInt32 lDimBase;
sal_uInt16 nTmpFlags; sal_uInt16 nTmpFlags;
sal_uInt16 nReserved1;
sal_uInt32 nReserved2;
sal_uInt32 nReserved3;
r.ReadUInt32( nVersion ).ReadUInt32( nCharSet ).ReadUInt32( lDimBase ) r.ReadUInt32( nVersion ).ReadUInt32( nCharSet ).ReadUInt32( lDimBase )
.ReadUInt16( nTmpFlags ).ReadUInt16( nReserved1 ).ReadUInt32( nReserved2 ).ReadUInt32( nReserved3 ); .ReadUInt16( nTmpFlags ).ReadUInt16( nReserved1 ).ReadUInt32( nReserved2 ).ReadUInt32( nReserved3 );
nFlags = static_cast<SbiImageFlags>(nTmpFlags); nFlags = static_cast<SbiImageFlags>(nTmpFlags);

View File

@@ -4107,8 +4107,6 @@ void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
OUString aOldStr = rPar.Get32(1)->GetOUString(); OUString aOldStr = rPar.Get32(1)->GetOUString();
sal_Int32 nConversion = rPar.Get32(2)->GetLong(); sal_Int32 nConversion = rPar.Get32(2)->GetLong();
LanguageType nLanguage = LANGUAGE_SYSTEM;
sal_Int32 nOldLen = aOldStr.getLength(); sal_Int32 nOldLen = aOldStr.getLength();
if( nOldLen == 0 ) if( nOldLen == 0 )
{ {
@@ -4153,6 +4151,7 @@ void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext(); uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext();
::utl::TransliterationWrapper aTransliterationWrapper( xContext, nType ); ::utl::TransliterationWrapper aTransliterationWrapper( xContext, nType );
uno::Sequence<sal_Int32> aOffsets; uno::Sequence<sal_Int32> aOffsets;
LanguageType nLanguage = LANGUAGE_SYSTEM;
aTransliterationWrapper.loadModuleIfNeeded( nLanguage ); aTransliterationWrapper.loadModuleIfNeeded( nLanguage );
aNewStr = aTransliterationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets ); aNewStr = aTransliterationWrapper.transliterate( aOldStr, nLanguage, 0, nOldLen, &aOffsets );
} }

View File

@@ -784,7 +784,7 @@ bool SbiRuntime::Step()
} }
SbiOpcode eOp = static_cast<SbiOpcode>( *pCode++ ); SbiOpcode eOp = static_cast<SbiOpcode>( *pCode++ );
sal_uInt32 nOp1, nOp2; sal_uInt32 nOp1;
if (eOp <= SbiOpcode::SbOP0_END) if (eOp <= SbiOpcode::SbOP0_END)
{ {
(this->*( aStep0[ int(eOp) ] ) )(); (this->*( aStep0[ int(eOp) ] ) )();
@@ -798,7 +798,7 @@ bool SbiRuntime::Step()
else if (eOp >= SbiOpcode::SbOP2_START && eOp <= SbiOpcode::SbOP2_END) else if (eOp >= SbiOpcode::SbOP2_START && eOp <= SbiOpcode::SbOP2_END)
{ {
nOp1 = *pCode++; nOp1 |= *pCode++ << 8; nOp1 |= *pCode++ << 16; nOp1 |= *pCode++ << 24; nOp1 = *pCode++; nOp1 |= *pCode++ << 8; nOp1 |= *pCode++ << 16; nOp1 |= *pCode++ << 24;
nOp2 = *pCode++; nOp2 |= *pCode++ << 8; nOp2 |= *pCode++ << 16; nOp2 |= *pCode++ << 24; sal_uInt32 nOp2 = *pCode++; nOp2 |= *pCode++ << 8; nOp2 |= *pCode++ << 16; nOp2 |= *pCode++ << 24;
(this->*( aStep2[ int(eOp) - int(SbiOpcode::SbOP2_START) ] ) )( nOp1, nOp2 ); (this->*( aStep2[ int(eOp) - int(SbiOpcode::SbOP2_START) ] ) )( nOp1, nOp2 );
} }
else else
@@ -2430,7 +2430,6 @@ void SbiRuntime::StepARGV()
void SbiRuntime::StepINPUT() void SbiRuntime::StepINPUT()
{ {
OUStringBuffer sin; OUStringBuffer sin;
OUString s;
char ch = 0; char ch = 0;
ErrCode err; ErrCode err;
// Skip whitespace // Skip whitespace
@@ -2482,7 +2481,7 @@ void SbiRuntime::StepINPUT()
} }
if( !err ) if( !err )
{ {
s = sin.makeStringAndClear(); OUString s = sin.makeStringAndClear();
SbxVariableRef pVar = GetTOS(); SbxVariableRef pVar = GetTOS();
// try to fill the variable with a numeric value first, // try to fill the variable with a numeric value first,
// then with a string value // then with a string value

View File

@@ -1026,9 +1026,9 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary
if( bLoadSource || bVerifyPasswordOnly ) if( bLoadSource || bVerifyPasswordOnly )
{ {
// Access encrypted source stream // Access encrypted source stream
OUString aSourceStreamName( "source.xml" );
try try
{ {
OUString aSourceStreamName( "source.xml" );
uno::Reference< io::XStream > xSourceStream = xElementRootStorage->openEncryptedStreamElement( uno::Reference< io::XStream > xSourceStream = xElementRootStorage->openEncryptedStreamElement(
aSourceStreamName, aSourceStreamName,
embed::ElementModes::READ, embed::ElementModes::READ,