RVNGRawGeneratorBase.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* librevenge
3 * Version: MPL 2.0 / LGPLv2.1+
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * Major Contributor(s):
10 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
11 * Copyright (C) 2002-2004 Marc Maurer (uwog@uwog.net)
12 *
13 * For minor contributions see the git repository.
14 *
15 * Alternatively, the contents of this file may be used under the terms
16 * of the GNU Lesser General Public License Version 2.1 or later
17 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18 * applicable instead of those above.
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 } // anonymous namespace
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 } // namespace librevenge
142
143 #endif // RVNGRAWGENERATORBASE_H
144
145 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
librevenge::RVNGRawGeneratorBase::iuprintf
void void iuprintf(const char *format,...) REVENGE_ATTRIBUTE_PRINTF(2
Definition: RVNGRawGeneratorBase.cpp:57
librevenge
Definition: RVNGBinaryData.cpp:38
librevenge::RVNGRawGeneratorBase::idprintf
void void void idprintf(const char *format,...) REVENGE_ATTRIBUTE_PRINTF(2
Definition: RVNGRawGeneratorBase.cpp:69
REVENGE_ATTRIBUTE_PRINTF
#define REVENGE_ATTRIBUTE_PRINTF(fmt, arg)
Definition: librevenge-api.h:41
librevenge::RVNGRawGeneratorBase::indentDown
void indentDown()
Definition: RVNGRawGeneratorBase.h:131
librevenge::RVNGRawGeneratorBase::m_callbackMisses
int m_callbackMisses
Definition: RVNGRawGeneratorBase.h:122
librevenge::RVNGRawGeneratorBase::m_printCallgraphScore
bool m_printCallgraphScore
Definition: RVNGRawGeneratorBase.h:124
librevenge::@18::RVNGCallback
RVNGCallback
Definition: RVNGRawGeneratorBase.h:69
librevenge::RVNGRawGeneratorBase::~RVNGRawGeneratorBase
virtual ~RVNGRawGeneratorBase()
Definition: RVNGRawGeneratorBase.cpp:40
librevenge.h
librevenge::RVNGRawGeneratorBase::iprintf
void iprintf(const char *format,...) REVENGE_ATTRIBUTE_PRINTF(2
Definition: RVNGRawGeneratorBase.cpp:44
librevenge::RVNGRawGeneratorBase::indentUp
void indentUp()
Definition: RVNGRawGeneratorBase.h:127
librevenge::RVNGRawGeneratorBase::m_atLeastOneCallback
bool m_atLeastOneCallback
Definition: RVNGRawGeneratorBase.h:123
librevenge::RVNGRawGeneratorBase
Definition: RVNGRawGeneratorBase.h:116
librevenge::RVNGRawGeneratorBase::m_callStack
std::stack< int > m_callStack
Definition: RVNGRawGeneratorBase.h:125
librevenge::RVNGRawGeneratorBase::RVNGRawGeneratorBase
RVNGRawGeneratorBase(bool printCallgraphScore)
Definition: RVNGRawGeneratorBase.cpp:31
librevenge::RVNGRawGeneratorBase::m_indent
int m_indent
Definition: RVNGRawGeneratorBase.h:121