summaryrefslogtreecommitdiff
path: root/vcl/source/pdf
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-09-20 08:30:53 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-09-20 09:22:28 +0200
commitaddfb3cce0f7ce8fbd0b169d467b6956ed95dbb5 (patch)
tree44ad218bf4ee32be4b77003c0deea853ad60e41e /vcl/source/pdf
parent6754b647c145cded1f54b49d53d37ad35ace211c (diff)
sw content controls: add a11y description for PDF export
Acrobat Reader shows these descriptions on mouse hovering on a form widget. Change-Id: I8614222e46c992baca8a57b13a948f88973e8911 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140215 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'vcl/source/pdf')
-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 bb371ca930dc..e64aa2f5e3e5 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -251,6 +251,7 @@ public:
std::vector<basegfx::B2DPoint> getLineGeometry() override;
PDFFormFieldType getFormFieldType(PDFiumDocument* pDoc) override;
float getFormFontSize(PDFiumDocument* pDoc) override;
+ OUString getFormFieldAlternateName(PDFiumDocument* pDoc) override;
};
class PDFiumPageObjectImpl final : public PDFiumPageObject
@@ -1148,6 +1149,36 @@ float PDFiumAnnotationImpl::getFormFontSize(PDFiumDocument* pDoc)
return fRet;
}
+OUString PDFiumAnnotationImpl::getFormFieldAlternateName(PDFiumDocument* pDoc)
+{
+ auto pDocImpl = static_cast<PDFiumDocumentImpl*>(pDoc);
+ OUString aString;
+ unsigned long nSize = FPDFAnnot_GetFormFieldAlternateName(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_GetFormFieldAlternateName(
+ 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,