diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-10-04 14:16:53 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-01-13 21:19:35 +0100 |
commit | 36038264400f591a529a18f0b742410e53db73d3 (patch) | |
tree | ce9a465ece22430438f12d62d80dded42b6b9f33 /sw | |
parent | 9fbbaf11f1b44f241d8a8d819e7de1c98612aa83 (diff) |
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@redhat.com>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109226
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/writerhelper.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 55 |
2 files changed, 29 insertions, 28 deletions
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> |