summaryrefslogtreecommitdiff
path: root/vcl/source/pdf/PDFiumLibrary.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/pdf/PDFiumLibrary.cxx')
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index c6781bca2f26..5db5805b2250 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -253,6 +253,7 @@ public:
float getFontSize(PDFiumDocument* pDoc) override;
OUString getFormFieldAlternateName(PDFiumDocument* pDoc) override;
int getFormFieldFlags(PDFiumDocument* pDoc) override;
+ OUString getFormFieldValue(PDFiumDocument* pDoc) override;
};
class PDFiumPageObjectImpl final : public PDFiumPageObject
@@ -1230,6 +1231,36 @@ OUString PDFiumAnnotationImpl::getFormFieldAlternateName(PDFiumDocument* pDoc)
return aString;
}
+OUString PDFiumAnnotationImpl::getFormFieldValue(PDFiumDocument* pDoc)
+{
+ auto pDocImpl = static_cast<PDFiumDocumentImpl*>(pDoc);
+ OUString aString;
+ unsigned long nSize
+ = FPDFAnnot_GetFormFieldValue(pDocImpl->getFormHandlePointer(), mpAnnotation, nullptr, 0);
+ assert(nSize % 2 == 0);
+ nSize /= 2;
+ if (nSize > 1)
+ {
+ std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nSize]);
+ unsigned long nStringSize
+ = FPDFAnnot_GetFormFieldValue(pDocImpl->getFormHandlePointer(), mpAnnotation,
+ reinterpret_cast<FPDF_WCHAR*>(pText.get()), nSize * 2);
+ assert(nStringSize % 2 == 0);
+ nStringSize /= 2;
+ if (nStringSize > 0)
+ {
+#if defined OSL_BIGENDIAN
+ for (unsigned long i = 0; i != nStringSize; ++i)
+ {
+ pText[i] = OSL_SWAPWORD(pText[i]);
+ }
+#endif
+ aString = OUString(pText.get());
+ }
+ }
+ return aString;
+}
+
namespace
{
bool getBorderProperties(FPDF_ANNOTATION mpAnnotation, float& rHorizontalCornerRadius,