summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2016-07-20 16:08:38 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-07-22 08:59:59 +0000
commitb949604b91f77dee3b2737ea09e1ac3ade4eed1c (patch)
tree84b3f65668c933f8fc5e5ce3541df5aa0919c7ef /sfx2
parentb5c05876f73c31270bc374e4f481ef1d09a42e5f (diff)
GSoC notebookbar: file menu
+ added icon to the notebookbar, after click the file menu will appear Change-Id: I30e1ed7e2c4a194e150c7196652904fd4e5c9e8e Reviewed-on: https://gerrit.libreoffice.org/27347 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/Library_sfx.mk1
-rw-r--r--sfx2/source/dialog/backingcomp.cxx4
-rw-r--r--sfx2/source/dialog/dialog.src49
-rw-r--r--sfx2/source/inc/sfxlocal.hrc2
-rw-r--r--sfx2/source/notebookbar/NotebookBarPopupMenu.cxx82
-rw-r--r--sfx2/source/notebookbar/NotebookBarPopupMenu.hxx23
-rw-r--r--sfx2/source/notebookbar/SfxNotebookBar.cxx61
7 files changed, 219 insertions, 3 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 1a28afd63dee..5ee2773ebbf4 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -235,6 +235,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/explorer/nochaos \
sfx2/source/inet/inettbc \
sfx2/source/notebookbar/DropdownBox \
+ sfx2/source/notebookbar/NotebookBarPopupMenu \
sfx2/source/notebookbar/PriorityHBox \
sfx2/source/notebookbar/SfxNotebookBar \
sfx2/source/notify/eventsupplier \
diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx
index 937501b4efa4..8767519e1b3f 100644
--- a/sfx2/source/dialog/backingcomp.cxx
+++ b/sfx2/source/dialog/backingcomp.cxx
@@ -603,9 +603,7 @@ void SAL_CALL BackingComp::dispose()
VclPtr< WorkWindow > pParent = static_cast<WorkWindow*>(VCLUnoHelper::GetWindow(xParentWindow).get());
// hide NotebookBar
- SystemWindow* pSysWindow = static_cast<SystemWindow*>(pParent);
- if (pSysWindow && pSysWindow->GetNotebookBar())
- pSysWindow->GetNotebookBar()->Hide();
+ sfx2::SfxNotebookBar::CloseMethod(static_cast<SystemWindow*>(pParent));
}
// stop listening at the window
diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src
index a3ed837987c8..c66f4475858a 100644
--- a/sfx2/source/dialog/dialog.src
+++ b/sfx2/source/dialog/dialog.src
@@ -121,4 +121,53 @@ String STR_FONT_TABPAGE
Text [ en-US ] = "Font" ;
};
+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_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 33eb9410e4ce..65360c9175f3 100644
--- a/sfx2/source/inc/sfxlocal.hrc
+++ b/sfx2/source/inc/sfxlocal.hrc
@@ -47,6 +47,8 @@
#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
new file mode 100644
index 000000000000..d0cd103613da
--- /dev/null
+++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.cxx
@@ -0,0 +1,82 @@
+/* -*- 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 <sfx2/dispatch.hxx>
+#include <vcl/notebookbar.hxx>
+#include <vcl/menu.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/util/URLTransformer.hpp>
+#include <sfxlocal.hrc>
+#include <sfx2/sfxresid.hxx>
+#include "NotebookBarPopupMenu.hxx"
+
+using namespace sfx2;
+using namespace css::uno;
+using namespace css::ui;
+
+NotebookBarPopupMenu::NotebookBarPopupMenu(ResId aRes)
+ : PopupMenu(aRes)
+{
+ if (SfxViewFrame::Current())
+ {
+ for (int i = 0; i < GetItemCount(); ++i)
+ {
+ const SfxPoolItem* pItem;
+ SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->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,
+ css::uno::Reference<css::frame::XFrame>& xFrame)
+{
+ if (pNotebookbar)
+ {
+ sal_uInt16 nSelected = PopupMenu::Execute(pNotebookbar, Point(0, 40));
+
+ if (nSelected)
+ {
+ OUString aCommandURL = GetItemCommand(nSelected);
+ css::util::URL aUrl;
+ aUrl.Complete = aCommandURL;
+
+ Reference<css::util::XURLTransformer> xURLTransformer(
+ css::util::URLTransformer::create(comphelper::getProcessComponentContext()));
+ if (xURLTransformer.is())
+ xURLTransformer->parseStrict(aUrl);
+
+ css::uno::Reference<css::frame::XDispatch> xDispatch;
+ css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(xFrame, UNO_QUERY);
+
+ if (xDispatchProvider.is())
+ {
+ xDispatch = xDispatchProvider->queryDispatch(aUrl, OUString(), 0);
+ }
+ if (xDispatch.is())
+ {
+ Sequence<com::sun::star::beans::PropertyValue> aArgs;
+ xDispatch->dispatch(aUrl, aArgs);
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx b/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx
new file mode 100644
index 000000000000..2fca13512849
--- /dev/null
+++ b/sfx2/source/notebookbar/NotebookBarPopupMenu.hxx
@@ -0,0 +1,23 @@
+/* -*- 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 <vcl/notebookbar.hxx>
+#include <vcl/menu.hxx>
+#include <sfxlocal.hrc>
+#include <sfx2/sfxresid.hxx>
+
+class NotebookBarPopupMenu : public PopupMenu
+{
+public:
+ NotebookBarPopupMenu(ResId aRes);
+ void Execute(NotebookBar* pNotebookbar,
+ css::uno::Reference<css::frame::XFrame>& xFrame);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 2ae984d2fb5e..dc20c7528bbb 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -13,20 +13,40 @@
#include <unotools/viewoptions.hxx>
#include <vcl/notebookbar.hxx>
#include <vcl/syswin.hxx>
+#include <vcl/menu.hxx>
#include <sfx2/viewfrm.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include "NotebookBarPopupMenu.hxx"
using namespace sfx2;
using namespace css::uno;
using namespace css::ui;
+#define MENUBAR_STR "private:resource/menubar/menubar"
+
+bool SfxNotebookBar::m_bLock = false;
+Reference<css::frame::XLayoutManager> SfxNotebookBar::m_xLayoutManager;
+css::uno::Reference<css::frame::XFrame> SfxNotebookBar::m_xFrame;
+
void SfxNotebookBar::CloseMethod(SfxBindings& rBindings)
{
SfxFrame& rFrame = rBindings.GetDispatcher_Impl()->GetFrame()->GetFrame();
if (rFrame.GetSystemWindow()->GetNotebookBar())
rFrame.GetSystemWindow()->CloseNotebookBar();
+ m_xLayoutManager.clear();
+ m_xFrame.clear();
+}
+
+void SfxNotebookBar::CloseMethod(SystemWindow* pSysWindow)
+{
+ if (pSysWindow && pSysWindow->GetNotebookBar())
+ pSysWindow->CloseNotebookBar();
+ m_xLayoutManager.clear();
+ m_xFrame.clear();
}
void SfxNotebookBar::ExecMethod(SfxBindings& rBindings)
@@ -51,6 +71,19 @@ void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
{
assert(pSysWindow);
+ m_xFrame = xFrame;
+
+ if (!m_xLayoutManager.is())
+ {
+ Reference<css::beans::XPropertySet> xPropSet(xFrame, UNO_QUERY);
+
+ if (xPropSet.is())
+ {
+ Any aValue = xPropSet->getPropertyValue("LayoutManager");
+ aValue >>= m_xLayoutManager;
+ }
+ }
+
SvtViewOptions aViewOpt(E_WINDOW, "notebookbar");
if (aViewOpt.IsVisible())
@@ -61,6 +94,7 @@ void SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
pSysWindow->SetNotebookBar(rUIFile, xFrame);
pSysWindow->GetNotebookBar()->Show();
+ pSysWindow->GetNotebookBar()->SetIconClickHdl(LINK(nullptr, SfxNotebookBar, ToggleMenubar));
SfxViewFrame* pView = SfxViewFrame::Current();
@@ -95,4 +129,31 @@ void SfxNotebookBar::RemoveListeners(SystemWindow* pSysWindow)
}
}
+IMPL_STATIC_LINK_TYPED(SfxNotebookBar, ToggleMenubar, NotebookBar*, pNotebookbar, void)
+{
+ if (pNotebookbar)
+ {
+ VclPtr<NotebookBarPopupMenu> pMenu = VclPtr<NotebookBarPopupMenu>::Create(SfxResId(RID_MENU_NOTEBOOKBAR));
+ pMenu->Execute(pNotebookbar, m_xFrame);
+ pMenu->Clear();
+ }
+}
+
+void SfxNotebookBar::ShowMenubar(bool bShow)
+{
+ if (!m_bLock && m_xLayoutManager.is())
+ {
+ 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);
+
+ m_xLayoutManager->unlock();
+ m_bLock = false;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */