| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef RVNGRAWGENERATORBASE_H |
| 22 |
#define RVNGRAWGENERATORBASE_H |
| 23 |
|
| 24 |
#include <stack> |
| 25 |
#include <librevenge/librevenge.h> |
| 26 |
|
| 27 |
#ifdef RVNG_CALLGRAPH_ENTER |
| 28 |
#warning who defined RVNG_CALLGRAPH_ENTER? |
| 29 |
#undef RVNG_CALLGRAPH_ENTER |
| 30 |
#endif |
| 31 |
|
| 32 |
#define RVNG_CALLGRAPH_ENTER(M, L) \ |
| 33 |
m_impl->m_atLeastOneCallback = true; \ |
| 34 |
if (!m_impl->m_printCallgraphScore) \ |
| 35 |
m_impl->iuprintf M; \ |
| 36 |
else \ |
| 37 |
m_impl->m_callStack.push(L); |
| 38 |
|
| 39 |
#ifdef RVNG_CALLGRAPH_LEAVE |
| 40 |
#warning who defined RVNG_CALLGRAPH_LEAVE? |
| 41 |
#undef RVNG_CALLGRAPH_LEAVE |
| 42 |
#endif |
| 43 |
|
| 44 |
#define RVNG_CALLGRAPH_LEAVE(M, L) \ |
| 45 |
m_impl->m_atLeastOneCallback = true; \ |
| 46 |
if (!m_impl->m_printCallgraphScore) \ |
| 47 |
m_impl->idprintf M; \ |
| 48 |
else \ |
| 49 |
{ \ |
| 50 |
if (m_impl->m_callStack.empty()) \ |
| 51 |
{ \ |
| 52 |
m_impl->m_callbackMisses++; \ |
| 53 |
} \ |
| 54 |
else \ |
| 55 |
{ \ |
| 56 |
const int lc = m_impl->m_callStack.top(); \ |
| 57 |
if (lc != L) \ |
| 58 |
m_impl->m_callbackMisses++; \ |
| 59 |
m_impl->m_callStack.pop(); \ |
| 60 |
} \ |
| 61 |
} |
| 62 |
|
| 63 |
namespace librevenge |
| 64 |
{ |
| 65 |
|
| 66 |
namespace |
| 67 |
{ |
| 68 |
|
| 69 |
enum RVNGCallback |
| 70 |
{ |
| 71 |
CALLBACK_OPEN_ANIMATION_GROUP, |
| 72 |
CALLBACK_OPEN_ANIMATION_ITERATION, |
| 73 |
CALLBACK_OPEN_ANIMATION_SEQUENCE, |
| 74 |
CALLBACK_OPEN_CHART, |
| 75 |
CALLBACK_OPEN_CHART_TEXTOBJECT, |
| 76 |
CALLBACK_OPEN_CHART_PLOTAREA, |
| 77 |
CALLBACK_OPEN_CHART_SERIE, |
| 78 |
CALLBACK_OPEN_COMMENT, |
| 79 |
CALLBACK_OPEN_ENDNOTE, |
| 80 |
CALLBACK_OPEN_FOOTNOTE, |
| 81 |
CALLBACK_OPEN_FRAME, |
| 82 |
CALLBACK_OPEN_GRAPHIC, |
| 83 |
CALLBACK_OPEN_GRAPHIC_LAYER, |
| 84 |
CALLBACK_OPEN_GRAPHIC_PAGE, |
| 85 |
CALLBACK_OPEN_GROUP, |
| 86 |
CALLBACK_OPEN_HEADER_FOOTER, |
| 87 |
CALLBACK_OPEN_LINK, |
| 88 |
CALLBACK_OPEN_LIST_ELEMENT, |
| 89 |
CALLBACK_OPEN_ORDERED_LIST_LEVEL, |
| 90 |
CALLBACK_OPEN_PAGE_SPAN, |
| 91 |
CALLBACK_OPEN_PARAGRAPH, |
| 92 |
CALLBACK_OPEN_SECTION, |
| 93 |
CALLBACK_OPEN_SHEET, |
| 94 |
CALLBACK_OPEN_SHEET_CELL, |
| 95 |
CALLBACK_OPEN_SHEET_ROW, |
| 96 |
CALLBACK_OPEN_SPAN, |
| 97 |
CALLBACK_OPEN_TABLE, |
| 98 |
CALLBACK_OPEN_TABLE_CELL, |
| 99 |
CALLBACK_OPEN_TABLE_ROW, |
| 100 |
CALLBACK_OPEN_TEXT_BOX, |
| 101 |
CALLBACK_OPEN_UNORDERED_LIST_LEVEL, |
| 102 |
CALLBACK_START_COMMENT, |
| 103 |
CALLBACK_START_DOCUMENT, |
| 104 |
CALLBACK_START_EMBEDDED_GRAPHICS, |
| 105 |
CALLBACK_START_LAYER, |
| 106 |
CALLBACK_START_NOTES, |
| 107 |
CALLBACK_START_PAGE, |
| 108 |
CALLBACK_START_MASTER_PAGE, |
| 109 |
CALLBACK_START_SLIDE, |
| 110 |
CALLBACK_START_MASTER_SLIDE, |
| 111 |
CALLBACK_START_TEXT_OBJECT |
| 112 |
}; |
| 113 |
|
| 114 |
} |
| 115 |
|
| 116 |
struct RVNGRawGeneratorBase |
| 117 |
{ |
| 118 |
explicit RVNGRawGeneratorBase(bool printCallgraphScore); |
| 119 |
virtual ~RVNGRawGeneratorBase(); |
| 120 |
|
| 121 |
int m_indent; |
| 122 |
int m_callbackMisses; |
| 123 |
bool m_atLeastOneCallback; |
| 124 |
bool m_printCallgraphScore; |
| 125 |
std::stack<int> m_callStack; |
| 126 |
|
| 127 |
void indentUp() |
| 128 |
{ |
| 129 |
m_indent++; |
| 130 |
} |
| 131 |
void indentDown() |
| 132 |
{ |
| 133 |
if (m_indent > 0) m_indent--; |
| 134 |
} |
| 135 |
|
| 136 |
void iprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3); |
| 137 |
void iuprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3); |
| 138 |
void idprintf(const char *format, ...) REVENGE_ATTRIBUTE_PRINTF(2, 3); |
| 139 |
}; |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
#endif |
| 144 |
|
| 145 |
|