2a8c10c
From ea117175b56ea059407da3b4e840ccc96e6f78b0 Mon Sep 17 00:00:00 2001
2a8c10c
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
2a8c10c
Date: Fri, 3 Jun 2016 11:06:22 +0100
2a8c10c
Subject: [PATCH] on switching to slide layouts panel move into slide layout
2a8c10c
 context
2a8c10c
2a8c10c
i.e. exit current textbox edit and shape selection
2a8c10c
2a8c10c
Change-Id: I16a2fca158cb4caab7b6bd001742df698735dd2b
2a8c10c
(cherry picked from commit 05aaef55252bc9f90cbbcc1967c38ab9a5a6c798)
2a8c10c
2a8c10c
OpenThenSwitchToDeck actually *toggles* deck visibility
2a8c10c
2a8c10c
so rename it to that and add a OpenThenSwitchToDeck that actually
2a8c10c
does that, using the Toggle varient as the callback from the
2a8c10c
sidebar button which toggles the current deck on/off
2a8c10c
2a8c10c
which retains the features of
2a8c10c
2a8c10c
// tdf#67627 Clicking a second time on a Deck icon will close the Deck
2a8c10c
// tdf#88241 Summoning an undocked sidebar a second time should close sidebar
2a8c10c
2a8c10c
but means that calls to OpenThenSwitchToDeck from e.g. slide layout
2a8c10c
don't auto close it if that deck is already open
2a8c10c
2a8c10c
(cherry picked from commit b81daea4a78083def286fa2d5360b152b7a703fd)
2a8c10c
2a8c10c
Change-Id: I3e3724626b93447a7ab6bc7032e9c6839dabcf55
2a8c10c
---
2a8c10c
 include/sfx2/sidebar/Sidebar.hxx              | 12 +++++++++++-
2a8c10c
 include/sfx2/sidebar/SidebarController.hxx    | 16 ++++++++--------
2a8c10c
 sd/source/ui/view/ViewShellImplementation.cxx |  2 ++
2a8c10c
 sfx2/source/sidebar/Sidebar.cxx               | 20 ++++++++++++++++++++
2a8c10c
 sfx2/source/sidebar/SidebarController.cxx     | 19 ++++++++++++++++---
2a8c10c
 sfx2/source/view/viewfrm.cxx                  |  4 ++--
2a8c10c
 6 files changed, 59 insertions(+), 14 deletions(-)
2a8c10c
2a8c10c
diff --git a/include/sfx2/sidebar/Sidebar.hxx b/include/sfx2/sidebar/Sidebar.hxx
2a8c10c
index aea1fcb..6b138b9 100644
2a8c10c
--- a/include/sfx2/sidebar/Sidebar.hxx
2a8c10c
+++ b/include/sfx2/sidebar/Sidebar.hxx
2a8c10c
@@ -38,7 +38,17 @@ public:
2a8c10c
         this function probably returns before the requested panel is visible.
2a8c10c
     */
2a8c10c
     static void ShowPanel (
2a8c10c
-        const ::rtl::OUString& rsPanelId,
2a8c10c
+        const OUString& rsPanelId,
2a8c10c
+        const css::uno::Reference<css::frame::XFrame>& rxFrame);
2a8c10c
+
2a8c10c
+    /** Switch to the deck that contains the specified panel and toggle
2a8c10c
+        the visibility of the panel (expanded and scrolled into the
2a8c10c
+        visible area when visible)
2a8c10c
+        Note that most of the work is done asynchronously and that
2a8c10c
+        this function probably returns before the requested panel is visible.
2a8c10c
+    */
2a8c10c
+    static void TogglePanel (
2a8c10c
+        const OUString& rsPanelId,
2a8c10c
         const css::uno::Reference<css::frame::XFrame>& rxFrame);
2a8c10c
 };
2a8c10c
 
2a8c10c
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
2a8c10c
index c077eeb..0298862 100644
2a8c10c
--- a/include/sfx2/sidebar/SidebarController.hxx
2a8c10c
+++ b/include/sfx2/sidebar/SidebarController.hxx
2a8c10c
@@ -124,8 +124,8 @@ public:
2a8c10c
 
2a8c10c
     const static sal_Int32 gnMaximumSidebarWidth = 400;
2a8c10c
 
2a8c10c
-    void OpenThenSwitchToDeck (
2a8c10c
-        const ::rtl::OUString& rsDeckId);
2a8c10c
+    void OpenThenSwitchToDeck(const OUString& rsDeckId);
2a8c10c
+    void OpenThenToggleDeck(const OUString& rsDeckId);
2a8c10c
 
2a8c10c
     /** Show only the tab bar, not the deck.
2a8c10c
     */
2a8c10c
@@ -137,7 +137,7 @@ public:
2a8c10c
 
