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 #ifndef _TOOLBOX_HXX //autogen 32*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #ifndef _RCID_H 35*cdf0e10cSrcweir #include <tools/rcid.h> 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir #include <unotools/viewoptions.hxx> 38*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp> 41*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #ifndef GCC 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <sfx2/childwin.hxx> 47*cdf0e10cSrcweir #include <sfx2/app.hxx> 48*cdf0e10cSrcweir #include "arrdecl.hxx" 49*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 50*cdf0e10cSrcweir #include <sfx2/module.hxx> 51*cdf0e10cSrcweir #include <sfx2/dockwin.hxx> 52*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 53*cdf0e10cSrcweir #include "workwin.hxx" 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir static const sal_uInt16 nVersion = 2; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir DBG_NAME(SfxChildWindow) 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir SV_IMPL_PTRARR( SfxChildWinContextArr_Impl, SfxChildWinContextFactory* ); 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir struct SfxChildWindow_Impl 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame; 64*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xListener; 65*cdf0e10cSrcweir SfxChildWinFactory* pFact; 66*cdf0e10cSrcweir sal_Bool bHideNotDelete; 67*cdf0e10cSrcweir sal_Bool bVisible; 68*cdf0e10cSrcweir sal_Bool bHideAtToggle; 69*cdf0e10cSrcweir sal_Bool bWantsFocus; 70*cdf0e10cSrcweir SfxModule* pContextModule; 71*cdf0e10cSrcweir SfxWorkWindow* pWorkWin; 72*cdf0e10cSrcweir }; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir // ----------------------------------------------------------------------- 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir class DisposeListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener > 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir public: 79*cdf0e10cSrcweir DisposeListener( SfxChildWindow* pOwner , 80*cdf0e10cSrcweir SfxChildWindow_Impl* pData ) 81*cdf0e10cSrcweir : m_pOwner( pOwner ) 82*cdf0e10cSrcweir , m_pData ( pData ) 83*cdf0e10cSrcweir {} 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aSource ) throw (::com::sun::star::uno::RuntimeException) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xSelfHold( this ); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( aSource.Source, ::com::sun::star::uno::UNO_QUERY ); 90*cdf0e10cSrcweir if( xComp.is() ) 91*cdf0e10cSrcweir xComp->removeEventListener( this ); 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir if( m_pOwner && m_pData ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir m_pData->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >(); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir if ( m_pData->pWorkWin ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir // m_pOwner and m_pData will be killed 100*cdf0e10cSrcweir m_pData->xFrame = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >(); 101*cdf0e10cSrcweir m_pData->pWorkWin->GetBindings().Execute( m_pOwner->GetType() ); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir else 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir delete m_pOwner; 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir m_pOwner = NULL; 109*cdf0e10cSrcweir m_pData = NULL; 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir private: 114*cdf0e10cSrcweir SfxChildWindow* m_pOwner; 115*cdf0e10cSrcweir SfxChildWindow_Impl* m_pData ; 116*cdf0e10cSrcweir }; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir // ----------------------------------------------------------------------- 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir sal_Bool GetPosSizeFromString( const String& rStr, Point& rPos, Size& rSize ) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir if ( rStr.GetTokenCount('/') != 4 ) 123*cdf0e10cSrcweir return sal_False; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir xub_StrLen nIdx = 0; 126*cdf0e10cSrcweir rPos.X() = rStr.GetToken(0, '/', nIdx).ToInt32(); 127*cdf0e10cSrcweir rPos.Y() = rStr.GetToken(0, '/', nIdx).ToInt32(); 128*cdf0e10cSrcweir rSize.Width() = rStr.GetToken(0, '/', nIdx).ToInt32(); 129*cdf0e10cSrcweir rSize.Height() = rStr.GetToken(0, '/', nIdx).ToInt32(); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir // negative sizes are invalid 132*cdf0e10cSrcweir if ( rSize.Width() < 0 || rSize.Height() < 0 ) 133*cdf0e10cSrcweir return sal_False; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir return sal_True; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir sal_Bool GetSplitSizeFromString( const String& rStr, Size& rSize ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir xub_StrLen nIndex = rStr.Search( ',' ); 141*cdf0e10cSrcweir if ( nIndex != STRING_NOTFOUND ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir String aStr = rStr.Copy( nIndex+1 ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir sal_Int32 nCount = aStr.GetTokenCount(';'); 146*cdf0e10cSrcweir if ( nCount != 2 ) 147*cdf0e10cSrcweir return sal_False; 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir rSize.Width() = aStr.GetToken(0, ';' ).ToInt32(); 150*cdf0e10cSrcweir rSize.Height() = aStr.GetToken(1, ';' ).ToInt32(); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir // negative sizes are invalid 153*cdf0e10cSrcweir if ( rSize.Width() < 0 || rSize.Height() < 0 ) 154*cdf0e10cSrcweir return sal_False; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir return sal_True; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir return sal_False; 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir //========================================================================= 163*cdf0e10cSrcweir SfxChildWindow::SfxChildWindow(Window *pParentWindow, sal_uInt16 nId) 164*cdf0e10cSrcweir : pParent(pParentWindow) 165*cdf0e10cSrcweir , nType(nId) 166*cdf0e10cSrcweir , eChildAlignment(SFX_ALIGN_NOALIGNMENT) 167*cdf0e10cSrcweir , pWindow(0L) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir pImp = new SfxChildWindow_Impl; 170*cdf0e10cSrcweir pImp->pFact = 0L; 171*cdf0e10cSrcweir pImp->bHideNotDelete = sal_False; 172*cdf0e10cSrcweir pImp->bHideAtToggle = sal_False; 173*cdf0e10cSrcweir pImp->bWantsFocus = sal_True; 174*cdf0e10cSrcweir pImp->bVisible = sal_True; 175*cdf0e10cSrcweir pImp->pContextModule = NULL; 176*cdf0e10cSrcweir pImp->pWorkWin = NULL; 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir pContext = 0L; 179*cdf0e10cSrcweir DBG_CTOR(SfxChildWindow,0); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir void SfxChildWindow::Destroy() 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir if ( GetFrame().is() ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir pImp->pWorkWin = NULL; 187*cdf0e10cSrcweir try 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::util::XCloseable > xClose( GetFrame(), ::com::sun::star::uno::UNO_QUERY ); 190*cdf0e10cSrcweir if ( xClose.is() ) 191*cdf0e10cSrcweir xClose->close( sal_True ); 192*cdf0e10cSrcweir else 193*cdf0e10cSrcweir GetFrame()->dispose(); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir catch ( com::sun::star::uno::Exception& ) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir else 200*cdf0e10cSrcweir delete this; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir //------------------------------------------------------------------------- 204*cdf0e10cSrcweir SfxChildWindow::~SfxChildWindow() 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir DBG_DTOR(SfxChildWindow,0); 207*cdf0e10cSrcweir if ( pContext ) 208*cdf0e10cSrcweir delete pContext; 209*cdf0e10cSrcweir if ( pWindow ) 210*cdf0e10cSrcweir delete pWindow; 211*cdf0e10cSrcweir delete pImp; 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir //------------------------------------------------------------------------- 215*cdf0e10cSrcweir SfxChildWindow* SfxChildWindow::CreateChildWindow( sal_uInt16 nId, 216*cdf0e10cSrcweir Window *pParent, SfxBindings* pBindings, SfxChildWinInfo& rInfo) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir SfxChildWindow *pChild=0; 219*cdf0e10cSrcweir SfxChildWinFactory* pFact=0; 220*cdf0e10cSrcweir sal_uInt16 nOldMode = Application::GetSystemWindowMode(); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir // Zuerst ChildWindow im SDT suchen; "Uberlagerungen m"ussen mit einem 223*cdf0e10cSrcweir // ChildWindowContext realisiert werden 224*cdf0e10cSrcweir SfxApplication *pApp = SFX_APP(); 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl(); 227*cdf0e10cSrcweir for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir pFact = rFactories[nFactory]; 230*cdf0e10cSrcweir if ( pFact->nId == nId ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir SfxChildWinInfo& rFactInfo = pFact->aInfo; 233*cdf0e10cSrcweir if ( rInfo.bVisible ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir if ( pBindings ) 236*cdf0e10cSrcweir pBindings->ENTERREGISTRATIONS(); 237*cdf0e10cSrcweir SfxChildWinInfo aInfo = rFactInfo; 238*cdf0e10cSrcweir Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE ); 239*cdf0e10cSrcweir pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo ); 240*cdf0e10cSrcweir Application::SetSystemWindowMode( nOldMode ); 241*cdf0e10cSrcweir if ( pBindings ) 242*cdf0e10cSrcweir pBindings->LEAVEREGISTRATIONS(); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir break; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir SfxDispatcher *pDisp = pBindings->GetDispatcher_Impl(); 251*cdf0e10cSrcweir SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0; 252*cdf0e10cSrcweir if ( !pChild && pMod ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl(); 255*cdf0e10cSrcweir if ( pFactories ) 256*cdf0e10cSrcweir { 257*cdf0e10cSrcweir SfxChildWinFactArr_Impl &rFactories = *pFactories; 258*cdf0e10cSrcweir for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory ) 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir pFact = rFactories[nFactory]; 261*cdf0e10cSrcweir if ( pFact->nId == nId ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir SfxChildWinInfo& rFactInfo = pFact->aInfo; 264*cdf0e10cSrcweir if ( rInfo.bVisible ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir if ( pBindings ) 267*cdf0e10cSrcweir pBindings->ENTERREGISTRATIONS(); 268*cdf0e10cSrcweir SfxChildWinInfo aInfo = rFactInfo; 269*cdf0e10cSrcweir Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE ); 270*cdf0e10cSrcweir pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo ); 271*cdf0e10cSrcweir Application::SetSystemWindowMode( nOldMode ); 272*cdf0e10cSrcweir if ( pBindings ) 273*cdf0e10cSrcweir pBindings->LEAVEREGISTRATIONS(); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir break; 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir if ( pChild ) 283*cdf0e10cSrcweir pChild->SetFactory_Impl( pFact ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir DBG_ASSERT(pFact && (pChild || !rInfo.bVisible), "ChildWindow-Typ nicht registriert!"); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir if ( pChild && !pChild->pWindow ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir DELETEZ(pChild); 290*cdf0e10cSrcweir DBG_WARNING("ChildWindow hat kein Fenster!"); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir return pChild; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir //------------------------------------------------------------------------- 297*cdf0e10cSrcweir void SfxChildWindow::SaveStatus(const SfxChildWinInfo& rInfo) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir sal_uInt16 nID = GetType(); 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir String aWinData( 'V' ); 302*cdf0e10cSrcweir aWinData += String::CreateFromInt32( nVersion ); 303*cdf0e10cSrcweir aWinData += ','; 304*cdf0e10cSrcweir aWinData += rInfo.bVisible ? 'V' : 'H'; 305*cdf0e10cSrcweir aWinData += ','; 306*cdf0e10cSrcweir aWinData += String::CreateFromInt32( rInfo.nFlags ); 307*cdf0e10cSrcweir if ( rInfo.aExtraString.Len() ) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir aWinData += ','; 310*cdf0e10cSrcweir aWinData += rInfo.aExtraString; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir SvtViewOptions aWinOpt( E_WINDOW, String::CreateFromInt32( nID ) ); 314*cdf0e10cSrcweir // aWinOpt.SetPosition( rInfo.aPos.X(), rInfo.aPos.Y() ); 315*cdf0e10cSrcweir // aWinOpt.SetSize( rInfo.aSize.Width(), rInfo.aSize.Height() ); 316*cdf0e10cSrcweir aWinOpt.SetWindowState( String( rInfo.aWinState, RTL_TEXTENCODING_UTF8 ) ); 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1); 319*cdf0e10cSrcweir aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Data") ); 320*cdf0e10cSrcweir aSeq[0].Value <<= ::rtl::OUString( aWinData ); 321*cdf0e10cSrcweir aWinOpt.SetUserData( aSeq ); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // ... but save status at runtime! 324*cdf0e10cSrcweir pImp->pFact->aInfo = rInfo; 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir //------------------------------------------------------------------------- 328*cdf0e10cSrcweir void SfxChildWindow::SetAlignment(SfxChildAlignment eAlign) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir DBG_CHKTHIS(SfxChildWindow,0); 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir eChildAlignment = eAlign; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir //------------------------------------------------------------------------- 336*cdf0e10cSrcweir void SfxChildWindow::SetPosSizePixel(const Point& rPoint, Size& rSize) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir DBG_CHKTHIS(SfxChildWindow,0); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir pWindow->SetPosSizePixel(rPoint, rSize); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir //------------------------------------------------------------------------- 344*cdf0e10cSrcweir SfxChildWinInfo SfxChildWindow::GetInfo() const 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir DBG_CHKTHIS(SfxChildWindow,0); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir SfxChildWinInfo aInfo; 349*cdf0e10cSrcweir aInfo.aPos = pWindow->GetPosPixel(); 350*cdf0e10cSrcweir aInfo.aSize = pWindow->GetSizePixel(); 351*cdf0e10cSrcweir if ( pWindow->IsSystemWindow() ) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE; 354*cdf0e10cSrcweir if ( pWindow->GetStyle() & WB_SIZEABLE ) 355*cdf0e10cSrcweir nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT ); 356*cdf0e10cSrcweir aInfo.aWinState = ((SystemWindow*)pWindow)->GetWindowState( nMask ); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir else if ( pWindow->GetType() == RSC_DOCKINGWINDOW ) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir if (((DockingWindow*)pWindow)->GetFloatingWindow() ) 361*cdf0e10cSrcweir aInfo.aWinState = ((DockingWindow*)pWindow)->GetFloatingWindow()->GetWindowState(); 362*cdf0e10cSrcweir else 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir SfxChildWinInfo aTmpInfo; 365*cdf0e10cSrcweir ((SfxDockingWindow*)pWindow)->FillInfo( aTmpInfo ); 366*cdf0e10cSrcweir aInfo.aExtraString = aTmpInfo.aExtraString; 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir aInfo.bVisible = pImp->bVisible; 371*cdf0e10cSrcweir aInfo.nFlags = 0; 372*cdf0e10cSrcweir return aInfo; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir //------------------------------------------------------------------------- 376*cdf0e10cSrcweir sal_uInt16 SfxChildWindow::GetPosition() 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir return pImp->pFact->nPos; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir #if 0 382*cdf0e10cSrcweir static void ImplWindowStateFromStr( Point rPos, Size rSize, const ByteString& rStr ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir sal_uIntPtr nValidMask = 0; 385*cdf0e10cSrcweir xub_StrLen nIndex = 0; 386*cdf0e10cSrcweir ByteString aTokenStr; 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir aTokenStr = rStr.GetToken( 0, ',', nIndex ); 389*cdf0e10cSrcweir if ( aTokenStr.Len() ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir rPos.X() = aTokenStr.ToInt32(); 392*cdf0e10cSrcweir nValidMask |= WINDOWSTATE_MASK_X; 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir aTokenStr = rStr.GetToken( 0, ',', nIndex ); 396*cdf0e10cSrcweir if ( aTokenStr.Len() ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir rPos.Y() = aTokenStr.ToInt32(); 399*cdf0e10cSrcweir nValidMask |= WINDOWSTATE_MASK_Y; 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir aTokenStr = rStr.GetToken( 0, ',', nIndex ); 403*cdf0e10cSrcweir if ( aTokenStr.Len() ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir rSize.Width() = aTokenStr.ToInt32(); 406*cdf0e10cSrcweir nValidMask |= WINDOWSTATE_MASK_WIDTH; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir aTokenStr = rStr.GetToken( 0, ';', nIndex ); 410*cdf0e10cSrcweir if ( aTokenStr.Len() ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir rSize.Height() = aTokenStr.ToInt32(); 413*cdf0e10cSrcweir nValidMask |= WINDOWSTATE_MASK_HEIGHT; 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir #endif 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir //------------------------------------------------------------------------- 419*cdf0e10cSrcweir void SfxChildWindow::InitializeChildWinFactory_Impl( sal_uInt16 nId, SfxChildWinInfo& rInfo ) 420*cdf0e10cSrcweir { 421*cdf0e10cSrcweir // load configuration 422*cdf0e10cSrcweir SvtViewOptions aWinOpt( E_WINDOW, String::CreateFromInt32( nId ) ); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir if ( aWinOpt.Exists() ) 425*cdf0e10cSrcweir rInfo.bVisible = aWinOpt.IsVisible(); // set state from configuration. Can be overwritten by UserData, see below 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData(); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir ::rtl::OUString aTmp; 430*cdf0e10cSrcweir if ( aSeq.getLength() ) 431*cdf0e10cSrcweir aSeq[0].Value >>= aTmp; 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir String aWinData( aTmp ); 434*cdf0e10cSrcweir rInfo.aWinState = ByteString( String(aWinOpt.GetWindowState()), RTL_TEXTENCODING_UTF8 ); 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir //ImplWindowStateFromStr( rInfo.aPos, rInfo.aSize, ByteString( aWinState, RTL_TEXTENCODING_UTF8 ) ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir if ( aWinData.Len() ) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir // Nach Versionskennung suchen 441*cdf0e10cSrcweir if ( aWinData.GetChar((sal_uInt16)0) != 0x0056 ) // 'V' = 56h 442*cdf0e10cSrcweir // Keine Versionskennung, daher nicht verwenden 443*cdf0e10cSrcweir return; 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir // 'V' l"oschen 446*cdf0e10cSrcweir aWinData.Erase(0,1); 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir // Version lesen 449*cdf0e10cSrcweir char cToken = ','; 450*cdf0e10cSrcweir sal_uInt16 nPos = aWinData.Search( cToken ); 451*cdf0e10cSrcweir sal_uInt16 nActVersion = (sal_uInt16)aWinData.Copy( 0, nPos + 1 ).ToInt32(); 452*cdf0e10cSrcweir if ( nActVersion != nVersion ) 453*cdf0e10cSrcweir return; 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir aWinData.Erase(0,nPos+1); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir //aWinOpt.GetPosition( rInfo.aPos.X(), rInfo.aPos.Y() ); 458*cdf0e10cSrcweir //aWinOpt.GetSize( rInfo.aSize.Width(), rInfo.aSize.Height() ); 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir // Sichtbarkeit laden: ist als ein char codiert 461*cdf0e10cSrcweir rInfo.bVisible = (aWinData.GetChar(0) == 0x0056); // 'V' = 56h 462*cdf0e10cSrcweir aWinData.Erase(0,1); 463*cdf0e10cSrcweir nPos = aWinData.Search( cToken ); 464*cdf0e10cSrcweir if (nPos != STRING_NOTFOUND) 465*cdf0e10cSrcweir { 466*cdf0e10cSrcweir sal_uInt16 nNextPos = aWinData.Search( cToken, 2 ); 467*cdf0e10cSrcweir if ( nNextPos != STRING_NOTFOUND ) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir // es gibt noch Extra-Information 470*cdf0e10cSrcweir rInfo.nFlags = (sal_uInt16)aWinData.Copy( nPos+1, nNextPos - nPos - 1 ).ToInt32(); 471*cdf0e10cSrcweir aWinData.Erase( nPos, nNextPos-nPos+1 ); 472*cdf0e10cSrcweir rInfo.aExtraString = aWinData; 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir else 475*cdf0e10cSrcweir rInfo.nFlags = (sal_uInt16)aWinData.Copy( nPos+1 ).ToInt32(); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir void SfxChildWindow::CreateContext( sal_uInt16 nContextId, SfxBindings& rBindings ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir SfxChildWindowContext *pCon = NULL; 483*cdf0e10cSrcweir SfxChildWinFactory* pFact=0; 484*cdf0e10cSrcweir SfxApplication *pApp = SFX_APP(); 485*cdf0e10cSrcweir SfxDispatcher *pDisp = rBindings.GetDispatcher_Impl(); 486*cdf0e10cSrcweir SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0; 487*cdf0e10cSrcweir if ( pMod ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl(); 490*cdf0e10cSrcweir if ( pFactories ) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir SfxChildWinFactArr_Impl &rFactories = *pFactories; 493*cdf0e10cSrcweir for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory ) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir pFact = rFactories[nFactory]; 496*cdf0e10cSrcweir if ( pFact->nId == GetType() ) 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir DBG_ASSERT( pFact->pArr, "Kein Kontext angemeldet!" ); 499*cdf0e10cSrcweir if ( !pFact->pArr ) 500*cdf0e10cSrcweir break; 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir SfxChildWinContextFactory *pConFact=0; 503*cdf0e10cSrcweir for ( sal_uInt16 n=0; n<pFact->pArr->Count(); ++n ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir pConFact = (*pFact->pArr)[n]; 506*cdf0e10cSrcweir rBindings.ENTERREGISTRATIONS(); 507*cdf0e10cSrcweir if ( pConFact->nContextId == nContextId ) 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir SfxChildWinInfo aInfo = pFact->aInfo; 510*cdf0e10cSrcweir pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo ); 511*cdf0e10cSrcweir pCon->nContextId = pConFact->nContextId; 512*cdf0e10cSrcweir pImp->pContextModule = pMod; 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir rBindings.LEAVEREGISTRATIONS(); 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir break; 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir if ( !pCon ) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl(); 525*cdf0e10cSrcweir for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory ) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir pFact = rFactories[nFactory]; 528*cdf0e10cSrcweir if ( pFact->nId == GetType() ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir DBG_ASSERT( pFact->pArr, "Kein Kontext angemeldet!" ); 531*cdf0e10cSrcweir if ( !pFact->pArr ) 532*cdf0e10cSrcweir break; 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir SfxChildWinContextFactory *pConFact=0; 535*cdf0e10cSrcweir for ( sal_uInt16 n=0; n<pFact->pArr->Count(); ++n ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir pConFact = (*pFact->pArr)[n]; 538*cdf0e10cSrcweir rBindings.ENTERREGISTRATIONS(); 539*cdf0e10cSrcweir if ( pConFact->nContextId == nContextId ) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir SfxChildWinInfo aInfo = pFact->aInfo; 542*cdf0e10cSrcweir pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo ); 543*cdf0e10cSrcweir pCon->nContextId = pConFact->nContextId; 544*cdf0e10cSrcweir pImp->pContextModule = NULL; 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir rBindings.LEAVEREGISTRATIONS(); 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir break; 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir if ( !pCon ) 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir DBG_ERROR( "Kein geeigneter Context gefunden!" ); 556*cdf0e10cSrcweir return; 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir 559*cdf0e10cSrcweir if ( pContext ) 560*cdf0e10cSrcweir delete( pContext ); 561*cdf0e10cSrcweir pContext = pCon; 562*cdf0e10cSrcweir pContext->GetWindow()->SetSizePixel( pWindow->GetOutputSizePixel() ); 563*cdf0e10cSrcweir pContext->GetWindow()->Show(); 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir SfxChildWindowContext::SfxChildWindowContext( sal_uInt16 nId ) 567*cdf0e10cSrcweir : pWindow( NULL ) 568*cdf0e10cSrcweir , nContextId( nId ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir SfxChildWindowContext::~SfxChildWindowContext() 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir delete pWindow; 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir FloatingWindow* SfxChildWindowContext::GetFloatingWindow() const 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir Window *pParent = pWindow->GetParent(); 580*cdf0e10cSrcweir if ( pParent->GetType() == RSC_DOCKINGWINDOW || pParent->GetType() == RSC_TOOLBOX ) 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir return ((DockingWindow*)pParent)->GetFloatingWindow(); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir else if ( pParent->GetType() == RSC_FLOATINGWINDOW ) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir return (FloatingWindow*) pParent; 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir else 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir DBG_ERROR("Kein FloatingWindow-Context!"); 591*cdf0e10cSrcweir return NULL; 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir SfxChildAlignment SfxChildWindowContext::GetAlignment() const 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir Window *pParent = pWindow->GetParent(); 598*cdf0e10cSrcweir if ( pParent->GetType() == RSC_DOCKINGWINDOW ) 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir return ((SfxDockingWindow*)pParent)->GetAlignment(); 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir else if ( pParent->GetType() == RSC_TOOLBOX ) 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir HACK(noch nicht verwendet und noch nicht implementiert); 605*cdf0e10cSrcweir return SFX_ALIGN_NOALIGNMENT; 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir else 608*cdf0e10cSrcweir return SFX_ALIGN_NOALIGNMENT; 609*cdf0e10cSrcweir } 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir void SfxChildWindowContext::Resizing( Size& ) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir sal_Bool SfxChildWindowContext::Close() 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir return sal_True; 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir void SfxChildWindow::SetFactory_Impl( SfxChildWinFactory *pF ) 621*cdf0e10cSrcweir { 622*cdf0e10cSrcweir pImp->pFact = pF; 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir void SfxChildWindow::SetHideNotDelete( sal_Bool bOn ) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir pImp->bHideNotDelete = bOn; 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir sal_Bool SfxChildWindow::IsHideNotDelete() const 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir return pImp->bHideNotDelete; 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir void SfxChildWindow::SetHideAtToggle( sal_Bool bOn ) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir pImp->bHideAtToggle = bOn; 638*cdf0e10cSrcweir } 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir sal_Bool SfxChildWindow::IsHideAtToggle() const 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir return pImp->bHideAtToggle; 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir void SfxChildWindow::SetWantsFocus( sal_Bool bSet ) 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir pImp->bWantsFocus = bSet; 648*cdf0e10cSrcweir } 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir sal_Bool SfxChildWindow::WantsFocus() const 651*cdf0e10cSrcweir { 652*cdf0e10cSrcweir return pImp->bWantsFocus; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir sal_Bool SfxChildWinInfo::GetExtraData_Impl 656*cdf0e10cSrcweir ( 657*cdf0e10cSrcweir SfxChildAlignment *pAlign, 658*cdf0e10cSrcweir SfxChildAlignment *pLastAlign, 659*cdf0e10cSrcweir Size *pSize, 660*cdf0e10cSrcweir sal_uInt16 *pLine, 661*cdf0e10cSrcweir sal_uInt16 *pPos 662*cdf0e10cSrcweir ) const 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir // ung"ultig? 665*cdf0e10cSrcweir if ( !aExtraString.Len() ) 666*cdf0e10cSrcweir return sal_False; 667*cdf0e10cSrcweir String aStr; 668*cdf0e10cSrcweir sal_uInt16 nPos = aExtraString.SearchAscii("AL:"); 669*cdf0e10cSrcweir if ( nPos == STRING_NOTFOUND ) 670*cdf0e10cSrcweir return sal_False; 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn 673*cdf0e10cSrcweir // er nicht vorhanden ist, liegt eine "altere Version vor 674*cdf0e10cSrcweir if ( nPos != STRING_NOTFOUND ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir sal_uInt16 n1 = aExtraString.Search('(', nPos); 677*cdf0e10cSrcweir if ( n1 != STRING_NOTFOUND ) 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir sal_uInt16 n2 = aExtraString.Search(')', n1); 680*cdf0e10cSrcweir if ( n2 != STRING_NOTFOUND ) 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir // Alignment-String herausschneiden 683*cdf0e10cSrcweir aStr = aExtraString.Copy(nPos, n2 - nPos + 1); 684*cdf0e10cSrcweir aStr.Erase(nPos, n1-nPos+1); 685*cdf0e10cSrcweir } 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir // Zuerst das Alignment extrahieren 690*cdf0e10cSrcweir if ( !aStr.Len() ) 691*cdf0e10cSrcweir return sal_False; 692*cdf0e10cSrcweir if ( pAlign ) 693*cdf0e10cSrcweir *pAlign = (SfxChildAlignment) (sal_uInt16) aStr.ToInt32(); 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir // Dann das LastAlignment 696*cdf0e10cSrcweir nPos = aStr.Search(','); 697*cdf0e10cSrcweir if ( nPos == STRING_NOTFOUND ) 698*cdf0e10cSrcweir return sal_False; 699*cdf0e10cSrcweir aStr.Erase(0, nPos+1); 700*cdf0e10cSrcweir if ( pLastAlign ) 701*cdf0e10cSrcweir *pLastAlign = (SfxChildAlignment) (sal_uInt16) aStr.ToInt32(); 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir // Dann die Splitting-Informationen 704*cdf0e10cSrcweir nPos = aStr.Search(','); 705*cdf0e10cSrcweir if ( nPos == STRING_NOTFOUND ) 706*cdf0e10cSrcweir // Dockt nicht in einem Splitwindow 707*cdf0e10cSrcweir return sal_True; 708*cdf0e10cSrcweir aStr.Erase(0, nPos+1); 709*cdf0e10cSrcweir Point aChildPos; 710*cdf0e10cSrcweir Size aChildSize; 711*cdf0e10cSrcweir if ( GetPosSizeFromString( aStr, aChildPos, aChildSize ) ) 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir if ( pSize ) 714*cdf0e10cSrcweir *pSize = aChildSize; 715*cdf0e10cSrcweir if ( pLine ) 716*cdf0e10cSrcweir *pLine = (sal_uInt16) aChildPos.X(); 717*cdf0e10cSrcweir if ( pPos ) 718*cdf0e10cSrcweir *pPos = (sal_uInt16) aChildPos.Y(); 719*cdf0e10cSrcweir return sal_True; 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir return sal_False; 722*cdf0e10cSrcweir } 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir sal_Bool SfxChildWindow::IsVisible() const 725*cdf0e10cSrcweir { 726*cdf0e10cSrcweir return pImp->bVisible; 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir void SfxChildWindow::SetVisible_Impl( sal_Bool bVis ) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir pImp->bVisible = bVis; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir void SfxChildWindow::Hide() 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir switch ( pWindow->GetType() ) 737*cdf0e10cSrcweir { 738*cdf0e10cSrcweir case RSC_DOCKINGWINDOW : 739*cdf0e10cSrcweir ((DockingWindow*)pWindow)->Hide(); 740*cdf0e10cSrcweir break; 741*cdf0e10cSrcweir case RSC_TOOLBOX : 742*cdf0e10cSrcweir ((ToolBox*)pWindow)->Hide(); 743*cdf0e10cSrcweir break; 744*cdf0e10cSrcweir default: 745*cdf0e10cSrcweir pWindow->Hide(); 746*cdf0e10cSrcweir break; 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir } 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir void SfxChildWindow::Show( sal_uInt16 nFlags ) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir switch ( pWindow->GetType() ) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir case RSC_DOCKINGWINDOW : 757*cdf0e10cSrcweir ((DockingWindow*)pWindow)->Show( sal_True, nFlags ); 758*cdf0e10cSrcweir break; 759*cdf0e10cSrcweir case RSC_TOOLBOX : 760*cdf0e10cSrcweir ((ToolBox*)pWindow)->Show( sal_True, nFlags ); 761*cdf0e10cSrcweir break; 762*cdf0e10cSrcweir default: 763*cdf0e10cSrcweir pWindow->Show( sal_True, nFlags ); 764*cdf0e10cSrcweir break; 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir } 767*cdf0e10cSrcweir 768*cdf0e10cSrcweir Window* SfxChildWindow::GetContextWindow( SfxModule *pModule ) const 769*cdf0e10cSrcweir { 770*cdf0e10cSrcweir return pModule == pImp->pContextModule && pContext ? pContext->GetWindow(): 0; 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir void SfxChildWindow::SetWorkWindow_Impl( SfxWorkWindow* pWin ) 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir pImp->pWorkWin = pWin; 776*cdf0e10cSrcweir if ( pWin && pWindow->HasChildPathFocus() ) 777*cdf0e10cSrcweir pImp->pWorkWin->SetActiveChild_Impl( pWindow ); 778*cdf0e10cSrcweir } 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir //SfxWorkWindow* SfxChildWindow::GetWorkWindow_Impl() const 781*cdf0e10cSrcweir //{ 782*cdf0e10cSrcweir // return pImp->pWorkWin; 783*cdf0e10cSrcweir //} 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir void SfxChildWindow::Activate_Impl() 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir if(pImp->pWorkWin!=NULL) //@#60568# 788*cdf0e10cSrcweir pImp->pWorkWin->SetActiveChild_Impl( pWindow ); 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir 791*cdf0e10cSrcweir void SfxChildWindow::Deactivate_Impl() 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir // pImp->pWorkWin->SetActiveChild_Impl( NULL ); 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir sal_Bool SfxChildWindow::QueryClose() 797*cdf0e10cSrcweir { 798*cdf0e10cSrcweir sal_Bool bAllow = sal_True; 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir if ( pImp->xFrame.is() ) 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xCtrl = pImp->xFrame->getController(); 803*cdf0e10cSrcweir if ( xCtrl.is() ) 804*cdf0e10cSrcweir bAllow = xCtrl->suspend( sal_True ); 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir if ( bAllow ) 808*cdf0e10cSrcweir bAllow = !GetWindow()->IsInModalMode(); 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir return bAllow; 811*cdf0e10cSrcweir } 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxChildWindow::GetFrame() 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir return pImp->xFrame; 816*cdf0e10cSrcweir } 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir void SfxChildWindow::SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame ) 819*cdf0e10cSrcweir { 820*cdf0e10cSrcweir // Do nothing if nothing will be changed ... 821*cdf0e10cSrcweir if( pImp->xFrame != rFrame ) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir // ... but stop listening on old frame, if connection exist! 824*cdf0e10cSrcweir if( pImp->xFrame.is() ) 825*cdf0e10cSrcweir pImp->xFrame->removeEventListener( pImp->xListener ); 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir // If new frame isnt NULL -> we must guarantee valid listener for disposing events. 828*cdf0e10cSrcweir // Use already existing or create new one. 829*cdf0e10cSrcweir if( rFrame.is() ) 830*cdf0e10cSrcweir if( !pImp->xListener.is() ) 831*cdf0e10cSrcweir pImp->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >( new DisposeListener( this, pImp ) ); 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir // Set new frame in data container 834*cdf0e10cSrcweir // and build new listener connection, if neccessary. 835*cdf0e10cSrcweir pImp->xFrame = rFrame; 836*cdf0e10cSrcweir if( pImp->xFrame.is() ) 837*cdf0e10cSrcweir pImp->xFrame->addEventListener( pImp->xListener ); 838*cdf0e10cSrcweir } 839*cdf0e10cSrcweir } 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir sal_Bool SfxChildWindow::CanGetFocus() const 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir return !(pImp->pFact->aInfo.nFlags & SFX_CHILDWIN_CANTGETFOCUS); 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir void SfxChildWindowContext::RegisterChildWindowContext(SfxModule* pMod, sal_uInt16 nId, SfxChildWinContextFactory* pFact) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir SFX_APP()->RegisterChildWindowContext_Impl( pMod, nId, pFact ); 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir void SfxChildWindow::RegisterChildWindow(SfxModule* pMod, SfxChildWinFactory* pFact) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir SFX_APP()->RegisterChildWindow_Impl( pMod, pFact ); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir 856