From c438141318a79350ef26a37b59fd7328e46275b2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 10 Aug 2015 09:17:42 +0200 Subject: tdf#87922 testcase Change-Id: I71afd42a1825b44e885485051e56a1c1fb81b0c4 Reviewed-on: https://gerrit.libreoffice.org/17620 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/qa/extras/uiwriter/data/tdf87922.odt | Bin 0 -> 8866 bytes sw/qa/extras/uiwriter/uiwriter.cxx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 sw/qa/extras/uiwriter/data/tdf87922.odt diff --git a/sw/qa/extras/uiwriter/data/tdf87922.odt b/sw/qa/extras/uiwriter/data/tdf87922.odt new file mode 100644 index 000000000000..b0560f180a28 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf87922.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 233837cc5829..cedc59654a0e 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -74,6 +74,8 @@ #include "com/sun/star/text/TextMarkupType.hpp" #include #include +#include +#include #include #include #include @@ -151,6 +153,7 @@ public: void testTdf89954(); void testTdf89720(); void testTdf88986(); + void testTdf87922(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -218,6 +221,7 @@ public: CPPUNIT_TEST(testTdf89954); CPPUNIT_TEST(testTdf89720); CPPUNIT_TEST(testTdf88986); + CPPUNIT_TEST(testTdf87922); CPPUNIT_TEST_SUITE_END(); private: @@ -2223,6 +2227,32 @@ void SwUiWriterTest::testTdf88986() CPPUNIT_ASSERT(aSet.HasItem(SID_COLOR_TABLE)); } +void SwUiWriterTest::testTdf87922() +{ + // Create an SwDrawTextInfo. + SwDoc* pDoc = createDoc("tdf87922.odt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + SwScriptInfo* pScriptInfo = 0; + // Get access to the single paragraph in the document. + SwNodeIndex aNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1); + const OUString& rText = aNodeIndex.GetNode().GetTextNode()->GetText(); + sal_Int32 nIndex = 0; + sal_Int32 nLength = rText.getLength(); + SwDrawTextInfo aDrawTextInfo(pWrtShell, *pWrtShell->GetOut(), pScriptInfo, rText, nIndex, nLength); + // Root -> page -> body -> text. + SwTextFrm* pTextFrm = static_cast(pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()); + aDrawTextInfo.SetFrm(pTextFrm); + + // If no color background color is found, assume white. + Color* pColor = sw::GetActiveRetoucheColor(); + *pColor = Color(COL_WHITE); + + // Make sure that automatic color on black background is white, not black. + vcl::Font aFont; + aDrawTextInfo.ApplyAutoColor(&aFont); + CPPUNIT_ASSERT_EQUAL(COL_WHITE, aFont.GetColor().GetColor()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit v1.2.3