include/svx/swframeexample.hxx | 4 ++-- svx/source/dialog/swframeexample.cxx | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-)
New commits: commit 5571d80795253cfa08169520852901c14d22d1f5 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jul 1 08:51:35 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jul 1 10:39:29 2025 +0200 tdf#166842 do not use FillColor==COL_TRANSPARENT... .. on OutputDevice if that OutputDevice does not support alpha Change-Id: I44243118dd38aab0c3c453206da7606d5d067b83 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187220 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svx/swframeexample.hxx b/include/svx/swframeexample.hxx index fc64982cee3c..1c3256d5c8fe 100644 --- a/include/svx/swframeexample.hxx +++ b/include/svx/swframeexample.hxx @@ -28,7 +28,6 @@ class SVX_DLLPUBLIC SwFrameExample final : public weld::CustomWidgetController { - Color m_aTransColor; ///< transparency Color m_aBgCol; ///< background Color m_aFrameColor; ///< graphic frame Color m_aAlignColor; ///< align anchor @@ -63,7 +62,8 @@ class SVX_DLLPUBLIC SwFrameExample final : public weld::CustomWidgetController void InitColors_Impl(); void InitAllRects_Impl(vcl::RenderContext& rRenderContext); void CalcBoundRect_Impl(const vcl::RenderContext& rRenderContext, tools::Rectangle &rRect); - tools::Rectangle DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor); + tools::Rectangle DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, + std::optional<Color> oFillColor, const Color &rBorderColor); virtual void StyleUpdated() override; virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; diff --git a/svx/source/dialog/swframeexample.cxx b/svx/source/dialog/swframeexample.cxx index 8beb189a40fe..db46cf58a8da 100644 --- a/svx/source/dialog/swframeexample.cxx +++ b/svx/source/dialog/swframeexample.cxx @@ -36,10 +36,16 @@ constexpr OUString DEMOTEXT = u"Ij"_ustr; namespace { void DrawRect_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, - const Color &rFillColor, const Color &rLineColor) + std::optional<Color> oFillColor, std::optional<Color> oLineColor) { - rRenderContext.SetFillColor(rFillColor); - rRenderContext.SetLineColor(rLineColor); + if (oFillColor) + rRenderContext.SetFillColor(*oFillColor); + else + rRenderContext.SetFillColor(); + if (oLineColor) + rRenderContext.SetLineColor(*oLineColor); + else + rRenderContext.SetLineColor(); rRenderContext.DrawRect(rRect); } @@ -74,7 +80,6 @@ void SwFrameExample::InitColors_Impl() m_aFrameColor = COL_LIGHTGREEN; m_aAlignColor = COL_LIGHTRED; - m_aTransColor = COL_TRANSPARENT; m_aTxtCol = bHC? svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor : @@ -440,9 +445,9 @@ void SwFrameExample::CalcBoundRect_Impl(const vcl::RenderContext& rRenderContext } tools::Rectangle SwFrameExample::DrawInnerFrame_Impl(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, - const Color &rFillColor, const Color &rBorderColor) + std::optional<Color> oFillColor, const Color &rBorderColor) { - DrawRect_Impl(rRenderContext, rRect, rFillColor, rBorderColor); + DrawRect_Impl(rRenderContext, rRect, oFillColor, rBorderColor); // determine the area relative to which the positioning happens tools::Rectangle aRect(rRect); // aPagePrtArea = Default @@ -459,7 +464,7 @@ tools::Rectangle SwFrameExample::DrawInnerFrame_Impl(vcl::RenderContext& rRender { if (i == nLines - 1) aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight())); - DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor); + DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, std::nullopt); aTxt.Move(0, nStep); } } @@ -477,7 +482,7 @@ void SwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::Rect DrawRect_Impl(rRenderContext, aPage, m_aBgCol, m_aBorderCol); // Draw PrintArea - tools::Rectangle aRect = DrawInnerFrame_Impl(rRenderContext, aPagePrtArea, m_aTransColor, m_aPrintAreaCol); + tools::Rectangle aRect = DrawInnerFrame_Impl(rRenderContext, aPagePrtArea, std::nullopt, m_aPrintAreaCol); if (nAnchor == RndStdIds::FLY_AT_FLY) aRect = DrawInnerFrame_Impl(rRenderContext, aFrameAtFrame, m_aBgCol, m_aBorderCol); @@ -661,7 +666,7 @@ void SwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::Rect } } if (pOuterFrame->Contains(aTxt)) - DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, m_aTransColor ); + DrawRect_Impl(rRenderContext, aTxt, m_aTxtCol, std::nullopt ); aTxt.Move(0, nStep); aTxt.SetRight( nOldR ); @@ -691,11 +696,11 @@ void SwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::Rect } // Draw rectangle on which the frame is aligned: - DrawRect_Impl(rRenderContext, aRect, m_aTransColor, m_aAlignColor); + DrawRect_Impl(rRenderContext, aRect, std::nullopt, m_aAlignColor); // Frame View bool bDontFill = (nAnchor == RndStdIds::FLY_AT_CHAR && aFrmRect.Overlaps(aAutoCharFrame)) || bTrans; - DrawRect_Impl(rRenderContext, aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor); + DrawRect_Impl(rRenderContext, aFrmRect, bDontFill ? std::nullopt : std::optional { m_aBgCol }, m_aFrameColor); } void SwFrameExample::SetRelPos(const Point& rP)