1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: statusbarwrapper.cxx,v $
10 * $Revision: 1.8.34.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 #include <uielement/statusbarwrapper.hxx>
36 //_________________________________________________________________________________________________________________
38 //_________________________________________________________________________________________________________________
39 #include <threadhelp/resetableguard.hxx>
40 #include <helper/actiontriggerhelper.hxx>
41 #include <uielement/constitemcontainer.hxx>
42 #include <uielement/rootitemcontainer.hxx>
43 #include <uielement/statusbar.hxx>
46 //_________________________________________________________________________________________________________________
48 //_________________________________________________________________________________________________________________
49 #include <com/sun/star/lang/XServiceInfo.hpp>
50 #include <com/sun/star/beans/XPropertySet.hpp>
51 #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
52 #include <com/sun/star/awt/XMenuBar.hpp>
53 #include <com/sun/star/container/XIndexContainer.hpp>
54 #include <com/sun/star/container/XNameAccess.hpp>
55 #include <com/sun/star/ui/UIElementType.hpp>
57 //_________________________________________________________________________________________________________________
59 //_________________________________________________________________________________________________________________
60 #include <comphelper/processfactory.hxx>
61 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
62 #include <toolkit/unohlp.hxx>
65 #include <tools/solar.h>
66 #include <vcl/svapp.hxx>
67 #include <rtl/logfile.hxx>
69 using namespace com::sun::star::uno
;
70 using namespace com::sun::star::beans
;
71 using namespace com::sun::star::frame
;
72 using namespace com::sun::star::lang
;
73 using namespace com::sun::star::container
;
74 using namespace com::sun::star::awt
;
75 using namespace ::com::sun::star::ui
;
80 StatusBarWrapper::StatusBarWrapper(
81 const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& xServiceManager
83 : UIConfigElementWrapperBase( UIElementType::STATUSBAR
,xServiceManager
)
87 StatusBarWrapper::~StatusBarWrapper()
91 void SAL_CALL
StatusBarWrapper::dispose() throw (::com::sun::star::uno::RuntimeException
)
93 Reference
< XComponent
> xThis( static_cast< OWeakObject
* >(this), UNO_QUERY
);
95 com::sun::star::lang::EventObject
aEvent( xThis
);
96 m_aListenerContainer
.disposeAndClear( aEvent
);
98 ResetableGuard
aLock( m_aLock
);
101 if ( m_xStatusBarManager
.is() )
102 m_xStatusBarManager
->dispose();
103 m_xStatusBarManager
.clear();
104 m_xConfigSource
.clear();
105 m_xConfigData
.clear();
106 m_xServiceFactory
.clear();
108 m_bDisposed
= sal_True
;
111 throw DisposedException();
115 void SAL_CALL
StatusBarWrapper::initialize( const Sequence
< Any
>& aArguments
) throw ( Exception
, RuntimeException
)
117 ResetableGuard
aLock( m_aLock
);
120 throw DisposedException();
122 if ( !m_bInitialized
)
124 UIConfigElementWrapperBase::initialize( aArguments
);
126 Reference
< XFrame
> xFrame( m_xWeakFrame
);
127 if ( xFrame
.is() && m_xConfigSource
.is() )
129 // Create VCL based toolbar which will be filled with settings data
130 StatusBar
* pStatusBar( 0 );
131 StatusBarManager
* pStatusBarManager( 0 );
133 vos::OGuard
aSolarMutexGuard( Application::GetSolarMutex() );
134 Window
* pWindow
= VCLUnoHelper::GetWindow( xFrame
->getContainerWindow() );
137 ULONG nStyles
= WinBits( WB_LEFT
| WB_3DLOOK
);
139 pStatusBar
= new FrameworkStatusBar( pWindow
, nStyles
);
140 pStatusBarManager
= new StatusBarManager( m_xServiceFactory
, xFrame
, m_aResourceURL
, pStatusBar
);
141 ((FrameworkStatusBar
*)pStatusBar
)->SetStatusBarManager( pStatusBarManager
);
142 m_xStatusBarManager
= Reference
< XComponent
>( static_cast< OWeakObject
*>( pStatusBarManager
), UNO_QUERY
);
143 pStatusBar
->SetUniqueId( HID_STATUSBAR
);
149 m_xConfigData
= m_xConfigSource
->getSettings( m_aResourceURL
, sal_False
);
150 if ( m_xConfigData
.is() && pStatusBar
&& pStatusBarManager
)
152 // Fill statusbar with container contents
153 pStatusBarManager
->FillStatusBar( m_xConfigData
);
156 catch ( NoSuchElementException
& )
163 // XUIElementSettings
164 void SAL_CALL
StatusBarWrapper::updateSettings() throw ( RuntimeException
)
166 ResetableGuard
aLock( m_aLock
);
169 throw DisposedException();
171 if ( m_bPersistent
&&
172 m_xConfigSource
.is() &&
173 m_xStatusBarManager
.is() )
177 StatusBarManager
* pStatusBarManager
= static_cast< StatusBarManager
*>( m_xStatusBarManager
.get() );
179 m_xConfigData
= m_xConfigSource
->getSettings( m_aResourceURL
, sal_False
);
180 if ( m_xConfigData
.is() )
181 pStatusBarManager
->FillStatusBar( m_xConfigData
);
183 catch ( NoSuchElementException
& )
189 Reference
< XInterface
> SAL_CALL
StatusBarWrapper::getRealInterface() throw ( RuntimeException
)
191 ResetableGuard
aLock( m_aLock
);
193 if ( m_xStatusBarManager
.is() )
195 StatusBarManager
* pStatusBarManager
= static_cast< StatusBarManager
*>( m_xStatusBarManager
.get() );
196 if ( pStatusBarManager
)
198 Window
* pWindow
= (Window
*)pStatusBarManager
->GetStatusBar();
200 return Reference
< XInterface
>( VCLUnoHelper::GetInterface( pWindow
), UNO_QUERY
);
204 return Reference
< XInterface
>();
207 } // namespace framework