From 3d4fef85d05269e613316a7af6245f05d207d76e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Apr 2013 14:42:22 +0200 Subject: fdo#63023 incorrect RTF background color in header Change-Id: I33f5c8a856206860ac9cdb23dd6b5222cb785bf7 --- sw/qa/extras/inc/swmodeltestbase.hxx | 18 +++++++++++++++--- sw/qa/extras/rtfimport/data/fdo63023.rtf | 10 ++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 9 +++++++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 11 ++++++++--- 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 sw/qa/extras/rtfimport/data/fdo63023.rtf diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 86547b8848ad..94b5d7e58e04 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -198,10 +198,16 @@ protected: } // Get paragraph (counted from 1), optionally check it contains the given text. - uno::Reference getParagraphOrTable(int number) const + uno::Reference getParagraphOrTable(int number, uno::Reference xText = uno::Reference()) const { - uno::Reference textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); + uno::Reference paraEnumAccess; + if (xText.is()) + paraEnumAccess.set(xText, uno::UNO_QUERY); + else + { + uno::Reference textDocument(mxComponent, uno::UNO_QUERY); + paraEnumAccess.set(textDocument->getText(), uno::UNO_QUERY); + } uno::Reference paraEnum = paraEnumAccess->createEnumeration(); for( int i = 1; i < number; @@ -221,6 +227,12 @@ protected: return xParagraph; } + uno::Reference getParagraphOfText(int number, uno::Reference xText) const + { + uno::Reference const xParagraph(getParagraphOrTable(number, xText), uno::UNO_QUERY_THROW); + return xParagraph; + } + /// Get run (counted from 1) of a paragraph, optionally check it contains the given text. uno::Reference getRun(uno::Reference xParagraph, int number, OUString content = OUString()) const { diff --git a/sw/qa/extras/rtfimport/data/fdo63023.rtf b/sw/qa/extras/rtfimport/data/fdo63023.rtf new file mode 100644 index 000000000000..c246dc634b10 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo63023.rtf @@ -0,0 +1,10 @@ +{\rtf1 +{\colortbl;\red0\green0\blue0;\red0\green0\blue128;\red92\green133\blue38;\red153\green153\blue255;\red220\green35\blue0;\red255\green255\blue153;\red128\green128\blue128;} +{\header +{\cf4\chcbpat6 +Yellow 2 Background with Violet Text} +\pard\par +} +body text +\pard\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 0b3d758c5fa5..950c95b31337 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -151,6 +151,7 @@ public: void testFdo37716(); void testFdo51916(); void testFdo61193(); + void testFdo63023(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -274,6 +275,7 @@ void Test::run() {"fdo37716.rtf", &Test::testFdo37716}, {"fdo51916.rtf", &Test::testFdo51916}, {"hello.rtf", &Test::testFdo61193}, + {"fdo63023.rtf", &Test::testFdo63023}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1233,6 +1235,13 @@ void Test::testFdo51916() // Complex nested table caused a crash. } +void Test::testFdo63023() +{ + uno::Reference xHeaderText = getProperty< uno::Reference >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText"); + // Back color was black (0) in the header, due to missing color table in the substream. + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFFFF99), getProperty(getRun(getParagraphOfText(1, xHeaderText), 1), "CharBackColor")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index f1268f546d50..8d88a27052b3 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -578,9 +578,14 @@ void RTFDocumentImpl::seek(sal_uInt32 nPos) sal_uInt32 RTFDocumentImpl::getColorTable(sal_uInt32 nIndex) { - if (nIndex < m_aColorTable.size()) - return m_aColorTable[nIndex]; - return 0; + if (!m_pSuperstream) + { + if (nIndex < m_aColorTable.size()) + return m_aColorTable[nIndex]; + return 0; + } + else + return m_pSuperstream->getColorTable(nIndex); } rtl_TextEncoding RTFDocumentImpl::getEncoding(sal_uInt32 nFontIndex) -- cgit v1.2.3