00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef RVNGRAWGENERATORBASE_H
00022 #define RVNGRAWGENERATORBASE_H
00023
00024 #include <stack>
00025 #include <librevenge/librevenge.h>
00026
00027 #ifdef RVNG_CALLGRAPH_ENTER
00028 #warning who defined RVNG_CALLGRAPH_ENTER?
00029 #undef RVNG_CALLGRAPH_ENTER
00030 #endif
00031
00032 #define RVNG_CALLGRAPH_ENTER(M, L) \
00033 m_impl->m_atLeastOneCallback = true; \
00034 if (!m_impl->m_printCallgraphScore) \
00035 m_impl->iuprintf M; \
00036 else \
00037 m_impl->m_callStack.push(L);
00038
00039 #ifdef RVNG_CALLGRAPH_LEAVE
00040 #warning who defined RVNG_CALLGRAPH_LEAVE?
00041 #undef RVNG_CALLGRAPH_LEAVE
00042 #endif
00043
00044 #define RVNG_CALLGRAPH_LEAVE(M, L) \
00045 m_impl->m_atLeastOneCallback = true; \
00046 if (!m_impl->m_printCallgraphScore) \
00047 m_impl->idprintf M; \
00048 else \
00049 { \
00050 if (m_impl->m_callStack.empty()) \
00051 { \
00052 m_impl->m_callbackMisses++; \
00053 } \
00054 else \
00055 { \
00056 const int lc = m_impl->m_callStack.top(); \
00057 if (lc != L) \
00058 m_impl->m_callbackMisses++; \
00059 m_impl->m_callStack.pop(); \
00060 } \
00061 }
00062
00063 namespace librevenge
00064 {
00065
00066 namespace
00067 {
00068
00069 enum RVNGCallback
00070 {
00071 CALLBACK_OPEN_ANIMATION_GROUP,
00072 CALLBACK_OPEN_ANIMATION_ITERATION,
00073 CALLBACK_OPEN_ANIMATION_SEQUENCE,
00074 CALLBACK_OPEN_CHART,
00075 CALLBACK_OPEN_CHART_TEXTOBJECT,
00076 CALLBACK_OPEN_CHART_PLOTAREA,
00077 CALLBACK_OPEN_CHART_SERIE,
00078 CALLBACK_OPEN_COMMENT,
00079 CALLBACK_OPEN_ENDNOTE,
00080 CALLBACK_OPEN_FOOTNOTE,
00081 CALLBACK_OPEN_FRAME,
00082 CALLBACK_OPEN_GRAPHIC,
00083 CALLBACK_OPEN_GRAPHIC_LAYER,
00084 CALLBACK_OPEN_GRAPHIC_PAGE,
00085 CALLBACK_OPEN_GROUP,
00086 CALLBACK_OPEN_HEADER_FOOTER,
00087 CALLBACK_OPEN_LINK,
00088 CALLBACK_OPEN_LIST_ELEMENT,
00089 CALLBACK_OPEN_ORDERED_LIST_LEVEL,
00090 CALLBACK_OPEN_PAGE_SPAN,
00091 CALLBACK_OPEN_PARAGRAPH,
00092 CALLBACK_OPEN_SECTION,
00093 CALLBACK_OPEN_SHEET,
00094 CALLBACK_OPEN_SHEET_CELL,
00095 CALLBACK_OPEN_SHEET_ROW,
00096 CALLBACK_OPEN_SPAN,
00097 CALLBACK_OPEN_TABLE,
00098 CALLBACK_OPEN_TABLE_CELL,
00099 CALLBACK_OPEN_TABLE_ROW,
00100 CALLBACK_OPEN_TEXT_BOX,
00101 CALLBACK_OPEN_UNORDERED_LIST_LEVEL,
00102 CALLBACK_START_COMMENT,
00103 CALLBACK_START_DOCUMENT,
00104 CALLBACK_START_EMBEDDED_GRAPHICS,
00105 CALLBACK_START_LAYER,
00106 CALLBACK_START_NOTES,
00107 CALLBACK_START_PAGE,
00108 CALLBACK_START_MASTER_PAGE,
00109 CALLBACK_START_SLIDE,
00110 CALLBACK_START_MASTER_SLIDE,
00111 CALLBACK_START_TEXT_OBJECT
00112 };
00113
00114 }
00115
00116 struct RVNGRawGeneratorBase
00117 {
00118 explicit RVNGRawGeneratorBase(bool printCallgraphScore);
00119 virtual ~RVNGRawGeneratorBase();
00120
00121 int m_indent;
00122 int m_callbackMisses;
00123 bool m_atLeastOneCallback;
00124 bool m_printCallgraphScore;
00125 std::stack<int> m_callStack;
00126
00127 void indentUp()
00128 {
00129 m_indent++;
00130 }
00131 void indentDown()
00132 {
00133 if (m_indent > 0) m_indent--;
00134 }
00135
00136 void iprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3);
00137 void iuprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3);
00138 void idprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3);
00139 };
00140
00141 }
00142
00143 #endif // RVNGRAWGENERATORBASE_H
00144
00145