include/sfx2/sidebar/Deck.hxx             |    2 +
 include/vcl/jsdialog/executor.hxx         |    5 ++++
 include/vcl/weld.hxx                      |    2 +
 sfx2/source/sidebar/Deck.cxx              |   16 +++++++++++++++
 sfx2/source/sidebar/DeckLayouter.cxx      |    7 ------
 sfx2/source/sidebar/SidebarController.cxx |    3 ++
 vcl/inc/jsdialog/jsdialogbuilder.hxx      |   13 ++++++++++++
 vcl/jsdialog/executor.cxx                 |   12 +++++++++++
 vcl/jsdialog/jsdialogbuilder.cxx          |   32 ++++++++++++++++++++++++++++++
 9 files changed, 85 insertions(+), 7 deletions(-)

New commits:
commit a2528102bfc2e51aefe1ac99d5ead438b8e121d3
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Wed Jun 21 17:36:09 2023 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Jul 13 07:58:02 2023 +0200

    lok: sidebar: send full update only when changed panels
    
    we only need to send update when:
    - we switch to other deck
    - panels were hidden, shown, created
    
    this helps to avoid full updates in navigator when
    clicking on images, what causes context change
    
    Change-Id: If1bca6167cdc3e9294eb5aefb923e92bc9043edc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153401
    Reviewed-by: Attila Szűcs <attila.sz...@collabora.com>
    Tested-by: Attila Szűcs <attila.sz...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154360
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/include/sfx2/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx
index fe73e6332d90..215d3d215674 100644
--- a/include/sfx2/sidebar/Deck.hxx
+++ b/include/sfx2/sidebar/Deck.hxx
@@ -66,6 +66,8 @@ public:
 
     sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; }
 
+    static void LOKSendSidebarFullUpdate();
+
 private:
     void RequestLayoutInternal();
 
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index b6ddffa89550..629a1d76d3d0 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -29,6 +29,7 @@
 
 #include <vcl/event.hxx>
 #include <comphelper/lok.hxx>
+#include <vcl/jsdialog/executor.hxx>
 #include <tools/json_writer.hxx>
 
 using namespace css;
@@ -36,6 +37,15 @@ using namespace css::uno;
 
 namespace sfx2::sidebar {
 
+void Deck::LOKSendSidebarFullUpdate()
+{
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        sal_uInt64 nShellId = 
reinterpret_cast<sal_uInt64>(SfxViewShell::Current());
+        jsdialog::SendFullUpdate(OUString::number(nShellId) + "sidebar", 
"Panel");
+    }
+}
+
 Deck::Deck(const DeckDescriptor& rDeckDescriptor, SidebarDockingWindow* 
pParentWindow,
            const std::function<void()>& rCloserAction)
     : InterimItemWindow(pParentWindow, "sfx/ui/deck.ui", "Deck")
@@ -117,6 +127,7 @@ void Deck::DataChanged(const DataChangedEvent&)
         rpPanel->DataChanged();
 
     RequestLayoutInternal();
