summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2016-08-11 12:07:36 +0200
committerSzymon Kłos <eszkadev@gmail.com>2016-08-25 16:55:05 +0000
commit3b01af931470c82375b4f962beb9f71243001230 (patch)
tree79c7ec0bc2582bb8d99c4d62e81d5a361d3dc642
parent1594fd83c303139692c5dd6a7f2e236dbf99638e (diff)
GSoC notebookbar: hiding menubar
+ node in the Notebookbar.xcu determines if menubar is visible for each implementation + new .uno:Menubar command (toggles menubar's visibility) Change-Id: I8ee4ec5bdb78556a8561cc328cba8ecd9bbef60d Reviewed-on: https://gerrit.libreoffice.org/28044 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <eszkadev@gmail.com>
-rw-r--r--include/sfx2/notebookbar/SfxNotebookBar.hxx1
-rw-r--r--include/sfx2/sfxsids.hrc1
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu5
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu6
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs5
-rw-r--r--sfx2/sdi/appslots.sdi5
-rw-r--r--sfx2/sdi/sfx.sdi16
-rw-r--r--sfx2/source/appl/appserv.cxx46
-rw-r--r--sfx2/source/dialog/dialog.src6
-rw-r--r--sfx2/source/notebookbar/NotebookBarPopupMenu.cxx5
-rw-r--r--sfx2/source/notebookbar/NotebookBarPopupMenu.hxx2
-rw-r--r--sfx2/source/notebookbar/SfxNotebookBar.cxx115
12 files changed, 183 insertions, 30 deletions
diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx b/include/sfx2/notebookbar/SfxNotebookBar.hxx
index e3735658d857..12373d1ddd62 100644
--- a/include/sfx2/notebookbar/SfxNotebookBar.hxx
+++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx
@@ -40,6 +40,7 @@ public:
static void RemoveListeners(SystemWindow* pSysWindow);
static void ShowMenubar(bool bShow);
+ static void ToggleMenubar();
private:
static bool m_bLock;
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 249894298f99..f5561feb2ba8 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -545,6 +545,7 @@
#define SID_SEARCH_ITEM (SID_SVX_START + 291)
#define SID_SIDEBAR (SID_SVX_START + 336)
#define SID_NOTEBOOKBAR (SID_SVX_START + 338)
+#define SID_MENUBAR (SID_SVX_START + 339)
#define SID_HYPERLINK_GETLINK (SID_SVX_START + 361)
#define SID_HYPERLINK_SETLINK (SID_SVX_START + 362)
#define SID_INFOBAR (SID_SVX_START + 365)
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 0247b1769d16..9f476a516cf4 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6130,6 +6130,11 @@
<value xml:lang="en-US">Paste Special</value>
</prop>
</node>
+ <node oor:name=".uno:Menubar" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Menubar</value>
+ </prop>
+ </node>
</node>
</node>
</oor:component-data>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu
index 3814b3e71e3c..2b67a6d983e9 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Notebookbar.xcu
@@ -12,6 +12,9 @@
<prop oor:name="File">
<value>notebookbar.ui</value>
</prop>
+ <prop oor:name="HasMenubar">
+ <value>false</value>
+ </prop>
</node>
<node oor:name="Groups" oor:op="replace">
<prop oor:name="Label">
@@ -20,6 +23,9 @@
<prop oor:name="File">
<value>notebookbar_groups.ui</value>
</prop>
+ <prop oor:name="HasMenubar">
+ <value>true</value>
+ </prop>
</node>
</node>
</oor:component-data>
diff --git a/officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs b/officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs
index 51dbeed451f6..ace1d508aefb 100644
--- a/officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/UI/Notebookbar.xcs
@@ -36,6 +36,11 @@
<desc>The .ui file name.</desc>
</info>
</prop>
+ <prop oor:name="HasMenubar" oor:type="xs:boolean" oor:nillable="false">
+ <info>
+ <desc>Determines if menubar is visible.</desc>
+ </info>
+ </prop>
</group>
</templates>
<component>
diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi
index d103b962669a..4921f27e0d3e 100644
--- a/sfx2/sdi/appslots.sdi
+++ b/sfx2/sdi/appslots.sdi
@@ -220,6 +220,11 @@ interface Application
[
ExecMethod = MiscExec_Impl ;
]
+ SID_MENUBAR
+ [
+ ExecMethod = MiscExec_Impl ;
+ StateMethod = MiscState_Impl ;
+ ]
}
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 3afeb51b32d2..7c24c75f65d7 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -2623,6 +2623,22 @@ SfxBoolItem Sidebar SID_SIDEBAR
GroupId = GID_VIEW;
]
+SfxBoolItem Menubar SID_MENUBAR
+[
+ AutoUpdate = TRUE,
+ FastCall = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Asynchron;
+
+ AccelConfig = FALSE,
+ MenuConfig = TRUE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_VIEW;
+]
SfxBoolItem Notebookbar SID_NOTEBOOKBAR
(SfxStringItem File SID_NOTEBOOKBAR)
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index 0014f059c469..1afe604918c8 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -944,6 +944,12 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
bDone = true;
break;
}
+ case SID_MENUBAR:
+ {
+ sfx2::SfxNotebookBar::ToggleMenubar();
+ bDone = true;
+ break;
+ }
default:
break;
@@ -1080,6 +1086,46 @@ void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
}
break;
+ case SID_MENUBAR:
+ {
+ Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
+ Reference< XFrame > xFrame = xDesktop->getActiveFrame();
+
+ Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
+ Reference< css::frame::XLayoutManager > xLayoutManager;
+ if ( xPropSet.is() )
+ {
+ try
+ {
+ Any aValue = xPropSet->getPropertyValue("LayoutManager");
+ aValue >>= xLayoutManager;
+ }
+ catch ( const css::uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch ( css::uno::Exception& )
+ {
+ }
+ }
+
+ if ( xLayoutManager.is() )
+ {
+ bool bState = true;
+ if ( xLayoutManager->getElement( "private:resource/menubar/menubar" ).is()
+ && xLayoutManager->isElementVisible( "private:resource/menubar/menubar" ) )
+ bState = true;
+ else
+ bState = false;
+
+ SfxBoolItem aItem( SID_MENUBAR, bState );
+ rSet.Put( aItem );
+ }
+ if ( Application::GetToolkitName().compareTo( "gtk3" ) == 0 )
+ rSet.DisableItem( SID_MENUBAR );
+ break;
+ }
+
default:
break;
}
diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src
index 732a716b1ecd..1c77c86e6ec6 100644
--- a/sfx2/source/dialog/dialog.src
+++ b/sfx2/source/dialog/dialog.src
@@ -162,6 +162,12 @@ Menu RID_MENU_NOTEBOOKBAR
};
MenuItem
{
+ Identifier = SID_MENUBAR;
+ Command = ".uno:Menubar";
+ Text [ en-US ] = "Menubar" ;
+ };
+ MenuItem
+ {
Identifier = SID_OPTIONS;
Command = ".uno:OptionsTreeDialog";
Text [ en-US ] = "Options" ;
diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx
index 9644b35a9462..35c2495387d0 100644
--- a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx
+++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx
@@ -16,13 +16,14 @@
#include <sfx2/sfxresid.hxx>
#include "NotebookBarPopupMenu.hxx"
#include <vcl/tabctrl.hxx>
+#include <sfx2/notebookbar/SfxNotebookBar.hxx>
using namespace sfx2;
using namespace css::uno;
using namespace css::ui;
-NotebookBarPopupMenu::NotebookBarPopupMenu(ResId aRes)
- : PopupMenu(aRes)
+NotebookBarPopupMenu::NotebookBarPopupMenu()
+ : PopupMenu(SfxResId(RID_MENU_NOTEBOOKBAR))
{
if (SfxViewFrame::Current())
{
diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx
index b8ea6c6aec88..80514113a075 100644
--- a/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx
+++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx
@@ -15,7 +15,7 @@
class NotebookBarPopupMenu : public PopupMenu
{
public:
- explicit NotebookBarPopupMenu(ResId aRes);
+ explicit NotebookBarPopupMenu();
void Execute(NotebookBar* pNotebookbar,
css::uno::Reference<css::frame::XFrame>& xFrame);
};
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 41dac9c5c900..e12beadc2886 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -38,6 +38,64 @@ bool SfxNotebookBar::m_bLock = false;
Reference<css::frame::XLayoutManager> SfxNotebookBar::m_xLayoutManager;
css::uno::Reference<css::frame::XFrame> SfxNotebookBar::m_xFrame;
+static OUString lcl_getAppName( vcl::EnumContext::Application eApp )
+{
+ switch ( eApp )
+ {
+ case vcl::EnumContext::Application::Application_Writer:
+ return OUString( "Writer" );
+ break;
+ case vcl::EnumContext::Application::Application_Calc:
+ return OUString( "Calc" );
+ break;
+ case vcl::EnumContext::Application::Application_Impress:
+ return OUString( "Impress" );
+ break;
+ case vcl::EnumContext::Application::Application_Draw:
+ return OUString( "Draw" );
+ break;
+ default:
+ return OUString( "" );
+ break;
+ }
+}
+
+static const utl::OConfigurationNode lcl_getCurrentImplConfigNode()
+{
+ const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( ::comphelper::getProcessComponentContext() );
+
+ OUStringBuffer aPath("org.openoffice.Office.UI.Notebookbar/");
+
+ const utl::OConfigurationTreeRoot aNotebookbarNode(
+ ::comphelper::getProcessComponentContext(),
+ aPath.makeStringAndClear(),
+ false);
+ if ( !aNotebookbarNode.isValid() )
+ return utl::OConfigurationNode();
+
+ OUString aActive = comphelper::getString( aNotebookbarNode.getNodeValue( "Active" ) );
+
+ const utl::OConfigurationNode aImplsNode = aNotebookbarNode.openNode("Implementations");
+ const Sequence<OUString> aModeNodeNames( aImplsNode.getNodeNames() );
+ const sal_Int32 nCount( aModeNodeNames.getLength() );
+
+ for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex )
+ {
+ const utl::OConfigurationNode aImplNode( aImplsNode.openNode( aModeNodeNames[nReadIndex] ) );
+ if ( !aImplNode.isValid() )
+ continue;
+
+ OUString aCommandArg = comphelper::getString( aImplNode.getNodeValue( "File" ) );
+
+ if ( aCommandArg.compareTo( aActive ) == 0 )
+ {
+ return aImplNode;
+ }
+ }
+
+ return utl::OConfigurationNode();
+}
+
void SfxNotebookBar::CloseMethod(SfxBindings& rBindings)
{
SfxFrame& rFrame = rBindings.GetDispatcher_Impl()->GetFrame()->GetFrame();
@@ -52,6 +110,8 @@ void SfxNotebookBar::CloseMethod(SystemWindow* pSysWindow)
if(pSysWindow->GetNotebookBar())
pSysWindow->CloseNotebookBar();
}
+ SfxNotebookBar::ShowMenubar(true);
+
m_xLayoutManager.clear();
m_xFrame.clear();
}
@@ -62,23 +122,7 @@ bool SfxNotebookBar::IsActive()
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;
- }
+ aPath.append( lcl_getAppName( eApp ) );
const utl::OConfigurationTreeRoot aAppNode(
::comphelper::getProcessComponentContext(),
@@ -92,7 +136,6 @@ bool SfxNotebookBar::IsActive()
const utl::OConfigurationNode aModesNode = aAppNode.openNode("Modes");
const Sequence<OUString> aModeNodeNames( aModesNode.getNodeNames() );
const sal_Int32 nCount( aModeNodeNames.getLength() );
- bool bNotebookbarVisible = false;
for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex )
{
@@ -104,11 +147,10 @@ bool SfxNotebookBar::IsActive()
if ( aCommandArg.compareTo( aActive ) == 0 )
{
- bNotebookbarVisible = comphelper::getBOOL( aModeNode.getNodeValue( "HasNotebookbar" ) );
- break;
+ return comphelper::getBOOL( aModeNode.getNodeValue( "HasNotebookbar" ) );
}
}
- return bNotebookbarVisible;
+ return false;
}
void SfxNotebookBar::ExecMethod(SfxBindings& rBindings, const OUString& rUIName)
@@ -164,10 +206,12 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
// setup if necessary
pSysWindow->SetNotebookBar(aBuf.makeStringAndClear(), xFrame);
-
pSysWindow->GetNotebookBar()->Show();
pSysWindow->GetNotebookBar()->SetIconClickHdl(LINK(nullptr, SfxNotebookBar, OpenNotebookbarPopupMenu));
+ const utl::OConfigurationNode aModeNode( lcl_getCurrentImplConfigNode() );
+ SfxNotebookBar::ShowMenubar( comphelper::getBOOL( aModeNode.getNodeValue( "HasMenubar" ) ) );
+
SfxViewFrame* pView = SfxViewFrame::Current();
if(pView)
@@ -188,7 +232,10 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
return true;
}
else if (auto pNotebookBar = pSysWindow->GetNotebookBar())
+ {
pNotebookBar->Hide();
+ SfxNotebookBar::ShowMenubar(true);
+ }
return false;
}
@@ -210,7 +257,7 @@ IMPL_STATIC_LINK_TYPED(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, p
{
if (pNotebookbar)
{
- ScopedVclPtrInstance<NotebookBarPopupMenu> pMenu(SfxResId(RID_MENU_NOTEBOOKBAR));
+ ScopedVclPtrInstance<NotebookBarPopupMenu> pMenu;
pMenu->Execute(pNotebookbar, m_xFrame);
}
}
@@ -222,14 +269,28 @@ void SfxNotebookBar::ShowMenubar(bool bShow)
m_bLock = true;
m_xLayoutManager->lock();
- if (m_xLayoutManager->getElement(MENUBAR_STR).is() && !bShow)
- m_xLayoutManager->destroyElement(MENUBAR_STR);
- else if(!m_xLayoutManager->getElement(MENUBAR_STR).is() && bShow)
- m_xLayoutManager->createElement(MENUBAR_STR);
+ if (m_xLayoutManager->getElement(MENUBAR_STR).is())
+ {
+ if (m_xLayoutManager->isElementVisible(MENUBAR_STR) && !bShow)
+ m_xLayoutManager->hideElement(MENUBAR_STR);
+ else if(!m_xLayoutManager->isElementVisible(MENUBAR_STR) && bShow)
+ m_xLayoutManager->showElement(MENUBAR_STR);
+ }
m_xLayoutManager->unlock();
m_bLock = false;
}
}
+void SfxNotebookBar::ToggleMenubar()
+{
+ if (m_xLayoutManager.is() && m_xLayoutManager->getElement(MENUBAR_STR).is())
+ {
+ if (m_xLayoutManager->isElementVisible(MENUBAR_STR))
+ SfxNotebookBar::ShowMenubar(false);
+ else
+ SfxNotebookBar::ShowMenubar(true);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */