comphelper: reduce copypasta with UniquePtrValueLess functor
Change-Id: Ib93b818eeebc2f370535d1b061beabf7e8c65257
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
#include <rtl/ustrbuf.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
|
/** STL-compliant structure for comparing Reference< <iface> > instances
|
||||||
*/
|
*/
|
||||||
template < class IAFCE >
|
template < class IAFCE >
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#include <com/sun/star/embed/XEmbeddedObject.hpp>
|
#include <com/sun/star/embed/XEmbeddedObject.hpp>
|
||||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||||
|
|
||||||
|
#include <comphelper/stl_types.hxx>
|
||||||
|
|
||||||
#include <tools/solar.h>
|
#include <tools/solar.h>
|
||||||
#include <tools/color.hxx>
|
#include <tools/color.hxx>
|
||||||
#include <tools/gen.hxx>
|
#include <tools/gen.hxx>
|
||||||
@@ -266,15 +268,9 @@ private:
|
|||||||
SvxMSDffImportRec &operator=(const SvxMSDffImportRec&) SAL_DELETED_FUNCTION;
|
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 */
|
/** list of all SvxMSDffImportRec instances of/for a group */
|
||||||
typedef std::set<std::unique_ptr<SvxMSDffImportRec>, MSDffImportRecords_Less>
|
typedef std::set<std::unique_ptr<SvxMSDffImportRec>,
|
||||||
MSDffImportRecords;
|
comphelper::UniquePtrValueLess<SvxMSDffImportRec>> MSDffImportRecords;
|
||||||
|
|
||||||
/** block of parameters for import/export for a single call of
|
/** block of parameters for import/export for a single call of
|
||||||
ImportObjAtCurrentStreamPos() */
|
ImportObjAtCurrentStreamPos() */
|
||||||
|
@@ -26,6 +26,7 @@ class SwTextFrm;
|
|||||||
|
|
||||||
#include <vcl/timer.hxx>
|
#include <vcl/timer.hxx>
|
||||||
#include <tools/gen.hxx>
|
#include <tools/gen.hxx>
|
||||||
|
#include <comphelper/stl_types.hxx>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -63,16 +64,8 @@ public:
|
|||||||
{ return reinterpret_cast<sal_IntPtr>(pPor) == reinterpret_cast<sal_IntPtr>(rBlinkPortion.pPor); }
|
{ return reinterpret_cast<sal_IntPtr>(pPor) == reinterpret_cast<sal_IntPtr>(rBlinkPortion.pPor); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SwBlinkPortion_Less
|
typedef std::set<std::unique_ptr<SwBlinkPortion>,
|
||||||
{
|
comphelper::UniquePtrValueLess<SwBlinkPortion>> SwBlinkSet;
|
||||||
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;
|
|
||||||
|
|
||||||
class SwBlink
|
class SwBlink
|
||||||
{
|
{
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include <vcl/field.hxx>
|
#include <vcl/field.hxx>
|
||||||
#include <i18nlangtag/lang.h>
|
#include <i18nlangtag/lang.h>
|
||||||
#include <tools/stream.hxx>
|
#include <tools/stream.hxx>
|
||||||
|
#include <comphelper/stl_types.hxx>
|
||||||
#include <o3tl/sorted_vector.hxx>
|
#include <o3tl/sorted_vector.hxx>
|
||||||
|
|
||||||
#include "shellio.hxx"
|
#include "shellio.hxx"
|
||||||
@@ -262,16 +263,8 @@ struct SwHTMLFormatInfo
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SwHTMLFormatInfo_Less
|
typedef std::set<std::unique_ptr<SwHTMLFormatInfo>,
|
||||||
{
|
comphelper::UniquePtrValueLess<SwHTMLFormatInfo>> SwHTMLFormatInfos;
|
||||||
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;
|
|
||||||
|
|
||||||
class IDocumentStylePoolAccess;
|
class IDocumentStylePoolAccess;
|
||||||
|
|
||||||
|
@@ -28,6 +28,9 @@
|
|||||||
#include <com/sun/star/uno/Reference.h>
|
#include <com/sun/star/uno/Reference.h>
|
||||||
#include <com/sun/star/xml/sax/XAttributeList.hpp>
|
#include <com/sun/star/xml/sax/XAttributeList.hpp>
|
||||||
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
|
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
|
||||||
|
|
||||||
|
#include <comphelper/stl_types.hxx>
|
||||||
|
|
||||||
#include <xmloff/maptype.hxx>
|
#include <xmloff/maptype.hxx>
|
||||||
#include <xmloff/xmlexppr.hxx>
|
#include <xmloff/xmlexppr.hxx>
|
||||||
|
|
||||||
@@ -102,15 +105,8 @@ public:
|
|||||||
|
|
||||||
struct XMLAutoStyleFamily : boost::noncopyable
|
struct XMLAutoStyleFamily : boost::noncopyable
|
||||||
{
|
{
|
||||||
struct XMLAutoStylePoolParent_Less
|
typedef std::set<std::unique_ptr<XMLAutoStylePoolParent>,
|
||||||
{
|
comphelper::UniquePtrValueLess<XMLAutoStylePoolParent>> ParentSetType;
|
||||||
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<OUString> NameSetType;
|
typedef std::set<OUString> NameSetType;
|
||||||
|
|
||||||
sal_uInt32 mnFamily;
|
sal_uInt32 mnFamily;
|
||||||
@@ -140,16 +136,9 @@ struct XMLAutoStyleFamily : boost::noncopyable
|
|||||||
|
|
||||||
class SvXMLAutoStylePoolP_Impl
|
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
|
// 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;
|
SvXMLExport& rExport;
|
||||||
FamilySetType m_FamilySet;
|
FamilySetType m_FamilySet;
|
||||||
|
Reference in New Issue
Block a user