1 /* AbiWord 2 * Copyright (C) 1998 AbiSource, Inc. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 * 02110-1301 USA. 18 */ 19 20 21 #ifndef IE_EXP_DOCBOOK_H 22 #define IE_EXP_DOCBOOK_H 23 24 #include "ie_exp.h" 25 #include "pl_Listener.h" 26 #include "pp_AttrProp.h" 27 #include "ut_stack.h" 28 #include "ie_Table.h" 29 30 class PD_Document; 31 class s_DocBook_Listener; 32 33 // The exporter/writer for DocBook 34 35 class IE_Exp_DocBook_Sniffer : public IE_ExpSniffer 36 { 37 friend class IE_Exp; 38 39 public: 40 IE_Exp_DocBook_Sniffer (const char * name); ~IE_Exp_DocBook_Sniffer()41 virtual ~IE_Exp_DocBook_Sniffer () {} 42 43 virtual bool recognizeSuffix (const char * szSuffix); 44 virtual bool getDlgLabels (const char ** szDesc, 45 const char ** szSuffixList, 46 IEFileType * ft); 47 virtual UT_Error constructExporter (PD_Document * pDocument, 48 IE_Exp ** ppie); 49 }; 50 51 52 class IE_Exp_DocBook : public IE_Exp 53 { 54 public: 55 IE_Exp_DocBook(PD_Document * pDocument); 56 virtual ~IE_Exp_DocBook(); 57 58 void iwrite (const char *); 59 void writeln (const char *); 60 int indent (void); 61 int unindent (void); 62 63 protected: 64 virtual UT_Error _writeDocument(void); 65 int s_align; 66 67 private: 68 s_DocBook_Listener * m_pListener; 69 }; 70 71 72 class s_DocBook_Listener : public PL_Listener 73 { 74 public: 75 s_DocBook_Listener(PD_Document * pDocument, 76 IE_Exp_DocBook * pie); 77 virtual ~s_DocBook_Listener(); 78 79 virtual bool populate(fl_ContainerLayout* sfh, 80 const PX_ChangeRecord * pcr); 81 82 virtual bool populateStrux(pf_Frag_Strux* sdh, 83 const PX_ChangeRecord * pcr, 84 fl_ContainerLayout* * psfh); 85 86 virtual bool change(fl_ContainerLayout* sfh, 87 const PX_ChangeRecord * pcr); 88 89 virtual bool insertStrux(fl_ContainerLayout* sfh, 90 const PX_ChangeRecord * pcr, 91 pf_Frag_Strux* sdh, 92 PL_ListenerId lid, 93 void (* pfnBindHandles)(pf_Frag_Strux* sdhNew, 94 PL_ListenerId lid, 95 fl_ContainerLayout* sfhNew)); 96 97 virtual bool signal(UT_uint32 iSignal); 98 virtual bool _initFile(void); 99 virtual void _closeFile(void); 100 protected: 101 102 void _tagClose(UT_uint32 tagID, const UT_UTF8String & content, bool newline=true, bool indent=true, bool decrease=true); 103 void _tagOpen(UT_uint32 tagID, const UT_UTF8String & content, bool newline=true, bool indent=true, bool increase=true); 104 void _tagOpenClose(const UT_UTF8String & content, bool suppress, bool newline=true, bool indent=true); 105 UT_uint32 _tagTop(void); 106 void _closeSection(int sub); 107 void _closeSectionTitle(void); 108 void _closeParagraph(void); 109 void _closeSpan(void); 110 void _closeList(void); 111 void _closeChapter (void); 112 void _closeChapterTitle (void); 113 void _openParagraph(PT_AttrPropIndex api); 114 void _openSection(PT_AttrPropIndex api, int, const UT_UTF8String & content); 115 void _openSectionTitle(void); 116 void _openSpan(PT_AttrPropIndex api); 117 void _openChapter (PT_AttrPropIndex api); 118 void _openChapterTitle (PT_AttrPropIndex api); 119 void _openList(PT_AttrPropIndex api); 120 void _openBlock (bool indent); 121 void _openPlainBlock (); 122 void _handleDocument(void); 123 void _handleMetaData(void); 124 void _handleRevisions(void); 125 void _handleImage(PT_AttrPropIndex api); 126 void _handlePositionedImage(PT_AttrPropIndex api); 127 void _handleMath(PT_AttrPropIndex api); 128 void _handleEmbedded(PT_AttrPropIndex api); 129 void _handleField(const PX_ChangeRecord_Object * pcro, PT_AttrPropIndex api); 130 void _handleTOC(PT_AttrPropIndex api); 131 void _handleHyperlink(PT_AttrPropIndex api); 132 void _handleBookmark(PT_AttrPropIndex api); 133 void _handleHdrFtr(PT_AttrPropIndex api); 134 void _handleFootnote(PT_AttrPropIndex api); 135 void _openTable(PT_AttrPropIndex api); 136 void _openNestedTable(); 137 void _openCell(); 138 void _openRow(void); 139 void _closeNestedTable(void); 140 void _closeTable(void); 141 void _closeCell(void); 142 void _closeRow(void); 143 bool _decideIndent(void); 144 bool _inFormattedSpan(void); 145 bool _inSectionStrux(void); 146 147 void _outputData(const UT_UCSChar * p, UT_uint32 length); 148 void _handleDataItems(void); 149 void _convertFontSize(char* szDest, const char* pszFontSize); 150 void _convertColor(char* szDest, const char* pszColor); 151 152 const UT_UTF8String _getProps(PT_AttrPropIndex api); 153 154 PD_Document * m_pDocument; 155 IE_Exp_DocBook * m_pie; 156 private: 157 158 bool m_bInParagraph; 159 bool m_bInSection; 160 bool m_bInSpan; 161 bool m_bInChapter; 162 bool m_bInTable; 163 bool m_bInTitle; 164 bool m_bInFrame; 165 bool m_bInHdrFtr; 166 bool m_bInNote; 167 int m_iNestedTable; 168 int m_iTableDepth; 169 int m_iListDepth; 170 int m_iPreviousListDepth; 171 int m_iSectionDepth; 172 int m_iLastClosed; 173 UT_UTF8String m_sLastStyle; 174 UT_UTF8String m_sParentStyle; 175 const PP_AttrProp* m_pAP_Span; 176 177 // Need to look up proper type, and place to stick #defines... 178 179 UT_uint16 m_iBlockType; // BT_* 180 bool m_bWasSpace; 181 bool m_bExternal; 182 183 UT_Stack m_utsListStack; 184 UT_NumberStack m_utnsTagStack; 185 186 UT_Vector m_utvDataIDs; // list of data ids for image enumeration 187 ie_Table mTableHelper; 188 }; 189 190 #endif /* IE_EXP_DOCBOOK_H */ 191