[Libreoffice-commits] core.git: svx/inc svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 22 13:20:43 UTC 2020


 svx/inc/CommonStylePreviewRenderer.hxx           |    1 +
 svx/source/styles/CommonStylePreviewRenderer.cxx |   20 ++++++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

New commits:
commit 804dac9222fdf6e423993ac348a43e52a8f74ba3
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Sep 22 12:24:15 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Sep 22 15:20:00 2020 +0200

    tdf#93756 show highlight color in style preview
    
    Change-Id: Ibddd97f8829d824667657177c7311680707df4e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103167
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/inc/CommonStylePreviewRenderer.hxx b/svx/inc/CommonStylePreviewRenderer.hxx
index 5dfd41faa39a..6d4466b31bf3 100644
--- a/svx/inc/CommonStylePreviewRenderer.hxx
+++ b/svx/inc/CommonStylePreviewRenderer.hxx
@@ -27,6 +27,7 @@ class CommonStylePreviewRenderer final : public sfx2::StylePreviewRenderer
 {
     std::unique_ptr<SvxFont> m_pFont;
     Color maFontColor;
+    Color maHighlightColor;
     Color maBackgroundColor;
     Size maPixelSize;
     OUString maStyleName;
diff --git a/svx/source/styles/CommonStylePreviewRenderer.cxx b/svx/source/styles/CommonStylePreviewRenderer.cxx
index 9920903df469..cd3a311dfcb0 100644
--- a/svx/source/styles/CommonStylePreviewRenderer.cxx
+++ b/svx/source/styles/CommonStylePreviewRenderer.cxx
@@ -20,6 +20,7 @@
 #include <svx/xdef.hxx>
 #include <svx/xfillit0.hxx>
 #include <svx/xflclit.hxx>
+#include <editeng/brushitem.hxx>
 #include <editeng/fontitem.hxx>
 #include <editeng/fhgtitem.hxx>
 #include <editeng/charreliefitem.hxx>
@@ -47,6 +48,7 @@ CommonStylePreviewRenderer::CommonStylePreviewRenderer(
     : StylePreviewRenderer(rShell, rOutputDev, pStyle, nMaxHeight)
     , m_pFont()
     , maFontColor(COL_AUTO)
+    , maHighlightColor(COL_AUTO)
     , maBackgroundColor(COL_AUTO)
     , maPixelSize()
     , maStyleName(mpStyle->GetName())
@@ -112,6 +114,10 @@ bool CommonStylePreviewRenderer::recalculate()
     {
         maFontColor = static_cast<const SvxColorItem*>(pItem)->GetValue();
     }
+    if ((pItem = pItemSet->GetItem(SID_ATTR_BRUSH_CHAR)) != nullptr)
+    {
+        maHighlightColor = static_cast<const SvxBrushItem*>(pItem)->GetColor();
+    }
 
     if (mpStyle->GetFamily() == SfxStyleFamily::Para)
     {
@@ -188,9 +194,7 @@ bool CommonStylePreviewRenderer::render(const tools::Rectangle& aRectangle, Rend
     const OUString& rText = maStyleName;
 
     // setup the device & draw
-    vcl::Font aOldFont(mrOutputDev.GetFont());
-    Color aOldColor(mrOutputDev.GetTextColor());
-    Color aOldFillColor(mrOutputDev.GetFillColor());
+    mrOutputDev.Push(PushFlags::FONT | PushFlags::TEXTCOLOR | PushFlags::FILLCOLOR | PushFlags::TEXTFILLCOLOR);
 
     if (maBackgroundColor != COL_AUTO)
     {
@@ -199,12 +203,14 @@ bool CommonStylePreviewRenderer::render(const tools::Rectangle& aRectangle, Rend
     }
 
     if (m_pFont)
-    {
         mrOutputDev.SetFont(*m_pFont);
-    }
+
     if (maFontColor != COL_AUTO)
         mrOutputDev.SetTextColor(maFontColor);
 
+    if (maHighlightColor != COL_AUTO)
+        mrOutputDev.SetTextFillColor(maHighlightColor);
+
     Size aPixelSize(m_pFont ? maPixelSize : mrOutputDev.GetFont().GetFontSize());
 
     Point aFontDrawPosition = aRectangle.TopLeft();
@@ -216,9 +222,7 @@ bool CommonStylePreviewRenderer::render(const tools::Rectangle& aRectangle, Rend
 
     mrOutputDev.DrawText(aFontDrawPosition, rText);
 
-    mrOutputDev.SetFillColor(aOldFillColor);
-    mrOutputDev.SetTextColor(aOldColor);
-    mrOutputDev.SetFont(aOldFont);
+    mrOutputDev.Pop();
 
     return true;
 }


More information about the Libreoffice-commits mailing list