[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 13 20:20:11 UTC 2021


 sw/source/filter/ww8/writerhelper.hxx |    2 +
 sw/source/filter/ww8/ww8atr.cxx       |   55 ++++++++++++++++------------------
 2 files changed, 29 insertions(+), 28 deletions(-)

New commits:
commit 36038264400f591a529a18f0b742410e53db73d3
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Oct 4 14:16:53 2020 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed Jan 13 21:19:35 2021 +0100

    tdf#139580: combine these identical blocks together into a function
    
    Change-Id: I783c7f649d0624de9fb46c2b8379fc47ec311f63
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103917
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109226

diff --git a/sw/source/filter/ww8/writerhelper.hxx b/sw/source/filter/ww8/writerhelper.hxx
index f9d186ec58df..9ad16d0c2f14 100644
--- a/sw/source/filter/ww8/writerhelper.hxx
+++ b/sw/source/filter/ww8/writerhelper.hxx
@@ -650,6 +650,8 @@ namespace sw
             */
             explicit SetLayer(const SwDoc &rDoc);
         };
+
+        const SwCharFormat* GetSwCharFormat(const SwFormatINetFormat& rINet, SwDoc& rDoc);
     }
 
     namespace hack
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index e081b730f037..5ff2f7be0f7e 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -226,22 +226,10 @@ void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16
                  if (pINetItem)
                  {
                      const SwFormatINetFormat& rINet = static_cast<const SwFormatINetFormat&>(*pINetItem);
-
-                     if ( rINet.GetValue().isEmpty() )
+                     const SwCharFormat* pINetFormat = GetSwCharFormat(rINet, *m_pDoc);
+                     if (!pINetFormat)
                          continue;
 
-                     const sal_uInt16 nId = rINet.GetINetFormatId();
-                     const OUString& rStr = rINet.GetINetFormat();
-
-                     if (rStr.isEmpty())
-                     {
-                         SAL_WARN("sw.ww8", "MSWordExportBase::ExportPoolItemsToCHP(..) - missing unvisited character format at hyperlink attribute" );
-                     }
-
-                     const SwCharFormat* pINetFormat = IsPoolUserFormat( nId )
-                        ? m_pDoc->FindCharFormatByName( rStr )
-                        : m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
-
                      const SwCharFormat* pFormat = static_cast<const SwFormatCharFormat&>(*pItem).GetCharFormat();
                      ww8::PoolItems aCharItems, aINetItems;
                      GetPoolItems(pFormat->GetAttrSet(), aCharItems, false);
@@ -1645,25 +1633,36 @@ void WW8AttributeOutput::CharBackground( const SvxBrushItem& rBrush )
     m_rWW8Export.InsUInt16( 0x0000);
 }
 
-void WW8AttributeOutput::TextINetFormat( const SwFormatINetFormat& rINet )
+namespace sw { namespace util {
+
+const SwCharFormat* GetSwCharFormat(const SwFormatINetFormat& rINet, SwDoc& rDoc)
 {
-    if ( !rINet.GetValue().isEmpty() )
+    if (rINet.GetValue().isEmpty())
+        return nullptr;
+
+    const sal_uInt16 nId = rINet.GetINetFormatId();
+    const OUString& rStr = rINet.GetINetFormat();
+    if (rStr.isEmpty())
     {
-        const sal_uInt16 nId = rINet.GetINetFormatId();
-        const OUString& rStr = rINet.GetINetFormat();
-        if (rStr.isEmpty())
-        {
-            OSL_ENSURE( false, "WW8AttributeOutput::TextINetFormat(..) - missing unvisited character format at hyperlink attribute" );
-        }
+        OSL_ENSURE( false, "WW8AttributeOutput::TextINetFormat(..) - missing unvisited character format at hyperlink attribute" );
+    }
 
-        const SwCharFormat* pFormat = IsPoolUserFormat( nId )
-                        ? m_rWW8Export.m_pDoc->FindCharFormatByName( rStr )
-                        : m_rWW8Export.m_pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
+    return IsPoolUserFormat( nId )
+               ? rDoc.FindCharFormatByName( rStr )
+               : rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
+}
 
-        m_rWW8Export.InsUInt16( NS_sprm::sprmCIstd );
+} }
 
-        m_rWW8Export.InsUInt16( m_rWW8Export.GetId( pFormat ) );
-    }
+void WW8AttributeOutput::TextINetFormat( const SwFormatINetFormat& rINet )
+{
+    const SwCharFormat* pFormat = GetSwCharFormat(rINet, *m_rWW8Export.m_pDoc);
+    if (!pFormat)
+        return;
+
+    m_rWW8Export.InsUInt16( NS_sprm::sprmCIstd );
+
+    m_rWW8Export.InsUInt16( m_rWW8Export.GetId( pFormat ) );
 }
 
 // #i43956# - add optional parameter <pLinkStr>


More information about the Libreoffice-commits mailing list