summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorAndreas Brandner <Andreas.Brandner@cib.de>2017-11-05 20:41:31 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-11-09 00:47:46 +0100
commite4ccf5f597d84f5745d73d306e83594f665024bb (patch)
tree60f37ad1efb476d89dc664b65e0a511e0ddf862d /sw/source/filter
parent65d69d95e88de25bcb59486231d92ace6be5feed (diff)
tdf#66401 don't lose docx-combined-characters' font props on roundtrip
Change-Id: Idbdb5bf3066e2ed86b494255d72d66eebf72f755 Reviewed-on: https://gerrit.libreoffice.org/44336 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx22
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx4
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx4
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx18
5 files changed, 40 insertions, 10 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d844268dbff3..1ab6cde62852 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1747,12 +1747,18 @@ void DocxAttributeOutput::DoWriteCmd( const OUString& rCmd )
void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun )
{
+ bool bWriteCombChars(false);
+
// Write the Field instruction
{
if ( bWriteRun )
{
m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
- DoWriteFieldRunProperties( pNode, nPos );
+
+ if (rInfos.eType == ww::eEQ)
+ bWriteCombChars = true;
+
+ DoWriteFieldRunProperties( pNode, nPos, bWriteCombChars );
}
sal_Int32 nNbToken = comphelper::string::getTokenCount(rInfos.sCmd, '\t');
@@ -1836,7 +1842,7 @@ void DocxAttributeOutput::CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos
/// <w:fldChar w:fldCharType="end" />
/// </w:r>
/// See, tdf#38778
-void DocxAttributeOutput::DoWriteFieldRunProperties( const SwTextNode * pNode, sal_Int32 nPos )
+void DocxAttributeOutput::DoWriteFieldRunProperties( const SwTextNode * pNode, sal_Int32 nPos, bool bWriteCombChars)
{
if (! pNode)
{
@@ -1866,7 +1872,17 @@ void DocxAttributeOutput::DoWriteFieldRunProperties( const SwTextNode * pNode, s
// 3. output all other character properties
SwWW8AttrIter aAttrIt( m_rExport, *pNode );
- aAttrIt.OutAttr( nPos, false );
+ aAttrIt.OutAttr( nPos, false, bWriteCombChars );
+
+ // 4. explicitly write the font-properties, to ensure all runs in the field have them
+ // see tdf#66401
+ if ( m_pFontsAttrList.is() )
+ {
+ XFastAttributeListRef xAttrList( m_pFontsAttrList.get() );
+ m_pFontsAttrList.clear();
+
+ m_pSerializer->singleElementNS( XML_w, XML_rFonts, xAttrList );
+ }
m_pSerializer->endElementNS( XML_w, XML_rPr );
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 7a09130e23e5..76bfc1a98af0 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -732,7 +732,7 @@ private:
void DoWriteCmd( const OUString& rCmd );
void CmdField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos const & rInfos, bool bWriteRun );
void EndField_Impl( const SwTextNode* pNode, sal_Int32 nPos, FieldInfos& rInfos );
- void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos );
+ void DoWriteFieldRunProperties( const SwTextNode* pNode, sal_Int32 nPos, bool bWriteCombChars = false );
virtual void GenerateBookmarksForSequenceField(const SwTextNode& rNode, SwWW8AttrIter& rAttrIter) override;
static void AddToAttrList( rtl::Reference<sax_fastparser::FastAttributeList>& pAttrList, sal_Int32 nAttrName, const sal_Char* sAttrValue );
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 23208e90a8fc..663036af6b70 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -379,7 +379,7 @@ static bool lcl_isFontsizeItem( const SfxPoolItem& rItem )
rItem.Which( ) == RES_CHRATR_CTL_FONTSIZE );
}
-void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby )
+void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby , bool bWriteCombChars)
{
m_rExport.AttrOutput().RTLAndCJKState( mbCharIsRTL, GetScript() );
@@ -484,7 +484,7 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby )
// 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 );
+ m_rExport.ExportPoolItemsToCHP( aExportItems, GetScript(), pFontToOutput, bWriteCombChars );
// 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 c96dcd8299b0..31ccbeba4554 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, const SvxFontItem *pFont );
+ void ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 nScript, const SvxFontItem *pFont, bool bWriteCombChars = false );
/// Return the numeric id of the numbering rule
sal_uInt16 GetId( const SwNumRule& rNumRule );
@@ -1495,7 +1495,7 @@ public:
void NextPos() { if ( nAktSwPos < SAL_MAX_INT32 ) nAktSwPos = SearchNext( nAktSwPos + 1 ); }
- void OutAttr( sal_Int32 nSwPos, bool bRuby = false );
+ void OutAttr( sal_Int32 nSwPos, bool bRuby = false, bool bWriteCombinedChars = false );
virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const override;
virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const override;
int OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos);
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 51ef08a2a21e..9bc93b67fcfa 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, const SvxFontItem *pFont )
+void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 nScript, const SvxFontItem *pFont, bool bWriteCombChars )
{
ww8::cPoolItemIter aEnd = rItems.end();
for ( ww8::cPoolItemIter aI = rItems.begin(); aI != aEnd; ++aI )
@@ -228,7 +228,21 @@ void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16
AttrOutput().OutputItem( *pFont );
}
- AttrOutput().OutputItem( *pItem );
+ // tdf#66401 For Combined Characters in docx, MS Word uses half the normal font-size for the field's
+ // font-size, but only for <w:sz>. Therefore, we check if we are currently writing a field of type
+ // Combined Characters and if so, we half the font size.
+ if (bWriteCombChars &&
+ nWhich == RES_CHRATR_FONTSIZE)
+ {
+ SvxFontHeightItem fontHeight(item_cast<SvxFontHeightItem>( *pItem ));
+ fontHeight.SetHeight( fontHeight.GetHeight() / 2 );
+
+ AttrOutput().OutputItem( fontHeight );
+ }
+ else
+ {
+ AttrOutput().OutputItem( *pItem );
+ }
}
}
}