summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--external/pdfium/UnpackedTarball_pdfium.mk2
-rw-r--r--external/pdfium/annot.patch.145
-rw-r--r--include/vcl/filter/PDFiumLibrary.hxx1
-rw-r--r--sw/qa/core/text/text.cxx27
-rw-r--r--sw/source/core/text/itrform2.cxx6
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx13
6 files changed, 94 insertions, 0 deletions
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk
index c1791ed8e823..272fa5cb606f 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -28,6 +28,8 @@ pdfium_patches += include.patch
pdfium_patches += abseil-trivial.patch
+pdfium_patches += annot.patch.1
+
$(eval $(call gb_UnpackedTarball_UnpackedTarball,pdfium))
$(eval $(call gb_UnpackedTarball_set_tarball,pdfium,$(PDFIUM_TARBALL)))
diff --git a/external/pdfium/annot.patch.1 b/external/pdfium/annot.patch.1
new file mode 100644
index 000000000000..542cb9766ff7
--- /dev/null
+++ b/external/pdfium/annot.patch.1
@@ -0,0 +1,45 @@
+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 8274ded92e1f..390c826cd57b 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -102,6 +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;
};
class PDFiumTextPage;
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 106a28e096e9..12dc50884f23 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -18,6 +18,7 @@
#include <vcl/filter/PDFiumLibrary.hxx>
#include <comphelper/propertyvalue.hxx>
#include <unotools/mediadescriptor.hxx>
+#include <editeng/fhgtitem.hxx>
#include <docsh.hxx>
#include <unotxdoc.hxx>
@@ -711,6 +712,32 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testDateContentControlPDF)
pAnnotation->getFormFieldType(pPdfDocument.get()));
}
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testContentControlPDFFont)
+{
+ // Given a document with a custom 24pt font size and a content control:
+ SwDoc* pDoc = createSwDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SfxItemSetFixed<RES_CHRATR_FONTSIZE, RES_CHRATR_FONTSIZE> aSet(pWrtShell->GetAttrPool());
+ SvxFontHeightItem aItem(480, 100, RES_CHRATR_FONTSIZE);
+ aSet.Put(aItem);
+ pWrtShell->SetAttrSet(aSet);
+ pWrtShell->InsertContentControl(SwContentControlType::RICH_TEXT);
+
+ // When exporting that document to PDF:
+ StoreToTempFile("writer_pdf_Export");
+
+ // 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);
+ 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_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index c0eed565b8cf..74057e743cf6 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -978,6 +978,12 @@ bool SwContentControlPortion::DescribePDFControl(const SwTextPaintInfo& rInf) co
return false;
}
+ const SwFont* pFont = rInf.GetFont();
+ if (pFont)
+ {
+ pDescriptor->TextFont = pFont->GetActualFont();
+ }
+
SwRect aLocation;
rInf.CalcRect(*this, &aLocation);
pDescriptor->Location = aLocation.SVRect();
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 5e4588f6bf17..bb371ca930dc 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -250,6 +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;
};
class PDFiumPageObjectImpl final : public PDFiumPageObject
@@ -1135,6 +1136,18 @@ PDFFormFieldType PDFiumAnnotationImpl::getFormFieldType(PDFiumDocument* pDoc)
FPDFAnnot_GetFormFieldType(pDocImpl->getFormHandlePointer(), mpAnnotation));
}
+float PDFiumAnnotationImpl::getFormFontSize(PDFiumDocument* pDoc)
+{
+ auto pDocImpl = static_cast<PDFiumDocumentImpl*>(pDoc);
+ float fRet{};
+ if (!FPDFAnnot_GetFormFontSize(pDocImpl->getFormHandlePointer(), mpAnnotation, &fRet))
+ {
+ return 0.0f;
+ }
+
+ return fRet;
+}
+
namespace
{
bool getBorderProperties(FPDF_ANNOTATION mpAnnotation, float& rHorizontalCornerRadius,