File Support-podofo-0.10.patch of Package krename4
From a3397954e4a8888d90557fcaea65af1eae56c26e Mon Sep 17 00:00:00 2001
From: Antonio Rojas <arojas@archlinux.org>
Date: Mon, 17 Jul 2023 20:29:37 +0000
Subject: [PATCH] Support podofo 0.10
Version 0.10 of podofo is a complete rewrite. krename's use of it is minimal, so porting is easy.
Switch the cmake module to use pkgconfig, which is available since 0.9.5 (release in 2017).
Unfortunately, the hack to find the version number is still needed, since the pc file is buggy and ships an empty "Version" field.
---
cmake/modules/FindPoDoFo.cmake | 31 +++++++++++++++----------------
src/podofoplugin.cpp | 20 ++++++++++++++++++++
2 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/src/podofoplugin.cpp b/src/podofoplugin.cpp
index 9bcce21..79fd735 100644
--- a/src/podofoplugin.cpp
+++ b/src/podofoplugin.cpp
@@ -66,6 +66,25 @@ QString PodofoPlugin::processFile(BatchRenamer *b, int index, const QString &fil
try {
PdfMemDocument doc;
doc.Load(filename.toUtf8().data());
+#if 1
+ const PdfInfo *info = doc.GetInfo();
+
+ if (token == "pdfauthor") {
+ return info->GetAuthor().has_value() ? QString::fromUtf8(info->GetAuthor()->GetString().c_str()) : QString();
+ } else if (token == "pdfcreator") {
+ return info->GetCreator().has_value() ? QString::fromUtf8(info->GetCreator()->GetString().c_str()) : QString();
+ } else if (token == "pdfkeywords") {
+ return info->GetKeywords().has_value() ? QString::fromUtf8(info->GetKeywords()->GetString().c_str()) : QString();
+ } else if (token == "pdfsubject") {
+ return info->GetSubject().has_value() ? QString::fromUtf8(info->GetSubject()->GetString().c_str()) : QString();
+ } else if (token == "pdftitle") {
+ return info->GetTitle().has_value() ? QString::fromUtf8(info->GetTitle()->GetString().c_str()) : QString();
+ } else if (token == "pdfproducer") {
+ return info->GetProducer().has_value() ? QString::fromUtf8(info->GetProducer()->GetString().c_str()) : QString();
+ } else if (token == "pdfpages") {
+ return QString::number(doc.GetPages().GetCount());
+ }
+#else
PdfInfo* info = doc.GetInfo();
if( token == "pdfauthor" )
@@ -82,6 +101,7 @@ QString PodofoPlugin::processFile(BatchRenamer *b, int index, const QString &fil
return QString::fromUtf8(info->GetProducer().GetStringUtf8().c_str());
else if( token == "pdfpages" )
return QString::number(doc.GetPageCount());
+#endif
}
catch( PdfError & error )
{
--
2.41.0