LibreOffice Module framework (master) 1
statusbarwrapper.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21
23
24#include <com/sun/star/ui/UIElementType.hpp>
25
27
28#include <tools/solar.h>
29#include <utility>
30#include <vcl/svapp.hxx>
31
32using namespace com::sun::star::uno;
33using namespace com::sun::star::beans;
34using namespace com::sun::star::frame;
35using namespace com::sun::star::lang;
36using namespace com::sun::star::container;
37using namespace com::sun::star::awt;
38using namespace ::com::sun::star::ui;
39
40namespace framework
41{
42
44 css::uno::Reference< css::uno::XComponentContext > xContext
45 )
46 : UIConfigElementWrapperBase( UIElementType::STATUSBAR ),
47 m_xContext(std::move( xContext ))
48{
49}
50
52{
53}
54
56{
57 Reference< XComponent > xThis(this);
58
59 css::lang::EventObject aEvent( xThis );
61
63 if ( m_bDisposed )
64 return;
65
66 if ( m_xStatusBarManager.is() )
67 m_xStatusBarManager->dispose();
68 m_xStatusBarManager.clear();
69 m_xConfigSource.clear();
70 m_xConfigData.clear();
71 m_xContext.clear();
72
73 m_bDisposed = true;
74
75}
76
77// XInitialization
78void SAL_CALL StatusBarWrapper::initialize( const Sequence< Any >& aArguments )
79{
81
82 if ( m_bDisposed )
83 throw DisposedException();
84
85 if ( m_bInitialized )
86 return;
87
89
91 if ( !(xFrame.is() && m_xConfigSource.is()) )
92 return;
93
94 // Create VCL based toolbar which will be filled with settings data
95 StatusBar* pStatusBar( nullptr );
96 rtl::Reference<StatusBarManager> pStatusBarManager;
97 {
98 SolarMutexGuard aSolarMutexGuard;
99 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
100 if ( pWindow )
101 {
102 sal_uLong nStyles = WinBits( WB_LEFT | WB_3DLOOK );
103
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;
108 }
109 }
110
111 try
112 {
113 m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, false );
114 if ( m_xConfigData.is() && pStatusBar && pStatusBarManager )
115 {
116 // Fill statusbar with container contents
117 pStatusBarManager->FillStatusBar( m_xConfigData );
118 }
119 }
120 catch ( const NoSuchElementException& )
121 {
122 }
123}
124
125// XUIElementSettings
127{
129
130 if ( m_bDisposed )
131 throw DisposedException();
132
133 if ( !(m_bPersistent &&
134 m_xConfigSource.is() &&
135 m_xStatusBarManager.is()) )
136 return;
137
138 try
139 {
140 StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
141
142 m_xConfigData = m_xConfigSource->getSettings( m_aResourceURL, false );
143 if ( m_xConfigData.is() )
144 pStatusBarManager->FillStatusBar( m_xConfigData );
145 }
146 catch ( const NoSuchElementException& )
147 {
148 }
149}
150
152{
154
155 if ( m_xStatusBarManager.is() )
156 {
157 StatusBarManager* pStatusBarManager = static_cast< StatusBarManager *>( m_xStatusBarManager.get() );
158 if ( pStatusBarManager )
159 {
160 vcl::Window* pWindow = pStatusBarManager->GetStatusBar();
161 if ( pWindow )
162 return Reference< XInterface >( VCLUnoHelper::GetInterface( pWindow ), UNO_QUERY );
163 }
164 }
165
167}
168
169} // namespace framework
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
static VclPtr< reference_type > Create(Arg &&... arg)
void disposeAndClear(const css::lang::EventObject &rEvt)
void FillStatusBar(const css::uno::Reference< css::container::XIndexAccess > &rStatusBarData)
StatusBar * GetStatusBar() const
virtual ~StatusBarWrapper() override
StatusBarWrapper(css::uno::Reference< css::uno::XComponentContext > xContext)
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void SAL_CALL updateSettings() override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual void SAL_CALL dispose() override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override
css::uno::Reference< css::lang::XComponent > m_xStatusBarManager
css::uno::Reference< css::container::XIndexAccess > m_xConfigData
css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame
comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
css::uno::Reference< css::ui::XUIConfigurationManager > m_xConfigSource
css::uno::Reference< css::uno::XComponentContext > m_xContext
Sequence< PropertyValue > aArguments
sal_uIntPtr sal_uLong
Reference< XFrame > xFrame
sal_Int64 WinBits
WinBits const WB_3DLOOK
WinBits const WB_LEFT