[Libreoffice-commits] core.git: sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sun Oct 4 16:02:34 UTC 2020


 sw/source/filter/ww8/writerhelper.hxx |    2 +
 sw/source/filter/ww8/ww8atr.cxx       |   39 ++++++++++++++++------------------
 2 files changed, 21 insertions(+), 20 deletions(-)

New commits:
commit 9f81fc25e528406f12cbfa6d56a27b69f9957edd
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Oct 4 14:16:53 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Oct 4 18:01:53 2020 +0200

    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>

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 7d2a1c0432d3..d6b0fabe8701 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_rDoc);
+                     if (!pINetFormat)
                          continue;
 
-                     const sal_uInt16 nId = rINet.GetINetFormatId();
-                     const OUString& rStr = rINet.GetINetFormat();
-
-                     if (rStr.isEmpty())
-                     {
-                         OSL_ENSURE( false, "MSWordExportBase::ExportPoolItemsToCHP(..) - missing unvisited character format at hyperlink attribute" );
-                     }
-
-                     const SwCharFormat* pINetFormat = IsPoolUserFormat( nId )
-                        ? m_rDoc.FindCharFormatByName( rStr )
-                        : m_rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
-
                      const SwCharFormat* pFormat = static_cast<const SwFormatCharFormat&>(*pItem).GetCharFormat();
                      ww8::PoolItems aCharItems, aINetItems;
                      GetPoolItems(pFormat->GetAttrSet(), aCharItems, false);
@@ -1604,10 +1592,12 @@ 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() )
-        return;
+    if (rINet.GetValue().isEmpty())
+        return nullptr;
 
     const sal_uInt16 nId = rINet.GetINetFormatId();
     const OUString& rStr = rINet.GetINetFormat();
@@ -1616,9 +1606,18 @@ void WW8AttributeOutput::TextINetFormat( const SwFormatINetFormat& rINet )
         OSL_ENSURE( false, "WW8AttributeOutput::TextINetFormat(..) - missing unvisited character format at hyperlink attribute" );
     }
 
-    const SwCharFormat* pFormat = IsPoolUserFormat( nId )
-                    ? m_rWW8Export.m_rDoc.FindCharFormatByName( rStr )
-                    : m_rWW8Export.m_rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
+    return IsPoolUserFormat( nId )
+               ? rDoc.FindCharFormatByName( rStr )
+               : rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( nId );
+}
+
+} }
+
+void WW8AttributeOutput::TextINetFormat( const SwFormatINetFormat& rINet )
+{
+    const SwCharFormat* pFormat = GetSwCharFormat(rINet, m_rWW8Export.m_rDoc);
+    if (!pFormat)
+        return;
 
     m_rWW8Export.InsUInt16( NS_sprm::CIstd::val );
 


More information about the Libreoffice-commits mailing list