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