diff options
-rw-r--r-- | include/sfx2/sidebar/ContextList.hxx | 1 | ||||
-rw-r--r-- | sfx2/source/sidebar/ContextList.cxx | 20 | ||||
-rw-r--r-- | sfx2/source/sidebar/ResourceManager.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/sidebar/TabBar.cxx | 10 |
4 files changed, 35 insertions, 5 deletions
diff --git a/include/sfx2/sidebar/ContextList.hxx b/include/sfx2/sidebar/ContextList.hxx index 9c56d153f7c6..8e9c1ce48ef4 100644 --- a/include/sfx2/sidebar/ContextList.hxx +++ b/include/sfx2/sidebar/ContextList.hxx @@ -55,6 +55,7 @@ public: const bool bIsInitiallyVisible, const ::rtl::OUString& rsMenuCommand); + void ToggleVisibilityForContext( const Context& rContext,const bool bIsInitiallyVisible ); const ::std::vector<Entry>& GetEntries() const {return maEntries;}; private: diff --git a/sfx2/source/sidebar/ContextList.cxx b/sfx2/source/sidebar/ContextList.cxx index 6b9519639f37..f515dcfcb7ab 100644 --- a/sfx2/source/sidebar/ContextList.cxx +++ b/sfx2/source/sidebar/ContextList.cxx @@ -85,6 +85,26 @@ void ContextList::AddContextDescription ( maEntries.back().msMenuCommand = rsMenuCommand; } +void ContextList::ToggleVisibilityForContext( const Context &rContext, const bool bVisible) +{ + ContextList::Entry *pEntry = GetMatch( rContext ); + + if ( pEntry ) + { + const sal_Int32 nMatch( rContext.EvaluateMatch( pEntry->maContext ) ); + + if ( nMatch & Context::ApplicationWildcardMatch ) + { + // Create a separate context list entry for this app if 'any' + // is the only context that matches. Toggling the visibility + // for 'any' would change it for all apps, not just this one + AddContextDescription( rContext, bVisible, OUString() ); + } + else if ( nMatch == Context::OptimalMatch || nMatch == Context::ContextWildcardMatch ) + pEntry->mbIsInitiallyVisible = bVisible; + } +} + } } // end of namespace sfx2::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index 1389c53a6d80..b2f9d1763f9a 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -54,7 +54,7 @@ bool getBool(utl::OConfigurationNode const & aNode, const char* pNodeName) return comphelper::getBOOL(aNode.getNodeValue(pNodeName)); } -css::uno::Sequence<OUString> BuildContextList (ContextList rContextList, bool isEnabled) +css::uno::Sequence<OUString> BuildContextList (ContextList rContextList) { const ::std::vector<ContextList::Entry>& entries = rContextList.GetEntries(); @@ -69,7 +69,7 @@ css::uno::Sequence<OUString> BuildContextList (ContextList rContextList, bool is OUString menuCommand = iEntry->msMenuCommand; OUString visibility; - if (isEnabled) + if (iEntry->mbIsInitiallyVisible) visibility = "visible"; else visibility = "hidden"; @@ -323,7 +323,7 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc) // save deck settings - ::uno::Sequence< OUString > sContextList = BuildContextList(pDeckDesc->maContextList, pDeckDesc->mbIsEnabled); + ::uno::Sequence< OUString > sContextList = BuildContextList(pDeckDesc->maContextList); utl::OConfigurationNode aDeckNode (aDeckRootNode.openNode(pDeckDesc->msNodeName)); @@ -353,10 +353,9 @@ void ResourceManager::SaveDeckSettings(const DeckDescriptor* pDeckDesc) { Panel* aPanel = *iPanel; OUString panelId = aPanel->GetId(); - bool isExpanded = aPanel->IsExpanded(); const PanelDescriptor* pPanelDesc = GetPanelDescriptor(panelId); - ::uno::Sequence< OUString > sPanelContextList = BuildContextList(pPanelDesc->maContextList, isExpanded); + ::uno::Sequence< OUString > sPanelContextList = BuildContextList(pPanelDesc->maContextList); utl::OConfigurationNode aPanelNode (aPanelRootNode.openNode(pPanelDesc->msNodeName)); diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx index 0c993175f55d..ef6e18557b29 100644 --- a/sfx2/source/sidebar/TabBar.cxx +++ b/sfx2/source/sidebar/TabBar.cxx @@ -337,8 +337,18 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex) DeckDescriptor* pDeckDescriptor = pParentSidebarController->GetResourceManager()->GetDeckDescriptor(maItems[nIndex].msDeckId); if (pDeckDescriptor) + { pDeckDescriptor->mbIsEnabled = ! maItems[nIndex].mbIsHidden; + Context aContext; + aContext.msApplication = pParentSidebarController->GetCurrentContext().msApplication; + // leave aContext.msContext on default 'any' ... this func is used only for decks + // and we don't have context-sensitive decks anyway + + pDeckDescriptor->maContextList.ToggleVisibilityForContext( + aContext, pDeckDescriptor->mbIsEnabled ); + } + Layout(); } } |