Kaydet (Commit) 11f8ed40 authored tarafından Andre Fischer's avatar Andre Fischer Kaydeden (comit) Michael Meeks

Resolves: #i122255# Store sidebar panel extension state

(non persistent)

(cherry picked from commit f6f8c047)

Change-Id: I917050dd57b3fa952200dd536b371f902661e88f
üst 5e8a2c64
......@@ -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);
......
......@@ -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,
......
......@@ -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());
}
}
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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
......@@ -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);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment