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 neccessary 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             throw(css::uno::Exception       ,
173                   css::uno::RuntimeException);
174 
175         //____________________________
176         // XFrameActionListener
177         virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent)
178             throw(css::uno::RuntimeException);
179 
180         //____________________________
181         // XTitleChangeListener
182         virtual void SAL_CALL titleChanged(const css::frame::TitleChangedEvent& aEvent)
183             throw (css::uno::RuntimeException);
184 
185         //____________________________
186         // XEventListener
187         virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
188             throw(css::uno::RuntimeException);
189 
190     //________________________________
191     // helper
192 
193     private:
194 
195         //____________________________
196         /** @short  identify the application module, which  is used behind the component
197                     of our frame.
198 
199             @param  xFrame
200                     contains the component, wich must be identified.
201 
202             @param  rInfo
203                     describe the module in its details.
204                     Is set only if return value is true.
205 
206             @return [sal_Bool]
207                     sal_True in casee module could be identified and all needed values could be read.
208                     sal_False otherwise.
209          */
210         ::sal_Bool implst_getModuleInfo(const css::uno::Reference< css::frame::XFrame >& xFrame,
211                                               TModuleInfo&                               rInfo );
212 
213         //____________________________
214         /** @short  set a new icon and title on the title bar of our connected frame window.
215 
216             @descr  It does not check if an update is realy needed. That has to be done outside.
217                     It retrieves all needed informations and update the title bar - nothing less -
218                     nothing more.
219          */
220         void impl_forceUpdate();
221 
222         //____________________________
223         /** @short  identify the current component (inside the connected frame)
224                     and set the right module icon on the title bar.
225 
226             @param  xFrame
227                     the frame which contains the component and where the icon must be set
228                     on the window title bar.
229          */
230         void impl_updateIcon(const css::uno::Reference< css::frame::XFrame >& xFrame);
231 
232         //____________________________
233         /** @short  gets the current title from the frame and set it on the window.
234 
235             @param  xFrame
236                     the frame which contains the component and where the title must be set
237                     on the window title bar.
238          */
239         void impl_updateTitle(const css::uno::Reference< css::frame::XFrame >& xFrame);
240 
241 }; // class TitleBarUpdate
242 
243 } // namespace framework
244 
245 #endif // #ifndef __FRAMEWORK_HELPER_TITLEBARUPDATE_HXX_
246