"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/podofoplugin.cpp" between
krename-4.0.9.tar.gz and krename-4.90.90.tar.gz

About: KRename is a batch file-renamer (KDE).

podofoplugin.cpp  (krename-4.0.9):podofoplugin.cpp  (krename-4.90.90)
skipping to change at line 18 skipping to change at line 18
/*************************************************************************** /***************************************************************************
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
***************************************************************************/ ***************************************************************************/
#include "../config-krename.h"
#ifdef HAVE_PODOFO
#include "podofoplugin.h" #include "podofoplugin.h"
#include <klocale.h>
#include <podofo/podofo.h> #include <podofo/podofo.h>
#include "batchrenamer.h" #include "batchrenamer.h"
#include "tokenhelpdialog.h" #include "tokenhelpdialog.h"
using namespace PoDoFo; using namespace PoDoFo;
PodofoPlugin::PodofoPlugin( PluginLoader* loader ) PodofoPlugin::PodofoPlugin(PluginLoader *loader)
: FilePlugin( loader ) : FilePlugin(loader)
{ {
this->addSupportedToken("pdfAuthor"); this->addSupportedToken("pdfAuthor");
this->addSupportedToken("pdfCreator"); this->addSupportedToken("pdfCreator");
this->addSupportedToken("pdfKeywords"); this->addSupportedToken("pdfKeywords");
this->addSupportedToken("pdfSubject"); this->addSupportedToken("pdfSubject");
this->addSupportedToken("pdfTitle"); this->addSupportedToken("pdfTitle");
this->addSupportedToken("pdfProducer"); this->addSupportedToken("pdfProducer");
this->addSupportedToken("pdfPages"); this->addSupportedToken("pdfPages");
m_help.append( "[pdfAuthor]" + TokenHelpDialog::getTokenSeparator() + i18n(" m_help.append("[pdfAuthor]" + TokenHelpDialog::getTokenSeparator() + i18n("A
Author of the pdf file") ); uthor of the PDF file"));
m_help.append( "[pdfCreator]" + TokenHelpDialog::getTokenSeparator() + i18n( m_help.append("[pdfCreator]" + TokenHelpDialog::getTokenSeparator() + i18n("
"Creator of the pdf file") ); Creator of the PDF file"));
m_help.append( "[pdfKeywords]" + TokenHelpDialog::getTokenSeparator() + i18n m_help.append("[pdfKeywords]" + TokenHelpDialog::getTokenSeparator() + i18n(
("Keywords of the pdf file") ); "Keywords of the PDF file"));
m_help.append( "[pdfSubject]" + TokenHelpDialog::getTokenSeparator() + i18n( m_help.append("[pdfSubject]" + TokenHelpDialog::getTokenSeparator() + i18n("
"Subject of the pdf file") ); Subject of the PDF file"));
m_help.append( "[pdfTitle]" + TokenHelpDialog::getTokenSeparator() + i18n("T m_help.append("[pdfTitle]" + TokenHelpDialog::getTokenSeparator() + i18n("Ti
itle of the pdf file") ); tle of the PDF file"));
m_help.append( "[pdfProducer]" + TokenHelpDialog::getTokenSeparator() + i18n m_help.append("[pdfProducer]" + TokenHelpDialog::getTokenSeparator() + i18n(
("Producer of the pdf file") ); "Producer of the PDF file"));
m_help.append( "[pdfPages]" + TokenHelpDialog::getTokenSeparator() + i18n("N m_help.append("[pdfPages]" + TokenHelpDialog::getTokenSeparator() + i18n("Nu
umber of pages in the pdf file") ); mber of pages in the PDF file"));
m_name = i18n("PoDoFo (PDF) Plugin"); m_name = i18n("PoDoFo (PDF) Plugin");
m_comment = i18n("<qt>This plugin supports reading tags from " m_comment = i18n("<qt>This plugin supports reading tags from "
"PDF files.</qt>"); "PDF files.</qt>");
m_icon = "application-pdf"; m_icon = "application-pdf";
} }
QString PodofoPlugin::processFile( BatchRenamer* b, int index, const QString & f ilenameOrToken, EPluginType ) QString PodofoPlugin::processFile(BatchRenamer *b, int index, const QString &fil enameOrToken, EPluginType)
{ {
QString token( filenameOrToken.toLower() ); QString token(filenameOrToken.toLower());
QString filename = (*b->files())[index].srcUrl().path(); QString filename = (*b->files())[index].srcUrl().path();
if( !this->supports( token ) ) if (!this->supports(token)) {
return QString(""); return QString("");
}
try { try {
PdfMemDocument doc; PdfMemDocument doc;
doc.Load(filename.toUtf8().data()); doc.Load(filename.toUtf8().data());
PdfInfo* info = doc.GetInfo(); PdfInfo *info = doc.GetInfo();
if( token == "pdfauthor" ) if (token == "pdfauthor") {
return QString::fromUtf8(info->GetAuthor().GetStringUtf8().c_str()); return QString::fromUtf8(info->GetAuthor().GetStringUtf8().c_str());
else if( token == "pdfcreator" ) } else if (token == "pdfcreator") {
return QString::fromUtf8(info->GetCreator().GetStringUtf8().c_str()) ; return QString::fromUtf8(info->GetCreator().GetStringUtf8().c_str()) ;
else if( token == "pdfkeywords" ) } else if (token == "pdfkeywords") {
return QString::fromUtf8(info->GetKeywords().GetStringUtf8().c_str() ); return QString::fromUtf8(info->GetKeywords().GetStringUtf8().c_str() );
else if( token == "pdfsubject" ) } else if (token == "pdfsubject") {
return QString::fromUtf8(info->GetSubject().GetStringUtf8().c_str()) ; return QString::fromUtf8(info->GetSubject().GetStringUtf8().c_str()) ;
else if( token == "pdftitle" ) } else if (token == "pdftitle") {
return QString::fromUtf8(info->GetTitle().GetStringUtf8().c_str()); return QString::fromUtf8(info->GetTitle().GetStringUtf8().c_str());
else if( token == "pdfproducer" ) } else if (token == "pdfproducer") {
return QString::fromUtf8(info->GetProducer().GetStringUtf8().c_str() ); return QString::fromUtf8(info->GetProducer().GetStringUtf8().c_str() );
else if( token == "pdfpages" ) } else if (token == "pdfpages") {
return QString::number(doc.GetPageCount()); return QString::number(doc.GetPageCount());
} }
catch( PdfError & error ) } catch (PdfError &error) {
{ return QString::fromUtf8(error.what());
return QString::fromUtf8( error.what() );
} }
return QString(""); return QString("");
} }
#endif // HAVE_PODOFO
 End of changes. 18 change blocks. 
36 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)