diff options
author | Noel <noelgrandin@gmail.com> | 2020-10-02 09:35:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-10-02 10:52:56 +0200 |
commit | c87da778e35214655c8cf825ea46cb720426c5d7 (patch) | |
tree | 9a29711f7dcdec7f5b9abf94e68c3d269e2a40db /dbaccess | |
parent | 268a49f473c1830be269a7db5f561e3681134bbd (diff) |
loplugin:reducevarscope in dbaccess
Change-Id: I22163b3303ae0c2326d079a18fa8906f38aa1d4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103810
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/qa/extras/dialog-save.cxx | 2 | ||||
-rw-r--r-- | dbaccess/qa/extras/empty-stdlib-save.cxx | 2 | ||||
-rw-r--r-- | dbaccess/qa/extras/nolib-save.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 4 | ||||
-rw-r--r-- | dbaccess/source/core/api/tablecontainer.cxx | 3 | ||||
-rw-r--r-- | dbaccess/source/core/api/viewcontainer.cxx | 3 | ||||
-rw-r--r-- | dbaccess/source/ui/app/AppController.cxx | 3 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbagrid.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/control/FieldDescControl.cxx | 3 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/UserAdmin.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/queryfilter.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/misc/UITools.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/QueryDesignView.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/querydesign/querycontroller.cxx | 2 |
14 files changed, 17 insertions, 17 deletions
diff --git a/dbaccess/qa/extras/dialog-save.cxx b/dbaccess/qa/extras/dialog-save.cxx index a336a66e31e4..af7b9fda3f8e 100644 --- a/dbaccess/qa/extras/dialog-save.cxx +++ b/dbaccess/qa/extras/dialog-save.cxx @@ -55,7 +55,6 @@ void DialogSaveTest::test() // be locked anyway: SolarMutexReleaser rel; - const OUString sStandard("Standard"); const OUString aFileName(m_directories.getURLFromWorkdir("CppunitTest/testDialogSave.odb")); { uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName); @@ -68,6 +67,7 @@ void DialogSaveTest::test() uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries()); CPPUNIT_ASSERT(xStorDlgLib.is()); uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW); + const OUString sStandard("Standard"); xBasLib->loadLibrary(sStandard); CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard)); // the whole point of this test is to test the "save" operation diff --git a/dbaccess/qa/extras/empty-stdlib-save.cxx b/dbaccess/qa/extras/empty-stdlib-save.cxx index cce32ed08885..ea9c660a4e87 100644 --- a/dbaccess/qa/extras/empty-stdlib-save.cxx +++ b/dbaccess/qa/extras/empty-stdlib-save.cxx @@ -53,7 +53,6 @@ void DialogSaveTest::test() // be locked anyway: SolarMutexReleaser rel; - const OUString sStandard("Standard"); const OUString aFileName(m_directories.getURLFromWorkdir("CppunitTest/testEmptyStdlibSave.odb")); { uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName); @@ -66,6 +65,7 @@ void DialogSaveTest::test() uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries()); CPPUNIT_ASSERT(xStorDlgLib.is()); uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW); + const OUString sStandard("Standard"); xBasLib->loadLibrary(sStandard); xDlgLib->loadLibrary(sStandard); CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard)); diff --git a/dbaccess/qa/extras/nolib-save.cxx b/dbaccess/qa/extras/nolib-save.cxx index b42171ce2676..5914511e6dbe 100644 --- a/dbaccess/qa/extras/nolib-save.cxx +++ b/dbaccess/qa/extras/nolib-save.cxx @@ -53,7 +53,6 @@ void DialogSaveTest::test() // be locked anyway: SolarMutexReleaser rel; - const OUString sStandard("Standard"); const OUString aFileName(m_directories.getURLFromWorkdir("CppunitTest/testNolibSave.odb")); { uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFileName); @@ -66,6 +65,7 @@ void DialogSaveTest::test() uno::Reference< script::XStorageBasedLibraryContainer > xStorDlgLib(xDocScr->getDialogLibraries()); CPPUNIT_ASSERT(xStorDlgLib.is()); uno::Reference< script::XLibraryContainer > xDlgLib(xStorDlgLib, UNO_QUERY_THROW); + const OUString sStandard("Standard"); xBasLib->loadLibrary(sStandard); xDlgLib->loadLibrary(sStandard); CPPUNIT_ASSERT(xBasLib->isLibraryLoaded(sStandard)); diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 06745cacabcc..6ca83d6d9879 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -1314,7 +1314,7 @@ OUString OSingleSelectQueryComposer::getTableAlias(const Reference< XPropertySet OUString sReturn; if(m_pTables && m_pTables->getCount() > 1) { - OUString aCatalog,aSchema,aTable,aComposedName,aColumnName; + OUString aCatalog,aSchema,aTable,aColumnName; if(column->getPropertySetInfo()->hasPropertyByName(PROPERTY_CATALOGNAME)) column->getPropertyValue(PROPERTY_CATALOGNAME) >>= aCatalog; if(column->getPropertySetInfo()->hasPropertyByName(PROPERTY_SCHEMANAME)) @@ -1343,7 +1343,7 @@ OUString OSingleSelectQueryComposer::getTableAlias(const Reference< XPropertySet } else { - aComposedName = ::dbtools::composeTableName( m_xMetaData, aCatalog, aSchema, aTable, false, ::dbtools::EComposeRule::InDataManipulation ); + OUString aComposedName = ::dbtools::composeTableName( m_xMetaData, aCatalog, aSchema, aTable, false, ::dbtools::EComposeRule::InDataManipulation ); // Is this the right case for the table name? // Else, look for it with different case, if applicable. diff --git a/dbaccess/source/core/api/tablecontainer.cxx b/dbaccess/source/core/api/tablecontainer.cxx index 61405b41e464..2da2c3350a91 100644 --- a/dbaccess/source/core/api/tablecontainer.cxx +++ b/dbaccess/source/core/api/tablecontainer.cxx @@ -335,12 +335,13 @@ void OTableContainer::dropObject(sal_Int32 _nPos, const OUString& _sElementName) xDrop->dropByName(_sElementName); else { - OUString sCatalog,sSchema,sTable,sComposedName; + OUString sComposedName; bool bIsView = false; Reference<XPropertySet> xTable(getObject(_nPos),UNO_QUERY); if ( xTable.is() && m_xMetaData.is() ) { + OUString sSchema,sCatalog,sTable; if (m_xMetaData->supportsCatalogsInTableDefinitions()) xTable->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog; if (m_xMetaData->supportsSchemasInTableDefinitions()) diff --git a/dbaccess/source/core/api/viewcontainer.cxx b/dbaccess/source/core/api/viewcontainer.cxx index 690df713923d..796e23c9f49d 100644 --- a/dbaccess/source/core/api/viewcontainer.cxx +++ b/dbaccess/source/core/api/viewcontainer.cxx @@ -154,11 +154,12 @@ void OViewContainer::dropObject(sal_Int32 _nPos, const OUString& _sElementName) xDrop->dropByName(_sElementName); else { - OUString sCatalog,sSchema,sTable,sComposedName; + OUString sComposedName; Reference<XPropertySet> xTable(getObject(_nPos),UNO_QUERY); if ( xTable.is() ) { + OUString sCatalog,sSchema,sTable; xTable->getPropertyValue(PROPERTY_CATALOGNAME) >>= sCatalog; xTable->getPropertyValue(PROPERTY_SCHEMANAME) >>= sSchema; xTable->getPropertyValue(PROPERTY_NAME) >>= sTable; diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index f8818f11d7ed..b6c1c16ffca5 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -2338,10 +2338,9 @@ sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const if ( nAction != DND_ACTION_NONE ) { auto xHitEntry = pView->getEntry(_rEvt.maPosPixel); - OUString sName; if (xHitEntry) { - sName = pView->getQualifiedName(xHitEntry.get()); + OUString sName = pView->getQualifiedName(xHitEntry.get()); if ( !sName.isEmpty() ) { Reference< XHierarchicalNameAccess > xContainer(getElements(pView->getElementType()),UNO_QUERY); diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 13b6ceac29cd..5d86042a92c6 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -1126,9 +1126,9 @@ void SbaGridControl::DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos) // the old implementation copied a SBA_FIELDDATAEXCHANGE_FORMAT, too, (which was rather expensive to obtain), // but we have no client for this DnD format anymore (the mail part of SO 5.2 was the only client) - OUString sCellText; try { + OUString sCellText; Reference< XGridFieldDataSupplier > xFieldData(static_cast< XGridPeer* >(GetPeer()), UNO_QUERY); Sequence<sal_Bool> aSupportingText = xFieldData->queryFieldDataType(cppu::UnoType<decltype(sCellText)>::get()); if (aSupportingText.getConstArray()[nColumnPos]) diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index 28f3c9662500..f0d9b9ee4468 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -1278,11 +1278,10 @@ OUString OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldD bool bCheck = !_bCheck || _pFieldDescr->GetControlDefault().hasValue(); if ( bCheck ) { - sal_uInt32 nFormatKey; - try { double nValue = 0.0; + sal_uInt32 nFormatKey; bool bTextFormat = isTextFormat(_pFieldDescr,nFormatKey); if ( _pFieldDescr->GetControlDefault() >>= sDefault ) { diff --git a/dbaccess/source/ui/dlg/UserAdmin.cxx b/dbaccess/source/ui/dlg/UserAdmin.cxx index 3e63f9424fce..a3e24939709f 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.cxx +++ b/dbaccess/source/ui/dlg/UserAdmin.cxx @@ -220,10 +220,10 @@ IMPL_LINK(OUserAdmin, UserHdl, weld::Button&, rButton, void) m_xUsers->getByName(sName) >>= xUser; if(xUser.is()) { - OUString sNewPassword,sOldPassword; OPasswordDialog aDlg(GetFrameWeld(), sName); if (aDlg.run() == RET_OK) { + OUString sNewPassword,sOldPassword; sNewPassword = aDlg.GetNewPassword(); sOldPassword = aDlg.GetOldPassword(); diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx index 5eeb86ef0869..56db11946315 100644 --- a/dbaccess/source/ui/dlg/queryfilter.cxx +++ b/dbaccess/source/ui/dlg/queryfilter.cxx @@ -282,12 +282,12 @@ bool DlgFilterCrit::getCondition(const weld::ComboBox& _rField,const weld::Combo bool bHaving = false; try { - OUString sTableName; _rFilter.Name = _rField.get_active_text(); Reference< XPropertySet > xColumn = getQueryColumn(_rFilter.Name); if ( xColumn.is() ) { bool bFunction = false; + OUString sTableName; Reference< XPropertySetInfo > xInfo = xColumn->getPropertySetInfo(); if ( xInfo->hasPropertyByName(PROPERTY_REALNAME) ) { diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 46b6c83f5692..d75ea241ed95 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -1285,9 +1285,9 @@ bool insertHierachyElement(weld::Window* pParent, const Reference< XComponentCon if ( !_bMove || sNewName.isEmpty() ) { - OUString sTargetName,sLabel; if ( sNewName.isEmpty() || xNameAccess->hasByName(sNewName) ) { + OUString sLabel, sTargetName; if ( !sNewName.isEmpty() ) sTargetName = sNewName; else diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx index 487d6bce42ce..96e44ab6e68d 100644 --- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx +++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx @@ -238,7 +238,6 @@ namespace bool bErg = false; OUString aTableRange,aColumnName; - sal_uInt16 nCntAccount; ::connectivity::OSQLParseTreeIterator& rParseIter = static_cast<OQueryController&>(_pView->getController()).getParseIterator(); rParseIter.getColumnRange( pColumnRef, aColumnName, aTableRange ); @@ -249,6 +248,7 @@ namespace } if ( !bErg ) { + sal_uInt16 nCntAccount; bErg = static_cast<OQueryTableView*>(_pView->getTableView())->FindTableFromField(aColumnName, _rDragInfo, nCntAccount); if ( !bErg ) bErg = _pView->HasFieldByAliasName(aColumnName, _rDragInfo); diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx index 31c67a71f124..b6ef3fedff6c 100644 --- a/dbaccess/source/ui/querydesign/querycontroller.cxx +++ b/dbaccess/source/ui/querydesign/querycontroller.cxx @@ -463,7 +463,6 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& SQLExceptionInfo aError; try { - OUString aErrorMsg; setStatement_fireEvent( getContainer()->getStatement() ); if(m_sStatement.isEmpty() && m_pSqlIterator) { @@ -475,6 +474,7 @@ void OQueryController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& } else { + OUString aErrorMsg; std::unique_ptr<::connectivity::OSQLParseNode> pNode = m_aSqlParser.parseTree(aErrorMsg,m_sStatement,m_bGraphicalDesign); if ( pNode ) { |