diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-25 14:08:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-25 21:46:32 +0200 |
commit | ff3bdde2527123fc9e011ff0d93e958174632186 (patch) | |
tree | 07d86dceca57fc1c85ad208fb436d70ac7e648ab | |
parent | 305285bd1450bb847058a877b0dc2adface4e521 (diff) |
loplugin:passstuffbyref
Change-Id: I785e96599bbda029adf4698d11d7f981750dec07
Reviewed-on: https://gerrit.libreoffice.org/54802
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
27 files changed, 44 insertions, 40 deletions
diff --git a/basegfx/source/polygon/b3dpolygon.cxx b/basegfx/source/polygon/b3dpolygon.cxx index 1f2e6ebea67a..58be07cfe897 100644 --- a/basegfx/source/polygon/b3dpolygon.cxx +++ b/basegfx/source/polygon/b3dpolygon.cxx @@ -1442,7 +1442,7 @@ namespace basegfx return mpPolygon->count(); } - basegfx::B3DPoint B3DPolygon::getB3DPoint(sal_uInt32 nIndex) const + basegfx::B3DPoint const & B3DPolygon::getB3DPoint(sal_uInt32 nIndex) const { OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)"); @@ -1457,7 +1457,7 @@ namespace basegfx mpPolygon->setPoint(nIndex, rValue); } - BColor B3DPolygon::getBColor(sal_uInt32 nIndex) const + BColor const & B3DPolygon::getBColor(sal_uInt32 nIndex) const { OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)"); @@ -1488,7 +1488,7 @@ namespace basegfx return mpPolygon->getNormal(); } - B3DVector B3DPolygon::getNormal(sal_uInt32 nIndex) const + B3DVector const & B3DPolygon::getNormal(sal_uInt32 nIndex) const { OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)"); @@ -1520,7 +1520,7 @@ namespace basegfx mpPolygon->clearNormals(); } - B2DPoint B3DPolygon::getTextureCoordinate(sal_uInt32 nIndex) const + B2DPoint const & B3DPolygon::getTextureCoordinate(sal_uInt32 nIndex) const { OSL_ENSURE(nIndex < mpPolygon->count(), "B3DPolygon access outside range (!)"); diff --git a/basegfx/source/polygon/b3dpolypolygon.cxx b/basegfx/source/polygon/b3dpolypolygon.cxx index b7ea0b36631e..7cb977065e0f 100644 --- a/basegfx/source/polygon/b3dpolypolygon.cxx +++ b/basegfx/source/polygon/b3dpolypolygon.cxx @@ -229,7 +229,7 @@ namespace basegfx return mpPolyPolygon->count(); } - B3DPolygon B3DPolyPolygon::getB3DPolygon(sal_uInt32 nIndex) const + B3DPolygon const & B3DPolyPolygon::getB3DPolygon(sal_uInt32 nIndex) const { OSL_ENSURE(nIndex < mpPolyPolygon->count(), "B3DPolyPolygon access outside range (!)"); diff --git a/basic/source/runtime/inputbox.cxx b/basic/source/runtime/inputbox.cxx index ae7302f14c21..b3d495d5bead 100644 --- a/basic/source/runtime/inputbox.cxx +++ b/basic/source/runtime/inputbox.cxx @@ -42,7 +42,7 @@ class SvRTLInputBox : public weld::GenericDialogController public: SvRTLInputBox(weld::Window* pParent, const OUString& rPrompt, const OUString& rTitle, const OUString& rDefault, long nXTwips, long nYTwips ); - OUString GetText() const { return m_aText; } + OUString const & GetText() const { return m_aText; } }; SvRTLInputBox::SvRTLInputBox(weld::Window* pParent, const OUString& rPrompt, diff --git a/compilerplugins/clang/passstuffbyref.cxx b/compilerplugins/clang/passstuffbyref.cxx index 8cfae946f041..61bd3cf0f00c 100644 --- a/compilerplugins/clang/passstuffbyref.cxx +++ b/compilerplugins/clang/passstuffbyref.cxx @@ -274,6 +274,10 @@ void PassStuffByRef::checkReturnValue(const FunctionDecl * functionDecl, const C if (startswith(type.getAsString(), "struct o3tl::strong_int")) { return; } + // extremely simple class, might as well pass by value + if (loplugin::TypeCheck(functionDecl->getReturnType()).Class("Color")) { + return; + } // functionDecl->dump(); diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index 5af66b617022..d236d812d603 100755 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -214,7 +214,7 @@ void SvxCharacterMap::SetChar( sal_UCS4 c ) sal_UCS4 SvxCharacterMap::GetChar() const { - return (m_aShowChar.GetText()).toChar(); + return m_aShowChar.GetText().toChar(); } void SvxCharacterMap::DisableFontSelection() diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx index e99a0f81573a..9e926f20484b 100644 --- a/cui/source/inc/cuicharmap.hxx +++ b/cui/source/inc/cuicharmap.hxx @@ -58,9 +58,9 @@ public: SvxShowText(const VclPtr<VirtualDevice>& rVirDev); void SetFont(const vcl::Font& rFont); - vcl::Font GetFont() const { return m_aFont; } + vcl::Font const & GetFont() const { return m_aFont; } void SetText(const OUString& rText); - OUString GetText() const { return m_sText; } + OUString const & GetText() const { return m_sText; } void SetCentered(bool bCenter) { mbCenter = bCenter; } Size get_preferred_size() const { return GetDrawingArea()->get_preferred_size(); } diff --git a/cui/source/inc/postdlg.hxx b/cui/source/inc/postdlg.hxx index 0434f19b1f9d..45e5c9ea62da 100644 --- a/cui/source/inc/postdlg.hxx +++ b/cui/source/inc/postdlg.hxx @@ -71,7 +71,7 @@ public: { m_xDialog->set_title(rTitle); } - std::shared_ptr<weld::Dialog> GetDialog() + std::shared_ptr<weld::Dialog> const & GetDialog() { return m_xDialog; } diff --git a/dbaccess/source/filter/hsqldb/alterparser.hxx b/dbaccess/source/filter/hsqldb/alterparser.hxx index 12b496a55df9..6f2e3535307e 100644 --- a/dbaccess/source/filter/hsqldb/alterparser.hxx +++ b/dbaccess/source/filter/hsqldb/alterparser.hxx @@ -32,9 +32,9 @@ private: protected: AlterAction getActionType() const { return m_eAction; } - OUString getColumnName() const { return m_sColumnName; } + OUString const& getColumnName() const { return m_sColumnName; } sal_Int32 getIdentityParam() const { return m_nIdentityParam; } - OUString getStatement() const { return m_sStmt; } + OUString const& getStatement() const { return m_sStmt; } public: virtual ~AlterStmtParser() = default; @@ -42,7 +42,7 @@ public: /** * @return name of the table which is to be created. */ - OUString getTableName() const { return m_sTableName; } + OUString const& getTableName() const { return m_sTableName; } void parse(const OUString& sSql); diff --git a/dbaccess/source/filter/hsqldb/columndef.hxx b/dbaccess/source/filter/hsqldb/columndef.hxx index 1700f7b29554..b356d3906b37 100644 --- a/dbaccess/source/filter/hsqldb/columndef.hxx +++ b/dbaccess/source/filter/hsqldb/columndef.hxx @@ -32,14 +32,14 @@ public: bool bPrimary = false, sal_Int32 nAutoIncr = -1, bool bNullable = true, bool bCaseInsensitive = false); - OUString getName() const { return m_sName; } + OUString const& getName() const { return m_sName; } sal_Int32 getDataType() const { return m_eType; } bool isPrimaryKey() const { return m_bPrimaryKey; } bool isNullable() const { return m_bNullable; } bool isAutoIncremental() const { return m_nAutoIncrement >= 0; } bool isCaseInsensitive() const { return m_bCaseInsensitive; } sal_Int32 getStartValue() const { return m_nAutoIncrement; } - const std::vector<sal_Int32> getParams() const { return m_aParams; } + const std::vector<sal_Int32>& getParams() const { return m_aParams; } }; } diff --git a/dbaccess/source/filter/hsqldb/createparser.hxx b/dbaccess/source/filter/hsqldb/createparser.hxx index 41db73797c2e..327cab869f01 100644 --- a/dbaccess/source/filter/hsqldb/createparser.hxx +++ b/dbaccess/source/filter/hsqldb/createparser.hxx @@ -34,12 +34,12 @@ public: /** * @return name of the table which is to be created. */ - OUString getTableName() const { return m_sTableName; } + OUString const& getTableName() const { return m_sTableName; } /** * @return primary keys of parsed table. */ - std::vector<OUString> getPrimaryKeys() const { return m_PrimaryKeys; } + std::vector<OUString> const& getPrimaryKeys() const { return m_PrimaryKeys; } /** * @return a vector of column descriptors, representing the columns of the diff --git a/include/basegfx/polygon/b3dpolygon.hxx b/include/basegfx/polygon/b3dpolygon.hxx index 1d3dd515b757..47eefd498597 100644 --- a/include/basegfx/polygon/b3dpolygon.hxx +++ b/include/basegfx/polygon/b3dpolygon.hxx @@ -66,28 +66,28 @@ namespace basegfx sal_uInt32 count() const; // Coordinate interface - B3DPoint getB3DPoint(sal_uInt32 nIndex) const; + B3DPoint const & getB3DPoint(sal_uInt32 nIndex) const; void setB3DPoint(sal_uInt32 nIndex, const B3DPoint& rValue); // Coordinate append void append(const B3DPoint& rPoint, sal_uInt32 nCount = 1); // BColor interface - BColor getBColor(sal_uInt32 nIndex) const; + BColor const & getBColor(sal_uInt32 nIndex) const; void setBColor(sal_uInt32 nIndex, const BColor& rValue); bool areBColorsUsed() const; void clearBColors(); // Normals interface B3DVector const & getNormal() const; // plane normal - B3DVector getNormal(sal_uInt32 nIndex) const; // normal in each point + B3DVector const & getNormal(sal_uInt32 nIndex) const; // normal in each point void setNormal(sal_uInt32 nIndex, const B3DVector& rValue); void transformNormals(const B3DHomMatrix& rMatrix); bool areNormalsUsed() const; void clearNormals(); // TextureCoordinate interface - B2DPoint getTextureCoordinate(sal_uInt32 nIndex) const; + B2DPoint const & getTextureCoordinate(sal_uInt32 nIndex) const; void setTextureCoordinate(sal_uInt32 nIndex, const B2DPoint& rValue); void transformTextureCoordinates(const B2DHomMatrix& rMatrix); bool areTextureCoordinatesUsed() const; diff --git a/include/basegfx/polygon/b3dpolypolygon.hxx b/include/basegfx/polygon/b3dpolypolygon.hxx index ebab91a44ce2..ce659148c72a 100644 --- a/include/basegfx/polygon/b3dpolypolygon.hxx +++ b/include/basegfx/polygon/b3dpolypolygon.hxx @@ -62,7 +62,7 @@ namespace basegfx sal_uInt32 count() const; // B3DPolygon interface - B3DPolygon getB3DPolygon(sal_uInt32 nIndex) const; + B3DPolygon const & getB3DPolygon(sal_uInt32 nIndex) const; void setB3DPolygon(sal_uInt32 nIndex, const B3DPolygon& rPolygon); // BColor interface diff --git a/include/filter/msfilter/svdfppt.hxx b/include/filter/msfilter/svdfppt.hxx index 7dc6082fb931..e3be8307a185 100644 --- a/include/filter/msfilter/svdfppt.hxx +++ b/include/filter/msfilter/svdfppt.hxx @@ -195,8 +195,8 @@ struct MSFILTER_DLLPUBLIC PptDocumentAtom public: - Size GetSlidesPageSize() const { return aSlidesPageSize; } - Size GetNotesPageSize() const { return aNotesPageSize; } + Size const & GetSlidesPageSize() const { return aSlidesPageSize; } + Size const & GetNotesPageSize() const { return aNotesPageSize; } friend SvStream& ReadPptDocumentAtom( SvStream& rIn, PptDocumentAtom& rAtom ); }; diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx index 85c40d84b225..c718815b9bd2 100644 --- a/include/sfx2/charwin.hxx +++ b/include/sfx2/charwin.hxx @@ -50,9 +50,9 @@ public: SvxCharView(const VclPtr<VirtualDevice>& rVirDev); void SetFont( const vcl::Font& rFont ); - vcl::Font GetFont() const { return maFont; } + vcl::Font const & GetFont() const { return maFont; } void SetText( const OUString& rText ); - OUString GetText() const { return m_sText; } + OUString const & GetText() const { return m_sText; } void SetHasInsert( bool bInsert ); void InsertCharToDoc(); diff --git a/include/sfx2/opengrf.hxx b/include/sfx2/opengrf.hxx index 0178cc0bb745..c99433a2c3f0 100644 --- a/include/sfx2/opengrf.hxx +++ b/include/sfx2/opengrf.hxx @@ -55,7 +55,7 @@ public: OUString const & GetDetectedFilter() const; void SetDetectedFilter(const OUString&); - css::uno::Reference<css::ui::dialogs::XFilePickerControlAccess> GetFilePickerControlAccess(); + css::uno::Reference<css::ui::dialogs::XFilePickerControlAccess> const & GetFilePickerControlAccess(); private: SvxOpenGraphicDialog (const SvxOpenGraphicDialog&) = delete; diff --git a/include/svl/aeitem.hxx b/include/svl/aeitem.hxx index add7e0b2c465..7be7e83352fd 100644 --- a/include/svl/aeitem.hxx +++ b/include/svl/aeitem.hxx @@ -61,7 +61,7 @@ public: virtual sal_uInt16 GetValueCount() const override; sal_uInt16 GetValueByPos( sal_uInt16 nPos ) const; - OUString GetValueTextByPos( sal_uInt16 nPos ) const; + OUString const & GetValueTextByPos( sal_uInt16 nPos ) const; virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override; virtual SfxPoolItem* Create(SvStream &, sal_uInt16 nVersion) const override; }; diff --git a/include/svx/charmap.hxx b/include/svx/charmap.hxx index 2446c0607cbb..6e18581c4786 100644 --- a/include/svx/charmap.hxx +++ b/include/svx/charmap.hxx @@ -80,7 +80,7 @@ public: void SetFavClickHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aFavClickHdl = rHdl; } static sal_uInt32& getSelectedChar(); void SetFont( const vcl::Font& rFont ); - vcl::Font GetFont() const { return mxVirDev->GetFont(); } + vcl::Font const & GetFont() const { return mxVirDev->GetFont(); } bool GetFontCharMap(FontCharMapRef& rxFontCharMap) const { return mxVirDev->GetFontCharMap(rxFontCharMap); } bool isFavChar(const OUString& sTitle, const OUString& rFont); void getFavCharacterList(); //gets both Fav char and Fav char font list diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx index 4eef04e85323..274db81bd781 100644 --- a/include/vcl/customweld.hxx +++ b/include/vcl/customweld.hxx @@ -36,7 +36,7 @@ public: } virtual tools::Rectangle GetFocusRect() { return tools::Rectangle(); } virtual FactoryFunction GetUITestFactory() const { return nullptr; } - Size GetOutputSizePixel() const { return m_aSize; } + Size const& GetOutputSizePixel() const { return m_aSize; } void SetOutputSizePixel(const Size& rSize) { m_aSize = rSize; } virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) { m_pDrawingArea = pDrawingArea; } weld::DrawingArea* GetDrawingArea() const { return m_pDrawingArea; } diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index e3974dcf39ad..b2742ddba9a0 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -175,7 +175,7 @@ public: void SetPrintOptions ( const ScPrintOptions& rOpt ); void InsertEntryToLRUList(sal_uInt16 nFIndex); - SC_DLLPUBLIC css::uno::Reference<css::datatransfer::XTransferable2> + SC_DLLPUBLIC const css::uno::Reference<css::datatransfer::XTransferable2> & GetClipData() { return m_xClipData; } SC_DLLPUBLIC void SetClipData( const css::uno::Reference<css::datatransfer::XTransferable2>& xTransferable) { m_xClipData = xTransferable; } diff --git a/sc/inc/userdat.hxx b/sc/inc/userdat.hxx index 655d869b0d84..8b1b1cee9e77 100644 --- a/sc/inc/userdat.hxx +++ b/sc/inc/userdat.hxx @@ -47,8 +47,8 @@ public: explicit ScDrawObjData(); - tools::Rectangle getShapeRect() { return maShapeRect; }; - tools::Rectangle getLastCellRect() { return maLastCellRect; }; + const tools::Rectangle & getShapeRect() { return maShapeRect; }; + const tools::Rectangle & getLastCellRect() { return maLastCellRect; }; void setShapeRect(const ScDocument* rDoc, tools::Rectangle rNewRect, bool bIsVisible=true) { // bIsVisible should be false when the object is hidden obviously. we dont want to store the old cell rect in that diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 0c6bb6b119ec..2181e61aa325 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -395,7 +395,7 @@ public: static bool isAnyEditViewInRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd); css::uno::Reference<css::drawing::XShapes> getSelectedXShapes(); - css::uno::Reference<css::datatransfer::XTransferable2> GetClipData() { return m_xClipData; }; + const css::uno::Reference<css::datatransfer::XTransferable2> & GetClipData() { return m_xClipData; }; void SetClipData(const css::uno::Reference<css::datatransfer::XTransferable2>& xTransferable) { m_xClipData = xTransferable; } }; diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx index 65e0d2aa8727..e7a40b65a2e9 100644 --- a/sd/source/ui/dlg/navigatr.cxx +++ b/sd/source/ui/dlg/navigatr.cxx @@ -215,7 +215,7 @@ NavigatorDragType SdNavigatorWin::GetNavigatorDragType() return eDT; } -VclPtr<SdPageObjsTLB> SdNavigatorWin::GetObjects() +VclPtr<SdPageObjsTLB> const & SdNavigatorWin::GetObjects() { return maTlbObjects; } diff --git a/sd/source/ui/inc/navigatr.hxx b/sd/source/ui/inc/navigatr.hxx index a9501c5236a4..5a01453bdf95 100644 --- a/sd/source/ui/inc/navigatr.hxx +++ b/sd/source/ui/inc/navigatr.hxx @@ -101,7 +101,7 @@ public: bool InsertFile(const OUString& rFileName); NavigatorDragType GetNavigatorDragType(); - VclPtr<SdPageObjsTLB> GetObjects(); + VclPtr<SdPageObjsTLB> const & GetObjects(); protected: virtual bool EventNotify(NotifyEvent& rNEvt) override; diff --git a/sfx2/source/appl/opengrf.cxx b/sfx2/source/appl/opengrf.cxx index d1775a8a5940..9f17de32c1a1 100644 --- a/sfx2/source/appl/opengrf.cxx +++ b/sfx2/source/appl/opengrf.cxx @@ -281,7 +281,7 @@ void SvxOpenGraphicDialog::SetDetectedFilter(const OUString& rStr) mpImpl->sDetectedFilter = rStr; } -Reference<ui::dialogs::XFilePickerControlAccess> SvxOpenGraphicDialog::GetFilePickerControlAccess() +Reference<ui::dialogs::XFilePickerControlAccess> const & SvxOpenGraphicDialog::GetFilePickerControlAccess() { return mpImpl->xCtrlAcc; } diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 9133afe6b8d9..cae51357f2a6 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -114,7 +114,7 @@ static OUString HelpLocaleString(); namespace { /// Root path of the help. -OUString getHelpRootURL() +OUString const & getHelpRootURL() { static OUString s_instURL; if (!s_instURL.isEmpty()) diff --git a/svl/source/items/aeitem.cxx b/svl/source/items/aeitem.cxx index 7d818b903067..39fa0cda74c6 100644 --- a/svl/source/items/aeitem.cxx +++ b/svl/source/items/aeitem.cxx @@ -66,7 +66,7 @@ sal_uInt16 SfxAllEnumItem::GetValueCount() const return pValues ? pValues->size() : 0; } -OUString SfxAllEnumItem::GetValueTextByPos( sal_uInt16 nPos ) const +OUString const & SfxAllEnumItem::GetValueTextByPos( sal_uInt16 nPos ) const { assert(pValues && nPos < pValues->size()); return (*pValues)[nPos].aText; diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx index 82dbdf71fbf8..4338ed20021d 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -116,7 +116,7 @@ private: bool operator==( const ImpGraphic& rImpGraphic ) const; bool operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); } - OUString getOriginURL() const + OUString const & getOriginURL() const { return maGraphicExternalLink.msURL; } |