From ff41cf1b8dbeb36b8824257acb5c5ba272415108 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 27 Jul 2019 21:08:23 +0200 Subject: loplugin:oncevar Change-Id: I3c014f53607a849c743a2fd1aa47d03d5af978fb Reviewed-on: https://gerrit.libreoffice.org/76495 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basegfx/source/polygon/WaveLine.cxx | 2 +- chart2/source/controller/dialogs/tp_DataSource.cxx | 3 +-- cui/source/dialogs/hangulhanjadlg.cxx | 2 +- jvmfwk/source/elements.cxx | 15 +++++---------- sc/source/ui/vba/vbaapplication.cxx | 3 +-- sfx2/source/doc/DocumentSigner.cxx | 5 ++--- svx/source/dialog/_contdlg.cxx | 3 +-- sw/source/core/text/itrform2.cxx | 2 +- sw/source/core/unocore/unotbl.cxx | 3 +-- sw/source/filter/ww8/docxattributeoutput.cxx | 3 +-- sw/source/ui/dbui/addresslistdialog.cxx | 3 +-- sw/source/uibase/shells/textfld.cxx | 2 +- test/source/container/xnamed.cxx | 3 +-- vcl/source/control/notebookbar.cxx | 3 +-- vcl/source/gdi/vectorgraphicdata.cxx | 3 +-- xmlhelp/source/treeview/tvread.cxx | 4 +--- 16 files changed, 21 insertions(+), 38 deletions(-) diff --git a/basegfx/source/polygon/WaveLine.cxx b/basegfx/source/polygon/WaveLine.cxx index 8385cef7be1b..bc85c4536250 100644 --- a/basegfx/source/polygon/WaveLine.cxx +++ b/basegfx/source/polygon/WaveLine.cxx @@ -28,7 +28,7 @@ BASEGFX_DLLPUBLIC B2DPolygon createWaveLinePolygon(basegfx::B2DRectangle const& // In quadratic bezier the curve is 1/2 of the control height // so we need to compensate for that. - double fHeightCompensation = 2.0; + constexpr double fHeightCompensation = 2.0; aPolygon.append(basegfx::B2DPoint(fLastX, fBaseY)); diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index c650e7951af6..48acb07074b9 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -82,7 +82,6 @@ bool lcl_UpdateCurrentSeriesName(weld::TreeView& rOutListBox) OUString lcl_GetSelectedRole(const weld::TreeView& rRoleListBox, bool bUITranslated = false) { - OUString aResult; int nEntry = rRoleListBox.get_selected_index(); if (nEntry != -1) { @@ -91,7 +90,7 @@ OUString lcl_GetSelectedRole(const weld::TreeView& rRoleListBox, bool bUITransla ::chart::SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(rRoleListBox.get_id(nEntry).toInt64()); return pEntry->m_sRole; } - return aResult; + return OUString(); } OUString lcl_GetSelectedRolesRange( const weld::TreeView& rRoleListBox ) diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx index 65633ab79461..2019bc6cc1f6 100644 --- a/cui/source/dialogs/hangulhanjadlg.cxx +++ b/cui/source/dialogs/hangulhanjadlg.cxx @@ -255,7 +255,7 @@ namespace svx aTextRect.AdjustTop( 1 ); aTextRect.AdjustBottom( -1 ); // calculate the text flags for the painting - DrawTextFlags nTextStyle = DrawTextFlags::Mnemonic | + constexpr DrawTextFlags nTextStyle = DrawTextFlags::Mnemonic | DrawTextFlags::Left | DrawTextFlags::VCenter; diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index 27de3532d70c..bc4a4b7554b7 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -407,8 +407,7 @@ void NodeJava::write() const //The element must exist if (m_enabled) { - OString sExpression("/jf:java/jf:enabled"); - pathObj = xmlXPathEvalExpression(reinterpret_cast(sExpression.getStr()), + pathObj = xmlXPathEvalExpression(reinterpret_cast("/jf:java/jf:enabled"), contextUser); if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)) throw FrameworkException(JFW_E_ERROR, sExcMsg); @@ -429,8 +428,7 @@ void NodeJava::write() const //The element must exist if (m_userClassPath) { - OString sExpression("/jf:java/jf:userClassPath"); - pathObj = xmlXPathEvalExpression(reinterpret_cast(sExpression.getStr()), + pathObj = xmlXPathEvalExpression(reinterpret_cast("/jf:java/jf:userClassPath"), contextUser); if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)) throw FrameworkException(JFW_E_ERROR, sExcMsg); @@ -443,8 +441,7 @@ void NodeJava::write() const //set element if (m_javaInfo) { - OString sExpression("/jf:java/jf:javaInfo"); - pathObj = xmlXPathEvalExpression(reinterpret_cast(sExpression.getStr()), + pathObj = xmlXPathEvalExpression(reinterpret_cast("/jf:java/jf:javaInfo"), contextUser); if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)) throw FrameworkException(JFW_E_ERROR, sExcMsg); @@ -455,8 +452,7 @@ void NodeJava::write() const //set element if (m_vmParameters) { - OString sExpression("/jf:java/jf:vmParameters"); - pathObj = xmlXPathEvalExpression(reinterpret_cast(sExpression.getStr()), + pathObj = xmlXPathEvalExpression(reinterpret_cast("/jf:java/jf:vmParameters"), contextUser); if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)) throw FrameworkException(JFW_E_ERROR, sExcMsg); @@ -494,8 +490,7 @@ void NodeJava::write() const //set element if (m_JRELocations) { - OString sExpression("/jf:java/jf:jreLocations"); - pathObj = xmlXPathEvalExpression(reinterpret_cast(sExpression.getStr()), + pathObj = xmlXPathEvalExpression(reinterpret_cast("/jf:java/jf:jreLocations"), contextUser); if ( ! pathObj || xmlXPathNodeSetIsEmpty(pathObj->nodesetval)) throw FrameworkException(JFW_E_ERROR, sExcMsg); diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 002e09282485..d6e0162c0aef 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -709,8 +709,7 @@ ScVbaApplication::setCursor( sal_Int32 _cursor ) { case excel::XlMousePointer::xlNorthwestArrow: { - PointerStyle nPointer( PointerStyle::Arrow ); - setCursorHelper( xModel, nPointer, false ); + setCursorHelper( xModel, PointerStyle::Arrow, false ); break; } case excel::XlMousePointer::xlWait: diff --git a/sfx2/source/doc/DocumentSigner.cxx b/sfx2/source/doc/DocumentSigner.cxx index d7b05d6acdbd..519a66a40089 100644 --- a/sfx2/source/doc/DocumentSigner.cxx +++ b/sfx2/source/doc/DocumentSigner.cxx @@ -35,8 +35,6 @@ bool DocumentSigner::signDocument(uno::Reference const& utl::UcbStreamHelper::CreateStream(m_aUrl, StreamMode::READ | StreamMode::WRITE)); uno::Reference xInputStream(new utl::OStreamWrapper(std::move(pStream))); - bool bHasValidDocumentSignature = true; - bool bResult = false; uno::Reference xWriteableZipStore; try @@ -52,7 +50,8 @@ bool DocumentSigner::signDocument(uno::Reference const& uno::Reference xSigner( security::DocumentDigitalSignatures::createWithVersionAndValidSignature( - comphelper::getProcessComponentContext(), aODFVersion, bHasValidDocumentSignature)); + comphelper::getProcessComponentContext(), aODFVersion, + /*bHasValidDocumentSignature*/ true)); try { diff --git a/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx index cc7da3c25fd6..13a3581257b7 100644 --- a/svx/source/dialog/_contdlg.cxx +++ b/svx/source/dialog/_contdlg.cxx @@ -87,7 +87,6 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic, { Bitmap aBmp; bool bContourEdgeDetect = false; - bool bContourVert = false; if ( rGraphic.GetType() == GraphicType::Bitmap ) { @@ -164,7 +163,7 @@ tools::PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic, aBmp.SetPrefSize( rGraphic.GetPrefSize() ); aBmp.SetPrefMapMode( rGraphic.GetPrefMapMode() ); - return tools::PolyPolygon( BitmapEx(aBmp).GetContour( bContourEdgeDetect, bContourVert, pRect ) ); + return tools::PolyPolygon( BitmapEx(aBmp).GetContour( bContourEdgeDetect, /*bContourVert*/false, pRect ) ); } // Loop through to super class, no virtual Methods to not become incompatible diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 2601040869aa..8047c2565906 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -861,7 +861,7 @@ namespace sw { namespace mark { return vListEntries[nCurrentIdx]; } - sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; + static const sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; return OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH); } } } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 06afc42cb7d4..b5e79f67a4dd 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -991,8 +991,7 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV // Hack to support hidden property to transfer textDirection if(rPropertyName == "FRMDirection") { - SvxFrameDirection eDir = SvxFrameDirection::Environment; - SvxFrameDirectionItem aItem(eDir, RES_FRAMEDIR); + SvxFrameDirectionItem aItem(SvxFrameDirection::Environment, RES_FRAMEDIR); aItem.PutValue(aValue, 0); m_pBox->GetFrameFormat()->SetFormatAttr(aItem); } diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 0deed645675c..fab97d156c78 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5121,7 +5121,6 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) // gather component properties OUString sDateFormat; - OUString sLocale("en-US"); uno::Reference xPropertySet(xControlModel, uno::UNO_QUERY); OString sDate; @@ -5156,7 +5155,7 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) m_pSerializer->singleElementNS(XML_w, XML_dateFormat, FSNS(XML_w, XML_val), sDateFormat.toUtf8()); m_pSerializer->singleElementNS(XML_w, XML_lid, - FSNS(XML_w, XML_val), sLocale.toUtf8()); + FSNS(XML_w, XML_val), "en-US"); m_pSerializer->singleElementNS(XML_w, XML_storeMappedDataAs, FSNS(XML_w, XML_val), "dateTime"); m_pSerializer->singleElementNS(XML_w, XML_calendar, diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx index fc1475647b82..f1d0f49a555d 100644 --- a/sw/source/ui/dbui/addresslistdialog.cxx +++ b/sw/source/ui/dbui/addresslistdialog.cxx @@ -287,8 +287,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, LoadHdl_Impl, weld::Button&, void) IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, weld::Button&, void) { - OUString sInputURL; - SwCreateAddressListDialog aDlg(m_xDialog.get(), sInputURL, m_xAddressPage->GetWizard()->GetConfigItem()); + SwCreateAddressListDialog aDlg(m_xDialog.get(), /*sInputURL*/OUString(), m_xAddressPage->GetWizard()->GetConfigItem()); if (RET_OK == aDlg.run()) { //register the URL a new datasource diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index 325c2b78fda9..8663229f4609 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -677,7 +677,7 @@ FIELD_INSERT: if(pCursorPos) { // Insert five En Space into the text field so the field has extent - sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; + static const sal_Unicode vEnSpaces[ODF_FORMFIELD_DEFAULT_LENGTH] = {8194, 8194, 8194, 8194, 8194}; bool bSuccess = rSh.GetDoc()->getIDocumentContentOperations().InsertString(*pCursorPos, OUString(vEnSpaces, ODF_FORMFIELD_DEFAULT_LENGTH)); if(bSuccess) { diff --git a/test/source/container/xnamed.cxx b/test/source/container/xnamed.cxx index 3b8023b6bc95..e2968dca9d8e 100644 --- a/test/source/container/xnamed.cxx +++ b/test/source/container/xnamed.cxx @@ -57,9 +57,8 @@ void XNamed::testSetNameByScSheetLinkObj() void XNamed::testSetNameThrowsException() { uno::Reference xNamed(init(), uno::UNO_QUERY_THROW); - OUString aTestName("NewName"); - CPPUNIT_ASSERT_THROW(xNamed->setName(aTestName), uno::RuntimeException); + CPPUNIT_ASSERT_THROW(xNamed->setName("NewName"), uno::RuntimeException); } } diff --git a/vcl/source/control/notebookbar.cxx b/vcl/source/control/notebookbar.cxx index 5d960f1d81d6..8fefed9c5841 100644 --- a/vcl/source/control/notebookbar.cxx +++ b/vcl/source/control/notebookbar.cxx @@ -32,8 +32,7 @@ static bool doesFileExist(const OUString& sUIDir, const OUString& sUIFile) { OUString sUri = sUIDir + sUIFile; osl::File file(sUri); - sal_uInt32 flag = 0; - return( file.open(flag) == osl::FileBase::E_None ); + return( file.open(0) == osl::FileBase::E_None ); } /** diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx index 19de20690e06..5beef667e367 100644 --- a/vcl/source/gdi/vectorgraphicdata.cxx +++ b/vcl/source/gdi/vectorgraphicdata.cxx @@ -290,8 +290,7 @@ const BitmapEx& VectorGraphicData::getReplacement() const BitmapChecksum VectorGraphicData::GetChecksum() const { - BitmapChecksum nRet = 0; - return vcl_get_checksum(nRet, maVectorGraphicDataArray.getConstArray(), maVectorGraphicDataArray.getLength()); + return vcl_get_checksum(0, maVectorGraphicDataArray.getConstArray(), maVectorGraphicDataArray.getLength()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx index 9dac255a8320..1aacebcf8768 100644 --- a/xmlhelp/source/treeview/tvread.cxx +++ b/xmlhelp/source/treeview/tvread.cxx @@ -773,15 +773,13 @@ TVChildTarget::getHierAccess( const Reference< XMultiServiceFactory >& sProvider if( sProvider.is() ) { Sequence< Any > seq(1); - OUString sReaderService( "com.sun.star.configuration.ConfigurationAccess" ); - seq[0] <<= OUString::createFromAscii( file ); try { xHierAccess = Reference< XHierarchicalNameAccess > - ( sProvider->createInstanceWithArguments( sReaderService,seq ), + ( sProvider->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", seq ), UNO_QUERY ); } catch( const css::uno::Exception& ) -- cgit