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 $
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 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
40 #ifndef _FRAMEWORK_SERVICES_LAYOUTMANAGER_HXX_
41 #include <services/layoutmanager.hxx>
43 #include <threadhelp/resetableguard.hxx>
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>
55 #include <toolkit/helper/convert.hxx>
56 #include <uielement/progressbarwrapper.hxx>
57 #include <uiconfiguration/globalsettings.hxx>
59 //_________________________________________________________________________________________________________________
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>
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>
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 //_________________________________________________________________________________________________________________
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>
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>
111 #include <boost/bind.hpp>
112 // ______________________________________________
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 ))
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();
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() )
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
;
165 return WINDOWALIGN_BOTTOM
;
168 //_________________________________________________________________________________________________________________
170 //_________________________________________________________________________________________________________________
176 struct UIElementVisibility
182 bool LayoutManager::UIElement::operator< ( const LayoutManager::UIElement
& aUIElement
) const
184 if ( !m_xUIElement
.is() && aUIElement
.m_xUIElement
.is() )
186 else if ( m_xUIElement
.is() && !aUIElement
.m_xUIElement
.is() )
188 else if ( !m_bVisible
&& aUIElement
.m_bVisible
)
190 else if ( m_bVisible
&& !aUIElement
.m_bVisible
)
192 else if ( !m_bFloating
&& aUIElement
.m_bFloating
)
194 else if ( m_bFloating
&& !aUIElement
.m_bFloating
)
200 bool bEqual
= ( m_aFloatingData
.m_aPos
.Y() == aUIElement
.m_aFloatingData
.m_aPos
.Y() );
202 return ( m_aFloatingData
.m_aPos
.X() < aUIElement
.m_aFloatingData
.m_aPos
.X() );
204 return ( m_aFloatingData
.m_aPos
.Y() < aUIElement
.m_aFloatingData
.m_aPos
.Y() );
208 if ( m_aDockedData
.m_nDockedArea
< aUIElement
.m_aDockedData
.m_nDockedArea
)
210 else if ( m_aDockedData
.m_nDockedArea
> aUIElement
.m_aDockedData
.m_nDockedArea
)
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() );
221 bool bEqual
= ( m_aDockedData
.m_aPos
.X() == aUIElement
.m_aDockedData
.m_aPos
.X() );
224 return m_bUserActive
&& !aUIElement
.m_bUserActive
;
227 return ( m_aDockedData
.m_aPos
.X() < aUIElement
.m_aDockedData
.m_aPos
.X() );
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() );
236 bool bEqual
= ( m_aDockedData
.m_aPos
.Y() == aUIElement
.m_aDockedData
.m_aPos
.Y() );
239 return m_bUserActive
&& !aUIElement
.m_bUserActive
;
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
;
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
;
279 Reference
< XController
> xController( rFrame
->getController(), UNO_QUERY
);
280 if ( xController
.is() )
281 xModel
= xController
->getModel();
287 static sal_Bool
implts_isPreviewModel( const Reference
< XModel
>& xModel
)
291 ::comphelper::MediaDescriptor
aDesc( xModel
->getArgs() );
292 return aDesc
.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_PREVIEW(), (sal_Bool
)sal_False
);
298 static sal_Bool
implts_isFrameOrWindowTop( const css::uno::Reference
< css::frame::XFrame
>& xFrame
)
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() );
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(
348 ::rtl::OUString::createFromAscii("_self"),
354 //*****************************************************************************************************************
355 // XInterface, XTypeProvider, XServiceInfo
356 //*****************************************************************************************************************
357 DEFINE_XINTERFACE_14 ( LayoutManager
,
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
),
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
;
476 m_aAsyncLayoutTimer
.Stop();
479 // Internal helper function
480 void LayoutManager::impl_clearUpMenuBar()
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();
495 MenuBar
* pSetMenuBar
= 0;
496 if ( m_xInplaceMenuBar
.is() )
497 pSetMenuBar
= (MenuBar
*)m_pInplaceMenuBar
->GetMenuBar();
500 Reference
< css::awt::XMenuBar
> xMenuBar
;
502 Reference
< XPropertySet
> xPropSet( m_xMenuBar
, UNO_QUERY
);
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
);
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
);
543 sal_Bool
LayoutManager::impl_parseResourceURL( const rtl::OUString aResourceURL
, rtl::OUString
& aElementType
, rtl::OUString
& aElementName
)
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
);
564 void LayoutManager::implts_lock()
566 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
567 WriteGuard
aWriteLock( m_aLock
);
570 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
573 sal_Bool
LayoutManager::implts_unlock()
575 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
576 WriteGuard
aWriteLock( m_aLock
);
578 if ( 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
);
602 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
606 Reference
< XModel
> xModel
;
611 ::rtl::OUString
aOldModuleIdentifier( aModuleIdentifier
);
614 aModuleIdentifier
= m_xModuleManager
->identify( Reference
< XInterface
>( xFrame
, UNO_QUERY
) );
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
));
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
));
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
);
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
));
684 xDocCfgMgr
= Reference
< XUIConfiguration
>( xUIConfigurationManagerSupplier
->getUIConfigurationManager(), UNO_QUERY
);
685 if ( xDocCfgMgr
.is() )
686 xDocCfgMgr
->addConfigurationListener( Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
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
));
709 if ( xDocCfgMgr
.is() )
713 xDocCfgMgr
->removeConfigurationListener(
714 Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
721 // Release references to our configuration managers as we currently don't have
722 // an attached module.
723 xModuleCfgMgr
.clear();
725 xPersistentWindowState
.clear();
726 aModuleIdentifier
= ::rtl::OUString();
729 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
730 WriteGuard
aWriteLock( m_aLock
);
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!
740 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
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
);
760 if ( bAutomaticToolbars
)
762 implts_createCustomToolBars();
763 implts_createAddonsToolBars();
764 implts_createNonContextSensitiveToolBars();
766 implts_sortUIElements();
769 implts_destroyElements();
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
);
783 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
785 Reference
< css::awt::XWindow
> xFrameContainerWindow
= xFrame
->getContainerWindow();
786 if ( xFrameContainerWindow
== xContainerWindow
)
792 void LayoutManager::implts_destroyElements()
794 UIElementVector aUIElementVector
;
796 WriteGuard
aWriteLock( m_aLock
);
797 aUIElementVector
= m_aUIElements
;
798 m_aUIElements
.clear();
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();
812 impl_clearUpMenuBar();
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();
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();
850 void LayoutManager::implts_createCustomToolBar( const rtl::OUString
& aTbxResName
, const rtl::OUString
& aTitle
)
852 if ( aTbxResName
.getLength() > 0 )
854 createElement( aTbxResName
);
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
);
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
)
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
);
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
)
946 Reference
< XModel
> xModel
;
947 Reference
< XFrame
> xFrame( m_xFrame
);
951 if ( !m_pAddonOptions
)
952 m_pAddonOptions
= new AddonsOptions
;
954 Reference
< XUIElementFactory
> xUIElementFactory( m_xUIElementFactoryManager
);
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
;
980 UIElement aElement
= impl_findElement( aAddonToolBarName
);
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() )
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
);
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
);
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
);
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() ||
1070 !m_bComponentAttached
)
1073 Reference
< XFrame
> xFrame( m_xFrame
);
1075 Reference
< XUIElementFactory
> xUIElementFactory( m_xUIElementFactoryManager
);
1076 Reference
< XNameAccess
> xPersistentWindowState( m_xPersistentWindowState
);
1079 if ( implts_isPreviewModel( impl_getModelFromFrame( xFrame
)))
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
);
1113 implts_readWindowStateData( aName
, aNewToolbar
);
1115 if ( aNewToolbar
.m_bVisible
&&
1116 !aNewToolbar
.m_bContextSensitive
)
1119 implts_insertUIElement( aNewToolbar
);
1120 aMakeVisibleToolbars
.push_back( aName
);
1127 catch ( RuntimeException
& e
)
1131 catch ( Exception
& )
1135 if ( !aMakeVisibleToolbars
.empty() )
1138 ::std::for_each( aMakeVisibleToolbars
.begin(), aMakeVisibleToolbars
.end(),::boost::bind( &LayoutManager::requestElement
, this,_1
));
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
);
1161 bVisible
= pWindow
->IsVisible();
1163 if ( xDockWindow
->isFloating() )
1167 if ( !bVisible
&& pIter
->m_bDeactiveHide
)
1169 pIter
->m_bDeactiveHide
= sal_False
;
1170 // we need VCL here to pass special flags to Show()
1172 pWindow
->Show( TRUE
, SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
1173 //xWindow->setVisible( sal_True );
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
;
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
;
1209 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
1210 aElementName
.equalsIgnoreAsciiCaseAscii( "progressbar" ))
1212 ReadGuard
aReadLock( m_aLock
);
1213 xUIElement
= m_aProgressBarElement
.m_xUIElement
;
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
;
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
;
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
;
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
)
1286 return aEmptyElement
;
1289 sal_Bool
LayoutManager::implts_insertUIElement( const UIElement
& rUIElement
)
1291 UIElement aTempData
;
1292 bool bFound
= implts_findElement( rUIElement
.m_aName
, aTempData
);
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
);
1306 bool bResult( false );
1309 WriteGuard
aWriteLock( m_aLock
);
1310 m_aUIElements
.push_back( rUIElement
);
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
);
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
);
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
;
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
)
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 ----------------------------------------------------------------------------------------------- */
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() )
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
,
1524 aValue
>>= rElementData
.m_aDockedData
.m_bLocked
;
1525 if ( pGlobalSettings
->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR
,
1526 GlobalSettings::STATEINFO_DOCKED
,
1529 if ( aValue
>>= bValue
)
1530 rElementData
.m_bFloating
= !bValue
;
1537 catch ( NoSuchElementException
& )
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
));
1615 Reference
< XNameContainer
> xInsert( xPersistentWindowState
, UNO_QUERY
);
1616 xInsert
->insertByName( aName
, makeAny( aWindowState
));
1619 catch ( Exception
& )
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
);
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
);
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
;
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
)
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
);
1688 aPos
= implts_findNextCascadeFloatingPos();
1689 rElement
.m_aFloatingData
.m_aPos
= aPos
; // set new cascaded position
1690 bWriteData
= sal_True
;
1694 xWindow
->setOutputSize( AWTSize( rElement
.m_aFloatingData
.m_aSize
) );
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
1714 xWindow
->setPosSize( aPos
.X(), aPos
.Y(), 0, 0,
1715 css::awt::PosSize::POS
);
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
);
1729 sal_Bool
bSetSize( sal_False
);
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
,
1749 rElement
.m_aDockedData
.m_aPos
= aDockPos
;
1753 xWindow
->setPosSize( aPixelPos
.X(),
1756 css::awt::PosSize::POS
);
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
];
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
;
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 );
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();
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
);
1904 rPixelPos
= ::Point( nCurrPos
, aDockingWinSize
.Height() - nPixelPos
);
1907 nCurrPos
= rRect
.X
+ rRect
.Width
;
1911 if ( rSpace
>= nNeededSpace
)
1913 rVirtualPos
= ::Point( rRowColumnWindowData
.nRowColumn
, nCurrPos
);
1914 if ( DockingArea
== DockingArea_DOCKINGAREA_LEFT
)
1915 rPixelPos
= ::Point( nPixelPos
, nTopDockingAreaSize
+ nCurrPos
);
1917 rPixelPos
= ::Point( aDockingWinSize
.Width() - nPixelPos
, nTopDockingAreaSize
+ nCurrPos
);
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
);
1933 rPixelPos
= ::Point( nCurrPos
, aDockingWinSize
.Height() - nPixelPos
);
1938 rVirtualPos
= ::Point( rRowColumnWindowData
.nRowColumn
, nCurrPos
);
1939 if ( DockingArea
== DockingArea_DOCKINGAREA_LEFT
)
1940 rPixelPos
= ::Point( nPixelPos
, nTopDockingAreaSize
+ nCurrPos
);
1942 rPixelPos
= ::Point( aDockingWinSize
.Width() - nPixelPos
, nTopDockingAreaSize
+ nCurrPos
);
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;
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
);
1975 rPixelPos
= ::Point( 0, aDockingWinSize
.Height() - nFreeRowColPixelPos
);
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 );
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();
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
;
2019 implts_checkElementContainer();
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() )
2051 aWindowVector
.push_back( *pIter
);
2057 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2059 rRowColumnsWindowData
.clear();
2061 // Collect data from windows that are on the same row/column
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;
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
) )
2090 if (( eDockingArea
== DockingArea_DOCKINGAREA_TOP
) ||
2091 ( eDockingArea
== DockingArea_DOCKINGAREA_BOTTOM
))
2093 if ( nCurrPos
== -1 )
2095 nCurrPos
= rElement
.m_aDockedData
.m_aPos
.Y();
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
;
2109 nLastRowColPixelPos
-= rRowColumnsWindowData
[nIndex
].nStaticSize
;
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
;
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(),
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
);
2145 rRowColumnsWindowData
[nIndex
].aRowColumnRect
= css::awt::Rectangle( 0, ( nLastRowColPixelPos
- aPosSize
.Height
),
2146 aDockAreaRect
.Width
, aPosSize
.Height
);
2147 rRowColumnsWindowData
[nIndex
].nVarSize
+= aPosSize
.Width
+ nSpace
;
2151 if ( nCurrPos
== -1 )
2153 nCurrPos
= rElement
.m_aDockedData
.m_aPos
.X();
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
;
2167 nLastRowColPixelPos
-= rRowColumnsWindowData
[nIndex
].nStaticSize
;
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
;
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(),
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
);
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
);
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
)
2245 aWindowVector
.push_back( *pIter
);
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
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
) )
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
;
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(),
2298 if ( rRowColumnWindowData
.nStaticSize
< aPosSize
.Height
)
2299 rRowColumnWindowData
.nStaticSize
= aPosSize
.Height
;
2300 rRowColumnWindowData
.nVarSize
+= aPosSize
.Width
;
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
;
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(),
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
,
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
;
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
];
2359 else if ( aRowColumnWindowData
.aUIElementNames
[i
] == rMovedElementName
)
2360 nSpace
+= aRowColumnWindowData
.aRowColumnWindowSizes
[i
].Width
+
2361 aRowColumnWindowData
.aRowColumnSpace
[i
];
2367 if ( aRowColumnWindowData
.aRowColumnWindowSizes
[i
].Y
>= rDockedElementRect
.Top() )
2369 nSpace
+= aRowColumnWindowData
.aRowColumnSpace
[i
];
2372 else if ( aRowColumnWindowData
.aUIElementNames
[i
] == rMovedElementName
)
2373 nSpace
+= aRowColumnWindowData
.aRowColumnWindowSizes
[i
].Height
+
2374 aRowColumnWindowData
.aRowColumnSpace
[i
];
2382 sal_Int32 nMove
= std::min( nSpace
, static_cast<sal_Int32
>(aFrontDockingRect
.getWidth()) );
2383 if ( bHorzDockArea
)
2384 aFrontDockingRect
.Move( -nMove
, 0 );
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() )
2409 ReadGuard
aReadLock( m_aLock
);
2410 Reference
< css::awt::XWindow
> xContainerWindow
= m_xContainerWindow
;
2411 Reference
< css::awt::XWindow
> xDockingAreaWindow
= m_xDockAreaWindows
[DockingArea
];
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
] )
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
;
2466 return ( DockingArea
== DockingArea_DOCKINGAREA_TOP
) ? DOCKOP_AFTER_COLROW
: DOCKOP_BEFORE_COLROW
;
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
;
2478 return ( DockingArea
== DockingArea_DOCKINGAREA_LEFT
) ? DOCKOP_AFTER_COLROW
: DOCKOP_BEFORE_COLROW
;
2482 return DOCKOP_ON_COLROW
;
2485 ::Rectangle
LayoutManager::implts_calcTrackingAndElementRect(
2486 ::com::sun::star::ui::DockingArea eDockingArea
,
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() ),
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
;
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
;
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();
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 );
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();
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
;
2622 xDockingAreaWindow
= m_xDockAreaWindows
[eDockedArea
];
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() );
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
)
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
;
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() )));
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
;
2726 sal_Int32 nSize
= ::std::max( sal_Int32( 0 ), std::min( sal_Int32(
2727 nTopDockingAreaSize
+ nMaxLeftRightDockAreaSize
- aWindowRect
.Top() ),
2728 sal_Int32( aTrackingRect
.getHeight() )));
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
;
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() )));
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();
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
;
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
;
2791 implts_setTrackingRect( eDockedArea
, rMousePos
, aTrackingRect
);
2792 rTrackingRect
= implts_calcTrackingAndElementRect(
2793 eDockedArea
, nRowCol
, rUIElement
,
2794 aTrackingRect
, aRowColumnRect
, aContainerWinSize
);
2800 if ((( nRowCol
== nMinRowCol
) && ( rDockingOperation
== DOCKOP_BEFORE_COLROW
)) ||
2801 (( nRowCol
== nMaxRowCol
) && ( rDockingOperation
== DOCKOP_AFTER_COLROW
)))
2802 bOpOutsideOfDockingArea
= sal_True
;
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 ));
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.
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.
2844 if ( bHorizontalDockArea
)
2845 rUIElement
.m_aDockedData
.m_aPos
.Y() = nRowCol
;
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() ),
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;
2888 rUIElement
.m_aDockedData
.m_aPos
.Y() = ( nMaxRowCol
>= 0 ) ? nMaxRowCol
+1 : 0;
2889 rDockingOperation
= DOCKOP_BEFORE_COLROW
;
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;
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
;
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;
2936 rUIElement
.m_aDockedData
.m_aPos
.X() = ( nMaxRowCol
>= 0 ) ? nMaxRowCol
+1 : 0;
2937 rDockingOperation
= DOCKOP_BEFORE_COLROW
;
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;
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
);
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
))
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;
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
))
3028 sal_Int32 nWindowRowCol
= ( bHorzDockingArea
) ? aDockedPos
.Y
: aDockedPos
.X
;
3029 if (( nDockedArea
== eDockingArea
) && ( nWindowRowCol
>= nRowCol
))
3031 if ( bHorzDockingArea
)
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()
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
];
3063 if ( xTopDockingAreaWindow
.is() )
3064 aSize
.Width() = xTopDockingAreaWindow
->getPosSize().Height
;
3065 if ( xBottomDockingAreaWindow
.is() )
3066 aSize
.Height() = xBottomDockingAreaWindow
->getPosSize().Height
;
3071 void LayoutManager::implts_sortActiveElement( const UIElement
& )
3073 implts_sortUIElements();
3076 Reference
< XUIElement
> LayoutManager::implts_createElement( const rtl::OUString
& aName
)
3078 Reference
< ::com::sun::star::ui::XUIElement
> xUIElement
;
3080 ReadGuard
aReadLock( m_aLock
);
3081 Sequence
< PropertyValue
> aPropSeq( 2 );
3082 aPropSeq
[0].Name
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
3083 aPropSeq
[0].Value
<<= m_xFrame
;
3084 aPropSeq
[1].Name
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ));
3085 aPropSeq
[1].Value
<<= sal_True
;
3089 xUIElement
= m_xUIElementFactoryManager
->createUIElement( aName
, aPropSeq
);
3091 catch ( NoSuchElementException
& )
3094 catch ( IllegalArgumentException
& )
3101 Reference
< css::awt::XWindowPeer
> LayoutManager::implts_createToolkitWindow( const Reference
< css::awt::XWindowPeer
>& rParent
)
3103 Reference
< css::awt::XWindowPeer
> xPeer
;
3104 css::uno::Reference
< css::awt::XToolkit
> xToolkit( m_xSMGR
->createInstance( SERVICENAME_VCLTOOLKIT
), css::uno::UNO_QUERY
);
3105 if ( xToolkit
.is() )
3107 // describe window properties.
3108 css::awt::WindowDescriptor aDescriptor
;
3109 aDescriptor
.Type
= css::awt::WindowClass_SIMPLE
;
3110 aDescriptor
.WindowServiceName
= DECLARE_ASCII("dockingarea") ;
3111 aDescriptor
.ParentIndex
= -1 ;
3112 aDescriptor
.Parent
= css::uno::Reference
< css::awt::XWindowPeer
>( rParent
, UNO_QUERY
) ;
3113 aDescriptor
.Bounds
= css::awt::Rectangle(0,0,0,0) ;
3114 aDescriptor
.WindowAttributes
= 0 ;
3116 // create a docking area window
3117 xPeer
= xToolkit
->createWindow( aDescriptor
);
3123 void LayoutManager::implts_setVisibleState( sal_Bool bShow
)
3125 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3126 WriteGuard
aWriteLock( m_aLock
);
3127 UIElementVector::iterator pIter
;
3128 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
3129 pIter
->m_bMasterHide
= !bShow
;
3130 m_aStatusBarElement
.m_bMasterHide
= !bShow
;
3131 aWriteLock
.unlock();
3132 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3134 implts_updateUIElementsVisibleState( bShow
);
3135 //implts_doLayout( sal_False );
3138 void LayoutManager::implts_updateUIElementsVisibleState( sal_Bool bSetVisible
)
3143 implts_notifyListeners( css::frame::LayoutManagerEvents::VISIBLE
, a
);
3145 implts_notifyListeners( css::frame::LayoutManagerEvents::INVISIBLE
, a
);
3146 std::vector
< Reference
< css::awt::XWindow
> > aWinVector
;
3150 WriteGuard
aWriteLock( m_aLock
);
3151 m_bDoLayout
= sal_True
;
3155 ReadGuard
aReadLock( m_aLock
);
3156 aWinVector
.reserve(m_aUIElements
.size());
3157 UIElementVector::iterator pIter
;
3158 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
3160 if ( pIter
->m_xUIElement
.is() )
3162 Reference
< css::awt::XWindow
> xWindow( pIter
->m_xUIElement
->getRealInterface(), UNO_QUERY
);
3167 if ( pIter
->m_bVisible
&& !pIter
->m_bMasterHide
)
3168 aWinVector
.push_back( xWindow
);
3171 aWinVector
.push_back( xWindow
);
3180 vos::OGuard
aGuard( Application::GetSolarMutex() );
3181 const sal_uInt32 nCount
= aWinVector
.size();
3182 for ( sal_uInt32 i
= 0; i
< nCount
; i
++ )
3184 Reference
< css::awt::XWindow
> xWindow( aWinVector
[i
] );
3187 // we need VCL here to pass special flags to Show()
3188 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
3190 pWindow
->Show( bSetVisible
, SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
3194 catch ( DisposedException
& )
3198 // Hide/show menubar according to bSetVisible
3200 Reference
< XUIElement
> xMenuBar( m_xMenuBar
, UNO_QUERY
);
3201 Reference
< css::awt::XWindow
> xContainerWindow( m_xContainerWindow
);
3202 Reference
< XComponent
> xInplaceMenuBar( m_xInplaceMenuBar
);
3203 MenuBarManager
* pInplaceMenuBar( m_pInplaceMenuBar
);
3206 if (( xMenuBar
.is() || xInplaceMenuBar
.is() ) && xContainerWindow
.is() )
3208 vos::OGuard
aGuard( Application::GetSolarMutex() );
3210 MenuBar
* pMenuBar( 0 );
3211 if ( xInplaceMenuBar
.is() )
3212 pMenuBar
= (MenuBar
*)pInplaceMenuBar
->GetMenuBar();
3215 MenuBarWrapper
* pMenuBarWrapper
= SAL_STATIC_CAST( MenuBarWrapper
*, xMenuBar
.get() );
3216 pMenuBar
= (MenuBar
*)pMenuBarWrapper
->GetMenuBarManager()->GetMenuBar();
3219 Window
* pWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
3220 while ( pWindow
&& !pWindow
->IsSystemWindow() )
3221 pWindow
= pWindow
->GetParent();
3225 SystemWindow
* pSysWindow
= (SystemWindow
*)pWindow
;
3227 pSysWindow
->SetMenuBar( pMenuBar
);
3229 pSysWindow
->SetMenuBar( 0 );
3233 // Hide/show the statusbar according to bSetVisible
3235 implts_showStatusBar();
3237 implts_hideStatusBar();
3241 WriteGuard
aWriteLock( m_aLock
);
3242 m_bDoLayout
= sal_False
;
3247 implts_createNonContextSensitiveToolBars();
3252 // Set docking area window size to zero
3253 ReadGuard
aReadLock2( m_aLock
);
3254 Reference
< css::awt::XWindow
> xTopDockingWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_TOP
];
3255 Reference
< css::awt::XWindow
> xLeftDockingWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_LEFT
];
3256 Reference
< css::awt::XWindow
> xRightDockingWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_RIGHT
];
3257 Reference
< css::awt::XWindow
> xBottomDockingWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_BOTTOM
];
3258 aReadLock2
.unlock();
3262 if ( xTopDockingWindow
.is() )
3263 xTopDockingWindow
->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE
);
3264 if ( xLeftDockingWindow
.is() )
3265 xLeftDockingWindow
->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE
);
3266 if ( xRightDockingWindow
.is() )
3267 xRightDockingWindow
->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE
);
3268 if ( xBottomDockingWindow
.is() )
3269 xBottomDockingWindow
->setPosSize( 0, 0, 0, 0, css::awt::PosSize::POSSIZE
);
3271 WriteGuard
aWriteLock( m_aLock
);
3272 m_aDockingArea
= css::awt::Rectangle();
3273 m_bMustDoLayout
= sal_True
;
3274 aWriteLock
.unlock();
3276 catch ( Exception
& )
3282 void LayoutManager::implts_setCurrentUIVisibility( sal_Bool bShow
)
3284 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3285 WriteGuard
aWriteLock( m_aLock
);
3286 UIElementVector::iterator pIter
;
3287 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
3289 if ( !bShow
&& pIter
->m_bVisible
&& pIter
->m_xUIElement
.is() )
3290 pIter
->m_bMasterHide
= true;
3291 else if ( bShow
&& pIter
->m_bMasterHide
)
3292 pIter
->m_bMasterHide
= false;
3295 if ( !bShow
&& m_aStatusBarElement
.m_bVisible
&& m_aStatusBarElement
.m_xUIElement
.is() )
3296 m_aStatusBarElement
.m_bMasterHide
= true;
3297 else if ( bShow
&& m_aStatusBarElement
.m_bVisible
)
3298 m_aStatusBarElement
.m_bMasterHide
= false;
3299 aWriteLock
.unlock();
3300 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3302 implts_updateUIElementsVisibleState( bShow
);
3305 void LayoutManager::implts_destroyStatusBar()
3307 Reference
< XComponent
> xCompStatusBar
;
3309 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3310 WriteGuard
aWriteLock( m_aLock
);
3311 m_aStatusBarElement
.m_aName
= rtl::OUString();
3312 xCompStatusBar
= Reference
< XComponent
>( m_aStatusBarElement
.m_xUIElement
, UNO_QUERY
);
3313 m_aStatusBarElement
.m_xUIElement
.clear();
3314 aWriteLock
.unlock();
3315 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3317 if ( xCompStatusBar
.is() )
3318 xCompStatusBar
->dispose();
3320 implts_destroyProgressBar();
3323 void LayoutManager::implts_createStatusBar( const rtl::OUString
& aStatusBarName
)
3325 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3326 WriteGuard
aWriteLock( m_aLock
);
3327 if ( !m_aStatusBarElement
.m_xUIElement
.is() )
3329 implts_readStatusBarState( aStatusBarName
);
3330 m_aStatusBarElement
.m_aName
= aStatusBarName
;
3331 m_aStatusBarElement
.m_xUIElement
= implts_createElement( aStatusBarName
);
3334 implts_createProgressBar();
3335 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3338 void LayoutManager::implts_readStatusBarState( const rtl::OUString
& rStatusBarName
)
3340 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3341 WriteGuard
aWriteLock( m_aLock
);
3342 if ( !m_aStatusBarElement
.m_bStateRead
)
3344 // Read persistent data for status bar if not yet read!
3345 if ( implts_readWindowStateData( rStatusBarName
, m_aStatusBarElement
))
3346 m_aStatusBarElement
.m_bStateRead
= sal_True
;
3348 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3351 void LayoutManager::implts_createProgressBar()
3353 Reference
< XUIElement
> xStatusBar
;
3354 Reference
< XUIElement
> xProgressBar
;
3355 Reference
< XUIElement
> xProgressBarBackup
;
3356 Reference
< css::awt::XWindow
> xContainerWindow
;
3358 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3359 WriteGuard
aWriteLock( m_aLock
);
3360 xStatusBar
= Reference
< XUIElement
>( m_aStatusBarElement
.m_xUIElement
, UNO_QUERY
);
3361 xProgressBar
= Reference
< XUIElement
>( m_aProgressBarElement
.m_xUIElement
, UNO_QUERY
);
3362 xProgressBarBackup
= m_xProgressBarBackup
;
3363 m_xProgressBarBackup
.clear();
3364 xContainerWindow
= m_xContainerWindow
;
3365 aWriteLock
.unlock();
3366 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3368 sal_Bool bRecycled
= xProgressBarBackup
.is();
3369 ProgressBarWrapper
* pWrapper
= 0;
3371 pWrapper
= (ProgressBarWrapper
*)xProgressBarBackup
.get();
3372 else if ( xProgressBar
.is() )
3373 pWrapper
= (ProgressBarWrapper
*)xProgressBar
.get();
3375 pWrapper
= new ProgressBarWrapper();
3377 if ( xStatusBar
.is() )
3379 Reference
< css::awt::XWindow
> xWindow( xStatusBar
->getRealInterface(), UNO_QUERY
);
3380 pWrapper
->setStatusBar( xWindow
);
3384 Reference
< css::awt::XWindow
> xStatusBarWindow
= pWrapper
->getStatusBar();
3386 vos::OGuard
aGuard( Application::GetSolarMutex() );
3387 Window
* pStatusBarWnd
= VCLUnoHelper::GetWindow( xStatusBarWindow
);
3388 if ( !pStatusBarWnd
)
3390 Window
* pWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
3393 StatusBar
* pStatusBar
= new StatusBar( pWindow
, WinBits( WB_LEFT
| WB_3DLOOK
) );
3394 Reference
< css::awt::XWindow
> xStatusBarWindow2( VCLUnoHelper::GetInterface( pStatusBar
));
3395 pWrapper
->setStatusBar( xStatusBarWindow2
, sal_True
);
3400 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3402 m_aProgressBarElement
.m_xUIElement
= Reference
< XUIElement
>(
3403 static_cast< cppu::OWeakObject
* >( pWrapper
), UNO_QUERY
);
3404 aWriteLock
.unlock();
3405 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3408 implts_showProgressBar();
3411 void LayoutManager::implts_backupProgressBarWrapper()
3413 // SAFE -> ----------------------------------
3414 WriteGuard
aWriteLock(m_aLock
);
3416 if (m_xProgressBarBackup
.is())
3419 // safe a backup copy of the current progress!
3420 // This copy will be used automaticly inside createProgressBar() which is called
3421 // implictly from implts_doLayout() .-)
3422 m_xProgressBarBackup
= m_aProgressBarElement
.m_xUIElement
;
3424 // remove the relation between this old progress bar and our old status bar.
3425 // Otherwhise we work on disposed items ...
3426 // The internal used ProgressBarWrapper can handle a NULL reference.
3427 if ( m_xProgressBarBackup
.is() )
3429 ProgressBarWrapper
* pWrapper
= (ProgressBarWrapper
*)m_xProgressBarBackup
.get();
3431 pWrapper
->setStatusBar( Reference
< css::awt::XWindow
>(), sal_False
);
3434 // prevent us from dispose() the m_aProgressBarElement.m_xUIElement inside implts_reset()
3435 m_aProgressBarElement
.m_xUIElement
.clear();
3437 aWriteLock
.unlock();
3438 // <- SAFE ----------------------------------
3441 void LayoutManager::implts_destroyProgressBar()
3443 // dont remove the progressbar in general
3444 // We must reuse it if a new status bar is created later.
3445 // Of course there exists one backup only.
3446 // And further this backup will be released inside our dtor.
3447 implts_backupProgressBarWrapper();
3450 void LayoutManager::implts_setStatusBarPosSize( const ::Point
& rPos
, const ::Size
& rSize
)
3452 Reference
< XUIElement
> xStatusBar
;
3453 Reference
< XUIElement
> xProgressBar
;
3454 Reference
< css::awt::XWindow
> xContainerWindow
;
3456 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3457 ReadGuard
aReadLock( m_aLock
);
3458 xStatusBar
= Reference
< XUIElement
>( m_aStatusBarElement
.m_xUIElement
, UNO_QUERY
);
3459 xProgressBar
= Reference
< XUIElement
>( m_aProgressBarElement
.m_xUIElement
, UNO_QUERY
);
3460 xContainerWindow
= m_xContainerWindow
;
3462 Reference
< css::awt::XWindow
> xWindow
;
3463 if ( xStatusBar
.is() )
3464 xWindow
= Reference
< css::awt::XWindow
>( xStatusBar
->getRealInterface(), UNO_QUERY
);
3465 else if ( xProgressBar
.is() )
3467 ProgressBarWrapper
* pWrapper
= (ProgressBarWrapper
*)xProgressBar
.get();
3469 xWindow
= pWrapper
->getStatusBar();
3472 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3476 vos::OGuard
aGuard( Application::GetSolarMutex() );
3477 Window
* pParentWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
3478 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
3479 if ( pParentWindow
&& ( pWindow
&& pWindow
->GetType() == WINDOW_STATUSBAR
))
3481 Window
* pOldParentWindow
= pWindow
->GetParent();
3482 if ( pParentWindow
!= pOldParentWindow
)
3483 pWindow
->SetParent( pParentWindow
);
3484 ((StatusBar
*)pWindow
)->SetPosSizePixel( rPos
, rSize
);
3489 sal_Bool
LayoutManager::implts_showProgressBar()
3491 Reference
< XUIElement
> xStatusBar
;
3492 Reference
< XUIElement
> xProgressBar
;
3493 Reference
< css::awt::XWindow
> xWindow
;
3495 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3496 WriteGuard
aWriteLock( m_aLock
);
3497 xStatusBar
= Reference
< XUIElement
>( m_aStatusBarElement
.m_xUIElement
, UNO_QUERY
);
3498 xProgressBar
= Reference
< XUIElement
>( m_aProgressBarElement
.m_xUIElement
, UNO_QUERY
);
3499 sal_Bool
bVisible( m_bVisible
);
3501 m_aProgressBarElement
.m_bVisible
= sal_True
;
3504 if ( xStatusBar
.is() && !m_aStatusBarElement
.m_bMasterHide
)
3506 xWindow
= Reference
< css::awt::XWindow
>( xStatusBar
->getRealInterface(), UNO_QUERY
);
3508 else if ( xProgressBar
.is() )
3510 ProgressBarWrapper
* pWrapper
= (ProgressBarWrapper
*)xProgressBar
.get();
3512 xWindow
= pWrapper
->getStatusBar();
3515 aWriteLock
.unlock();
3517 vos::OGuard
aGuard( Application::GetSolarMutex() );
3518 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
3521 if ( !pWindow
->IsVisible() )
3532 sal_Bool
LayoutManager::implts_hideProgressBar()
3534 Reference
< XUIElement
> xProgressBar
;
3535 Reference
< css::awt::XWindow
> xWindow
;
3536 sal_Bool
bHideStatusBar( sal_False
);
3538 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3539 WriteGuard
aWriteLock( m_aLock
);
3540 xProgressBar
= Reference
< XUIElement
>( m_aProgressBarElement
.m_xUIElement
, UNO_QUERY
);
3542 sal_Bool
bInternalStatusBar( sal_False
);
3543 if ( xProgressBar
.is() )
3545 Reference
< css::awt::XWindow
> xStatusBar
;
3546 ProgressBarWrapper
* pWrapper
= (ProgressBarWrapper
*)xProgressBar
.get();
3548 xWindow
= pWrapper
->getStatusBar();
3549 Reference
< css::ui::XUIElement
> xStatusBarElement
= m_aStatusBarElement
.m_xUIElement
;
3550 if ( xStatusBarElement
.is() )
3551 xStatusBar
= Reference
< css::awt::XWindow
>( xStatusBarElement
->getRealInterface(), UNO_QUERY
);
3552 bInternalStatusBar
= xStatusBar
!= xWindow
;
3554 m_aProgressBarElement
.m_bVisible
= sal_False
;
3555 implts_readStatusBarState( m_aStatusBarAlias
);
3556 bHideStatusBar
= !m_aStatusBarElement
.m_bVisible
;
3557 aWriteLock
.unlock();
3559 vos::OGuard
aGuard( Application::GetSolarMutex() );
3560 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
3561 if ( pWindow
&& pWindow
->IsVisible() &&
3562 ( bHideStatusBar
|| bInternalStatusBar
))
3572 sal_Bool
LayoutManager::implts_showStatusBar( sal_Bool bStoreState
)
3574 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3575 WriteGuard
aWriteLock( m_aLock
);
3576 Reference
< css::ui::XUIElement
> xStatusBar
= m_aStatusBarElement
.m_xUIElement
;
3578 m_aStatusBarElement
.m_bVisible
= sal_True
;
3579 aWriteLock
.unlock();
3580 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3582 if ( xStatusBar
.is() )
3584 Reference
< css::awt::XWindow
> xWindow( xStatusBar
->getRealInterface(), UNO_QUERY
);
3586 vos::OGuard
aGuard( Application::GetSolarMutex() );
3587 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
3588 if ( pWindow
&& !pWindow
->IsVisible() )
3598 sal_Bool
LayoutManager::implts_hideStatusBar( sal_Bool bStoreState
)
3600 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3601 WriteGuard
aWriteLock( m_aLock
);
3602 Reference
< css::ui::XUIElement
> xStatusBar
= m_aStatusBarElement
.m_xUIElement
;
3604 m_aStatusBarElement
.m_bVisible
= sal_False
;
3605 aWriteLock
.unlock();
3606 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3608 if ( xStatusBar
.is() )
3610 Reference
< css::awt::XWindow
> xWindow( xStatusBar
->getRealInterface(), UNO_QUERY
);
3612 vos::OGuard
aGuard( Application::GetSolarMutex() );
3613 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
3614 if ( pWindow
&& pWindow
->IsVisible() )
3624 void LayoutManager::implts_setInplaceMenuBar( const Reference
< XIndexAccess
>& xMergedMenuBar
)
3625 throw (::com::sun::star::uno::RuntimeException
)
3627 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3628 WriteGuard
aWriteLock( m_aLock
);
3630 if ( !m_bInplaceMenuSet
)
3632 vos::OGuard
aGuard( Application::GetSolarMutex() );
3634 // Reset old inplace menubar!
3635 m_pInplaceMenuBar
= 0;
3636 if ( m_xInplaceMenuBar
.is() )
3637 m_xInplaceMenuBar
->dispose();
3638 m_xInplaceMenuBar
.clear();
3639 m_bInplaceMenuSet
= sal_False
;
3641 if ( m_xFrame
.is() &&
3642 m_xContainerWindow
.is() )
3644 rtl::OUString aModuleIdentifier
;
3645 Reference
< XDispatchProvider
> xDispatchProvider
;
3647 MenuBar
* pMenuBar
= new MenuBar
;
3648 m_pInplaceMenuBar
= new MenuBarManager( m_xSMGR
, m_xFrame
, m_xURLTransformer
,xDispatchProvider
, aModuleIdentifier
, pMenuBar
, sal_True
, sal_True
);
3649 m_pInplaceMenuBar
->SetItemContainer( xMergedMenuBar
);
3651 Window
* pWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
3652 while ( pWindow
&& !pWindow
->IsSystemWindow() )
3653 pWindow
= pWindow
->GetParent();
3657 SystemWindow
* pSysWindow
= (SystemWindow
*)pWindow
;
3658 pSysWindow
->SetMenuBar( pMenuBar
);
3661 m_bInplaceMenuSet
= sal_True
;
3662 m_xInplaceMenuBar
= Reference
< XComponent
>( (OWeakObject
*)m_pInplaceMenuBar
, UNO_QUERY
);
3665 aWriteLock
.unlock();
3666 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3667 implts_updateMenuBarClose();
3672 void LayoutManager::implts_resetInplaceMenuBar()
3673 throw (::com::sun::star::uno::RuntimeException
)
3675 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3676 WriteGuard
aWriteLock( m_aLock
);
3677 m_bInplaceMenuSet
= sal_False
;
3679 // if ( m_xMenuBar.is() &&
3680 if ( m_xContainerWindow
.is() )
3682 vos::OGuard
aGuard( Application::GetSolarMutex() );
3683 MenuBarWrapper
* pMenuBarWrapper
= SAL_STATIC_CAST( MenuBarWrapper
*, m_xMenuBar
.get() );
3684 Window
* pWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
3685 while ( pWindow
&& !pWindow
->IsSystemWindow() )
3686 pWindow
= pWindow
->GetParent();
3690 SystemWindow
* pSysWindow
= (SystemWindow
*)pWindow
;
3691 if ( pMenuBarWrapper
)
3692 pSysWindow
->SetMenuBar( (MenuBar
*)pMenuBarWrapper
->GetMenuBarManager()->GetMenuBar() );
3694 pSysWindow
->SetMenuBar( 0 );
3698 // Remove inplace menu bar
3699 m_pInplaceMenuBar
= 0;
3700 if ( m_xInplaceMenuBar
.is() )
3701 m_xInplaceMenuBar
->dispose();
3702 m_xInplaceMenuBar
.clear();
3704 aWriteLock
.unlock();
3705 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3708 void SAL_CALL
LayoutManager::attachFrame( const Reference
< XFrame
>& xFrame
)
3709 throw (::com::sun::star::uno::RuntimeException
)
3711 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3712 WriteGuard
aWriteLock( m_aLock
);
3714 aWriteLock
.unlock();
3715 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3716 // if ( xFrame.is() )
3717 // xFrame->getContainerWindow()->addWindowListener( Reference< css::awt::XWindowListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ));
3720 void SAL_CALL
LayoutManager::reset()
3721 throw (RuntimeException
)
3723 sal_Bool
bComponentAttached( sal_False
);
3725 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3726 ReadGuard
aReadLock( m_aLock
);
3727 bComponentAttached
= m_bComponentAttached
;
3730 implts_reset( sal_True
);
3733 void SAL_CALL
LayoutManager::setInplaceMenuBar( sal_Int64
)
3734 throw (::com::sun::star::uno::RuntimeException
)
3736 OSL_ENSURE( sal_False
, "This method is obsolete and should not be used!\n" );
3739 void SAL_CALL
LayoutManager::resetInplaceMenuBar()
3740 throw (::com::sun::star::uno::RuntimeException
)
3742 OSL_ENSURE( sal_False
, "This method is obsolete and should not be used!\n" );
3745 //---------------------------------------------------------------------------------------------------------
3746 // XMenuBarMergingAcceptor
3747 //---------------------------------------------------------------------------------------------------------
3748 sal_Bool SAL_CALL
LayoutManager::setMergedMenuBar(
3749 const Reference
< XIndexAccess
>& xMergedMenuBar
)
3750 throw (::com::sun::star::uno::RuntimeException
)
3752 implts_setInplaceMenuBar( xMergedMenuBar
);
3755 implts_notifyListeners( css::frame::LayoutManagerEvents::MERGEDMENUBAR
, a
);
3759 void SAL_CALL
LayoutManager::removeMergedMenuBar()
3760 throw (::com::sun::star::uno::RuntimeException
)
3762 implts_resetInplaceMenuBar();
3765 ::com::sun::star::awt::Rectangle SAL_CALL
LayoutManager::getCurrentDockingArea()
3766 throw ( RuntimeException
)
3768 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3769 ReadGuard
aReadLock( m_aLock
);
3770 return m_aDockingArea
;
3773 Reference
< XDockingAreaAcceptor
> SAL_CALL
LayoutManager::getDockingAreaAcceptor()
3774 throw (::com::sun::star::uno::RuntimeException
)
3776 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3777 ReadGuard
aReadLock( m_aLock
);
3778 return m_xDockingAreaAcceptor
;
3781 void SAL_CALL
LayoutManager::setDockingAreaAcceptor( const Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
>& xDockingAreaAcceptor
)
3782 throw ( RuntimeException
)
3784 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3785 WriteGuard
aWriteLock( m_aLock
);
3787 if (( m_xDockingAreaAcceptor
== xDockingAreaAcceptor
) ||
3791 // IMPORTANT: Be sure to stop layout timer if don't have a docking area acceptor!
3792 if ( !xDockingAreaAcceptor
.is() )
3793 m_aAsyncLayoutTimer
.Stop();
3795 sal_Bool
bAutomaticToolbars( m_bAutomaticToolbars
);
3796 std::vector
< Reference
< css::awt::XWindow
> > oldDockingAreaWindows
;
3798 if ( !xDockingAreaAcceptor
.is() )
3799 m_aAsyncLayoutTimer
.Stop();
3801 // Remove listener from old docking area acceptor
3802 if ( m_xDockingAreaAcceptor
.is() )
3804 Reference
< css::awt::XWindow
> xWindow( m_xDockingAreaAcceptor
->getContainerWindow() );
3805 if ( xWindow
.is() && ( m_xFrame
->getContainerWindow() != m_xContainerWindow
|| !xDockingAreaAcceptor
.is() ) )
3806 xWindow
->removeWindowListener( Reference
< css::awt::XWindowListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
3808 oldDockingAreaWindows
.push_back( m_xDockAreaWindows
[DockingArea_DOCKINGAREA_TOP
] );
3809 oldDockingAreaWindows
.push_back( m_xDockAreaWindows
[DockingArea_DOCKINGAREA_BOTTOM
] );
3810 oldDockingAreaWindows
.push_back( m_xDockAreaWindows
[DockingArea_DOCKINGAREA_LEFT
] );
3811 oldDockingAreaWindows
.push_back( m_xDockAreaWindows
[DockingArea_DOCKINGAREA_RIGHT
] );
3813 m_xDockAreaWindows
[DockingArea_DOCKINGAREA_TOP
].clear();
3814 m_xDockAreaWindows
[DockingArea_DOCKINGAREA_BOTTOM
].clear();
3815 m_xDockAreaWindows
[DockingArea_DOCKINGAREA_LEFT
].clear();
3816 m_xDockAreaWindows
[DockingArea_DOCKINGAREA_RIGHT
].clear();
3817 m_aDockingArea
= css::awt::Rectangle();
3819 Window
* pContainerWindow
= VCLUnoHelper::GetWindow( xWindow
);
3820 if ( pContainerWindow
)
3821 pContainerWindow
->RemoveChildEventListener( LINK( this, LayoutManager
, WindowEventListener
) );
3824 // Set new docking area acceptor and add ourself as window listener on the container window.
3825 // Create our docking area windows which are parents for all docked windows.
3826 css::uno::Reference
< css::awt::XWindow
> xTopDockWindow
;
3827 css::uno::Reference
< css::awt::XWindow
> xBottomDockWindow
;
3828 css::uno::Reference
< css::awt::XWindow
> xLeftDockWindow
;
3829 css::uno::Reference
< css::awt::XWindow
> xRightDockWindow
;
3831 Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
> xOldDockingAreaAcceptor( m_xDockingAreaAcceptor
);
3832 m_xDockingAreaAcceptor
= xDockingAreaAcceptor
;
3833 if ( m_xDockingAreaAcceptor
.is() )
3835 m_aDockingArea
= css::awt::Rectangle();
3836 m_xContainerWindow
= m_xDockingAreaAcceptor
->getContainerWindow();
3837 m_xContainerWindow
->addWindowListener( Reference
< css::awt::XWindowListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
3839 // we always must keep a connection to the window of our frame for resize events
3840 if ( m_xContainerWindow
!= m_xFrame
->getContainerWindow() )
3841 m_xFrame
->getContainerWindow()->addWindowListener( Reference
< css::awt::XWindowListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
3843 // #i37884# set initial visibility state - in the plugin case the container window is already shown
3844 // and we get no notification anymore
3846 vos::OGuard
aGuard( Application::GetSolarMutex() );
3847 Window
* pContainerWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
3848 if( pContainerWindow
)
3849 m_bParentWindowVisible
= pContainerWindow
->IsVisible();
3852 css::uno::Reference
< css::awt::XWindowPeer
> xParent( m_xContainerWindow
, UNO_QUERY
);
3853 xTopDockWindow
= Reference
< css::awt::XWindow
>( implts_createToolkitWindow( xParent
), UNO_QUERY
);
3854 xBottomDockWindow
= Reference
< css::awt::XWindow
>( implts_createToolkitWindow( xParent
), UNO_QUERY
);
3855 xLeftDockWindow
= Reference
< css::awt::XWindow
>( implts_createToolkitWindow( xParent
), UNO_QUERY
);
3856 xRightDockWindow
= Reference
< css::awt::XWindow
>( implts_createToolkitWindow( xParent
), UNO_QUERY
);
3857 m_xDockAreaWindows
[DockingArea_DOCKINGAREA_TOP
] = xTopDockWindow
;
3858 m_xDockAreaWindows
[DockingArea_DOCKINGAREA_BOTTOM
] = xBottomDockWindow
;
3859 m_xDockAreaWindows
[DockingArea_DOCKINGAREA_LEFT
] = xLeftDockWindow
;
3860 m_xDockAreaWindows
[DockingArea_DOCKINGAREA_RIGHT
] = xRightDockWindow
;
3863 aWriteLock
.unlock();
3864 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3866 if ( xDockingAreaAcceptor
.is() )
3868 vos::OGuard
aGuard( Application::GetSolarMutex() );
3869 ::DockingAreaWindow
* pWindow
;
3870 pWindow
= dynamic_cast< ::DockingAreaWindow
* >(VCLUnoHelper::GetWindow( xTopDockWindow
) );
3871 if( pWindow
) pWindow
->SetAlign( WINDOWALIGN_TOP
);
3872 pWindow
= dynamic_cast< ::DockingAreaWindow
* >(VCLUnoHelper::GetWindow( xBottomDockWindow
) );
3873 if( pWindow
) pWindow
->SetAlign( WINDOWALIGN_BOTTOM
);
3874 pWindow
= dynamic_cast< ::DockingAreaWindow
* >(VCLUnoHelper::GetWindow( xLeftDockWindow
) );
3875 if( pWindow
) pWindow
->SetAlign( WINDOWALIGN_LEFT
);
3876 pWindow
= dynamic_cast< ::DockingAreaWindow
* >(VCLUnoHelper::GetWindow( xRightDockWindow
) );
3877 if( pWindow
) pWindow
->SetAlign( WINDOWALIGN_RIGHT
);
3879 // Add layout manager as listener to get notifications about toolbar button activties
3880 Window
* pContainerWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
3881 if ( pContainerWindow
)
3882 pContainerWindow
->AddChildEventListener( LINK( this, LayoutManager
, WindowEventListener
) );
3884 // We have now a new container window, reparent all child windows!
3885 implts_reparentChildWindows();
3888 implts_destroyElements(); // remove all elements
3890 if ( !oldDockingAreaWindows
.empty() )
3892 const sal_uInt32 nCount
= oldDockingAreaWindows
.size();
3893 for ( sal_uInt32 i
= 0; i
< nCount
; ++i
)
3895 if ( oldDockingAreaWindows
[i
].is() )
3899 oldDockingAreaWindows
[i
]->dispose();
3901 catch ( Exception
& )
3907 // Reset docking area size for our old docking area acceptor
3908 css::awt::Rectangle aEmptyRect
;
3909 xOldDockingAreaAcceptor
->setDockingAreaSpace( aEmptyRect
);
3912 if ( xDockingAreaAcceptor
.is() )
3914 if ( bAutomaticToolbars
)
3916 implts_createAddonsToolBars(); // create addon toolbars
3917 implts_createCustomToolBars(); // create custom toolbars
3918 implts_createNonContextSensitiveToolBars();
3920 implts_sortUIElements();
3921 implts_doLayout( sal_True
);
3925 void LayoutManager::implts_reparentChildWindows()
3927 UIElementVector aUIElementVector
;
3928 UIElement aStatusBarElement
;
3929 css::uno::Reference
< css::awt::XWindow
> xTopDockWindow
;
3930 css::uno::Reference
< css::awt::XWindow
> xBottomDockWindow
;
3931 css::uno::Reference
< css::awt::XWindow
> xLeftDockWindow
;
3932 css::uno::Reference
< css::awt::XWindow
> xRightDockWindow
;
3933 css::uno::Reference
< css::awt::XWindow
> xContainerWindow
;
3934 css::uno::Reference
< css::awt::XWindow
> xStatusBarWindow
;
3936 WriteGuard
aWriteLock( m_aLock
);
3937 aUIElementVector
= m_aUIElements
;
3938 xTopDockWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_TOP
];
3939 xBottomDockWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_BOTTOM
];
3940 xLeftDockWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_LEFT
];
3941 xRightDockWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_RIGHT
];
3942 xContainerWindow
= m_xContainerWindow
;
3943 aStatusBarElement
= m_aStatusBarElement
;
3944 aWriteLock
.unlock();
3946 if ( aStatusBarElement
.m_xUIElement
.is() )
3950 xStatusBarWindow
= Reference
< css::awt::XWindow
>(
3951 aStatusBarElement
.m_xUIElement
->getRealInterface(),
3954 catch ( RuntimeException
& )
3958 catch ( Exception
& )
3963 vos::OGuard
aGuard( Application::GetSolarMutex() );
3964 Window
* pContainerWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
3965 Window
* pTopDockWindow
= VCLUnoHelper::GetWindow( xTopDockWindow
);
3966 Window
* pBottomDockWindow
= VCLUnoHelper::GetWindow( xBottomDockWindow
);
3967 Window
* pLeftDockWindow
= VCLUnoHelper::GetWindow( xLeftDockWindow
);
3968 Window
* pRightDockWindow
= VCLUnoHelper::GetWindow( xRightDockWindow
);
3969 if ( pContainerWindow
)
3971 UIElementVector::iterator pIter
;
3972 for ( pIter
= aUIElementVector
.begin(); pIter
!= aUIElementVector
.end(); pIter
++ )
3974 Reference
< XUIElement
> xUIElement( pIter
->m_xUIElement
);
3975 if ( xUIElement
.is() )
3977 Reference
< css::awt::XWindow
> xWindow
;
3980 // We have to retreive the window reference with try/catch as it is
3981 // possible that all elements has been disposed!
3982 xWindow
= Reference
< css::awt::XWindow
>( xUIElement
->getRealInterface(), UNO_QUERY
);
3984 catch ( RuntimeException
& )
3988 catch ( Exception
& )
3992 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
3995 // Reparent our child windows acording to their current state.
3996 if ( pIter
->m_bFloating
)
3997 pWindow
->SetParent( pContainerWindow
);
4000 if ( pIter
->m_aDockedData
.m_nDockedArea
== DockingArea_DOCKINGAREA_TOP
)
4001 pWindow
->SetParent( pTopDockWindow
);
4002 else if ( pIter
->m_aDockedData
.m_nDockedArea
== DockingArea_DOCKINGAREA_BOTTOM
)
4003 pWindow
->SetParent( pBottomDockWindow
);
4004 else if ( pIter
->m_aDockedData
.m_nDockedArea
== DockingArea_DOCKINGAREA_LEFT
)
4005 pWindow
->SetParent( pLeftDockWindow
);
4007 pWindow
->SetParent( pRightDockWindow
);
4013 if ( xStatusBarWindow
.is() )
4015 Window
* pWindow
= VCLUnoHelper::GetWindow( xStatusBarWindow
);
4017 pWindow
->SetParent( pContainerWindow
);
4020 implts_resetMenuBar();
4024 IMPL_LINK( LayoutManager
, WindowEventListener
, VclSimpleEvent
*, pEvent
)
4026 // To enable toolbar controllers to change their image when a sub-toolbar function
4027 // is activated, we need this mechanism. We have NO connection between these toolbars
4029 if ( pEvent
&& pEvent
->ISA( VclWindowEvent
))
4031 if ( pEvent
->GetId() == VCLEVENT_TOOLBOX_SELECT
)
4033 Window
* pWindow( ((VclWindowEvent
*)pEvent
)->GetWindow() );
4034 ToolBox
* pToolBox( 0 );
4035 rtl::OUString aToolbarName
;
4036 rtl::OUString aCommand
;
4038 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
4040 pToolBox
= (ToolBox
*)pWindow
;
4041 aToolbarName
= pToolBox
->GetSmartHelpId().GetStr();
4042 sal_Int32 i
= aToolbarName
.lastIndexOf( ':' );
4043 if (( aToolbarName
.getLength() > 0 ) &&
4044 ( i
> 0 ) && (( i
+ 1 ) < aToolbarName
.getLength() ))
4046 // Remove ".HelpId:" protocol from toolbar name
4047 aToolbarName
= aToolbarName
.copy( i
+1 );
4049 USHORT nId
= pToolBox
->GetCurItemId();
4051 aCommand
= pToolBox
->GetItemCommand( nId
);
4055 if (( aToolbarName
.getLength() > 0 ) && ( aCommand
.getLength() > 0 ))
4057 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4058 ReadGuard
aReadLock( m_aLock
);
4059 std::vector
< css::uno::Reference
< css::ui::XUIFunctionListener
> > aListenerArray
;
4060 UIElementVector::iterator pIter
;
4062 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
4064 if ( pIter
->m_aType
.equalsAscii( "toolbar" ) &&
4065 pIter
->m_xUIElement
.is() )
4067 css::uno::Reference
< css::ui::XUIFunctionListener
> xListener( pIter
->m_xUIElement
, UNO_QUERY
);
4068 if ( xListener
.is() )
4069 aListenerArray
.push_back( xListener
);
4073 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4075 const sal_uInt32 nCount
= aListenerArray
.size();
4076 for ( sal_uInt32 i
= 0; i
< nCount
; ++i
)
4080 aListenerArray
[i
]->functionExecute( aToolbarName
, aCommand
);
4082 catch ( RuntimeException
& e
)
4086 catch ( Exception
& ) {}
4090 else if ( pEvent
->GetId() == VCLEVENT_TOOLBOX_FORMATCHANGED
)
4092 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4093 ReadGuard
aReadLock( m_aLock
);
4095 Window
* pWindow( ((VclWindowEvent
*)pEvent
)->GetWindow() );
4096 ToolBox
* pToolBox( 0 );
4097 rtl::OUString aToolbarName
;
4099 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
4101 pToolBox
= (ToolBox
*)pWindow
;
4102 aToolbarName
= pToolBox
->GetSmartHelpId().GetStr();
4103 if (( aToolbarName
.getLength() > 0 ) && ( m_nLockCount
== 0 ))
4104 m_aAsyncLayoutTimer
.Start();
4106 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4113 void SAL_CALL
LayoutManager::createElement( const ::rtl::OUString
& aName
)
4114 throw (RuntimeException
)
4116 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::createElement" );
4118 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4119 ReadGuard
aReadLock( m_aLock
);
4120 Reference
< XFrame
> xFrame
= m_xFrame
;
4121 Reference
< XURLTransformer
> xURLTransformer
= m_xURLTransformer
;
4122 sal_Bool bInPlaceMenu
= m_bInplaceMenuSet
;
4124 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4129 Reference
< XModel
> xModel( impl_getModelFromFrame( xFrame
) );
4131 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4132 WriteGuard
aWriteLock( m_aLock
);
4134 sal_Bool
bFound( sal_False
);
4135 sal_Bool
bNotify( sal_False
);
4136 ::rtl::OUString aElementType
;
4137 ::rtl::OUString aElementName
;
4138 Reference
< ::com::sun::star::ui::XUIElement
> xUIElement
;
4140 implts_findElement( aName
, aElementType
, aElementName
, xUIElement
);
4141 bFound
= xUIElement
.is();
4143 if ( /*xFrame.is() && */m_xContainerWindow
.is() && !implts_isPreviewModel( xModel
) ) // no bars on preview mode
4145 if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4149 SvtCommandOptions aCmdOptions
;
4151 xUIElement
= implts_createElement( aName
);
4152 sal_Bool
bVisible( sal_False
);
4153 if ( xUIElement
.is() )
4155 Reference
< css::awt::XWindow
> xWindow( xUIElement
->getRealInterface(), UNO_QUERY
);
4156 Reference
< css::awt::XDockableWindow
> xDockWindow( xUIElement
->getRealInterface(), UNO_QUERY
);
4157 if ( xDockWindow
.is() && xWindow
.is() )
4161 xDockWindow
->addDockableWindowListener( Reference
< css::awt::XDockableWindowListener
>(
4162 static_cast< OWeakObject
* >( this ), UNO_QUERY
));
4163 xWindow
->addWindowListener( Reference
< css::awt::XWindowListener
>(
4164 static_cast< OWeakObject
* >( this ), UNO_QUERY
));
4165 xDockWindow
->enableDocking( sal_True
);
4167 catch ( Exception
& )
4172 UIElement
& rElement
= impl_findElement( aName
);
4173 if ( rElement
.m_aName
.getLength() > 0 )
4175 // Reuse a local entry so we are able to use the latest
4176 // UI changes for this document.
4177 implts_setElementData( rElement
, xDockWindow
);
4178 rElement
.m_xUIElement
= xUIElement
;
4179 bVisible
= rElement
.m_bVisible
;
4183 // Create new UI element and try to read its state data
4184 UIElement
aNewToolbar( aName
, aElementType
, xUIElement
);
4185 implts_readWindowStateData( aName
, aNewToolbar
);
4186 implts_setElementData( aNewToolbar
, xDockWindow
);
4187 implts_insertUIElement( aNewToolbar
);
4188 bVisible
= aNewToolbar
.m_bVisible
;
4191 // set toolbar menu style according to customize command state
4192 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
4193 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
4195 ToolBox
* pToolbar
= (ToolBox
*)pWindow
;
4196 USHORT nMenuType
= pToolbar
->GetMenuType();
4197 if ( aCmdOptions
.Lookup( SvtCommandOptions::CMDOPTION_DISABLED
, m_aCustomizeCmd
))
4198 pToolbar
->SetMenuType( nMenuType
& ~TOOLBOX_MENUTYPE_CUSTOMIZE
);
4200 pToolbar
->SetMenuType( nMenuType
| TOOLBOX_MENUTYPE_CUSTOMIZE
);
4203 aWriteLock
.unlock();
4205 implts_sortUIElements();
4214 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "menubar" ))
4216 if ( aElementName
.equalsIgnoreAsciiCaseAscii( "menubar" ) && !bInPlaceMenu
)
4218 vos::OGuard
aGuard( Application::GetSolarMutex() );
4219 // PB 2004-12-15 #i38743# don't create a menubar if frame isn't top
4220 if ( !m_xMenuBar
.is() && implts_isFrameOrWindowTop(xFrame
) )
4221 m_xMenuBar
= implts_createElement( aName
);
4223 if ( m_xMenuBar
.is() && implts_isFrameOrWindowTop(xFrame
) )
4225 Window
* pWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
4226 while ( pWindow
&& !pWindow
->IsSystemWindow() )
4227 pWindow
= pWindow
->GetParent();
4231 SystemWindow
* pSysWindow
= (SystemWindow
*)pWindow
;
4232 Reference
< css::awt::XMenuBar
> xMenuBar
;
4234 Reference
< XPropertySet
> xPropSet( m_xMenuBar
, UNO_QUERY
);
4235 if ( xPropSet
.is() )
4239 xPropSet
->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XMenuBar" ))) >>= xMenuBar
;
4241 catch ( com::sun::star::beans::UnknownPropertyException
)
4244 catch ( com::sun::star::lang::WrappedTargetException
)
4249 if ( xMenuBar
.is() )
4251 VCLXMenu
* pAwtMenuBar
= VCLXMenu::GetImplementation( xMenuBar
);
4254 MenuBar
* pMenuBar
= (MenuBar
*)pAwtMenuBar
->GetMenu();
4257 pSysWindow
->SetMenuBar( pMenuBar
);
4258 pMenuBar
->SetDisplayable( m_bMenuVisible
);
4259 if ( m_bMenuVisible
)
4263 implts_updateMenuBarClose();
4270 aWriteLock
.unlock();
4272 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "statusbar" ) && ( implts_isFrameOrWindowTop(xFrame
) || implts_isEmbeddedLayoutManager() ))
4274 implts_createStatusBar( aName
);
4277 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4278 aElementName
.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4279 implts_isFrameOrWindowTop(xFrame
) )
4281 implts_createProgressBar();
4284 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4286 aWriteLock
.unlock();
4288 // The docking window is created by a factory method located in the sfx2 library.
4289 CreateDockingWindow( xFrame
, aElementName
);
4293 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4296 // UI element is invisible - provide information to listeners
4297 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_VISIBLE
, uno::makeAny( aName
) );
4301 void SAL_CALL
LayoutManager::destroyElement( const ::rtl::OUString
& aName
)
4302 throw (RuntimeException
)
4304 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::destroyElement" );
4306 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4307 WriteGuard
aWriteLock( m_aLock
);
4309 sal_Bool
bMustLayouted( sal_False
);
4310 sal_Bool
bMustBeDestroyed( sal_False
);
4311 sal_Bool
bMustBeSorted( sal_False
);
4312 sal_Bool
bNotify( sal_False
);
4313 ::rtl::OUString aElementType
;
4314 ::rtl::OUString aElementName
;
4316 Reference
< XComponent
> xComponent
;
4317 if ( impl_parseResourceURL( aName
, aElementType
, aElementName
))
4319 if ( aElementType
.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
4320 aElementName
.equalsIgnoreAsciiCaseAscii( "menubar" ))
4322 if ( !m_bInplaceMenuSet
)
4324 impl_clearUpMenuBar();
4329 else if (( aElementType
.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
4330 aElementName
.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
4331 ( m_aStatusBarElement
.m_aName
== aName
))
4333 aWriteLock
.unlock();
4334 implts_destroyStatusBar();
4335 bMustLayouted
= sal_True
;
4338 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4339 aElementName
.equalsIgnoreAsciiCaseAscii( "progressbar" ) )
4341 aWriteLock
.unlock();
4342 implts_createProgressBar();
4343 bMustLayouted
= sal_True
;
4346 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4348 UIElementVector::iterator pIter
;
4350 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
4352 if ( pIter
->m_aName
== aName
)
4354 xComponent
.set( pIter
->m_xUIElement
, UNO_QUERY
);
4355 Reference
< XUIElement
> xUIElement( pIter
->m_xUIElement
);
4356 if ( xUIElement
.is() )
4358 Reference
< css::awt::XWindow
> xWindow( xUIElement
->getRealInterface(), UNO_QUERY
);
4359 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
4361 rtl::OUString
aAddonTbResourceName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/addon_" ));
4362 if ( aName
.indexOf( aAddonTbResourceName
) != 0 )
4367 xWindow
->removeWindowListener( Reference
< css::awt::XWindowListener
>(
4368 static_cast< OWeakObject
* >( this ), UNO_QUERY
));
4376 if ( xDockWindow
.is() )
4377 xDockWindow
->removeDockableWindowListener( Reference
< css::awt::XDockableWindowListener
>(
4378 static_cast< OWeakObject
* >( this ), UNO_QUERY
));
4380 catch ( Exception
& )
4384 bMustBeDestroyed
= sal_True
;
4388 pIter
->m_bVisible
= sal_False
;
4389 xWindow
->setVisible( sal_False
);
4393 if ( !xDockWindow
->isFloating() )
4394 bMustLayouted
= sal_True
;
4395 if ( bMustBeDestroyed
)
4396 pIter
->m_xUIElement
.clear();
4398 bMustBeSorted
= sal_True
;
4405 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4407 css::uno::Reference
< css::frame::XFrame
> xFrame( m_xFrame
);
4408 css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR( m_xSMGR
);
4409 aWriteLock
.unlock();
4411 impl_setDockingWindowVisibility( xSMGR
, xFrame
, aElementName
, false );
4412 bMustLayouted
= sal_False
;
4413 bNotify
= sal_False
;
4416 aWriteLock
.unlock();
4417 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
4419 if ( bMustBeDestroyed
)
4421 if ( xComponent
.is() )
4422 xComponent
->dispose();
4426 if ( bMustBeSorted
)
4428 implts_sortUIElements();
4429 if ( bMustLayouted
)
4435 // UI element is invisible - provide information to listeners
4436 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_INVISIBLE
, uno::makeAny( aName
) );
4440 ::sal_Bool SAL_CALL
LayoutManager::requestElement( const ::rtl::OUString
& ResourceURL
)
4441 throw (::com::sun::star::uno::RuntimeException
)
4443 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::requestElement" );
4445 ::rtl::OUString aElementType
;
4446 ::rtl::OUString aElementName
;
4447 UIElementVector::iterator pIter
;
4448 sal_Bool
bResult( sal_False
);
4449 sal_Bool
bNotify( sal_False
);
4451 WriteGuard
aWriteLock( m_aLock
);
4452 if ( impl_parseResourceURL( ResourceURL
, aElementType
, aElementName
))
4454 ::rtl::OString aResName
= rtl::OUStringToOString( aElementName
, RTL_TEXTENCODING_ASCII_US
);
4455 RTL_LOGFILE_CONTEXT_TRACE1( aLog
, "framework (cd100003) Element %s", aResName
.getStr() );
4457 if (( aElementType
.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
4458 aElementName
.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
4459 ( m_aStatusBarElement
.m_aName
== ResourceURL
))
4461 implts_readStatusBarState( ResourceURL
);
4462 if ( m_aStatusBarElement
.m_bVisible
&& !m_aStatusBarElement
.m_bMasterHide
)
4464 createElement( ResourceURL
);
4466 // There are some situation where we are not able to create an element.
4467 // Therefore we have to check the reference before further action.
4469 css::uno::Reference
< css::ui::XUIElement
> xUIElement( m_aStatusBarElement
.m_xUIElement
);
4470 if ( xUIElement
.is() )
4472 // we need VCL here to pass special flags to Show()
4473 vos::OGuard
aGuard( Application::GetSolarMutex() );
4474 Reference
< css::awt::XWindow
> xWindow( xUIElement
->getRealInterface(), UNO_QUERY
);
4475 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
4478 pWindow
->Show( TRUE
, SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
4486 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4487 aElementName
.equalsIgnoreAsciiCaseAscii( "progressbar" ) )
4489 aWriteLock
.unlock();
4490 implts_showProgressBar();
4495 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4499 bool bFound( false );
4500 bool bShowElement( false );
4502 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
4504 if ( pIter
->m_aName
== ResourceURL
)
4507 bShowElement
= ( pIter
->m_bVisible
&& !pIter
->m_bMasterHide
&& m_bParentWindowVisible
);
4509 Reference
< css::awt::XWindow2
> xContainerWindow( m_xContainerWindow
, UNO_QUERY
);
4510 if ( xContainerWindow
.is() && pIter
->m_bFloating
)
4511 bShowElement
= ( bShowElement
&& xContainerWindow
->isActive() );
4513 if ( pIter
->m_xUIElement
.is() )
4515 Reference
< css::awt::XWindow
> xWindow( pIter
->m_xUIElement
->getRealInterface(), UNO_QUERY
);
4516 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
4518 if ( xDockWindow
.is() && xDockWindow
->isFloating() )
4519 bShowElement
= ( bShowElement
&& xContainerWindow
->isActive() );
4521 if ( xDockWindow
.is() && bShowElement
)
4523 pIter
->m_bVisible
= sal_True
;
4524 aWriteLock
.unlock();
4526 // we need VCL here to pass special flags to Show()
4527 vos::OGuard
aGuard( Application::GetSolarMutex() );
4528 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
4529 if( pWindow
&& !pWindow
->IsReallyVisible() )
4531 pWindow
->Show( TRUE
, SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
4532 implts_writeNewStateData( ResourceURL
, xWindow
);
4534 if ( xDockWindow
.is() && !xDockWindow
->isFloating() )
4540 bResult
= sal_False
;
4542 } // if ( pIter->m_xUIElement.is() )
4547 // Create toolbar on demand when it's visible
4550 Reference
< ::com::sun::star::ui::XUIElement
> xUIElement
;
4553 UIElement
aNewToolbar( aElementName
, aElementType
, xUIElement
);
4554 aNewToolbar
.m_aName
= ResourceURL
;
4555 implts_readWindowStateData( ResourceURL
, aNewToolbar
);
4556 implts_insertUIElement( aNewToolbar
);
4557 aWriteLock
.unlock();
4559 implts_sortUIElements();
4560 if ( aNewToolbar
.m_bVisible
)
4561 createElement( ResourceURL
);
4565 else if ( bShowElement
)
4567 aWriteLock
.unlock();
4569 createElement( ResourceURL
);
4576 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4578 css::uno::Reference
< css::frame::XFrame
> xFrame( m_xFrame
);
4579 aWriteLock
.unlock();
4581 CreateDockingWindow( xFrame
, aElementName
);
4587 // UI element is visible - provide information to listeners
4588 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_VISIBLE
, uno::makeAny( ResourceURL
) );
4594 Reference
< XUIElement
> SAL_CALL
LayoutManager::getElement( const ::rtl::OUString
& aName
)
4595 throw (RuntimeException
)
4597 ::rtl::OUString aElementType
;
4598 ::rtl::OUString aElementName
;
4599 Reference
< XUIElement
> xElement
;
4601 implts_findElement( aName
, aElementType
, aElementName
, xElement
);
4605 Sequence
< Reference
< ::com::sun::star::ui::XUIElement
> > SAL_CALL
LayoutManager::getElements()
4606 throw (::com::sun::star::uno::RuntimeException
)
4608 ReadGuard
aReadLock( m_aLock
);
4610 sal_Bool
bMenuBar( sal_False
);
4611 sal_Bool
bStatusBar( sal_False
);
4612 sal_Int32 nSize
= m_aUIElements
.size();
4614 if ( m_xMenuBar
.is() )
4617 bMenuBar
= sal_True
;
4619 if ( m_aStatusBarElement
.m_xUIElement
.is() )
4622 bStatusBar
= sal_True
;
4625 Sequence
< Reference
< ::com::sun::star::ui::XUIElement
> > aSeq( nSize
);
4627 sal_Int32 nIndex
= 0;
4628 UIElementVector::const_iterator pIter
;
4629 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
4631 if ( pIter
->m_xUIElement
.is() )
4632 aSeq
[nIndex
++] = pIter
->m_xUIElement
;
4635 aSeq
[nIndex
++] = m_xMenuBar
;
4637 aSeq
[nIndex
++] = m_aStatusBarElement
.m_xUIElement
;
4639 // Resize sequence as we now know our correct size
4640 aSeq
.realloc( nIndex
);
4645 sal_Bool SAL_CALL
LayoutManager::showElement( const ::rtl::OUString
& aName
)
4646 throw (RuntimeException
)
4648 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::showElement" );
4650 sal_Bool
bResult( sal_False
);
4651 sal_Bool
bNotify( sal_False
);
4652 ::rtl::OUString aElementType
;
4653 ::rtl::OUString aElementName
;
4655 if ( impl_parseResourceURL( aName
, aElementType
, aElementName
))
4657 ::rtl::OString aResName
= rtl::OUStringToOString( aElementName
, RTL_TEXTENCODING_ASCII_US
);
4658 RTL_LOGFILE_CONTEXT_TRACE1( aLog
, "framework (cd100003) Element %s", aResName
.getStr() );
4660 if ( aElementType
.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
4661 aElementName
.equalsIgnoreAsciiCaseAscii( "menubar" ))
4663 WriteGuard
aWriteLock( m_aLock
);
4664 m_bMenuVisible
= sal_True
;
4665 aWriteLock
.unlock();
4667 bResult
= implts_resetMenuBar();
4670 else if (( aElementType
.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
4671 aElementName
.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
4672 ( m_aStatusBarElement
.m_aName
== aName
))
4674 WriteGuard
aWriteLock( m_aLock
);
4675 if ( m_aStatusBarElement
.m_xUIElement
.is() &&
4676 !m_aStatusBarElement
.m_bMasterHide
)
4678 if ( implts_showStatusBar( sal_True
))
4680 implts_writeWindowStateData( m_aStatusBarAlias
, m_aStatusBarElement
);
4687 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4688 aElementName
.equalsIgnoreAsciiCaseAscii( "progressbar" ))
4690 bNotify
= bResult
= implts_showProgressBar();
4692 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4694 UIElementVector::iterator pIter
;
4696 WriteGuard
aWriteLock( m_aLock
);
4697 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
4699 if ( pIter
->m_aName
== aName
&& pIter
->m_xUIElement
.is() )
4701 UIElement aUIElement
= *pIter
;
4702 Reference
< css::awt::XWindow
> xWindow( pIter
->m_xUIElement
->getRealInterface(), UNO_QUERY
);
4703 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
4705 sal_Bool
bShowElement( !pIter
->m_bMasterHide
&& m_bParentWindowVisible
);
4707 pIter
->m_bVisible
= sal_True
;
4708 aWriteLock
.unlock();
4710 implts_writeWindowStateData( aUIElement
.m_aName
, aUIElement
);
4711 implts_sortUIElements();
4713 if ( xDockWindow
.is() && bShowElement
)
4715 // we need VCL here to pass special flags to Show()
4716 vos::OGuard
aGuard( Application::GetSolarMutex() );
4717 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
4720 pWindow
->Show( TRUE
, SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
4723 implts_writeNewStateData( aName
, xWindow
);
4725 if ( xDockWindow
.is() && !xDockWindow
->isFloating() )
4729 } // if ( xDockWindow.is() && bShowElement )
4734 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4736 ReadGuard
aReadGuard( m_aLock
);
4737 css::uno::Reference
< css::frame::XFrame
> xFrame( m_xFrame
);
4738 css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR( m_xSMGR
);
4739 aReadGuard
.unlock();
4741 impl_setDockingWindowVisibility( xSMGR
, xFrame
, aElementName
, true );
4747 // UI element is visible - provide information to listeners
4748 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_VISIBLE
, uno::makeAny( aName
) );
4754 sal_Bool SAL_CALL
LayoutManager::hideElement( const ::rtl::OUString
& aName
)
4755 throw (RuntimeException
)
4757 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::hideElement" );
4760 sal_Bool
bResult( sal_False
);
4761 sal_Bool
bNotify( sal_False
);
4762 ::rtl::OUString aElementType
;
4763 ::rtl::OUString aElementName
;
4765 if ( impl_parseResourceURL( aName
, aElementType
, aElementName
))
4767 ::rtl::OString aResName
= rtl::OUStringToOString( aElementName
, RTL_TEXTENCODING_ASCII_US
);
4768 RTL_LOGFILE_CONTEXT_TRACE1( aLog
, "framework (cd100003) Element %s", aResName
.getStr() );
4770 if ( aElementType
.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
4771 aElementName
.equalsIgnoreAsciiCaseAscii( "menubar" ))
4773 WriteGuard
aWriteLock( m_aLock
);
4775 if ( m_xContainerWindow
.is() )
4777 vos::OGuard
aGuard( Application::GetSolarMutex() );
4778 Window
* pWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
4779 while ( pWindow
&& !pWindow
->IsSystemWindow() )
4780 pWindow
= pWindow
->GetParent();
4782 m_bMenuVisible
= sal_False
;
4785 MenuBar
* pMenuBar
= ((SystemWindow
*)pWindow
)->GetMenuBar();
4788 pMenuBar
->SetDisplayable( sal_False
);
4795 else if (( aElementType
.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
4796 aElementName
.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
4797 ( m_aStatusBarElement
.m_aName
== aName
))
4799 WriteGuard
aWriteLock( m_aLock
);
4800 if ( m_aStatusBarElement
.m_xUIElement
.is() &&
4801 !m_aStatusBarElement
.m_bMasterHide
)
4803 if ( implts_hideStatusBar( sal_True
))
4805 implts_writeWindowStateData( m_aStatusBarAlias
, m_aStatusBarElement
);
4812 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
4813 aElementName
.equalsIgnoreAsciiCaseAscii( "progressbar" ))
4815 bResult
= bNotify
= implts_hideProgressBar();
4817 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ))
4819 UIElementVector::iterator pIter
;
4821 WriteGuard
aWriteLock( m_aLock
);
4822 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
4824 if ( pIter
->m_aName
== aName
&& pIter
->m_xUIElement
.is() )
4826 Reference
< css::awt::XWindow
> xWindow( pIter
->m_xUIElement
->getRealInterface(), UNO_QUERY
);
4827 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
4829 if ( xDockWindow
.is() )
4831 pIter
->m_bVisible
= sal_False
;
4832 aWriteLock
.unlock();
4834 xWindow
->setVisible( sal_False
);
4835 implts_writeNewStateData( aName
, xWindow
);
4837 if ( xDockWindow
.is() && !xDockWindow
->isFloating() )
4842 } // if ( xDockWindow.is() )
4847 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
4849 ReadGuard
aReadGuard( m_aLock
);
4850 css::uno::Reference
< css::frame::XFrame
> xFrame( m_xFrame
);
4851 css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR( m_xSMGR
);
4852 aReadGuard
.unlock();
4854 impl_setDockingWindowVisibility( xSMGR
, xFrame
, aElementName
, false );
4860 // UI element is visible - provide information to listeners
4861 implts_notifyListeners( css::frame::LayoutManagerEvents::UIELEMENT_INVISIBLE
, uno::makeAny( aName
) );
4867 sal_Bool SAL_CALL
LayoutManager::dockWindow( const ::rtl::OUString
& aName
, DockingArea DockingArea
, const css::awt::Point
& Pos
)
4868 throw (RuntimeException
)
4870 UIElement aUIElement
;
4872 if ( implts_findElement( aName
, aUIElement
) && aUIElement
.m_xUIElement
.is() )
4876 Reference
< css::awt::XWindow
> xWindow( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
4877 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
4878 if ( xDockWindow
.is() )
4880 if ( DockingArea
!= DockingArea_DOCKINGAREA_DEFAULT
)
4881 aUIElement
.m_aDockedData
.m_nDockedArea
= sal_Int16( DockingArea
);
4883 if (( Pos
.X
!= SAL_MAX_INT32
) && ( Pos
.Y
!= SAL_MAX_INT32
))
4884 aUIElement
.m_aDockedData
.m_aPos
= ::Point( Pos
.X
, Pos
.Y
);
4886 if ( !xDockWindow
->isFloating() )
4888 Window
* pWindow( 0 );
4889 ToolBox
* pToolBox( 0 );
4892 vos::OGuard
aGuard( Application::GetSolarMutex() );
4893 pWindow
= VCLUnoHelper::GetWindow( xWindow
);
4894 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
4896 pToolBox
= (ToolBox
*)pWindow
;
4898 // We have to set the alignment of the toolbox. It's possible that the toolbox is moved from a
4899 // horizontal to a vertical docking area!
4900 pToolBox
->SetAlign( ImplConvertAlignment( aUIElement
.m_aDockedData
.m_nDockedArea
));
4904 if (( aUIElement
.m_aDockedData
.m_aPos
.X() == SAL_MAX_INT32
) ||
4905 ( aUIElement
.m_aDockedData
.m_aPos
.Y() == SAL_MAX_INT32
))
4907 // Docking on its default position without a preset position -
4908 // we have to find a good place for it.
4911 vos::OGuard
aGuard( Application::GetSolarMutex() );
4914 aSize
= pToolBox
->CalcWindowSizePixel( 1, ImplConvertAlignment( aUIElement
.m_aDockedData
.m_nDockedArea
) );
4916 aSize
= pWindow
->GetSizePixel();
4921 implts_findNextDockingPos( (::com::sun::star::ui::DockingArea
)aUIElement
.m_aDockedData
.m_nDockedArea
,
4925 aUIElement
.m_aDockedData
.m_aPos
= aDockPos
;
4929 WriteGuard
aWriteLock( m_aLock
);
4930 UIElement
& rUIElement
= LayoutManager::impl_findElement( aUIElement
.m_aName
);
4931 if ( rUIElement
.m_aName
== aName
)
4933 rUIElement
.m_aDockedData
.m_nDockedArea
= aUIElement
.m_aDockedData
.m_nDockedArea
;
4934 rUIElement
.m_aDockedData
.m_aPos
= aUIElement
.m_aDockedData
.m_aPos
;
4936 aWriteLock
.unlock();
4938 if ( xDockWindow
->isFloating() )
4940 // Will call toggle floating mode which will do the rest!
4941 xWindow
->setVisible( sal_False
);
4942 xDockWindow
->setFloatingMode( sal_False
);
4943 xWindow
->setVisible( sal_True
);
4947 implts_writeWindowStateData( aName
, aUIElement
);
4948 implts_sortUIElements();
4950 if ( aUIElement
.m_bVisible
)
4957 catch ( DisposedException
& )
4965 ::sal_Bool SAL_CALL
LayoutManager::dockAllWindows( ::sal_Int16 nElementType
) throw (::com::sun::star::uno::RuntimeException
)
4967 if ( nElementType
== UIElementType::TOOLBAR
)
4969 std::vector
< rtl::OUString
> aToolBarNameVector
;
4971 ::rtl::OUString aElementType
;
4972 ::rtl::OUString aElementName
;
4975 ReadGuard
aReadLock( m_aLock
);
4976 UIElementVector::iterator pIter
;
4977 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
4979 if ( pIter
->m_aType
.equalsAscii( "toolbar" ) &&
4980 pIter
->m_xUIElement
.is() &&
4981 pIter
->m_bFloating
&&
4983 aToolBarNameVector
.push_back( pIter
->m_aName
);
4987 const sal_uInt32 nCount
= aToolBarNameVector
.size();
4988 for ( sal_uInt32 i
= 0; i
< nCount
; ++i
)
4990 ::com::sun::star::awt::Point aPoint
;
4991 aPoint
.X
= aPoint
.Y
= SAL_MAX_INT32
;
4992 dockWindow( aToolBarNameVector
[i
], DockingArea_DOCKINGAREA_DEFAULT
, aPoint
);
4999 sal_Bool SAL_CALL
LayoutManager::floatWindow( const ::rtl::OUString
& aName
)
5000 throw (RuntimeException
)
5002 UIElement aUIElement
;
5004 if ( implts_findElement( aName
, aUIElement
))
5006 if ( aUIElement
.m_xUIElement
.is() )
5010 Reference
< css::awt::XWindow
> xWindow( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5011 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
5012 if ( xWindow
.is() && xDockWindow
.is() )
5014 if ( !xDockWindow
->isFloating() )
5016 xDockWindow
->setFloatingMode( sal_True
);
5021 catch ( DisposedException
& )
5030 ::sal_Bool SAL_CALL
LayoutManager::lockWindow( const ::rtl::OUString
& ResourceURL
)
5031 throw (::com::sun::star::uno::RuntimeException
)
5033 UIElement aUIElement
;
5035 if ( implts_findElement( ResourceURL
, aUIElement
))
5037 if ( aUIElement
.m_xUIElement
.is() )
5041 Reference
< css::awt::XWindow
> xWindow( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5042 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
5043 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
5045 pWindow
->IsVisible() &&
5047 !xDockWindow
->isFloating() )
5049 aUIElement
.m_aDockedData
.m_bLocked
= sal_True
;
5050 implts_writeWindowStateData( ResourceURL
, aUIElement
);
5051 xDockWindow
->lock();
5053 // Write back lock state
5054 WriteGuard
aWriteLock( m_aLock
);
5055 UIElement
& rUIElement
= LayoutManager::impl_findElement( aUIElement
.m_aName
);
5056 if ( rUIElement
.m_aName
== aUIElement
.m_aName
)
5057 rUIElement
.m_aDockedData
.m_bLocked
= aUIElement
.m_aDockedData
.m_bLocked
;
5058 aWriteLock
.unlock();
5064 catch ( DisposedException
& )
5073 ::sal_Bool SAL_CALL
LayoutManager::unlockWindow( const ::rtl::OUString
& ResourceURL
)
5074 throw (::com::sun::star::uno::RuntimeException
)
5076 UIElement aUIElement
;
5078 if ( implts_findElement( ResourceURL
, aUIElement
))
5080 if ( aUIElement
.m_xUIElement
.is() )
5084 Reference
< css::awt::XWindow
> xWindow( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5085 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
5086 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
5088 pWindow
->IsVisible() &&
5090 !xDockWindow
->isFloating() )
5092 aUIElement
.m_aDockedData
.m_bLocked
= sal_False
;
5093 implts_writeWindowStateData( ResourceURL
, aUIElement
);
5094 xDockWindow
->unlock();
5096 // Write back lock state
5097 WriteGuard
aWriteLock( m_aLock
);
5098 UIElement
& rUIElement
= LayoutManager::impl_findElement( aUIElement
.m_aName
);
5099 if ( rUIElement
.m_aName
== aUIElement
.m_aName
)
5100 rUIElement
.m_aDockedData
.m_bLocked
= aUIElement
.m_aDockedData
.m_bLocked
;
5101 aWriteLock
.unlock();
5107 catch ( DisposedException
& )
5116 void SAL_CALL
LayoutManager::setElementSize( const ::rtl::OUString
& aName
, const css::awt::Size
& aSize
)
5117 throw (RuntimeException
)
5119 UIElement aUIElement
;
5121 if ( implts_findElement( aName
, aUIElement
))
5123 if ( aUIElement
.m_xUIElement
.is() )
5127 Reference
< css::awt::XWindow
> xWindow( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5128 Reference
< css::awt::XWindow2
> xWindow2( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5129 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
5131 if ( xWindow
.is() && xWindow2
.is() && xDockWindow
.is() )
5133 if ( aUIElement
.m_bFloating
)
5135 xWindow2
->setOutputSize( aSize
);
5136 implts_writeNewStateData( aName
, xWindow
);
5140 catch ( DisposedException
& )
5147 void SAL_CALL
LayoutManager::setElementPos( const ::rtl::OUString
& aName
, const css::awt::Point
& aPos
)
5148 throw (RuntimeException
)
5150 UIElement aUIElement
;
5152 if ( implts_findElement( aName
, aUIElement
) && aUIElement
.m_xUIElement
.is() )
5156 Reference
< css::awt::XWindow
> xWindow( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5157 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
5159 if ( xWindow
.is() && xDockWindow
.is() )
5161 if ( aUIElement
.m_bFloating
)
5163 xWindow
->setPosSize( aPos
.X
, aPos
.Y
, 0, 0, css::awt::PosSize::POS
);
5164 implts_writeNewStateData( aName
, xWindow
);
5168 WriteGuard
aWriteLock( m_aLock
);
5169 UIElement
& rUIElement
= LayoutManager::impl_findElement( aUIElement
.m_aName
);
5170 if ( rUIElement
.m_aName
== aName
)
5171 rUIElement
.m_aDockedData
.m_aPos
= ::Point( aPos
.X
, aPos
.Y
);
5172 aWriteLock
.unlock();
5174 aUIElement
.m_aDockedData
.m_aPos
= ::Point( aPos
.X
, aPos
.Y
);
5175 implts_writeWindowStateData( aName
, aUIElement
);
5176 implts_sortUIElements();
5178 if ( aUIElement
.m_bVisible
)
5183 catch ( DisposedException
& )
5189 void SAL_CALL
LayoutManager::setElementPosSize( const ::rtl::OUString
& aName
, const css::awt::Point
& aPos
, const css::awt::Size
& aSize
)
5190 throw (RuntimeException
)
5192 UIElement aUIElement
;
5194 if ( implts_findElement( aName
, aUIElement
))
5196 if ( aUIElement
.m_xUIElement
.is() )
5200 Reference
< css::awt::XWindow
> xWindow( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5201 Reference
< css::awt::XWindow2
> xWindow2( aUIElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5202 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
5204 if ( xWindow
.is() && xWindow2
.is() && xDockWindow
.is() )
5206 if ( aUIElement
.m_bFloating
)
5208 xWindow2
->setPosSize( aPos
.X
, aPos
.Y
, 0, 0, css::awt::PosSize::POS
);
5209 xWindow2
->setOutputSize( aSize
);
5210 implts_writeNewStateData( aName
, xWindow
);
5214 WriteGuard
aWriteLock( m_aLock
);
5215 UIElement
& rUIElement
= LayoutManager::impl_findElement( aUIElement
.m_aName
);
5216 if ( rUIElement
.m_aName
== aName
)
5217 rUIElement
.m_aDockedData
.m_aPos
= ::Point( aPos
.X
, aPos
.Y
);
5218 aWriteLock
.unlock();
5220 aUIElement
.m_aDockedData
.m_aPos
= ::Point( aPos
.X
, aPos
.Y
);
5221 implts_writeWindowStateData( aName
, rUIElement
);
5222 implts_sortUIElements();
5224 if ( aUIElement
.m_bVisible
)
5229 catch ( DisposedException
& )
5236 sal_Bool SAL_CALL
LayoutManager::isElementVisible( const ::rtl::OUString
& aName
)
5237 throw (RuntimeException
)
5239 ::rtl::OUString aElementType
;
5240 ::rtl::OUString aElementName
;
5242 if ( impl_parseResourceURL( aName
, aElementType
, aElementName
))
5244 if ( aElementType
.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
5245 aElementName
.equalsIgnoreAsciiCaseAscii( "menubar" ))
5247 ReadGuard
aReadLock( m_aLock
);
5248 if ( m_xContainerWindow
.is() )
5252 vos::OGuard
aGuard( Application::GetSolarMutex() );
5253 Window
* pWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
5254 while ( pWindow
&& !pWindow
->IsSystemWindow() )
5255 pWindow
= pWindow
->GetParent();
5259 MenuBar
* pMenuBar
= ((SystemWindow
*)pWindow
)->GetMenuBar();
5260 if ( pMenuBar
&& pMenuBar
->IsDisplayable() )
5266 return m_bMenuVisible
;
5270 else if (( aElementType
.equalsIgnoreAsciiCaseAscii( "statusbar" ) &&
5271 aElementName
.equalsIgnoreAsciiCaseAscii( "statusbar" )) ||
5272 ( m_aStatusBarElement
.m_aName
== aName
))
5274 if ( m_aStatusBarElement
.m_xUIElement
.is() )
5276 Reference
< css::awt::XWindow
> xWindow(
5277 m_aStatusBarElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5280 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
5281 if ( pWindow
&& pWindow
->IsVisible() )
5288 else if (( aElementType
.equalsIgnoreAsciiCaseAscii( "progressbar" ) &&
5289 aElementName
.equalsIgnoreAsciiCaseAscii( "progressbar" )))
5291 if ( m_aProgressBarElement
.m_xUIElement
.is() )
5292 return m_aProgressBarElement
.m_bVisible
;
5294 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ))
5296 UIElementVector::const_iterator pIter
;
5298 ReadGuard
aReadLock( m_aLock
);
5299 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
5301 if ( pIter
->m_aName
== aName
&& pIter
->m_xUIElement
.is() )
5303 Reference
< css::awt::XWindow
> xWindow( pIter
->m_xUIElement
->getRealInterface(), UNO_QUERY
);
5306 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
5307 return pWindow
&& pWindow
->IsVisible();
5312 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "dockingwindow" ))
5314 ReadGuard
aReadGuard( m_aLock
);
5315 css::uno::Reference
< css::frame::XFrame
> xFrame( m_xFrame
);
5316 aReadGuard
.unlock();
5318 return IsDockingWindowVisible( xFrame
, aElementName
);
5325 sal_Bool SAL_CALL
LayoutManager::isElementFloating( const ::rtl::OUString
& aName
)
5326 throw (RuntimeException
)
5328 UIElementVector::const_iterator pIter
;
5330 ReadGuard
aReadLock( m_aLock
);
5331 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
5333 if ( pIter
->m_aName
== aName
&& pIter
->m_xUIElement
.is() )
5335 Reference
< css::awt::XDockableWindow
> xDockWindow( pIter
->m_xUIElement
->getRealInterface(), UNO_QUERY
);
5336 return xDockWindow
.is() && xDockWindow
->isFloating();
5343 sal_Bool SAL_CALL
LayoutManager::isElementDocked( const ::rtl::OUString
& aName
)
5344 throw (RuntimeException
)
5346 UIElementVector::const_iterator pIter
;
5348 ReadGuard
aReadLock( m_aLock
);
5349 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
5351 if ( pIter
->m_aName
== aName
&& pIter
->m_xUIElement
.is() )
5353 Reference
< css::awt::XDockableWindow
> xDockWindow( pIter
->m_xUIElement
->getRealInterface(), UNO_QUERY
);
5354 return xDockWindow
.is() && !xDockWindow
->isFloating();
5361 ::sal_Bool SAL_CALL
LayoutManager::isElementLocked( const ::rtl::OUString
& ResourceURL
)
5362 throw (::com::sun::star::uno::RuntimeException
)
5364 UIElementVector::const_iterator pIter
;
5366 ReadGuard
aReadLock( m_aLock
);
5367 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
5369 if (( pIter
->m_aName
== ResourceURL
) && ( pIter
->m_xUIElement
.is() ))
5371 Reference
< css::awt::XDockableWindow
> xDockWindow( pIter
->m_xUIElement
->getRealInterface(), UNO_QUERY
);
5372 return xDockWindow
.is() && !xDockWindow
->isLocked();
5379 css::awt::Size SAL_CALL
LayoutManager::getElementSize( const ::rtl::OUString
& aName
)
5380 throw (RuntimeException
)
5382 ReadGuard
aReadLock( m_aLock
);
5383 UIElement aElementData
;
5384 if ( implts_findElement( aName
,aElementData
) && aElementData
.m_xUIElement
.is() )
5386 Reference
< css::awt::XWindow
> xWindow( aElementData
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5389 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
5392 ::Size aSize
= pWindow
->GetSizePixel();
5393 css::awt::Size aElementSize
;
5394 aElementSize
.Width
= aSize
.Width();
5395 aElementSize
.Height
= aSize
.Height();
5396 return aElementSize
;
5400 return css::awt::Size();
5403 css::awt::Point SAL_CALL
LayoutManager::getElementPos( const ::rtl::OUString
& aName
)
5404 throw (RuntimeException
)
5406 ReadGuard
aReadLock( m_aLock
);
5407 UIElement aElementData
;
5408 if ( implts_findElement( aName
,aElementData
) && aElementData
.m_xUIElement
.is() )
5410 Reference
< css::awt::XWindow
> xWindow( aElementData
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
5411 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
5412 if ( xDockWindow
.is() )
5414 css::awt::Point aPos
;
5415 if ( aElementData
.m_bFloating
)
5417 css::awt::Rectangle aRect
= xWindow
->getPosSize();
5423 ::Point aVirtualPos
= aElementData
.m_aDockedData
.m_aPos
;
5424 aPos
.X
= aVirtualPos
.X();
5425 aPos
.Y
= aVirtualPos
.Y();
5432 return css::awt::Point();
5435 void SAL_CALL
LayoutManager::lock()
5436 throw (RuntimeException
)
5440 ReadGuard
aReadLock( m_aLock
);
5441 sal_Int32
nLockCount( m_nLockCount
);
5444 RTL_LOGFILE_TRACE1( "framework (cd100003) ::LayoutManager::lock lockCount=%d", nLockCount
);
5446 ByteString
aStr("LayoutManager::lock ");
5447 aStr
+= ByteString::CreateFromInt32((long)this);
5449 aStr
+= ByteString::CreateFromInt32(nLockCount
);
5450 DBG_TRACE( aStr
.GetBuffer() );
5453 Any
a( nLockCount
);
5454 implts_notifyListeners( css::frame::LayoutManagerEvents::LOCK
, a
);
5457 void SAL_CALL
LayoutManager::unlock()
5458 throw (RuntimeException
)
5460 sal_Bool
bDoLayout( implts_unlock() );
5462 ReadGuard
aReadLock( m_aLock
);
5463 sal_Int32
nLockCount( m_nLockCount
);
5466 RTL_LOGFILE_TRACE1( "framework (cd100003) ::LayoutManager::unlock lockCount=%d", nLockCount
);
5468 ByteString
aStr("LayoutManager::unlock ");
5469 aStr
+= ByteString::CreateFromInt32((long)this);
5471 aStr
+= ByteString::CreateFromInt32(nLockCount
);
5472 DBG_TRACE( aStr
.GetBuffer() );
5474 // conform to documentation: unlock with lock count == 0 means force a layout
5476 WriteGuard
aWriteLock( m_aLock
);
5478 m_aAsyncLayoutTimer
.Stop();
5479 aWriteLock
.unlock();
5481 Any
a( nLockCount
);
5482 implts_notifyListeners( css::frame::LayoutManagerEvents::UNLOCK
, a
);
5488 void SAL_CALL
LayoutManager::doLayout()
5489 throw (RuntimeException
)
5491 sal_Bool bLayouted
= implts_doLayout( sal_False
);
5494 implts_notifyListeners( css::frame::LayoutManagerEvents::LAYOUT
, Any() );
5497 sal_Bool
LayoutManager::implts_doLayout( sal_Bool bForceRequestBorderSpace
)
5499 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::implts_doLayout" );
5501 sal_Bool
bNoLock( sal_False
);
5502 css::awt::Rectangle aCurrBorderSpace
;
5503 Reference
< css::awt::XWindow
> xContainerWindow
;
5504 Reference
< XDockingAreaAcceptor
> xDockingAreaAcceptor
;
5506 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5507 ReadGuard
aReadLock( m_aLock
);
5509 sal_Bool
bMustDoLayout( m_bMustDoLayout
);
5510 if ( !m_bParentWindowVisible
)
5513 bNoLock
= ( m_nLockCount
== 0 );
5514 xContainerWindow
= m_xContainerWindow
;
5515 xDockingAreaAcceptor
= m_xDockingAreaAcceptor
;
5516 aCurrBorderSpace
= m_aDockingArea
;
5518 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5520 sal_Bool
bLayouted( sal_False
);
5523 xDockingAreaAcceptor
.is() &&
5524 xContainerWindow
.is() )
5526 bLayouted
= sal_True
;
5528 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5529 WriteGuard
aWriteGuard( m_aLock
);
5530 m_bDoLayout
= sal_True
;
5531 aWriteGuard
.unlock();
5532 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5534 css::awt::Rectangle aBorderSpace
= implts_calcDockingAreaSizes();
5535 sal_Bool
bGotRequestedBorderSpace( sal_True
);
5536 sal_Bool bEqual
= implts_compareRectangles( aBorderSpace
, aCurrBorderSpace
);
5538 if ( !bEqual
|| bForceRequestBorderSpace
|| bMustDoLayout
)
5540 bGotRequestedBorderSpace
= xDockingAreaAcceptor
->requestDockingAreaSpace( aBorderSpace
);
5541 if ( bGotRequestedBorderSpace
)
5543 xDockingAreaAcceptor
->setDockingAreaSpace( aBorderSpace
);
5545 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5547 m_aDockingArea
= aBorderSpace
;
5548 m_bMustDoLayout
= sal_False
;
5549 aWriteGuard
.unlock();
5550 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5554 if ( bGotRequestedBorderSpace
)
5556 ::Size aContainerSize
;
5557 ::Size aStatusBarSize
;
5559 aStatusBarSize
= implts_getStatusBarSize();
5560 aBorderSpace
.Height
-= aStatusBarSize
.Height();
5561 implts_setDockingAreaWindowSizes( aBorderSpace
);
5563 // Subtract status bar size from our container output size. Docking area windows
5564 // don't contain the status bar!
5565 aContainerSize
= implts_getContainerWindowOutputSize();
5566 aContainerSize
.Height() -= aStatusBarSize
.Height();
5568 // Retrieve row/column dependent data from all docked user-interface elements
5569 for ( sal_Int32 i
= 0; i
< DOCKINGAREAS_COUNT
; i
++ )
5571 std::vector
< SingleRowColumnWindowData
> aRowColumnsWindowData
;
5573 implts_getDockingAreaElementInfos( (DockingArea
)i
, aRowColumnsWindowData
);
5575 sal_Int32
nOffset( 0 );
5576 const sal_uInt32 nCount
= aRowColumnsWindowData
.size();
5577 for ( sal_uInt32 j
= 0; j
< nCount
; ++j
)
5579 implts_calcWindowPosSizeOnSingleRowColumn( i
, nOffset
, aRowColumnsWindowData
[j
], aContainerSize
);
5580 nOffset
+= aRowColumnsWindowData
[j
].nStaticSize
;
5584 // Position the status bar
5585 if ( aStatusBarSize
.Height() > 0 )
5587 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerSize
.Height() ), long( 0 ))),
5588 ::Size( aContainerSize
.Width(),aStatusBarSize
.Height() ));
5591 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5593 m_bDoLayout
= sal_False
;
5594 aWriteGuard
.unlock();
5595 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5602 sal_Bool
LayoutManager::implts_compareRectangles( const css::awt::Rectangle
& rRect1
,
5603 const css::awt::Rectangle
& rRect2
)
5605 return (( rRect1
.X
== rRect2
.X
) &&
5606 ( rRect1
.Y
== rRect2
.Y
) &&
5607 ( rRect1
.Width
== rRect2
.Width
) &&
5608 ( rRect1
.Height
== rRect2
.Height
));
5611 void SAL_CALL
LayoutManager::setVisible( sal_Bool bVisible
)
5612 throw (::com::sun::star::uno::RuntimeException
)
5614 sal_Bool
bWasVisible( sal_True
);
5616 WriteGuard
aWriteLock( m_aLock
);
5617 bWasVisible
= m_bVisible
;
5618 m_bVisible
= bVisible
;
5619 aWriteLock
.unlock();
5621 if ( bWasVisible
!= bVisible
)
5622 implts_setVisibleState( bVisible
);
5625 sal_Bool SAL_CALL
LayoutManager::isVisible()
5626 throw (::com::sun::star::uno::RuntimeException
)
5628 ReadGuard
aReadLock( m_aLock
);
5632 void LayoutManager::implts_calcWindowPosSizeOnSingleRowColumn( sal_Int32 nDockingArea
,
5634 SingleRowColumnWindowData
& rRowColumnWindowData
,
5635 const ::Size
& rContainerSize
)
5637 sal_Int32
nDiff( 0 );
5638 sal_Int32
nRCSpace( rRowColumnWindowData
.nSpace
);
5639 sal_Int32 nTopDockingAreaSize
;
5640 sal_Int32 nBottomDockingAreaSize
;
5641 sal_Int32 nContainerClientSize
;
5643 if ( rRowColumnWindowData
.aRowColumnWindows
.empty() )
5646 if (( nDockingArea
== DockingArea_DOCKINGAREA_TOP
) ||
5647 ( nDockingArea
== DockingArea_DOCKINGAREA_BOTTOM
))
5649 nContainerClientSize
= rContainerSize
.Width();
5650 nDiff
= nContainerClientSize
- rRowColumnWindowData
.nVarSize
;
5654 nTopDockingAreaSize
= implts_getTopBottomDockingAreaSizes().Width();
5655 nBottomDockingAreaSize
= implts_getTopBottomDockingAreaSizes().Height();
5656 nContainerClientSize
= ( rContainerSize
.Height() - nTopDockingAreaSize
- nBottomDockingAreaSize
);
5657 nDiff
= nContainerClientSize
- rRowColumnWindowData
.nVarSize
;
5660 const sal_uInt32 nCount
= rRowColumnWindowData
.aRowColumnWindowSizes
.size();
5661 if (( nDiff
< 0 ) && ( nRCSpace
> 0 ))
5663 // First we try to reduce the size of blank space before/behind docked windows
5664 sal_Int32 i
= nCount
- 1;
5667 sal_Int32 nSpace
= rRowColumnWindowData
.aRowColumnSpace
[i
];
5668 if ( nSpace
>= -nDiff
)
5671 if (( nDockingArea
== DockingArea_DOCKINGAREA_TOP
) ||
5672 ( nDockingArea
== DockingArea_DOCKINGAREA_BOTTOM
))
5674 // Try to move this and all user elements behind with the calculated difference
5675 for ( sal_uInt32 j
= i
; j
< nCount
; j
++ )
5676 rRowColumnWindowData
.aRowColumnWindowSizes
[j
].X
+= nDiff
;
5680 // Try to move this and all user elements behind with the calculated difference
5681 for ( sal_uInt32 j
= i
; j
< nCount
; j
++ )
5682 rRowColumnWindowData
.aRowColumnWindowSizes
[j
].Y
+= nDiff
;
5688 else if ( nSpace
> 0 )
5690 if (( nDockingArea
== DockingArea_DOCKINGAREA_TOP
) ||
5691 ( nDockingArea
== DockingArea_DOCKINGAREA_BOTTOM
))
5693 // Try to move this and all user elements behind with the calculated difference
5694 for ( sal_uInt32 j
= i
; j
< nCount
; j
++ )
5695 rRowColumnWindowData
.aRowColumnWindowSizes
[j
].X
-= nSpace
;
5699 // Try to move this and all user elements behind with the calculated difference
5700 for ( sal_uInt32 j
= i
; j
< nCount
; j
++ )
5701 rRowColumnWindowData
.aRowColumnWindowSizes
[j
].Y
-= nSpace
;
5709 // Check if we have to reduce further
5712 // Now we have to reduce the size of certain docked windows
5713 sal_Int32 i
= sal_Int32( nCount
- 1 );
5716 css::awt::Rectangle
& rWinRect
= rRowColumnWindowData
.aRowColumnWindowSizes
[i
];
5719 vos::OGuard
aGuard( Application::GetSolarMutex() );
5721 Reference
< css::awt::XWindow
> xWindow
= rRowColumnWindowData
.aRowColumnWindows
[i
];
5722 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
5723 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
5724 aMinSize
= ((ToolBox
*)pWindow
)->CalcMinimumWindowSizePixel();
5727 if (( aMinSize
.Width() > 0 ) && ( aMinSize
.Height() > 0 ))
5729 if (( nDockingArea
== DockingArea_DOCKINGAREA_TOP
) ||
5730 ( nDockingArea
== DockingArea_DOCKINGAREA_BOTTOM
))
5732 sal_Int32 nMaxReducation
= ( rWinRect
.Width
- aMinSize
.Width() );
5733 if ( nMaxReducation
>= -nDiff
)
5735 rWinRect
.Width
= rWinRect
.Width
+ nDiff
;
5740 rWinRect
.Width
= aMinSize
.Width();
5741 nDiff
+= nMaxReducation
;
5744 // Try to move this and all user elements behind with the calculated difference
5745 for ( sal_uInt32 j
= i
; j
< nCount
; j
++ )
5746 rRowColumnWindowData
.aRowColumnWindowSizes
[j
].X
+= nDiff
;
5750 sal_Int32 nMaxReducation
= ( rWinRect
.Height
- aMinSize
.Height() );
5751 if ( nMaxReducation
>= -nDiff
)
5753 rWinRect
.Height
= rWinRect
.Height
+ nDiff
;
5758 rWinRect
.Height
= aMinSize
.Height();
5759 nDiff
+= nMaxReducation
;
5762 // Try to move this and all user elements behind with the calculated difference
5763 for ( sal_uInt32 j
= i
; j
< nCount
; j
++ )
5764 rRowColumnWindowData
.aRowColumnWindowSizes
[j
].Y
+= nDiff
;
5775 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
5776 ReadGuard
aReadLock( m_aLock
);
5777 Window
* pDockAreaWindow
= VCLUnoHelper::GetWindow( m_xDockAreaWindows
[nDockingArea
] );
5780 sal_Int32
nCurrPos( 0 );
5781 sal_Int32
nStartOffset( 0 );
5783 if ( nDockingArea
== DockingArea_DOCKINGAREA_RIGHT
)
5784 nStartOffset
= pDockAreaWindow
->GetSizePixel().Width() - rRowColumnWindowData
.nStaticSize
;
5785 else if ( nDockingArea
== DockingArea_DOCKINGAREA_BOTTOM
)
5786 nStartOffset
= pDockAreaWindow
->GetSizePixel().Height() - rRowColumnWindowData
.nStaticSize
;
5788 vos::OGuard
aGuard( Application::GetSolarMutex() );
5789 for ( sal_uInt32 i
= 0; i
< nCount
; i
++ )
5791 Reference
< css::awt::XWindow
> xWindow
= rRowColumnWindowData
.aRowColumnWindows
[i
];
5792 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
5793 Window
* pOldParentWindow
= pWindow
->GetParent();
5795 if ( pDockAreaWindow
!= pOldParentWindow
)
5796 pWindow
->SetParent( pDockAreaWindow
);
5798 css::awt::Rectangle aWinRect
= rRowColumnWindowData
.aRowColumnWindowSizes
[i
];
5799 if ( nDockingArea
== DockingArea_DOCKINGAREA_TOP
)
5801 if ( aWinRect
.X
< nCurrPos
)
5802 aWinRect
.X
= nCurrPos
;
5803 pWindow
->SetPosSizePixel( ::Point( aWinRect
.X
, nOffset
),
5804 ::Size( aWinRect
.Width
, rRowColumnWindowData
.nStaticSize
));
5805 nCurrPos
+= ( aWinRect
.X
- nCurrPos
) + aWinRect
.Width
;
5807 else if ( nDockingArea
== DockingArea_DOCKINGAREA_BOTTOM
)
5809 if ( aWinRect
.X
< nCurrPos
)
5810 aWinRect
.X
= nCurrPos
;
5811 pWindow
->SetPosSizePixel( ::Point( aWinRect
.X
, nStartOffset
- nOffset
),
5812 ::Size( aWinRect
.Width
, rRowColumnWindowData
.nStaticSize
));
5813 nCurrPos
+= ( aWinRect
.X
- nCurrPos
) + aWinRect
.Width
;
5815 else if ( nDockingArea
== DockingArea_DOCKINGAREA_LEFT
)
5817 if ( aWinRect
.Y
< nCurrPos
)
5818 aWinRect
.Y
= nCurrPos
;
5819 pWindow
->SetPosSizePixel( ::Point( nOffset
, aWinRect
.Y
),
5820 ::Size( rRowColumnWindowData
.nStaticSize
, aWinRect
.Height
));
5821 nCurrPos
+= ( aWinRect
.Y
- nCurrPos
) + aWinRect
.Height
;
5823 else if ( nDockingArea
== DockingArea_DOCKINGAREA_RIGHT
)
5825 if ( aWinRect
.Y
< nCurrPos
)
5826 aWinRect
.Y
= nCurrPos
;
5827 pWindow
->SetPosSizePixel( ::Point( nStartOffset
- nOffset
, aWinRect
.Y
),
5828 ::Size( rRowColumnWindowData
.nStaticSize
, aWinRect
.Height
));
5829 nCurrPos
+= ( aWinRect
.Y
- nCurrPos
) + aWinRect
.Height
;
5834 ::Size
LayoutManager::implts_getStatusBarSize()
5836 ReadGuard
aReadLock( m_aLock
);
5837 sal_Bool
bStatusBarVisible( isElementVisible( m_aStatusBarAlias
));
5838 sal_Bool
bProgressBarVisible( isElementVisible( m_aProgressBarAlias
));
5839 sal_Bool bVisible
= m_bVisible
;
5840 Reference
< XUIElement
> xStatusBar
= m_aStatusBarElement
.m_xUIElement
;
5841 Reference
< XUIElement
> xProgressBar
= m_aProgressBarElement
.m_xUIElement
;
5843 Reference
< css::awt::XWindow
> xWindow
;
5844 if ( bStatusBarVisible
&& bVisible
&& xStatusBar
.is() )
5845 xWindow
= Reference
< css::awt::XWindow
>( xStatusBar
->getRealInterface(), UNO_QUERY
);
5846 else if ( xProgressBar
.is() && !xStatusBar
.is() && bProgressBarVisible
)
5848 ProgressBarWrapper
* pWrapper
= (ProgressBarWrapper
*)xProgressBar
.get();
5850 xWindow
= pWrapper
->getStatusBar();
5856 css::awt::Rectangle aPosSize
= xWindow
->getPosSize();
5857 return ::Size( aPosSize
.Width
, aPosSize
.Height
);
5863 css::awt::Rectangle
LayoutManager::implts_calcDockingAreaSizes()
5865 Reference
< css::awt::XWindow
> xContainerWindow
;
5866 Reference
< XDockingAreaAcceptor
> xDockingAreaAcceptor
;
5868 ReadGuard
aReadLock( m_aLock
);
5869 xContainerWindow
= m_xContainerWindow
;
5870 xDockingAreaAcceptor
= m_xDockingAreaAcceptor
;
5871 UIElementVector
aWindowVector( m_aUIElements
);
5874 css::awt::Rectangle aBorderSpace
;
5875 if ( xDockingAreaAcceptor
.is() && xContainerWindow
.is() )
5877 sal_Int32
nCurrRowColumn( 0 );
5878 sal_Int32
nCurrPos( 0 );
5879 sal_Int32
nCurrDockingArea( DockingArea_DOCKINGAREA_TOP
);
5880 std::vector
< sal_Int32
> aRowColumnSizes
[DOCKINGAREAS_COUNT
];
5881 UIElementVector::const_iterator pConstIter
;
5883 aRowColumnSizes
[nCurrDockingArea
].clear();
5884 aRowColumnSizes
[nCurrDockingArea
].push_back( 0 );
5886 for ( pConstIter
= aWindowVector
.begin(); pConstIter
!= aWindowVector
.end(); pConstIter
++ )
5888 Reference
< XUIElement
> xUIElement( pConstIter
->m_xUIElement
, UNO_QUERY
);
5889 if ( xUIElement
.is() )
5891 Reference
< css::awt::XWindow
> xWindow( xUIElement
->getRealInterface(), UNO_QUERY
);
5892 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
5893 if ( xWindow
.is() && xDockWindow
.is() )
5895 vos::OGuard
aGuard( Application::GetSolarMutex() );
5897 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
5898 if ( pWindow
&& pWindow
->IsVisible() && !xDockWindow
->isFloating() )
5900 css::awt::Rectangle aPosSize
= xWindow
->getPosSize();
5901 if ( pConstIter
->m_aDockedData
.m_nDockedArea
!= nCurrDockingArea
)
5903 nCurrDockingArea
= pConstIter
->m_aDockedData
.m_nDockedArea
;
5906 aRowColumnSizes
[nCurrDockingArea
].clear();
5907 aRowColumnSizes
[nCurrDockingArea
].push_back( 0 );
5910 if ( pConstIter
->m_aDockedData
.m_nDockedArea
== nCurrDockingArea
)
5912 if (( pConstIter
->m_aDockedData
.m_nDockedArea
== DockingArea_DOCKINGAREA_TOP
) ||
5913 ( pConstIter
->m_aDockedData
.m_nDockedArea
== DockingArea_DOCKINGAREA_BOTTOM
))
5915 if ( pConstIter
->m_aDockedData
.m_aPos
.Y() > nCurrPos
)
5918 nCurrPos
= pConstIter
->m_aDockedData
.m_aPos
.Y();
5919 aRowColumnSizes
[nCurrDockingArea
].push_back( 0 );
5922 if ( aPosSize
.Height
> aRowColumnSizes
[nCurrDockingArea
][nCurrRowColumn
] )
5923 aRowColumnSizes
[nCurrDockingArea
][nCurrRowColumn
] = aPosSize
.Height
;
5927 if ( pConstIter
->m_aDockedData
.m_aPos
.X() > nCurrPos
)
5930 nCurrPos
= pConstIter
->m_aDockedData
.m_aPos
.X();
5931 aRowColumnSizes
[nCurrDockingArea
].push_back( 0 );
5934 if ( aPosSize
.Width
> aRowColumnSizes
[nCurrDockingArea
][nCurrRowColumn
] )
5935 aRowColumnSizes
[nCurrDockingArea
][nCurrRowColumn
] = aPosSize
.Width
;
5943 // Sum up max heights from every row/column
5944 if ( !aWindowVector
.empty() )
5946 for ( sal_Int32 i
= 0; i
<= DockingArea_DOCKINGAREA_RIGHT
; i
++ )
5948 sal_Int32
nSize( 0 );
5949 const sal_uInt32 nCount
= aRowColumnSizes
[i
].size();
5950 for ( sal_uInt32 j
= 0; j
< nCount
; j
++ )
5951 nSize
+= aRowColumnSizes
[i
][j
];
5953 if ( i
== DockingArea_DOCKINGAREA_TOP
)
5954 aBorderSpace
.Y
= nSize
;
5955 else if ( i
== DockingArea_DOCKINGAREA_BOTTOM
)
5956 aBorderSpace
.Height
= nSize
;
5957 else if ( i
== DockingArea_DOCKINGAREA_LEFT
)
5958 aBorderSpace
.X
= nSize
;
5960 aBorderSpace
.Width
= nSize
;
5964 // We have to add the height of a possible status bar
5965 aBorderSpace
.Height
+= implts_getStatusBarSize().Height();
5968 return aBorderSpace
;
5971 void LayoutManager::implts_setDockingAreaWindowSizes( const css::awt::Rectangle
& rBorderSpace
)
5973 Reference
< css::awt::XWindow
> xContainerWindow
;
5975 ReadGuard
aReadLock( m_aLock
);
5976 xContainerWindow
= m_xContainerWindow
;
5979 css::uno::Reference
< css::awt::XDevice
> xDevice( xContainerWindow
, css::uno::UNO_QUERY
);
5980 // Convert relativ size to output size.
5981 css::awt::Rectangle aRectangle
= xContainerWindow
->getPosSize();
5982 css::awt::DeviceInfo aInfo
= xDevice
->getInfo();
5983 css::awt::Size aContainerClientSize
= css::awt::Size( aRectangle
.Width
- aInfo
.LeftInset
- aInfo
.RightInset
,
5984 aRectangle
.Height
- aInfo
.TopInset
- aInfo
.BottomInset
);
5985 ::Size aStatusBarSize
= implts_getStatusBarSize();
5987 sal_Int32
nLeftRightDockingAreaHeight( aContainerClientSize
.Height
);
5988 if ( rBorderSpace
.Y
>= 0 )
5990 // Top docking area window
5992 Reference
< css::awt::XWindow
> xDockAreaWindow( m_xDockAreaWindows
[DockingArea_DOCKINGAREA_TOP
] );
5995 xDockAreaWindow
->setPosSize( 0, 0, aContainerClientSize
.Width
, rBorderSpace
.Y
, css::awt::PosSize::POSSIZE
);
5996 xDockAreaWindow
->setVisible( sal_True
);
5997 nLeftRightDockingAreaHeight
-= rBorderSpace
.Y
;
6000 if ( rBorderSpace
.Height
>= 0 )
6002 // Bottom docking area window
6003 sal_Int32 nBottomPos
= std::max( sal_Int32( aContainerClientSize
.Height
- rBorderSpace
.Height
- aStatusBarSize
.Height() ), sal_Int32( 0 ));
6004 sal_Int32 nHeight
= ( nBottomPos
== 0 ) ? 0 : rBorderSpace
.Height
;
6007 Reference
< css::awt::XWindow
> xDockAreaWindow( m_xDockAreaWindows
[DockingArea_DOCKINGAREA_BOTTOM
] );
6010 xDockAreaWindow
->setPosSize( 0, nBottomPos
, aContainerClientSize
.Width
, nHeight
, css::awt::PosSize::POSSIZE
);
6011 xDockAreaWindow
->setVisible( sal_True
);
6012 nLeftRightDockingAreaHeight
-= nHeight
;
6015 nLeftRightDockingAreaHeight
-= aStatusBarSize
.Height();
6016 if ( rBorderSpace
.X
>= 0 || nLeftRightDockingAreaHeight
> 0 )
6018 // Left docking area window
6020 Reference
< css::awt::XWindow
> xDockAreaWindow( m_xDockAreaWindows
[DockingArea_DOCKINGAREA_LEFT
] );
6023 // We also have to change our right docking area window if the top or bottom area has changed. They have a higher priority!
6024 sal_Int32 nHeight
= std::max( sal_Int32( 0 ), sal_Int32( nLeftRightDockingAreaHeight
));
6026 xDockAreaWindow
->setPosSize( 0, rBorderSpace
.Y
, rBorderSpace
.X
, nHeight
, css::awt::PosSize::POSSIZE
);
6027 xDockAreaWindow
->setVisible( sal_True
);
6029 if ( rBorderSpace
.Width
>= 0 || nLeftRightDockingAreaHeight
> 0 )
6031 // Right docking area window
6033 Reference
< css::awt::XWindow
> xDockAreaWindow( m_xDockAreaWindows
[DockingArea_DOCKINGAREA_RIGHT
] );
6036 // We also have to change our right docking area window if the top or bottom area has changed. They have a higher priority!
6037 sal_Int32 nLeftPos
= std::max( sal_Int32( 0 ), sal_Int32( aContainerClientSize
.Width
- rBorderSpace
.Width
));
6038 sal_Int32 nHeight
= std::max( sal_Int32( 0 ), sal_Int32( nLeftRightDockingAreaHeight
));
6039 sal_Int32 nWidth
= ( nLeftPos
== 0 ) ? 0 : rBorderSpace
.Width
;
6041 xDockAreaWindow
->setPosSize( nLeftPos
, rBorderSpace
.Y
, nWidth
, nHeight
, css::awt::PosSize::POSSIZE
);
6042 xDockAreaWindow
->setVisible( sal_True
);
6045 // Position the status bar
6046 if ( aStatusBarSize
.Height() > 0 )
6048 implts_setStatusBarPosSize( ::Point( 0, std::max(( aContainerClientSize
.Height
- aStatusBarSize
.Height() ), long( 0 ))),
6049 ::Size( aContainerClientSize
.Width
, aStatusBarSize
.Height() ));
6053 //---------------------------------------------------------------------------------------------------------
6055 //---------------------------------------------------------------------------------------------------------
6056 void LayoutManager::implts_updateMenuBarClose()
6058 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6059 WriteGuard
aWriteLock( m_aLock
);
6060 sal_Bool bShowCloser
= m_bMenuBarCloser
;
6061 Reference
< css::awt::XWindow
> xContainerWindow( m_xContainerWindow
);
6062 aWriteLock
.unlock();
6064 if ( xContainerWindow
.is() )
6066 vos::OGuard
aGuard( Application::GetSolarMutex() );
6068 Window
* pWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
6069 while ( pWindow
&& !pWindow
->IsSystemWindow() )
6070 pWindow
= pWindow
->GetParent();
6074 SystemWindow
* pSysWindow
= (SystemWindow
*)pWindow
;
6075 MenuBar
* pMenuBar
= pSysWindow
->GetMenuBar();
6078 // TODO remove link on FALSE ?!
6081 pMenuBar
->ShowCloser( TRUE
);
6082 pMenuBar
->SetCloserHdl( LINK( this, LayoutManager
, MenuBarClose
));
6086 pMenuBar
->ShowCloser( FALSE
);
6087 pMenuBar
->SetCloserHdl( LINK( this, LayoutManager
, MenuBarClose
));
6094 sal_Bool
LayoutManager::implts_resetMenuBar()
6096 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6097 WriteGuard
aWriteLock( m_aLock
);
6098 sal_Bool
bMenuVisible( m_bMenuVisible
);
6099 Reference
< css::awt::XWindow
> xContainerWindow( m_xContainerWindow
);
6101 MenuBar
* pSetMenuBar
= 0;
6102 if ( m_xInplaceMenuBar
.is() )
6103 pSetMenuBar
= (MenuBar
*)m_pInplaceMenuBar
->GetMenuBar();
6106 MenuBarWrapper
* pMenuBarWrapper
= SAL_STATIC_CAST( MenuBarWrapper
*, m_xMenuBar
.get() );
6107 if ( pMenuBarWrapper
)
6108 pSetMenuBar
= (MenuBar
*)pMenuBarWrapper
->GetMenuBarManager()->GetMenuBar();
6110 aWriteLock
.unlock();
6111 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6113 vos::OGuard
aGuard( Application::GetSolarMutex() );
6114 Window
* pWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
6115 while ( pWindow
&& !pWindow
->IsSystemWindow() )
6116 pWindow
= pWindow
->GetParent();
6118 if ( pWindow
&& bMenuVisible
&& pSetMenuBar
)
6120 ((SystemWindow
*)pWindow
)->SetMenuBar( pSetMenuBar
);
6121 pSetMenuBar
->SetDisplayable( sal_True
);
6128 void LayoutManager::implts_setMenuBarCloser(sal_Bool bCloserState
)
6130 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6131 WriteGuard
aWriteLock( m_aLock
);
6132 m_bMenuBarCloser
= bCloserState
;
6133 aWriteLock
.unlock();
6135 implts_updateMenuBarClose();
6138 sal_Int16
LayoutManager::implts_getCurrentSymbolsSize()
6140 sal_Int16
eOptSymbolsSize( 0 );
6143 ReadGuard
aReadLock( m_aLock
);
6144 vos::OGuard
aGuard( Application::GetSolarMutex() );
6145 if ( m_pMiscOptions
)
6146 eOptSymbolsSize
= m_pMiscOptions
->GetCurrentSymbolsSize();
6149 return eOptSymbolsSize
;
6152 sal_Int16
LayoutManager::implts_getCurrentSymbolsStyle()
6154 sal_Int16
eOptSymbolsStyle( 0 );
6157 ReadGuard
aReadLock( m_aLock
);
6158 vos::OGuard
aGuard( Application::GetSolarMutex() );
6159 if ( m_pMiscOptions
)
6160 eOptSymbolsStyle
= m_pMiscOptions
->GetCurrentSymbolsStyle();
6163 return eOptSymbolsStyle
;
6166 IMPL_LINK( LayoutManager
, MenuBarClose
, MenuBar
*, EMPTYARG
)
6168 ReadGuard
aReadLock( m_aLock
);
6169 css::uno::Reference
< css::frame::XDispatchProvider
> xProvider(m_xFrame
, css::uno::UNO_QUERY
);
6170 css::uno::Reference
< css::lang::XMultiServiceFactory
> xSMGR
= m_xSMGR
;
6173 if (! xProvider
.is())
6176 css::uno::Reference
< css::frame::XDispatchHelper
> xDispatcher(
6177 xSMGR
->createInstance(SERVICENAME_DISPATCHHELPER
), css::uno::UNO_QUERY_THROW
);
6179 xDispatcher
->executeDispatch(
6181 ::rtl::OUString::createFromAscii(".uno:CloseWin"),
6182 ::rtl::OUString::createFromAscii("_self"),
6184 css::uno::Sequence
< css::beans::PropertyValue
>());
6189 IMPL_LINK( LayoutManager
, OptionsChanged
, void*, EMPTYARG
)
6191 sal_Int16
eSymbolsSize( implts_getCurrentSymbolsSize() );
6192 sal_Int16
eSymbolsStyle( implts_getCurrentSymbolsStyle() );
6194 ReadGuard
aReadLock( m_aLock
);
6195 sal_Int16 eOldSymbolsSize
= m_eSymbolsSize
;
6196 sal_Int16 eOldSymbolsStyle
= m_eSymbolsStyle
;
6199 if ( eSymbolsSize
!= eOldSymbolsSize
|| eSymbolsStyle
!= eOldSymbolsStyle
)
6201 WriteGuard
aWriteLock( m_aLock
);
6202 m_eSymbolsSize
= eSymbolsSize
;
6203 m_eSymbolsStyle
= eSymbolsStyle
;
6204 aWriteLock
.unlock();
6206 std::vector
< Reference
< XUpdatable
> > aToolBarVector
;
6210 UIElementVector::iterator pIter
;
6211 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
6213 if ( pIter
->m_xUIElement
.is() )
6214 aToolBarVector
.push_back( Reference
< XUpdatable
>( pIter
->m_xUIElement
, UNO_QUERY
));
6221 std::vector
< Reference
< XUpdatable
> >::iterator pIter
;
6222 for ( pIter
= aToolBarVector
.begin(); pIter
!= aToolBarVector
.end(); pIter
++ )
6224 if ( (*pIter
).is() )
6235 IMPL_LINK( LayoutManager
, SettingsChanged
, void*, EMPTYARG
)
6240 //---------------------------------------------------------------------------------------------------------
6241 // XDockableWindowListener
6242 //---------------------------------------------------------------------------------------------------------
6243 void SAL_CALL
LayoutManager::startDocking( const ::com::sun::star::awt::DockingEvent
& e
) throw (::com::sun::star::uno::RuntimeException
)
6245 sal_Bool
bWinFound( sal_False
);
6246 UIElement aUIElement
;
6248 ReadGuard
aReadGuard( m_aLock
);
6249 Reference
< css::awt::XWindow
> xContainerWindow( m_xContainerWindow
);
6250 Reference
< css::awt::XWindow2
> xWindow( e
.Source
, UNO_QUERY
);
6251 aReadGuard
.unlock();
6253 Window
* pContainerWindow( 0 );
6254 Window
* pWindow( 0 );
6257 vos::OGuard
aGuard( Application::GetSolarMutex() );
6258 pContainerWindow
= VCLUnoHelper::GetWindow( xContainerWindow
);
6259 aMousePos
= pContainerWindow
->ScreenToOutputPixel( ::Point( e
.MousePos
.X
, e
.MousePos
.Y
));
6262 bWinFound
= implts_findElement( e
.Source
, aUIElement
);
6264 if ( bWinFound
&& xWindow
.is() )
6266 css::awt::Rectangle aRect
;
6267 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
6268 if ( xDockWindow
->isFloating() )
6270 css::awt::Rectangle aPos
= xWindow
->getPosSize();
6271 css::awt::Size aSize
= xWindow
->getOutputSize();
6273 aUIElement
.m_aFloatingData
.m_aPos
= ::Point( aPos
.X
, aPos
.Y
);
6274 aUIElement
.m_aFloatingData
.m_aSize
= ::Size( aSize
.Width
, aSize
.Height
);
6276 vos::OGuard
aGuard( Application::GetSolarMutex() );
6277 pWindow
= VCLUnoHelper::GetWindow( xWindow
);
6278 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
6280 ToolBox
* pToolBox
= (ToolBox
*)pWindow
;
6281 aUIElement
.m_aFloatingData
.m_nLines
= pToolBox
->GetFloatingLines();
6282 aUIElement
.m_aFloatingData
.m_bIsHorizontal
= (( pToolBox
->GetAlign() == WINDOWALIGN_TOP
) ||
6283 ( pToolBox
->GetAlign() == WINDOWALIGN_BOTTOM
));
6288 WriteGuard
aWriteLock( m_aLock
);
6289 m_bDockingInProgress
= bWinFound
;
6290 m_aDockUIElement
= aUIElement
;
6291 m_aDockUIElement
.m_bUserActive
= sal_True
;
6292 m_aStartDockMousePos
= aMousePos
;
6293 aWriteLock
.unlock();
6296 ::Rectangle
LayoutManager::implts_calcHotZoneRect( const ::Rectangle
& rRect
, sal_Int32 nHotZoneOffset
)
6298 ::Rectangle
aRect( rRect
);
6300 aRect
.Left() -= nHotZoneOffset
;
6301 aRect
.Top() -= nHotZoneOffset
;
6302 aRect
.Right() += nHotZoneOffset
;
6303 aRect
.Bottom() += nHotZoneOffset
;
6307 css::awt::DockingData SAL_CALL
LayoutManager::docking( const ::com::sun::star::awt::DockingEvent
& e
)
6308 throw (::com::sun::star::uno::RuntimeException
)
6310 const sal_Int32 MAGNETIC_DISTANCE_UNDOCK
= 25;
6311 const sal_Int32 MAGNETIC_DISTANCE_DOCK
= 20;
6313 css::awt::DockingData aDockingData
;
6314 Reference
< css::awt::XDockableWindow
> xDockWindow( e
.Source
, UNO_QUERY
);
6315 Reference
< css::awt::XWindow
> xWindow( e
.Source
, UNO_QUERY
);
6316 Reference
< css::awt::XWindow
> xTopDockingWindow
;
6317 Reference
< css::awt::XWindow
> xLeftDockingWindow
;
6318 Reference
< css::awt::XWindow
> xRightDockingWindow
;
6319 Reference
< css::awt::XWindow
> xBottomDockingWindow
;
6320 Reference
< css::awt::XWindow
> xContainerWindow
;
6321 UIElement aUIDockingElement
;
6322 DockingOperation
eDockingOperation( DOCKOP_ON_COLROW
);
6323 ::Size aStatusBarSize
;
6325 aDockingData
.TrackingRectangle
= e
.TrackingRectangle
;
6326 sal_Bool bDockingInProgress
;
6329 ReadGuard
aReadLock( m_aLock
);
6330 bDockingInProgress
= m_bDockingInProgress
;
6331 if ( bDockingInProgress
)
6333 xContainerWindow
= m_xContainerWindow
;
6334 xTopDockingWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_TOP
];
6335 xLeftDockingWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_LEFT
];
6336 xRightDockingWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_RIGHT
];
6337 xBottomDockingWindow
= m_xDockAreaWindows
[DockingArea_DOCKINGAREA_BOTTOM
];
6338 aUIDockingElement
= m_aDockUIElement
;
6339 aStatusBarSize
= implts_getStatusBarSize();
6343 if ( bDockingInProgress
&&
6349 vos::OGuard
aGuard( Application::GetSolarMutex() );
6351 sal_Int16
eDockingArea( -1 ); // none
6352 sal_Int32
nMagneticZone( aUIDockingElement
.m_bFloating
? MAGNETIC_DISTANCE_DOCK
: MAGNETIC_DISTANCE_UNDOCK
);
6353 css::awt::Rectangle aNewTrackingRect
;
6354 ::Rectangle
aTrackingRect( e
.TrackingRectangle
.X
,
6355 e
.TrackingRectangle
.Y
,
6356 ( e
.TrackingRectangle
.X
+ e
.TrackingRectangle
.Width
),
6357 ( e
.TrackingRectangle
.Y
+ e
.TrackingRectangle
.Height
));
6359 css::awt::Rectangle aTmpRect
= xTopDockingWindow
->getPosSize();
6360 ::Rectangle
aTopDockRect( aTmpRect
.X
, aTmpRect
.Y
, aTmpRect
.Width
, aTmpRect
.Height
);
6361 ::Rectangle
aHotZoneTopDockRect( implts_calcHotZoneRect( aTopDockRect
, nMagneticZone
));
6363 aTmpRect
= xBottomDockingWindow
->getPosSize();
6364 ::Rectangle
aBottomDockRect( aTmpRect
.X
, aTmpRect
.Y
, ( aTmpRect
.X
+ aTmpRect
.Width
), ( aTmpRect
.Y
+ aTmpRect
.Height
));
6365 ::Rectangle
aHotZoneBottomDockRect( implts_calcHotZoneRect( aBottomDockRect
, nMagneticZone
));
6367 aTmpRect
= xLeftDockingWindow
->getPosSize();
6368 ::Rectangle
aLeftDockRect( aTmpRect
.X
, aTmpRect
.Y
, ( aTmpRect
.X
+ aTmpRect
.Width
), ( aTmpRect
.Y
+ aTmpRect
.Height
));
6369 ::Rectangle
aHotZoneLeftDockRect( implts_calcHotZoneRect( aLeftDockRect
, nMagneticZone
));
6371 aTmpRect
= xRightDockingWindow
->getPosSize();
6372 ::Rectangle
aRightDockRect( aTmpRect
.X
, aTmpRect
.Y
, ( aTmpRect
.X
+ aTmpRect
.Width
), ( aTmpRect
.Y
+ aTmpRect
.Height
));
6373 ::Rectangle
aHotZoneRightDockRect( implts_calcHotZoneRect( aRightDockRect
, nMagneticZone
));
6375 Window
* pContainerWindow( VCLUnoHelper::GetWindow( xContainerWindow
) );
6376 Window
* pDockingAreaWindow( 0 );
6377 ::Point
aMousePos( pContainerWindow
->ScreenToOutputPixel( ::Point( e
.MousePos
.X
, e
.MousePos
.Y
)));
6379 if ( aHotZoneTopDockRect
.IsInside( aMousePos
))
6380 eDockingArea
= DockingArea_DOCKINGAREA_TOP
;
6381 else if ( aHotZoneBottomDockRect
.IsInside( aMousePos
))
6382 eDockingArea
= DockingArea_DOCKINGAREA_BOTTOM
;
6383 else if ( aHotZoneLeftDockRect
.IsInside( aMousePos
))
6384 eDockingArea
= DockingArea_DOCKINGAREA_LEFT
;
6385 else if ( aHotZoneRightDockRect
.IsInside( aMousePos
))
6386 eDockingArea
= DockingArea_DOCKINGAREA_RIGHT
;
6388 // Higher priority for movements inside the real docking area
6389 if ( aTopDockRect
.IsInside( aMousePos
))
6390 eDockingArea
= DockingArea_DOCKINGAREA_TOP
;
6391 else if ( aBottomDockRect
.IsInside( aMousePos
))
6392 eDockingArea
= DockingArea_DOCKINGAREA_BOTTOM
;
6393 else if ( aLeftDockRect
.IsInside( aMousePos
))
6394 eDockingArea
= DockingArea_DOCKINGAREA_LEFT
;
6395 else if ( aRightDockRect
.IsInside( aMousePos
))
6396 eDockingArea
= DockingArea_DOCKINGAREA_RIGHT
;
6398 // Determine if we have a toolbar and set alignment according to the docking area!
6399 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
6400 ToolBox
* pToolBox
= 0;
6401 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
6402 pToolBox
= (ToolBox
*)pWindow
;
6404 if ( eDockingArea
!= -1 )
6406 if ( eDockingArea
== DockingArea_DOCKINGAREA_TOP
)
6408 aUIDockingElement
.m_aDockedData
.m_nDockedArea
= DockingArea_DOCKINGAREA_TOP
;
6409 aUIDockingElement
.m_bFloating
= sal_False
;
6410 pDockingAreaWindow
= VCLUnoHelper::GetWindow( xTopDockingWindow
);
6412 else if ( eDockingArea
== DockingArea_DOCKINGAREA_BOTTOM
)
6414 aUIDockingElement
.m_aDockedData
.m_nDockedArea
= DockingArea_DOCKINGAREA_BOTTOM
;
6415 aUIDockingElement
.m_bFloating
= sal_False
;
6416 pDockingAreaWindow
= VCLUnoHelper::GetWindow( xBottomDockingWindow
);
6418 else if ( eDockingArea
== DockingArea_DOCKINGAREA_LEFT
)
6420 aUIDockingElement
.m_aDockedData
.m_nDockedArea
= DockingArea_DOCKINGAREA_LEFT
;
6421 aUIDockingElement
.m_bFloating
= sal_False
;
6422 pDockingAreaWindow
= VCLUnoHelper::GetWindow( xLeftDockingWindow
);
6424 else if ( eDockingArea
== DockingArea_DOCKINGAREA_RIGHT
)
6426 aUIDockingElement
.m_aDockedData
.m_nDockedArea
= DockingArea_DOCKINGAREA_RIGHT
;
6427 aUIDockingElement
.m_bFloating
= sal_False
;
6428 pDockingAreaWindow
= VCLUnoHelper::GetWindow( xRightDockingWindow
);
6431 ::Point aOutputPos
= pContainerWindow
->ScreenToOutputPixel( aTrackingRect
.TopLeft() );
6432 aTrackingRect
.SetPos( aOutputPos
);
6434 ::Rectangle
aNewDockingRect( aTrackingRect
);
6435 implts_calcDockingPosSize( aUIDockingElement
, eDockingOperation
, aNewDockingRect
, aMousePos
);
6437 ::Point aScreenPos
= pContainerWindow
->OutputToScreenPixel( aNewDockingRect
.TopLeft() );
6438 aNewTrackingRect
= css::awt::Rectangle( aScreenPos
.X(),
6440 aNewDockingRect
.getWidth(),
6441 aNewDockingRect
.getHeight() );
6442 aDockingData
.TrackingRectangle
= aNewTrackingRect
;
6444 else if ( pToolBox
&& bDockingInProgress
)
6446 sal_Bool bIsHorizontal
= (( pToolBox
->GetAlign() == WINDOWALIGN_TOP
) ||
6447 ( pToolBox
->GetAlign() == WINDOWALIGN_BOTTOM
));
6448 ::Size aFloatSize
= aUIDockingElement
.m_aFloatingData
.m_aSize
;
6449 if ( aFloatSize
.Width() > 0 && aFloatSize
.Height() > 0 )
6451 aUIDockingElement
.m_aFloatingData
.m_aPos
= pContainerWindow
->ScreenToOutputPixel(
6452 ::Point( e
.MousePos
.X
, e
.MousePos
.Y
));
6453 aDockingData
.TrackingRectangle
.Height
= aFloatSize
.Height();
6454 aDockingData
.TrackingRectangle
.Width
= aFloatSize
.Width();
6458 aFloatSize
= pToolBox
->CalcWindowSizePixel();
6459 if ( !bIsHorizontal
)
6461 // Floating toolbars are always horizontal aligned! We have to swap
6462 // width/height if we have a vertical aligned toolbar.
6463 sal_Int32 nTemp
= aFloatSize
.Height();
6464 aFloatSize
.Height() = aFloatSize
.Width();
6465 aFloatSize
.Width() = nTemp
;
6468 aDockingData
.TrackingRectangle
.Height
= aFloatSize
.Height();
6469 aDockingData
.TrackingRectangle
.Width
= aFloatSize
.Width();
6471 // For the first time we don't have any data about the floating size of a toolbar.
6472 // We calculate it and store it for later use.
6473 aUIDockingElement
.m_aFloatingData
.m_aPos
= pContainerWindow
->ScreenToOutputPixel(
6474 ::Point( e
.MousePos
.X
, e
.MousePos
.Y
));
6475 aUIDockingElement
.m_aFloatingData
.m_aSize
= aFloatSize
;
6476 aUIDockingElement
.m_aFloatingData
.m_nLines
= pToolBox
->GetFloatingLines();
6477 aUIDockingElement
.m_aFloatingData
.m_bIsHorizontal
= (( pToolBox
->GetAlign() == WINDOWALIGN_TOP
) ||
6478 ( pToolBox
->GetAlign() == WINDOWALIGN_BOTTOM
));
6480 aDockingData
.TrackingRectangle
.X
= e
.MousePos
.X
;
6481 aDockingData
.TrackingRectangle
.Y
= e
.MousePos
.Y
;
6484 aDockingData
.bFloating
= ( eDockingArea
== -1 );
6486 // Write current data to the member docking progress data
6487 WriteGuard
aWriteLock( m_aLock
);
6488 m_aDockUIElement
.m_bFloating
= aDockingData
.bFloating
;
6489 if ( !aDockingData
.bFloating
)
6491 m_aDockUIElement
.m_aDockedData
= aUIDockingElement
.m_aDockedData
;
6492 m_eDockOperation
= eDockingOperation
;
6495 m_aDockUIElement
.m_aFloatingData
= aUIDockingElement
.m_aFloatingData
;
6496 aWriteLock
.unlock();
6498 catch ( Exception
& )
6503 return aDockingData
;
6506 void SAL_CALL
LayoutManager::endDocking( const ::com::sun::star::awt::EndDockingEvent
& e
)
6507 throw (::com::sun::star::uno::RuntimeException
)
6509 sal_Bool
bDockingInProgress( sal_False
);
6510 sal_Bool
bStartDockFloated( sal_False
);
6511 sal_Bool
bFloating( sal_False
);
6512 UIElement aUIDockingElement
;
6514 WriteGuard
aWriteLock( m_aLock
);
6515 bDockingInProgress
= m_bDockingInProgress
;
6516 aUIDockingElement
= m_aDockUIElement
;
6517 bFloating
= aUIDockingElement
.m_bFloating
;
6519 UIElement
& rUIElement
= impl_findElement( aUIDockingElement
.m_aName
);
6520 if ( rUIElement
.m_aName
== aUIDockingElement
.m_aName
)
6522 if ( aUIDockingElement
.m_bFloating
)
6524 // Write last position into position data
6525 Reference
< css::awt::XWindow
> xWindow( aUIDockingElement
.m_xUIElement
->getRealInterface(), UNO_QUERY
);
6526 rUIElement
.m_aFloatingData
= aUIDockingElement
.m_aFloatingData
;
6527 css::awt::Rectangle aTmpRect
= xWindow
->getPosSize();
6528 rUIElement
.m_aFloatingData
.m_aPos
= ::Point( aTmpRect
.X
, aTmpRect
.Y
);
6529 // make changes also for our local data as we use it to make data persistent
6530 aUIDockingElement
.m_aFloatingData
= rUIElement
.m_aFloatingData
;
6534 rUIElement
.m_aDockedData
= aUIDockingElement
.m_aDockedData
;
6535 rUIElement
.m_aFloatingData
.m_aSize
= aUIDockingElement
.m_aFloatingData
.m_aSize
;
6537 if ( m_eDockOperation
!= DOCKOP_ON_COLROW
)
6539 // we have to renumber our row/column data to insert a new row/column
6540 implts_renumberRowColumnData( (::com::sun::star::ui::DockingArea
)aUIDockingElement
.m_aDockedData
.m_nDockedArea
,
6542 aUIDockingElement
);
6546 bStartDockFloated
= rUIElement
.m_bFloating
;
6547 rUIElement
.m_bFloating
= m_aDockUIElement
.m_bFloating
;
6548 rUIElement
.m_bUserActive
= sal_True
;
6551 // reset member for next docking operation
6552 m_aDockUIElement
.m_xUIElement
.clear();
6553 m_eDockOperation
= DOCKOP_ON_COLROW
;
6554 aWriteLock
.unlock();
6556 implts_writeWindowStateData( aUIDockingElement
.m_aName
, aUIDockingElement
);
6558 if ( bDockingInProgress
)
6560 vos::OGuard
aGuard( Application::GetSolarMutex() );
6561 Window
* pWindow
= VCLUnoHelper::GetWindow( Reference
< css::awt::XWindow
>( e
.Source
, UNO_QUERY
));
6562 ToolBox
* pToolBox
= 0;
6563 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
6564 pToolBox
= (ToolBox
*)pWindow
;
6570 if ( aUIDockingElement
.m_aFloatingData
.m_bIsHorizontal
)
6571 pToolBox
->SetAlign( WINDOWALIGN_TOP
);
6573 pToolBox
->SetAlign( WINDOWALIGN_LEFT
);
6579 pToolBox
->SetAlign( ImplConvertAlignment( aUIDockingElement
.m_aDockedData
.m_nDockedArea
) );
6581 // Docked toolbars have always one line
6582 aSize
= pToolBox
->CalcWindowSizePixel( 1 );
6584 // Lock layouting updates as our listener would be called due to SetSizePixel
6585 pToolBox
->SetOutputSizePixel( aSize
);
6591 m_bDockingInProgress
= sal_False
;
6592 aWriteLock
.unlock();
6594 implts_sortUIElements();
6595 if ( !bStartDockFloated
|| !bFloating
)
6597 // Optimization: Don't layout if we started floating and now floating again.
6598 // This would not change anything for the docked user-interface elements.
6603 sal_Bool SAL_CALL
LayoutManager::prepareToggleFloatingMode( const ::com::sun::star::lang::EventObject
& e
)
6604 throw (::com::sun::star::uno::RuntimeException
)
6606 sal_Bool
bDockingInProgress( sal_False
);
6608 ReadGuard
aReadLock( m_aLock
);
6609 bDockingInProgress
= m_bDockingInProgress
;
6612 UIElement aUIDockingElement
;
6613 sal_Bool
bWinFound( implts_findElement( e
.Source
, aUIDockingElement
) );
6614 Reference
< css::awt::XWindow
> xWindow( e
.Source
, UNO_QUERY
);
6616 if ( bWinFound
&& xWindow
.is() )
6618 if ( !bDockingInProgress
)
6620 css::awt::Rectangle aRect
;
6621 Reference
< css::awt::XDockableWindow
> xDockWindow( xWindow
, UNO_QUERY
);
6622 if ( xDockWindow
->isFloating() )
6625 vos::OGuard
aGuard( Application::GetSolarMutex() );
6626 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
6629 if ( pWindow
->GetType() == WINDOW_TOOLBOX
)
6631 ToolBox
* pToolBox
= (ToolBox
*)pWindow
;
6632 aUIDockingElement
.m_aFloatingData
.m_aPos
= pToolBox
->GetPosPixel();
6633 aUIDockingElement
.m_aFloatingData
.m_aSize
= pToolBox
->GetOutputSizePixel();
6634 aUIDockingElement
.m_aFloatingData
.m_nLines
= pToolBox
->GetFloatingLines();
6635 aUIDockingElement
.m_aFloatingData
.m_bIsHorizontal
= (( pToolBox
->GetAlign() == WINDOWALIGN_TOP
) ||
6636 ( pToolBox
->GetAlign() == WINDOWALIGN_BOTTOM
));
6641 WriteGuard
aWriteLock( m_aLock
);
6642 UIElement
& rUIElement
= LayoutManager::impl_findElement( aUIDockingElement
.m_aName
);
6643 if ( rUIElement
.m_aName
== aUIDockingElement
.m_aName
)
6644 rUIElement
= aUIDockingElement
;
6645 aWriteLock
.unlock();
6653 void SAL_CALL
LayoutManager::toggleFloatingMode( const ::com::sun::star::lang::EventObject
& e
)
6654 throw (::com::sun::star::uno::RuntimeException
)
6656 sal_Bool
bDockingInProgress( sal_False
);
6657 UIElement aUIDockingElement
;
6659 ReadGuard
aReadLock( m_aLock
);
6660 bDockingInProgress
= m_bDockingInProgress
;
6661 if ( bDockingInProgress
)
6662 aUIDockingElement
= m_aDockUIElement
;
6665 Window
* pWindow( 0 );
6666 ToolBox
* pToolBox( 0 );
6667 Reference
< css::awt::XWindow2
> xWindow
;
6670 vos::OGuard
aGuard( Application::GetSolarMutex() );
6671 xWindow
= Reference
< css::awt::XWindow2
>( e
.Source
, UNO_QUERY
);
6672 pWindow
= VCLUnoHelper::GetWindow( xWindow
);
6674 if ( pWindow
&& pWindow
->GetType() == WINDOW_TOOLBOX
)
6675 pToolBox
= (ToolBox
*)pWindow
;
6678 if ( !bDockingInProgress
)
6680 sal_Bool
bWinFound( implts_findElement( e
.Source
, aUIDockingElement
) );
6681 if ( bWinFound
&& xWindow
.is() )
6683 aUIDockingElement
.m_bFloating
= !aUIDockingElement
.m_bFloating
;
6684 aUIDockingElement
.m_bUserActive
= sal_True
;
6686 WriteGuard
aWriteLock( m_aLock
);
6687 m_bDoLayout
= sal_True
;
6688 aWriteLock
.unlock();
6690 if ( aUIDockingElement
.m_bFloating
)
6692 vos::OGuard
aGuard( Application::GetSolarMutex() );
6695 pToolBox
->SetLineCount( aUIDockingElement
.m_aFloatingData
.m_nLines
);
6696 if ( aUIDockingElement
.m_aFloatingData
.m_bIsHorizontal
)
6697 pToolBox
->SetAlign( WINDOWALIGN_TOP
);
6699 pToolBox
->SetAlign( WINDOWALIGN_LEFT
);
6702 sal_Bool bUndefPos
= ( aUIDockingElement
.m_aFloatingData
.m_aPos
.X() == SAL_MAX_INT32
||
6703 aUIDockingElement
.m_aFloatingData
.m_aPos
.Y() == SAL_MAX_INT32
);
6704 sal_Bool bSetSize
= ( aUIDockingElement
.m_aFloatingData
.m_aSize
.Width() != 0 &&
6705 aUIDockingElement
.m_aFloatingData
.m_aSize
.Height() != 0 );
6708 aUIDockingElement
.m_aFloatingData
.m_aPos
= implts_findNextCascadeFloatingPos();
6713 aUIDockingElement
.m_aFloatingData
.m_aSize
= pToolBox
->CalcFloatingWindowSizePixel();
6715 aUIDockingElement
.m_aFloatingData
.m_aSize
= pWindow
->GetOutputSizePixel();
6718 xWindow
->setPosSize( aUIDockingElement
.m_aFloatingData
.m_aPos
.X(),
6719 aUIDockingElement
.m_aFloatingData
.m_aPos
.Y(),
6720 0, 0, css::awt::PosSize::POS
);
6721 xWindow
->setOutputSize( AWTSize( aUIDockingElement
.m_aFloatingData
.m_aSize
) );
6725 if (( aUIDockingElement
.m_aDockedData
.m_aPos
.X() == SAL_MAX_INT32
) &&
6726 ( aUIDockingElement
.m_aDockedData
.m_aPos
.Y() == SAL_MAX_INT32
))
6728 // Docking on its default position without a preset position -
6729 // we have to find a good place for it.
6735 vos::OGuard
aGuard( Application::GetSolarMutex() );
6737 aSize
= pToolBox
->CalcWindowSizePixel( 1, ImplConvertAlignment( aUIDockingElement
.m_aDockedData
.m_nDockedArea
) );
6739 aSize
= pWindow
->GetSizePixel();
6742 implts_findNextDockingPos( (::com::sun::star::ui::DockingArea
)aUIDockingElement
.m_aDockedData
.m_nDockedArea
,
6746 aUIDockingElement
.m_aDockedData
.m_aPos
= aDockPos
;
6749 vos::OGuard
aGuard( Application::GetSolarMutex() );
6752 pToolBox
->SetAlign( ImplConvertAlignment( aUIDockingElement
.m_aDockedData
.m_nDockedArea
) );
6753 ::Size aSize
= pToolBox
->CalcWindowSizePixel( 1 );
6754 css::awt::Rectangle aRect
= xWindow
->getPosSize();
6755 xWindow
->setPosSize( aRect
.X
, aRect
.Y
, 0, 0, css::awt::PosSize::POS
);
6756 xWindow
->setOutputSize( AWTSize( aSize
) );
6761 m_bDoLayout
= sal_False
;
6762 UIElement
& rUIElement
= LayoutManager::impl_findElement( aUIDockingElement
.m_aName
);
6763 if ( rUIElement
.m_aName
== aUIDockingElement
.m_aName
)
6764 rUIElement
= aUIDockingElement
;
6765 aWriteLock
.unlock();
6767 implts_writeWindowStateData( aUIDockingElement
.m_aName
, aUIDockingElement
);
6769 implts_sortUIElements();
6775 vos::OGuard
aGuard( Application::GetSolarMutex() );
6778 if ( aUIDockingElement
.m_bFloating
)
6780 if ( aUIDockingElement
.m_aFloatingData
.m_bIsHorizontal
)
6781 pToolBox
->SetAlign( WINDOWALIGN_TOP
);
6783 pToolBox
->SetAlign( WINDOWALIGN_LEFT
);
6787 pToolBox
->SetAlign( ImplConvertAlignment( aUIDockingElement
.m_aDockedData
.m_nDockedArea
) );
6793 void SAL_CALL
LayoutManager::closed( const ::com::sun::star::lang::EventObject
& e
)
6794 throw (::com::sun::star::uno::RuntimeException
)
6796 rtl::OUString aName
;
6797 UIElement aUIElement
;
6798 UIElementVector::iterator pIter
;
6800 WriteGuard
aWriteLock( m_aLock
);
6801 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
6803 Reference
< XUIElement
> xUIElement( pIter
->m_xUIElement
);
6804 if ( xUIElement
.is() )
6806 Reference
< XInterface
> xIfac( xUIElement
->getRealInterface(), UNO_QUERY
);
6807 if ( xIfac
== e
.Source
)
6809 aName
= pIter
->m_aName
;
6811 // user closes a toolbar =>
6812 // context sensitive toolbar: only destroy toolbar and store state.
6813 // context sensitive toolbar: make it invisible, store state and destroy it.
6814 if ( !pIter
->m_bContextSensitive
)
6815 pIter
->m_bVisible
= sal_False
;
6817 aUIElement
= *pIter
;
6822 aWriteLock
.unlock();
6826 if ( aName
.getLength() > 0 )
6828 implts_writeWindowStateData( aName
, aUIElement
);
6829 destroyElement( aName
);
6833 void SAL_CALL
LayoutManager::endPopupMode( const ::com::sun::star::awt::EndPopupModeEvent
& )
6834 throw (::com::sun::star::uno::RuntimeException
)
6839 //---------------------------------------------------------------------------------------------------------
6840 // XLayoutManagerEventBroadcaster
6841 //---------------------------------------------------------------------------------------------------------
6842 void SAL_CALL
LayoutManager::addLayoutManagerEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManagerListener
>& xListener
)
6843 throw (::com::sun::star::uno::RuntimeException
)
6845 m_aListenerContainer
.addInterface( ::getCppuType( (const css::uno::Reference
< css::frame::XLayoutManagerListener
>*)NULL
), xListener
);
6848 void SAL_CALL
LayoutManager::removeLayoutManagerEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XLayoutManagerListener
>& xListener
)
6849 throw (::com::sun::star::uno::RuntimeException
)
6851 m_aListenerContainer
.removeInterface( ::getCppuType( (const css::uno::Reference
< css::frame::XLayoutManagerListener
>*)NULL
), xListener
);
6854 void LayoutManager::implts_notifyListeners( short nEvent
, ::com::sun::star::uno::Any aInfoParam
)
6856 css::lang::EventObject
aSource (static_cast< ::cppu::OWeakObject
*>(this));
6857 ::cppu::OInterfaceContainerHelper
* pContainer
= m_aListenerContainer
.getContainer( ::getCppuType( ( const css::uno::Reference
< css::frame::XLayoutManagerListener
>*) NULL
) );
6858 if (pContainer
!=NULL
)
6860 ::cppu::OInterfaceIteratorHelper
pIterator(*pContainer
);
6861 while (pIterator
.hasMoreElements())
6865 ((css::frame::XLayoutManagerListener
*)pIterator
.next())->layoutEvent( aSource
, nEvent
, aInfoParam
);
6867 catch( css::uno::RuntimeException
& )
6875 //---------------------------------------------------------------------------------------------------------
6877 //---------------------------------------------------------------------------------------------------------
6878 void SAL_CALL
LayoutManager::windowResized( const css::awt::WindowEvent
& aEvent
)
6879 throw( css::uno::RuntimeException
)
6881 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6882 WriteGuard
aWriteLock( m_aLock
);
6884 if ( !m_xDockingAreaAcceptor
.is() )
6887 // Request to set docking area space again.
6888 css::awt::Rectangle
aDockingArea( m_aDockingArea
);
6889 Reference
< XDockingAreaAcceptor
> xDockingAreaAcceptor( m_xDockingAreaAcceptor
);
6890 Reference
< css::awt::XWindow
> xContainerWindow( m_xContainerWindow
);
6892 Reference
< XInterface
> xIfac( xContainerWindow
, UNO_QUERY
);
6893 if ( xIfac
== aEvent
.Source
&& m_bVisible
)
6895 // We have to call our resize handler at least once synchronously, as some
6896 // application modules need this. So we have to check if this is the first
6897 // call after the async layout time expired.
6898 m_bMustDoLayout
= sal_True
;
6899 if ( !m_aAsyncLayoutTimer
.IsActive() )
6901 const Link
& aLink
= m_aAsyncLayoutTimer
.GetTimeoutHdl();
6902 if ( aLink
.IsSet() )
6903 aLink
.Call( &m_aAsyncLayoutTimer
);
6905 if ( m_nLockCount
== 0 )
6906 m_aAsyncLayoutTimer
.Start();
6908 else if ( m_xFrame
.is() && aEvent
.Source
== m_xFrame
->getContainerWindow() )
6910 // the container window of my DockingAreaAcceptor is not the same as of my frame
6911 // I still have to resize my frames' window as nobody else will do it
6912 Reference
< css::awt::XWindow
> xComponentWindow( m_xFrame
->getComponentWindow() );
6913 if( xComponentWindow
.is() == sal_True
)
6915 css::uno::Reference
< css::awt::XDevice
> xDevice( m_xFrame
->getContainerWindow(), css::uno::UNO_QUERY
);
6917 // Convert relativ size to output size.
6918 css::awt::Rectangle aRectangle
= m_xFrame
->getContainerWindow()->getPosSize();
6919 css::awt::DeviceInfo aInfo
= xDevice
->getInfo();
6920 css::awt::Size
aSize ( aRectangle
.Width
- aInfo
.LeftInset
- aInfo
.RightInset
,
6921 aRectangle
.Height
- aInfo
.TopInset
- aInfo
.BottomInset
);
6923 // Resize our component window.
6924 xComponentWindow
->setPosSize( 0, 0, aSize
.Width
, aSize
.Height
, css::awt::PosSize::POSSIZE
);
6929 // resize event for one of the UIElements
6930 sal_Bool
bLocked( m_bDockingInProgress
);
6931 sal_Bool
bDoLayout( m_bDoLayout
);
6932 aWriteLock
.unlock();
6933 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6935 if ( !bLocked
&& !bDoLayout
)
6937 // Do not do anything if we are in the middle of a docking process. This would interfere all other
6938 // operations. We will store the new position and size in the docking handlers.
6939 // Do not do anything if we are in the middle of our layouting process. We will adapt the position
6940 // and size of the user interface elements.
6941 UIElement aUIElement
;
6942 if ( implts_findElement( aEvent
.Source
, aUIElement
))
6944 if ( aUIElement
.m_bFloating
)
6945 implts_writeNewStateData( aUIElement
.m_aName
,
6946 Reference
< css::awt::XWindow
>( aEvent
.Source
, UNO_QUERY
));
6954 void SAL_CALL
LayoutManager::windowMoved( const css::awt::WindowEvent
& ) throw( css::uno::RuntimeException
)
6958 void SAL_CALL
LayoutManager::windowShown( const css::lang::EventObject
& aEvent
) throw( css::uno::RuntimeException
)
6960 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6961 ReadGuard
aReadLock( m_aLock
);
6963 // Request to set docking area space again.
6964 Reference
< css::awt::XWindow
> xContainerWindow( m_xContainerWindow
);
6965 bool bParentWindowVisible( m_bParentWindowVisible
);
6967 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6969 Reference
< XInterface
> xIfac( xContainerWindow
, UNO_QUERY
);
6970 if ( xIfac
== aEvent
.Source
)
6972 bool bSetVisible
= false;
6974 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6975 WriteGuard
aWriteLock( m_aLock
);
6976 m_bParentWindowVisible
= true;
6977 bSetVisible
= ( m_bParentWindowVisible
!= bParentWindowVisible
);
6978 aWriteLock
.unlock();
6979 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6983 implts_updateUIElementsVisibleState( sal_True
);
6984 //implts_doLayout( sal_False );
6989 void SAL_CALL
LayoutManager::windowHidden( const css::lang::EventObject
& aEvent
) throw( css::uno::RuntimeException
)
6991 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
6992 ReadGuard
aReadLock( m_aLock
);
6994 // Request to set docking area space again.
6995 Reference
< css::awt::XWindow
> xContainerWindow( m_xContainerWindow
);
6996 bool bParentWindowVisible( m_bParentWindowVisible
);
6998 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7000 Reference
< XInterface
> xIfac( xContainerWindow
, UNO_QUERY
);
7001 if ( xIfac
== aEvent
.Source
)
7003 bool bSetInvisible
= false;
7005 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7006 WriteGuard
aWriteLock( m_aLock
);
7007 m_bParentWindowVisible
= false;
7008 bSetInvisible
= ( m_bParentWindowVisible
!= bParentWindowVisible
);
7009 aWriteLock
.unlock();
7010 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7012 if ( bSetInvisible
)
7013 implts_updateUIElementsVisibleState( sal_False
);
7017 IMPL_LINK( LayoutManager
, AsyncLayoutHdl
, Timer
*, EMPTYARG
)
7019 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7020 ReadGuard
aReadLock( m_aLock
);
7022 // Request to set docking area space again.
7023 m_aAsyncLayoutTimer
.Stop();
7025 if( !m_xContainerWindow
.is() )
7028 css::awt::Rectangle
aDockingArea( m_aDockingArea
);
7029 ::Size
aStatusBarSize( implts_getStatusBarSize() );
7031 // Subtract status bar height
7032 aDockingArea
.Height
-= aStatusBarSize
.Height();
7035 implts_setDockingAreaWindowSizes( aDockingArea
);
7036 implts_doLayout( sal_True
);
7041 void LayoutManager::implts_checkElementContainer()
7044 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7045 ReadGuard
aReadLock( m_aLock
);
7047 BaseHash
< sal_Int32
> aUIElementHash
;
7049 UIElementVector::iterator pIter
;
7050 for ( pIter
= m_aUIElements
.begin(); pIter
!= m_aUIElements
.end(); pIter
++ )
7051 aUIElementHash
[pIter
->m_aName
]++;
7054 BaseHash
< sal_Int32
>::const_iterator pCheckIter
= aUIElementHash
.begin();
7055 for ( ; pCheckIter
!= aUIElementHash
.end(); pCheckIter
++ )
7057 if ( pCheckIter
->second
> 1 )
7059 ::rtl::OString aName
= ::rtl::OUStringToOString( pCheckIter
->first
, RTL_TEXTENCODING_ASCII_US
);
7060 DBG_ASSERT( "More than one element (%s) with the same name found!", aName
.getStr() );
7062 } // for ( ; pCheckIter != aUIElementHash.end(); pCheckIter++ )
7066 //---------------------------------------------------------------------------------------------------------
7067 // XFrameActionListener
7068 //---------------------------------------------------------------------------------------------------------
7069 void SAL_CALL
LayoutManager::frameAction( const FrameActionEvent
& aEvent
)
7070 throw ( RuntimeException
)
7072 if (( aEvent
.Action
== FrameAction_COMPONENT_ATTACHED
) ||
7073 ( aEvent
.Action
== FrameAction_COMPONENT_REATTACHED
))
7075 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_ATTACHED|REATTACHED)" );
7077 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7078 WriteGuard
aWriteLock( m_aLock
);
7079 m_bComponentAttached
= sal_True
;
7080 m_bMustDoLayout
= sal_True
;
7081 aWriteLock
.unlock();
7082 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7084 implts_reset( sal_True
);
7085 implts_doLayout( sal_True
);
7087 else if (( aEvent
.Action
== FrameAction_FRAME_UI_ACTIVATED
) ||
7088 ( aEvent
.Action
== FrameAction_FRAME_UI_DEACTIVATING
))
7090 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::frameAction (FRAME_UI_ACTIVATED|DEACTIVATING)" );
7092 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7093 WriteGuard
aWriteLock( m_aLock
);
7094 m_bActive
= ( aEvent
.Action
== FrameAction_FRAME_UI_ACTIVATED
);
7095 aWriteLock
.unlock();
7096 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7098 implts_toggleFloatingUIElementsVisibility( aEvent
.Action
== FrameAction_FRAME_UI_ACTIVATED
);
7101 else if ( aEvent
.Action
== FrameAction_COMPONENT_DETACHING
)
7103 RTL_LOGFILE_CONTEXT( aLog
, "framework (cd100003) ::LayoutManager::frameAction (COMPONENT_DETACHING)" );
7105 // SAFE AREA -----------------------------------------------------------------------------------------------
7106 WriteGuard
aWriteLock( m_aLock
);
7107 m_bComponentAttached
= sal_False
;
7108 aWriteLock
.unlock();
7109 // SAFE AREA -----------------------------------------------------------------------------------------------
7111 implts_reset( sal_False
);
7116 // ______________________________________________
7118 void SAL_CALL
LayoutManager::disposing( const css::lang::EventObject
& rEvent
)
7119 throw( RuntimeException
)
7121 sal_Bool
bDisposeAndClear( sal_False
);
7123 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7124 WriteGuard
aWriteLock( m_aLock
);
7126 if ( rEvent
.Source
== Reference
< XInterface
>( m_xFrame
, UNO_QUERY
))
7128 // Our frame gets disposed, release all our references that depends on a working
7130 Application::RemoveEventListener( LINK( this, LayoutManager
, SettingsChanged
) );
7131 if ( m_pMiscOptions
)
7133 m_pMiscOptions
->RemoveListener( LINK( this, LayoutManager
, OptionsChanged
) );
7134 delete m_pMiscOptions
;
7138 delete m_pAddonOptions
;
7139 m_pAddonOptions
= 0;
7141 // destroy all elements, it's possible that dettaching is NOT called!
7142 implts_destroyElements();
7144 m_aUIElements
.clear();
7145 impl_clearUpMenuBar();
7147 if ( m_xInplaceMenuBar
.is() )
7149 m_pInplaceMenuBar
= 0;
7150 m_xInplaceMenuBar
->dispose();
7152 m_xInplaceMenuBar
.clear();
7153 m_xContainerWindow
.clear();
7154 implts_destroyDockingAreaWindows();
7156 if ( m_xModuleCfgMgr
.is() )
7160 Reference
< XUIConfiguration
> xModuleCfgMgr( m_xModuleCfgMgr
, UNO_QUERY
);
7161 xModuleCfgMgr
->removeConfigurationListener(
7162 Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
7164 catch ( Exception
& )
7169 if ( m_xDocCfgMgr
.is() )
7173 Reference
< XUIConfiguration
> xDocCfgMgr( m_xDocCfgMgr
, UNO_QUERY
);
7174 xDocCfgMgr
->removeConfigurationListener(
7175 Reference
< XUIConfigurationListener
>( static_cast< OWeakObject
* >( this ), UNO_QUERY
));
7177 catch ( Exception
& )
7182 m_xDocCfgMgr
.clear();
7183 m_xModuleCfgMgr
.clear();
7185 delete m_pGlobalSettings
;
7186 m_pGlobalSettings
= 0;
7187 m_xDockingAreaAcceptor
= Reference
< ::com::sun::star::ui::XDockingAreaAcceptor
>();
7189 bDisposeAndClear
= sal_True
;
7191 else if ( rEvent
.Source
== Reference
< XInterface
>( m_xContainerWindow
, UNO_QUERY
))
7193 // Our container window gets disposed. Remove all user interface elements.
7194 m_aUIElements
.clear();
7195 impl_clearUpMenuBar();
7197 if ( m_xInplaceMenuBar
.is() )
7199 m_pInplaceMenuBar
= 0;
7200 m_xInplaceMenuBar
->dispose();
7202 m_xInplaceMenuBar
.clear();
7203 m_xContainerWindow
.clear();
7205 else if ( rEvent
.Source
== Reference
< XInterface
>( m_xDocCfgMgr
, UNO_QUERY
))
7207 m_xDocCfgMgr
.clear();
7209 else if ( rEvent
.Source
== Reference
< XInterface
>( m_xModuleCfgMgr
, UNO_QUERY
))
7211 m_xModuleCfgMgr
.clear();
7214 aWriteLock
.unlock();
7215 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7217 // Send disposing to our listener when we have lost our frame.
7218 if ( bDisposeAndClear
)
7220 // Send message to all listener and forget her references.
7221 css::uno::Reference
< css::frame::XLayoutManager
> xThis( static_cast< ::cppu::OWeakObject
* >(this), css::uno::UNO_QUERY
);
7222 css::lang::EventObject
aEvent( xThis
);
7223 m_aListenerContainer
.disposeAndClear( aEvent
);
7227 void SAL_CALL
LayoutManager::elementInserted( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
)
7229 ReadGuard
aReadLock( m_aLock
);
7231 ::rtl::OUString aElementType
;
7232 ::rtl::OUString aElementName
;
7233 Reference
< XUIElement
> xElement
;
7234 Reference
< XFrame
> xFrame( m_xFrame
);
7236 if ( m_xFrame
.is() )
7238 implts_findElement( Event
.ResourceURL
, aElementType
, aElementName
, xElement
);
7240 Reference
< XUIElementSettings
> xElementSettings( xElement
, UNO_QUERY
);
7241 if ( xElementSettings
.is() )
7243 ::rtl::OUString
aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
7244 Reference
< XPropertySet
> xPropSet( xElementSettings
, UNO_QUERY
);
7245 if ( xPropSet
.is() )
7247 if ( Event
.Source
== Reference
< XInterface
>( m_xDocCfgMgr
, UNO_QUERY
))
7248 xPropSet
->setPropertyValue( aConfigSourcePropName
, makeAny( m_xDocCfgMgr
));
7250 xElementSettings
->updateSettings();
7254 if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ) &&
7255 ( aElementName
.indexOf( m_aCustomTbxPrefix
) != -1 ))
7257 // custom toolbar must be directly created, shown and layouted!
7258 createElement( Event
.ResourceURL
);
7259 Reference
< XUIElement
> xUIElement
= getElement( Event
.ResourceURL
);
7260 if ( xUIElement
.is() )
7262 Reference
< XUIConfigurationManager
> xCfgMgr
;
7263 Reference
< XPropertySet
> xPropSet
;
7264 ::rtl::OUString aUIName
;
7268 xCfgMgr
= Reference
< XUIConfigurationManager
>( Event
.Source
, UNO_QUERY
);
7269 xPropSet
= Reference
< XPropertySet
>( xCfgMgr
->getSettings( Event
.ResourceURL
, sal_False
), UNO_QUERY
);
7271 if ( xPropSet
.is() )
7272 xPropSet
->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UIName" ))) >>= aUIName
;
7274 catch ( com::sun::star::container::NoSuchElementException
& )
7277 catch ( com::sun::star::beans::UnknownPropertyException
& )
7280 catch ( com::sun::star::lang::WrappedTargetException
& )
7285 vos::OGuard
aGuard( Application::GetSolarMutex() );
7286 Reference
< css::awt::XWindow
> xWindow( xUIElement
->getRealInterface(), UNO_QUERY
);
7287 Window
* pWindow
= VCLUnoHelper::GetWindow( xWindow
);
7289 pWindow
->SetText( aUIName
);
7292 showElement( Event
.ResourceURL
);
7299 void SAL_CALL
LayoutManager::elementRemoved( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
)
7301 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
7302 WriteGuard
aWriteLock( m_aLock
);
7304 ::rtl::OUString aElementType
;
7305 ::rtl::OUString aElementName
;
7306 Reference
< XUIElement
> xUIElement
;
7307 Reference
< XFrame
> xFrame( m_xFrame
);
7309 if ( m_xFrame
.is() )
7311 implts_findElement( Event
.ResourceURL
, aElementType
, aElementName
, xUIElement
);
7313 Reference
< XUIElementSettings
> xElementSettings( xUIElement
, UNO_QUERY
);
7314 if ( xElementSettings
.is() )
7316 bool bNoSettings( false );
7317 ::rtl::OUString
aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
7318 Reference
< XInterface
> xElementCfgMgr
;
7319 Reference
< XPropertySet
> xPropSet( xElementSettings
, UNO_QUERY
);
7321 if ( xPropSet
.is() )
7322 xPropSet
->getPropertyValue( aConfigSourcePropName
) >>= xElementCfgMgr
;
7324 if ( !xElementCfgMgr
.is() )
7327 // Check if the same UI configuration manager has changed => check further
7328 if ( Event
.Source
== xElementCfgMgr
)
7330 // Same UI configuration manager where our element has its settings
7331 if ( Event
.Source
== Reference
< XInterface
>( m_xDocCfgMgr
, UNO_QUERY
))
7333 // document settings removed
7334 if ( m_xModuleCfgMgr
->hasSettings( Event
.ResourceURL
))
7336 xPropSet
->setPropertyValue( aConfigSourcePropName
, makeAny( m_xModuleCfgMgr
));
7337 xElementSettings
->updateSettings();
7345 // No settings anymore, element must be destroyed
7346 if ( m_xContainerWindow
.is() && bNoSettings
)
7348 if ( aElementType
.equalsIgnoreAsciiCaseAscii( "menubar" ) &&
7349 aElementName
.equalsIgnoreAsciiCaseAscii( "menubar" ))
7351 Window
* pWindow
= VCLUnoHelper::GetWindow( m_xContainerWindow
);
7352 while ( pWindow
&& !pWindow
->IsSystemWindow() )
7353 pWindow
= pWindow
->GetParent();
7355 if ( pWindow
&& !m_bInplaceMenuSet
)
7356 ((SystemWindow
*)pWindow
)->SetMenuBar( 0 );
7358 Reference
< XComponent
> xComp( m_xMenuBar
, UNO_QUERY
);
7363 else if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ))
7365 destroyElement( Event
.ResourceURL
);
7372 void SAL_CALL
LayoutManager::elementReplaced( const ::com::sun::star::ui::ConfigurationEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
)
7374 ReadGuard
aReadLock( m_aLock
);
7376 ::rtl::OUString aElementType
;
7377 ::rtl::OUString aElementName
;
7378 Reference
< XUIElement
> xUIElement
;
7379 Reference
< XFrame
> xFrame( m_xFrame
);
7381 if ( m_xFrame
.is() )
7383 implts_findElement( Event
.ResourceURL
, aElementType
, aElementName
, xUIElement
);
7385 Reference
< XUIElementSettings
> xElementSettings( xUIElement
, UNO_QUERY
);
7386 if ( xElementSettings
.is() )
7388 ::rtl::OUString
aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
7389 Reference
< XInterface
> xElementCfgMgr
;
7390 Reference
< XPropertySet
> xPropSet( xElementSettings
, UNO_QUERY
);
7392 if ( xPropSet
.is() )
7393 xPropSet
->getPropertyValue( aConfigSourcePropName
) >>= xElementCfgMgr
;
7395 if ( !xElementCfgMgr
.is() )
7398 // Check if the same UI configuration manager has changed => update settings
7399 if ( Event
.Source
== xElementCfgMgr
)
7401 xElementSettings
->updateSettings();
7402 if ( aElementType
.equalsIgnoreAsciiCaseAscii( "toolbar" ))
7409 //---------------------------------------------------------------------------------------------------------
7410 // OPropertySetHelper
7411 //---------------------------------------------------------------------------------------------------------
7412 // XPropertySet helper
7413 sal_Bool SAL_CALL
LayoutManager::convertFastPropertyValue( Any
& aConvertedValue
,
7416 const Any
& aValue
) throw( com::sun::star::lang::IllegalArgumentException
)
7418 // Initialize state with FALSE !!!
7419 // (Handle can be invalid)
7420 sal_Bool bReturn
= sal_False
;
7424 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER
:
7425 bReturn
= PropHelper::willPropertyBeChanged(
7426 com::sun::star::uno::makeAny(m_bMenuBarCloser
),
7431 case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS
:
7432 bReturn
= PropHelper::willPropertyBeChanged(
7433 com::sun::star::uno::makeAny(m_bAutomaticToolbars
),
7438 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY
:
7439 bReturn
= PropHelper::willPropertyBeChanged(
7440 com::sun::star::uno::makeAny(sal_False
),
7445 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI
:
7446 bReturn
= PropHelper::willPropertyBeChanged(
7447 com::sun::star::uno::makeAny(m_bHideCurrentUI
),
7454 // Return state of operation.
7458 void SAL_CALL
LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle
,
7459 const com::sun::star::uno::Any
& aValue
) throw( com::sun::star::uno::Exception
)
7463 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER
:
7465 sal_Bool bCloserState
= sal_False
;
7466 aValue
>>= bCloserState
;
7467 implts_setMenuBarCloser( bCloserState
);
7470 case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS
:
7472 sal_Bool bValue
= sal_Bool();
7473 if ( aValue
>>= bValue
)
7474 m_bAutomaticToolbars
= bValue
;
7477 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY
:
7479 sal_Bool bValue
= sal_Bool();
7480 if (( aValue
>>= bValue
) && bValue
)
7481 implts_refreshContextToolbarsVisibility();
7484 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI
:
7486 sal_Bool bValue
= sal_Bool();
7487 if ( aValue
>>= bValue
)
7489 m_bHideCurrentUI
= bValue
;
7490 implts_setCurrentUIVisibility( !bValue
);
7497 void SAL_CALL
LayoutManager::getFastPropertyValue( com::sun::star::uno::Any
& aValue
,
7498 sal_Int32 nHandle
) const
7502 case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER
:
7503 aValue
<<= m_bMenuBarCloser
;
7505 case LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS
:
7506 aValue
<<= m_bAutomaticToolbars
;
7508 case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY
:
7509 aValue
<<= sal_False
;
7511 case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI
:
7512 aValue
<<= m_bHideCurrentUI
;
7514 case LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT
:
7515 aValue
<<= m_nLockCount
;
7520 ::cppu::IPropertyArrayHelper
& SAL_CALL
LayoutManager::getInfoHelper()
7522 // Optimize this method !
7523 // We initialize a static variable only one time. And we don't must use a mutex at every call!
7524 // For the first call; pInfoHelper is NULL - for the second call pInfoHelper is different from NULL!
7525 static ::cppu::OPropertyArrayHelper
* pInfoHelper
= NULL
;
7527 if( pInfoHelper
== NULL
)
7529 // Ready for multithreading
7530 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() ) ;
7532 // Control this pointer again, another instance can be faster then these!
7533 if( pInfoHelper
== NULL
)
7535 // Define static member to give structure of properties to baseclass "OPropertySetHelper".
7536 // "impl_getStaticPropertyDescriptor" is a non exported and static funtion, who will define a static propertytable.
7537 // "sal_True" say: Table is sorted by name.
7538 static ::cppu::OPropertyArrayHelper
aInfoHelper( impl_getStaticPropertyDescriptor(), sal_True
);
7539 pInfoHelper
= &aInfoHelper
;
7543 return(*pInfoHelper
);
7546 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
> SAL_CALL
LayoutManager::getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException
)
7548 // Optimize this method !
7549 // We initialize a static variable only one time. And we don't must use a mutex at every call!
7550 // For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
7551 static com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
>* pInfo
= NULL
;
7555 // Ready for multithreading
7556 osl::MutexGuard
aGuard( osl::Mutex::getGlobalMutex() ) ;
7557 // Control this pointer again, another instance can be faster then these!
7560 // Create structure of propertysetinfo for baseclass "OPropertySetHelper".
7561 // (Use method "getInfoHelper()".)
7562 static com::sun::star::uno::Reference
< com::sun::star::beans::XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
7570 const com::sun::star::uno::Sequence
< com::sun::star::beans::Property
> LayoutManager::impl_getStaticPropertyDescriptor()
7572 // Create a new static property array to initialize sequence!
7573 // Table of all predefined properties of this class. Its used from OPropertySetHelper-class!
7574 // Don't forget to change the defines (see begin of this file), if you add, change or delete a property in this list!!!
7575 // It's necessary for methods of OPropertySetHelper.
7577 // YOU MUST SORT FOLLOW TABLE BY NAME ALPHABETICAL !!!
7579 static const com::sun::star::beans::Property pProperties
[] =
7581 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_AUTOMATICTOOLBARS
, LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS
, ::getCppuType((const sal_Bool
*)NULL
), com::sun::star::beans::PropertyAttribute::TRANSIENT
),
7582 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_HIDECURRENTUI
, LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI
, ::getCppuType((const sal_Bool
*)NULL
), com::sun::star::beans::PropertyAttribute::TRANSIENT
),
7583 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
),
7584 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER
, LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER
, ::getCppuType((const sal_Bool
*)NULL
), com::sun::star::beans::PropertyAttribute::TRANSIENT
),
7585 com::sun::star::beans::Property( LAYOUTMANAGER_PROPNAME_REFRESHVISIBILITY
, LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY
, ::getCppuType((const sal_Bool
*)NULL
), com::sun::star::beans::PropertyAttribute::TRANSIENT
)
7587 // Use it to initialize sequence!
7588 static const com::sun::star::uno::Sequence
< com::sun::star::beans::Property
> lPropertyDescriptor( pProperties
, LAYOUTMANAGER_PROPCOUNT
);
7589 // Return static "PropertyDescriptor"
7590 return lPropertyDescriptor
;
7593 } // namespace framework