Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _ODI_STREAMLISTENER_H_
00023 #define _ODI_STREAMLISTENER_H_
00024
00025 #include "ut_compiler.h"
00026
00027
00028 #include "ODi_ListenerStateAction.h"
00029 #include "ODi_ElementStack.h"
00030 #include "ODi_FontFaceDecls.h"
00031 #include "ODi_XMLRecorder.h"
00032
00033
00034 ABI_W_NO_CONST_QUAL
00035 #include <gsf/gsf.h>
00036 ABI_W_POP
00037
00038
00039 #include <ut_types.h>
00040 #include <ut_xml.h>
00041 #include <ut_vector.h>
00042
00043
00044 class ODi_Office_Styles;
00045 class ODi_Postpone_ListenerState;
00046 class ODi_Abi_Data;
00047
00048
00049 class PD_Document;
00050
00059 class ODi_StreamListener : public virtual UT_XML::Listener {
00060
00061 public:
00062
00063 ODi_StreamListener(PD_Document* pAbiDocument, GsfInfile* pGsfInfile,
00064 ODi_Office_Styles* pStyles, ODi_Abi_Data& rAbiData,
00065 ODi_ElementStack* pElementStack = NULL);
00066
00067 virtual ~ODi_StreamListener();
00068
00069 void startElement (const gchar* pName, const gchar** ppAtts) {
00070 _startElement(pName, ppAtts, false);
00071 }
00072
00073 void endElement (const gchar* pName) {
00074 _endElement(pName, false);
00075 }
00076
00077 void charData (const gchar* pBuffer, int length);
00078
00079 UT_Error setState(const char* pStateName);
00080 void setState(ODi_ListenerState* pState, bool deleteWhenPop);
00081
00082 void clearFontFaceDecls() {m_fontFaceDecls.clear();}
00083
00084 ODi_ElementStack* getElementStack() {return m_pElementStack;}
00085 ODi_ListenerState* getCurrentState() { return m_pCurrentState; }
00086
00087
00088 private:
00089
00090 void _startElement (const gchar* pName, const gchar** ppAtts,
00091 bool doingRecursion);
00092
00093 void _endElement (const gchar* pName, bool doingRecursion);
00094
00095 void _handleStateAction();
00096 void _clear();
00097 ODi_ListenerState* _createState(const char* pStateName);
00098 void _resumeParsing(ODi_Postpone_ListenerState* pPostponeState);
00099 void _playRecordedElement();
00100
00101 PD_Document* m_pAbiDocument;
00102 GsfInfile* m_pGsfInfile;
00103 ODi_Office_Styles* m_pStyles;
00104 ODi_Abi_Data& m_rAbiData;
00105 ODi_FontFaceDecls m_fontFaceDecls;
00106
00107
00108 ODi_ListenerStateAction m_stateAction;
00109
00110 ODi_ElementStack* m_pElementStack;
00111
00112 enum ODi_StreamListenerAction {
00113 ODI_NONE,
00114 ODI_RECORDING,
00115 ODI_IGNORING
00116 } m_currentAction;
00117
00118
00119 UT_sint32 m_elemenStackSize;
00120
00121 ODi_XMLRecorder m_xmlRecorder;
00122
00123
00125
00126
00127 class StackCell {
00128 public:
00129 StackCell() {m_pState=NULL; m_deleteWhenPop=false;}
00130 StackCell(ODi_ListenerState* pState, bool deleteWhenPop) {
00131 m_deleteWhenPop = deleteWhenPop;
00132 m_pState = pState;
00133 }
00134
00135 StackCell(UT_uint32 ) {m_pState=NULL; m_deleteWhenPop=false;}
00136
00137 StackCell& operator=(const StackCell& sc) {
00138 this->m_deleteWhenPop = sc.m_deleteWhenPop;
00139 this->m_pState = sc.m_pState;
00140
00141 return *this;
00142 }
00143
00144 bool m_deleteWhenPop;
00145 ODi_ListenerState* m_pState;
00146 };
00147
00148 ODi_ListenerState* m_pCurrentState;
00149 bool m_deleteCurrentWhenPop;
00150 bool m_ownStack;
00151
00152 UT_GenericVector <ODi_StreamListener::StackCell> m_stateStack;
00153 UT_GenericVector <ODi_Postpone_ListenerState*> m_postponedParsing;
00154 };
00155
00156 #endif //_ODI_STREAMLISTENER_H_