sw/source/core/text/EnhancedPDFExportHelper.cxx |   47 +++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

New commits:
commit a20591e08d8996db02f3811b62b06f12a9f033e1
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Mar 9 17:00:45 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Mar 10 11:48:38 2023 +0000

    sw: PDF/UA export: produce ListNumbering
    
    As required by ISO 14289-1:2014:
    
      7.6 Lists
      — An explicit ListNumbering attribute shall be used for L tags in
        ordered lists as specified in ISO 32000-1:2008, 14.8.5.5, Table
        347.
    
    Change-Id: If3d1e4aa63f7bcfba1a28294fe9f59cf2e068070
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148557
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index c1a6995bd2aa..3fc2ab0c478e 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -901,6 +901,51 @@ void SwTaggedPDFHelper::SetAttributes( 
vcl::PDFWriter::StructElement eType )
             }
         }
     }
+    else if (mpNumInfo && eType == vcl::PDFWriter::List)
+    {
+        SwTextFrame const& rFrame(static_cast<SwTextFrame 
const&>(mpNumInfo->mrFrame));
+        SwTextNode const& rNode(*rFrame.GetTextNodeForParaProps());
+        SwNumRule const*const pNumRule = rNode.GetNumRule();
+        assert(pNumRule); // was required for List
+
+        auto ToPDFListNumbering = [](SvxNumberFormat const& rFormat) {
+            switch (rFormat.GetNumberingType())
+            {
+                case css::style::NumberingType::CHARS_UPPER_LETTER:
+                    return vcl::PDFWriter::UpperAlpha;
+                case css::style::NumberingType::CHARS_LOWER_LETTER:
+                    return vcl::PDFWriter::LowerAlpha;
+                case css::style::NumberingType::ROMAN_UPPER:
+                    return vcl::PDFWriter::UpperRoman;
+                case css::style::NumberingType::ROMAN_LOWER:
+                    return vcl::PDFWriter::LowerRoman;
+                case css::style::NumberingType::ARABIC:
+                    return vcl::PDFWriter::Decimal;
+                case css::style::NumberingType::CHAR_SPECIAL:
+                    switch (rFormat.GetBulletChar())
+                    {
+                        case u'\u2022': case u'\uE12C': case u'\uE01E': case 
u'\uE437':
+                            return vcl::PDFWriter::Disc;
+                        case u'\u2218': case u'\u25CB': case u'\u25E6':
+                            return vcl::PDFWriter::Circle;
+                        case u'\u25A0': case u'\u25AA': case u'\uE00A':
+                            return vcl::PDFWriter::Square;
+                        default:
+                            return vcl::PDFWriter::NONE;
+                    }
+                default: // the other 50 types
+                    return vcl::PDFWriter::NONE;
+            }
+        };
+
+        // Note: for every level, BeginNumberedListStructureElements() produces
+        // a separate List element, so even though in PDF this is limited to
+        // the whole List we can just export the current level here.
+        vcl::PDFWriter::StructAttributeValue const value(
+                ToPDFListNumbering(pNumRule->Get(rNode.GetActualListLevel())));
+        // ISO 14289-1:2014, Clause: 7.6
+        
mpPDFExtOutDevData->SetStructureAttribute(vcl::PDFWriter::ListNumbering, value);
+    }
 }
 
 void SwTaggedPDFHelper::BeginNumberedListStructureElements()
@@ -910,7 +955,7 @@ void SwTaggedPDFHelper::BeginNumberedListStructureElements()
         return;
 
     const SwFrame& rFrame = mpNumInfo->mrFrame;
-    OSL_ENSURE( rFrame.IsTextFrame(), "numbered only for text frames" );
+    assert(rFrame.IsTextFrame());
     const SwTextFrame& rTextFrame = static_cast<const SwTextFrame&>(rFrame);
 
     // Lowers of NonStructureElements should not be considered:

Reply via email to