fdo#48356 fix RTF import of special unicode characters

The \'0d string should not be an exception when ignoring characters
after the \u control word.
This commit is contained in:
Miklos Vajna 2012-04-20 12:42:23 +02:00
parent 1dcab66d5c
commit 69259c6509
3 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1,3 @@
{\rtf1
Ma\u269\'0dek
\par }

View file

@ -81,6 +81,7 @@ public:
void testFdo45182();
void testFdo44176();
void testFdo39053();
void testFdo48356();
CPPUNIT_TEST_SUITE(RtfModelTest);
#if !defined(MACOSX) && !defined(WNT)
@ -104,6 +105,7 @@ public:
CPPUNIT_TEST(testFdo45182);
CPPUNIT_TEST(testFdo44176);
CPPUNIT_TEST(testFdo39053);
CPPUNIT_TEST(testFdo48356);
#endif
CPPUNIT_TEST_SUITE_END();
@ -554,6 +556,24 @@ void RtfModelTest::testFdo39053()
CPPUNIT_ASSERT_EQUAL(1, nAsCharacter);
}
void RtfModelTest::testFdo48356()
{
load("fdo48356.rtf");
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
OUStringBuffer aBuf;
int i = 0;
while (xParaEnum->hasMoreElements())
{
xParaEnum->nextElement();
i++;
}
// The document used to be imported as two paragraphs.
CPPUNIT_ASSERT_EQUAL(1, i);
}
CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
CPPUNIT_PLUGIN_IMPLEMENT();

View file

@ -765,7 +765,7 @@ int RTFDocumentImpl::resolveChars(char ch)
bool bSkipped = false;
while(!Strm().IsEof() && ch != '{' && ch != '}' && ch != '\\')
{
if (ch != 0x0d && ch != 0x0a)
if (m_aStates.top().nInternalState == INTERNAL_HEX || (ch != 0x0d && ch != 0x0a))
{
if (m_aStates.top().nCharsToSkip == 0)
{