drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx |   23 ++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

New commits:
commit 5ef4d326a06f9fc0aff36bd5cdcba1b7af8e03db
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed Apr 5 18:00:27 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Apr 6 09:34:52 2023 +0200

    tdf#152234 drawinglayer: PDF/UA export: fallback for unsupported forms
    
    veraPDF complains:
    
      Specification: ISO 14289-1:2014, Clause: 7.1, Test number: 3
      Content shall be marked as Artifact or tagged as real content
    
    Form element can only be used for those form controls for which
    PDFWriterImpl can produce a Widget annotation; see createDefaultWidget().
    
    For a label control, it's not editable so it's not a PDF widget.
    
    For an image button, it could be implemented in VCL but isn't currently.
    
    So a fallback is required in any case, "Figure" or "Div" can be used.
    
    Change-Id: I454030ff7c67a8a8101fcc59e945fe9dbc5f87a8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150059
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx 
b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 58396ba0c73b..9adbb7501701 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -1157,7 +1157,6 @@ void VclMetafileProcessor2D::processControlPrimitive2D(
             pPDFControl->TextFont.SetFontSize(aFontSize);
 
             mpPDFExtOutDevData->BeginStructureElement(vcl::PDFWriter::Form);
-            OUString const& rAltText(rControlPrimitive.GetAltText());
             vcl::PDFWriter::StructAttributeValue role;
             switch (pPDFControl->Type)
             {
@@ -1177,6 +1176,7 @@ void VclMetafileProcessor2D::processControlPrimitive2D(
             // ISO 14289-1:2014, Clause: 7.18.4
             mpPDFExtOutDevData->SetStructureAttribute(vcl::PDFWriter::Role, 
role);
             // ISO 14289-1:2014, Clause: 7.18.1
+            OUString const& rAltText(rControlPrimitive.GetAltText());
             if (!rAltText.isEmpty())
             {
                 mpPDFExtOutDevData->SetAlternateText(rAltText);
@@ -1196,6 +1196,22 @@ void VclMetafileProcessor2D::processControlPrimitive2D(
         }
     }
 
+    if (!bDoProcessRecursively)
+    {
+        return;
+    }
+
+    if (mpPDFExtOutDevData)
+    { // no corresponding PDF Form, use Figure instead
+        mpPDFExtOutDevData->BeginStructureElement(vcl::PDFWriter::Figure);
+        mpPDFExtOutDevData->SetStructureAttribute(vcl::PDFWriter::Placement, 
vcl::PDFWriter::Block);
+        OUString const& rAltText(rControlPrimitive.GetAltText());
+        if (!rAltText.isEmpty())
+        {
+            mpPDFExtOutDevData->SetAlternateText(rAltText);
+        }
+    }
+
     // #i93169# used flag the wrong way; true means that nothing was done yet
     if (bDoProcessRecursively)
     {
@@ -1240,6 +1256,11 @@ void VclMetafileProcessor2D::processControlPrimitive2D(
     {
         process(rControlPrimitive);
     }
+
+    if (mpPDFExtOutDevData)
+    {
+        mpPDFExtOutDevData->EndStructureElement();
+    }
 }
 
 void VclMetafileProcessor2D::processTextHierarchyFieldPrimitive2D(

Reply via email to