From 535f2b2b0a21407c4412d14149d271a199c3e6b8 Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Sun, 15 Jan 2017 21:02:49 +0200 Subject: Convert RID_MENU_NOTEBOOKBAR to xml Brings a lot of features (icons, keyboard shortcuts, customization, context menu interception etc.) Other changes: - Make SfxDispatcher::ExecutePopup take PopupMenuFlags arg, to be able to pass NoMouseUpClose, so that the menu won't close on mouse-up under anything != gtk3. - Make .uno:OpenFromWriter and .uno:OpenFromCalc async slots, to avoid crash under gtk3 when recycling the current frame. - Don't show the menu in customization dialog, if experimental mode disabled. Change-Id: Ieea2f73f6b48fbaf4bdfc4acf1a33d25422357cb Reviewed-on: https://gerrit.libreoffice.org/33101 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky --- cui/source/customize/cfg.cxx | 8 ++ include/sfx2/dispatch.hxx | 4 +- .../org/openoffice/Office/UI/CalcWindowState.xcu | 5 ++ .../openoffice/Office/UI/ImpressWindowState.xcu | 5 ++ .../org/openoffice/Office/UI/WriterWindowState.xcu | 5 ++ sc/UIConfig_scalc.mk | 1 + sc/sdi/scalc.sdi | 1 + sc/uiconfig/scalc/popupmenu/notebookbar.xml | 19 +++++ sd/UIConfig_simpress.mk | 1 + sd/uiconfig/simpress/popupmenu/notebookbar.xml | 19 +++++ sfx2/Library_sfx.mk | 1 - sfx2/source/control/dispatch.cxx | 4 +- sfx2/source/dialog/dialog.src | 55 ------------- sfx2/source/inc/sfxlocal.hrc | 2 - sfx2/source/notebookbar/NotebookBarPopupMenu.cxx | 96 ---------------------- sfx2/source/notebookbar/NotebookBarPopupMenu.hxx | 23 ------ sfx2/source/notebookbar/SfxNotebookBar.cxx | 17 ++-- sw/UIConfig_swriter.mk | 1 + sw/sdi/swriter.sdi | 1 + sw/uiconfig/swriter/popupmenu/notebookbar.xml | 19 +++++ 20 files changed, 97 insertions(+), 190 deletions(-) create mode 100644 sc/uiconfig/scalc/popupmenu/notebookbar.xml create mode 100644 sd/uiconfig/simpress/popupmenu/notebookbar.xml delete mode 100644 sfx2/source/notebookbar/NotebookBarPopupMenu.cxx delete mode 100644 sfx2/source/notebookbar/NotebookBarPopupMenu.hxx create mode 100644 sw/uiconfig/swriter/popupmenu/notebookbar.xml diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index 695a51c64219..a3406f2f10e0 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -1358,6 +1358,8 @@ SvxEntries* ContextMenuSaveInData::GetEntries() { if ( !m_pRootEntry ) { + bool bExperimental = SvtMiscOptions().IsExperimentalMode(); + typedef std::unordered_map< OUString, bool, OUStringHash > MenuInfo; MenuInfo aMenuInfo; @@ -1382,6 +1384,9 @@ SvxEntries* ContextMenuSaveInData::GetEntries() } } + if ( !bExperimental && aUrl.endsWith("notebookbar") ) + continue; + css::uno::Reference< css::container::XIndexAccess > xPopupMenu; try { @@ -1430,6 +1435,9 @@ SvxEntries* ContextMenuSaveInData::GetEntries() } } + if ( !bExperimental && aUrl.endsWith("notebookbar") ) + continue; + css::uno::Reference< css::container::XIndexAccess > xPopupMenu; try { diff --git a/include/sfx2/dispatch.hxx b/include/sfx2/dispatch.hxx index ac675cc242b3..92d0b42cb3fb 100644 --- a/include/sfx2/dispatch.hxx +++ b/include/sfx2/dispatch.hxx @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -147,7 +148,8 @@ public: SfxViewFrame* GetFrame() const; SfxModule* GetModule() const; - void ExecutePopup( const OUString &rResName, vcl::Window *pWin = nullptr, const Point *pPos = nullptr ); + void ExecutePopup( const OUString &rResName, vcl::Window *pWin = nullptr, const Point *pPos = nullptr, + PopupMenuFlags nFlags = PopupMenuFlags::ExecuteDown ); static void ExecutePopup( vcl::Window *pWin = nullptr, const Point *pPosPixel = nullptr ); bool IsAppDispatcher() const; diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu index 0a797cdd0e07..0bbaab8d50d5 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcWindowState.xcu @@ -75,6 +75,11 @@ Media + + + Notebookbar + + OLE Object diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu index 9669f88a811d..2f81b1143f78 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ImpressWindowState.xcu @@ -100,6 +100,11 @@ Multiple Selection + + + Notebookbar + + OLE Object diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu index f1eb33d19754..740462ad46c7 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu @@ -60,6 +60,11 @@ Media + + + Notebookbar + + OLE Object diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk index 056dbdace4cb..89527f367a4f 100644 --- a/sc/UIConfig_scalc.mk +++ b/sc/UIConfig_scalc.mk @@ -35,6 +35,7 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/scalc,\ sc/uiconfig/scalc/popupmenu/freezepanes \ sc/uiconfig/scalc/popupmenu/graphic \ sc/uiconfig/scalc/popupmenu/media \ + sc/uiconfig/scalc/popupmenu/notebookbar \ sc/uiconfig/scalc/popupmenu/oleobject \ sc/uiconfig/scalc/popupmenu/pagebreak \ sc/uiconfig/scalc/popupmenu/pivot \ diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi index aff80507a625..2ca2a7b2b74d 100644 --- a/sc/sdi/scalc.sdi +++ b/sc/sdi/scalc.sdi @@ -6468,6 +6468,7 @@ SfxVoidItem OpenFromCalc SID_OPEN_CALC Container = FALSE, RecordAbsolute = FALSE, RecordPerSet; + Asynchron; SlotType = SfxStringItem diff --git a/sc/uiconfig/scalc/popupmenu/notebookbar.xml b/sc/uiconfig/scalc/popupmenu/notebookbar.xml new file mode 100644 index 000000000000..29356d5c8281 --- /dev/null +++ b/sc/uiconfig/scalc/popupmenu/notebookbar.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/sd/UIConfig_simpress.mk b/sd/UIConfig_simpress.mk index a2930acd7b66..f268c0074d62 100644 --- a/sd/UIConfig_simpress.mk +++ b/sd/UIConfig_simpress.mk @@ -31,6 +31,7 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/simpress,\ sd/uiconfig/simpress/popupmenu/measure \ sd/uiconfig/simpress/popupmenu/media \ sd/uiconfig/simpress/popupmenu/multiselect \ + sd/uiconfig/simpress/popupmenu/notebookbar \ sd/uiconfig/simpress/popupmenu/oleobject \ sd/uiconfig/simpress/popupmenu/outlinetext \ sd/uiconfig/simpress/popupmenu/outline \ diff --git a/sd/uiconfig/simpress/popupmenu/notebookbar.xml b/sd/uiconfig/simpress/popupmenu/notebookbar.xml new file mode 100644 index 000000000000..7814a63c3f71 --- /dev/null +++ b/sd/uiconfig/simpress/popupmenu/notebookbar.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 642e96031230..65e52861d9c1 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -242,7 +242,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/notebookbar/BigToolBox \ sfx2/source/notebookbar/ContextVBox \ sfx2/source/notebookbar/DropdownBox \ - sfx2/source/notebookbar/NotebookBarPopupMenu \ sfx2/source/notebookbar/NotebookbarToolBox \ sfx2/source/notebookbar/PriorityHBox \ sfx2/source/notebookbar/SfxNotebookBar \ diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index dbb4a7b9d360..93e5c778d8f2 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -1941,7 +1941,7 @@ void SfxDispatcher::ExecutePopup( vcl::Window *pWin, const Point *pPos ) } } -void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window *pWin, const Point* pPos ) +void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window* pWin, const Point* pPos, PopupMenuFlags nFlags ) { css::uno::Sequence< css::uno::Any > aArgs( 3 ); aArgs[0] <<= comphelper::makePropertyValue( "Value", rResName ); @@ -1986,7 +1986,7 @@ void SfxDispatcher::ExecutePopup( const OUString& rResName, vcl::Window *pWin, c OUString aMenuURL = "private:resource/popupmenu/" + rResName; if (pVCLMenu && GetFrame()->GetViewShell()->TryContextMenuInterception(*pVCLMenu, aMenuURL, aEvent)) { - pVCLMenu->Execute(pWindow, aPos); + pVCLMenu->Execute(pWindow, Rectangle(aPos, aPos), nFlags); } } diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src index 1c77c86e6ec6..60128b6c3884 100644 --- a/sfx2/source/dialog/dialog.src +++ b/sfx2/source/dialog/dialog.src @@ -126,59 +126,4 @@ String STR_PREVIEW_CHECKBOX Text [ en-US ] = "Show Previews"; }; -Menu RID_MENU_NOTEBOOKBAR -{ - ItemList = - { - MenuItem - { - Identifier = SID_OPENDOC; - Command = ".uno:Open"; - Text [ en-US ] = "Open..." ; - }; - MenuItem - { - Identifier = SID_SAVEDOC; - Command = ".uno:Save"; - Text [ en-US ] = "Save" ; - }; - MenuItem - { - Identifier = SID_UNDO; - Command = ".uno:Undo"; - Text [ en-US ] = "Undo" ; - }; - MenuItem - { - Identifier = SID_REDO; - Command = ".uno:Redo"; - Text [ en-US ] = "Redo" ; - }; - MenuItem - { - Identifier = SID_PRINTDOC; - Command = ".uno:Print"; - Text [ en-US ] = "Print" ; - }; - MenuItem - { - Identifier = SID_MENUBAR; - Command = ".uno:Menubar"; - Text [ en-US ] = "Menubar" ; - }; - MenuItem - { - Identifier = SID_OPTIONS; - Command = ".uno:OptionsTreeDialog"; - Text [ en-US ] = "Options" ; - }; - MenuItem - { - Identifier = SID_CLOSEDOC; - Command = ".uno:CloseDoc"; - Text [ en-US ] = "Close" ; - }; - }; -}; - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/sfxlocal.hrc b/sfx2/source/inc/sfxlocal.hrc index ea9f8354f18a..f1fa47483d98 100644 --- a/sfx2/source/inc/sfxlocal.hrc +++ b/sfx2/source/inc/sfxlocal.hrc @@ -43,8 +43,6 @@ #define SFX_IMG_PROPERTY_REMOVE (RID_SFX_SFXLOCAL_START + 0) #define SFX_IMG_CLOSE_DOC (RID_SFX_SFXLOCAL_START + 2) -#define RID_MENU_NOTEBOOKBAR (RID_SFX_SFXLOCAL_START + 10) - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx deleted file mode 100644 index 9d36d015fe18..000000000000 --- a/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "NotebookBarPopupMenu.hxx" -#include -#include - -using namespace sfx2; -using namespace css::uno; -using namespace css::ui; - -NotebookBarPopupMenu::NotebookBarPopupMenu() - : PopupMenu(SfxResId(RID_MENU_NOTEBOOKBAR)) -{ - if (SfxViewFrame::Current()) - { - SfxDispatcher* pDispatcher = SfxViewFrame::Current()->GetBindings().GetDispatcher(); - if (pDispatcher) - { - for (int i = 0; i < GetItemCount(); ++i) - { - const SfxPoolItem* pItem; - SfxItemState eState = pDispatcher->QueryState(GetItemId(i), pItem); - if (eState == SfxItemState::DISABLED) - this->EnableItem(GetItemId(i), false); - else - this->EnableItem(GetItemId(i)); - } - } - } - else - { - HideItem(SID_UNDO); - HideItem(SID_REDO); - HideItem(SID_PRINTDOC); - HideItem(SID_SAVEDOC); - } - EnableItem(SID_OPTIONS); -} - -void NotebookBarPopupMenu::Execute(NotebookBar* pNotebookbar, - const Reference& xFrame) -{ - if (pNotebookbar) - { - sal_uInt16 nTop = NotebookbarTabControl::GetHeaderHeight(); - sal_uInt16 nSelected = PopupMenu::Execute(pNotebookbar, - Rectangle(0, nTop, 0, nTop), - PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose); - - if (nSelected) - { - OUString aCommandURL = GetItemCommand(nSelected); - css::util::URL aUrl; - aUrl.Complete = aCommandURL; - - Reference xURLTransformer( - css::util::URLTransformer::create(comphelper::getProcessComponentContext())); - if (xURLTransformer.is()) - xURLTransformer->parseStrict(aUrl); - - if (xFrame.is()) - { - css::uno::Reference xDispatch; - css::uno::Reference xDispatchProvider(xFrame, UNO_QUERY); - - if (xDispatchProvider.is()) - { - xDispatch = xDispatchProvider->queryDispatch(aUrl, OUString(), 0); - } - if (xDispatch.is()) - { - Sequence aArgs; - xDispatch->dispatch(aUrl, aArgs); - } - } - else - SAL_WARN("sfx", "Can't create XDispatchProvider"); - } - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx deleted file mode 100644 index 0d06a6e788d6..000000000000 --- a/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include -#include -#include -#include - -class NotebookBarPopupMenu : public PopupMenu -{ -public: - explicit NotebookBarPopupMenu(); - void Execute(NotebookBar* pNotebookbar, - const css::uno::Reference& xFrame); -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 8adf1c0c3493..203c0f93f729 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -13,14 +13,13 @@ #include #include #include -#include +#include #include #include #include #include #include #include -#include "NotebookBarPopupMenu.hxx" #include #include #include @@ -336,15 +335,13 @@ void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow) IMPL_STATIC_LINK(SfxNotebookBar, OpenNotebookbarPopupMenu, NotebookBar*, pNotebookbar, void) { - if (pNotebookbar) + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : nullptr; + if (pNotebookbar && pDispatcher) { - ScopedVclPtrInstance pMenu; - if (SfxViewFrame::Current()) - { - const Reference& xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface(); - if (xFrame.is()) - pMenu->Execute(pNotebookbar, xFrame); - } + Point aPos(0, NotebookbarTabControl::GetHeaderHeight()); + pDispatcher->ExecutePopup("notebookbar", pNotebookbar, &aPos, + PopupMenuFlags::ExecuteDown|PopupMenuFlags::NoMouseUpClose); } } diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 2ff017fe3b6a..532f0ba409cb 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -24,6 +24,7 @@ $(eval $(call gb_UIConfig_add_popupmenufiles,modules/swriter,\ sw/uiconfig/swriter/popupmenu/graphic \ sw/uiconfig/swriter/popupmenu/insertfield \ sw/uiconfig/swriter/popupmenu/media \ + sw/uiconfig/swriter/popupmenu/notebookbar \ sw/uiconfig/swriter/popupmenu/oleobject \ sw/uiconfig/swriter/popupmenu/preview \ sw/uiconfig/swriter/popupmenu/table \ diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 494068ac9968..4de6cbba33d0 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -7408,6 +7408,7 @@ SfxVoidItem OpenFromWriter FN_OPEN_FILE Container = FALSE, RecordAbsolute = FALSE, RecordPerSet; + Asynchron; SlotType = SfxStringItem diff --git a/sw/uiconfig/swriter/popupmenu/notebookbar.xml b/sw/uiconfig/swriter/popupmenu/notebookbar.xml new file mode 100644 index 000000000000..d37082e53a14 --- /dev/null +++ b/sw/uiconfig/swriter/popupmenu/notebookbar.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + -- cgit