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