summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/ww8export/data/tdf38778_properties_in_run_for_field.docbin0 -> 25600 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export.cxx6
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx15
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx5
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx2
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx14
6 files changed, 36 insertions, 6 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf38778_properties_in_run_for_field.doc b/sw/qa/extras/ww8export/data/tdf38778_properties_in_run_for_field.doc
new file mode 100644
index 000000000000..960fe50dae35
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/tdf38778_properties_in_run_for_field.doc
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 38f41d83bf49..825ba6be7cf0 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -702,6 +702,12 @@ DECLARE_WW8EXPORT_TEST(testTdf102334, "tdf102334.doc")
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getRun(getParagraph(7), 1), "CharHidden"));
}
+DECLARE_WW8EXPORT_TEST(testTdf38778, "tdf38778_properties_in_run_for_field.doc")
+{
+ CPPUNIT_ASSERT_EQUAL(10.0f, getProperty<float>(getRun(getParagraph(1), 1), "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
+}
+
DECLARE_WW8EXPORT_TEST(testN325936, "n325936.doc")
{
/*
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();