From f84e0e6b1b0ec5f52ee963a62ac420cd872a771e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 23 Mar 2012 12:47:41 +0100 Subject: fdo#47326 fix RTF import of mixed super/nonsuper text In most cases \super has its own group, but it's valid to have mixed super and non-super text in a single group, as long as \super and \nosupersub keywords are used: handle this. --- sw/qa/extras/rtftok/data/fdo47326.rtf | 5 +++++ sw/qa/extras/rtftok/rtftok.cxx | 9 +++++++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 sw/qa/extras/rtftok/data/fdo47326.rtf diff --git a/sw/qa/extras/rtftok/data/fdo47326.rtf b/sw/qa/extras/rtftok/data/fdo47326.rtf new file mode 100644 index 000000000000..264e719127b7 --- /dev/null +++ b/sw/qa/extras/rtftok/data/fdo47326.rtf @@ -0,0 +1,5 @@ +{\rtf1 +Windows\super\'ae\nosupersub XP: +\pard + Cartes:\par +} diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx index 74836343717d..f4a0c4de85ce 100644 --- a/sw/qa/extras/rtftok/rtftok.cxx +++ b/sw/qa/extras/rtftok/rtftok.cxx @@ -68,6 +68,7 @@ public: void testFdo45563(); void testFdo43965(); void testN751020(); + void testFdo47326(); CPPUNIT_TEST_SUITE(RtfModelTest); #if !defined(MACOSX) && !defined(WNT) @@ -82,6 +83,7 @@ public: CPPUNIT_TEST(testFdo45563); CPPUNIT_TEST(testFdo43965); CPPUNIT_TEST(testN751020); + CPPUNIT_TEST(testFdo47326); #endif CPPUNIT_TEST_SUITE_END(); @@ -389,6 +391,13 @@ void RtfModelTest::testN751020() CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(200)), nValue); } +void RtfModelTest::testFdo47326() +{ + load(OUString(RTL_CONSTASCII_USTRINGPARAM("fdo47326.rtf"))); + // This was 15 only, as \super buffered text, then the contents of it got lost. + CPPUNIT_ASSERT_EQUAL(19, getLength()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 84267f3abf6b..d378694bc407 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1932,6 +1932,14 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) m_aStates.top().aCharacterSprms->push_back(make_pair(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue)); } break; + case RTF_NOSUPERSUB: + if (m_pCurrentBuffer == &m_aSuperBuffer) + { + replayBuffer(m_aSuperBuffer); + m_pCurrentBuffer = 0; + } + m_aStates.top().aCharacterSprms.erase(NS_ooxml::LN_EG_RPrBase_vertAlign); + break; case RTF_LINEPPAGE: case RTF_LINECONT: { -- cgit