diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-29 16:24:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-30 08:43:04 +0200 |
commit | 22f2cf3ccc6d0c9ba2c2860735e789d6b3a25f72 (patch) | |
tree | f20474881dd71d3f815a964718a3b7dbcc53340a /include | |
parent | f9f7cc62e95f12a9d4ea02413a658d40e09ccde6 (diff) |
implement std::hash for css::uno::Reference and rtl::Reference
The declaration in BarChart.cxx is particularly suspicious, because it
was using a < for the KeyEqual template parameter.
Been there since:
commit b2c3233e5f267b5d244d722a94424a3b224b3314
Date: Thu Dec 21 20:08:33 2017 +0900
chart2: suspend/resume setting rects dirty for 3D shapes
comphelper::OInterfaceCompare is no longer necessary
Change-Id: I8278c4a3d9113a18570ca237cd05d553ec8f3975
Reviewed-on: https://gerrit.libreoffice.org/71537
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/com/sun/star/uno/Reference.hxx | 20 | ||||
-rw-r--r-- | include/comphelper/accessiblewrapper.hxx | 2 | ||||
-rw-r--r-- | include/comphelper/stl_types.hxx | 15 | ||||
-rw-r--r-- | include/oox/export/shapes.hxx | 14 | ||||
-rw-r--r-- | include/rtl/ref.hxx | 24 | ||||
-rw-r--r-- | include/svx/fmtools.hxx | 5 |
6 files changed, 46 insertions, 34 deletions
diff --git a/include/com/sun/star/uno/Reference.hxx b/include/com/sun/star/uno/Reference.hxx index d822c97aeb2d..c6869d922d7e 100644 --- a/include/com/sun/star/uno/Reference.hxx +++ b/include/com/sun/star/uno/Reference.hxx @@ -450,6 +450,26 @@ operator <<( } } +#if defined LIBO_INTERNAL_ONLY +namespace std +{ + +/** + Make css::uno::Reference hashable by default for use in STL containers. + + @since LibreOffice 6.3 +*/ +template<typename T> +struct hash<::css::uno::Reference<T>> +{ + std::size_t operator()(::css::uno::Reference<T> const & s) const + { return size_t(s.get()); } +}; + +} + +#endif + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/comphelper/accessiblewrapper.hxx b/include/comphelper/accessiblewrapper.hxx index 30f775f255e5..34b3cb8edad4 100644 --- a/include/comphelper/accessiblewrapper.hxx +++ b/include/comphelper/accessiblewrapper.hxx @@ -36,7 +36,6 @@ #include <comphelper/uno3.hxx> #include <cppuhelper/interfacecontainer.h> #include <comphelper/accessibleeventnotifier.hxx> -#include <comphelper/stl_types.hxx> #include <comphelper/comphelperdllapi.h> #include <rtl/ref.hxx> @@ -317,7 +316,6 @@ namespace comphelper typedef ::std::map < css::uno::Reference< css::accessibility::XAccessible > , css::uno::Reference< css::accessibility::XAccessible > - , OInterfaceCompare< css::accessibility::XAccessible > > AccessibleMap; // TODO: think about if we should hold these objects weak diff --git a/include/comphelper/stl_types.hxx b/include/comphelper/stl_types.hxx index c166b5a7040e..e84f9d405dae 100644 --- a/include/comphelper/stl_types.hxx +++ b/include/comphelper/stl_types.hxx @@ -97,21 +97,6 @@ bool ContainerUniquePtrEquals( }; -/** STL-compliant structure for comparing Reference< <iface> > instances -*/ -template < class IAFCE > -struct OInterfaceCompare -{ - bool operator() (const css::uno::Reference< IAFCE >& lhs, const css::uno::Reference< IAFCE >& rhs) const - { - return lhs.get() < rhs.get(); - // this does not make any sense if you see the semantics of the pointer returned by get: - // It's a pointer to a point in memory where an interface implementation lies. - // But for our purpose (provide a reliable less-operator which can be used with the STL), this is - // sufficient .... - } -}; - template <class Tp, class Arg> class mem_fun1_t { diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx index b7755ccee9d2..a8ea2d5c6005 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -82,21 +82,9 @@ class OOX_DLLPUBLIC ShapeExport : public DrawingML { private: int m_nEmbeddedObjects; - struct ShapeCheck - { - bool operator()( const css::uno::Reference< css::drawing::XShape>& s1, const css::uno::Reference< css::drawing::XShape>& s2 ) const - { - return s1 == s2; - } - }; - - struct ShapeHash - { - size_t operator()( const css::uno::Reference < css::drawing::XShape >& ) const; - }; public: - typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32, ShapeHash, ShapeCheck> ShapeHashMap; + typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32> ShapeHashMap; protected: sal_Int32 mnShapeIdMax, mnPictureIdMax; diff --git a/include/rtl/ref.hxx b/include/rtl/ref.hxx index 437f7a34fc05..73c03ff7657d 100644 --- a/include/rtl/ref.hxx +++ b/include/rtl/ref.hxx @@ -23,6 +23,8 @@ #include "sal/config.h" #include <cassert> +#include <cstddef> +#include <functional> #include "sal/types.h" @@ -250,6 +252,28 @@ public: } // namespace rtl +#if defined LIBO_INTERNAL_ONLY +namespace std +{ + +/// @cond INTERNAL +/** + Make rtl::Reference hashable by default for use in STL containers. + + @since LibreOffice 6.3 +*/ +template<typename T> +struct hash<::rtl::Reference<T>> +{ + std::size_t operator()(::rtl::Reference<T> const & s) const + { return std::size_t(s.get()); } +}; +/// @endcond + +} + +#endif + #endif /* ! INCLUDED_RTL_REF_HXX */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/fmtools.hxx b/include/svx/fmtools.hxx index 000f3032ca83..6322cc3720d0 100644 --- a/include/svx/fmtools.hxx +++ b/include/svx/fmtools.hxx @@ -58,7 +58,6 @@ #include <rtl/ref.hxx> #include <tools/wintypes.hxx> #include <cppuhelper/weakref.hxx> -#include <comphelper/stl_types.hxx> #include <cppuhelper/implbase.hxx> #include <set> @@ -189,9 +188,7 @@ bool isRowSetAlive(const css::uno::Reference< css::uno::XInterface>& _rxRowSet); // checks if the css::sdbcx::XColumnsSupplier provided by _rxRowSet supplies any columns -typedef ::std::set < css::uno::Reference< css::uno::XInterface > - , ::comphelper::OInterfaceCompare< css::uno::XInterface > - > InterfaceBag; +typedef ::std::set< css::uno::Reference< css::uno::XInterface > > InterfaceBag; #endif // INCLUDED_SVX_FMTOOLS_HXX |