summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-10-04 14:16:53 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-10-04 18:01:53 +0200
commit9f81fc25e528406f12cbfa6d56a27b69f9957edd (patch)
tree49a2e08eb808719860968cedb88cf6b8bcdf92d2 /sw/source/filter/ww8
parent1b6dead4dc7d11fd3d2e1b88da941857cb1be046 (diff)
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>
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r--sw/source/filter/ww8/writerhelper.hxx2
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx39
2 files changed, 21 insertions, 20 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 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 );