Author: af
Date: Wed May  8 09:48:36 2013
New Revision: 1480209

URL: http://svn.apache.org/r1480209
Log:
122255: Store sidebar panel extension state (non persistent).

Modified:
    openoffice/trunk/main/sfx2/source/sidebar/ContextList.cxx
    openoffice/trunk/main/sfx2/source/sidebar/ContextList.hxx
    openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx
    openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx
    openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.cxx
    openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.hxx
    openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx
    openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx

Modified: openoffice/trunk/main/sfx2/source/sidebar/ContextList.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/ContextList.cxx?rev=1480209&r1=1480208&r2=1480209&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/ContextList.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/ContextList.cxx Wed May  8 
09:48:36 2013
@@ -56,6 +56,18 @@ const ContextList::Entry* ContextList::G
 
 
 
+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);

Modified: openoffice/trunk/main/sfx2/source/sidebar/ContextList.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/ContextList.hxx?rev=1480209&r1=1480208&r2=1480209&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/ContextList.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/ContextList.hxx Wed May  8 
09:48:36 2013
@@ -31,7 +31,8 @@
 
 namespace sfx2 { namespace sidebar {
 
-
+/** Per context data for deck and panel descriptors.
+*/
 class ContextList
 {
 public:
@@ -50,6 +51,8 @@ public:
     */
     const Entry* GetMatch (
         const Context& rContext) const;
+    Entry* GetMatch (
+        const Context& rContext);
 
     void AddContextDescription (
         const Context& rContext,

Modified: openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx?rev=1480209&r1=1480208&r2=1480209&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/Panel.cxx Wed May  8 09:48:36 2013
@@ -26,6 +26,7 @@
 #include "PanelDescriptor.hxx"
 #include "sfx2/sidebar/Theme.hxx"
 #include "Paint.hxx"
+#include "ResourceManager.hxx"
 
 #ifdef DEBUG
 #include "sfx2/sidebar/Tools.hxx"
@@ -52,7 +53,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(
@@ -62,8 +65,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());
 
@@ -158,6 +162,12 @@ void Panel::SetExpanded (const bool bIsE
     {
         mbIsExpanded = bIsExpanded;
         maDeckLayoutTrigger();
+
+        if (maContextAccess)
+            ResourceManager::Instance().StorePanelExpansionState(
+                msPanelId,
+                bIsExpanded,
+                maContextAccess());
     }
 }
 

Modified: openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx?rev=1480209&r1=1480208&r2=1480209&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/Panel.hxx Wed May  8 09:48:36 2013
@@ -22,6 +22,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>
@@ -49,7 +50,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);
@@ -80,7 +83,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;

Modified: openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.cxx?rev=1480209&r1=1480208&r2=1480209&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.cxx Wed May  8 
09:48:36 2013
@@ -572,6 +572,30 @@ void ResourceManager::ReadLegacyAddons (
 
 
 
+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)
 {

Modified: openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.hxx?rev=1480209&r1=1480208&r2=1480209&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/ResourceManager.hxx Wed May  8 
09:48:36 2013
@@ -94,6 +94,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);
 

Modified: openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx?rev=1480209&r1=1480208&r2=1480209&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/SidebarController.cxx Wed May  8 
09:48:36 2013
@@ -573,19 +573,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
@@ -649,7 +649,8 @@ bool SidebarController::ArePanelSetsEqua
 
 SharedPanel SidebarController::CreatePanel (
     const OUString& rsPanelId,
-    ::Window* pParentWindow )
+    ::Window* pParentWindow,
+    const bool bIsInitiallyExpanded)
 {
     const PanelDescriptor* pPanelDescriptor = 
ResourceManager::Instance().GetPanelDescriptor(rsPanelId);
     if (pPanelDescriptor == NULL)
@@ -659,7 +660,9 @@ SharedPanel SidebarController::CreatePan
     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(
@@ -1175,4 +1178,12 @@ void SidebarController::ShowPanel (const
 }
 
 
+
+
+Context SidebarController::GetCurrentContext (void) const
+{
+    return maCurrentContext;
+}
+
+
 } } // end of namespace sfx2::sidebar

Modified: openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx?rev=1480209&r1=1480208&r2=1480209&view=diff
==============================================================================
--- openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx (original)
+++ openoffice/trunk/main/sfx2/source/sidebar/SidebarController.hxx Wed May  8 
09:48:36 2013
@@ -116,7 +116,7 @@ public:
     void RequestOpenDeck (void);
 
     FocusManager& GetFocusManager (void);
-    
+
 private:
     ::boost::scoped_ptr<Deck> mpCurrentDeck;
     SidebarDockingWindow* mpParentWindow;
@@ -172,7 +172,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);
@@ -215,7 +216,9 @@ private:
         completely visible.
     */
     void ShowPanel (const Panel& rPanel);
-    
+
+    Context GetCurrentContext (void) const;
+
     virtual void SAL_CALL disposing (void);
 };
 


Reply via email to