[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - include/sfx2 sd/source sfx2/source

Caolán McNamara caolanm at redhat.com
Tue Jul 12 19:20:32 UTC 2016


 include/sfx2/sidebar/Sidebar.hxx              |   12 +++++++++++-
 include/sfx2/sidebar/SidebarController.hxx    |   16 ++++++++--------
 sd/source/ui/view/ViewShellImplementation.cxx |    2 ++
 sfx2/source/sidebar/Sidebar.cxx               |   23 +++++++++++++++++++++++
 sfx2/source/sidebar/SidebarController.cxx     |   19 ++++++++++++++++---
 sfx2/source/view/viewfrm.cxx                  |    4 ++--
 6 files changed, 62 insertions(+), 14 deletions(-)

New commits:
commit e1e61bf5e5f368fc1ea579f8ae5eec9faafbd599
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 3 11:06:22 2016 +0100

    Resolves: tdf#88396 switching to sidebar panel will toggle it *off*...
    
    if its already visible.
    
    This solves tdf#88396, but I did this fix originally for....
    
    on switching to slide layouts panel move into slide layout context
    
    i.e. exit current textbox edit and shape selection
    
    (cherry picked from commit 05aaef55252bc9f90cbbcc1967c38ab9a5a6c798)
    
    OpenThenSwitchToDeck actually *toggles* deck visibility
    
    so rename it to that and add a OpenThenSwitchToDeck that actually
    does that, using the Toggle varient as the callback from the
    sidebar button which toggles the current deck on/off
    
    which retains the features of
    
    // tdf#67627 Clicking a second time on a Deck icon will close the Deck
    // tdf#88241 Summoning an undocked sidebar a second time should close sidebar
    
    but means that calls to OpenThenSwitchToDeck from e.g. slide layout
    don't auto close it if that deck is already open
    
    (cherry picked from commit b81daea4a78083def286fa2d5360b152b7a703fd)
    
    3e3724626b93447a7ab6bc7032e9c6839dabcf55
    
    Change-Id: I16a2fca158cb4caab7b6bd001742df698735dd2b
    Reviewed-on: https://gerrit.libreoffice.org/27071
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/sfx2/sidebar/Sidebar.hxx b/include/sfx2/sidebar/Sidebar.hxx
index aea1fcb..6b138b9 100644
--- a/include/sfx2/sidebar/Sidebar.hxx
+++ b/include/sfx2/sidebar/Sidebar.hxx
@@ -38,7 +38,17 @@ public:
         this function probably returns before the requested panel is visible.
     */
     static void ShowPanel (
-        const ::rtl::OUString& rsPanelId,
+        const OUString& rsPanelId,
+        const css::uno::Reference<css::frame::XFrame>& rxFrame);
+
+    /** Switch to the deck that contains the specified panel and toggle
+        the visibility of the panel (expanded and scrolled into the
+        visible area when visible)
+        Note that most of the work is done asynchronously and that
+        this function probably returns before the requested panel is visible.
+    */
+    static void TogglePanel (
+        const OUString& rsPanelId,
         const css::uno::Reference<css::frame::XFrame>& rxFrame);
 };
 
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index c077eeb..0298862 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -124,8 +124,8 @@ public:
 
     const static sal_Int32 gnMaximumSidebarWidth = 400;
 
-    void OpenThenSwitchToDeck (
-        const ::rtl::OUString& rsDeckId);
+    void OpenThenSwitchToDeck(const OUString& rsDeckId);
+    void OpenThenToggleDeck(const OUString& rsDeckId);
 
     /** Show only the tab bar, not the deck.
     */
@@ -137,7 +137,7 @@ public:
 
     /** Returns true when the given deck is the currently visible deck
      */
-    bool IsDeckVisible (const ::rtl::OUString& rsDeckId);
+    bool IsDeckVisible(const OUString& rsDeckId);
 
     FocusManager& GetFocusManager() { return maFocusManager;}
 
@@ -148,14 +148,14 @@ public:
     Context GetCurrentContext() const { return maCurrentContext;}
     bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;}
 
-    void SwitchToDeck ( const ::rtl::OUString& rsDeckId);
+    void SwitchToDeck(const OUString& rsDeckId);
     void SwitchToDefaultDeck();
 
     void CreateDeck(const ::rtl::OUString& rDeckId, bool bForceCreate = false);
     void CreatePanels(const ::rtl::OUString& rDeckId);
 
     ResourceManager::DeckContextDescriptorContainer GetMatchingDecks();
-    ResourceManager::PanelContextDescriptorContainer GetMatchingPanels( const ::rtl::OUString& rDeckId);
+    ResourceManager::PanelContextDescriptorContainer GetMatchingPanels(const OUString& rDeckId);
 
     void notifyDeckTitle(const OUString& targetDeckId);
 
@@ -174,7 +174,7 @@ private:
     css::uno::Reference<css::frame::XController> mxCurrentController;
     /// Use a combination of SwitchFlag_* as value.
     sal_Int32 mnRequestedForceFlags;
-    ::rtl::OUString msCurrentDeckId;
+    OUString msCurrentDeckId;
     AsynchronousCall maPropertyChangeForwarder;
     AsynchronousCall maContextChangeUpdate;
     AsynchronousCall maAsynchronousDeckSwitch;
@@ -216,12 +216,12 @@ private:
 
     css::uno::Reference<css::ui::XUIElement> CreateUIElement (
         const css::uno::Reference<css::awt::XWindowPeer>& rxWindow,
-        const ::rtl::OUString& rsImplementationURL,
+        const OUString& rsImplementationURL,
         const bool bWantsCanvas,
         const Context& rContext);
 
     VclPtr<Panel> CreatePanel (
-        const ::rtl::OUString& rsPanelId,
+        const OUString& rsPanelId,
         vcl::Window* pParentWindow,
         const bool bIsInitiallyExpanded,
         const Context& rContext,
diff --git a/sd/source/ui/view/ViewShellImplementation.cxx b/sd/source/ui/view/ViewShellImplementation.cxx
index b523e03..7944304 100644
--- a/sd/source/ui/view/ViewShellImplementation.cxx
+++ b/sd/source/ui/view/ViewShellImplementation.cxx
@@ -120,6 +120,8 @@ void ViewShell::Implementation::ProcessModifyPageSlot (
         if (!pArgs || pArgs->Count() == 1 || pArgs->Count() == 2 )
         {
             // First make sure that the sidebar is visible
+            mrViewShell.GetDrawView()->SdrEndTextEdit();
+            mrViewShell.GetDrawView()->UnmarkAll();
             mrViewShell.GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
             sfx2::sidebar::Sidebar::ShowPanel(
                 "SdLayoutsPanel",
diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx
index c4e9c80..02a17f4 100644
--- a/sfx2/source/sidebar/Sidebar.cxx
+++ b/sfx2/source/sidebar/Sidebar.cxx
@@ -45,6 +45,29 @@ void Sidebar::ShowPanel (
     }
 }
 
+void Sidebar::TogglePanel (
+    const ::rtl::OUString& rsPanelId,
+    const css::uno::Reference<frame::XFrame>& rxFrame)
+{
+    SidebarController* pController = SidebarController::GetSidebarControllerForFrame(rxFrame);
+
+    if (!pController)
+        return;
+
+    std::shared_ptr<PanelDescriptor> xPanelDescriptor = pController->GetResourceManager()->GetPanelDescriptor(rsPanelId);
+
+    if (!xPanelDescriptor)
+        return;
+
+    // This should be a lot more sophisticated:
+    // - Make the deck switching asynchronous
+    // - Make sure to use a context that really shows the panel
+
+    // All that is not necessary for the current use cases so lets
+    // keep it simple for the time being.
+    pController->OpenThenToggleDeck(xPanelDescriptor->msDeckId);
+}
+
 } } // end of namespace sfx2::sidebar
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 74973d1..fe73d2c 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -94,7 +94,7 @@ SidebarController::SidebarController (
       mpTabBar(VclPtr<TabBar>::Create(
               mpParentWindow,
               rxFrame,
-              [this](const ::rtl::OUString& rsDeckId) { return this->OpenThenSwitchToDeck(rsDeckId); },
+              [this](const ::rtl::OUString& rsDeckId) { return this->OpenThenToggleDeck(rsDeckId); },
               [this](const Rectangle& rButtonBox,const ::std::vector<TabBar::DeckMenuData>& rMenuData) { return this->ShowPopupMenu(rButtonBox,rMenuData); },
               this)),
       mxFrame(rxFrame),
@@ -500,8 +500,8 @@ void SidebarController::UpdateConfigurations()
     }
 }
 
-void SidebarController::OpenThenSwitchToDeck (
-    const ::rtl::OUString& rsDeckId)
+void SidebarController::OpenThenToggleDeck (
+    const OUString& rsDeckId)
 {
     SfxSplitWindow* pSplitWindow = GetSplitWindow();
     if ( pSplitWindow && !pSplitWindow->IsFadeIn() )
@@ -523,6 +523,19 @@ void SidebarController::OpenThenSwitchToDeck (
     mpTabBar->HighlightDeck(rsDeckId);
 }
 
+void SidebarController::OpenThenSwitchToDeck (
+    const OUString& rsDeckId)
+{
+    SfxSplitWindow* pSplitWindow = GetSplitWindow();
+    if ( pSplitWindow && !pSplitWindow->IsFadeIn() )
+        // tdf#83546 Collapsed sidebar should expand first
+        pSplitWindow->FadeIn();
+    RequestOpenDeck();
+    SwitchToDeck(rsDeckId);
+    mpTabBar->Invalidate();
+    mpTabBar->HighlightDeck(rsDeckId);
+}
+
 void SidebarController::SwitchToDefaultDeck()
 {
     SwitchToDeck(gsDefaultDeckId);
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 33365ec..8f6c624 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3048,8 +3048,8 @@ void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq )
         // First make sure that the sidebar is visible
         ShowChildWindow(SID_SIDEBAR);
 
-        ::sfx2::sidebar::Sidebar::ShowPanel("StyleListPanel",
-                                            GetFrame().GetFrameInterface());
+        ::sfx2::sidebar::Sidebar::TogglePanel("StyleListPanel",
+                                              GetFrame().GetFrameInterface());
         rReq.Done();
         return;
     }


More information about the Libreoffice-commits mailing list