1*6d739b60SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*6d739b60SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*6d739b60SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*6d739b60SAndrew Rist  * distributed with this work for additional information
6*6d739b60SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*6d739b60SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*6d739b60SAndrew Rist  * "License"); you may not use this file except in compliance
9*6d739b60SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*6d739b60SAndrew Rist  *
11*6d739b60SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*6d739b60SAndrew Rist  *
13*6d739b60SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*6d739b60SAndrew Rist  * software distributed under the License is distributed on an
15*6d739b60SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*6d739b60SAndrew Rist  * KIND, either express or implied.  See the License for the
17*6d739b60SAndrew Rist  * specific language governing permissions and limitations
18*6d739b60SAndrew Rist  * under the License.
19*6d739b60SAndrew Rist  *
20*6d739b60SAndrew Rist  *************************************************************/
21*6d739b60SAndrew Rist 
22*6d739b60SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_framework.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef __FRAMEWORK_HELPER_TITLEBARUPDATE_HXX_
28cdf0e10cSrcweir #include <helper/titlebarupdate.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32cdf0e10cSrcweir //	my own includes
33cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #ifndef __FRAMEWORK_PATTERN_WINDOW_HXX_
36cdf0e10cSrcweir #include <pattern/window.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #ifndef __FRAMEWORK_THREADHELP_WRITEGUARD_HXX_
40cdf0e10cSrcweir #include <threadhelp/writeguard.hxx>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #ifndef __FRAMEWORK_THREADHELP_READGUARD_HXX_
44cdf0e10cSrcweir #include <threadhelp/readguard.hxx>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #ifndef __FRAMEWORK_MACROS_GENERIC_HXX_
48cdf0e10cSrcweir #include <macros/generic.hxx>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #ifndef __FRAMEWORK_SERVICES_H_
52cdf0e10cSrcweir #include <services.h>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #ifndef __FRAMEWORK_PROPETIES_H_
56cdf0e10cSrcweir #include <properties.h>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir 
59cdf0e10cSrcweir //_________________________________________________________________________________________________________________
60cdf0e10cSrcweir //	interface includes
61cdf0e10cSrcweir //_________________________________________________________________________________________________________________
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
64cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir 
67cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICXEINFO_HPP_
68cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
69cdf0e10cSrcweir #endif
70cdf0e10cSrcweir 
71cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_
72cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir 
75cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XMODULEMANAGER_HPP_
76cdf0e10cSrcweir #include <com/sun/star/frame/XModuleManager.hpp>
77cdf0e10cSrcweir #endif
78cdf0e10cSrcweir 
79cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
80cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
81cdf0e10cSrcweir #endif
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
84cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
85cdf0e10cSrcweir #endif
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XMATERIALHOLDER_HPP_
88cdf0e10cSrcweir #include <com/sun/star/beans/XMaterialHolder.hpp>
89cdf0e10cSrcweir #endif
90cdf0e10cSrcweir 
91cdf0e10cSrcweir #ifndef _COM_SUN_STAR_FRAME_XTITLECHANGEBROADCASTER_HPP_
92cdf0e10cSrcweir #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp>
93cdf0e10cSrcweir #endif
94cdf0e10cSrcweir 
95cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
96cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
97cdf0e10cSrcweir #endif
98cdf0e10cSrcweir 
99cdf0e10cSrcweir //_________________________________________________________________________________________________________________
100cdf0e10cSrcweir //	other includes
101cdf0e10cSrcweir //_________________________________________________________________________________________________________________
102cdf0e10cSrcweir 
103cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
104cdf0e10cSrcweir #include <unotools/configmgr.hxx>
105cdf0e10cSrcweir #include <unotools/bootstrap.hxx>
106cdf0e10cSrcweir #include <vcl/window.hxx>
107cdf0e10cSrcweir #include <vcl/syswin.hxx>
108cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
109cdf0e10cSrcweir #include <vcl/svapp.hxx>
110cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
111cdf0e10cSrcweir #include <tools/diagnose_ex.h>
112cdf0e10cSrcweir 
113cdf0e10cSrcweir //_________________________________________________________________________________________________________________
114cdf0e10cSrcweir //	namespace
115cdf0e10cSrcweir 
116cdf0e10cSrcweir namespace framework{
117cdf0e10cSrcweir 
118cdf0e10cSrcweir //_________________________________________________________________________________________________________________
119cdf0e10cSrcweir //	const
120cdf0e10cSrcweir 
121cdf0e10cSrcweir static const ::sal_Int32 INVALID_ICON_ID = -1;
122cdf0e10cSrcweir static const ::sal_Int32 DEFAULT_ICON_ID =  0;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir //_________________________________________________________________________________________________________________
125cdf0e10cSrcweir //	definitions
126cdf0e10cSrcweir 
127cdf0e10cSrcweir //*****************************************************************************************************************
128cdf0e10cSrcweir //  XInterface, XTypeProvider
129cdf0e10cSrcweir 
DEFINE_XINTERFACE_5(TitleBarUpdate,OWeakObject,DIRECT_INTERFACE (css::lang::XTypeProvider),DIRECT_INTERFACE (css::lang::XInitialization),DIRECT_INTERFACE (css::frame::XFrameActionListener),DIRECT_INTERFACE (css::frame::XTitleChangeListener),DERIVED_INTERFACE (css::lang::XEventListener,css::frame::XFrameActionListener))130cdf0e10cSrcweir DEFINE_XINTERFACE_5(TitleBarUpdate                                                              ,
131cdf0e10cSrcweir                     OWeakObject                                                                 ,
132cdf0e10cSrcweir                     DIRECT_INTERFACE (css::lang::XTypeProvider                                  ),
133cdf0e10cSrcweir                     DIRECT_INTERFACE (css::lang::XInitialization                                ),
134cdf0e10cSrcweir                     DIRECT_INTERFACE (css::frame::XFrameActionListener                          ),
135cdf0e10cSrcweir                     DIRECT_INTERFACE (css::frame::XTitleChangeListener                          ),
136cdf0e10cSrcweir                     DERIVED_INTERFACE(css::lang::XEventListener,css::frame::XFrameActionListener))
137cdf0e10cSrcweir 
138cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_5(TitleBarUpdate                  ,
139cdf0e10cSrcweir                        css::lang::XTypeProvider        ,
140cdf0e10cSrcweir                        css::lang::XInitialization      ,
141cdf0e10cSrcweir                        css::frame::XFrameActionListener,
142cdf0e10cSrcweir                        css::frame::XTitleChangeListener,
143cdf0e10cSrcweir                        css::lang::XEventListener       )
144cdf0e10cSrcweir 
145cdf0e10cSrcweir //*****************************************************************************************************************
146cdf0e10cSrcweir TitleBarUpdate::TitleBarUpdate(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
147cdf0e10cSrcweir     : ThreadHelpBase          (&Application::GetSolarMutex())
148cdf0e10cSrcweir     , m_xSMGR                 (xSMGR                        )
149cdf0e10cSrcweir     , m_xFrame                (                             )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir //*****************************************************************************************************************
~TitleBarUpdate()154cdf0e10cSrcweir TitleBarUpdate::~TitleBarUpdate()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir //*****************************************************************************************************************
initialize(const css::uno::Sequence<css::uno::Any> & lArguments)159cdf0e10cSrcweir void SAL_CALL TitleBarUpdate::initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
160cdf0e10cSrcweir     throw(css::uno::Exception       ,
161cdf0e10cSrcweir           css::uno::RuntimeException)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir     // check arguments
164cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame > xFrame;
165cdf0e10cSrcweir     if (lArguments.getLength() < 1)
166cdf0e10cSrcweir         throw css::lang::IllegalArgumentException(
167cdf0e10cSrcweir                 DECLARE_ASCII("Empty argument list!"),
168cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this),
169cdf0e10cSrcweir                 1);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     lArguments[0] >>= xFrame;
172cdf0e10cSrcweir     if (!xFrame.is())
173cdf0e10cSrcweir         throw css::lang::IllegalArgumentException(
174cdf0e10cSrcweir                 DECLARE_ASCII("No valid frame specified!"),
175cdf0e10cSrcweir                 static_cast< ::cppu::OWeakObject* >(this),
176cdf0e10cSrcweir                 1);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     // SYNCHRONIZED ->
179cdf0e10cSrcweir     WriteGuard aWriteLock(m_aLock);
180cdf0e10cSrcweir     // hold the frame as weak reference(!) so it can die everytimes :-)
181cdf0e10cSrcweir     m_xFrame = xFrame;
182cdf0e10cSrcweir     aWriteLock.unlock();
183cdf0e10cSrcweir     // <- SYNCHRONIZED
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     // start listening
186cdf0e10cSrcweir     xFrame->addFrameActionListener(this);
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(xFrame, css::uno::UNO_QUERY);
189cdf0e10cSrcweir     if (xBroadcaster.is ())
190cdf0e10cSrcweir         xBroadcaster->addTitleChangeListener (this);
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir //*****************************************************************************************************************
frameAction(const css::frame::FrameActionEvent & aEvent)194cdf0e10cSrcweir void SAL_CALL TitleBarUpdate::frameAction(const css::frame::FrameActionEvent& aEvent)
195cdf0e10cSrcweir     throw(css::uno::RuntimeException)
196cdf0e10cSrcweir {
197cdf0e10cSrcweir     // we are interested on events only, which must trigger a title bar update
198cdf0e10cSrcweir     // because component was changed.
199cdf0e10cSrcweir     if (
200cdf0e10cSrcweir         (aEvent.Action == css::frame::FrameAction_COMPONENT_ATTACHED  ) ||
201cdf0e10cSrcweir         (aEvent.Action == css::frame::FrameAction_COMPONENT_REATTACHED) ||
202cdf0e10cSrcweir         (aEvent.Action == css::frame::FrameAction_COMPONENT_DETACHING )
203cdf0e10cSrcweir        )
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir         impl_forceUpdate ();
206cdf0e10cSrcweir     }
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir //*****************************************************************************************************************
titleChanged(const css::frame::TitleChangedEvent &)210cdf0e10cSrcweir void SAL_CALL TitleBarUpdate::titleChanged(const css::frame::TitleChangedEvent& /* aEvent */)
211cdf0e10cSrcweir     throw (css::uno::RuntimeException)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir     impl_forceUpdate ();
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir //*****************************************************************************************************************
disposing(const css::lang::EventObject &)217cdf0e10cSrcweir void SAL_CALL TitleBarUpdate::disposing(const css::lang::EventObject&)
218cdf0e10cSrcweir     throw(css::uno::RuntimeException)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir     // nothing todo here - because we hold the frame as weak reference only
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir //*****************************************************************************************************************
implst_getModuleInfo(const css::uno::Reference<css::frame::XFrame> & xFrame,TModuleInfo & rInfo)224cdf0e10cSrcweir ::sal_Bool TitleBarUpdate::implst_getModuleInfo(const css::uno::Reference< css::frame::XFrame >& xFrame,
225cdf0e10cSrcweir                                                       TModuleInfo&                               rInfo )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir     if ( ! xFrame.is ())
228cdf0e10cSrcweir         return sal_False;
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     // SYNCHRONIZED ->
231cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
232cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
233cdf0e10cSrcweir     aReadLock.unlock();
234cdf0e10cSrcweir     // <- SYNCHRONIZED
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     try
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         css::uno::Reference< css::frame::XModuleManager > xModuleManager(
239cdf0e10cSrcweir             xSMGR->createInstance(SERVICENAME_MODULEMANAGER),
240cdf0e10cSrcweir             css::uno::UNO_QUERY_THROW);
241cdf0e10cSrcweir 
242cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > xConfig(
243cdf0e10cSrcweir             xModuleManager,
244cdf0e10cSrcweir             css::uno::UNO_QUERY_THROW);
245cdf0e10cSrcweir 
246cdf0e10cSrcweir                                         rInfo.sID = xModuleManager->identify(xFrame);
247cdf0e10cSrcweir         ::comphelper::SequenceAsHashMap lProps    = xConfig->getByName (rInfo.sID);
248cdf0e10cSrcweir 
249cdf0e10cSrcweir         rInfo.sUIName = lProps.getUnpackedValueOrDefault (OFFICEFACTORY_PROPNAME_UINAME, ::rtl::OUString());
250cdf0e10cSrcweir         rInfo.nIcon   = lProps.getUnpackedValueOrDefault (OFFICEFACTORY_PROPNAME_ICON  , INVALID_ICON_ID  );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 		// Note: If we could retrieve a module id ... everything is OK.
253cdf0e10cSrcweir 		// UIName and Icon ID are optional values !
254cdf0e10cSrcweir         ::sal_Bool bSuccess = (rInfo.sID.getLength () > 0);
255cdf0e10cSrcweir         return bSuccess;
256cdf0e10cSrcweir     }
257cdf0e10cSrcweir     catch(const css::uno::Exception&)
258cdf0e10cSrcweir         {}
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     return sal_False;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir //*****************************************************************************************************************
impl_forceUpdate()264cdf0e10cSrcweir void TitleBarUpdate::impl_forceUpdate()
265cdf0e10cSrcweir {
266cdf0e10cSrcweir     // SYNCHRONIZED ->
267cdf0e10cSrcweir     ReadGuard aReadLock(m_aLock);
268cdf0e10cSrcweir     css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR ;
269cdf0e10cSrcweir     css::uno::Reference< css::frame::XFrame >              xFrame(m_xFrame.get(), css::uno::UNO_QUERY);
270cdf0e10cSrcweir     aReadLock.unlock();
271cdf0e10cSrcweir     // <- SYNCHRONIZED
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     // frame already gone ? We hold it weak only ...
274cdf0e10cSrcweir     if ( ! xFrame.is())
275cdf0e10cSrcweir         return;
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     // no window -> no chance to set/update title and icon
278cdf0e10cSrcweir     css::uno::Reference< css::awt::XWindow > xWindow = xFrame->getContainerWindow();
279cdf0e10cSrcweir     if ( ! xWindow.is())
280cdf0e10cSrcweir         return;
281cdf0e10cSrcweir 
282cdf0e10cSrcweir     impl_updateIcon  (xFrame);
283cdf0e10cSrcweir     impl_updateTitle (xFrame);
284cdf0e10cSrcweir }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir //*****************************************************************************************************************
impl_updateIcon(const css::uno::Reference<css::frame::XFrame> & xFrame)287cdf0e10cSrcweir void TitleBarUpdate::impl_updateIcon(const css::uno::Reference< css::frame::XFrame >& xFrame)
288cdf0e10cSrcweir {
289cdf0e10cSrcweir     css::uno::Reference< css::frame::XController > xController = xFrame->getController      ();
290cdf0e10cSrcweir     css::uno::Reference< css::awt::XWindow >       xWindow     = xFrame->getContainerWindow ();
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     if (
293cdf0e10cSrcweir         ( ! xController.is() ) ||
294cdf0e10cSrcweir         ( ! xWindow.is()     )
295cdf0e10cSrcweir        )
296cdf0e10cSrcweir         return;
297cdf0e10cSrcweir 
298cdf0e10cSrcweir     // a) set default value to an invalid one. So we can start further searches for right icon id, if
299cdf0e10cSrcweir     //    first steps failed!
300cdf0e10cSrcweir     sal_Int32 nIcon = INVALID_ICON_ID;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir     // b) try to find information on controller property set directly
303cdf0e10cSrcweir     //    Don't forget to catch possible exceptions - because these property is an optional one!
304cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > xSet( xController, css::uno::UNO_QUERY );
305cdf0e10cSrcweir     if ( xSet.is() )
306cdf0e10cSrcweir     {
307cdf0e10cSrcweir         try
308cdf0e10cSrcweir         {
309cdf0e10cSrcweir             css::uno::Reference< css::beans::XPropertySetInfo > const xPSI( xSet->getPropertySetInfo(), css::uno::UNO_SET_THROW );
310cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( CONTROLLER_PROPNAME_ICONID ) )
311cdf0e10cSrcweir                 xSet->getPropertyValue( CONTROLLER_PROPNAME_ICONID ) >>= nIcon;
312cdf0e10cSrcweir         }
313cdf0e10cSrcweir         catch(const css::uno::Exception&)
314cdf0e10cSrcweir         {
315cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
316cdf0e10cSrcweir         }
317cdf0e10cSrcweir     }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     // c) if b) failed ... identify the used module and retrieve set icon from module config.
320cdf0e10cSrcweir     //    Tirck :-) Module was already specified outside and aInfo contains all needed informations.
321cdf0e10cSrcweir     if ( nIcon == INVALID_ICON_ID )
322cdf0e10cSrcweir 	{
323cdf0e10cSrcweir 		TModuleInfo aInfo;
324cdf0e10cSrcweir 		if (implst_getModuleInfo(xFrame, aInfo))
325cdf0e10cSrcweir 			nIcon = aInfo.nIcon;
326cdf0e10cSrcweir 	}
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     // d) if all steps failed - use fallback :-)
329cdf0e10cSrcweir     //    ... means using the global staroffice icon
330cdf0e10cSrcweir     if( nIcon == INVALID_ICON_ID )
331cdf0e10cSrcweir         nIcon = DEFAULT_ICON_ID;
332cdf0e10cSrcweir 
333cdf0e10cSrcweir     // e) set icon on container window now
334cdf0e10cSrcweir     //    Don't forget SolarMutex! We use vcl directly :-(
335cdf0e10cSrcweir     //    Check window pointer for right WorkWindow class too!!!
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     // VCL SYNCHRONIZED ->
338cdf0e10cSrcweir     ::vos::OClearableGuard aSolarLock( Application::GetSolarMutex() );
339cdf0e10cSrcweir 
340cdf0e10cSrcweir     Window* pWindow = (VCLUnoHelper::GetWindow( xWindow ));
341cdf0e10cSrcweir     if (
342cdf0e10cSrcweir         ( pWindow                                 ) &&
343cdf0e10cSrcweir         ( pWindow->GetType() == WINDOW_WORKWINDOW )
344cdf0e10cSrcweir        )
345cdf0e10cSrcweir     {
346cdf0e10cSrcweir         WorkWindow* pWorkWindow = (WorkWindow*)pWindow;
347cdf0e10cSrcweir         pWorkWindow->SetIcon( (sal_uInt16)nIcon );
348cdf0e10cSrcweir 
349cdf0e10cSrcweir         css::uno::Reference< css::frame::XModel > xModel = xController->getModel();
350cdf0e10cSrcweir         rtl::OUString aURL;
351cdf0e10cSrcweir         if( xModel.is() )
352cdf0e10cSrcweir             aURL = xModel->getURL();
353cdf0e10cSrcweir         pWorkWindow->SetRepresentedURL( aURL );
354cdf0e10cSrcweir     }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir     aSolarLock.clear();
357cdf0e10cSrcweir     // <- VCL SYNCHRONIZED
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir //*****************************************************************************************************************
impl_updateTitle(const css::uno::Reference<css::frame::XFrame> & xFrame)361cdf0e10cSrcweir void TitleBarUpdate::impl_updateTitle(const css::uno::Reference< css::frame::XFrame >& xFrame)
362cdf0e10cSrcweir {
363cdf0e10cSrcweir 	// no window ... no chance to set any title -> return
364cdf0e10cSrcweir     css::uno::Reference< css::awt::XWindow > xWindow = xFrame->getContainerWindow ();
365cdf0e10cSrcweir     if ( ! xWindow.is() )
366cdf0e10cSrcweir         return;
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	css::uno::Reference< css::frame::XTitle > xTitle(xFrame, css::uno::UNO_QUERY);
369cdf0e10cSrcweir 	if ( ! xTitle.is() )
370cdf0e10cSrcweir 		return;
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	const ::rtl::OUString sTitle = xTitle->getTitle ();
373cdf0e10cSrcweir 
374cdf0e10cSrcweir     // VCL SYNCHRONIZED ->
375cdf0e10cSrcweir     ::vos::OClearableGuard aSolarLock( Application::GetSolarMutex() );
376cdf0e10cSrcweir 
377cdf0e10cSrcweir     Window* pWindow = (VCLUnoHelper::GetWindow( xWindow ));
378cdf0e10cSrcweir     if (
379cdf0e10cSrcweir         ( pWindow                                 ) &&
380cdf0e10cSrcweir         ( pWindow->GetType() == WINDOW_WORKWINDOW )
381cdf0e10cSrcweir        )
382cdf0e10cSrcweir     {
383cdf0e10cSrcweir         WorkWindow* pWorkWindow = (WorkWindow*)pWindow;
384cdf0e10cSrcweir         pWorkWindow->SetText( sTitle );
385cdf0e10cSrcweir     }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     aSolarLock.clear();
388cdf0e10cSrcweir     // <- VCL SYNCHRONIZED
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir } // namespace framework
392