[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - include/vcl svx/source vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 29 20:04:53 UTC 2020
include/vcl/filter/PDFiumLibrary.hxx | 2 +
svx/source/inc/svdpdf.hxx | 2 -
svx/source/svdraw/svdpdf.cxx | 55 ++++++++++-------------------------
vcl/source/gdi/pdfwriter_impl.cxx | 3 +
4 files changed, 22 insertions(+), 40 deletions(-)
New commits:
commit 9cc54e9bc1219fcaea87ca35eb93b0e79325a7ac
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Jun 28 09:11:09 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 29 22:04:33 2020 +0200
use PDFium wrapper in ImpSdrPdfImport (partially)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97363
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit 34745b022d0c58e262c7ad3bfd103e769b2cdd18)
Change-Id: If13bcaa6a256354aceb2e1998521644041c03b7b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97448
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx
index 2a70c3f89bce..35826097e45e 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -90,6 +90,8 @@ public:
FPDF_ClosePage(mpPage);
}
+ FPDF_PAGE getPointer() { return mpPage; }
+
int getAnnotationCount();
int getAnnotationIndex(std::unique_ptr<PDFiumAnnotation> const& rAnnotation);
diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index 3765f8a59577..896b84783d30 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -92,7 +92,7 @@ class SVXCORE_DLLPUBLIC ImpSdrPdfImport final
// clipregion
basegfx::B2DPolyPolygon maClip;
- FPDF_DOCUMENT mpPdfDocument;
+ std::unique_ptr<vcl::pdf::PDFiumDocument> mpPdfDocument;
int mnPageCount;
double mdPageWidthPts;
double mdPageHeightPts;
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index f539d56ca355..ca8226b68ce5 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -127,7 +127,6 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools:
, mbNoLine(false)
, mbNoFill(false)
, maClip()
- , mpPdfDocument(nullptr)
, mnPageCount(0)
, mdPageWidthPts(0)
, mdPageHeightPts(0)
@@ -147,65 +146,46 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools:
// Load the buffer using pdfium.
auto const& rVectorGraphicData = mrGraphic.getVectorGraphicData();
- mpPdfDocument = FPDF_LoadMemDocument(
- rVectorGraphicData->getVectorGraphicDataArray().getConstArray(),
- rVectorGraphicData->getVectorGraphicDataArrayLength(), /*password=*/nullptr);
+ auto* pData = rVectorGraphicData->getVectorGraphicDataArray().getConstArray();
+ sal_Int32 nSize = rVectorGraphicData->getVectorGraphicDataArrayLength();
+ mpPdfDocument = mpPDFium->openDocument(pData, nSize);
if (!mpPdfDocument)
- {
- //TODO: Handle failure to load.
- switch (FPDF_GetLastError())
- {
- case FPDF_ERR_SUCCESS:
- break;
- case FPDF_ERR_UNKNOWN:
- break;
- case FPDF_ERR_FILE:
- break;
- case FPDF_ERR_FORMAT:
- break;
- case FPDF_ERR_PASSWORD:
- break;
- case FPDF_ERR_SECURITY:
- break;
- case FPDF_ERR_PAGE:
- break;
- default:
- break;
- }
-
return;
- }
- mnPageCount = FPDF_GetPageCount(mpPdfDocument);
+ mnPageCount = mpPdfDocument->getPageCount();
}
-ImpSdrPdfImport::~ImpSdrPdfImport() { FPDF_CloseDocument(mpPdfDocument); }
+ImpSdrPdfImport::~ImpSdrPdfImport() = default;
void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport,
int nPageIndex)
{
- const int nPageCount = FPDF_GetPageCount(mpPdfDocument);
+ const int nPageCount = mpPdfDocument->getPageCount();
if (nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount)
{
// Render next page.
- FPDF_PAGE pPdfPage = FPDF_LoadPage(mpPdfDocument, nPageIndex);
- if (pPdfPage == nullptr)
+ auto pPdfPage = mpPdfDocument->openPage(nPageIndex);
+ if (!pPdfPage)
return;
- const double dPageWidth = FPDF_GetPageWidth(pPdfPage);
- const double dPageHeight = FPDF_GetPageHeight(pPdfPage);
+ basegfx::B2DSize dPageSize = mpPdfDocument->getPageSize(nPageIndex);
+
+ const double dPageWidth = dPageSize.getX();
+ const double dPageHeight = dPageSize.getY();
+
SetupPageScale(dPageWidth, dPageHeight);
// Load the page text to extract it when we get text elements.
- FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage);
+ FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage->getPointer());
- const int nPageObjectCount = FPDFPage_CountObjects(pPdfPage);
+ const int nPageObjectCount = FPDFPage_CountObjects(pPdfPage->getPointer());
if (pProgrInfo)
pProgrInfo->SetActionCount(nPageObjectCount);
for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; ++nPageObjectIndex)
{
- FPDF_PAGEOBJECT pPageObject = FPDFPage_GetObject(pPdfPage, nPageObjectIndex);
+ FPDF_PAGEOBJECT pPageObject
+ = FPDFPage_GetObject(pPdfPage->getPointer(), nPageObjectIndex);
ImportPdfObject(pPageObject, pTextPage, nPageObjectIndex);
if (pProgrInfo && pActionsToReport)
{
@@ -222,7 +202,6 @@ void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pAction
}
FPDFText_ClosePage(pTextPage);
- FPDF_ClosePage(pPdfPage);
}
}
commit f1cfba09f2aedc20fc7c3e2bc841d74ae2d58325
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri Jun 26 09:18:47 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 29 22:04:21 2020 +0200
pdf: fix text annotation (note) modification date
The modification date wasn't encolsed in brackets, which is
required for the modification date.
Change-Id: Icf91516436b095a8577d3ab10b2a708d10d58cb5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97330
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit 09c01a8d6f5dc072991450d215558555152764a8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97447
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 963967e02ae6..ea3058f5f616 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3632,8 +3632,9 @@ void PDFWriterImpl::emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry c
auto & rDateTime = rNote.m_aContents.maModificationDate;
- aLine.append("/M ");
+ aLine.append("/M (");
appendPdfTimeDate(aLine, rDateTime.Year, rDateTime.Month, rDateTime.Day, rDateTime.Hours, rDateTime.Minutes, rDateTime.Seconds, 0);
+ aLine.append(") ");
// contents of the note (type text string)
aLine.append("/Contents ");
More information about the Libreoffice-commits
mailing list