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
remotes/origin/kpdf-3.5
Albert Astals Cid 21 years ago
parent 46f05ccaa0
commit 2d237a802a
  1. 4
      core/document.cpp
  2. 4
      core/document.h
  3. 12
      part.cpp

@ -24,7 +24,6 @@
#include <kmessagebox.h>
#include <kapplication.h>
#include <kuserprofile.h>
#include <kmimetype.h>
#include <krun.h>
#include <kstandarddirs.h>
@ -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" )

@ -16,6 +16,8 @@
#include <qstring.h>
#include <qdom.h>
#include <kmimetype.h>
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

@ -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());

Loading…
Cancel
Save