bump product version to 4.1.6.2
[LibreOffice.git] / odk / examples / cpp / complextoolbarcontrols / ListenerHelper.h
blob0fe4bd02a9379f193fb44a1321a8558af0963a44
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 #include <map>
21 #include <vector>
23 #include <com/sun/star/frame/XFrame.hpp>
24 #include <com/sun/star/frame/XStatusListener.hpp>
25 #include <com/sun/star/frame/XDispatch.hpp>
27 #include <rtl/ustring.hxx>
28 #include <cppuhelper/implbase1.hxx>
30 typedef std::vector < com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > > StatusListeners;
32 typedef std::map < ::rtl::OUString, StatusListeners > ListenerMap;
34 // For every frame there is *one* Dispatch object for all possible commands
35 // this struct contains an array of listeners for every supported command
36 // these arrays are accessed by a std::map (with the command string as index)
37 struct ListenerItem
39 ListenerMap aContainer;
40 ::com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > xDispatch;
41 ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame;
44 typedef std::vector < ListenerItem > AllListeners;
46 class ListenerHelper
48 public:
49 void AddListener(
50 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
51 const com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > xControl,
52 const ::rtl::OUString& aCommand );
53 void RemoveListener(
54 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
55 const com::sun::star::uno::Reference < com::sun::star::frame::XStatusListener > xControl,
56 const ::rtl::OUString& aCommand );
57 void Notify(
58 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
59 const ::rtl::OUString& aCommand,
60 com::sun::star::frame::FeatureStateEvent& rEvent );
61 com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > GetDispatch(
62 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
63 const ::rtl::OUString& aCommand );
64 void AddDispatch(
65 const com::sun::star::uno::Reference < com::sun::star::frame::XDispatch > xDispatch,
66 const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame,
67 const ::rtl::OUString& aCommand );
70 class ListenerItemEventListener : public cppu::WeakImplHelper1 < ::com::sun::star::lang::XEventListener >
72 ::com::sun::star::uno::Reference< com::sun::star::frame::XFrame > mxFrame;
73 public:
74 ListenerItemEventListener( const com::sun::star::uno::Reference < com::sun::star::frame::XFrame >& xFrame)
75 : mxFrame(xFrame)
77 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException);
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */