diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-04-18 17:07:22 +0200 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2013-05-06 17:48:45 +0200 |
commit | 6bf2ac6b88d4fd4f1cfe420d7a9c78dc0ab2b90b (patch) | |
tree | c0984093a5912d93f3297ceb9d3df4d302931ab0 /sw | |
parent | e238fdf9c495c0f1d5917cbc26c95ade42732835 (diff) |
fdo#63023 incorrect RTF background color in header
(cherry picked from commits 3d4fef85d05269e613316a7af6245f05d207d76e and
08dc5de900b2e5cca9d9443fc5d4ea7756842af9)
Change-Id: I33f5c8a856206860ac9cdb23dd6b5222cb785bf7
Reviewed-on: https://gerrit.libreoffice.org/3461
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/inc/swmodeltestbase.hxx | 34 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo63023.rtf | 10 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 9 |
3 files changed, 47 insertions, 6 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index ae0af3db2daf..a4e821329aac 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -29,6 +29,8 @@ #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/table/XCell.hpp> #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> @@ -189,19 +191,39 @@ protected: } // Get paragraph (counted from 1), optionally check it contains the given text. - uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const + uno::Reference<text::XTextContent> getParagraphOrTable(int number, uno::Reference<text::XText> xText = uno::Reference<text::XText>()) const { - uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> paraEnumAccess; + if (xText.is()) + paraEnumAccess.set(xText, uno::UNO_QUERY); + else + { + uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); + paraEnumAccess.set(textDocument->getText(), uno::UNO_QUERY); + } uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration(); for( int i = 1; i < number; ++i ) paraEnum->nextElement(); - uno::Reference< text::XTextRange > paragraph( paraEnum->nextElement(), uno::UNO_QUERY ); + uno::Reference< text::XTextContent> const xElem(paraEnum->nextElement(), + uno::UNO_QUERY_THROW); + return xElem; + } + + uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const + { + uno::Reference<text::XTextRange> const xParagraph( + getParagraphOrTable(number), uno::UNO_QUERY_THROW); if( !content.isEmpty()) - CPPUNIT_ASSERT_EQUAL( content, paragraph->getString()); - return paragraph; + CPPUNIT_ASSERT_EQUAL( content, xParagraph->getString()); + return xParagraph; + } + + uno::Reference<text::XTextRange> getParagraphOfText(int number, uno::Reference<text::XText> xText) const + { + uno::Reference<text::XTextRange> 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. 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 246358eb4c89..c02dac5db5be 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -146,6 +146,7 @@ public: void testFdo37716(); void testFdo51916(); void testFdo61193(); + void testFdo63023(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -262,6 +263,7 @@ void Test::run() {"fdo37716.rtf", &Test::testFdo37716}, {"fdo51916.rtf", &Test::testFdo51916}, {"hello.rtf", &Test::testFdo61193}, + {"fdo63023.rtf", &Test::testFdo63023}, }; for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) { @@ -1205,6 +1207,13 @@ void Test::testFdo51916() // Complex nested table caused a crash. } +void Test::testFdo63023() +{ + uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(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<sal_Int32>(getRun(getParagraphOfText(1, xHeaderText), 1), "CharBackColor")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); |