diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-06-28 12:34:19 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-29 14:35:56 +0200 |
commit | b5b8da80439419a2daa6a80c9d3979173fe2887a (patch) | |
tree | 70c16aa6bc6682d289d03400b131d67e7973062d /svx | |
parent | 440cb3fb80d9fd356871eac410b9797f23433722 (diff) |
pdf: support PDF Form object and getMatrix
Change-Id: I61f2004df7f9c9ac37959e0b50ea1ff83387c77a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97365
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/inc/svdpdf.hxx | 7 | ||||
-rw-r--r-- | svx/source/svdraw/svdpdf.cxx | 30 |
2 files changed, 20 insertions, 17 deletions
diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx index 71e66ff3deac..0bfdb2b3e6ef 100644 --- a/svx/source/inc/svdpdf.hxx +++ b/svx/source/inc/svdpdf.hxx @@ -107,9 +107,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 9fa8c82f722b..79693be693e1 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -169,7 +169,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)++; @@ -666,23 +666,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); @@ -697,21 +698,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; - FS_MATRIX matrix; - FPDFFormObj_GetMatrix(pPageObject, &matrix); - maCurrentMatrix - = basegfx::B2DHomMatrix::abcdef(matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.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); } |