diff options
-rw-r--r-- | sw/qa/extras/rtftok/data/fdo45182.rtf | 11 | ||||
-rw-r--r-- | sw/qa/extras/rtftok/rtftok.cxx | 15 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 17 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 |
4 files changed, 43 insertions, 2 deletions
diff --git a/sw/qa/extras/rtftok/data/fdo45182.rtf b/sw/qa/extras/rtftok/data/fdo45182.rtf new file mode 100644 index 000000000000..b076106162b7 --- /dev/null +++ b/sw/qa/extras/rtftok/data/fdo45182.rtf @@ -0,0 +1,11 @@ +{\rtf1\deff0 +{\fonttbl +{\f0\fcharset238 +Times New Roman;} +} +a\chftn +{\footnote +\ltrpar \pard\plain\'9eivnost\'ed +\par +} +} diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx index 45eabbf62e0d..926796799f82 100644 --- a/sw/qa/extras/rtftok/rtftok.cxx +++ b/sw/qa/extras/rtftok/rtftok.cxx @@ -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(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 5ceeaeb8450c..e938f98be74f 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -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; diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 1747958ae07b..1d72ece73a80 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -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(); |