From 2d237a802ab0936a2fe82307685e3e7fa3df3f1d Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 1 Sep 2005 13:41:25 +0000 Subject: [PATCH] If somebody from the upper spheres (like Konqui for example) gives us the mimetype use it instead trying to guess the mimetype ourselves for the file we are opening, fixes problem in opening a pdf file generated by php code svn path=/branches/KDE/3.5/kdegraphics/kpdf/; revision=455826 --- core/document.cpp | 4 +--- core/document.h | 4 +++- part.cpp | 12 ++++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) 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());