[Libreoffice-commits] core.git: Branch 'feature/jssidebar' - 9 commits - chart2/source desktop/source include/sfx2 include/svx sfx2/sdi sfx2/source

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Mon Dec 16 15:13:24 UTC 2019


Rebased ref, commits from common ancestor:
commit b87bab9109df4eb134e18ac2884ea39382827c13
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Dec 15 21:12:17 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:12:01 2019 +0000

    sfx2: sidebar: new .uno commands to show and hide sidebars.
    
    Change-Id: I9afba5eec855d6de590086736177b543d52d3b20
    Reviewed-on: https://gerrit.libreoffice.org/85192
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 81c02c2c5d22..ad44965df7dd 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3310,12 +3310,12 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin
     }
     else if (aMap.find("id") != aMap.end())
     {
-        const OUString sClickAction("CLICK");
-        const OUString sSelectAction("SELECT");
-        const OUString sClearAction("CLEAR");
-        const OUString sTypeAction("TYPE");
-        const OUString sUpAction("UP");
-        const OUString sDownAction("DOWN");
+        static const OUString sClickAction("CLICK");
+        static const OUString sSelectAction("SELECT");
+        static const OUString sClearAction("CLEAR");
+        static const OUString sTypeAction("TYPE");
+        static const OUString sUpAction("UP");
+        static const OUString sDownAction("DOWN");
 
         try
         {
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 9fa90a5f6226..f7d77257350c 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -575,6 +575,8 @@ class SvxSearchItem;
 #define SID_TABLE_BORDER_TYPE               (SID_SVX_START + 1065)
 #define SID_TABLE_BORDER_INDEX              (SID_SVX_START + 1066)
 #define SID_TABLE_BORDER_OFFSET             (SID_SVX_START + 1067)
+#define SID_SHOW_SIDEBAR                    (SID_SVX_START + 1200)
+#define SID_HIDE_SIDEBAR                    (SID_SVX_START + 1201)
 
 #define FID_SVX_START                       (SID_LIB_START + 500)
 #define FID_SEARCH_NOW                      (FID_SVX_START + 2)
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index f12a326d0d2a..09fa766fbb5b 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -999,8 +999,11 @@ class SvxSetItem;
 #define SID_ULINE_VAL_DOUBLE                            (SID_SVX_START + 1197) /* double underline */
 #define SID_ULINE_VAL_DOTTED                            (SID_SVX_START + 1198) /* dotted underline */
 
+// #define SID_SHOW_SIDEBAR                                ( SID_SVX_START + 1200 ) -> sfxsids.hrc
+// #define SID_HIDE_SIDEBAR                                ( SID_SVX_START + 1201 ) -> sfxsids.hrc
+
 // IMPORTANT NOTE: adjust SID_SVX_FIRSTFREE, when adding new slot id
-#define SID_SVX_FIRSTFREE                               ( SID_SVX_START + 1198 + 1 )
+#define SID_SVX_FIRSTFREE                               ( SID_HIDE_SIDEBAR + 1 )
 
 // Overflow check for slot IDs
 #if SID_SVX_FIRSTFREE > SID_SVX_END
diff --git a/sfx2/sdi/frmslots.sdi b/sfx2/sdi/frmslots.sdi
index 09aafef95b7d..53a13b479a7c 100644
--- a/sfx2/sdi/frmslots.sdi
+++ b/sfx2/sdi/frmslots.sdi
@@ -43,6 +43,16 @@ interface Window
         ExecMethod = ChildWindowExecute ;
         StateMethod = ChildWindowState ;
     ]
+    SID_SHOW_SIDEBAR // status(final|play)
+    [
+        ExecMethod = ChildWindowExecute ;
+        StateMethod = ChildWindowState ;
+    ]
+    SID_HIDE_SIDEBAR // status(final|play)
+    [
+        ExecMethod = ChildWindowExecute ;
+        StateMethod = ChildWindowState ;
+    ]
     SID_BROWSER // ole(no) api()
     [
         ExecMethod = ChildWindowExecute ;
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 624abe196661..f95610d07f5c 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -2594,6 +2594,42 @@ SfxBoolItem Sidebar SID_SIDEBAR
     GroupId = SfxGroupId::View;
 ]
 
+SfxBoolItem SidebarShow SID_SHOW_SIDEBAR
+[
+    AutoUpdate = TRUE,
+    FastCall = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Asynchron;
+
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::View;
+]
+
+SfxBoolItem SidebarHide SID_HIDE_SIDEBAR
+[
+    AutoUpdate = TRUE,
+    FastCall = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Asynchron;
+
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::View;
+]
+
 SfxBoolItem Menubar SID_MENUBAR
 [
     AutoUpdate = TRUE,
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 335b634da6e3..8d5e7f154650 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -1223,7 +1223,7 @@ void SidebarController::RequestCloseDeck()
             // Mobile.
             std::stringstream aStream;
             boost::property_tree::ptree aTree;
-            aTree.put("id", mpParentWindow->get_id()); // TODO could be missing - sort out
+            aTree.put("id", mpCurrentDeck->GetLOKWindowId());
             aTree.put("type", "dockingwindow");
             aTree.put("text", mpParentWindow->GetText());
             aTree.put("enabled", false);
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 0ee2117875a5..5f731f6400a7 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -69,7 +69,9 @@ public:
             {
                 // Mobile.
                 std::stringstream aStream;
-                boost::property_tree::write_json(aStream, m_rSidebarDockingWin.DumpAsPropertyTree());
+                boost::property_tree::ptree aTree = m_rSidebarDockingWin.DumpAsPropertyTree();
+                aTree.put("id", m_rSidebarDockingWin.GetLOKWindowId());
+                boost::property_tree::write_json(aStream, aTree);
                 const std::string message = aStream.str();
                 if (message != m_LastNotificationMessage)
                 {
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 81f9d1fd4bdd..a19a89a91b91 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3217,17 +3217,28 @@ void SfxViewFrame::ChildWindowState( SfxItemSet& rState )
             else if ( KnowsChildWindow(nSID) )
                 rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
         }
-        else if ( nSID == SID_SIDEBAR )
+        else if ( nSID == SID_SIDEBAR || nSID == SID_SHOW_SIDEBAR || nSID == SID_HIDE_SIDEBAR )
         {
-            if  ( !KnowsChildWindow( nSID ) )
+            if  ( !KnowsChildWindow( SID_SIDEBAR ) )
             {
                 SAL_WARN("sfx.view", "SID_SIDEBAR state requested, but no task pane child window exists for this ID!");
-                rState.DisableItem( nSID );
+                rState.DisableItem( SID_SIDEBAR );
             }
-            else
+            else if ( nSID == SID_SIDEBAR )
             {
+                // Toggle.
                 rState.Put( SfxBoolItem( nSID, HasChildWindow( nSID ) ) );
             }
+            else if ( nSID == SID_SHOW_SIDEBAR )
+            {
+                // Show.
+                rState.Put( SfxBoolItem( nSID, false ) );
+            }
+            else if ( nSID == SID_HIDE_SIDEBAR )
+            {
+                // Hide.
+                rState.Put( SfxBoolItem( nSID, true ) );
+            }
         }
         else if ( KnowsChildWindow(nSID) )
             rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
commit 4562080724493e8890a2c08268959553c25f0cd0
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Wed Dec 11 18:19:43 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:12:00 2019 +0000

    chart2: clear listener parents in dispose
    
    Change-Id: Icdab125589ab0f55255f683a1ea39e036de661b1
    Reviewed-on: https://gerrit.libreoffice.org/84997
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx
index 2a3bd54a85e6..0971fd079ca1 100644
--- a/chart2/source/controller/main/ChartWindow.cxx
+++ b/chart2/source/controller/main/ChartWindow.cxx
@@ -74,6 +74,7 @@ ChartWindow::~ChartWindow()
 
 void ChartWindow::dispose()
 {
+    m_pWindowController = nullptr;
     m_pViewShellWindow.clear();
     vcl::Window::dispose();
 }
diff --git a/chart2/source/controller/sidebar/ChartSidebarModifyListener.cxx b/chart2/source/controller/sidebar/ChartSidebarModifyListener.cxx
index b000e55c5aa6..0fa0b793b5b6 100644
--- a/chart2/source/controller/sidebar/ChartSidebarModifyListener.cxx
+++ b/chart2/source/controller/sidebar/ChartSidebarModifyListener.cxx
@@ -27,12 +27,17 @@ ChartSidebarModifyListener::~ChartSidebarModifyListener()
 
 void ChartSidebarModifyListener::modified(const css::lang::EventObject& /*rEvent*/)
 {
-    mpParent->updateData();
+    if (mpParent)
+        mpParent->updateData();
 }
 
 void ChartSidebarModifyListener::disposing(const css::lang::EventObject& /*rEvent*/)
 {
+    if (!mpParent)
+        return;
+
     mpParent->modelInvalid();
+    mpParent = nullptr;
 }
 
 } }
diff --git a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx
index e037fc39aa5f..e7d74c656a55 100644
--- a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx
+++ b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx
@@ -41,6 +41,9 @@ ChartSidebarSelectionListener::~ChartSidebarSelectionListener()
 
 void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObject& rEvent)
 {
+    if (!mpParent)
+        return;
+
     bool bCorrectObjectSelected = false;
 
     css::uno::Reference<css::frame::XController> xController(rEvent.Source, css::uno::UNO_QUERY);
@@ -66,6 +69,10 @@ void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObjec
 
 void ChartSidebarSelectionListener::disposing(const css::lang::EventObject& /*rEvent*/)
 {
+    if (!mpParent)
+        return;
+
+    mpParent = nullptr;
 }
 
 void ChartSidebarSelectionListener::setAcceptedTypes(const std::vector<ObjectType>& aTypes)
commit c9904148a21d00a0b1cce1932908e394311b3a83
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Wed Dec 11 12:23:08 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:11:58 2019 +0000

    sfx2: sidebar: notify mobile when the sidebar closes
    
    Change-Id: Idb05346a9ccc8690cad566b74ec86d5fdd3bfb35
    Reviewed-on: https://gerrit.libreoffice.org/84973
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 14c78d918494..335b634da6e3 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -53,6 +53,8 @@
 #include <sal/log.hxx>
 #include <officecfg/Office/UI/Sidebar.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/json_parser.hpp>
 
 #include <com/sun/star/awt/XWindowPeer.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
@@ -1215,7 +1217,21 @@ void SidebarController::RequestCloseDeck()
     if (comphelper::LibreOfficeKit::isActive() && mpCurrentDeck.get())
     {
         const vcl::ILibreOfficeKitNotifier* pNotifier = mpCurrentDeck->GetLOKNotifier();
-        if (pNotifier)
+        auto pMobileNotifier = SfxViewShell::Current();
+        if (pMobileNotifier && comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()))
+        {
+            // Mobile.
+            std::stringstream aStream;
+            boost::property_tree::ptree aTree;
+            aTree.put("id", mpParentWindow->get_id()); // TODO could be missing - sort out
+            aTree.put("type", "dockingwindow");
+            aTree.put("text", mpParentWindow->GetText());
+            aTree.put("enabled", false);
+            boost::property_tree::write_json(aStream, aTree);
+            const std::string message = aStream.str();
+            pMobileNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+        }
+        else if (pNotifier)
             pNotifier->notifyWindow(mpCurrentDeck->GetLOKWindowId(), "close");
     }
 
