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

OXML_Element.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiSource
00004  *
00005  * Copyright (C) 2007 Philippe Milot <PhilMilot@gmail.com>
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
00021  */
00022 
00023 #ifndef _OXML_ELEMENT_H_
00024 #define _OXML_ELEMENT_H_
00025 
00026 // Internal includes
00027 #include <OXML_Types.h>
00028 #include <OXML_ObjectWithAttrProp.h>
00029 #include "OXML_Style.h"
00030 #include "OXML_List.h"
00031 #include "OXML_Image.h"
00032 
00033 // AbiWord includes
00034 #include <ut_types.h>
00035 #include <pp_AttrProp.h>
00036 #include <pd_Document.h>
00037 
00038 // External includes
00039 #include <string>
00040 #include <vector>
00041 #include <map>
00042 #include <boost/shared_ptr.hpp>
00043 
00044 class OXML_Element;
00045 class IE_Exp_OpenXML;
00046 
00047 typedef boost::shared_ptr<OXML_Element> OXML_SharedElement;
00048 typedef std::vector<OXML_SharedElement> OXML_ElementVector;
00049 
00050 /* \class OXML_Element
00051  * \brief This class represents any element in the OpenXML data model.
00052  * OXML_Element can represent any tag, whether it is block-level or character-level.
00053  * The tags it can represent are listed in the ElementTag enum of OXML_Types.h.
00054  * If additional logic is required for a specific tag, this class can be derived
00055  * (see the documentation on the virtual methods in this case).
00056 */
00057 class OXML_Element : public OXML_ObjectWithAttrProp
00058 {
00059 public:
00065     OXML_Element(const std::string & id, OXML_ElementTag tag, OXML_ElementType type);
00066     virtual ~OXML_Element();
00067 
00068     inline const std::string & getId() const { return m_id; }
00069     inline void setId(const std::string & id) { m_id = id; }
00070     inline OXML_ElementTag getTag() const { return m_tag; }
00071     inline OXML_ElementType getType() const { return m_type; }
00072     inline void setType(OXML_ElementType type) { m_type = type; }
00073 
00074     bool operator ==(const std::string & id);
00075     friend bool operator ==(const OXML_SharedElement& lhs, const std::string & id) { return (*lhs) == id; }
00076 
00077     OXML_SharedElement getElement(const std::string & id) const;
00078     UT_Error appendElement(const OXML_SharedElement & obj);
00079     inline const OXML_ElementVector & getChildren() const { return m_children; }
00080     UT_Error clearChildren();
00081 
00083 
00088     virtual UT_Error serialize(IE_Exp_OpenXML* exporter);
00090 
00095     virtual UT_Error addToPT(PD_Document * pDocument);
00097 
00099     UT_Error addChildrenToPT(PD_Document * pDocument);
00100 
00101     void setTarget(int target);
00102 
00103 protected:
00105 
00107     UT_Error serializeChildren(IE_Exp_OpenXML* exporter);
00108 
00109     int TARGET;
00110 
00111 private:
00112     std::string m_id;
00113     OXML_ElementTag m_tag;
00114     OXML_ElementType m_type;
00115     OXML_ElementVector m_children;
00116 
00117 };
00118 
00119 typedef std::map<std::string, OXML_SharedStyle > OXML_StyleMap;
00120 typedef std::map<UT_uint32, OXML_SharedList > OXML_ListMap;
00121 typedef std::map<std::string, OXML_SharedImage > OXML_ImageMap;
00122 
00123 #endif //_OXML_ELEMENT_H_
00124 

Generated on Wed Jun 19 2013 for AbiWord by  doxygen 1.7.1