include/svx/sdr/overlay/overlayobject.hxx   |    8 ++++++++
 svx/source/sdr/overlay/overlaymanager.cxx   |   19 +++++++++++++++++++
 svx/source/sdr/overlay/overlayobject.cxx    |    3 ++-
 svx/source/sdr/overlay/overlayrectangle.cxx |    2 ++
 svx/source/svdraw/svdedxv.cxx               |    2 ++
 5 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit 046bc5029681444cb5d707b33a8aa3cc67732c22
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Oct 12 15:53:21 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Oct 13 10:04:53 2022 +0200

    tdf#150622 allow use of selection color for frame in HighContrast mode
    
    Change-Id: I0a45051c9ba8bbfe785689103c6af6285a282345
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141261
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/include/svx/sdr/overlay/overlayobject.hxx 
b/include/svx/sdr/overlay/overlayobject.hxx
index d4ef56646171..294ceb3447f8 100644
--- a/include/svx/sdr/overlay/overlayobject.hxx
+++ b/include/svx/sdr/overlay/overlayobject.hxx
@@ -109,6 +109,11 @@ namespace sdr::overlay
             // it is switched to false
             bool                                            mbAllowsAntiAliase 
: 1;
 
+            // Flag to control if this OverlayObject is allowed to ignore the
+            // DrawMode settings which force use of colors to High Contrast 
fg/bg
+            // Default is false.
+            bool                                            
mbOverruleDrawModeSettings : 1;
+
             // set changed flag. Call after change, since the old range is 
invalidated
             // and then the new one is calculated and invalidated, too. This 
will only
             // work after the change.
@@ -142,6 +147,9 @@ namespace sdr::overlay
             // read access to AntiAliase flag
             bool allowsAntiAliase() const { return mbAllowsAntiAliase; }
 
+            // read access to DrawModeSettings flag
+            bool overrulesDrawModeSettings() const { return 
mbOverruleDrawModeSettings; }
+
             // read access to baseRange. This may trigger createBaseRange() if
             // object is changed.
             const basegfx::B2DRange& getBaseRange() const;
diff --git a/svx/source/sdr/overlay/overlaymanager.cxx 
b/svx/source/sdr/overlay/overlaymanager.cxx
index 3cbd821fb3bd..3d501b814da5 100644
--- a/svx/source/sdr/overlay/overlaymanager.cxx
+++ b/svx/source/sdr/overlay/overlaymanager.cxx
@@ -47,6 +47,12 @@ namespace sdr::overlay
 
             const AntialiasingFlags 
nOriginalAA(rDestinationDevice.GetAntialiasing());
             const bool 
bIsAntiAliasing(SvtOptionsDrawinglayer::IsAntiAliasing());
+            // tdf#150622 for High Contrast we typically force colors to a 
single pair Fore/Back,
+            // but it seems reasonable to allow overlays to use the selection 
color
+            // taken from the system High Contrast settings
+            const DrawModeFlags 
nOriginalDrawMode(rDestinationDevice.GetDrawMode());
+            const DrawModeFlags nForceSettings = DrawModeFlags::SettingsLine | 
DrawModeFlags::SettingsFill |
+                                                 DrawModeFlags::SettingsText | 
DrawModeFlags::SettingsGradient;
 
             // create processor
             std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> 
pProcessor(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
@@ -75,7 +81,20 @@ namespace sdr::overlay
                                 rDestinationDevice.SetAntialiasing(nOriginalAA 
& ~AntialiasingFlags::Enable);
                             }
 
+                            const bool bOverrulesDrawModeSettings = 
rCandidate.overrulesDrawModeSettings();
+                            if (bOverrulesDrawModeSettings)
+                            {
+                                // overrule DrawMode settings
+                                
rDestinationDevice.SetDrawMode(nOriginalDrawMode & ~nForceSettings);
+                            }
+
                             pProcessor->process(rSequence);
+
+                            if (bOverrulesDrawModeSettings)
+                            {
+                                // restore DrawMode settings
+                                
rDestinationDevice.SetDrawMode(nOriginalDrawMode);
+                            }
                         }
                     }
                 }
diff --git a/svx/source/sdr/overlay/overlayobject.cxx 
b/svx/source/sdr/overlay/overlayobject.cxx
index 4fd227977dbb..6aab4f88068c 100644
--- a/svx/source/sdr/overlay/overlayobject.cxx
+++ b/svx/source/sdr/overlay/overlayobject.cxx
@@ -90,7 +90,8 @@ namespace sdr::overlay
             mbIsVisible(true),
             mbIsHittable(true),
             mbAllowsAnimation(false),
-            mbAllowsAntiAliase(true)
+            mbAllowsAntiAliase(true),
+            mbOverruleDrawModeSettings(false)
         {
         }
 
diff --git a/svx/source/sdr/overlay/overlayrectangle.cxx 
b/svx/source/sdr/overlay/overlayrectangle.cxx
index 617c6d4dc7bf..ce9c11b51835 100644
--- a/svx/source/sdr/overlay/overlayrectangle.cxx
+++ b/svx/source/sdr/overlay/overlayrectangle.cxx
@@ -81,6 +81,8 @@ namespace sdr::overlay
 
             // set AllowsAnimation flag to mark this object as animation 
capable
             mbAllowsAnimation = bAnimate;
+            // allow use of selection color even in HighContrast mode
+            mbOverruleDrawModeSettings = true;
         }
 
         void OverlayRectangle::Trigger(sal_uInt32 nTime)
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 78e8ac08958a..9f3552f2cfaf 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -531,6 +531,8 @@ TextEditFrameOverlayObject::TextEditFrameOverlayObject(
     , mrTextEditOverlayObject(rTextEditOverlayObject)
 {
     allowAntiAliase(rTextEditOverlayObject.allowsAntiAliase());
+    // allow use of selection color even in HighContrast mode
+    mbOverruleDrawModeSettings = true;
 }
 
 TextEditFrameOverlayObject::~TextEditFrameOverlayObject()

Reply via email to