writerfilter/source/rtftok/rtfsprm.cxx | 11 +- writerfilter/source/rtftok/rtfsprm.hxx | 161 ++++++++++++++++++--------------- 2 files changed, 96 insertions(+), 76 deletions(-)
New commits: commit bde1e4dce3e036d2265e22910156ca6345b596ab Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sat Apr 19 12:03:14 2014 +0200 writerfilter: fix indentation in rtfsprm Change-Id: Id81cb97033e616acf071f386630b49ccb83dfedc diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx index 48ce468..e69f6ed 100644 --- a/writerfilter/source/rtftok/rtfsprm.cxx +++ b/writerfilter/source/rtftok/rtfsprm.cxx @@ -13,12 +13,14 @@ #include <resourcemodel/QNameToString.hxx> -namespace writerfilter { -namespace rtftok { +namespace writerfilter +{ +namespace rtftok +{ RTFSprm::RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue) : m_nKeyword(nKeyword), - m_pValue(pValue) + m_pValue(pValue) { } @@ -156,7 +158,8 @@ void RTFSprms::deduplicate(RTFSprms& rReference) void RTFSprms::ensureCopyBeforeWrite() { - if (m_pSprms->m_nRefCount > 1) { + if (m_pSprms->m_nRefCount > 1) + { 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) pClone->push_back(std::make_pair(i->first, RTFValue::Pointer_t(i->second->Clone()))); diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx index fae97fc..9f811bd 100644 --- a/writerfilter/source/rtftok/rtfsprm.hxx +++ b/writerfilter/source/rtftok/rtfsprm.hxx @@ -20,84 +20,101 @@ #include <rtfcontrolwords.hxx> #include <rtfvalue.hxx> -namespace writerfilter { - namespace rtftok { +namespace writerfilter +{ +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. - class RTFSprmsImpl : public RTFSprmsImplBase - { - public: - sal_Int32 m_nRefCount; - RTFSprmsImpl() : RTFSprmsImplBase(), m_nRefCount(0) {} - }; +/// The payload of RTFSprms which is only copied on write. +class RTFSprmsImpl : public RTFSprmsImplBase +{ +public: + sal_Int32 m_nRefCount; + RTFSprmsImpl() : RTFSprmsImplBase(), m_nRefCount(0) {} +}; - inline void intrusive_ptr_add_ref(RTFSprmsImpl* p) - { - ++(p->m_nRefCount); - } - inline void intrusive_ptr_release(RTFSprmsImpl* p) - { - if (!--(p->m_nRefCount)) - delete p; - } +inline void intrusive_ptr_add_ref(RTFSprmsImpl* p) +{ + ++(p->m_nRefCount); +} +inline void intrusive_ptr_release(RTFSprmsImpl* p) +{ + if (!--(p->m_nRefCount)) + delete p; +} - enum RTFOverwrite - { - 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_IGNORE ///< No, if the key is already in the list, then ignore, otherwise append. - }; +enum RTFOverwrite +{ + 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_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. - class RTFSprms - { - public: - typedef ::boost::shared_ptr<RTFSprms> Pointer_t; - typedef std::pair<Id, RTFValue::Pointer_t> Entry_t; - typedef std::vector<Entry_t>::iterator Iterator_t; - RTFSprms(); - RTFSprms(const RTFSprms& rSprms); - ~RTFSprms(); - RTFSprms& operator=(const RTFSprms& rOther); - 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. - void set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwrite = OVERWRITE_YES); - bool erase(Id nKeyword); - /// Removes elements, which are already in the reference set. - void deduplicate(RTFSprms& rReference); - size_t size() const { return m_pSprms->size(); } - bool empty() const { return m_pSprms->empty(); } - 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; - }; +/// A list of RTFSprm with a copy constructor that performs a deep copy. +class RTFSprms +{ +public: + typedef ::boost::shared_ptr<RTFSprms> Pointer_t; + typedef std::pair<Id, RTFValue::Pointer_t> Entry_t; + typedef std::vector<Entry_t>::iterator Iterator_t; + RTFSprms(); + RTFSprms(const RTFSprms& rSprms); + ~RTFSprms(); + RTFSprms& operator=(const RTFSprms& rOther); + 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. + void set(Id nKeyword, RTFValue::Pointer_t pValue, RTFOverwrite eOverwrite = OVERWRITE_YES); + bool erase(Id nKeyword); + /// Removes elements, which are already in the reference set. + void deduplicate(RTFSprms& rReference); + size_t size() const + { + return m_pSprms->size(); + } + bool empty() const + { + return m_pSprms->empty(); + } + 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 - class RTFSprm - : public Sprm - { - public: - RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue); - virtual ~RTFSprm() {} - virtual sal_uInt32 getId() const SAL_OVERRIDE; - virtual Value::Pointer_t getValue() SAL_OVERRIDE; - virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() SAL_OVERRIDE; - virtual writerfilter::Reference<Stream>::Pointer_t getStream() SAL_OVERRIDE; - virtual writerfilter::Reference<Properties>::Pointer_t getProps() SAL_OVERRIDE; - virtual Kind getKind() SAL_OVERRIDE; - virtual std::string getName() const SAL_OVERRIDE; - virtual std::string toString() const SAL_OVERRIDE; - private: - Id m_nKeyword; - RTFValue::Pointer_t& m_pValue; - }; - } // namespace rtftok +/// RTF keyword with a parameter +class RTFSprm + : public Sprm +{ +public: + RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue); + virtual ~RTFSprm() {} + virtual sal_uInt32 getId() const SAL_OVERRIDE; + virtual Value::Pointer_t getValue() SAL_OVERRIDE; + virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() SAL_OVERRIDE; + virtual writerfilter::Reference<Stream>::Pointer_t getStream() SAL_OVERRIDE; + virtual writerfilter::Reference<Properties>::Pointer_t getProps() SAL_OVERRIDE; + virtual Kind getKind() SAL_OVERRIDE; + virtual std::string getName() const SAL_OVERRIDE; + virtual std::string toString() const SAL_OVERRIDE; +private: + Id m_nKeyword; + RTFValue::Pointer_t& m_pValue; +}; +} // namespace rtftok } // namespace writerfilter #endif // INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFSPRM_HXX _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits