[Libreoffice-commits] core.git: Branch 'feature/sidebar' - sfx2/source

Andre Fischer af at apache.org
Fri May 10 08:17:11 PDT 2013


 sfx2/source/sidebar/ContextList.cxx       |   12 ++++++++++++
 sfx2/source/sidebar/ContextList.hxx       |    5 ++++-
 sfx2/source/sidebar/Panel.cxx             |   16 +++++++++++++---
 sfx2/source/sidebar/Panel.hxx             |    7 +++++--
 sfx2/source/sidebar/ResourceManager.cxx   |   24 ++++++++++++++++++++++++
 sfx2/source/sidebar/ResourceManager.hxx   |    8 ++++++++
 sfx2/source/sidebar/SidebarController.cxx |   21 ++++++++++++++++-----
 sfx2/source/sidebar/SidebarController.hxx |    5 ++++-
 8 files changed, 86 insertions(+), 12 deletions(-)

New commits:
commit 219f0935fb3480cd2fde86619028c15cb69943ef
Author: Andre Fischer <af at apache.org>
Date:   Wed May 8 09:48:36 2013 +0000

    Resolves: #i122255# Store sidebar panel extension state
    
    (non persistent)
    
    (cherry picked from commit f6f8c047b73f8fc8b4c78b321761a26ef7ed96ba)
    
    Change-Id: I917050dd57b3fa952200dd536b371f902661e88f

diff --git a/sfx2/source/sidebar/ContextList.cxx b/sfx2/source/sidebar/ContextList.cxx
index aebfdbd..f7028c3 100644
--- a/sfx2/source/sidebar/ContextList.cxx
+++ b/sfx2/source/sidebar/ContextList.cxx
@@ -50,6 +50,18 @@ const ContextList::Entry* ContextList::GetMatch (const Context& rContext) const
 
 
 
+ContextList::Entry* ContextList::GetMatch (const Context& rContext)
+{
+    const ::std::vector<Entry>::const_iterator iEntry = FindBestMatch(rContext);
+    if (iEntry != maEntries.end())
+        return const_cast<Entry*>(&*iEntry);
+    else
+        return NULL;
+}
+
+
+
+
 ::std::vector<ContextList::Entry>::const_iterator ContextList::FindBestMatch (const Context& rContext) const
 {
     sal_Int32 nBestMatch (Context::NoMatch);
diff --git a/sfx2/source/sidebar/ContextList.hxx b/sfx2/source/sidebar/ContextList.hxx
index f026ff9..8d9886f 100644
--- a/sfx2/source/sidebar/ContextList.hxx
+++ b/sfx2/source/sidebar/ContextList.hxx
@@ -27,7 +27,8 @@
 
 namespace sfx2 { namespace sidebar {
 
-
+/** Per context data for deck and panel descriptors.
+*/
 class ContextList
 {
 public:
@@ -46,6 +47,8 @@ public:
     */
     const Entry* GetMatch (
         const Context& rContext) const;
+    Entry* GetMatch (
+        const Context& rContext);
 
     void AddContextDescription (
         const Context& rContext,
diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx
index 59eeb05..0840c4c 100644
--- a/sfx2/source/sidebar/Panel.cxx
+++ b/sfx2/source/sidebar/Panel.cxx
@@ -21,6 +21,7 @@
 #include "PanelDescriptor.hxx"
 #include "sfx2/sidebar/Theme.hxx"
 #include "Paint.hxx"
+#include "ResourceManager.hxx"
 
 #ifdef DEBUG
 #include "sfx2/sidebar/Tools.hxx"
@@ -47,7 +48,9 @@ namespace sfx2 { namespace sidebar {
 Panel::Panel (
     const PanelDescriptor& rPanelDescriptor,
     Window* pParentWindow,
-    const ::boost::function<void(void)>& rDeckLayoutTrigger)
+    const bool bIsInitiallyExpanded,
+    const ::boost::function<void(void)>& rDeckLayoutTrigger,
+    const ::boost::function<Context(void)>& rContextAccess)
     : Window(pParentWindow),
       msPanelId(rPanelDescriptor.msId),
       mpTitleBar(new PanelTitleBar(
@@ -57,8 +60,9 @@ Panel::Panel (
       mbIsTitleBarOptional(rPanelDescriptor.mbIsTitleBarOptional),
       mxElement(),
       mxPanelComponent(),
-      mbIsExpanded(true),
-      maDeckLayoutTrigger(rDeckLayoutTrigger)
+      mbIsExpanded(bIsInitiallyExpanded),
+      maDeckLayoutTrigger(rDeckLayoutTrigger),
+      maContextAccess(rContextAccess)
 {
     SetBackground(Theme::GetPaint(Theme::Paint_PanelBackground).GetWallpaper());
 
@@ -153,6 +157,12 @@ void Panel::SetExpanded (const bool bIsExpanded)
     {
         mbIsExpanded = bIsExpanded;
         maDeckLayoutTrigger();
+
+        if (maContextAccess)
+            ResourceManager::Instance().StorePanelExpansionState(
+                msPanelId,
+                bIsExpanded,
+                maContextAccess());
     }
 }
 
diff --git a/sfx2/source/sidebar/Panel.hxx b/sfx2/source/sidebar/Panel.hxx
index 5a7ca1c..27c771a 100644
--- a/sfx2/source/sidebar/Panel.hxx
+++ b/sfx2/source/sidebar/Panel.hxx
@@ -18,6 +18,7 @@
 #ifndef SFX_SIDEBAR_PANEL_HXX
 #define SFX_SIDEBAR_PANEL_HXX
 
+#include "Context.hxx"
 #include <vcl/window.hxx>
 
 #include <com/sun/star/ui/XUIElement.hpp>
@@ -45,7 +46,9 @@ public:
     Panel (
         const PanelDescriptor& rPanelDescriptor,
         Window* pParentWindow,
-        const ::boost::function<void(void)>& rDeckLayoutTrigger );
+        const bool bIsInitiallyExpanded,
+        const ::boost::function<void(void)>& rDeckLayoutTrigger,
+        const ::boost::function<Context(void)>& rContextAccess);
     virtual ~Panel (void);
 
     void Dispose (void);
@@ -76,7 +79,7 @@ private:
     cssu::Reference<css::ui::XSidebarPanel> mxPanelComponent;
     bool mbIsExpanded;
     const ::boost::function<void(void)> maDeckLayoutTrigger;
-    Rectangle maBoundingBox;
+    const ::boost::function<Context(void)> maContextAccess;
 };
 typedef ::boost::shared_ptr<Panel> SharedPanel;
 typedef ::std::vector<SharedPanel> SharedPanelContainer;
diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index 6838562..d65c9b4 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -561,6 +561,30 @@ void ResourceManager::ReadLegacyAddons (const Reference<frame::XFrame>& rxFrame)
 
 
 
+void ResourceManager::StorePanelExpansionState (
+    const ::rtl::OUString& rsPanelId,
+    const bool bExpansionState,
+    const Context& rContext)
+{
+    for (PanelContainer::iterator
+             iPanel(maPanels.begin()),
+             iEnd(maPanels.end());
+         iPanel!=iEnd;
+         ++iPanel)
+    {
+        if (iPanel->msId.equals(rsPanelId))
+        {
+            ContextList::Entry* pEntry (
+                iPanel->maContextList.GetMatch (rContext));
+            if (pEntry != NULL)
+                pEntry->mbIsInitiallyVisible = bExpansionState;
+        }
+    }
+}
+
+
+
+
 ::rtl::OUString ResourceManager::GetModuleName (
     const cssu::Reference<css::frame::XFrame>& rxFrame)
 {
diff --git a/sfx2/source/sidebar/ResourceManager.hxx b/sfx2/source/sidebar/ResourceManager.hxx
index 80c0b0b..e1b6e68 100644
--- a/sfx2/source/sidebar/ResourceManager.hxx
+++ b/sfx2/source/sidebar/ResourceManager.hxx
@@ -90,6 +90,14 @@ public:
         const ::rtl::OUString& rsDeckId,
         const cssu::Reference<css::frame::XFrame>& rxFrame);
 
+    /** Remember the expansions state per panel and context.
+        This is not persistent past application end.
+    */
+    void StorePanelExpansionState (
+        const ::rtl::OUString& rsPanelId,
+        const bool bExpansionState,
+        const Context& rContext);
+
     static ::rtl::OUString GetModuleName (
         const cssu::Reference<css::frame::XFrame>& rxFrame);
 
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 0cbaea7b..3a28941 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -565,19 +565,19 @@ void SidebarController::SwitchToDeck (
         {
             // Panel already exists in current deck.  Reuse it.
             aNewPanels[nWriteIndex] = *iPanel;
+            aNewPanels[nWriteIndex]->SetExpanded(rPanelContexDescriptor.mbIsInitiallyVisible);
         }
         else
         {
             // Panel does not yet exist.  Create it.
             aNewPanels[nWriteIndex] = CreatePanel(
                 rPanelContexDescriptor.msId,
-                mpCurrentDeck->GetPanelParentWindow());
+                mpCurrentDeck->GetPanelParentWindow(),
+                rPanelContexDescriptor.mbIsInitiallyVisible);
             bHasPanelSetChanged = true;
         }
         if (aNewPanels[nWriteIndex] != NULL)
         {
-            // Depending on the context we have to collapse the panel.
-            aNewPanels[nWriteIndex]->SetExpanded(rPanelContexDescriptor.mbIsInitiallyVisible);
             // Depending on the context we have to apply the show menu functor.
             aNewPanels[nWriteIndex]->SetShowMenuFunctor(
                 rPanelContexDescriptor.msMenuCommand.getLength()>0
@@ -641,7 +641,8 @@ bool SidebarController::ArePanelSetsEqual (
 
 SharedPanel SidebarController::CreatePanel (
     const OUString& rsPanelId,
-    ::Window* pParentWindow )
+    ::Window* pParentWindow,
+    const bool bIsInitiallyExpanded)
 {
     const PanelDescriptor* pPanelDescriptor = ResourceManager::Instance().GetPanelDescriptor(rsPanelId);
     if (pPanelDescriptor == NULL)
@@ -651,7 +652,9 @@ SharedPanel SidebarController::CreatePanel (
     SharedPanel pPanel (new Panel(
         *pPanelDescriptor,
         pParentWindow,
-        ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()) ) );
+        bIsInitiallyExpanded,
+        ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()),
+        ::boost::bind(&SidebarController::GetCurrentContext, this)));
 
     // Create the XUIElement.
     Reference<ui::XUIElement> xUIElement (CreateUIElement(
@@ -1167,4 +1170,12 @@ void SidebarController::ShowPanel (const Panel& rPanel)
 }
 
 
+
+
+Context SidebarController::GetCurrentContext (void) const
+{
+    return maCurrentContext;
+}
+
+
 } } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/SidebarController.hxx b/sfx2/source/sidebar/SidebarController.hxx
index 7ba4092..5a4923f 100644
--- a/sfx2/source/sidebar/SidebarController.hxx
+++ b/sfx2/source/sidebar/SidebarController.hxx
@@ -168,7 +168,8 @@ private:
         const bool bWantsCanvas);
     SharedPanel CreatePanel (
         const ::rtl::OUString& rsPanelId,
-        ::Window* pParentWindow );
+        ::Window* pParentWindow,
+        const bool bIsInitiallyExpanded);
     void SwitchToDeck (
         const DeckDescriptor& rDeckDescriptor,
         const Context& rContext);
@@ -212,6 +213,8 @@ private:
     */
     void ShowPanel (const Panel& rPanel);
 
+    Context GetCurrentContext (void) const;
+
     virtual void SAL_CALL disposing (void);
 };
 


More information about the Libreoffice-commits mailing list