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

pp_Revision.h

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

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1