sw/qa/extras/rtfexport/data/tdf138779.docx |binary sw/qa/extras/rtfexport/rtfexport5.cxx | 6 ++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 19 +++++++++++-------- sw/source/filter/ww8/rtfattributeoutput.hxx | 2 ++ 4 files changed, 19 insertions(+), 8 deletions(-)
New commits: commit 326388da4e40c85f8a1af40264aaf56c7845e224 Author: Mark Hung <mark...@gmail.com> AuthorDate: Sun Dec 20 22:36:20 2020 +0800 Commit: Mark Hung <mark...@gmail.com> CommitDate: Tue Dec 29 13:55:41 2020 +0100 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 <mark...@gmail.com> diff --git a/sw/qa/extras/rtfexport/data/tdf138779.docx b/sw/qa/extras/rtfexport/data/tdf138779.docx new file mode 100644 index 000000000000..ef7d5dd84105 Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf138779.docx differ 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 5fdabb896756..6213a509aa3e 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) { @@ -3807,6 +3809,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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits