Line data Source code
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 : #ifndef CHART2_FEATURECOMMANDDISPATCHBASE_HXX
20 : #define CHART2_FEATURECOMMANDDISPATCHBASE_HXX
21 :
22 : #include "CommandDispatch.hxx"
23 :
24 : #include <com/sun/star/frame/CommandGroup.hpp>
25 : #include <com/sun/star/frame/DispatchInformation.hpp>
26 : #include <com/sun/star/util/URL.hpp>
27 :
28 : namespace chart
29 : {
30 :
31 0 : struct ControllerFeature: public ::com::sun::star::frame::DispatchInformation
32 : {
33 : sal_uInt16 nFeatureId;
34 : };
35 :
36 : typedef ::std::map< ::rtl::OUString,
37 : ControllerFeature,
38 : ::std::less< ::rtl::OUString > > SupportedFeatures;
39 :
40 0 : struct FeatureState
41 : {
42 : bool bEnabled;
43 : ::com::sun::star::uno::Any aState;
44 :
45 0 : FeatureState() : bEnabled( false ) { }
46 : };
47 :
48 : /** This is a base class for CommandDispatch implementations with feature support.
49 : */
50 : class FeatureCommandDispatchBase: public CommandDispatch
51 : {
52 : public:
53 : FeatureCommandDispatchBase( const ::com::sun::star::uno::Reference<
54 : ::com::sun::star::uno::XComponentContext >& rxContext );
55 : virtual ~FeatureCommandDispatchBase();
56 :
57 : // late initialisation, especially for adding as listener
58 : virtual void initialize();
59 :
60 : virtual bool isFeatureSupported( const ::rtl::OUString& rCommandURL );
61 :
62 : protected:
63 : // XDispatch
64 : virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& URL,
65 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments )
66 : throw (::com::sun::star::uno::RuntimeException);
67 :
68 : virtual void fireStatusEvent( const ::rtl::OUString& rURL,
69 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xSingleListener );
70 :
71 : // state of a feature
72 : virtual FeatureState getState( const ::rtl::OUString& rCommand ) = 0;
73 :
74 : // execute a feature
75 : virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs ) = 0;
76 :
77 : // all the features which should be handled by this class
78 : virtual void describeSupportedFeatures() = 0;
79 :
80 : /** describes a feature supported by the controller
81 :
82 : Must not be called outside <member>describeSupportedFeatures</member>.
83 :
84 : @param pAsciiCommandURL
85 : the URL of the feature command
86 : @param nId
87 : the id of the feature. Later references to this feature usually happen by id, not by
88 : URL.
89 : @param nGroup
90 : the command group of the feature. This is important for configuring the controller UI
91 : by the user, see also <type scope="com::sun::star::frame">CommandGroup</type>.
92 : */
93 : void implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL, sal_uInt16 nId,
94 : sal_Int16 nGroup = ::com::sun::star::frame::CommandGroup::INTERNAL );
95 :
96 : mutable SupportedFeatures m_aSupportedFeatures;
97 :
98 : sal_uInt16 m_nFeatureId;
99 :
100 : private:
101 : void fillSupportedFeatures();
102 : };
103 :
104 : } // namespace chart
105 :
106 : // CHART2_FEATURECOMMANDDISPATCHBASE_HXX
107 : #endif
108 :
109 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|