diff options
author | Andre Fischer <af@apache.org> | 2013-05-08 09:48:36 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-05-20 11:33:30 +0100 |
commit | 11f8ed408d43f40de5f694d6b7d00cb7762ee84f (patch) | |
tree | 56a920759e63a3202c750cf21dc884832140e0d0 /sfx2 | |
parent | 5e8a2c64799856ddc34ab5d468bd54d7302302f4 (diff) |
Resolves: #i122255# Store sidebar panel extension state
(non persistent)
(cherry picked from commit f6f8c047b73f8fc8b4c78b321761a26ef7ed96ba)
Change-Id: I917050dd57b3fa952200dd536b371f902661e88f
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/sidebar/ContextList.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/sidebar/ContextList.hxx | 5 | ||||
-rw-r--r-- | sfx2/source/sidebar/Panel.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/sidebar/Panel.hxx | 7 | ||||
-rw-r--r-- | sfx2/source/sidebar/ResourceManager.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/sidebar/ResourceManager.hxx | 8 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.cxx | 21 | ||||
-rw-r--r-- | sfx2/source/sidebar/SidebarController.hxx | 5 |
8 files changed, 86 insertions, 12 deletions
diff --git a/sfx2/source/sidebar/ContextList.cxx b/sfx2/source/sidebar/ContextList.cxx index aebfdbd1897d..f7028c3962d8 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 f026ff9d3305..8d9886f4d0d6 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 59eeb0589c2a..0840c4c5f805 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 5a7ca1c1ebb2..27c771a34d3f 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 683856257d5f..d65c9b44fdd4 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 80c0b0b25c97..e1b6e68afe21 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 0cbaea7ba8cd..3a289415cf92 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 7ba4092d366a..5a4923f16eb4 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); }; |