commit fe5b490f51e9c293bda2e8f300c6502ffcc5ae59
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Dec 8 12:36:58 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:11:57 2019 +0000

    sidebar: sensible line and page sizes and invalidate
    
    Change-Id: Icf60480a47d7c93bad44f6457bb05af332e63c6d
    Reviewed-on: https://gerrit.libreoffice.org/84718
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index d6c485b1f3c8..aeaf6274e6f9 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -65,6 +65,8 @@ Deck::Deck(const DeckDescriptor& rDeckDescriptor, vcl::Window* pParentWindow,
     mpScrollContainer->Show();
 
     mpVerticalScrollBar->SetScrollHdl(LINK(this, Deck, HandleVerticalScrollBarChange));
+    mpVerticalScrollBar->SetLineSize(10);
+    mpVerticalScrollBar->SetPageSize(100);
 
 #ifdef DEBUG
     SetText(OUString("Deck"));
@@ -353,6 +355,7 @@ IMPL_LINK_NOARG(Deck, HandleVerticalScrollBarChange, ScrollBar*, void)
     const sal_Int32 nYOffset (-mpVerticalScrollBar->GetThumbPos());
     mpScrollContainer->SetPosPixel(Point(mpScrollContainer->GetPosPixel().X(),
                                          nYOffset));
+    mpScrollContainer->Invalidate();
 }
 
 //----- Deck::ScrollContainerWindow -------------------------------------------
commit f3c8d01b339861df972f54f36f54542ccb91dfe1
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Wed Dec 4 08:19:22 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:11:56 2019 +0000

    LOK: don't send LOK notifications while switching views
    
    Changing the active view is done for virtually every
    LOK API, and in some cases simply changing the view
    results in a flurry of notifications that themselves
    caues further API calls that need to change the view.
    
    This moves the disabling of callbacks during setView
    to SfxLokHelper to make sure no view gets any
    notifications. This is needed because even when
    we disable notifications for the current view,
    the _other_ view(s) can still get notified as they
    lose their frame.
    
    Change-Id: Ia88a58d6a1162e48c40f4c4ce73c40ecb2c1fb7e
    Reviewed-on: https://gerrit.libreoffice.org/84417
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 68b75b3d181c..81c02c2c5d22 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -4634,28 +4634,14 @@ static void doc_destroyView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis
     SfxLokHelper::destroyView(nId);
 }
 
-static void doc_setView(LibreOfficeKitDocument* pThis, int nId)
+static void doc_setView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, int nId)
 {
     comphelper::ProfileZone aZone("doc_setView");
 
     SolarMutexGuard aGuard;
     SetLastExceptionMsg();
 
-    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-    const auto handlerIt = pDocument->mpCallbackFlushHandlers.find(nId);
-    if (handlerIt != pDocument->mpCallbackFlushHandlers.end())
-        handlerIt->second->disableCallbacks();
-
-    try
-    {
-        SfxLokHelper::setView(nId);
-    }
-    catch (const std::exception&)
-    {
-    }
-
-    if (handlerIt != pDocument->mpCallbackFlushHandlers.end())
-        handlerIt->second->enableCallbacks();
+    SfxLokHelper::setView(nId);
 }
 
 static int doc_getView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/)
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 4670bd098663..9a160b79d413 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -34,6 +34,34 @@
 
 using namespace com::sun::star;
 
+/// Used to disable callbacks.
+/// Needed to avoid recursion when switching views,
+/// which can cause clients to invoke LOKit API and
+/// implicitly set the view, which might cause an
+/// infinite recursion if not detected and prevented.
+class DisableCallbacks
+{
+public:
+    DisableCallbacks()
+    {
+        assert(m_nDisabled >= 0 && "Expected non-negative DisabledCallbacks state when disabling.");
+        ++m_nDisabled;
+    }
+
+    ~DisableCallbacks()
+    {
+        assert(m_nDisabled > 0 && "Expected positive DisabledCallbacks state when re-enabling.");
+        --m_nDisabled;
+    }
+
+    static bool disabled() { return m_nDisabled != 0; }
+
+private:
+    static int m_nDisabled;
+};
+
+int DisableCallbacks::m_nDisabled = 0;
+
 int SfxLokHelper::createView()
 {
     SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
@@ -81,6 +109,8 @@ void SfxLokHelper::setView(int nId)
     {
         if (static_cast<sal_Int32>(pViewShell->GetViewShellId()) == nViewShellId)
         {
+            DisableCallbacks dc;
+
             // update the current LOK language for the dialog tunneling
             comphelper::LibreOfficeKit::setLanguageTag(pViewShell->GetLOKLanguageTag());
 
@@ -166,6 +196,9 @@ static OString lcl_escapeQuotes(const OString &rStr)
 
 void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload)
 {
+    if (DisableCallbacks::disabled())
+        return;
+
     OString aPayload = OStringLiteral("{ \"viewId\": \"") + OString::number(SfxLokHelper::getView(pThisView)) +
                        "\", \"part\": \"" + OString::number(pThisView->getPart()) +
                        "\", \"" + rKey + "\": \"" + lcl_escapeQuotes(rPayload) + "\" }";
@@ -175,7 +208,7 @@ void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell const*
 
 void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload)
 {
-    if (SfxLokHelper::getViewsCount() <= 1)
+    if (SfxLokHelper::getViewsCount() <= 1 || DisableCallbacks::disabled())
         return;
 
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
@@ -212,7 +245,7 @@ namespace {
 
 void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem)
 {
-    if (!pShell || !pItem || pItem == INVALID_POOL_ITEM)
+    if (!pShell || !pItem || pItem == INVALID_POOL_ITEM || DisableCallbacks::disabled())
         return;
 
     boost::property_tree::ptree aItem = pItem->dumpAsJSON();
@@ -236,7 +269,7 @@ void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView,
 {
     assert(pThisView);
 
-    if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0)
+    if (SfxLokHelper::getViewsCount() <= 0 || nLOKWindowId == 0 || DisableCallbacks::disabled())
         return;
 
     OStringBuffer aPayload;
@@ -260,6 +293,10 @@ void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView,
 void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload)
 {
     OStringBuffer aBuf(32);
+
+    if (DisableCallbacks::disabled())
+        return;
+
     aBuf.append(rPayload);
     if (comphelper::LibreOfficeKit::isPartInInvalidation())
     {
@@ -271,10 +308,7 @@ void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OStri
 
 void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, const OString& rPayload, vcl::ITiledRenderable* pDoc, bool bInvalidateAll)
 {
-    if (!comphelper::LibreOfficeKit::isActive())
-        return;
-
-    if (!pDoc)
+    if (!pDoc || !comphelper::LibreOfficeKit::isActive() || DisableCallbacks::disabled())
         return;
 
     if (bInvalidateAll)
@@ -291,7 +325,7 @@ void SfxLokHelper::notifyDocumentSizeChanged(SfxViewShell const* pThisView, cons
 
 void SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, bool bInvalidateAll)
 {
-    if (!comphelper::LibreOfficeKit::isActive())
+    if (!comphelper::LibreOfficeKit::isActive() || DisableCallbacks::disabled())
         return;
 
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
@@ -304,6 +338,9 @@ void SfxLokHelper::notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc
 
 void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle)
 {
+    if (DisableCallbacks::disabled())
+        return;
+
     OString sPayload;
     if (comphelper::LibreOfficeKit::isViewIdForVisCursorInvalidation())
     {
@@ -319,6 +356,9 @@ void SfxLokHelper::notifyVisCursorInvalidation(OutlinerViewShell const* pThisVie
 
 void SfxLokHelper::notifyAllViews(int nType, const OString& rPayload)
 {
+    if (DisableCallbacks::disabled())
+        return;
+
     const auto payload = rPayload.getStr();
     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     while (pViewShell)
@@ -330,6 +370,9 @@ void SfxLokHelper::notifyAllViews(int nType, const OString& rPayload)
 
 void SfxLokHelper::notifyContextChange(SfxViewShell const* pViewShell, const OUString& aApplication, const OUString& aContext)
 {
+    if (DisableCallbacks::disabled())
+        return;
+
     OString aBuffer =
         OUStringToOString(aApplication.replace(' ', '_'), RTL_TEXTENCODING_UTF8) +
         " " +
commit c6e36352d7002ddb7ebed0c844e285736f69e363
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Dec 3 17:31:08 2019 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:11:55 2019 +0000

    jsdialogs: make possible to use on multiple mobile devices
    
    Change-Id: I1f7867dfd15e423f10622b3cec17ed8039d23c49
    Reviewed-on: https://gerrit.libreoffice.org/84367
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 3aba87450c4f..0ee2117875a5 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -59,7 +59,8 @@ public:
     void Invoke() override
     {
         auto pNotifier = m_rSidebarDockingWin.GetLOKNotifier();
-        if (!pNotifier || !comphelper::LibreOfficeKit::isActive())
+        auto pMobileNotifier = SfxViewShell::Current();
+        if (!pNotifier || (!pMobileNotifier && !comphelper::LibreOfficeKit::isActive()))
             return;
 
         try
@@ -73,7 +74,7 @@ public:
                 if (message != m_LastNotificationMessage)
                 {
                     m_LastNotificationMessage = message;
-                    pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+                    pMobileNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
                 }
             }
             else
commit 8ed67703117583e08dd49a46e19133798b4f9a7d
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Tue Dec 3 09:23:27 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:11:53 2019 +0000

    sidebar: always trigger LOK notifications on resize
    
    This is critical for the Mobile Wizard, which
    refreshes by pushing, not pulling (following invalidations).
    
    Change-Id: Ie75c2f5c07798fa89c21901d6d0233c42768ea8d
    Reviewed-on: https://gerrit.libreoffice.org/84359
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index bb6a08e48d8e..3aba87450c4f 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -195,8 +195,9 @@ void SidebarDockingWindow::NotifyResize()
             LOKClose();
 
             SetLOKNotifier(pCurrentView);
-            mpIdleNotify->Start();
         }
+
+        mpIdleNotify->Start();
     }
 }
 
commit c2e0621caf5e45ff16757e697c087a7737ec7b67
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Fri May 24 09:11:11 2019 -0400
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:11:52 2019 +0000

    sfx2: LOK: disable the Reset button from tabbed dialogs
    
    The reset functionality seems to be confusing to more
    than one user. Their expectation isn't always matching
    the functionality, perhaps because it has rough edges(?).
    
    Disabling for LOK to avoid this; users can Cancel
    and start over if they wish to do (which is what the
    Reset button is supposed to do in effect).
    
    (cherry picked from commit c3c28235cf1f853e644250ba110b2715a270a8b5)
    
    Change-Id: I4a744dd0263ab72a5858746c1f3572e62990a13b
    Reviewed-on: https://gerrit.libreoffice.org/83630
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 9b73516c97c2..e25c30baea5b 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -38,6 +38,7 @@
 #include <vcl/virdev.hxx>
 #include <sal/log.hxx>
 #include <osl/diagnose.h>
+#include <comphelper/lok.hxx>
 
 #include <sfx2/strings.hrc>
 #include <helpids.h>
@@ -353,6 +354,10 @@ SfxTabDialogController::SfxTabDialogController
         m_xExampleSet.reset(new SfxItemSet(*m_pSet));
         m_pOutSet.reset(new SfxItemSet(*m_pSet->GetPool(), m_pSet->GetRanges()));
     }
+
+    // The reset functionality seems to be confusing to many; disable in LOK.
+    if (comphelper::LibreOfficeKit::isActive())
+        RemoveResetButton();
 }
 
 IMPL_LINK_NOARG(SfxTabDialogController, OkHdl, weld::Button&, void)
commit 4cb650afabe29a84f452fae06c534818a684f778
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Nov 24 09:56:02 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Dec 16 15:11:51 2019 +0000

    sidebar: do not emit unnecessary created notifications
    
    This also breaks a potentially recursive cycle where
    each 'created' notification requests a re-rendering,
    which triggers view change (when more than one view
    is open on the doc), which triggers a frame change,
    which resets the sidebar, causing a 'created'
    notification, thereby starting the cycle anew.
    
    Change-Id: I1aafe7f45871748afb393fa55c357037215e6c33
    Reviewed-on: https://gerrit.libreoffice.org/83629
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 15f21057aa0e..bb6a08e48d8e 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -42,19 +42,23 @@ namespace sfx2 { namespace sidebar {
 
 class SidebarNotifyIdle : public Idle
 {
-    SidebarDockingWindow &mrSidebarDockingWin;
+    SidebarDockingWindow& m_rSidebarDockingWin;
+    std::string m_LastNotificationMessage;
+    vcl::LOKWindowId m_LastLOKWindowId;
 
 public:
     SidebarNotifyIdle(SidebarDockingWindow &rSidebarDockingWin) :
         Idle("Sidebar notify"),
-        mrSidebarDockingWin(rSidebarDockingWin)
+        m_rSidebarDockingWin(rSidebarDockingWin),
+        m_LastNotificationMessage(),
+        m_LastLOKWindowId(0)
     {
         SetPriority(TaskPriority::POST_PAINT);
     }
 
     void Invoke() override
     {
-        auto pNotifier = mrSidebarDockingWin.GetLOKNotifier();
+        auto pNotifier = m_rSidebarDockingWin.GetLOKNotifier();
         if (!pNotifier || !comphelper::LibreOfficeKit::isActive())
             return;
 
@@ -64,19 +68,36 @@ public:
             {
                 // Mobile.
                 std::stringstream aStream;
-                boost::property_tree::write_json(aStream, mrSidebarDockingWin.DumpAsPropertyTree());
-                pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aStream.str().c_str());
+                boost::property_tree::write_json(aStream, m_rSidebarDockingWin.DumpAsPropertyTree());
+                const std::string message = aStream.str();
+                if (message != m_LastNotificationMessage)
+                {
+                    m_LastNotificationMessage = message;
+                    pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+                }
             }
             else
             {
                 // On desktop use the classic notifications.
-                std::vector<vcl::LOKPayloadItem> aItems;
-                aItems.emplace_back("type", "deck");
-                const Point pos = Point(mrSidebarDockingWin.GetOutOffXPixel(),
-                                        mrSidebarDockingWin.GetOutOffYPixel());
-                aItems.emplace_back("position", pos.toString());
-                aItems.emplace_back("size", mrSidebarDockingWin.GetSizePixel().toString());
-                pNotifier->notifyWindow(mrSidebarDockingWin.GetLOKWindowId(), "created", aItems);
+                const Point pos(m_rSidebarDockingWin.GetOutOffXPixel(),
+                                m_rSidebarDockingWin.GetOutOffYPixel());
+                const OString posMessage = pos.toString();
+                const OString sizeMessage = m_rSidebarDockingWin.GetSizePixel().toString();
+
+                const std::string message = OString(posMessage + sizeMessage).getStr();
+                const vcl::LOKWindowId lokWindowId = m_rSidebarDockingWin.GetLOKWindowId();
+
+                if (lokWindowId != m_LastLOKWindowId || message != m_LastNotificationMessage)
+                {
+                    m_LastLOKWindowId = lokWindowId;
+                    m_LastNotificationMessage = message;
+
+                    std::vector<vcl::LOKPayloadItem> aItems;
+                    aItems.emplace_back("type", "deck");
+                    aItems.emplace_back("position", posMessage);
+                    aItems.emplace_back("size", sizeMessage);
+                    pNotifier->notifyWindow(lokWindowId, "created", aItems);
+                }
             }
         }
         catch (boost::property_tree::json_parser::json_parser_error& rError)


More information about the Libreoffice-commits mailing list