diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2019-07-13 13:10:20 +1000 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-08-08 13:03:01 +0200 |
commit | 41dbf08b99c259b387e95e9143b88b508724d945 (patch) | |
tree | 95809c129da81a78d484836d32195effe780221b /vcl | |
parent | 7e88bc73030c7708f1a8b47491070aae5b73aac1 (diff) |
tdf#74702: use OutputDevice::GetBackgroundColor()
Apply the Liskov substitution principle to OutputDevice::GetBackgroundColor().
This helps in SmTmpDevice::Impl_GetColor() because it no longer needs to know
about what type of OutputDevice it is calling to get the background color.
This forced a rename of basctl::ModulWindowLayout::GetBackgroundColor() to be
GetSyntaxBackgroundColor(), but this is a happy coincidence as it makes the
function intent clearer anyway.
Change-Id: I11298a63cb01c187f3a8a4a2c9e90eacda6c3e6b
Reviewed-on: https://gerrit.libreoffice.org/75521
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/outdev.cxx | 22 | ||||
-rw-r--r-- | vcl/source/outdev/wallpaper.cxx | 5 | ||||
-rw-r--r-- | vcl/source/window/paint.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 7 |
4 files changed, 34 insertions, 2 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 45bae92ca58c..b91248078ab8 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -10,6 +10,8 @@ #include <test/bootstrapfixture.hxx> #include <vcl/virdev.hxx> +#include <vcl/print.hxx> +#include <vcl/window.hxx> #include <vcl/bitmapaccess.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> @@ -21,18 +23,38 @@ public: void testVirtualDevice(); void testUseAfterDispose(); + void testPrinterBackgroundColor(); + void testWindowBackgroundColor(); CPPUNIT_TEST_SUITE(VclOutdevTest); CPPUNIT_TEST(testVirtualDevice); CPPUNIT_TEST(testUseAfterDispose); + CPPUNIT_TEST(testPrinterBackgroundColor); + CPPUNIT_TEST(testWindowBackgroundColor); CPPUNIT_TEST_SUITE_END(); }; +void VclOutdevTest::testPrinterBackgroundColor() +{ + ScopedVclPtrInstance<Printer> pPrinter; + CPPUNIT_ASSERT_EQUAL(pPrinter->GetBackgroundColor(), COL_WHITE); +} + +void VclOutdevTest::testWindowBackgroundColor() +{ + ScopedVclPtrInstance<vcl::Window> pWindow(nullptr, WB_APP | WB_STDWORK); + pWindow->SetBackground(Wallpaper(COL_WHITE)); + CPPUNIT_ASSERT_EQUAL(pWindow->GetBackgroundColor(), COL_WHITE); +} + void VclOutdevTest::testVirtualDevice() { ScopedVclPtrInstance< VirtualDevice > pVDev; pVDev->SetOutputSizePixel(Size(32,32)); pVDev->SetBackground(Wallpaper(COL_WHITE)); + + CPPUNIT_ASSERT_EQUAL(pVDev->GetBackgroundColor(), COL_WHITE); + pVDev->Erase(); pVDev->DrawPixel(Point(1,2),COL_BLUE); pVDev->DrawPixel(Point(31,30),COL_RED); diff --git a/vcl/source/outdev/wallpaper.cxx b/vcl/source/outdev/wallpaper.cxx index 71cd67017bcd..d2a5f1003940 100644 --- a/vcl/source/outdev/wallpaper.cxx +++ b/vcl/source/outdev/wallpaper.cxx @@ -27,6 +27,11 @@ #include <wall2.hxx> +Color OutputDevice::GetBackgroundColor() const +{ + return GetBackground().GetColor(); +} + void OutputDevice::DrawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWallpaper ) { diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx index 34e76fa6c316..8bdbc5a3b79f 100644 --- a/vcl/source/window/paint.cxx +++ b/vcl/source/window/paint.cxx @@ -333,7 +333,7 @@ void RenderTools::DrawSelectionBackground(vcl::RenderContext& rRenderContext, vc bool bBright = ( rStyles.GetFaceColor() == COL_WHITE ); int c1 = aSelectionBorderColor.GetLuminance(); - int c2 = rWindow.GetDisplayBackground().GetColor().GetLuminance(); + int c2 = rWindow.GetBackgroundColor().GetLuminance(); if (!bDark && !bBright && std::abs(c2 - c1) < (pPaintColor ? 40 : 75)) { diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 88ea0087a1f8..96b066ee23a0 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -585,6 +585,11 @@ Window::~Window() return this; } +Color Window::GetBackgroundColor() const +{ + return GetDisplayBackground().GetColor(); +} + } /* namespace vcl */ WindowImpl::WindowImpl( WindowType nType ) @@ -3320,7 +3325,7 @@ void Window::DrawSelectionBackground( const tools::Rectangle& rRect, bool bBright = ( rStyles.GetFaceColor() == COL_WHITE ); int c1 = aSelectionBorderCol.GetLuminance(); - int c2 = GetDisplayBackground().GetColor().GetLuminance(); + int c2 = GetBackgroundColor().GetLuminance(); if( !bDark && !bBright && abs( c2-c1 ) < 75 ) { |