2a8c10c
     /** Returns true when the given deck is the currently visible deck
2a8c10c
      */
2a8c10c
-    bool IsDeckVisible (const ::rtl::OUString& rsDeckId);
2a8c10c
+    bool IsDeckVisible(const OUString& rsDeckId);
2a8c10c
 
2a8c10c
     FocusManager& GetFocusManager() { return maFocusManager;}
2a8c10c
 
2a8c10c
@@ -148,14 +148,14 @@ public:
2a8c10c
     Context GetCurrentContext() const { return maCurrentContext;}
2a8c10c
     bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;}
2a8c10c
 
2a8c10c
-    void SwitchToDeck ( const ::rtl::OUString& rsDeckId);
2a8c10c
+    void SwitchToDeck(const OUString& rsDeckId);
2a8c10c
     void SwitchToDefaultDeck();
2a8c10c
 
2a8c10c
     void CreateDeck(const ::rtl::OUString& rDeckId, bool bForceCreate = false);
2a8c10c
     void CreatePanels(const ::rtl::OUString& rDeckId);
2a8c10c
 
2a8c10c
     ResourceManager::DeckContextDescriptorContainer GetMatchingDecks();
2a8c10c
-    ResourceManager::PanelContextDescriptorContainer GetMatchingPanels( const ::rtl::OUString& rDeckId);
2a8c10c
+    ResourceManager::PanelContextDescriptorContainer GetMatchingPanels(const OUString& rDeckId);
2a8c10c
 
2a8c10c
     void notifyDeckTitle(const OUString& targetDeckId);
2a8c10c
 
2a8c10c
@@ -174,7 +174,7 @@ private:
2a8c10c
     css::uno::Reference<css::frame::XController> mxCurrentController;
2a8c10c
     /// Use a combination of SwitchFlag_* as value.
2a8c10c
     sal_Int32 mnRequestedForceFlags;
2a8c10c
-    ::rtl::OUString msCurrentDeckId;
2a8c10c
+    OUString msCurrentDeckId;
2a8c10c
     AsynchronousCall maPropertyChangeForwarder;
2a8c10c
     AsynchronousCall maContextChangeUpdate;
2a8c10c
     AsynchronousCall maAsynchronousDeckSwitch;
2a8c10c
@@ -216,12 +216,12 @@ private:
2a8c10c
 
2a8c10c
     css::uno::Reference<css::ui::XUIElement> CreateUIElement (
2a8c10c
         const css::uno::Reference<css::awt::XWindowPeer>& rxWindow,
2a8c10c
-        const ::rtl::OUString& rsImplementationURL,
2a8c10c
+        const OUString& rsImplementationURL,
2a8c10c
         const bool bWantsCanvas,
2a8c10c
         const Context& rContext);
2a8c10c
 
2a8c10c
     VclPtr<Panel> CreatePanel (
2a8c10c
-        const ::rtl::OUString& rsPanelId,
2a8c10c
+        const OUString& rsPanelId,
2a8c10c
         vcl::Window* pParentWindow,
2a8c10c
         const bool bIsInitiallyExpanded,
2a8c10c
         const Context& rContext,
2a8c10c
diff --git a/sd/source/ui/view/ViewShellImplementation.cxx b/sd/source/ui/view/ViewShellImplementation.cxx
2a8c10c
index b523e03..7944304 100644
2a8c10c
--- a/sd/source/ui/view/ViewShellImplementation.cxx
2a8c10c
+++ b/sd/source/ui/view/ViewShellImplementation.cxx
2a8c10c
@@ -120,6 +120,8 @@ void ViewShell::Implementation::ProcessModifyPageSlot (
2a8c10c
         if (!pArgs || pArgs->Count() == 1 || pArgs->Count() == 2 )
2a8c10c
         {
2a8c10c
             // First make sure that the sidebar is visible
2a8c10c
+            mrViewShell.GetDrawView()->SdrEndTextEdit();
2a8c10c
+            mrViewShell.GetDrawView()->UnmarkAll();
2a8c10c
             mrViewShell.GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
2a8c10c
             sfx2::sidebar::Sidebar::ShowPanel(
2a8c10c
                 "SdLayoutsPanel",
2a8c10c
diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx
2a8c10c
index 88f0b06..148214b 100644
2a8c10c
--- a/sfx2/source/sidebar/Sidebar.cxx
2a8c10c
+++ b/sfx2/source/sidebar/Sidebar.cxx
2a8c10c
@@ -45,6 +45,26 @@ void Sidebar::ShowPanel (
2a8c10c
     }
2a8c10c
 }
2a8c10c
 
2a8c10c
+void Sidebar::TogglePanel (
2a8c10c
+    const ::rtl::OUString& rsPanelId,
2a8c10c
+    const css::uno::Reference<frame::XFrame>& rxFrame)
2a8c10c
+{
2a8c10c
+    SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame);
2a8c10c
+
2a8c10c
+    const PanelDescriptor* pPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId);
2a8c10c
+
2a8c10c
+    if (pController!=nullptr && pPanelDescriptor != nullptr)
2a8c10c
+    {
2a8c10c
+        // This should be a lot more sophisticated:
2a8c10c
+        // - Make the deck switching asynchronous
2a8c10c
+        // - Make sure to use a context that really shows the panel
2a8c10c
+
2a8c10c
+        // All that is not necessary for the current use cases so lets
2a8c10c
+        // keep it simple for the time being.
2a8c10c
+        pController->OpenThenToggleDeck(pPanelDescriptor->msDeckId);
2a8c10c
+    }
2a8c10c
+}
2a8c10c
+
2a8c10c
 } } // end of namespace sfx2::sidebar
2a8c10c
 
2a8c10c
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
2a8c10c
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
2a8c10c
index 55f4d0b..a9cf69b 100644
2a8c10c
--- a/sfx2/source/sidebar/SidebarController.cxx
2a8c10c
+++ b/sfx2/source/sidebar/SidebarController.cxx
2a8c10c
@@ -94,7 +94,7 @@ SidebarController::SidebarController (
2a8c10c
       mpTabBar(VclPtr<TabBar>::Create(
2a8c10c
               mpParentWindow,
2a8c10c
               rxFrame,
2a8c10c
-              [this](const ::rtl::OUString& rsDeckId) { return this->OpenThenSwitchToDeck(rsDeckId); },
2a8c10c
+              [this](const ::rtl::OUString& rsDeckId) { return this->OpenThenToggleDeck(rsDeckId); },
2a8c10c
               [this](const Rectangle& rButtonBox,const ::std::vector<TabBar::DeckMenuData>& rMenuData) { return this->ShowPopupMenu(rButtonBox,rMenuData); },
2a8c10c
               this)),
2a8c10c
       mxFrame(rxFrame),
2a8c10c
@@ -502,8 +502,8 @@ void SidebarController::UpdateConfigurations()
2a8c10c
     }
2a8c10c
 }
2a8c10c
 
2a8c10c
-void SidebarController::OpenThenSwitchToDeck (
2a8c10c
-    const ::rtl::OUString& rsDeckId)
2a8c10c
+void SidebarController::OpenThenToggleDeck (
2a8c10c
+    const OUString& rsDeckId)
2a8c10c
 {
2a8c10c
     SfxSplitWindow* pSplitWindow = GetSplitWindow();
2a8c10c
     if ( pSplitWindow && !pSplitWindow->IsFadeIn() )
2a8c10c
@@ -525,6 +525,19 @@ void SidebarController::OpenThenSwitchToDeck (
2a8c10c
     mpTabBar->HighlightDeck(rsDeckId);
2a8c10c
 }
2a8c10c
 
2a8c10c
+void SidebarController::OpenThenSwitchToDeck (
2a8c10c
+    const OUString& rsDeckId)
2a8c10c
+{
2a8c10c
+    SfxSplitWindow* pSplitWindow = GetSplitWindow();
2a8c10c
+    if ( pSplitWindow && !pSplitWindow->IsFadeIn() )
2a8c10c
+        // tdf#83546 Collapsed sidebar should expand first
2a8c10c
+        pSplitWindow->FadeIn();
2a8c10c
+    RequestOpenDeck();
2a8c10c
+    SwitchToDeck(rsDeckId);
2a8c10c
+    mpTabBar->Invalidate();
2a8c10c
+    mpTabBar->HighlightDeck(rsDeckId);
2a8c10c
+}
2a8c10c
+
2a8c10c
 void SidebarController::SwitchToDefaultDeck()
2a8c10c
 {
2a8c10c
     SwitchToDeck(gsDefaultDeckId);
2a8c10c
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
2a8c10c
index 33365ec..8f6c624 100644
2a8c10c
--- a/sfx2/source/view/viewfrm.cxx
2a8c10c
+++ b/sfx2/source/view/viewfrm.cxx
2a8c10c
@@ -3048,8 +3048,8 @@ void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq )
2a8c10c
         // First make sure that the sidebar is visible
2a8c10c
         ShowChildWindow(SID_SIDEBAR);
2a8c10c
 
2a8c10c
-        ::sfx2::sidebar::Sidebar::ShowPanel("StyleListPanel",
2a8c10c
-                                            GetFrame().GetFrameInterface());
2a8c10c
+        ::sfx2::sidebar::Sidebar::TogglePanel("StyleListPanel",
2a8c10c
+                                              GetFrame().GetFrameInterface());
2a8c10c
         rReq.Done();
2a8c10c
         return;
2a8c10c
     }
2a8c10c
-- 
2a8c10c
2.7.3
2a8c10c