[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/3.5/kdegraphics/kdvi
From: Stefan Kebekus <stefan.kebekus () uni-bayreuth ! de>
Date: 2005-10-09 8:17:56
Message-ID: 1128845876.088120.29325.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 468828 by kebekus:
robustification, patch by Angus Leeming
M +12 -8 dviRenderer_prescan.cpp
M +8 -8 special.cpp
--- branches/KDE/3.5/kdegraphics/kdvi/dviRenderer_prescan.cpp #468827:468828
@@ -38,8 +38,6 @@
//#define DEBUG_PRESCAN
-
-
void dviRenderer::prescan_embedPS(char *cp, Q_UINT8 *beginningOfSpecialCommand)
{
#ifdef DEBUG_PRESCAN
@@ -69,11 +67,17 @@
if ((EPSfilename.at(0) == '\"') && (EPSfilename.at(EPSfilename.length()-1) == \
'\"')) EPSfilename = EPSfilename.mid(1,EPSfilename.length()-2);
- // If the file name ends in 'png', 'gif', 'jpg' or 'jpeg', we assume
- // that this is NOT a PostScript file, and we exit here. The graphic
- // file is later read when the page is rendered.
- QString ending = EPSfilename.section('.', -1).lower();
- if ((ending == "png") || (ending == "gif") || (ending == "jpg") || (ending == \
"jpeg") || (ending == "mng")) + // If the file is neither a PostScript not a PDF \
file, we exit here. + // The graphic file is later read when the page is rendered.
+ KMimeType::Ptr const mime_type =
+ KMimeType::findByFileContent(EPSfilename);
+ QString const & mime_type_name = mime_type->name();
+
+ bool const is_ps_file = (mime_type_name == "application/postscript" ||
+ mime_type_name == "image/x-eps");
+ bool const is_pdf_file = (!is_ps_file &&
+ mime_type_name == "application/pdf");
+ if (!(is_ps_file || is_pdf_file))
return;
QString originalFName = EPSfilename;
@@ -86,7 +90,7 @@
EPSfilename = ghostscript_interface::locateEPSfile(EPSfilename, dviFile);
// If the EPSfilename really points to a PDF file, convert that file now.
- if (ending == "pdf")
+ if (is_pdf_file)
EPSfilename = dviFile->convertPDFtoPS(EPSfilename);
if (!QFile::exists(EPSfilename)) {
--- branches/KDE/3.5/kdegraphics/kdvi/special.cpp #468827:468828
@@ -9,6 +9,7 @@
#include <kdebug.h>
#include <klocale.h>
+#include <kmimetype.h>
#include <kprocio.h>
#include <qdir.h>
#include <qfile.h>
@@ -356,15 +357,14 @@
parse_special_argument(include_command, "rhi=", &rhi);
parse_special_argument(include_command, "angle=", &angle);
+ // If we have a png, gif, jpeg or mng file, we need to draw it here.
+ KMimeType::Ptr const mime_type = KMimeType::findByFileContent(EPSfilename);
+ QString const & mime_type_name = mime_type->name();
+ bool const isGFX = (mime_type_name == "image/png" ||
+ mime_type_name == "image/gif" ||
+ mime_type_name == "image/jpeg" ||
+ mime_type_name == "video/x-mng");
- // If the file name ends in 'png', 'gif', 'jpg' or 'jpeg', we assume
- // that this is NOT a PostScript file, and we need to draw that
- // here.
- QString ending = EPSfilename.section('.', -1).lower();
- bool isGFX = false;
- if ((ending == "png") || (ending == "gif") || (ending == "jpg") || (ending == \
"jpeg") || (ending == "mng"))
- isGFX = true;
-
// So, if we do not have a PostScript file, but a graphics file, and
// if that file exists, we draw it here.
if (isGFX && QFile::exists(EPSfilename)) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic