diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-08-19 13:21:18 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-08-19 19:32:18 +0200 |
commit | a4de770bab5e05af42dcd790b1e4a54fcc758e6c (patch) | |
tree | 11a9db938a7f405ee737511356e88917a25d7625 | |
parent | 58c3bbfd467b93d133e00789afcd7a00a3f53895 (diff) |
comphelper: reduce copypasta with UniquePtrValueLess functor
Change-Id: Ib93b818eeebc2f370535d1b061beabf7e8c65257
-rw-r--r-- | include/comphelper/stl_types.hxx | 14 | ||||
-rw-r--r-- | include/filter/msfilter/msdffimp.hxx | 12 | ||||
-rw-r--r-- | sw/source/core/inc/blink.hxx | 13 | ||||
-rw-r--r-- | sw/source/filter/html/wrthtml.hxx | 13 | ||||
-rw-r--r-- | xmloff/source/style/impastpl.hxx | 25 |
5 files changed, 31 insertions, 46 deletions
diff --git a/include/comphelper/stl_types.hxx b/include/comphelper/stl_types.hxx index 251137b92485..f5c58fd15190 100644 --- a/include/comphelper/stl_types.hxx +++ b/include/comphelper/stl_types.hxx @@ -23,6 +23,7 @@ #include <math.h> #include <functional> +#include <memory> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> @@ -86,6 +87,19 @@ public: } }; +/// by-value less functor for std::set<std::unique_ptr<T>> +template<class T> struct UniquePtrValueLess + : public ::std::binary_function<std::unique_ptr<T>, std::unique_ptr<T>, bool> +{ + bool operator()(std::unique_ptr<T> const& lhs, + std::unique_ptr<T> const& rhs) const + { + assert(lhs.get()); + assert(rhs.get()); + return (*lhs) < (*rhs); + } +}; + /** STL-compliant structure for comparing Reference< <iface> > instances */ template < class IAFCE > diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx index 5c256e8af544..42328e01127c 100644 --- a/include/filter/msfilter/msdffimp.hxx +++ b/include/filter/msfilter/msdffimp.hxx @@ -31,6 +31,8 @@ #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <comphelper/stl_types.hxx> + #include <tools/solar.h> #include <tools/color.hxx> #include <tools/gen.hxx> @@ -266,15 +268,9 @@ private: SvxMSDffImportRec &operator=(const SvxMSDffImportRec&) SAL_DELETED_FUNCTION; }; -struct MSDffImportRecords_Less -{ - bool operator()(std::unique_ptr<SvxMSDffImportRec> const& left, - std::unique_ptr<SvxMSDffImportRec> const& right) const - { return (*left) < (*right); } -}; /** list of all SvxMSDffImportRec instances of/for a group */ -typedef std::set<std::unique_ptr<SvxMSDffImportRec>, MSDffImportRecords_Less> - MSDffImportRecords; +typedef std::set<std::unique_ptr<SvxMSDffImportRec>, + comphelper::UniquePtrValueLess<SvxMSDffImportRec>> MSDffImportRecords; /** block of parameters for import/export for a single call of ImportObjAtCurrentStreamPos() */ diff --git a/sw/source/core/inc/blink.hxx b/sw/source/core/inc/blink.hxx index 6c14225dadfa..8b9fc5d2d10a 100644 --- a/sw/source/core/inc/blink.hxx +++ b/sw/source/core/inc/blink.hxx @@ -26,6 +26,7 @@ class SwTextFrm; #include <vcl/timer.hxx> #include <tools/gen.hxx> +#include <comphelper/stl_types.hxx> #include <set> #include <memory> @@ -63,16 +64,8 @@ public: { return reinterpret_cast<sal_IntPtr>(pPor) == reinterpret_cast<sal_IntPtr>(rBlinkPortion.pPor); } }; -struct SwBlinkPortion_Less -{ - bool operator()(std::unique_ptr<SwBlinkPortion> const& lhs, - std::unique_ptr<SwBlinkPortion> const& rhs) - { - return (*lhs) < (*rhs); - } -}; - -typedef std::set<std::unique_ptr<SwBlinkPortion>, SwBlinkPortion_Less> SwBlinkSet; +typedef std::set<std::unique_ptr<SwBlinkPortion>, + comphelper::UniquePtrValueLess<SwBlinkPortion>> SwBlinkSet; class SwBlink { diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index df11e3eb00d1..f0323295351b 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -29,6 +29,7 @@ #include <vcl/field.hxx> #include <i18nlangtag/lang.h> #include <tools/stream.hxx> +#include <comphelper/stl_types.hxx> #include <o3tl/sorted_vector.hxx> #include "shellio.hxx" @@ -262,16 +263,8 @@ struct SwHTMLFormatInfo }; -struct SwHTMLFormatInfo_Less -{ - bool operator()(std::unique_ptr<SwHTMLFormatInfo> const& lhs, - std::unique_ptr<SwHTMLFormatInfo> const& rhs) - { - return (*lhs) < (*rhs); - } -}; - -typedef std::set<std::unique_ptr<SwHTMLFormatInfo>, SwHTMLFormatInfo_Less> SwHTMLFormatInfos; +typedef std::set<std::unique_ptr<SwHTMLFormatInfo>, + comphelper::UniquePtrValueLess<SwHTMLFormatInfo>> SwHTMLFormatInfos; class IDocumentStylePoolAccess; diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx index 4dbce494ac74..d7a8240e7c3b 100644 --- a/xmloff/source/style/impastpl.hxx +++ b/xmloff/source/style/impastpl.hxx @@ -28,6 +28,9 @@ #include <com/sun/star/uno/Reference.h> #include <com/sun/star/xml/sax/XAttributeList.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <comphelper/stl_types.hxx> + #include <xmloff/maptype.hxx> #include <xmloff/xmlexppr.hxx> @@ -102,15 +105,8 @@ public: struct XMLAutoStyleFamily : boost::noncopyable { - struct XMLAutoStylePoolParent_Less - { - bool operator()(std::unique_ptr<XMLAutoStylePoolParent> const& lhs, - std::unique_ptr<XMLAutoStylePoolParent> const& rhs) const - { - return (*lhs) < (*rhs); - } - }; - typedef std::set<std::unique_ptr<XMLAutoStylePoolParent>, XMLAutoStylePoolParent_Less> ParentSetType; + typedef std::set<std::unique_ptr<XMLAutoStylePoolParent>, + comphelper::UniquePtrValueLess<XMLAutoStylePoolParent>> ParentSetType; typedef std::set<OUString> NameSetType; sal_uInt32 mnFamily; @@ -140,16 +136,9 @@ struct XMLAutoStyleFamily : boost::noncopyable class SvXMLAutoStylePoolP_Impl { - struct XMLAutoStyleFamily_Less - { - bool operator()(std::unique_ptr<XMLAutoStyleFamily> const& lhs, - std::unique_ptr<XMLAutoStyleFamily> const& rhs) const - { - return (*lhs) < (*rhs); - } - }; // A set that finds and sorts based only on mnFamily - typedef std::set<std::unique_ptr<XMLAutoStyleFamily>, XMLAutoStyleFamily_Less> FamilySetType; + typedef std::set<std::unique_ptr<XMLAutoStyleFamily>, + comphelper::UniquePtrValueLess<XMLAutoStyleFamily>> FamilySetType; SvXMLExport& rExport; FamilySetType m_FamilySet; |