| 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 ([email protected]) |
| 11 | * Copyright (C) 2002-2004 Marc Maurer ([email protected]) |
| 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 | #include <librevenge-generators/librevenge-generators.h> |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | |
| 25 | #include "RVNGRawGeneratorBase.h" |
| 26 | |
| 27 | namespace librevenge |
| 28 | { |
| 29 | |
| 30 | struct RVNGRawTextGeneratorImpl : RVNGRawGeneratorBase |
| 31 | { |
| 32 | explicit RVNGRawTextGeneratorImpl(bool printCallgraphScore); |
| 33 | }; |
| 34 | |
| 35 | RVNGRawTextGeneratorImpl::RVNGRawTextGeneratorImpl(const bool printCallgraphScore) |
| 36 | : RVNGRawGeneratorBase(printCallgraphScore) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | RVNGRawTextGenerator::RVNGRawTextGenerator(bool printCallgraphScore) : |
| 41 | m_impl(new RVNGRawTextGeneratorImpl(printCallgraphScore)) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | RVNGRawTextGenerator::~RVNGRawTextGenerator() |
| 46 | { |
| 47 | if (m_impl->m_printCallgraphScore) |
| 48 | printf("%d\n", m_impl->m_atLeastOneCallback ? (int)m_impl->m_callStack.size() + m_impl->m_callbackMisses : -1); |
| 49 | |
| 50 | delete m_impl; |
| 51 | } |
| 52 | |
| 53 | void RVNGRawTextGenerator::setDocumentMetaData(const RVNGPropertyList &propList) |
| 54 | { |
| 55 | if (m_impl->m_printCallgraphScore) |
| 56 | return; |
| 57 | |
| 58 | m_impl->iprintf("setDocumentMetaData(%s)\n", propList.getPropString().cstr()); |
| 59 | } |
| 60 | |
| 61 | void RVNGRawTextGenerator::startDocument(const RVNGPropertyList &propList) |
| 62 | { |
| 63 | RVNG_CALLGRAPH_ENTER(("startDocument(%s)\n", propList.getPropString().cstr()), CALLBACK_START_DOCUMENT); |
| 64 | } |
| 65 | |
| 66 | void RVNGRawTextGenerator::endDocument() |
| 67 | { |
| 68 | RVNG_CALLGRAPH_LEAVE(("endDocument()\n"), CALLBACK_START_DOCUMENT); |
| 69 | } |
| 70 | |
| 71 | void RVNGRawTextGenerator::definePageStyle(const RVNGPropertyList &propList) |
| 72 | { |
| 73 | if (m_impl->m_printCallgraphScore) |
| 74 | return; |
| 75 | |
| 76 | m_impl->iprintf("definePageStyle(%s)\n", propList.getPropString().cstr()); |
| 77 | } |
| 78 | |
| 79 | void RVNGRawTextGenerator::defineEmbeddedFont(const RVNGPropertyList &propList) |
| 80 | { |
| 81 | if (m_impl->m_printCallgraphScore) |
| 82 | return; |
| 83 | |
| 84 | m_impl->iprintf("defineEmbeddedFont(%s)\n", propList.getPropString().cstr()); |
| 85 | } |
| 86 | |
| 87 | void RVNGRawTextGenerator::openPageSpan(const RVNGPropertyList &propList) |
| 88 | { |
| 89 | RVNG_CALLGRAPH_ENTER(("openPageSpan(%s)\n", propList.getPropString().cstr()), |
| 90 | CALLBACK_OPEN_PAGE_SPAN); |
| 91 | } |
| 92 | |
| 93 | void RVNGRawTextGenerator::closePageSpan() |
| 94 | { |
| 95 | RVNG_CALLGRAPH_LEAVE(("closePageSpan()\n"), |
| 96 | CALLBACK_OPEN_PAGE_SPAN); |
| 97 | } |
| 98 | |
| 99 | void RVNGRawTextGenerator::openHeader(const RVNGPropertyList &propList) |
| 100 | { |
| 101 | RVNG_CALLGRAPH_ENTER(("openHeader(%s)\n", |
| 102 | propList.getPropString().cstr()), |
| 103 | CALLBACK_OPEN_HEADER_FOOTER); |
| 104 | } |
| 105 | |
| 106 | void RVNGRawTextGenerator::closeHeader() |
| 107 | { |
| 108 | RVNG_CALLGRAPH_LEAVE(("closeHeader()\n"), |
| 109 | CALLBACK_OPEN_HEADER_FOOTER); |
| 110 | } |
| 111 | |
| 112 | void RVNGRawTextGenerator::openFooter(const RVNGPropertyList &propList) |
| 113 | { |
| 114 | RVNG_CALLGRAPH_ENTER(("openFooter(%s)\n", |
| 115 | propList.getPropString().cstr()), |
| 116 | CALLBACK_OPEN_HEADER_FOOTER); |
| 117 | } |
| 118 | |
| 119 | void RVNGRawTextGenerator::closeFooter() |
| 120 | { |
| 121 | RVNG_CALLGRAPH_LEAVE(("closeFooter()\n"), |
| 122 | CALLBACK_OPEN_HEADER_FOOTER); |
| 123 | } |
| 124 | |
| 125 | void RVNGRawTextGenerator::defineParagraphStyle(const RVNGPropertyList &propList) |
| 126 | { |
| 127 | if (m_impl->m_printCallgraphScore) |
| 128 | return; |
| 129 | |
| 130 | m_impl->iprintf("defineParagraphStyle(%s)\n", propList.getPropString().cstr()); |
| 131 | } |
| 132 | |
| 133 | void RVNGRawTextGenerator::openParagraph(const RVNGPropertyList &propList) |
| 134 | { |
| 135 | RVNG_CALLGRAPH_ENTER(("openParagraph(%s)\n", propList.getPropString().cstr()), |
| 136 | CALLBACK_OPEN_PARAGRAPH); |
| 137 | } |
| 138 | |
| 139 | void RVNGRawTextGenerator::closeParagraph() |
| 140 | { |
| 141 | RVNG_CALLGRAPH_LEAVE(("closeParagraph()\n"), CALLBACK_OPEN_PARAGRAPH); |
| 142 | } |
| 143 | |
| 144 | void RVNGRawTextGenerator::defineCharacterStyle(const RVNGPropertyList &propList) |
| 145 | { |
| 146 | if (m_impl->m_printCallgraphScore) |
| 147 | return; |
| 148 | |
| 149 | m_impl->iprintf("defineCharacterStyle(%s)\n", propList.getPropString().cstr()); |
| 150 | } |
| 151 | |
| 152 | void RVNGRawTextGenerator::openSpan(const RVNGPropertyList &propList) |
| 153 | { |
| 154 | RVNG_CALLGRAPH_ENTER(("openSpan(%s)\n", propList.getPropString().cstr()), CALLBACK_OPEN_SPAN); |
| 155 | } |
| 156 | |
| 157 | void RVNGRawTextGenerator::closeSpan() |
| 158 | { |
| 159 | RVNG_CALLGRAPH_LEAVE(("closeSpan()\n"), CALLBACK_OPEN_SPAN); |
| 160 | } |
| 161 | |
| 162 | void RVNGRawTextGenerator::openLink(const RVNGPropertyList &propList) |
| 163 | { |
| 164 | RVNG_CALLGRAPH_ENTER(("openLink(%s)\n", propList.getPropString().cstr()), CALLBACK_OPEN_LINK); |
| 165 | } |
| 166 | |
| 167 | void RVNGRawTextGenerator::closeLink() |
| 168 | { |
| 169 | RVNG_CALLGRAPH_LEAVE(("closeLink()\n"), CALLBACK_OPEN_LINK); |
| 170 | } |
| 171 | |
| 172 | void RVNGRawTextGenerator::defineSectionStyle(const RVNGPropertyList &propList) |
| 173 | { |
| 174 | if (m_impl->m_printCallgraphScore) |
| 175 | return; |
| 176 | |
| 177 | m_impl->iprintf("defineSectionStyle(%s)\n", propList.getPropString().cstr()); |
| 178 | } |
| 179 | |
| 180 | void RVNGRawTextGenerator::openSection(const RVNGPropertyList &propList) |
| 181 | { |
| 182 | RVNG_CALLGRAPH_ENTER(("openSection(%s)\n", propList.getPropString().cstr()), CALLBACK_OPEN_SECTION); |
| 183 | } |
| 184 | |
| 185 | void RVNGRawTextGenerator::closeSection() |
| 186 | { |
| 187 | RVNG_CALLGRAPH_LEAVE(("closeSection()\n"), CALLBACK_OPEN_SECTION); |
| 188 | } |
| 189 | |
| 190 | void RVNGRawTextGenerator::insertTab() |
| 191 | { |
| 192 | if (m_impl->m_printCallgraphScore) |
| 193 | return; |
| 194 | |
| 195 | m_impl->iprintf("insertTab()\n"); |
| 196 | } |
| 197 | |
| 198 | void RVNGRawTextGenerator::insertSpace() |
| 199 | { |
| 200 | if (m_impl->m_printCallgraphScore) |
| 201 | return; |
| 202 | |
| 203 | m_impl->iprintf("insertSpace()\n"); |
| 204 | } |
| 205 | |
| 206 | void RVNGRawTextGenerator::insertText(const RVNGString &text) |
| 207 | { |
| 208 | if (m_impl->m_printCallgraphScore) |
| 209 | return; |
| 210 | |
| 211 | m_impl->iprintf("insertText(text: %s)\n", text.cstr()); |
| 212 | } |
| 213 | |
| 214 | void RVNGRawTextGenerator::insertLineBreak() |
| 215 | { |
| 216 | if (m_impl->m_printCallgraphScore) |
| 217 | return; |
| 218 | |
| 219 | m_impl->iprintf("insertLineBreak()\n"); |
| 220 | } |
| 221 | |
| 222 | void RVNGRawTextGenerator::insertField(const RVNGPropertyList &propList) |
| 223 | { |
| 224 | if (m_impl->m_printCallgraphScore) |
| 225 | return; |
| 226 | |
| 227 | m_impl->iprintf("insertField(%s)\n", propList.getPropString().cstr()); |
| 228 | } |
| 229 | |
| 230 | void RVNGRawTextGenerator::openOrderedListLevel(const RVNGPropertyList &propList) |
| 231 | { |
| 232 | RVNG_CALLGRAPH_ENTER(("openOrderedListLevel(%s)\n", propList.getPropString().cstr()), |
| 233 | CALLBACK_OPEN_ORDERED_LIST_LEVEL); |
| 234 | } |
| 235 | |
| 236 | void RVNGRawTextGenerator::openUnorderedListLevel(const RVNGPropertyList &propList) |
| 237 | { |
| 238 | RVNG_CALLGRAPH_ENTER(("openUnorderedListLevel(%s)\n", propList.getPropString().cstr()), |
| 239 | CALLBACK_OPEN_UNORDERED_LIST_LEVEL); |
| 240 | } |
| 241 | |
| 242 | void RVNGRawTextGenerator::closeOrderedListLevel() |
| 243 | { |
| 244 | RVNG_CALLGRAPH_LEAVE(("closeOrderedListLevel()\n"), |
| 245 | CALLBACK_OPEN_ORDERED_LIST_LEVEL); |
| 246 | } |
| 247 | |
| 248 | void RVNGRawTextGenerator::closeUnorderedListLevel() |
| 249 | { |
| 250 | RVNG_CALLGRAPH_LEAVE(("closeUnorderedListLevel()\n"), CALLBACK_OPEN_UNORDERED_LIST_LEVEL); |
| 251 | } |
| 252 | |
| 253 | void RVNGRawTextGenerator::openListElement(const RVNGPropertyList &propList) |
| 254 | { |
| 255 | RVNG_CALLGRAPH_ENTER(("openListElement(%s)\n", propList.getPropString().cstr()), |
| 256 | CALLBACK_OPEN_LIST_ELEMENT); |
| 257 | } |
| 258 | |
| 259 | void RVNGRawTextGenerator::closeListElement() |
| 260 | { |
| 261 | RVNG_CALLGRAPH_LEAVE(("closeListElement()\n"), CALLBACK_OPEN_LIST_ELEMENT); |
| 262 | } |
| 263 | |
| 264 | void RVNGRawTextGenerator::openFootnote(const RVNGPropertyList &propList) |
| 265 | { |
| 266 | RVNG_CALLGRAPH_ENTER(("openFootnote(%s)\n", propList.getPropString().cstr()), |
| 267 | CALLBACK_OPEN_FOOTNOTE); |
| 268 | } |
| 269 | |
| 270 | void RVNGRawTextGenerator::closeFootnote() |
| 271 | { |
| 272 | RVNG_CALLGRAPH_LEAVE(("closeFootnote()\n"), CALLBACK_OPEN_FOOTNOTE); |
| 273 | } |
| 274 | |
| 275 | void RVNGRawTextGenerator::openEndnote(const RVNGPropertyList &propList) |
| 276 | { |
| 277 | RVNG_CALLGRAPH_ENTER(("openEndnote(%s)\n", propList.getPropString().cstr()), |
| 278 | CALLBACK_OPEN_ENDNOTE); |
| 279 | } |
| 280 | |
| 281 | void RVNGRawTextGenerator::closeEndnote() |
| 282 | { |
| 283 | RVNG_CALLGRAPH_LEAVE(("closeEndnote()\n"), CALLBACK_OPEN_ENDNOTE); |
| 284 | } |
| 285 | |
| 286 | void RVNGRawTextGenerator::openComment(const RVNGPropertyList &propList) |
| 287 | { |
| 288 | RVNG_CALLGRAPH_ENTER(("openComment(%s)\n", propList.getPropString().cstr()), |
| 289 | CALLBACK_OPEN_COMMENT); |
| 290 | } |
| 291 | |
| 292 | void RVNGRawTextGenerator::closeComment() |
| 293 | { |
| 294 | RVNG_CALLGRAPH_LEAVE(("closeComment()\n"), CALLBACK_OPEN_COMMENT); |
| 295 | } |
| 296 | |
| 297 | void RVNGRawTextGenerator::openTextBox(const RVNGPropertyList &propList) |
| 298 | { |
| 299 | RVNG_CALLGRAPH_ENTER(("openTextBox(%s)\n", propList.getPropString().cstr()), |
| 300 | CALLBACK_OPEN_TEXT_BOX); |
| 301 | } |
| 302 | |
| 303 | void RVNGRawTextGenerator::closeTextBox() |
| 304 | { |
| 305 | RVNG_CALLGRAPH_LEAVE(("closeTextBox()\n"), CALLBACK_OPEN_TEXT_BOX); |
| 306 | } |
| 307 | |
| 308 | void RVNGRawTextGenerator::openTable(const RVNGPropertyList &propList) |
| 309 | { |
| 310 | RVNG_CALLGRAPH_ENTER(("openTable(%s)\n", propList.getPropString().cstr()), CALLBACK_OPEN_TABLE); |
| 311 | } |
| 312 | |
| 313 | void RVNGRawTextGenerator::openTableRow(const RVNGPropertyList &propList) |
| 314 | { |
| 315 | RVNG_CALLGRAPH_ENTER(("openTableRow(%s)\n", propList.getPropString().cstr()), |
| 316 | CALLBACK_OPEN_TABLE_ROW); |
| 317 | } |
| 318 | |
| 319 | void RVNGRawTextGenerator::closeTableRow() |
| 320 | { |
| 321 | RVNG_CALLGRAPH_LEAVE(("closeTableRow()\n"), CALLBACK_OPEN_TABLE_ROW); |
| 322 | } |
| 323 | |
| 324 | void RVNGRawTextGenerator::openTableCell(const RVNGPropertyList &propList) |
| 325 | { |
| 326 | RVNG_CALLGRAPH_ENTER(("openTableCell(%s)\n", propList.getPropString().cstr()), |
| 327 | CALLBACK_OPEN_TABLE_CELL); |
| 328 | } |
| 329 | |
| 330 | void RVNGRawTextGenerator::closeTableCell() |
| 331 | { |
| 332 | RVNG_CALLGRAPH_LEAVE(("closeTableCell()\n"), CALLBACK_OPEN_TABLE_CELL); |
| 333 | } |
| 334 | |
| 335 | void RVNGRawTextGenerator::insertCoveredTableCell(const RVNGPropertyList &propList) |
| 336 | { |
| 337 | if (m_impl->m_printCallgraphScore) |
| 338 | return; |
| 339 | |
| 340 | m_impl->iprintf("insertCoveredTableCell(%s)\n", propList.getPropString().cstr()); |
| 341 | } |
| 342 | |
| 343 | void RVNGRawTextGenerator::closeTable() |
| 344 | { |
| 345 | RVNG_CALLGRAPH_LEAVE(("closeTable()\n"), CALLBACK_OPEN_TABLE); |
| 346 | } |
| 347 | |
| 348 | void RVNGRawTextGenerator::openFrame(const RVNGPropertyList &propList) |
| 349 | { |
| 350 | RVNG_CALLGRAPH_ENTER(("openFrame(%s)\n", propList.getPropString().cstr()), |
| 351 | CALLBACK_OPEN_FRAME); |
| 352 | } |
| 353 | |
| 354 | void RVNGRawTextGenerator::closeFrame() |
| 355 | { |
| 356 | RVNG_CALLGRAPH_LEAVE(("closeFrame()\n"), CALLBACK_OPEN_FRAME); |
| 357 | } |
| 358 | |
| 359 | void RVNGRawTextGenerator::openGroup(const librevenge::RVNGPropertyList &propList) |
| 360 | { |
| 361 | RVNG_CALLGRAPH_ENTER(("openGroup(%s)\n", propList.getPropString().cstr()), |
| 362 | CALLBACK_OPEN_GROUP); |
| 363 | } |
| 364 | |
| 365 | void RVNGRawTextGenerator::closeGroup() |
| 366 | { |
| 367 | RVNG_CALLGRAPH_LEAVE(("closeGroup()\n"), CALLBACK_OPEN_GROUP); |
| 368 | } |
| 369 | |
| 370 | void RVNGRawTextGenerator::defineGraphicStyle(const librevenge::RVNGPropertyList &propList) |
| 371 | { |
| 372 | if (m_impl->m_printCallgraphScore) |
| 373 | return; |
| 374 | |
| 375 | m_impl->iprintf("defineGraphicStyle(%s)\n", propList.getPropString().cstr()); |
| 376 | } |
| 377 | |
| 378 | void RVNGRawTextGenerator::drawRectangle(const librevenge::RVNGPropertyList &propList) |
| 379 | { |
| 380 | if (m_impl->m_printCallgraphScore) |
| 381 | return; |
| 382 | |
| 383 | m_impl->iprintf("drawRectangle(%s)\n", propList.getPropString().cstr()); |
| 384 | } |
| 385 | |
| 386 | void RVNGRawTextGenerator::drawEllipse(const librevenge::RVNGPropertyList &propList) |
| 387 | { |
| 388 | if (m_impl->m_printCallgraphScore) |
| 389 | return; |
| 390 | |
| 391 | m_impl->iprintf("drawEllipse(%s)\n", propList.getPropString().cstr()); |
| 392 | } |
| 393 | |
| 394 | void RVNGRawTextGenerator::drawPolygon(const librevenge::RVNGPropertyList &propList) |
| 395 | { |
| 396 | if (m_impl->m_printCallgraphScore) |
| 397 | return; |
| 398 | |
| 399 | m_impl->iprintf("drawPolygon(%s)\n", propList.getPropString().cstr()); |
| 400 | } |
| 401 | |
| 402 | void RVNGRawTextGenerator::drawPolyline(const librevenge::RVNGPropertyList &propList) |
| 403 | { |
| 404 | if (m_impl->m_printCallgraphScore) |
| 405 | return; |
| 406 | |
| 407 | m_impl->iprintf("drawPolyline(%s)\n", propList.getPropString().cstr()); |
| 408 | } |
| 409 | |
| 410 | void RVNGRawTextGenerator::drawPath(const librevenge::RVNGPropertyList &propList) |
| 411 | { |
| 412 | if (m_impl->m_printCallgraphScore) |
| 413 | return; |
| 414 | |
| 415 | m_impl->iprintf("drawPath(%s)\n", propList.getPropString().cstr()); |
| 416 | } |
| 417 | |
| 418 | void RVNGRawTextGenerator::drawConnector(const librevenge::RVNGPropertyList &propList) |
| 419 | { |
| 420 | if (m_impl->m_printCallgraphScore) |
| 421 | return; |
| 422 | |
| 423 | m_impl->iprintf("drawConnector(%s)\n", propList.getPropString().cstr()); |
| 424 | } |
| 425 | |
| 426 | void RVNGRawTextGenerator::insertBinaryObject(const RVNGPropertyList &propList) |
| 427 | { |
| 428 | if (m_impl->m_printCallgraphScore) |
| 429 | return; |
| 430 | |
| 431 | m_impl->iprintf("insertBinaryObject(%s)\n", propList.getPropString().cstr()); |
| 432 | } |
| 433 | |
| 434 | void RVNGRawTextGenerator::insertEquation(const RVNGPropertyList &propList) |
| 435 | { |
| 436 | if (m_impl->m_printCallgraphScore) |
| 437 | return; |
| 438 | |
| 439 | m_impl->iprintf("insertEquation(%s)\n", propList.getPropString().cstr()); |
| 440 | } |
| 441 | |
| 442 | } |
| 443 | |
| 444 | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |