1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #pragma once 21 22 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp> 23 24 #include <svtools/popupmenucontrollerbase.hxx> 25 #include <rtl/ustring.hxx> 26 #include <vcl/menu.hxx> 27 28 namespace framework 29 { 30 class NewMenuController final : public svt::PopupMenuControllerBase 31 { 32 using svt::PopupMenuControllerBase::disposing; 33 34 public: 35 NewMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); 36 virtual ~NewMenuController() override; 37 38 /* interface XServiceInfo */ 39 virtual OUString SAL_CALL getImplementationName() override; 40 virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override; 41 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; 42 43 // XInitialization 44 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; 45 46 // XStatusListener 47 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; 48 49 // XMenuListener 50 virtual void SAL_CALL itemSelected( const css::awt::MenuEvent& rEvent ) override; 51 virtual void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) override; 52 53 // XEventListener 54 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; 55 56 private: 57 virtual void impl_setPopupMenu() override; 58 59 void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); 60 void retrieveShortcutsFromConfiguration( const css::uno::Reference< css::ui::XAcceleratorConfiguration >& rAccelCfg, 61 const css::uno::Sequence< OUString >& rCommands, 62 std::vector< vcl::KeyCode >& aMenuShortCuts ); 63 void setAccelerators( PopupMenu* pPopupMenu ); 64 void determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const vcl::KeyCode& rKeyCode ); 65 void setMenuImages( PopupMenu* pPopupMenu, bool bSetImages ); 66 67 private: 68 // members 69 bool m_bShowImages : 1, 70 m_bNewMenu : 1, 71 m_bModuleIdentified : 1, 72 m_bAcceleratorCfg : 1; 73 OUString m_aIconTheme; 74 OUString m_aTargetFrame; 75 OUString m_aModuleIdentifier; 76 OUString m_aEmptyDocURL; 77 css::uno::Reference< css::uno::XComponentContext > m_xContext; 78 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xDocAcceleratorManager; 79 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModuleAcceleratorManager; 80 css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobalAcceleratorManager; 81 }; 82 } 83 84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 85