Kaydet (Commit) bde1e4dc authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: fix indentation in rtfsprm

Change-Id: Id81cb97033e616acf071f386630b49ccb83dfedc
üst 2d786ef2
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
#include <resourcemodel/QNameToString.hxx> #include <resourcemodel/QNameToString.hxx>
namespace writerfilter { namespace writerfilter
namespace rtftok { {
namespace rtftok
{
RTFSprm::RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue) RTFSprm::RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue)
: m_nKeyword(nKeyword), : m_nKeyword(nKeyword),
m_pValue(pValue) m_pValue(pValue)
{ {
} }
...@@ -156,7 +158,8 @@ void RTFSprms::deduplicate(RTFSprms& rReference) ...@@ -156,7 +158,8 @@ void RTFSprms::deduplicate(RTFSprms& rReference)
void RTFSprms::ensureCopyBeforeWrite() void RTFSprms::ensureCopyBeforeWrite()
{ {
if (m_pSprms->m_nRefCount > 1) { if (m_pSprms->m_nRefCount > 1)
{
boost::intrusive_ptr<RTFSprmsImpl> pClone(new RTFSprmsImpl()); boost::intrusive_ptr<RTFSprmsImpl> pClone(new RTFSprmsImpl());
for (std::vector< std::pair<Id, RTFValue::Pointer_t> >::const_iterator i = m_pSprms->begin(); i != m_pSprms->end(); ++i) for (std::vector< std::pair<Id, RTFValue::Pointer_t> >::const_iterator i = m_pSprms->begin(); i != m_pSprms->end(); ++i)
pClone->push_back(std::make_pair(i->first, RTFValue::Pointer_t(i->second->Clone()))); pClone->push_back(std::make_pair(i->first, RTFValue::Pointer_t(i->second->Clone())));
......
...@@ -20,84 +20,101 @@ ...@@ -20,84 +20,101 @@
#include <rtfcontrolwords.hxx> #include <rtfcontrolwords.hxx>
#include <rtfvalue.hxx> #include <rtfvalue.hxx>
namespace writerfilter { namespace writerfilter
namespace rtftok { {
namespace rtftok
{
typedef std::vector< std::pair<Id, RTFValue::Pointer_t> > RTFSprmsImplBase; typedef std::vector< std::pair<Id, RTFValue::Pointer_t> > RTFSprmsImplBase;
/// The payload of RTFSprms which is only copied on write. /// The payload of RTFSprms which is only copied on write.
class RTFSprmsImpl : public RTFSprmsImplBase class RTFSprmsImpl : public RTFSprmsImplBase
{ {
public: public:
sal_Int32 m_nRefCount; sal_Int32 m_nRefCount;
RTFSprmsImpl() : RTFSprmsImplBase(), m_nRefCount(0) {} RTFSprmsImpl() : RTFSprmsImplBase(), m_nRefCount(0) {}
}; };
inline void intrusive_ptr_add_ref(RTFSprmsImpl* p) inline void intrusive_ptr_add_ref(RTFSprmsImpl* p)
{ {
++(p->m_nRefCount); ++(p->m_nRefCount);
} }
inline void intrusive_ptr_release(RTFSprmsImpl* p) inline void intrusive_ptr_release(RTFSprmsImpl* p)
{ {
if (!--(p->m_nRefCount)) if (!--(p->m_nRefCount))
delete p; delete p;
} }
enum RTFOverwrite enum RTFOverwrite
{ {
OVERWRITE_YES, ///< Yes, if an existing key is found, overwrite it. OVERWRITE_YES, ///< Yes, if an existing key is found, overwrite it.
OVERWRITE_NO_APPEND, ///< No, always append the value to the end of the list. OVERWRITE_NO_APPEND, ///< No, always append the value to the end of the list.
OVERWRITE_NO_IGNORE ///< No, if the key is already in the list, then ignore, otherwise append. OVERWRITE_NO_IGNORE ///< No, if the key is already in the list, then ignore, otherwise append.
}; };
/// A list of RTFSprm with a copy constructor that performs a deep copy. /// A list of RTFSprm with a copy constructor that performs a deep copy.
class RTFSprms class RTFSprms
{ {
public: public:
typedef ::boost::shared_ptr<RTFSprms> Pointer_t; typedef ::boost::shared_ptr<RTFSprms> Pointer_t;
typedef std::pair<Id, RTFValue::Pointer_t> Entry_t; typedef std::pair<Id, RTFValue::Pointer_t> Entry_t;
typedef std::vector<Entry_t>::iterator Iterator_t; typedef std::vector<Entry_t>::iterator Iterator_t;
RTFSprms(); RTFSprms();
RTFSprms(const RTFSprms& rSprms); RTFSprms(const RTFSprms& rSprms);
~RTFSprms(); ~RTFSprms();
RTFSprms& operator=(const RTFSprms& rOther); RTFSprms& operator=(const RTFSprms& rOther);
RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true, bool bForWrite = false); RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true, bool bForWrite = false);
/// Does the same as ->push_back(), except that it can overwrite or ignore existing entries. /// Does the same as ->push_back(), except that it can overwrite or ignore existing entries.
void set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwrite = OVERWRITE_YES); void set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwrite = OVERWRITE_YES);
bool erase(Id nKeyword); bool erase(Id nKeyword);
/// Removes elements, which are already in the reference set. /// Removes elements, which are already in the reference set.
void deduplicate(RTFSprms& rReference); void deduplicate(RTFSprms& rReference);
size_t size() const { return m_pSprms->size(); } size_t size() const
bool empty() const { return m_pSprms->empty(); } {
Entry_t& back() { return m_pSprms->back(); } return m_pSprms->size();
Iterator_t begin() { return m_pSprms->begin(); } }
Iterator_t end() { return m_pSprms->end(); } bool empty() const
void clear(); {
private: return m_pSprms->empty();
void ensureCopyBeforeWrite(); }
boost::intrusive_ptr<RTFSprmsImpl> m_pSprms; Entry_t& back()
}; {
return m_pSprms->back();
}
Iterator_t begin()
{
return m_pSprms->begin();
}
Iterator_t end()
{
return m_pSprms->end();
}
void clear();
private:
void ensureCopyBeforeWrite();
boost::intrusive_ptr<RTFSprmsImpl> m_pSprms;
};
/// RTF keyword with a parameter /// RTF keyword with a parameter
class RTFSprm class RTFSprm
: public Sprm : public Sprm
{ {
public: public:
RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue); RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue);
virtual ~RTFSprm() {} virtual ~RTFSprm() {}
virtual sal_uInt32 getId() const SAL_OVERRIDE; virtual sal_uInt32 getId() const SAL_OVERRIDE;
virtual Value::Pointer_t getValue() SAL_OVERRIDE; virtual Value::Pointer_t getValue() SAL_OVERRIDE;
virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() SAL_OVERRIDE; virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() SAL_OVERRIDE;
virtual writerfilter::Reference<Stream>::Pointer_t getStream() SAL_OVERRIDE; virtual writerfilter::Reference<Stream>::Pointer_t getStream() SAL_OVERRIDE;
virtual writerfilter::Reference<Properties>::Pointer_t getProps() SAL_OVERRIDE; virtual writerfilter::Reference<Properties>::Pointer_t getProps() SAL_OVERRIDE;
virtual Kind getKind() SAL_OVERRIDE; virtual Kind getKind() SAL_OVERRIDE;
virtual std::string getName() const SAL_OVERRIDE; virtual std::string getName() const SAL_OVERRIDE;
virtual std::string toString() const SAL_OVERRIDE; virtual std::string toString() const SAL_OVERRIDE;
private: private:
Id m_nKeyword; Id m_nKeyword;
RTFValue::Pointer_t& m_pValue; RTFValue::Pointer_t& m_pValue;
}; };
} // namespace rtftok } // namespace rtftok
} // namespace writerfilter } // namespace writerfilter
#endif // INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSPRM_HXX #endif // INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSPRM_HXX
......
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