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 #include "impframe.hxx" 32*cdf0e10cSrcweir #include "objshimp.hxx" 33*cdf0e10cSrcweir #include "sfx2/sfxhelp.hxx" 34*cdf0e10cSrcweir #include "workwin.hxx" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include "sfx2/app.hxx" 37*cdf0e10cSrcweir #include "sfx2/bindings.hxx" 38*cdf0e10cSrcweir #include "sfx2/dispatch.hxx" 39*cdf0e10cSrcweir #include "sfx2/docfac.hxx" 40*cdf0e10cSrcweir #include "sfx2/docfile.hxx" 41*cdf0e10cSrcweir #include "sfx2/event.hxx" 42*cdf0e10cSrcweir #include "sfx2/objface.hxx" 43*cdf0e10cSrcweir #include "sfx2/request.hxx" 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow2.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/frame/XFramesSupplier.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/frame/XLayoutManager.hpp> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 53*cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx> 54*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 55*cdf0e10cSrcweir #include <svl/eitem.hxx> 56*cdf0e10cSrcweir #include <svl/intitem.hxx> 57*cdf0e10cSrcweir #include <svl/itemset.hxx> 58*cdf0e10cSrcweir #include <svl/rectitem.hxx> 59*cdf0e10cSrcweir #include <svl/stritem.hxx> 60*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 61*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir using namespace ::com::sun::star; 64*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 65*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 66*cdf0e10cSrcweir using namespace ::com::sun::star::util; 67*cdf0e10cSrcweir using namespace ::com::sun::star::container; 68*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 69*cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 70*cdf0e10cSrcweir using ::com::sun::star::lang::XComponent; 71*cdf0e10cSrcweir using ::com::sun::star::frame::XComponentLoader; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir //------------------------------------------------------------------------ 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir class SfxFrameWindow_Impl : public Window 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir public: 78*cdf0e10cSrcweir SfxFrame* pFrame; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir SfxFrameWindow_Impl( SfxFrame* pF, Window& i_rContainerWindow ); 81*cdf0e10cSrcweir ~SfxFrameWindow_Impl( ); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 84*cdf0e10cSrcweir virtual void StateChanged( StateChangedType nStateChange ); 85*cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 86*cdf0e10cSrcweir virtual long Notify( NotifyEvent& rEvt ); 87*cdf0e10cSrcweir virtual void Resize(); 88*cdf0e10cSrcweir virtual void GetFocus(); 89*cdf0e10cSrcweir void DoResize(); 90*cdf0e10cSrcweir DECL_LINK( CloserHdl, void* ); 91*cdf0e10cSrcweir }; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir SfxFrameWindow_Impl::SfxFrameWindow_Impl( SfxFrame* pF, Window& i_rContainerWindow ) 94*cdf0e10cSrcweir : Window( &i_rContainerWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK ) 95*cdf0e10cSrcweir , pFrame( pF ) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir SfxFrameWindow_Impl::~SfxFrameWindow_Impl( ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir void SfxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 106*cdf0e10cSrcweir SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl(); 107*cdf0e10cSrcweir if ( pWorkWin ) 108*cdf0e10cSrcweir pWorkWin->DataChanged_Impl( rDCEvt ); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir long SfxFrameWindow_Impl::Notify( NotifyEvent& rNEvt ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir if ( pFrame->IsClosing_Impl() || !pFrame->GetFrameInterface().is() ) 114*cdf0e10cSrcweir return sal_False; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); 117*cdf0e10cSrcweir if ( !pView || !pView->GetObjectShell() ) 118*cdf0e10cSrcweir return Window::Notify( rNEvt ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_GETFOCUS ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir if ( pView->GetViewShell() && !pView->GetViewShell()->GetUIActiveIPClient_Impl() && !pFrame->IsInPlace() ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir DBG_TRACE("SfxFrame: GotFocus"); 125*cdf0e10cSrcweir pView->MakeActive_Impl( sal_False ); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir // TODO/LATER: do we still need this code? 129*cdf0e10cSrcweir Window* pWindow = rNEvt.GetWindow(); 130*cdf0e10cSrcweir rtl::OString sHelpId; 131*cdf0e10cSrcweir while ( !sHelpId.getLength() && pWindow ) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir sHelpId = pWindow->GetHelpId(); 134*cdf0e10cSrcweir pWindow = pWindow->GetParent(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir if ( sHelpId.getLength() ) 138*cdf0e10cSrcweir SfxHelp::OpenHelpAgent( pFrame, sHelpId ); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir // if focus was on an external window, the clipboard content might have been changed 141*cdf0e10cSrcweir pView->GetBindings().Invalidate( SID_PASTE ); 142*cdf0e10cSrcweir pView->GetBindings().Invalidate( SID_PASTE_SPECIAL ); 143*cdf0e10cSrcweir return sal_True; 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir else if( rNEvt.GetType() == EVENT_KEYINPUT ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir if ( pView->GetViewShell()->KeyInput( *rNEvt.GetKeyEvent() ) ) 148*cdf0e10cSrcweir return sal_True; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir else if ( rNEvt.GetType() == EVENT_EXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTDISABLE*/ ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir pView->SetModalMode( sal_True ); 153*cdf0e10cSrcweir return sal_True; 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir else if ( rNEvt.GetType() == EVENT_ENDEXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTENABLE*/ ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir //EnableInput( sal_True, sal_True ); 158*cdf0e10cSrcweir pView->SetModalMode( sal_False ); 159*cdf0e10cSrcweir return sal_True; 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir return Window::Notify( rNEvt ); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir long SfxFrameWindow_Impl::PreNotify( NotifyEvent& rNEvt ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir sal_uInt16 nType = rNEvt.GetType(); 168*cdf0e10cSrcweir if ( nType == EVENT_KEYINPUT || nType == EVENT_KEYUP ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); 171*cdf0e10cSrcweir SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL; 172*cdf0e10cSrcweir if ( pShell && pShell->HasKeyListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) ) 173*cdf0e10cSrcweir return sal_True; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir else if ( nType == EVENT_MOUSEBUTTONUP || nType == EVENT_MOUSEBUTTONDOWN ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir Window* pWindow = rNEvt.GetWindow(); 178*cdf0e10cSrcweir SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); 179*cdf0e10cSrcweir SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL; 180*cdf0e10cSrcweir if ( pShell ) 181*cdf0e10cSrcweir if ( pWindow == pShell->GetWindow() || pShell->GetWindow()->IsChild( pWindow ) ) 182*cdf0e10cSrcweir if ( pShell->HasMouseClickListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) ) 183*cdf0e10cSrcweir return sal_True; 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir if ( nType == EVENT_MOUSEBUTTONDOWN ) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir Window* pWindow = rNEvt.GetWindow(); 189*cdf0e10cSrcweir const MouseEvent* pMEvent = rNEvt.GetMouseEvent(); 190*cdf0e10cSrcweir Point aPos = pWindow->OutputToScreenPixel( pMEvent->GetPosPixel() ); 191*cdf0e10cSrcweir SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl(); 192*cdf0e10cSrcweir if ( pWorkWin ) 193*cdf0e10cSrcweir pWorkWin->EndAutoShow_Impl( aPos ); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir return Window::PreNotify( rNEvt ); 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir void SfxFrameWindow_Impl::GetFocus() 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir if ( pFrame && !pFrame->IsClosing_Impl() && pFrame->GetCurrentViewFrame() && pFrame->GetFrameInterface().is() ) 202*cdf0e10cSrcweir pFrame->GetCurrentViewFrame()->MakeActive_Impl( sal_True ); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir void SfxFrameWindow_Impl::Resize() 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() ) 208*cdf0e10cSrcweir DoResize(); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir void SfxFrameWindow_Impl::StateChanged( StateChangedType nStateChange ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir if ( nStateChange == STATE_CHANGE_INITSHOW ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir pFrame->pImp->bHidden = sal_False; 216*cdf0e10cSrcweir if ( pFrame->IsInPlace() ) 217*cdf0e10cSrcweir // TODO/MBA: workaround for bug in LayoutManager: the final resize does not get through because the 218*cdf0e10cSrcweir // LayoutManager works asynchronously and between resize and time execution the DockingAcceptor was exchanged so that 219*cdf0e10cSrcweir // the resize event never is sent to the component 220*cdf0e10cSrcweir SetSizePixel( GetParent()->GetOutputSizePixel() ); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir DoResize(); 223*cdf0e10cSrcweir SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); 224*cdf0e10cSrcweir if ( pView ) 225*cdf0e10cSrcweir pView->GetBindings().GetWorkWindow_Impl()->ShowChilds_Impl(); 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir Window::StateChanged( nStateChange ); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir void SfxFrameWindow_Impl::DoResize() 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir if ( !pFrame->pImp->bLockResize ) 234*cdf0e10cSrcweir pFrame->Resize(); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir Reference < XFrame > SfxFrame::CreateBlankFrame() 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir Reference < XFrame > xFrame; 240*cdf0e10cSrcweir try 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); 243*cdf0e10cSrcweir Reference < XFrame > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); 244*cdf0e10cSrcweir xFrame.set( xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 ), UNO_SET_THROW ); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir catch( const Exception& ) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir return xFrame; 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir SfxFrame* SfxFrame::Create( SfxObjectShell& rDoc, Window& rWindow, sal_uInt16 nViewId, bool bHidden ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir SfxFrame* pFrame = NULL; 256*cdf0e10cSrcweir try 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir // create and initialize new top level frame for this window 259*cdf0e10cSrcweir ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); 260*cdf0e10cSrcweir Reference < XFramesSupplier > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); 261*cdf0e10cSrcweir Reference < XFrame > xFrame( aContext.createComponent( "com.sun.star.frame.Frame"), UNO_QUERY_THROW ); 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir Reference< awt::XWindow2 > xWin( VCLUnoHelper::GetInterface ( &rWindow ), uno::UNO_QUERY_THROW ); 264*cdf0e10cSrcweir xFrame->initialize( xWin.get() ); 265*cdf0e10cSrcweir xDesktop->getFrames()->append( xFrame ); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir if ( xWin->isActive() ) 268*cdf0e10cSrcweir xFrame->activate(); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir // create load arguments 271*cdf0e10cSrcweir Sequence< PropertyValue > aLoadArgs; 272*cdf0e10cSrcweir TransformItems( SID_OPENDOC, *rDoc.GetMedium()->GetItemSet(), aLoadArgs ); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir ::comphelper::NamedValueCollection aArgs( aLoadArgs ); 275*cdf0e10cSrcweir aArgs.put( "Model", rDoc.GetModel() ); 276*cdf0e10cSrcweir aArgs.put( "Hidden", bHidden ); 277*cdf0e10cSrcweir if ( nViewId ) 278*cdf0e10cSrcweir aArgs.put( "ViewId", nViewId ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir aLoadArgs = aArgs.getPropertyValues(); 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir // load the doc into that frame 283*cdf0e10cSrcweir ::rtl::OUString sLoaderURL( RTL_CONSTASCII_USTRINGPARAM( "private:object" ) ); 284*cdf0e10cSrcweir Reference< XComponentLoader > xLoader( xFrame, UNO_QUERY_THROW ); 285*cdf0e10cSrcweir xLoader->loadComponentFromURL( 286*cdf0e10cSrcweir sLoaderURL, 287*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ), 288*cdf0e10cSrcweir 0, 289*cdf0e10cSrcweir aLoadArgs 290*cdf0e10cSrcweir ); 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir for ( pFrame = SfxFrame::GetFirst(); 293*cdf0e10cSrcweir pFrame; 294*cdf0e10cSrcweir pFrame = SfxFrame::GetNext( *pFrame ) 295*cdf0e10cSrcweir ) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir if ( pFrame->GetFrameInterface() == xFrame ) 298*cdf0e10cSrcweir break; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir OSL_ENSURE( pFrame, "SfxFrame::Create: load succeeded, but no SfxFrame was created during this!" ); 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir catch( const Exception& ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir return pFrame; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir SfxFrame* SfxFrame::Create( const Reference < XFrame >& i_rFrame ) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir // create a new TopFrame to an external XFrame object ( wrap controller ) 314*cdf0e10cSrcweir ENSURE_OR_THROW( i_rFrame.is(), "NULL frame not allowed" ); 315*cdf0e10cSrcweir Window* pWindow = VCLUnoHelper::GetWindow( i_rFrame->getContainerWindow() ); 316*cdf0e10cSrcweir ENSURE_OR_THROW( pWindow, "frame without container window not allowed" ); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir SfxFrame* pFrame = new SfxFrame( *pWindow, false ); 319*cdf0e10cSrcweir pFrame->SetFrameInterface_Impl( i_rFrame ); 320*cdf0e10cSrcweir return pFrame; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir SfxFrame::SfxFrame( Window& i_rContainerWindow, bool i_bHidden ) 324*cdf0e10cSrcweir :pParentFrame( NULL ) 325*cdf0e10cSrcweir ,pChildArr( NULL ) 326*cdf0e10cSrcweir ,pImp( NULL ) 327*cdf0e10cSrcweir ,pWindow( NULL ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir Construct_Impl(); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir pImp->bHidden = i_bHidden; 332*cdf0e10cSrcweir InsertTopFrame_Impl( this ); 333*cdf0e10cSrcweir pImp->pExternalContainerWindow = &i_rContainerWindow; 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir pWindow = new SfxFrameWindow_Impl( this, i_rContainerWindow ); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir // always show pWindow, which is the ComponentWindow of the XFrame we live in 338*cdf0e10cSrcweir // nowadays, since SfxFrames can be created with an XFrame only, hiding or showing the complete XFrame 339*cdf0e10cSrcweir // is not done at level of the container window, not at SFX level. Thus, the component window can 340*cdf0e10cSrcweir // always be visible. 341*cdf0e10cSrcweir pWindow->Show(); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir void SfxFrame::SetPresentationMode( sal_Bool bSet ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir if ( GetCurrentViewFrame() ) 347*cdf0e10cSrcweir GetCurrentViewFrame()->GetWindow().SetBorderStyle( bSet ? WINDOW_BORDER_NOBORDER : WINDOW_BORDER_NORMAL ); 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY ); 350*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir if ( xPropSet.is() ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); 355*cdf0e10cSrcweir aValue >>= xLayoutManager; 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir if ( xLayoutManager.is() ) 359*cdf0e10cSrcweir xLayoutManager->setVisible( !bSet ); // we don't want to have ui in presentation mode 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir SetMenuBarOn_Impl( !bSet ); 362*cdf0e10cSrcweir if ( GetWorkWindow_Impl() ) 363*cdf0e10cSrcweir GetWorkWindow_Impl()->SetDockingAllowed( !bSet ); 364*cdf0e10cSrcweir if ( GetCurrentViewFrame() ) 365*cdf0e10cSrcweir GetCurrentViewFrame()->GetDispatcher()->Update_Impl( sal_True ); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir SystemWindow* SfxFrame::GetSystemWindow() const 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir return GetTopWindow_Impl(); 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir SystemWindow* SfxFrame::GetTopWindow_Impl() const 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir if ( pImp->pExternalContainerWindow->IsSystemWindow() ) 376*cdf0e10cSrcweir return (SystemWindow*) pImp->pExternalContainerWindow; 377*cdf0e10cSrcweir else 378*cdf0e10cSrcweir return NULL; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir Window& SfxFrame::GetWindow() const 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir return *pWindow; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir sal_Bool SfxFrame::Close() 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir delete this; 389*cdf0e10cSrcweir return sal_True; 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir void SfxFrame::LockResize_Impl( sal_Bool bLock ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir pImp->bLockResize = bLock; 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir IMPL_LINK( SfxFrameWindow_Impl, CloserHdl, void*, EMPTYARG ) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir if ( pFrame && !pFrame->PrepareClose_Impl( sal_True ) ) 400*cdf0e10cSrcweir return 0L; 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir if ( pFrame ) 403*cdf0e10cSrcweir pFrame->GetCurrentViewFrame()->GetBindings().Execute( SID_CLOSEWIN, 0, 0, SFX_CALLMODE_ASYNCHRON ); 404*cdf0e10cSrcweir return 0L; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir void SfxFrame::SetMenuBarOn_Impl( sal_Bool bOn ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir pImp->bMenuBarOn = bOn; 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY ); 412*cdf0e10cSrcweir Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir if ( xPropSet.is() ) 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); 417*cdf0e10cSrcweir aValue >>= xLayoutManager; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir if ( xLayoutManager.is() ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir rtl::OUString aMenuBarURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir if ( bOn ) 425*cdf0e10cSrcweir xLayoutManager->showElement( aMenuBarURL ); 426*cdf0e10cSrcweir else 427*cdf0e10cSrcweir xLayoutManager->hideElement( aMenuBarURL ); 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir sal_Bool SfxFrame::IsMenuBarOn_Impl() const 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir return pImp->bMenuBarOn; 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir void SfxFrame::PositionWindow_Impl( const Rectangle& rWinArea ) const 437*cdf0e10cSrcweir { 438*cdf0e10cSrcweir Window *pWin = pImp->pExternalContainerWindow; 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir // Groesse setzen 441*cdf0e10cSrcweir const Size aAppWindow( pImp->pExternalContainerWindow->GetDesktopRectPixel().GetSize() ); 442*cdf0e10cSrcweir Point aPos( rWinArea.TopLeft() ); 443*cdf0e10cSrcweir Size aSz( rWinArea.GetSize() ); 444*cdf0e10cSrcweir if ( aSz.Width() && aSz.Height() ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir aPos.X() = Min(aPos.X(), 447*cdf0e10cSrcweir long(aAppWindow.Width() - aSz.Width() + aSz.Width() / 2) ); 448*cdf0e10cSrcweir aPos.Y() = Min(aPos.Y(), 449*cdf0e10cSrcweir long( aAppWindow.Height() - aSz.Height() + aSz.Height() / 2) ); 450*cdf0e10cSrcweir if ( aPos.X() + aSz.Width() < 451*cdf0e10cSrcweir aAppWindow.Width() + aSz.Width() / 2 && 452*cdf0e10cSrcweir aPos.Y() + aSz.Height() < 453*cdf0e10cSrcweir aAppWindow.Height() + aSz.Height() / 2 ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir pWin->SetPosPixel( aPos ); 456*cdf0e10cSrcweir pWin->SetOutputSizePixel( aSz ); 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir void SfxFrame::PrepareForDoc_Impl( SfxObjectShell& i_rDoc ) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir const ::comphelper::NamedValueCollection aDocumentArgs( i_rDoc.GetModel()->getArgs() ); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir // hidden? 466*cdf0e10cSrcweir OSL_ENSURE( !pImp->bHidden, "when does this happen?" ); 467*cdf0e10cSrcweir pImp->bHidden = aDocumentArgs.getOrDefault( "Hidden", pImp->bHidden ); 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir // update our descriptor 470*cdf0e10cSrcweir UpdateDescriptor( &i_rDoc ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir // plugin mode 473*cdf0e10cSrcweir sal_Int16 nPluginMode = aDocumentArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) ); 474*cdf0e10cSrcweir if ( nPluginMode && ( nPluginMode != 2 ) ) 475*cdf0e10cSrcweir SetInPlace_Impl( sal_True ); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir bool SfxFrame::IsMarkedHidden_Impl() const 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir return pImp->bHidden; 481*cdf0e10cSrcweir } 482