[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl svx/source vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 29 21:39:04 UTC 2020
include/vcl/filter/PDFiumLibrary.hxx | 6 ++++++
svx/source/inc/svdpdf.hxx | 7 +++++--
svx/source/svdraw/svdpdf.cxx | 29 +++++++++++++++--------------
vcl/source/pdf/PDFiumLibrary.cxx | 24 ++++++++++++++++++++++++
4 files changed, 50 insertions(+), 16 deletions(-)
New commits:
commit f5124552d87e84b5b6d6707c30b5f8a5defed69e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Jun 28 12:34:19 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 29 23:38:31 2020 +0200
pdf: support PDF Form object and getMatrix
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97365
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit b5b8da80439419a2daa6a80c9d3979173fe2887a)
Change-Id: I61f2004df7f9c9ac37959e0b50ea1ff83387c77a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97450
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 501f964f395d..9f34bdb92ad6 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -20,6 +20,7 @@
#include <rtl/instance.hxx>
#include <basegfx/vector/b2dsize.hxx>
#include <basegfx/range/b2drectangle.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
#include <rtl/ustring.hxx>
#include <fpdf_doc.h>
@@ -87,6 +88,11 @@ public:
int getType();
OUString getText(std::unique_ptr<PDFiumTextPage> const& pTextPage);
+
+ int getFormObjectCount();
+ std::unique_ptr<PDFiumPageObject> getFormObject(int nIndex);
+
+ basegfx::B2DHomMatrix getMatrix();
};
class VCL_DLLPUBLIC PDFiumTextPage final
diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index 896b84783d30..49c8d3e1b3c2 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -112,9 +112,12 @@ class SVXCORE_DLLPUBLIC ImpSdrPdfImport final
void checkClip();
bool isClip() const;
- void ImportPdfObject(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
+ void ImportPdfObject(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
+ std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
int nPageObjectIndex);
- void ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage, int nPageObjectIndex);
+ void ImportForm(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
+ std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
+ int nPageObjectIndex);
void ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex);
void ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex);
void ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage, int nPageObjectIndex);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 50e94a6f983b..066c77f0798f 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -185,7 +185,7 @@ void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pAction
for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; ++nPageObjectIndex)
{
auto pPageObject = pPdfPage->getObject(nPageObjectIndex);
- ImportPdfObject(pPageObject->getPointer(), pTextPage->getPointer(), nPageObjectIndex);
+ ImportPdfObject(pPageObject, pTextPage, nPageObjectIndex);
if (pProgrInfo && pActionsToReport)
{
(*pActionsToReport)++;
@@ -683,23 +683,24 @@ void ImpSdrPdfImport::checkClip()
}
bool ImpSdrPdfImport::isClip() const { return !maClip.getB2DRange().isEmpty(); }
-void ImpSdrPdfImport::ImportPdfObject(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
- int nPageObjectIndex)
+void ImpSdrPdfImport::ImportPdfObject(
+ std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
+ std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage, int nPageObjectIndex)
{
- if (pPageObject == nullptr)
+ if (!pPageObject)
return;
- const int nPageObjectType = FPDFPageObj_GetType(pPageObject);
+ const int nPageObjectType = pPageObject->getType();
switch (nPageObjectType)
{
case FPDF_PAGEOBJ_TEXT:
- ImportText(pPageObject, pTextPage, nPageObjectIndex);
+ ImportText(pPageObject->getPointer(), pTextPage->getPointer(), nPageObjectIndex);
break;
case FPDF_PAGEOBJ_PATH:
- ImportPath(pPageObject, nPageObjectIndex);
+ ImportPath(pPageObject->getPointer(), nPageObjectIndex);
break;
case FPDF_PAGEOBJ_IMAGE:
- ImportImage(pPageObject, nPageObjectIndex);
+ ImportImage(pPageObject->getPointer(), nPageObjectIndex);
break;
case FPDF_PAGEOBJ_SHADING:
SAL_WARN("sd.filter", "Got page object SHADING: " << nPageObjectIndex);
@@ -714,20 +715,20 @@ void ImpSdrPdfImport::ImportPdfObject(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE
}
}
-void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
+void ImpSdrPdfImport::ImportForm(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
+ std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
int /*nPageObjectIndex*/)
{
// Get the form matrix to perform correct translation/scaling of the form sub-objects.
const basegfx::B2DHomMatrix aOldMatrix = maCurrentMatrix;
- double a, b, c, d, e, f;
- FPDFTextObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
- maCurrentMatrix = basegfx::B2DHomMatrix::abcdef(a, b, c, d, e, f);
+ maCurrentMatrix = pPageObject->getMatrix();
- const int nCount = FPDFFormObj_CountObjects(pPageObject);
+ const int nCount = pPageObject->getFormObjectCount();
for (int nIndex = 0; nIndex < nCount; ++nIndex)
{
- FPDF_PAGEOBJECT pFormObject = FPDFFormObj_GetObject(pPageObject, nIndex);
+ auto pFormObject = pPageObject->getFormObject(nIndex);
+
ImportPdfObject(pFormObject, pTextPage, -1);
}
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index af13f8ec8fbe..7e30ba47b0bc 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -235,6 +235,30 @@ OUString PDFiumPageObject::getText(std::unique_ptr<PDFiumTextPage> const& pTextP
int PDFiumPageObject::getType() { return FPDFPageObj_GetType(mpPageObject); }
+int PDFiumPageObject::getFormObjectCount()
+{
+ return FPDFFormObj_CountObjects(mpPageObject);
+ ;
+}
+
+std::unique_ptr<PDFiumPageObject> PDFiumPageObject::getFormObject(int nIndex)
+{
+ std::unique_ptr<PDFiumPageObject> pPDFiumFormObject;
+ FPDF_PAGEOBJECT pFormObject = FPDFFormObj_GetObject(mpPageObject, nIndex);
+ if (pFormObject)
+ {
+ pPDFiumFormObject = std::make_unique<PDFiumPageObject>(pFormObject);
+ }
+ return pPDFiumFormObject;
+}
+
+basegfx::B2DHomMatrix PDFiumPageObject::getMatrix()
+{
+ double a, b, c, d, e, f;
+ FPDFTextObj_GetMatrix(mpPageObject, &a, &b, &c, &d, &e, &f);
+ return basegfx::B2DHomMatrix::abcdef(a, b, c, d, e, f);
+}
+
PDFiumAnnotation::PDFiumAnnotation(FPDF_ANNOTATION pAnnotation)
: mpAnnotation(pAnnotation)
{
More information about the Libreoffice-commits
mailing list