sw/inc/EnhancedPDFExportHelper.hxx              |    1 
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   52 +++++++++++-------------
 2 files changed, 26 insertions(+), 27 deletions(-)

New commits:
commit 7aca867aa1e1e675c0a9d27d76bd069bc6d5f512
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Aug 31 19:01:47 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Sep 1 10:23:46 2023 +0200

    tdf#156306 sw: PDF export: refactor, split out BeginTagImpl()
    
    Change-Id: Ifcb8db6d9a5caaf50c0ca2794266fb501b59dee0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156356
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx 
b/sw/inc/EnhancedPDFExportHelper.hxx
index 6a505ff88887..c75e7cfe70ce 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -145,6 +145,7 @@ class SwTaggedPDFHelper
     const Frame_Info* mpFrameInfo;
     const Por_Info* mpPorInfo;
 
+    sal_Int32 BeginTagImpl(void const* pKey,vcl::PDFWriter::StructElement 
aTagRole, const OUString& rTagName);
     void BeginTag( vcl::PDFWriter::StructElement aTagRole, const OUString& 
rTagName );
     void EndTag();
 
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 0b4fe669b7d8..d3529e54b7f9 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -464,11 +464,27 @@ void SwTaggedPDFHelper::CheckRestoreTag() const
     }
 }
 
+sal_Int32 SwTaggedPDFHelper::BeginTagImpl(void const*const pKey,
+    vcl::PDFWriter::StructElement const eType, const OUString& rString)
+{
+    // write new tag
+    const sal_Int32 nId = mpPDFExtOutDevData->EnsureStructureElement(pKey);
+    mpPDFExtOutDevData->InitStructureElement(nId, eType, rString);
+    mpPDFExtOutDevData->BeginStructureElement(nId);
+    ++m_nEndStructureElement;
+
+#if OSL_DEBUG_LEVEL > 1
+    aStructStack.push_back( o3tl::narrowing<sal_uInt16>(eType) );
+#endif
+
+    return nId;
+}
+
 void SwTaggedPDFHelper::BeginTag( vcl::PDFWriter::StructElement eType, const 
OUString& rString )
 {
     void const* pKey(nullptr);
 
-    if (mpFrameInfo && eType != vcl::PDFWriter::LIBody && eType != 
vcl::PDFWriter::TOCI)
+    if (mpFrameInfo)
     {
         const SwFrame& rFrame = mpFrameInfo->mrFrame;
 
@@ -489,15 +505,7 @@ void SwTaggedPDFHelper::BeginTag( 
vcl::PDFWriter::StructElement eType, const OUS
         }
     }
 
-    // write new tag
-    const sal_Int32 nId = mpPDFExtOutDevData->EnsureStructureElement(pKey);
-    mpPDFExtOutDevData->InitStructureElement(nId, eType, rString);
-    mpPDFExtOutDevData->BeginStructureElement(nId);
-    ++m_nEndStructureElement;
-
-#if OSL_DEBUG_LEVEL > 1
-    aStructStack.push_back( o3tl::narrowing<sal_uInt16>(eType) );
-#endif
+    sal_Int32 const nId = BeginTagImpl(pKey, eType, rString);
 
     // Store the id of the current structure element if
     // - it is a list structure element
@@ -524,19 +532,6 @@ void SwTaggedPDFHelper::BeginTag( 
vcl::PDFWriter::StructElement eType, const OUS
             rNumListBodyIdMap[ pNodeNum ] = nId;
         }
     }
-    else if ( mpFrameInfo )
-    {
-        const SwFrame& rFrame = mpFrameInfo->mrFrame;
-
-        if (vcl::PDFWriter::LIBody == eType && rFrame.IsTextFrame())
-        {
-            SwTextFrame const& rTextFrame(static_cast<const 
SwTextFrame&>(rFrame));
-            SwTextNode const*const 
pTextNd(rTextFrame.GetTextNodeForParaProps());
-            SwNodeNum const*const 
pNodeNum(pTextNd->GetNum(rTextFrame.getRootFrame()));
-            NumListBodyIdMap& 
rNumListBodyIdMap(mpPDFExtOutDevData->GetSwPDFState()->m_NumListBodyIdMap);
-            rNumListBodyIdMap[ pNodeNum ] = nId;
-        }
-    }
 
     SetAttributes( eType );
 }
@@ -1250,14 +1245,17 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
         case SwFrameType::Txt :
             {
                 SwTextFrame const& rTextFrame(*static_cast<const 
SwTextFrame*>(pFrame));
+                const SwTextNode *const 
pTextNd(rTextFrame.GetTextNodeForParaProps());
+
                 // lazy open LBody after Lbl
                 if 
(rTextFrame.GetPara()->HasNumberingPortion(SwParaPortion::OnlyNumbering))
                 {
-                    BeginTag(vcl::PDFWriter::LIBody, aListBodyString);
+                    sal_Int32 const nId = BeginTagImpl(nullptr, 
vcl::PDFWriter::LIBody, aListBodyString);
+                    SwNodeNum const*const 
pNodeNum(pTextNd->GetNum(rTextFrame.getRootFrame()));
+                    NumListBodyIdMap& 
rNumListBodyIdMap(mpPDFExtOutDevData->GetSwPDFState()->m_NumListBodyIdMap);
+                    rNumListBodyIdMap[ pNodeNum ] = nId;
                 }
 
-                const SwTextNode *const 
pTextNd(rTextFrame.GetTextNodeForParaProps());
-
                 const SwFormat* pTextFormat = pTextNd->GetFormatColl();
                 const SwFormat* pParentTextFormat = pTextFormat ? 
pTextFormat->DerivedFrom() : nullptr;
 
@@ -1371,7 +1369,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements()
                         if ( pTOXBase && TOX_INDEX != pTOXBase->GetType() )
                         {
                             // Special case: Open additional TOCI tag:
-                            BeginTag( vcl::PDFWriter::TOCI, aTOCIString );
+                            BeginTagImpl(nullptr, vcl::PDFWriter::TOCI, 
aTOCIString);
                         }
                     }
                 }

Reply via email to