summaryrefslogtreecommitdiff
path: root/framework/source/uielement/notebookbarmenucontroller.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/uielement/notebookbarmenucontroller.cxx')
-rw-r--r--framework/source/uielement/notebookbarmenucontroller.cxx42
1 files changed, 39 insertions, 3 deletions
diff --git a/framework/source/uielement/notebookbarmenucontroller.cxx b/framework/source/uielement/notebookbarmenucontroller.cxx
index 1c08b6e2b2eb..c5de77f306b5 100644
--- a/framework/source/uielement/notebookbarmenucontroller.cxx
+++ b/framework/source/uielement/notebookbarmenucontroller.cxx
@@ -30,6 +30,9 @@
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/ui/UIElementType.hpp>
#include <officecfg/Office/UI/Notebookbar.hxx>
+#include <officecfg/Office/UI/ToolbarMode.hxx>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
#include <vcl/menu.hxx>
#include <vcl/svapp.hxx>
@@ -199,9 +202,7 @@ void SAL_CALL NotebookbarMenuController::itemSelected( const css::awt::MenuEvent
OUStringBuffer aBuf(".uno:Notebookbar?File:string=");
aBuf.append( aCmd );
aTargetURL.Complete = aBuf.makeStringAndClear();
- std::shared_ptr<comphelper::ConfigurationChanges> batch( comphelper::ConfigurationChanges::create( m_xContext ) );
- officecfg::Office::UI::Notebookbar::Active::set( aCmd, batch );
- batch->commit();
+
xURLTransformer->parseStrict( aTargetURL );
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
if ( xDispatchProvider.is() )
@@ -223,8 +224,43 @@ void SAL_CALL NotebookbarMenuController::itemActivated( const css::awt::MenuEven
{
OUString aActive = officecfg::Office::UI::Notebookbar::Active::get( m_xContext );
+ const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( m_xContext );
+ vcl::EnumContext::Application eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(m_xFrame));
+
+ OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/");
+ switch ( eApp )
+ {
+ case vcl::EnumContext::Application::Application_Writer:
+ aPath.append("Writer");
+ break;
+ case vcl::EnumContext::Application::Application_Calc:
+ aPath.append("Calc");
+ break;
+ case vcl::EnumContext::Application::Application_Impress:
+ aPath.append("Impress");
+ break;
+ case vcl::EnumContext::Application::Application_Draw:
+ aPath.append("Draw");
+ break;
+ default:
+ break;
+ }
+
+ const utl::OConfigurationTreeRoot aModesNode(
+ m_xContext,
+ aPath.makeStringAndClear(),
+ false);
+ if ( !aModesNode.isValid() )
+ return;
+
+ // Entries are enabled only when Notebookbar mode is active
+ bool bActive = ( comphelper::getString( aModesNode.getNodeValue( "Active" ) ).compareTo("Notebookbar") == 0 );
+
for ( int i = 0; i < m_xPopupMenu->getItemCount(); ++i )
+ {
m_xPopupMenu->checkItem( i+1, ( aActive.compareTo( m_xPopupMenu->getCommand( i+1 ) ) == 0 ) );
+ m_xPopupMenu->enableItem( i+1, bActive );
+ }
}
// XPopupMenuController