1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // includes ****************************************************************** 32*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/task/XStatusIndicator.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 35*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 36*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/util/CloseVetoException.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 46*cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX 47*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <sfx2/sfxsids.hrc> 53*cdf0e10cSrcweir #include "partwnd.hxx" 54*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 55*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 56*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 57*cdf0e10cSrcweir #include <sfx2/frame.hxx> 58*cdf0e10cSrcweir #include <sfx2/sfxuno.hxx> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir //**************************************************************************** 61*cdf0e10cSrcweir // SfxPartChildWnd_Impl 62*cdf0e10cSrcweir //**************************************************************************** 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir SFX_IMPL_DOCKINGWINDOW( SfxPartChildWnd_Impl, SID_BROWSER ); 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir SfxPartChildWnd_Impl::SfxPartChildWnd_Impl 67*cdf0e10cSrcweir ( 68*cdf0e10cSrcweir Window* pParentWnd, 69*cdf0e10cSrcweir sal_uInt16 nId, 70*cdf0e10cSrcweir SfxBindings* pBindings, 71*cdf0e10cSrcweir SfxChildWinInfo* pInfo 72*cdf0e10cSrcweir ) 73*cdf0e10cSrcweir : SfxChildWindow( pParentWnd, nId ) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir // Window erzeugen 76*cdf0e10cSrcweir pWindow = new SfxPartDockWnd_Impl( pBindings, this, pParentWnd, WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK ); 77*cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_TOP; 78*cdf0e10cSrcweir if ( pInfo ) 79*cdf0e10cSrcweir pInfo->nFlags |= SFX_CHILDWIN_FORCEDOCK; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir ((SfxDockingWindow*)pWindow)->SetFloatingSize( Size( 175, 175 ) ); 82*cdf0e10cSrcweir pWindow->SetSizePixel( Size( 175, 175 ) ); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir ( ( SfxDockingWindow* ) pWindow )->Initialize( pInfo ); 85*cdf0e10cSrcweir SetHideNotDelete( sal_True ); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir SfxPartChildWnd_Impl::~SfxPartChildWnd_Impl() 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = GetFrame(); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir // If xFrame=NULL release pMgr! Because this window lives longer then the manager! 93*cdf0e10cSrcweir // In these case we got a xFrame->dispose() call from outside ... and has release our 94*cdf0e10cSrcweir // frame reference in our own DisposingListener. 95*cdf0e10cSrcweir // But don't do it, if xFrame already exist. Then dispose() must come from inside ... 96*cdf0e10cSrcweir // and we need a valid pMgr for further operations ... 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir SfxPartDockWnd_Impl* pWin = (SfxPartDockWnd_Impl*) pWindow; 99*cdf0e10cSrcweir // if( pWin != NULL && !xFrame.is() ) 100*cdf0e10cSrcweir // pWin->ReleaseChildWindow_Impl(); 101*cdf0e10cSrcweir /* 102*cdf0e10cSrcweir // Release frame and window. 103*cdf0e10cSrcweir // If frame reference is valid here ... start dieing from inside by calling dispose(). 104*cdf0e10cSrcweir SetFrame( NULL ); 105*cdf0e10cSrcweir pWindow = NULL; 106*cdf0e10cSrcweir */ 107*cdf0e10cSrcweir if ( pWin && xFrame == pWin->GetBindings().GetActiveFrame() ) 108*cdf0e10cSrcweir pWin->GetBindings().SetActiveFrame( NULL ); 109*cdf0e10cSrcweir /* 110*cdf0e10cSrcweir if( xFrame.is() ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir try 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > xCloseable ( xFrame, ::com::sun::star::uno::UNO_QUERY ); 115*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xDisposeable( xFrame, ::com::sun::star::uno::UNO_QUERY ); 116*cdf0e10cSrcweir if (xCloseable.is()) 117*cdf0e10cSrcweir xCloseable->close(sal_True); 118*cdf0e10cSrcweir else 119*cdf0e10cSrcweir if (xDisposeable.is()) 120*cdf0e10cSrcweir xDisposeable->dispose(); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir catch( ::com::sun::star::util::CloseVetoException& ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir catch( ::com::sun::star::lang::DisposedException& ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir } 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir */ 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir sal_Bool SfxPartChildWnd_Impl::QueryClose() 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir return ( (SfxPartDockWnd_Impl*)pWindow )->QueryClose(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir //**************************************************************************** 138*cdf0e10cSrcweir // SfxPartDockWnd_Impl 139*cdf0e10cSrcweir //**************************************************************************** 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir SfxPartDockWnd_Impl::SfxPartDockWnd_Impl 142*cdf0e10cSrcweir ( 143*cdf0e10cSrcweir SfxBindings* pBind, 144*cdf0e10cSrcweir SfxChildWindow* pChildWin, 145*cdf0e10cSrcweir Window* pParent, 146*cdf0e10cSrcweir WinBits nBits 147*cdf0e10cSrcweir ) 148*cdf0e10cSrcweir : SfxDockingWindow( pBind, pChildWin, pParent, nBits ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame( 151*cdf0e10cSrcweir ::comphelper::getProcessServiceFactory()->createInstance( 152*cdf0e10cSrcweir DEFINE_CONST_UNICODE("com.sun.star.frame.Frame") ), ::com::sun::star::uno::UNO_QUERY ); 153*cdf0e10cSrcweir xFrame->initialize( VCLUnoHelper::GetInterface ( this ) ); 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xPropSet( 156*cdf0e10cSrcweir xFrame, ::com::sun::star::uno::UNO_QUERY ); 157*cdf0e10cSrcweir try 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir const ::rtl::OUString aLayoutManager( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )); 160*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xLMPropSet; 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir ::com::sun::star::uno::Any a = xPropSet->getPropertyValue( aLayoutManager ); 163*cdf0e10cSrcweir if ( a >>= xLMPropSet ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir const ::rtl::OUString aAutomaticToolbars( RTL_CONSTASCII_USTRINGPARAM( "AutomaticToolbars" )); 166*cdf0e10cSrcweir xLMPropSet->setPropertyValue( aAutomaticToolbars, ::com::sun::star::uno::Any( sal_False )); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir catch( ::com::sun::star::uno::RuntimeException& ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir throw; 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir catch( ::com::sun::star::uno::Exception& ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir pChildWin->SetFrame( xFrame ); 178*cdf0e10cSrcweir if ( pBind->GetDispatcher() ) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFramesSupplier > 181*cdf0e10cSrcweir xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ); 182*cdf0e10cSrcweir if ( xSupp.is() ) 183*cdf0e10cSrcweir xSupp->getFrames()->append( xFrame ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir else { 186*cdf0e10cSrcweir DBG_ERROR("Bindings without Dispatcher!"); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir //**************************************************************************** 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir SfxPartDockWnd_Impl::~SfxPartDockWnd_Impl() 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir //**************************************************************************** 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir Rectangle impl_Rectangle_Struct2Object( const ::com::sun::star::awt::Rectangle& aRectangleStruct ) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir return Rectangle(aRectangleStruct.X,aRectangleStruct.Y,aRectangleStruct.Width,aRectangleStruct.Height); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir void SfxPartDockWnd_Impl::Resize() 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir /* [Beschreibung] 206*cdf0e10cSrcweir Anpassung der Gr"osse der Controls an die neue Windowgr"osse 207*cdf0e10cSrcweir */ 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir SfxDockingWindow::Resize(); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir //**************************************************************************** 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir sal_Bool SfxPartDockWnd_Impl::QueryClose() 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir sal_Bool bClose = sal_True; 218*cdf0e10cSrcweir SfxChildWindow* pChild = GetChildWindow_Impl(); 219*cdf0e10cSrcweir if( pChild ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame(); 222*cdf0e10cSrcweir if( xFrame.is() ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xCtrl = xFrame->getController(); 225*cdf0e10cSrcweir if( xCtrl.is() ) 226*cdf0e10cSrcweir bClose = xCtrl->suspend( sal_True ); 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir return bClose; 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir //**************************************************************************** 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir long SfxPartDockWnd_Impl::Notify( NotifyEvent& rEvt ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir if( rEvt.GetType() == EVENT_GETFOCUS ) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir SfxChildWindow* pChild = GetChildWindow_Impl(); 240*cdf0e10cSrcweir if( pChild ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pChild->GetFrame(); 243*cdf0e10cSrcweir if( xFrame.is() ) 244*cdf0e10cSrcweir xFrame->activate(); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir return SfxDockingWindow::Notify( rEvt ); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir void SfxPartDockWnd_Impl::FillInfo( SfxChildWinInfo& rInfo ) const 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir SfxDockingWindow::FillInfo( rInfo ); 254*cdf0e10cSrcweir rInfo.bVisible = sal_False; 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir 258