1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2008 by Sun Microsystems, Inc. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * $RCSfile: layoutmanager.hxx,v $ 10*cdf0e10cSrcweir * $Revision: 1.34 $ 11*cdf0e10cSrcweir * 12*cdf0e10cSrcweir * This file is part of OpenOffice.org. 13*cdf0e10cSrcweir * 14*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 15*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 16*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 17*cdf0e10cSrcweir * 18*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 19*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 20*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 22*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 23*cdf0e10cSrcweir * 24*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 25*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 26*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 27*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 28*cdf0e10cSrcweir * 29*cdf0e10cSrcweir ************************************************************************/ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 32*cdf0e10cSrcweir #include "precompiled_framework.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir // my own includes 35*cdf0e10cSrcweir #include "helpers.hxx" 36*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx> 37*cdf0e10cSrcweir #include <services.h> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir // interface includes 40*cdf0e10cSrcweir #include <com/sun/star/ui/DockingArea.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/awt/XTopWindow.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchHelper.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/awt/XDockableWindow.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/awt/XDockableWindowListener.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/ui/XUIElement.hpp> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // other includes 49*cdf0e10cSrcweir #include <comphelper/mediadescriptor.hxx> 50*cdf0e10cSrcweir #include <vcl/svapp.hxx> 51*cdf0e10cSrcweir #include <vos/mutex.hxx> 52*cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir // namespace 55*cdf0e10cSrcweir using namespace com::sun::star; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir namespace framework 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir bool hasEmptySize( const:: Size& aSize ) 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir return ( aSize.Width() == 0 ) && ( aSize.Height() == 0 ); 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir bool hasDefaultPosValue( const ::Point& aPos ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir return (( aPos.X() == SAL_MAX_INT32 ) || ( aPos.Y() == SAL_MAX_INT32 )); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir bool isDefaultPos( const ::com::sun::star::awt::Point& aPos ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir return (( aPos.X == SAL_MAX_INT32 ) && ( aPos.Y == SAL_MAX_INT32 )); 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir bool isDefaultPos( const ::Point& aPos ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir return (( aPos.X() == SAL_MAX_INT32 ) && ( aPos.Y() == SAL_MAX_INT32 )); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir bool isReverseOrderDockingArea( const sal_Int32 nDockArea ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir ui::DockingArea eDockArea = static_cast< ui::DockingArea >( nDockArea ); 83*cdf0e10cSrcweir return (( eDockArea == ui::DockingArea_DOCKINGAREA_BOTTOM ) || 84*cdf0e10cSrcweir ( eDockArea == ui::DockingArea_DOCKINGAREA_RIGHT )); 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir bool isToolboxHorizontalAligned( ToolBox* pToolBox ) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir if ( pToolBox ) 90*cdf0e10cSrcweir return (( pToolBox->GetAlign() == WINDOWALIGN_TOP ) || ( pToolBox->GetAlign() == WINDOWALIGN_BOTTOM )); 91*cdf0e10cSrcweir return false; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir bool isHorizontalDockingArea( const ui::DockingArea& nDockingArea ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir return (( nDockingArea == ui::DockingArea_DOCKINGAREA_TOP ) || 97*cdf0e10cSrcweir ( nDockingArea == ui::DockingArea_DOCKINGAREA_BOTTOM )); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir bool isHorizontalDockingArea( const sal_Int32 nDockArea ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir return isHorizontalDockingArea(static_cast< ui::DockingArea >( nDockArea )); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir ::rtl::OUString retrieveToolbarNameFromHelpURL( Window* pWindow ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir ::rtl::OUString aToolbarName; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir if ( pWindow->GetType() == WINDOW_TOOLBOX ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir ToolBox* pToolBox = dynamic_cast<ToolBox *>( pWindow ); 112*cdf0e10cSrcweir if ( pToolBox ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir aToolbarName = rtl::OStringToOUString( pToolBox->GetHelpId(), RTL_TEXTENCODING_UTF8 ); 115*cdf0e10cSrcweir sal_Int32 i = aToolbarName.lastIndexOf( ':' ); 116*cdf0e10cSrcweir if (( aToolbarName.getLength() > 0 ) && ( i > 0 ) && (( i+ 1 ) < aToolbarName.getLength() )) 117*cdf0e10cSrcweir aToolbarName = aToolbarName.copy( i+1 ); // Remove ".HelpId:" protocol from toolbar name 118*cdf0e10cSrcweir else 119*cdf0e10cSrcweir aToolbarName = ::rtl::OUString(); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir return aToolbarName; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir ToolBox* getToolboxPtr( Window* pWindow ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir ToolBox* pToolbox(NULL); 128*cdf0e10cSrcweir if ( pWindow->GetType() == WINDOW_TOOLBOX ) 129*cdf0e10cSrcweir pToolbox = dynamic_cast<ToolBox*>( pWindow ); 130*cdf0e10cSrcweir return pToolbox; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir Window* getWindowFromXUIElement( const uno::Reference< ui::XUIElement >& xUIElement ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 136*cdf0e10cSrcweir uno::Reference< awt::XWindow > xWindow; 137*cdf0e10cSrcweir if ( xUIElement.is() ) 138*cdf0e10cSrcweir xWindow = uno::Reference< awt::XWindow >( xUIElement->getRealInterface(), uno::UNO_QUERY ); 139*cdf0e10cSrcweir return VCLUnoHelper::GetWindow( xWindow ); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir SystemWindow* getTopSystemWindow( const uno::Reference< awt::XWindow >& xWindow ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 145*cdf0e10cSrcweir while ( pWindow && !pWindow->IsSystemWindow() ) 146*cdf0e10cSrcweir pWindow = pWindow->GetParent(); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir if ( pWindow ) 149*cdf0e10cSrcweir return (SystemWindow *)pWindow; 150*cdf0e10cSrcweir else 151*cdf0e10cSrcweir return 0; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir void setZeroRectangle( ::Rectangle& rRect ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir rRect.setX(0); 157*cdf0e10cSrcweir rRect.setY(0); 158*cdf0e10cSrcweir rRect.setWidth(0); 159*cdf0e10cSrcweir rRect.setHeight(0); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // ATTENTION! 163*cdf0e10cSrcweir // This value is directly copied from the sfx2 project. 164*cdf0e10cSrcweir // You have to change BOTH values, see sfx2/inc/sfx2/sfxsids.hrc (SID_DOCKWIN_START) 165*cdf0e10cSrcweir static const sal_Int32 DOCKWIN_ID_BASE = 9800; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir bool lcl_checkUIElement(const uno::Reference< ui::XUIElement >& xUIElement, awt::Rectangle& _rPosSize, uno::Reference< awt::XWindow >& _xWindow) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir bool bRet = xUIElement.is(); 170*cdf0e10cSrcweir if ( bRet ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() ); 173*cdf0e10cSrcweir _xWindow.set( xUIElement->getRealInterface(), uno::UNO_QUERY ); 174*cdf0e10cSrcweir _rPosSize = _xWindow->getPosSize(); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( _xWindow ); 177*cdf0e10cSrcweir if ( pWindow->GetType() == WINDOW_TOOLBOX ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir ::Size aSize = ((ToolBox*)pWindow)->CalcWindowSizePixel( 1 ); 180*cdf0e10cSrcweir _rPosSize.Width = aSize.Width(); 181*cdf0e10cSrcweir _rPosSize.Height = aSize.Height(); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir } // if ( xUIElement.is() ) 184*cdf0e10cSrcweir return bRet; 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir uno::Reference< awt::XWindowPeer > createToolkitWindow( const uno::Reference< lang::XMultiServiceFactory >& rFactory, const uno::Reference< awt::XWindowPeer >& rParent, const char* pService ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir const rtl::OUString aAWTToolkit( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" )); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir uno::Reference< awt::XWindowPeer > xPeer; 192*cdf0e10cSrcweir if ( rFactory.is() ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir uno::Reference< awt::XToolkit > xToolkit( rFactory->createInstance( aAWTToolkit ), uno::UNO_QUERY_THROW ); 195*cdf0e10cSrcweir if ( xToolkit.is() ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir // describe window properties. 198*cdf0e10cSrcweir css::awt::WindowDescriptor aDescriptor; 199*cdf0e10cSrcweir aDescriptor.Type = awt::WindowClass_SIMPLE; 200*cdf0e10cSrcweir aDescriptor.WindowServiceName = ::rtl::OUString::createFromAscii( pService ); 201*cdf0e10cSrcweir aDescriptor.ParentIndex = -1; 202*cdf0e10cSrcweir aDescriptor.Parent = uno::Reference< awt::XWindowPeer >( rParent, uno::UNO_QUERY ); 203*cdf0e10cSrcweir aDescriptor.Bounds = awt::Rectangle(0,0,0,0); 204*cdf0e10cSrcweir aDescriptor.WindowAttributes = 0; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir // create a awt window 207*cdf0e10cSrcweir xPeer = xToolkit->createWindow( aDescriptor ); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir return xPeer; 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir // convert alignment constant to vcl's WindowAlign type 215*cdf0e10cSrcweir WindowAlign ImplConvertAlignment( sal_Int16 aAlignment ) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir if ( aAlignment == ui::DockingArea_DOCKINGAREA_LEFT ) 218*cdf0e10cSrcweir return WINDOWALIGN_LEFT; 219*cdf0e10cSrcweir else if ( aAlignment == ui::DockingArea_DOCKINGAREA_RIGHT ) 220*cdf0e10cSrcweir return WINDOWALIGN_RIGHT; 221*cdf0e10cSrcweir else if ( aAlignment == ui::DockingArea_DOCKINGAREA_TOP ) 222*cdf0e10cSrcweir return WINDOWALIGN_TOP; 223*cdf0e10cSrcweir else 224*cdf0e10cSrcweir return WINDOWALIGN_BOTTOM; 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir ::rtl::OUString getElementTypeFromResourceURL( const ::rtl::OUString& aResourceURL ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir ::rtl::OUString aType; 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir ::rtl::OUString aUIResourceURL( UIRESOURCE_URL ); 232*cdf0e10cSrcweir if ( aResourceURL.indexOf( aUIResourceURL ) == 0 ) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir sal_Int32 nIndex = 0; 235*cdf0e10cSrcweir ::rtl::OUString aPathPart = aResourceURL.copy( aUIResourceURL.getLength() ); 236*cdf0e10cSrcweir ::rtl::OUString aUIResource = aPathPart.getToken( 0, (sal_Unicode)'/', nIndex ); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir return aPathPart.getToken( 0, (sal_Unicode)'/', nIndex ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir return aType; 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir void parseResourceURL( const rtl::OUString& aResourceURL, rtl::OUString& aElementType, rtl::OUString& aElementName ) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir ::rtl::OUString aUIResourceURL( UIRESOURCE_URL ); 247*cdf0e10cSrcweir if ( aResourceURL.indexOf( aUIResourceURL ) == 0 ) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir sal_Int32 nIndex = 0; 250*cdf0e10cSrcweir ::rtl::OUString aPathPart = aResourceURL.copy( aUIResourceURL.getLength() ); 251*cdf0e10cSrcweir ::rtl::OUString aUIResource = aPathPart.getToken( 0, (sal_Unicode)'/', nIndex ); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir aElementType = aPathPart.getToken( 0, (sal_Unicode)'/', nIndex ); 254*cdf0e10cSrcweir aElementName = aPathPart.getToken( 0, (sal_Unicode)'/', nIndex ); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir ::com::sun::star::awt::Rectangle putRectangleValueToAWT( const ::Rectangle& rRect ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir css::awt::Rectangle aRect; 261*cdf0e10cSrcweir aRect.X = rRect.Left(); 262*cdf0e10cSrcweir aRect.Y = rRect.Top(); 263*cdf0e10cSrcweir aRect.Width = rRect.Right(); 264*cdf0e10cSrcweir aRect.Height = rRect.Bottom(); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir return aRect; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir ::Rectangle putAWTToRectangle( const ::com::sun::star::awt::Rectangle& rRect ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir ::Rectangle aRect; 272*cdf0e10cSrcweir aRect.Left() = rRect.X; 273*cdf0e10cSrcweir aRect.Top() = rRect.Y; 274*cdf0e10cSrcweir aRect.Right() = rRect.Width; 275*cdf0e10cSrcweir aRect.Bottom() = rRect.Height; 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir return aRect; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir css::awt::Rectangle convertRectangleToAWT( const ::Rectangle& rRect ) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir css::awt::Rectangle aRect; 283*cdf0e10cSrcweir aRect.X = rRect.Left(); 284*cdf0e10cSrcweir aRect.Y = rRect.Top(); 285*cdf0e10cSrcweir aRect.Width = rRect.GetWidth(); 286*cdf0e10cSrcweir aRect.Height = rRect.GetHeight(); 287*cdf0e10cSrcweir return aRect; 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir ::Rectangle convertAWTToRectangle( const ::com::sun::star::awt::Rectangle& rRect ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir ::Rectangle aRect; 293*cdf0e10cSrcweir aRect.Left() = rRect.X; 294*cdf0e10cSrcweir aRect.Top() = rRect.Y; 295*cdf0e10cSrcweir aRect.Right() = rRect.X + rRect.Width; 296*cdf0e10cSrcweir aRect.Bottom() = rRect.Y + rRect.Height; 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir return aRect; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir bool equalRectangles( const css::awt::Rectangle& rRect1, 302*cdf0e10cSrcweir const css::awt::Rectangle& rRect2 ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir return (( rRect1.X == rRect2.X ) && 305*cdf0e10cSrcweir ( rRect1.Y == rRect2.Y ) && 306*cdf0e10cSrcweir ( rRect1.Width == rRect2.Width ) && 307*cdf0e10cSrcweir ( rRect1.Height == rRect2.Height )); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir uno::Reference< frame::XModel > impl_getModelFromFrame( const uno::Reference< frame::XFrame >& rFrame ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir // Query for the model to get check the context information 313*cdf0e10cSrcweir uno::Reference< frame::XModel > xModel; 314*cdf0e10cSrcweir if ( rFrame.is() ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir uno::Reference< frame::XController > xController( rFrame->getController(), uno::UNO_QUERY ); 317*cdf0e10cSrcweir if ( xController.is() ) 318*cdf0e10cSrcweir xModel = xController->getModel(); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir return xModel; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir sal_Bool implts_isPreviewModel( const uno::Reference< frame::XModel >& xModel ) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir if ( xModel.is() ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir ::comphelper::MediaDescriptor aDesc( xModel->getArgs() ); 329*cdf0e10cSrcweir return aDesc.getUnpackedValueOrDefault(::comphelper::MediaDescriptor::PROP_PREVIEW(), (sal_Bool)sal_False); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir else 332*cdf0e10cSrcweir return sal_False; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir sal_Bool implts_isFrameOrWindowTop( const uno::Reference< frame::XFrame >& xFrame ) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir if (xFrame->isTop()) 338*cdf0e10cSrcweir return sal_True; 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir uno::Reference< awt::XTopWindow > xWindowCheck(xFrame->getContainerWindow(), uno::UNO_QUERY); // dont use _THROW here ... its a check only 341*cdf0e10cSrcweir if (xWindowCheck.is()) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir // --> PB 2007-06-18 #i76867# top and system window is required. 344*cdf0e10cSrcweir ::vos::OGuard aSolarLock(&Application::GetSolarMutex()); 345*cdf0e10cSrcweir uno::Reference< awt::XWindow > xWindow( xWindowCheck, uno::UNO_QUERY ); 346*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( xWindow ); 347*cdf0e10cSrcweir return ( pWindow && pWindow->IsSystemWindow() ); 348*cdf0e10cSrcweir // <-- 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir return sal_False; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir 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 ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir const ::rtl::OUString aDockWinPrefixCommand( RTL_CONSTASCII_USTRINGPARAM( "DockingWindow" )); 357*cdf0e10cSrcweir css::uno::WeakReference< css::frame::XDispatchHelper > xDispatchHelper; 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir sal_Int32 nID = rDockingWindowName.toInt32(); 360*cdf0e10cSrcweir sal_Int32 nIndex = nID - DOCKWIN_ID_BASE; 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchProvider > xProvider(rFrame, css::uno::UNO_QUERY); 363*cdf0e10cSrcweir if ( nIndex >= 0 && xProvider.is() ) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir ::rtl::OUString aDockWinCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:" )); 366*cdf0e10cSrcweir ::rtl::OUString aDockWinArgName( aDockWinPrefixCommand ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir aDockWinArgName += ::rtl::OUString::valueOf( nIndex ); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir css::uno::Sequence< css::beans::PropertyValue > aArgs(1); 371*cdf0e10cSrcweir aArgs[0].Name = aDockWinArgName; 372*cdf0e10cSrcweir aArgs[0].Value = css::uno::makeAny( bVisible ); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir css::uno::Reference< css::frame::XDispatchHelper > xDispatcher( xDispatchHelper ); 375*cdf0e10cSrcweir if ( !xDispatcher.is()) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir xDispatcher = css::uno::Reference< css::frame::XDispatchHelper >( 378*cdf0e10cSrcweir rSMGR->createInstance(SERVICENAME_DISPATCHHELPER), css::uno::UNO_QUERY_THROW); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir aDockWinCommand = aDockWinCommand + aDockWinArgName; 382*cdf0e10cSrcweir xDispatcher->executeDispatch( 383*cdf0e10cSrcweir xProvider, 384*cdf0e10cSrcweir aDockWinCommand, 385*cdf0e10cSrcweir ::rtl::OUString::createFromAscii("_self"), 386*cdf0e10cSrcweir 0, 387*cdf0e10cSrcweir aArgs); 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir void impl_addWindowListeners( 392*cdf0e10cSrcweir const css::uno::Reference< css::uno::XInterface >& xThis, 393*cdf0e10cSrcweir const css::uno::Reference< css::ui::XUIElement >& xUIElement ) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xWindow( xUIElement->getRealInterface(), css::uno::UNO_QUERY ); 396*cdf0e10cSrcweir css::uno::Reference< css::awt::XDockableWindow > xDockWindow( xUIElement->getRealInterface(), css::uno::UNO_QUERY ); 397*cdf0e10cSrcweir if ( xDockWindow.is() && xWindow.is() ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir try 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir xDockWindow->addDockableWindowListener( 402*cdf0e10cSrcweir css::uno::Reference< css::awt::XDockableWindowListener >( 403*cdf0e10cSrcweir xThis, css::uno::UNO_QUERY )); 404*cdf0e10cSrcweir xWindow->addWindowListener( 405*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindowListener >( 406*cdf0e10cSrcweir xThis, css::uno::UNO_QUERY )); 407*cdf0e10cSrcweir xDockWindow->enableDocking( sal_True ); 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir catch ( css::uno::Exception& ) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir } // namespace framework 416