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

pp_AttrProp.h

Go to the documentation of this file.
00001 /* AbiWord
00002  * Copyright (C) 1998 AbiSource, Inc.
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 
00021 #ifndef PP_ATTRPROP_H
00022 #define PP_ATTRPROP_H
00023 
00024 #include <utility>
00025 
00026 #include "ut_types.h"
00027 #include "ut_hash.h"
00028 #include "ut_vector.h"
00029 #include "ut_xml.h"
00030 #include "pp_Property.h"
00031 #include "pt_Types.h"
00032 
00033 class PD_Document;
00034 
00035 // the following class holds the state of the view when we set
00036 // m_iRevisionIndex
00037 class ABI_EXPORT PP_RevisionState
00038 {
00039   public:
00040     PP_RevisionState()
00041         :m_iId(0),
00042         m_bShow(false),
00043         m_bMark(false)
00044     {
00045     }
00046 
00047     bool operator == (const PP_RevisionState & rs) const
00048          {
00049              if(rs.m_iId == m_iId && rs.m_bShow == m_bShow && rs.m_bMark == m_bMark)
00050                  return true;
00051              return false;
00052          }
00053 
00054     bool isEqual(UT_uint32 iId, bool bShow, bool bMark) const
00055          {
00056              if(m_iId == iId && m_bShow == bShow && m_bMark == bMark)
00057                  return true;
00058              return false;
00059          }
00060 
00061     UT_uint32 m_iId;
00062     bool      m_bShow;
00063     bool      m_bMark;
00064 };
00065 
00066 
00067 // PP_AttrProp captures the complete set of XML and CSS
00068 // Attributes/Properties for a piece of the document.
00069 // These are generally created by the file-reader.  Attributes
00070 // represent all of the attribute/value pairs in the XML with
00071 // the exception of the PT_PROPS_ATTRIBUTE_NAME attribute.
00072 // The value of the this attribute is parsed into CSS properties.
00073 // PP_AttrProp just provides a pair of association lists
00074 // (one for attributes and one for properties), it does not
00075 // know the meaning of any of them.
00076 
00077 class ABI_EXPORT PP_AttrProp
00078 {
00079 public:
00080     PP_AttrProp();
00081     virtual ~PP_AttrProp();
00082 
00083     // The "gchar **" is an argv-like thing containing
00084     // multiple sets of name/value pairs.  names are in the
00085     // even cells; values are in the odd.  the list is
00086     // terminated by a null name.
00087 
00088     bool    setAttributes(const gchar ** attributes);
00089     bool    setAttributes(const UT_GenericVector<const gchar*> * pVector);
00090     bool    setProperties(const gchar ** properties);
00091     bool    setProperties(const UT_GenericVector<gchar*> * pVector);
00092 
00093     const gchar ** getAttributes () const { return m_pAttributes ? m_pAttributes->list () : 0; }
00094     const gchar ** getProperties () const;
00095 
00096     bool    setAttribute(const gchar * szName, const gchar * szValue);
00097     bool    setProperty(const gchar * szName, const gchar * szValue);
00098 
00099     bool    getNthAttribute(int ndx, const gchar *& szName, const gchar *& szValue) const;
00100     bool    getNthProperty(int ndx, const gchar *& szName, const gchar *& szValue) const;
00101 
00102     bool getAttribute(const gchar * szName, const gchar *& szValue) const;
00103     bool getProperty(const gchar * szName, const gchar *& szValue) const;
00104     const PP_PropertyType *getPropertyType(const gchar * szName, tProperty_type Type) const;
00105 
00106     bool hasProperties(void) const;
00107     bool hasAttributes(void) const;
00108     size_t getPropertyCount (void) const;
00109     size_t getAttributeCount (void) const;
00110     bool areAlreadyPresent(const gchar ** attributes, const gchar ** properties) const;
00111     bool areAnyOfTheseNamesPresent(const gchar ** attributes, const gchar ** properties) const;
00112     bool isExactMatch(const PP_AttrProp * pMatch) const;
00113     bool isEquivalent(const PP_AttrProp * pAP2) const;
00114     bool isEquivalent(const gchar ** attrs, const gchar ** props) const;
00115 
00116     PP_AttrProp * createExactly(const gchar ** attributes,
00117                     const gchar ** properties) const;
00118 
00119     PP_AttrProp * cloneWithReplacements(const gchar ** attributes,
00120                                         const gchar ** properties,
00121                                         bool bClearProps) const;
00122     PP_AttrProp * cloneWithElimination(const gchar ** attributes,
00123                                        const gchar ** properties) const;
00124     PP_AttrProp * cloneWithEliminationIfEqual(const gchar ** attributes,
00125                                        const gchar ** properties) const;
00126 
00127     void markReadOnly(void);
00128     UT_uint32 getCheckSum(void) const;
00129 
00130     void operator = (const PP_AttrProp &Other);
00131     UT_uint32 getIndex(void) const; //$HACK
00132     void setIndex(UT_uint32 i); //$HACK
00133 
00134     /* m_iRevisionIndex points to a AP that has our revision attribute
00135        inflated into actual attributes and properties; since the
00136        inflation is view-dependent, we need to keep track of the view
00137        state */
00138     PT_AttrPropIndex   getRevisedIndex() const {return m_iRevisedIndex;}
00139     PP_RevisionState & getRevisionState() const {return m_RevisionState;}
00140 
00141     void               setRevisedIndex (PT_AttrPropIndex i, UT_uint32 iId, bool bShow, bool bMark, bool bHidden) const
00142                            {
00143                                m_iRevisedIndex = i; m_RevisionState.m_iId = iId;
00144                                m_RevisionState.m_bShow = bShow; m_RevisionState.m_bMark = bMark;
00145                                m_bRevisionHidden = bHidden;
00146                            }
00147 
00148     bool               getRevisionHidden() const {return m_bRevisionHidden;}
00149 
00150     void prune();
00151     bool explodeStyle(const PD_Document * pDoc, bool bOverwrite = false);
00152 
00153     void miniDump(const PD_Document * pDoc) const;
00154 
00155 protected:
00156     void _computeCheckSum(void);
00157     void _clearEmptyProperties();
00158     void _clearEmptyAttributes();
00159 
00160 
00161     typedef std::pair<const gchar*,const PP_PropertyType *> PropertyPair;
00162 
00163     UT_GenericStringMap<gchar*> * m_pAttributes; // of gchar*
00164     UT_GenericStringMap<PropertyPair*> * m_pProperties; // of PropertyPair
00165 
00166     bool                m_bIsReadOnly;
00167     UT_uint32           m_checkSum;
00168     UT_uint32           m_index;    //$HACK
00169     mutable const gchar **   m_szProperties;
00170 
00171     mutable PT_AttrPropIndex    m_iRevisedIndex;
00172     mutable PP_RevisionState    m_RevisionState;
00173     mutable bool                m_bRevisionHidden;
00174 };
00175 
00176 #endif /* PP_ATTRPROP_H */

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1