summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-12-04 15:39:45 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-12-04 17:48:56 +0100
commitfcb7fe3a082c200f69f10c1d3951761a7e41d6e0 (patch)
tree5417f4a4198ccb5cf186460a079d872ff8728a3c /svtools
parentd97a819abe84fe667f8b136b1c2adaec5ca7196e (diff)
move ManagedMenuButton to vcl
Change-Id: Ie2dd1635a5f5f677d286011a14b734af7435612a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107231 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/Library_svt.mk1
-rw-r--r--svtools/source/control/managedmenubutton.cxx122
2 files changed, 0 insertions, 123 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index be89ea4c2b56..adaa6b1bc99d 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -96,7 +96,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/control/ctrltool \
svtools/source/control/indexentryres \
svtools/source/control/inettbc \
- svtools/source/control/managedmenubutton \
svtools/source/control/ruler \
svtools/source/control/scriptedtext \
svtools/source/control/tabbar \
diff --git a/svtools/source/control/managedmenubutton.cxx b/svtools/source/control/managedmenubutton.cxx
deleted file mode 100644
index 4db9d2a1858b..000000000000
--- a/svtools/source/control/managedmenubutton.cxx
+++ /dev/null
@@ -1,122 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
-/*
- * 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 <comphelper/processfactory.hxx>
-#include <comphelper/propertyvalue.hxx>
-#include <vcl/builderfactory.hxx>
-#include <vcl/menu.hxx>
-#include <vcl/menubtn.hxx>
-
-#include <com/sun/star/awt/XPopupMenu.hpp>
-#include <com/sun/star/frame/theDesktop.hpp>
-#include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/frame/thePopupMenuControllerFactory.hpp>
-#include <com/sun/star/frame/XPopupMenuController.hpp>
-
-namespace {
-
-class ManagedMenuButton : public MenuButton
-{
-public:
- ManagedMenuButton(vcl::Window* pParent, WinBits nStyle);
- ~ManagedMenuButton() override;
-
- void Activate() override;
- void dispose() override;
-
-private:
- css::uno::Reference<css::awt::XPopupMenu> m_xPopupMenu;
- css::uno::Reference<css::frame::XPopupMenuController> m_xPopupController;
-};
-
-ManagedMenuButton::ManagedMenuButton(vcl::Window* pParent, WinBits nStyle)
- : MenuButton(pParent, nStyle)
-{
- SetImageAlign(ImageAlign::Left);
-}
-
-ManagedMenuButton::~ManagedMenuButton()
-{
- disposeOnce();
-}
-
-void ManagedMenuButton::dispose()
-{
- css::uno::Reference<css::lang::XComponent> xComponent(m_xPopupController, css::uno::UNO_QUERY);
- if (xComponent.is())
- xComponent->dispose();
-
- m_xPopupMenu.clear();
- m_xPopupController.clear();
- MenuButton::dispose();
-}
-
-void ManagedMenuButton::Activate()
-{
- if (!GetPopupMenu())
- SetPopupMenu(VclPtr<PopupMenu>::Create());
-
- MenuButton::Activate();
-
- if (m_xPopupController.is())
- {
- m_xPopupController->updatePopupMenu();
- return;
- }
-
- if (!m_xPopupMenu.is())
- m_xPopupMenu = GetPopupMenu()->CreateMenuInterface();
-
- // FIXME: get the frame from the parent VclBuilder.
- css::uno::Reference<css::uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
- css::uno::Reference<css::frame::XDesktop2> xDesktop(css::frame::theDesktop::get(xContext));
- css::uno::Reference<css::frame::XFrame> xFrame(xDesktop->getActiveFrame());
- if (!xFrame.is())
- return;
-
- OUString aModuleName;
- try
- {
- css::uno::Reference<css::frame::XModuleManager> xModuleManager(css::frame::ModuleManager::create(xContext));
- aModuleName = xModuleManager->identify(xFrame);
- }
- catch( const css::uno::Exception& )
- {}
-
- css::uno::Sequence<css::uno::Any> aArgs {
- css::uno::makeAny(comphelper::makePropertyValue("ModuleIdentifier", aModuleName)),
- css::uno::makeAny(comphelper::makePropertyValue("Frame", css::uno::makeAny(xFrame))),
- css::uno::makeAny(comphelper::makePropertyValue("InToolbar", css::uno::makeAny(true)))
- };
-
- const OUString aCommand(GetCommand());
- if (!aCommand.isEmpty() && GetPopupMenu()->GetItemCount() == 0)
- {
- css::uno::Reference<css::frame::XUIControllerFactory> xPopupMenuControllerFactory =
- css::frame::thePopupMenuControllerFactory::get(xContext);
-
- if (xPopupMenuControllerFactory->hasController(aCommand, aModuleName))
- m_xPopupController.set(xPopupMenuControllerFactory->createInstanceWithArgumentsAndContext(
- aCommand, aArgs, xContext), css::uno::UNO_QUERY);
- }
-
- // No registered controller found, use one the can handle arbitrary menus (e.g. defined in .ui file).
- if (!m_xPopupController.is())
- m_xPopupController.set(xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
- "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY);
-
- if (m_xPopupController.is())
- m_xPopupController->setPopupMenu(m_xPopupMenu);
-}
-
-}
-
-VCL_BUILDER_FACTORY_ARGS(ManagedMenuButton, WB_CLIPCHILDREN|WB_CENTER|WB_VCENTER|WB_FLATBUTTON)
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */