starmath/UIConfig_smath.mk                |    1 
 starmath/source/view.cxx                  |   15 +++++++++++
 starmath/uiconfig/smath/ui/embedwindow.ui |   38 ++++++++++++++++++++++++++++++
 starmath/uiconfig/smath/ui/mathwindow.ui  |    2 -
 4 files changed, 54 insertions(+), 2 deletions(-)

New commits:
commit 3cada6586511aecaf7f8fbf4d36c8d23dfc5d6f1
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Fri Aug 16 21:09:04 2024 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Sun Aug 18 03:18:12 2024 +0200

    tdf#160459 embedded starmath doesn't fit inside allocated area
    
    much to and fro with MapModes and rounding issue obscured that
    fundmentally that the 'etched-out' GtkScrolledWindow frame requires
    space which eats into what is available to show the formula, and
    in embedded mode we want the editing area to be equal in size
    to the area used for the preview.
    
    Change-Id: I1d126ddcc953131cf4add7da58ccd89e7fa86b66
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171985
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/starmath/UIConfig_smath.mk b/starmath/UIConfig_smath.mk
index d79d791a92df..824f54822db5 100644
--- a/starmath/UIConfig_smath.mk
+++ b/starmath/UIConfig_smath.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/smath,\
        starmath/uiconfig/smath/ui/alignmentdialog \
        starmath/uiconfig/smath/ui/catalogdialog \
        starmath/uiconfig/smath/ui/editwindow \
+       starmath/uiconfig/smath/ui/embedwindow \
        starmath/uiconfig/smath/ui/fontdialog \
        starmath/uiconfig/smath/ui/fontsizedialog \
        starmath/uiconfig/smath/ui/fonttypedialog \
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 6e7edfef4482..13bc165e3a54 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -105,8 +105,21 @@ using namespace css;
 using namespace css::accessibility;
 using namespace css::uno;
 
+static OUString GetScrollUIName(const SmViewShell& rShell)
+{
+    const SmDocShell* pShell = rShell.GetDoc();
+    if (pShell && pShell->GetCreateMode() == SfxObjectCreateMode::EMBEDDED)
+    {
+        // This one has no border on the scrolledwindow, to maximize the space
+        // available when in embedded mode and minimize the difference from
+        // the ole preview to give a more seamless embedded editing experience.
+        return "modules/smath/ui/embedwindow.ui";
+    }
+    return "modules/smath/ui/mathwindow.ui";
+}
+
 SmGraphicWindow::SmGraphicWindow(SmViewShell& rShell)
-    : InterimItemWindow(&rShell.GetViewFrame().GetWindow(), 
u"modules/smath/ui/mathwindow.ui"_ustr, u"MathWindow"_ustr)
+    : InterimItemWindow(&rShell.GetViewFrame().GetWindow(), 
GetScrollUIName(rShell), u"MathWindow"_ustr)
     , nLinePixH(GetSettings().GetStyleSettings().GetScrollBarSize())
     , nColumnPixW(nLinePixH)
     , nZoom(100)
diff --git a/starmath/uiconfig/smath/ui/embedwindow.ui 
b/starmath/uiconfig/smath/ui/embedwindow.ui
new file mode 100644
index 000000000000..d63bceca8f0e
--- /dev/null
+++ b/starmath/uiconfig/smath/ui/embedwindow.ui
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.40.0 -->
+<interface domain="sm">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkBox" id="MathWindow">
+    <property name="visible">True</property>
+    <property name="can-focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="spacing">6</property>
+    <child>
+      <object class="GtkScrolledWindow" id="scrolledwindow">
+        <property name="visible">True</property>
+        <property name="can-focus">True</property>
+        <property name="hexpand">True</property>
+        <property name="border-width">0</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <child>
+              <object class="GtkDrawingArea" id="mathview">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="events">GDK_BUTTON_MOTION_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | 
GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | 
GDK_SCROLL_MASK</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/starmath/uiconfig/smath/ui/mathwindow.ui 
b/starmath/uiconfig/smath/ui/mathwindow.ui
index 527e436fd6e1..3588e3a1c2c5 100644
--- a/starmath/uiconfig/smath/ui/mathwindow.ui
+++ b/starmath/uiconfig/smath/ui/mathwindow.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 -->
+<!-- Generated with glade 3.40.0 -->
 <interface domain="sm">
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkBox" id="MathWindow">

Reply via email to