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 23 24 #ifndef __FRAMEWORK_HELPER_TITLEBARUPDATE_HXX_ 25 #define __FRAMEWORK_HELPER_TITLEBARUPDATE_HXX_ 26 27 //_________________________________________________________________________________________________________________ 28 // my own includes 29 //_________________________________________________________________________________________________________________ 30 31 #ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_ 32 #include <threadhelp/threadhelpbase.hxx> 33 #endif 34 35 #ifndef __FRAMEWORK_MACROS_DEBUG_HXX_ 36 #include <macros/debug.hxx> 37 #endif 38 39 #ifndef __FRAMEWORK_MACROS_XINTERFACE_HXX_ 40 #include <macros/xinterface.hxx> 41 #endif 42 43 #ifndef __FRAMEWORK_MACROS_XTYPEPROVIDER_HXX_ 44 #include <macros/xtypeprovider.hxx> 45 #endif 46 47 #ifndef __FRAMEWORK_GENERAL_H_ 48 #include <general.h> 49 #endif 50 51 //_________________________________________________________________________________________________________________ 52 // interface includes 53 //_________________________________________________________________________________________________________________ 54 55 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ 56 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 57 #endif 58 59 #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ 60 #include <com/sun/star/lang/XInitialization.hpp> 61 #endif 62 63 #ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ 64 #include <com/sun/star/frame/XFrame.hpp> 65 #endif 66 67 #ifndef _COM_SUN_STAR_FRAME_XTITLE_HPP_ 68 #include <com/sun/star/frame/XTitle.hpp> 69 #endif 70 71 #ifndef _COM_SUN_STAR_FRAME_XFRAMEACTIONLISTENER_HPP_ 72 #include <com/sun/star/frame/XFrameActionListener.hpp> 73 #endif 74 75 #ifndef _COM_SUN_STAR_FRAME_XTITLECHANGELISTENER_HPP_ 76 #include <com/sun/star/frame/XTitleChangeListener.hpp> 77 #endif 78 79 #ifndef _COM_SUN_STAR_LANG_XEVENTLISTENER_HPP_ 80 #include <com/sun/star/lang/XEventListener.hpp> 81 #endif 82 83 //_________________________________________________________________________________________________________________ 84 // other includes 85 //_________________________________________________________________________________________________________________ 86 87 #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX 88 #include <unotools/moduleoptions.hxx> 89 #endif 90 91 #ifndef _CPPUHELPER_WEAK_HXX_ 92 #include <cppuhelper/weak.hxx> 93 #endif 94 95 #ifndef _RTL_USTRBUF_HXX_ 96 #include <rtl/ustrbuf.hxx> 97 #endif 98 99 //_________________________________________________________________________________________________________________ 100 // const 101 //_________________________________________________________________________________________________________________ 102 103 //_________________________________________________________________________________________________________________ 104 // namespace 105 //_________________________________________________________________________________________________________________ 106 107 namespace framework{ 108 109 //_________________________________________________________________________________________________________________ 110 // declarations 111 //_________________________________________________________________________________________________________________ 112 113 /*-************************************************************************************************************//** 114 @short helps our frame on setting title/icon on the titlebar (including updates) 115 116 @devstatus draft 117 @threadsafe yes 118 *//*-*************************************************************************************************************/ 119 class TitleBarUpdate : // interfaces 120 public css::lang::XTypeProvider 121 , public css::lang::XInitialization 122 , public css::frame::XTitleChangeListener // => XEventListener 123 , public css::frame::XFrameActionListener // => XEventListener 124 // baseclasses (order necessary for right initialization!) 125 , private ThreadHelpBase 126 , public ::cppu::OWeakObject 127 { 128 //________________________________ 129 // structs, types 130 131 private: 132 133 struct TModuleInfo 134 { 135 /// internal id of this module 136 ::rtl::OUString sID; 137 /// localized name for this module 138 ::rtl::OUString sUIName; 139 /// configured icon for this module 140 ::sal_Int32 nIcon; 141 }; 142 143 //________________________________ 144 // member 145 146 private: 147 148 /// may we need an uno service manager to create own services 149 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 150 151 /// reference to the frame which was created by the office himself 152 css::uno::WeakReference< css::frame::XFrame > m_xFrame; 153 154 //________________________________ 155 // interface 156 157 public: 158 159 //____________________________ 160 // ctor/dtor 161 TitleBarUpdate(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR); 162 virtual ~TitleBarUpdate( ); 163 164 //____________________________ 165 // XInterface, XTypeProvider 166 FWK_DECLARE_XINTERFACE 167 FWK_DECLARE_XTYPEPROVIDER 168 169 //____________________________ 170 // XInitialization 171 virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments); 172 173 //____________________________ 174 // XFrameActionListener 175 virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent); 176 177 //____________________________ 178 // XTitleChangeListener 179 virtual void SAL_CALL titleChanged(const css::frame::TitleChangedEvent& aEvent); 180 181 //____________________________ 182 // XEventListener 183 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent); 184 185 //________________________________ 186 // helper 187 188 private: 189 190 //____________________________ 191 /** @short identify the application module, which is used behind the component 192 of our frame. 193 194 @param xFrame 195 contains the component, which must be identified. 196 197 @param rInfo 198 describe the module in its details. 199 Is set only if return value is true. 200 201 @return [sal_Bool] 202 sal_True in casee module could be identified and all needed values could be read. 203 sal_False otherwise. 204 */ 205 ::sal_Bool implst_getModuleInfo(const css::uno::Reference< css::frame::XFrame >& xFrame, 206 TModuleInfo& rInfo ); 207 208 //____________________________ 209 /** @short set a new icon and title on the title bar of our connected frame window. 210 211 @descr It does not check if an update is really needed. That has to be done outside. 212 It retrieves all needed informations and update the title bar - nothing less - 213 nothing more. 214 */ 215 void impl_forceUpdate(); 216 217 //____________________________ 218 /** @short identify the current component (inside the connected frame) 219 and set the right module icon on the title bar. 220 221 @param xFrame 222 the frame which contains the component and where the icon must be set 223 on the window title bar. 224 */ 225 void impl_updateIcon(const css::uno::Reference< css::frame::XFrame >& xFrame); 226 227 //____________________________ 228 /** @short gets the current title from the frame and set it on the window. 229 230 @param xFrame 231 the frame which contains the component and where the title must be set 232 on the window title bar. 233 */ 234 void impl_updateTitle(const css::uno::Reference< css::frame::XFrame >& xFrame); 235 236 }; // class TitleBarUpdate 237 238 } // namespace framework 239 240 #endif // #ifndef __FRAMEWORK_HELPER_TITLEBARUPDATE_HXX_ 241