Bug Summary

File:home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx
Warning:line 724, column 29
Use of memory after it is freed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name layoutmanager.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D FWK_DLLIMPLEMENTATION -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/framework/source/inc -I /home/maarten/src/libreoffice/core/framework/inc -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx

/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx

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
20#include <memory>
21#include <config_feature_desktop.h>
22
23#include <properties.h>
24#include <services/layoutmanager.hxx>
25#include "helpers.hxx"
26
27#include <framework/sfxhelperfunctions.hxx>
28#include <uielement/menubarwrapper.hxx>
29#include <uielement/progressbarwrapper.hxx>
30#include <uiconfiguration/globalsettings.hxx>
31#include <uiconfiguration/windowstateproperties.hxx>
32#include "toolbarlayoutmanager.hxx"
33
34#include <com/sun/star/beans/XPropertySet.hpp>
35#include <com/sun/star/beans/PropertyAttribute.hpp>
36#include <com/sun/star/frame/ModuleManager.hpp>
37#include <com/sun/star/frame/XModel.hpp>
38#include <com/sun/star/frame/FrameAction.hpp>
39#include <com/sun/star/awt/PosSize.hpp>
40#include <com/sun/star/awt/XDevice.hpp>
41#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
42#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
43#include <com/sun/star/ui/theWindowStateConfiguration.hpp>
44#include <com/sun/star/ui/theUIElementFactoryManager.hpp>
45#include <com/sun/star/container/XNameReplace.hpp>
46#include <com/sun/star/container/XNameContainer.hpp>
47#include <com/sun/star/frame/LayoutManagerEvents.hpp>
48#include <com/sun/star/frame/XDispatchProvider.hpp>
49#include <com/sun/star/frame/DispatchHelper.hpp>
50#include <com/sun/star/lang/DisposedException.hpp>
51#include <com/sun/star/util/URLTransformer.hpp>
52
53#include <comphelper/lok.hxx>
54#include <vcl/status.hxx>
55#include <vcl/settings.hxx>
56#include <vcl/window.hxx>
57#include <vcl/svapp.hxx>
58#include <toolkit/helper/vclunohelper.hxx>
59#include <toolkit/awt/vclxmenu.hxx>
60#include <comphelper/uno3.hxx>
61#include <rtl/instance.hxx>
62#include <officecfg/Office/Compatibility.hxx>
63
64#include <rtl/ref.hxx>
65#include <sal/log.hxx>
66
67#include <algorithm>
68
69// using namespace
70using namespace ::com::sun::star;
71using namespace ::com::sun::star::uno;
72using namespace ::com::sun::star::beans;
73using namespace ::com::sun::star::util;
74using namespace ::com::sun::star::lang;
75using namespace ::com::sun::star::container;
76using namespace ::com::sun::star::ui;
77using namespace ::com::sun::star::frame;
78
79const char STATUS_BAR_ALIAS[] = "private:resource/statusbar/statusbar";
80
81namespace framework
82{
83
84IMPLEMENT_FORWARD_XTYPEPROVIDER2( LayoutManager, LayoutManager_Base, LayoutManager_PBase )css::uno::Sequence< css::uno::Type > LayoutManager::getTypes
( ) { return ::comphelper::concatSequences( LayoutManager_Base
::getTypes(), LayoutManager_PBase::getTypes() ); } css::uno::
Sequence< sal_Int8 > LayoutManager::getImplementationId
( ) { return css::uno::Sequence<sal_Int8>(); }
85IMPLEMENT_FORWARD_XINTERFACE2( LayoutManager, LayoutManager_Base, LayoutManager_PBase )void LayoutManager::acquire() throw() { LayoutManager_Base::acquire
(); } void LayoutManager::release() throw() { LayoutManager_Base
::release(); } css::uno::Any LayoutManager::queryInterface( const
css::uno::Type& _rType ) { css::uno::Any aReturn = LayoutManager_Base
::queryInterface( _rType ); if ( !aReturn.hasValue() ) aReturn
= LayoutManager_PBase::queryInterface( _rType ); return aReturn
; }
86
87LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) : LayoutManager_Base()
88 , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >(m_aMutex)
89 , LayoutManager_PBase( *static_cast< ::cppu::OBroadcastHelper* >(this) )
90 , m_xContext( xContext )
91 , m_xURLTransformer( URLTransformer::create(xContext) )
92 , m_nLockCount( 0 )
93 , m_bInplaceMenuSet( false )
94 , m_bMenuVisible( true )
95 , m_bVisible( true )
96 , m_bParentWindowVisible( false )
97 , m_bMustDoLayout( true )
98#if HAVE_FEATURE_DESKTOP1
99 , m_bAutomaticToolbars( true )
100#else
101 , m_bAutomaticToolbars( false )
102#endif
103 , m_bHideCurrentUI( false )
104 , m_bGlobalSettings( false )
105 , m_bPreserveContentSize( false )
106 , m_bMenuBarCloseButton( false )
107 , m_xModuleManager( ModuleManager::create( xContext ))
108 , m_xUIElementFactoryManager( ui::theUIElementFactoryManager::get(xContext) )
109 , m_xPersistentWindowStateSupplier( ui::theWindowStateConfiguration::get( xContext ) )
110 , m_aListenerContainer( m_aMutex )
111{
112 // Initialize statusbar member
113 m_aStatusBarElement.m_aType = "statusbar";
114 m_aStatusBarElement.m_aName = STATUS_BAR_ALIAS;
115
116 if (!comphelper::LibreOfficeKit::isActive())
117 {
118 m_xToolbarManager = new ToolbarLayoutManager( xContext, Reference<XUIElementFactory>(m_xUIElementFactoryManager, UNO_QUERY_THROW), this );
119 }
120
121 m_aAsyncLayoutTimer.SetPriority( TaskPriority::HIGH_IDLE );
122 m_aAsyncLayoutTimer.SetTimeout( 50 );
123 m_aAsyncLayoutTimer.SetInvokeHandler( LINK( this, LayoutManager, AsyncLayoutHdl )::tools::detail::makeLink( ::tools::detail::castTo<LayoutManager
*>(this), &LayoutManager::LinkStubAsyncLayoutHdl)
);
124 m_aAsyncLayoutTimer.SetDebugName( "framework::LayoutManager m_aAsyncLayoutTimer" );
125
126 registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS"AutomaticToolbars", LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS1, css::beans::PropertyAttribute::TRANSIENT, &m_bAutomaticToolbars, cppu::UnoType<decltype(m_bAutomaticToolbars)>::get() );
127 registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI"HideCurrentUI", LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI3, beans::PropertyAttribute::TRANSIENT, &m_bHideCurrentUI, cppu::UnoType<decltype(m_bHideCurrentUI)>::get() );
128 registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_LOCKCOUNT"LockCount", LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT4, beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::READONLY, &m_nLockCount, cppu::UnoType<decltype(m_nLockCount)>::get() );
129 registerProperty( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER"MenuBarCloser", LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER0, beans::PropertyAttribute::TRANSIENT, &m_bMenuBarCloseButton, cppu::UnoType<decltype(m_bMenuBarCloseButton)>::get() );
130 registerPropertyNoMember( LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY"RefreshContextToolbarVisibility", LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY2, beans::PropertyAttribute::TRANSIENT, cppu::UnoType<bool>::get(), css::uno::Any(false) );
131 registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_PRESERVE_CONTENT_SIZE"PreserveContentSize", LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE5, beans::PropertyAttribute::TRANSIENT, &m_bPreserveContentSize, cppu::UnoType<decltype(m_bPreserveContentSize)>::get() );
132}
133
134LayoutManager::~LayoutManager()
135{
136 m_aAsyncLayoutTimer.Stop();
137 setDockingAreaAcceptor(nullptr);
138 m_pGlobalSettings.reset();
139}
140
141void LayoutManager::implts_createMenuBar(const OUString& rMenuBarName)
142{
143 SolarMutexGuard aWriteLock;
144
145 // Create a customized menu if compatibility mode is on
146 if (m_aModuleIdentifier == "com.sun.star.text.TextDocument" && officecfg::Office::Compatibility::View::MSCompatibleFormsMenu::get())
147 {
148 implts_createMSCompatibleMenuBar(rMenuBarName);
149 }
150
151 // Create the default menubar otherwise
152 if (m_bInplaceMenuSet || m_xMenuBar.is())
153 return;
154
155 m_xMenuBar = implts_createElement( rMenuBarName );
156 if ( !m_xMenuBar.is() )
157 return;
158
159 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
160 if ( !pSysWindow )
161 return;
162
163 Reference< awt::XMenuBar > xMenuBar;
164
165 Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
166 if ( xPropSet.is() )
167 {
168 try
169 {
170 xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar;
171 }
172 catch (const beans::UnknownPropertyException&)
173 {
174 }
175 catch (const lang::WrappedTargetException&)
176 {
177 }
178 }
179
180 if ( !xMenuBar.is() )
181 return;
182
183 VCLXMenu* pAwtMenuBar = comphelper::getUnoTunnelImplementation<VCLXMenu>( xMenuBar );
184 if ( pAwtMenuBar )
185 {
186 MenuBar* pMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu());
187 if ( pMenuBar )
188 {
189 pSysWindow->SetMenuBar(pMenuBar);
190 pMenuBar->SetDisplayable( m_bMenuVisible );
191 implts_updateMenuBarClose();
192 }
193 }
194}
195
196// Internal helper function
197void LayoutManager::impl_clearUpMenuBar()
198{
199 implts_lock();
200
201 // Clear up VCL menu bar to prepare shutdown
202 if ( m_xContainerWindow.is() )
203 {
204 SolarMutexGuard aGuard;
205
206 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
207 if ( pSysWindow )
208 {
209 MenuBar* pSetMenuBar = nullptr;
210 if ( m_xInplaceMenuBar.is() )
211 pSetMenuBar = static_cast<MenuBar *>(m_xInplaceMenuBar->GetMenuBar());
212 else
213 {
214 Reference< awt::XMenuBar > xMenuBar;
215
216 Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
217 if ( xPropSet.is() )
218 {
219 try
220 {
221 xPropSet->getPropertyValue("XMenuBar") >>= xMenuBar;
222 }
223 catch (const beans::UnknownPropertyException&)
224 {
225 }
226 catch (const lang::WrappedTargetException&)
227 {
228 }
229 }
230
231 VCLXMenu* pAwtMenuBar = comphelper::getUnoTunnelImplementation<VCLXMenu>( xMenuBar );
232 if ( pAwtMenuBar )
233 pSetMenuBar = static_cast<MenuBar*>(pAwtMenuBar->GetMenu());
234 }
235
236 MenuBar* pTopMenuBar = pSysWindow->GetMenuBar();
237 if ( pSetMenuBar == pTopMenuBar )
238 pSysWindow->SetMenuBar( nullptr );
239 }
240 }
241
242 // reset inplace menubar manager
243 VclPtr<Menu> pMenuBar;
244 if (m_xInplaceMenuBar.is())
245 {
246 pMenuBar = m_xInplaceMenuBar->GetMenuBar();
247 m_xInplaceMenuBar->dispose();
248 m_xInplaceMenuBar.clear();
249 }
250 pMenuBar.disposeAndClear();
251 m_bInplaceMenuSet = false;
252
253 Reference< XComponent > xComp( m_xMenuBar, UNO_QUERY );
254 if ( xComp.is() )
255 xComp->dispose();
256 m_xMenuBar.clear();
257 implts_unlock();
258}
259
260void LayoutManager::implts_lock()
261{
262 SolarMutexGuard g;
263 ++m_nLockCount;
264}
265
266bool LayoutManager::implts_unlock()
267{
268 SolarMutexGuard g;
269 m_nLockCount = std::max( m_nLockCount-1, static_cast<sal_Int32>(0) );
270 return ( m_nLockCount == 0 );
271}
272
273void LayoutManager::implts_reset( bool bAttached )
274{
275 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
276 SolarMutexClearableGuard aReadLock;
277 Reference< XFrame > xFrame = m_xFrame;
278 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
279 Reference< XUIConfiguration > xModuleCfgMgr( m_xModuleCfgMgr, UNO_QUERY );
280 Reference< XUIConfiguration > xDocCfgMgr( m_xDocCfgMgr, UNO_QUERY );
281 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
282 Reference< XComponentContext > xContext( m_xContext );
283 Reference< XNameAccess > xPersistentWindowStateSupplier( m_xPersistentWindowStateSupplier );
284 rtl::Reference<ToolbarLayoutManager> xToolbarManager( m_xToolbarManager );
285 OUString aModuleIdentifier( m_aModuleIdentifier );
286 bool bAutomaticToolbars( m_bAutomaticToolbars );
287 aReadLock.clear();
288 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
289
290 implts_lock();
291
292 Reference< XModel > xModel;
293 if ( xFrame.is() )
294 {
295 if ( bAttached )
296 {
297 OUString aOldModuleIdentifier( aModuleIdentifier );
298 try
299 {
300 aModuleIdentifier = m_xModuleManager->identify( xFrame );
301 }
302 catch( const Exception& ) {}
303
304 if ( !aModuleIdentifier.isEmpty() && aOldModuleIdentifier != aModuleIdentifier )
305 {
306 Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier;
307 if ( xContext.is() )
308 xModuleCfgSupplier = theModuleUIConfigurationManagerSupplier::get( xContext );
309
310 if ( xModuleCfgMgr.is() )
311 {
312 try
313 {
314 // Remove listener to old module ui configuration manager
315 xModuleCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
316 }
317 catch (const Exception&)
318 {
319 }
320 }
321
322 try
323 {
324 // Add listener to new module ui configuration manager
325 xModuleCfgMgr.set( xModuleCfgSupplier->getUIConfigurationManager( aModuleIdentifier ), UNO_QUERY );
326 if ( xModuleCfgMgr.is() )
327 xModuleCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
328 }
329 catch (const Exception&)
330 {
331 }
332
333 try
334 {
335 // Retrieve persistent window state reference for our new module
336 if ( xPersistentWindowStateSupplier.is() )
337 xPersistentWindowStateSupplier->getByName( aModuleIdentifier ) >>= xPersistentWindowState;
338 }
339 catch (const NoSuchElementException&)
340 {
341 }
342 catch (const WrappedTargetException&)
343 {
344 }
345 }
346
347 xModel = impl_getModelFromFrame( xFrame );
348 if ( xModel.is() )
349 {
350 Reference< XUIConfigurationManagerSupplier > xUIConfigurationManagerSupplier( xModel, UNO_QUERY );
351 if ( xUIConfigurationManagerSupplier.is() )
352 {
353 if ( xDocCfgMgr.is() )
354 {
355 try
356 {
357 // Remove listener to old ui configuration manager
358 xDocCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
359 }
360 catch (const Exception&)
361 {
362 }
363 }
364
365 try
366 {
367 xDocCfgMgr.set( xUIConfigurationManagerSupplier->getUIConfigurationManager(), UNO_QUERY );
368 if ( xDocCfgMgr.is() )
369 xDocCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
370 }
371 catch (const Exception&)
372 {
373 }
374 }
375 }
376 }
377 else
378 {
379 // Remove configuration listeners before we can release our references
380 if ( xModuleCfgMgr.is() )
381 {
382 try
383 {
384 xModuleCfgMgr->removeConfigurationListener(
385 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
386 }
387 catch (const Exception&)
388 {
389 }
390 }
391
392 if ( xDocCfgMgr.is() )
393 {
394 try
395 {
396 xDocCfgMgr->removeConfigurationListener(
397 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
398 }
399 catch (const Exception&)
400 {
401 }
402 }
403
404 // Release references to our configuration managers as we currently don't have
405 // an attached module.
406 xModuleCfgMgr.clear();
407 xDocCfgMgr.clear();
408 xPersistentWindowState.clear();
409 aModuleIdentifier.clear();
410 }
411
412 Reference< XUIConfigurationManager > xModCfgMgr( xModuleCfgMgr, UNO_QUERY );
413 Reference< XUIConfigurationManager > xDokCfgMgr( xDocCfgMgr, UNO_QUERY );
414
415 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
416 SolarMutexClearableGuard aWriteLock;
417 m_aDockingArea = awt::Rectangle();
418 m_aModuleIdentifier = aModuleIdentifier;
419 m_xModuleCfgMgr = xModCfgMgr;
420 m_xDocCfgMgr = xDokCfgMgr;
421 m_xPersistentWindowState = xPersistentWindowState;
422 m_aStatusBarElement.m_bStateRead = false; // reset state to read data again!
423 aWriteLock.clear();
424 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
425
426 // reset/notify toolbar layout manager
427 if ( xToolbarManager.is() )
428 {
429 if ( bAttached )
430 {
431 xToolbarManager->attach( xFrame, xModCfgMgr, xDokCfgMgr, xPersistentWindowState );
432 uno::Reference< awt::XWindowPeer > xParent( xContainerWindow, UNO_QUERY );
433 xToolbarManager->setParentWindow( xParent );
434 if ( bAutomaticToolbars )
435 xToolbarManager->createStaticToolbars();
436 }
437 else
438 {
439 xToolbarManager->reset();
440 implts_destroyElements();
441 }
442 }
443 }
444
445 implts_unlock();
446}
447
448bool LayoutManager::implts_isEmbeddedLayoutManager() const
449{
450 SolarMutexClearableGuard aReadLock;
451 Reference< XFrame > xFrame = m_xFrame;
452 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
453 aReadLock.clear();
454
455 Reference< awt::XWindow > xFrameContainerWindow = xFrame->getContainerWindow();
456 return xFrameContainerWindow != xContainerWindow;
457}
458
459void LayoutManager::implts_destroyElements()
460{
461 SolarMutexResettableGuard aWriteLock;
462 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
463 aWriteLock.clear();
464
465 if ( pToolbarManager )
466 pToolbarManager->destroyToolbars();
467
468 implts_destroyStatusBar();
469
470 aWriteLock.reset();
471 impl_clearUpMenuBar();
472 aWriteLock.clear();
473}
474
475void LayoutManager::implts_toggleFloatingUIElementsVisibility( bool bActive )
476{
477 SolarMutexClearableGuard aReadLock;
478 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
479 aReadLock.clear();
480
481 if ( pToolbarManager )
482 pToolbarManager->setFloatingToolbarsVisibility( bActive );
483}
484
485uno::Reference< ui::XUIElement > LayoutManager::implts_findElement( const OUString& aName )
486{
487 OUString aElementType;
488 OUString aElementName;
489
490 parseResourceURL( aName, aElementType, aElementName );
491 if ( aElementType.equalsIgnoreAsciiCase("menubar") &&
492 aElementName.equalsIgnoreAsciiCase("menubar") )
493 return m_xMenuBar;
494 else if (( aElementType.equalsIgnoreAsciiCase("statusbar") &&
495 aElementName.equalsIgnoreAsciiCase("statusbar") ) ||
496 ( m_aStatusBarElement.m_aName == aName ))
497 return m_aStatusBarElement.m_xUIElement;
498 else if ( aElementType.equalsIgnoreAsciiCase("progressbar") &&
499 aElementName.equalsIgnoreAsciiCase("progressbar") )
500 return m_aProgressBarElement.m_xUIElement;
501
502 return uno::Reference< ui::XUIElement >();
503}
504
505bool LayoutManager::implts_readWindowStateData( const OUString& aName, UIElement& rElementData )
506{
507 return readWindowStateData( aName, rElementData, m_xPersistentWindowState,
508 m_pGlobalSettings, m_bGlobalSettings, m_xContext );
509}
510
511bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElementData,
512 const Reference< XNameAccess > &rPersistentWindowState,
513 std::unique_ptr<GlobalSettings> &rGlobalSettings, bool &bInGlobalSettings,
514 const Reference< XComponentContext > &rComponentContext )
515{
516 if ( rPersistentWindowState.is() )
517 {
518 bool bGetSettingsState( false );
519
520 SolarMutexClearableGuard aWriteLock;
521 bool bGlobalSettings( bInGlobalSettings );
522 if ( rGlobalSettings == nullptr )
523 {
524 rGlobalSettings.reset( new GlobalSettings( rComponentContext ) );
525 bGetSettingsState = true;
526 }
527 GlobalSettings* pGlobalSettings = rGlobalSettings.get();
528 aWriteLock.clear();
529
530 try
531 {
532 Sequence< PropertyValue > aWindowState;
533 if ( rPersistentWindowState->hasByName( aName ) && (rPersistentWindowState->getByName( aName ) >>= aWindowState) )
534 {
535 bool bValue( false );
536 for ( PropertyValue const & rProp : std::as_const(aWindowState) )
537 {
538 if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKED"Docked" )
539 {
540 if ( rProp.Value >>= bValue )
541 rElementData.m_bFloating = !bValue;
542 }
543 else if ( rProp.Name == WINDOWSTATE_PROPERTY_VISIBLE"Visible" )
544 {
545 if ( rProp.Value >>= bValue )
546 rElementData.m_bVisible = bValue;
547 }
548 else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKINGAREA"DockingArea" )
549 {
550 ui::DockingArea eDockingArea;
551 if ( rProp.Value >>= eDockingArea )
552 rElementData.m_aDockedData.m_nDockedArea = eDockingArea;
553 }
554 else if ( rProp.Name == WINDOWSTATE_PROPERTY_DOCKPOS"DockPos" )
555 {
556 awt::Point aPoint;
557 if (rProp.Value >>= aPoint)
558 {
559 //tdf#90256 repair these broken Docking positions
560 if (aPoint.X < 0)
561 aPoint.X = SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF);
562 if (aPoint.Y < 0)
563 aPoint.Y = SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF);
564 rElementData.m_aDockedData.m_aPos = aPoint;
565 }
566 }
567 else if ( rProp.Name == WINDOWSTATE_PROPERTY_POS"Pos" )
568 {
569 awt::Point aPoint;
570 if ( rProp.Value >>= aPoint )
571 rElementData.m_aFloatingData.m_aPos = aPoint;
572 }
573 else if ( rProp.Name == WINDOWSTATE_PROPERTY_SIZE"Size" )
574 {
575 awt::Size aSize;
576 if ( rProp.Value >>= aSize )
577 rElementData.m_aFloatingData.m_aSize = aSize;
578 }
579 else if ( rProp.Name == WINDOWSTATE_PROPERTY_UINAME"UIName" )
580 rProp.Value >>= rElementData.m_aUIName;
581 else if ( rProp.Name == WINDOWSTATE_PROPERTY_STYLE"Style" )
582 {
583 sal_Int32 nStyle = 0;
584 if ( rProp.Value >>= nStyle )
585 rElementData.m_nStyle = static_cast<ButtonType>( nStyle );
586 }
587 else if ( rProp.Name == WINDOWSTATE_PROPERTY_LOCKED"Locked" )
588 {
589 if ( rProp.Value >>= bValue )
590 rElementData.m_aDockedData.m_bLocked = bValue;
591 }
592 else if ( rProp.Name == WINDOWSTATE_PROPERTY_CONTEXT"ContextSensitive" )
593 {
594 if ( rProp.Value >>= bValue )
595 rElementData.m_bContextSensitive = bValue;
596 }
597 else if ( rProp.Name == WINDOWSTATE_PROPERTY_NOCLOSE"NoClose" )
598 {
599 if ( rProp.Value >>= bValue )
600 rElementData.m_bNoClose = bValue;
601 }
602 }
603 }
604
605 // oversteer values with global settings
606 if (bGetSettingsState || bGlobalSettings)
607 {
608 if ( pGlobalSettings->HasToolbarStatesInfo())
609 {
610 {
611 SolarMutexGuard aWriteLock2;
612 bInGlobalSettings = true;
613 }
614
615 uno::Any aValue;
616 if ( pGlobalSettings->GetToolbarStateInfo(
617 GlobalSettings::STATEINFO_LOCKED,
618 aValue ))
619 aValue >>= rElementData.m_aDockedData.m_bLocked;
620 if ( pGlobalSettings->GetToolbarStateInfo(
621 GlobalSettings::STATEINFO_DOCKED,
622 aValue ))
623 {
624 bool bValue;
625 if ( aValue >>= bValue )
626 rElementData.m_bFloating = !bValue;
627 }
628 }
629 }
630
631 const bool bDockingSupportCrippled = !StyleSettings::GetDockingFloatsSupported();
632 if (bDockingSupportCrippled)
633 rElementData.m_bFloating = false;
634
635 return true;
636 }
637 catch (const NoSuchElementException&)
638 {
639 }
640 }
641
642 return false;
643}
644
645void LayoutManager::implts_writeWindowStateData( const OUString& aName, const UIElement& rElementData )
646{
647 SolarMutexClearableGuard aWriteLock;
648 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
649
650 aWriteLock.clear();
651
652 bool bPersistent( false );
653 Reference< XPropertySet > xPropSet( rElementData.m_xUIElement, UNO_QUERY );
654 if ( xPropSet.is() )
655 {
656 try
657 {
658 // Check persistent flag of the user interface element
659 xPropSet->getPropertyValue("Persistent") >>= bPersistent;
660 }
661 catch (const beans::UnknownPropertyException&)
662 {
663 // Non-configurable elements should at least store their dimension/position
664 bPersistent = true;
665 }
666 catch (const lang::WrappedTargetException&)
667 {
668 }
669 }
670
671 if ( !(bPersistent && xPersistentWindowState.is()) )
672 return;
673
674 try
675 {
676 Sequence< PropertyValue > aWindowState( 8 );
677
678 aWindowState[0].Name = WINDOWSTATE_PROPERTY_DOCKED"Docked";
679 aWindowState[0].Value <<= !rElementData.m_bFloating;
680 aWindowState[1].Name = WINDOWSTATE_PROPERTY_VISIBLE"Visible";
681 aWindowState[1].Value <<= rElementData.m_bVisible;
682
683 aWindowState[2].Name = WINDOWSTATE_PROPERTY_DOCKINGAREA"DockingArea";
684 aWindowState[2].Value <<= rElementData.m_aDockedData.m_nDockedArea;
685
686 aWindowState[3].Name = WINDOWSTATE_PROPERTY_DOCKPOS"DockPos";
687 aWindowState[3].Value <<= rElementData.m_aDockedData.m_aPos;
688
689 aWindowState[4].Name = WINDOWSTATE_PROPERTY_POS"Pos";
690 aWindowState[4].Value <<= rElementData.m_aFloatingData.m_aPos;
691
692 aWindowState[5].Name = WINDOWSTATE_PROPERTY_SIZE"Size";
693 aWindowState[5].Value <<= rElementData.m_aFloatingData.m_aSize;
694 aWindowState[6].Name = WINDOWSTATE_PROPERTY_UINAME"UIName";
695 aWindowState[6].Value <<= rElementData.m_aUIName;
696 aWindowState[7].Name = WINDOWSTATE_PROPERTY_LOCKED"Locked";
697 aWindowState[7].Value <<= rElementData.m_aDockedData.m_bLocked;
698
699 if ( xPersistentWindowState->hasByName( aName ))
700 {
701 Reference< XNameReplace > xReplace( xPersistentWindowState, uno::UNO_QUERY );
702 xReplace->replaceByName( aName, makeAny( aWindowState ));
703 }
704 else
705 {
706 Reference< XNameContainer > xInsert( xPersistentWindowState, uno::UNO_QUERY );
707 xInsert->insertByName( aName, makeAny( aWindowState ));
708 }
709 }
710 catch (const Exception&)
711 {
712 }
713}
714
715::Size LayoutManager::implts_getContainerWindowOutputSize()
716{
717 ::Size aContainerWinSize;
718 vcl::Window* pContainerWindow( nullptr );
719
720 // Retrieve output size from container Window
721 SolarMutexGuard aGuard;
722 pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow ).get();
1
Calling implicit destructor for 'VclPtr<vcl::Window>'
2
Calling '~Reference'
10
Returning from '~Reference'
11
Returning from destructor for 'VclPtr<vcl::Window>'
723 if ( pContainerWindow
11.1
'pContainerWindow' is non-null
11.1
'pContainerWindow' is non-null
11.1
'pContainerWindow' is non-null
)
12
Taking true branch
724 aContainerWinSize = pContainerWindow->GetOutputSizePixel();
13
Use of memory after it is freed
725
726 return aContainerWinSize;
727}
728
729Reference< XUIElement > LayoutManager::implts_createElement( const OUString& aName )
730{
731 Reference< ui::XUIElement > xUIElement;
732
733 SolarMutexGuard g;
734 Sequence< PropertyValue > aPropSeq( 2 );
735 aPropSeq[0].Name = "Frame";
736 aPropSeq[0].Value <<= m_xFrame;
737 aPropSeq[1].Name = "Persistent";
738 aPropSeq[1].Value <<= true;
739
740 try
741 {
742 xUIElement = m_xUIElementFactoryManager->createUIElement( aName, aPropSeq );
743 }
744 catch (const NoSuchElementException&)
745 {
746 }
747 catch (const IllegalArgumentException&)
748 {
749 }
750
751 return xUIElement;
752}
753
754void LayoutManager::implts_setVisibleState( bool bShow )
755{
756 {
757 SolarMutexGuard aWriteLock;
758 m_aStatusBarElement.m_bMasterHide = !bShow;
759 }
760
761 implts_updateUIElementsVisibleState( bShow );
762}
763
764void LayoutManager::implts_updateUIElementsVisibleState( bool bSetVisible )
765{
766 // notify listeners
767 uno::Any a;
768 if ( bSetVisible )
769 implts_notifyListeners( frame::LayoutManagerEvents::VISIBLE, a );
770 else
771 implts_notifyListeners( frame::LayoutManagerEvents::INVISIBLE, a );
772
773 SolarMutexResettableGuard aWriteLock;
774 Reference< XUIElement > xMenuBar = m_xMenuBar;
775 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
776 rtl::Reference< MenuBarManager > xInplaceMenuBar( m_xInplaceMenuBar );
777 aWriteLock.clear();
778
779 if (( xMenuBar.is() || xInplaceMenuBar.is() ) && xContainerWindow.is() )
780 {
781 SolarMutexGuard aGuard;
782
783 MenuBar* pMenuBar( nullptr );
784 if ( xInplaceMenuBar.is() )
785 pMenuBar = static_cast<MenuBar *>(xInplaceMenuBar->GetMenuBar());
786 else
787 {
788 MenuBarWrapper* pMenuBarWrapper = static_cast< MenuBarWrapper* >(xMenuBar.get());
789 pMenuBar = static_cast<MenuBar *>(pMenuBarWrapper->GetMenuBarManager()->GetMenuBar());
790 }
791
792 SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow );
793 if ( pSysWindow )
794 {
795 if ( bSetVisible )
796 {
797 pSysWindow->SetMenuBar(pMenuBar);
798 }
799 else
800 pSysWindow->SetMenuBar( nullptr );
801 }
802 }
803
804 bool bMustDoLayout;
805 // Hide/show the statusbar according to bSetVisible
806 if ( bSetVisible )
807 bMustDoLayout = !implts_showStatusBar();
808 else
809 bMustDoLayout = !implts_hideStatusBar();
810
811 aWriteLock.reset();
812 ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() );
813 aWriteLock.clear();
814
815 if ( pToolbarManager )
816 {
817 pToolbarManager->setVisible( bSetVisible );
818 bMustDoLayout = pToolbarManager->isLayoutDirty();
819 }
820
821 if ( bMustDoLayout )
822 implts_doLayout_notify( false );
823}
824
825void LayoutManager::implts_setCurrentUIVisibility( bool bShow )
826{
827 {
828 SolarMutexGuard aWriteLock;
829 if (!bShow && m_aStatusBarElement.m_bVisible && m_aStatusBarElement.m_xUIElement.is())
830 m_aStatusBarElement.m_bMasterHide = true;
831 else if (bShow && m_aStatusBarElement.m_bVisible)
832 m_aStatusBarElement.m_bMasterHide = false;
833 }
834
835 implts_updateUIElementsVisibleState( bShow );
836}
837
838void LayoutManager::implts_destroyStatusBar()
839{
840 Reference< XComponent > xCompStatusBar;
841
842 SolarMutexClearableGuard aWriteLock;
843 m_aStatusBarElement.m_aName.clear();
844 xCompStatusBar.set( m_aStatusBarElement.m_xUIElement, UNO_QUERY );
845 m_aStatusBarElement.m_xUIElement.clear();
846 aWriteLock.clear();
847
848 if ( xCompStatusBar.is() )
849 xCompStatusBar->dispose();
850
851 implts_destroyProgressBar();
852}
853
854void LayoutManager::implts_createStatusBar( const OUString& aStatusBarName )
855{
856 {
857 SolarMutexGuard aWriteLock;
858 if (!m_aStatusBarElement.m_xUIElement.is())
859 {
860 implts_readStatusBarState(aStatusBarName);
861 m_aStatusBarElement.m_aName = aStatusBarName;
862 m_aStatusBarElement.m_xUIElement = implts_createElement(aStatusBarName);
863 }
864 }
865
866 implts_createProgressBar();
867}
868
869void LayoutManager::implts_readStatusBarState( const OUString& rStatusBarName )
870{
871 SolarMutexGuard g;
872 if ( !m_aStatusBarElement.m_bStateRead )
873 {
874 // Read persistent data for status bar if not yet read!
875 if ( implts_readWindowStateData( rStatusBarName, m_aStatusBarElement ))
876 m_aStatusBarElement.m_bStateRead = true;
877 }
878}
879
880void LayoutManager::implts_createProgressBar()
881{
882 Reference< XUIElement > xStatusBar;
883 Reference< XUIElement > xProgressBar;
884 Reference< XUIElement > xProgressBarBackup;
885 Reference< awt::XWindow > xContainerWindow;
886
887 SolarMutexResettableGuard aWriteLock;
888 xStatusBar = m_aStatusBarElement.m_xUIElement;
889 xProgressBar = m_aProgressBarElement.m_xUIElement;
890 xProgressBarBackup = m_xProgressBarBackup;
891 m_xProgressBarBackup.clear();
892 xContainerWindow = m_xContainerWindow;
893 aWriteLock.clear();
894
895 bool bRecycled = xProgressBarBackup.is();
896 ProgressBarWrapper* pWrapper = nullptr;
897 if ( bRecycled )
898 pWrapper = static_cast<ProgressBarWrapper*>(xProgressBarBackup.get());
899 else if ( xProgressBar.is() )
900 pWrapper = static_cast<ProgressBarWrapper*>(xProgressBar.get());
901 else
902 pWrapper = new ProgressBarWrapper();
903
904 if ( xStatusBar.is() )
905 {
906 Reference< awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY );
907 pWrapper->setStatusBar( xWindow );
908 }
909 else
910 {
911 Reference< awt::XWindow > xStatusBarWindow = pWrapper->getStatusBar();
912
913 SolarMutexGuard aGuard;
914 VclPtr<vcl::Window> pStatusBarWnd = VCLUnoHelper::GetWindow( xStatusBarWindow );
915 if ( !pStatusBarWnd )
916 {
917 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
918 if ( pWindow )
919 {
920 VclPtrInstance<StatusBar> pStatusBar( pWindow, WinBits( WB_LEFT | WB_3DLOOK ) );
921 Reference< awt::XWindow > xStatusBarWindow2( VCLUnoHelper::GetInterface( pStatusBar ));
922 pWrapper->setStatusBar( xStatusBarWindow2, true );
923 }
924 }
925 }
926
927 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
928 aWriteLock.reset();
929 m_aProgressBarElement.m_xUIElement.set( static_cast< cppu::OWeakObject* >( pWrapper ), UNO_QUERY );
930 aWriteLock.clear();
931 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
932
933 if ( bRecycled )
934 implts_showProgressBar();
935}
936
937void LayoutManager::implts_backupProgressBarWrapper()
938{
939 SolarMutexGuard g;
940
941 if (m_xProgressBarBackup.is())
942 return;
943
944 // safe a backup copy of the current progress!
945 // This copy will be used automatically inside createProgressBar() which is called
946 // implicitly from implts_doLayout() .-)
947 m_xProgressBarBackup = m_aProgressBarElement.m_xUIElement;
948
949 // remove the relation between this old progress bar and our old status bar.
950 // Otherwise we work on disposed items ...
951 // The internal used ProgressBarWrapper can handle a NULL reference.
952 if ( m_xProgressBarBackup.is() )
953 {
954 ProgressBarWrapper* pWrapper = static_cast<ProgressBarWrapper*>(m_xProgressBarBackup.get());
955 if ( pWrapper )
956 pWrapper->setStatusBar( Reference< awt::XWindow >() );
957 }
958
959 // prevent us from dispose() the m_aProgressBarElement.m_xUIElement inside implts_reset()
960 m_aProgressBarElement.m_xUIElement.clear();
961}
962
963void LayoutManager::implts_destroyProgressBar()
964{
965 // don't remove the progressbar in general
966 // We must reuse it if a new status bar is created later.
967 // Of course there exists one backup only.
968 // And further this backup will be released inside our dtor.
969 implts_backupProgressBarWrapper();
970}
971
972void LayoutManager::implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize )
973{
974 Reference< XUIElement > xStatusBar;
975 Reference< XUIElement > xProgressBar;
976 Reference< awt::XWindow > xContainerWindow;
977
978 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
979 SolarMutexClearableGuard aReadLock;
980 xStatusBar = m_aStatusBarElement.m_xUIElement;
981 xProgressBar = m_aProgressBarElement.m_xUIElement;
982 xContainerWindow = m_xContainerWindow;
983
984 Reference< awt::XWindow > xWindow;
985 if ( xStatusBar.is() )
986 xWindow.set( xStatusBar->getRealInterface(), UNO_QUERY );
987 else if ( xProgressBar.is() )
988 {
989 ProgressBarWrapper* pWrapper = static_cast<ProgressBarWrapper*>(xProgressBar.get());
990 if ( pWrapper )
991 xWindow = pWrapper->getStatusBar();
992 }
993 aReadLock.clear();
994 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
995
996 if ( !xWindow.is() )
997 return;
998
999 SolarMutexGuard aGuard;
1000 VclPtr<vcl::Window> pParentWindow = VCLUnoHelper::GetWindow( xContainerWindow );
1001 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
1002 if ( pParentWindow && ( pWindow && pWindow->GetType() == WindowType::STATUSBAR ))
1003 {
1004 vcl::Window* pOldParentWindow = pWindow->GetParent();
1005 if ( pParentWindow != pOldParentWindow )
1006 pWindow->SetParent( pParentWindow );
1007 static_cast<StatusBar *>(pWindow.get())->SetPosSizePixel( rPos, rSize );
1008 }
1009}
1010
1011bool LayoutManager::implts_showProgressBar()
1012{
1013 Reference< XUIElement > xStatusBar;
1014 Reference< XUIElement > xProgressBar;
1015 Reference< awt::XWindow > xWindow;
1016
1017 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1018 SolarMutexGuard aWriteLock;
1019 xStatusBar = m_aStatusBarElement.m_xUIElement;
1020 xProgressBar = m_aProgressBarElement.m_xUIElement;
1021 bool bVisible( m_bVisible );
1022
1023 m_aProgressBarElement.m_bVisible = true;
1024 if ( bVisible )
1025 {
1026 if ( xStatusBar.is() && !m_aStatusBarElement.m_bMasterHide )
1027 {
1028 xWindow.set( xStatusBar->getRealInterface(), UNO_QUERY );
1029 }
1030 else if ( xProgressBar.is() )
1031 {
1032 ProgressBarWrapper* pWrapper = static_cast<ProgressBarWrapper*>(xProgressBar.get());
1033 if ( pWrapper )
1034 xWindow = pWrapper->getStatusBar();
1035 }
1036 }
1037
1038 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
1039 if ( pWindow )
1040 {
1041 if ( !pWindow->IsVisible() )
1042 {
1043 implts_setOffset( pWindow->GetSizePixel().Height() );
1044 pWindow->Show();
1045 implts_doLayout_notify( false );
1046 }
1047 return true;
1048 }
1049
1050 return false;
1051}
1052
1053bool LayoutManager::implts_hideProgressBar()
1054{
1055 Reference< XUIElement > xProgressBar;
1056 Reference< awt::XWindow > xWindow;
1057 bool bHideStatusBar( false );
1058
1059 SolarMutexGuard g;
1060 xProgressBar = m_aProgressBarElement.m_xUIElement;
1061
1062 bool bInternalStatusBar( false );
1063 if ( xProgressBar.is() )
1064 {
1065 Reference< awt::XWindow > xStatusBar;
1066 ProgressBarWrapper* pWrapper = static_cast<ProgressBarWrapper*>(xProgressBar.get());
1067 if ( pWrapper )
1068 xWindow = pWrapper->getStatusBar();
1069 Reference< ui::XUIElement > xStatusBarElement = m_aStatusBarElement.m_xUIElement;
1070 if ( xStatusBarElement.is() )
1071 xStatusBar.set( xStatusBarElement->getRealInterface(), UNO_QUERY );
1072 bInternalStatusBar = xStatusBar != xWindow;
1073 }
1074 m_aProgressBarElement.m_bVisible = false;
1075 implts_readStatusBarState( STATUS_BAR_ALIAS );
1076 bHideStatusBar = !m_aStatusBarElement.m_bVisible;
1077
1078 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
1079 if ( pWindow && pWindow->IsVisible() && ( bHideStatusBar || bInternalStatusBar ))
1080 {
1081 implts_setOffset( 0 );
1082 pWindow->Hide();
1083 implts_doLayout_notify( false );
1084 return true;
1085 }
1086
1087 return false;
1088}
1089
1090bool LayoutManager::implts_showStatusBar( bool bStoreState )
1091{
1092 SolarMutexClearableGuard aWriteLock;
1093 Reference< ui::XUIElement > xStatusBar = m_aStatusBarElement.m_xUIElement;
1094 if ( bStoreState )
1095 m_aStatusBarElement.m_bVisible = true;
1096 aWriteLock.clear();
1097
1098 if ( xStatusBar.is() )
1099 {
1100 Reference< awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY );
1101
1102 SolarMutexGuard aGuard;
1103 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
1104 if ( pWindow && !pWindow->IsVisible() )
1105 {
1106 implts_setOffset( pWindow->GetSizePixel().Height() );
1107 pWindow->Show();
1108 implts_doLayout_notify( false );
1109 return true;
1110 }
1111 }
1112
1113 return false;
1114}
1115
1116bool LayoutManager::implts_hideStatusBar( bool bStoreState )
1117{
1118 SolarMutexClearableGuard aWriteLock;
1119 Reference< ui::XUIElement > xStatusBar = m_aStatusBarElement.m_xUIElement;
1120 if ( bStoreState )
1121 m_aStatusBarElement.m_bVisible = false;
1122 aWriteLock.clear();
1123
1124 if ( xStatusBar.is() )
1125 {
1126 Reference< awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY );
1127
1128 SolarMutexGuard aGuard;
1129 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
1130 if ( pWindow && pWindow->IsVisible() )
1131 {
1132 implts_setOffset( 0 );
1133 pWindow->Hide();
1134 implts_doLayout_notify( false );
1135 return true;
1136 }
1137 }
1138
1139 return false;
1140}
1141
1142void LayoutManager::implts_setOffset( const sal_Int32 nBottomOffset )
1143{
1144 ::tools::Rectangle aOffsetRect;
1145 setZeroRectangle( aOffsetRect );
1146 aOffsetRect.setHeight( nBottomOffset );
1147
1148 if ( m_xToolbarManager.is() )
1149 m_xToolbarManager->setDockingAreaOffsets( aOffsetRect );
1150}
1151
1152void LayoutManager::implts_setInplaceMenuBar( const Reference< XIndexAccess >& xMergedMenuBar )
1153{
1154 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1155 SolarMutexClearableGuard aWriteLock;
1156
1157 if ( m_bInplaceMenuSet )
1158 return;
1159
1160 SolarMutexGuard aGuard;
1161
1162 // Reset old inplace menubar!
1163 VclPtr<Menu> pOldMenuBar;
1164 if (m_xInplaceMenuBar.is())
1165 {
1166 pOldMenuBar = m_xInplaceMenuBar->GetMenuBar();
1167 m_xInplaceMenuBar->dispose();
1168 m_xInplaceMenuBar.clear();
1169 }
1170 pOldMenuBar.disposeAndClear();
1171
1172 m_bInplaceMenuSet = false;
1173
1174 if ( m_xFrame.is() && m_xContainerWindow.is() )
1175 {
1176 Reference< XDispatchProvider > xDispatchProvider;
1177
1178 VclPtr<MenuBar> pMenuBar = VclPtr<MenuBar>::Create();
1179 m_xInplaceMenuBar = new MenuBarManager( m_xContext, m_xFrame, m_xURLTransformer, xDispatchProvider, OUString(), pMenuBar, true );
1180 m_xInplaceMenuBar->SetItemContainer( xMergedMenuBar );
1181
1182 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
1183 if ( pSysWindow )
1184 pSysWindow->SetMenuBar(pMenuBar);
1185
1186 m_bInplaceMenuSet = true;
1187 }
1188
1189 aWriteLock.clear();
1190 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1191
1192 implts_updateMenuBarClose();
1193}
1194
1195void LayoutManager::implts_resetInplaceMenuBar()
1196{
1197 SolarMutexGuard g;
1198 m_bInplaceMenuSet = false;
1199
1200 if ( m_xContainerWindow.is() )
1201 {
1202 SolarMutexGuard aGuard;
1203 MenuBarWrapper* pMenuBarWrapper = static_cast< MenuBarWrapper* >(m_xMenuBar.get());
1204 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
1205 if ( pSysWindow )
1206 {
1207 if ( pMenuBarWrapper )
1208 pSysWindow->SetMenuBar(static_cast<MenuBar *>(pMenuBarWrapper->GetMenuBarManager()->GetMenuBar()));
1209 else
1210 pSysWindow->SetMenuBar(nullptr);
1211 }
1212 }
1213
1214 // Remove inplace menu bar
1215 VclPtr<Menu> pMenuBar;
1216 if (m_xInplaceMenuBar.is())
1217 {
1218 pMenuBar = m_xInplaceMenuBar->GetMenuBar();
1219 m_xInplaceMenuBar->dispose();
1220 m_xInplaceMenuBar.clear();
1221 }
1222 pMenuBar.disposeAndClear();
1223}
1224
1225void SAL_CALL LayoutManager::attachFrame( const Reference< XFrame >& xFrame )
1226{
1227 SolarMutexGuard g;
1228 m_xFrame = xFrame;
1229}
1230
1231void SAL_CALL LayoutManager::reset()
1232{
1233 implts_reset( true );
1234}
1235
1236// XMenuBarMergingAcceptor
1237
1238sal_Bool SAL_CALL LayoutManager::setMergedMenuBar(
1239 const Reference< XIndexAccess >& xMergedMenuBar )
1240{
1241 implts_setInplaceMenuBar( xMergedMenuBar );
1242
1243 uno::Any a;
1244 implts_notifyListeners( frame::LayoutManagerEvents::MERGEDMENUBAR, a );
1245 return true;
1246}
1247
1248void SAL_CALL LayoutManager::removeMergedMenuBar()
1249{
1250 implts_resetInplaceMenuBar();
1251}
1252
1253awt::Rectangle SAL_CALL LayoutManager::getCurrentDockingArea()
1254{
1255 SolarMutexGuard g;
1256 return m_aDockingArea;
1257}
1258
1259Reference< XDockingAreaAcceptor > SAL_CALL LayoutManager::getDockingAreaAcceptor()
1260{
1261 SolarMutexGuard g;
1262 return m_xDockingAreaAcceptor;
1263}
1264
1265void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ui::XDockingAreaAcceptor >& xDockingAreaAcceptor )
1266{
1267 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1268 SolarMutexClearableGuard aWriteLock;
1269
1270 if (( m_xDockingAreaAcceptor == xDockingAreaAcceptor ) || !m_xFrame.is() )
1271 return;
1272
1273 // IMPORTANT: Be sure to stop layout timer if don't have a docking area acceptor!
1274 if ( !xDockingAreaAcceptor.is() )
1275 m_aAsyncLayoutTimer.Stop();
1276
1277 bool bAutomaticToolbars( m_bAutomaticToolbars );
1278
1279 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1280
1281 if ( !xDockingAreaAcceptor.is() )
1282 m_aAsyncLayoutTimer.Stop();
1283
1284 // Remove listener from old docking area acceptor
1285 if ( m_xDockingAreaAcceptor.is() )
1286 {
1287 Reference< awt::XWindow > xWindow( m_xDockingAreaAcceptor->getContainerWindow() );
1288 if ( xWindow.is() && ( m_xFrame->getContainerWindow() != m_xContainerWindow || !xDockingAreaAcceptor.is() ) )
1289 xWindow->removeWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject * >( this ), UNO_QUERY ));
1290
1291 m_aDockingArea = awt::Rectangle();
1292 if ( pToolbarManager )
1293 pToolbarManager->resetDockingArea();
1294
1295 VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow( xWindow );
1296 if ( pContainerWindow )
1297 pContainerWindow->RemoveChildEventListener( LINK( this, LayoutManager, WindowEventListener )::tools::detail::makeLink( ::tools::detail::castTo<LayoutManager
*>(this), &LayoutManager::LinkStubWindowEventListener
)
);
1298 }
1299
1300 m_xDockingAreaAcceptor = xDockingAreaAcceptor;
1301 if ( m_xDockingAreaAcceptor.is() )
1302 {
1303 m_aDockingArea = awt::Rectangle();
1304 m_xContainerWindow = m_xDockingAreaAcceptor->getContainerWindow();
1305 m_xContainerTopWindow.set( m_xContainerWindow, UNO_QUERY );
1306 m_xContainerWindow->addWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
1307
1308 // we always must keep a connection to the window of our frame for resize events
1309 if ( m_xContainerWindow != m_xFrame->getContainerWindow() )
1310 m_xFrame->getContainerWindow()->addWindowListener( Reference< awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
1311
1312 // #i37884# set initial visibility state - in the plugin case the container window is already shown
1313 // and we get no notification anymore
1314 {
1315 VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
1316 if( pContainerWindow )
1317 m_bParentWindowVisible = pContainerWindow->IsVisible();
1318 }
1319 }
1320
1321 aWriteLock.clear();
1322 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1323
1324 if ( xDockingAreaAcceptor.is() )
1325 {
1326 SolarMutexGuard aGuard;
1327
1328 // Add layout manager as listener to get notifications about toolbar button activities
1329 VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
1330 if ( pContainerWindow )
1331 pContainerWindow->AddChildEventListener( LINK( this, LayoutManager, WindowEventListener )::tools::detail::makeLink( ::tools::detail::castTo<LayoutManager
*>(this), &LayoutManager::LinkStubWindowEventListener
)
);
1332
1333 // We have now a new container window, reparent all child windows!
1334 implts_reparentChildWindows();
1335 }
1336 else
1337 implts_destroyElements(); // remove all elements
1338
1339 if ( pToolbarManager && xDockingAreaAcceptor.is() )
1340 {
1341 if ( bAutomaticToolbars )
1342 {
1343 lock();
1344 pToolbarManager->createStaticToolbars();
1345 unlock();
1346 }
1347 implts_doLayout( true, false );
1348 }
1349}
1350
1351void LayoutManager::implts_reparentChildWindows()
1352{
1353 SolarMutexResettableGuard aWriteLock;
1354 UIElement aStatusBarElement = m_aStatusBarElement;
1355 uno::Reference< awt::XWindow > xContainerWindow = m_xContainerWindow;
1356 aWriteLock.clear();
1357
1358 uno::Reference< awt::XWindow > xStatusBarWindow;
1359 if ( aStatusBarElement.m_xUIElement.is() )
1360 {
1361 try
1362 {
1363 xStatusBarWindow.set( aStatusBarElement.m_xUIElement->getRealInterface(), UNO_QUERY );
1364 }
1365 catch (const RuntimeException&)
1366 {
1367 throw;
1368 }
1369 catch (const Exception&)
1370 {
1371 }
1372 }
1373
1374 if ( xStatusBarWindow.is() )
1375 {
1376 SolarMutexGuard aGuard;
1377 VclPtr<vcl::Window> pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
1378 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xStatusBarWindow );
1379 if ( pWindow && pContainerWindow )
1380 pWindow->SetParent( pContainerWindow );
1381 }
1382
1383 implts_resetMenuBar();
1384
1385 aWriteLock.reset();
1386 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1387 if ( pToolbarManager )
1388 pToolbarManager->setParentWindow( uno::Reference< awt::XWindowPeer >( xContainerWindow, uno::UNO_QUERY ));
1389 aWriteLock.clear();
1390}
1391
1392uno::Reference< ui::XUIElement > LayoutManager::implts_createDockingWindow( const OUString& aElementName )
1393{
1394 Reference< XUIElement > xUIElement = implts_createElement( aElementName );
1395 return xUIElement;
1396}
1397
1398IMPL_LINK( LayoutManager, WindowEventListener, VclWindowEvent&, rEvent, void )void LayoutManager::LinkStubWindowEventListener(void * instance
, VclWindowEvent& data) { return static_cast<LayoutManager
*>(instance)->WindowEventListener(data); } void LayoutManager
::WindowEventListener(VclWindowEvent& rEvent)
1399{
1400 vcl::Window* pWindow = rEvent.GetWindow();
1401 if ( pWindow && pWindow->GetType() == WindowType::TOOLBOX )
1402 {
1403 SolarMutexClearableGuard aReadLock;
1404 ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() );
1405 aReadLock.clear();
1406
1407 if ( pToolbarManager )
1408 pToolbarManager->childWindowEvent( &rEvent );
1409 }
1410}
1411
1412void SAL_CALL LayoutManager::createElement( const OUString& aName )
1413{
1414 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::createElement" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::createElement"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1414" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::createElement"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::createElement"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1414" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::createElement"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1414" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::createElement"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::createElement"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1414" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1415
1416 SolarMutexClearableGuard aReadLock;
1417 Reference< XFrame > xFrame = m_xFrame;
1418 aReadLock.clear();
1419
1420 if ( !xFrame.is() )
1421 return;
1422
1423 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1424 SolarMutexClearableGuard aWriteLock;
1425
1426 bool bMustBeLayouted( false );
1427 bool bNotify( false );
1428
1429 bool bPreviewFrame;
1430 if (m_xToolbarManager.is())
1431 // Assumes that we created the ToolbarLayoutManager with our frame, if
1432 // not then we're somewhat fouled up ...
1433 bPreviewFrame = m_xToolbarManager->isPreviewFrame();
1434 else
1435 {
1436 Reference< XModel > xModel( impl_getModelFromFrame( xFrame ) );
1437 bPreviewFrame = implts_isPreviewModel( xModel );
1438 }
1439
1440 if ( m_xContainerWindow.is() && !bPreviewFrame ) // no UI elements on preview frames
1441 {
1442 OUString aElementType;
1443 OUString aElementName;
1444
1445 parseResourceURL( aName, aElementType, aElementName );
1446
1447 if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ) && m_xToolbarManager.is() )
1448 {
1449 bNotify = m_xToolbarManager->createToolbar( aName );
1450 bMustBeLayouted = m_xToolbarManager->isLayoutDirty();
1451 }
1452 else if ( aElementType.equalsIgnoreAsciiCase("menubar") &&
1453 aElementName.equalsIgnoreAsciiCase("menubar") &&
1454 implts_isFrameOrWindowTop(xFrame) )
1455 {
1456 implts_createMenuBar( aName );
1457 if (m_bMenuVisible)
1458 bNotify = true;
1459
1460 aWriteLock.clear();
1461 }
1462 else if ( aElementType.equalsIgnoreAsciiCase("statusbar") &&
1463 ( implts_isFrameOrWindowTop(xFrame) || implts_isEmbeddedLayoutManager() ))
1464 {
1465 implts_createStatusBar( aName );
1466 bNotify = true;
1467 }
1468 else if ( aElementType.equalsIgnoreAsciiCase("progressbar") &&
1469 aElementName.equalsIgnoreAsciiCase("progressbar") &&
1470 implts_isFrameOrWindowTop(xFrame) )
1471 {
1472 implts_createProgressBar();
1473 bNotify = true;
1474 }
1475 else if ( aElementType.equalsIgnoreAsciiCase("dockingwindow"))
1476 {
1477 // Add layout manager as listener for docking and other window events
1478 uno::Reference< uno::XInterface > xThis( static_cast< OWeakObject* >(this), uno::UNO_QUERY );
1479 uno::Reference< ui::XUIElement > xUIElement( implts_createDockingWindow( aName ));
1480
1481 if ( xUIElement.is() )
1482 {
1483 impl_addWindowListeners( xThis, xUIElement );
1484 }
1485
1486 // The docking window is created by a factory method located in the sfx2 library.
1487// CreateDockingWindow( xFrame, aElementName );
1488 }
1489 }
1490
1491 if ( bMustBeLayouted )
1492 implts_doLayout_notify( true );
1493
1494 if ( bNotify )
1495 {
1496 // UI element is invisible - provide information to listeners
1497 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( aName ) );
1498 }
1499}
1500
1501void SAL_CALL LayoutManager::destroyElement( const OUString& aName )
1502{
1503 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::destroyElement" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::destroyElement"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1503" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::destroyElement"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::destroyElement"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1503" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::destroyElement"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1503" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::destroyElement"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::destroyElement"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1503" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1504
1505 bool bMustBeLayouted(false);
1506 bool bNotify(false);
1507 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1508 {
1509 SolarMutexClearableGuard aWriteLock;
1510
1511 OUString aElementType;
1512 OUString aElementName;
1513
1514 parseResourceURL(aName, aElementType, aElementName);
1515
1516 if (aElementType.equalsIgnoreAsciiCase("menubar")
1517 && aElementName.equalsIgnoreAsciiCase("menubar"))
1518 {
1519 if (!m_bInplaceMenuSet)
1520 {
1521 impl_clearUpMenuBar();
1522 m_xMenuBar.clear();
1523 bNotify = true;
1524 }
1525 }
1526 else if ((aElementType.equalsIgnoreAsciiCase("statusbar")
1527 && aElementName.equalsIgnoreAsciiCase("statusbar"))
1528 || (m_aStatusBarElement.m_aName == aName))
1529 {
1530 aWriteLock.clear();
1531 implts_destroyStatusBar();
1532 bMustBeLayouted = true;
1533 bNotify = true;
1534 }
1535 else if (aElementType.equalsIgnoreAsciiCase("progressbar")
1536 && aElementName.equalsIgnoreAsciiCase("progressbar"))
1537 {
1538 aWriteLock.clear();
1539 implts_createProgressBar();
1540 bMustBeLayouted = true;
1541 bNotify = true;
1542 }
1543 else if (aElementType.equalsIgnoreAsciiCase(UIRESOURCETYPE_TOOLBAR"toolbar")
1544 && m_xToolbarManager.is())
1545 {
1546 aWriteLock.clear();
1547 bNotify = m_xToolbarManager->destroyToolbar(aName);
1548 bMustBeLayouted = m_xToolbarManager->isLayoutDirty();
1549 }
1550 else if (aElementType.equalsIgnoreAsciiCase("dockingwindow"))
1551 {
1552 uno::Reference<frame::XFrame> xFrame(m_xFrame);
1553 uno::Reference<XComponentContext> xContext(m_xContext);
1554 aWriteLock.clear();
1555
1556 impl_setDockingWindowVisibility(xContext, xFrame, aElementName, false);
1557 bMustBeLayouted = false;
1558 bNotify = false;
1559 }
1560 }
1561 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1562
1563 if ( bMustBeLayouted )
1564 doLayout();
1565
1566 if ( bNotify )
1567 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::makeAny( aName ) );
1568}
1569
1570sal_Bool SAL_CALL LayoutManager::requestElement( const OUString& rResourceURL )
1571{
1572 bool bResult( false );
1573 bool bNotify( false );
1574 OUString aElementType;
1575 OUString aElementName;
1576
1577 parseResourceURL( rResourceURL, aElementType, aElementName );
1578
1579 SolarMutexClearableGuard aWriteLock;
1580
1581 OString aResName = OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
1582 SAL_INFO( "fwk", "framework (cd100003) Element " << aResName << " requested." )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) Element " << aResName
<< " requested.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1582" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) Element " <<
aResName << " requested."), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "framework (cd100003) Element "
<< aResName << " requested."; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1582" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) Element " << aResName
<< " requested.") == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1582" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) Element " <<
aResName << " requested."), 0); } else { ::std::ostringstream
sal_detail_stream; sal_detail_stream << "framework (cd100003) Element "
<< aResName << " requested."; ::sal::detail::log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1582" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1583
1584 if (( aElementType.equalsIgnoreAsciiCase("statusbar") &&
1585 aElementName.equalsIgnoreAsciiCase("statusbar") ) ||
1586 ( m_aStatusBarElement.m_aName == rResourceURL ))
1587 {
1588 implts_readStatusBarState( rResourceURL );
1589 if ( m_aStatusBarElement.m_bVisible && !m_aStatusBarElement.m_bMasterHide )
1590 {
1591 aWriteLock.clear();
1592 createElement( rResourceURL );
1593
1594 // There are some situation where we are not able to create an element.
1595 // Therefore we have to check the reference before further action.
1596 // See #i70019#
1597 uno::Reference< ui::XUIElement > xUIElement( m_aStatusBarElement.m_xUIElement );
1598 if ( xUIElement.is() )
1599 {
1600 // we need VCL here to pass special flags to Show()
1601 SolarMutexGuard aGuard;
1602 Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
1603 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
1604 if ( pWindow )
1605 {
1606 pWindow->Show( true, ShowFlags::NoFocusChange | ShowFlags::NoActivate );
1607 bResult = true;
1608 bNotify = true;
1609 }
1610 }
1611 }
1612 }
1613 else if ( aElementType.equalsIgnoreAsciiCase("progressbar") &&
1614 aElementName.equalsIgnoreAsciiCase("progressbar") )
1615 {
1616 aWriteLock.clear();
1617 implts_showProgressBar();
1618 bResult = true;
1619 bNotify = true;
1620 }
1621 else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ) && m_bVisible )
1622 {
1623 bool bComponentAttached( !m_aModuleIdentifier.isEmpty() );
1624 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1625 aWriteLock.clear();
1626
1627 if ( pToolbarManager && bComponentAttached )
1628 {
1629 bNotify = pToolbarManager->requestToolbar( rResourceURL );
1630 }
1631 }
1632 else if ( aElementType.equalsIgnoreAsciiCase("dockingwindow"))
1633 {
1634 uno::Reference< frame::XFrame > xFrame( m_xFrame );
1635 aWriteLock.clear();
1636
1637 CreateDockingWindow( xFrame, aElementName );
1638 }
1639
1640 if ( bNotify )
1641 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( rResourceURL ) );
1642
1643 return bResult;
1644}
1645
1646Reference< XUIElement > SAL_CALL LayoutManager::getElement( const OUString& aName )
1647{
1648 Reference< XUIElement > xUIElement = implts_findElement( aName );
1649 if ( !xUIElement.is() )
1650 {
1651 SolarMutexClearableGuard aReadLock;
1652 ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() );
1653 aReadLock.clear();
1654
1655 if ( pToolbarManager )
1656 xUIElement = pToolbarManager->getToolbar( aName );
1657 }
1658
1659 return xUIElement;
1660}
1661
1662Sequence< Reference< ui::XUIElement > > SAL_CALL LayoutManager::getElements()
1663{
1664 SolarMutexClearableGuard aReadLock;
1665 uno::Reference< ui::XUIElement > xMenuBar( m_xMenuBar );
1666 uno::Reference< ui::XUIElement > xStatusBar( m_aStatusBarElement.m_xUIElement );
1667 ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() );
1668 aReadLock.clear();
1669
1670 Sequence< Reference< ui::XUIElement > > aSeq;
1671 if ( pToolbarManager )
1672 aSeq = pToolbarManager->getToolbars();
1673
1674 sal_Int32 nSize = aSeq.getLength();
1675 sal_Int32 nMenuBarIndex(-1);
1676 sal_Int32 nStatusBarIndex(-1);
1677 if ( xMenuBar.is() )
1678 {
1679 nMenuBarIndex = nSize;
1680 ++nSize;
1681 }
1682 if ( xStatusBar.is() )
1683 {
1684 nStatusBarIndex = nSize;
1685 ++nSize;
1686 }
1687
1688 aSeq.realloc(nSize);
1689 if ( nMenuBarIndex >= 0 )
1690 aSeq[nMenuBarIndex] = xMenuBar;
1691 if ( nStatusBarIndex >= 0 )
1692 aSeq[nStatusBarIndex] = xStatusBar;
1693
1694 return aSeq;
1695}
1696
1697sal_Bool SAL_CALL LayoutManager::showElement( const OUString& aName )
1698{
1699 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::showElement" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::showElement"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1699" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::showElement"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::showElement"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1699" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::showElement"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1699" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::showElement"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::showElement"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1699" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1700
1701 bool bResult( false );
1702 bool bNotify( false );
1703 bool bMustLayout( false );
1704 OUString aElementType;
1705 OUString aElementName;
1706
1707 parseResourceURL( aName, aElementType, aElementName );
1708
1709 OString aResName = OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
1710 SAL_INFO( "fwk", "framework (cd100003) Element " << aResName )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) Element " << aResName
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1710" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) Element " <<
aResName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "framework (cd100003) Element " <<
aResName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1710" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) Element " << aResName
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1710" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) Element " <<
aResName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "framework (cd100003) Element " <<
aResName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1710" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1711
1712 if ( aElementType.equalsIgnoreAsciiCase("menubar") &&
1713 aElementName.equalsIgnoreAsciiCase("menubar") )
1714 {
1715 {
1716 SolarMutexGuard aWriteLock;
1717 m_bMenuVisible = true;
1718 }
1719
1720 bResult = implts_resetMenuBar();
1721 bNotify = bResult;
1722 }
1723 else if (( aElementType.equalsIgnoreAsciiCase("statusbar") &&
1724 aElementName.equalsIgnoreAsciiCase("statusbar") ) ||
1725 ( m_aStatusBarElement.m_aName == aName ))
1726 {
1727 SolarMutexClearableGuard aWriteLock;
1728 if ( m_aStatusBarElement.m_xUIElement.is() && !m_aStatusBarElement.m_bMasterHide &&
1729 implts_showStatusBar( true ))
1730 {
1731 aWriteLock.clear();
1732
1733 implts_writeWindowStateData( STATUS_BAR_ALIAS, m_aStatusBarElement );
1734 bMustLayout = true;
1735 bResult = true;
1736 bNotify = true;
1737 }
1738 }
1739 else if ( aElementType.equalsIgnoreAsciiCase("progressbar") &&
1740 aElementName.equalsIgnoreAsciiCase("progressbar") )
1741 {
1742 bNotify = bResult = implts_showProgressBar();
1743 }
1744 else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1745 {
1746 SolarMutexClearableGuard aReadLock;
1747 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1748 aReadLock.clear();
1749
1750 if ( pToolbarManager )
1751 {
1752 bNotify = pToolbarManager->showToolbar( aName );
1753 bMustLayout = pToolbarManager->isLayoutDirty();
1754 }
1755 }
1756 else if ( aElementType.equalsIgnoreAsciiCase("dockingwindow"))
1757 {
1758 SolarMutexClearableGuard aReadGuard;
1759 uno::Reference< frame::XFrame > xFrame( m_xFrame );
1760 uno::Reference< XComponentContext > xContext( m_xContext );
1761 aReadGuard.clear();
1762
1763 impl_setDockingWindowVisibility( xContext, xFrame, aElementName, true );
1764 }
1765
1766 if ( bMustLayout )
1767 doLayout();
1768
1769 if ( bNotify )
1770 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( aName ) );
1771
1772 return bResult;
1773}
1774
1775sal_Bool SAL_CALL LayoutManager::hideElement( const OUString& aName )
1776{
1777 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::hideElement" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::hideElement"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1777" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::hideElement"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::hideElement"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1777" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::hideElement"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1777" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::hideElement"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::hideElement"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1777" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1778
1779 bool bNotify( false );
1780 bool bMustLayout( false );
1781 OUString aElementType;
1782 OUString aElementName;
1783
1784 parseResourceURL( aName, aElementType, aElementName );
1785 OString aResName = OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
1786 SAL_INFO( "fwk", "framework (cd100003) Element " << aResName )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) Element " << aResName
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1786" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) Element " <<
aResName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "framework (cd100003) Element " <<
aResName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1786" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) Element " << aResName
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1786" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) Element " <<
aResName), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "framework (cd100003) Element " <<
aResName; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO),
("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "1786" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
1787
1788 if ( aElementType.equalsIgnoreAsciiCase("menubar") &&
1789 aElementName.equalsIgnoreAsciiCase("menubar") )
1790 {
1791 SolarMutexGuard g;
1792
1793 if ( m_xContainerWindow.is() )
1794 {
1795 m_bMenuVisible = false;
1796
1797 SolarMutexGuard aGuard;
1798 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
1799 if ( pSysWindow )
1800 {
1801 MenuBar* pMenuBar = pSysWindow->GetMenuBar();
1802 if ( pMenuBar )
1803 {
1804 pMenuBar->SetDisplayable( false );
1805 bNotify = true;
1806 }
1807 }
1808 }
1809 }
1810 else if (( aElementType.equalsIgnoreAsciiCase("statusbar") &&
1811 aElementName.equalsIgnoreAsciiCase("statusbar") ) ||
1812 ( m_aStatusBarElement.m_aName == aName ))
1813 {
1814 SolarMutexGuard g;
1815 if ( m_aStatusBarElement.m_xUIElement.is() && !m_aStatusBarElement.m_bMasterHide &&
1816 implts_hideStatusBar( true ))
1817 {
1818 implts_writeWindowStateData( STATUS_BAR_ALIAS, m_aStatusBarElement );
1819 bMustLayout = true;
1820 bNotify = true;
1821 }
1822 }
1823 else if ( aElementType.equalsIgnoreAsciiCase("progressbar") &&
1824 aElementName.equalsIgnoreAsciiCase("progressbar") )
1825 {
1826 bNotify = implts_hideProgressBar();
1827 }
1828 else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1829 {
1830 SolarMutexClearableGuard aReadLock;
1831 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1832 aReadLock.clear();
1833
1834 if ( pToolbarManager )
1835 {
1836 bNotify = pToolbarManager->hideToolbar( aName );
1837 bMustLayout = pToolbarManager->isLayoutDirty();
1838 }
1839 }
1840 else if ( aElementType.equalsIgnoreAsciiCase("dockingwindow"))
1841 {
1842 SolarMutexClearableGuard aReadGuard;
1843 uno::Reference< frame::XFrame > xFrame( m_xFrame );
1844 uno::Reference< XComponentContext > xContext( m_xContext );
1845 aReadGuard.clear();
1846
1847 impl_setDockingWindowVisibility( xContext, xFrame, aElementName, false );
1848 }
1849
1850 if ( bMustLayout )
1851 doLayout();
1852
1853 if ( bNotify )
1854 implts_notifyListeners( frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::makeAny( aName ) );
1855
1856 return false;
1857}
1858
1859sal_Bool SAL_CALL LayoutManager::dockWindow( const OUString& aName, DockingArea DockingArea, const awt::Point& Pos )
1860{
1861 OUString aElementType;
1862 OUString aElementName;
1863
1864 parseResourceURL( aName, aElementType, aElementName );
1865 if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1866 {
1867 SolarMutexClearableGuard aReadLock;
1868 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1869 aReadLock.clear();
1870
1871 if ( pToolbarManager )
1872 {
1873 pToolbarManager->dockToolbar( aName, DockingArea, Pos );
1874 if ( pToolbarManager->isLayoutDirty() )
1875 doLayout();
1876 }
1877 }
1878 return false;
1879}
1880
1881sal_Bool SAL_CALL LayoutManager::dockAllWindows( ::sal_Int16 /*nElementType*/ )
1882{
1883 SolarMutexClearableGuard aReadLock;
1884 bool bResult( false );
1885 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1886 aReadLock.clear();
1887
1888 if ( pToolbarManager )
1889 {
1890 bResult = pToolbarManager->dockAllToolbars();
1891 if ( pToolbarManager->isLayoutDirty() )
1892 doLayout();
1893 }
1894 return bResult;
1895}
1896
1897sal_Bool SAL_CALL LayoutManager::floatWindow( const OUString& aName )
1898{
1899 bool bResult( false );
1900 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1901 {
1902 SolarMutexClearableGuard aReadLock;
1903 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1904 aReadLock.clear();
1905
1906 if ( pToolbarManager )
1907 {
1908 bResult = pToolbarManager->floatToolbar( aName );
1909 if ( pToolbarManager->isLayoutDirty() )
1910 doLayout();
1911 }
1912 }
1913 return bResult;
1914}
1915
1916sal_Bool SAL_CALL LayoutManager::lockWindow( const OUString& aName )
1917{
1918 bool bResult( false );
1919 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1920 {
1921 SolarMutexClearableGuard aReadLock;
1922 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1923 aReadLock.clear();
1924
1925 if ( pToolbarManager )
1926 {
1927 bResult = pToolbarManager->lockToolbar( aName );
1928 if ( pToolbarManager->isLayoutDirty() )
1929 doLayout();
1930 }
1931 }
1932 return bResult;
1933}
1934
1935sal_Bool SAL_CALL LayoutManager::unlockWindow( const OUString& aName )
1936{
1937 bool bResult( false );
1938 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1939 {
1940 SolarMutexClearableGuard aReadLock;
1941 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1942 aReadLock.clear();
1943
1944 if ( pToolbarManager )
1945 {
1946 bResult = pToolbarManager->unlockToolbar( aName );
1947 if ( pToolbarManager->isLayoutDirty() )
1948 doLayout();
1949 }
1950 }
1951 return bResult;
1952}
1953
1954void SAL_CALL LayoutManager::setElementSize( const OUString& aName, const awt::Size& aSize )
1955{
1956 if ( !getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1957 return;
1958
1959 SolarMutexClearableGuard aReadLock;
1960 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
1961 aReadLock.clear();
1962
1963 if ( pToolbarManager )
1964 {
1965 pToolbarManager->setToolbarSize( aName, aSize );
1966 if ( pToolbarManager->isLayoutDirty() )
1967 doLayout();
1968 }
1969}
1970
1971void SAL_CALL LayoutManager::setElementPos( const OUString& aName, const awt::Point& aPos )
1972{
1973 if ( !getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1974 return;
1975
1976 SolarMutexClearableGuard aReadLock;
1977 ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() );
1978 aReadLock.clear();
1979
1980 if ( pToolbarManager )
1981 {
1982 pToolbarManager->setToolbarPos( aName, aPos );
1983 if ( pToolbarManager->isLayoutDirty() )
1984 doLayout();
1985 }
1986}
1987
1988void SAL_CALL LayoutManager::setElementPosSize( const OUString& aName, const awt::Point& aPos, const awt::Size& aSize )
1989{
1990 if ( !getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
1991 return;
1992
1993 SolarMutexClearableGuard aReadLock;
1994 ToolbarLayoutManager* pToolbarManager( m_xToolbarManager.get() );
1995 aReadLock.clear();
1996
1997 if ( pToolbarManager )
1998 {
1999 pToolbarManager->setToolbarPosSize( aName, aPos, aSize );
2000 if ( pToolbarManager->isLayoutDirty() )
2001 doLayout();
2002 }
2003}
2004
2005sal_Bool SAL_CALL LayoutManager::isElementVisible( const OUString& aName )
2006{
2007 OUString aElementType;
2008 OUString aElementName;
2009
2010 parseResourceURL( aName, aElementType, aElementName );
2011 if ( aElementType.equalsIgnoreAsciiCase("menubar") &&
2012 aElementName.equalsIgnoreAsciiCase("menubar") )
2013 {
2014 SolarMutexResettableGuard aReadLock;
2015 if ( m_xContainerWindow.is() )
2016 {
2017 aReadLock.clear();
2018
2019 SolarMutexGuard aGuard;
2020 SystemWindow* pSysWindow = getTopSystemWindow( m_xContainerWindow );
2021 if ( pSysWindow )
2022 {
2023 MenuBar* pMenuBar = pSysWindow->GetMenuBar();
2024 if ( pMenuBar && pMenuBar->IsDisplayable() )
2025 return true;
2026 }
2027 else
2028 {
2029 aReadLock.reset();
2030 return m_bMenuVisible;
2031 }
2032 }
2033 }
2034 else if (( aElementType.equalsIgnoreAsciiCase("statusbar") &&
2035 aElementName.equalsIgnoreAsciiCase("statusbar") ) ||
2036 ( m_aStatusBarElement.m_aName == aName ))
2037 {
2038 if ( m_aStatusBarElement.m_xUIElement.is() )
2039 {
2040 Reference< awt::XWindow > xWindow( m_aStatusBarElement.m_xUIElement->getRealInterface(), UNO_QUERY );
2041 if ( xWindow.is() )
2042 {
2043 SolarMutexGuard g;
2044 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
2045 if ( pWindow && pWindow->IsVisible() )
2046 return true;
2047 else
2048 return false;
2049 }
2050 }
2051 }
2052 else if ( aElementType.equalsIgnoreAsciiCase("progressbar") &&
2053 aElementName.equalsIgnoreAsciiCase("progressbar") )
2054 {
2055 if ( m_aProgressBarElement.m_xUIElement.is() )
2056 return m_aProgressBarElement.m_bVisible;
2057 }
2058 else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2059 {
2060 SolarMutexClearableGuard aReadLock;
2061 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
2062 aReadLock.clear();
2063
2064 if ( pToolbarManager )
2065 return pToolbarManager->isToolbarVisible( aName );
2066 }
2067 else if ( aElementType.equalsIgnoreAsciiCase("dockingwindow"))
2068 {
2069 SolarMutexClearableGuard aReadGuard;
2070 uno::Reference< frame::XFrame > xFrame( m_xFrame );
2071 aReadGuard.clear();
2072
2073 return IsDockingWindowVisible( xFrame, aElementName );
2074 }
2075
2076 return false;
2077}
2078
2079sal_Bool SAL_CALL LayoutManager::isElementFloating( const OUString& aName )
2080{
2081 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2082 {
2083 SolarMutexClearableGuard aReadLock;
2084 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
2085 aReadLock.clear();
2086
2087 if ( pToolbarManager )
2088 return pToolbarManager->isToolbarFloating( aName );
2089 }
2090
2091 return false;
2092}
2093
2094sal_Bool SAL_CALL LayoutManager::isElementDocked( const OUString& aName )
2095{
2096 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2097 {
2098 SolarMutexClearableGuard aReadLock;
2099 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
2100 aReadLock.clear();
2101
2102 if ( pToolbarManager )
2103 return pToolbarManager->isToolbarDocked( aName );
2104 }
2105
2106 return false;
2107}
2108
2109sal_Bool SAL_CALL LayoutManager::isElementLocked( const OUString& aName )
2110{
2111 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2112 {
2113 SolarMutexClearableGuard aReadLock;
2114 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
2115 aReadLock.clear();
2116
2117 if ( pToolbarManager )
2118 return pToolbarManager->isToolbarLocked( aName );
2119 }
2120
2121 return false;
2122}
2123
2124awt::Size SAL_CALL LayoutManager::getElementSize( const OUString& aName )
2125{
2126 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2127 {
2128 SolarMutexClearableGuard aReadLock;
2129 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
2130 aReadLock.clear();
2131
2132 if ( pToolbarManager )
2133 return pToolbarManager->getToolbarSize( aName );
2134 }
2135
2136 return awt::Size();
2137}
2138
2139awt::Point SAL_CALL LayoutManager::getElementPos( const OUString& aName )
2140{
2141 if ( getElementTypeFromResourceURL( aName ).equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2142 {
2143 SolarMutexClearableGuard aReadLock;
2144 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
2145 aReadLock.clear();
2146
2147 if ( pToolbarManager )
2148 return pToolbarManager->getToolbarPos( aName );
2149 }
2150
2151 return awt::Point();
2152}
2153
2154void SAL_CALL LayoutManager::lock()
2155{
2156 implts_lock();
2157
2158 SolarMutexClearableGuard aReadLock;
2159 sal_Int32 nLockCount( m_nLockCount );
2160 aReadLock.clear();
2161
2162 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::lock lockCount=" << nLockCount )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::lock lockCount="
<< nLockCount) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2162" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::lock lockCount="
<< nLockCount), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "framework (cd100003) ::LayoutManager::lock lockCount="
<< nLockCount; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2162" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::lock lockCount="
<< nLockCount) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2162" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::lock lockCount="
<< nLockCount), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "framework (cd100003) ::LayoutManager::lock lockCount="
<< nLockCount; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2162" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2163#ifdef DBG_UTIL
2164 SAL_INFO( "fwk", "LayoutManager::lock " << reinterpret_cast<sal_Int64>(this) << " - " << nLockCount )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "LayoutManager::lock " << reinterpret_cast<
sal_Int64>(this) << " - " << nLockCount) == 1)
{ ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"), (
"/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2164" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "LayoutManager::lock " << reinterpret_cast
<sal_Int64>(this) << " - " << nLockCount), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "LayoutManager::lock " << reinterpret_cast<
sal_Int64>(this) << " - " << nLockCount; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2164" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "LayoutManager::lock " << reinterpret_cast<
sal_Int64>(this) << " - " << nLockCount) == 1)
{ ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"), (
"/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2164" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "LayoutManager::lock " << reinterpret_cast
<sal_Int64>(this) << " - " << nLockCount), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "LayoutManager::lock " << reinterpret_cast<
sal_Int64>(this) << " - " << nLockCount; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2164" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2165#endif
2166
2167 Any a( nLockCount );
2168 implts_notifyListeners( frame::LayoutManagerEvents::LOCK, a );
2169}
2170
2171void SAL_CALL LayoutManager::unlock()
2172{
2173 bool bDoLayout( implts_unlock() );
2174
2175 SolarMutexClearableGuard aReadLock;
2176 sal_Int32 nLockCount( m_nLockCount );
2177 aReadLock.clear();
2178
2179 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::unlock lockCount=" << nLockCount )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::unlock lockCount="
<< nLockCount) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2179" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::unlock lockCount="
<< nLockCount), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "framework (cd100003) ::LayoutManager::unlock lockCount="
<< nLockCount; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2179" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::unlock lockCount="
<< nLockCount) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2179" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::unlock lockCount="
<< nLockCount), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "framework (cd100003) ::LayoutManager::unlock lockCount="
<< nLockCount; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2179" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2180#ifdef DBG_UTIL
2181 SAL_INFO( "fwk", "LayoutManager::unlock " << reinterpret_cast<sal_Int64>(this) << " - " << nLockCount)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "LayoutManager::unlock " << reinterpret_cast
<sal_Int64>(this) << " - " << nLockCount) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2181" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "LayoutManager::unlock " << reinterpret_cast
<sal_Int64>(this) << " - " << nLockCount), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "LayoutManager::unlock " << reinterpret_cast<
sal_Int64>(this) << " - " << nLockCount; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2181" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "LayoutManager::unlock " << reinterpret_cast
<sal_Int64>(this) << " - " << nLockCount) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2181" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "LayoutManager::unlock " << reinterpret_cast
<sal_Int64>(this) << " - " << nLockCount), 0
); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "LayoutManager::unlock " << reinterpret_cast<
sal_Int64>(this) << " - " << nLockCount; ::sal
::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2181" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2182#endif
2183 // conform to documentation: unlock with lock count == 0 means force a layout
2184
2185 {
2186 SolarMutexGuard aWriteLock;
2187 if (bDoLayout)
2188 m_aAsyncLayoutTimer.Stop();
2189 }
2190
2191 Any a( nLockCount );
2192 implts_notifyListeners( frame::LayoutManagerEvents::UNLOCK, a );
2193
2194 if ( bDoLayout )
2195 implts_doLayout_notify( true );
2196}
2197
2198void SAL_CALL LayoutManager::doLayout()
2199{
2200 implts_doLayout_notify( true );
2201}
2202
2203// ILayoutNotifications
2204
2205void LayoutManager::requestLayout()
2206{
2207 doLayout();
2208}
2209
2210void LayoutManager::implts_doLayout_notify( bool bOuterResize )
2211{
2212 bool bLayouted = implts_doLayout( false, bOuterResize );
2213 if ( bLayouted )
2214 implts_notifyListeners( frame::LayoutManagerEvents::LAYOUT, Any() );
2215}
2216
2217bool LayoutManager::implts_doLayout( bool bForceRequestBorderSpace, bool bOuterResize )
2218{
2219 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::implts_doLayout" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::implts_doLayout"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2219" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::implts_doLayout"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::implts_doLayout"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2219" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::implts_doLayout"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2219" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::implts_doLayout"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::implts_doLayout"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2219" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2220
2221 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2222 SolarMutexClearableGuard aReadLock;
2223
2224 if ( !m_xFrame.is() || !m_bParentWindowVisible )
2225 return false;
2226
2227 bool bPreserveContentSize( m_bPreserveContentSize );
2228 bool bMustDoLayout( m_bMustDoLayout );
2229 bool bNoLock = ( m_nLockCount == 0 );
2230 awt::Rectangle aCurrBorderSpace( m_aDockingArea );
2231 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2232 Reference< awt::XTopWindow2 > xContainerTopWindow( m_xContainerTopWindow );
2233 Reference< awt::XWindow > xComponentWindow;
2234 try {
2235 xComponentWindow = m_xFrame->getComponentWindow();
2236 } catch (css::lang::DisposedException &) {
2237 // There can be a race between one thread calling Frame::dispose
2238 // (framework/source/services/frame.cxx) -> Frame::disableLayoutManager
2239 // -> LayoutManager::attachFrame(null) setting m_xFrame to null, and
2240 // the main thread firing the timer-triggered
2241 // LayoutManager::AsyncLayoutHdl -> LayoutManager::implts_doLayout and
2242 // calling into the in-dispose m_xFrame here, so silently ignore a
2243 // DisposedException here:
2244 return false;
2245 }
2246 Reference< XDockingAreaAcceptor > xDockingAreaAcceptor( m_xDockingAreaAcceptor );
2247 aReadLock.clear();
2248 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2249
2250 bool bLayouted( false );
2251
2252 if ( bNoLock && xDockingAreaAcceptor.is() && xContainerWindow.is() && xComponentWindow.is() )
2253 {
2254 bLayouted = true;
2255
2256 awt::Rectangle aDockSpace( implts_calcDockingAreaSizes() );
2257 awt::Rectangle aBorderSpace( aDockSpace );
2258 bool bGotRequestedBorderSpace( true );
2259
2260 // We have to add the height of a possible status bar
2261 aBorderSpace.Height += implts_getStatusBarSize().Height();
2262
2263 if ( !equalRectangles( aBorderSpace, aCurrBorderSpace ) || bForceRequestBorderSpace || bMustDoLayout )
2264 {
2265 // we always resize the content window (instead of the complete container window) if we're not set up
2266 // to (attempt to) preserve the content window's size
2267 if ( bOuterResize && !bPreserveContentSize )
2268 bOuterResize = false;
2269
2270 // maximized windows can resized their content window only, not their container window
2271 if ( bOuterResize && xContainerTopWindow.is() && xContainerTopWindow->getIsMaximized() )
2272 bOuterResize = false;
2273
2274 // if the component window does not have a size (yet), then we can't use it to calc the container
2275 // window size
2276 awt::Rectangle aComponentRect = xComponentWindow->getPosSize();
2277 if ( bOuterResize && ( aComponentRect.Width == 0 ) && ( aComponentRect.Height == 0 ) )
2278 bOuterResize = false;
2279
2280 bGotRequestedBorderSpace = false;
2281 if ( bOuterResize )
2282 {
2283 Reference< awt::XDevice > xDevice( xContainerWindow, uno::UNO_QUERY );
2284 awt::DeviceInfo aContainerInfo = xDevice->getInfo();
2285
2286 awt::Size aRequestedSize( aComponentRect.Width + aContainerInfo.LeftInset + aContainerInfo.RightInset + aBorderSpace.X + aBorderSpace.Width,
2287 aComponentRect.Height + aContainerInfo.TopInset + aContainerInfo.BottomInset + aBorderSpace.Y + aBorderSpace.Height );
2288 awt::Point aComponentPos( aBorderSpace.X, aBorderSpace.Y );
2289
2290 bGotRequestedBorderSpace = implts_resizeContainerWindow( aRequestedSize, aComponentPos );
2291 }
2292
2293 // if we did not do a container window resize, or it failed, then use the DockingAcceptor as usual
2294 if ( !bGotRequestedBorderSpace )
2295 bGotRequestedBorderSpace = xDockingAreaAcceptor->requestDockingAreaSpace( aBorderSpace );
2296
2297 if ( bGotRequestedBorderSpace )
2298 {
2299 SolarMutexGuard aWriteGuard;
2300 m_aDockingArea = aBorderSpace;
2301 m_bMustDoLayout = false;
2302 }
2303 }
2304
2305 if ( bGotRequestedBorderSpace )
2306 {
2307 ::Size aContainerSize;
2308 ::Size aStatusBarSize;
2309
2310 // Interim solution to let the layout method within the
2311 // toolbar layout manager.
2312 implts_setOffset( implts_getStatusBarSize().Height() );
2313 if ( m_xToolbarManager.is() )
2314 m_xToolbarManager->setDockingArea( aDockSpace );
2315
2316 // Subtract status bar size from our container output size. Docking area windows
2317 // don't contain the status bar!
2318 aStatusBarSize = implts_getStatusBarSize();
2319 aContainerSize = implts_getContainerWindowOutputSize();
2320 aContainerSize.AdjustHeight( -(aStatusBarSize.Height()) );
2321
2322 if ( m_xToolbarManager.is() )
2323 m_xToolbarManager->doLayout(aContainerSize);
2324
2325 // Position the status bar
2326 if ( aStatusBarSize.Height() > 0 )
2327 {
2328 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerSize.Height() ), long( 0 ))),
2329 ::Size( aContainerSize.Width(),aStatusBarSize.Height() ));
2330 }
2331
2332 xDockingAreaAcceptor->setDockingAreaSpace( aBorderSpace );
2333 }
2334 }
2335
2336 return bLayouted;
2337}
2338
2339bool LayoutManager::implts_resizeContainerWindow( const awt::Size& rContainerSize,
2340 const awt::Point& rComponentPos )
2341{
2342 SolarMutexClearableGuard aReadLock;
2343 Reference< awt::XWindow > xContainerWindow = m_xContainerWindow;
2344 Reference< awt::XTopWindow2 > xContainerTopWindow = m_xContainerTopWindow;
2345 Reference< awt::XWindow > xComponentWindow = m_xFrame->getComponentWindow();
2346 aReadLock.clear();
2347
2348 // calculate the maximum size we have for the container window
2349 sal_Int32 nDisplay = xContainerTopWindow->getDisplay();
2350 tools::Rectangle aWorkArea = Application::GetScreenPosSizePixel( nDisplay );
2351
2352 if (!aWorkArea.IsEmpty())
2353 {
2354 if (( rContainerSize.Width > aWorkArea.GetWidth() ) || ( rContainerSize.Height > aWorkArea.GetHeight() ))
2355 return false;
2356 // Strictly, this is not correct. If we have a multi-screen display (css.awt.DisplayAccess.MultiDisplay == true),
2357 // the "effective work area" would be much larger than the work area of a single display, since we could in theory
2358 // position the container window across multiple screens.
2359 // However, this should suffice as a heuristics here ... (nobody really wants to check whether the different screens are
2360 // stacked horizontally or vertically, whether their work areas can really be combined, or are separated by non-work-areas,
2361 // and the like ... right?)
2362 }
2363
2364 // resize our container window
2365 xContainerWindow->setPosSize( 0, 0, rContainerSize.Width, rContainerSize.Height, awt::PosSize::SIZE );
2366 // position the component window
2367 xComponentWindow->setPosSize( rComponentPos.X, rComponentPos.Y, 0, 0, awt::PosSize::POS );
2368 return true;
2369}
2370
2371void SAL_CALL LayoutManager::setVisible( sal_Bool bVisible )
2372{
2373 SolarMutexClearableGuard aWriteLock;
2374 bool bWasVisible( m_bVisible );
2375 m_bVisible = bVisible;
2376 aWriteLock.clear();
2377
2378 if ( bWasVisible != bool(bVisible) )
2379 implts_setVisibleState( bVisible );
2380}
2381
2382sal_Bool SAL_CALL LayoutManager::isVisible()
2383{
2384 SolarMutexGuard g;
2385 return m_bVisible;
2386}
2387
2388::Size LayoutManager::implts_getStatusBarSize()
2389{
2390 SolarMutexClearableGuard aReadLock;
2391 bool bStatusBarVisible( isElementVisible( STATUS_BAR_ALIAS ));
2392 bool bProgressBarVisible( isElementVisible( "private:resource/progressbar/progressbar" ));
2393 bool bVisible( m_bVisible );
2394 Reference< XUIElement > xStatusBar( m_aStatusBarElement.m_xUIElement );
2395 Reference< XUIElement > xProgressBar( m_aProgressBarElement.m_xUIElement );
2396
2397 Reference< awt::XWindow > xWindow;
2398 if ( bStatusBarVisible && bVisible && xStatusBar.is() )
2399 xWindow.set( xStatusBar->getRealInterface(), UNO_QUERY );
2400 else if ( xProgressBar.is() && !xStatusBar.is() && bProgressBarVisible )
2401 {
2402 ProgressBarWrapper* pWrapper = static_cast<ProgressBarWrapper*>(xProgressBar.get());
2403 if ( pWrapper )
2404 xWindow = pWrapper->getStatusBar();
2405 }
2406 aReadLock.clear();
2407
2408 if ( xWindow.is() )
2409 {
2410 awt::Rectangle aPosSize = xWindow->getPosSize();
2411 return ::Size( aPosSize.Width, aPosSize.Height );
2412 }
2413 else
2414 return ::Size();
2415}
2416
2417awt::Rectangle LayoutManager::implts_calcDockingAreaSizes()
2418{
2419 SolarMutexClearableGuard aReadLock;
2420 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2421 Reference< XDockingAreaAcceptor > xDockingAreaAcceptor( m_xDockingAreaAcceptor );
2422 aReadLock.clear();
2423
2424 awt::Rectangle aBorderSpace;
2425 if ( m_xToolbarManager.is() && xDockingAreaAcceptor.is() && xContainerWindow.is() )
2426 aBorderSpace = m_xToolbarManager->getDockingArea();
2427
2428 return aBorderSpace;
2429}
2430
2431void LayoutManager::implts_setDockingAreaWindowSizes()
2432{
2433 SolarMutexClearableGuard aReadLock;
2434 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2435 aReadLock.clear();
2436
2437 uno::Reference< awt::XDevice > xDevice( xContainerWindow, uno::UNO_QUERY );
2438 // Convert relative size to output size.
2439 awt::Rectangle aRectangle = xContainerWindow->getPosSize();
2440 awt::DeviceInfo aInfo = xDevice->getInfo();
2441 awt::Size aContainerClientSize( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset,
2442 aRectangle.Height - aInfo.TopInset - aInfo.BottomInset );
2443 ::Size aStatusBarSize = implts_getStatusBarSize();
2444
2445 // Position the status bar
2446 if ( aStatusBarSize.Height() > 0 )
2447 {
2448 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerClientSize.Height - aStatusBarSize.Height() ), long( 0 ))),
2449 ::Size( aContainerClientSize.Width, aStatusBarSize.Height() ));
2450 }
2451}
2452
2453void LayoutManager::implts_updateMenuBarClose()
2454{
2455 SolarMutexClearableGuard aWriteLock;
2456 bool bShowCloseButton( m_bMenuBarCloseButton );
2457 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2458 aWriteLock.clear();
2459
2460 if ( !xContainerWindow.is() )
2461 return;
2462
2463 SolarMutexGuard aGuard;
2464
2465 SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow );
2466 if ( pSysWindow )
2467 {
2468 MenuBar* pMenuBar = pSysWindow->GetMenuBar();
2469 if ( pMenuBar )
2470 {
2471 // TODO remove link on sal_False ?!
2472 pMenuBar->ShowCloseButton(bShowCloseButton);
2473 pMenuBar->SetCloseButtonClickHdl(LINK(this, LayoutManager, MenuBarClose)::tools::detail::makeLink( ::tools::detail::castTo<LayoutManager
*>(this), &LayoutManager::LinkStubMenuBarClose)
);
2474 }
2475 }
2476}
2477
2478bool LayoutManager::implts_resetMenuBar()
2479{
2480 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2481 SolarMutexGuard aWriteLock;
2482 bool bMenuVisible( m_bMenuVisible );
2483 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2484
2485 MenuBar* pSetMenuBar = nullptr;
2486 if ( m_xInplaceMenuBar.is() )
2487 pSetMenuBar = static_cast<MenuBar *>(m_xInplaceMenuBar->GetMenuBar());
2488 else
2489 {
2490 MenuBarWrapper* pMenuBarWrapper = static_cast< MenuBarWrapper* >( m_xMenuBar.get() );
2491 if ( pMenuBarWrapper )
2492 pSetMenuBar = static_cast<MenuBar*>(pMenuBarWrapper->GetMenuBarManager()->GetMenuBar());
2493 }
2494
2495 SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow );
2496 if ( pSysWindow && bMenuVisible && pSetMenuBar )
2497 {
2498 pSysWindow->SetMenuBar(pSetMenuBar);
2499 pSetMenuBar->SetDisplayable( true );
2500 return true;
2501 }
2502
2503 return false;
2504}
2505
2506void LayoutManager::implts_createMSCompatibleMenuBar( const OUString& aName )
2507{
2508 SolarMutexGuard aWriteLock;
2509
2510 // Find Form menu in the original menubar
2511 m_xMenuBar = implts_createElement( aName );
2512 uno::Reference< XUIElementSettings > xMenuBarSettings(m_xMenuBar, UNO_QUERY);
2513 uno::Reference< container::XIndexReplace > xMenuIndex(xMenuBarSettings->getSettings(true), UNO_QUERY);
2514
2515 sal_Int32 nFormsMenu = -1;
2516 for (sal_Int32 nIndex = 0; nIndex < xMenuIndex->getCount(); ++nIndex)
2517 {
2518 uno::Sequence< beans::PropertyValue > aProps;
2519 xMenuIndex->getByIndex( nIndex ) >>= aProps;
2520 OUString aCommand;
2521 for ( beans::PropertyValue const & rProp : std::as_const(aProps) )
2522 {
2523 if (rProp.Name == "CommandURL")
2524 {
2525 rProp.Value >>= aCommand;
2526 break;
2527 }
2528 }
2529
2530 if (aCommand == ".uno:FormatFormMenu")
2531 nFormsMenu = nIndex;
2532 }
2533 assert(nFormsMenu != -1)(static_cast <bool> (nFormsMenu != -1) ? void (0) : __assert_fail
("nFormsMenu != -1", "/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
, 2533, __extension__ __PRETTY_FUNCTION__))
;
2534
2535 // Create the MS compatible Form menu
2536 css::uno::Reference< css::ui::XUIElement > xFormsMenu = implts_createElement( "private:resource/menubar/mscompatibleformsmenu" );
2537 if(!xFormsMenu.is())
2538 return;
2539
2540 // Merge the MS compatible Form menu into the menubar
2541 uno::Reference< XUIElementSettings > xFormsMenuSettings(xFormsMenu, UNO_QUERY);
2542 uno::Reference< container::XIndexAccess > xFormsMenuIndex(xFormsMenuSettings->getSettings(true));
2543
2544 assert(xFormsMenuIndex->getCount() >= 1)(static_cast <bool> (xFormsMenuIndex->getCount() >=
1) ? void (0) : __assert_fail ("xFormsMenuIndex->getCount() >= 1"
, "/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
, 2544, __extension__ __PRETTY_FUNCTION__))
;
2545 uno::Sequence< beans::PropertyValue > aNewFormsMenu;
2546 xFormsMenuIndex->getByIndex( 0 ) >>= aNewFormsMenu;
2547 xMenuIndex->replaceByIndex(nFormsMenu, uno::makeAny(aNewFormsMenu));
2548
2549 setMergedMenuBar( xMenuIndex );
2550
2551 // Clear up the temporal forms menubar
2552 Reference< XComponent > xFormsMenuComp( xFormsMenu, UNO_QUERY );
2553 if ( xFormsMenuComp.is() )
2554 xFormsMenuComp->dispose();
2555 xFormsMenu.clear();
2556}
2557
2558IMPL_LINK_NOARG(LayoutManager, MenuBarClose, void*, void)void LayoutManager::LinkStubMenuBarClose(void * instance, void
* data) { return static_cast<LayoutManager *>(instance)
->MenuBarClose(data); } void LayoutManager::MenuBarClose(__attribute__
((unused)) void*)
2559{
2560 SolarMutexClearableGuard aReadLock;
2561 uno::Reference< frame::XDispatchProvider > xProvider(m_xFrame, uno::UNO_QUERY);
2562 uno::Reference< XComponentContext > xContext( m_xContext );
2563 aReadLock.clear();
2564
2565 if ( !xProvider.is())
2566 return;
2567
2568 uno::Reference< frame::XDispatchHelper > xDispatcher = frame::DispatchHelper::create( xContext );
2569
2570 xDispatcher->executeDispatch(
2571 xProvider,
2572 ".uno:CloseWin",
2573 "_self",
2574 0,
2575 uno::Sequence< beans::PropertyValue >());
2576}
2577
2578// XLayoutManagerEventBroadcaster
2579
2580void SAL_CALL LayoutManager::addLayoutManagerEventListener( const uno::Reference< frame::XLayoutManagerListener >& xListener )
2581{
2582 m_aListenerContainer.addInterface( cppu::UnoType<frame::XLayoutManagerListener>::get(), xListener );
2583}
2584
2585void SAL_CALL LayoutManager::removeLayoutManagerEventListener( const uno::Reference< frame::XLayoutManagerListener >& xListener )
2586{
2587 m_aListenerContainer.removeInterface( cppu::UnoType<frame::XLayoutManagerListener>::get(), xListener );
2588}
2589
2590void LayoutManager::implts_notifyListeners(short nEvent, const uno::Any& rInfoParam)
2591{
2592 lang::EventObject aSource( static_cast< ::cppu::OWeakObject*>(this) );
2593 ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<frame::XLayoutManagerListener>::get());
2594 if (pContainer==nullptr)
2595 return;
2596
2597 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
2598 while (pIterator.hasMoreElements())
2599 {
2600 try
2601 {
2602 static_cast<frame::XLayoutManagerListener*>(pIterator.next())->layoutEvent(aSource, nEvent, rInfoParam);
2603 }
2604 catch( const uno::RuntimeException& )
2605 {
2606 pIterator.remove();
2607 }
2608 }
2609}
2610
2611// XWindowListener
2612
2613void SAL_CALL LayoutManager::windowResized( const awt::WindowEvent& aEvent )
2614{
2615 SolarMutexGuard g;
2616 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2617
2618 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY );
2619 if ( xIfac == aEvent.Source && m_bVisible )
2620 {
2621 // We have to call our resize handler at least once synchronously, as some
2622 // application modules need this. So we have to check if this is the first
2623 // call after the async layout time expired.
2624 m_bMustDoLayout = true;
2625 if ( !m_aAsyncLayoutTimer.IsActive() )
2626 {
2627 m_aAsyncLayoutTimer.Invoke();
2628 if ( m_nLockCount == 0 )
2629 m_aAsyncLayoutTimer.Start();
2630 }
2631 }
2632 else if ( m_xFrame.is() && aEvent.Source == m_xFrame->getContainerWindow() )
2633 {
2634 // the container window of my DockingAreaAcceptor is not the same as of my frame
2635 // I still have to resize my frames' window as nobody else will do it
2636 Reference< awt::XWindow > xComponentWindow( m_xFrame->getComponentWindow() );
2637 if( xComponentWindow.is() )
2638 {
2639 uno::Reference< awt::XDevice > xDevice( m_xFrame->getContainerWindow(), uno::UNO_QUERY );
2640
2641 // Convert relative size to output size.
2642 awt::Rectangle aRectangle = m_xFrame->getContainerWindow()->getPosSize();
2643 awt::DeviceInfo aInfo = xDevice->getInfo();
2644 awt::Size aSize( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset ,
2645 aRectangle.Height - aInfo.TopInset - aInfo.BottomInset );
2646
2647 // Resize our component window.
2648 xComponentWindow->setPosSize( 0, 0, aSize.Width, aSize.Height, awt::PosSize::POSSIZE );
2649 }
2650 }
2651}
2652
2653void SAL_CALL LayoutManager::windowMoved( const awt::WindowEvent& )
2654{
2655}
2656
2657void SAL_CALL LayoutManager::windowShown( const lang::EventObject& aEvent )
2658{
2659 SolarMutexClearableGuard aReadLock;
2660 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2661 bool bParentWindowVisible( m_bParentWindowVisible );
2662 aReadLock.clear();
2663
2664 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY );
2665 if ( xIfac == aEvent.Source )
2666 {
2667 SolarMutexClearableGuard aWriteLock;
2668 m_bParentWindowVisible = true;
2669 bool bSetVisible = ( m_bParentWindowVisible != bParentWindowVisible );
2670 aWriteLock.clear();
2671
2672 if ( bSetVisible )
2673 implts_updateUIElementsVisibleState( true );
2674 }
2675}
2676
2677void SAL_CALL LayoutManager::windowHidden( const lang::EventObject& aEvent )
2678{
2679 SolarMutexClearableGuard aReadLock;
2680 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2681 bool bParentWindowVisible( m_bParentWindowVisible );
2682 aReadLock.clear();
2683
2684 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY );
2685 if ( xIfac == aEvent.Source )
2686 {
2687 SolarMutexClearableGuard aWriteLock;
2688 m_bParentWindowVisible = false;
2689 bool bSetInvisible = ( m_bParentWindowVisible != bParentWindowVisible );
2690 aWriteLock.clear();
2691
2692 if ( bSetInvisible )
2693 implts_updateUIElementsVisibleState( false );
2694 }
2695}
2696
2697IMPL_LINK_NOARG(LayoutManager, AsyncLayoutHdl, Timer *, void)void LayoutManager::LinkStubAsyncLayoutHdl(void * instance, Timer
* data) { return static_cast<LayoutManager *>(instance
)->AsyncLayoutHdl(data); } void LayoutManager::AsyncLayoutHdl
(__attribute__ ((unused)) Timer *)
2698{
2699 {
2700 SolarMutexGuard aReadLock;
2701
2702 if (!m_xContainerWindow.is())
2703 return;
2704 }
2705
2706 implts_setDockingAreaWindowSizes();
2707 implts_doLayout( true, false );
2708}
2709
2710// XFrameActionListener
2711
2712void SAL_CALL LayoutManager::frameAction( const FrameActionEvent& aEvent )
2713{
2714 if (( aEvent.Action == FrameAction_COMPONENT_ATTACHED ) || ( aEvent.Action == FrameAction_COMPONENT_REATTACHED ))
2715 {
2716 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2716" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2716" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2716" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2716" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2717
2718 {
2719 SolarMutexGuard aWriteLock;
2720 m_bMustDoLayout = true;
2721 }
2722
2723 implts_reset( true );
2724 implts_doLayout( true, false );
2725 implts_doLayout( true, true );
2726 }
2727 else if (( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED ) || ( aEvent.Action == FrameAction_FRAME_UI_DEACTIVATING ))
2728 {
2729 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2729" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2729" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2729" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2729" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2730
2731 implts_toggleFloatingUIElementsVisibility( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED );
2732 }
2733 else if ( aEvent.Action == FrameAction_COMPONENT_DETACHING )
2734 {
2735 SAL_INFO( "fwk", "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "fwk")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2735" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2735" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"
), ("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2735" ": "), ::sal::detail::unwrapStream( ::sal::detail
::StreamStart() << "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("fwk"),
("/home/maarten/src/libreoffice/core/framework/source/layoutmanager/layoutmanager.cxx"
":" "2735" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
2736
2737 implts_reset( false );
2738 }
2739}
2740
2741void SAL_CALL LayoutManager::disposing( const lang::EventObject& rEvent )
2742{
2743 bool bDisposeAndClear( false );
2744
2745 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2746 {
2747 SolarMutexGuard aWriteLock;
2748
2749 if (rEvent.Source == Reference<XInterface>(m_xFrame, UNO_QUERY))
2750 {
2751 // Our frame gets disposed, release all our references that depends on a working frame reference.
2752
2753 setDockingAreaAcceptor(Reference<ui::XDockingAreaAcceptor>());
2754
2755 // destroy all elements, it's possible that detaching is NOT called!
2756 implts_destroyElements();
2757 impl_clearUpMenuBar();
2758 m_xMenuBar.clear();
2759 VclPtr<Menu> pMenuBar;
2760 if (m_xInplaceMenuBar.is())
2761 {
2762 pMenuBar = m_xInplaceMenuBar->GetMenuBar();
2763 m_xInplaceMenuBar->dispose();
2764 m_xInplaceMenuBar.clear();
2765 }
2766 pMenuBar.disposeAndClear();
2767 m_xContainerWindow.clear();
2768 m_xContainerTopWindow.clear();
2769
2770 // forward disposing call to toolbar manager
2771 if (m_xToolbarManager.is())
2772 m_xToolbarManager->disposing(rEvent);
2773
2774 if (m_xModuleCfgMgr.is())
2775 {
2776 try
2777 {
2778 Reference<XUIConfiguration> xModuleCfgMgr(m_xModuleCfgMgr, UNO_QUERY);
2779 xModuleCfgMgr->removeConfigurationListener(Reference<XUIConfigurationListener>(
2780 static_cast<OWeakObject*>(this), UNO_QUERY));
2781 }
2782 catch (const Exception&)
2783 {
2784 }
2785 }
2786
2787 if (m_xDocCfgMgr.is())
2788 {
2789 try
2790 {
2791 Reference<XUIConfiguration> xDocCfgMgr(m_xDocCfgMgr, UNO_QUERY);
2792 xDocCfgMgr->removeConfigurationListener(Reference<XUIConfigurationListener>(
2793 static_cast<OWeakObject*>(this), UNO_QUERY));
2794 }
2795 catch (const Exception&)
2796 {
2797 }
2798 }
2799
2800 m_xDocCfgMgr.clear();
2801 m_xModuleCfgMgr.clear();
2802 m_xFrame.clear();
2803 m_pGlobalSettings.reset();
2804
2805 bDisposeAndClear = true;
2806 }
2807 else if (rEvent.Source == Reference<XInterface>(m_xContainerWindow, UNO_QUERY))
2808 {
2809 // Our container window gets disposed. Remove all user interface elements.
2810 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
2811 if (pToolbarManager)
2812 {
2813 uno::Reference<awt::XWindowPeer> aEmptyWindowPeer;
2814 pToolbarManager->setParentWindow(aEmptyWindowPeer);
2815 }
2816 impl_clearUpMenuBar();
2817 m_xMenuBar.clear();
2818 VclPtr<Menu> pMenuBar;
2819 if (m_xInplaceMenuBar.is())
2820 {
2821 pMenuBar = m_xInplaceMenuBar->GetMenuBar();
2822 m_xInplaceMenuBar->dispose();
2823 m_xInplaceMenuBar.clear();
2824 }
2825 pMenuBar.disposeAndClear();
2826 m_xContainerWindow.clear();
2827 m_xContainerTopWindow.clear();
2828 }
2829 else if (rEvent.Source == Reference<XInterface>(m_xDocCfgMgr, UNO_QUERY))
2830 m_xDocCfgMgr.clear();
2831 else if (rEvent.Source == Reference<XInterface>(m_xModuleCfgMgr, UNO_QUERY))
2832 m_xModuleCfgMgr.clear();
2833 }
2834 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2835
2836 // Send disposing to our listener when we have lost our frame.
2837 if ( bDisposeAndClear )
2838 {
2839 // Send message to all listener and forget her references.
2840 uno::Reference< frame::XLayoutManager > xThis( static_cast< ::cppu::OWeakObject* >(this), uno::UNO_QUERY );
2841 lang::EventObject aEvent( xThis );
2842 m_aListenerContainer.disposeAndClear( aEvent );
2843 }
2844}
2845
2846void SAL_CALL LayoutManager::elementInserted( const ui::ConfigurationEvent& Event )
2847{
2848 SolarMutexClearableGuard aReadLock;
2849 Reference< XFrame > xFrame( m_xFrame );
2850 rtl::Reference< ToolbarLayoutManager > xToolbarManager( m_xToolbarManager );
2851 aReadLock.clear();
2852
2853 if ( !xFrame.is() )
2854 return;
2855
2856 OUString aElementType;
2857 OUString aElementName;
2858 bool bRefreshLayout(false);
2859
2860 parseResourceURL( Event.ResourceURL, aElementType, aElementName );
2861 if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2862 {
2863 if ( xToolbarManager.is() )
2864 {
2865 xToolbarManager->elementInserted( Event );
2866 bRefreshLayout = xToolbarManager->isLayoutDirty();
2867 }
2868 }
2869 else if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_MENUBAR"menubar" ))
2870 {
2871 Reference< XUIElement > xUIElement = implts_findElement( Event.ResourceURL );
2872 Reference< XUIElementSettings > xElementSettings( xUIElement, UNO_QUERY );
2873 if ( xElementSettings.is() )
2874 {
2875 uno::Reference< XPropertySet > xPropSet( xElementSettings, uno::UNO_QUERY );
2876 if ( xPropSet.is() )
2877 {
2878 if ( Event.Source == uno::Reference< uno::XInterface >( m_xDocCfgMgr, uno::UNO_QUERY ))
2879 xPropSet->setPropertyValue( "ConfigurationSource", makeAny( m_xDocCfgMgr ));
2880 }
2881 xElementSettings->updateSettings();
2882 }
2883 }
2884
2885 if ( bRefreshLayout )
2886 doLayout();
2887}
2888
2889void SAL_CALL LayoutManager::elementRemoved( const ui::ConfigurationEvent& Event )
2890{
2891 SolarMutexClearableGuard aReadLock;
2892 Reference< frame::XFrame > xFrame( m_xFrame );
2893 rtl::Reference< ToolbarLayoutManager > xToolbarManager( m_xToolbarManager );
2894 Reference< awt::XWindow > xContainerWindow( m_xContainerWindow );
2895 Reference< ui::XUIElement > xMenuBar( m_xMenuBar );
2896 Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr );
2897 Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );
2898 aReadLock.clear();
2899
2900 if ( !xFrame.is() )
2901 return;
2902
2903 OUString aElementType;
2904 OUString aElementName;
2905 bool bRefreshLayout(false);
2906
2907 parseResourceURL( Event.ResourceURL, aElementType, aElementName );
2908 if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2909 {
2910 if ( xToolbarManager.is() )
2911 {
2912 xToolbarManager->elementRemoved( Event );
2913 bRefreshLayout = xToolbarManager->isLayoutDirty();
2914 }
2915 }
2916 else
2917 {
2918 Reference< XUIElement > xUIElement = implts_findElement( Event.ResourceURL );
2919 Reference< XUIElementSettings > xElementSettings( xUIElement, UNO_QUERY );
2920 if ( xElementSettings.is() )
2921 {
2922 bool bNoSettings( false );
2923 OUString aConfigSourcePropName( "ConfigurationSource" );
2924 Reference< XInterface > xElementCfgMgr;
2925 Reference< XPropertySet > xPropSet( xElementSettings, UNO_QUERY );
2926
2927 if ( xPropSet.is() )
2928 xPropSet->getPropertyValue( aConfigSourcePropName ) >>= xElementCfgMgr;
2929
2930 if ( !xElementCfgMgr.is() )
2931 return;
2932
2933 // Check if the same UI configuration manager has changed => check further
2934 if ( Event.Source == xElementCfgMgr )
2935 {
2936 // Same UI configuration manager where our element has its settings
2937 if ( Event.Source == Reference< XInterface >( xDocCfgMgr, UNO_QUERY ))
2938 {
2939 // document settings removed
2940 if ( xModuleCfgMgr->hasSettings( Event.ResourceURL ))
2941 {
2942 xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( m_xModuleCfgMgr ));
2943 xElementSettings->updateSettings();
2944 return;
2945 }
2946 }
2947
2948 bNoSettings = true;
2949 }
2950
2951 // No settings anymore, element must be destroyed
2952 if ( xContainerWindow.is() && bNoSettings )
2953 {
2954 if ( aElementType.equalsIgnoreAsciiCase("menubar") &&
2955 aElementName.equalsIgnoreAsciiCase("menubar") )
2956 {
2957 SystemWindow* pSysWindow = getTopSystemWindow( xContainerWindow );
2958 if ( pSysWindow && !m_bInplaceMenuSet )
2959 pSysWindow->SetMenuBar( nullptr );
2960
2961 Reference< XComponent > xComp( xMenuBar, UNO_QUERY );
2962 if ( xComp.is() )
2963 xComp->dispose();
2964
2965 SolarMutexGuard g;
2966 m_xMenuBar.clear();
2967 }
2968 }
2969 }
2970 }
2971
2972 if ( bRefreshLayout )
2973 doLayout();
2974}
2975
2976void SAL_CALL LayoutManager::elementReplaced( const ui::ConfigurationEvent& Event )
2977{
2978 SolarMutexClearableGuard aReadLock;
2979 Reference< XFrame > xFrame( m_xFrame );
2980 rtl::Reference< ToolbarLayoutManager > xToolbarManager( m_xToolbarManager );
2981 aReadLock.clear();
2982
2983 if ( !xFrame.is() )
2984 return;
2985
2986 OUString aElementType;
2987 OUString aElementName;
2988 bool bRefreshLayout(false);
2989
2990 parseResourceURL( Event.ResourceURL, aElementType, aElementName );
2991 if ( aElementType.equalsIgnoreAsciiCase( UIRESOURCETYPE_TOOLBAR"toolbar" ))
2992 {
2993 if ( xToolbarManager.is() )
2994 {
2995 xToolbarManager->elementReplaced( Event );
2996 bRefreshLayout = xToolbarManager->isLayoutDirty();
2997 }
2998 }
2999 else
3000 {
3001 Reference< XUIElement > xUIElement = implts_findElement( Event.ResourceURL );
3002 Reference< XUIElementSettings > xElementSettings( xUIElement, UNO_QUERY );
3003 if ( xElementSettings.is() )
3004 {
3005 Reference< XInterface > xElementCfgMgr;
3006 Reference< XPropertySet > xPropSet( xElementSettings, UNO_QUERY );
3007
3008 if ( xPropSet.is() )
3009 xPropSet->getPropertyValue( "ConfigurationSource" ) >>= xElementCfgMgr;
3010
3011 if ( !xElementCfgMgr.is() )
3012 return;
3013
3014 // Check if the same UI configuration manager has changed => update settings
3015 if ( Event.Source == xElementCfgMgr )
3016 xElementSettings->updateSettings();
3017 }
3018 }
3019
3020 if ( bRefreshLayout )
3021 doLayout();
3022}
3023
3024void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
3025 const uno::Any& aValue )
3026{
3027 if ( nHandle != LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY2 )
3028 LayoutManager_PBase::setFastPropertyValue_NoBroadcast( nHandle, aValue );
3029
3030 switch( nHandle )
3031 {
3032 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER0:
3033 implts_updateMenuBarClose();
3034 break;
3035
3036 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY2:
3037 {
3038 bool bValue(false);
3039 if (( aValue >>= bValue ) && bValue )
3040 {
3041 SolarMutexClearableGuard aReadLock;
3042 ToolbarLayoutManager* pToolbarManager = m_xToolbarManager.get();
3043 bool bAutomaticToolbars( m_bAutomaticToolbars );
3044 aReadLock.clear();
3045
3046 if ( pToolbarManager )
3047 pToolbarManager->refreshToolbarsVisibility( bAutomaticToolbars );
3048 }
3049 break;
3050 }
3051
3052 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI3:
3053 implts_setCurrentUIVisibility( !m_bHideCurrentUI );
3054 break;
3055 default: break;
3056 }
3057}
3058
3059namespace detail
3060{
3061 class InfoHelperBuilder
3062 {
3063 private:
3064 std::unique_ptr<::cppu::OPropertyArrayHelper> m_pInfoHelper;
3065 public:
3066 explicit InfoHelperBuilder(const LayoutManager &rManager)
3067 {
3068 uno::Sequence< beans::Property > aProperties;
3069 rManager.describeProperties(aProperties);
3070 m_pInfoHelper.reset( new ::cppu::OPropertyArrayHelper(aProperties, true) );
3071 }
3072 InfoHelperBuilder(const InfoHelperBuilder&) = delete;
3073 InfoHelperBuilder& operator=(const InfoHelperBuilder&) = delete;
3074
3075 ::cppu::OPropertyArrayHelper& getHelper() { return *m_pInfoHelper; }
3076 };
3077}
3078namespace
3079{
3080 struct theInfoHelper :
3081 public rtl::StaticWithArg< detail::InfoHelperBuilder, LayoutManager,
3082 theInfoHelper >
3083 {
3084 };
3085}
3086
3087::cppu::IPropertyArrayHelper& SAL_CALL LayoutManager::getInfoHelper()
3088{
3089 return theInfoHelper::get(*this).getHelper();
3090}
3091
3092uno::Reference< beans::XPropertySetInfo > SAL_CALL LayoutManager::getPropertySetInfo()
3093{
3094 static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
3095
3096 return xInfo;
3097}
3098
3099} // namespace framework
3100
3101extern "C" SAL_DLLPUBLIC_EXPORT__attribute__ ((visibility("default"))) css::uno::XInterface *
3102com_sun_star_comp_framework_LayoutManager_get_implementation(
3103 css::uno::XComponentContext *context,
3104 css::uno::Sequence<css::uno::Any> const &)
3105{
3106 return cppu::acquire(new framework::LayoutManager(context));
3107}
3108
3109/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/rtl/ref.hxx

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
20#ifndef INCLUDED_RTL_REF_HXX
21#define INCLUDED_RTL_REF_HXX
22
23#include "sal/config.h"
24
25#include <cassert>
26#include <cstddef>
27#include <functional>
28#ifdef LIBO_INTERNAL_ONLY1
29#include <type_traits>
30#endif
31
32#include "sal/types.h"
33
34namespace rtl
35{
36
37/** Template reference class for reference type.
38*/
39template <class reference_type>
40class Reference
41{
42 /** The <b>reference_type</b> body pointer.
43 */
44 reference_type * m_pBody;
45
46
47public:
48 /** Constructor...
49 */
50 Reference()
51 : m_pBody (NULL__null)
52 {}
53
54
55 /** Constructor...
56 */
57 Reference (reference_type * pBody, __sal_NoAcquire)
58 : m_pBody (pBody)
59 {
60 }
61
62 /** Constructor...
63 */
64 Reference (reference_type * pBody)
65 : m_pBody (pBody)
66 {
67 if (m_pBody)
68 m_pBody->acquire();
69 }
70
71 /** Copy constructor...
72 */
73 Reference (const Reference<reference_type> & handle)
74 : m_pBody (handle.m_pBody)
75 {
76 if (m_pBody)
77 m_pBody->acquire();
78 }
79
80#ifdef LIBO_INTERNAL_ONLY1
81 /** Move constructor...
82 */
83 Reference (Reference<reference_type> && handle) noexcept
84 : m_pBody (handle.m_pBody)
85 {
86 handle.m_pBody = nullptr;
87 }
88#endif
89
90#if defined LIBO_INTERNAL_ONLY1
91 /** Up-casting conversion constructor: Copies interface reference.
92
93 Does not work for up-casts to ambiguous bases.
94
95 @param rRef another reference
96 */
97 template< class derived_type >
98 inline Reference(
99 const Reference< derived_type > & rRef,
100 std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 )
101 : m_pBody (rRef.get())
102 {
103 if (m_pBody)
104 m_pBody->acquire();
105 }
106#endif
107
108 /** Destructor...
109 */
110 ~Reference() COVERITY_NOEXCEPT_FALSE
111 {
112 if (m_pBody)
3
Assuming field 'm_pBody' is non-null
4
Taking true branch
113 m_pBody->release();
5
Calling 'VclReferenceBase::release'
9
Returning; memory was released
114 }
115
116 /** Set...
117 Similar to assignment.
118 */
119 Reference<reference_type> &
120 SAL_CALL set (reference_type * pBody)
121 {
122 if (pBody)
123 pBody->acquire();
124 reference_type * const pOld = m_pBody;
125 m_pBody = pBody;
126 if (pOld)
127 pOld->release();
128 return *this;
129 }
130
131 /** Assignment.
132 Unbinds this instance from its body (if bound) and
133 bind it to the body represented by the handle.
134 */
135 Reference<reference_type> &
136 SAL_CALL operator= (const Reference<reference_type> & handle)
137 {
138 return set( handle.m_pBody );
139 }
140
141#ifdef LIBO_INTERNAL_ONLY1
142 /** Assignment.
143 * Unbinds this instance from its body (if bound),
144 * bind it to the body represented by the handle, and
145 * set the body represented by the handle to nullptr.
146 */
147 Reference<reference_type> &
148 operator= (Reference<reference_type> && handle)
149 {
150 // self-movement guts ourself
151 if (m_pBody)
152 m_pBody->release();
153 m_pBody = handle.m_pBody;
154 handle.m_pBody = nullptr;
155 return *this;
156 }
157#endif
158
159 /** Assignment...
160 */
161 Reference<reference_type> &
162 SAL_CALL operator= (reference_type * pBody)
163 {
164 return set( pBody );
165 }
166
167 /** Unbind the body from this handle.
168 Note that for a handle representing a large body,
169 "handle.clear().set(new body());" _might_
170 perform a little bit better than "handle.set(new body());",
171 since in the second case two large objects exist in memory
172 (the old body and the new body).
173 */
174 Reference<reference_type> & SAL_CALL clear()
175 {
176 if (m_pBody)
177 {
178 reference_type * const pOld = m_pBody;
179 m_pBody = NULL__null;
180 pOld->release();
181 }
182 return *this;
183 }
184
185
186 /** Get the body. Can be used instead of operator->().
187 I.e. handle->someBodyOp() and handle.get()->someBodyOp()
188 are the same.
189 */
190 reference_type * SAL_CALL get() const
191 {
192 return m_pBody;
193 }
194
195
196 /** Probably most common used: handle->someBodyOp().
197 */
198 reference_type * SAL_CALL operator->() const
199 {
200 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 200, __extension__ __PRETTY_FUNCTION__))
;
201 return m_pBody;
202 }
203
204
205 /** Allows (*handle).someBodyOp().
206 */
207 reference_type & SAL_CALL operator*() const
208 {
209 assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail
("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx"
, 209, __extension__ __PRETTY_FUNCTION__))
;
210 return *m_pBody;
211 }
212
213
214 /** Returns True if the handle does point to a valid body.
215 */
216 bool SAL_CALL is() const
217 {
218 return (m_pBody != NULL__null);
219 }
220
221#if defined LIBO_INTERNAL_ONLY1
222 /** Returns True if the handle does point to a valid body.
223 */
224 explicit operator bool() const
225 {
226 return is();
227 }
228#endif
229
230 /** Returns True if this points to pBody.
231 */
232 bool SAL_CALL operator== (const reference_type * pBody) const
233 {
234 return (m_pBody == pBody);
235 }
236
237
238 /** Returns True if handle points to the same body.
239 */
240 bool
241 SAL_CALL operator== (const Reference<reference_type> & handle) const
242 {
243 return (m_pBody == handle.m_pBody);
244 }
245
246
247 /** Needed to place References into STL collection.
248 */
249 bool
250 SAL_CALL operator!= (const Reference<reference_type> & handle) const
251 {
252 return (m_pBody != handle.m_pBody);
253 }
254
255
256 /** Needed to place References into STL collection.
257 */
258 bool
259 SAL_CALL operator< (const Reference<reference_type> & handle) const
260 {
261 return (m_pBody < handle.m_pBody);
262 }
263
264
265 /** Needed to place References into STL collection.
266 */
267 bool
268 SAL_CALL operator> (const Reference<reference_type> & handle) const
269 {
270 return (m_pBody > handle.m_pBody);
271 }
272};
273
274} // namespace rtl
275
276#if defined LIBO_INTERNAL_ONLY1
277namespace std
278{
279
280/// @cond INTERNAL
281/**
282 Make rtl::Reference hashable by default for use in STL containers.
283
284 @since LibreOffice 6.3
285*/
286template<typename T>
287struct hash<::rtl::Reference<T>>
288{
289 std::size_t operator()(::rtl::Reference<T> const & s) const
290 { return std::size_t(s.get()); }
291};
292/// @endcond
293
294}
295
296#endif
297
298#endif /* ! INCLUDED_RTL_REF_HXX */
299
300/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/include/vcl/vclreferencebase.hxx

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#ifndef INCLUDED_VCL_Reference_HXX
20#define INCLUDED_VCL_Reference_HXX
21
22#include <vcl/dllapi.h>
23#include <osl/interlck.h>
24
25class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase
26{
27 mutable oslInterlockedCount mnRefCnt;
28
29 template<typename T> friend class VclPtr;
30
31public:
32 void acquire() const
33 {
34 osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1);
35 }
36
37 void release() const
38 {
39 if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0)
6
Assuming the condition is true
7
Taking true branch
40 delete this;
8
Memory is released
41 }
42#ifdef DBG_UTIL
43#ifndef _WIN32
44 sal_Int32 getRefCount() const { return mnRefCnt; }
45#endif
46#endif
47
48
49private:
50 VclReferenceBase(const VclReferenceBase&) = delete;
51 VclReferenceBase& operator=(const VclReferenceBase&) = delete;
52
53 bool mbDisposed : 1;
54
55protected:
56 VclReferenceBase();
57protected:
58 virtual ~VclReferenceBase();
59
60protected:
61 virtual void dispose();
62
63public:
64 void disposeOnce();
65 bool isDisposed() const { return mbDisposed; }
66
67};
68#endif