1*de7b3f82SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*de7b3f82SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*de7b3f82SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*de7b3f82SAndrew Rist * distributed with this work for additional information 6*de7b3f82SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*de7b3f82SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*de7b3f82SAndrew Rist * "License"); you may not use this file except in compliance 9*de7b3f82SAndrew Rist * with the License. You may obtain a copy of the License at 10*de7b3f82SAndrew Rist * 11*de7b3f82SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*de7b3f82SAndrew Rist * 13*de7b3f82SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*de7b3f82SAndrew Rist * software distributed under the License is distributed on an 15*de7b3f82SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*de7b3f82SAndrew Rist * KIND, either express or implied. See the License for the 17*de7b3f82SAndrew Rist * specific language governing permissions and limitations 18*de7b3f82SAndrew Rist * under the License. 19*de7b3f82SAndrew Rist * 20*de7b3f82SAndrew Rist *************************************************************/ 21*de7b3f82SAndrew Rist 22*de7b3f82SAndrew Rist 23cdf0e10cSrcweir #ifndef CHART2_FEATURECOMMANDDISPATCHBASE_HXX 24cdf0e10cSrcweir #define CHART2_FEATURECOMMANDDISPATCHBASE_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "CommandDispatch.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <com/sun/star/frame/CommandGroup.hpp> 29cdf0e10cSrcweir #include <com/sun/star/frame/DispatchInformation.hpp> 30cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir namespace chart 33cdf0e10cSrcweir { 34cdf0e10cSrcweir 35cdf0e10cSrcweir struct ControllerFeature: public ::com::sun::star::frame::DispatchInformation 36cdf0e10cSrcweir { 37cdf0e10cSrcweir sal_uInt16 nFeatureId; 38cdf0e10cSrcweir }; 39cdf0e10cSrcweir 40cdf0e10cSrcweir typedef ::std::map< ::rtl::OUString, 41cdf0e10cSrcweir ControllerFeature, 42cdf0e10cSrcweir ::std::less< ::rtl::OUString > > SupportedFeatures; 43cdf0e10cSrcweir 44cdf0e10cSrcweir struct FeatureState 45cdf0e10cSrcweir { 46cdf0e10cSrcweir bool bEnabled; 47cdf0e10cSrcweir ::com::sun::star::uno::Any aState; 48cdf0e10cSrcweir FeatureStatechart::FeatureState49cdf0e10cSrcweir FeatureState() : bEnabled( false ) { } 50cdf0e10cSrcweir }; 51cdf0e10cSrcweir 52cdf0e10cSrcweir /** This is a base class for CommandDispatch implementations with feature support. 53cdf0e10cSrcweir */ 54cdf0e10cSrcweir class FeatureCommandDispatchBase: public CommandDispatch 55cdf0e10cSrcweir { 56cdf0e10cSrcweir public: 57cdf0e10cSrcweir FeatureCommandDispatchBase( const ::com::sun::star::uno::Reference< 58cdf0e10cSrcweir ::com::sun::star::uno::XComponentContext >& rxContext ); 59cdf0e10cSrcweir virtual ~FeatureCommandDispatchBase(); 60cdf0e10cSrcweir 61cdf0e10cSrcweir // late initialisation, especially for adding as listener 62cdf0e10cSrcweir virtual void initialize(); 63cdf0e10cSrcweir 64cdf0e10cSrcweir virtual bool isFeatureSupported( const ::rtl::OUString& rCommandURL ); 65cdf0e10cSrcweir 66cdf0e10cSrcweir protected: 67cdf0e10cSrcweir // XDispatch 68cdf0e10cSrcweir virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& URL, 69cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) 70cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 71cdf0e10cSrcweir 72cdf0e10cSrcweir virtual void fireStatusEvent( const ::rtl::OUString& rURL, 73cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xSingleListener ); 74cdf0e10cSrcweir 75cdf0e10cSrcweir // state of a feature 76cdf0e10cSrcweir virtual FeatureState getState( const ::rtl::OUString& rCommand ) = 0; 77cdf0e10cSrcweir 78cdf0e10cSrcweir // execute a feature 79cdf0e10cSrcweir virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs ) = 0; 80cdf0e10cSrcweir 81cdf0e10cSrcweir // all the features which should be handled by this class 82cdf0e10cSrcweir virtual void describeSupportedFeatures() = 0; 83cdf0e10cSrcweir 84cdf0e10cSrcweir /** describes a feature supported by the controller 85cdf0e10cSrcweir 86cdf0e10cSrcweir Must not be called outside <member>describeSupportedFeatures</member>. 87cdf0e10cSrcweir 88cdf0e10cSrcweir @param pAsciiCommandURL 89cdf0e10cSrcweir the URL of the feature command 90cdf0e10cSrcweir @param nId 91cdf0e10cSrcweir the id of the feature. Later references to this feature usually happen by id, not by 92cdf0e10cSrcweir URL. 93cdf0e10cSrcweir @param nGroup 94cdf0e10cSrcweir the command group of the feature. This is important for configuring the controller UI 95cdf0e10cSrcweir by the user, see also <type scope="com::sun::star::frame">CommandGroup</type>. 96cdf0e10cSrcweir */ 97cdf0e10cSrcweir void implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL, sal_uInt16 nId, 98cdf0e10cSrcweir sal_Int16 nGroup = ::com::sun::star::frame::CommandGroup::INTERNAL ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir mutable SupportedFeatures m_aSupportedFeatures; 101cdf0e10cSrcweir 102cdf0e10cSrcweir sal_uInt16 m_nFeatureId; 103cdf0e10cSrcweir 104cdf0e10cSrcweir private: 105cdf0e10cSrcweir void fillSupportedFeatures(); 106cdf0e10cSrcweir }; 107cdf0e10cSrcweir 108cdf0e10cSrcweir } // namespace chart 109cdf0e10cSrcweir 110cdf0e10cSrcweir // CHART2_FEATURECOMMANDDISPATCHBASE_HXX 111cdf0e10cSrcweir #endif 112