pdfium: replace PDFiumSignature::getPointer() with typed getters
Once reason and time has getters, no need to expose the underlying PDFium type. Change-Id: I8f6b152fddf38e76ad7c3b1897fcb2026129820f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106631 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
parent
586bd08fa2
commit
7ca0f29249
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <config_features.h>
|
#include <config_features.h>
|
||||||
|
|
||||||
|
#include <com/sun/star/util/DateTime.hpp>
|
||||||
|
|
||||||
#if HAVE_FEATURE_PDFIUM
|
#if HAVE_FEATURE_PDFIUM
|
||||||
|
|
||||||
#include <vcl/dllapi.h>
|
#include <vcl/dllapi.h>
|
||||||
@ -241,11 +243,12 @@ private:
|
|||||||
public:
|
public:
|
||||||
PDFiumSignature(FPDF_SIGNATURE pSignature);
|
PDFiumSignature(FPDF_SIGNATURE pSignature);
|
||||||
|
|
||||||
FPDF_SIGNATURE getPointer() { return mpSignature; }
|
|
||||||
std::vector<int> getByteRange();
|
std::vector<int> getByteRange();
|
||||||
int getDocMDPPermission();
|
int getDocMDPPermission();
|
||||||
std::vector<unsigned char> getContents();
|
std::vector<unsigned char> getContents();
|
||||||
OString getSubFilter();
|
OString getSubFilter();
|
||||||
|
OUString getReason();
|
||||||
|
css::util::DateTime getTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
class VCL_DLLPUBLIC PDFiumDocument final
|
class VCL_DLLPUBLIC PDFiumDocument final
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <bitmapwriteaccess.hxx>
|
#include <bitmapwriteaccess.hxx>
|
||||||
|
|
||||||
|
using namespace com::sun::star;
|
||||||
|
|
||||||
static_assert(static_cast<int>(vcl::pdf::PDFPageObjectType::Unknown) == FPDF_PAGEOBJ_UNKNOWN,
|
static_assert(static_cast<int>(vcl::pdf::PDFPageObjectType::Unknown) == FPDF_PAGEOBJ_UNKNOWN,
|
||||||
"PDFPageObjectType::Unknown value mismatch");
|
"PDFPageObjectType::Unknown value mismatch");
|
||||||
static_assert(static_cast<int>(vcl::pdf::PDFPageObjectType::Text) == FPDF_PAGEOBJ_TEXT,
|
static_assert(static_cast<int>(vcl::pdf::PDFPageObjectType::Text) == FPDF_PAGEOBJ_TEXT,
|
||||||
@ -237,6 +239,45 @@ OString PDFiumSignature::getSubFilter()
|
|||||||
return aSubFilter;
|
return aSubFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OUString PDFiumSignature::getReason()
|
||||||
|
{
|
||||||
|
int nReasonLen = FPDFSignatureObj_GetReason(mpSignature, nullptr, 0);
|
||||||
|
OUString aRet;
|
||||||
|
if (nReasonLen > 0)
|
||||||
|
{
|
||||||
|
std::vector<char16_t> aReasonBuf(nReasonLen);
|
||||||
|
FPDFSignatureObj_GetReason(mpSignature, aReasonBuf.data(), aReasonBuf.size());
|
||||||
|
aRet = OUString(aReasonBuf.data(), aReasonBuf.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
util::DateTime PDFiumSignature::getTime()
|
||||||
|
{
|
||||||
|
util::DateTime aRet;
|
||||||
|
int nTimeLen = FPDFSignatureObj_GetTime(mpSignature, nullptr, 0);
|
||||||
|
if (nTimeLen <= 0)
|
||||||
|
{
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example: "D:20161027100104".
|
||||||
|
std::vector<char> aTimeBuf(nTimeLen);
|
||||||
|
FPDFSignatureObj_GetTime(mpSignature, aTimeBuf.data(), aTimeBuf.size());
|
||||||
|
OString aM(aTimeBuf.data(), aTimeBuf.size() - 1);
|
||||||
|
if (aM.startsWith("D:") && aM.getLength() >= 16)
|
||||||
|
{
|
||||||
|
aRet.Year = aM.copy(2, 4).toInt32();
|
||||||
|
aRet.Month = aM.copy(6, 2).toInt32();
|
||||||
|
aRet.Day = aM.copy(8, 2).toInt32();
|
||||||
|
aRet.Hours = aM.copy(10, 2).toInt32();
|
||||||
|
aRet.Minutes = aM.copy(12, 2).toInt32();
|
||||||
|
aRet.Seconds = aM.copy(14, 2).toInt32();
|
||||||
|
}
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
PDFiumDocument::PDFiumDocument(FPDF_DOCUMENT pPdfDocument)
|
PDFiumDocument::PDFiumDocument(FPDF_DOCUMENT pPdfDocument)
|
||||||
: mpPdfDocument(pPdfDocument)
|
: mpPdfDocument(pPdfDocument)
|
||||||
{
|
{
|
||||||
|
@ -366,35 +366,11 @@ bool ValidateSignature(SvStream& rStream, const Signature& rSignature,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reason / comment / description is optional.
|
// Reason / comment / description is optional.
|
||||||
int nReasonLen = FPDFSignatureObj_GetReason(rSignature.m_pSignature->getPointer(), nullptr, 0);
|
rInformation.ouDescription = rSignature.m_pSignature->getReason();
|
||||||
if (nReasonLen > 0)
|
|
||||||
{
|
|
||||||
std::vector<char16_t> aReasonBuf(nReasonLen);
|
|
||||||
FPDFSignatureObj_GetReason(rSignature.m_pSignature->getPointer(), aReasonBuf.data(),
|
|
||||||
aReasonBuf.size());
|
|
||||||
rInformation.ouDescription = OUString(aReasonBuf.data(), aReasonBuf.size() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Date: used only when the time of signing is not available in the
|
// Date: used only when the time of signing is not available in the
|
||||||
// signature.
|
// signature.
|
||||||
int nTimeLen = FPDFSignatureObj_GetTime(rSignature.m_pSignature->getPointer(), nullptr, 0);
|
rInformation.stDateTime = rSignature.m_pSignature->getTime();
|
||||||
if (nTimeLen > 0)
|
|
||||||
{
|
|
||||||
// Example: "D:20161027100104".
|
|
||||||
std::vector<char> aTimeBuf(nTimeLen);
|
|
||||||
FPDFSignatureObj_GetTime(rSignature.m_pSignature->getPointer(), aTimeBuf.data(),
|
|
||||||
aTimeBuf.size());
|
|
||||||
OString aM(aTimeBuf.data(), aTimeBuf.size() - 1);
|
|
||||||
if (aM.startsWith("D:") && aM.getLength() >= 16)
|
|
||||||
{
|
|
||||||
rInformation.stDateTime.Year = aM.copy(2, 4).toInt32();
|
|
||||||
rInformation.stDateTime.Month = aM.copy(6, 2).toInt32();
|
|
||||||
rInformation.stDateTime.Day = aM.copy(8, 2).toInt32();
|
|
||||||
rInformation.stDateTime.Hours = aM.copy(10, 2).toInt32();
|
|
||||||
rInformation.stDateTime.Minutes = aM.copy(12, 2).toInt32();
|
|
||||||
rInformation.stDateTime.Seconds = aM.copy(14, 2).toInt32();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect if the byte ranges don't cover everything, but the signature itself.
|
// Detect if the byte ranges don't cover everything, but the signature itself.
|
||||||
if (rSignature.m_aByteRanges.size() < 2)
|
if (rSignature.m_aByteRanges.size() < 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user