Update ooo320-m1
[ooovba.git] / framework / source / layoutmanager / layoutmanager.cxx
blobf4d4f2ce7e24db9aa02f06e5bf4ddc387a596bcc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: layoutmanager.cxx,v $
10 * $Revision: 1.72 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
38 // #include <math.h>
40 #ifndef _FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_
41 #include <services/layoutmanager.hxx>
42 #endif
43 #include <threadhelp/resetableguard.hxx>
44 #include <services.h>
46 #include <classes/sfxhelperfunctions.hxx>
47 #include <uielement/menubarwrapper.hxx>
48 #include <classes/addonsoptions.hxx>
49 #include <uiconfiguration/windowstateconfiguration.hxx>
50 #include <classes/fwkresid.hxx>
52 #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_
53 #include <classes/resource.hrc>
54 #endif
55 #include <toolkit/helper/convert.hxx>
56 #include <uielement/progressbarwrapper.hxx>
57 #include <uiconfiguration/globalsettings.hxx>
59 //_________________________________________________________________________________________________________________
60 // interface includes
61 //_________________________________________________________________________________________________________________
62 #include <com/sun/star/beans/XPropertySet.hpp>
63 #include <com/sun/star/beans/PropertyAttribute.hpp>
64 #include <com/sun/star/frame/XModel.hpp>
65 #include <com/sun/star/frame/FrameAction.hpp>
66 #include <com/sun/star/frame/XUIControllerRegistration.hpp>
67 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
68 #include <com/sun/star/awt/XTopWindow.hpp>
69 #include <com/sun/star/awt/XSystemDependentMenuPeer.hpp>
70 #ifndef _COM_SUN_STAR_LANG_XYSTEMDEPENDENT_HPP_
71 #include <com/sun/star/lang/SystemDependent.hpp>
72 #endif
73 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
74 #include <com/sun/star/awt/PosSize.hpp>
75 #include <com/sun/star/awt/XDevice.hpp>
76 #include <com/sun/star/awt/XSystemDependentWindowPeer.hpp>
77 #include <com/sun/star/awt/XTopWindow.hpp>
78 #ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGER_HPP_
79 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
80 #endif
81 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
82 #include <com/sun/star/ui/UIElementType.hpp>
83 #include <com/sun/star/container/XNameReplace.hpp>
84 #include <com/sun/star/container/XNameContainer.hpp>
85 #include <com/sun/star/ui/XUIFunctionListener.hpp>
86 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
87 #include <com/sun/star/frame/XDispatchProvider.hpp>
88 #include <com/sun/star/frame/XDispatchHelper.hpp>
89 #include <com/sun/star/lang/DisposedException.hpp>
91 //_________________________________________________________________________________________________________________
92 // other includes
93 //_________________________________________________________________________________________________________________
94 #include <svtools/imgdef.hxx>
95 #include <vcl/window.hxx>
96 #include <vcl/wrkwin.hxx>
97 #include <vcl/dockingarea.hxx>
98 #include <vcl/svapp.hxx>
99 #include <vcl/i18nhelp.hxx>
100 #include <vcl/wall.hxx>
101 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
102 #include <toolkit/unohlp.hxx>
103 #endif
104 #include <toolkit/awt/vclxwindow.hxx>
105 #include <toolkit/awt/vclxmenu.hxx>
106 #include <comphelper/mediadescriptor.hxx>
107 #include <rtl/logfile.hxx>
108 #include <svtools/cmdoptions.hxx>
110 #include <algorithm>
111 #include <boost/bind.hpp>
112 // ______________________________________________
113 // using namespace
115 using namespace ::com::sun::star;
116 using namespace com::sun::star::uno;
117 using namespace com::sun::star::beans;
118 using namespace com::sun::star::util;
119 using namespace com::sun::star::lang;
120 using namespace com::sun::star::container;
121 using namespace ::com::sun::star::ui;
122 using namespace com::sun::star::frame;
123 using namespace ::com::sun::star::frame;
125 #define UIRESOURCE_PROTOCO_ASCII "private:"
126 #define UIRESOURCE_RESOURCE_ASCII "resource"
127 #define UIRESOURCE_URL_ASCII "private:resource"
128 #define UIRESOURCE_URL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( UIRESOURCE_URL_ASCII ))
130 // ATTENTION!
131 // This value is directly copied from the sfx2 project.
132 // You have to change BOTH values, see sfx2/inc/sfx2/sfxsids.hrc (SID_DOCKWIN_START)
133 static const sal_Int32 DOCKWIN_ID_BASE = 9800;
135 bool lcl_checkUIElement(const Reference< XUIElement >& xUIElement,css::awt::Rectangle& _rPosSize,Reference< css::awt::XWindow >& _xWindow)
137 bool bRet = xUIElement.is();
138 if ( bRet )
140 vos::OGuard aGuard( Application::GetSolarMutex() );
141 _xWindow.set( xUIElement->getRealInterface(), UNO_QUERY );
142 _rPosSize = _xWindow->getPosSize();
144 Window* pWindow = VCLUnoHelper::GetWindow( _xWindow );
145 if ( pWindow->GetType() == WINDOW_TOOLBOX )
147 ::Size aSize = ((ToolBox*)pWindow)->CalcWindowSizePixel( 1 );
148 _rPosSize.Width = aSize.Width();
149 _rPosSize.Height = aSize.Height();
151 } // if ( xUIElement.is() )
152 return bRet;
155 // convert alignment constant to vcl's WindowAlign type
156 static WindowAlign ImplConvertAlignment( sal_Int16 aAlignment )
158 if ( aAlignment == DockingArea_DOCKINGAREA_LEFT )
159 return WINDOWALIGN_LEFT;
160 else if ( aAlignment == DockingArea_DOCKINGAREA_RIGHT )
161 return WINDOWALIGN_RIGHT;
162 else if ( aAlignment == DockingArea_DOCKINGAREA_TOP )
163 return WINDOWALIGN_TOP;
164 else
165 return WINDOWALIGN_BOTTOM;
168 //_________________________________________________________________________________________________________________
169 // Namespace
170 //_________________________________________________________________________________________________________________
173 namespace framework
176 struct UIElementVisibility
178 rtl::OUString aName;
179 bool bVisible;
182 bool LayoutManager::UIElement::operator< ( const LayoutManager::UIElement& aUIElement ) const
184 if ( !m_xUIElement.is() && aUIElement.m_xUIElement.is() )
185 return false;
186 else if ( m_xUIElement.is() && !aUIElement.m_xUIElement.is() )
187 return true;
188 else if ( !m_bVisible && aUIElement.m_bVisible )
189 return false;
190 else if ( m_bVisible && !aUIElement.m_bVisible )
191 return true;
192 else if ( !m_bFloating && aUIElement.m_bFloating )
193 return true;
194 else if ( m_bFloating && !aUIElement.m_bFloating )
195 return false;
196 else
198 if ( m_bFloating )
200 bool bEqual = ( m_aFloatingData.m_aPos.Y() == aUIElement.m_aFloatingData.m_aPos.Y() );
201 if ( bEqual )
202 return ( m_aFloatingData.m_aPos.X() < aUIElement.m_aFloatingData.m_aPos.X() );
203 else
204 return ( m_aFloatingData.m_aPos.Y() < aUIElement.m_aFloatingData.m_aPos.Y() );
206 else
208 if ( m_aDockedData.m_nDockedArea < aUIElement.m_aDockedData.m_nDockedArea )
209 return true;
210 else if ( m_aDockedData.m_nDockedArea > aUIElement.m_aDockedData.m_nDockedArea )
211 return false;
212 else
214 if ( m_aDockedData.m_nDockedArea == DockingArea_DOCKINGAREA_TOP ||
215 m_aDockedData.m_nDockedArea == DockingArea_DOCKINGAREA_BOTTOM )
217 if ( !( m_aDockedData.m_aPos.Y() == aUIElement.m_aDockedData.m_aPos.Y() ) )
218 return ( m_aDockedData.m_aPos.Y() < aUIElement.m_aDockedData.m_aPos.Y() );
219 else
221 bool bEqual = ( m_aDockedData.m_aPos.X() == aUIElement.m_aDockedData.m_aPos.X() );
222 if ( bEqual )
224 return m_bUserActive && !aUIElement.m_bUserActive;
226 else
227 return ( m_aDockedData.m_aPos.X() < aUIElement.m_aDockedData.m_aPos.X() );
230 else
232 if ( !( m_aDockedData.m_aPos.X() == aUIElement.m_aDockedData.m_aPos.X() ) )
233 return ( m_aDockedData.m_aPos.X() < aUIElement.m_aDockedData.m_aPos.X() );
234 else
236 bool bEqual = ( m_aDockedData.m_aPos.Y() == aUIElement.m_aDockedData.m_aPos.Y() );
237 if ( bEqual )
239 return m_bUserActive && !aUIElement.m_bUserActive;
241 else
242 return ( m_aDockedData.m_aPos.Y() < aUIElement.m_aDockedData.m_aPos.Y() );
250 LayoutManager::UIElement& LayoutManager::UIElement::operator= ( const LayoutManager::UIElement& rUIElement )
252 m_aType = rUIElement.m_aType;
253 m_aName = rUIElement.m_aName;
254 m_aUIName = rUIElement.m_aUIName;
255 m_xUIElement = rUIElement.m_xUIElement;
256 m_bFloating = rUIElement.m_bFloating;
257 m_bVisible = rUIElement.m_bVisible;
258 m_bUserActive = rUIElement.m_bUserActive;
259 m_bCreateNewRowCol0 = rUIElement.m_bCreateNewRowCol0;
260 m_bDeactiveHide = rUIElement.m_bDeactiveHide;
261 m_bMasterHide = rUIElement.m_bMasterHide;
262 m_bContextSensitive = rUIElement.m_bContextSensitive;
263 m_bContextActive = rUIElement.m_bContextActive;
264 m_bNoClose = rUIElement.m_bNoClose;
265 m_bSoftClose = rUIElement.m_bSoftClose;
266 m_bStateRead = rUIElement.m_bStateRead;
267 m_nStyle = rUIElement.m_nStyle;
268 m_aDockedData = rUIElement.m_aDockedData;
269 m_aFloatingData = rUIElement.m_aFloatingData;
270 return *this;
273 static Reference< XModel > impl_getModelFromFrame( const Reference< XFrame >& rFrame )
275 // Query for the model to get check the context information
276 Reference< XModel > xModel;
277 if ( rFrame.is() )
279 Reference< XController > xController( rFrame->getController(), UNO_QUERY );
280 if ( xController.is() )
281 xModel = xController->getModel();
284 return xModel;
287 static sal_Bool implts_isPreviewModel( const Reference< XModel >& xModel )
289 if ( xModel.is() )
291 ::comphelper::MediaDescriptor aDesc( xModel->getArgs() );
292 return aDesc.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_PREVIEW(), (sal_Bool)sal_False);
294 else
295 return sal_False;
298 static sal_Bool implts_isFrameOrWindowTop( const css::uno::Reference< css::frame::XFrame >& xFrame )
300 if (xFrame->isTop())
301 return sal_True;
303 css::uno::Reference< css::awt::XTopWindow > xWindowCheck(xFrame->getContainerWindow(), css::uno::UNO_QUERY); // dont use _THROW here ... its a check only
304 if (xWindowCheck.is())
306 // --> PB 2007-06-18 #i76867# top and system window is required.
307 ::vos::OGuard aSolarLock(&Application::GetSolarMutex());
308 css::uno::Reference< css::awt::XWindow > xWindow( xWindowCheck, UNO_QUERY );
309 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
310 return ( pWindow && pWindow->IsSystemWindow() );
311 // <--
314 return sal_False;
317 static void impl_setDockingWindowVisibility( const css::uno::Reference< css::lang::XMultiServiceFactory>& rSMGR, const css::uno::Reference< css::frame::XFrame >& rFrame, const ::rtl::OUString& rDockingWindowName, bool bVisible )
319 const ::rtl::OUString aDockWinPrefixCommand( RTL_CONSTASCII_USTRINGPARAM( "DockingWindow" ));
320 css::uno::WeakReference< css::frame::XDispatchHelper > xDispatchHelper;
322 sal_Int32 nID = rDockingWindowName.toInt32();
323 sal_Int32 nIndex = nID - DOCKWIN_ID_BASE;
325 css::uno::Reference< css::frame::XDispatchProvider > xProvider(rFrame, css::uno::UNO_QUERY);
326 if ( nIndex >= 0 && xProvider.is() )
328 ::rtl::OUString aDockWinCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ));
329 ::rtl::OUString aDockWinArgName( aDockWinPrefixCommand );
331 aDockWinArgName += ::rtl::OUString::valueOf( nIndex );
333 css::uno::Sequence< css::beans::PropertyValue > aArgs(1);
334 aArgs[0].Name = aDockWinArgName;
335 aArgs[0].Value = css::uno::makeAny( bVisible );
337 css::uno::Reference< css::frame::XDispatchHelper > xDispatcher( xDispatchHelper );
338 if ( !xDispatcher.is())
340 xDispatcher = css::uno::Reference< css::frame::XDispatchHelper >(
341 rSMGR->createInstance(SERVICENAME_DISPATCHHELPER), css::uno::UNO_QUERY_THROW);
344 aDockWinCommand = aDockWinCommand + aDockWinArgName;
345 xDispatcher->executeDispatch(
346 xProvider,
347 aDockWinCommand,
348 ::rtl::OUString::createFromAscii("_self"),
350 aArgs);
354 //*****************************************************************************************************************
355 // XInterface, XTypeProvider, XServiceInfo
356 //*****************************************************************************************************************
357 DEFINE_XINTERFACE_14 ( LayoutManager ,
358 OWeakObject ,
359 DIRECT_INTERFACE( css::lang::XTypeProvider ),
360 DIRECT_INTERFACE( css::lang::XServiceInfo ),
361 DIRECT_INTERFACE( ::com::sun::star::frame::XLayoutManager ),
362 DIRECT_INTERFACE( css::awt::XWindowListener ),
363 DIRECT_INTERFACE( css::frame::XFrameActionListener ),
364 DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationListener ),
365 DIRECT_INTERFACE( ::com::sun::star::frame::XInplaceLayout ),
366 DIRECT_INTERFACE( css::awt::XDockableWindowListener ),
367 DIRECT_INTERFACE( ::com::sun::star::frame::XMenuBarMergingAcceptor ),
368 DIRECT_INTERFACE( css::frame::XLayoutManagerEventBroadcaster ),
369 DERIVED_INTERFACE( css::lang::XEventListener, css::frame::XFrameActionListener ),
370 DIRECT_INTERFACE( ::com::sun::star::beans::XMultiPropertySet ),
371 DIRECT_INTERFACE( ::com::sun::star::beans::XFastPropertySet ),
372 DIRECT_INTERFACE( ::com::sun::star::beans::XPropertySet )
375 DEFINE_XTYPEPROVIDER_14 ( LayoutManager ,
376 css::lang::XTypeProvider ,
377 css::lang::XServiceInfo ,
378 ::com::sun::star::frame::XLayoutManager ,
379 css::awt::XWindowListener ,
380 css::frame::XFrameActionListener ,
381 css::lang::XEventListener ,
382 ::com::sun::star::ui::XUIConfigurationListener ,
383 ::com::sun::star::frame::XInplaceLayout ,
384 css::awt::XDockableWindowListener ,
385 ::com::sun::star::frame::XMenuBarMergingAcceptor ,
386 css::frame::XLayoutManagerEventBroadcaster ,
387 ::com::sun::star::beans::XMultiPropertySet ,
388 ::com::sun::star::beans::XFastPropertySet ,
389 ::com::sun::star::beans::XPropertySet
392 DEFINE_XSERVICEINFO_MULTISERVICE ( LayoutManager ,
393 ::cppu::OWeakObject ,
394 SERVICENAME_LAYOUTMANAGER ,
395 IMPLEMENTATIONNAME_LAYOUTMANAGER
398 DEFINE_INIT_SERVICE ( LayoutManager, {} )
401 LayoutManager::LayoutManager( const Reference< XMultiServiceFactory >& xServiceManager ) :
402 ThreadHelpBase( &Application::GetSolarMutex() )
403 , ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() )
404 , ::cppu::OPropertySetHelper ( *(static_cast< ::cppu::OBroadcastHelper* >(this)) )
405 , ::cppu::OWeakObject ( )
406 , m_xSMGR( xServiceManager )
407 , m_xURLTransformer( Reference< XURLTransformer >( xServiceManager->createInstance(
408 SERVICENAME_URLTRANSFORMER),
409 UNO_QUERY ))
410 , m_nLockCount( 0 )
411 , m_bActive( sal_False )
412 , m_bInplaceMenuSet( sal_False )
413 , m_bDockingInProgress( sal_False )
414 , m_bMenuVisible( sal_True )
415 , m_bComponentAttached( sal_False )
416 , m_bDoLayout( sal_False )
417 , m_bVisible( sal_True )
418 , m_bParentWindowVisible( sal_False )
419 , m_bMustDoLayout( sal_True )
420 , m_bAutomaticToolbars( sal_True )
421 , m_bStoreWindowState( sal_False )
422 , m_bHideCurrentUI( false )
423 , m_bGlobalSettings( sal_False )
424 , m_eDockOperation( DOCKOP_ON_COLROW )
425 , m_pInplaceMenuBar( NULL )
426 , m_xModuleManager( Reference< XModuleManager >(
427 xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY ))
428 , m_xUIElementFactoryManager( Reference< ::com::sun::star::ui::XUIElementFactory >(
429 xServiceManager->createInstance( SERVICENAME_UIELEMENTFACTORYMANAGER ), UNO_QUERY ))
430 , m_bMenuBarCloser( sal_False )
431 , m_xPersistentWindowStateSupplier( Reference< XNameAccess >(
432 xServiceManager->createInstance( SERVICENAME_WINDOWSTATECONFIGURATION ), UNO_QUERY ))
433 , m_pGlobalSettings( 0 )
434 , m_aCustomTbxPrefix( RTL_CONSTASCII_USTRINGPARAM( "custom_" ))
435 , m_aFullCustomTbxPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/custom_" ))
436 , m_aFullAddonTbxPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/addon_" ))
437 , m_aStatusBarAlias( RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ))
438 , m_aProgressBarAlias( RTL_CONSTASCII_USTRINGPARAM( "private:resource/progressbar/progressbar" ))
439 , m_aPropDocked( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_DOCKED ))
440 , m_aPropVisible( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_VISIBLE ))
441 , m_aPropDockingArea( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_DOCKINGAREA ))
442 , m_aPropDockPos( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_DOCKPOS ))
443 , m_aPropPos( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_POS ))
444 , m_aPropSize( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_SIZE ))
445 , m_aPropUIName( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_UINAME ))
446 , m_aPropStyle( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_STYLE ))
447 , m_aPropLocked( RTL_CONSTASCII_USTRINGPARAM( WINDOWSTATE_PROPERTY_LOCKED ))
448 , m_aCustomizeCmd( RTL_CONSTASCII_USTRINGPARAM( "ConfigureDialog" ))
449 , m_pAddonOptions( 0 )
450 , m_aListenerContainer( m_aLock.getShareableOslMutex() )
452 // Initialize statusbar member
453 m_aStatusBarElement.m_aType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "statusbar" ));
454 m_aStatusBarElement.m_aName = m_aStatusBarAlias;
456 m_pMiscOptions = new SvtMiscOptions();
458 m_pMiscOptions->AddListener( LINK( this, LayoutManager, OptionsChanged ) );
459 Application::AddEventListener( LINK( this, LayoutManager, SettingsChanged ) );
460 m_eSymbolsSize = m_pMiscOptions->GetSymbolsSize();
461 m_eSymbolsStyle = m_pMiscOptions->GetCurrentSymbolsStyle();
463 m_aAsyncLayoutTimer.SetTimeout( 50 );
464 m_aAsyncLayoutTimer.SetTimeoutHdl( LINK( this, LayoutManager, AsyncLayoutHdl ) );
467 LayoutManager::~LayoutManager()
469 Application::RemoveEventListener( LINK( this, LayoutManager, SettingsChanged ) );
470 if ( m_pMiscOptions )
472 m_pMiscOptions->RemoveListener( LINK( this, LayoutManager, OptionsChanged ) );
473 delete m_pMiscOptions;
474 m_pMiscOptions = 0;
476 m_aAsyncLayoutTimer.Stop();
479 // Internal helper function
480 void LayoutManager::impl_clearUpMenuBar()
482 implts_lock();
484 // Clear up VCL menu bar to prepare shutdown
485 if ( m_xContainerWindow.is() )
487 vos::OGuard aGuard( Application::GetSolarMutex() );
489 Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
490 while ( pWindow && !pWindow->IsSystemWindow() )
491 pWindow = pWindow->GetParent();
493 if ( pWindow )
495 MenuBar* pSetMenuBar = 0;
496 if ( m_xInplaceMenuBar.is() )
497 pSetMenuBar = (MenuBar *)m_pInplaceMenuBar->GetMenuBar();
498 else
500 Reference< css::awt::XMenuBar > xMenuBar;
502 Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
503 if ( xPropSet.is() )
507 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMenuBar" ))) >>= xMenuBar;
509 catch ( com::sun::star::beans::UnknownPropertyException )
512 catch ( com::sun::star::lang::WrappedTargetException )
517 VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar );
518 if ( pAwtMenuBar )
519 pSetMenuBar = (MenuBar*)pAwtMenuBar->GetMenu();
522 MenuBar* pTopMenuBar = ((SystemWindow *)pWindow)->GetMenuBar();
523 if ( pSetMenuBar == pTopMenuBar )
524 ((SystemWindow *)pWindow)->SetMenuBar( 0 );
528 // reset inplace menubar manager
529 m_pInplaceMenuBar = 0;
530 if ( m_xInplaceMenuBar.is() )
532 m_xInplaceMenuBar->dispose();
533 m_xInplaceMenuBar.clear();
536 Reference< XComponent > xComp( m_xMenuBar, UNO_QUERY );
537 if ( xComp.is() )
538 xComp->dispose();
539 m_xMenuBar.clear();
540 implts_unlock();
543 sal_Bool LayoutManager::impl_parseResourceURL( const rtl::OUString aResourceURL, rtl::OUString& aElementType, rtl::OUString& aElementName )
545 URL aURL;
546 sal_Int32 nIndex = 0;
548 aURL.Complete = aResourceURL;
549 m_xURLTransformer->parseStrict( aURL );
551 ::rtl::OUString aUIResource = aURL.Path.getToken( 0, (sal_Unicode)'/', nIndex );
553 if (( aURL.Protocol.equalsIgnoreAsciiCaseAscii( UIRESOURCE_PROTOCO_ASCII )) &&
554 ( aUIResource.equalsIgnoreAsciiCaseAscii( UIRESOURCE_RESOURCE_ASCII )))
556 aElementType = aURL.Path.getToken( 0, (sal_Unicode)'/', nIndex );
557 aElementName = aURL.Path.getToken( 0, (sal_Unicode)'/', nIndex );
558 return sal_True;
561 return sal_False;
564 void LayoutManager::implts_lock()
566 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
567 WriteGuard aWriteLock( m_aLock );
568 ++m_nLockCount;
569 aWriteLock.unlock();
570 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
573 sal_Bool LayoutManager::implts_unlock()
575 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
576 WriteGuard aWriteLock( m_aLock );
577 --m_nLockCount;
578 if ( m_nLockCount < 0 )
579 m_nLockCount = 0;
580 return ( m_nLockCount == 0 );
581 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
584 void LayoutManager::implts_reset( sal_Bool bAttached )
586 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
587 ReadGuard aReadLock( m_aLock );
588 Reference< XFrame > xFrame = m_xFrame;
589 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
590 Reference< css::awt::XWindow > xTopDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP];
591 Reference< css::awt::XWindow > xLeftDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT];
592 Reference< css::awt::XWindow > xRightDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT];
593 Reference< css::awt::XWindow > xBottomDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM];
594 Reference< XUIConfiguration > xModuleCfgMgr( m_xModuleCfgMgr, UNO_QUERY );
595 Reference< XUIConfiguration > xDocCfgMgr( m_xDocCfgMgr, UNO_QUERY );
596 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
597 Reference< XMultiServiceFactory > xServiceManager( m_xSMGR );
598 Reference< XNameAccess > xPersistentWindowStateSupplier( m_xPersistentWindowStateSupplier );
599 ::rtl::OUString aModuleIdentifier( m_aModuleIdentifier );
600 sal_Bool bAutomaticToolbars( m_bAutomaticToolbars );
601 aReadLock.unlock();
602 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
604 implts_lock();
606 Reference< XModel > xModel;
607 if ( xFrame.is() )
609 if ( bAttached )
611 ::rtl::OUString aOldModuleIdentifier( aModuleIdentifier );
614 aModuleIdentifier = m_xModuleManager->identify( Reference< XInterface >( xFrame, UNO_QUERY ) );
616 catch( Exception& )
620 if ( aModuleIdentifier.getLength() && aOldModuleIdentifier != aModuleIdentifier )
622 Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier;
623 if ( xServiceManager.is() )
624 xModuleCfgSupplier = Reference< XModuleUIConfigurationManagerSupplier >(
625 xServiceManager->createInstance( SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ), UNO_QUERY );
627 if ( xModuleCfgMgr.is() )
631 // Remove listener to old module ui configuration manager
632 xModuleCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
634 catch ( Exception& )
641 // Add listener to new module ui configuration manager
642 xModuleCfgMgr = Reference< XUIConfiguration >( xModuleCfgSupplier->getUIConfigurationManager( aModuleIdentifier ), UNO_QUERY );
643 if ( xModuleCfgMgr.is() )
644 xModuleCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
646 catch ( Exception& )
652 // Retrieve persistent window state reference for our new module
653 if ( xPersistentWindowStateSupplier.is() )
654 xPersistentWindowStateSupplier->getByName( aModuleIdentifier ) >>= xPersistentWindowState;
656 catch ( NoSuchElementException& )
659 catch ( WrappedTargetException& )
664 xModel = impl_getModelFromFrame( xFrame );
665 if ( xModel.is() )
667 Reference< XUIConfigurationManagerSupplier > xUIConfigurationManagerSupplier( xModel, UNO_QUERY );
668 if ( xUIConfigurationManagerSupplier.is() )
670 if ( xDocCfgMgr.is() )
674 // Remove listener to old ui configuration manager
675 xDocCfgMgr->removeConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
677 catch ( Exception& )
684 xDocCfgMgr = Reference< XUIConfiguration >( xUIConfigurationManagerSupplier->getUIConfigurationManager(), UNO_QUERY );
685 if ( xDocCfgMgr.is() )
686 xDocCfgMgr->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
688 catch ( Exception& )
694 else
696 // Remove configuration listeners before we can release our references
697 if ( xModuleCfgMgr.is() )
701 xModuleCfgMgr->removeConfigurationListener(
702 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
704 catch ( Exception& )
709 if ( xDocCfgMgr.is() )
713 xDocCfgMgr->removeConfigurationListener(
714 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
716 catch ( Exception& )
721 // Release references to our configuration managers as we currently don't have
722 // an attached module.
723 xModuleCfgMgr.clear();
724 xDocCfgMgr.clear();
725 xPersistentWindowState.clear();
726 aModuleIdentifier = ::rtl::OUString();
729 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
730 WriteGuard aWriteLock( m_aLock );
731 m_xModel = xModel;
732 m_aDockingArea = css::awt::Rectangle();
733 m_bComponentAttached = bAttached;
734 m_aModuleIdentifier = aModuleIdentifier;
735 m_xModuleCfgMgr = Reference< XUIConfigurationManager >( xModuleCfgMgr, UNO_QUERY );
736 m_xDocCfgMgr = Reference< XUIConfigurationManager >( xDocCfgMgr, UNO_QUERY );
737 m_xPersistentWindowState = xPersistentWindowState;
738 m_aStatusBarElement.m_bStateRead = sal_False; // reset state to read data again!
739 aWriteLock.unlock();
740 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
742 if ( bAttached )
744 // reset docking area windows back to zero size
747 if ( xTopDockingWindow.is() )
748 xTopDockingWindow->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE );
749 if ( xLeftDockingWindow.is() )
750 xLeftDockingWindow->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE );
751 if ( xRightDockingWindow.is() )
752 xRightDockingWindow->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE );
753 if ( xBottomDockingWindow.is() )
754 xBottomDockingWindow->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE );
756 catch ( Exception& )
760 if ( bAutomaticToolbars )
762 implts_createCustomToolBars();
763 implts_createAddonsToolBars();
764 implts_createNonContextSensitiveToolBars();
766 implts_sortUIElements();
768 else
769 implts_destroyElements();
772 implts_unlock();
775 sal_Bool LayoutManager::implts_isEmbeddedLayoutManager() const
777 // check if this layout manager is currently using the embedded feature
778 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
779 ReadGuard aReadLock( m_aLock );
780 Reference< XFrame > xFrame = m_xFrame;
781 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
782 aReadLock.unlock();
783 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
785 Reference< css::awt::XWindow > xFrameContainerWindow = xFrame->getContainerWindow();
786 if ( xFrameContainerWindow == xContainerWindow )
787 return sal_False;
788 else
789 return sal_True;
792 void LayoutManager::implts_destroyElements()
794 UIElementVector aUIElementVector;
796 WriteGuard aWriteLock( m_aLock );
797 aUIElementVector = m_aUIElements;
798 m_aUIElements.clear();
799 aWriteLock.unlock();
801 UIElementVector::iterator pIter;
802 for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); pIter++ )
804 Reference< XComponent > xComponent( pIter->m_xUIElement, UNO_QUERY );
805 if ( xComponent.is() )
806 xComponent->dispose();
809 implts_destroyStatusBar();
811 aWriteLock.lock();
812 impl_clearUpMenuBar();
813 aWriteLock.unlock();
816 void LayoutManager::implts_destroyDockingAreaWindows()
818 std::vector< Reference< css::awt::XWindow > > oldDockingAreaWindows;
820 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
821 WriteGuard aWriteLock( m_aLock );
822 oldDockingAreaWindows.push_back( m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP] );
823 oldDockingAreaWindows.push_back( m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM] );
824 oldDockingAreaWindows.push_back( m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT] );
825 oldDockingAreaWindows.push_back( m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT] );
827 m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP].clear();
828 m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM].clear();
829 m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT].clear();
830 m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT].clear();
831 aWriteLock.unlock();
832 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
834 const sal_uInt32 nCount = oldDockingAreaWindows.size();
835 for ( sal_uInt32 i=0; i < nCount; i++ )
837 if ( oldDockingAreaWindows[i].is() )
841 oldDockingAreaWindows[i]->dispose();
843 catch ( Exception& )
850 void LayoutManager::implts_createCustomToolBar( const rtl::OUString& aTbxResName, const rtl::OUString& aTitle )
852 if ( aTbxResName.getLength() > 0 )
854 createElement( aTbxResName );
855 if ( aTitle )
857 Reference< XUIElement > xUIElement = getElement( aTbxResName );
858 if ( xUIElement.is() )
860 vos::OGuard aGuard( Application::GetSolarMutex() );
862 Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
863 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
864 if ( pWindow )
865 pWindow->SetText( aTitle );
871 void LayoutManager::implts_createCustomToolBars(
872 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aTbxSeqSeq )
874 const Sequence< PropertyValue >* pTbxSeq = aTbxSeqSeq.getConstArray();
875 for ( sal_Int32 i = 0; i < aTbxSeqSeq.getLength(); i++ )
877 const Sequence< PropertyValue >& rTbxSeq = pTbxSeq[i];
878 ::rtl::OUString aTbxResName;
879 ::rtl::OUString aTbxTitle;
880 for ( sal_Int32 j = 0; j < rTbxSeq.getLength(); j++ )
882 if ( rTbxSeq[j].Name.equalsAscii( "ResourceURL" ))
883 rTbxSeq[j].Value >>= aTbxResName;
884 else if ( rTbxSeq[j].Name.equalsAscii( "UIName" ))
885 rTbxSeq[j].Value >>= aTbxTitle;
888 // Only create custom toolbars. Their name have to start with "custom_"!
889 if ( aTbxResName.getLength() > 0 && aTbxResName.indexOf( m_aCustomTbxPrefix ) != -1 )
890 implts_createCustomToolBar( aTbxResName, aTbxTitle );
894 void LayoutManager::implts_createCustomToolBars()
896 ReadGuard aReadLock( m_aLock );
897 if ( !m_bComponentAttached )
898 return;
900 Reference< XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
901 Reference< XFrame > xFrame( m_xFrame );
902 Reference< XModel > xModel;
903 Reference< XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr, UNO_QUERY );
904 Reference< XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr, UNO_QUERY );
905 aReadLock.unlock();
907 if ( xFrame.is() )
909 xModel = impl_getModelFromFrame( xFrame );
910 if ( implts_isPreviewModel( xModel ))
911 return; // no custom toolbars for preview frame!
913 Sequence< Sequence< PropertyValue > > aTbxSeq;
914 if ( xDocCfgMgr.is() )
916 aTbxSeq = xDocCfgMgr->getUIElementsInfo( UIElementType::TOOLBAR );
917 implts_createCustomToolBars( aTbxSeq ); // first create all document based toolbars
919 if ( xModuleCfgMgr.is() )
921 aTbxSeq = xModuleCfgMgr->getUIElementsInfo( UIElementType::TOOLBAR );
922 implts_createCustomToolBars( aTbxSeq ); // second create module based toolbars
927 rtl::OUString LayoutManager::implts_generateGenericAddonToolbarTitle( sal_Int32 nNumber ) const
929 String aAddonGenericTitle;
931 aAddonGenericTitle = String( FwkResId( STR_TOOLBAR_TITLE_ADDON ));
932 const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
934 String aNumStr = rI18nHelper.GetNum( nNumber, 0, FALSE, FALSE );
935 aAddonGenericTitle.SearchAndReplaceAscii( "%num%", aNumStr );
937 return rtl::OUString( aAddonGenericTitle );
940 void LayoutManager::implts_createAddonsToolBars()
942 WriteGuard aWriteLock( m_aLock );
943 if ( !m_bComponentAttached )
944 return;
946 Reference< XModel > xModel;
947 Reference< XFrame > xFrame( m_xFrame );
948 if ( !xFrame.is() )
949 return;
951 if ( !m_pAddonOptions )
952 m_pAddonOptions = new AddonsOptions;
954 Reference< XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
955 aWriteLock.unlock();
957 xModel = impl_getModelFromFrame( xFrame );
958 if ( implts_isPreviewModel( xModel ))
959 return; // no addon toolbars for preview frame!
961 UIElementVector aUIElementVector;
962 Sequence< Sequence< PropertyValue > > aAddonToolBarData;
963 Reference< XUIElement > xUIElement;
965 sal_uInt32 nCount = m_pAddonOptions->GetAddonsToolBarCount();
966 ::rtl::OUString aAddonsToolBarStaticName( m_aFullAddonTbxPrefix );
967 ::rtl::OUString aElementType( RTL_CONSTASCII_USTRINGPARAM( "toolbar" ));
969 Sequence< PropertyValue > aPropSeq( 2 );
970 aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
971 aPropSeq[0].Value <<= xFrame;
972 aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationData" ));
973 for ( sal_uInt32 i = 0; i < nCount; i++ )
975 ::rtl::OUString aAddonToolBarName( aAddonsToolBarStaticName + m_pAddonOptions->GetAddonsToolbarResourceName(i) );
976 aAddonToolBarData = m_pAddonOptions->GetAddonsToolBarPart( i );
977 aPropSeq[1].Value <<= aAddonToolBarData;
979 aWriteLock.lock();
980 UIElement aElement = impl_findElement( aAddonToolBarName );
981 aWriteLock.unlock();
983 // #i79828
984 // It's now possible that we are called more than once. Be sure to not create
985 // add-on toolbars more than once!
986 if ( aElement.m_xUIElement.is() )
987 continue;
991 xUIElement = xUIElementFactory->createUIElement( aAddonToolBarName, aPropSeq );
992 if ( xUIElement.is() )
994 Reference< css::awt::XDockableWindow > xDockWindow( xUIElement->getRealInterface(), UNO_QUERY );
995 if ( xDockWindow.is() )
999 xDockWindow->addDockableWindowListener( Reference< css::awt::XDockableWindowListener >( static_cast< OWeakObject * >( this ), UNO_QUERY ));
1000 xDockWindow->enableDocking( sal_True );
1001 Reference< css::awt::XWindow > xWindow( xDockWindow, UNO_QUERY );
1002 if ( xWindow.is() )
1003 xWindow->addWindowListener( Reference< css::awt::XWindowListener >( static_cast< OWeakObject * >( this ), UNO_QUERY ));
1005 catch ( Exception& )
1010 ::rtl::OUString aGenericAddonTitle = implts_generateGenericAddonToolbarTitle( i+1 );
1012 if ( aElement.m_aName.getLength() > 0 )
1014 // Reuse a local entry so we are able to use the latest
1015 // UI changes for this document.
1016 implts_setElementData( aElement, xDockWindow );
1017 aElement.m_xUIElement = xUIElement;
1018 if ( aElement.m_aUIName.getLength() == 0 )
1020 aElement.m_aUIName = aGenericAddonTitle;
1021 implts_writeWindowStateData( aElement.m_aName, aElement );
1024 else
1026 // Create new UI element and try to read its state data
1027 UIElement aNewToolbar( aAddonToolBarName, aElementType, xUIElement );
1028 aNewToolbar.m_bFloating = sal_True;
1029 implts_readWindowStateData( aAddonToolBarName, aNewToolbar );
1030 implts_setElementData( aNewToolbar, xDockWindow );
1031 if ( aNewToolbar.m_aUIName.getLength() == 0 )
1033 aNewToolbar.m_aUIName = aGenericAddonTitle;
1034 implts_writeWindowStateData( aNewToolbar.m_aName, aNewToolbar );
1036 implts_insertUIElement( aNewToolbar );
1039 Reference< css::awt::XWindow > xWindow( xDockWindow, UNO_QUERY );
1040 if ( xWindow.is() )
1042 // Set generic title for add-on toolbar
1043 vos::OGuard aGuard( Application::GetSolarMutex() );
1044 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
1045 if ( pWindow->GetText().Len() == 0 )
1046 pWindow->SetText( aGenericAddonTitle );
1047 if ( pWindow->GetType() == WINDOW_TOOLBOX )
1049 ToolBox* pToolbar = (ToolBox *)pWindow;
1050 pToolbar->SetMenuType();
1055 catch ( NoSuchElementException& )
1058 catch ( IllegalArgumentException& )
1064 void LayoutManager::implts_createNonContextSensitiveToolBars()
1066 ReadGuard aReadLock( m_aLock );
1068 if ( !m_xPersistentWindowState.is() ||
1069 !m_xFrame.is() ||
1070 !m_bComponentAttached )
1071 return;
1073 Reference< XFrame > xFrame( m_xFrame );
1075 Reference< XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
1076 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
1077 aReadLock.unlock();
1079 if ( implts_isPreviewModel( impl_getModelFromFrame( xFrame )))
1080 return;
1082 std::vector< rtl::OUString > aMakeVisibleToolbars;
1086 Sequence< rtl::OUString > aToolbarNames = xPersistentWindowState->getElementNames();
1088 if ( aToolbarNames.getLength() > 0 )
1090 rtl::OUString aElementType;
1091 rtl::OUString aElementName;
1092 rtl::OUString aName;
1094 Reference< ::com::sun::star::ui::XUIElement > xUIElement;
1095 aMakeVisibleToolbars.reserve(aToolbarNames.getLength());
1096 WriteGuard aWriteLock( m_aLock );
1098 const rtl::OUString* pTbNames = aToolbarNames.getConstArray();
1099 for ( sal_Int32 i = 0; i < aToolbarNames.getLength(); i++ )
1101 aName = pTbNames[i];
1102 if ( impl_parseResourceURL( aName, aElementType, aElementName ))
1104 // Check that we only create:
1105 // - Toolbars (the statusbar is also member of the persistent window state)
1106 // - Not custom toolbars, there are created with their own method (implts_createCustomToolbars)
1107 if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ) &&
1108 aElementName.indexOf( m_aCustomTbxPrefix ) == -1 )
1110 UIElement aNewToolbar( aName, aElementType, xUIElement );
1111 bool bFound = implts_findElement( aName, aNewToolbar );
1112 if ( !bFound )
1113 implts_readWindowStateData( aName, aNewToolbar );
1115 if ( aNewToolbar.m_bVisible &&
1116 !aNewToolbar.m_bContextSensitive )
1118 if ( !bFound )
1119 implts_insertUIElement( aNewToolbar );
1120 aMakeVisibleToolbars.push_back( aName );
1127 catch ( RuntimeException& e )
1129 throw e;
1131 catch ( Exception& )
1135 if ( !aMakeVisibleToolbars.empty() )
1137 implts_lock();
1138 ::std::for_each( aMakeVisibleToolbars.begin(), aMakeVisibleToolbars.end(),::boost::bind( &LayoutManager::requestElement, this,_1 ));
1139 implts_unlock();
1143 void LayoutManager::implts_toggleFloatingUIElementsVisibility( sal_Bool bActive )
1145 WriteGuard aWriteLock( m_aLock );
1146 UIElementVector::iterator pIter;
1148 ReadGuard aReadLock( m_aLock );
1149 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
1151 if ( pIter->m_xUIElement.is() )
1153 Reference< css::awt::XDockableWindow > xDockWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
1154 Reference< css::awt::XWindow > xWindow( xDockWindow, UNO_QUERY );
1155 if ( xDockWindow.is() && xWindow.is() )
1157 sal_Bool bVisible( sal_True );
1158 vos::OGuard aGuard( Application::GetSolarMutex() );
1159 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
1160 if ( pWindow )
1161 bVisible = pWindow->IsVisible();
1163 if ( xDockWindow->isFloating() )
1165 if ( bActive )
1167 if ( !bVisible && pIter->m_bDeactiveHide )
1169 pIter->m_bDeactiveHide = sal_False;
1170 // we need VCL here to pass special flags to Show()
1171 if( pWindow )
1172 pWindow->Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1173 //xWindow->setVisible( sal_True );
1176 else
1178 if ( bVisible )
1180 pIter->m_bDeactiveHide = sal_True;
1181 xWindow->setVisible( sal_False );
1190 sal_Bool LayoutManager::implts_findElement( const rtl::OUString& aName, rtl::OUString& aElementType, rtl::OUString& aElementName, Reference< XUIElement >& xUIElement )
1192 if ( impl_parseResourceURL( aName, aElementType, aElementName ))
1194 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
1195 aElementName.equalsIgnoreAsciiCaseAscii( "menubar" ))
1197 ReadGuard aReadLock( m_aLock );
1198 xUIElement = m_xMenuBar;
1199 return sal_True;
1201 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
1202 aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
1203 ( m_aStatusBarElement.m_aName == aName ))
1205 ReadGuard aReadLock( m_aLock );
1206 xUIElement = m_aStatusBarElement.m_xUIElement;
1207 return sal_True;
1209 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
1210 aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ))
1212 ReadGuard aReadLock( m_aLock );
1213 xUIElement = m_aProgressBarElement.m_xUIElement;
1214 return sal_True;
1216 else
1218 UIElementVector::const_iterator pIter;
1220 ReadGuard aReadLock( m_aLock );
1221 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
1223 if ( pIter->m_aName == aName )
1225 xUIElement = pIter->m_xUIElement;
1226 return sal_True;
1232 return sal_False;
1235 sal_Bool LayoutManager::implts_findElement( const Reference< XInterface >& xUIElement, UIElement& aElementData )
1237 UIElementVector::const_iterator pIter;
1239 ReadGuard aReadLock( m_aLock );
1240 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
1242 if ( pIter->m_xUIElement.is() )
1244 Reference< XInterface > xIfac( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
1245 if ( xIfac == xUIElement )
1247 aElementData = *pIter;
1248 return sal_True;
1253 return sal_False;
1256 sal_Bool LayoutManager::implts_findElement( const rtl::OUString& aName, UIElement& aElementData )
1258 UIElementVector::const_iterator pIter;
1260 ReadGuard aReadLock( m_aLock );
1261 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
1263 if ( pIter->m_aName == aName )
1265 aElementData = *pIter;
1266 return sal_True;
1270 return sal_False;
1273 LayoutManager::UIElement& LayoutManager::impl_findElement( const rtl::OUString& aName )
1275 static UIElement aEmptyElement;
1277 UIElementVector::iterator pIter;
1279 ReadGuard aReadLock( m_aLock );
1280 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
1282 if ( pIter->m_aName == aName )
1283 return *pIter;
1286 return aEmptyElement;
1289 sal_Bool LayoutManager::implts_insertUIElement( const UIElement& rUIElement )
1291 UIElement aTempData;
1292 bool bFound = implts_findElement( rUIElement.m_aName, aTempData );
1294 #ifdef DBG_UTIL
1295 if ( bFound )
1297 char aBuffer[256];
1298 const sal_Int32 MAX_NAME_LENGTH = 128;
1299 ::rtl::OString aName = ::rtl::OUStringToOString( rUIElement.m_aName, RTL_TEXTENCODING_ASCII_US );
1300 aName = aName.copy( ::std::min( MAX_NAME_LENGTH, aName.getLength() ));
1301 sprintf( aBuffer, "Try to insert an already existing user interface element (%s) into the list\n", aName.getStr() );
1302 DBG_ASSERT( bFound, aBuffer );
1304 #endif
1306 bool bResult( false );
1307 if ( !bFound )
1309 WriteGuard aWriteLock( m_aLock );
1310 m_aUIElements.push_back( rUIElement );
1311 bResult = true;
1313 return bResult;
1316 void LayoutManager::implts_writeNewStateData( const rtl::OUString aName, const Reference< css::awt::XWindow >& xWindow )
1318 css::awt::Rectangle aPos;
1319 css::awt::Size aSize;
1320 sal_Bool bVisible( sal_False );
1321 sal_Bool bFloating( sal_True );
1323 if ( xWindow.is() )
1325 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
1326 if ( xDockWindow.is() )
1327 bFloating = xDockWindow->isFloating();
1329 Reference< css::awt::XWindow2 > xWindow2( xWindow, UNO_QUERY );
1330 if( xWindow2.is() )
1332 aPos = xWindow2->getPosSize();
1333 aSize = xWindow2->getOutputSize(); // always use output size for consistency
1334 bVisible = xWindow2->isVisible();
1338 WriteGuard aWriteLock( m_aLock );
1339 UIElement& rUIElement = impl_findElement( aName );
1340 if ( rUIElement.m_xUIElement.is() && xWindow.is() )
1342 rUIElement.m_bVisible = bVisible;
1343 rUIElement.m_bFloating = bFloating;
1344 if ( bFloating )
1346 rUIElement.m_aFloatingData.m_aPos = ::Point( aPos.X, aPos.Y );
1347 rUIElement.m_aFloatingData.m_aSize = ::Size( aSize.Width, aSize.Height );
1351 implts_writeWindowStateData( aName, rUIElement );
1353 aWriteLock.unlock();
1356 void LayoutManager::implts_refreshContextToolbarsVisibility()
1358 std::vector< UIElementVisibility > aToolbarVisibleVector;
1360 ReadGuard aReadLock( m_aLock );
1361 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1362 if ( !m_bVisible || !m_bAutomaticToolbars )
1363 return;
1365 UIElementVisibility aUIElementVisible;
1367 UIElementVector::iterator pIter;
1368 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
1370 if ( pIter->m_aType.equalsAsciiL( "toolbar", 7 ))
1372 aUIElementVisible.aName = pIter->m_aName;
1373 aUIElementVisible.bVisible = pIter->m_bVisible;
1374 aToolbarVisibleVector.push_back( aUIElementVisible );
1377 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1378 aReadLock.unlock();
1380 UIElement aUIElement;
1381 const sal_uInt32 nCount = aToolbarVisibleVector.size();
1382 for ( sal_uInt32 i = 0; i < nCount; i++ )
1384 UIElementVisibility& rToolbar = aToolbarVisibleVector[i];
1386 sal_Bool bVisible = rToolbar.bVisible;
1387 if ( implts_readWindowStateData( rToolbar.aName, aUIElement ) &&
1388 aUIElement.m_bVisible != bVisible )
1390 WriteGuard aWriteLock( m_aLock );
1391 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1392 UIElement& rUIElement = impl_findElement( rToolbar.aName );
1394 if ( rUIElement.m_aName == rToolbar.aName )
1395 rUIElement.m_bVisible = aUIElement.m_bVisible;
1396 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1397 aWriteLock.unlock();
1402 sal_Bool LayoutManager::implts_readWindowStateData( const rtl::OUString& aName, UIElement& rElementData )
1404 sal_Bool bGetSettingsState( sal_False );
1406 WriteGuard aWriteLock( m_aLock );
1407 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
1408 aWriteLock.unlock();
1410 if ( xPersistentWindowState.is() )
1412 aWriteLock.lock();
1413 sal_Bool bGlobalSettings( m_bGlobalSettings );
1414 GlobalSettings* pGlobalSettings( 0 );
1415 if ( m_pGlobalSettings == 0 )
1417 m_pGlobalSettings = new GlobalSettings( m_xSMGR );
1418 bGetSettingsState = sal_True;
1420 pGlobalSettings = m_pGlobalSettings;
1421 aWriteLock.unlock();
1425 Sequence< PropertyValue > aWindowState;
1426 if ( xPersistentWindowState->getByName( aName ) >>= aWindowState )
1428 sal_Bool bValue( sal_False );
1429 for ( sal_Int32 n = 0; n < aWindowState.getLength(); n++ )
1431 if ( aWindowState[n].Name == m_aPropDocked )
1433 if ( aWindowState[n].Value >>= bValue )
1434 rElementData.m_bFloating = !bValue;
1436 else if ( aWindowState[n].Name == m_aPropVisible )
1438 if ( aWindowState[n].Value >>= bValue )
1439 rElementData.m_bVisible = bValue;
1441 else if ( aWindowState[n].Name == m_aPropDockingArea )
1443 ::com::sun::star::ui::DockingArea eDockingArea;
1444 if ( aWindowState[n].Value >>= eDockingArea )
1445 rElementData.m_aDockedData.m_nDockedArea = sal_Int16( eDockingArea );
1447 else if ( aWindowState[n].Name == m_aPropDockPos )
1449 css::awt::Point aPoint;
1450 if ( aWindowState[n].Value >>= aPoint )
1452 rElementData.m_aDockedData.m_aPos.X() = aPoint.X;
1453 rElementData.m_aDockedData.m_aPos.Y() = aPoint.Y;
1456 else if ( aWindowState[n].Name == m_aPropPos )
1458 css::awt::Point aPoint;
1459 if ( aWindowState[n].Value >>= aPoint )
1461 rElementData.m_aFloatingData.m_aPos.X() = aPoint.X;
1462 rElementData.m_aFloatingData.m_aPos.Y() = aPoint.Y;
1465 else if ( aWindowState[n].Name == m_aPropSize )
1467 css::awt::Size aSize;
1468 if ( aWindowState[n].Value >>= aSize )
1470 rElementData.m_aFloatingData.m_aSize.Width() = aSize.Width;
1471 rElementData.m_aFloatingData.m_aSize.Height() = aSize.Height;
1474 else if ( aWindowState[n].Name == m_aPropUIName )
1475 aWindowState[n].Value >>= rElementData.m_aUIName;
1476 else if ( aWindowState[n].Name == m_aPropStyle )
1478 sal_Int32 nStyle = 0;
1479 if ( aWindowState[n].Value >>= nStyle )
1480 rElementData.m_nStyle = sal_Int16( nStyle );
1482 else if ( aWindowState[n].Name == m_aPropLocked )
1484 if ( aWindowState[n].Value >>= bValue )
1485 rElementData.m_aDockedData.m_bLocked = bValue;
1487 else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_CONTEXT ))
1489 if ( aWindowState[n].Value >>= bValue )
1490 rElementData.m_bContextSensitive = bValue;
1492 else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_NOCLOSE ))
1494 if ( aWindowState[n].Value >>= bValue )
1495 rElementData.m_bNoClose = bValue;
1497 else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_CONTEXTACTIVE ))
1499 if ( aWindowState[n].Value >>= bValue )
1500 rElementData.m_bContextActive = bValue;
1502 else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_SOFTCLOSE ))
1504 if ( aWindowState[n].Value >>= bValue )
1505 rElementData.m_bSoftClose = bValue;
1510 // oversteer values with global settings
1511 if ( pGlobalSettings && ( bGetSettingsState || bGlobalSettings ))
1513 if ( pGlobalSettings->HasStatesInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR ))
1515 WriteGuard aWriteLock2( m_aLock );
1516 m_bGlobalSettings = sal_True;
1517 aWriteLock2.unlock();
1519 css::uno::Any aValue;
1520 sal_Bool bValue = sal_Bool();
1521 if ( pGlobalSettings->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR,
1522 GlobalSettings::STATEINFO_LOCKED,
1523 aValue ))
1524 aValue >>= rElementData.m_aDockedData.m_bLocked;
1525 if ( pGlobalSettings->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR,
1526 GlobalSettings::STATEINFO_DOCKED,
1527 aValue ))
1529 if ( aValue >>= bValue )
1530 rElementData.m_bFloating = !bValue;
1535 return sal_True;
1537 catch ( NoSuchElementException& )
1542 return sal_False;
1545 void LayoutManager::implts_writeWindowStateData( const rtl::OUString& aName, const UIElement& rElementData )
1547 WriteGuard aWriteLock( m_aLock );
1548 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
1550 // set flag to determine that we triggered the notification
1551 m_bStoreWindowState = sal_True;
1552 aWriteLock.unlock();
1554 sal_Bool bPersistent( sal_False );
1555 Reference< XPropertySet > xPropSet( rElementData.m_xUIElement, UNO_QUERY );
1556 if ( xPropSet.is() )
1560 // Check persistent flag of the user interface element
1561 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ))) >>= bPersistent;
1563 catch ( com::sun::star::beans::UnknownPropertyException )
1565 // Non-configurable elements should at least store their dimension/position
1566 bPersistent = sal_True;
1568 catch ( com::sun::star::lang::WrappedTargetException )
1573 if ( bPersistent && xPersistentWindowState.is() )
1577 Sequence< PropertyValue > aWindowState( 8 );
1579 aWindowState[0].Name = m_aPropDocked;
1580 aWindowState[0].Value = makeAny( sal_Bool( !rElementData.m_bFloating ));
1581 aWindowState[1].Name = m_aPropVisible;
1582 aWindowState[1].Value = makeAny( sal_Bool( rElementData.m_bVisible ));
1584 aWindowState[2].Name = m_aPropDockingArea;
1585 aWindowState[2].Value = makeAny( static_cast< DockingArea >( rElementData.m_aDockedData.m_nDockedArea ) );
1587 css::awt::Point aPos;
1588 aPos.X = rElementData.m_aDockedData.m_aPos.X();
1589 aPos.Y = rElementData.m_aDockedData.m_aPos.Y();
1590 aWindowState[3].Name = m_aPropDockPos;
1591 aWindowState[3].Value <<= aPos;
1593 aPos.X = rElementData.m_aFloatingData.m_aPos.X();
1594 aPos.Y = rElementData.m_aFloatingData.m_aPos.Y();
1595 aWindowState[4].Name = m_aPropPos;
1596 aWindowState[4].Value <<= aPos;
1598 css::awt::Size aSize;
1599 aSize.Width = rElementData.m_aFloatingData.m_aSize.Width();
1600 aSize.Height = rElementData.m_aFloatingData.m_aSize.Height();
1601 aWindowState[5].Name = m_aPropSize;
1602 aWindowState[5].Value <<= aSize;
1603 aWindowState[6].Name = m_aPropUIName;
1604 aWindowState[6].Value = makeAny( rElementData.m_aUIName );
1605 aWindowState[7].Name = m_aPropLocked;
1606 aWindowState[7].Value = makeAny( rElementData.m_aDockedData.m_bLocked );
1608 if ( xPersistentWindowState->hasByName( aName ))
1610 Reference< XNameReplace > xReplace( xPersistentWindowState, UNO_QUERY );
1611 xReplace->replaceByName( aName, makeAny( aWindowState ));
1613 else
1615 Reference< XNameContainer > xInsert( xPersistentWindowState, UNO_QUERY );
1616 xInsert->insertByName( aName, makeAny( aWindowState ));
1619 catch ( Exception& )
1624 // Reset flag
1625 aWriteLock.lock();
1626 m_bStoreWindowState = sal_False;
1627 aWriteLock.unlock();
1630 void LayoutManager::implts_setElementData( UIElement& rElement, const Reference< css::awt::XDockableWindow >& rDockWindow )
1632 ReadGuard aReadLock( m_aLock );
1633 sal_Bool bShowElement( rElement.m_bVisible && !rElement.m_bMasterHide && m_bParentWindowVisible );
1634 aReadLock.unlock();
1636 Reference< css::awt::XDockableWindow > xDockWindow( rDockWindow );
1637 Reference< css::awt::XWindow2 > xWindow( xDockWindow, UNO_QUERY );
1639 Window* pWindow( 0 );
1640 ToolBox* pToolBox( 0 );
1642 if ( xDockWindow.is() && xWindow.is() )
1645 vos::OGuard aGuard( Application::GetSolarMutex() );
1646 pWindow = VCLUnoHelper::GetWindow( xWindow );
1647 if ( pWindow )
1649 String aText = pWindow->GetText();
1650 if ( aText.Len() == 0 )
1651 pWindow->SetText( rElement.m_aUIName );
1652 if ( rElement.m_bNoClose )
1653 pWindow->SetStyle( pWindow->GetStyle() & ~WB_CLOSEABLE );
1654 if ( pWindow->GetType() == WINDOW_TOOLBOX )
1655 pToolBox = (ToolBox *)pWindow;
1657 if ( pToolBox )
1659 if (( rElement.m_nStyle < 0 ) ||
1660 ( rElement.m_nStyle > BUTTON_SYMBOLTEXT ))
1661 rElement.m_nStyle = BUTTON_SYMBOL;
1662 pToolBox->SetButtonType( (ButtonType)rElement.m_nStyle );
1663 if ( rElement.m_bNoClose )
1664 pToolBox->SetFloatStyle( pToolBox->GetFloatStyle() & ~WB_CLOSEABLE );
1668 if ( rElement.m_bFloating )
1670 if ( pWindow )
1672 vos::OGuard aGuard( Application::GetSolarMutex() );
1673 String aText = pWindow->GetText();
1674 if ( aText.Len() == 0 )
1675 pWindow->SetText( rElement.m_aUIName );
1678 ::Point aPos( rElement.m_aFloatingData.m_aPos.X(),
1679 rElement.m_aFloatingData.m_aPos.Y() );
1680 sal_Bool bWriteData( sal_False );
1681 sal_Bool bUndefPos = ( rElement.m_aFloatingData.m_aPos.X() == SAL_MAX_INT32 ||
1682 rElement.m_aFloatingData.m_aPos.Y() == SAL_MAX_INT32 );
1683 sal_Bool bSetSize = ( rElement.m_aFloatingData.m_aSize.Width() != 0 &&
1684 rElement.m_aFloatingData.m_aSize.Height() != 0 );
1685 xDockWindow->setFloatingMode( sal_True );
1686 if ( bUndefPos )
1688 aPos = implts_findNextCascadeFloatingPos();
1689 rElement.m_aFloatingData.m_aPos = aPos; // set new cascaded position
1690 bWriteData = sal_True;
1693 if( bSetSize )
1694 xWindow->setOutputSize( AWTSize( rElement.m_aFloatingData.m_aSize ) );
1695 else
1697 if( pToolBox )
1699 // set an optimal initial floating size
1700 vos::OGuard aGuard( Application::GetSolarMutex() );
1701 ::Size aSize( pToolBox->CalcFloatingWindowSizePixel() );
1702 pToolBox->SetOutputSizePixel( aSize );
1706 // #i60882# IMPORTANT: Set position after size as it is
1707 // possible that we position some part of the toolbar
1708 // outside of the desktop. A default constructed toolbar
1709 // always has one line. Now VCL automatically
1710 // position the toolbar back into the desktop. Therefore
1711 // we resize the toolbar with the new (wrong) position.
1712 // To fix this problem we have to set the size BEFORE the
1713 // position.
1714 xWindow->setPosSize( aPos.X(), aPos.Y(), 0, 0,
1715 css::awt::PosSize::POS );
1717 if ( bWriteData )
1718 implts_writeWindowStateData( rElement.m_aName, rElement );
1719 if ( bShowElement && pWindow )
1721 vos::OGuard aGuard( Application::GetSolarMutex() );
1722 pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1725 else
1727 ::Point aDockPos;
1728 ::Point aPixelPos;
1729 sal_Bool bSetSize( sal_False );
1730 ::Size aSize;
1732 if ( pToolBox )
1734 vos::OGuard aGuard( Application::GetSolarMutex() );
1735 pToolBox->SetAlign( ImplConvertAlignment(rElement.m_aDockedData.m_nDockedArea ) );
1736 pToolBox->SetLineCount( 1 );
1737 if ( rElement.m_aDockedData.m_bLocked )
1738 xDockWindow->lock();
1739 aSize = pToolBox->CalcWindowSizePixel();
1740 bSetSize = sal_True;
1742 if (( rElement.m_aDockedData.m_aPos.X() == SAL_MAX_INT32 ) &&
1743 ( rElement.m_aDockedData.m_aPos.Y() == SAL_MAX_INT32 ))
1745 implts_findNextDockingPos( (DockingArea)rElement.m_aDockedData.m_nDockedArea,
1746 aSize,
1747 aDockPos,
1748 aPixelPos );
1749 rElement.m_aDockedData.m_aPos = aDockPos;
1753 xWindow->setPosSize( aPixelPos.X(),
1754 aPixelPos.Y(),
1755 0, 0,
1756 css::awt::PosSize::POS );
1757 if( bSetSize )
1758 xWindow->setOutputSize( AWTSize( aSize) );
1760 if ( bShowElement && pWindow )
1762 vos::OGuard aGuard( Application::GetSolarMutex() );
1763 pWindow->Show( sal_True );
1769 ::Point LayoutManager::implts_findNextCascadeFloatingPos()
1771 const sal_Int32 nHotZoneX = 50;
1772 const sal_Int32 nHotZoneY = 50;
1773 const sal_Int32 nCascadeIndentX = 15;
1774 const sal_Int32 nCascadeIndentY = 15;
1776 ReadGuard aReadLock( m_aLock );
1777 Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow;
1778 Reference< css::awt::XWindow > xTopDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP];
1779 Reference< css::awt::XWindow > xLeftDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT];
1780 aReadLock.unlock();
1782 ::Point aStartPos( nCascadeIndentX, nCascadeIndentY );
1783 ::Point aCurrPos( aStartPos );
1784 css::awt::Rectangle aRect;
1786 Window* pContainerWindow( 0 );
1787 if ( xContainerWindow.is() )
1789 vos::OGuard aGuard( Application::GetSolarMutex() );
1790 pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
1791 if ( pContainerWindow )
1792 aStartPos = pContainerWindow->OutputToScreenPixel( aStartPos );
1795 // Determine size of top and left docking area
1796 css::awt::Rectangle aTopRect = xTopDockingWindow->getPosSize();
1797 css::awt::Rectangle aLeftRect = xLeftDockingWindow->getPosSize();
1799 aStartPos.X() += aLeftRect.Width + nCascadeIndentX;
1800 aStartPos.Y() += aTopRect.Height + nCascadeIndentY;
1801 aCurrPos = aStartPos;
1803 // Try to find a cascaded position for the new floating window
1804 UIElementVector::const_iterator pIter;
1805 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
1807 if ( pIter->m_xUIElement.is() )
1809 Reference< css::awt::XDockableWindow > xDockWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
1810 Reference< css::awt::XWindow > xWindow( xDockWindow, UNO_QUERY );
1811 if ( xDockWindow.is() && xDockWindow->isFloating() )
1813 vos::OGuard aGuard( Application::GetSolarMutex() );
1814 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
1815 if ( pWindow && pWindow->IsVisible() )
1817 css::awt::Rectangle aFloatRect = xWindow->getPosSize();
1818 if ((( aFloatRect.X - nHotZoneX ) <= aCurrPos.X() ) &&
1819 ( aFloatRect.X >= aCurrPos.X() ) &&
1820 (( aFloatRect.Y - nHotZoneY ) <= aCurrPos.Y() ) &&
1821 ( aFloatRect.Y >= aCurrPos.Y() ))
1823 aCurrPos.X() = aFloatRect.X + nCascadeIndentX;
1824 aCurrPos.Y() = aFloatRect.Y + nCascadeIndentY;
1831 return aCurrPos;
1834 void LayoutManager::implts_findNextDockingPos( DockingArea DockingArea, const ::Size& aUIElementSize, ::Point& rVirtualPos, ::Point& rPixelPos )
1836 ReadGuard aReadLock( m_aLock );
1837 Reference< css::awt::XWindow > xDockingWindow = m_xDockAreaWindows[DockingArea];
1838 ::Size aDockingWinSize;
1839 Window* pDockingWindow( 0 );
1840 aReadLock.unlock();
1842 if (( DockingArea < DockingArea_DOCKINGAREA_TOP ) ||
1843 ( DockingArea > DockingArea_DOCKINGAREA_RIGHT ))
1844 DockingArea = DockingArea_DOCKINGAREA_TOP;
1847 // Retrieve output size from container Window
1848 vos::OGuard aGuard( Application::GetSolarMutex() );
1849 pDockingWindow = VCLUnoHelper::GetWindow( xDockingWindow );
1850 if ( pDockingWindow )
1851 aDockingWinSize = pDockingWindow->GetOutputSizePixel();
1854 sal_Int32 nFreeRowColPixelPos( 0 );
1855 sal_Int32 nMaxSpace( 0 );
1856 sal_Int32 nNeededSpace( 0 );
1857 sal_Int32 nTopDockingAreaSize( 0 );
1859 if (( DockingArea == DockingArea_DOCKINGAREA_TOP ) ||
1860 ( DockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
1862 nMaxSpace = aDockingWinSize.Width();
1863 nNeededSpace = aUIElementSize.Width();
1865 else
1867 nMaxSpace = aDockingWinSize.Height();
1868 nNeededSpace = aUIElementSize.Height();
1869 nTopDockingAreaSize = implts_getTopBottomDockingAreaSizes().Width();
1872 std::vector< SingleRowColumnWindowData > aRowColumnsWindowData;
1874 implts_getDockingAreaElementInfos( DockingArea, aRowColumnsWindowData );
1875 sal_Int32 nPixelPos( 0 );
1876 const sal_uInt32 nCount = aRowColumnsWindowData.size();
1877 for ( sal_uInt32 i = 0; i < nCount; i++ )
1879 SingleRowColumnWindowData& rRowColumnWindowData = aRowColumnsWindowData[i];
1881 if (( DockingArea == DockingArea_DOCKINGAREA_BOTTOM ) ||
1882 ( DockingArea == DockingArea_DOCKINGAREA_RIGHT ))
1883 nPixelPos += rRowColumnWindowData.nStaticSize;
1885 if ((( nMaxSpace - rRowColumnWindowData.nVarSize ) >= nNeededSpace ) ||
1886 ( rRowColumnWindowData.nSpace >= nNeededSpace ))
1888 // Check current row where we can find the needed space
1889 sal_Int32 nCurrPos( 0 );
1890 const sal_uInt32 nWindowSizesCount = rRowColumnWindowData.aRowColumnWindowSizes.size();
1891 for ( sal_uInt32 j = 0; j < nWindowSizesCount; j++ )
1893 css::awt::Rectangle rRect = rRowColumnWindowData.aRowColumnWindowSizes[j];
1894 sal_Int32& rSpace = rRowColumnWindowData.aRowColumnSpace[j];
1895 if (( DockingArea == DockingArea_DOCKINGAREA_TOP ) ||
1896 ( DockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
1898 if ( rSpace >= nNeededSpace )
1900 rVirtualPos = ::Point( nCurrPos, rRowColumnWindowData.nRowColumn );
1901 if ( DockingArea == DockingArea_DOCKINGAREA_TOP )
1902 rPixelPos = ::Point( nCurrPos, nPixelPos );
1903 else
1904 rPixelPos = ::Point( nCurrPos, aDockingWinSize.Height() - nPixelPos );
1905 return;
1907 nCurrPos = rRect.X + rRect.Width;
1909 else
1911 if ( rSpace >= nNeededSpace )
1913 rVirtualPos = ::Point( rRowColumnWindowData.nRowColumn, nCurrPos );
1914 if ( DockingArea == DockingArea_DOCKINGAREA_LEFT )
1915 rPixelPos = ::Point( nPixelPos, nTopDockingAreaSize + nCurrPos );
1916 else
1917 rPixelPos = ::Point( aDockingWinSize.Width() - nPixelPos , nTopDockingAreaSize + nCurrPos );
1918 return;
1920 nCurrPos = rRect.Y + rRect.Height;
1924 if (( nCurrPos + nNeededSpace ) <= nMaxSpace )
1926 if (( DockingArea == DockingArea_DOCKINGAREA_TOP ) ||
1927 ( DockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
1929 rVirtualPos = ::Point( nCurrPos, rRowColumnWindowData.nRowColumn );
1930 if ( DockingArea == DockingArea_DOCKINGAREA_TOP )
1931 rPixelPos = ::Point( nCurrPos, nPixelPos );
1932 else
1933 rPixelPos = ::Point( nCurrPos, aDockingWinSize.Height() - nPixelPos );
1934 return;
1936 else
1938 rVirtualPos = ::Point( rRowColumnWindowData.nRowColumn, nCurrPos );
1939 if ( DockingArea == DockingArea_DOCKINGAREA_LEFT )
1940 rPixelPos = ::Point( nPixelPos, nTopDockingAreaSize + nCurrPos );
1941 else
1942 rPixelPos = ::Point( aDockingWinSize.Width() - nPixelPos , nTopDockingAreaSize + nCurrPos );
1943 return;
1948 if (( DockingArea == DockingArea_DOCKINGAREA_TOP ) ||
1949 ( DockingArea == DockingArea_DOCKINGAREA_LEFT ))
1950 nPixelPos += rRowColumnWindowData.nStaticSize;
1953 sal_Int32 nNextFreeRowCol( 0 );
1954 sal_Int32 nRowColumnsCount = aRowColumnsWindowData.size();
1955 if ( nRowColumnsCount > 0 )
1956 nNextFreeRowCol = aRowColumnsWindowData[nRowColumnsCount-1].nRowColumn+1;
1957 else
1958 nNextFreeRowCol = 0;
1960 if ( nNextFreeRowCol == 0 )
1962 if ( DockingArea == DockingArea_DOCKINGAREA_BOTTOM )
1963 nFreeRowColPixelPos = aDockingWinSize.Height() - aUIElementSize.Height();
1964 else if ( DockingArea == DockingArea_DOCKINGAREA_RIGHT )
1965 nFreeRowColPixelPos = aDockingWinSize.Width() - aUIElementSize.Width();
1968 if (( DockingArea == DockingArea_DOCKINGAREA_TOP ) ||
1969 ( DockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
1971 rVirtualPos = ::Point( 0, nNextFreeRowCol );
1972 if ( DockingArea == DockingArea_DOCKINGAREA_TOP )
1973 rPixelPos = ::Point( 0, nFreeRowColPixelPos );
1974 else
1975 rPixelPos = ::Point( 0, aDockingWinSize.Height() - nFreeRowColPixelPos );
1977 else
1979 rVirtualPos = ::Point( nNextFreeRowCol, 0 );
1980 rPixelPos = ::Point( aDockingWinSize.Width() - nFreeRowColPixelPos, 0 );
1984 ::Size LayoutManager::implts_getContainerWindowOutputSize()
1986 ReadGuard aReadLock( m_aLock );
1987 Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow;
1988 ::Size aContainerWinSize;
1989 Window* pContainerWindow( 0 );
1990 aReadLock.unlock();
1992 // Retrieve output size from container Window
1993 vos::OGuard aGuard( Application::GetSolarMutex() );
1994 pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
1995 if ( pContainerWindow )
1996 return pContainerWindow->GetOutputSizePixel();
1997 else
1998 return ::Size();
2001 void LayoutManager::implts_sortUIElements()
2003 WriteGuard aWriteLock( m_aLock );
2004 UIElementVector::iterator pIterStart = m_aUIElements.begin();
2005 UIElementVector::iterator pIterEnd = m_aUIElements.end();
2007 std::stable_sort( pIterStart, pIterEnd ); // first created element should first
2009 // We have to reset our temporary flags.
2010 UIElementVector::iterator pIter;
2011 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
2013 // why check, just set it to false
2014 //if ( pIter->m_bUserActive )
2015 pIter->m_bUserActive = sal_False;
2018 #ifdef DBG_UTIL
2019 implts_checkElementContainer();
2020 #endif
2021 aWriteLock.unlock();
2024 void LayoutManager::implts_getDockingAreaElementInfos( DockingArea eDockingArea, std::vector< SingleRowColumnWindowData >& rRowColumnsWindowData )
2026 std::vector< UIElement > aWindowVector;
2028 if (( eDockingArea < DockingArea_DOCKINGAREA_TOP ) ||
2029 ( eDockingArea > DockingArea_DOCKINGAREA_RIGHT ))
2030 eDockingArea = DockingArea_DOCKINGAREA_TOP;
2032 Reference< css::awt::XWindow > xDockAreaWindow;
2034 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2035 ReadGuard aReadLock( m_aLock );
2036 aWindowVector.reserve(m_aUIElements.size());
2037 xDockAreaWindow = m_xDockAreaWindows[eDockingArea];
2038 UIElementVector::iterator pIter;
2039 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
2041 if ( pIter->m_aDockedData.m_nDockedArea == eDockingArea && pIter->m_bVisible && !pIter->m_bFloating )
2043 Reference< XUIElement > xUIElement( pIter->m_xUIElement );
2044 if ( xUIElement.is() )
2046 Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
2047 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
2048 if ( xDockWindow.is() )
2050 // docked windows
2051 aWindowVector.push_back( *pIter );
2056 aReadLock.unlock();
2057 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2059 rRowColumnsWindowData.clear();
2061 // Collect data from windows that are on the same row/column
2062 sal_Int32 j;
2063 sal_Int32 nIndex( 0 );
2064 sal_Int32 nLastPos( 0 );
2065 sal_Int32 nCurrPos( -1 );
2066 sal_Int32 nLastRowColPixelPos( 0 );
2067 css::awt::Rectangle aDockAreaRect;
2069 if ( xDockAreaWindow.is() )
2070 aDockAreaRect = xDockAreaWindow->getPosSize();
2072 if ( eDockingArea == DockingArea_DOCKINGAREA_TOP )
2073 nLastRowColPixelPos = 0;
2074 else if ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM )
2075 nLastRowColPixelPos = aDockAreaRect.Height;
2076 else if ( eDockingArea == DockingArea_DOCKINGAREA_LEFT )
2077 nLastRowColPixelPos = 0;
2078 else
2079 nLastRowColPixelPos = aDockAreaRect.Width;
2081 const sal_uInt32 nCount = aWindowVector.size();
2082 for ( j = 0; j < sal_Int32( nCount); j++ )
2084 const UIElement& rElement = aWindowVector[j];
2085 Reference< css::awt::XWindow > xWindow;
2086 Reference< XUIElement > xUIElement( rElement.m_xUIElement );
2087 css::awt::Rectangle aPosSize;
2088 if ( !lcl_checkUIElement(xUIElement,aPosSize,xWindow) )
2089 continue;
2090 if (( eDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
2091 ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
2093 if ( nCurrPos == -1 )
2095 nCurrPos = rElement.m_aDockedData.m_aPos.Y();
2096 nLastPos = 0;
2098 SingleRowColumnWindowData aRowColumnWindowData;
2099 aRowColumnWindowData.nRowColumn = nCurrPos;
2100 rRowColumnsWindowData.push_back( aRowColumnWindowData );
2103 sal_Int32 nSpace( 0 );
2104 if ( rElement.m_aDockedData.m_aPos.Y() != nCurrPos )
2106 if ( eDockingArea == DockingArea_DOCKINGAREA_TOP )
2107 nLastRowColPixelPos += rRowColumnsWindowData[nIndex].nStaticSize;
2108 else
2109 nLastRowColPixelPos -= rRowColumnsWindowData[nIndex].nStaticSize;
2110 ++nIndex;
2111 nLastPos = 0;
2112 nCurrPos = rElement.m_aDockedData.m_aPos.Y();
2113 SingleRowColumnWindowData aRowColumnWindowData;
2114 aRowColumnWindowData.nRowColumn = nCurrPos;
2115 rRowColumnsWindowData.push_back( aRowColumnWindowData );
2118 // Calc space before an element and store it
2119 nSpace = ( rElement.m_aDockedData.m_aPos.X() - nLastPos );
2120 if ( rElement.m_aDockedData.m_aPos.X() >= nLastPos )
2122 rRowColumnsWindowData[nIndex].nSpace += nSpace;
2123 nLastPos = rElement.m_aDockedData.m_aPos.X() + aPosSize.Width;
2125 else
2127 nSpace = 0;
2128 nLastPos += aPosSize.Width;
2130 rRowColumnsWindowData[nIndex].aRowColumnSpace.push_back( nSpace );
2132 rRowColumnsWindowData[nIndex].aRowColumnWindows.push_back( xWindow );
2133 rRowColumnsWindowData[nIndex].aUIElementNames.push_back( rElement.m_aName );
2134 rRowColumnsWindowData[nIndex].aRowColumnWindowSizes.push_back(
2135 css::awt::Rectangle( rElement.m_aDockedData.m_aPos.X(),
2136 rElement.m_aDockedData.m_aPos.Y(),
2137 aPosSize.Width,
2138 aPosSize.Height ));
2139 if ( rRowColumnsWindowData[nIndex].nStaticSize < aPosSize.Height )
2140 rRowColumnsWindowData[nIndex].nStaticSize = aPosSize.Height;
2141 if ( eDockingArea == DockingArea_DOCKINGAREA_TOP )
2142 rRowColumnsWindowData[nIndex].aRowColumnRect = css::awt::Rectangle( 0, nLastRowColPixelPos,
2143 aDockAreaRect.Width, aPosSize.Height );
2144 else
2145 rRowColumnsWindowData[nIndex].aRowColumnRect = css::awt::Rectangle( 0, ( nLastRowColPixelPos - aPosSize.Height ),
2146 aDockAreaRect.Width, aPosSize.Height );
2147 rRowColumnsWindowData[nIndex].nVarSize += aPosSize.Width + nSpace;
2149 else
2151 if ( nCurrPos == -1 )
2153 nCurrPos = rElement.m_aDockedData.m_aPos.X();
2154 nLastPos = 0;
2156 SingleRowColumnWindowData aRowColumnWindowData;
2157 aRowColumnWindowData.nRowColumn = nCurrPos;
2158 rRowColumnsWindowData.push_back( aRowColumnWindowData );
2161 sal_Int32 nSpace( 0 );
2162 if ( rElement.m_aDockedData.m_aPos.X() != nCurrPos )
2164 if ( eDockingArea == DockingArea_DOCKINGAREA_LEFT )
2165 nLastRowColPixelPos += rRowColumnsWindowData[nIndex].nStaticSize;
2166 else
2167 nLastRowColPixelPos -= rRowColumnsWindowData[nIndex].nStaticSize;
2168 ++nIndex;
2169 nLastPos = 0;
2170 nCurrPos = rElement.m_aDockedData.m_aPos.X();
2171 SingleRowColumnWindowData aRowColumnWindowData;
2172 aRowColumnWindowData.nRowColumn = nCurrPos;
2173 rRowColumnsWindowData.push_back( aRowColumnWindowData );
2176 // Calc space before an element and store it
2177 nSpace = ( rElement.m_aDockedData.m_aPos.Y() - nLastPos );
2178 if ( rElement.m_aDockedData.m_aPos.Y() > nLastPos )
2180 rRowColumnsWindowData[nIndex].nSpace += nSpace;
2181 nLastPos = rElement.m_aDockedData.m_aPos.Y() + aPosSize.Height;
2183 else
2185 nSpace = 0;
2186 nLastPos += aPosSize.Height;
2188 rRowColumnsWindowData[nIndex].aRowColumnSpace.push_back( nSpace );
2190 rRowColumnsWindowData[nIndex].aRowColumnWindows.push_back( xWindow );
2191 rRowColumnsWindowData[nIndex].aUIElementNames.push_back( rElement.m_aName );
2192 rRowColumnsWindowData[nIndex].aRowColumnWindowSizes.push_back(
2193 css::awt::Rectangle( rElement.m_aDockedData.m_aPos.X(),
2194 rElement.m_aDockedData.m_aPos.Y(),
2195 aPosSize.Width,
2196 aPosSize.Height ));
2197 if ( rRowColumnsWindowData[nIndex].nStaticSize < aPosSize.Width )
2198 rRowColumnsWindowData[nIndex].nStaticSize = aPosSize.Width;
2199 if ( eDockingArea == DockingArea_DOCKINGAREA_LEFT )
2200 rRowColumnsWindowData[nIndex].aRowColumnRect = css::awt::Rectangle( nLastRowColPixelPos, 0,
2201 aPosSize.Width, aDockAreaRect.Height );
2202 else
2203 rRowColumnsWindowData[nIndex].aRowColumnRect = css::awt::Rectangle( ( nLastRowColPixelPos - aPosSize.Width ), 0,
2204 aPosSize.Width, aDockAreaRect.Height );
2205 rRowColumnsWindowData[nIndex].nVarSize += aPosSize.Height + nSpace;
2210 void LayoutManager::implts_getDockingAreaElementInfoOnSingleRowCol( DockingArea eDockingArea, sal_Int32 nRowCol, SingleRowColumnWindowData& rRowColumnWindowData )
2212 std::vector< UIElement > aWindowVector;
2214 if (( eDockingArea < DockingArea_DOCKINGAREA_TOP ) ||
2215 ( eDockingArea > DockingArea_DOCKINGAREA_RIGHT ))
2216 eDockingArea = DockingArea_DOCKINGAREA_TOP;
2218 sal_Bool bHorzDockArea = (( eDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
2219 ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM ));
2221 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2222 ReadGuard aReadLock( m_aLock );
2223 UIElementVector::iterator pIter;
2224 UIElementVector::iterator pEnd = m_aUIElements.end();
2225 for ( pIter = m_aUIElements.begin(); pIter != pEnd; pIter++ )
2227 if ( pIter->m_aDockedData.m_nDockedArea == eDockingArea )
2229 sal_Bool bSameRowCol = bHorzDockArea ?
2230 ( pIter->m_aDockedData.m_aPos.Y() == nRowCol ) :
2231 ( pIter->m_aDockedData.m_aPos.X() == nRowCol );
2232 Reference< XUIElement > xUIElement( pIter->m_xUIElement );
2234 if ( bSameRowCol && xUIElement.is() )
2236 Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
2237 if ( xWindow.is() )
2239 vos::OGuard aGuard( Application::GetSolarMutex() );
2240 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
2241 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
2242 if ( pWindow && pIter->m_bVisible && xDockWindow.is() && !pIter->m_bFloating )
2244 // docked windows
2245 aWindowVector.push_back( *pIter );
2251 aReadLock.unlock();
2252 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2254 // Initialize structure
2255 rRowColumnWindowData.aUIElementNames.clear();
2256 rRowColumnWindowData.aRowColumnWindows.clear();
2257 rRowColumnWindowData.aRowColumnWindowSizes.clear();
2258 rRowColumnWindowData.aRowColumnSpace.clear();
2259 rRowColumnWindowData.nVarSize = 0;
2260 rRowColumnWindowData.nStaticSize = 0;
2261 rRowColumnWindowData.nSpace = 0;
2262 rRowColumnWindowData.nRowColumn = nRowCol;
2264 // Collect data from windows that are on the same row/column
2265 sal_Int32 j;
2266 sal_Int32 nLastPos( 0 );
2268 const sal_uInt32 nCount = aWindowVector.size();
2269 for ( j = 0; j < sal_Int32( nCount); j++ )
2271 const UIElement& rElement = aWindowVector[j];
2272 Reference< css::awt::XWindow > xWindow;
2273 Reference< XUIElement > xUIElement( rElement.m_xUIElement );
2274 css::awt::Rectangle aPosSize;
2275 if ( !lcl_checkUIElement(xUIElement,aPosSize,xWindow) )
2276 continue;
2278 sal_Int32 nSpace;
2279 if (( eDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
2280 ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
2282 nSpace = ( rElement.m_aDockedData.m_aPos.X() - nLastPos );
2284 // Calc space before an element and store it
2285 if ( rElement.m_aDockedData.m_aPos.X() > nLastPos )
2286 rRowColumnWindowData.nSpace += nSpace;
2287 else
2288 nSpace = 0;
2290 nLastPos = rElement.m_aDockedData.m_aPos.X() + aPosSize.Width;
2293 rRowColumnWindowData.aRowColumnWindowSizes.push_back(
2294 css::awt::Rectangle( rElement.m_aDockedData.m_aPos.X(),
2295 rElement.m_aDockedData.m_aPos.Y(),
2296 aPosSize.Width,
2297 aPosSize.Height ));
2298 if ( rRowColumnWindowData.nStaticSize < aPosSize.Height )
2299 rRowColumnWindowData.nStaticSize = aPosSize.Height;
2300 rRowColumnWindowData.nVarSize += aPosSize.Width;
2302 else
2304 // Calc space before an element and store it
2305 nSpace = ( rElement.m_aDockedData.m_aPos.Y() - nLastPos );
2306 if ( rElement.m_aDockedData.m_aPos.Y() > nLastPos )
2307 rRowColumnWindowData.nSpace += nSpace;
2308 else
2309 nSpace = 0;
2311 nLastPos = rElement.m_aDockedData.m_aPos.Y() + aPosSize.Height;
2313 rRowColumnWindowData.aRowColumnWindowSizes.push_back(
2314 css::awt::Rectangle( rElement.m_aDockedData.m_aPos.X(),
2315 rElement.m_aDockedData.m_aPos.Y(),
2316 aPosSize.Width,
2317 aPosSize.Height ));
2318 if ( rRowColumnWindowData.nStaticSize < aPosSize.Width )
2319 rRowColumnWindowData.nStaticSize = aPosSize.Width;
2320 rRowColumnWindowData.nVarSize += aPosSize.Height;
2323 rRowColumnWindowData.aUIElementNames.push_back( rElement.m_aName );
2324 rRowColumnWindowData.aRowColumnWindows.push_back( xWindow );
2325 rRowColumnWindowData.aRowColumnSpace.push_back( nSpace );
2326 rRowColumnWindowData.nVarSize += nSpace;
2330 ::Rectangle LayoutManager::implts_determineFrontDockingRect(
2331 DockingArea eDockingArea,
2332 sal_Int32 nRowCol,
2333 const ::Rectangle& rDockedElementRect,
2334 const ::rtl::OUString& rMovedElementName,
2335 const ::Rectangle& rMovedElementRect )
2337 SingleRowColumnWindowData aRowColumnWindowData;
2339 sal_Bool bHorzDockArea = (( eDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
2340 ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM ));
2342 implts_getDockingAreaElementInfoOnSingleRowCol( eDockingArea, nRowCol, aRowColumnWindowData );
2343 if ( aRowColumnWindowData.aRowColumnWindows.empty() )
2344 return rMovedElementRect;
2345 else
2347 sal_Int32 nSpace( 0 );
2348 ::Rectangle aFrontDockingRect( rMovedElementRect );
2349 const sal_uInt32 nCount = aRowColumnWindowData.aRowColumnWindows.size();
2350 for ( sal_uInt32 i = 0; i < nCount; i++ )
2352 if ( bHorzDockArea )
2354 if ( aRowColumnWindowData.aRowColumnWindowSizes[i].X >= rDockedElementRect.Left() )
2356 nSpace += aRowColumnWindowData.aRowColumnSpace[i];
2357 break;
2359 else if ( aRowColumnWindowData.aUIElementNames[i] == rMovedElementName )
2360 nSpace += aRowColumnWindowData.aRowColumnWindowSizes[i].Width +
2361 aRowColumnWindowData.aRowColumnSpace[i];
2362 else
2363 nSpace = 0;
2365 else
2367 if ( aRowColumnWindowData.aRowColumnWindowSizes[i].Y >= rDockedElementRect.Top() )
2369 nSpace += aRowColumnWindowData.aRowColumnSpace[i];
2370 break;
2372 else if ( aRowColumnWindowData.aUIElementNames[i] == rMovedElementName )
2373 nSpace += aRowColumnWindowData.aRowColumnWindowSizes[i].Height +
2374 aRowColumnWindowData.aRowColumnSpace[i];
2375 else
2376 nSpace = 0;
2380 if ( nSpace > 0 )
2382 sal_Int32 nMove = std::min( nSpace, static_cast<sal_Int32>(aFrontDockingRect.getWidth()) );
2383 if ( bHorzDockArea )
2384 aFrontDockingRect.Move( -nMove, 0 );
2385 else
2386 aFrontDockingRect.Move( 0, -nMove );
2389 return aFrontDockingRect;
2393 ::Rectangle LayoutManager::implts_getWindowRectFromRowColumn(
2394 ::com::sun::star::ui::DockingArea DockingArea,
2395 const SingleRowColumnWindowData& rRowColumnWindowData,
2396 const ::Point& rMousePos,
2397 const rtl::OUString& rExcludeElementName )
2399 ::Rectangle aWinRect;
2401 if (( DockingArea < DockingArea_DOCKINGAREA_TOP ) ||
2402 ( DockingArea > DockingArea_DOCKINGAREA_RIGHT ))
2403 DockingArea = DockingArea_DOCKINGAREA_TOP;
2405 if ( rRowColumnWindowData.aRowColumnWindows.empty() )
2406 return aWinRect;
2407 else
2409 ReadGuard aReadLock( m_aLock );
2410 Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow;
2411 Reference< css::awt::XWindow > xDockingAreaWindow = m_xDockAreaWindows[DockingArea];
2412 aReadLock.unlock();
2414 // Calc correct position of the column/row rectangle to be able to compare it with mouse pos/tracking rect
2415 vos::OGuard aGuard( Application::GetSolarMutex() );
2417 // Retrieve output size from container Window
2418 Window* pContainerWindow( VCLUnoHelper::GetWindow( xContainerWindow ));
2419 Window* pDockingAreaWindow( VCLUnoHelper::GetWindow( xDockingAreaWindow ));
2420 if ( pDockingAreaWindow && pContainerWindow )
2422 const sal_uInt32 nCount = rRowColumnWindowData.aRowColumnWindows.size();
2423 for ( sal_uInt32 i = 0; i < nCount; i++ )
2425 css::awt::Rectangle aWindowRect = rRowColumnWindowData.aRowColumnWindows[i]->getPosSize();
2426 ::Rectangle aRect( aWindowRect.X, aWindowRect.Y, aWindowRect.X+aWindowRect.Width, aWindowRect.Y+aWindowRect.Height );
2427 aRect.SetPos( pContainerWindow->ScreenToOutputPixel( pDockingAreaWindow->OutputToScreenPixel( aRect.TopLeft() )));
2428 if ( aRect.IsInside( rMousePos ))
2430 // Check if we have found the excluded element. If yes, we have to provide an empty rectangle.
2431 // We prevent that a toolbar cannot be moved when the mouse pointer is inside its own rectangle!
2432 if ( rExcludeElementName != rRowColumnWindowData.aUIElementNames[i] )
2433 return aRect;
2434 else
2435 break;
2441 return aWinRect;
2444 framework::LayoutManager::DockingOperation
2445 LayoutManager::implts_determineDockingOperation(
2446 ::com::sun::star::ui::DockingArea DockingArea,
2447 const ::Rectangle& rRowColRect,
2448 const Point& rMousePos )
2450 const sal_Int32 nHorzVerticalRegionSize = 6;
2451 const sal_Int32 nHorzVerticalMoveRegion = 4;
2453 if ( rRowColRect.IsInside( rMousePos ))
2455 if (( DockingArea == DockingArea_DOCKINGAREA_TOP ) ||
2456 ( DockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
2458 sal_Int32 nRegion = rRowColRect.getHeight() / nHorzVerticalRegionSize;
2459 sal_Int32 nPosY = rRowColRect.Top() + nRegion;
2461 if ( rMousePos.Y() < nPosY )
2462 return ( DockingArea == DockingArea_DOCKINGAREA_TOP ) ? DOCKOP_BEFORE_COLROW : DOCKOP_AFTER_COLROW;
2463 else if ( rMousePos.Y() < ( nPosY + nRegion*nHorzVerticalMoveRegion ))
2464 return DOCKOP_ON_COLROW;
2465 else
2466 return ( DockingArea == DockingArea_DOCKINGAREA_TOP ) ? DOCKOP_AFTER_COLROW : DOCKOP_BEFORE_COLROW;
2468 else
2470 sal_Int32 nRegion = rRowColRect.getWidth() / nHorzVerticalRegionSize;
2471 sal_Int32 nPosX = rRowColRect.Left() + nRegion;
2473 if ( rMousePos.X() < nPosX )
2474 return ( DockingArea == DockingArea_DOCKINGAREA_LEFT ) ? DOCKOP_BEFORE_COLROW : DOCKOP_AFTER_COLROW;
2475 else if ( rMousePos.X() < ( nPosX + nRegion*nHorzVerticalMoveRegion ))
2476 return DOCKOP_ON_COLROW;
2477 else
2478 return ( DockingArea == DockingArea_DOCKINGAREA_LEFT ) ? DOCKOP_AFTER_COLROW : DOCKOP_BEFORE_COLROW;
2481 else
2482 return DOCKOP_ON_COLROW;
2485 ::Rectangle LayoutManager::implts_calcTrackingAndElementRect(
2486 ::com::sun::star::ui::DockingArea eDockingArea,
2487 sal_Int32 nRowCol,
2488 UIElement& rUIElement,
2489 const ::Rectangle& rTrackingRect,
2490 const ::Rectangle& rRowColumnRect,
2491 const ::Size& rContainerWinSize )
2493 sal_Bool bHorizontalDockArea( ( eDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
2494 ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM ));
2496 sal_Int32 nTopDockingAreaSize( implts_getTopBottomDockingAreaSizes().Width() );
2497 sal_Int32 nBottomDockingAreaSize( implts_getTopBottomDockingAreaSizes().Height() );
2499 ::Size aStatusBarSize( implts_getStatusBarSize() );
2500 sal_Int32 nMaxLeftRightDockAreaSize = rContainerWinSize.Height() -
2501 nTopDockingAreaSize -
2502 nBottomDockingAreaSize -
2503 aStatusBarSize.Height();
2505 ::Rectangle aTrackingRect( rTrackingRect );
2506 if ( bHorizontalDockArea )
2508 sal_Int32 nPosX( std::max( sal_Int32( rTrackingRect.Left()), sal_Int32( 0 )));
2509 if (( nPosX + rTrackingRect.getWidth()) > rContainerWinSize.Width() )
2510 nPosX = std::min( nPosX,
2511 std::max( sal_Int32( rContainerWinSize.Width() - rTrackingRect.getWidth() ),
2512 sal_Int32( 0 )));
2514 sal_Int32 nSize = std::min( rContainerWinSize.Width(), rTrackingRect.getWidth() );
2516 aTrackingRect.SetPos( ::Point( nPosX, rRowColumnRect.Top() ));
2517 aTrackingRect.setWidth( nSize );
2518 aTrackingRect.setHeight( rRowColumnRect.getHeight() );
2520 // Set virtual position
2521 rUIElement.m_aDockedData.m_aPos.X() = nPosX;
2522 rUIElement.m_aDockedData.m_aPos.Y() = nRowCol;
2524 else
2526 sal_Int32 nMaxDockingAreaHeight = std::max( sal_Int32( 0 ),
2527 sal_Int32( nMaxLeftRightDockAreaSize ));
2529 sal_Int32 nPosY( std::max( sal_Int32( aTrackingRect.Top()), sal_Int32( nTopDockingAreaSize )));
2530 if (( nPosY + aTrackingRect.getHeight()) > ( nTopDockingAreaSize + nMaxDockingAreaHeight ))
2531 nPosY = std::min( nPosY,
2532 std::max( sal_Int32( nTopDockingAreaSize + ( nMaxDockingAreaHeight - aTrackingRect.getHeight() )),
2533 sal_Int32( nTopDockingAreaSize )));
2535 sal_Int32 nSize = std::min( nMaxDockingAreaHeight, static_cast<sal_Int32>(aTrackingRect.getHeight()) );
2537 aTrackingRect.SetPos( ::Point( rRowColumnRect.Left(), nPosY ));
2538 aTrackingRect.setWidth( rRowColumnRect.getWidth() );
2539 aTrackingRect.setHeight( nSize );
2541 ReadGuard aReadLock( m_aLock );
2542 Reference< css::awt::XWindow > xDockingAreaWindow = m_xDockAreaWindows[eDockingArea];
2543 Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow;
2544 aReadLock.unlock();
2546 sal_Int32 nDockPosY( 0 );
2547 Window* pDockingAreaWindow( 0 );
2548 Window* pContainerWindow( 0 );
2550 vos::OGuard aGuard( Application::GetSolarMutex() );
2551 pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow );
2552 pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
2553 nDockPosY = pDockingAreaWindow->ScreenToOutputPixel(
2554 pContainerWindow->OutputToScreenPixel( ::Point( 0, nPosY ))).Y();
2557 // Set virtual position
2558 rUIElement.m_aDockedData.m_aPos.X() = nRowCol;
2559 rUIElement.m_aDockedData.m_aPos.Y() = nDockPosY;
2562 return aTrackingRect;
2565 void implts_setTrackingRect( DockingArea eDockingArea, const Point& rMousePos, ::Rectangle& rTrackingRect )
2567 sal_Bool bHorizontalDockArea( ( eDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
2568 ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM ));
2570 ::Point aPoint = rTrackingRect.TopLeft();
2571 if ( bHorizontalDockArea )
2572 aPoint.X() = rMousePos.X();
2573 else
2574 aPoint.Y() = rMousePos.Y();
2575 rTrackingRect.SetPos( aPoint );
2578 void LayoutManager::implts_calcDockingPosSize(
2579 UIElement& rUIElement,
2580 DockingOperation& rDockingOperation,
2581 ::Rectangle& rTrackingRect,
2582 const Point& rMousePos )
2584 ReadGuard aReadLock( m_aLock );
2585 Reference< css::awt::XWindow > xContainerWindow = m_xContainerWindow;
2586 ::Size aContainerWinSize;
2587 Window* pContainerWindow( 0 );
2588 aReadLock.unlock();
2591 // Retrieve output size from container Window
2592 vos::OGuard aGuard( Application::GetSolarMutex() );
2593 pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
2594 aContainerWinSize = pContainerWindow->GetOutputSizePixel();
2597 if ( !rUIElement.m_xUIElement.is() )
2599 rTrackingRect = ::Rectangle();
2600 return;
2603 Window* pDockWindow( 0 );
2604 Window* pDockingAreaWindow( 0 );
2605 ToolBox* pToolBox( 0 );
2606 Reference< css::awt::XWindow > xWindow( rUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
2607 Reference< css::awt::XWindow > xDockingAreaWindow;
2608 ::Rectangle aTrackingRect( rTrackingRect );
2609 ::com::sun::star::ui::DockingArea eDockedArea( (::com::sun::star::ui::DockingArea)rUIElement.m_aDockedData.m_nDockedArea );
2610 sal_Int32 nTopDockingAreaSize( implts_getTopBottomDockingAreaSizes().Width() );
2611 sal_Int32 nBottomDockingAreaSize( implts_getTopBottomDockingAreaSizes().Height() );
2612 sal_Bool bHorizontalDockArea( ( eDockedArea == DockingArea_DOCKINGAREA_TOP ) ||
2613 ( eDockedArea == DockingArea_DOCKINGAREA_BOTTOM ));
2614 ::Size aStatusBarSize( implts_getStatusBarSize() );
2615 sal_Int32 nMaxLeftRightDockAreaSize = aContainerWinSize.Height() -
2616 nTopDockingAreaSize -
2617 nBottomDockingAreaSize -
2618 aStatusBarSize.Height();
2619 ::Rectangle aDockingAreaRect;
2621 aReadLock.lock();
2622 xDockingAreaWindow = m_xDockAreaWindows[eDockedArea];
2623 aReadLock.unlock();
2626 vos::OGuard aGuard( Application::GetSolarMutex() );
2627 pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow );
2628 pDockWindow = VCLUnoHelper::GetWindow( xWindow );
2629 if ( pDockWindow && pDockWindow->GetType() == WINDOW_TOOLBOX )
2630 pToolBox = (ToolBox *)pDockWindow;
2632 aDockingAreaRect = ::Rectangle( pDockingAreaWindow->GetPosPixel(), pDockingAreaWindow->GetSizePixel() );
2633 if ( pToolBox )
2635 // docked toolbars always have one line
2636 ::Size aSize = pToolBox->CalcWindowSizePixel( 1, ImplConvertAlignment( sal_Int16( eDockedArea )) );
2637 aTrackingRect.SetSize( ::Size( aSize.Width(), aSize.Height() ));
2641 // default docking operation, dock on the given row/column
2642 sal_Bool bOpOutsideOfDockingArea( !aDockingAreaRect.IsInside( rMousePos ));
2643 std::vector< SingleRowColumnWindowData > aRowColumnsWindowData;
2645 rDockingOperation = DOCKOP_ON_COLROW;
2646 implts_getDockingAreaElementInfos( eDockedArea, aRowColumnsWindowData );
2648 // determine current first row/column and last row/column
2649 sal_Int32 nMaxRowCol( -1 );
2650 sal_Int32 nMinRowCol( SAL_MAX_INT32 );
2651 const sal_uInt32 nCount = aRowColumnsWindowData.size();
2652 for ( sal_uInt32 i = 0; i < nCount; i++ )
2654 if ( aRowColumnsWindowData[i].nRowColumn > nMaxRowCol )
2655 nMaxRowCol = aRowColumnsWindowData[i].nRowColumn;
2656 if ( aRowColumnsWindowData[i].nRowColumn < nMinRowCol )
2657 nMinRowCol = aRowColumnsWindowData[i].nRowColumn;
2660 if ( !bOpOutsideOfDockingArea )
2662 // docking inside our docking area
2663 sal_Int32 nIndex( -1 );
2664 sal_Int32 nRowCol( -1 );
2665 ::Rectangle aWindowRect;
2666 ::Rectangle aRowColumnRect;
2668 const sal_uInt32 nWindowDataCount = aRowColumnsWindowData.size();
2669 for ( sal_uInt32 i = 0; i < nWindowDataCount; i++ )
2671 ::Rectangle aRect( aRowColumnsWindowData[i].aRowColumnRect.X,
2672 aRowColumnsWindowData[i].aRowColumnRect.Y,
2673 aRowColumnsWindowData[i].aRowColumnRect.X + aRowColumnsWindowData[i].aRowColumnRect.Width,
2674 aRowColumnsWindowData[i].aRowColumnRect.Y + aRowColumnsWindowData[i].aRowColumnRect.Height );
2677 // Calc correct position of the column/row rectangle to be able to compare it with mouse pos/tracking rect
2678 vos::OGuard aGuard( Application::GetSolarMutex() );
2679 aRect.SetPos( pContainerWindow->ScreenToOutputPixel( pDockingAreaWindow->OutputToScreenPixel( aRect.TopLeft() )));
2682 sal_Bool bIsInsideRowCol( aRect.IsInside( rMousePos ) );
2683 if ( bIsInsideRowCol )
2685 nIndex = i;
2686 nRowCol = aRowColumnsWindowData[i].nRowColumn;
2687 rDockingOperation = implts_determineDockingOperation( eDockedArea, aRect, rMousePos );
2688 aWindowRect = implts_getWindowRectFromRowColumn( eDockedArea, aRowColumnsWindowData[i], rMousePos, rUIElement.m_aName );
2689 aRowColumnRect = aRect;
2690 break;
2694 OSL_ENSURE( ( nIndex >= 0 ) && ( nRowCol >= 0 ), "Impossible case - no row/column found but mouse pointer is inside our docking area" );
2695 if (( nIndex >= 0 ) && ( nRowCol >= 0 ))
2697 if ( rDockingOperation == DOCKOP_ON_COLROW )
2699 if ( !aWindowRect.IsEmpty())
2701 // Tracking rect is on a row/column and mouse is over a docked toolbar.
2702 // Determine if the tracking rect must be located before/after the docked toolbar.
2704 ::Rectangle aUIElementRect( aWindowRect );
2705 sal_Int32 nMiddle( bHorizontalDockArea ? ( aWindowRect.Left() + aWindowRect.getWidth() / 2 ) :
2706 ( aWindowRect.Top() + aWindowRect.getHeight() / 2 ));
2707 sal_Bool bInsertBefore( bHorizontalDockArea ? ( rMousePos.X() < nMiddle ) : ( rMousePos.Y() < nMiddle ));
2708 if ( bInsertBefore )
2710 if ( bHorizontalDockArea )
2712 sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32( aContainerWinSize.Width() - aWindowRect.Left() ),
2713 sal_Int32( aTrackingRect.getWidth() )));
2714 if ( nSize == 0 )
2715 nSize = aWindowRect.getWidth();
2717 aUIElementRect.SetSize( ::Size( nSize, aWindowRect.getHeight() ));
2718 aWindowRect = implts_determineFrontDockingRect( eDockedArea, nRowCol, aWindowRect,rUIElement.m_aName, aUIElementRect );
2720 // Set virtual position
2721 rUIElement.m_aDockedData.m_aPos.X() = aWindowRect.Left();
2722 rUIElement.m_aDockedData.m_aPos.Y() = nRowCol;
2724 else
2726 sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32(
2727 nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Top() ),
2728 sal_Int32( aTrackingRect.getHeight() )));
2729 if ( nSize == 0 )
2730 nSize = aWindowRect.getHeight();
2732 aUIElementRect.SetSize( ::Size( aWindowRect.getWidth(), nSize ));
2733 aWindowRect = implts_determineFrontDockingRect( eDockedArea, nRowCol, aWindowRect, rUIElement.m_aName, aUIElementRect );
2735 // Set virtual position
2736 sal_Int32 nPosY = pDockingAreaWindow->ScreenToOutputPixel(
2737 pContainerWindow->OutputToScreenPixel( aWindowRect.TopLeft() )).Y();
2738 rUIElement.m_aDockedData.m_aPos.X() = nRowCol;
2739 rUIElement.m_aDockedData.m_aPos.Y() = nPosY;
2742 rTrackingRect = aWindowRect;
2743 return;
2745 else
2747 if ( bHorizontalDockArea )
2749 sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32(( aContainerWinSize.Width() ) - aWindowRect.Right() ),
2750 sal_Int32( aTrackingRect.getWidth() )));
2751 if ( nSize == 0 )
2753 aUIElementRect.SetPos( ::Point( aContainerWinSize.Width() - aTrackingRect.getWidth(), aWindowRect.Top() ));
2754 aUIElementRect.SetSize( ::Size( aTrackingRect.getWidth(), aWindowRect.getHeight() ));
2755 rUIElement.m_aDockedData.m_aPos.X() = aUIElementRect.Left();
2757 else
2759 aUIElementRect.SetPos( ::Point( aWindowRect.Right(), aWindowRect.Top() ));
2760 aUIElementRect.SetSize( ::Size( nSize, aWindowRect.getHeight() ));
2761 rUIElement.m_aDockedData.m_aPos.X() = aWindowRect.Right();
2764 // Set virtual position
2765 rUIElement.m_aDockedData.m_aPos.Y() = nRowCol;
2767 else
2769 sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32( nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Bottom() ),
2770 sal_Int32( aTrackingRect.getHeight() )));
2771 aUIElementRect.SetPos( ::Point( aWindowRect.Left(), aWindowRect.Bottom() ));
2772 aUIElementRect.SetSize( ::Size( aWindowRect.getWidth(), nSize ));
2774 // Set virtual position
2775 sal_Int32 nPosY( 0 );
2777 vos::OGuard aGuard( Application::GetSolarMutex() );
2778 nPosY = pDockingAreaWindow->ScreenToOutputPixel(
2779 pContainerWindow->OutputToScreenPixel( aWindowRect.BottomRight() )).Y();
2781 rUIElement.m_aDockedData.m_aPos.X() = nRowCol;
2782 rUIElement.m_aDockedData.m_aPos.Y() = nPosY;
2785 rTrackingRect = aUIElementRect;
2786 return;
2789 else
2791 implts_setTrackingRect( eDockedArea, rMousePos, aTrackingRect );
2792 rTrackingRect = implts_calcTrackingAndElementRect(
2793 eDockedArea, nRowCol, rUIElement,
2794 aTrackingRect, aRowColumnRect, aContainerWinSize );
2795 return;
2798 else
2800 if ((( nRowCol == nMinRowCol ) && ( rDockingOperation == DOCKOP_BEFORE_COLROW )) ||
2801 (( nRowCol == nMaxRowCol ) && ( rDockingOperation == DOCKOP_AFTER_COLROW )))
2802 bOpOutsideOfDockingArea = sal_True;
2803 else
2805 // handle docking before/after a row
2806 implts_setTrackingRect( eDockedArea, rMousePos, aTrackingRect );
2807 rTrackingRect = implts_calcTrackingAndElementRect(
2808 eDockedArea, nRowCol, rUIElement,
2809 aTrackingRect, aRowColumnRect, aContainerWinSize );
2811 sal_Int32 nOffsetX( 0 );
2812 sal_Int32 nOffsetY( 0 );
2813 if ( bHorizontalDockArea )
2814 nOffsetY = sal_Int32( floor( aRowColumnRect.getHeight() / 2 + 0.5 ));
2815 else
2816 nOffsetX = sal_Int32( floor( aRowColumnRect.getWidth() / 2 + 0.5 ));
2818 if ( rDockingOperation == DOCKOP_BEFORE_COLROW )
2820 if (( eDockedArea == DockingArea_DOCKINGAREA_TOP ) ||
2821 ( eDockedArea == DockingArea_DOCKINGAREA_LEFT ))
2823 // Docking before/after means move track rectangle half column/row.
2824 // As left and top are ordered 0...n instead of right and bottom
2825 // which uses n...0, we have to use negative values for top/left.
2826 nOffsetX *= -1;
2827 nOffsetY *= -1;
2830 else
2832 if (( eDockedArea == DockingArea_DOCKINGAREA_BOTTOM ) ||
2833 ( eDockedArea == DockingArea_DOCKINGAREA_RIGHT ))
2835 // Docking before/after means move track rectangle half column/row.
2836 // As left and top are ordered 0...n instead of right and bottom
2837 // which uses n...0, we have to use negative values for top/left.
2838 nOffsetX *= -1;
2839 nOffsetY *= -1;
2841 nRowCol++;
2844 if ( bHorizontalDockArea )
2845 rUIElement.m_aDockedData.m_aPos.Y() = nRowCol;
2846 else
2847 rUIElement.m_aDockedData.m_aPos.X() = nRowCol;
2849 rTrackingRect.Move( nOffsetX, nOffsetY );
2850 rTrackingRect.SetSize( aTrackingRect.GetSize() );
2856 // Docking outside of our docking window area =>
2857 // Users want to dock before/after first/last docked element or to an empty docking area
2858 if ( bOpOutsideOfDockingArea )
2860 // set correct size for docking
2861 implts_setTrackingRect( eDockedArea, rMousePos, aTrackingRect );
2862 rTrackingRect = aTrackingRect;
2864 if ( bHorizontalDockArea )
2866 sal_Int32 nPosX( std::max( sal_Int32( rTrackingRect.Left()), sal_Int32( 0 )));
2867 if (( nPosX + rTrackingRect.getWidth()) > aContainerWinSize.Width() )
2868 nPosX = std::min( nPosX,
2869 std::max( sal_Int32( aContainerWinSize.Width() - rTrackingRect.getWidth() ),
2870 sal_Int32( 0 )));
2872 sal_Int32 nSize = std::min( aContainerWinSize.Width(), rTrackingRect.getWidth() );
2873 sal_Int32 nDockHeight = std::max( static_cast<sal_Int32>(aDockingAreaRect.getHeight()), sal_Int32( 0 ));
2874 if ( nDockHeight == 0 )
2876 sal_Int32 nPosY( std::max( aDockingAreaRect.Top(), aDockingAreaRect.Bottom() ));
2877 if ( eDockedArea == DockingArea_DOCKINGAREA_BOTTOM )
2878 nPosY -= rTrackingRect.getHeight();
2879 rTrackingRect.SetPos( Point( nPosX, nPosY ));
2880 rUIElement.m_aDockedData.m_aPos.Y() = 0;
2882 else if ( rMousePos.Y() < ( aDockingAreaRect.Top() + ( nDockHeight / 2 )))
2884 rTrackingRect.SetPos( Point( nPosX, aDockingAreaRect.Top() - rTrackingRect.getHeight() ));
2885 if ( eDockedArea == DockingArea_DOCKINGAREA_TOP )
2886 rUIElement.m_aDockedData.m_aPos.Y() = 0;
2887 else
2888 rUIElement.m_aDockedData.m_aPos.Y() = ( nMaxRowCol >= 0 ) ? nMaxRowCol+1 : 0;
2889 rDockingOperation = DOCKOP_BEFORE_COLROW;
2891 else
2893 rTrackingRect.SetPos( Point( nPosX, aDockingAreaRect.Bottom() ));
2894 if ( eDockedArea == DockingArea_DOCKINGAREA_TOP )
2895 rUIElement.m_aDockedData.m_aPos.Y() = ( nMaxRowCol >= 0 ) ? nMaxRowCol+1 : 0;
2896 else
2897 rUIElement.m_aDockedData.m_aPos.Y() = 0;
2898 rDockingOperation = DOCKOP_AFTER_COLROW;
2900 rTrackingRect.setWidth( nSize );
2903 vos::OGuard aGuard( Application::GetSolarMutex() );
2904 nPosX = pDockingAreaWindow->ScreenToOutputPixel(
2905 pContainerWindow->OutputToScreenPixel( rTrackingRect.TopLeft() )).X();
2907 rUIElement.m_aDockedData.m_aPos.X() = nPosX;
2909 else
2911 sal_Int32 nMaxDockingAreaHeight = std::max( sal_Int32( 0 ),
2912 sal_Int32( nMaxLeftRightDockAreaSize ));
2914 sal_Int32 nPosY( std::max( sal_Int32( aTrackingRect.Top()), sal_Int32( nTopDockingAreaSize )));
2915 if (( nPosY + aTrackingRect.getHeight()) > ( nTopDockingAreaSize + nMaxDockingAreaHeight ))
2916 nPosY = std::min( nPosY,
2917 std::max( sal_Int32( nTopDockingAreaSize + ( nMaxDockingAreaHeight - aTrackingRect.getHeight() )),
2918 sal_Int32( nTopDockingAreaSize )));
2920 sal_Int32 nSize = std::min( nMaxDockingAreaHeight, static_cast<sal_Int32>(aTrackingRect.getHeight()) );
2921 sal_Int32 nDockWidth = std::max( static_cast<sal_Int32>(aDockingAreaRect.getWidth()), sal_Int32( 0 ));
2922 if ( nDockWidth == 0 )
2924 sal_Int32 nPosX( std::max( aDockingAreaRect.Left(), aDockingAreaRect.Right() ));
2925 if ( eDockedArea == DockingArea_DOCKINGAREA_RIGHT )
2926 nPosX -= rTrackingRect.getWidth();
2927 rTrackingRect.SetPos( Point( nPosX, nPosY ));
2928 rUIElement.m_aDockedData.m_aPos.X() = 0;
2930 else if ( rMousePos.X() < ( aDockingAreaRect.Left() + ( nDockWidth / 2 )))
2932 rTrackingRect.SetPos( Point( aDockingAreaRect.Left() - rTrackingRect.getWidth(), nPosY ));
2933 if ( eDockedArea == DockingArea_DOCKINGAREA_LEFT )
2934 rUIElement.m_aDockedData.m_aPos.X() = 0;
2935 else
2936 rUIElement.m_aDockedData.m_aPos.X() = ( nMaxRowCol >= 0 ) ? nMaxRowCol+1 : 0;
2937 rDockingOperation = DOCKOP_BEFORE_COLROW;
2939 else
2941 rTrackingRect.SetPos( Point( aDockingAreaRect.Right(), nPosY ));
2942 if ( eDockedArea == DockingArea_DOCKINGAREA_LEFT )
2943 rUIElement.m_aDockedData.m_aPos.X() = ( nMaxRowCol >= 0 ) ? nMaxRowCol+1 : 0;
2944 else
2945 rUIElement.m_aDockedData.m_aPos.X() = 0;
2946 rDockingOperation = DOCKOP_AFTER_COLROW;
2948 rTrackingRect.setHeight( nSize );
2951 vos::OGuard aGuard( Application::GetSolarMutex() );
2952 nPosY = pDockingAreaWindow->ScreenToOutputPixel(
2953 pContainerWindow->OutputToScreenPixel( rTrackingRect.TopLeft() )).Y();
2955 rUIElement.m_aDockedData.m_aPos.Y() = nPosY;
2960 void LayoutManager::implts_renumberRowColumnData(
2961 ::com::sun::star::ui::DockingArea eDockingArea,
2962 DockingOperation /*eDockingOperation*/,
2963 const UIElement& rUIElement )
2965 ReadGuard aReadLock( m_aLock );
2966 Reference< XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
2967 aReadLock.unlock();
2969 sal_Bool bHorzDockingArea(( eDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
2970 ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM ));
2971 sal_Int32 nRowCol( bHorzDockingArea ? rUIElement.m_aDockedData.m_aPos.Y() :
2972 rUIElement.m_aDockedData.m_aPos.X() );
2974 WriteGuard aWriteLock( m_aLock );
2975 UIElementVector::iterator pIter;
2976 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
2978 if (( pIter->m_aDockedData.m_nDockedArea == sal_Int16( eDockingArea )) &&
2979 ( pIter->m_aName != rUIElement.m_aName ))
2981 // Don't change toolbars without a valid docking position!
2982 if (( pIter->m_aDockedData.m_aPos.X() == SAL_MAX_INT32 ) &&
2983 ( pIter->m_aDockedData.m_aPos.Y() == SAL_MAX_INT32 ))
2984 continue;
2986 sal_Int32 nWindowRowCol = ( bHorzDockingArea ) ?
2987 pIter->m_aDockedData.m_aPos.Y() : pIter->m_aDockedData.m_aPos.X();
2988 if ( nWindowRowCol >= nRowCol )
2990 if ( bHorzDockingArea )
2991 pIter->m_aDockedData.m_aPos.Y() += 1;
2992 else
2993 pIter->m_aDockedData.m_aPos.X() += 1;
2997 aWriteLock.unlock();
2999 // We have to change the persistent window state part
3000 if ( xPersistentWindowState.is() )
3004 Sequence< rtl::OUString > aWindowElements = xPersistentWindowState->getElementNames();
3005 for ( sal_Int32 i = 0; i < aWindowElements.getLength(); i++ )
3007 if ( rUIElement.m_aName != aWindowElements[i] )
3011 Sequence< PropertyValue > aPropValueSeq;
3012 css::awt::Point aDockedPos;
3013 DockingArea nDockedArea( DockingArea_DOCKINGAREA_DEFAULT );
3015 xPersistentWindowState->getByName( aWindowElements[i] ) >>= aPropValueSeq;
3016 for ( sal_Int32 j = 0; j < aPropValueSeq.getLength(); j++ )
3018 if ( aPropValueSeq[j].Name == m_aPropDockingArea )
3019 aPropValueSeq[j].Value >>= nDockedArea;
3020 else if ( aPropValueSeq[j].Name == m_aPropDockPos )
3021 aPropValueSeq[j].Value >>= aDockedPos;
3024 // Don't change toolbars without a valid docking position!
3025 if (( aDockedPos.X == SAL_MAX_INT32 ) && ( aDockedPos.Y == SAL_MAX_INT32 ))
3026 continue;
3028 sal_Int32 nWindowRowCol = ( bHorzDockingArea ) ? aDockedPos.Y : aDockedPos.X;
3029 if (( nDockedArea == eDockingArea ) && ( nWindowRowCol >= nRowCol ))
3031 if ( bHorzDockingArea )
3032 aDockedPos.Y += 1;
3033 else
3034 aDockedPos.X += 1;
3036 Reference< XNameReplace > xReplace( xPersistentWindowState, UNO_QUERY );
3037 xReplace->replaceByName( aWindowElements[i], makeAny( aPropValueSeq ));
3040 catch ( Exception& )
3046 catch ( Exception& )
3052 ::Size LayoutManager::implts_getTopBottomDockingAreaSizes()
3054 ::Size aSize;
3055 Reference< css::awt::XWindow > xTopDockingAreaWindow;
3056 Reference< css::awt::XWindow > xBottomDockingAreaWindow;
3058 ReadGuard aReadLock( m_aLock );
3059 xTopDockingAreaWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP];
3060 xBottomDockingAreaWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM];
3061 aReadLock.unlock();
3063 if ( xTopDockingAreaWindow.is() )
3064 aSize.Width() = xTopDockingAreaWindow->getPosSize().Height;
3065 if ( xBottomDockingAreaWindow.is() )
3066 aSize.Height() = xBottomDockingAreaWindow->getPosSize().Height;
3068 return aSize;
3071 Reference< XUIElement > LayoutManager::implts_createElement( const rtl::OUString& aName )
3073 Reference< ::com::sun::star::ui::XUIElement > xUIElement;
3075 ReadGuard aReadLock( m_aLock );
3076 Sequence< PropertyValue > aPropSeq( 2 );
3077 aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
3078 aPropSeq[0].Value <<= m_xFrame;
3079 aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ));
3080 aPropSeq[1].Value <<= sal_True;
3084 xUIElement = m_xUIElementFactoryManager->createUIElement( aName, aPropSeq );
3086 catch ( NoSuchElementException& )
3089 catch ( IllegalArgumentException& )
3093 return xUIElement;
3096 Reference< css::awt::XWindowPeer > LayoutManager::implts_createToolkitWindow( const Reference< css::awt::XWindowPeer >& rParent )
3098 Reference< css::awt::XWindowPeer > xPeer;
3099 css::uno::Reference< css::awt::XToolkit > xToolkit( m_xSMGR->createInstance( SERVICENAME_VCLTOOLKIT ), css::uno::UNO_QUERY );
3100 if ( xToolkit.is() )
3102 // describe window properties.
3103 css::awt::WindowDescriptor aDescriptor;
3104 aDescriptor.Type = css::awt::WindowClass_SIMPLE ;
3105 aDescriptor.WindowServiceName = DECLARE_ASCII("dockingarea") ;
3106 aDescriptor.ParentIndex = -1 ;
3107 aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >( rParent, UNO_QUERY ) ;
3108 aDescriptor.Bounds = css::awt::Rectangle(0,0,0,0) ;
3109 aDescriptor.WindowAttributes = 0 ;
3111 // create a docking area window
3112 xPeer = xToolkit->createWindow( aDescriptor );
3115 return xPeer;
3118 void LayoutManager::implts_setVisibleState( sal_Bool bShow )
3120 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3121 WriteGuard aWriteLock( m_aLock );
3122 UIElementVector::iterator pIter;
3123 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
3124 pIter->m_bMasterHide = !bShow;
3125 m_aStatusBarElement.m_bMasterHide = !bShow;
3126 aWriteLock.unlock();
3127 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3129 implts_updateUIElementsVisibleState( bShow );
3130 //implts_doLayout( sal_False );
3133 void LayoutManager::implts_updateUIElementsVisibleState( sal_Bool bSetVisible )
3135 // notify listeners
3136 css::uno::Any a;
3137 if ( bSetVisible )
3138 implts_notifyListeners( css::frame::LayoutManagerEvents::VISIBLE, a );
3139 else
3140 implts_notifyListeners( css::frame::LayoutManagerEvents::INVISIBLE, a );
3141 std::vector< Reference< css::awt::XWindow > > aWinVector;
3142 sal_Bool bOld;
3145 WriteGuard aWriteLock( m_aLock );
3146 m_bDoLayout = sal_True;
3147 bOld = m_bDoLayout;
3150 ReadGuard aReadLock( m_aLock );
3151 aWinVector.reserve(m_aUIElements.size());
3152 UIElementVector::iterator pIter;
3153 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
3155 if ( pIter->m_xUIElement.is() )
3157 Reference< css::awt::XWindow > xWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
3158 if ( xWindow.is() )
3160 if ( bSetVisible )
3162 if ( pIter->m_bVisible && !pIter->m_bMasterHide )
3163 aWinVector.push_back( xWindow );
3165 else
3166 aWinVector.push_back( xWindow );
3171 aReadLock.unlock();
3175 vos::OGuard aGuard( Application::GetSolarMutex() );
3176 const sal_uInt32 nCount = aWinVector.size();
3177 for ( sal_uInt32 i = 0; i < nCount; i++ )
3179 Reference< css::awt::XWindow > xWindow( aWinVector[i] );
3180 if ( xWindow.is() )
3182 // we need VCL here to pass special flags to Show()
3183 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3184 if( pWindow )
3185 pWindow->Show( bSetVisible, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
3189 catch ( DisposedException& )
3193 // Hide/show menubar according to bSetVisible
3194 aReadLock.lock();
3195 Reference< XUIElement > xMenuBar( m_xMenuBar, UNO_QUERY );
3196 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
3197 Reference< XComponent > xInplaceMenuBar( m_xInplaceMenuBar );
3198 MenuBarManager* pInplaceMenuBar( m_pInplaceMenuBar );
3199 aReadLock.unlock();
3201 if (( xMenuBar.is() || xInplaceMenuBar.is() ) && xContainerWindow.is() )
3203 vos::OGuard aGuard( Application::GetSolarMutex() );
3205 MenuBar* pMenuBar( 0 );
3206 if ( xInplaceMenuBar.is() )
3207 pMenuBar = (MenuBar *)pInplaceMenuBar->GetMenuBar();
3208 else
3210 MenuBarWrapper* pMenuBarWrapper = SAL_STATIC_CAST( MenuBarWrapper*, xMenuBar.get() );
3211 pMenuBar = (MenuBar *)pMenuBarWrapper->GetMenuBarManager()->GetMenuBar();
3214 Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
3215 while ( pWindow && !pWindow->IsSystemWindow() )
3216 pWindow = pWindow->GetParent();
3218 if ( pWindow )
3220 SystemWindow* pSysWindow = (SystemWindow *)pWindow;
3221 if ( bSetVisible )
3222 pSysWindow->SetMenuBar( pMenuBar );
3223 else
3224 pSysWindow->SetMenuBar( 0 );
3228 // Hide/show the statusbar according to bSetVisible
3229 if ( bSetVisible )
3230 implts_showStatusBar();
3231 else
3232 implts_hideStatusBar();
3234 if ( !bOld )
3236 WriteGuard aWriteLock( m_aLock );
3237 m_bDoLayout = sal_False;
3240 if ( bSetVisible )
3242 implts_createNonContextSensitiveToolBars();
3243 doLayout();
3245 else
3247 // Set docking area window size to zero
3248 ReadGuard aReadLock2( m_aLock );
3249 Reference< css::awt::XWindow > xTopDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP];
3250 Reference< css::awt::XWindow > xLeftDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT];
3251 Reference< css::awt::XWindow > xRightDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT];
3252 Reference< css::awt::XWindow > xBottomDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM];
3253 aReadLock2.unlock();
3257 if ( xTopDockingWindow.is() )
3258 xTopDockingWindow->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE );
3259 if ( xLeftDockingWindow.is() )
3260 xLeftDockingWindow->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE );
3261 if ( xRightDockingWindow.is() )
3262 xRightDockingWindow->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE );
3263 if ( xBottomDockingWindow.is() )
3264 xBottomDockingWindow->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE );
3266 WriteGuard aWriteLock( m_aLock );
3267 m_aDockingArea = css::awt::Rectangle();
3268 m_bMustDoLayout = sal_True;
3269 aWriteLock.unlock();
3271 catch ( Exception& )
3277 void LayoutManager::implts_setCurrentUIVisibility( sal_Bool bShow )
3279 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3280 WriteGuard aWriteLock( m_aLock );
3281 UIElementVector::iterator pIter;
3282 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
3284 if ( !bShow && pIter->m_bVisible && pIter->m_xUIElement.is() )
3285 pIter->m_bMasterHide = true;
3286 else if ( bShow && pIter->m_bMasterHide )
3287 pIter->m_bMasterHide = false;
3290 if ( !bShow && m_aStatusBarElement.m_bVisible && m_aStatusBarElement.m_xUIElement.is() )
3291 m_aStatusBarElement.m_bMasterHide = true;
3292 else if ( bShow && m_aStatusBarElement.m_bVisible )
3293 m_aStatusBarElement.m_bMasterHide = false;
3294 aWriteLock.unlock();
3295 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3297 implts_updateUIElementsVisibleState( bShow );
3300 void LayoutManager::implts_destroyStatusBar()
3302 Reference< XComponent > xCompStatusBar;
3304 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3305 WriteGuard aWriteLock( m_aLock );
3306 m_aStatusBarElement.m_aName = rtl::OUString();
3307 xCompStatusBar = Reference< XComponent >( m_aStatusBarElement.m_xUIElement, UNO_QUERY );
3308 m_aStatusBarElement.m_xUIElement.clear();
3309 aWriteLock.unlock();
3310 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3312 if ( xCompStatusBar.is() )
3313 xCompStatusBar->dispose();
3315 implts_destroyProgressBar();
3318 void LayoutManager::implts_createStatusBar( const rtl::OUString& aStatusBarName )
3320 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3321 WriteGuard aWriteLock( m_aLock );
3322 if ( !m_aStatusBarElement.m_xUIElement.is() )
3324 implts_readStatusBarState( aStatusBarName );
3325 m_aStatusBarElement.m_aName = aStatusBarName;
3326 m_aStatusBarElement.m_xUIElement = implts_createElement( aStatusBarName );
3329 implts_createProgressBar();
3330 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3333 void LayoutManager::implts_readStatusBarState( const rtl::OUString& rStatusBarName )
3335 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3336 WriteGuard aWriteLock( m_aLock );
3337 if ( !m_aStatusBarElement.m_bStateRead )
3339 // Read persistent data for status bar if not yet read!
3340 if ( implts_readWindowStateData( rStatusBarName, m_aStatusBarElement ))
3341 m_aStatusBarElement.m_bStateRead = sal_True;
3343 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3346 void LayoutManager::implts_createProgressBar()
3348 Reference< XUIElement > xStatusBar;
3349 Reference< XUIElement > xProgressBar;
3350 Reference< XUIElement > xProgressBarBackup;
3351 Reference< css::awt::XWindow > xContainerWindow;
3353 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3354 WriteGuard aWriteLock( m_aLock );
3355 xStatusBar = Reference< XUIElement >( m_aStatusBarElement.m_xUIElement, UNO_QUERY );
3356 xProgressBar = Reference< XUIElement >( m_aProgressBarElement.m_xUIElement, UNO_QUERY );
3357 xProgressBarBackup = m_xProgressBarBackup;
3358 m_xProgressBarBackup.clear();
3359 xContainerWindow = m_xContainerWindow;
3360 aWriteLock.unlock();
3361 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3363 sal_Bool bRecycled = xProgressBarBackup.is();
3364 ProgressBarWrapper* pWrapper = 0;
3365 if ( bRecycled )
3366 pWrapper = (ProgressBarWrapper*)xProgressBarBackup.get();
3367 else if ( xProgressBar.is() )
3368 pWrapper = (ProgressBarWrapper*)xProgressBar.get();
3369 else
3370 pWrapper = new ProgressBarWrapper();
3372 if ( xStatusBar.is() )
3374 Reference< css::awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY );
3375 pWrapper->setStatusBar( xWindow );
3377 else
3379 Reference< css::awt::XWindow > xStatusBarWindow = pWrapper->getStatusBar();
3381 vos::OGuard aGuard( Application::GetSolarMutex() );
3382 Window* pStatusBarWnd = VCLUnoHelper::GetWindow( xStatusBarWindow );
3383 if ( !pStatusBarWnd )
3385 Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
3386 if ( pWindow )
3388 StatusBar* pStatusBar = new StatusBar( pWindow, WinBits( WB_LEFT | WB_3DLOOK ) );
3389 Reference< css::awt::XWindow > xStatusBarWindow2( VCLUnoHelper::GetInterface( pStatusBar ));
3390 pWrapper->setStatusBar( xStatusBarWindow2, sal_True );
3395 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3396 aWriteLock.lock();
3397 m_aProgressBarElement.m_xUIElement = Reference< XUIElement >(
3398 static_cast< cppu::OWeakObject* >( pWrapper ), UNO_QUERY );
3399 aWriteLock.unlock();
3400 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3402 if ( bRecycled )
3403 implts_showProgressBar();
3406 void LayoutManager::implts_backupProgressBarWrapper()
3408 // SAFE -> ----------------------------------
3409 WriteGuard aWriteLock(m_aLock);
3411 if (m_xProgressBarBackup.is())
3412 return;
3414 // safe a backup copy of the current progress!
3415 // This copy will be used automaticly inside createProgressBar() which is called
3416 // implictly from implts_doLayout() .-)
3417 m_xProgressBarBackup = m_aProgressBarElement.m_xUIElement;
3419 // remove the relation between this old progress bar and our old status bar.
3420 // Otherwhise we work on disposed items ...
3421 // The internal used ProgressBarWrapper can handle a NULL reference.
3422 if ( m_xProgressBarBackup.is() )
3424 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)m_xProgressBarBackup.get();
3425 if ( pWrapper )
3426 pWrapper->setStatusBar( Reference< css::awt::XWindow >(), sal_False );
3429 // prevent us from dispose() the m_aProgressBarElement.m_xUIElement inside implts_reset()
3430 m_aProgressBarElement.m_xUIElement.clear();
3432 aWriteLock.unlock();
3433 // <- SAFE ----------------------------------
3436 void LayoutManager::implts_destroyProgressBar()
3438 // dont remove the progressbar in general
3439 // We must reuse it if a new status bar is created later.
3440 // Of course there exists one backup only.
3441 // And further this backup will be released inside our dtor.
3442 implts_backupProgressBarWrapper();
3445 void LayoutManager::implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize )
3447 Reference< XUIElement > xStatusBar;
3448 Reference< XUIElement > xProgressBar;
3449 Reference< css::awt::XWindow > xContainerWindow;
3451 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3452 ReadGuard aReadLock( m_aLock );
3453 xStatusBar = Reference< XUIElement >( m_aStatusBarElement.m_xUIElement, UNO_QUERY );
3454 xProgressBar = Reference< XUIElement >( m_aProgressBarElement.m_xUIElement, UNO_QUERY );
3455 xContainerWindow = m_xContainerWindow;
3457 Reference< css::awt::XWindow > xWindow;
3458 if ( xStatusBar.is() )
3459 xWindow = Reference< css::awt::XWindow >( xStatusBar->getRealInterface(), UNO_QUERY );
3460 else if ( xProgressBar.is() )
3462 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)xProgressBar.get();
3463 if ( pWrapper )
3464 xWindow = pWrapper->getStatusBar();
3466 aReadLock.unlock();
3467 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3469 if ( xWindow.is() )
3471 vos::OGuard aGuard( Application::GetSolarMutex() );
3472 Window* pParentWindow = VCLUnoHelper::GetWindow( xContainerWindow );
3473 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3474 if ( pParentWindow && ( pWindow && pWindow->GetType() == WINDOW_STATUSBAR ))
3476 Window* pOldParentWindow = pWindow->GetParent();
3477 if ( pParentWindow != pOldParentWindow )
3478 pWindow->SetParent( pParentWindow );
3479 ((StatusBar *)pWindow)->SetPosSizePixel( rPos, rSize );
3484 sal_Bool LayoutManager::implts_showProgressBar()
3486 Reference< XUIElement > xStatusBar;
3487 Reference< XUIElement > xProgressBar;
3488 Reference< css::awt::XWindow > xWindow;
3490 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3491 WriteGuard aWriteLock( m_aLock );
3492 xStatusBar = Reference< XUIElement >( m_aStatusBarElement.m_xUIElement, UNO_QUERY );
3493 xProgressBar = Reference< XUIElement >( m_aProgressBarElement.m_xUIElement, UNO_QUERY );
3494 sal_Bool bVisible( m_bVisible );
3496 m_aProgressBarElement.m_bVisible = sal_True;
3497 if ( bVisible )
3499 if ( xStatusBar.is() && !m_aStatusBarElement.m_bMasterHide )
3501 xWindow = Reference< css::awt::XWindow >( xStatusBar->getRealInterface(), UNO_QUERY );
3503 else if ( xProgressBar.is() )
3505 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)xProgressBar.get();
3506 if ( pWrapper )
3507 xWindow = pWrapper->getStatusBar();
3510 aWriteLock.unlock();
3512 vos::OGuard aGuard( Application::GetSolarMutex() );
3513 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3514 if ( pWindow )
3516 if ( !pWindow->IsVisible() )
3518 pWindow->Show();
3519 doLayout();
3521 return sal_True;
3524 return sal_False;
3527 sal_Bool LayoutManager::implts_hideProgressBar()
3529 Reference< XUIElement > xProgressBar;
3530 Reference< css::awt::XWindow > xWindow;
3531 sal_Bool bHideStatusBar( sal_False );
3533 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3534 WriteGuard aWriteLock( m_aLock );
3535 xProgressBar = Reference< XUIElement >( m_aProgressBarElement.m_xUIElement, UNO_QUERY );
3537 sal_Bool bInternalStatusBar( sal_False );
3538 if ( xProgressBar.is() )
3540 Reference< css::awt::XWindow > xStatusBar;
3541 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)xProgressBar.get();
3542 if ( pWrapper )
3543 xWindow = pWrapper->getStatusBar();
3544 Reference< css::ui::XUIElement > xStatusBarElement = m_aStatusBarElement.m_xUIElement;
3545 if ( xStatusBarElement.is() )
3546 xStatusBar = Reference< css::awt::XWindow >( xStatusBarElement->getRealInterface(), UNO_QUERY );
3547 bInternalStatusBar = xStatusBar != xWindow;
3549 m_aProgressBarElement.m_bVisible = sal_False;
3550 implts_readStatusBarState( m_aStatusBarAlias );
3551 bHideStatusBar = !m_aStatusBarElement.m_bVisible;
3552 aWriteLock.unlock();
3554 vos::OGuard aGuard( Application::GetSolarMutex() );
3555 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3556 if ( pWindow && pWindow->IsVisible() &&
3557 ( bHideStatusBar || bInternalStatusBar ))
3559 pWindow->Hide();
3560 doLayout();
3561 return sal_True;
3564 return sal_False;
3567 sal_Bool LayoutManager::implts_showStatusBar( sal_Bool bStoreState )
3569 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3570 WriteGuard aWriteLock( m_aLock );
3571 Reference< css::ui::XUIElement > xStatusBar = m_aStatusBarElement.m_xUIElement;
3572 if ( bStoreState )
3573 m_aStatusBarElement.m_bVisible = sal_True;
3574 aWriteLock.unlock();
3575 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3577 if ( xStatusBar.is() )
3579 Reference< css::awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY );
3581 vos::OGuard aGuard( Application::GetSolarMutex() );
3582 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3583 if ( pWindow && !pWindow->IsVisible() )
3585 pWindow->Show();
3586 return sal_True;
3590 return sal_False;
3593 sal_Bool LayoutManager::implts_hideStatusBar( sal_Bool bStoreState )
3595 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3596 WriteGuard aWriteLock( m_aLock );
3597 Reference< css::ui::XUIElement > xStatusBar = m_aStatusBarElement.m_xUIElement;
3598 if ( bStoreState )
3599 m_aStatusBarElement.m_bVisible = sal_False;
3600 aWriteLock.unlock();
3601 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3603 if ( xStatusBar.is() )
3605 Reference< css::awt::XWindow > xWindow( xStatusBar->getRealInterface(), UNO_QUERY );
3607 vos::OGuard aGuard( Application::GetSolarMutex() );
3608 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3609 if ( pWindow && pWindow->IsVisible() )
3611 pWindow->Hide();
3612 return sal_True;
3616 return sal_False;
3619 void LayoutManager::implts_setInplaceMenuBar( const Reference< XIndexAccess >& xMergedMenuBar )
3620 throw (::com::sun::star::uno::RuntimeException)
3622 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3623 WriteGuard aWriteLock( m_aLock );
3625 if ( !m_bInplaceMenuSet )
3627 vos::OGuard aGuard( Application::GetSolarMutex() );
3629 // Reset old inplace menubar!
3630 m_pInplaceMenuBar = 0;
3631 if ( m_xInplaceMenuBar.is() )
3632 m_xInplaceMenuBar->dispose();
3633 m_xInplaceMenuBar.clear();
3634 m_bInplaceMenuSet = sal_False;
3636 if ( m_xFrame.is() &&
3637 m_xContainerWindow.is() )
3639 rtl::OUString aModuleIdentifier;
3640 Reference< XDispatchProvider > xDispatchProvider;
3642 MenuBar* pMenuBar = new MenuBar;
3643 m_pInplaceMenuBar = new MenuBarManager( m_xSMGR, m_xFrame, m_xURLTransformer,xDispatchProvider, aModuleIdentifier, pMenuBar, sal_True, sal_True );
3644 m_pInplaceMenuBar->SetItemContainer( xMergedMenuBar );
3646 Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
3647 while ( pWindow && !pWindow->IsSystemWindow() )
3648 pWindow = pWindow->GetParent();
3650 if ( pWindow )
3652 SystemWindow* pSysWindow = (SystemWindow *)pWindow;
3653 pSysWindow->SetMenuBar( pMenuBar );
3656 m_bInplaceMenuSet = sal_True;
3657 m_xInplaceMenuBar = Reference< XComponent >( (OWeakObject *)m_pInplaceMenuBar, UNO_QUERY );
3660 aWriteLock.unlock();
3661 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3662 implts_updateMenuBarClose();
3667 void LayoutManager::implts_resetInplaceMenuBar()
3668 throw (::com::sun::star::uno::RuntimeException)
3670 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3671 WriteGuard aWriteLock( m_aLock );
3672 m_bInplaceMenuSet = sal_False;
3674 // if ( m_xMenuBar.is() &&
3675 if ( m_xContainerWindow.is() )
3677 vos::OGuard aGuard( Application::GetSolarMutex() );
3678 MenuBarWrapper* pMenuBarWrapper = SAL_STATIC_CAST( MenuBarWrapper*, m_xMenuBar.get() );
3679 Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
3680 while ( pWindow && !pWindow->IsSystemWindow() )
3681 pWindow = pWindow->GetParent();
3683 if ( pWindow )
3685 SystemWindow* pSysWindow = (SystemWindow *)pWindow;
3686 if ( pMenuBarWrapper )
3687 pSysWindow->SetMenuBar( (MenuBar *)pMenuBarWrapper->GetMenuBarManager()->GetMenuBar() );
3688 else
3689 pSysWindow->SetMenuBar( 0 );
3693 // Remove inplace menu bar
3694 m_pInplaceMenuBar = 0;
3695 if ( m_xInplaceMenuBar.is() )
3696 m_xInplaceMenuBar->dispose();
3697 m_xInplaceMenuBar.clear();
3699 aWriteLock.unlock();
3700 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3703 void SAL_CALL LayoutManager::attachFrame( const Reference< XFrame >& xFrame )
3704 throw (::com::sun::star::uno::RuntimeException)
3706 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3707 WriteGuard aWriteLock( m_aLock );
3708 m_xFrame = xFrame;
3709 aWriteLock.unlock();
3710 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3711 // if ( xFrame.is() )
3712 // xFrame->getContainerWindow()->addWindowListener( Reference< css::awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
3715 void SAL_CALL LayoutManager::reset()
3716 throw (RuntimeException)
3718 sal_Bool bComponentAttached( sal_False );
3720 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3721 ReadGuard aReadLock( m_aLock );
3722 bComponentAttached = m_bComponentAttached;
3723 aReadLock.unlock();
3725 implts_reset( sal_True );
3728 void SAL_CALL LayoutManager::setInplaceMenuBar( sal_Int64 )
3729 throw (::com::sun::star::uno::RuntimeException)
3731 OSL_ENSURE( sal_False, "This method is obsolete and should not be used!\n" );
3734 void SAL_CALL LayoutManager::resetInplaceMenuBar()
3735 throw (::com::sun::star::uno::RuntimeException)
3737 OSL_ENSURE( sal_False, "This method is obsolete and should not be used!\n" );
3740 //---------------------------------------------------------------------------------------------------------
3741 // XMenuBarMergingAcceptor
3742 //---------------------------------------------------------------------------------------------------------
3743 sal_Bool SAL_CALL LayoutManager::setMergedMenuBar(
3744 const Reference< XIndexAccess >& xMergedMenuBar )
3745 throw (::com::sun::star::uno::RuntimeException)
3747 implts_setInplaceMenuBar( xMergedMenuBar );
3749 css::uno::Any a;
3750 implts_notifyListeners( css::frame::LayoutManagerEvents::MERGEDMENUBAR, a );
3751 return sal_True;
3754 void SAL_CALL LayoutManager::removeMergedMenuBar()
3755 throw (::com::sun::star::uno::RuntimeException)
3757 implts_resetInplaceMenuBar();
3760 ::com::sun::star::awt::Rectangle SAL_CALL LayoutManager::getCurrentDockingArea()
3761 throw ( RuntimeException )
3763 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3764 ReadGuard aReadLock( m_aLock );
3765 return m_aDockingArea;
3768 Reference< XDockingAreaAcceptor > SAL_CALL LayoutManager::getDockingAreaAcceptor()
3769 throw (::com::sun::star::uno::RuntimeException)
3771 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3772 ReadGuard aReadLock( m_aLock );
3773 return m_xDockingAreaAcceptor;
3776 void SAL_CALL LayoutManager::setDockingAreaAcceptor( const Reference< ::com::sun::star::ui::XDockingAreaAcceptor >& xDockingAreaAcceptor )
3777 throw ( RuntimeException )
3779 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3780 WriteGuard aWriteLock( m_aLock );
3782 if (( m_xDockingAreaAcceptor == xDockingAreaAcceptor ) ||
3783 !m_xFrame.is() )
3784 return;
3786 // IMPORTANT: Be sure to stop layout timer if don't have a docking area acceptor!
3787 if ( !xDockingAreaAcceptor.is() )
3788 m_aAsyncLayoutTimer.Stop();
3790 sal_Bool bAutomaticToolbars( m_bAutomaticToolbars );
3791 std::vector< Reference< css::awt::XWindow > > oldDockingAreaWindows;
3793 if ( !xDockingAreaAcceptor.is() )
3794 m_aAsyncLayoutTimer.Stop();
3796 // Remove listener from old docking area acceptor
3797 if ( m_xDockingAreaAcceptor.is() )
3799 Reference< css::awt::XWindow > xWindow( m_xDockingAreaAcceptor->getContainerWindow() );
3800 if ( xWindow.is() && ( m_xFrame->getContainerWindow() != m_xContainerWindow || !xDockingAreaAcceptor.is() ) )
3801 xWindow->removeWindowListener( Reference< css::awt::XWindowListener >( static_cast< OWeakObject * >( this ), UNO_QUERY ));
3803 oldDockingAreaWindows.push_back( m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP] );
3804 oldDockingAreaWindows.push_back( m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM] );
3805 oldDockingAreaWindows.push_back( m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT] );
3806 oldDockingAreaWindows.push_back( m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT] );
3808 m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP].clear();
3809 m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM].clear();
3810 m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT].clear();
3811 m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT].clear();
3812 m_aDockingArea = css::awt::Rectangle();
3814 Window* pContainerWindow = VCLUnoHelper::GetWindow( xWindow );
3815 if ( pContainerWindow )
3816 pContainerWindow->RemoveChildEventListener( LINK( this, LayoutManager, WindowEventListener ) );
3819 // Set new docking area acceptor and add ourself as window listener on the container window.
3820 // Create our docking area windows which are parents for all docked windows.
3821 css::uno::Reference< css::awt::XWindow > xTopDockWindow;
3822 css::uno::Reference< css::awt::XWindow > xBottomDockWindow;
3823 css::uno::Reference< css::awt::XWindow > xLeftDockWindow;
3824 css::uno::Reference< css::awt::XWindow > xRightDockWindow;
3826 Reference< ::com::sun::star::ui::XDockingAreaAcceptor > xOldDockingAreaAcceptor( m_xDockingAreaAcceptor );
3827 m_xDockingAreaAcceptor = xDockingAreaAcceptor;
3828 if ( m_xDockingAreaAcceptor.is() )
3830 m_aDockingArea = css::awt::Rectangle();
3831 m_xContainerWindow = m_xDockingAreaAcceptor->getContainerWindow();
3832 m_xContainerWindow->addWindowListener( Reference< css::awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
3834 // we always must keep a connection to the window of our frame for resize events
3835 if ( m_xContainerWindow != m_xFrame->getContainerWindow() )
3836 m_xFrame->getContainerWindow()->addWindowListener( Reference< css::awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
3838 // #i37884# set initial visibility state - in the plugin case the container window is already shown
3839 // and we get no notification anymore
3841 vos::OGuard aGuard( Application::GetSolarMutex() );
3842 Window* pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
3843 if( pContainerWindow )
3844 m_bParentWindowVisible = pContainerWindow->IsVisible();
3847 css::uno::Reference< css::awt::XWindowPeer > xParent( m_xContainerWindow, UNO_QUERY );
3848 xTopDockWindow = Reference< css::awt::XWindow >( implts_createToolkitWindow( xParent ), UNO_QUERY );
3849 xBottomDockWindow = Reference< css::awt::XWindow >( implts_createToolkitWindow( xParent ), UNO_QUERY );
3850 xLeftDockWindow = Reference< css::awt::XWindow >( implts_createToolkitWindow( xParent ), UNO_QUERY );
3851 xRightDockWindow = Reference< css::awt::XWindow >( implts_createToolkitWindow( xParent ), UNO_QUERY );
3852 m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP] = xTopDockWindow;
3853 m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM] = xBottomDockWindow;
3854 m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT] = xLeftDockWindow;
3855 m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT] = xRightDockWindow;
3858 aWriteLock.unlock();
3859 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3861 if ( xDockingAreaAcceptor.is() )
3863 vos::OGuard aGuard( Application::GetSolarMutex() );
3864 ::DockingAreaWindow* pWindow;
3865 pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xTopDockWindow ) );
3866 if( pWindow ) pWindow->SetAlign( WINDOWALIGN_TOP );
3867 pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xBottomDockWindow ) );
3868 if( pWindow ) pWindow->SetAlign( WINDOWALIGN_BOTTOM );
3869 pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xLeftDockWindow ) );
3870 if( pWindow ) pWindow->SetAlign( WINDOWALIGN_LEFT );
3871 pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xRightDockWindow ) );
3872 if( pWindow ) pWindow->SetAlign( WINDOWALIGN_RIGHT );
3874 // Add layout manager as listener to get notifications about toolbar button activties
3875 Window* pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
3876 if ( pContainerWindow )
3877 pContainerWindow->AddChildEventListener( LINK( this, LayoutManager, WindowEventListener ) );
3879 // We have now a new container window, reparent all child windows!
3880 implts_reparentChildWindows();
3882 else
3883 implts_destroyElements(); // remove all elements
3885 if ( !oldDockingAreaWindows.empty() )
3887 const sal_uInt32 nCount = oldDockingAreaWindows.size();
3888 for ( sal_uInt32 i = 0; i < nCount; ++i )
3890 if ( oldDockingAreaWindows[i].is() )
3894 oldDockingAreaWindows[i]->dispose();
3896 catch ( Exception& )
3902 // Reset docking area size for our old docking area acceptor
3903 css::awt::Rectangle aEmptyRect;
3904 xOldDockingAreaAcceptor->setDockingAreaSpace( aEmptyRect );
3907 if ( xDockingAreaAcceptor.is() )
3909 if ( bAutomaticToolbars )
3911 implts_createAddonsToolBars(); // create addon toolbars
3912 implts_createCustomToolBars(); // create custom toolbars
3913 implts_createNonContextSensitiveToolBars();
3915 implts_sortUIElements();
3916 implts_doLayout( sal_True );
3920 void LayoutManager::implts_reparentChildWindows()
3922 UIElementVector aUIElementVector;
3923 UIElement aStatusBarElement;
3924 css::uno::Reference< css::awt::XWindow > xTopDockWindow;
3925 css::uno::Reference< css::awt::XWindow > xBottomDockWindow;
3926 css::uno::Reference< css::awt::XWindow > xLeftDockWindow;
3927 css::uno::Reference< css::awt::XWindow > xRightDockWindow;
3928 css::uno::Reference< css::awt::XWindow > xContainerWindow;
3929 css::uno::Reference< css::awt::XWindow > xStatusBarWindow;
3931 WriteGuard aWriteLock( m_aLock );
3932 aUIElementVector = m_aUIElements;
3933 xTopDockWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP];
3934 xBottomDockWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM];
3935 xLeftDockWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT];
3936 xRightDockWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT];
3937 xContainerWindow = m_xContainerWindow;
3938 aStatusBarElement = m_aStatusBarElement;
3939 aWriteLock.unlock();
3941 if ( aStatusBarElement.m_xUIElement.is() )
3945 xStatusBarWindow = Reference< css::awt::XWindow >(
3946 aStatusBarElement.m_xUIElement->getRealInterface(),
3947 UNO_QUERY );
3949 catch ( RuntimeException& )
3951 throw;
3953 catch ( Exception& )
3958 vos::OGuard aGuard( Application::GetSolarMutex() );
3959 Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
3960 Window* pTopDockWindow = VCLUnoHelper::GetWindow( xTopDockWindow );
3961 Window* pBottomDockWindow = VCLUnoHelper::GetWindow( xBottomDockWindow );
3962 Window* pLeftDockWindow = VCLUnoHelper::GetWindow( xLeftDockWindow );
3963 Window* pRightDockWindow = VCLUnoHelper::GetWindow( xRightDockWindow );
3964 if ( pContainerWindow )
3966 UIElementVector::iterator pIter;
3967 for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); pIter++ )
3969 Reference< XUIElement > xUIElement( pIter->m_xUIElement );
3970 if ( xUIElement.is() )
3972 Reference< css::awt::XWindow > xWindow;
3975 // We have to retreive the window reference with try/catch as it is
3976 // possible that all elements has been disposed!
3977 xWindow = Reference< css::awt::XWindow >( xUIElement->getRealInterface(), UNO_QUERY );
3979 catch ( RuntimeException& )
3981 throw;
3983 catch ( Exception& )
3987 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3988 if ( pWindow )
3990 // Reparent our child windows acording to their current state.
3991 if ( pIter->m_bFloating )
3992 pWindow->SetParent( pContainerWindow );
3993 else
3995 if ( pIter->m_aDockedData.m_nDockedArea == DockingArea_DOCKINGAREA_TOP )
3996 pWindow->SetParent( pTopDockWindow );
3997 else if ( pIter->m_aDockedData.m_nDockedArea == DockingArea_DOCKINGAREA_BOTTOM )
3998 pWindow->SetParent( pBottomDockWindow );
3999 else if ( pIter->m_aDockedData.m_nDockedArea == DockingArea_DOCKINGAREA_LEFT )
4000 pWindow->SetParent( pLeftDockWindow );
4001 else
4002 pWindow->SetParent( pRightDockWindow );
4008 if ( xStatusBarWindow.is() )
4010 Window* pWindow = VCLUnoHelper::GetWindow( xStatusBarWindow );
4011 if ( pWindow )
4012 pWindow->SetParent( pContainerWindow );
4015 implts_resetMenuBar();
4019 IMPL_LINK( LayoutManager, WindowEventListener, VclSimpleEvent*, pEvent )
4021 // To enable toolbar controllers to change their image when a sub-toolbar function
4022 // is activated, we need this mechanism. We have NO connection between these toolbars
4023 // anymore!
4024 if ( pEvent && pEvent->ISA( VclWindowEvent ))
4026 if ( pEvent->GetId() == VCLEVENT_TOOLBOX_SELECT )
4028 Window* pWindow( ((VclWindowEvent*)pEvent)->GetWindow() );
4029 ToolBox* pToolBox( 0 );
4030 rtl::OUString aToolbarName;
4031 rtl::OUString aCommand;
4033 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
4035 pToolBox = (ToolBox *)pWindow;
4036 aToolbarName = pToolBox->GetSmartHelpId().GetStr();
4037 sal_Int32 i = aToolbarName.lastIndexOf( ':' );
4038 if (( aToolbarName.getLength() > 0 ) &&
4039 ( i > 0 ) && (( i+ 1 ) < aToolbarName.getLength() ))
4041 // Remove ".HelpId:" protocol from toolbar name
4042 aToolbarName = aToolbarName.copy( i+1 );
4044 USHORT nId = pToolBox->GetCurItemId();
4045 if ( nId > 0 )
4046 aCommand = pToolBox->GetItemCommand( nId );
4050 if (( aToolbarName.getLength() > 0 ) && ( aCommand.getLength() > 0 ))
4052 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4053 ReadGuard aReadLock( m_aLock );
4054 std::vector< css::uno::Reference< css::ui::XUIFunctionListener > > aListenerArray;
4055 UIElementVector::iterator pIter;
4057 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
4059 if ( pIter->m_aType.equalsAscii( "toolbar" ) &&
4060 pIter->m_xUIElement.is() )
4062 css::uno::Reference< css::ui::XUIFunctionListener > xListener( pIter->m_xUIElement, UNO_QUERY );
4063 if ( xListener.is() )
4064 aListenerArray.push_back( xListener );
4067 aReadLock.unlock();
4068 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4070 const sal_uInt32 nCount = aListenerArray.size();
4071 for ( sal_uInt32 i = 0; i < nCount; ++i )
4075 aListenerArray[i]->functionExecute( aToolbarName, aCommand );
4077 catch ( RuntimeException& e )
4079 throw e;
4081 catch ( Exception& ) {}
4085 else if ( pEvent->GetId() == VCLEVENT_TOOLBOX_FORMATCHANGED )
4087 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4088 ReadGuard aReadLock( m_aLock );
4090 Window* pWindow( ((VclWindowEvent*)pEvent)->GetWindow() );
4091 ToolBox* pToolBox( 0 );
4092 rtl::OUString aToolbarName;
4094 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
4096 pToolBox = (ToolBox *)pWindow;
4097 aToolbarName = pToolBox->GetSmartHelpId().GetStr();
4098 if (( aToolbarName.getLength() > 0 ) && ( m_nLockCount == 0 ))
4099 m_aAsyncLayoutTimer.Start();
4101 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4105 return 1;
4108 void SAL_CALL LayoutManager::createElement( const ::rtl::OUString& aName )
4109 throw (RuntimeException)
4111 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::createElement" );
4113 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4114 ReadGuard aReadLock( m_aLock );
4115 Reference< XFrame > xFrame = m_xFrame;
4116 Reference< XURLTransformer > xURLTransformer = m_xURLTransformer;
4117 sal_Bool bInPlaceMenu = m_bInplaceMenuSet;
4118 aReadLock.unlock();
4119 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4121 if ( !xFrame.is() )
4122 return;
4124 Reference< XModel > xModel( impl_getModelFromFrame( xFrame ) );
4126 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4127 WriteGuard aWriteLock( m_aLock );
4129 sal_Bool bFound( sal_False );
4130 sal_Bool bNotify( sal_False );
4131 ::rtl::OUString aElementType;
4132 ::rtl::OUString aElementName;
4133 Reference< ::com::sun::star::ui::XUIElement > xUIElement;
4135 implts_findElement( aName, aElementType, aElementName, xUIElement );
4136 bFound = xUIElement.is();
4138 if ( /*xFrame.is() && */m_xContainerWindow.is() && !implts_isPreviewModel( xModel ) ) // no bars on preview mode
4140 if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4142 if ( !bFound )
4144 SvtCommandOptions aCmdOptions;
4146 xUIElement = implts_createElement( aName );
4147 sal_Bool bVisible( sal_False );
4148 if ( xUIElement.is() )
4150 Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
4151 Reference< css::awt::XDockableWindow > xDockWindow( xUIElement->getRealInterface(), UNO_QUERY );
4152 if ( xDockWindow.is() && xWindow.is() )
4156 xDockWindow->addDockableWindowListener( Reference< css::awt::XDockableWindowListener >(
4157 static_cast< OWeakObject * >( this ), UNO_QUERY ));
4158 xWindow->addWindowListener( Reference< css::awt::XWindowListener >(
4159 static_cast< OWeakObject * >( this ), UNO_QUERY ));
4160 xDockWindow->enableDocking( sal_True );
4162 catch ( Exception& )
4167 UIElement& rElement = impl_findElement( aName );
4168 if ( rElement.m_aName.getLength() > 0 )
4170 // Reuse a local entry so we are able to use the latest
4171 // UI changes for this document.
4172 implts_setElementData( rElement, xDockWindow );
4173 rElement.m_xUIElement = xUIElement;
4174 bVisible = rElement.m_bVisible;
4176 else
4178 // Create new UI element and try to read its state data
4179 UIElement aNewToolbar( aName, aElementType, xUIElement );
4180 implts_readWindowStateData( aName, aNewToolbar );
4181 implts_setElementData( aNewToolbar, xDockWindow );
4182 implts_insertUIElement( aNewToolbar );
4183 bVisible = aNewToolbar.m_bVisible;
4186 // set toolbar menu style according to customize command state
4187 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
4188 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
4190 ToolBox* pToolbar = (ToolBox *)pWindow;
4191 USHORT nMenuType = pToolbar->GetMenuType();
4192 if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, m_aCustomizeCmd ))
4193 pToolbar->SetMenuType( nMenuType & ~TOOLBOX_MENUTYPE_CUSTOMIZE );
4194 else
4195 pToolbar->SetMenuType( nMenuType | TOOLBOX_MENUTYPE_CUSTOMIZE );
4198 aWriteLock.unlock();
4200 implts_sortUIElements();
4202 if ( bVisible )
4204 doLayout();
4205 bNotify = sal_True;
4209 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ))
4211 if ( aElementName.equalsIgnoreAsciiCaseAscii( "menubar" ) && !bInPlaceMenu )
4213 vos::OGuard aGuard( Application::GetSolarMutex() );
4214 // PB 2004-12-15 #i38743# don't create a menubar if frame isn't top
4215 if ( !m_xMenuBar.is() && implts_isFrameOrWindowTop(xFrame) )
4216 m_xMenuBar = implts_createElement( aName );
4218 if ( m_xMenuBar.is() && implts_isFrameOrWindowTop(xFrame) )
4220 Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
4221 while ( pWindow && !pWindow->IsSystemWindow() )
4222 pWindow = pWindow->GetParent();
4224 if ( pWindow )
4226 SystemWindow* pSysWindow = (SystemWindow *)pWindow;
4227 Reference< css::awt::XMenuBar > xMenuBar;
4229 Reference< XPropertySet > xPropSet( m_xMenuBar, UNO_QUERY );
4230 if ( xPropSet.is() )
4234 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMenuBar" ))) >>= xMenuBar;
4236 catch ( com::sun::star::beans::UnknownPropertyException )
4239 catch ( com::sun::star::lang::WrappedTargetException )
4244 if ( xMenuBar.is() )
4246 VCLXMenu* pAwtMenuBar = VCLXMenu::GetImplementation( xMenuBar );
4247 if ( pAwtMenuBar )
4249 MenuBar* pMenuBar = (MenuBar*)pAwtMenuBar->GetMenu();
4250 if ( pMenuBar )
4252 pSysWindow->SetMenuBar( pMenuBar );
4253 pMenuBar->SetDisplayable( m_bMenuVisible );
4254 if ( m_bMenuVisible )
4256 bNotify = sal_True;
4258 implts_updateMenuBarClose();
4265 aWriteLock.unlock();
4267 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) && ( implts_isFrameOrWindowTop(xFrame) || implts_isEmbeddedLayoutManager() ))
4269 implts_createStatusBar( aName );
4270 bNotify = sal_True;
4272 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4273 aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4274 implts_isFrameOrWindowTop(xFrame) )
4276 implts_createProgressBar();
4277 bNotify = sal_True;
4279 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4281 aWriteLock.unlock();
4283 // The docking window is created by a factory method located in the sfx2 library.
4284 CreateDockingWindow( xFrame, aElementName );
4288 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4289 if ( bNotify )
4291 // UI element is invisible - provide information to listeners
4292 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( aName ) );
4296 void SAL_CALL LayoutManager::destroyElement( const ::rtl::OUString& aName )
4297 throw (RuntimeException)
4299 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::destroyElement" );
4301 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4302 WriteGuard aWriteLock( m_aLock );
4304 sal_Bool bMustLayouted( sal_False );
4305 sal_Bool bMustBeDestroyed( sal_False );
4306 sal_Bool bMustBeSorted( sal_False );
4307 sal_Bool bNotify( sal_False );
4308 ::rtl::OUString aElementType;
4309 ::rtl::OUString aElementName;
4311 Reference< XComponent > xComponent;
4312 if ( impl_parseResourceURL( aName, aElementType, aElementName ))
4314 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
4315 aElementName.equalsIgnoreAsciiCaseAscii( "menubar" ))
4317 if ( !m_bInplaceMenuSet )
4319 impl_clearUpMenuBar();
4320 m_xMenuBar.clear();
4321 bNotify = sal_True;
4324 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
4325 aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
4326 ( m_aStatusBarElement.m_aName == aName ))
4328 aWriteLock.unlock();
4329 implts_destroyStatusBar();
4330 bMustLayouted = sal_True;
4331 bNotify = sal_True;
4333 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4334 aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ) )
4336 aWriteLock.unlock();
4337 implts_createProgressBar();
4338 bMustLayouted = sal_True;
4339 bNotify = sal_True;
4341 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4343 UIElementVector::iterator pIter;
4345 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
4347 if ( pIter->m_aName == aName )
4349 xComponent.set( pIter->m_xUIElement, UNO_QUERY );
4350 Reference< XUIElement > xUIElement( pIter->m_xUIElement );
4351 if ( xUIElement.is() )
4353 Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
4354 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
4356 rtl::OUString aAddonTbResourceName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/addon_" ));
4357 if ( aName.indexOf( aAddonTbResourceName ) != 0 )
4361 if ( xWindow.is() )
4362 xWindow->removeWindowListener( Reference< css::awt::XWindowListener >(
4363 static_cast< OWeakObject * >( this ), UNO_QUERY ));
4365 catch( Exception& )
4371 if ( xDockWindow.is() )
4372 xDockWindow->removeDockableWindowListener( Reference< css::awt::XDockableWindowListener >(
4373 static_cast< OWeakObject * >( this ), UNO_QUERY ));
4375 catch ( Exception& )
4379 bMustBeDestroyed = sal_True;
4381 else
4383 pIter->m_bVisible = sal_False;
4384 xWindow->setVisible( sal_False );
4385 bNotify = sal_True;
4388 if ( !xDockWindow->isFloating() )
4389 bMustLayouted = sal_True;
4390 if ( bMustBeDestroyed )
4391 pIter->m_xUIElement.clear();
4393 bMustBeSorted = sal_True;
4396 break;
4400 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4402 css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame );
4403 css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR );
4404 aWriteLock.unlock();
4406 impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, false );
4407 bMustLayouted = sal_False;
4408 bNotify = sal_False;
4411 aWriteLock.unlock();
4412 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4414 if ( bMustBeDestroyed )
4416 if ( xComponent.is() )
4417 xComponent->dispose();
4418 bNotify = sal_True;
4421 if ( bMustBeSorted )
4423 implts_sortUIElements();
4424 if ( bMustLayouted )
4425 doLayout();
4428 if ( bNotify )
4430 // UI element is invisible - provide information to listeners
4431 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::makeAny( aName ) );
4435 ::sal_Bool SAL_CALL LayoutManager::requestElement( const ::rtl::OUString& ResourceURL )
4436 throw (::com::sun::star::uno::RuntimeException)
4438 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::requestElement" );
4440 ::rtl::OUString aElementType;
4441 ::rtl::OUString aElementName;
4442 UIElementVector::iterator pIter;
4443 sal_Bool bResult( sal_False );
4444 sal_Bool bNotify( sal_False );
4446 WriteGuard aWriteLock( m_aLock );
4447 if ( impl_parseResourceURL( ResourceURL, aElementType, aElementName ))
4449 ::rtl::OString aResName = rtl::OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US );
4450 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "framework (cd100003) Element %s", aResName.getStr() );
4452 if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
4453 aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
4454 ( m_aStatusBarElement.m_aName == ResourceURL ))
4456 implts_readStatusBarState( ResourceURL );
4457 if ( m_aStatusBarElement.m_bVisible && !m_aStatusBarElement.m_bMasterHide )
4459 createElement( ResourceURL );
4461 // There are some situation where we are not able to create an element.
4462 // Therefore we have to check the reference before further action.
4463 // See #i70019#
4464 css::uno::Reference< css::ui::XUIElement > xUIElement( m_aStatusBarElement.m_xUIElement );
4465 if ( xUIElement.is() )
4467 // we need VCL here to pass special flags to Show()
4468 vos::OGuard aGuard( Application::GetSolarMutex() );
4469 Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
4470 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
4471 if ( pWindow )
4473 pWindow->Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
4474 doLayout();
4475 bResult = sal_True;
4476 bNotify = sal_True;
4481 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4482 aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ) )
4484 aWriteLock.unlock();
4485 implts_showProgressBar();
4486 doLayout();
4487 bResult = sal_True;
4488 bNotify = sal_True;
4490 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4492 if ( m_bVisible )
4494 bool bFound( false );
4495 bool bShowElement( false );
4497 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
4499 if ( pIter->m_aName == ResourceURL )
4501 bFound = sal_True;
4502 bShowElement = ( pIter->m_bVisible && !pIter->m_bMasterHide && m_bParentWindowVisible );
4504 Reference< css::awt::XWindow2 > xContainerWindow( m_xContainerWindow, UNO_QUERY );
4505 if ( xContainerWindow.is() && pIter->m_bFloating )
4506 bShowElement = ( bShowElement && xContainerWindow->isActive() );
4508 if ( pIter->m_xUIElement.is() )
4510 Reference< css::awt::XWindow > xWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
4511 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
4513 if ( xDockWindow.is() && xDockWindow->isFloating() )
4514 bShowElement = ( bShowElement && xContainerWindow->isActive() );
4516 if ( xDockWindow.is() && bShowElement )
4518 pIter->m_bVisible = sal_True;
4519 aWriteLock.unlock();
4521 // we need VCL here to pass special flags to Show()
4522 vos::OGuard aGuard( Application::GetSolarMutex() );
4523 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
4524 if( pWindow && !pWindow->IsReallyVisible() )
4526 pWindow->Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
4527 implts_writeNewStateData( ResourceURL, xWindow );
4529 if ( xDockWindow.is() && !xDockWindow->isFloating() )
4530 doLayout();
4531 bResult = sal_True;
4532 bNotify = sal_True;
4535 bResult = sal_False;
4537 } // if ( pIter->m_xUIElement.is() )
4538 break;
4542 // Create toolbar on demand when it's visible
4543 if ( !bResult )
4545 Reference< ::com::sun::star::ui::XUIElement > xUIElement;
4546 if ( !bFound )
4548 UIElement aNewToolbar( aElementName, aElementType, xUIElement );
4549 aNewToolbar.m_aName = ResourceURL;
4550 implts_readWindowStateData( ResourceURL, aNewToolbar );
4551 implts_insertUIElement( aNewToolbar );
4552 aWriteLock.unlock();
4554 implts_sortUIElements();
4555 if ( aNewToolbar.m_bVisible )
4556 createElement( ResourceURL );
4557 bResult = sal_True;
4558 bNotify = sal_True;
4560 else if ( bShowElement )
4562 aWriteLock.unlock();
4564 createElement( ResourceURL );
4565 bResult = sal_True;
4566 bNotify = sal_True;
4571 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4573 css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame );
4574 aWriteLock.unlock();
4576 CreateDockingWindow( xFrame, aElementName );
4580 if ( bNotify )
4582 // UI element is visible - provide information to listeners
4583 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( ResourceURL ) );
4586 return bResult;
4589 Reference< XUIElement > SAL_CALL LayoutManager::getElement( const ::rtl::OUString& aName )
4590 throw (RuntimeException)
4592 ::rtl::OUString aElementType;
4593 ::rtl::OUString aElementName;
4594 Reference< XUIElement > xElement;
4596 implts_findElement( aName, aElementType, aElementName, xElement );
4597 return xElement;
4600 Sequence< Reference< ::com::sun::star::ui::XUIElement > > SAL_CALL LayoutManager::getElements()
4601 throw (::com::sun::star::uno::RuntimeException)
4603 ReadGuard aReadLock( m_aLock );
4605 sal_Bool bMenuBar( sal_False );
4606 sal_Bool bStatusBar( sal_False );
4607 sal_Int32 nSize = m_aUIElements.size();
4609 if ( m_xMenuBar.is() )
4611 ++nSize;
4612 bMenuBar = sal_True;
4614 if ( m_aStatusBarElement.m_xUIElement.is() )
4616 ++nSize;
4617 bStatusBar = sal_True;
4620 Sequence< Reference< ::com::sun::star::ui::XUIElement > > aSeq( nSize );
4622 sal_Int32 nIndex = 0;
4623 UIElementVector::const_iterator pIter;
4624 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
4626 if ( pIter->m_xUIElement.is() )
4627 aSeq[nIndex++] = pIter->m_xUIElement;
4629 if ( bMenuBar )
4630 aSeq[nIndex++] = m_xMenuBar;
4631 if ( bStatusBar )
4632 aSeq[nIndex++] = m_aStatusBarElement.m_xUIElement;
4634 // Resize sequence as we now know our correct size
4635 aSeq.realloc( nIndex );
4637 return aSeq;
4640 sal_Bool SAL_CALL LayoutManager::showElement( const ::rtl::OUString& aName )
4641 throw (RuntimeException)
4643 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::showElement" );
4645 sal_Bool bResult( sal_False );
4646 sal_Bool bNotify( sal_False );
4647 ::rtl::OUString aElementType;
4648 ::rtl::OUString aElementName;
4650 if ( impl_parseResourceURL( aName, aElementType, aElementName ))
4652 ::rtl::OString aResName = rtl::OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US );
4653 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "framework (cd100003) Element %s", aResName.getStr() );
4655 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
4656 aElementName.equalsIgnoreAsciiCaseAscii( "menubar" ))
4658 WriteGuard aWriteLock( m_aLock );
4659 m_bMenuVisible = sal_True;
4660 aWriteLock.unlock();
4662 bResult = implts_resetMenuBar();
4663 bNotify = bResult;
4665 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
4666 aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
4667 ( m_aStatusBarElement.m_aName == aName ))
4669 WriteGuard aWriteLock( m_aLock );
4670 if ( m_aStatusBarElement.m_xUIElement.is() &&
4671 !m_aStatusBarElement.m_bMasterHide )
4673 if ( implts_showStatusBar( sal_True ))
4675 implts_writeWindowStateData( m_aStatusBarAlias, m_aStatusBarElement );
4676 doLayout();
4677 bResult = sal_True;
4678 bNotify = sal_True;
4682 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4683 aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ))
4685 bNotify = bResult = implts_showProgressBar();
4687 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4689 UIElementVector::iterator pIter;
4691 WriteGuard aWriteLock( m_aLock );
4692 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
4694 if ( pIter->m_aName == aName && pIter->m_xUIElement.is() )
4696 UIElement aUIElement = *pIter;
4697 Reference< css::awt::XWindow > xWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
4698 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
4700 sal_Bool bShowElement( !pIter->m_bMasterHide && m_bParentWindowVisible );
4702 pIter->m_bVisible = sal_True;
4703 aWriteLock.unlock();
4705 implts_writeWindowStateData( aUIElement.m_aName, aUIElement );
4706 implts_sortUIElements();
4708 if ( xDockWindow.is() && bShowElement )
4710 // we need VCL here to pass special flags to Show()
4711 vos::OGuard aGuard( Application::GetSolarMutex() );
4712 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
4713 if( pWindow )
4715 pWindow->Show( TRUE, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
4716 bNotify = sal_True;
4718 implts_writeNewStateData( aName, xWindow );
4720 if ( xDockWindow.is() && !xDockWindow->isFloating() )
4721 doLayout();
4723 bResult = sal_True;
4724 } // if ( xDockWindow.is() && bShowElement )
4725 break;
4729 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4731 ReadGuard aReadGuard( m_aLock );
4732 css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame );
4733 css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR );
4734 aReadGuard.unlock();
4736 impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, true );
4740 if ( bNotify )
4742 // UI element is visible - provide information to listeners
4743 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_VISIBLE, uno::makeAny( aName ) );
4746 return bResult;
4749 sal_Bool SAL_CALL LayoutManager::hideElement( const ::rtl::OUString& aName )
4750 throw (RuntimeException)
4752 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::hideElement" );
4755 sal_Bool bResult( sal_False );
4756 sal_Bool bNotify( sal_False );
4757 ::rtl::OUString aElementType;
4758 ::rtl::OUString aElementName;
4760 if ( impl_parseResourceURL( aName, aElementType, aElementName ))
4762 ::rtl::OString aResName = rtl::OUStringToOString( aElementName, RTL_TEXTENCODING_ASCII_US );
4763 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "framework (cd100003) Element %s", aResName.getStr() );
4765 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
4766 aElementName.equalsIgnoreAsciiCaseAscii( "menubar" ))
4768 WriteGuard aWriteLock( m_aLock );
4770 if ( m_xContainerWindow.is() )
4772 vos::OGuard aGuard( Application::GetSolarMutex() );
4773 Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
4774 while ( pWindow && !pWindow->IsSystemWindow() )
4775 pWindow = pWindow->GetParent();
4777 m_bMenuVisible = sal_False;
4778 if ( pWindow )
4780 MenuBar* pMenuBar = ((SystemWindow *)pWindow)->GetMenuBar();
4781 if ( pMenuBar )
4783 pMenuBar->SetDisplayable( sal_False );
4784 bResult = sal_True;
4785 bNotify = sal_True;
4790 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
4791 aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
4792 ( m_aStatusBarElement.m_aName == aName ))
4794 WriteGuard aWriteLock( m_aLock );
4795 if ( m_aStatusBarElement.m_xUIElement.is() &&
4796 !m_aStatusBarElement.m_bMasterHide )
4798 if ( implts_hideStatusBar( sal_True ))
4800 implts_writeWindowStateData( m_aStatusBarAlias, m_aStatusBarElement );
4801 doLayout();
4802 bNotify = sal_True;
4803 bResult = sal_True;
4807 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4808 aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" ))
4810 bResult = bNotify = implts_hideProgressBar();
4812 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4814 UIElementVector::iterator pIter;
4816 WriteGuard aWriteLock( m_aLock );
4817 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
4819 if ( pIter->m_aName == aName && pIter->m_xUIElement.is() )
4821 Reference< css::awt::XWindow > xWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
4822 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
4824 if ( xDockWindow.is() )
4826 pIter->m_bVisible = sal_False;
4827 aWriteLock.unlock();
4829 xWindow->setVisible( sal_False );
4830 implts_writeNewStateData( aName, xWindow );
4832 if ( xDockWindow.is() && !xDockWindow->isFloating() )
4833 doLayout();
4835 bResult = sal_True;
4836 bNotify = sal_True;
4837 } // if ( xDockWindow.is() )
4838 break;
4842 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4844 ReadGuard aReadGuard( m_aLock );
4845 css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame );
4846 css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR( m_xSMGR );
4847 aReadGuard.unlock();
4849 impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, false );
4853 if ( bNotify )
4855 // UI element is visible - provide information to listeners
4856 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_INVISIBLE, uno::makeAny( aName ) );
4859 return sal_False;
4862 sal_Bool SAL_CALL LayoutManager::dockWindow( const ::rtl::OUString& aName, DockingArea DockingArea, const css::awt::Point& Pos )
4863 throw (RuntimeException)
4865 UIElement aUIElement;
4867 if ( implts_findElement( aName, aUIElement ) && aUIElement.m_xUIElement.is() )
4871 Reference< css::awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
4872 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
4873 if ( xDockWindow.is() )
4875 if ( DockingArea != DockingArea_DOCKINGAREA_DEFAULT )
4876 aUIElement.m_aDockedData.m_nDockedArea = sal_Int16( DockingArea );
4878 if (( Pos.X != SAL_MAX_INT32 ) && ( Pos.Y != SAL_MAX_INT32 ))
4879 aUIElement.m_aDockedData.m_aPos = ::Point( Pos.X, Pos.Y );
4881 if ( !xDockWindow->isFloating() )
4883 Window* pWindow( 0 );
4884 ToolBox* pToolBox( 0 );
4887 vos::OGuard aGuard( Application::GetSolarMutex() );
4888 pWindow = VCLUnoHelper::GetWindow( xWindow );
4889 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
4891 pToolBox = (ToolBox *)pWindow;
4893 // We have to set the alignment of the toolbox. It's possible that the toolbox is moved from a
4894 // horizontal to a vertical docking area!
4895 pToolBox->SetAlign( ImplConvertAlignment( aUIElement.m_aDockedData.m_nDockedArea ));
4899 if (( aUIElement.m_aDockedData.m_aPos.X() == SAL_MAX_INT32 ) ||
4900 ( aUIElement.m_aDockedData.m_aPos.Y() == SAL_MAX_INT32 ))
4902 // Docking on its default position without a preset position -
4903 // we have to find a good place for it.
4904 ::Size aSize;
4906 vos::OGuard aGuard( Application::GetSolarMutex() );
4908 if ( pToolBox )
4909 aSize = pToolBox->CalcWindowSizePixel( 1, ImplConvertAlignment( aUIElement.m_aDockedData.m_nDockedArea ) );
4910 else
4911 aSize = pWindow->GetSizePixel();
4914 ::Point aPixelPos;
4915 ::Point aDockPos;
4916 implts_findNextDockingPos( (::com::sun::star::ui::DockingArea)aUIElement.m_aDockedData.m_nDockedArea,
4917 aSize,
4918 aDockPos,
4919 aPixelPos );
4920 aUIElement.m_aDockedData.m_aPos = aDockPos;
4924 WriteGuard aWriteLock( m_aLock );
4925 UIElement& rUIElement = LayoutManager::impl_findElement( aUIElement.m_aName );
4926 if ( rUIElement.m_aName == aName )
4928 rUIElement.m_aDockedData.m_nDockedArea = aUIElement.m_aDockedData.m_nDockedArea;
4929 rUIElement.m_aDockedData.m_aPos = aUIElement.m_aDockedData.m_aPos;
4931 aWriteLock.unlock();
4933 if ( xDockWindow->isFloating() )
4935 // Will call toggle floating mode which will do the rest!
4936 xWindow->setVisible( sal_False );
4937 xDockWindow->setFloatingMode( sal_False );
4938 xWindow->setVisible( sal_True );
4940 else
4942 implts_writeWindowStateData( aName, aUIElement );
4943 implts_sortUIElements();
4945 if ( aUIElement.m_bVisible )
4946 doLayout();
4949 return sal_True;
4952 catch ( DisposedException& )
4957 return sal_False;
4960 ::sal_Bool SAL_CALL LayoutManager::dockAllWindows( ::sal_Int16 nElementType ) throw (::com::sun::star::uno::RuntimeException)
4962 if ( nElementType == UIElementType::TOOLBAR )
4964 std::vector< rtl::OUString > aToolBarNameVector;
4966 ::rtl::OUString aElementType;
4967 ::rtl::OUString aElementName;
4970 ReadGuard aReadLock( m_aLock );
4971 UIElementVector::iterator pIter;
4972 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
4974 if ( pIter->m_aType.equalsAscii( "toolbar" ) &&
4975 pIter->m_xUIElement.is() &&
4976 pIter->m_bFloating &&
4977 pIter->m_bVisible )
4978 aToolBarNameVector.push_back( pIter->m_aName );
4982 const sal_uInt32 nCount = aToolBarNameVector.size();
4983 for ( sal_uInt32 i = 0; i < nCount; ++i )
4985 ::com::sun::star::awt::Point aPoint;
4986 aPoint.X = aPoint.Y = SAL_MAX_INT32;
4987 dockWindow( aToolBarNameVector[i], DockingArea_DOCKINGAREA_DEFAULT, aPoint );
4991 return sal_False;
4994 sal_Bool SAL_CALL LayoutManager::floatWindow( const ::rtl::OUString& aName )
4995 throw (RuntimeException)
4997 UIElement aUIElement;
4999 if ( implts_findElement( aName, aUIElement ))
5001 if ( aUIElement.m_xUIElement.is() )
5005 Reference< css::awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5006 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
5007 if ( xWindow.is() && xDockWindow.is() )
5009 if ( !xDockWindow->isFloating() )
5011 xDockWindow->setFloatingMode( sal_True );
5012 return sal_True;
5016 catch ( DisposedException& )
5022 return sal_False;
5025 ::sal_Bool SAL_CALL LayoutManager::lockWindow( const ::rtl::OUString& ResourceURL )
5026 throw (::com::sun::star::uno::RuntimeException)
5028 UIElement aUIElement;
5030 if ( implts_findElement( ResourceURL, aUIElement ))
5032 if ( aUIElement.m_xUIElement.is() )
5036 Reference< css::awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5037 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
5038 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
5039 if ( pWindow &&
5040 pWindow->IsVisible() &&
5041 xDockWindow.is() &&
5042 !xDockWindow->isFloating() )
5044 aUIElement.m_aDockedData.m_bLocked = sal_True;
5045 implts_writeWindowStateData( ResourceURL, aUIElement );
5046 xDockWindow->lock();
5048 // Write back lock state
5049 WriteGuard aWriteLock( m_aLock );
5050 UIElement& rUIElement = LayoutManager::impl_findElement( aUIElement.m_aName );
5051 if ( rUIElement.m_aName == aUIElement.m_aName )
5052 rUIElement.m_aDockedData.m_bLocked = aUIElement.m_aDockedData.m_bLocked;
5053 aWriteLock.unlock();
5055 doLayout();
5056 return sal_True;
5059 catch ( DisposedException& )
5065 return sal_False;
5068 ::sal_Bool SAL_CALL LayoutManager::unlockWindow( const ::rtl::OUString& ResourceURL )
5069 throw (::com::sun::star::uno::RuntimeException)
5071 UIElement aUIElement;
5073 if ( implts_findElement( ResourceURL, aUIElement ))
5075 if ( aUIElement.m_xUIElement.is() )
5079 Reference< css::awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5080 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
5081 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
5082 if ( pWindow &&
5083 pWindow->IsVisible() &&
5084 xDockWindow.is() &&
5085 !xDockWindow->isFloating() )
5087 aUIElement.m_aDockedData.m_bLocked = sal_False;
5088 implts_writeWindowStateData( ResourceURL, aUIElement );
5089 xDockWindow->unlock();
5091 // Write back lock state
5092 WriteGuard aWriteLock( m_aLock );
5093 UIElement& rUIElement = LayoutManager::impl_findElement( aUIElement.m_aName );
5094 if ( rUIElement.m_aName == aUIElement.m_aName )
5095 rUIElement.m_aDockedData.m_bLocked = aUIElement.m_aDockedData.m_bLocked;
5096 aWriteLock.unlock();
5098 doLayout();
5099 return sal_True;
5102 catch ( DisposedException& )
5108 return sal_False;
5111 void SAL_CALL LayoutManager::setElementSize( const ::rtl::OUString& aName, const css::awt::Size& aSize )
5112 throw (RuntimeException)
5114 UIElement aUIElement;
5116 if ( implts_findElement( aName, aUIElement ))
5118 if ( aUIElement.m_xUIElement.is() )
5122 Reference< css::awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5123 Reference< css::awt::XWindow2 > xWindow2( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5124 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
5126 if ( xWindow.is() && xWindow2.is() && xDockWindow.is() )
5128 if ( aUIElement.m_bFloating )
5130 xWindow2->setOutputSize( aSize );
5131 implts_writeNewStateData( aName, xWindow );
5135 catch ( DisposedException& )
5142 void SAL_CALL LayoutManager::setElementPos( const ::rtl::OUString& aName, const css::awt::Point& aPos )
5143 throw (RuntimeException)
5145 UIElement aUIElement;
5147 if ( implts_findElement( aName, aUIElement ) && aUIElement.m_xUIElement.is() )
5151 Reference< css::awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5152 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
5154 if ( xWindow.is() && xDockWindow.is() )
5156 if ( aUIElement.m_bFloating )
5158 xWindow->setPosSize( aPos.X, aPos.Y, 0, 0, css::awt::PosSize::POS );
5159 implts_writeNewStateData( aName, xWindow );
5161 else
5163 WriteGuard aWriteLock( m_aLock );
5164 UIElement& rUIElement = LayoutManager::impl_findElement( aUIElement.m_aName );
5165 if ( rUIElement.m_aName == aName )
5166 rUIElement.m_aDockedData.m_aPos = ::Point( aPos.X, aPos.Y );
5167 aWriteLock.unlock();
5169 aUIElement.m_aDockedData.m_aPos = ::Point( aPos.X, aPos.Y );
5170 implts_writeWindowStateData( aName, aUIElement );
5171 implts_sortUIElements();
5173 if ( aUIElement.m_bVisible )
5174 doLayout();
5178 catch ( DisposedException& )
5184 void SAL_CALL LayoutManager::setElementPosSize( const ::rtl::OUString& aName, const css::awt::Point& aPos, const css::awt::Size& aSize )
5185 throw (RuntimeException)
5187 UIElement aUIElement;
5189 if ( implts_findElement( aName, aUIElement ))
5191 if ( aUIElement.m_xUIElement.is() )
5195 Reference< css::awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5196 Reference< css::awt::XWindow2 > xWindow2( aUIElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5197 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
5199 if ( xWindow.is() && xWindow2.is() && xDockWindow.is() )
5201 if ( aUIElement.m_bFloating )
5203 xWindow2->setPosSize( aPos.X, aPos.Y, 0, 0, css::awt::PosSize::POS );
5204 xWindow2->setOutputSize( aSize );
5205 implts_writeNewStateData( aName, xWindow );
5207 else
5209 WriteGuard aWriteLock( m_aLock );
5210 UIElement& rUIElement = LayoutManager::impl_findElement( aUIElement.m_aName );
5211 if ( rUIElement.m_aName == aName )
5212 rUIElement.m_aDockedData.m_aPos = ::Point( aPos.X, aPos.Y );
5213 aWriteLock.unlock();
5215 aUIElement.m_aDockedData.m_aPos = ::Point( aPos.X, aPos.Y );
5216 implts_writeWindowStateData( aName, rUIElement );
5217 implts_sortUIElements();
5219 if ( aUIElement.m_bVisible )
5220 doLayout();
5224 catch ( DisposedException& )
5231 sal_Bool SAL_CALL LayoutManager::isElementVisible( const ::rtl::OUString& aName )
5232 throw (RuntimeException)
5234 ::rtl::OUString aElementType;
5235 ::rtl::OUString aElementName;
5237 if ( impl_parseResourceURL( aName, aElementType, aElementName ))
5239 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
5240 aElementName.equalsIgnoreAsciiCaseAscii( "menubar" ))
5242 ReadGuard aReadLock( m_aLock );
5243 if ( m_xContainerWindow.is() )
5245 aReadLock.unlock();
5247 vos::OGuard aGuard( Application::GetSolarMutex() );
5248 Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
5249 while ( pWindow && !pWindow->IsSystemWindow() )
5250 pWindow = pWindow->GetParent();
5252 if ( pWindow )
5254 MenuBar* pMenuBar = ((SystemWindow *)pWindow)->GetMenuBar();
5255 if ( pMenuBar && pMenuBar->IsDisplayable() )
5256 return sal_True;
5258 else
5260 aReadLock.lock();
5261 return m_bMenuVisible;
5265 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
5266 aElementName.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
5267 ( m_aStatusBarElement.m_aName == aName ))
5269 if ( m_aStatusBarElement.m_xUIElement.is() )
5271 Reference< css::awt::XWindow > xWindow(
5272 m_aStatusBarElement.m_xUIElement->getRealInterface(), UNO_QUERY );
5273 if ( xWindow.is() )
5275 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
5276 if ( pWindow && pWindow->IsVisible() )
5277 return sal_True;
5278 else
5279 return sal_False;
5283 else if (( aElementType.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
5284 aElementName.equalsIgnoreAsciiCaseAscii( "progressbar" )))
5286 if ( m_aProgressBarElement.m_xUIElement.is() )
5287 return m_aProgressBarElement.m_bVisible;
5289 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ))
5291 UIElementVector::const_iterator pIter;
5293 ReadGuard aReadLock( m_aLock );
5294 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
5296 if ( pIter->m_aName == aName && pIter->m_xUIElement.is() )
5298 Reference< css::awt::XWindow > xWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
5299 if ( xWindow.is() )
5301 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
5302 return pWindow && pWindow->IsVisible();
5307 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
5309 ReadGuard aReadGuard( m_aLock );
5310 css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame );
5311 aReadGuard.unlock();
5313 return IsDockingWindowVisible( xFrame, aElementName );
5317 return sal_False;
5320 sal_Bool SAL_CALL LayoutManager::isElementFloating( const ::rtl::OUString& aName )
5321 throw (RuntimeException)
5323 UIElementVector::const_iterator pIter;
5325 ReadGuard aReadLock( m_aLock );
5326 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
5328 if ( pIter->m_aName == aName && pIter->m_xUIElement.is() )
5330 Reference< css::awt::XDockableWindow > xDockWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
5331 return xDockWindow.is() && xDockWindow->isFloating();
5335 return sal_False;
5338 sal_Bool SAL_CALL LayoutManager::isElementDocked( const ::rtl::OUString& aName )
5339 throw (RuntimeException)
5341 UIElementVector::const_iterator pIter;
5343 ReadGuard aReadLock( m_aLock );
5344 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
5346 if ( pIter->m_aName == aName && pIter->m_xUIElement.is() )
5348 Reference< css::awt::XDockableWindow > xDockWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
5349 return xDockWindow.is() && !xDockWindow->isFloating();
5353 return sal_False;
5356 ::sal_Bool SAL_CALL LayoutManager::isElementLocked( const ::rtl::OUString& ResourceURL )
5357 throw (::com::sun::star::uno::RuntimeException)
5359 UIElementVector::const_iterator pIter;
5361 ReadGuard aReadLock( m_aLock );
5362 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
5364 if (( pIter->m_aName == ResourceURL ) && ( pIter->m_xUIElement.is() ))
5366 Reference< css::awt::XDockableWindow > xDockWindow( pIter->m_xUIElement->getRealInterface(), UNO_QUERY );
5367 return xDockWindow.is() && !xDockWindow->isLocked();
5371 return sal_False;
5374 css::awt::Size SAL_CALL LayoutManager::getElementSize( const ::rtl::OUString& aName )
5375 throw (RuntimeException)
5377 ReadGuard aReadLock( m_aLock );
5378 UIElement aElementData;
5379 if ( implts_findElement( aName,aElementData ) && aElementData.m_xUIElement.is() )
5381 Reference< css::awt::XWindow > xWindow( aElementData.m_xUIElement->getRealInterface(), UNO_QUERY );
5382 if ( xWindow.is() )
5384 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
5385 if ( pWindow )
5387 ::Size aSize = pWindow->GetSizePixel();
5388 css::awt::Size aElementSize;
5389 aElementSize.Width = aSize.Width();
5390 aElementSize.Height = aSize.Height();
5391 return aElementSize;
5392 } // if ( pWindow )
5395 return css::awt::Size();
5398 css::awt::Point SAL_CALL LayoutManager::getElementPos( const ::rtl::OUString& aName )
5399 throw (RuntimeException)
5401 ReadGuard aReadLock( m_aLock );
5402 UIElement aElementData;
5403 if ( implts_findElement( aName,aElementData ) && aElementData.m_xUIElement.is() )
5405 Reference< css::awt::XWindow > xWindow( aElementData.m_xUIElement->getRealInterface(), UNO_QUERY );
5406 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
5407 if ( xDockWindow.is() )
5409 css::awt::Point aPos;
5410 if ( aElementData.m_bFloating )
5412 css::awt::Rectangle aRect = xWindow->getPosSize();
5413 aPos.X = aRect.X;
5414 aPos.Y = aRect.Y;
5416 else
5418 ::Point aVirtualPos = aElementData.m_aDockedData.m_aPos;
5419 aPos.X = aVirtualPos.X();
5420 aPos.Y = aVirtualPos.Y();
5423 return aPos;
5427 return css::awt::Point();
5430 void SAL_CALL LayoutManager::lock()
5431 throw (RuntimeException)
5433 implts_lock();
5435 ReadGuard aReadLock( m_aLock );
5436 sal_Int32 nLockCount( m_nLockCount );
5437 aReadLock.unlock();
5439 RTL_LOGFILE_TRACE1( "framework (cd100003) ::LayoutManager::lock lockCount=%d", nLockCount );
5440 #ifdef DBG_UTIL
5441 ByteString aStr("LayoutManager::lock ");
5442 aStr += ByteString::CreateFromInt32((long)this);
5443 aStr += " - ";
5444 aStr += ByteString::CreateFromInt32(nLockCount);
5445 DBG_TRACE( aStr.GetBuffer() );
5446 #endif
5448 Any a( nLockCount );
5449 implts_notifyListeners( css::frame::LayoutManagerEvents::LOCK, a );
5452 void SAL_CALL LayoutManager::unlock()
5453 throw (RuntimeException)
5455 sal_Bool bDoLayout( implts_unlock() );
5457 ReadGuard aReadLock( m_aLock );
5458 sal_Int32 nLockCount( m_nLockCount );
5459 aReadLock.unlock();
5461 RTL_LOGFILE_TRACE1( "framework (cd100003) ::LayoutManager::unlock lockCount=%d", nLockCount );
5462 #ifdef DBG_UTIL
5463 ByteString aStr("LayoutManager::unlock ");
5464 aStr += ByteString::CreateFromInt32((long)this);
5465 aStr += " - ";
5466 aStr += ByteString::CreateFromInt32(nLockCount);
5467 DBG_TRACE( aStr.GetBuffer() );
5468 #endif
5469 // conform to documentation: unlock with lock count == 0 means force a layout
5471 WriteGuard aWriteLock( m_aLock );
5472 if ( bDoLayout )
5473 m_aAsyncLayoutTimer.Stop();
5474 aWriteLock.unlock();
5476 Any a( nLockCount );
5477 implts_notifyListeners( css::frame::LayoutManagerEvents::UNLOCK, a );
5479 if ( bDoLayout )
5480 doLayout();
5483 void SAL_CALL LayoutManager::doLayout()
5484 throw (RuntimeException)
5486 sal_Bool bLayouted = implts_doLayout( sal_False );
5488 if ( bLayouted )
5489 implts_notifyListeners( css::frame::LayoutManagerEvents::LAYOUT, Any() );
5492 sal_Bool LayoutManager::implts_doLayout( sal_Bool bForceRequestBorderSpace )
5494 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::implts_doLayout" );
5496 sal_Bool bNoLock( sal_False );
5497 css::awt::Rectangle aCurrBorderSpace;
5498 Reference< css::awt::XWindow > xContainerWindow;
5499 Reference< XDockingAreaAcceptor > xDockingAreaAcceptor;
5501 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5502 ReadGuard aReadLock( m_aLock );
5504 sal_Bool bMustDoLayout( m_bMustDoLayout );
5505 if ( !m_bParentWindowVisible )
5506 return sal_False;
5508 bNoLock = ( m_nLockCount == 0 );
5509 xContainerWindow = m_xContainerWindow;
5510 xDockingAreaAcceptor = m_xDockingAreaAcceptor;
5511 aCurrBorderSpace = m_aDockingArea;
5512 aReadLock.unlock();
5513 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5515 sal_Bool bLayouted( sal_False );
5517 if ( bNoLock &&
5518 xDockingAreaAcceptor.is() &&
5519 xContainerWindow.is() )
5521 bLayouted = sal_True;
5523 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5524 WriteGuard aWriteGuard( m_aLock );
5525 m_bDoLayout = sal_True;
5526 aWriteGuard.unlock();
5527 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5529 css::awt::Rectangle aBorderSpace = implts_calcDockingAreaSizes();
5530 sal_Bool bGotRequestedBorderSpace( sal_True );
5531 sal_Bool bEqual = implts_compareRectangles( aBorderSpace, aCurrBorderSpace );
5533 if ( !bEqual || bForceRequestBorderSpace || bMustDoLayout )
5535 bGotRequestedBorderSpace = xDockingAreaAcceptor->requestDockingAreaSpace( aBorderSpace );
5536 if ( bGotRequestedBorderSpace )
5538 xDockingAreaAcceptor->setDockingAreaSpace( aBorderSpace );
5540 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5541 aWriteGuard.lock();
5542 m_aDockingArea = aBorderSpace;
5543 m_bMustDoLayout = sal_False;
5544 aWriteGuard.unlock();
5545 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5549 if ( bGotRequestedBorderSpace )
5551 ::Size aContainerSize;
5552 ::Size aStatusBarSize;
5554 aStatusBarSize = implts_getStatusBarSize();
5555 aBorderSpace.Height -= aStatusBarSize.Height();
5556 implts_setDockingAreaWindowSizes( aBorderSpace );
5558 // Subtract status bar size from our container output size. Docking area windows
5559 // don't contain the status bar!
5560 aContainerSize = implts_getContainerWindowOutputSize();
5561 aContainerSize.Height() -= aStatusBarSize.Height();
5563 // Retrieve row/column dependent data from all docked user-interface elements
5564 for ( sal_Int32 i = 0; i < DOCKINGAREAS_COUNT; i++ )
5566 std::vector< SingleRowColumnWindowData > aRowColumnsWindowData;
5568 implts_getDockingAreaElementInfos( (DockingArea)i, aRowColumnsWindowData );
5570 sal_Int32 nOffset( 0 );
5571 const sal_uInt32 nCount = aRowColumnsWindowData.size();
5572 for ( sal_uInt32 j = 0; j < nCount; ++j )
5574 implts_calcWindowPosSizeOnSingleRowColumn( i, nOffset, aRowColumnsWindowData[j], aContainerSize );
5575 nOffset += aRowColumnsWindowData[j].nStaticSize;
5579 // Position the status bar
5580 if ( aStatusBarSize.Height() > 0 )
5582 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerSize.Height() ), long( 0 ))),
5583 ::Size( aContainerSize.Width(),aStatusBarSize.Height() ));
5586 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5587 aWriteGuard.lock();
5588 m_bDoLayout = sal_False;
5589 aWriteGuard.unlock();
5590 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5594 return bLayouted;
5597 sal_Bool LayoutManager::implts_compareRectangles( const css::awt::Rectangle& rRect1,
5598 const css::awt::Rectangle& rRect2 )
5600 return (( rRect1.X == rRect2.X ) &&
5601 ( rRect1.Y == rRect2.Y ) &&
5602 ( rRect1.Width == rRect2.Width ) &&
5603 ( rRect1.Height == rRect2.Height ));
5606 void SAL_CALL LayoutManager::setVisible( sal_Bool bVisible )
5607 throw (::com::sun::star::uno::RuntimeException)
5609 sal_Bool bWasVisible( sal_True );
5611 WriteGuard aWriteLock( m_aLock );
5612 bWasVisible = m_bVisible;
5613 m_bVisible = bVisible;
5614 aWriteLock.unlock();
5616 if ( bWasVisible != bVisible )
5617 implts_setVisibleState( bVisible );
5620 sal_Bool SAL_CALL LayoutManager::isVisible()
5621 throw (::com::sun::star::uno::RuntimeException)
5623 ReadGuard aReadLock( m_aLock );
5624 return m_bVisible;
5627 void LayoutManager::implts_calcWindowPosSizeOnSingleRowColumn( sal_Int32 nDockingArea,
5628 sal_Int32 nOffset,
5629 SingleRowColumnWindowData& rRowColumnWindowData,
5630 const ::Size& rContainerSize )
5632 sal_Int32 nDiff( 0 );
5633 sal_Int32 nRCSpace( rRowColumnWindowData.nSpace );
5634 sal_Int32 nTopDockingAreaSize;
5635 sal_Int32 nBottomDockingAreaSize;
5636 sal_Int32 nContainerClientSize;
5638 if ( rRowColumnWindowData.aRowColumnWindows.empty() )
5639 return;
5641 if (( nDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
5642 ( nDockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
5644 nContainerClientSize = rContainerSize.Width();
5645 nDiff = nContainerClientSize - rRowColumnWindowData.nVarSize;
5647 else
5649 nTopDockingAreaSize = implts_getTopBottomDockingAreaSizes().Width();
5650 nBottomDockingAreaSize = implts_getTopBottomDockingAreaSizes().Height();
5651 nContainerClientSize = ( rContainerSize.Height() - nTopDockingAreaSize - nBottomDockingAreaSize );
5652 nDiff = nContainerClientSize - rRowColumnWindowData.nVarSize;
5655 const sal_uInt32 nCount = rRowColumnWindowData.aRowColumnWindowSizes.size();
5656 if (( nDiff < 0 ) && ( nRCSpace > 0 ))
5658 // First we try to reduce the size of blank space before/behind docked windows
5659 sal_Int32 i = nCount - 1;
5660 while ( i >= 0 )
5662 sal_Int32 nSpace = rRowColumnWindowData.aRowColumnSpace[i];
5663 if ( nSpace >= -nDiff )
5666 if (( nDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
5667 ( nDockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
5669 // Try to move this and all user elements behind with the calculated difference
5670 for ( sal_uInt32 j = i; j < nCount ; j++ )
5671 rRowColumnWindowData.aRowColumnWindowSizes[j].X += nDiff;
5673 else
5675 // Try to move this and all user elements behind with the calculated difference
5676 for ( sal_uInt32 j = i; j < nCount ; j++ )
5677 rRowColumnWindowData.aRowColumnWindowSizes[j].Y += nDiff;
5679 nDiff = 0;
5681 break;
5683 else if ( nSpace > 0 )
5685 if (( nDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
5686 ( nDockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
5688 // Try to move this and all user elements behind with the calculated difference
5689 for ( sal_uInt32 j = i; j < nCount; j++ )
5690 rRowColumnWindowData.aRowColumnWindowSizes[j].X -= nSpace;
5692 else
5694 // Try to move this and all user elements behind with the calculated difference
5695 for ( sal_uInt32 j = i; j < nCount; j++ )
5696 rRowColumnWindowData.aRowColumnWindowSizes[j].Y -= nSpace;
5698 nDiff += nSpace;
5700 --i;
5704 // Check if we have to reduce further
5705 if ( nDiff < 0 )
5707 // Now we have to reduce the size of certain docked windows
5708 sal_Int32 i = sal_Int32( nCount - 1 );
5709 while ( i >= 0 )
5711 css::awt::Rectangle& rWinRect = rRowColumnWindowData.aRowColumnWindowSizes[i];
5712 ::Size aMinSize;
5714 vos::OGuard aGuard( Application::GetSolarMutex() );
5716 Reference< css::awt::XWindow > xWindow = rRowColumnWindowData.aRowColumnWindows[i];
5717 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
5718 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
5719 aMinSize = ((ToolBox *)pWindow)->CalcMinimumWindowSizePixel();
5722 if (( aMinSize.Width() > 0 ) && ( aMinSize.Height() > 0 ))
5724 if (( nDockingArea == DockingArea_DOCKINGAREA_TOP ) ||
5725 ( nDockingArea == DockingArea_DOCKINGAREA_BOTTOM ))
5727 sal_Int32 nMaxReducation = ( rWinRect.Width - aMinSize.Width() );
5728 if ( nMaxReducation >= -nDiff )
5730 rWinRect.Width = rWinRect.Width + nDiff;
5731 nDiff = 0;
5733 else
5735 rWinRect.Width = aMinSize.Width();
5736 nDiff += nMaxReducation;
5739 // Try to move this and all user elements behind with the calculated difference
5740 for ( sal_uInt32 j = i; j < nCount; j++ )
5741 rRowColumnWindowData.aRowColumnWindowSizes[j].X += nDiff;
5743 else
5745 sal_Int32 nMaxReducation = ( rWinRect.Height - aMinSize.Height() );
5746 if ( nMaxReducation >= -nDiff )
5748 rWinRect.Height = rWinRect.Height + nDiff;
5749 nDiff = 0;
5751 else
5753 rWinRect.Height = aMinSize.Height();
5754 nDiff += nMaxReducation;
5757 // Try to move this and all user elements behind with the calculated difference
5758 for ( sal_uInt32 j = i; j < nCount; j++ )
5759 rRowColumnWindowData.aRowColumnWindowSizes[j].Y += nDiff;
5763 if ( nDiff >= 0 )
5764 break;
5766 --i;
5770 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5771 ReadGuard aReadLock( m_aLock );
5772 Window* pDockAreaWindow = VCLUnoHelper::GetWindow( m_xDockAreaWindows[nDockingArea] );
5773 aReadLock.unlock();
5775 sal_Int32 nCurrPos( 0 );
5776 sal_Int32 nStartOffset( 0 );
5778 if ( nDockingArea == DockingArea_DOCKINGAREA_RIGHT )
5779 nStartOffset = pDockAreaWindow->GetSizePixel().Width() - rRowColumnWindowData.nStaticSize;
5780 else if ( nDockingArea == DockingArea_DOCKINGAREA_BOTTOM )
5781 nStartOffset = pDockAreaWindow->GetSizePixel().Height() - rRowColumnWindowData.nStaticSize;
5783 vos::OGuard aGuard( Application::GetSolarMutex() );
5784 for ( sal_uInt32 i = 0; i < nCount; i++ )
5786 Reference< css::awt::XWindow > xWindow = rRowColumnWindowData.aRowColumnWindows[i];
5787 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
5788 Window* pOldParentWindow = pWindow->GetParent();
5790 if ( pDockAreaWindow != pOldParentWindow )
5791 pWindow->SetParent( pDockAreaWindow );
5793 css::awt::Rectangle aWinRect = rRowColumnWindowData.aRowColumnWindowSizes[i];
5794 if ( nDockingArea == DockingArea_DOCKINGAREA_TOP )
5796 if ( aWinRect.X < nCurrPos )
5797 aWinRect.X = nCurrPos;
5798 pWindow->SetPosSizePixel( ::Point( aWinRect.X, nOffset ),
5799 ::Size( aWinRect.Width, rRowColumnWindowData.nStaticSize ));
5800 nCurrPos += ( aWinRect.X - nCurrPos ) + aWinRect.Width;
5802 else if ( nDockingArea == DockingArea_DOCKINGAREA_BOTTOM )
5804 if ( aWinRect.X < nCurrPos )
5805 aWinRect.X = nCurrPos;
5806 pWindow->SetPosSizePixel( ::Point( aWinRect.X, nStartOffset - nOffset ),
5807 ::Size( aWinRect.Width, rRowColumnWindowData.nStaticSize ));
5808 nCurrPos += ( aWinRect.X - nCurrPos ) + aWinRect.Width;
5810 else if ( nDockingArea == DockingArea_DOCKINGAREA_LEFT )
5812 if ( aWinRect.Y < nCurrPos )
5813 aWinRect.Y = nCurrPos;
5814 pWindow->SetPosSizePixel( ::Point( nOffset, aWinRect.Y ),
5815 ::Size( rRowColumnWindowData.nStaticSize, aWinRect.Height ));
5816 nCurrPos += ( aWinRect.Y - nCurrPos ) + aWinRect.Height;
5818 else if ( nDockingArea == DockingArea_DOCKINGAREA_RIGHT )
5820 if ( aWinRect.Y < nCurrPos )
5821 aWinRect.Y = nCurrPos;
5822 pWindow->SetPosSizePixel( ::Point( nStartOffset - nOffset, aWinRect.Y ),
5823 ::Size( rRowColumnWindowData.nStaticSize, aWinRect.Height ));
5824 nCurrPos += ( aWinRect.Y - nCurrPos ) + aWinRect.Height;
5829 ::Size LayoutManager::implts_getStatusBarSize()
5831 ReadGuard aReadLock( m_aLock );
5832 sal_Bool bStatusBarVisible( isElementVisible( m_aStatusBarAlias ));
5833 sal_Bool bProgressBarVisible( isElementVisible( m_aProgressBarAlias ));
5834 sal_Bool bVisible = m_bVisible;
5835 Reference< XUIElement > xStatusBar = m_aStatusBarElement.m_xUIElement;
5836 Reference< XUIElement > xProgressBar = m_aProgressBarElement.m_xUIElement;
5838 Reference< css::awt::XWindow > xWindow;
5839 if ( bStatusBarVisible && bVisible && xStatusBar.is() )
5840 xWindow = Reference< css::awt::XWindow >( xStatusBar->getRealInterface(), UNO_QUERY );
5841 else if ( xProgressBar.is() && !xStatusBar.is() && bProgressBarVisible )
5843 ProgressBarWrapper* pWrapper = (ProgressBarWrapper*)xProgressBar.get();
5844 if ( pWrapper )
5845 xWindow = pWrapper->getStatusBar();
5847 aReadLock.unlock();
5849 if ( xWindow.is() )
5851 css::awt::Rectangle aPosSize = xWindow->getPosSize();
5852 return ::Size( aPosSize.Width, aPosSize.Height );
5854 else
5855 return ::Size();
5858 css::awt::Rectangle LayoutManager::implts_calcDockingAreaSizes()
5860 Reference< css::awt::XWindow > xContainerWindow;
5861 Reference< XDockingAreaAcceptor > xDockingAreaAcceptor;
5863 ReadGuard aReadLock( m_aLock );
5864 xContainerWindow = m_xContainerWindow;
5865 xDockingAreaAcceptor = m_xDockingAreaAcceptor;
5866 UIElementVector aWindowVector( m_aUIElements );
5867 aReadLock.unlock();
5869 css::awt::Rectangle aBorderSpace;
5870 if ( xDockingAreaAcceptor.is() && xContainerWindow.is() )
5872 sal_Int32 nCurrRowColumn( 0 );
5873 sal_Int32 nCurrPos( 0 );
5874 sal_Int32 nCurrDockingArea( DockingArea_DOCKINGAREA_TOP );
5875 std::vector< sal_Int32 > aRowColumnSizes[DOCKINGAREAS_COUNT];
5876 UIElementVector::const_iterator pConstIter;
5878 aRowColumnSizes[nCurrDockingArea].clear();
5879 aRowColumnSizes[nCurrDockingArea].push_back( 0 );
5881 for ( pConstIter = aWindowVector.begin(); pConstIter != aWindowVector.end(); pConstIter++ )
5883 Reference< XUIElement > xUIElement( pConstIter->m_xUIElement, UNO_QUERY );
5884 if ( xUIElement.is() )
5886 Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
5887 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
5888 if ( xWindow.is() && xDockWindow.is() )
5890 vos::OGuard aGuard( Application::GetSolarMutex() );
5892 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
5893 if ( pWindow && pWindow->IsVisible() && !xDockWindow->isFloating() )
5895 css::awt::Rectangle aPosSize = xWindow->getPosSize();
5896 if ( pConstIter->m_aDockedData.m_nDockedArea != nCurrDockingArea )
5898 nCurrDockingArea = pConstIter->m_aDockedData.m_nDockedArea;
5899 nCurrRowColumn = 0;
5900 nCurrPos = 0;
5901 aRowColumnSizes[nCurrDockingArea].clear();
5902 aRowColumnSizes[nCurrDockingArea].push_back( 0 );
5905 if ( pConstIter->m_aDockedData.m_nDockedArea == nCurrDockingArea )
5907 if (( pConstIter->m_aDockedData.m_nDockedArea == DockingArea_DOCKINGAREA_TOP ) ||
5908 ( pConstIter->m_aDockedData.m_nDockedArea == DockingArea_DOCKINGAREA_BOTTOM ))
5910 if ( pConstIter->m_aDockedData.m_aPos.Y() > nCurrPos )
5912 ++nCurrRowColumn;
5913 nCurrPos = pConstIter->m_aDockedData.m_aPos.Y();
5914 aRowColumnSizes[nCurrDockingArea].push_back( 0 );
5917 if ( aPosSize.Height > aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] )
5918 aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] = aPosSize.Height;
5920 else
5922 if ( pConstIter->m_aDockedData.m_aPos.X() > nCurrPos )
5924 ++nCurrRowColumn;
5925 nCurrPos = pConstIter->m_aDockedData.m_aPos.X();
5926 aRowColumnSizes[nCurrDockingArea].push_back( 0 );
5929 if ( aPosSize.Width > aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] )
5930 aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] = aPosSize.Width;
5938 // Sum up max heights from every row/column
5939 if ( !aWindowVector.empty() )
5941 for ( sal_Int32 i = 0; i <= DockingArea_DOCKINGAREA_RIGHT; i++ )
5943 sal_Int32 nSize( 0 );
5944 const sal_uInt32 nCount = aRowColumnSizes[i].size();
5945 for ( sal_uInt32 j = 0; j < nCount; j++ )
5946 nSize += aRowColumnSizes[i][j];
5948 if ( i == DockingArea_DOCKINGAREA_TOP )
5949 aBorderSpace.Y = nSize;
5950 else if ( i == DockingArea_DOCKINGAREA_BOTTOM )
5951 aBorderSpace.Height = nSize;
5952 else if ( i == DockingArea_DOCKINGAREA_LEFT )
5953 aBorderSpace.X = nSize;
5954 else
5955 aBorderSpace.Width = nSize;
5959 // We have to add the height of a possible status bar
5960 aBorderSpace.Height += implts_getStatusBarSize().Height();
5963 return aBorderSpace;
5966 void LayoutManager::implts_setDockingAreaWindowSizes( const css::awt::Rectangle& rBorderSpace )
5968 Reference< css::awt::XWindow > xContainerWindow;
5970 ReadGuard aReadLock( m_aLock );
5971 xContainerWindow = m_xContainerWindow;
5972 aReadLock.unlock();
5974 css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY );
5975 // Convert relativ size to output size.
5976 css::awt::Rectangle aRectangle = xContainerWindow->getPosSize();
5977 css::awt::DeviceInfo aInfo = xDevice->getInfo();
5978 css::awt::Size aContainerClientSize = css::awt::Size( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset ,
5979 aRectangle.Height - aInfo.TopInset - aInfo.BottomInset );
5980 ::Size aStatusBarSize = implts_getStatusBarSize();
5982 sal_Int32 nLeftRightDockingAreaHeight( aContainerClientSize.Height );
5983 if ( rBorderSpace.Y >= 0 )
5985 // Top docking area window
5986 aReadLock.lock();
5987 Reference< css::awt::XWindow > xDockAreaWindow( m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP] );
5988 aReadLock.unlock();
5990 xDockAreaWindow->setPosSize( 0, 0, aContainerClientSize.Width, rBorderSpace.Y, css::awt::PosSize::POSSIZE );
5991 xDockAreaWindow->setVisible( sal_True );
5992 nLeftRightDockingAreaHeight -= rBorderSpace.Y;
5995 if ( rBorderSpace.Height >= 0 )
5997 // Bottom docking area window
5998 sal_Int32 nBottomPos = std::max( sal_Int32( aContainerClientSize.Height - rBorderSpace.Height - aStatusBarSize.Height() ), sal_Int32( 0 ));
5999 sal_Int32 nHeight = ( nBottomPos == 0 ) ? 0 : rBorderSpace.Height;
6001 aReadLock.lock();
6002 Reference< css::awt::XWindow > xDockAreaWindow( m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM] );
6003 aReadLock.unlock();
6005 xDockAreaWindow->setPosSize( 0, nBottomPos, aContainerClientSize.Width, nHeight, css::awt::PosSize::POSSIZE );
6006 xDockAreaWindow->setVisible( sal_True );
6007 nLeftRightDockingAreaHeight -= nHeight;
6010 nLeftRightDockingAreaHeight -= aStatusBarSize.Height();
6011 if ( rBorderSpace.X >= 0 || nLeftRightDockingAreaHeight > 0 )
6013 // Left docking area window
6014 aReadLock.lock();
6015 Reference< css::awt::XWindow > xDockAreaWindow( m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT] );
6016 aReadLock.unlock();
6018 // We also have to change our right docking area window if the top or bottom area has changed. They have a higher priority!
6019 sal_Int32 nHeight = std::max( sal_Int32( 0 ), sal_Int32( nLeftRightDockingAreaHeight ));
6021 xDockAreaWindow->setPosSize( 0, rBorderSpace.Y, rBorderSpace.X, nHeight, css::awt::PosSize::POSSIZE );
6022 xDockAreaWindow->setVisible( sal_True );
6024 if ( rBorderSpace.Width >= 0 || nLeftRightDockingAreaHeight > 0 )
6026 // Right docking area window
6027 aReadLock.lock();
6028 Reference< css::awt::XWindow > xDockAreaWindow( m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT] );
6029 aReadLock.unlock();
6031 // We also have to change our right docking area window if the top or bottom area has changed. They have a higher priority!
6032 sal_Int32 nLeftPos = std::max( sal_Int32( 0 ), sal_Int32( aContainerClientSize.Width - rBorderSpace.Width ));
6033 sal_Int32 nHeight = std::max( sal_Int32( 0 ), sal_Int32( nLeftRightDockingAreaHeight ));
6034 sal_Int32 nWidth = ( nLeftPos == 0 ) ? 0 : rBorderSpace.Width;
6036 xDockAreaWindow->setPosSize( nLeftPos, rBorderSpace.Y, nWidth, nHeight, css::awt::PosSize::POSSIZE );
6037 xDockAreaWindow->setVisible( sal_True );
6040 // Position the status bar
6041 if ( aStatusBarSize.Height() > 0 )
6043 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerClientSize.Height - aStatusBarSize.Height() ), long( 0 ))),
6044 ::Size( aContainerClientSize.Width, aStatusBarSize.Height() ));
6048 //---------------------------------------------------------------------------------------------------------
6049 // XMenuCloser
6050 //---------------------------------------------------------------------------------------------------------
6051 void LayoutManager::implts_updateMenuBarClose()
6053 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6054 WriteGuard aWriteLock( m_aLock );
6055 sal_Bool bShowCloser = m_bMenuBarCloser;
6056 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
6057 aWriteLock.unlock();
6059 if ( xContainerWindow.is() )
6061 vos::OGuard aGuard( Application::GetSolarMutex() );
6063 Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
6064 while ( pWindow && !pWindow->IsSystemWindow() )
6065 pWindow = pWindow->GetParent();
6067 if ( pWindow )
6069 SystemWindow* pSysWindow = (SystemWindow *)pWindow;
6070 MenuBar* pMenuBar = pSysWindow->GetMenuBar();
6071 if ( pMenuBar )
6073 // TODO remove link on FALSE ?!
6074 if ( bShowCloser )
6076 pMenuBar->ShowCloser( TRUE );
6077 pMenuBar->SetCloserHdl( LINK( this, LayoutManager, MenuBarClose ));
6079 else
6081 pMenuBar->ShowCloser( FALSE );
6082 pMenuBar->SetCloserHdl( LINK( this, LayoutManager, MenuBarClose ));
6089 sal_Bool LayoutManager::implts_resetMenuBar()
6091 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6092 WriteGuard aWriteLock( m_aLock );
6093 sal_Bool bMenuVisible( m_bMenuVisible );
6094 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
6096 MenuBar* pSetMenuBar = 0;
6097 if ( m_xInplaceMenuBar.is() )
6098 pSetMenuBar = (MenuBar *)m_pInplaceMenuBar->GetMenuBar();
6099 else
6101 MenuBarWrapper* pMenuBarWrapper = SAL_STATIC_CAST( MenuBarWrapper*, m_xMenuBar.get() );
6102 if ( pMenuBarWrapper )
6103 pSetMenuBar = (MenuBar *)pMenuBarWrapper->GetMenuBarManager()->GetMenuBar();
6105 aWriteLock.unlock();
6106 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6108 vos::OGuard aGuard( Application::GetSolarMutex() );
6109 Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
6110 while ( pWindow && !pWindow->IsSystemWindow() )
6111 pWindow = pWindow->GetParent();
6113 if ( pWindow && bMenuVisible && pSetMenuBar )
6115 ((SystemWindow *)pWindow)->SetMenuBar( pSetMenuBar );
6116 pSetMenuBar->SetDisplayable( sal_True );
6117 return sal_True;
6120 return sal_False;
6123 void LayoutManager::implts_setMenuBarCloser(sal_Bool bCloserState)
6125 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6126 WriteGuard aWriteLock( m_aLock );
6127 m_bMenuBarCloser = bCloserState;
6128 aWriteLock.unlock();
6130 implts_updateMenuBarClose();
6133 sal_Int16 LayoutManager::implts_getCurrentSymbolsSize()
6135 sal_Int16 eOptSymbolsSize( 0 );
6138 ReadGuard aReadLock( m_aLock );
6139 vos::OGuard aGuard( Application::GetSolarMutex() );
6140 if ( m_pMiscOptions )
6141 eOptSymbolsSize = m_pMiscOptions->GetCurrentSymbolsSize();
6144 return eOptSymbolsSize;
6147 sal_Int16 LayoutManager::implts_getCurrentSymbolsStyle()
6149 sal_Int16 eOptSymbolsStyle( 0 );
6152 ReadGuard aReadLock( m_aLock );
6153 vos::OGuard aGuard( Application::GetSolarMutex() );
6154 if ( m_pMiscOptions )
6155 eOptSymbolsStyle = m_pMiscOptions->GetCurrentSymbolsStyle();
6158 return eOptSymbolsStyle;
6161 IMPL_LINK( LayoutManager, MenuBarClose, MenuBar *, EMPTYARG )
6163 ReadGuard aReadLock( m_aLock );
6164 css::uno::Reference< css::frame::XDispatchProvider > xProvider(m_xFrame, css::uno::UNO_QUERY);
6165 css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
6166 aReadLock.unlock();
6168 if (! xProvider.is())
6169 return 0;
6171 css::uno::Reference< css::frame::XDispatchHelper > xDispatcher(
6172 xSMGR->createInstance(SERVICENAME_DISPATCHHELPER), css::uno::UNO_QUERY_THROW);
6174 xDispatcher->executeDispatch(
6175 xProvider,
6176 ::rtl::OUString::createFromAscii(".uno:CloseWin"),
6177 ::rtl::OUString::createFromAscii("_self"),
6179 css::uno::Sequence< css::beans::PropertyValue >());
6181 return 0;
6184 IMPL_LINK( LayoutManager, OptionsChanged, void*, EMPTYARG )
6186 sal_Int16 eSymbolsSize( implts_getCurrentSymbolsSize() );
6187 sal_Int16 eSymbolsStyle( implts_getCurrentSymbolsStyle() );
6189 ReadGuard aReadLock( m_aLock );
6190 sal_Int16 eOldSymbolsSize = m_eSymbolsSize;
6191 sal_Int16 eOldSymbolsStyle = m_eSymbolsStyle;
6192 aReadLock.unlock();
6194 if ( eSymbolsSize != eOldSymbolsSize || eSymbolsStyle != eOldSymbolsStyle )
6196 WriteGuard aWriteLock( m_aLock );
6197 m_eSymbolsSize = eSymbolsSize;
6198 m_eSymbolsStyle = eSymbolsStyle;
6199 aWriteLock.unlock();
6201 std::vector< Reference< XUpdatable > > aToolBarVector;
6203 aReadLock.lock();
6205 UIElementVector::iterator pIter;
6206 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
6208 if ( pIter->m_xUIElement.is() )
6209 aToolBarVector.push_back( Reference< XUpdatable >( pIter->m_xUIElement, UNO_QUERY ));
6212 aReadLock.unlock();
6214 lock();
6216 std::vector< Reference< XUpdatable > >::iterator pIter;
6217 for ( pIter = aToolBarVector.begin(); pIter != aToolBarVector.end(); pIter++ )
6219 if ( (*pIter).is() )
6220 (*pIter)->update();
6223 unlock();
6224 doLayout();
6227 return 1;
6230 IMPL_LINK( LayoutManager, SettingsChanged, void*, EMPTYARG )
6232 return 1;
6235 //---------------------------------------------------------------------------------------------------------
6236 // XDockableWindowListener
6237 //---------------------------------------------------------------------------------------------------------
6238 void SAL_CALL LayoutManager::startDocking( const ::com::sun::star::awt::DockingEvent& e ) throw (::com::sun::star::uno::RuntimeException)
6240 sal_Bool bWinFound( sal_False );
6241 UIElement aUIElement;
6243 ReadGuard aReadGuard( m_aLock );
6244 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
6245 Reference< css::awt::XWindow2 > xWindow( e.Source, UNO_QUERY );
6246 aReadGuard.unlock();
6248 Window* pContainerWindow( 0 );
6249 Window* pWindow( 0 );
6250 ::Point aMousePos;
6252 vos::OGuard aGuard( Application::GetSolarMutex() );
6253 pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
6254 aMousePos = pContainerWindow->ScreenToOutputPixel( ::Point( e.MousePos.X, e.MousePos.Y ));
6257 bWinFound = implts_findElement( e.Source, aUIElement );
6259 if ( bWinFound && xWindow.is() )
6261 css::awt::Rectangle aRect;
6262 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
6263 if ( xDockWindow->isFloating() )
6265 css::awt::Rectangle aPos = xWindow->getPosSize();
6266 css::awt::Size aSize = xWindow->getOutputSize();
6268 aUIElement.m_aFloatingData.m_aPos = ::Point( aPos.X, aPos.Y );
6269 aUIElement.m_aFloatingData.m_aSize = ::Size( aSize.Width, aSize.Height );
6271 vos::OGuard aGuard( Application::GetSolarMutex() );
6272 pWindow = VCLUnoHelper::GetWindow( xWindow );
6273 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
6275 ToolBox* pToolBox = (ToolBox *)pWindow;
6276 aUIElement.m_aFloatingData.m_nLines = pToolBox->GetFloatingLines();
6277 aUIElement.m_aFloatingData.m_bIsHorizontal = (( pToolBox->GetAlign() == WINDOWALIGN_TOP ) ||
6278 ( pToolBox->GetAlign() == WINDOWALIGN_BOTTOM ));
6283 WriteGuard aWriteLock( m_aLock );
6284 m_bDockingInProgress = bWinFound;
6285 m_aDockUIElement = aUIElement;
6286 m_aDockUIElement.m_bUserActive = sal_True;
6287 m_aStartDockMousePos = aMousePos;
6288 aWriteLock.unlock();
6291 ::Rectangle LayoutManager::implts_calcHotZoneRect( const ::Rectangle& rRect, sal_Int32 nHotZoneOffset )
6293 ::Rectangle aRect( rRect );
6295 aRect.Left() -= nHotZoneOffset;
6296 aRect.Top() -= nHotZoneOffset;
6297 aRect.Right() += nHotZoneOffset;
6298 aRect.Bottom() += nHotZoneOffset;
6299 return aRect;
6302 css::awt::DockingData SAL_CALL LayoutManager::docking( const ::com::sun::star::awt::DockingEvent& e )
6303 throw (::com::sun::star::uno::RuntimeException)
6305 const sal_Int32 MAGNETIC_DISTANCE_UNDOCK = 25;
6306 const sal_Int32 MAGNETIC_DISTANCE_DOCK = 20;
6308 css::awt::DockingData aDockingData;
6309 Reference< css::awt::XDockableWindow > xDockWindow( e.Source, UNO_QUERY );
6310 Reference< css::awt::XWindow > xWindow( e.Source, UNO_QUERY );
6311 Reference< css::awt::XWindow > xTopDockingWindow;
6312 Reference< css::awt::XWindow > xLeftDockingWindow;
6313 Reference< css::awt::XWindow > xRightDockingWindow;
6314 Reference< css::awt::XWindow > xBottomDockingWindow;
6315 Reference< css::awt::XWindow > xContainerWindow;
6316 UIElement aUIDockingElement;
6317 DockingOperation eDockingOperation( DOCKOP_ON_COLROW );
6318 ::Size aStatusBarSize;
6320 aDockingData.TrackingRectangle = e.TrackingRectangle;
6321 sal_Bool bDockingInProgress;
6324 ReadGuard aReadLock( m_aLock );
6325 bDockingInProgress = m_bDockingInProgress;
6326 if ( bDockingInProgress )
6328 xContainerWindow = m_xContainerWindow;
6329 xTopDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_TOP];
6330 xLeftDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_LEFT];
6331 xRightDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_RIGHT];
6332 xBottomDockingWindow = m_xDockAreaWindows[DockingArea_DOCKINGAREA_BOTTOM];
6333 aUIDockingElement = m_aDockUIElement;
6334 aStatusBarSize = implts_getStatusBarSize();
6338 if ( bDockingInProgress &&
6339 xDockWindow.is() &&
6340 xWindow.is() )
6344 vos::OGuard aGuard( Application::GetSolarMutex() );
6346 sal_Int16 eDockingArea( -1 ); // none
6347 sal_Int32 nMagneticZone( aUIDockingElement.m_bFloating ? MAGNETIC_DISTANCE_DOCK : MAGNETIC_DISTANCE_UNDOCK );
6348 css::awt::Rectangle aNewTrackingRect;
6349 ::Rectangle aTrackingRect( e.TrackingRectangle.X,
6350 e.TrackingRectangle.Y,
6351 ( e.TrackingRectangle.X + e.TrackingRectangle.Width ),
6352 ( e.TrackingRectangle.Y + e.TrackingRectangle.Height ));
6354 css::awt::Rectangle aTmpRect = xTopDockingWindow->getPosSize();
6355 ::Rectangle aTopDockRect( aTmpRect.X, aTmpRect.Y, aTmpRect.Width, aTmpRect.Height );
6356 ::Rectangle aHotZoneTopDockRect( implts_calcHotZoneRect( aTopDockRect, nMagneticZone ));
6358 aTmpRect = xBottomDockingWindow->getPosSize();
6359 ::Rectangle aBottomDockRect( aTmpRect.X, aTmpRect.Y, ( aTmpRect.X + aTmpRect.Width), ( aTmpRect.Y + aTmpRect.Height ));
6360 ::Rectangle aHotZoneBottomDockRect( implts_calcHotZoneRect( aBottomDockRect, nMagneticZone ));
6362 aTmpRect = xLeftDockingWindow->getPosSize();
6363 ::Rectangle aLeftDockRect( aTmpRect.X, aTmpRect.Y, ( aTmpRect.X + aTmpRect.Width ), ( aTmpRect.Y + aTmpRect.Height ));
6364 ::Rectangle aHotZoneLeftDockRect( implts_calcHotZoneRect( aLeftDockRect, nMagneticZone ));
6366 aTmpRect = xRightDockingWindow->getPosSize();
6367 ::Rectangle aRightDockRect( aTmpRect.X, aTmpRect.Y, ( aTmpRect.X + aTmpRect.Width ), ( aTmpRect.Y + aTmpRect.Height ));
6368 ::Rectangle aHotZoneRightDockRect( implts_calcHotZoneRect( aRightDockRect, nMagneticZone ));
6370 Window* pContainerWindow( VCLUnoHelper::GetWindow( xContainerWindow ) );
6371 Window* pDockingAreaWindow( 0 );
6372 ::Point aMousePos( pContainerWindow->ScreenToOutputPixel( ::Point( e.MousePos.X, e.MousePos.Y )));
6374 if ( aHotZoneTopDockRect.IsInside( aMousePos ))
6375 eDockingArea = DockingArea_DOCKINGAREA_TOP;
6376 else if ( aHotZoneBottomDockRect.IsInside( aMousePos ))
6377 eDockingArea = DockingArea_DOCKINGAREA_BOTTOM;
6378 else if ( aHotZoneLeftDockRect.IsInside( aMousePos ))
6379 eDockingArea = DockingArea_DOCKINGAREA_LEFT;
6380 else if ( aHotZoneRightDockRect.IsInside( aMousePos ))
6381 eDockingArea = DockingArea_DOCKINGAREA_RIGHT;
6383 // Higher priority for movements inside the real docking area
6384 if ( aTopDockRect.IsInside( aMousePos ))
6385 eDockingArea = DockingArea_DOCKINGAREA_TOP;
6386 else if ( aBottomDockRect.IsInside( aMousePos ))
6387 eDockingArea = DockingArea_DOCKINGAREA_BOTTOM;
6388 else if ( aLeftDockRect.IsInside( aMousePos ))
6389 eDockingArea = DockingArea_DOCKINGAREA_LEFT;
6390 else if ( aRightDockRect.IsInside( aMousePos ))
6391 eDockingArea = DockingArea_DOCKINGAREA_RIGHT;
6393 // Determine if we have a toolbar and set alignment according to the docking area!
6394 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
6395 ToolBox* pToolBox = 0;
6396 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
6397 pToolBox = (ToolBox *)pWindow;
6399 if ( eDockingArea != -1 )
6401 if ( eDockingArea == DockingArea_DOCKINGAREA_TOP )
6403 aUIDockingElement.m_aDockedData.m_nDockedArea = DockingArea_DOCKINGAREA_TOP;
6404 aUIDockingElement.m_bFloating = sal_False;
6405 pDockingAreaWindow = VCLUnoHelper::GetWindow( xTopDockingWindow );
6407 else if ( eDockingArea == DockingArea_DOCKINGAREA_BOTTOM )
6409 aUIDockingElement.m_aDockedData.m_nDockedArea = DockingArea_DOCKINGAREA_BOTTOM;
6410 aUIDockingElement.m_bFloating = sal_False;
6411 pDockingAreaWindow = VCLUnoHelper::GetWindow( xBottomDockingWindow );
6413 else if ( eDockingArea == DockingArea_DOCKINGAREA_LEFT )
6415 aUIDockingElement.m_aDockedData.m_nDockedArea = DockingArea_DOCKINGAREA_LEFT;
6416 aUIDockingElement.m_bFloating = sal_False;
6417 pDockingAreaWindow = VCLUnoHelper::GetWindow( xLeftDockingWindow );
6419 else if ( eDockingArea == DockingArea_DOCKINGAREA_RIGHT )
6421 aUIDockingElement.m_aDockedData.m_nDockedArea = DockingArea_DOCKINGAREA_RIGHT;
6422 aUIDockingElement.m_bFloating = sal_False;
6423 pDockingAreaWindow = VCLUnoHelper::GetWindow( xRightDockingWindow );
6426 ::Point aOutputPos = pContainerWindow->ScreenToOutputPixel( aTrackingRect.TopLeft() );
6427 aTrackingRect.SetPos( aOutputPos );
6429 ::Rectangle aNewDockingRect( aTrackingRect );
6430 implts_calcDockingPosSize( aUIDockingElement, eDockingOperation, aNewDockingRect, aMousePos );
6432 ::Point aScreenPos = pContainerWindow->OutputToScreenPixel( aNewDockingRect.TopLeft() );
6433 aNewTrackingRect = css::awt::Rectangle( aScreenPos.X(),
6434 aScreenPos.Y(),
6435 aNewDockingRect.getWidth(),
6436 aNewDockingRect.getHeight() );
6437 aDockingData.TrackingRectangle = aNewTrackingRect;
6439 else if ( pToolBox && bDockingInProgress )
6441 sal_Bool bIsHorizontal = (( pToolBox->GetAlign() == WINDOWALIGN_TOP ) ||
6442 ( pToolBox->GetAlign() == WINDOWALIGN_BOTTOM ));
6443 ::Size aFloatSize = aUIDockingElement.m_aFloatingData.m_aSize;
6444 if ( aFloatSize.Width() > 0 && aFloatSize.Height() > 0 )
6446 aUIDockingElement.m_aFloatingData.m_aPos = pContainerWindow->ScreenToOutputPixel(
6447 ::Point( e.MousePos.X, e.MousePos.Y ));
6448 aDockingData.TrackingRectangle.Height = aFloatSize.Height();
6449 aDockingData.TrackingRectangle.Width = aFloatSize.Width();
6451 else
6453 aFloatSize = pToolBox->CalcWindowSizePixel();
6454 if ( !bIsHorizontal )
6456 // Floating toolbars are always horizontal aligned! We have to swap
6457 // width/height if we have a vertical aligned toolbar.
6458 sal_Int32 nTemp = aFloatSize.Height();
6459 aFloatSize.Height() = aFloatSize.Width();
6460 aFloatSize.Width() = nTemp;
6463 aDockingData.TrackingRectangle.Height = aFloatSize.Height();
6464 aDockingData.TrackingRectangle.Width = aFloatSize.Width();
6466 // For the first time we don't have any data about the floating size of a toolbar.
6467 // We calculate it and store it for later use.
6468 aUIDockingElement.m_aFloatingData.m_aPos = pContainerWindow->ScreenToOutputPixel(
6469 ::Point( e.MousePos.X, e.MousePos.Y ));
6470 aUIDockingElement.m_aFloatingData.m_aSize = aFloatSize;
6471 aUIDockingElement.m_aFloatingData.m_nLines = pToolBox->GetFloatingLines();
6472 aUIDockingElement.m_aFloatingData.m_bIsHorizontal = (( pToolBox->GetAlign() == WINDOWALIGN_TOP ) ||
6473 ( pToolBox->GetAlign() == WINDOWALIGN_BOTTOM ));
6475 aDockingData.TrackingRectangle.X = e.MousePos.X;
6476 aDockingData.TrackingRectangle.Y = e.MousePos.Y;
6479 aDockingData.bFloating = ( eDockingArea == -1 );
6481 // Write current data to the member docking progress data
6482 WriteGuard aWriteLock( m_aLock );
6483 m_aDockUIElement.m_bFloating = aDockingData.bFloating;
6484 if ( !aDockingData.bFloating )
6486 m_aDockUIElement.m_aDockedData = aUIDockingElement.m_aDockedData;
6487 m_eDockOperation = eDockingOperation;
6489 else
6490 m_aDockUIElement.m_aFloatingData = aUIDockingElement.m_aFloatingData;
6491 aWriteLock.unlock();
6493 catch ( Exception& )
6498 return aDockingData;
6501 void SAL_CALL LayoutManager::endDocking( const ::com::sun::star::awt::EndDockingEvent& e )
6502 throw (::com::sun::star::uno::RuntimeException)
6504 sal_Bool bDockingInProgress( sal_False );
6505 sal_Bool bStartDockFloated( sal_False );
6506 sal_Bool bFloating( sal_False );
6507 UIElement aUIDockingElement;
6509 WriteGuard aWriteLock( m_aLock );
6510 bDockingInProgress = m_bDockingInProgress;
6511 aUIDockingElement = m_aDockUIElement;
6512 bFloating = aUIDockingElement.m_bFloating;
6514 UIElement& rUIElement = impl_findElement( aUIDockingElement.m_aName );
6515 if ( rUIElement.m_aName == aUIDockingElement.m_aName )
6517 if ( aUIDockingElement.m_bFloating )
6519 // Write last position into position data
6520 Reference< css::awt::XWindow > xWindow( aUIDockingElement.m_xUIElement->getRealInterface(), UNO_QUERY );
6521 rUIElement.m_aFloatingData = aUIDockingElement.m_aFloatingData;
6522 css::awt::Rectangle aTmpRect = xWindow->getPosSize();
6523 rUIElement.m_aFloatingData.m_aPos = ::Point( aTmpRect.X, aTmpRect.Y );
6524 // make changes also for our local data as we use it to make data persistent
6525 aUIDockingElement.m_aFloatingData = rUIElement.m_aFloatingData;
6527 else
6529 rUIElement.m_aDockedData = aUIDockingElement.m_aDockedData;
6530 rUIElement.m_aFloatingData.m_aSize = aUIDockingElement.m_aFloatingData.m_aSize;
6532 if ( m_eDockOperation != DOCKOP_ON_COLROW )
6534 // we have to renumber our row/column data to insert a new row/column
6535 implts_renumberRowColumnData( (::com::sun::star::ui::DockingArea)aUIDockingElement.m_aDockedData.m_nDockedArea,
6536 m_eDockOperation,
6537 aUIDockingElement );
6541 bStartDockFloated = rUIElement.m_bFloating;
6542 rUIElement.m_bFloating = m_aDockUIElement.m_bFloating;
6543 rUIElement.m_bUserActive = sal_True;
6546 // reset member for next docking operation
6547 m_aDockUIElement.m_xUIElement.clear();
6548 m_eDockOperation = DOCKOP_ON_COLROW;
6549 aWriteLock.unlock();
6551 implts_writeWindowStateData( aUIDockingElement.m_aName, aUIDockingElement );
6553 if ( bDockingInProgress )
6555 vos::OGuard aGuard( Application::GetSolarMutex() );
6556 Window* pWindow = VCLUnoHelper::GetWindow( Reference< css::awt::XWindow >( e.Source, UNO_QUERY ));
6557 ToolBox* pToolBox = 0;
6558 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
6559 pToolBox = (ToolBox *)pWindow;
6561 if ( pToolBox )
6563 if( e.bFloating )
6565 if ( aUIDockingElement.m_aFloatingData.m_bIsHorizontal )
6566 pToolBox->SetAlign( WINDOWALIGN_TOP );
6567 else
6568 pToolBox->SetAlign( WINDOWALIGN_LEFT );
6570 else
6572 ::Size aSize;
6574 pToolBox->SetAlign( ImplConvertAlignment( aUIDockingElement.m_aDockedData.m_nDockedArea) );
6576 // Docked toolbars have always one line
6577 aSize = pToolBox->CalcWindowSizePixel( 1 );
6579 // Lock layouting updates as our listener would be called due to SetSizePixel
6580 pToolBox->SetOutputSizePixel( aSize );
6585 aWriteLock.lock();
6586 m_bDockingInProgress = sal_False;
6587 aWriteLock.unlock();
6589 implts_sortUIElements();
6590 if ( !bStartDockFloated || !bFloating )
6592 // Optimization: Don't layout if we started floating and now floating again.
6593 // This would not change anything for the docked user-interface elements.
6594 doLayout();
6598 sal_Bool SAL_CALL LayoutManager::prepareToggleFloatingMode( const ::com::sun::star::lang::EventObject& e )
6599 throw (::com::sun::star::uno::RuntimeException)
6601 sal_Bool bDockingInProgress( sal_False );
6603 ReadGuard aReadLock( m_aLock );
6604 bDockingInProgress = m_bDockingInProgress;
6605 aReadLock.unlock();
6607 UIElement aUIDockingElement;
6608 sal_Bool bWinFound( implts_findElement( e.Source, aUIDockingElement ) );
6609 Reference< css::awt::XWindow > xWindow( e.Source, UNO_QUERY );
6611 if ( bWinFound && xWindow.is() )
6613 if ( !bDockingInProgress )
6615 css::awt::Rectangle aRect;
6616 Reference< css::awt::XDockableWindow > xDockWindow( xWindow, UNO_QUERY );
6617 if ( xDockWindow->isFloating() )
6620 vos::OGuard aGuard( Application::GetSolarMutex() );
6621 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
6622 if ( pWindow )
6624 if ( pWindow->GetType() == WINDOW_TOOLBOX )
6626 ToolBox* pToolBox = (ToolBox *)pWindow;
6627 aUIDockingElement.m_aFloatingData.m_aPos = pToolBox->GetPosPixel();
6628 aUIDockingElement.m_aFloatingData.m_aSize = pToolBox->GetOutputSizePixel();
6629 aUIDockingElement.m_aFloatingData.m_nLines = pToolBox->GetFloatingLines();
6630 aUIDockingElement.m_aFloatingData.m_bIsHorizontal = (( pToolBox->GetAlign() == WINDOWALIGN_TOP ) ||
6631 ( pToolBox->GetAlign() == WINDOWALIGN_BOTTOM ));
6636 WriteGuard aWriteLock( m_aLock );
6637 UIElement& rUIElement = LayoutManager::impl_findElement( aUIDockingElement.m_aName );
6638 if ( rUIElement.m_aName == aUIDockingElement.m_aName )
6639 rUIElement = aUIDockingElement;
6640 aWriteLock.unlock();
6645 return sal_True;
6648 void SAL_CALL LayoutManager::toggleFloatingMode( const ::com::sun::star::lang::EventObject& e )
6649 throw (::com::sun::star::uno::RuntimeException)
6651 sal_Bool bDockingInProgress( sal_False );
6652 UIElement aUIDockingElement;
6654 ReadGuard aReadLock( m_aLock );
6655 bDockingInProgress = m_bDockingInProgress;
6656 if ( bDockingInProgress )
6657 aUIDockingElement = m_aDockUIElement;
6658 aReadLock.unlock();
6660 Window* pWindow( 0 );
6661 ToolBox* pToolBox( 0 );
6662 Reference< css::awt::XWindow2 > xWindow;
6665 vos::OGuard aGuard( Application::GetSolarMutex() );
6666 xWindow = Reference< css::awt::XWindow2 >( e.Source, UNO_QUERY );
6667 pWindow = VCLUnoHelper::GetWindow( xWindow );
6669 if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
6670 pToolBox = (ToolBox *)pWindow;
6673 if ( !bDockingInProgress )
6675 sal_Bool bWinFound( implts_findElement( e.Source, aUIDockingElement ) );
6676 if ( bWinFound && xWindow.is() )
6678 aUIDockingElement.m_bFloating = !aUIDockingElement.m_bFloating;
6679 aUIDockingElement.m_bUserActive = sal_True;
6681 WriteGuard aWriteLock( m_aLock );
6682 m_bDoLayout = sal_True;
6683 aWriteLock.unlock();
6685 if ( aUIDockingElement.m_bFloating )
6687 vos::OGuard aGuard( Application::GetSolarMutex() );
6688 if ( pToolBox )
6690 pToolBox->SetLineCount( aUIDockingElement.m_aFloatingData.m_nLines );
6691 if ( aUIDockingElement.m_aFloatingData.m_bIsHorizontal )
6692 pToolBox->SetAlign( WINDOWALIGN_TOP );
6693 else
6694 pToolBox->SetAlign( WINDOWALIGN_LEFT );
6697 sal_Bool bUndefPos = ( aUIDockingElement.m_aFloatingData.m_aPos.X() == SAL_MAX_INT32 ||
6698 aUIDockingElement.m_aFloatingData.m_aPos.Y() == SAL_MAX_INT32 );
6699 sal_Bool bSetSize = ( aUIDockingElement.m_aFloatingData.m_aSize.Width() != 0 &&
6700 aUIDockingElement.m_aFloatingData.m_aSize.Height() != 0 );
6702 if ( bUndefPos )
6703 aUIDockingElement.m_aFloatingData.m_aPos = implts_findNextCascadeFloatingPos();
6705 if ( !bSetSize )
6707 if ( pToolBox )
6708 aUIDockingElement.m_aFloatingData.m_aSize = pToolBox->CalcFloatingWindowSizePixel();
6709 else
6710 aUIDockingElement.m_aFloatingData.m_aSize = pWindow->GetOutputSizePixel();
6713 xWindow->setPosSize( aUIDockingElement.m_aFloatingData.m_aPos.X(),
6714 aUIDockingElement.m_aFloatingData.m_aPos.Y(),
6715 0, 0, css::awt::PosSize::POS );
6716 xWindow->setOutputSize( AWTSize( aUIDockingElement.m_aFloatingData.m_aSize ) );
6718 else
6720 if (( aUIDockingElement.m_aDockedData.m_aPos.X() == SAL_MAX_INT32 ) &&
6721 ( aUIDockingElement.m_aDockedData.m_aPos.Y() == SAL_MAX_INT32 ))
6723 // Docking on its default position without a preset position -
6724 // we have to find a good place for it.
6725 ::Point aPixelPos;
6726 ::Point aDockPos;
6727 ::Size aSize;
6730 vos::OGuard aGuard( Application::GetSolarMutex() );
6731 if ( pToolBox )
6732 aSize = pToolBox->CalcWindowSizePixel( 1, ImplConvertAlignment( aUIDockingElement.m_aDockedData.m_nDockedArea ) );
6733 else
6734 aSize = pWindow->GetSizePixel();
6737 implts_findNextDockingPos( (::com::sun::star::ui::DockingArea)aUIDockingElement.m_aDockedData.m_nDockedArea,
6738 aSize,
6739 aDockPos,
6740 aPixelPos );
6741 aUIDockingElement.m_aDockedData.m_aPos = aDockPos;
6744 vos::OGuard aGuard( Application::GetSolarMutex() );
6745 if ( pToolBox )
6747 pToolBox->SetAlign( ImplConvertAlignment( aUIDockingElement.m_aDockedData.m_nDockedArea) );
6748 ::Size aSize = pToolBox->CalcWindowSizePixel( 1 );
6749 css::awt::Rectangle aRect = xWindow->getPosSize();
6750 xWindow->setPosSize( aRect.X, aRect.Y, 0, 0, css::awt::PosSize::POS );
6751 xWindow->setOutputSize( AWTSize( aSize ) );
6755 aWriteLock.lock();
6756 m_bDoLayout = sal_False;
6757 UIElement& rUIElement = LayoutManager::impl_findElement( aUIDockingElement.m_aName );
6758 if ( rUIElement.m_aName == aUIDockingElement.m_aName )
6759 rUIElement = aUIDockingElement;
6760 aWriteLock.unlock();
6762 implts_writeWindowStateData( aUIDockingElement.m_aName, aUIDockingElement );
6764 implts_sortUIElements();
6765 doLayout();
6768 else
6770 vos::OGuard aGuard( Application::GetSolarMutex() );
6771 if ( pToolBox )
6773 if ( aUIDockingElement.m_bFloating )
6775 if ( aUIDockingElement.m_aFloatingData.m_bIsHorizontal )
6776 pToolBox->SetAlign( WINDOWALIGN_TOP );
6777 else
6778 pToolBox->SetAlign( WINDOWALIGN_LEFT );
6780 else
6782 pToolBox->SetAlign( ImplConvertAlignment( aUIDockingElement.m_aDockedData.m_nDockedArea) );
6788 void SAL_CALL LayoutManager::closed( const ::com::sun::star::lang::EventObject& e )
6789 throw (::com::sun::star::uno::RuntimeException)
6791 rtl::OUString aName;
6792 UIElement aUIElement;
6793 UIElementVector::iterator pIter;
6795 WriteGuard aWriteLock( m_aLock );
6796 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
6798 Reference< XUIElement > xUIElement( pIter->m_xUIElement );
6799 if ( xUIElement.is() )
6801 Reference< XInterface > xIfac( xUIElement->getRealInterface(), UNO_QUERY );
6802 if ( xIfac == e.Source )
6804 aName = pIter->m_aName;
6806 // user closes a toolbar =>
6807 // context sensitive toolbar: only destroy toolbar and store state.
6808 // context sensitive toolbar: make it invisible, store state and destroy it.
6809 if ( !pIter->m_bContextSensitive )
6810 pIter->m_bVisible = sal_False;
6812 aUIElement = *pIter;
6813 break;
6817 aWriteLock.unlock();
6820 // destroy element
6821 if ( aName.getLength() > 0 )
6823 implts_writeWindowStateData( aName, aUIElement );
6824 destroyElement( aName );
6828 void SAL_CALL LayoutManager::endPopupMode( const ::com::sun::star::awt::EndPopupModeEvent& )
6829 throw (::com::sun::star::uno::RuntimeException)
6834 //---------------------------------------------------------------------------------------------------------
6835 // XLayoutManagerEventBroadcaster
6836 //---------------------------------------------------------------------------------------------------------
6837 void SAL_CALL LayoutManager::addLayoutManagerEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManagerListener >& xListener )
6838 throw (::com::sun::star::uno::RuntimeException)
6840 m_aListenerContainer.addInterface( ::getCppuType( (const css::uno::Reference< css::frame::XLayoutManagerListener >*)NULL ), xListener );
6843 void SAL_CALL LayoutManager::removeLayoutManagerEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManagerListener >& xListener )
6844 throw (::com::sun::star::uno::RuntimeException)
6846 m_aListenerContainer.removeInterface( ::getCppuType( (const css::uno::Reference< css::frame::XLayoutManagerListener >*)NULL ), xListener );
6849 void LayoutManager::implts_notifyListeners( short nEvent, ::com::sun::star::uno::Any aInfoParam )
6851 css::lang::EventObject aSource (static_cast< ::cppu::OWeakObject*>(this));
6852 ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< css::frame::XLayoutManagerListener >*) NULL ) );
6853 if (pContainer!=NULL)
6855 ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
6856 while (pIterator.hasMoreElements())
6860 ((css::frame::XLayoutManagerListener*)pIterator.next())->layoutEvent( aSource, nEvent, aInfoParam );
6862 catch( css::uno::RuntimeException& )
6864 pIterator.remove();
6870 //---------------------------------------------------------------------------------------------------------
6871 // XWindowListener
6872 //---------------------------------------------------------------------------------------------------------
6873 void SAL_CALL LayoutManager::windowResized( const css::awt::WindowEvent& aEvent )
6874 throw( css::uno::RuntimeException )
6876 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6877 WriteGuard aWriteLock( m_aLock );
6879 if ( !m_xDockingAreaAcceptor.is() )
6880 return;
6882 // Request to set docking area space again.
6883 css::awt::Rectangle aDockingArea( m_aDockingArea );
6884 Reference< XDockingAreaAcceptor > xDockingAreaAcceptor( m_xDockingAreaAcceptor );
6885 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
6887 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY );
6888 if ( xIfac == aEvent.Source && m_bVisible )
6890 // We have to call our resize handler at least once synchronously, as some
6891 // application modules need this. So we have to check if this is the first
6892 // call after the async layout time expired.
6893 m_bMustDoLayout = sal_True;
6894 if ( !m_aAsyncLayoutTimer.IsActive() )
6896 const Link& aLink = m_aAsyncLayoutTimer.GetTimeoutHdl();
6897 if ( aLink.IsSet() )
6898 aLink.Call( &m_aAsyncLayoutTimer );
6900 if ( m_nLockCount == 0 )
6901 m_aAsyncLayoutTimer.Start();
6903 else if ( m_xFrame.is() && aEvent.Source == m_xFrame->getContainerWindow() )
6905 // the container window of my DockingAreaAcceptor is not the same as of my frame
6906 // I still have to resize my frames' window as nobody else will do it
6907 Reference< css::awt::XWindow > xComponentWindow( m_xFrame->getComponentWindow() );
6908 if( xComponentWindow.is() == sal_True )
6910 css::uno::Reference< css::awt::XDevice > xDevice( m_xFrame->getContainerWindow(), css::uno::UNO_QUERY );
6912 // Convert relativ size to output size.
6913 css::awt::Rectangle aRectangle = m_xFrame->getContainerWindow()->getPosSize();
6914 css::awt::DeviceInfo aInfo = xDevice->getInfo();
6915 css::awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset ,
6916 aRectangle.Height - aInfo.TopInset - aInfo.BottomInset );
6918 // Resize our component window.
6919 xComponentWindow->setPosSize( 0, 0, aSize.Width, aSize.Height, css::awt::PosSize::POSSIZE );
6922 else
6924 // resize event for one of the UIElements
6925 sal_Bool bLocked( m_bDockingInProgress );
6926 sal_Bool bDoLayout( m_bDoLayout );
6927 aWriteLock.unlock();
6928 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6930 if ( !bLocked && !bDoLayout )
6932 // Do not do anything if we are in the middle of a docking process. This would interfere all other
6933 // operations. We will store the new position and size in the docking handlers.
6934 // Do not do anything if we are in the middle of our layouting process. We will adapt the position
6935 // and size of the user interface elements.
6936 UIElement aUIElement;
6937 if ( implts_findElement( aEvent.Source, aUIElement ))
6939 if ( aUIElement.m_bFloating )
6940 implts_writeNewStateData( aUIElement.m_aName,
6941 Reference< css::awt::XWindow >( aEvent.Source, UNO_QUERY ));
6942 else
6943 doLayout();
6949 void SAL_CALL LayoutManager::windowMoved( const css::awt::WindowEvent& ) throw( css::uno::RuntimeException )
6953 void SAL_CALL LayoutManager::windowShown( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException )
6955 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6956 ReadGuard aReadLock( m_aLock );
6958 // Request to set docking area space again.
6959 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
6960 bool bParentWindowVisible( m_bParentWindowVisible );
6961 aReadLock.unlock();
6962 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6964 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY );
6965 if ( xIfac == aEvent.Source )
6967 bool bSetVisible = false;
6969 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6970 WriteGuard aWriteLock( m_aLock );
6971 m_bParentWindowVisible = true;
6972 bSetVisible = ( m_bParentWindowVisible != bParentWindowVisible );
6973 aWriteLock.unlock();
6974 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6976 if ( bSetVisible )
6978 implts_updateUIElementsVisibleState( sal_True );
6979 //implts_doLayout( sal_False );
6984 void SAL_CALL LayoutManager::windowHidden( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException )
6986 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6987 ReadGuard aReadLock( m_aLock );
6989 // Request to set docking area space again.
6990 Reference< css::awt::XWindow > xContainerWindow( m_xContainerWindow );
6991 bool bParentWindowVisible( m_bParentWindowVisible );
6992 aReadLock.unlock();
6993 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6995 Reference< XInterface > xIfac( xContainerWindow, UNO_QUERY );
6996 if ( xIfac == aEvent.Source )
6998 bool bSetInvisible = false;
7000 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7001 WriteGuard aWriteLock( m_aLock );
7002 m_bParentWindowVisible = false;
7003 bSetInvisible = ( m_bParentWindowVisible != bParentWindowVisible );
7004 aWriteLock.unlock();
7005 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7007 if ( bSetInvisible )
7008 implts_updateUIElementsVisibleState( sal_False );
7012 IMPL_LINK( LayoutManager, AsyncLayoutHdl, Timer *, EMPTYARG )
7014 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7015 ReadGuard aReadLock( m_aLock );
7017 // Request to set docking area space again.
7018 m_aAsyncLayoutTimer.Stop();
7020 if( !m_xContainerWindow.is() )
7021 return 0;
7023 css::awt::Rectangle aDockingArea( m_aDockingArea );
7024 ::Size aStatusBarSize( implts_getStatusBarSize() );
7026 // Subtract status bar height
7027 aDockingArea.Height -= aStatusBarSize.Height();
7028 aReadLock.unlock();
7030 implts_setDockingAreaWindowSizes( aDockingArea );
7031 implts_doLayout( sal_True );
7033 return 0;
7036 #ifdef DBG_UTIL
7037 void LayoutManager::implts_checkElementContainer()
7039 #ifdef DBG_UTIL
7040 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7041 ReadGuard aReadLock( m_aLock );
7043 BaseHash< sal_Int32 > aUIElementHash;
7045 UIElementVector::iterator pIter;
7046 for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); pIter++ )
7047 aUIElementHash[pIter->m_aName]++;
7050 BaseHash< sal_Int32 >::const_iterator pCheckIter = aUIElementHash.begin();
7051 for ( ; pCheckIter != aUIElementHash.end(); pCheckIter++ )
7053 if ( pCheckIter->second > 1 )
7055 ::rtl::OString aName = ::rtl::OUStringToOString( pCheckIter->first, RTL_TEXTENCODING_ASCII_US );
7056 DBG_ASSERT( "More than one element (%s) with the same name found!", aName.getStr() );
7058 } // for ( ; pCheckIter != aUIElementHash.end(); pCheckIter++ )
7059 #endif
7061 #endif
7063 //---------------------------------------------------------------------------------------------------------
7064 // XFrameActionListener
7065 //---------------------------------------------------------------------------------------------------------
7066 void SAL_CALL LayoutManager::frameAction( const FrameActionEvent& aEvent )
7067 throw ( RuntimeException )
7069 if (( aEvent.Action == FrameAction_COMPONENT_ATTACHED ) ||
7070 ( aEvent.Action == FrameAction_COMPONENT_REATTACHED ))
7072 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)" );
7074 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7075 WriteGuard aWriteLock( m_aLock );
7076 m_bComponentAttached = sal_True;
7077 m_bMustDoLayout = sal_True;
7078 aWriteLock.unlock();
7079 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7081 implts_reset( sal_True );
7082 implts_doLayout( sal_True );
7084 else if (( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED ) ||
7085 ( aEvent.Action == FrameAction_FRAME_UI_DEACTIVATING ))
7087 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)" );
7089 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7090 WriteGuard aWriteLock( m_aLock );
7091 m_bActive = ( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED );
7092 aWriteLock.unlock();
7093 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7095 implts_toggleFloatingUIElementsVisibility( aEvent.Action == FrameAction_FRAME_UI_ACTIVATED );
7096 // doLayout();
7098 else if ( aEvent.Action == FrameAction_COMPONENT_DETACHING )
7100 RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)" );
7102 // SAFE AREA -----------------------------------------------------------------------------------------------
7103 WriteGuard aWriteLock( m_aLock );
7104 m_bComponentAttached = sal_False;
7105 aWriteLock.unlock();
7106 // SAFE AREA -----------------------------------------------------------------------------------------------
7108 implts_reset( sal_False );
7113 // ______________________________________________
7115 void SAL_CALL LayoutManager::disposing( const css::lang::EventObject& rEvent )
7116 throw( RuntimeException )
7118 sal_Bool bDisposeAndClear( sal_False );
7120 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7121 WriteGuard aWriteLock( m_aLock );
7123 if ( rEvent.Source == Reference< XInterface >( m_xFrame, UNO_QUERY ))
7125 // Our frame gets disposed, release all our references that depends on a working
7126 // frame reference.
7127 Application::RemoveEventListener( LINK( this, LayoutManager, SettingsChanged ) );
7128 if ( m_pMiscOptions )
7130 m_pMiscOptions->RemoveListener( LINK( this, LayoutManager, OptionsChanged ) );
7131 delete m_pMiscOptions;
7132 m_pMiscOptions = 0;
7135 delete m_pAddonOptions;
7136 m_pAddonOptions = 0;
7138 // destroy all elements, it's possible that dettaching is NOT called!
7139 implts_destroyElements();
7141 m_aUIElements.clear();
7142 impl_clearUpMenuBar();
7143 m_xMenuBar.clear();
7144 if ( m_xInplaceMenuBar.is() )
7146 m_pInplaceMenuBar = 0;
7147 m_xInplaceMenuBar->dispose();
7149 m_xInplaceMenuBar.clear();
7150 m_xContainerWindow.clear();
7151 implts_destroyDockingAreaWindows();
7153 if ( m_xModuleCfgMgr.is() )
7157 Reference< XUIConfiguration > xModuleCfgMgr( m_xModuleCfgMgr, UNO_QUERY );
7158 xModuleCfgMgr->removeConfigurationListener(
7159 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
7161 catch ( Exception& )
7166 if ( m_xDocCfgMgr.is() )
7170 Reference< XUIConfiguration > xDocCfgMgr( m_xDocCfgMgr, UNO_QUERY );
7171 xDocCfgMgr->removeConfigurationListener(
7172 Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
7174 catch ( Exception& )
7179 m_xDocCfgMgr.clear();
7180 m_xModuleCfgMgr.clear();
7181 m_xFrame.clear();
7182 delete m_pGlobalSettings;
7183 m_pGlobalSettings = 0;
7184 m_xDockingAreaAcceptor = Reference< ::com::sun::star::ui::XDockingAreaAcceptor >();
7186 bDisposeAndClear = sal_True;
7188 else if ( rEvent.Source == Reference< XInterface >( m_xContainerWindow, UNO_QUERY ))
7190 // Our container window gets disposed. Remove all user interface elements.
7191 m_aUIElements.clear();
7192 impl_clearUpMenuBar();
7193 m_xMenuBar.clear();
7194 if ( m_xInplaceMenuBar.is() )
7196 m_pInplaceMenuBar = 0;
7197 m_xInplaceMenuBar->dispose();
7199 m_xInplaceMenuBar.clear();
7200 m_xContainerWindow.clear();
7202 else if ( rEvent.Source == Reference< XInterface >( m_xDocCfgMgr, UNO_QUERY ))
7204 m_xDocCfgMgr.clear();
7206 else if ( rEvent.Source == Reference< XInterface >( m_xModuleCfgMgr , UNO_QUERY ))
7208 m_xModuleCfgMgr.clear();
7211 aWriteLock.unlock();
7212 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7214 // Send disposing to our listener when we have lost our frame.
7215 if ( bDisposeAndClear )
7217 // Send message to all listener and forget her references.
7218 css::uno::Reference< css::frame::XLayoutManager > xThis( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
7219 css::lang::EventObject aEvent( xThis );
7220 m_aListenerContainer.disposeAndClear( aEvent );
7224 void SAL_CALL LayoutManager::elementInserted( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
7226 ReadGuard aReadLock( m_aLock );
7228 ::rtl::OUString aElementType;
7229 ::rtl::OUString aElementName;
7230 Reference< XUIElement > xElement;
7231 Reference< XFrame > xFrame( m_xFrame );
7233 if ( m_xFrame.is() )
7235 implts_findElement( Event.ResourceURL, aElementType, aElementName, xElement );
7237 Reference< XUIElementSettings > xElementSettings( xElement, UNO_QUERY );
7238 if ( xElementSettings.is() )
7240 ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
7241 Reference< XPropertySet > xPropSet( xElementSettings, UNO_QUERY );
7242 if ( xPropSet.is() )
7244 if ( Event.Source == Reference< XInterface >( m_xDocCfgMgr, UNO_QUERY ))
7245 xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( m_xDocCfgMgr ));
7247 xElementSettings->updateSettings();
7249 else
7251 if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ) &&
7252 ( aElementName.indexOf( m_aCustomTbxPrefix ) != -1 ))
7254 // custom toolbar must be directly created, shown and layouted!
7255 createElement( Event.ResourceURL );
7256 Reference< XUIElement > xUIElement = getElement( Event.ResourceURL );
7257 if ( xUIElement.is() )
7259 Reference< XUIConfigurationManager > xCfgMgr;
7260 Reference< XPropertySet > xPropSet;
7261 ::rtl::OUString aUIName;
7265 xCfgMgr = Reference< XUIConfigurationManager >( Event.Source, UNO_QUERY );
7266 xPropSet = Reference< XPropertySet >( xCfgMgr->getSettings( Event.ResourceURL, sal_False ), UNO_QUERY );
7268 if ( xPropSet.is() )
7269 xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UIName" ))) >>= aUIName;
7271 catch ( com::sun::star::container::NoSuchElementException& )
7274 catch ( com::sun::star::beans::UnknownPropertyException& )
7277 catch ( com::sun::star::lang::WrappedTargetException& )
7282 vos::OGuard aGuard( Application::GetSolarMutex() );
7283 Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), UNO_QUERY );
7284 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
7285 if ( pWindow )
7286 pWindow->SetText( aUIName );
7289 showElement( Event.ResourceURL );
7296 void SAL_CALL LayoutManager::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
7298 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7299 WriteGuard aWriteLock( m_aLock );
7301 ::rtl::OUString aElementType;
7302 ::rtl::OUString aElementName;
7303 Reference< XUIElement > xUIElement;
7304 Reference< XFrame > xFrame( m_xFrame );
7306 if ( m_xFrame.is() )
7308 implts_findElement( Event.ResourceURL, aElementType, aElementName, xUIElement );
7310 Reference< XUIElementSettings > xElementSettings( xUIElement, UNO_QUERY );
7311 if ( xElementSettings.is() )
7313 bool bNoSettings( false );
7314 ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
7315 Reference< XInterface > xElementCfgMgr;
7316 Reference< XPropertySet > xPropSet( xElementSettings, UNO_QUERY );
7318 if ( xPropSet.is() )
7319 xPropSet->getPropertyValue( aConfigSourcePropName ) >>= xElementCfgMgr;
7321 if ( !xElementCfgMgr.is() )
7322 return;
7324 // Check if the same UI configuration manager has changed => check further
7325 if ( Event.Source == xElementCfgMgr )
7327 // Same UI configuration manager where our element has its settings
7328 if ( Event.Source == Reference< XInterface >( m_xDocCfgMgr, UNO_QUERY ))
7330 // document settings removed
7331 if ( m_xModuleCfgMgr->hasSettings( Event.ResourceURL ))
7333 xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( m_xModuleCfgMgr ));
7334 xElementSettings->updateSettings();
7335 return;
7339 bNoSettings = true;
7342 // No settings anymore, element must be destroyed
7343 if ( m_xContainerWindow.is() && bNoSettings )
7345 if ( aElementType.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
7346 aElementName.equalsIgnoreAsciiCaseAscii( "menubar" ))
7348 Window* pWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
7349 while ( pWindow && !pWindow->IsSystemWindow() )
7350 pWindow = pWindow->GetParent();
7352 if ( pWindow && !m_bInplaceMenuSet )
7353 ((SystemWindow *)pWindow)->SetMenuBar( 0 );
7355 Reference< XComponent > xComp( m_xMenuBar, UNO_QUERY );
7356 if ( xComp.is() )
7357 xComp->dispose();
7358 m_xMenuBar.clear();
7360 else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ))
7362 destroyElement( Event.ResourceURL );
7369 void SAL_CALL LayoutManager::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
7371 ReadGuard aReadLock( m_aLock );
7373 ::rtl::OUString aElementType;
7374 ::rtl::OUString aElementName;
7375 Reference< XUIElement > xUIElement;
7376 Reference< XFrame > xFrame( m_xFrame );
7378 if ( m_xFrame.is() )
7380 implts_findElement( Event.ResourceURL, aElementType, aElementName, xUIElement );
7382 Reference< XUIElementSettings > xElementSettings( xUIElement, UNO_QUERY );
7383 if ( xElementSettings.is() )
7385 ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
7386 Reference< XInterface > xElementCfgMgr;
7387 Reference< XPropertySet > xPropSet( xElementSettings, UNO_QUERY );
7389 if ( xPropSet.is() )
7390 xPropSet->getPropertyValue( aConfigSourcePropName ) >>= xElementCfgMgr;
7392 if ( !xElementCfgMgr.is() )
7393 return;
7395 // Check if the same UI configuration manager has changed => update settings
7396 if ( Event.Source == xElementCfgMgr )
7398 xElementSettings->updateSettings();
7399 if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolbar" ))
7400 doLayout();
7406 //---------------------------------------------------------------------------------------------------------
7407 // OPropertySetHelper
7408 //---------------------------------------------------------------------------------------------------------
7409 // XPropertySet helper
7410 sal_Bool SAL_CALL LayoutManager::convertFastPropertyValue( Any& aConvertedValue ,
7411 Any& aOldValue ,
7412 sal_Int32 nHandle ,
7413 const Any& aValue ) throw( com::sun::star::lang::IllegalArgumentException )
7415 // Initialize state with FALSE !!!
7416 // (Handle can be invalid)
7417 sal_Bool bReturn = sal_False;
7419 switch( nHandle )
7421 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER :
7422 bReturn = PropHelper::willPropertyBeChanged(
7423 com::sun::star::uno::makeAny(m_bMenuBarCloser),
7424 aValue,
7425 aOldValue,
7426 aConvertedValue);
7427 break;
7428 case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS:
7429 bReturn = PropHelper::willPropertyBeChanged(
7430 com::sun::star::uno::makeAny(m_bAutomaticToolbars),
7431 aValue,
7432 aOldValue,
7433 aConvertedValue);
7434 break;
7435 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY:
7436 bReturn = PropHelper::willPropertyBeChanged(
7437 com::sun::star::uno::makeAny(sal_False),
7438 aValue,
7439 aOldValue,
7440 aConvertedValue);
7441 break;
7442 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI:
7443 bReturn = PropHelper::willPropertyBeChanged(
7444 com::sun::star::uno::makeAny(m_bHideCurrentUI),
7445 aValue,
7446 aOldValue,
7447 aConvertedValue);
7448 break;
7451 // Return state of operation.
7452 return bReturn ;
7455 void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle ,
7456 const com::sun::star::uno::Any& aValue ) throw( com::sun::star::uno::Exception )
7458 switch( nHandle )
7460 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER:
7462 sal_Bool bCloserState = sal_False;
7463 aValue >>= bCloserState;
7464 implts_setMenuBarCloser( bCloserState );
7465 break;
7467 case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS:
7469 sal_Bool bValue = sal_Bool();
7470 if ( aValue >>= bValue )
7471 m_bAutomaticToolbars = bValue;
7472 break;
7474 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY:
7476 sal_Bool bValue = sal_Bool();
7477 if (( aValue >>= bValue ) && bValue )
7478 implts_refreshContextToolbarsVisibility();
7479 break;
7481 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI:
7483 sal_Bool bValue = sal_Bool();
7484 if ( aValue >>= bValue )
7486 m_bHideCurrentUI = bValue;
7487 implts_setCurrentUIVisibility( !bValue );
7489 break;
7494 void SAL_CALL LayoutManager::getFastPropertyValue( com::sun::star::uno::Any& aValue ,
7495 sal_Int32 nHandle ) const
7497 switch( nHandle )
7499 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER:
7500 aValue <<= m_bMenuBarCloser;
7501 break;
7502 case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS:
7503 aValue <<= m_bAutomaticToolbars;
7504 break;
7505 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY:
7506 aValue <<= sal_False;
7507 break;
7508 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI:
7509 aValue <<= m_bHideCurrentUI;
7510 break;
7511 case LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT:
7512 aValue <<= m_nLockCount;
7513 break;
7517 ::cppu::IPropertyArrayHelper& SAL_CALL LayoutManager::getInfoHelper()
7519 // Optimize this method !
7520 // We initialize a static variable only one time. And we don't must use a mutex at every call!
7521 // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
7522 static ::cppu::OPropertyArrayHelper* pInfoHelper = NULL;
7524 if( pInfoHelper == NULL )
7526 // Ready for multithreading
7527 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
7529 // Control this pointer again, another instance can be faster then these!
7530 if( pInfoHelper == NULL )
7532 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
7533 // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
7534 // "sal_True" say: Table is sorted by name.
7535 static ::cppu::OPropertyArrayHelper aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True );
7536 pInfoHelper = &aInfoHelper;
7540 return(*pInfoHelper);
7543 com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL LayoutManager::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException)
7545 // Optimize this method !
7546 // We initialize a static variable only one time. And we don't must use a mutex at every call!
7547 // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
7548 static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo >* pInfo = NULL;
7550 if( pInfo == NULL )
7552 // Ready for multithreading
7553 osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
7554 // Control this pointer again, another instance can be faster then these!
7555 if( pInfo == NULL )
7557 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
7558 // (Use method "getInfoHelper()".)
7559 static com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
7560 pInfo = &xInfo;
7564 return (*pInfo);
7567 const com::sun::star::uno::Sequence< com::sun::star::beans::Property > LayoutManager::impl_getStaticPropertyDescriptor()
7569 // Create a new static property array to initialize sequence!
7570 // Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
7571 // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
7572 // It's necessary for methods of OPropertySetHelper.
7573 // ATTENTION:
7574 // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
7576 static const com::sun::star::beans::Property pProperties[] =
7578 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_AUTOMATICTOOLBARS, LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS, ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ),
7579 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_HIDECURRENTUI, LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI, ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ),
7580 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_LOCKCOUNT, LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT, ::getCppuType((const sal_Int32*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT|com::sun::star::beans::PropertyAttribute::READONLY ),
7581 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER, ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT ),
7582 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_REFRESHVISIBILITY, LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY, ::getCppuType((const sal_Bool*)NULL), com::sun::star::beans::PropertyAttribute::TRANSIENT )
7584 // Use it to initialize sequence!
7585 static const com::sun::star::uno::Sequence< com::sun::star::beans::Property > lPropertyDescriptor( pProperties, LAYOUTMANAGER_PROPCOUNT );
7586 // Return static "PropertyDescriptor"
7587 return lPropertyDescriptor;
7590 } // namespace framework