loplugin:reducevarscope in comphelper,connectivity

Change-Id: Ia70d4963fb892120cc8f79597b46a8fe67b540a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103762
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel
2020-10-01 14:02:32 +02:00
committed by Noel Grandin
parent a2d3b5721f
commit 9bac19e37f
11 changed files with 28 additions and 34 deletions

View File

@@ -66,7 +66,6 @@ namespace comphelper {
if ( !_rxDocument.is() ) if ( !_rxDocument.is() )
return sTitle; return sTitle;
OUString sDocURL;
try try
{ {
// 1. ask the model and the controller for their XTitle::getTitle // 1. ask the model and the controller for their XTitle::getTitle
@@ -81,7 +80,7 @@ namespace comphelper {
// work around a problem with embedded objects, which sometimes return // work around a problem with embedded objects, which sometimes return
// private:object as URL // private:object as URL
sDocURL = _rxDocument->getURL(); OUString sDocURL = _rxDocument->getURL();
if ( sDocURL.startsWithIgnoreAsciiCase( "private:" ) ) if ( sDocURL.startsWithIgnoreAsciiCase( "private:" ) )
sDocURL.clear(); sDocURL.clear();

View File

@@ -121,7 +121,6 @@ void SAL_CALL OInstanceLocker::initialize( const uno::Sequence< uno::Any >& aArg
uno::Reference< uno::XInterface > xInstance; uno::Reference< uno::XInterface > xInstance;
uno::Reference< embed::XActionsApproval > xApproval; uno::Reference< embed::XActionsApproval > xApproval;
sal_Int32 nModes = 0;
try try
{ {
@@ -138,6 +137,7 @@ void SAL_CALL OInstanceLocker::initialize( const uno::Sequence< uno::Any >& aArg
uno::Reference< uno::XInterface >(), uno::Reference< uno::XInterface >(),
0 ); 0 );
sal_Int32 nModes = 0;
if ( if (
!( aArguments[1] >>= nModes ) || !( aArguments[1] >>= nModes ) ||
( (

View File

@@ -66,11 +66,11 @@ namespace connectivity
{ {
OSQLParser aParser( m_xContext ); OSQLParser aParser( m_xContext );
OUString sErrorMessage; OUString sErrorMessage;
OUString sNewSql;
std::unique_ptr<OSQLParseNode> pNode = aParser.parseTree(sErrorMessage,_sText); std::unique_ptr<OSQLParseNode> pNode = aParser.parseTree(sErrorMessage,_sText);
if(pNode) if(pNode)
{ // special handling for parameters { // special handling for parameters
OSQLParseNode::substituteParameterNames(pNode.get()); OSQLParseNode::substituteParameterNames(pNode.get());
OUString sNewSql;
pNode->parseNodeToStr( sNewSql, xConnection ); pNode->parseNodeToStr( sNewSql, xConnection );
sRet = sNewSql; sRet = sNewSql;
} }

View File

@@ -171,7 +171,7 @@ bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,bool _bRetrieveData)
{ {
// bookmark isn't known yet // bookmark isn't known yet
// start at the last known position // start at the last known position
sal_Int32 nCurPos = 0,nLastBookmark = 1; sal_Int32 nCurPos = 0;
if ( m_aBookmarksPositions.empty() ) if ( m_aBookmarksPositions.empty() )
{ {
bDataFound = m_pHelper->move(IResultSetHelper::FIRST, 0, _bRetrieveData ); bDataFound = m_pHelper->move(IResultSetHelper::FIRST, 0, _bRetrieveData );
@@ -185,7 +185,7 @@ bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,bool _bRetrieveData)
} // if ( m_aBookmarksPositions.empty() ) } // if ( m_aBookmarksPositions.empty() )
else else
{ {
nLastBookmark = (*m_aBookmarksPositions.rbegin())/*->first*/; sal_Int32 nLastBookmark = *m_aBookmarksPositions.rbegin()/*->first*/;
nCurPos = /*(**/m_aBookmarksPositions.size()/*->second*/; nCurPos = /*(**/m_aBookmarksPositions.size()/*->second*/;
nNewPos = nNewPos - nCurPos; nNewPos = nNewPos - nCurPos;
bDataFound = m_pHelper->move(IResultSetHelper::BOOKMARK, nLastBookmark, _bRetrieveData); bDataFound = m_pHelper->move(IResultSetHelper::BOOKMARK, nLastBookmark, _bRetrieveData);

View File

@@ -917,7 +917,7 @@ Reference< XNumberFormatsSupplier> getNumberFormats(
// ask the parent of the connection (should be a DatabaseAccess) // ask the parent of the connection (should be a DatabaseAccess)
Reference< XNumberFormatsSupplier> xReturn; Reference< XNumberFormatsSupplier> xReturn;
Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY); Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY);
OUString sPropFormatsSupplier( "NumberFormatsSupplier" ); static const OUStringLiteral sPropFormatsSupplier( u"NumberFormatsSupplier" );
if (xConnAsChild.is()) if (xConnAsChild.is())
{ {
Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY); Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY);
@@ -952,20 +952,20 @@ try
Property* pNewProps = aNewProperties.getArray(); Property* pNewProps = aNewProperties.getArray();
OUString sPropFormatsSupplier("FormatsSupplier"); static const OUStringLiteral sPropFormatsSupplier(u"FormatsSupplier");
OUString sPropCurrencySymbol("CurrencySymbol"); static const OUStringLiteral sPropCurrencySymbol(u"CurrencySymbol");
OUString sPropDecimals("Decimals"); static const OUStringLiteral sPropDecimals(u"Decimals");
OUString sPropEffectiveMin("EffectiveMin"); static const OUStringLiteral sPropEffectiveMin(u"EffectiveMin");
OUString sPropEffectiveMax("EffectiveMax"); static const OUStringLiteral sPropEffectiveMax(u"EffectiveMax");
OUString sPropEffectiveDefault("EffectiveDefault"); static const OUStringLiteral sPropEffectiveDefault(u"EffectiveDefault");
OUString sPropDefaultText("DefaultText"); static const OUStringLiteral sPropDefaultText(u"DefaultText");
OUString sPropDefaultDate("DefaultDate"); static const OUStringLiteral sPropDefaultDate(u"DefaultDate");
OUString sPropDefaultTime("DefaultTime"); static const OUStringLiteral sPropDefaultTime(u"DefaultTime");
OUString sPropValueMin("ValueMin"); static const OUStringLiteral sPropValueMin(u"ValueMin");
OUString sPropValueMax("ValueMax"); static const OUStringLiteral sPropValueMax(u"ValueMax");
OUString sPropDecimalAccuracy("DecimalAccuracy"); static const OUStringLiteral sPropDecimalAccuracy(u"DecimalAccuracy");
OUString sPropClassId("ClassId"); static const OUStringLiteral sPropClassId(u"ClassId");
OUString sFormattedServiceName( "com.sun.star.form.component.FormattedField" ); static const OUStringLiteral sFormattedServiceName( u"com.sun.star.form.component.FormattedField" );
for (const Property& rOldProp : aOldProperties) for (const Property& rOldProp : aOldProperties)
{ {

View File

@@ -153,11 +153,10 @@ void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,css::util::DateTi
{ {
if ( _nJulianDate ) if ( _nJulianDate )
{ {
sal_Int32 ialp;
sal_Int32 ka = _nJulianDate; sal_Int32 ka = _nJulianDate;
if ( _nJulianDate >= 2299161 ) if ( _nJulianDate >= 2299161 )
{ {
ialp = static_cast<sal_Int32>( (static_cast<double>(_nJulianDate) - 1867216.25 ) / 36524.25 ); sal_Int32 ialp = static_cast<sal_Int32>( (static_cast<double>(_nJulianDate) - 1867216.25 ) / 36524.25 );
ka = _nJulianDate + 1 + ialp - ( ialp >> 2 ); ka = _nJulianDate + 1 + ialp - ( ialp >> 2 );
} }
sal_Int32 kb = ka + 1524; sal_Int32 kb = ka + 1524;
@@ -2137,7 +2136,6 @@ void ODbaseTable::alterColumn(sal_Int32 index,
if(index < 0 || index >= m_xColumns->getCount()) if(index < 0 || index >= m_xColumns->getCount())
throw IndexOutOfBoundsException(OUString::number(index),*this); throw IndexOutOfBoundsException(OUString::number(index),*this);
ODbaseTable* pNewTable = nullptr;
try try
{ {
OSL_ENSURE(descriptor.is(),"ODbaseTable::alterColumn: descriptor can not be null!"); OSL_ENSURE(descriptor.is(),"ODbaseTable::alterColumn: descriptor can not be null!");
@@ -2154,7 +2152,7 @@ void ODbaseTable::alterColumn(sal_Int32 index,
OUString sTempName = createTempFile(); OUString sTempName = createTempFile();
pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection)); ODbaseTable* pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection));
Reference<XPropertySet> xHoldTable = pNewTable; Reference<XPropertySet> xHoldTable = pNewTable;
pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(sTempName)); pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(sTempName));
Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY); Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY);

View File

@@ -239,10 +239,10 @@ namespace connectivity
); );
aProperties.put( "SystemProperties", Sequence< NamedValue >( &aPermittedClasses, 1 ) ); aProperties.put( "SystemProperties", Sequence< NamedValue >( &aPermittedClasses, 1 ) );
const OUString sProperties( "properties" );
OUString sMessage; OUString sMessage;
try try
{ {
const OUString sProperties( "properties" );
if ( !bIsNewDatabase && xStorage->isStreamElement(sProperties) ) if ( !bIsNewDatabase && xStorage->isStreamElement(sProperties) )
{ {
Reference<XStream > xStream = xStorage->openStreamElement(sProperties,ElementModes::READ); Reference<XStream > xStream = xStorage->openStreamElement(sProperties,ElementModes::READ);

View File

@@ -129,7 +129,6 @@ sal_Int32 SAL_CALL java_io_Reader::readBytes( css::uno::Sequence< sal_Int8 >& aD
sal_Int32 nCharsToRead = (nBytesToRead + 1)/2; sal_Int32 nCharsToRead = (nBytesToRead + 1)/2;
jint outChars(0);
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!"); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
{ {
@@ -139,7 +138,7 @@ sal_Int32 SAL_CALL java_io_Reader::readBytes( css::uno::Sequence< sal_Int8 >& aD
// Java-Call // Java-Call
static jmethodID mID(nullptr); static jmethodID mID(nullptr);
obtainMethodId_throwRuntime(t.pEnv, cMethodName,cSignature, mID); obtainMethodId_throwRuntime(t.pEnv, cMethodName,cSignature, mID);
outChars = t.pEnv->CallIntMethod( object, mID, pCharArray, 0, nCharsToRead ); jint outChars = t.pEnv->CallIntMethod( object, mID, pCharArray, 0, nCharsToRead );
if ( !outChars ) if ( !outChars )
{ {
if(nBytesWritten==0) if(nBytesWritten==0)

View File

@@ -288,7 +288,6 @@ Reference< XRef > SAL_CALL java_sql_ResultSet::getRef( sal_Int32 columnIndex )
Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& typeMap ) Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& typeMap )
{ {
jobject out(nullptr);
Any aRet; Any aRet;
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!"); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
{ {
@@ -307,7 +306,7 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen
obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID); obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
} }
out = t.pEnv->CallObjectMethodA( object, mID, args); jobject out = t.pEnv->CallObjectMethodA( object, mID, args);
t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l)); t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l));
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
// and clean up // and clean up

View File

@@ -37,7 +37,6 @@ using namespace ::com::sun::star::lang;
void java_util_Properties::setProperty(const OUString& key, const OUString& value) void java_util_Properties::setProperty(const OUString& key, const OUString& value)
{ {
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!"); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
jobject out(nullptr);
{ {
jvalue args[2]; jvalue args[2];
@@ -50,7 +49,7 @@ void java_util_Properties::setProperty(const OUString& key, const OUString& valu
// Turn off Java-Call // Turn off Java-Call
static jmethodID mID(nullptr); static jmethodID mID(nullptr);
obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID); obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
out = t.pEnv->CallObjectMethod(object, mID, args[0].l,args[1].l); jobject out = t.pEnv->CallObjectMethod(object, mID, args[0].l,args[1].l);
ThrowSQLException(t.pEnv,nullptr); ThrowSQLException(t.pEnv,nullptr);
t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l)); t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l));
t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l)); t.pEnv->DeleteLocalRef(static_cast<jstring>(args[0].l));

View File

@@ -104,10 +104,10 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :
catch(const Exception&) catch(const Exception&)
{ // we don't want our result destroy here { // we don't want our result destroy here
} }
SQLULEN nCurType = 0;
try try
{ {
nCurType = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE); SQLULEN nCurType = getStmtOption<SQLULEN, SQL_IS_UINTEGER>(SQL_ATTR_CURSOR_TYPE);
SQLUINTEGER nValueLen = m_pStatement->getCursorProperties(nCurType,false); SQLUINTEGER nValueLen = m_pStatement->getCursorProperties(nCurType,false);
if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS || if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS ||
(nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT) (nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT)