| 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-2004 William Lachance ([email protected]) |
| 11 | * Copyright (C) 2002 Marc Maurer ([email protected]) |
| 12 | * Copyright (C) 2004 Fridrich Strba ([email protected]) |
| 13 | * Copyright (C) 2005 Net Integration Technologies (http://www.net-itech.com) |
| 14 | * |
| 15 | * For minor contributions see the git repository. |
| 16 | * |
| 17 | * Alternatively, the contents of this file may be used under the terms |
| 18 | * of the GNU Lesser General Public License Version 2.1 or later |
| 19 | * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are |
| 20 | * applicable instead of those above. |
| 21 | */ |
| 22 | |
| 23 | #include <librevenge-generators/librevenge-generators.h> |
| 24 | |
| 25 | #include <cassert> |
| 26 | #include <cstring> |
| 27 | #include <fstream> |
| 28 | #include <sstream> |
| 29 | #include <vector> |
| 30 | |
| 31 | #include "RVNGHTMLTextTableStyle.h" |
| 32 | #include "RVNGHTMLTextTextStyle.h" |
| 33 | |
| 34 | #include "librevenge_internal.h" |
| 35 | |
| 36 | namespace librevenge |
| 37 | { |
| 38 | |
| 39 | struct RVNGHTMLTextStream; |
| 40 | |
| 41 | //! a zone to regroup footnote/endnote,... data |
| 42 | struct RVNGHTMLTextZone |
| 43 | { |
| 44 | friend struct RVNGHTMLTextStream; |
| 45 | |
| 46 | //! the different zone |
| 47 | enum Type { Z_Comment=0, Z_EndNote, Z_FootNote, Z_Main, Z_MetaData, Z_TextBox, Z_Unknown, Z_NumZones= Z_Unknown+1}; |
| 48 | //! constructor for basic stream |
| 49 | RVNGHTMLTextZone(Type tp=Z_Unknown) : m_type(tp), m_actualId(0), m_stringList() |
| 50 | { |
| 51 | } |
| 52 | //! the type |
| 53 | Type type() const |
| 54 | { |
| 55 | return m_type; |
| 56 | } |
| 57 | //! the type |
| 58 | void setType(Type tp) |
| 59 | { |
| 60 | m_type=tp; |
| 61 | } |
| 62 | //! returns a new stream corresponding to this zone |
| 63 | RVNGHTMLTextStream *getNewStream(); |
| 64 | //! delete a stream corresponding to this zone |
| 65 | static void deleteStream(RVNGHTMLTextStream *stream); |
| 66 | //! returns true if there is no data |
| 67 | bool isEmpty() const |
| 68 | { |
| 69 | for (const auto &i : m_stringList) |
| 70 | if (i.size()) |
| 71 | return false; |
| 72 | return true; |
| 73 | } |
| 74 | //! send the zone data |
| 75 | void send(std::ostream &out) const |
| 76 | { |
| 77 | if (isEmpty() || m_type==Z_Unknown || m_type==Z_Main) |
| 78 | return; |
| 79 | if (m_type!=Z_MetaData) |
| 80 | out << "<hr>\n"; |
| 81 | if (m_type==Z_MetaData) |
| 82 | { |
| 83 | for (const auto &i : m_stringList) |
| 84 | out << i; |
| 85 | return; |
| 86 | } |
| 87 | if (m_type==Z_TextBox) |
| 88 | { |
| 89 | out << "<p><b>TEXT BOXES</b></p><hr>\n"; |
| 90 | for (const auto &i : m_stringList) |
| 91 | out << i << "<hr>\n"; |
| 92 | return; |
| 93 | } |
| 94 | for (const auto &str : m_stringList) |
| 95 | { |
| 96 | out << str << "\n"; |
| 97 | // check if we need to add a return line |
| 98 | size_t lastComPos=str.rfind('<'); |
| 99 | if (lastComPos!=std::string::npos) |
| 100 | { |
| 101 | if (str.compare(lastComPos,4,"</p>")==0 || |
| 102 | str.compare(lastComPos,5,"</ul>")==0 || |
| 103 | str.compare(lastComPos,5,"</ol>")==0 || |
| 104 | str.compare(lastComPos,4,"<br>")==0) |
| 105 | continue; |
| 106 | } |
| 107 | out << "<br>\n"; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | protected: |
| 112 | //! return a label corresponding to the zone |
| 113 | std::string label(int id) const; |
| 114 | //! the zone type |
| 115 | Type m_type; |
| 116 | //! the actual id |
| 117 | mutable int m_actualId; |
| 118 | //! the list of data string |
| 119 | std::vector<std::string> m_stringList; |
| 120 | private: |
| 121 | RVNGHTMLTextZone(RVNGHTMLTextZone const &orig); |
| 122 | RVNGHTMLTextZone operator=(RVNGHTMLTextZone const &orig); |
| 123 | }; |
| 124 | |
| 125 | struct RVNGHTMLTextStream |
| 126 | { |
| 127 | //! constructor |
| 128 | RVNGHTMLTextStream(RVNGHTMLTextZone *zone): m_zone(zone), m_zoneId(0), m_stream(), m_delayedLabel("") |
| 129 | { |
| 130 | if (m_zone) |
| 131 | m_zoneId=m_zone->m_actualId++; |
| 132 | } |
| 133 | //! destructor |
| 134 | ~RVNGHTMLTextStream() { } |
| 135 | //! add a label called on main and a label in this ( delayed to allow openParagraph to be called ) |
| 136 | void addLabel(std::ostream &output) |
| 137 | { |
| 138 | std::string lbl=label(); |
| 139 | if (!lbl.length()) |
| 140 | return; |
| 141 | output << "<sup id=\"called" << lbl << "\"><a href=\"#data" << lbl << "\">" << lbl << "</a></sup>"; |
| 142 | flush(); |
| 143 | std::stringstream ss; |
| 144 | ss << "<sup id=\"data" << lbl << "\"><a href=\"#called" << lbl << "\">" << lbl << "</a></sup>"; |
| 145 | m_delayedLabel=ss.str(); |
| 146 | } |
| 147 | //! flush delayed label, ... |
| 148 | void flush() |
| 149 | { |
| 150 | if (m_delayedLabel.length()) |
| 151 | { |
| 152 | m_stream << m_delayedLabel; |
| 153 | m_delayedLabel=""; |
| 154 | } |
| 155 | } |
| 156 | //! return the stream |
| 157 | std::ostream &stream() |
| 158 | { |
| 159 | return m_stream; |
| 160 | } |
| 161 | //! send the data to the zone |
| 162 | void send() |
| 163 | { |
| 164 | if (!m_zone || m_zone->m_type==RVNGHTMLTextZone::Z_Main) |
| 165 | { |
| 166 | RVNG_DEBUG_MSG(("RVNGHTMLTextStream::send: must not be called\n")); |
| 167 | return; |
| 168 | } |
| 169 | flush(); |
| 170 | if (m_zone->m_stringList.size() <= size_t(m_zoneId)) |
| 171 | m_zone->m_stringList.resize(size_t(m_zoneId)+1); |
| 172 | m_zone->m_stringList[size_t(m_zoneId)]=m_stream.str(); |
| 173 | } |
| 174 | //! send the data to the zone |
| 175 | void sendMain(std::ostream &output) |
| 176 | { |
| 177 | flush(); |
| 178 | output << m_stream.str() << "\n"; |
| 179 | } |
| 180 | protected: |
| 181 | //! return the stream label |
| 182 | std::string label() const |
| 183 | { |
| 184 | if (!m_zone || m_zone->m_type==RVNGHTMLTextZone::Z_Main) |
| 185 | { |
| 186 | RVNG_DEBUG_MSG(("RVNGHTMLTextStream::label: must not be called\n")); |
| 187 | return ""; |
| 188 | } |
| 189 | return m_zone->label(m_zoneId); |
| 190 | } |
| 191 | //! a zone |
| 192 | RVNGHTMLTextZone *m_zone; |
| 193 | //! the zone id |
| 194 | int m_zoneId; |
| 195 | //! the stream |
| 196 | std::ostringstream m_stream; |
| 197 | //! the label |
| 198 | std::string m_delayedLabel; |
| 199 | private: |
| 200 | RVNGHTMLTextStream(RVNGHTMLTextStream const &orig); |
| 201 | RVNGHTMLTextStream operator=(RVNGHTMLTextStream const &orig); |
| 202 | }; |
| 203 | |
| 204 | RVNGHTMLTextStream *RVNGHTMLTextZone::getNewStream() |
| 205 | { |
| 206 | return new RVNGHTMLTextStream(this); |
| 207 | } |
| 208 | |
| 209 | void RVNGHTMLTextZone::deleteStream(RVNGHTMLTextStream *stream) |
| 210 | { |
| 211 | if (stream) delete stream; |
| 212 | } |
| 213 | |
| 214 | std::string RVNGHTMLTextZone::label(int id) const |
| 215 | { |
| 216 | char c=0; |
| 217 | switch (m_type) |
| 218 | { |
| 219 | case Z_Comment: |
| 220 | c='C'; |
| 221 | break; |
| 222 | case Z_EndNote: |
| 223 | c='E'; |
| 224 | break; |
| 225 | case Z_FootNote: |
| 226 | c='F'; |
| 227 | break; |
| 228 | case Z_TextBox: |
| 229 | c='T'; |
| 230 | break; |
| 231 | case Z_Main: |
| 232 | case Z_MetaData: |
| 233 | case Z_Unknown: |
| 234 | case Z_NumZones: |
| 235 | default: |
| 236 | break; |
| 237 | } |
| 238 | if (c==0) |
| 239 | return ""; |
| 240 | std::stringstream s; |
| 241 | s << c << id+1; |
| 242 | return s.str(); |
| 243 | } |
| 244 | |
| 245 | //! the internal state of a html document generator |
| 246 | struct RVNGHTMLTextGeneratorImpl |
| 247 | { |
| 248 | //! constructor |
| 249 | RVNGHTMLTextGeneratorImpl(RVNGString &document) : m_document(document), m_actualPage(0), m_ignore(false), m_listManager(), m_paragraphManager(), m_spanManager(), m_tableManager(), m_currentParaElement(), m_actualStream(), m_streamStack() |
| 250 | { |
| 251 | for (int i = 0; i < RVNGHTMLTextZone::Z_NumZones; ++i) |
| 252 | m_zones[i].setType(RVNGHTMLTextZone::Type(i)); |
| 253 | m_actualStream=m_zones[RVNGHTMLTextZone::Z_Main].getNewStream(); |
| 254 | } |
| 255 | //! destructor |
| 256 | ~RVNGHTMLTextGeneratorImpl() |
| 257 | { |
| 258 | for (auto &i : m_streamStack) |
| 259 | { |
| 260 | if (i) delete i; |
| 261 | } |
| 262 | if (m_actualStream) delete m_actualStream; |
| 263 | } |
| 264 | |
| 265 | //! returns the actual output ( sending delayed data if needed) |
| 266 | std::ostream &output(bool sendDelayed=true) |
| 267 | { |
| 268 | if (sendDelayed) |
| 269 | m_actualStream->flush(); |
| 270 | return m_actualStream->stream(); |
| 271 | } |
| 272 | //! returns the actual stream |
| 273 | RVNGHTMLTextStream &stream() |
| 274 | { |
| 275 | return *m_actualStream; |
| 276 | } |
| 277 | void push(RVNGHTMLTextZone::Type type) |
| 278 | { |
| 279 | m_streamStack.push_back(m_actualStream); |
| 280 | if (type==RVNGHTMLTextZone::Z_Main || type==RVNGHTMLTextZone::Z_NumZones) |
| 281 | { |
| 282 | RVNG_DEBUG_MSG(("RVNGHTMLTextGeneratorImpl::push: can not push the main zone\n")); |
| 283 | type=RVNGHTMLTextZone::Z_Unknown; |
| 284 | } |
| 285 | m_actualStream=m_zones[type].getNewStream(); |
| 286 | } |
| 287 | void pop() |
| 288 | { |
| 289 | if (m_streamStack.size() <= 0) |
| 290 | { |
| 291 | RVNG_DEBUG_MSG(("RVNGHTMLTextGenerator::pop: can not pop stream\n")); |
| 292 | return; |
| 293 | } |
| 294 | if (m_actualStream) |
| 295 | { |
| 296 | m_actualStream->send(); |
| 297 | delete m_actualStream; |
| 298 | } |
| 299 | m_actualStream = m_streamStack.back(); |
| 300 | m_streamStack.pop_back(); |
| 301 | } |
| 302 | void sendMetaData(std::ostream &out) |
| 303 | { |
| 304 | m_zones[RVNGHTMLTextZone::Z_MetaData].send(out); |
| 305 | } |
| 306 | void flushUnsent(std::ostream &out) |
| 307 | { |
| 308 | if (m_streamStack.size()) |
| 309 | { |
| 310 | RVNG_DEBUG_MSG(("RVNGHTMLTextGenerator::flushUnsent: the stream stack is not empty\n")); |
| 311 | while (m_streamStack.size()) |
| 312 | pop(); |
| 313 | } |
| 314 | // first send the main data |
| 315 | if (!m_actualStream) |
| 316 | { |
| 317 | RVNG_DEBUG_MSG(("RVNGHTMLTextGenerator::flushUnsent: can not find the main block\n")); |
| 318 | } |
| 319 | else |
| 320 | m_actualStream->sendMain(out); |
| 321 | m_zones[RVNGHTMLTextZone::Z_Comment].send(out); |
| 322 | m_zones[RVNGHTMLTextZone::Z_FootNote].send(out); |
| 323 | m_zones[RVNGHTMLTextZone::Z_EndNote].send(out); |
| 324 | m_zones[RVNGHTMLTextZone::Z_TextBox].send(out); |
| 325 | } |
| 326 | |
| 327 | RVNGString &m_document; |
| 328 | |
| 329 | int m_actualPage; |
| 330 | bool m_ignore; |
| 331 | |
| 332 | RVNGHTMLTextListStyleManager m_listManager; |
| 333 | RVNGHTMLTextParagraphStyleManager m_paragraphManager; |
| 334 | RVNGHTMLTextSpanStyleManager m_spanManager; |
| 335 | RVNGHTMLTextTableStyleManager m_tableManager; |
| 336 | |
| 337 | std::string m_currentParaElement; |
| 338 | |
| 339 | protected: |
| 340 | RVNGHTMLTextStream *m_actualStream; |
| 341 | std::vector<RVNGHTMLTextStream *> m_streamStack; |
| 342 | |
| 343 | RVNGHTMLTextZone m_zones[RVNGHTMLTextZone::Z_NumZones]; |
| 344 | private: |
| 345 | RVNGHTMLTextGeneratorImpl(RVNGHTMLTextGeneratorImpl const &orig); |
| 346 | RVNGHTMLTextGeneratorImpl operator=(RVNGHTMLTextGeneratorImpl const &orig); |
| 347 | }; |
| 348 | |
| 349 | RVNGHTMLTextGenerator::RVNGHTMLTextGenerator(RVNGString &document) : m_impl(new RVNGHTMLTextGeneratorImpl(document)) |
| 350 | { |
| 351 | } |
| 352 | |
| 353 | RVNGHTMLTextGenerator::~RVNGHTMLTextGenerator() |
| 354 | { |
| 355 | if (m_impl) delete m_impl; |
| 356 | } |
| 357 | |
| 358 | void RVNGHTMLTextGenerator::setDocumentMetaData(const RVNGPropertyList &propList) |
| 359 | { |
| 360 | m_impl->push(RVNGHTMLTextZone::Z_MetaData); |
| 361 | std::ostream &meta=m_impl->output(); |
| 362 | static char const *wpdMetaFields[9]= |
| 363 | { |
| 364 | "meta:initial-creator", "dc:creator", "dc:subject", "dc:publisher", "meta:keywords", |
| 365 | "dc:language", "dc:description", "librevenge:descriptive-name", "librevenge:descriptive-type" |
| 366 | }; |
| 367 | static char const *metaFields[9]= |
| 368 | { |
| 369 | "author", "typist", "subject", "publisher", "keywords", |
| 370 | "language", "abstract", "descriptive-name", "descriptive-type" |
| 371 | }; |
| 372 | for (int i = 0; i < 9; i++) |
| 373 | { |
| 374 | if (!propList[wpdMetaFields[i]]) |
| 375 | continue; |
| 376 | meta << "<meta name=\"" << metaFields[i] << "\" content=\"" << propList[wpdMetaFields[i]]->getStr().cstr() << "\">" << std::endl; |
| 377 | } |
| 378 | if (propList["librevenge:descriptive-name"]) |
| 379 | meta << "<title>" << propList["librevenge:descriptive-name"]->getStr().cstr() << "</title>" << std::endl; |
| 380 | else |
| 381 | meta << "<title></title>" << std::endl; |
| 382 | m_impl->pop(); |
| 383 | } |
| 384 | |
| 385 | void RVNGHTMLTextGenerator::startDocument(const RVNGPropertyList &) |
| 386 | { |
| 387 | } |
| 388 | |
| 389 | void RVNGHTMLTextGenerator::endDocument() |
| 390 | { |
| 391 | std::ostringstream out; |
| 392 | out << "<!DOCTYPE HTML>" << std::endl; |
| 393 | out << "<html>" << std::endl; |
| 394 | out << "<head>" << std::endl; |
| 395 | out << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" >" << std::endl; |
| 396 | m_impl->sendMetaData(out); |
| 397 | out << "<style>" << std::endl; |
| 398 | m_impl->m_listManager.send(out); |
| 399 | m_impl->m_paragraphManager.send(out); |
| 400 | m_impl->m_spanManager.send(out); |
| 401 | m_impl->m_tableManager.send(out); |
| 402 | out << "</style>" << std::endl; |
| 403 | out << "</head>" << std::endl; |
| 404 | out << "<body>" << std::endl; |
| 405 | m_impl->flushUnsent(out); |
| 406 | out << "</body>" << std::endl; |
| 407 | out << "</html>" << std::endl; |
| 408 | |
| 409 | m_impl->m_document.append(out.str().c_str()); |
| 410 | } |
| 411 | |
| 412 | void RVNGHTMLTextGenerator::defineEmbeddedFont(const RVNGPropertyList &/*propList*/) |
| 413 | { |
| 414 | } |
| 415 | |
| 416 | void RVNGHTMLTextGenerator::openPageSpan(const RVNGPropertyList & /* propList */) |
| 417 | { |
| 418 | m_impl->m_actualPage++; |
| 419 | } |
| 420 | |
| 421 | void RVNGHTMLTextGenerator::closePageSpan() |
| 422 | { |
| 423 | } |
| 424 | |
| 425 | void RVNGHTMLTextGenerator::definePageStyle(const RVNGPropertyList &) {} |
| 426 | |
| 427 | void RVNGHTMLTextGenerator::openHeader(const RVNGPropertyList & /* propList */) |
| 428 | { |
| 429 | m_impl->m_ignore = true; |
| 430 | } |
| 431 | |
| 432 | void RVNGHTMLTextGenerator::closeHeader() |
| 433 | { |
| 434 | m_impl->m_ignore = false; |
| 435 | } |
| 436 | |
| 437 | |
| 438 | void RVNGHTMLTextGenerator::openFooter(const RVNGPropertyList & /* propList */) |
| 439 | { |
| 440 | m_impl->m_ignore = true; |
| 441 | } |
| 442 | |
| 443 | void RVNGHTMLTextGenerator::closeFooter() |
| 444 | { |
| 445 | m_impl->m_ignore = false; |
| 446 | } |
| 447 | |
| 448 | void RVNGHTMLTextGenerator::defineSectionStyle(const RVNGPropertyList &) {} |
| 449 | void RVNGHTMLTextGenerator::openSection(const RVNGPropertyList & /* propList */) {} |
| 450 | void RVNGHTMLTextGenerator::closeSection() {} |
| 451 | |
| 452 | void RVNGHTMLTextGenerator::defineParagraphStyle(const RVNGPropertyList &propList) |
| 453 | { |
| 454 | RVNGPropertyList pList(propList); |
| 455 | if (pList["text:outline-level"]) |
| 456 | pList.remove("text:outline-level"); |
| 457 | m_impl->m_paragraphManager.defineParagraph(pList); |
| 458 | } |
| 459 | |
| 460 | void RVNGHTMLTextGenerator::openParagraph(const RVNGPropertyList &propList) |
| 461 | { |
| 462 | if (m_impl->m_ignore) |
| 463 | return; |
| 464 | |
| 465 | m_impl->m_currentParaElement = "p"; |
| 466 | |
| 467 | const RVNGProperty *const outlineLevel = propList["text:outline-level"]; |
| 468 | if (outlineLevel) |
| 469 | { |
| 470 | const int level = outlineLevel->getInt(); |
| 471 | if ((0 < level) && (7 > level)) |
| 472 | m_impl->m_currentParaElement = "h" + std::to_string(level); |
| 473 | } |
| 474 | |
| 475 | m_impl->output(false) << "<" << m_impl->m_currentParaElement |
| 476 | << " class=\"" << m_impl->m_paragraphManager.getClass(propList) << "\">"; |
| 477 | } |
| 478 | |
| 479 | void RVNGHTMLTextGenerator::closeParagraph() |
| 480 | { |
| 481 | if (m_impl->m_ignore) |
| 482 | return; |
| 483 | |
| 484 | assert(!m_impl->m_currentParaElement.empty()); |
| 485 | m_impl->output() << "</" << m_impl->m_currentParaElement << ">" << std::endl; |
| 486 | } |
| 487 | |
| 488 | void RVNGHTMLTextGenerator::defineCharacterStyle(const RVNGPropertyList &propList) |
| 489 | { |
| 490 | m_impl->m_spanManager.defineSpan(propList); |
| 491 | } |
| 492 | |
| 493 | void RVNGHTMLTextGenerator::openSpan(const RVNGPropertyList &propList) |
| 494 | { |
| 495 | if (m_impl->m_ignore) |
| 496 | return; |
| 497 | |
| 498 | m_impl->output() << "<span class=\"" << m_impl->m_spanManager.getClass(propList) << "\">"; |
| 499 | } |
| 500 | |
| 501 | void RVNGHTMLTextGenerator::closeSpan() |
| 502 | { |
| 503 | if (m_impl->m_ignore) |
| 504 | return; |
| 505 | m_impl->output() << "</span>" << std::endl; |
| 506 | } |
| 507 | |
| 508 | void RVNGHTMLTextGenerator::openLink(const RVNGPropertyList &propList) |
| 509 | { |
| 510 | if (m_impl->m_ignore) |
| 511 | return; |
| 512 | |
| 513 | if (!propList["librevenge:type"]) |
| 514 | { |
| 515 | RVNG_DEBUG_MSG(("RVNGHTMLTextGenerator::openLink: librevenge:type: not filled, suppose link\n")); |
| 516 | } |
| 517 | m_impl->output() << "<a "; |
| 518 | if (propList["xlink:href"]) |
| 519 | m_impl->output() << "href=\"" << RVNGString::escapeXML(propList["xlink:href"]->getStr()).cstr() << "\""; |
| 520 | m_impl->output() << ">"; |
| 521 | } |
| 522 | |
| 523 | void RVNGHTMLTextGenerator::closeLink() |
| 524 | { |
| 525 | if (m_impl->m_ignore) |
| 526 | return; |
| 527 | m_impl->output() << "</a>" << std::endl; |
| 528 | } |
| 529 | |
| 530 | void RVNGHTMLTextGenerator::insertTab() |
| 531 | { |
| 532 | if (m_impl->m_ignore) |
| 533 | return; |
| 534 | |
| 535 | // Does not have a lot of effect since tabs in html are ignorable white-space |
| 536 | m_impl->output() << "\t"; |
| 537 | } |
| 538 | |
| 539 | void RVNGHTMLTextGenerator::insertLineBreak() |
| 540 | { |
| 541 | if (m_impl->m_ignore) |
| 542 | return; |
| 543 | m_impl->output() << "<br>" << std::endl; |
| 544 | } |
| 545 | |
| 546 | void RVNGHTMLTextGenerator::insertField(const RVNGPropertyList & /* propList */) |
| 547 | { |
| 548 | if (m_impl->m_ignore) |
| 549 | return; |
| 550 | m_impl->output() << "#" << std::endl; |
| 551 | } |
| 552 | |
| 553 | void RVNGHTMLTextGenerator::insertText(const RVNGString &text) |
| 554 | { |
| 555 | if (m_impl->m_ignore) |
| 556 | return; |
| 557 | m_impl->output() << RVNGString::escapeXML(text).cstr(); |
| 558 | } |
| 559 | |
| 560 | void RVNGHTMLTextGenerator::insertSpace() |
| 561 | { |
| 562 | if (m_impl->m_ignore) |
| 563 | return; |
| 564 | m_impl->output() << " "; |
| 565 | } |
| 566 | |
| 567 | void RVNGHTMLTextGenerator::openOrderedListLevel(const RVNGPropertyList &propList) |
| 568 | { |
| 569 | if (m_impl->m_ignore) |
| 570 | return; |
| 571 | m_impl->m_listManager.defineLevel(propList, true); |
| 572 | // fixme: if level is > 1, we must first insert a div here |
| 573 | m_impl->output(false) << "<ol class=\"" << m_impl->m_listManager.openLevel(propList, true) << "\">\n"; |
| 574 | } |
| 575 | |
| 576 | void RVNGHTMLTextGenerator::closeOrderedListLevel() |
| 577 | { |
| 578 | if (m_impl->m_ignore) |
| 579 | return; |
| 580 | m_impl->m_listManager.closeLevel(); |
| 581 | m_impl->output() << "</ol>" << std::endl; |
| 582 | } |
| 583 | |
| 584 | void RVNGHTMLTextGenerator::openUnorderedListLevel(const RVNGPropertyList &propList) |
| 585 | { |
| 586 | if (m_impl->m_ignore) |
| 587 | return; |
| 588 | m_impl->m_listManager.defineLevel(propList, false); |
| 589 | // fixme: if level is > 1, we must first insert a div here |
| 590 | m_impl->output(false) << "<ul class=\"" << m_impl->m_listManager.openLevel(propList, false) << "\">\n"; |
| 591 | } |
| 592 | |
| 593 | void RVNGHTMLTextGenerator::closeUnorderedListLevel() |
| 594 | { |
| 595 | if (m_impl->m_ignore) |
| 596 | return; |
| 597 | m_impl->m_listManager.closeLevel(); |
| 598 | m_impl->output() << "</ul>" << std::endl; |
| 599 | } |
| 600 | |
| 601 | |
| 602 | void RVNGHTMLTextGenerator::openListElement(const RVNGPropertyList &propList) |
| 603 | { |
| 604 | if (m_impl->m_ignore) |
| 605 | return; |
| 606 | m_impl->output(false) << "<li class=\"" << m_impl->m_listManager.getClass(propList) << "\">"; |
| 607 | } |
| 608 | |
| 609 | void RVNGHTMLTextGenerator::closeListElement() |
| 610 | { |
| 611 | if (m_impl->m_ignore) |
| 612 | return; |
| 613 | m_impl->output() << "</li>" << std::endl; |
| 614 | } |
| 615 | |
| 616 | void RVNGHTMLTextGenerator::openFootnote(const RVNGPropertyList &) |
| 617 | { |
| 618 | if (m_impl->m_ignore) |
| 619 | return; |
| 620 | std::ostream &out=m_impl->output(); |
| 621 | m_impl->push(RVNGHTMLTextZone::Z_FootNote); |
| 622 | m_impl->stream().addLabel(out); |
| 623 | } |
| 624 | |
| 625 | void RVNGHTMLTextGenerator::closeFootnote() |
| 626 | { |
| 627 | if (m_impl->m_ignore) |
| 628 | return; |
| 629 | m_impl->pop(); |
| 630 | } |
| 631 | |
| 632 | void RVNGHTMLTextGenerator::openEndnote(const RVNGPropertyList &) |
| 633 | { |
| 634 | if (m_impl->m_ignore) |
| 635 | return; |
| 636 | std::ostream &out=m_impl->output(); |
| 637 | m_impl->push(RVNGHTMLTextZone::Z_EndNote); |
| 638 | m_impl->stream().addLabel(out); |
| 639 | } |
| 640 | |
| 641 | void RVNGHTMLTextGenerator::closeEndnote() |
| 642 | { |
| 643 | if (m_impl->m_ignore) |
| 644 | return; |
| 645 | m_impl->pop(); |
| 646 | } |
| 647 | |
| 648 | void RVNGHTMLTextGenerator::openComment(const RVNGPropertyList & /*propList*/) |
| 649 | { |
| 650 | if (m_impl->m_ignore) |
| 651 | return; |
| 652 | std::ostream &out=m_impl->output(); |
| 653 | m_impl->push(RVNGHTMLTextZone::Z_Comment); |
| 654 | m_impl->stream().addLabel(out); |
| 655 | } |
| 656 | |
| 657 | void RVNGHTMLTextGenerator::closeComment() |
| 658 | { |
| 659 | if (m_impl->m_ignore) |
| 660 | return; |
| 661 | m_impl->pop(); |
| 662 | } |
| 663 | |
| 664 | void RVNGHTMLTextGenerator::openTextBox(const RVNGPropertyList & /*propList*/) |
| 665 | { |
| 666 | if (m_impl->m_ignore) |
| 667 | return; |
| 668 | std::ostream &out=m_impl->output(); |
| 669 | m_impl->push(RVNGHTMLTextZone::Z_TextBox); |
| 670 | m_impl->stream().addLabel(out); |
| 671 | } |
| 672 | |
| 673 | void RVNGHTMLTextGenerator::closeTextBox() |
| 674 | { |
| 675 | if (m_impl->m_ignore) |
| 676 | return; |
| 677 | m_impl->pop(); |
| 678 | } |
| 679 | |
| 680 | void RVNGHTMLTextGenerator::openTable(const RVNGPropertyList &propList) |
| 681 | { |
| 682 | if (m_impl->m_ignore) |
| 683 | return; |
| 684 | |
| 685 | const librevenge::RVNGPropertyListVector *columns = propList.child("librevenge:table-columns"); |
| 686 | if (columns) |
| 687 | m_impl->m_tableManager.openTable(*columns); |
| 688 | m_impl->output() << "<table>" << std::endl; |
| 689 | m_impl->output() << "<tbody>" << std::endl; |
| 690 | } |
| 691 | |
| 692 | void RVNGHTMLTextGenerator::openTableRow(const RVNGPropertyList &propList) |
| 693 | { |
| 694 | if (m_impl->m_ignore) |
| 695 | return; |
| 696 | m_impl->output() << "<tr class=\"" << m_impl->m_tableManager.getRowClass(propList) << "\">\n"; |
| 697 | } |
| 698 | |
| 699 | void RVNGHTMLTextGenerator::closeTableRow() |
| 700 | { |
| 701 | if (m_impl->m_ignore) |
| 702 | return; |
| 703 | m_impl->output() << "</tr>" << std::endl; |
| 704 | } |
| 705 | |
| 706 | void RVNGHTMLTextGenerator::openTableCell(const RVNGPropertyList &propList) |
| 707 | { |
| 708 | if (m_impl->m_ignore) |
| 709 | return; |
| 710 | std::ostream &out=m_impl->output(); |
| 711 | out << "<td class=\"" << m_impl->m_tableManager.getCellClass(propList) << "\""; |
| 712 | if (propList["table:number-columns-spanned"]) |
| 713 | out << " colspan=\"" << propList["table:number-columns-spanned"]->getInt() << "\""; |
| 714 | if (propList["table:number-rows-spanned"]) |
| 715 | out << " rowspan=\"" << propList["table:number-rows-spanned"]->getInt() << "\""; |
| 716 | out << ">" << std::endl; |
| 717 | |
| 718 | } |
| 719 | |
| 720 | void RVNGHTMLTextGenerator::closeTableCell() |
| 721 | { |
| 722 | if (m_impl->m_ignore) |
| 723 | return; |
| 724 | m_impl->output() << "</td>" << std::endl; |
| 725 | } |
| 726 | |
| 727 | void RVNGHTMLTextGenerator::insertCoveredTableCell(const RVNGPropertyList & /* propList */) {} |
| 728 | |
| 729 | void RVNGHTMLTextGenerator::closeTable() |
| 730 | { |
| 731 | if (m_impl->m_ignore) |
| 732 | return; |
| 733 | m_impl->output() << "</tbody>" << std::endl; |
| 734 | m_impl->output() << "</table>" << std::endl; |
| 735 | m_impl->m_tableManager.closeTable(); |
| 736 | } |
| 737 | |
| 738 | void RVNGHTMLTextGenerator::openFrame(const RVNGPropertyList & /* propList */) {} |
| 739 | void RVNGHTMLTextGenerator::closeFrame() {} |
| 740 | |
| 741 | void RVNGHTMLTextGenerator::openGroup(const librevenge::RVNGPropertyList & /* propList */) {} |
| 742 | void RVNGHTMLTextGenerator::closeGroup() {} |
| 743 | |
| 744 | void RVNGHTMLTextGenerator::defineGraphicStyle(const librevenge::RVNGPropertyList & /* propList */) {} |
| 745 | void RVNGHTMLTextGenerator::drawRectangle(const librevenge::RVNGPropertyList & /* propList */) {} |
| 746 | void RVNGHTMLTextGenerator::drawEllipse(const librevenge::RVNGPropertyList & /* propList */) {} |
| 747 | void RVNGHTMLTextGenerator::drawPolygon(const librevenge::RVNGPropertyList & /* propList */) {} |
| 748 | void RVNGHTMLTextGenerator::drawPolyline(const librevenge::RVNGPropertyList & /* propList */) {} |
| 749 | void RVNGHTMLTextGenerator::drawPath(const librevenge::RVNGPropertyList & /* propList */) {} |
| 750 | void RVNGHTMLTextGenerator::drawConnector(const librevenge::RVNGPropertyList & /* propList */) {} |
| 751 | |
| 752 | void RVNGHTMLTextGenerator::insertBinaryObject(const RVNGPropertyList & /* propList */) {} |
| 753 | void RVNGHTMLTextGenerator::insertEquation(const RVNGPropertyList & /* propList */) {} |
| 754 | |
| 755 | } |
| 756 | /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */ |