diff --git a/core/generator.cpp b/core/generator.cpp index 40f32a058..302dc233b 100644 --- a/core/generator.cpp +++ b/core/generator.cpp @@ -554,6 +554,9 @@ ExportFormat ExportFormat::standardFormat( StandardExportFormat type ) KIcon( "application-vnd.oasis.opendocument.text" ), i18nc( "This is the document format", "OpenDocument Text" ), KMimeType::mimeType( "application/vnd.oasis.opendocument.text" ) ); + break; + case HTML: + return ExportFormat( KIcon( "text-html" ), i18nc( "This is the document format", "HTML" ), KMimeType::mimeType( "text/html" ) ); break; } return ExportFormat(); diff --git a/core/generator.h b/core/generator.h index 322de7e8d..4b88a9e2c 100644 --- a/core/generator.h +++ b/core/generator.h @@ -144,7 +144,8 @@ class OKULAR_EXPORT ExportFormat { PlainText, ///< Plain text PDF, ///< PDF, aka Portable Document Format - OpenDocumentText ///< OpenDocument Text format @since 0.8 (KDE 4.2) + OpenDocumentText, ///< OpenDocument Text format @since 0.8 (KDE 4.2) + HTML ///< OpenDocument Text format @since 0.8 (KDE 4.2) }; /** diff --git a/core/textdocumentgenerator.cpp b/core/textdocumentgenerator.cpp index f27f3e7dd..656e05c5f 100644 --- a/core/textdocumentgenerator.cpp +++ b/core/textdocumentgenerator.cpp @@ -19,6 +19,9 @@ #include #include #include +#if QT_VERSION >= 0x040500 +#include +#endif #include #include @@ -425,6 +428,14 @@ Okular::ExportFormat::List TextDocumentGenerator::exportFormats( ) const if ( formats.isEmpty() ) { formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PlainText ) ); formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PDF ) ); +#if QT_VERSION >= 0x040500 + if ( QTextDocumentWriter::supportedDocumentFormats().contains( "ODF" ) ) { + formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::OpenDocumentText ) ); + } + if ( QTextDocumentWriter::supportedDocumentFormats().contains( "HTML" ) ) { + formats.append( Okular::ExportFormat::standardFormat( Okular::ExportFormat::HTML ) ); + } +#endif } return formats; @@ -456,8 +467,17 @@ bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::Exp out << d->mDocument->toPlainText(); return true; - } +#if QT_VERSION >= 0x040500 + } else if ( format.mimeType()->name() == QLatin1String( "application/vnd.oasis.opendocument.text" ) ) { + QTextDocumentWriter odfWriter( fileName, "odf" ); + return odfWriter.write( d->mDocument ); + } else if ( format.mimeType()->name() == QLatin1String( "text/html" ) ) { + QTextDocumentWriter odfWriter( fileName, "html" ); + + return odfWriter.write( d->mDocument ); + } +#endif return false; }