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., 59 Temple Place - Suite 330, Boston, MA 00020 * 02111-1307, USA. 00021 */ 00022 00023 #ifndef _OXML_SECTION_H_ 00024 #define _OXML_SECTION_H_ 00025 00026 // Internal includes 00027 #include <OXML_Types.h> 00028 #include <OXML_ObjectWithAttrProp.h> 00029 #include <OXML_Element.h> 00030 00031 // AbiWord includes 00032 #include <ut_types.h> 00033 #include <pd_Document.h> 00034 00035 // External includes 00036 #include <string> 00037 #include <vector> 00038 #include <map> 00039 #include <boost/shared_ptr.hpp> 00040 00041 class OXML_Section; 00042 class IE_Exp_OpenXML; 00043 00044 typedef boost::shared_ptr<OXML_Section> OXML_SharedSection; 00045 00046 /* \class OXML_Section 00047 * \brief This class represents a single section in the OpenXML data model. 00048 * It holds references to all its content, as well as references 00049 * to all its corresponding headers and footers. 00050 */ 00051 class OXML_Section : public OXML_ObjectWithAttrProp 00052 { 00053 public: 00054 OXML_Section(); 00055 OXML_Section(const std::string & id); 00056 virtual ~OXML_Section(); 00057 00058 const std::string & getId() const 00059 { return m_id; } 00060 OXML_SectionBreakType getBreakType() const 00061 { return m_breakType; } 00062 void setBreakType(OXML_SectionBreakType br) 00063 { m_breakType = br; } 00064 00065 const char * getHeaderId(OXML_HeaderFooterType type) const 00066 { return m_headerIds[type]; } 00067 const char * getFooterId(OXML_HeaderFooterType type) const 00068 { return m_footerIds[type]; } 00069 void setHeaderId(const char * id, OXML_HeaderFooterType type) 00070 { m_headerIds[type] = g_strdup(id); } 00071 void setFooterId(const char * id, OXML_HeaderFooterType type) 00072 { m_footerIds[type] = g_strdup(id); } 00073 00074 bool operator ==(const std::string & id); 00075 friend bool operator ==(const OXML_SharedSection& lhs, const std::string & id); 00076 00077 OXML_SharedElement getElement(const std::string & id); 00078 UT_Error appendElement(OXML_SharedElement obj); 00079 inline void setChildren(OXML_ElementVector c) { m_children = c; } 00080 UT_Error clearChildren(); 00081 00083 00086 UT_Error serialize(IE_Exp_OpenXML* exporter); 00087 UT_Error serializeProperties(IE_Exp_OpenXML* exporter); 00088 void applyDocumentProperties(); 00089 00090 UT_Error serializeHeader(IE_Exp_OpenXML* exporter); 00091 UT_Error serializeFooter(IE_Exp_OpenXML* exporter); 00092 UT_Error serializeFootnote(IE_Exp_OpenXML* exporter); 00093 UT_Error serializeEndnote(IE_Exp_OpenXML* exporter); 00094 00096 00099 UT_Error addToPT(PD_Document * pDocument); 00100 UT_Error addToPTAsHdrFtr(PD_Document * pDocument); 00101 UT_Error addToPTAsFootnote(PD_Document * pDocument); 00102 UT_Error addToPTAsEndnote(PD_Document * pDocument); 00103 00104 void setTarget(int target); 00105 bool hasFirstPageHdrFtr(); 00106 bool hasEvenPageHdrFtr(); 00107 00108 UT_Error setPageMargins(const std::string & top, const std::string & left, const std::string & right, const std::string & bottom); 00109 00110 private: 00111 std::string m_id; 00112 OXML_SectionBreakType m_breakType; 00113 OXML_ElementVector m_children; 00114 char * m_headerIds[3]; 00115 char * m_footerIds[3]; 00116 int TARGET; 00117 00118 UT_Error _setReferenceIds(); 00119 }; 00120 00121 00122 typedef std::vector< OXML_SharedSection > OXML_SectionVector; 00123 typedef std::map<std::string, OXML_SharedSection > OXML_SectionMap; 00124 00125 inline bool operator ==(const OXML_SharedSection& lhs, const std::string & id) 00126 { 00127 return (*lhs) == id; 00128 } 00129 00130 #endif //_OXML_SECTION_H_ 00131
1.7.1