1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef CHART2_FEATURECOMMANDDISPATCHBASE_HXX 28 #define CHART2_FEATURECOMMANDDISPATCHBASE_HXX 29 30 #include "CommandDispatch.hxx" 31 32 #include <com/sun/star/frame/CommandGroup.hpp> 33 #include <com/sun/star/frame/DispatchInformation.hpp> 34 #include <com/sun/star/util/URL.hpp> 35 36 namespace chart 37 { 38 39 struct ControllerFeature: public ::com::sun::star::frame::DispatchInformation 40 { 41 sal_uInt16 nFeatureId; 42 }; 43 44 typedef ::std::map< ::rtl::OUString, 45 ControllerFeature, 46 ::std::less< ::rtl::OUString > > SupportedFeatures; 47 48 struct FeatureState 49 { 50 bool bEnabled; 51 ::com::sun::star::uno::Any aState; 52 53 FeatureState() : bEnabled( false ) { } 54 }; 55 56 /** This is a base class for CommandDispatch implementations with feature support. 57 */ 58 class FeatureCommandDispatchBase: public CommandDispatch 59 { 60 public: 61 FeatureCommandDispatchBase( const ::com::sun::star::uno::Reference< 62 ::com::sun::star::uno::XComponentContext >& rxContext ); 63 virtual ~FeatureCommandDispatchBase(); 64 65 // late initialisation, especially for adding as listener 66 virtual void initialize(); 67 68 virtual bool isFeatureSupported( const ::rtl::OUString& rCommandURL ); 69 70 protected: 71 // XDispatch 72 virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& URL, 73 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) 74 throw (::com::sun::star::uno::RuntimeException); 75 76 virtual void fireStatusEvent( const ::rtl::OUString& rURL, 77 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xSingleListener ); 78 79 // state of a feature 80 virtual FeatureState getState( const ::rtl::OUString& rCommand ) = 0; 81 82 // execute a feature 83 virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs ) = 0; 84 85 // all the features which should be handled by this class 86 virtual void describeSupportedFeatures() = 0; 87 88 /** describes a feature supported by the controller 89 90 Must not be called outside <member>describeSupportedFeatures</member>. 91 92 @param pAsciiCommandURL 93 the URL of the feature command 94 @param nId 95 the id of the feature. Later references to this feature usually happen by id, not by 96 URL. 97 @param nGroup 98 the command group of the feature. This is important for configuring the controller UI 99 by the user, see also <type scope="com::sun::star::frame">CommandGroup</type>. 100 */ 101 void implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL, sal_uInt16 nId, 102 sal_Int16 nGroup = ::com::sun::star::frame::CommandGroup::INTERNAL ); 103 104 mutable SupportedFeatures m_aSupportedFeatures; 105 106 sal_uInt16 m_nFeatureId; 107 108 private: 109 void fillSupportedFeatures(); 110 }; 111 112 } // namespace chart 113 114 // CHART2_FEATURECOMMANDDISPATCHBASE_HXX 115 #endif 116