[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: [PATCH] EPS support in kfile_ps plugin
From: Martin Willers <M.Willers () tu-bs ! de>
Date: 2003-07-31 15:05:03
[Download RAW message or body]
Hi!
This patch to kdegraphics/kfile-plugins/ps/ adds support for displaying meta
info on EPS files (currently, only PS files are supported). I am fairly
sure that there had been EPS support not too long ago, but couldn't find
any prove for this in my CVS history!?
It would be nice if KFilePlugin had some kind of MIME-aliasing (so one could
handle several MIME types (like in this case, "image/x-eps" and
"application/postscript") identically with one single kfile-plugin)...
["kfile_ps_eps.diff" (text/x-diff)]
Index: kfile_ps.cpp
===================================================================
RCS file: /home/kde/kdegraphics/kfile-plugins/ps/kfile_ps.cpp,v
retrieving revision 1.10
diff -u -3 -p -r1.10 kfile_ps.cpp
--- kfile_ps.cpp 27 Jul 2003 00:25:15 -0000 1.10
+++ kfile_ps.cpp 31 Jul 2003 14:42:21 -0000
@@ -31,14 +31,13 @@ typedef KGenericFactory<KPSPlugin> PSFac
K_EXPORT_COMPONENT_FACTORY(kfile_ps, PSFactory("kfile_ps"))
KPSPlugin::KPSPlugin(QObject *parent, const char *name,
- const QStringList &preferredItems) :
+ const QStringList &preferredItems) :
KFilePlugin( parent, name, preferredItems )
{
kdDebug(7034) << "ps plugin\n";
-
+
// set up our mimetype
KFileMimeTypeInfo* info = addMimeTypeInfo( "application/postscript" );
-
// general group
KFileMimeTypeInfo::GroupInfo* group = addGroupInfo(info, "General", i18n("General"));
addItemInfo(group, "Title", i18n("Title"), QVariant::String);
@@ -46,6 +45,17 @@ KPSPlugin::KPSPlugin(QObject *parent, co
addItemInfo(group, "CreationDate", i18n("Creation date"), QVariant::String);
addItemInfo(group, "For", i18n("For"), QVariant::String);
addItemInfo(group, "Pages", i18n("Pages"), QVariant::UInt);
+
+ // EPS files are handled exactly the same, except that 'Pages' doesn't make sense
+ // (an EPS file is always one single page)
+ info = addMimeTypeInfo( "image/x-eps" );
+ // general group
+ group = addGroupInfo(info, "General", i18n("General"));
+ addItemInfo(group, "Title", i18n("Title"), QVariant::String);
+ addItemInfo(group, "Creator", i18n("Creator"), QVariant::String);
+ addItemInfo(group, "CreationDate", i18n("Creation date"), QVariant::String);
+ addItemInfo(group, "For", i18n("For"), QVariant::String);
+ // FIXME: could add 'BoundingBox' instead?
}
bool KPSPlugin::readInfo( KFileMetaInfo& info, uint /* what */)
@@ -54,13 +64,14 @@ bool KPSPlugin::readInfo( KFileMetaInfo&
_group = appendGroup(info, "General");
_dsc = new KDSC;
_endComments = false;
+ _usePages = (info.mimeType() == QString("application/postscript"));
_setData = false;
_dsc->setCommentHandler( this );
FILE* fp = fopen( QFile::encodeName( info.path() ), "r" );
if( fp == 0 )
return false;
-
+
char buf[4096];
int count;
while( ( count = fread( buf, sizeof(char), 4096, fp ) ) != 0
@@ -72,9 +83,9 @@ bool KPSPlugin::readInfo( KFileMetaInfo&
delete _dsc;
_dsc = 0;
-
+
return _setData;
-}
+}
void KPSPlugin::comment( Name name )
{
@@ -99,11 +110,13 @@ void KPSPlugin::comment( Name name )
_setData = true;
break;
case Pages:
- pages = _dsc->page_pages();
- if (pages)
- {
- appendItem(_group, "Pages", pages);
- _setData = true;
+ if (_usePages) {
+ pages = _dsc->page_pages();
+ if (pages)
+ {
+ appendItem(_group, "Pages", pages);
+ _setData = true;
+ }
}
break;
case EndComments: _endComments = true;
Index: kfile_ps.h
===================================================================
RCS file: /home/kde/kdegraphics/kfile-plugins/ps/kfile_ps.h,v
retrieving revision 1.4
diff -u -3 -p -r1.4 kfile_ps.h
--- kfile_ps.h 22 Mar 2002 20:15:30 -0000 1.4
+++ kfile_ps.h 31 Jul 2003 14:42:21 -0000
@@ -33,16 +33,17 @@ class KPSPlugin: public KFilePlugin, pub
public:
KPSPlugin( QObject *parent, const char *name,
const QStringList& preferredItems );
-
+
virtual bool readInfo( KFileMetaInfo& info, uint what);
void comment( Name );
-
+
private:
KFileMetaInfo _info;
KFileMetaInfoGroup _group;
KDSC* _dsc;
bool _endComments;
+ bool _usePages;
bool _setData;
};
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic