You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
4.0 KiB
105 lines
4.0 KiB
15 years ago
|
/* 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$
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include "tdefile_pdf.h"
|
||
15 years ago
|
|
||
|
#include <kgenericfactory.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
|
typedef KGenericFactory<KPdfPlugin> PdfFactory;
|
||
|
|
||
12 years ago
|
K_EXPORT_COMPONENT_FACTORY(tdefile_pdf, PdfFactory("tdefile_pdf"))
|
||
15 years ago
|
|
||
14 years ago
|
KPdfPlugin::KPdfPlugin(TQObject *parent, const char *name, const TQStringList &preferredItems)
|
||
|
: KFilePlugin(parent, name, preferredItems)
|
||
15 years ago
|
{
|
||
|
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;
|
||
|
|
||
15 years ago
|
item = addItemInfo(group, "Title", i18n("Title"), TQVariant::String);
|
||
15 years ago
|
setHint(item, KFileMimeTypeInfo::Name);
|
||
15 years ago
|
item = addItemInfo(group, "Subject", i18n("Subject"), TQVariant::String);
|
||
15 years ago
|
setHint(item, KFileMimeTypeInfo::Description);
|
||
15 years ago
|
item = addItemInfo(group, "Author", i18n("Author"), TQVariant::String);
|
||
15 years ago
|
setHint(item, KFileMimeTypeInfo::Author);
|
||
15 years ago
|
addItemInfo(group, "Keywords", i18n("Key Words"), TQVariant::String);
|
||
|
addItemInfo(group, "Creator", i18n("Creator"), TQVariant::String);
|
||
|
addItemInfo(group, "Producer", i18n("Producer"), TQVariant::String);
|
||
|
addItemInfo(group, "CreationDate", i18n("Creation Date"), TQVariant::DateTime);
|
||
|
addItemInfo(group, "ModificationDate", i18n("Modified"), TQVariant::DateTime);
|
||
|
addItemInfo(group, "Pages", i18n("Pages"), TQVariant::Int);
|
||
|
addItemInfo(group, "Protected", i18n("Protected"), TQVariant::String);
|
||
|
addItemInfo(group, "Linearized", i18n("Linearized"), TQVariant::String);
|
||
|
addItemInfo(group, "Version", i18n("Version"), TQVariant::String);
|
||
15 years ago
|
}
|
||
|
|
||
|
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() );
|
||
|
|
||
15 years ago
|
TQString enc;
|
||
15 years ago
|
if (doc->isEncrypted())
|
||
|
{
|
||
|
enc = i18n("Yes (Can Print:%1 Can Copy:%2 Can Change:%3 Can Add notes:%4)")
|
||
13 years ago
|
.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"));
|
||
15 years ago
|
}
|
||
|
else enc = i18n("No");
|
||
|
|
||
|
appendItem(generalGroup, "Protected", enc );
|
||
|
appendItem(generalGroup, "Linearized", doc->isLinearized() ? i18n("Yes") : i18n("No") );
|
||
13 years ago
|
TQString versionString = TQString("%1").arg( doc->getPDFVersion(), 0, 'f', 1 );
|
||
15 years ago
|
appendItem(generalGroup, "Version", versionString );
|
||
|
|
||
|
delete doc;
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
12 years ago
|
#include "tdefile_pdf.moc"
|
||
15 years ago
|
|