+    Deck::LOKSendSidebarFullUpdate();
 }
 
 /*
@@ -181,12 +192,17 @@ void Deck::ResetPanels(SharedPanelContainer&& 
rPanelContainer)
             aHiddens.push_back(rpPanel);
         }
     }
+
+    bool bDifferent = maPanels.size() != rPanelContainer.size() || 
aHiddens.size();
     maPanels = std::move(rPanelContainer);
 
     // Hidden ones always at the end
     maPanels.insert(std::end(maPanels), std::begin(aHiddens), 
std::end(aHiddens));
 
     RequestLayoutInternal();
+
+    if (bDifferent)
+        Deck::LOKSendSidebarFullUpdate();
 }
 
 void Deck::RequestLayoutInternal()
diff --git a/sfx2/source/sidebar/DeckLayouter.cxx 
b/sfx2/source/sidebar/DeckLayouter.cxx
index 05a82dd2003f..824b66ac1aff 100644
--- a/sfx2/source/sidebar/DeckLayouter.cxx
+++ b/sfx2/source/sidebar/DeckLayouter.cxx
@@ -37,7 +37,6 @@
 #include <com/sun/star/ui/XSidebarPanel.hpp>
 
 #include <utility>
-#include <vcl/jsdialog/executor.hxx>
 
 using namespace css;
 using namespace css::uno;
@@ -307,12 +306,6 @@ sal_Int32 PlacePanels (
         }
     }
 
-    if (comphelper::LibreOfficeKit::isActive())
-    {
-        sal_uInt64 nShellId = 
reinterpret_cast<sal_uInt64>(SfxViewShell::Current());
-        jsdialog::SendFullUpdate(OUString::number(nShellId) + "sidebar", 
"Panel");
-    }
-
     return nY;
 }
 
diff --git a/sfx2/source/sidebar/SidebarController.cxx 
b/sfx2/source/sidebar/SidebarController.cxx
index b967cbb10369..666870147875 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -686,7 +686,10 @@ void SidebarController::SwitchToDeck (
         std::shared_ptr<DeckDescriptor> xDeckDescriptor = 
mpResourceManager->GetDeckDescriptor(rsDeckId);
 
         if (xDeckDescriptor)
+        {
             SwitchToDeck(*xDeckDescriptor, maCurrentContext);
+            Deck::LOKSendSidebarFullUpdate();
+        }
     }
 }
 
commit 642a628355f2bcfc45b829e7763b69351324634f
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Fri Jul 7 18:13:18 2023 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Jul 13 07:57:52 2023 +0200

    jsdialog: formatted spin field
    
    Change-Id: I5830dd523e0ccc736a686f38319a6c509e5650be
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154193
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Pranam Lashkari <lpra...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154363
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/include/vcl/jsdialog/executor.hxx 
b/include/vcl/jsdialog/executor.hxx
index 26fd7070e86c..b60c035d587a 100644
--- a/include/vcl/jsdialog/executor.hxx
+++ b/include/vcl/jsdialog/executor.hxx
@@ -95,6 +95,11 @@ public:
         rSpinButton.signal_value_changed();
     }
 
+    static void trigger_value_changed(weld::FormattedSpinButton& rSpinButton)
+    {
+        rSpinButton.signal_value_changed();
+    }
+
     static void trigger_closed(weld::Popover& rPopover) { rPopover.popdown(); }
 
     static void trigger_key_press(weld::Widget& rWidget, const KeyEvent& 
rEvent)
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index df1bb05c4575..4c198b3ecc99 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1863,6 +1863,8 @@ class EntryFormatter;
 // are managed by a more complex Formatter which can support doubles.
 class VCL_DLLPUBLIC FormattedSpinButton : virtual public Entry
 {
+    friend class ::LOKTrigger;
+
     Link<FormattedSpinButton&, void> m_aValueChangedHdl;
 
 protected:
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx 
b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 06e2c6135171..527278e886bd 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -295,6 +295,8 @@ public:
     virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OUString& id) 
override;
     virtual std::unique_ptr<weld::Notebook> weld_notebook(const OUString& id) 
override;
     virtual std::unique_ptr<weld::SpinButton> weld_spin_button(const OUString& 
id) override;
+    virtual std::unique_ptr<weld::FormattedSpinButton>
+    weld_formatted_spin_button(const OUString& id) override;
     virtual std::unique_ptr<weld::CheckButton> weld_check_button(const 
OUString& id) override;
     virtual std::unique_ptr<weld::DrawingArea>
     weld_drawing_area(const OUString& id, const a11yref& rA11yImpl = nullptr,
@@ -643,6 +645,17 @@ public:
     virtual void set_value(sal_Int64 value) override;
 };
 
+class JSFormattedSpinButton final
+    : public JSWidget<SalInstanceFormattedSpinButton, ::FormattedField>
+{
+public:
+    JSFormattedSpinButton(JSDialogSender* pSender, ::FormattedField* pSpin,
+                          SalInstanceBuilder* pBuilder, bool bTakeOwnership);
+
+    virtual void set_text(const OUString& rText) override;
+    void set_text_without_notify(const OUString& rText);
+};
+
 class JSMessageDialog final : public JSWidget<SalInstanceMessageDialog, 
::MessageDialog>
 {
     std::unique_ptr<JSDialogSender> m_pOwnedSender;
diff --git a/vcl/jsdialog/executor.cxx b/vcl/jsdialog/executor.cxx
index 98babfb65023..25e1af80b324 100644
--- a/vcl/jsdialog/executor.cxx
+++ b/vcl/jsdialog/executor.cxx
@@ -333,6 +333,18 @@ bool ExecuteAction(const OUString& nWindowId, const 
OUString& rWidget, StringMap
                     return true;
                 }
             }
+
+            auto pFormattedField = 
dynamic_cast<weld::FormattedSpinButton*>(pWidget);
+            if (pFormattedField)
+            {
+                if (sAction == "change")
+                {
+                    pFormattedField->set_text(rData["data"]);
+                    LOKTrigger::trigger_changed(*pFormattedField);
+                    LOKTrigger::trigger_value_changed(*pFormattedField);
+                    return true;
+                }
+            }
         }
         else if (sControlType == "toolbox")
         {
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 0f2f23950add..34b28184cc16 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1066,6 +1066,20 @@ std::unique_ptr<weld::SpinButton> 
JSInstanceBuilder::weld_spin_button(const OUSt
     return pWeldWidget;
 }
 
+std::unique_ptr<weld::FormattedSpinButton>
+JSInstanceBuilder::weld_formatted_spin_button(const OUString& id)
+{
+    FormattedField* pSpinButton = m_xBuilder->get<FormattedField>(id);
+    auto pWeldWidget = pSpinButton
+                           ? std::make_unique<JSFormattedSpinButton>(this, 
pSpinButton, this, false)
+                           : nullptr;
+
+    if (pWeldWidget)
+        RememberWidget(id, pWeldWidget.get());
+
+    return pWeldWidget;
+}
+
 std::unique_ptr<weld::CheckButton> JSInstanceBuilder::weld_check_button(const 
OUString& id)
 {
     CheckBox* pCheckButton = m_xBuilder->get<CheckBox>(id);
@@ -1682,6 +1696,24 @@ void JSSpinButton::set_value(sal_Int64 value)
     sendAction(std::move(pMap));
 }
 
+JSFormattedSpinButton::JSFormattedSpinButton(JSDialogSender* pSender, 
::FormattedField* pSpin,
+                                             SalInstanceBuilder* pBuilder, 
bool bTakeOwnership)
+    : JSWidget<SalInstanceFormattedSpinButton, ::FormattedField>(pSender, 
pSpin, pBuilder,
+                                                                 
bTakeOwnership)
+{
+}
+
+void JSFormattedSpinButton::set_text(const OUString& rText)
+{
+    SalInstanceFormattedSpinButton::set_text(rText);
+    sendUpdate();
+}
+
+void JSFormattedSpinButton::set_text_without_notify(const OUString& rText)
+{
+    SalInstanceFormattedSpinButton::set_text(rText);
+}
+
 JSMessageDialog::JSMessageDialog(JSDialogSender* pSender, ::MessageDialog* 
pDialog,
                                  SalInstanceBuilder* pBuilder, bool 
bTakeOwnership)
     : JSWidget<SalInstanceMessageDialog, ::MessageDialog>(pSender, pDialog, 
pBuilder,

Reply via email to