1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <uielement/statusbar.hxx>
24 #include <com/sun/star/ui/UIElementType.hpp>
26 #include <toolkit/helper/vclunohelper.hxx>
28 #include <tools/solar.h>
30 #include <vcl/svapp.hxx>
31 #include <vcl/wintypes.hxx>
33 using namespace com::sun::star::uno
;
34 using namespace com::sun::star::frame
;
35 using namespace com::sun::star::lang
;
36 using namespace com::sun::star::container
;
37 using namespace com::sun::star::awt
;
38 using namespace ::com::sun::star::ui
;
43 StatusBarWrapper::StatusBarWrapper(
44 css::uno::Reference
< css::uno::XComponentContext
> xContext
46 : UIConfigElementWrapperBase( UIElementType::STATUSBAR
),
47 m_xContext(std::move( xContext
))
51 StatusBarWrapper::~StatusBarWrapper()
55 void SAL_CALL
StatusBarWrapper::dispose()
57 Reference
< XComponent
> xThis(this);
59 css::lang::EventObject
aEvent( xThis
);
60 m_aListenerContainer
.disposeAndClear( aEvent
);
66 if ( m_xStatusBarManager
.is() )
67 m_xStatusBarManager
->dispose();
68 m_xStatusBarManager
.clear();
69 m_xConfigSource
.clear();
70 m_xConfigData
.clear();
78 void SAL_CALL
StatusBarWrapper::initialize( const Sequence
< Any
>& aArguments
)
83 throw DisposedException();
88 UIConfigElementWrapperBase::initialize( aArguments
);
90 Reference
< XFrame
> xFrame( m_xWeakFrame
);
91 if ( !(xFrame
.is() && m_xConfigSource
.is()) )
94 // Create VCL based toolbar which will be filled with settings data
95 StatusBar
* pStatusBar( nullptr );
96 rtl::Reference
<StatusBarManager
> pStatusBarManager
;
98 SolarMutexGuard aSolarMutexGuard
;
99 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow( xFrame
->getContainerWindow() );
102 WinBits nStyles
= WinBits( WB_LEFT
| WB_3DLOOK
);
104 pStatusBar
= VclPtr
<FrameworkStatusBar
>::Create( pWindow
, nStyles
);
105 pStatusBarManager
= new StatusBarManager( m_xContext
, xFrame
, pStatusBar
);
106 static_cast<FrameworkStatusBar
*>(pStatusBar
)->SetStatusBarManager( pStatusBarManager
.get() );
107 m_xStatusBarManager
= pStatusBarManager
;
113 m_xConfigData
= m_xConfigSource
->getSettings( m_aResourceURL
, false );
114 if ( m_xConfigData
.is() && pStatusBar
&& pStatusBarManager
)
116 // Fill statusbar with container contents
117 pStatusBarManager
->FillStatusBar( m_xConfigData
);
120 catch ( const NoSuchElementException
& )
125 // XUIElementSettings
126 void SAL_CALL
StatusBarWrapper::updateSettings()
131 throw DisposedException();
133 if ( !(m_bPersistent
&&
134 m_xConfigSource
.is() &&
135 m_xStatusBarManager
.is()) )
140 m_xConfigData
= m_xConfigSource
->getSettings( m_aResourceURL
, false );
141 if ( m_xConfigData
.is() )
142 m_xStatusBarManager
->FillStatusBar( m_xConfigData
);
144 catch ( const NoSuchElementException
& )
149 Reference
< XInterface
> SAL_CALL
StatusBarWrapper::getRealInterface()
153 if ( m_xStatusBarManager
)
155 vcl::Window
* pWindow
= m_xStatusBarManager
->GetStatusBar();
157 return Reference
< XInterface
>( VCLUnoHelper::GetInterface( pWindow
), UNO_QUERY
);
160 return Reference
< XInterface
>();
163 } // namespace framework
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */