From d5c19ef9d30cde052e8cd2486ac9395e62d9c9a9 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 11 Oct 2023 19:13:53 +0200 Subject: drawinglayer,svx: PDF/UA export: put Form SE into anchor paragraph SE This is like commit d467f1aa3d028f399826c97e2eecedcd79efcf65 and commit 6e5d59c2ca6969e9491f97cd7a00d094fc62cfb3 but for the form controls, which have their own special ControlPrimitive2D. Change-Id: I4b4ac45e81f490a7b625acd9e8753300d10bf119 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157847 Tested-by: Jenkins Reviewed-by: Michael Stahl --- .../source/primitive2d/controlprimitive2d.cxx | 4 +++- .../source/processor2d/vclmetafileprocessor2d.cxx | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'drawinglayer') diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx index 372fb61244a0..c8448efa981f 100644 --- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx @@ -243,10 +243,12 @@ namespace drawinglayer::primitive2d uno::Reference< awt::XControlModel > xControlModel, uno::Reference xXControl, ::std::u16string_view const rTitle, - ::std::u16string_view const rDescription) + ::std::u16string_view const rDescription, + void const*const pAnchorKey) : maTransform(std::move(aTransform)), mxControlModel(std::move(xControlModel)), mxXControl(std::move(xXControl)) + , m_pAnchorStructureElementKey(pAnchorKey) { ::rtl::OUStringBuffer buf(rTitle); if (!rTitle.empty() && !rDescription.empty()) diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index d87c70c7e772..084cc0bef17e 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -1102,6 +1102,18 @@ void VclMetafileProcessor2D::processControlPrimitive2D( if (!bIsPrintableControl) return; + ::std::optional oAnchorParent; + if (mpPDFExtOutDevData) + { + if (rControlPrimitive.GetAnchorStructureElementKey()) + { + sal_Int32 const id = mpPDFExtOutDevData->EnsureStructureElement( + rControlPrimitive.GetAnchorStructureElementKey()); + oAnchorParent.emplace(mpPDFExtOutDevData->GetCurrentStructureElement()); + mpPDFExtOutDevData->SetCurrentStructureElement(id); + } + } + const bool bPDFExport(mpPDFExtOutDevData && mpPDFExtOutDevData->GetIsExportFormFields()); bool bDoProcessRecursively(true); @@ -1154,6 +1166,10 @@ void VclMetafileProcessor2D::processControlPrimitive2D( } mpPDFExtOutDevData->CreateControl(*pPDFControl); mpPDFExtOutDevData->EndStructureElement(); + if (oAnchorParent) + { + mpPDFExtOutDevData->SetCurrentStructureElement(*oAnchorParent); + } // no normal paint needed (see original UnoControlPDFExportContact::do_PaintObject); // do not process recursively @@ -1236,6 +1252,10 @@ void VclMetafileProcessor2D::processControlPrimitive2D( if (mpPDFExtOutDevData) { mpPDFExtOutDevData->EndStructureElement(); + if (oAnchorParent) + { + mpPDFExtOutDevData->SetCurrentStructureElement(*oAnchorParent); + } } } -- cgit