tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / odk / examples / cpp / complextoolbarcontrols / ListenerHelper.h
blobb053ccef39365b777e7e0997a9fdf3d7355aa7b2
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 #ifndef INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_LISTENERHELPER_H
21 #define INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_LISTENERHELPER_H
23 #include <map>
24 #include <vector>
26 #include <com/sun/star/frame/XFrame.hpp>
27 #include <com/sun/star/frame/XStatusListener.hpp>
28 #include <com/sun/star/frame/XDispatch.hpp>
30 #include <rtl/ustring.hxx>
31 #include <cppuhelper/implbase1.hxx>
33 typedef std::vector < com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > > StatusListeners;
35 typedef std::map < ::rtl::OUString, StatusListeners > ListenerMap;
37 // For every frame there is *one* Dispatch object for all possible commands
38 // this struct contains an array of listeners for every supported command
39 // these arrays are accessed by a std::map (with the command string as index)
40 struct ListenerItem
42 ListenerMap aContainer;
43 ::com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > xDispatch;
44 ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame;
47 typedef std::vector < ListenerItem > AllListeners;
49 class ListenerHelper
51 public:
52 void AddListener(
53 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
54 const com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > xControl,
55 const ::rtl::OUString& aCommand );
56 void RemoveListener(
57 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
58 const com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > xControl,
59 const ::rtl::OUString& aCommand );
60 void Notify(
61 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
62 const ::rtl::OUString& aCommand,
63 com::sun::star::frame::FeatureStateEvent& rEvent );
64 com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > GetDispatch(
65 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
66 const ::rtl::OUString& aCommand );
67 void AddDispatch(
68 const com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > xDispatch,
69 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
70 const ::rtl::OUString& aCommand );
73 class ListenerItemEventListener : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XEventListener >
75 ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame;
76 public:
77 ListenerItemEventListener( const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame)
78 : mxFrame(xFrame)
80 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent );
83 #endif
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */