include/vcl/outdev.hxx            |    4 -
 solenv/clang-format/excludelist   |    1 
 vcl/Library_vcl.mk                |    1 
 vcl/qa/cppunit/outdev.cxx         |   69 +++++++++++++++++++++++++
 vcl/source/outdev/fill.cxx        |  103 ++++++++++++++++++++++++++++++++++++++
 vcl/source/outdev/outdevstate.cxx |   70 -------------------------
 6 files changed, 176 insertions(+), 72 deletions(-)

New commits:
commit ec52161eb5bd71ee5bcb1dd6cf0cb596da39fa48
Author:     Chris Sherlock <chris.sherloc...@gmail.com>
AuthorDate: Wed May 12 18:13:09 2021 +1000
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Aug 27 13:28:43 2021 +0200

    vcl: move OutputDevice fill functions to fill.cxx
    
    Add unit test for SetFillColor(), IsFillColor() and GetFillColor().
    
    Change-Id: I64b3b15d6c6a0062af716ecc02d0414ae8a9f134
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115461
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index b529763099ca..7d4a7e533356 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -506,8 +506,8 @@ public:
 
     void                        SetFillColor();
     void                        SetFillColor( const Color& rColor );
-    const Color&                GetFillColor() const { return maFillColor; }
-    bool                        IsFillColor() const { return mbFillColor; }
+    const Color&                GetFillColor() const;
+    bool                        IsFillColor() const;
 
     void                        SetBackground();
     void                        SetBackground( const Wallpaper& rBackground );
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 7cf7ea89c1f2..51d61da54d09 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -15032,6 +15032,7 @@ vcl/source/outdev/background.cxx
 vcl/source/outdev/bitmap.cxx
 vcl/source/outdev/clipping.cxx
 vcl/source/outdev/curvedshapes.cxx
+vcl/source/outdev/fill.cxx
 vcl/source/outdev/font.cxx
 vcl/source/outdev/gradient.cxx
 vcl/source/outdev/hatch.cxx
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a19c23b7b926..e7ed402ef0d8 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -216,6 +216,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/outdev/outdev \
     vcl/source/outdev/outdevstate \
     vcl/source/outdev/clipping \
+    vcl/source/outdev/fill \
     vcl/source/outdev/polygon \
     vcl/source/outdev/transparent \
     vcl/source/outdev/mask \
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index e9d9924a2ab8..ed84ae7ac456 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -45,6 +45,9 @@ public:
     void testDrawTransformedBitmapExFlip();
     void testRTL();
     void testRTLGuard();
+    void testDefaultFillColor();
+    void testTransparentFillColor();
+    void testFillColor();
 
     CPPUNIT_TEST_SUITE(VclOutdevTest);
     CPPUNIT_TEST(testVirtualDevice);
@@ -63,6 +66,9 @@ public:
     CPPUNIT_TEST(testDrawTransformedBitmapExFlip);
     CPPUNIT_TEST(testRTL);
     CPPUNIT_TEST(testRTLGuard);
+    CPPUNIT_TEST(testDefaultFillColor);
+    CPPUNIT_TEST(testTransparentFillColor);
+    CPPUNIT_TEST(testFillColor);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -460,6 +466,69 @@ void VclOutdevTest::testRTLGuard()
     CPPUNIT_ASSERT(aGuard.GetRenderContext()->IsRTLEnabled());
 }
 
