Kaydet (Commit) febd02b7 authored tarafından Michael Stahl's avatar Michael Stahl

xmloff: replace boost::ptr_set with std::set<std::unique_ptr>

boost::ptr_set was actually quite nice here, pity about the obnoxious
warnings...

Change-Id: I46973635fd26e4f1db96f2806c211b83436bef5e
üst 18c502b0
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/iterator_adaptors.hpp> #include <boost/iterator_adaptors.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_set.hpp>
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <memory> #include <memory>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
......
...@@ -60,7 +60,7 @@ XMLAutoStyleFamily::~XMLAutoStyleFamily() {} ...@@ -60,7 +60,7 @@ XMLAutoStyleFamily::~XMLAutoStyleFamily() {}
void XMLAutoStyleFamily::ClearEntries() void XMLAutoStyleFamily::ClearEntries()
{ {
maParentSet.clear(); m_ParentSet.clear();
} }
static OUString static OUString
...@@ -506,16 +506,17 @@ bool SvXMLAutoStylePoolP_Impl::Add( ...@@ -506,16 +506,17 @@ bool SvXMLAutoStylePoolP_Impl::Add(
XMLAutoStyleFamily &rFamily = **iter; XMLAutoStyleFamily &rFamily = **iter;
XMLAutoStylePoolParent aTmp(rParentName); std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParentName));
XMLAutoStyleFamily::ParentSetType::iterator it2 = rFamily.maParentSet.find(aTmp); auto it2 = rFamily.m_ParentSet.find(pTmp);
if (it2 == rFamily.maParentSet.end()) if (it2 == rFamily.m_ParentSet.end())
{ {
std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r = std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r =
rFamily.maParentSet.insert(new XMLAutoStylePoolParent(rParentName)); rFamily.m_ParentSet.insert(std::unique_ptr<XMLAutoStylePoolParent>(
new XMLAutoStylePoolParent(rParentName)));
it2 = r.first; it2 = r.first;
} }
XMLAutoStylePoolParent& rParent = *it2; XMLAutoStylePoolParent& rParent = **it2;
bool bRet = false; bool bRet = false;
if (rParent.Add(rFamily, rProperties, rName, bDontSeek)) if (rParent.Add(rFamily, rProperties, rName, bDontSeek))
...@@ -539,16 +540,17 @@ bool SvXMLAutoStylePoolP_Impl::AddNamed( ...@@ -539,16 +540,17 @@ bool SvXMLAutoStylePoolP_Impl::AddNamed(
XMLAutoStyleFamily &rFamily = **iter; XMLAutoStyleFamily &rFamily = **iter;
XMLAutoStylePoolParent aTmp(rParentName); std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParentName));
XMLAutoStyleFamily::ParentSetType::iterator it2 = rFamily.maParentSet.find(aTmp); auto it2 = rFamily.m_ParentSet.find(pTmp);
if (it2 == rFamily.maParentSet.end()) if (it2 == rFamily.m_ParentSet.end())
{ {
std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r = std::pair<XMLAutoStyleFamily::ParentSetType::iterator,bool> r =
rFamily.maParentSet.insert(new XMLAutoStylePoolParent(rParentName)); rFamily.m_ParentSet.insert(std::unique_ptr<XMLAutoStylePoolParent>(
new XMLAutoStylePoolParent(rParentName)));
it2 = r.first; it2 = r.first;
} }
XMLAutoStylePoolParent& rParent = *it2; XMLAutoStylePoolParent& rParent = **it2;
bool bRet = false; bool bRet = false;
if (rParent.AddNamed(rFamily, rProperties, rName)) if (rParent.AddNamed(rFamily, rProperties, rName))
...@@ -575,11 +577,11 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily, ...@@ -575,11 +577,11 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily,
assert(iter != m_FamilySet.end()); // family must be known assert(iter != m_FamilySet.end()); // family must be known
XMLAutoStyleFamily const& rFamily = **iter; XMLAutoStyleFamily const& rFamily = **iter;
XMLAutoStylePoolParent aTmp( rParent ); std::unique_ptr<XMLAutoStylePoolParent> pTmp(new XMLAutoStylePoolParent(rParent));
XMLAutoStyleFamily::ParentSetType::const_iterator it2 = rFamily.maParentSet.find(aTmp); auto const it2 = rFamily.m_ParentSet.find(pTmp);
if (it2 != rFamily.maParentSet.end()) if (it2 != rFamily.m_ParentSet.end())
{ {
sName = it2->Find(rFamily, rProperties); sName = (*it2)->Find(rFamily, rProperties);
} }
return sName; return sName;
...@@ -628,8 +630,7 @@ void SvXMLAutoStylePoolP_Impl::exportXML( ...@@ -628,8 +630,7 @@ void SvXMLAutoStylePoolP_Impl::exportXML(
// which contains a parent-name and a SvXMLAutoStylePoolProperties_Impl // which contains a parent-name and a SvXMLAutoStylePoolProperties_Impl
std::vector<AutoStylePoolExport> aExpStyles(nCount); std::vector<AutoStylePoolExport> aExpStyles(nCount);
XMLAutoStyleFamily::ParentSetType::iterator it = rFamily.maParentSet.begin(), itEnd = rFamily.maParentSet.end(); for (auto const& it : rFamily.m_ParentSet)
for (; it != itEnd; ++it)
{ {
XMLAutoStylePoolParent& rParent = *it; XMLAutoStylePoolParent& rParent = *it;
size_t nProperties = rParent.GetPropertiesList().size(); size_t nProperties = rParent.GetPropertiesList().size();
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#ifndef INCLUDED_XMLOFF_SOURCE_STYLE_IMPASTPL_HXX #ifndef INCLUDED_XMLOFF_SOURCE_STYLE_IMPASTPL_HXX
#define INCLUDED_XMLOFF_SOURCE_STYLE_IMPASTPL_HXX #define INCLUDED_XMLOFF_SOURCE_STYLE_IMPASTPL_HXX
#include <boost/ptr_container/ptr_set.hpp>
#include <sal/types.h> #include <sal/types.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <set> #include <set>
...@@ -37,39 +36,10 @@ ...@@ -37,39 +36,10 @@
class SvXMLAutoStylePoolP; class SvXMLAutoStylePoolP;
class XMLAutoStylePoolParent; class XMLAutoStylePoolParent;
class XMLAutoStyleFamily;
class SvXMLExportPropertyMapper; class SvXMLExportPropertyMapper;
class SvXMLExport; class SvXMLExport;
// Implementationclass for stylefamily-information
struct XMLAutoStyleFamily : boost::noncopyable
{
typedef boost::ptr_set<XMLAutoStylePoolParent> ParentSetType;
typedef std::set<OUString> NameSetType;
sal_uInt32 mnFamily;
OUString maStrFamilyName;
rtl::Reference < SvXMLExportPropertyMapper > mxMapper;
ParentSetType maParentSet;
NameSetType maNameSet;
sal_uInt32 mnCount;
sal_uInt32 mnName;
OUString maStrPrefix;
bool mbAsFamily;
XMLAutoStyleFamily( sal_Int32 nFamily, const OUString& rStrName,
const rtl::Reference<SvXMLExportPropertyMapper>& rMapper,
const OUString& rStrPrefix, bool bAsFamily = true );
explicit XMLAutoStyleFamily( sal_Int32 nFamily );
~XMLAutoStyleFamily();
friend bool operator<(const XMLAutoStyleFamily& r1, const XMLAutoStyleFamily& r2);
void ClearEntries();
};
// Properties of a pool // Properties of a pool
class XMLAutoStylePoolProperties class XMLAutoStylePoolProperties
...@@ -128,6 +98,44 @@ public: ...@@ -128,6 +98,44 @@ public:
bool operator< (const XMLAutoStylePoolParent& rOther) const; bool operator< (const XMLAutoStylePoolParent& rOther) const;
}; };
// Implementationclass for stylefamily-information
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<OUString> NameSetType;
sal_uInt32 mnFamily;
OUString maStrFamilyName;
rtl::Reference<SvXMLExportPropertyMapper> mxMapper;
ParentSetType m_ParentSet;
NameSetType maNameSet;
sal_uInt32 mnCount;
sal_uInt32 mnName;
OUString maStrPrefix;
bool mbAsFamily;
XMLAutoStyleFamily( sal_Int32 nFamily, const OUString& rStrName,
const rtl::Reference<SvXMLExportPropertyMapper>& rMapper,
const OUString& rStrPrefix, bool bAsFamily = true );
explicit XMLAutoStyleFamily( sal_Int32 nFamily );
~XMLAutoStyleFamily();
friend bool operator<(const XMLAutoStyleFamily& r1, const XMLAutoStyleFamily& r2);
void ClearEntries();
};
// Implementationclass of SvXMLAutoStylePool // Implementationclass of SvXMLAutoStylePool
class SvXMLAutoStylePoolP_Impl class SvXMLAutoStylePoolP_Impl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment