From 63ee1e1b27b5a9b6b221a78a4567f76cba2a1adb Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 28 Jan 2019 21:50:54 +0100 Subject: tdf#122430 RTF import: fix lost font size on footnote start This become more visible since commit 49614a9ea971ff7f370f863ce8a2735aab973cee (tdf#119599 RTF import: fix missing deduplication of font size, 2018-09-24) as now incorrect font size from style affects the rendering result. Change-Id: I5b339337f021e2fc359f6fc5f5aa2ed0bcf844b9 Reviewed-on: https://gerrit.libreoffice.org/67034 Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit e45fbf479944b9ec940bdddfa8ee7d523244a9ba) Reviewed-on: https://gerrit.libreoffice.org/67122 Reviewed-by: Christian Lohmaier --- sw/qa/extras/rtfimport/data/tdf122430.rtf | 31 ++++++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 7 ++++++ writerfilter/source/rtftok/rtfdispatchflag.cxx | 8 +++++++ 3 files changed, 46 insertions(+) create mode 100644 sw/qa/extras/rtfimport/data/tdf122430.rtf diff --git a/sw/qa/extras/rtfimport/data/tdf122430.rtf b/sw/qa/extras/rtfimport/data/tdf122430.rtf new file mode 100644 index 000000000000..fc1a80f532c9 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/tdf122430.rtf @@ -0,0 +1,31 @@ +{\rtf1\ansi\deff0\adeflang1025 +{\fonttbl +{\f0\froman\fprq2\fcharset0 Times New Roman;} +{\f1\froman\fprq2\fcharset2 Symbol;} +{\f2\fswiss\fprq2\fcharset0 Arial;} +{\f3\froman\fprq2\fcharset0 Arial;} +{\f4\froman\fprq2\fcharset0 Cambria;} +{\f5\froman\fprq2\fcharset0 Calibri;} +{\f6\fnil\fprq2\fcharset0 Microsoft YaHei;} +{\f7\fnil\fprq2\fcharset0 Cambria;} +{\f8\fnil\fprq2\fcharset0 Times New Roman;} +{\f9\fnil\fprq2\fcharset0 Lucida Sans;} +{\f10\fswiss\fprq0\fcharset128 Lucida Sans;} +} +{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;} +{\stylesheet +{\s0\snext0\ql\nowidctlpar\hyphpar0\ltrpar\cf1\kerning1\dbch\af7\langfe1081\dbch\af7\afs24\alang1081\loch\f0\fs24\lang1040 Normal;} +{\s43\snext43\ql\nowidctlpar\hyphpar0\faauto\li0\ri0\lin0\rin0\fi0\sb240\sa120\keepn\ltrpar\cf1\b\kerning1\dbch\af7\langfe1040\dbch\af9\afs24\alang1081\loch\f3\fs36\lang1040 Titolo 1;} +{\s61\sbasedon0\snext61\ql\nowidctlpar\hyphpar0\ltrpar\cf1\kerning1\dbch\af7\langfe1081\dbch\af7\afs24\loch\f0\fs24\lang1040 Footnote;} +} +\pard\plain \s43\ql\nowidctlpar\hyphpar0\faauto\li0\ri0\lin0\rin0\fi0\sb240\sa120\keepn\ltrpar\cf1\b\kerning1\dbch\af7\langfe1040\dbch\af9\afs24\alang1081\loch\f3\fs36\lang1040\sb240\sa120 +{ +{\super 1 +{\*\footnote 1\pard\plain \s61\fs24 +{\cf1\kerning1\dbch\af7\langfe1040\rtlch \ltrch\rtlch \ltrch\loch\fs20\lang1040 +\tab A} +} +} +} +A +\par} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 233d987e5db0..f09169ed77d3 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -354,6 +354,13 @@ DECLARE_RTFIMPORT_TEST(testTdf112211_2, "tdf112211-2.rtf") CPPUNIT_ASSERT_LESS(300, nWidth); } +DECLARE_RTFIMPORT_TEST(testTdf122430, "tdf122430.rtf") +{ + // Without the accompanying fix in place, this test would have failed with + // 'Expected: 18, Actual : 12', i.e. the font was smaller than expected. + CPPUNIT_ASSERT_EQUAL(18.0f, getProperty(getRun(getParagraph(1), 2), "CharHeight")); +} + DECLARE_RTFIMPORT_TEST(testFdo49892, "fdo49892.rtf") { uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx index 833b38d16876..b68262ff265e 100644 --- a/writerfilter/source/rtftok/rtfdispatchflag.cxx +++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx @@ -773,6 +773,14 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) break; case RTF_SUPER: { + // Make sure character properties are not lost if the document + // starts with a footnote. + if (!isStyleSheetImport()) + { + checkFirstRun(); + checkNeedPap(); + } + if (!m_aStates.top().pCurrentBuffer) m_aStates.top().pCurrentBuffer = &m_aSuperBuffer; -- cgit