diff options
author | Mark Hung <marklh9@gmail.com> | 2020-12-20 22:36:20 +0800 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-01-04 12:25:39 +0100 |
commit | 30ad09049bf76956a696c2b61f5b9922bb744a08 (patch) | |
tree | 31fa5795bf0c5fb4685287d3d6e7def720cf0712 | |
parent | 4f7d5b0ed8df89dec6cc2ae45be5885f5f4ebae6 (diff) |
tdf#138779 do not call EndRun() in StartRuby()
and EndRuby(). Ruby is implemented as EQ field in RTF.
The original run text become the ruby base text in this
case. Calling EndRun() in StartRuby() might cause the
run completed early and text attributes that hasn't be
processed mistakenly applied to next run. This patch
close the in EQ field command in EndRun, in case StartRuby
has already inserted EQ field command.
Change-Id: I3a755f235b79d11b7897f85ae3989cc3ac73b06a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108194
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9@gmail.com>
(cherry picked from commit 326388da4e40c85f8a1af40264aaf56c7845e224)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108343
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sw/qa/extras/rtfexport/data/tdf138779.docx | bin | 0 -> 16556 bytes | |||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport5.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.hxx | 2 |
4 files changed, 19 insertions, 8 deletions
diff --git a/sw/qa/extras/rtfexport/data/tdf138779.docx b/sw/qa/extras/rtfexport/data/tdf138779.docx Binary files differnew file mode 100644 index 000000000000..ef7d5dd84105 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf138779.docx diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 0d921ed6c7b6..fea953889795 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -1276,6 +1276,12 @@ DECLARE_RTFEXPORT_TEST(testTdf137894, "tdf137894.odt") CPPUNIT_ASSERT_EQUAL(32.f, getProperty<float>(getRun(getParagraph(2), 1), "CharHeightComplex")); } +DECLARE_RTFEXPORT_TEST(testTdf138779, "tdf138779.docx") +{ + // The text "2. Kozuka Mincho Pro, 8 pt Ruby ..." has font size 11pt ( was 20pt ). + CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(getRun(getParagraph(2), 14), "CharHeight")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 23dc3af728e2..f1a6da4f3f47 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -405,6 +405,13 @@ void RtfAttributeOutput::EndRun(const SwTextNode* /*pNode*/, sal_Int32 /*nPos*/, { m_aRun->append(SAL_NEWLINE_STRING); m_aRun.appendAndClear(m_aRunText); + + if (m_bInRuby) + { + m_aRun->append(")}}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {}}}"); + m_bInRuby = false; + } + if (!m_bSingleEmptyRun && m_bInRun) m_aRun->append('}'); m_bInRun = false; @@ -508,7 +515,7 @@ void RtfAttributeOutput::RawText(const OUString& rText, rtl_TextEncoding eCharSe m_aRunText->append(msfilter::rtfutil::OutString(rText, eCharSet)); } -void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 nPos, +void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/, const SwFormatRuby& rRuby) { WW8Ruby aWW8Ruby(rNode, rRuby, GetExport()); @@ -521,18 +528,13 @@ void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 nPos, aStr += "\\a" + OUStringChar(aWW8Ruby.GetDirective()); } aStr += "(\\s\\up " + OUString::number((aWW8Ruby.GetBaseHeight() + 10) / 20 - 1) + "("; - EndRun(&rNode, nPos); m_rExport.OutputField(nullptr, ww::eEQ, aStr, FieldFlags::Start | FieldFlags::CmdStart); aStr = rRuby.GetText() + "),"; m_rExport.OutputField(nullptr, ww::eEQ, aStr, FieldFlags::NONE); + m_bInRuby = true; } -void RtfAttributeOutput::EndRuby(const SwTextNode& rNode, sal_Int32 nPos) -{ - m_rExport.OutputField(nullptr, ww::eEQ, ")", - FieldFlags::CmdEnd | FieldFlags::End | FieldFlags::Close); - EndRun(&rNode, nPos); -} +void RtfAttributeOutput::EndRuby(const SwTextNode& /*rNode*/, sal_Int32 /*nPos*/) {} bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget) { @@ -3810,6 +3812,7 @@ RtfAttributeOutput::RtfAttributeOutput(RtfExport& rExport) , m_bIsBeforeFirstParagraph(true) , m_bSingleEmptyRun(false) , m_bInRun(false) + , m_bInRuby(false) , m_pFlyFrameSize(nullptr) , m_bParaBeforeAutoSpacing(false) , m_nParaBeforeSpacing(0) diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index 246ab4aba50b..a7f95813c2c0 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -610,6 +610,8 @@ private: bool m_bInRun; + bool m_bInRuby; + /// Maps ID's to postit fields, used in atrfstart/end and atnref. std::map<sal_uInt16, const SwPostItField*> m_aPostitFields; |