summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2023-03-24 18:45:53 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2023-03-27 08:40:08 +0000
commit002a6fee2fbd07c3f0cd1f1ddba39c691130727e (patch)
treede778c23d7841b8f6c84db24a399d70dabd3d43e /drawinglayer
parenta41dbf0bd726613204d975fb4fc5e50c23d61410 (diff)
tdf#152234 drawinglayer,svx: PDF/UA export: add Alt text to form controls
Specification: ISO 14289-1:2014, Clause: 7.18.1, Test number: 3 A form field whose hidden flag is not set and whose rectangle is not outside the crop-box shall have a TU key present or all its Widget annotations shall have alternative descriptions (in the form of an Alt entry in the enclosing structure elements) Form controls are weird because they have an SdrObject with the usual name/title/description plus a property "HelpText" on the control itself which is already exported as "/TU" on the /Annot unless it's empty. Exporting the SdrObject properties via ObjectInfoPrimitive2D doesn't work as tragically that is only created for form controls when painting to the screen while PDF export takes a detour that needs special handling. Change-Id: Id96f7dd13f190ab439c099cd1f4acb70c1c9fdc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149554 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/controlprimitive2d.cxx20
-rw-r--r--drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx7
2 files changed, 16 insertions, 11 deletions
diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx
index 6fe6e57c10d1..372fb61244a0 100644
--- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <drawinglayer/geometry/viewinformation2d.hxx>
#include <utility>
+#include <rtl/ustrbuf.hxx>
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
#include <com/sun/star/awt/PosSize.hpp>
@@ -239,20 +240,21 @@ namespace drawinglayer::primitive2d
ControlPrimitive2D::ControlPrimitive2D(
basegfx::B2DHomMatrix aTransform,
- uno::Reference< awt::XControlModel > xControlModel)
- : maTransform(std::move(aTransform)),
- mxControlModel(std::move(xControlModel))
- {
- }
-
- ControlPrimitive2D::ControlPrimitive2D(
- basegfx::B2DHomMatrix aTransform,
uno::Reference< awt::XControlModel > xControlModel,
- uno::Reference< awt::XControl > xXControl)
+ uno::Reference<awt::XControl> xXControl,
+ ::std::u16string_view const rTitle,
+ ::std::u16string_view const rDescription)
: maTransform(std::move(aTransform)),
mxControlModel(std::move(xControlModel)),
mxXControl(std::move(xXControl))
{
+ ::rtl::OUStringBuffer buf(rTitle);
+ if (!rTitle.empty() && !rDescription.empty())
+ {
+ buf.append(" - ");
+ }
+ buf.append(rDescription);
+ m_AltText = buf.makeStringAndClear();
}
const uno::Reference< awt::XControl >& ControlPrimitive2D::getXControl() const
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index d82465ceb313..56675ff113ef 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -1137,8 +1137,6 @@ void VclMetafileProcessor2D::processControlPrimitive2D(
if (bPDFExport)
{
// PDF export. Emulate data handling from UnoControlPDFExportContact
- // I have now moved describePDFControl to toolkit, thus i can implement the PDF
- // form control support now as follows
std::unique_ptr<vcl::PDFWriter::AnyWidget> pPDFControl(
::toolkitform::describePDFControl(rXControl, *mpPDFExtOutDevData));
@@ -1159,6 +1157,11 @@ void VclMetafileProcessor2D::processControlPrimitive2D(
pPDFControl->TextFont.SetFontSize(aFontSize);
mpPDFExtOutDevData->BeginStructureElement(vcl::PDFWriter::Form);
+ OUString const& rAltText(rControlPrimitive.GetAltText());
+ if (!rAltText.isEmpty())
+ {
+ mpPDFExtOutDevData->SetAlternateText(rAltText);
+ }
mpPDFExtOutDevData->CreateControl(*pPDFControl);
mpPDFExtOutDevData->EndStructureElement();