summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/rtfexport/data/tdf104390.rtf6
-rw-r--r--sw/qa/extras/rtfexport/rtfexport5.cxx15
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx20
3 files changed, 34 insertions, 7 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf104390.rtf b/sw/qa/extras/rtfexport/data/tdf104390.rtf
new file mode 100644
index 000000000000..842e73e19a85
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf104390.rtf
@@ -0,0 +1,6 @@
+{\rtf1\deff0
+{\fonttbl
+{\f0 Courier New;}}
+\fs72
+{{{{Hello }}}{World!}}
+} \ No newline at end of file
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 36bf6c839b65..297635fce37e 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -1339,6 +1339,21 @@ DECLARE_RTFEXPORT_TEST(testTdf118047, "tdf118047.rtf")
CPPUNIT_ASSERT_MESSAGE("Header is too large", 1000 > nHeight);
}
+DECLARE_RTFEXPORT_TEST(testTdf104390, "tdf104390.rtf")
+{
+ uno::Reference<text::XTextRange> xPara = getParagraph(1);
+ uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xPara, uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+
+ // Check font in first run
+ uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(36.f, getProperty<float>(xRun, "CharHeight"));
+ CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(xRun, "CharFontName"));
+
+ // Ensure there is only one run
+ CPPUNIT_ASSERT_MESSAGE("Extra elements in paragraph", !xRunEnum->hasMoreElements());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 072430ebe15f..af4ba47158c3 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -397,16 +397,22 @@ void RTFDocumentImpl::checkFirstRun()
assert(!m_bNeedSect || m_bFirstRunException);
setNeedSect(true); // first call that succeeds
- // set the requested default font, if there are none
+ // set the requested default font, if there are none for each state in stack
RTFValue::Pointer_t pFont
= getNestedAttribute(m_aDefaultState.getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts,
NS_ooxml::LN_CT_Fonts_ascii);
- RTFValue::Pointer_t pCurrentFont
- = getNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts,
- NS_ooxml::LN_CT_Fonts_ascii);
- if (pFont && !pCurrentFont)
- putNestedAttribute(m_aStates.top().getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts,
- NS_ooxml::LN_CT_Fonts_ascii, pFont);
+ if (!pFont)
+ return;
+
+ for (size_t i = 0; i < m_aStates.size(); i++)
+ {
+ RTFValue::Pointer_t pCurrentFont
+ = getNestedAttribute(m_aStates[i].getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts,
+ NS_ooxml::LN_CT_Fonts_ascii);
+ if (!pCurrentFont)
+ putNestedAttribute(m_aStates[i].getCharacterSprms(), NS_ooxml::LN_EG_RPrBase_rFonts,
+ NS_ooxml::LN_CT_Fonts_ascii, pFont);
+ }
}
void RTFDocumentImpl::setNeedPar(bool bNeedPar) { m_bNeedPar = bNeedPar; }