diff options
-rw-r--r-- | external/pdfium/UnpackedTarball_pdfium.mk | 1 | ||||
-rw-r--r-- | external/pdfium/annot.patch.1 | 45 | ||||
-rw-r--r-- | include/vcl/filter/PDFiumLibrary.hxx | 4 | ||||
-rw-r--r-- | sw/qa/core/text/text.cxx | 3 | ||||
-rw-r--r-- | vcl/source/pdf/PDFiumLibrary.cxx | 14 |
5 files changed, 16 insertions, 51 deletions
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk index 4c9f483f8ed7..7dde5d674e6f 100644 --- a/external/pdfium/UnpackedTarball_pdfium.mk +++ b/external/pdfium/UnpackedTarball_pdfium.mk @@ -28,7 +28,6 @@ pdfium_patches += include.patch pdfium_patches += abseil-trivial.patch -pdfium_patches += annot.patch.1 pdfium_patches += annot-alternate-name.patch.1 $(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium)) diff --git a/external/pdfium/annot.patch.1 b/external/pdfium/annot.patch.1 deleted file mode 100644 index 542cb9766ff7..000000000000 --- a/external/pdfium/annot.patch.1 +++ /dev/null @@ -1,45 +0,0 @@ -diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp -index 349348583..54e139645 100644 ---- a/fpdfsdk/fpdf_annot.cpp -+++ b/fpdfsdk/fpdf_annot.cpp -@@ -1223,6 +1223,26 @@ FPDFAnnot_GetFormFieldType(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot) { - return pFormField ? static_cast<int>(pFormField->GetFieldType()) : -1; - } - -+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV -+FPDFAnnot_GetFormFontSize(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, float* value) { -+ const CPDF_FormField* pFormField = GetFormField(hHandle, annot); -+ if (!pFormField) { -+ return false; -+ } -+ -+ if (!value) { -+ return false; -+ } -+ -+ ByteString DA; -+ if (const CPDF_Object* pObj = pFormField->GetFieldAttr(pFormField->GetDict(), "DA")) -+ DA = pObj->GetString(); -+ -+ CPDF_DefaultAppearance appearance(DA); -+ appearance.GetFont(value); -+ return true; -+} -+ - FPDF_EXPORT unsigned long FPDF_CALLCONV - FPDFAnnot_GetFormFieldValue(FPDF_FORMHANDLE hHandle, - FPDF_ANNOTATION annot, -diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h -index ccfbb0f1c..3c96b99a0 100644 ---- a/public/fpdf_annot.h -+++ b/public/fpdf_annot.h -@@ -699,6 +699,9 @@ FPDFAnnot_GetFormFieldName(FPDF_FORMHANDLE hHandle, - FPDF_EXPORT int FPDF_CALLCONV - FPDFAnnot_GetFormFieldType(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot); - -+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV -+FPDFAnnot_GetFormFontSize(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, float* value); -+ - // Experimental API. - // Gets the value of |annot|, which is an interactive form annotation. - // |buffer| is only modified if |buflen| is longer than the length of contents. diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx index 1541fcb689e4..f0a642847cc6 100644 --- a/include/vcl/filter/PDFiumLibrary.hxx +++ b/include/vcl/filter/PDFiumLibrary.hxx @@ -102,7 +102,7 @@ public: virtual std::vector<basegfx::B2DPoint> getAttachmentPoints(size_t nIndex) = 0; virtual std::vector<basegfx::B2DPoint> getLineGeometry() = 0; virtual PDFFormFieldType getFormFieldType(PDFiumDocument* pDoc) = 0; - virtual float getFormFontSize(PDFiumDocument* pDoc) = 0; + virtual float getFontSize(PDFiumDocument* pDoc) = 0; virtual OUString getFormFieldAlternateName(PDFiumDocument* pDoc) = 0; virtual int getFormFieldFlags(PDFiumDocument* pDoc) = 0; }; @@ -194,6 +194,8 @@ public: virtual bool hasTransparency() = 0; virtual bool hasLinks() = 0; + + virtual void onAfterLoadPage(PDFiumDocument* pDoc) = 0; }; /// Represents one digital signature, as exposed by PDFium. diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx index 0084ac52bae2..c776dd20609e 100644 --- a/sw/qa/core/text/text.cxx +++ b/sw/qa/core/text/text.cxx @@ -742,13 +742,14 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDFFont) // Then make sure that the widget in the PDF result has that custom font size: std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = LoadPdfFromTempFile(); std::unique_ptr<vcl::pdf::PDFiumPage> pPage = pPdfDocument->openPage(0); + pPage->onAfterLoadPage(pPdfDocument.get()); CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationCount()); std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnotation = pPage->getAnnotation(0); // Without the accompanying fix in place, this test would have failed with: // - Expected: 24 // - Actual : 8 // i.e. i.e. the font size was some default, not the 24pt specified in the model. - CPPUNIT_ASSERT_EQUAL(24.0f, pAnnotation->getFormFontSize(pPdfDocument.get())); + CPPUNIT_ASSERT_EQUAL(24.0f, pAnnotation->getFontSize(pPdfDocument.get())); } CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testComboContentControlPDF) diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index 68bae2d78d80..3e247b7772eb 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -250,7 +250,7 @@ public: std::vector<basegfx::B2DPoint> getAttachmentPoints(size_t nIndex) override; std::vector<basegfx::B2DPoint> getLineGeometry() override; PDFFormFieldType getFormFieldType(PDFiumDocument* pDoc) override; - float getFormFontSize(PDFiumDocument* pDoc) override; + float getFontSize(PDFiumDocument* pDoc) override; OUString getFormFieldAlternateName(PDFiumDocument* pDoc) override; int getFormFieldFlags(PDFiumDocument* pDoc) override; }; @@ -388,6 +388,8 @@ public: bool hasTransparency() override; bool hasLinks() override; + + void onAfterLoadPage(PDFiumDocument* pDoc) override; }; /// Wrapper around FPDF_FORMHANDLE. @@ -756,6 +758,12 @@ bool PDFiumPageImpl::hasLinks() return FPDFLink_Enumerate(mpPage, &nStartPos, &pLinkAnnot); } +void PDFiumPageImpl::onAfterLoadPage(PDFiumDocument* pDoc) +{ + auto pDocImpl = static_cast<PDFiumDocumentImpl*>(pDoc); + FORM_OnAfterLoadPage(mpPage, pDocImpl->getFormHandlePointer()); +} + PDFiumPageObjectImpl::PDFiumPageObjectImpl(FPDF_PAGEOBJECT pPageObject) : mpPageObject(pPageObject) { @@ -1144,11 +1152,11 @@ int PDFiumAnnotationImpl::getFormFieldFlags(PDFiumDocument* pDoc) return FPDFAnnot_GetFormFieldFlags(pDocImpl->getFormHandlePointer(), mpAnnotation); } -float PDFiumAnnotationImpl::getFormFontSize(PDFiumDocument* pDoc) +float PDFiumAnnotationImpl::getFontSize(PDFiumDocument* pDoc) { auto pDocImpl = static_cast<PDFiumDocumentImpl*>(pDoc); float fRet{}; - if (!FPDFAnnot_GetFormFontSize(pDocImpl->getFormHandlePointer(), mpAnnotation, &fRet)) + if (!FPDFAnnot_GetFontSize(pDocImpl->getFormHandlePointer(), mpAnnotation, &fRet)) { return 0.0f; } |