[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 19 12:46:58 UTC 2019


 vcl/win/gdi/salnativewidgets-luna.cxx |   27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

New commits:
commit 17e17feb6ad180432e656364a4b48acb83cdd33c
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Mar 7 18:05:11 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Mar 19 13:46:35 2019 +0100

    tdf#119947 vcl opengl win: fix fontwork popup menu
    
    Regression from commit b160db926b574b7e9d6696d49dbbce8dd289aade
    (tdf#96947 vcl opengl win: fix background of menu items w/ check/radio
    marks, 2018-05-14), the problem was that GetMenuPopupMarkRegion() did an
    unconditional downcast from ImplControlValue to MenupopupValue.  This
    looked safe, but when the extracted function was used in
    WinSalGraphics::drawNativeControl(), then that argument was not safe to
    downcast.
    
    Fix the problem by switching to safe downcast, and returning an empty
    rectangle (instead of a bogus one) on error.
    
    This way the old bug stays fixed but fontwork popup menu works again as
    well.
    
    (cherry picked from commit 5f2b67e7c1aa4ea7bb66292207ed8c9b20a6f78f)
    
    Change-Id: I2b69b9f2e6823850892ac73df78dac5c2f04ec03
    Reviewed-on: https://gerrit.libreoffice.org/68904
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index 00c5c4c3c6f7..4aa3edd5910a 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -503,18 +503,21 @@ static tools::Rectangle GetMenuPopupMarkRegion(const ImplControlValue& rValue)
 {
     tools::Rectangle aRet;
 
-    const MenupopupValue& rMVal(static_cast<const MenupopupValue&>(rValue));
-    aRet.SetTop(rMVal.maItemRect.Top());
-    aRet.SetBottom(rMVal.maItemRect.Bottom() + 1); // see below in drawNativeControl
+    auto pMVal = dynamic_cast<const MenupopupValue*>(&rValue);
+    if (!pMVal)
+        return aRet;
+
+    aRet.SetTop(pMVal->maItemRect.Top());
+    aRet.SetBottom(pMVal->maItemRect.Bottom() + 1); // see below in drawNativeControl
     if (AllSettings::GetLayoutRTL())
     {
-        aRet.SetRight(rMVal.maItemRect.Right() + 1);
-        aRet.SetLeft(aRet.Right() - (rMVal.getNumericVal() - rMVal.maItemRect.Left()));
+        aRet.SetRight(pMVal->maItemRect.Right() + 1);
+        aRet.SetLeft(aRet.Right() - (pMVal->getNumericVal() - pMVal->maItemRect.Left()));
     }
     else
     {
-        aRet.SetRight(rMVal.getNumericVal());
-        aRet.SetLeft(rMVal.maItemRect.Left());
+        aRet.SetRight(pMVal->getNumericVal());
+        aRet.SetLeft(pMVal->maItemRect.Left());
     }
 
     return aRet;
@@ -1180,9 +1183,13 @@ bool WinSalGraphics::drawNativeControl( ControlType nType,
 
     if (pImpl && nType == ControlType::MenuPopup && (nPart == ControlPart::MenuItemCheckMark || nPart == ControlPart::MenuItemRadioMark))
     {
-        cacheRect = GetMenuPopupMarkRegion(aValue);
-        buttonRect = cacheRect;
-        keySize = cacheRect.GetSize();
+        tools::Rectangle aRectangle = GetMenuPopupMarkRegion(aValue);
+        if (!aRectangle.IsEmpty())
+        {
+            cacheRect = GetMenuPopupMarkRegion(aValue);
+            buttonRect = cacheRect;
+            keySize = cacheRect.GetSize();
+        }
     }
 
 


More information about the Libreoffice-commits mailing list