loplugin:oncevar in helpcompiler..jvmfwk

Change-Id: Ia9b20a8ca95684cbeb21e3425972c43ba50df3cd
Reviewed-on: https://gerrit.libreoffice.org/39187
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2017-06-23 16:04:59 +02:00
parent d116894b26
commit a006f60b6a
15 changed files with 41 additions and 49 deletions

View File

@ -490,8 +490,7 @@ bool HelpCompiler::compile()
{ {
if (fileName.compare(0, 6, "/text/") == 0) if (fileName.compare(0, 6, "/text/") == 0)
{ {
int len = strlen("/text/"); actMod = fileName.substr(strlen("/text/"));
actMod = fileName.substr(len);
actMod = actMod.substr(0, actMod.find('/')); actMod = actMod.substr(0, actMod.find('/'));
} }
} }

View File

@ -151,7 +151,7 @@ void writeKeyValue_DBHelp( FILE* pFile, const std::string& aKeyStr, const std::s
{ {
if( pFile == nullptr ) if( pFile == nullptr )
return; return;
char cLF = 10; char const cLF = 10;
unsigned int nKeyLen = aKeyStr.length(); unsigned int nKeyLen = aKeyStr.length();
unsigned int nValueLen = aValueStr.length(); unsigned int nValueLen = aValueStr.length();
fprintf( pFile, "%x ", nKeyLen ); fprintf( pFile, "%x ", nKeyLen );

View File

@ -122,11 +122,11 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportHWP(SvStream &rStream)
{ {
std::unique_ptr<HStream> stream(new HStream); std::unique_ptr<HStream> stream(new HStream);
byte aData[32768]; byte aData[32768];
std::size_t nRead, nBlock = 32768; std::size_t nRead;
while (true) while (true)
{ {
nRead = rStream.ReadBytes(aData, nBlock); nRead = rStream.ReadBytes(aData, 32768);
if (nRead == 0) if (nRead == 0)
break; break;
stream->addData(aData, (int)nRead); stream->addData(aData, (int)nRead);
@ -153,10 +153,10 @@ sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor)
std::unique_ptr<HStream> stream(new HStream); std::unique_ptr<HStream> stream(new HStream);
Sequence < sal_Int8 > aBuffer; Sequence < sal_Int8 > aBuffer;
sal_Int32 nRead, nBlock = 32768, nTotal = 0; sal_Int32 nRead, nTotal = 0;
while( true ) while( true )
{ {
nRead = xInputStream->readBytes(aBuffer, nBlock); nRead = xInputStream->readBytes(aBuffer, 32768);
if( nRead == 0 ) if( nRead == 0 )
break; break;
stream->addData( reinterpret_cast<const byte *>(aBuffer.getConstArray()), nRead ); stream->addData( reinterpret_cast<const byte *>(aBuffer.getConstArray()), nRead );

View File

@ -45,7 +45,7 @@ public:
void TestLanguageTag::testAllTags() void TestLanguageTag::testAllTags()
{ {
{ {
OUString s_de_Latn_DE( "de-Latn-DE" ); OUString const s_de_Latn_DE( "de-Latn-DE" );
LanguageTag de_DE( s_de_Latn_DE, true ); LanguageTag de_DE( s_de_Latn_DE, true );
OUString aBcp47 = de_DE.getBcp47(); OUString aBcp47 = de_DE.getBcp47();
lang::Locale aLocale = de_DE.getLocale(); lang::Locale aLocale = de_DE.getLocale();
@ -63,7 +63,7 @@ void TestLanguageTag::testAllTags()
} }
{ {
OUString s_klingon( "i-klingon" ); OUString const s_klingon( "i-klingon" );
LanguageTag klingon( s_klingon, true ); LanguageTag klingon( s_klingon, true );
lang::Locale aLocale = klingon.getLocale(); lang::Locale aLocale = klingon.getLocale();
CPPUNIT_ASSERT_EQUAL( OUString("tlh"), klingon.getBcp47() ); CPPUNIT_ASSERT_EQUAL( OUString("tlh"), klingon.getBcp47() );
@ -143,7 +143,7 @@ void TestLanguageTag::testAllTags()
// 'sh-RS' has an internal override to 'sr-Latn-RS' // 'sh-RS' has an internal override to 'sr-Latn-RS'
{ {
OUString s_sh_RS( "sh-RS" ); OUString const s_sh_RS( "sh-RS" );
LanguageTag sh_RS( s_sh_RS, true ); LanguageTag sh_RS( s_sh_RS, true );
lang::Locale aLocale = sh_RS.getLocale(); lang::Locale aLocale = sh_RS.getLocale();
CPPUNIT_ASSERT_EQUAL( OUString("sr-Latn-RS"), sh_RS.getBcp47() ); CPPUNIT_ASSERT_EQUAL( OUString("sr-Latn-RS"), sh_RS.getBcp47() );
@ -175,7 +175,7 @@ void TestLanguageTag::testAllTags()
// known LangID with an override and canonicalization should work the same // known LangID with an override and canonicalization should work the same
// without liblangtag. // without liblangtag.
{ {
OUString s_bs_Latn_BA( "bs-Latn-BA" ); OUString const s_bs_Latn_BA( "bs-Latn-BA" );
LanguageTag bs_Latn_BA( s_bs_Latn_BA, true ); LanguageTag bs_Latn_BA( s_bs_Latn_BA, true );
lang::Locale aLocale = bs_Latn_BA.getLocale(); lang::Locale aLocale = bs_Latn_BA.getLocale();
CPPUNIT_ASSERT_EQUAL( OUString("bs-BA"), bs_Latn_BA.getBcp47() ); CPPUNIT_ASSERT_EQUAL( OUString("bs-BA"), bs_Latn_BA.getBcp47() );
@ -250,7 +250,7 @@ void TestLanguageTag::testAllTags()
// 'ca-XV' has an internal override to 'ca-ES-valencia' // 'ca-XV' has an internal override to 'ca-ES-valencia'
{ {
OUString s_ca_XV( "ca-XV" ); OUString const s_ca_XV( "ca-XV" );
OUString s_ca_ES_valencia( "ca-ES-valencia" ); OUString s_ca_ES_valencia( "ca-ES-valencia" );
LanguageTag ca_XV( s_ca_XV, true ); LanguageTag ca_XV( s_ca_XV, true );
lang::Locale aLocale = ca_XV.getLocale(); lang::Locale aLocale = ca_XV.getLocale();
@ -300,7 +300,7 @@ void TestLanguageTag::testAllTags()
} }
{ {
OUString s_de_DE( "de-DE" ); OUString const s_de_DE( "de-DE" );
LanguageTag de_DE( lang::Locale( "de", "DE", "" ) ); LanguageTag de_DE( lang::Locale( "de", "DE", "" ) );
lang::Locale aLocale = de_DE.getLocale(); lang::Locale aLocale = de_DE.getLocale();
CPPUNIT_ASSERT_EQUAL( s_de_DE, de_DE.getBcp47() ); CPPUNIT_ASSERT_EQUAL( s_de_DE, de_DE.getBcp47() );
@ -311,7 +311,7 @@ void TestLanguageTag::testAllTags()
} }
{ {
OUString s_de_DE( "de-DE" ); OUString const s_de_DE( "de-DE" );
LanguageTag de_DE( LANGUAGE_GERMAN ); LanguageTag de_DE( LANGUAGE_GERMAN );
lang::Locale aLocale = de_DE.getLocale(); lang::Locale aLocale = de_DE.getLocale();
CPPUNIT_ASSERT_EQUAL( s_de_DE, de_DE.getBcp47() ); CPPUNIT_ASSERT_EQUAL( s_de_DE, de_DE.getBcp47() );
@ -389,9 +389,8 @@ void TestLanguageTag::testAllTags()
// Deprecated as of 2015-04-17, prefer en-GB-oxendict instead. // Deprecated as of 2015-04-17, prefer en-GB-oxendict instead.
// As of 2017-03-14 we also alias to en-GB-oxendict. // As of 2017-03-14 we also alias to en-GB-oxendict.
{ {
OUString s_en_GB_oed( "en-GB-oed" );
OUString s_en_GB_oxendict( "en-GB-oxendict" ); OUString s_en_GB_oxendict( "en-GB-oxendict" );
LanguageTag en_GB_oed( s_en_GB_oed ); LanguageTag en_GB_oed( "en-GB-oed" );
lang::Locale aLocale = en_GB_oed.getLocale(); lang::Locale aLocale = en_GB_oed.getLocale();
CPPUNIT_ASSERT_EQUAL( s_en_GB_oxendict, en_GB_oed.getBcp47() ); CPPUNIT_ASSERT_EQUAL( s_en_GB_oxendict, en_GB_oed.getBcp47() );
CPPUNIT_ASSERT_EQUAL( OUString("qlt"), aLocale.Language ); CPPUNIT_ASSERT_EQUAL( OUString("qlt"), aLocale.Language );
@ -493,7 +492,7 @@ void TestLanguageTag::testAllTags()
// 'qtx' is an unknown new mslangid // 'qtx' is an unknown new mslangid
{ {
OUString s_qtx( "qtx" ); OUString const s_qtx( "qtx" );
LanguageTag qtx( s_qtx ); LanguageTag qtx( s_qtx );
qtx.setScriptType( LanguageTag::ScriptType::RTL ); qtx.setScriptType( LanguageTag::ScriptType::RTL );
LanguageType n_qtx = qtx.getLanguageType(); LanguageType n_qtx = qtx.getLanguageType();

View File

@ -115,7 +115,7 @@ void TestBreakIterator::testLineBreaking()
//See https://bz.apache.org/ooo/show_bug.cgi?id=17155 //See https://bz.apache.org/ooo/show_bug.cgi?id=17155
{ {
OUString aTest("foo /bar/baz"); OUString const aTest("foo /bar/baz");
aLocale.Language = "en"; aLocale.Language = "en";
aLocale.Country = "US"; aLocale.Country = "US";

View File

@ -103,9 +103,9 @@ void TestTextSearch::testSearches()
{ {
OUString str( "acababaabcababadcdaa" ); OUString str( "acababaabcababadcdaa" );
sal_Int32 startPos = 2, endPos = 20 ; sal_Int32 startPos = 2, endPos = 20 ;
OUString searchStr( "(ab)*a(c|d)+" ); OUString const searchStr( "(ab)*a(c|d)+" );
sal_Int32 fStartRes = 10, fEndRes = 18 ; sal_Int32 const fStartRes = 10, fEndRes = 18 ;
sal_Int32 bStartRes = 18, bEndRes = 10 ; sal_Int32 const bStartRes = 18, bEndRes = 10 ;
// set options // set options
util::SearchOptions aOptions; util::SearchOptions aOptions;

View File

@ -316,12 +316,12 @@ Calendar_hijri::getJulianDay(sal_Int32 day, sal_Int32 month, sal_Int32 year)
sal_Int32 intgr = (sal_Int32)((sal_Int32)(365.25 * jy) + (sal_Int32)(30.6001 * jm) + day + 1720995 ); sal_Int32 intgr = (sal_Int32)((sal_Int32)(365.25 * jy) + (sal_Int32)(30.6001 * jm) + day + 1720995 );
//check for switch to Gregorian calendar //check for switch to Gregorian calendar
double gregcal = 15 + 31 * ( 10 + 12 * 1582 ); double const gregcal = 15 + 31 * ( 10 + 12 * 1582 );
if( day + 31 * (month + 12 * year) >= gregcal ) { if( day + 31 * (month + 12 * year) >= gregcal ) {
double ja; double ja;
ja = (sal_Int32)(0.01 * jy); ja = (sal_Int32)(0.01 * jy);
intgr += (sal_Int32)(2 - ja + (sal_Int32)(0.25 * ja)); intgr += (sal_Int32)(2 - ja + (sal_Int32)(0.25 * ja));
} }
return (double) intgr; return (double) intgr;

View File

@ -798,10 +798,10 @@ void LCFormatNode::generateCode (const OFileWriter &of) const
if (strcmp( of.getLocale(), "en_US") != 0) if (strcmp( of.getLocale(), "en_US") != 0)
{ {
OUString aCode( n->getValue()); OUString aCode( n->getValue());
OUString aPar1( "0)"); OUString const aPar1( "0)");
OUString aPar2( "-)" ); OUString const aPar2( "-)" );
OUString aPar3( " )" ); OUString const aPar3( " )" );
OUString aPar4( "])" ); OUString const aPar4( "])" );
if (aCode.indexOf( aPar1 ) > 0 || aCode.indexOf( aPar2 ) > 0 || if (aCode.indexOf( aPar1 ) > 0 || aCode.indexOf( aPar2 ) > 0 ||
aCode.indexOf( aPar3 ) > 0 || aCode.indexOf( aPar4 ) > 0) aCode.indexOf( aPar3 ) > 0 || aCode.indexOf( aPar4 ) > 0)
fprintf( stderr, "Warning: FormatCode formatindex=\"%d\" for currency uses parentheses for negative amounts, which probably is not correct for locales not based on en_US.\n", formatindex); fprintf( stderr, "Warning: FormatCode formatindex=\"%d\" for currency uses parentheses for negative amounts, which probably is not correct for locales not based on en_US.\n", formatindex);

View File

@ -259,7 +259,7 @@ PaperInfo PaperInfo::getSystemDefaultPaper()
bool bHalve = false; bool bHalve = false;
size_t nExtraTabSize = SAL_N_ELEMENTS(aCustoms); size_t const nExtraTabSize = SAL_N_ELEMENTS(aCustoms);
for (size_t i = 0; i < nExtraTabSize; ++i) for (size_t i = 0; i < nExtraTabSize; ++i)
{ {
if (rtl_str_compareIgnoreAsciiCase(aCustoms[i].pName, aPaper.getStr()) == 0) if (rtl_str_compareIgnoreAsciiCase(aCustoms[i].pName, aPaper.getStr()) == 0)

View File

@ -252,9 +252,7 @@ oneToOneMapping& widthfolding::gethalf2fullTableForJIS()
// //
// See the following page for detail: // See the following page for detail:
// http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
int i, j; for( int i = 0; i < int(SAL_N_ELEMENTS(half2fullJISException)); i++ )
int n = SAL_N_ELEMENTS(half2fullJISException);
for( i = 0; i < n; i++ )
{ {
const int high = (half2fullJISException[i].first >> 8) & 0xFF; const int high = (half2fullJISException[i].first >> 8) & 0xFF;
const int low = (half2fullJISException[i].first) & 0xFF; const int low = (half2fullJISException[i].first) & 0xFF;
@ -263,7 +261,7 @@ oneToOneMapping& widthfolding::gethalf2fullTableForJIS()
{ {
table.mpIndex[high] = new UnicodePairWithFlag*[256]; table.mpIndex[high] = new UnicodePairWithFlag*[256];
for( j = 0; j < 256; j++ ) for( int j = 0; j < 256; j++ )
table.mpIndex[high][j] = nullptr; table.mpIndex[high][j] = nullptr;
} }
table.mpIndex[high][low] = &half2fullJISException[i]; table.mpIndex[high][low] = &half2fullJISException[i];

View File

@ -42,7 +42,6 @@ bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
{ {
sal_uInt16 nParam = getNodeCount(NT_parameter); sal_uInt16 nParam = getNodeCount(NT_parameter);
sal_uInt16 nExcep = (sal_uInt16)m_exceptions.size(); sal_uInt16 nExcep = (sal_uInt16)m_exceptions.size();
RTMethodMode methodMode = RTMethodMode::TWOWAY;
OUString returnTypeName; OUString returnTypeName;
if (m_pReturnType == nullptr) { if (m_pReturnType == nullptr) {
@ -52,7 +51,7 @@ bool AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index)
m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8); m_pReturnType->getRelativName(), RTL_TEXTENCODING_UTF8);
} }
rBlob.setMethodData( rBlob.setMethodData(
index, getDocumentation(), methodMode, index, getDocumentation(), RTMethodMode::TWOWAY,
OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8), OStringToOUString(getLocalName(), RTL_TEXTENCODING_UTF8),
returnTypeName, nParam, nExcep); returnTypeName, nParam, nExcep);

View File

@ -180,8 +180,8 @@ bool copyFile(const OString* source, const OString& target)
return false; return false;
} }
size_t totalSize = 512; size_t const totalSize = 512;
char pBuffer[513]; char pBuffer[totalSize + 1];
while ( !feof(pSource) ) while ( !feof(pSource) )
{ {

View File

@ -170,8 +170,7 @@ OUString OTextInputStream::implReadString( const Sequence< sal_Unicode >& Delimi
OUString aRetStr; OUString aRetStr;
if( !mbEncodingInitialized ) if( !mbEncodingInitialized )
{ {
OUString aUtf8Str("utf8"); setEncoding( "utf8" );
setEncoding( aUtf8Str );
} }
if( !mbEncodingInitialized ) if( !mbEncodingInitialized )
return aRetStr; return aRetStr;
@ -278,8 +277,7 @@ sal_Int32 OTextInputStream::implReadNext()
try try
{ {
sal_Int32 nBytesToRead = READ_BYTE_COUNT; sal_Int32 nRead = mxStream->readSomeBytes( mSeqSource, READ_BYTE_COUNT );
sal_Int32 nRead = mxStream->readSomeBytes( mSeqSource, nBytesToRead );
sal_Int32 nTotalRead = nRead; sal_Int32 nTotalRead = nRead;
if( nRead == 0 ) if( nRead == 0 )
mbReachedEOF = true; mbReachedEOF = true;

View File

@ -159,8 +159,7 @@ void OTextOutputStream::writeString( const OUString& aString )
checkOutputStream(); checkOutputStream();
if( !mbEncodingInitialized ) if( !mbEncodingInitialized )
{ {
OUString aUtf8Str("utf8"); setEncoding( "utf8" );
setEncoding( aUtf8Str );
} }
if( !mbEncodingInitialized ) if( !mbEncodingInitialized )
return; return;

View File

@ -98,11 +98,11 @@ bool GnuInfo::initialize(vector<pair<OUString, OUString> > props)
OUString sJavaLibraryPath; OUString sJavaLibraryPath;
typedef vector<pair<OUString, OUString> >::const_iterator it_prop; typedef vector<pair<OUString, OUString> >::const_iterator it_prop;
OUString sVendorProperty("java.vendor"); OUString const sVendorProperty("java.vendor");
OUString sVersionProperty("java.version"); OUString const sVersionProperty("java.version");
OUString sJavaHomeProperty("java.home"); OUString const sJavaHomeProperty("java.home");
OUString sJavaLibraryPathProperty("java.library.path"); OUString const sJavaLibraryPathProperty("java.library.path");
OUString sGNUHomeProperty("gnu.classpath.home.url"); OUString const sGNUHomeProperty("gnu.classpath.home.url");
OUString sAccessProperty("javax.accessibility.assistive_technologies"); OUString sAccessProperty("javax.accessibility.assistive_technologies");
bool bVersion = false; bool bVersion = false;