+void VclOutdevTest::testDefaultFillColor()
+{
+    // Create a virtual device, and connect a metafile to it.
+    ScopedVclPtrInstance<VirtualDevice> pVDev;
+
+    GDIMetaFile aMtf;
+    aMtf.Record(pVDev.get());
+
+    CPPUNIT_ASSERT(pVDev->IsFillColor());
+    CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0xFF, 0xFF), pVDev->GetFillColor());
+
+    pVDev->SetFillColor();
+    CPPUNIT_ASSERT(!pVDev->IsFillColor());
+    CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, pVDev->GetFillColor());
+    MetaAction* pAction = aMtf.GetAction(0);
+    CPPUNIT_ASSERT_EQUAL(MetaActionType::FILLCOLOR, pAction->GetType());
+    auto pFillAction = static_cast<MetaFillColorAction*>(pAction);
+    const Color& rColor = pFillAction->GetColor();
+    CPPUNIT_ASSERT_EQUAL(Color(), rColor);
+}
+
+void VclOutdevTest::testTransparentFillColor()
+{
+    // Create a virtual device, and connect a metafile to it.
+    ScopedVclPtrInstance<VirtualDevice> pVDev;
+
+    GDIMetaFile aMtf;
+    aMtf.Record(pVDev.get());
+
+    CPPUNIT_ASSERT(pVDev->IsFillColor());
+    CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0xFF, 0xFF), pVDev->GetFillColor());
+
+    pVDev->SetFillColor(COL_TRANSPARENT);
+    CPPUNIT_ASSERT(!pVDev->IsFillColor());
+    CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, pVDev->GetFillColor());
+    MetaAction* pAction = aMtf.GetAction(0);
+    CPPUNIT_ASSERT_EQUAL(MetaActionType::FILLCOLOR, pAction->GetType());
+    auto pFillAction = static_cast<MetaFillColorAction*>(pAction);
+    const Color& rColor = pFillAction->GetColor();
+    CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, rColor);
+}
+
+void VclOutdevTest::testFillColor()
+{
+    // Create a virtual device, and connect a metafile to it.
+    ScopedVclPtrInstance<VirtualDevice> pVDev;
+
+    GDIMetaFile aMtf;
+    aMtf.Record(pVDev.get());
+
+    CPPUNIT_ASSERT(pVDev->IsFillColor());
+    CPPUNIT_ASSERT_EQUAL(Color(0xFF, 0xFF, 0xFF), pVDev->GetFillColor());
+
+    pVDev->SetFillColor(COL_RED);
+    CPPUNIT_ASSERT(pVDev->IsFillColor());
+    CPPUNIT_ASSERT_EQUAL(COL_RED, pVDev->GetFillColor());
+    MetaAction* pAction = aMtf.GetAction(0);
+    CPPUNIT_ASSERT_EQUAL(MetaActionType::FILLCOLOR, pAction->GetType());
+    auto pFillAction = static_cast<MetaFillColorAction*>(pAction);
+    const Color& rColor = pFillAction->GetColor();
+    CPPUNIT_ASSERT_EQUAL(COL_RED, rColor);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/outdev/fill.cxx b/vcl/source/outdev/fill.cxx
new file mode 100644
index 000000000000..ea00990cbece
--- /dev/null
+++ b/vcl/source/outdev/fill.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/debug.hxx>
+
+#include <vcl/metaact.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/virdev.hxx>
+
+#include <drawmode.hxx>
+#include <salgdi.hxx>
+
+Color const& OutputDevice::GetFillColor() const { return maFillColor; }
+
+bool OutputDevice::IsFillColor() const { return mbFillColor; }
+
+void OutputDevice::SetFillColor()
+{
+
+    if ( mpMetaFile )
+        mpMetaFile->AddAction( new MetaFillColorAction( Color(), false ) );
+
+    if ( mbFillColor )
+    {
+        mbInitFillColor = true;
+        mbFillColor = false;
+        maFillColor = COL_TRANSPARENT;
+    }
+
+    if( mpAlphaVDev )
+        mpAlphaVDev->SetFillColor();
+}
+
+void OutputDevice::SetFillColor( const Color& rColor )
+{
+    Color aColor(vcl::drawmode::GetFillColor(rColor, GetDrawMode(), 
GetSettings().GetStyleSettings()));
+
+    if ( mpMetaFile )
+        mpMetaFile->AddAction( new MetaFillColorAction( aColor, true ) );
+
+    if ( aColor.IsTransparent() )
+    {
+        if ( mbFillColor )
+        {
+            mbInitFillColor = true;
+            mbFillColor = false;
+            maFillColor = COL_TRANSPARENT;
+        }
+    }
+    else
+    {
+        if ( maFillColor != aColor )
+        {
+            mbInitFillColor = true;
+            mbFillColor = true;
+            maFillColor = aColor;
+        }
+    }
+
+    if( mpAlphaVDev )
+        mpAlphaVDev->SetFillColor( COL_BLACK );
+}
+
+void OutputDevice::InitFillColor()
+{
+    DBG_TESTSOLARMUTEX();
+
+    if( mbFillColor )
+    {
+        if( RasterOp::N0 == meRasterOp )
+            mpGraphics->SetROPFillColor( SalROPColor::N0 );
+        else if( RasterOp::N1 == meRasterOp )
+            mpGraphics->SetROPFillColor( SalROPColor::N1 );
+        else if( RasterOp::Invert == meRasterOp )
+            mpGraphics->SetROPFillColor( SalROPColor::Invert );
+        else
+            mpGraphics->SetFillColor( maFillColor );
+    }
+    else
+    {
+        mpGraphics->SetFillColor();
+    }
+
+    mbInitFillColor = false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/source/outdev/outdevstate.cxx 
b/vcl/source/outdev/outdevstate.cxx
index fa1af5ab576d..41ee775a84e6 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -285,54 +285,6 @@ void OutputDevice::SetRasterOp( RasterOp eRasterOp )
         mpAlphaVDev->SetRasterOp( eRasterOp );
 }
 
-
-void OutputDevice::SetFillColor()
-{
-
-    if ( mpMetaFile )
-        mpMetaFile->AddAction( new MetaFillColorAction( Color(), false ) );
-
-    if ( mbFillColor )
-    {
-        mbInitFillColor = true;
-        mbFillColor = false;
-        maFillColor = COL_TRANSPARENT;
-    }
-
-    if( mpAlphaVDev )
-        mpAlphaVDev->SetFillColor();
-}
-
-void OutputDevice::SetFillColor( const Color& rColor )
-{
-    Color aColor(vcl::drawmode::GetFillColor(rColor, GetDrawMode(), 
GetSettings().GetStyleSettings()));
-
-    if ( mpMetaFile )
-        mpMetaFile->AddAction( new MetaFillColorAction( aColor, true ) );
-
-    if ( aColor.IsTransparent() )
-    {
-        if ( mbFillColor )
-        {
-            mbInitFillColor = true;
-            mbFillColor = false;
-            maFillColor = COL_TRANSPARENT;
-        }
-    }
-    else
-    {
-        if ( maFillColor != aColor )
-        {
-            mbInitFillColor = true;
-            mbFillColor = true;
-            maFillColor = aColor;
-        }
-    }
-
-    if( mpAlphaVDev )
-        mpAlphaVDev->SetFillColor( COL_BLACK );
-}
-
 void OutputDevice::SetLineColor()
 {
 
@@ -449,26 +401,4 @@ void OutputDevice::InitLineColor()
     mbInitLineColor = false;
 }
 
-
-void OutputDevice::InitFillColor()
-{
-    DBG_TESTSOLARMUTEX();
-
-    if( mbFillColor )
-    {
-        if( RasterOp::N0 == meRasterOp )
-            mpGraphics->SetROPFillColor( SalROPColor::N0 );
-        else if( RasterOp::N1 == meRasterOp )
-            mpGraphics->SetROPFillColor( SalROPColor::N1 );
-        else if( RasterOp::Invert == meRasterOp )
-            mpGraphics->SetROPFillColor( SalROPColor::Invert );
-        else
-            mpGraphics->SetFillColor( maFillColor );
-    }
-    else
-        mpGraphics->SetFillColor();
-
-    mbInitFillColor = false;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to