diff options
author | Serge Krot <Serge.Krot@cib.de> | 2017-10-31 23:39:26 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-11-03 11:38:17 +0100 |
commit | 3f2e84b4bd0bbd936e0af845ba7cbf68cb2803d6 (patch) | |
tree | c0ed895af55792f343659eebbde76dd8ab656cd8 /sw/source | |
parent | 25a26b66b398d127842369e06c3ef95fe901e305 (diff) |
tdf#38778 Fix output of the font in DOC run
The font information should be output before field declaration.
Added unit test.
Change-Id: I147dd8956fbd8e69c3a2e86aff01dc249f4fa815
tdf#38778 DOCX output: no double output of the font info
Change-Id: Ia080f742cde88b914e146fe7a95b90bf1952c96a
Reviewed-on: https://gerrit.libreoffice.org/44160
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 14 |
4 files changed, 30 insertions, 6 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 6cbd0a6cdc18..146b7b9e3a5f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6699,11 +6699,24 @@ void DocxAttributeOutput::CharFont( const SvxFontItem& rFont) { GetExport().GetId( rFont ); // ensure font info is written to fontTable.xml const OUString& sFontName(rFont.GetFamilyName()); - OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8); + const OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8); if (!sFontNameUtf8.isEmpty()) + { + if (m_pFontsAttrList && + ( m_pFontsAttrList->hasAttribute(FSNS( XML_w, XML_ascii )) || + m_pFontsAttrList->hasAttribute(FSNS( XML_w, XML_hAnsi )) ) + ) + { + // tdf#38778: do to fields output into DOC the font could be added before and after field declaration + // that all sub runs of the field will have correct font inside. + // For DOCX we should do not add the same font information twice in the same node + return; + } + AddToAttrList( m_pFontsAttrList, 2, FSNS( XML_w, XML_ascii ), sFontNameUtf8.getStr(), FSNS( XML_w, XML_hAnsi ), sFontNameUtf8.getStr() ); + } } void DocxAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize) diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index de0820b8204a..de71bd55e618 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -481,7 +481,10 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby ) m_rExport.m_pOutFormatNode = &rNd; m_rExport.m_aCurrentCharPropStarts.push( nSwPos ); - m_rExport.ExportPoolItemsToCHP( aExportItems, GetScript() ); + // tdf#38778 Fix output of the font in DOC run for fields + const SvxFontItem * pFontToOutput = ( rParentFont != *pFont )? pFont : nullptr; + + m_rExport.ExportPoolItemsToCHP( aExportItems, GetScript(), pFontToOutput ); // HasTextItem only allowed in the above range m_rExport.m_aCurrentCharPropStarts.pop(); diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 6d7f0069731d..e995f61cf140 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -588,7 +588,7 @@ public: void WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_uInt8 nTTyp ); /// Export the pool items to attributes (through an attribute output class). - void ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 nScript ); + void ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 nScript, const SvxFontItem *pFont ); /// Return the numeric id of the numbering rule sal_uInt16 GetId( const SwNumRule& rNumRule ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 9ebe781599d2..dfa4c2d29aa2 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -204,7 +204,7 @@ bool WW8Export::CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich } -void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 nScript ) +void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 nScript, const SvxFontItem *pFont ) { ww8::cPoolItemIter aEnd = rItems.end(); for ( ww8::cPoolItemIter aI = rItems.begin(); aI != aEnd; ++aI ) @@ -220,7 +220,15 @@ void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 //add the second judgement for #i24291# definition. if ( nWhich == RES_TXTATR_INETFMT && ( rItems.begin()->second->Which() == RES_TXTATR_CHARFMT ) ) continue; - AttrOutput().OutputItem( *pItem ); + + // tdf#38778 Fix output of the font in DOC run for fields + if (pFont && + nWhich == RES_TXTATR_FIELD) + { + AttrOutput().OutputItem( *pFont ); + } + + AttrOutput().OutputItem( *pItem ); } } } @@ -269,7 +277,7 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, b ww8::PoolItems aItems; GetPoolItems( rSet, aItems, bExportParentItemSet ); if ( bChpFormat ) - ExportPoolItemsToCHP(aItems, nScript); + ExportPoolItemsToCHP(aItems, nScript, nullptr); if ( bPapFormat ) { ww8::cPoolItemIter aEnd = aItems.end(); |