diff --git a/core/document.cpp b/core/document.cpp index 1b0154887..37f3e31d4 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -132,7 +131,7 @@ KPDFDocument::~KPDFDocument() } -bool KPDFDocument::openDocument( const QString & docFile, const KURL & url ) +bool KPDFDocument::openDocument( const QString & docFile, const KURL & url, const KMimeType::Ptr &mime ) { // docFile is always local so we can use QFile on it QFile fileReadTest( docFile ); @@ -150,7 +149,6 @@ bool KPDFDocument::openDocument( const QString & docFile, const KURL & url ) d->xmlFileName = locateLocal( "data", fn ); // create the generator based on the file's mimetype - KMimeType::Ptr mime = KMimeType::findByPath( docFile ); if ( (*mime).is( "application/pdf" ) ) generator = new PDFGenerator( this ); // else if ( mimeName == "application/postscript" ) diff --git a/core/document.h b/core/document.h index 07fb11f3e..b5a8c6b0b 100644 --- a/core/document.h +++ b/core/document.h @@ -16,6 +16,8 @@ #include #include +#include + class KPDFPage; class KPDFLink; class DocumentObserver; @@ -53,7 +55,7 @@ class KPDFDocument : public QObject ~KPDFDocument(); // document handling - bool openDocument( const QString & docFile, const KURL & url ); + bool openDocument( const QString & docFile, const KURL & url, const KMimeType::Ptr &mime ); void closeDocument(); // misc methods diff --git a/part.cpp b/part.cpp index 864bb3043..4fba0952b 100644 --- a/part.cpp +++ b/part.cpp @@ -343,7 +343,15 @@ KAboutData* Part::createAboutData() bool Part::openFile() { - KMimeType::Ptr mime = KMimeType::findByPath( m_file ); + KMimeType::Ptr mime; + if ( m_bExtension->urlArgs().serviceType.isEmpty() ) + { + mime = KMimeType::findByPath( m_file ); + } + else + { + mime = KMimeType::mimeType( m_bExtension->urlArgs().serviceType ); + } if ( (*mime).is( "application/postscript" ) ) { QString app = KStandardDirs::findExe( "ps2pdf" ); @@ -373,7 +381,7 @@ bool Part::openFile() m_temporaryLocalFile = QString::null; - bool ok = m_document->openDocument( m_file, url() ); + bool ok = m_document->openDocument( m_file, url(), mime ); // update one-time actions m_find->setEnabled( ok && m_document-> supportsSearching());