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

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Fri May 24 01:13:09 UTC 2019


 vcl/qt5/Qt5Widget.cxx |   42 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

New commits:
commit 88158bb37d1e41fd192dc66db544daebc980df31
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri May 3 21:18:34 2019 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Fri May 24 03:12:19 2019 +0200

    tdf#123957 Qt5 IM generate correct formating
    
    Actually really evaluate some of the formating provided by the
    QInputMethodEvent::TextFormat attribute and not blindly underline
    all of the text. This evaluates the same formating that the gtk3
    backend evaluates from pango, so the result should be somehow on
    par. Couldn't find a way to test the red strike-out text.
    
    Don't know how often I typed hyoujunnsutairu to test this bug,
    which - according to Google - translates to "standard style".
    
    Reviewed-on: https://gerrit.libreoffice.org/71783
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    (cherry picked from commit da3103365f9574307f70f3f2bae2a3dc461915c1)
    
    This includes 48e44b367a6fde947963de0d896e5d276a7f231e
    
    Change-Id: I4263df6dc1e0e5ce5d8cb0be681656ccd662a830
    Reviewed-on: https://gerrit.libreoffice.org/71990
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 3bc310954cc8..62d02e58565d 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -34,6 +34,7 @@
 #include <QtGui/QPaintEvent>
 #include <QtGui/QResizeEvent>
 #include <QtGui/QShowEvent>
+#include <QtGui/QTextCharFormat>
 #include <QtGui/QWheelEvent>
 #include <QtWidgets/QMainWindow>
 #include <QtWidgets/QToolTip>
@@ -448,6 +449,24 @@ Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f)
     setFocusPolicy(Qt::StrongFocus);
 }
 
+static ExtTextInputAttr lcl_MapUndrelineStyle(QTextCharFormat::UnderlineStyle us)
+{
+    switch (us)
+    {
+        case QTextCharFormat::NoUnderline:
+            return ExtTextInputAttr::NONE;
+        case QTextCharFormat::DotLine:
+            return ExtTextInputAttr::DottedUnderline;
+        case QTextCharFormat::DashDotDotLine:
+        case QTextCharFormat::DashDotLine:
+            return ExtTextInputAttr::DashDotUnderline;
+        case QTextCharFormat::WaveUnderline:
+            return ExtTextInputAttr::GrayWaveline;
+        default:
+            return ExtTextInputAttr::Underline;
+    }
+}
+
 void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent)
 {
     SolarMutexGuard aGuard;
@@ -472,13 +491,32 @@ void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent)
 
         const sal_Int32 nLength = aInputEvent.maText.getLength();
         const QList<QInputMethodEvent::Attribute>& rAttrList = pEvent->attributes();
-        std::vector<ExtTextInputAttr> aTextAttrs(nLength, ExtTextInputAttr::Underline);
+        std::vector<ExtTextInputAttr> aTextAttrs(std::max(sal_Int32(1), nLength),
+                                                 ExtTextInputAttr::NONE);
+        aInputEvent.mpTextAttr = &aTextAttrs[0];
 
         for (int i = 0; i < rAttrList.size(); ++i)
         {
             const QInputMethodEvent::Attribute& rAttr = rAttrList.at(i);
             switch (rAttr.type)
             {
+                case QInputMethodEvent::TextFormat:
+                {
+                    QTextCharFormat aCharFormat
+                        = qvariant_cast<QTextFormat>(rAttr.value).toCharFormat();
+                    if (aCharFormat.isValid())
+                    {
+                        ExtTextInputAttr aETIP
+                            = lcl_MapUndrelineStyle(aCharFormat.underlineStyle());
+                        if (aCharFormat.hasProperty(QTextFormat::BackgroundBrush))
+                            aETIP |= ExtTextInputAttr::Highlight;
+                        if (aCharFormat.fontStrikeOut())
+                            aETIP |= ExtTextInputAttr::RedText;
+                        for (int j = rAttr.start; j < rAttr.start + rAttr.length; j++)
+                            aTextAttrs[j] = aETIP;
+                    }
+                    break;
+                }
                 case QInputMethodEvent::Cursor:
                 {
                     aInputEvent.mnCursorPos = rAttr.start;
@@ -492,8 +530,6 @@ void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent)
                     break;
             }
         }
-        if (nLength)
-            aInputEvent.mpTextAttr = &aTextAttrs[0];
 
         m_pFrame->CallCallback(SalEvent::ExtTextInput, &aInputEvent);
         pEvent->accept();


More information about the Libreoffice-commits mailing list