LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/writerfilter/source/rtftok - rtfsprm.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 14 100.0 %
Date: 2013-07-09 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #ifndef _RTFSPRM_HXX_
      11             : #define _RTFSPRM_HXX_
      12             : 
      13             : #include <boost/intrusive_ptr.hpp>
      14             : #include <rtfcontrolwords.hxx>
      15             : #include <rtfvalue.hxx>
      16             : 
      17             : namespace writerfilter {
      18             :     namespace rtftok {
      19             : 
      20             :         typedef std::vector< std::pair<Id, RTFValue::Pointer_t> > RTFSprmsImplBase;
      21             : 
      22             :         /// The payload of RTFSprms which is only copied on write.
      23       84413 :         class RTFSprmsImpl : public RTFSprmsImplBase
      24             :         {
      25             :         public:
      26             :             sal_Int32 m_nRefCount;
      27       84413 :             RTFSprmsImpl() : RTFSprmsImplBase(), m_nRefCount(0) {}
      28             :         };
      29             : 
      30      613207 :         inline void intrusive_ptr_add_ref(RTFSprmsImpl* p)
      31             :         {
      32      613207 :             ++(p->m_nRefCount);
      33      613207 :         }
      34      613207 :         inline void intrusive_ptr_release(RTFSprmsImpl* p)
      35             :         {
      36      613207 :             if (!--(p->m_nRefCount))
      37       84413 :                 delete p;
      38      613207 :         }
      39             : 
      40             :         /// A list of RTFSprm with a copy constructor that performs a deep copy.
      41             :         class RTFSprms
      42             :         {
      43             :         public:
      44             :             typedef ::boost::shared_ptr<RTFSprms> Pointer_t;
      45             :             typedef std::pair<Id, RTFValue::Pointer_t> Entry_t;
      46             :             typedef std::vector<Entry_t>::iterator Iterator_t;
      47             :             RTFSprms();
      48             :             RTFSprms(const RTFSprms& rSprms);
      49             :             ~RTFSprms();
      50             :             RTFSprms& operator=(const RTFSprms& rOther);
      51             :             RTFValue::Pointer_t find(Id nKeyword, bool bFirst = true);
      52             :             /// Does the same as ->push_back(), except that it can overwrite existing entries.
      53             :             void set(Id nKeyword, RTFValue::Pointer_t pValue, bool bOverwrite = true);
      54             :             bool erase(Id nKeyword);
      55             :             /// Removes elements, which are already in the reference set.
      56             :             void deduplicate(RTFSprms& rReference);
      57         540 :             size_t size() const { return m_pSprms->size(); }
      58             :             bool empty() const { return m_pSprms->empty(); }
      59         536 :             Entry_t& back() { return m_pSprms->back(); }
      60       20349 :             Iterator_t begin() { return m_pSprms->begin(); }
      61       51547 :             Iterator_t end() { return m_pSprms->end(); }
      62             :             void clear();
      63             :         private:
      64             :             void ensureCopyBeforeWrite();
      65             :             boost::intrusive_ptr<RTFSprmsImpl> m_pSprms;
      66             :         };
      67             : 
      68             :         /// RTF keyword with a parameter
      69             :         class RTFSprm
      70             :             : public Sprm
      71             :         {
      72             :             public:
      73             :                 RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue);
      74       22050 :                 virtual ~RTFSprm() {}
      75             :                 virtual sal_uInt32 getId() const;
      76             :                 virtual Value::Pointer_t getValue();
      77             :                 virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary();
      78             :                 virtual writerfilter::Reference<Stream>::Pointer_t getStream();
      79             :                 virtual writerfilter::Reference<Properties>::Pointer_t getProps();
      80             :                 virtual Kind getKind();
      81             :                 virtual std::string getName() const;
      82             :                 virtual std::string toString() const;
      83             :             private:
      84             :                 Id m_nKeyword;
      85             :                 RTFValue::Pointer_t& m_pValue;
      86             :         };
      87             :     } // namespace rtftok
      88             : } // namespace writerfilter
      89             : 
      90             : #endif // _RTFSPRM_HXX_
      91             : 
      92             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10