summaryrefslogtreecommitdiff
path: root/basic/source
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-19 16:02:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-20 07:50:06 +0200
commit6ee9f2c188290ba8a8bc6d435f645b31a05783ea (patch)
tree60a58e7c8995d64f3b22cf228480284172b6a17c /basic/source
parent9c2b43e86fbb7612a58f6e55bc429f674977d6dd (diff)
loplugin:oncevar accessibility..basic
Change-Id: I8fb41b658ef0f6ad1774ea897eace3dc9bb12de6 Reviewed-on: https://gerrit.libreoffice.org/38969 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source')
-rw-r--r--basic/source/classes/sb.cxx6
-rw-r--r--basic/source/classes/sbunoobj.cxx7
-rw-r--r--basic/source/classes/sbxmod.cxx8
-rw-r--r--basic/source/comp/dim.cxx3
-rw-r--r--basic/source/comp/exprtree.cxx6
-rw-r--r--basic/source/runtime/iosys.cxx3
-rw-r--r--basic/source/runtime/methods.cxx6
-rw-r--r--basic/source/runtime/methods1.cxx11
-rw-r--r--basic/source/runtime/runtime.cxx6
-rw-r--r--basic/source/sbx/sbxcurr.cxx6
-rw-r--r--basic/source/sbx/sbxvalue.cxx6
-rw-r--r--basic/source/uno/namecont.cxx19
-rw-r--r--basic/source/uno/scriptcont.cxx13
13 files changed, 35 insertions, 65 deletions
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 3f59b63118ff..9e6e32a0d02a 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -511,8 +511,7 @@ SbxObject* SbFormFactory::CreateObject( const OUString& rClassName )
if( bInitState )
{
// Not the first instantiate, reset
- bool bTriggerTerminateEvent = false;
- pFormModule->ResetApiObj( bTriggerTerminateEvent );
+ pFormModule->ResetApiObj( false/*bTriggerTerminateEvent*/ );
pFormModule->setInitState( false );
}
else
@@ -747,8 +746,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule )
}
else if( aObjClass.equalsIgnoreAsciiCase( "Collection" ) )
{
- OUString aCollectionName("Collection");
- BasicCollection* pNewCollection = new BasicCollection( aCollectionName );
+ BasicCollection* pNewCollection = new BasicCollection( "Collection" );
pNewCollection->SetName( pProp->GetName() );
pNewCollection->SetParent( pClassModule->pParent );
pNewProp->PutObject( pNewCollection );
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index f102e4efa694..7b755de3ee16 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -2221,8 +2221,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
}
else if( bInvocation && pParams && mxInvocation.is() )
{
- bool bOLEAutomation = true;
- processAutomationParams( pParams, args, bOLEAutomation, nParamCount );
+ processAutomationParams( pParams, args, true/*bOLEAutomation*/, nParamCount );
}
// call the method
@@ -2529,9 +2528,7 @@ SbxInfo* SbUnoMethod::GetInfo()
const ParamInfo& rInfo = pParamInfos[i];
OUString aParamName = rInfo.aName;
- SbxDataType t = SbxVARIANT;
- SbxFlagBits nFlags_ = SbxFlagBits::Read;
- pInfo->AddParam( aParamName, t, nFlags_ );
+ pInfo->AddParam( aParamName, SbxVARIANT, SbxFlagBits::Read );
}
}
}
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index cea279f14b7a..d56894fffe3d 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1999,7 +1999,7 @@ bool SbMethod::LoadData( SvStream& rStrm, sal_uInt16 nVer )
if (nFlag & 0x8000)
{
sal_uInt16 nMult = nFlag & 0x7FFF;
- sal_Int16 nMax = std::numeric_limits<sal_Int16>::max();
+ sal_Int16 const nMax = std::numeric_limits<sal_Int16>::max();
nStart = nMult * nMax + nTempStart;
}
else
@@ -2559,12 +2559,11 @@ void SbUserFormModule::Unload()
SAL_INFO("basic", "** Unload() ");
sal_Int8 nCancel = 0;
- sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormCode;
Sequence< Any > aParams;
aParams.realloc(2);
aParams[0] <<= nCancel;
- aParams[1] <<= nCloseMode;
+ aParams[1] <<= sal_Int8(::ooo::vba::VbQueryClose::vbFormCode);
triggerMethod( "Userform_QueryClose", aParams);
@@ -2609,8 +2608,7 @@ void SbUserFormModule::InitObject()
{
try
{
- OUString aHook("VBAGlobals");
- SbUnoObject* pGlobs = static_cast<SbUnoObject*>(GetParent()->Find( aHook, SbxClassType::DontCare ));
+ SbUnoObject* pGlobs = static_cast<SbUnoObject*>(GetParent()->Find( "VBAGlobals", SbxClassType::DontCare ));
if ( m_xModel.is() && pGlobs )
{
// broadcast INITIALIZE_USERFORM script event before the dialog is created
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 3b3a0e75bd5c..a5d5380a53ed 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -775,12 +775,11 @@ void SbiParser::DefEnum( bool bPrivate )
if( !bPrivate )
{
- SbiOpcode eOp = SbiOpcode::GLOBAL_;
aGen.BackChain( nGblChain );
nGblChain = 0;
bGblDefs = bNewGblDefs = true;
aGen.Gen(
- eOp, pElem->GetId(),
+ SbiOpcode::GLOBAL_, pElem->GetId(),
sal::static_int_cast< sal_uInt16 >( pElem->GetType() ) );
aVar.Gen();
diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index d75b32364e30..3039046f39bd 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -419,8 +419,7 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj )
if( DoParametersFollow( pParser, eCurExpr, eTok ) )
{
- bool bStandaloneExpression = false;
- pPar = SbiExprList::ParseParameters( pParser, bStandaloneExpression );
+ pPar = SbiExprList::ParseParameters( pParser, false/*bStandaloneExpression*/ );
bError = bError || !pPar->IsValid();
eTok = pParser->Peek();
@@ -605,8 +604,7 @@ SbiExprNode* SbiExpression::Unary()
case TYPEOF:
{
pParser->Next();
- bool bUsedForTypeOf = true;
- SbiExprNode* pObjNode = Operand( bUsedForTypeOf );
+ SbiExprNode* pObjNode = Operand( true/*bUsedForTypeOf*/ );
pParser->TestToken( IS );
OUString aDummy;
SbiSymDef* pTypeDef = new SbiSymDef( aDummy );
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index 5782026bc946..472c4321e0ec 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -589,10 +589,9 @@ void SbiStream::ExpandFile()
if( nCur < nExpandOnWriteTo )
{
sal_uInt64 nDiff = nExpandOnWriteTo - nCur;
- char c = 0;
while( nDiff-- )
{
- pStrm->WriteChar( c );
+ pStrm->WriteChar( 0 );
}
}
else
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 15f357c9950f..1ca9282f5468 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -372,8 +372,7 @@ RTLFUNC(Chr)
(void)pBasic;
(void)bWrite;
- bool bChrW = false;
- implChr( rPar, bChrW );
+ implChr( rPar, false/*bChrW*/ );
}
RTLFUNC(ChrW)
@@ -381,8 +380,7 @@ RTLFUNC(ChrW)
(void)pBasic;
(void)bWrite;
- bool bChrW = true;
- implChr( rPar, bChrW );
+ implChr( rPar, true/*bChrW*/ );
}
RTLFUNC(CurDir)
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 8ebcab989e08..f8ad651fae30 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -2260,20 +2260,17 @@ RTLFUNC(DateDiff)
}
case INTERVAL_H:
{
- double dFactor = 24.0;
- dRet = RoundImpl( dFactor * (dDate2 - dDate1) );
+ dRet = RoundImpl( 24.0 * (dDate2 - dDate1) );
break;
}
case INTERVAL_N:
{
- double dFactor =1440.0;
- dRet = RoundImpl( dFactor * (dDate2 - dDate1) );
+ dRet = RoundImpl( 1440.0 * (dDate2 - dDate1) );
break;
}
case INTERVAL_S:
{
- double dFactor = 86400.0;
- dRet = RoundImpl( dFactor * (dDate2 - dDate1) );
+ dRet = RoundImpl( 86400.0 * (dDate2 - dDate1) );
break;
}
}
@@ -3174,7 +3171,7 @@ RTLFUNC(Rate)
if ( nArgCount >= 6 )
{
if( rPar.Get(6)->GetType() != SbxEMPTY )
- type = rPar.Get(6)->GetDouble();
+ guess = rPar.Get(6)->GetDouble();
}
Sequence< Any > aParams( 6 );
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index f43e882d87a4..d33e584dce20 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -433,8 +433,7 @@ SvNumberFormatter* SbiInstance::PrepareNumberFormatter( sal_uInt32 &rnStdDateIdx
pNumberFormater->PutandConvertEntry( aStr, nCheckPos, nType,
rnStdDateIdx, LANGUAGE_ENGLISH_US, eLangType );
nCheckPos = 0;
- OUString aStrHHMMSS(" HH:MM:SS");
- aDateStr += aStrHHMMSS;
+ aDateStr += " HH:MM:SS";
aStr = aDateStr;
pNumberFormater->PutandConvertEntry( aStr, nCheckPos, nType,
rnStdDateTimeIdx, LANGUAGE_ENGLISH_US, eLangType );
@@ -486,8 +485,7 @@ void SbiInstance::ErrorVB( sal_Int32 nVBNumber, const OUString& rMsg )
aErrorMsg = rMsg;
SbiRuntime::translateErrorToVba( n, aErrorMsg );
- bool bVBATranslationAlreadyDone = true;
- pRun->Error( ERRCODE_BASIC_COMPAT, bVBATranslationAlreadyDone );
+ pRun->Error( ERRCODE_BASIC_COMPAT, true/*bVBATranslationAlreadyDone*/ );
}
}
diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx
index 9f013ea64f8c..e4d525bd794e 100644
--- a/basic/source/sbx/sbxcurr.cxx
+++ b/basic/source/sbx/sbxcurr.cxx
@@ -31,7 +31,7 @@ static OUString ImpCurrencyToString( sal_Int64 rVal )
bool isNeg = ( rVal < 0 );
sal_Int64 absVal = isNeg ? -rVal : rVal;
- sal_Unicode cDecimalSep = '.';
+ sal_Unicode const cDecimalSep = '.';
OUString aAbsStr = OUString::number( absVal );
OUStringBuffer aBuf;
@@ -92,8 +92,8 @@ static sal_Int64 ImpStringToCurrency( const OUString &rStr )
sal_Int32 nFractDigit = 4;
- sal_Unicode cDeciPnt = '.';
- sal_Unicode c1000Sep = ',';
+ sal_Unicode const cDeciPnt = '.';
+ sal_Unicode const c1000Sep = ',';
// lets use the existing string number conversions
// there is a performance impact here ( multiple string copies )
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 10c3e0620016..e18e4afa7180 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -1594,14 +1594,12 @@ bool SbxValue::LoadData( SvStream& r, sal_uInt16 )
r.WriteUInt32( aData.nULong ); break;
case SbxINT:
{
- sal_uInt8 n = SAL_TYPES_SIZEOFINT;
- r.WriteUChar( n ).WriteInt32( aData.nInt );
+ r.WriteUChar( SAL_TYPES_SIZEOFINT ).WriteInt32( aData.nInt );
break;
}
case SbxUINT:
{
- sal_uInt8 n = SAL_TYPES_SIZEOFINT;
- r.WriteUChar( n ).WriteUInt32( aData.nUInt );
+ r.WriteUChar( SAL_TYPES_SIZEOFINT ).WriteUInt32( aData.nUInt );
break;
}
case SbxEMPTY:
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 0d5a4c1b0e22..a76d47a23723 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -1036,11 +1036,10 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
aCheckFileName, aXlbExtension, mxSFI );
// Check if module1.xba exists
- OUString aXbaExtension("xba");
aCheckFileName = "Module1";
checkAndCopyFileImpl( aUserBasicStandardInetObj,
aPrevUserBasicStandardInetObj,
- aCheckFileName, aXbaExtension, mxSFI );
+ aCheckFileName, "xba", mxSFI );
}
else
{
@@ -1102,8 +1101,8 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
OUString aUserSearchStr("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE");
OUString aSharedSearchStr("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE");
- OUString aBundledSearchStr("vnd.sun.star.expand:$BUNDLED_EXTENSIONS");
- OUString aInstSearchStr("$(INST)");
+ OUString const aBundledSearchStr("vnd.sun.star.expand:$BUNDLED_EXTENSIONS");
+ OUString const aInstSearchStr("$(INST)");
Sequence< OUString > aNames = pPrevCont->getElementNames();
const OUString* pNames = aNames.getConstArray();
@@ -1413,8 +1412,6 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
embed::ElementModes::READWRITE );
// throw uno::RuntimeException(); // TODO: method must either return the stream or throw an exception
- OUString aMime( "text/xml" );
-
uno::Reference< beans::XPropertySet > xProps( xElementStream, uno::UNO_QUERY );
SAL_WARN_IF(
!xProps.is(), "basic",
@@ -1423,7 +1420,7 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
if ( xProps.is() )
{
- xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
+ xProps->setPropertyValue("MediaType", uno::Any( OUString( "text/xml" ) ) );
// #87671 Allow encryption
xProps->setPropertyValue("UseCommonStoragePasswordEncryption", uno::Any( true ) );
@@ -1561,8 +1558,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
if ( xProps.is() )
{
- OUString aMime("text/xml");
- xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
+ xProps->setPropertyValue("MediaType", uno::Any( OUString("text/xml") ) );
// #87671 Allow encryption
xProps->setPropertyValue("UseCommonStoragePasswordEncryption", uno::Any( true ) );
@@ -2076,8 +2072,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
{
xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY_THROW );
- OUString aMime( "text/xml" );
- xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
+ xProps->setPropertyValue("MediaType", uno::Any( OUString( "text/xml" ) ) );
// #87671 Allow encryption
xProps->setPropertyValue("UseCommonStoragePasswordEncryption", uno::Any( true ) );
@@ -2224,7 +2219,7 @@ Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink
OUString aUserSearchStr("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE");
OUString aSharedSearchStr("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE");
- OUString aBundledSearchStr("vnd.sun.star.expand:$BUNDLED_EXTENSIONS");
+ OUString const aBundledSearchStr("vnd.sun.star.expand:$BUNDLED_EXTENSIONS");
if( StorageURL.indexOf( aUserSearchStr ) != -1 )
{
pNewLib->mbExtension = true;
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index b93217485929..327e9d33fd01 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -662,8 +662,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
aSourceStreamName,
embed::ElementModes::READWRITE );
uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY_THROW );
- OUString aMime( "text/xml" );
- xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
+ xProps->setPropertyValue("MediaType", uno::Any( OUString( "text/xml" ) ) );
// Set encryption key
setStreamKey( xSourceStream, pLib->maPassword );
@@ -746,10 +745,8 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
SbModule* pMod = pBasicLib->FindModule( aElementName );
if( pMod )
{
- OUString aCodeStreamName( "code.bin" );
-
uno::Reference< io::XStream > xCodeStream = xElementRootStorage->openStreamElement(
- aCodeStreamName,
+ "code.bin",
embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
SvMemoryStream aMemStream;
@@ -792,8 +789,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
}
uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY_THROW );
- OUString aMime( "text/xml" );
- xProps->setPropertyValue("MediaType", uno::Any( aMime ) );
+ xProps->setPropertyValue("MediaType", uno::Any( OUString( "text/xml" ) ) );
Reference< XOutputStream > xOut = xSourceStream->getOutputStream();
Reference< XNameContainer > xLib( pLib );
@@ -1023,9 +1019,8 @@ bool SfxScriptLibraryContainer::implLoadPasswordLibrary
try
{
- OUString aCodeStreamName( "code.bin" );
uno::Reference< io::XStream > xCodeStream = xElementRootStorage->openStreamElement(
- aCodeStreamName,
+ "code.bin",
embed::ElementModes::READ );
std::unique_ptr<SvStream> pStream(::utl::UcbStreamHelper::CreateStream( xCodeStream ));