sc/UIConfig_scalc.mk                    |    1 
 sc/source/ui/view/viewfunc.cxx          |   32 ++++++++++---
 sc/uiconfig/scalc/ui/warnautocorrect.ui |   74 ++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 7 deletions(-)

New commits:
commit 36121e87b7e2a2defbfe75dfdadb2dde4fff6b4f
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Jan 25 15:49:57 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Jan 25 18:36:08 2022 +0100

    tdf#146970 use a textview to show the proposed replacement formula
    
    so it can scroll and keep the text area to some finite size
    
    no strings changes or new translations, so this is a backportable
    change.
    
    Change-Id: Ibc36812c6aa7fff8e035c06d0dad885909f057ff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128933
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 336e1710958d..bc320cc44fd7 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -259,6 +259,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
        sc/uiconfig/scalc/ui/validationcriteriapage \
        sc/uiconfig/scalc/ui/validationhelptabpage \
        sc/uiconfig/scalc/ui/validationhelptabpage-mobile \
+       sc/uiconfig/scalc/ui/warnautocorrect \
        sc/uiconfig/scalc/ui/xmlsourcedialog \
        sc/uiconfig/scalc/ui/zoombox \
        sc/uiconfig/scalc/ui/ztestdialog \
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 247fdeda5a70..ecaa0a2cdf8a 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -337,6 +337,29 @@ namespace HelperNotifyChanges
     }
 }
 
+namespace
+{
+    class AutoCorrectQuery : public weld::MessageDialogController
+    {
+    private:
+        std::unique_ptr<weld::TextView> m_xError;
+    public:
+        AutoCorrectQuery(weld::Window* pParent, const OUString& rFormula)
+            : weld::MessageDialogController(pParent, 
"modules/scalc/ui/warnautocorrect.ui", "WarnAutoCorrect", "grid")
+            , m_xError(m_xBuilder->weld_text_view("error"))
+        {
+            
m_xDialog->set_primary_text(ScResId(SCSTR_FORMULA_AUTOCORRECTION).trim());
+            m_xDialog->set_default_response(RET_YES);
+
+            const int nMaxWidth = m_xError->get_approximate_digit_width() * 65;
+            const int nMaxHeight = m_xError->get_height_rows(6);
+            m_xError->set_size_request(nMaxWidth, nMaxHeight);
+
+            m_xError->set_text(rFormula);
+        }
+    };
+}
+
 //      actual functions
 
 //  input - undo OK
@@ -447,13 +470,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB 
nTab,
                     nResult = RET_NO;   // empty formula, just '='
                 else
                 {
-                    OUString aMessage = ScResId( SCSTR_FORMULA_AUTOCORRECTION 
) + aCorrectedFormula;
-
-                    std::unique_ptr<weld::MessageDialog> 
xQueryBox(Application::CreateMessageDialog(GetViewData().GetDialogParent(),
-                                                                   
VclMessageType::Question, VclButtonsType::YesNo,
-                                                                   aMessage));
-                    xQueryBox->set_default_response(RET_YES);
-                    nResult = xQueryBox->run();
+                    AutoCorrectQuery 
aQueryBox(GetViewData().GetDialogParent(), aCorrectedFormula);
+                    nResult = aQueryBox.run();
                 }
                 if ( nResult == RET_YES )
                 {
diff --git a/sc/uiconfig/scalc/ui/warnautocorrect.ui 
b/sc/uiconfig/scalc/ui/warnautocorrect.ui
new file mode 100644
index 000000000000..632dbcc80360
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/warnautocorrect.ui
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface domain="sc">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkMessageDialog" id="WarnAutoCorrect">
+    <property name="can-focus">False</property>
+    <property name="border-width">6</property>
+    <property name="type">popup</property>
+    <property name="modal">True</property>
+    <property name="type-hint">dialog</property>
+    <property name="skip-taskbar-hint">True</property>
+    <property name="message-type">question</property>
+    <property name="buttons">yes-no</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="messagedialog-vbox">
+        <property name="can-focus">False</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="messagedialog-action_area">
+            <property name="can-focus">False</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <!-- n-columns=1 n-rows=1 -->
+          <object class="GtkGrid" id="grid">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="hscrollbar-policy">never</property>
+                <property name="shadow-type">in</property>
+                <child>
+                  <object class="GtkTextView" id="error">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="editable">False</property>
+                    <property name="wrap-mode">char</property>
+                    <property name="cursor-visible">False</property>
+                    <property name="accepts-tab">False</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>

Reply via email to