Kaydet (Commit) f4e0cbaa authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#45182 fix RTF import of character encoding in footnotes

There were two problems here:

1) \plain reset the character properties, but did not touch the current encoding
2) the default properties were not passed to substreams
üst 97bcf0b6
{\rtf1\deff0
{\fonttbl
{\f0\fcharset238
Times New Roman;}
}
a\chftn
{\footnote
\ltrpar \pard\plain\'9eivnost\'ed
\par
}
}
......@@ -35,6 +35,7 @@
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/SizeType.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/XFootnotesSupplier.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
......@@ -77,6 +78,7 @@ public:
void testFdo45394();
void testFdo48104();
void testFdo47107();
void testFdo45182();
CPPUNIT_TEST_SUITE(RtfModelTest);
#if !defined(MACOSX) && !defined(WNT)
......@@ -97,6 +99,7 @@ public:
CPPUNIT_TEST(testFdo45394);
CPPUNIT_TEST(testFdo48104);
CPPUNIT_TEST(testFdo47107);
CPPUNIT_TEST(testFdo45182);
#endif
CPPUNIT_TEST_SUITE_END();
......@@ -500,6 +503,18 @@ void RtfModelTest::testFdo47107()
xNumberingStyles->getByName("WWNum2");
}
void RtfModelTest::testFdo45182()
{
load("fdo45182.rtf");
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
// Encoding in the footnote was wrong.
OUString aExpected("živností", 10, RTL_TEXTENCODING_UTF8);
CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
}
CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -541,6 +541,14 @@ int RTFDocumentImpl::getFontIndex(int nIndex)
return m_pSuperstream->getFontIndex(nIndex);
}
RTFParserState& RTFDocumentImpl::getDefaultState()
{
if (!m_pSuperstream)
return m_aDefaultState;
else
return m_pSuperstream->getDefaultState();
}
void RTFDocumentImpl::resolve(Stream & rMapper)
{
m_pMapperStream = &rMapper;
......@@ -1762,8 +1770,13 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
m_aStates.top().nCurrentEncoding = RTL_TEXTENCODING_MS_1252;
break;
case RTF_PLAIN:
m_aStates.top().aCharacterSprms = m_aDefaultState.aCharacterSprms;
m_aStates.top().aCharacterAttributes = m_aDefaultState.aCharacterAttributes;
{
m_aStates.top().aCharacterSprms = getDefaultState().aCharacterSprms;
RTFValue::Pointer_t pValue = m_aStates.top().aCharacterSprms.find(NS_sprm::LN_CRgFtc0);
if (pValue.get())
m_aStates.top().nCurrentEncoding = getEncoding(pValue->getInt());
m_aStates.top().aCharacterAttributes = getDefaultState().aCharacterAttributes;
}
break;
case RTF_PARD:
m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
......
......@@ -372,6 +372,8 @@ namespace writerfilter {
int getFontIndex(int nIndex);
/// Return the encoding associated with a dmapper font index.
rtl_TextEncoding getEncoding(sal_uInt32 nFontIndex);
/// Get the default parser state.
RTFParserState& getDefaultState();
private:
SvStream& Strm();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment