1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 #ifndef SFX_SIDEBAR_CONTEXT_CHANGE_BROADCASTER_HXX 23 #define SFX_SIDEBAR_CONTEXT_CHANGE_BROADCASTER_HXX 24 25 #include <com/sun/star/frame/XFrame.hpp> 26 27 namespace css = ::com::sun::star; 28 namespace cssu = ::com::sun::star::uno; 29 30 namespace sfx2 { namespace sidebar { 31 32 33 /** This class is a helper for broadcasting context changes that are 34 tied to shells being activated or deactivated. 35 */ 36 class ContextChangeBroadcaster 37 { 38 public: 39 ContextChangeBroadcaster (void); 40 ~ContextChangeBroadcaster (void); 41 42 void Initialize (const ::rtl::OUString& rsContextName); 43 44 void Activate (const cssu::Reference<css::frame::XFrame>& rxFrame); 45 void Deactivate (const cssu::Reference<css::frame::XFrame>& rxFrame); 46 47 /** Enable or disable the broadcaster. 48 @param bIsEnabled 49 The new value of the "enabled" state. 50 @return 51 The old value of the "enabled" state is returned. 52 */ 53 bool SetBroadcasterEnabled (const bool bIsEnabled); 54 55 private: 56 rtl::OUString msContextName; 57 bool mbIsContextActive; 58 bool mbIsBroadcasterEnabled; 59 60 void BroadcastContextChange ( 61 const cssu::Reference<css::frame::XFrame>& rxFrame, 62 const ::rtl::OUString& rsModuleName, 63 const ::rtl::OUString& rsContextName); 64 ::rtl::OUString GetModuleName ( 65 const cssu::Reference<css::frame::XFrame>& rxFrame); 66 }; 67 68 69 } } // end of namespace ::sd::sidebar 70 71 #endif 72