| 477 | } |
| 478 | |
| 479 | bool TextDocumentGenerator::exportTo(const QString &fileName, const Okular::ExportFormat &format) |
| 480 | { |
| 481 | Q_D(TextDocumentGenerator); |
| 482 | if (!d->mDocument) { |
| 483 | return false; |
| 484 | } |
| 485 | |
| 486 | if (format.mimeType().name() == QLatin1String("application/pdf")) { |
| 487 | QFile file(fileName); |
| 488 | if (!file.open(QIODevice::WriteOnly)) { |
| 489 | return false; |
| 490 | } |
| 491 | |
| 492 | QPrinter printer(QPrinter::HighResolution); |
| 493 | printer.setOutputFormat(QPrinter::PdfFormat); |
| 494 | printer.setOutputFileName(fileName); |
| 495 | d->mDocument->print(&printer); |
| 496 | |
| 497 | return true; |
| 498 | } else if (format.mimeType().name() == QLatin1String("text/plain")) { |
| 499 | QFile file(fileName); |
| 500 | if (!file.open(QIODevice::WriteOnly)) { |
| 501 | return false; |
| 502 | } |
| 503 | |
| 504 | QTextStream out(&file); |
| 505 | out << d->mDocument->toPlainText(); |
| 506 | |
| 507 | return true; |
| 508 | } else if (format.mimeType().name() == QLatin1String("application/vnd.oasis.opendocument.text")) { |
| 509 | QTextDocumentWriter odfWriter(fileName, "odf"); |
| 510 | |
| 511 | return odfWriter.write(d->mDocument); |
| 512 | } else if (format.mimeType().name() == QLatin1String("text/html")) { |
| 513 | QTextDocumentWriter odfWriter(fileName, "html"); |
| 514 | |
| 515 | return odfWriter.write(d->mDocument); |
| 516 | } |
| 517 | return false; |
| 518 | } |
| 519 | |
| 520 | bool TextDocumentGenerator::reparseConfig() |
| 521 | { |