/* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ /* AbiWord * Copyright (C) 1998 AbiSource, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ #ifndef PD_STYLE_H #define PD_STYLE_H #include "ut_types.h" #include "pt_Types.h" #include "ut_xml.h" #include "pp_Property.h" class pt_PieceTable; ////////////////////////////////////////////////////////////////// // PD_Style is the representation for an individual style. class ABI_EXPORT PD_Style { public: PD_Style(pt_PieceTable * pPT, PT_AttrPropIndex indexAP, GQuark name = NULL); virtual ~PD_Style(); const PP_PropertyType * getPropertyType(PT_Property name, tProperty_type Type) const; inline PT_AttrPropIndex getIndexAP(void) const { return m_indexAP; }; bool setIndexAP(PT_AttrPropIndex indexAP); bool getProperty(PT_Property name, GQuark & value) const; bool getAttribute(PT_Attribute name, GQuark & value) const; bool getPropertyExpand(PT_Property name, GQuark & value); bool getAttributeExpand(PT_Attribute name, GQuark & value); PD_Style * getBasedOn(void); PD_Style * getFollowedBy(void); virtual bool isUserDefined(void) const { return true; }; void used(UT_sint32 count); bool isUsed(void) const; bool isCharStyle(void) const; bool isList(void); bool addProperty(PT_Property name, GQuark); bool addProperties(const PT_PropertyPair * pProperties); bool setAllAttributes(const PT_AttributePair * pAtts); bool addAttributes(const PT_AttributePair * pAtts); bool getAllProperties( PT_PropertyVector & vProps, UT_sint32 depth); bool getAllAttributes( PT_AttributeVector & vAttribs, UT_sint32 depth); size_t getPropertyCount(void) const; size_t getAttributeCount(void) const; inline GQuark getName (void) const {return m_name;} protected: bool _getPropertyExpand(PT_Property name, GQuark & value, UT_sint32 iDepth); bool _getAttributeExpand(PT_Attribute name, GQuark & value, UT_sint32 iDepth); pt_PieceTable * m_pPT; PT_AttrPropIndex m_indexAP; GQuark m_name; UT_sint32 m_iUsed; // lazily-bound attribute caches to speed lookups PD_Style * m_pBasedOn; PD_Style * m_pFollowedBy; }; ////////////////////////////////////////////////////////////////// // PD_BuiltinStyle class ABI_EXPORT PD_BuiltinStyle : public PD_Style { public: PD_BuiltinStyle(pt_PieceTable * pPT, PT_AttrPropIndex indexAP, GQuark name); virtual ~PD_BuiltinStyle(); virtual bool isUserDefined(void) const {return (m_indexAP != m_indexAPOrig);} protected: PT_AttrPropIndex m_indexAPOrig; // the builtin one }; #endif /* PD_STYLE_H */