[Libreoffice-commits] core.git: basctl/source filter/source include/svx include/vcl starmath/source svx/source toolkit/source vcl/qa vcl/source

Chris Sherlock (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 8 11:04:12 UTC 2019


 basctl/source/basicide/baside2.hxx   |    2 +-
 basctl/source/basicide/baside2b.cxx  |    2 +-
 filter/source/msfilter/mstoolbar.cxx |    2 +-
 include/svx/dialcontrol.hxx          |    2 +-
 include/vcl/outdev.hxx               |    1 +
 include/vcl/print.hxx                |    2 ++
 include/vcl/window.hxx               |    2 ++
 starmath/source/tmpdevice.cxx        |    4 +---
 svx/source/dialog/dialcontrol.cxx    |    2 +-
 toolkit/source/awt/vclxwindow.cxx    |    2 +-
 vcl/qa/cppunit/outdev.cxx            |   22 ++++++++++++++++++++++
 vcl/source/outdev/wallpaper.cxx      |    5 +++++
 vcl/source/window/paint.cxx          |    2 +-
 vcl/source/window/window.cxx         |    7 ++++++-
 14 files changed, 46 insertions(+), 11 deletions(-)

New commits:
commit 41dbf08b99c259b387e95e9143b88b508724d945
Author:     Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Sat Jul 13 13:10:20 2019 +1000
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Aug 8 13:03:01 2019 +0200

    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 at gmail.com>

diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 7fd23faa304f..dadcf639c666 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -418,7 +418,7 @@ public:
 public:
     void BasicAddWatch (OUString const&);
     void BasicRemoveWatch ();
-    Color const & GetBackgroundColor () const { return aSyntaxColors.GetBackgroundColor(); }
+    Color const & GetSyntaxBackgroundColor () const { return aSyntaxColors.GetBackgroundColor(); }
     Color const & GetFontColor () const { return aSyntaxColors.GetFontColor(); }
     Color const & GetSyntaxColor (TokenType eType) const { return aSyntaxColors.GetColor(eType); }
 
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 4421e78cb6ff..57c18788319f 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -235,7 +235,7 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
     bDelayHighlight(true),
     pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this))
 {
-    SetBackground(Wallpaper(rModulWindow.GetLayout().GetBackgroundColor()));
+    SetBackground(Wallpaper(rModulWindow.GetLayout().GetSyntaxBackgroundColor()));
     SetPointer( PointerStyle::Text );
     SetHelpId( HID_BASICIDE_EDITORWINDOW );
 
diff --git a/filter/source/msfilter/mstoolbar.cxx b/filter/source/msfilter/mstoolbar.cxx
index a17baaff276b..d8ddc076caec 100644
--- a/filter/source/msfilter/mstoolbar.cxx
+++ b/filter/source/msfilter/mstoolbar.cxx
@@ -65,7 +65,7 @@ void CustomToolBarImportHelper::applyIcons()
         sal_uInt16 nColor = ui::ImageType::COLOR_NORMAL;
 
         vcl::Window* topwin = Application::GetActiveTopWindow();
-        if ( topwin != nullptr && topwin->GetDisplayBackground().GetColor().IsDark() )
+        if ( topwin != nullptr && topwin->GetBackgroundColor().IsDark() )
                 nColor = css::ui::ImageType::COLOR_HIGHCONTRAST;
 
         ScaleImage( images[ 0 ], 16 );
diff --git a/include/svx/dialcontrol.hxx b/include/svx/dialcontrol.hxx
index c15e0ae92e3c..53976b86c606 100644
--- a/include/svx/dialcontrol.hxx
+++ b/include/svx/dialcontrol.hxx
@@ -43,9 +43,9 @@ public:
     void                DrawBackground( const Size& rSize, bool bEnabled );
     void                DrawBackground();
     void                DrawElements( const OUString& rText, sal_Int32 nAngle );
+    Color               GetBackgroundColor() const override;
 
 private:
-    const Color&        GetBackgroundColor() const;
     const Color&        GetTextColor() const;
     const Color&        GetScaleLineColor() const;
     const Color&        GetButtonLineColor() const;
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 8d385e003dd2..cac19b490fa3 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -629,6 +629,7 @@ public:
                                                const Point& rPos, const Size& rSize, const Size& rBackgroundSize) const;
 
     const Wallpaper&            GetBackground() const { return maBackground; }
+    virtual Color               GetBackgroundColor() const;
     bool                        IsBackground() const { return mbBackground; }
 
     void                        SetFont( const vcl::Font& rNewFont );
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 957d97b49a61..854c08d96660 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -289,6 +289,8 @@ public:
                                       PrinterSetupMode eMode = PrinterSetupMode::DocumentGlobal);
     bool                        SetPrinterProps( const Printer* pPrinter );
 
+    Color                       GetBackgroundColor() const override { return COL_WHITE; }
+
     /** SetPrinterOptions is used internally only now
 
         in earlier times it was used only to set the options loaded directly from the configuration
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index ce8669895fe5..a93b1da700a8 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -764,6 +764,8 @@ public:
     ::OutputDevice const*               GetOutDev() const;
     ::OutputDevice*                     GetOutDev();
 
+    Color                               GetBackgroundColor() const override;
+
     virtual void                        EnableRTL ( bool bEnable = true ) override;
     virtual void                        MouseMove( const MouseEvent& rMEvt );
     virtual void                        MouseButtonDown( const MouseEvent& rMEvt );
diff --git a/starmath/source/tmpdevice.cxx b/starmath/source/tmpdevice.cxx
index d69dc0be2c89..778d9196ad35 100644
--- a/starmath/source/tmpdevice.cxx
+++ b/starmath/source/tmpdevice.cxx
@@ -54,9 +54,7 @@ Color SmTmpDevice::Impl_GetColor( const Color& rColor )
             nNewCol = COL_BLACK;
         else
         {
-            Color aBgCol( rOutDev.GetBackground().GetColor() );
-            if (OUTDEV_WINDOW == rOutDev.GetOutDevType())
-                aBgCol = static_cast<vcl::Window &>(rOutDev).GetDisplayBackground().GetColor();
+            Color aBgCol(rOutDev.GetBackgroundColor());
 
             nNewCol = SM_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor;
 
diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx
index 2d5062f4e441..50f65ed2a0be 100644
--- a/svx/source/dialog/dialcontrol.cxx
+++ b/svx/source/dialog/dialcontrol.cxx
@@ -111,7 +111,7 @@ void DialControlBmp::DrawElements( const OUString& rText, sal_Int32 nAngle )
     DrawEllipse( tools::Rectangle( nX - nSize, nY - nSize, nX + nSize, nY + nSize ) );
 }
 
-const Color& DialControlBmp::GetBackgroundColor() const
+Color DialControlBmp::GetBackgroundColor() const
 {
     return GetSettings().GetStyleSettings().GetDialogColor();
 }
diff --git a/toolkit/source/awt/vclxwindow.cxx b/toolkit/source/awt/vclxwindow.cxx
index 04c8cffc2a2b..d632fc13036b 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -2012,7 +2012,7 @@ css::uno::Any VCLXWindow::getProperty( const OUString& PropertyName )
                 aProp <<= GetWindow()->GetControlBackground();
             break;
             case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR:
-                aProp <<= GetWindow()->GetDisplayBackground().GetColor();
+                aProp <<= GetWindow()->GetBackgroundColor();
             break;
             case BASEPROPERTY_FONTRELIEF:
                 aProp <<= static_cast<sal_Int16>(GetWindow()->GetControlFont().GetRelief());
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 )
     {


More information about the Libreoffice-commits mailing list