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() )
return sTitle;
OUString sDocURL;
try
{
// 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
// private:object as URL
sDocURL = _rxDocument->getURL();
OUString sDocURL = _rxDocument->getURL();
if ( sDocURL.startsWithIgnoreAsciiCase( "private:" ) )
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< embed::XActionsApproval > xApproval;
sal_Int32 nModes = 0;
try
{
@ -138,6 +137,7 @@ void SAL_CALL OInstanceLocker::initialize( const uno::Sequence< uno::Any >& aArg
uno::Reference< uno::XInterface >(),
0 );
sal_Int32 nModes = 0;
if (
!( aArguments[1] >>= nModes ) ||
(

View File

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

View File

@ -171,7 +171,7 @@ bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,bool _bRetrieveData)
{
// bookmark isn't known yet
// start at the last known position
sal_Int32 nCurPos = 0,nLastBookmark = 1;
sal_Int32 nCurPos = 0;
if ( m_aBookmarksPositions.empty() )
{
bDataFound = m_pHelper->move(IResultSetHelper::FIRST, 0, _bRetrieveData );
@ -185,7 +185,7 @@ bool OSkipDeletedSet::moveAbsolute(sal_Int32 _nPos,bool _bRetrieveData)
} // if ( m_aBookmarksPositions.empty() )
else
{
nLastBookmark = (*m_aBookmarksPositions.rbegin())/*->first*/;
sal_Int32 nLastBookmark = *m_aBookmarksPositions.rbegin()/*->first*/;
nCurPos = /*(**/m_aBookmarksPositions.size()/*->second*/;
nNewPos = nNewPos - nCurPos;
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)
Reference< XNumberFormatsSupplier> xReturn;
Reference< XChild> xConnAsChild(_rxConn, UNO_QUERY);
OUString sPropFormatsSupplier( "NumberFormatsSupplier" );
static const OUStringLiteral sPropFormatsSupplier( u"NumberFormatsSupplier" );
if (xConnAsChild.is())
{
Reference< XPropertySet> xConnParentProps(xConnAsChild->getParent(), UNO_QUERY);
@ -952,20 +952,20 @@ try
Property* pNewProps = aNewProperties.getArray();
OUString sPropFormatsSupplier("FormatsSupplier");
OUString sPropCurrencySymbol("CurrencySymbol");
OUString sPropDecimals("Decimals");
OUString sPropEffectiveMin("EffectiveMin");
OUString sPropEffectiveMax("EffectiveMax");
OUString sPropEffectiveDefault("EffectiveDefault");
OUString sPropDefaultText("DefaultText");
OUString sPropDefaultDate("DefaultDate");
OUString sPropDefaultTime("DefaultTime");
OUString sPropValueMin("ValueMin");
OUString sPropValueMax("ValueMax");
OUString sPropDecimalAccuracy("DecimalAccuracy");
OUString sPropClassId("ClassId");
OUString sFormattedServiceName( "com.sun.star.form.component.FormattedField" );
static const OUStringLiteral sPropFormatsSupplier(u"FormatsSupplier");
static const OUStringLiteral sPropCurrencySymbol(u"CurrencySymbol");
static const OUStringLiteral sPropDecimals(u"Decimals");
static const OUStringLiteral sPropEffectiveMin(u"EffectiveMin");
static const OUStringLiteral sPropEffectiveMax(u"EffectiveMax");
static const OUStringLiteral sPropEffectiveDefault(u"EffectiveDefault");
static const OUStringLiteral sPropDefaultText(u"DefaultText");
static const OUStringLiteral sPropDefaultDate(u"DefaultDate");
static const OUStringLiteral sPropDefaultTime(u"DefaultTime");
static const OUStringLiteral sPropValueMin(u"ValueMin");
static const OUStringLiteral sPropValueMax(u"ValueMax");
static const OUStringLiteral sPropDecimalAccuracy(u"DecimalAccuracy");
static const OUStringLiteral sPropClassId(u"ClassId");
static const OUStringLiteral sFormattedServiceName( u"com.sun.star.form.component.FormattedField" );
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 )
{
sal_Int32 ialp;
sal_Int32 ka = _nJulianDate;
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 );
}
sal_Int32 kb = ka + 1524;
@ -2137,7 +2136,6 @@ void ODbaseTable::alterColumn(sal_Int32 index,
if(index < 0 || index >= m_xColumns->getCount())
throw IndexOutOfBoundsException(OUString::number(index),*this);
ODbaseTable* pNewTable = nullptr;
try
{
OSL_ENSURE(descriptor.is(),"ODbaseTable::alterColumn: descriptor can not be null!");
@ -2154,7 +2152,7 @@ void ODbaseTable::alterColumn(sal_Int32 index,
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;
pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(sTempName));
Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY);

View File

@ -239,10 +239,10 @@ namespace connectivity
);
aProperties.put( "SystemProperties", Sequence< NamedValue >( &aPermittedClasses, 1 ) );
const OUString sProperties( "properties" );
OUString sMessage;
try
{
const OUString sProperties( "properties" );
if ( !bIsNewDatabase && xStorage->isStreamElement(sProperties) )
{
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;
jint outChars(0);
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
static jmethodID mID(nullptr);
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(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 )
{
jobject out(nullptr);
Any aRet;
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);
}
out = t.pEnv->CallObjectMethodA( object, mID, args);
jobject out = t.pEnv->CallObjectMethodA( object, mID, args);
t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].l));
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
// 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)
{
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
jobject out(nullptr);
{
jvalue args[2];
@ -50,7 +49,7 @@ void java_util_Properties::setProperty(const OUString& key, const OUString& valu
// Turn off Java-Call
static jmethodID mID(nullptr);
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);
t.pEnv->DeleteLocalRef(static_cast<jstring>(args[1].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&)
{ // we don't want our result destroy here
}
SQLULEN nCurType = 0;
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);
if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS ||
(nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT)