• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pp_Revision.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 2002 Tomas Frydrych <tomas@frydrych.uklinux.net>
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00017  * 02111-1307, USA.
00018  */
00019 
00020 #ifndef PT_REVISION_H
00021 #define PT_REVISION_H
00022 
00023 #include "ut_types.h"
00024 #include "ut_string_class.h"
00025 #include "ut_vector.h"
00026 #include "pp_AttrProp.h"
00027 
00028 class PD_Document;
00029 
00030 ABI_EXPORT const char* UT_getAttribute( const PP_AttrProp* pAP, const char* name, const char* def = 0 );
00035 ABI_EXPORT std::string UT_getLatestAttribute( const PP_AttrProp* pAP,
00036                                               const char* name,
00037                                               const char* def );
00038 
00039 
00040 typedef enum {
00041     PP_REVISION_NONE             = 0,
00042     PP_REVISION_ADDITION         = 0x01,
00043     PP_REVISION_DELETION         = 0x02,
00044     PP_REVISION_FMT_CHANGE       = 0x04,
00045     PP_REVISION_ADDITION_AND_FMT = 0x05
00046 } PP_RevisionType;
00047 
00053 class ABI_EXPORT PP_Revision: public PP_AttrProp
00054 {
00055   public:
00056     PP_Revision(UT_uint32 Id,
00057                 PP_RevisionType eType,
00058                 const gchar *  props,
00059                 const gchar * attrs);
00060 
00061     PP_Revision(UT_uint32 Id,
00062                 PP_RevisionType eType,
00063                 const gchar ** props,
00064                 const gchar ** attrs);
00065 
00066     virtual ~PP_Revision(){};
00067 
00068     UT_uint32        getId()    const {return m_iID;}
00069     void             setId(UT_uint32 iId) {UT_ASSERT_HARMLESS( iId >= m_iID); m_iID = iId;}
00070 
00071     PP_RevisionType  getType()  const {return m_eType;}
00072     void             setType(PP_RevisionType t) {m_eType = t; m_bDirty = true;}
00073 
00074     const gchar * getPropsString() const;
00075     const gchar * getAttrsString() const;
00076 
00077     // this is intentionally not virtual (no need for that)
00078     bool    setAttributes(const gchar ** attributes);
00079 
00080     bool operator == (const PP_Revision &op2) const;
00081 
00082 //    PP_Revision* clone() const;
00083 
00084     std::string toString() const;
00085     bool onlyContainsAbiwordChangeTrackingMarkup() const;
00086 
00087   private:
00088     void             _refreshString() const;
00089     bool             _handleNestedRevAttr();
00090 
00091     UT_uint32        m_iID;
00092     PP_RevisionType  m_eType;
00093     // these next three are a cache, therefor mutable
00094     mutable UT_String        m_sXMLProps;
00095     mutable UT_String        m_sXMLAttrs;
00096     mutable bool             m_bDirty;
00097 };
00098 
00099 
00100 
00133 class ABI_EXPORT PP_RevisionAttr
00134 {
00135   public:
00136     PP_RevisionAttr()
00137         :m_vRev(),m_sXMLstring(),m_bDirty(true),m_iSuperfluous(0),m_pLastRevision(NULL)
00138         {};
00139     PP_RevisionAttr(const gchar * r);
00140 
00141 
00142     PP_RevisionAttr(UT_uint32 iId, PP_RevisionType eType, const gchar ** pAttrs, const gchar ** pProps);
00143 
00144     ~PP_RevisionAttr();
00145 
00146     void                  setRevision(const gchar * r);
00147     void                  setRevision(std::string&  r);
00148 
00149     void                  addRevision(UT_uint32 iId,
00150                                       PP_RevisionType eType,
00151                                       const gchar ** pAttrs,
00152                                       const gchar ** pProps);
00153     void                  addRevision(UT_uint32 iId, PP_RevisionType eType );
00154     // No ownership of the given revision is taken.
00155     void                  addRevision( const PP_Revision* r );
00156 
00157     bool                  changeRevisionType(UT_uint32 iId, PP_RevisionType eType);
00158     bool                  changeRevisionId(UT_uint32 iOldId, UT_uint32 iNewId);
00159 
00160     void                  removeRevisionIdWithType(UT_uint32 iId, PP_RevisionType eType);
00161     void                  removeRevisionIdTypeless(UT_uint32 iId);
00162     void                  removeAllLesserOrEqualIds(UT_uint32 id);
00163     void                  removeAllHigherOrEqualIds(UT_uint32 id);
00164     void                  removeRevision(const PP_Revision * pRev);
00165 
00166     const PP_Revision *   getGreatestLesserOrEqualRevision(UT_uint32 id,
00167                                                            const PP_Revision ** ppR) const;
00168     const PP_Revision *   getLowestGreaterOrEqualRevision(UT_uint32 id) const;
00169 
00170     const PP_Revision *   getLastRevision() const;
00171     const PP_Revision *   getRevisionWithId(UT_uint32 iId, UT_uint32 & iMinId) const;
00172     UT_uint32             getHighestId() const;
00173 
00174     UT_uint32             getRevisionsCount() const {return m_vRev.getItemCount();}
00175     bool                  empty() const { return !getRevisionsCount(); }
00176     const PP_Revision *   getNthRevision(UT_uint32 n) const {return (const PP_Revision*)m_vRev.getNthItem(n);}
00177 
00178     void                  pruneForCumulativeResult(PD_Document * pDoc);
00179 
00185     bool                  isVisible(UT_uint32 id) const;
00186     bool                  hasProperty(UT_uint32 iId, const gchar * pName, const gchar * &pValue) const;
00187     bool                  hasProperty(const gchar * pName, const gchar * &pValue) const;
00188     PP_RevisionType       getType(UT_uint32 iId) const;
00189     PP_RevisionType       getType() const;
00190     UT_uint32             getHighestRevisionNumberWithAttribute( const gchar * pName ) const;
00191 #if 0
00192     const UT_Vector *     getProps(UT_uint32 iId);
00193     const UT_Vector *     getProps();
00194 #endif
00195     const gchar *      getXMLstring() const;
00196     std::string        getXMLstringUpTo( UT_uint32 iId ) const;
00197     void                  forceDirty() {m_bDirty = true;}
00198     bool                  isFragmentSuperfluous() const;
00199 
00200     bool operator== (const PP_RevisionAttr &op2) const;
00201 
00202     // MIQ: This would be nice, but there are ownership issues I don't know about with M
00203 //    PP_RevisionAttr& operator=(const PP_RevisionAttr &rhs);
00204 
00205     void mergeAll( const PP_RevisionAttr& ra );
00206     void mergeAttr( UT_uint32 iId, PP_RevisionType t,
00207                     const gchar* pzName, const gchar* pzValue );
00208     void mergeAttrIfNotAlreadyThere( UT_uint32 iId, PP_RevisionType t,
00209                                      const gchar* pzName, const gchar* pzValue );
00210 
00211     const PP_Revision *   getLowestDeletionRevision() const;
00212 
00213 
00214   private:
00215     void _init(const gchar *r);
00216     void _clear();
00217     void _refreshString() const;
00218 
00219     UT_Vector           m_vRev;
00220     // these next 2 are a cache, hence mutable
00221     mutable UT_String           m_sXMLstring;
00222     mutable bool                m_bDirty; // indicates whether m_sXMLstring corresponds
00223                                   // to current state of the instance
00224     UT_uint32           m_iSuperfluous;
00225     // also a cache
00226     mutable const PP_Revision * m_pLastRevision;
00227 };
00228 
00229 #endif // #ifndef PT_REVISION_H

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1