dbaccess/source/ui/browser/dataview.cxx |    2 +-
 editeng/source/editeng/impedit3.cxx     |    4 ++--
 svx/source/dialog/fntctrl.cxx           |    8 +++++++-
 svx/source/dialog/pagectrl.cxx          |    2 +-
 sw/qa/extras/uiwriter/uiwriter2.cxx     |   10 +++++++---
 sw/source/core/text/frmpaint.cxx        |    4 ++--
 sw/source/core/txtnode/fntcache.cxx     |    9 +++------
 vcl/qa/cppunit/outdev.cxx               |    2 +-
 vcl/source/filter/imet/ios2met.cxx      |    7 ++++++-
 vcl/source/filter/ipict/ipict.cxx       |    8 ++++----
 vcl/source/outdev/line.cxx              |    6 ++++++
 vcl/source/treelist/svlbitm.cxx         |    4 ++--
 12 files changed, 42 insertions(+), 24 deletions(-)

New commits:
commit 20667acbca5df17771a3581632a672d5db4e751b
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jul 2 12:59:40 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Thu Jul 3 09:47:52 2025 +0200

    tdf#166842 do not use LineColor==COL_TRANSPARENT...
    
    .. on OutputDevice if that OutputDevice does not support alpha
    
    Change-Id: Ic912237eda97beec6276c6c837f3b95fe92aea50
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187275
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/dbaccess/source/ui/browser/dataview.cxx 
b/dbaccess/source/ui/browser/dataview.cxx
index 23657f196839..11f9a91df015 100644
--- a/dbaccess/source/ui/browser/dataview.cxx
+++ b/dbaccess/source/ui/browser/dataview.cxx
@@ -69,7 +69,7 @@ namespace dbaui
         // draw the background
         {
             rRenderContext.Push(vcl::PushFlags::LINECOLOR | 
vcl::PushFlags::FILLCOLOR);
-            rRenderContext.SetLineColor(COL_TRANSPARENT);
+            rRenderContext.SetLineColor();
             
rRenderContext.SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
             rRenderContext.DrawRect(_rRect);
             rRenderContext.Pop();
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index d4eda028ac23..ae32cd98cd61 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -4117,13 +4117,13 @@ void ImpEditEngine::PaintOrStrip( OutputDevice& 
rOutDev, tools::Rectangle aClipR
                                                 
adjustYDirectionAware(aRedLineTmpPos, -nShift);
                                             }
                                         }
-                                        Color aOldColor( 
rOutDev.GetLineColor() );
+                                        
rOutDev.Push(vcl::PushFlags::LINECOLOR);
                                         rOutDev.SetLineColor( 
GetColorConfig().GetColorValue( svtools::SPELL ).nColor );
                                         lcl_DrawRedLines(rOutDev, 
aTmpFont.GetFontSize().Height(), aRedLineTmpPos,
                                                          
static_cast<size_t>(nIndex), static_cast<size_t>(nIndex) + 
rTextPortion.GetLen(),
                                                          pDXArray, 
rParaPortion.GetNode()->GetWrongList(), nOrientation,
                                                          aOrigin, 
IsEffectivelyVertical(), rTextPortion.IsRightToLeft());
-                                        rOutDev.SetLineColor( aOldColor );
+                                        rOutDev.Pop();
                                     }
                                 }
 
diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
index ad9c5fc62c49..ad918212c15b 100644
--- a/svx/source/dialog/fntctrl.cxx
+++ b/svx/source/dialog/fntctrl.cxx
@@ -765,7 +765,13 @@ void SvxFontPrevWindow::Paint(vcl::RenderContext& 
rRenderContext, const tools::R
 
             Color aLineCol = rRenderContext.GetLineColor();
 
-            rRenderContext.SetLineColor(rFont.GetColor());
+            if (rFont.GetColor() == COL_TRANSPARENT)
+                rRenderContext.SetLineColor();
+            else if (!rRenderContext.HasAlpha() && 
rFont.GetColor().IsTransparent())
+                rRenderContext.SetLineColor(::Color(rFont.GetColor().GetRed(), 
rFont.GetColor().GetGreen(),
+                    rFont.GetColor().GetBlue()));
+            else
+                rRenderContext.SetLineColor(rFont.GetColor());
             rRenderContext.DrawLine(Point(0,  nY), Point(nX, nY));
             rRenderContext.DrawLine(Point(nX + aTxtSize.Width(), nY), 
Point(aLogSize.Width(), nY));
             rRenderContext.SetLineColor(aLineCol);
diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx
index 1bf5bc0b395b..2cadfae290ee 100644
--- a/svx/source/dialog/pagectrl.cxx
+++ b/svx/source/dialog/pagectrl.cxx
@@ -133,7 +133,7 @@ void SvxPageWindow::DrawPage(vcl::RenderContext& 
rRenderContext, const Point& rO
     // background
     if (!bSecond || bResetBackground)
     {
-        rRenderContext.SetLineColor(COL_TRANSPARENT);
+        rRenderContext.SetLineColor();
         rRenderContext.SetFillColor(rDlgColor);
         Size winSize(rRenderContext.GetOutputSize());
         rRenderContext.DrawRect(tools::Rectangle(Point(0,0), winSize));
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 21d00ef6d6c5..88ed33a31cd1 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -2906,7 +2906,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137771)
     CPPUNIT_ASSERT(pXmlDoc);
 
     // This would be 5 without the new vertical redline mark
-    assertXPath(pXmlDoc, "/metafile/push/push/push/line", 6);
+    assertXPath(pXmlDoc, "/metafile/push/push/push/push/line", 6);
 
     // This was the content of the next <text> (missing deletion on margin)
     // or only the first character of the deleted character sequence
@@ -2948,12 +2948,16 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf142130)
     // This was 6 (bad crossing out of the first, not deleted image)
     // (4 lines = 2 lines for crossing out of the second image + 2 lines =
     // vertical "changed line" indicator before the two paragraph lines)
-    assertXPath(pXmlDoc, "/metafile/push/push/push/line", 4);
+    assertXPath(pXmlDoc, "/metafile/push/push/push/line", 2);
+    assertXPath(pXmlDoc, "/metafile/push/push/push/push/line", 2);
 
     // check line color
-    assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/linecolor", 5);
+    assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[1]/linecolor", 1);
+    assertXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[1]/linecolor", 1);
     // tdf#142128 This was 3 (NON_PRINTING_CHARACTER_COLOR = #268bd2)
     assertXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/linecolor[@color='#268bd2']", 0);
+    assertXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[1]/linecolor[@color='#268bd2']",
+                0);
 
     // reject deletion of the second image
     IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index 8ce80bcc1c37..22f00a9b6391 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -297,7 +297,7 @@ void SwExtraPainter::PaintRedline( SwTwips nY, tools::Long 
nMax, sal_Int16 nWord
             m_aClip.ChgClip( m_aRect, m_pTextFrame );
         }
     }
-    const Color aOldCol( m_pSh->GetOut()->GetLineColor() );
+    m_pSh->GetOut()->Push(vcl::PushFlags::LINECOLOR);
     m_pSh->GetOut()->SetLineColor(nWordSpacing ? COL_LIGHTRED : 
SwModule::get()->GetRedlineMarkColor());
 
     if ( nWordSpacing )
@@ -310,7 +310,7 @@ void SwExtraPainter::PaintRedline( SwTwips nY, tools::Long 
nMax, sal_Int16 nWord
     }
     else
         m_pSh->GetOut()->DrawLine( aStart, aEnd );
-    m_pSh->GetOut()->SetLineColor( aOldCol );
+    m_pSh->GetOut()->Pop();
 }
 
 void SwTextFrame::PaintExtraData( const SwRect &rRect ) const
diff --git a/sw/source/core/txtnode/fntcache.cxx 
b/sw/source/core/txtnode/fntcache.cxx
index b84f301944f8..c1f6c75147e0 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -652,8 +652,8 @@ static void lcl_DrawLineForWrongListData(
     SwForbidden::iterator pIter = rForbidden.begin();
     if (rInf.GetOut().GetConnectMetaFile())
         rInf.GetOut().Push();
-
-    const Color aCol( rInf.GetOut().GetLineColor() );
+    else
+        rInf.GetOut().Push(vcl::PushFlags::LINECOLOR);
 
     // iterate over all ranges stored in the respective SwWrongList
     do
@@ -743,10 +743,7 @@ static void lcl_DrawLineForWrongListData(
     }
     while (nWrLen && pWList->Check( nStart, nWrLen ));
 
-    rInf.GetOut().SetLineColor( aCol );
-
-    if (rInf.GetOut().GetConnectMetaFile())
-        rInf.GetOut().Pop();
+    rInf.GetOut().Pop();
 }
 
 static void GetTextArray(const SwDrawTextInfo& rExtraInf, const OutputDevice& 
rDevice,
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 10caf6e334b2..d0cb54376728 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -564,7 +564,7 @@ CPPUNIT_TEST_FIXTURE(VclOutdevTest, testDefaultLineColor)
 CPPUNIT_TEST_FIXTURE(VclOutdevTest, testTransparentLineColor)
 {
     // Create a virtual device, and connect a metafile to it.
-    ScopedVclPtrInstance<VirtualDevice> pVDev;
+    ScopedVclPtrInstance<VirtualDevice> pVDev(DeviceFormat::WITH_ALPHA);
 
     GDIMetaFile aMtf;
     aMtf.Record(pVDev.get());
diff --git a/vcl/source/filter/imet/ios2met.cxx 
b/vcl/source/filter/imet/ios2met.cxx
index 0c1107700852..b5b7e4c99415 100644
--- a/vcl/source/filter/imet/ios2met.cxx
+++ b/vcl/source/filter/imet/ios2met.cxx
@@ -742,7 +742,12 @@ void OS2METReader::SetPen( const Color& rColor, sal_uInt16 
nLineWidth, PenStyle
     LineStyle eLineStyle( LineStyle::Solid );
 
     if ( pVirDev->GetLineColor() != rColor )
-        pVirDev->SetLineColor( rColor );
+    {
+        if (rColor == COL_TRANSPARENT)
+            pVirDev->SetLineColor();
+        else
+            pVirDev->SetLineColor( rColor );
+    }
     aLineInfo.SetWidth( nLineWidth );
 
     if (ePenStyle == PEN_NULL)
diff --git a/vcl/source/filter/ipict/ipict.cxx 
b/vcl/source/filter/ipict/ipict.cxx
index de29adbc7f5f..98cb3ba331d6 100644
--- a/vcl/source/filter/ipict/ipict.cxx
+++ b/vcl/source/filter/ipict/ipict.cxx
@@ -647,7 +647,7 @@ void PictReader::DrawingMethod(PictDrawingMethod eMethod)
             pVirDev->SetRasterOp(eActROP);
             break;
         case PictDrawingMethod::PAINT:
-            SetLineColor( COL_TRANSPARENT );
+            pVirDev->SetLineColor();
             if (eActPenPattern.isDefault())
               SetFillColor( aActForeColor );
             else
@@ -655,7 +655,7 @@ void PictReader::DrawingMethod(PictDrawingMethod eMethod)
             pVirDev->SetRasterOp(eActROP);
             break;
         case PictDrawingMethod::ERASE:
-            SetLineColor( COL_TRANSPARENT );
+            pVirDev->SetLineColor();
             if (eActBackPattern.isDefault())
               SetFillColor( aActBackColor );// Osnola: previously aActForeColor
             else // checkMe
@@ -663,12 +663,12 @@ void PictReader::DrawingMethod(PictDrawingMethod eMethod)
             pVirDev->SetRasterOp(RasterOp::OverPaint);
             break;
         case PictDrawingMethod::INVERT: // checkme
-            SetLineColor( COL_TRANSPARENT);
+            pVirDev->SetLineColor();
             SetFillColor( COL_BLACK );
             pVirDev->SetRasterOp(RasterOp::Invert);
             break;
         case PictDrawingMethod::FILL:
-            SetLineColor( COL_TRANSPARENT );
+            pVirDev->SetLineColor();
             if (eActFillPattern.isDefault())
               SetFillColor( aActForeColor );
             else
diff --git a/vcl/source/outdev/line.cxx b/vcl/source/outdev/line.cxx
index 637966678a07..3abbdaba95ec 100644
--- a/vcl/source/outdev/line.cxx
+++ b/vcl/source/outdev/line.cxx
@@ -53,6 +53,12 @@ void OutputDevice::SetLineColor()
 
 void OutputDevice::SetLineColor( const Color& rColor )
 {
+    // If this assert fires, and this is a VirtualDevice, you likely need to 
either
+    // (a) create this VirtualDevice with the WITH_ALPHA flag
+    // or
+    // (b) call SetFillColor() to set no fill
+    assert((mpAlphaVDev || !rColor.IsTransparent())
+        && "transparent color on a device that has no alpha layer will turn 
out wrong");
 
     Color aColor = vcl::drawmode::GetLineColor(rColor, GetDrawMode(), 
GetSettings().GetStyleSettings());
 
diff --git a/vcl/source/treelist/svlbitm.cxx b/vcl/source/treelist/svlbitm.cxx
index 48731fd1d7fe..80410f967544 100644
--- a/vcl/source/treelist/svlbitm.cxx
+++ b/vcl/source/treelist/svlbitm.cxx
@@ -177,14 +177,14 @@ namespace
 {
     void drawSeparator(vcl::RenderContext& rRenderContext, const 
tools::Rectangle& rRegion)
     {
-        Color aOldLineColor(rRenderContext.GetLineColor());
+        rRenderContext.Push(vcl::PushFlags::LINECOLOR);
         const StyleSettings& rStyle = 
rRenderContext.GetSettings().GetStyleSettings();
         Point aTmpPos = rRegion.TopLeft();
         Size aSize = rRegion.GetSize();
         aTmpPos.AdjustY(aSize.Height() / 2 );
         rRenderContext.SetLineColor(rStyle.GetShadowColor());
         rRenderContext.DrawLine(aTmpPos, Point(aSize.Width() + aTmpPos.X(), 
aTmpPos.Y()));
-        rRenderContext.SetLineColor(aOldLineColor);
+        rRenderContext.Pop();
     }
 }
 

Reply via email to