summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2021-08-25 15:24:13 +1000
committerMike Kaganski <mike.kaganski@collabora.com>2021-09-02 08:18:51 +0200
commit7ded01efaec8171a204a255395767432bab881b5 (patch)
tree64c1c754d7b7ff31044beb685bdf8b735e3e8477 /vcl
parent2e5dad443a30055d93dbcb3bf9cac906e80b2e25 (diff)
vcl: move OutputDevice line functions to line.cxx
Add unit tests for SetLineColor(), IsLineColor() and GetLineColor() Change-Id: I54a6e191f9c821c258527ebf075d88ff60cc9471 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121015 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/outdev.cxx69
-rw-r--r--vcl/source/outdev/line.cxx87
-rw-r--r--vcl/source/outdev/outdevstate.cxx70
3 files changed, 148 insertions, 78 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index d9aa34a0250c..f5d814fe91fb 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -48,6 +48,9 @@ public:
void testDefaultFillColor();
void testTransparentFillColor();
void testFillColor();
+ void testDefaultLineColor();
+ void testTransparentLineColor();
+ void testLineColor();
void testSystemTextColor();
void testShouldDrawWavePixelAsRect();
void testGetWaveLineSize();
@@ -72,6 +75,9 @@ public:
CPPUNIT_TEST(testDefaultFillColor);
CPPUNIT_TEST(testTransparentFillColor);
CPPUNIT_TEST(testFillColor);
+ CPPUNIT_TEST(testDefaultLineColor);
+ CPPUNIT_TEST(testTransparentLineColor);
+ CPPUNIT_TEST(testLineColor);
CPPUNIT_TEST(testSystemTextColor);
CPPUNIT_TEST(testShouldDrawWavePixelAsRect);
CPPUNIT_TEST(testGetWaveLineSize);
@@ -535,6 +541,69 @@ void VclOutdevTest::testFillColor()
CPPUNIT_ASSERT_EQUAL(COL_RED, rColor);
}
+void VclOutdevTest::testDefaultLineColor()
+{
+ // Create a virtual device, and connect a metafile to it.
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+
+ GDIMetaFile aMtf;
+ aMtf.Record(pVDev.get());
+
+ CPPUNIT_ASSERT(pVDev->IsLineColor());
+ CPPUNIT_ASSERT_EQUAL(COL_BLACK, pVDev->GetLineColor());
+
+ pVDev->SetLineColor();
+ CPPUNIT_ASSERT(!pVDev->IsLineColor());
+ CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, pVDev->GetLineColor());
+ MetaAction* pAction = aMtf.GetAction(0);
+ CPPUNIT_ASSERT_EQUAL(MetaActionType::LINECOLOR, pAction->GetType());
+ auto pLineAction = static_cast<MetaLineColorAction*>(pAction);
+ const Color& rColor = pLineAction->GetColor();
+ CPPUNIT_ASSERT_EQUAL(Color(), rColor);
+}
+
+void VclOutdevTest::testTransparentLineColor()
+{
+ // Create a virtual device, and connect a metafile to it.
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+
+ GDIMetaFile aMtf;
+ aMtf.Record(pVDev.get());
+
+ CPPUNIT_ASSERT(pVDev->IsLineColor());
+ CPPUNIT_ASSERT_EQUAL(COL_BLACK, pVDev->GetLineColor());
+
+ pVDev->SetLineColor(COL_TRANSPARENT);
+ CPPUNIT_ASSERT(!pVDev->IsLineColor());
+ CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, pVDev->GetLineColor());
+ MetaAction* pAction = aMtf.GetAction(0);
+ CPPUNIT_ASSERT_EQUAL(MetaActionType::LINECOLOR, pAction->GetType());
+ auto pLineAction = static_cast<MetaLineColorAction*>(pAction);
+ const Color& rColor = pLineAction->GetColor();
+ CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, rColor);
+}
+
+void VclOutdevTest::testLineColor()
+{
+ // Create a virtual device, and connect a metafile to it.
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+
+ GDIMetaFile aMtf;
+ aMtf.Record(pVDev.get());
+
+ CPPUNIT_ASSERT(pVDev->IsLineColor());
+ CPPUNIT_ASSERT_EQUAL(COL_BLACK, pVDev->GetLineColor());
+
+ pVDev->SetLineColor(COL_RED);
+ CPPUNIT_ASSERT(pVDev->IsLineColor());
+ CPPUNIT_ASSERT_EQUAL(COL_RED, pVDev->GetLineColor());
+ MetaAction* pAction = aMtf.GetAction(0);
+ CPPUNIT_ASSERT_EQUAL(MetaActionType::LINECOLOR, pAction->GetType());
+ auto pLineAction = static_cast<MetaLineColorAction*>(pAction);
+ const Color& rColor = pLineAction->GetColor();
+ CPPUNIT_ASSERT_EQUAL(COL_RED, rColor);
+}
+
void VclOutdevTest::testSystemTextColor()
{
{
diff --git a/vcl/source/outdev/line.cxx b/vcl/source/outdev/line.cxx
index 479705082265..9c1b5749f336 100644
--- a/vcl/source/outdev/line.cxx
+++ b/vcl/source/outdev/line.cxx
@@ -17,21 +17,92 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <cassert>
-#include <numeric>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dlinegeometry.hxx>
+#include <tools/debug.hxx>
-#include <vcl/gdimtf.hxx>
#include <vcl/lineinfo.hxx>
#include <vcl/metaact.hxx>
-#include <vcl/outdev.hxx>
#include <vcl/virdev.hxx>
+#include <drawmode.hxx>
#include <salgdi.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <basegfx/polygon/b2dlinegeometry.hxx>
+#include <cassert>
+#include <numeric>
+
+void OutputDevice::SetLineColor()
+{
+
+ if ( mpMetaFile )
+ mpMetaFile->AddAction( new MetaLineColorAction( Color(), false ) );
+
+ if ( mbLineColor )
+ {
+ mbInitLineColor = true;
+ mbLineColor = false;
+ maLineColor = COL_TRANSPARENT;
+ }
+
+ if( mpAlphaVDev )
+ mpAlphaVDev->SetLineColor();
+}
+
+void OutputDevice::SetLineColor( const Color& rColor )
+{
+
+ Color aColor = vcl::drawmode::GetLineColor(rColor, GetDrawMode(), GetSettings().GetStyleSettings());
+
+ if( mpMetaFile )
+ mpMetaFile->AddAction( new MetaLineColorAction( aColor, true ) );
+
+ if( aColor.IsTransparent() )
+ {
+ if ( mbLineColor )
+ {
+ mbInitLineColor = true;
+ mbLineColor = false;
+ maLineColor = COL_TRANSPARENT;
+ }
+ }
+ else
+ {
+ if( maLineColor != aColor )
+ {
+ mbInitLineColor = true;
+ mbLineColor = true;
+ maLineColor = aColor;
+ }
+ }
+
+ if( mpAlphaVDev )
+ mpAlphaVDev->SetLineColor( COL_BLACK );
+}
+
+void OutputDevice::InitLineColor()
+{
+ DBG_TESTSOLARMUTEX();
+
+ if( mbLineColor )
+ {
+ if( RasterOp::N0 == meRasterOp )
+ mpGraphics->SetROPLineColor( SalROPColor::N0 );
+ else if( RasterOp::N1 == meRasterOp )
+ mpGraphics->SetROPLineColor( SalROPColor::N1 );
+ else if( RasterOp::Invert == meRasterOp )
+ mpGraphics->SetROPLineColor( SalROPColor::Invert );
+ else
+ mpGraphics->SetLineColor( maLineColor );
+ }
+ else
+ {
+ mpGraphics->SetLineColor();
+ }
+
+ mbInitLineColor = false;
+}
void OutputDevice::DrawLine( const Point& rStartPt, const Point& rEndPt,
const LineInfo& rLineInfo )
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index 0568f2d3c577..a859f29faecb 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -277,54 +277,6 @@ void OutputDevice::SetRasterOp( RasterOp eRasterOp )
mpAlphaVDev->SetRasterOp( eRasterOp );
}
-void OutputDevice::SetLineColor()
-{
-
- if ( mpMetaFile )
- mpMetaFile->AddAction( new MetaLineColorAction( Color(), false ) );
-
- if ( mbLineColor )
- {
- mbInitLineColor = true;
- mbLineColor = false;
- maLineColor = COL_TRANSPARENT;
- }
-
- if( mpAlphaVDev )
- mpAlphaVDev->SetLineColor();
-}
-
-void OutputDevice::SetLineColor( const Color& rColor )
-{
-
- Color aColor = vcl::drawmode::GetLineColor(rColor, GetDrawMode(), GetSettings().GetStyleSettings());
-
- if( mpMetaFile )
- mpMetaFile->AddAction( new MetaLineColorAction( aColor, true ) );
-
- if( aColor.IsTransparent() )
- {
- if ( mbLineColor )
- {
- mbInitLineColor = true;
- mbLineColor = false;
- maLineColor = COL_TRANSPARENT;
- }
- }
- else
- {
- if( maLineColor != aColor )
- {
- mbInitLineColor = true;
- mbLineColor = true;
- maLineColor = aColor;
- }
- }
-
- if( mpAlphaVDev )
- mpAlphaVDev->SetLineColor( COL_BLACK );
-}
-
void OutputDevice::SetFont( const vcl::Font& rNewFont )
{
vcl::Font aFont = vcl::drawmode::GetFont(rNewFont, GetDrawMode(), GetSettings().GetStyleSettings());
@@ -371,26 +323,4 @@ void OutputDevice::SetFont( const vcl::Font& rNewFont )
mpAlphaVDev->SetFont( aFont );
}
-
-void OutputDevice::InitLineColor()
-{
- DBG_TESTSOLARMUTEX();
-
- if( mbLineColor )
- {
- if( RasterOp::N0 == meRasterOp )
- mpGraphics->SetROPLineColor( SalROPColor::N0 );
- else if( RasterOp::N1 == meRasterOp )
- mpGraphics->SetROPLineColor( SalROPColor::N1 );
- else if( RasterOp::Invert == meRasterOp )
- mpGraphics->SetROPLineColor( SalROPColor::Invert );
- else
- mpGraphics->SetLineColor( maLineColor );
- }
- else
- mpGraphics->SetLineColor();
-
- mbInitLineColor = false;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */