fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / uielement / statusbarwrapper.cxx
blob2f1f74028a0c4100c82b6780be87b09d48a54767
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <uielement/statusbarwrapper.hxx>
22 #include <framework/actiontriggerhelper.hxx>
23 #include <uielement/constitemcontainer.hxx>
24 #include <uielement/rootitemcontainer.hxx>
25 #include <uielement/statusbar.hxx>
26 #include <helpid.hrc>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
31 #include <com/sun/star/awt/XMenuBar.hpp>
32 #include <com/sun/star/container/XIndexContainer.hpp>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 #include <com/sun/star/ui/UIElementType.hpp>
36 #include <comphelper/processfactory.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
39 #include <tools/solar.h>
40 #include <vcl/svapp.hxx>
42 using namespace com::sun::star::uno;
43 using namespace com::sun::star::beans;
44 using namespace com::sun::star::frame;
45 using namespace com::sun::star::lang;
46 using namespace com::sun::star::container;
47 using namespace com::sun::star::awt;
48 using namespace ::com::sun::star::ui;
50 namespace framework
53 StatusBarWrapper::StatusBarWrapper(
54 const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext
56 : UIConfigElementWrapperBase( UIElementType::STATUSBAR ),
57 m_xContext( rxContext )
61 StatusBarWrapper::~StatusBarWrapper()
65 void SAL_CALL StatusBarWrapper::dispose() throw (::com::sun::star::uno::RuntimeException, std::exception)
67 Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
69 com::sun::star::lang::EventObject aEvent( xThis );
70 m_aListenerContainer.disposeAndClear( aEvent );
72 SolarMutexGuard g;
73 if ( !m_bDisposed )
75 if ( m_xStatusBarManager.is() )
76 m_xStatusBarManager->dispose();
77 m_xStatusBarManager.clear();
78 m_xConfigSource.clear();
79 m_xConfigData.clear();
80 m_xContext.clear();
82 m_bDisposed = true;
84 else
85 throw DisposedException();
88 // XInitialization
89 void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException, std::exception )
91 SolarMutexGuard g;
93 if ( m_bDisposed )
94 throw DisposedException();
96 if ( !m_bInitialized )
98 UIConfigElementWrapperBase::initialize( aArguments );
100 Reference< XFrame > xFrame( m_xWeakFrame );
101 if ( xFrame.is() && m_xConfigSource.is() )
103 // Create VCL based toolbar which will be filled with settings data
104 StatusBar* pStatusBar( 0 );
105 StatusBarManager* pStatusBarManager( 0 );
107 SolarMutexGuard aSolarMutexGuard;
108 vcl::Window* pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
109 if ( pWindow )
111 sal_uLong nStyles = WinBits( WB_LEFT | WB_3DLOOK );
113 pStatusBar = VclPtr<FrameworkStatusBar>::Create( pWindow, nStyles );
114 pStatusBarManager = new StatusBarManager( m_xContext, xFrame, m_aResourceURL, pStatusBar );
115 static_cast<FrameworkStatusBar*>(pStatusBar)->SetStatusBarManager( pStatusBarManager );
116 m_xStatusBarManager = Reference< XComponent >( static_cast< OWeakObject *>( pStatusBarManager ), UNO_QUERY );
117 pStatusBar->SetUniqueId( HID_STATUSBAR );
123 m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False );
124 if ( m_xConfigData.is() && pStatusBar && pStatusBarManager )
126 // Fill statusbar with container contents
127 pStatusBarManager->FillStatusBar( m_xConfigData );
130 catch ( const NoSuchElementException& )
137 // XUIElementSettings
138 void SAL_CALL StatusBarWrapper::updateSettings() throw ( RuntimeException, std::exception )
140 SolarMutexGuard g;
142 if ( m_bDisposed )
143 throw DisposedException();
145 if ( m_bPersistent &&
146 m_xConfigSource.is() &&
147 m_xStatusBarManager.is() )
151 StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
153 m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, sal_False );
154 if ( m_xConfigData.is() )
155 pStatusBarManager->FillStatusBar( m_xConfigData );
157 catch ( const NoSuchElementException& )
163 Reference< XInterface > SAL_CALL StatusBarWrapper::getRealInterface() throw ( RuntimeException, std::exception )
165 SolarMutexGuard g;
167 if ( m_xStatusBarManager.is() )
169 StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
170 if ( pStatusBarManager )
172 vcl::Window* pWindow = (vcl::Window *)pStatusBarManager->GetStatusBar();
173 if ( pWindow )
174 return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
178 return Reference< XInterface >();
181 } // namespace framework
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */