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