Kaydet (Commit) 536c259c authored tarafından Laurent Godard's avatar Laurent Godard Kaydeden (comit) Katarina Behrens

tdf#67770 store sidebar elements states

deck & panel states at user registry level
when disposing a sidebar

if a shared deck (with "any" context application) is modified,
it apply to all applications (eg. Gallery between calc and writer); TODO ?

clean ResourceManager Get/Set const/non-const

add panels when deck is created & refactoring

* macro example

Sub Main

controller = thisComponent.currentcontroller
sidebar = thisComponent.currentcontroller.getSidebar()

sidebar.setVisible(true)

decks = sidebar.getdecks()
deck = decks.getByName("PropertyDeck")

deck.activate(true)
deck.setTitle("new deck title")
deck.moveLast()

panels = deck.getPanels()
panel = panels.getByName("TextPropertyPanel")

panel.setTitle("new panel title")
panel.expand(true) ' expand and collapse other
panel.moveLast()

End Sub

Change-Id: I2552000af92a366ebb51a479962a094b72e400b6
Reviewed-on: https://gerrit.libreoffice.org/17992Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
Tested-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst ce6170da
...@@ -55,6 +55,8 @@ public: ...@@ -55,6 +55,8 @@ public:
const bool bIsInitiallyVisible, const bool bIsInitiallyVisible,
const ::rtl::OUString& rsMenuCommand); const ::rtl::OUString& rsMenuCommand);
const ::std::vector<Entry>& GetEntries() const {return maEntries;};
private: private:
::std::vector<Entry> maEntries; ::std::vector<Entry> maEntries;
......
...@@ -94,6 +94,7 @@ private: ...@@ -94,6 +94,7 @@ private:
DECL_LINK_TYPED(HandleVerticalScrollBarChange, ScrollBar*, void); DECL_LINK_TYPED(HandleVerticalScrollBarChange, ScrollBar*, void);
bool ProcessWheelEvent(CommandEvent* pCommandEvent); bool ProcessWheelEvent(CommandEvent* pCommandEvent);
}; };
} } // end of namespace sfx2::sidebar } } // end of namespace sfx2::sidebar
......
...@@ -42,6 +42,8 @@ public: ...@@ -42,6 +42,8 @@ public:
sal_Int32 mnOrderIndex; sal_Int32 mnOrderIndex;
bool mbExperimental; bool mbExperimental;
OUString msNodeName; // some impress deck nodes names are different from their Id
VclPtr<Deck> mpDeck; VclPtr<Deck> mpDeck;
DeckDescriptor(); DeckDescriptor();
......
...@@ -41,6 +41,8 @@ public: ...@@ -41,6 +41,8 @@ public:
bool mbWantsCanvas; bool mbWantsCanvas;
bool mbExperimental; bool mbExperimental;
OUString msNodeName; // some impress panel nodes names are different from their Id
PanelDescriptor(); PanelDescriptor();
PanelDescriptor (const PanelDescriptor& rPanelDescriptor); PanelDescriptor (const PanelDescriptor& rPanelDescriptor);
~PanelDescriptor(); ~PanelDescriptor();
......
...@@ -43,30 +43,18 @@ public: ...@@ -43,30 +43,18 @@ public:
ResourceManager(); ResourceManager();
~ResourceManager(); ~ResourceManager();
static ResourceManager& Instance();
const DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId) const; const DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId) const;
const PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId) const; DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId);
/** Excluded or include a deck from being displayed in the tab
bar.
Note that this value is not persistent.
The flag can not be set directly at a DeckDescriptor object
because the ResourceManager gives access to them only
read-only.
*/
void SetIsDeckEnabled(const OUString& rsDeckId, const bool bIsEnabled);
void SetDeckTitle(const OUString& rsDeckId, const OUString& sTitle);
void SetDeckToDescriptor(const OUString& rsDeckId, VclPtr<Deck> aDeck);
void SetDeckOrderIndex(const OUString& rsDeckId, const sal_Int32 orderIndex); const PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId) const;
PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId);
void SetPanelOrderIndex(const OUString& rsPanelId, const sal_Int32 orderIndex);
void UpdateModel(css::uno::Reference<css::frame::XModel> xModel); void UpdateModel(css::uno::Reference<css::frame::XModel> xModel);
void InitDeckContext(const Context& rContex);
void SaveDecksSettings(const Context& rContext);
void SaveDeckSettings(const DeckDescriptor* pDeckDesc);
void disposeDecks(); void disposeDecks();
class DeckContextDescriptor class DeckContextDescriptor
...@@ -100,7 +88,6 @@ public: ...@@ -100,7 +88,6 @@ public:
const css::uno::Reference<css::frame::XController>& rxController); const css::uno::Reference<css::frame::XController>& rxController);
/** Remember the expansions state per panel and context. /** Remember the expansions state per panel and context.
This is not persistent past application end.
*/ */
void StorePanelExpansionState(const OUString& rsPanelId, void StorePanelExpansionState(const OUString& rsPanelId,
const bool bExpansionState, const bool bExpansionState,
...@@ -123,13 +110,19 @@ private: ...@@ -123,13 +110,19 @@ private:
static void ReadContextList(const utl::OConfigurationNode& rNode, static void ReadContextList(const utl::OConfigurationNode& rNode,
ContextList& rContextList, ContextList& rContextList,
const OUString& rsDefaultMenuCommand); const OUString& rsDefaultMenuCommand);
css::uno::Sequence<OUString> BuildContextList (ContextList rContextList, bool isDeckEnabled);
void ReadLegacyAddons(const css::uno::Reference<css::frame::XController>& rxController); void ReadLegacyAddons(const css::uno::Reference<css::frame::XController>& rxController);
static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName); static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName);
static void GetToolPanelNodeNames(std::vector<OUString>& rMatchingNames, static void GetToolPanelNodeNames(std::vector<OUString>& rMatchingNames,
const utl::OConfigurationTreeRoot& aRoot); const utl::OConfigurationTreeRoot& aRoot);
static bool IsDeckEnabled(const OUString& rsDeckId, bool IsDeckEnabled(const OUString& rsDeckId,
const Context& rContext, const Context& rContext,
const css::uno::Reference<css::frame::XController>& rxController); const css::uno::Reference<css::frame::XController>& rxController);
const DeckDescriptor* ImplGetDeckDescriptor(const OUString& rsDeckId) const;
const PanelDescriptor* ImplGetPanelDescriptor(const OUString& rsPanelId) const;
}; };
} } // end of namespace sfx2::sidebar } } // end of namespace sfx2::sidebar
......
...@@ -151,7 +151,8 @@ public: ...@@ -151,7 +151,8 @@ public:
void SwitchToDeck ( const ::rtl::OUString& rsDeckId); void SwitchToDeck ( const ::rtl::OUString& rsDeckId);
void SwitchToDefaultDeck(); void SwitchToDefaultDeck();
void CreateDeck(const ::rtl::OUString& rDeckId); void CreateDeck(const ::rtl::OUString& rDeckId, bool bForceCreate = false);
void CreatePanels(const ::rtl::OUString& rDeckId);
ResourceManager::DeckContextDescriptorContainer GetMatchingDecks(); ResourceManager::DeckContextDescriptorContainer GetMatchingDecks();
ResourceManager::PanelContextDescriptorContainer GetMatchingPanels( const ::rtl::OUString& rDeckId); ResourceManager::PanelContextDescriptorContainer GetMatchingPanels( const ::rtl::OUString& rDeckId);
...@@ -223,7 +224,8 @@ private: ...@@ -223,7 +224,8 @@ private:
const ::rtl::OUString& rsPanelId, const ::rtl::OUString& rsPanelId,
vcl::Window* pParentWindow, vcl::Window* pParentWindow,
const bool bIsInitiallyExpanded, const bool bIsInitiallyExpanded,
const Context& rContext); const Context& rContext,
VclPtr<Deck> pDeck);
void SwitchToDeck ( void SwitchToDeck (
const DeckDescriptor& rDeckDescriptor, const DeckDescriptor& rDeckDescriptor,
......
...@@ -132,8 +132,8 @@ void TabBar::SetDecks(const ResourceManager::DeckContextDescriptorContainer& rDe ...@@ -132,8 +132,8 @@ void TabBar::SetDecks(const ResourceManager::DeckContextDescriptorContainer& rDe
rItem.mpButton = CreateTabItem(*pDescriptor); rItem.mpButton = CreateTabItem(*pDescriptor);
rItem.mpButton->SetClickHdl(LINK(&rItem, TabBar::Item, HandleClick)); rItem.mpButton->SetClickHdl(LINK(&rItem, TabBar::Item, HandleClick));
rItem.maDeckActivationFunctor = maDeckActivationFunctor; rItem.maDeckActivationFunctor = maDeckActivationFunctor;
rItem.mbIsHiddenByDefault = false;
rItem.mbIsHidden = ! pDescriptor->mbIsEnabled; rItem.mbIsHidden = ! pDescriptor->mbIsEnabled;
rItem.mbIsHiddenByDefault = rItem.mbIsHidden; // the default is the state while creating
rItem.mpButton->Enable(iDeck->mbIsEnabled); rItem.mpButton->Enable(iDeck->mbIsEnabled);
} }
...@@ -335,9 +335,10 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex) ...@@ -335,9 +335,10 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex)
{ {
maItems[nIndex].mbIsHidden = ! maItems[nIndex].mbIsHidden; maItems[nIndex].mbIsHidden = ! maItems[nIndex].mbIsHidden;
pParentSidebarController->GetResourceManager()->SetIsDeckEnabled( DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(maItems[nIndex].msDeckId);
maItems[nIndex].msDeckId, if (pDeckDescriptor)
maItems[nIndex].mbIsHidden); pDeckDescriptor->mbIsEnabled = ! maItems[nIndex].mbIsHidden;
Layout(); Layout();
} }
} }
...@@ -351,6 +352,11 @@ void TabBar::RestoreHideFlags() ...@@ -351,6 +352,11 @@ void TabBar::RestoreHideFlags()
{ {
iItem->mbIsHidden = iItem->mbIsHiddenByDefault; iItem->mbIsHidden = iItem->mbIsHiddenByDefault;
bNeedsLayout = true; bNeedsLayout = true;
DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId);
if (pDeckDescriptor)
pDeckDescriptor->mbIsEnabled = ! iItem->mbIsHidden;
} }
} }
if (bNeedsLayout) if (bNeedsLayout)
......
...@@ -67,15 +67,19 @@ void SAL_CALL SfxUnoDeck::setTitle( const OUString& newTitle ) ...@@ -67,15 +67,19 @@ void SAL_CALL SfxUnoDeck::setTitle( const OUString& newTitle )
SidebarController* pSidebarController = getSidebarController(); SidebarController* pSidebarController = getSidebarController();
pSidebarController->CreateDeck(mDeckId); pSidebarController->CreateDeck(mDeckId);
Deck* pDeck = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck; DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
DeckTitleBar* pTitleBar = pDeck->GetTitleBar(); if (pDeckDescriptor)
pTitleBar->SetTitle(newTitle); {
Deck* pDeck = pDeckDescriptor->mpDeck;
DeckTitleBar* pTitleBar = pDeck->GetTitleBar();
pTitleBar->SetTitle(newTitle);
// update the ResourceManager pDeckDescriptor->msTitle = newTitle;
pSidebarController->GetResourceManager()->SetDeckTitle(mDeckId, newTitle); pDeckDescriptor->msHelpText = newTitle;
pSidebarController->notifyDeckTitle(mDeckId);
pSidebarController->notifyDeckTitle(mDeckId);
}
} }
sal_Bool SAL_CALL SfxUnoDeck::isActive() sal_Bool SAL_CALL SfxUnoDeck::isActive()
...@@ -129,10 +133,14 @@ void SAL_CALL SfxUnoDeck::setOrderIndex( const sal_Int32 newOrderIndex ) ...@@ -129,10 +133,14 @@ void SAL_CALL SfxUnoDeck::setOrderIndex( const sal_Int32 newOrderIndex )
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
SidebarController* pSidebarController = getSidebarController(); SidebarController* pSidebarController = getSidebarController();
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, newOrderIndex); DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
// update the sidebar if (pDeckDescriptor)
pSidebarController->NotifyResize(); {
pDeckDescriptor->mnOrderIndex = newOrderIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
void SAL_CALL SfxUnoDeck::moveFirst() void SAL_CALL SfxUnoDeck::moveFirst()
...@@ -149,8 +157,13 @@ void SAL_CALL SfxUnoDeck::moveFirst() ...@@ -149,8 +157,13 @@ void SAL_CALL SfxUnoDeck::moveFirst()
if (curOrderIndex != minIndex) // is deck already in place ? if (curOrderIndex != minIndex) // is deck already in place ?
{ {
minIndex -= 1; minIndex -= 1;
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, minIndex); DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
pSidebarController->NotifyResize(); if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = minIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
} }
...@@ -168,8 +181,13 @@ void SAL_CALL SfxUnoDeck::moveLast() ...@@ -168,8 +181,13 @@ void SAL_CALL SfxUnoDeck::moveLast()
if (curOrderIndex != maxIndex) // is deck already in place ? if (curOrderIndex != maxIndex) // is deck already in place ?
{ {
maxIndex += 1; maxIndex += 1;
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, maxIndex); DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
pSidebarController->NotifyResize(); if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = maxIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
} }
...@@ -196,8 +214,13 @@ void SAL_CALL SfxUnoDeck::moveUp() ...@@ -196,8 +214,13 @@ void SAL_CALL SfxUnoDeck::moveUp()
if (curOrderIndex != previousIndex) // is deck already in place ? if (curOrderIndex != previousIndex) // is deck already in place ?
{ {
previousIndex -= 1; previousIndex -= 1;
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, previousIndex); DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
pSidebarController->NotifyResize(); if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = previousIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
} }
...@@ -225,8 +248,13 @@ void SAL_CALL SfxUnoDeck::moveDown() ...@@ -225,8 +248,13 @@ void SAL_CALL SfxUnoDeck::moveDown()
if (curOrderIndex != nextIndex) // is deck already in place ? if (curOrderIndex != nextIndex) // is deck already in place ?
{ {
nextIndex += 1; nextIndex += 1;
pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, nextIndex); DeckDescriptor* pDeckDescriptor = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId);
pSidebarController->NotifyResize(); if (pDeckDescriptor)
{
pDeckDescriptor->mnOrderIndex = nextIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
} }
......
...@@ -31,9 +31,11 @@ mpPanel() ...@@ -31,9 +31,11 @@ mpPanel()
{ {
SidebarController* pSidebarController = getSidebarController(); SidebarController* pSidebarController = getSidebarController();
pSidebarController->CreateDeck(mDeckId); // creates deck object is not already
mpDeck = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck; mpDeck = pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck;
mpPanel = mpDeck->GetPanel(mPanelId); mpPanel = mpDeck->GetPanel(mPanelId);
} }
SidebarController* SfxUnoPanel::getSidebarController() SidebarController* SfxUnoPanel::getSidebarController()
{ {
return SidebarController::GetSidebarControllerForFrame(xFrame); return SidebarController::GetSidebarControllerForFrame(xFrame);
...@@ -61,8 +63,16 @@ void SAL_CALL SfxUnoPanel::setTitle( const OUString& newTitle ) ...@@ -61,8 +63,16 @@ void SAL_CALL SfxUnoPanel::setTitle( const OUString& newTitle )
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
PanelTitleBar* pTitleBar = mpPanel->GetTitleBar(); SidebarController* pSidebarController = getSidebarController();
pTitleBar->SetTitle(newTitle); PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
if (pPanelDescriptor)
{
pPanelDescriptor->msTitle = newTitle;
PanelTitleBar* pTitleBar = mpPanel->GetTitleBar();
if (pTitleBar)
pTitleBar->SetTitle(newTitle);
}
} }
sal_Bool SAL_CALL SfxUnoPanel::isExpanded() sal_Bool SAL_CALL SfxUnoPanel::isExpanded()
...@@ -97,6 +107,9 @@ void SAL_CALL SfxUnoPanel::expand( const sal_Bool bCollapseOther ) ...@@ -97,6 +107,9 @@ void SAL_CALL SfxUnoPanel::expand( const sal_Bool bCollapseOther )
} }
} }
SidebarController* pSidebarController = getSidebarController();
pSidebarController->NotifyResize();
} }
void SAL_CALL SfxUnoPanel::collapse() void SAL_CALL SfxUnoPanel::collapse()
...@@ -105,6 +118,8 @@ void SAL_CALL SfxUnoPanel::collapse() ...@@ -105,6 +118,8 @@ void SAL_CALL SfxUnoPanel::collapse()
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
mpPanel->SetExpanded(false); mpPanel->SetExpanded(false);
SidebarController* pSidebarController = getSidebarController();
pSidebarController->NotifyResize();
} }
uno::Reference<awt::XWindow> SAL_CALL SfxUnoPanel::getDialog() uno::Reference<awt::XWindow> SAL_CALL SfxUnoPanel::getDialog()
...@@ -132,9 +147,14 @@ void SAL_CALL SfxUnoPanel::setOrderIndex( const sal_Int32 newOrderIndex ) ...@@ -132,9 +147,14 @@ void SAL_CALL SfxUnoPanel::setOrderIndex( const sal_Int32 newOrderIndex )
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
SidebarController* pSidebarController = getSidebarController(); SidebarController* pSidebarController = getSidebarController();
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, newOrderIndex); PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
pSidebarController->NotifyResize(); if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = newOrderIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
void SAL_CALL SfxUnoPanel::moveFirst() void SAL_CALL SfxUnoPanel::moveFirst()
...@@ -151,8 +171,13 @@ void SAL_CALL SfxUnoPanel::moveFirst() ...@@ -151,8 +171,13 @@ void SAL_CALL SfxUnoPanel::moveFirst()
if (curOrderIndex != minIndex) // is current panel already in place ? if (curOrderIndex != minIndex) // is current panel already in place ?
{ {
minIndex -= 1; minIndex -= 1;
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, minIndex); PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
pSidebarController->NotifyResize(); if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = minIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
} }
...@@ -170,8 +195,13 @@ void SAL_CALL SfxUnoPanel::moveLast() ...@@ -170,8 +195,13 @@ void SAL_CALL SfxUnoPanel::moveLast()
if (curOrderIndex != maxIndex) // is current panel already in place ? if (curOrderIndex != maxIndex) // is current panel already in place ?
{ {
maxIndex += 1; maxIndex += 1;
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, maxIndex); PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
pSidebarController->NotifyResize(); if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = maxIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
} }
...@@ -198,8 +228,13 @@ void SAL_CALL SfxUnoPanel::moveUp() ...@@ -198,8 +228,13 @@ void SAL_CALL SfxUnoPanel::moveUp()
if (curOrderIndex != previousIndex) // is current panel already in place ? if (curOrderIndex != previousIndex) // is current panel already in place ?
{ {
previousIndex -= 1; previousIndex -= 1;
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, previousIndex); PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
pSidebarController->NotifyResize(); if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = previousIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
} }
...@@ -226,8 +261,13 @@ void SAL_CALL SfxUnoPanel::moveDown() ...@@ -226,8 +261,13 @@ void SAL_CALL SfxUnoPanel::moveDown()
if (curOrderIndex != nextIndex) // is current panel already in place ? if (curOrderIndex != nextIndex) // is current panel already in place ?
{ {
nextIndex += 1; nextIndex += 1;
pSidebarController->GetResourceManager()->SetPanelOrderIndex(mPanelId, nextIndex); PanelDescriptor* pPanelDescriptor = pSidebarController->GetResourceManager()->GetPanelDescriptor(mPanelId);
pSidebarController->NotifyResize(); if (pPanelDescriptor)
{
pPanelDescriptor->mnOrderIndex = nextIndex;
// update the sidebar
pSidebarController->NotifyResize();
}
} }
} }
......
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