summaryrefslogtreecommitdiffstats
path: root/kfile-plugins/pdf
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit47d455dd55be855e4cc691c32f687f723d9247ee (patch)
tree52e236aaa2576bdb3840ebede26619692fed6d7d /kfile-plugins/pdf
downloadtdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz
tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kfile-plugins/pdf')
-rw-r--r--kfile-plugins/pdf/Makefile.am22
-rw-r--r--kfile-plugins/pdf/configure.in.in15
-rw-r--r--kfile-plugins/pdf/kfile_pdf.cpp104
-rw-r--r--kfile-plugins/pdf/kfile_pdf.desktop64
-rw-r--r--kfile-plugins/pdf/kfile_pdf.h38
5 files changed, 243 insertions, 0 deletions
diff --git a/kfile-plugins/pdf/Makefile.am b/kfile-plugins/pdf/Makefile.am
new file mode 100644
index 00000000..841d9980
--- /dev/null
+++ b/kfile-plugins/pdf/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for the pdf file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes) $(POPPLER_CFLAGS)
+
+# these are the headers for your project
+noinst_HEADERS = kfile_pdf.h
+
+kde_module_LTLIBRARIES = kfile_pdf.la
+
+kfile_pdf_la_SOURCES = kfile_pdf.cpp
+kfile_pdf_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kfile_pdf_la_LIBADD = $(LIB_KIO) $(POPPLER_LIBS)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/kfile_pdf.pot
+
+services_DATA = kfile_pdf.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/kfile-plugins/pdf/configure.in.in b/kfile-plugins/pdf/configure.in.in
new file mode 100644
index 00000000..926497a5
--- /dev/null
+++ b/kfile-plugins/pdf/configure.in.in
@@ -0,0 +1,15 @@
+AC_ARG_WITH([poppler],
+ [AC_HELP_STRING([--with-poppler],
+ [Enable PDF support through poppler @<:@default=check@:>@])],
+ [], with_poppler=check)
+
+# Compile the pdf meta info plugin only if Poppler is available
+if test "x$with_poppler" != xno; then
+ PKG_CHECK_MODULES(POPPLER, poppler-qt >= 0.3.1, have_poppler=yes, have_poppler=no)
+
+ if test "x$with_poppler" != xcheck && test "x$have_poppler" != xyes; then
+ AC_MSG_ERROR([--with-poppler was given, but test for poppler failed])
+ fi
+fi
+
+AM_CONDITIONAL(include_PDF, test "x$have_poppler" = xyes)
diff --git a/kfile-plugins/pdf/kfile_pdf.cpp b/kfile-plugins/pdf/kfile_pdf.cpp
new file mode 100644
index 00000000..d5beeb60
--- /dev/null
+++ b/kfile-plugins/pdf/kfile_pdf.cpp
@@ -0,0 +1,104 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2001, 2002 Rolf Magnus <ramagnus@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $Id$
+ */
+
+#include "kfile_pdf.h"
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+typedef KGenericFactory<KPdfPlugin> PdfFactory;
+
+K_EXPORT_COMPONENT_FACTORY(kfile_pdf, PdfFactory("kfile_pdf"))
+
+KPdfPlugin::KPdfPlugin(QObject *parent, const char *name, const QStringList &preferredItems)
+ : KFilePlugin(parent, name, preferredItems)
+{
+ kdDebug(7034) << "pdf plugin\n";
+
+ // set up our mime type
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "application/pdf" );
+
+ // general group
+ KFileMimeTypeInfo::GroupInfo* group = addGroupInfo(info, "General", i18n("General"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+
+ item = addItemInfo(group, "Title", i18n("Title"), QVariant::String);
+ setHint(item, KFileMimeTypeInfo::Name);
+ item = addItemInfo(group, "Subject", i18n("Subject"), QVariant::String);
+ setHint(item, KFileMimeTypeInfo::Description);
+ item = addItemInfo(group, "Author", i18n("Author"), QVariant::String);
+ setHint(item, KFileMimeTypeInfo::Author);
+ addItemInfo(group, "Keywords", i18n("Key Words"), QVariant::String);
+ addItemInfo(group, "Creator", i18n("Creator"), QVariant::String);
+ addItemInfo(group, "Producer", i18n("Producer"), QVariant::String);
+ addItemInfo(group, "CreationDate", i18n("Creation Date"), QVariant::DateTime);
+ addItemInfo(group, "ModificationDate", i18n("Modified"), QVariant::DateTime);
+ addItemInfo(group, "Pages", i18n("Pages"), QVariant::Int);
+ addItemInfo(group, "Protected", i18n("Protected"), QVariant::String);
+ addItemInfo(group, "Linearized", i18n("Linearized"), QVariant::String);
+ addItemInfo(group, "Version", i18n("Version"), QVariant::String);
+}
+
+bool KPdfPlugin::readInfo( KFileMetaInfo& info, uint /* what */)
+{
+ Poppler::Document *doc = Poppler::Document::load(info.path());
+ if (!doc || doc->isLocked())
+ {
+ delete doc;
+ return false;
+ }
+
+ KFileMetaInfoGroup generalGroup = appendGroup(info, "General");
+
+ appendItem(generalGroup, "Title", doc->getInfo("Title") );
+ appendItem(generalGroup, "Subject", doc->getInfo("Subject") );
+ appendItem(generalGroup, "Author", doc->getInfo("Author") );
+ appendItem(generalGroup, "Keywords", doc->getInfo("Keywords") );
+ appendItem(generalGroup, "Creator", doc->getInfo("Creator") );
+ appendItem(generalGroup, "Producer", doc->getInfo("Producer") );
+
+ appendItem(generalGroup, "CreationDate", doc->getDate("CreationDate") );
+ appendItem(generalGroup, "ModificationDate", doc->getDate("ModDate") );
+ appendItem(generalGroup, "Pages", doc->getNumPages() );
+
+ QString enc;
+ if (doc->isEncrypted())
+ {
+ enc = i18n("Yes (Can Print:%1 Can Copy:%2 Can Change:%3 Can Add notes:%4)")
+ .arg(doc->okToPrint() ? i18n("Yes") : i18n("No"))
+ .arg(doc->okToCopy() ? i18n("Yes") : i18n("No"))
+ .arg(doc->okToChange() ? i18n("Yes") : i18n("No"))
+ .arg(doc->okToAddNotes() ? i18n("Yes") : i18n("No"));
+ }
+ else enc = i18n("No");
+
+ appendItem(generalGroup, "Protected", enc );
+ appendItem(generalGroup, "Linearized", doc->isLinearized() ? i18n("Yes") : i18n("No") );
+ QString versionString = QString("%1").arg( doc->getPDFVersion(), 0, 'f', 1 );
+ appendItem(generalGroup, "Version", versionString );
+
+ delete doc;
+
+ return true;
+}
+
+#include "kfile_pdf.moc"
+
diff --git a/kfile-plugins/pdf/kfile_pdf.desktop b/kfile-plugins/pdf/kfile_pdf.desktop
new file mode 100644
index 00000000..cdc6a8e8
--- /dev/null
+++ b/kfile-plugins/pdf/kfile_pdf.desktop
@@ -0,0 +1,64 @@
+[Desktop Entry]
+Type=Service
+Name=PDF Info
+Name[af]=Pdf Inligting
+Name[ar]=معلومات PDF
+Name[br]=Titouroù PDF
+Name[ca]=Informació de PDF
+Name[cs]=PDF info
+Name[cy]=Gybodaeth PDF
+Name[da]=PDF-info
+Name[de]=PDF-Info
+Name[el]=Πληροφορίες PDF
+Name[eo]=PDF-informo
+Name[es]=Info PDF
+Name[et]=PDF info
+Name[fa]=اطلاعات PDF
+Name[fi]=PDF-tiedot
+Name[fr]=Informations PDF
+Name[gl]=Inf. PDF
+Name[he]=מידע PDF
+Name[hi]=PDF जानकारी
+Name[hr]=PDF Informacije
+Name[hu]=PDF-jellemzők
+Name[is]=PDF upplýsingar
+Name[it]=Informazioni PDF
+Name[ja]=PDF 情報
+Name[kk]=PDF мәліметі
+Name[km]=ព័ត៌មាន PDF
+Name[lt]=PDF informacija
+Name[ms]=Maklumat PDF
+Name[nds]=PDF-Info
+Name[ne]=PDF सूचना
+Name[nl]=PDF-info
+Name[nn]=PDF-info
+Name[nso]=Tshedimoso ya PDF
+Name[pa]=PDF ਜਾਣਕਾਰੀ
+Name[pl]=Informacja o pliku PDF
+Name[pt]=Informação do PDF
+Name[pt_BR]=Informação sobre PDF
+Name[ro]=Informaţii PDF
+Name[ru]=Информация о PDF
+Name[se]=PDF-dieđut
+Name[sl]=Podatki o PDF
+Name[sr]=PDF информације
+Name[sr@Latn]=PDF informacije
+Name[sv]=PDF-information
+Name[ta]=PDF தகவல்
+Name[tg]=Иттилоот оиди PDF
+Name[th]=ข้อมูลแฟ้ม PDF
+Name[tr]=PDF Bilgisi
+Name[uk]=Інформація про PDF
+Name[uz]=PDF haqida maʼlumot
+Name[uz@cyrillic]=PDF ҳақида маълумот
+Name[ven]=Mafhungo a PDF
+Name[wa]=Informåcion sol documint PDF
+Name[xh]=PDF Ulwazi
+Name[zh_CN]=PDF 信息
+Name[zh_HK]=PDF 資訊
+Name[zh_TW]=PDF 資訊
+Name[zu]=Ulwazi lwe-PDF
+ServiceTypes=KFilePlugin
+X-KDE-Library=kfile_pdf
+MimeType=application/pdf
+PreferredItems=Title,Subject,Author,Keywords,Creator,Producer,CreationDate,ModificationDate,Pages,Protected,Linearized,Version
diff --git a/kfile-plugins/pdf/kfile_pdf.h b/kfile-plugins/pdf/kfile_pdf.h
new file mode 100644
index 00000000..b0214f54
--- /dev/null
+++ b/kfile-plugins/pdf/kfile_pdf.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2001, 2002 Rolf Magnus <ramagnus@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $Id$
+ */
+
+#ifndef __KFILE_PDF_H__
+#define __KFILE_PDF_H__
+
+#include <kfilemetainfo.h>
+#include <poppler-qt.h>
+
+class QStringList;
+
+class KPdfPlugin: public KFilePlugin
+{
+Q_OBJECT
+public:
+ KPdfPlugin( QObject *parent, const char *name, const QStringList& preferredItems );
+
+ virtual bool readInfo(KFileMetaInfo& info, uint what);
+};
+
+#endif