include/sfx2/sidebar/SidebarController.hxx   |   13 +---
 sd/source/ui/view/drviewse.cxx               |    5 +
 sfx2/source/sidebar/SidebarController.cxx    |   86 +++++++++++++++++++++++----
 sfx2/source/sidebar/SidebarDockingWindow.cxx |    3 
 4 files changed, 88 insertions(+), 19 deletions(-)

New commits:
commit 80eb913d5944e88297b0734991bcf6c1cfb34463
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Wed Dec 12 03:01:31 2018 -0500
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Jul 26 20:22:05 2019 +0200

    sfx: LOK: notify clients of the sidebar state
    
    Change-Id: I35b174c3a5e302ce52ee4063fa71d47feffab624
    Reviewed-on: https://gerrit.libreoffice.org/73520
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/include/sfx2/sidebar/SidebarController.hxx 
b/include/sfx2/sidebar/SidebarController.hxx
index d6c8d54f7e8a..286036b6f141 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -28,6 +28,7 @@
 #include <sfx2/sidebar/FocusManager.hxx>
 #include <sfx2/sidebar/ResourceManager.hxx>
 #include <sfx2/sidebar/TabBar.hxx>
+#include <sfx2/viewfrm.hxx>
 
 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
 #include <com/sun/star/frame/XStatusListener.hpp>
@@ -63,9 +64,8 @@ class SFX2_DLLPUBLIC SidebarController
       public SidebarControllerInterfaceBase
 {
 public:
-    static rtl::Reference<SidebarController> create(
-        SidebarDockingWindow* pParentWindow,
-        const css::uno::Reference<css::frame::XFrame>& rxFrame);
+    static rtl::Reference<SidebarController> create(SidebarDockingWindow* 
pParentWindow,
+                                                    const SfxViewFrame* 
pViewFrame);
     virtual ~SidebarController() override;
     SidebarController(const SidebarController&) = delete;
     SidebarController& operator=( const SidebarController& ) = delete;
@@ -168,14 +168,13 @@ public:
     void setMaximumWidth(sal_Int32 nMaximumWidth) { mnMaximumSidebarWidth = 
nMaximumWidth; }
 
 private:
-    SidebarController(
-        SidebarDockingWindow* pParentWindow,
-        const css::uno::Reference<css::frame::XFrame>& rxFrame);
+    SidebarController(SidebarDockingWindow* pParentWindow, const SfxViewFrame* 
pViewFrame);
 
     VclPtr<Deck> mpCurrentDeck;
     VclPtr<SidebarDockingWindow> mpParentWindow;
-    VclPtr<TabBar> mpTabBar;
+    const SfxViewFrame* mpViewFrame;
     css::uno::Reference<css::frame::XFrame> mxFrame;
+    VclPtr<TabBar> mpTabBar;
     Context maCurrentContext;
     Context maRequestedContext;
     css::uno::Reference<css::frame::XController> mxCurrentController;
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 924b27aeb4bb..d825e4fc0c84 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/uno/Any.hxx>
 
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <comphelper/lok.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <undo/undomanager.hxx>
@@ -1031,6 +1032,10 @@ void DrawViewShell::FuSupport(SfxRequest& rReq)
 
         case SID_MASTERPAGE:          // BASIC
         {
+            if (comphelper::LibreOfficeKit::isActive())
+                
GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
+                                                           
".uno:SlideMasterPage=true");
+
             // AutoLayouts needs to be finished
             GetDoc()->StopWorkStartupDelay();
 
diff --git a/sfx2/source/sidebar/SidebarController.cxx 
b/sfx2/source/sidebar/SidebarController.cxx
index 83ff4c5354c6..a0f9cbd1dae4 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -52,6 +52,7 @@
 #include <comphelper/lok.hxx>
 #include <sal/log.hxx>
 #include <officecfg/Office/UI/Sidebar.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
 
 #include <com/sun/star/awt/XWindowPeer.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
@@ -72,6 +73,32 @@ namespace
     const static char gsReadOnlyCommandName[] = ".uno:EditDoc";
     const static sal_Int32 gnWidthCloseThreshold (70);
     const static sal_Int32 gnWidthOpenThreshold (40);
+
+    std::string UnoNameFromDeckId(const OUString& rsDeckId)
+    {
+        if (rsDeckId == "SdCustomAnimationDeck")
+            return ".uno:CustomAnimation";
+
+        if (rsDeckId == "PropertyDeck")
+            return ".uno:ModifyPage";
+
+        if (rsDeckId == "SdLayoutsDeck")
+            return ".uno:ModifyPage";
+
+        if (rsDeckId == "SdSlideTransitionDeck")
+            return ".uno:SlideChangeWindow";
+
+        if (rsDeckId == "SdAllMasterPagesDeck")
+            return ".uno:MasterSlidesPanel";
+
+        if (rsDeckId == "SdMasterPagesDeck")
+            return ".uno:MasterSlidesPanel";
+
+        if (rsDeckId == "GalleryDeck")
+            return ".uno:Gallery";
+
+        return "";
+    }
 }
 
 namespace sfx2 { namespace sidebar {
@@ -95,17 +122,18 @@ namespace {
 
 SidebarController::SidebarController (
     SidebarDockingWindow* pParentWindow,
-    const css::uno::Reference<css::frame::XFrame>& rxFrame)
+    const SfxViewFrame* pViewFrame)
     : SidebarControllerInterfaceBase(m_aMutex),
       mpCurrentDeck(),
       mpParentWindow(pParentWindow),
+      mpViewFrame(pViewFrame),
+      mxFrame(pViewFrame->GetFrame().GetFrameInterface()),
       mpTabBar(VclPtr<TabBar>::Create(
               mpParentWindow,
-              rxFrame,
+              mxFrame,
               [this](const OUString& rsDeckId) { return 
this->OpenThenToggleDeck(rsDeckId); },
               [this](const tools::Rectangle& rButtonBox,const 
::std::vector<TabBar::DeckMenuData>& rMenuData) { return 
this->ShowPopupMenu(rButtonBox,rMenuData); },
               this)),
-      mxFrame(rxFrame),
       maCurrentContext(OUString(), OUString()),
       maRequestedContext(),
       mnRequestedForceFlags(SwitchFlag_NoForce),
@@ -130,13 +158,12 @@ SidebarController::SidebarController (
     mpResourceManager = std::make_unique<ResourceManager>();
 }
 
-rtl::Reference<SidebarController> SidebarController::create(
-    SidebarDockingWindow* pParentWindow,
-    const css::uno::Reference<css::frame::XFrame>& rxFrame)
+rtl::Reference<SidebarController> 
SidebarController::create(SidebarDockingWindow* pParentWindow,
+                                                            const 
SfxViewFrame* pViewFrame)
 {
-    rtl::Reference<SidebarController> instance(
-        new SidebarController(pParentWindow, rxFrame));
+    rtl::Reference<SidebarController> instance(new 
SidebarController(pParentWindow, pViewFrame));
 
+    const css::uno::Reference<css::frame::XFrame>& rxFrame = 
pViewFrame->GetFrame().GetFrameInterface();
     registerSidebarForFrame(instance.get(), rxFrame->getController());
     rxFrame->addFrameActionListener(instance.get());
     // Listen for window events.
@@ -710,6 +737,22 @@ void SidebarController::SwitchToDeck (
         if (mpCurrentDeck)
             mpCurrentDeck->Hide();
 
+        if (comphelper::LibreOfficeKit::isActive())
+        {
+            if (const SfxViewShell* pViewShell = mpViewFrame->GetViewShell())
+            {
+                const std::string hide = UnoNameFromDeckId(msCurrentDeckId);
+                if (!hide.empty())
+                    
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
+                                                           (hide + 
"=false").c_str());
+
+                const std::string show = 
UnoNameFromDeckId(rDeckDescriptor.msId);
+                if (!show.empty())
+                    
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
+                                                           (show + 
"=true").c_str());
+            }
+        }
+
         msCurrentDeckId = rDeckDescriptor.msId;
     }
     mpTabBar->Invalidate();
@@ -1202,9 +1245,20 @@ void SidebarController::UpdateDeckOpenState()
             aNewSize.setWidth(mnSavedSidebarWidth);
 
             mpParentWindow->GetFloatingWindow()->SetPosSizePixel(aNewPos, 
aNewSize);
-            // Sidebar wide enought to render the menu; enable it.
+
             if (comphelper::LibreOfficeKit::isActive())
+            {
+                // Sidebar wide enought to render the menu; enable it.
                 mpTabBar->EnableMenuButton(true);
+
+                if (const SfxViewShell* pViewShell = 
mpViewFrame->GetViewShell())
+                {
+                    const std::string uno = UnoNameFromDeckId(msCurrentDeckId);
+                    if (!uno.empty())
+                        
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
+                                                                (uno + 
"=true").c_str());
+                }
+            }
         }
     }
     else
@@ -1229,10 +1283,22 @@ void SidebarController::UpdateDeckOpenState()
                 aNewSize.setWidth(nTabBarDefaultWidth);
 
             mpParentWindow->GetFloatingWindow()->SetPosSizePixel(aNewPos, 
aNewSize);
-            // Sidebar too narrow to render the menu; disable it.
+
             if (comphelper::LibreOfficeKit::isActive())
+            {
+                // Sidebar too narrow to render the menu; disable it.
                 mpTabBar->EnableMenuButton(false);
+
+                if (const SfxViewShell* pViewShell = 
mpViewFrame->GetViewShell())
+                {
+                    const std::string uno = UnoNameFromDeckId(msCurrentDeckId);
+                    if (!uno.empty())
+                        
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
+                                                                (uno + 
"=false").c_str());
+                }
+            }
         }
+
         if (mnWidthOnSplitterButtonDown > nTabBarDefaultWidth)
             mnSavedSidebarWidth = mnWidthOnSplitterButtonDown;
         mpParentWindow->SetStyle(mpParentWindow->GetStyle() & ~WB_SIZEABLE);
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx 
b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index f76e71fc2d45..08b1040f523e 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -54,8 +54,7 @@ SidebarDockingWindow::SidebarDockingWindow(SfxBindings* 
pSfxBindings, SidebarChi
     else
     {
         const SfxViewFrame* pViewFrame = 
pSfxBindings->GetDispatcher()->GetFrame();
-        const SfxFrame& rFrame = pViewFrame->GetFrame();
-        mpSidebarController.set(sfx2::sidebar::SidebarController::create(this, 
rFrame.GetFrameInterface()).get());
+        mpSidebarController.set(sfx2::sidebar::SidebarController::create(this, 
pViewFrame).get());
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to