cid#1607171 Data race condition
[LibreOffice.git] / framework / inc / uielement / newmenucontroller.hxx
blob30e57fa71cfaa4ee8309258bebf3ed3a90f4142d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
24 #include <svtools/popupmenucontrollerbase.hxx>
25 #include <rtl/ustring.hxx>
26 #include <vcl/menu.hxx>
28 namespace framework
30 class NewMenuController final : public svt::PopupMenuControllerBase
32 using svt::PopupMenuControllerBase::disposing;
34 public:
35 NewMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext );
36 virtual ~NewMenuController() override;
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;
43 // XStatusListener
44 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
46 // XMenuListener
47 virtual void SAL_CALL itemSelected( const css::awt::MenuEvent& rEvent ) override;
48 virtual void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) override;
50 // XEventListener
51 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
53 private:
54 // XInitialization
55 virtual void initializeImpl( std::unique_lock<std::mutex>& rGuard, const css::uno::Sequence< css::uno::Any >& aArguments ) override;
57 virtual void impl_setPopupMenu(std::unique_lock<std::mutex>& rGuard) override;
59 void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu );
60 static 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();
64 void determineAndSetNewDocAccel(const css::awt::KeyEvent& rKeyCode);
65 void setMenuImages( PopupMenu* pPopupMenu, bool bSetImages );
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;
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */