Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / appl / childwin.cxx
bloba6980023021172c5a9b48443244cd62f85f342af
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <vcl/toolbox.hxx>
31 #include <tools/rcid.h>
32 #include <unotools/viewoptions.hxx>
33 #include <com/sun/star/frame/XController.hpp>
34 #include <com/sun/star/frame/XFrame.hpp>
35 #include <com/sun/star/util/XCloseable.hpp>
36 #include <comphelper/string.hxx>
37 #include <cppuhelper/implbase1.hxx>
39 #include <sfx2/childwin.hxx>
40 #include <sfx2/app.hxx>
41 #include "arrdecl.hxx"
42 #include <sfx2/bindings.hxx>
43 #include <sfx2/module.hxx>
44 #include <sfx2/dockwin.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include "workwin.hxx"
48 static const sal_uInt16 nVersion = 2;
50 DBG_NAME(SfxChildWindow)
52 SV_IMPL_PTRARR( SfxChildWinContextArr_Impl, SfxChildWinContextFactory* );
54 struct SfxChildWindow_Impl
56 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
57 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xListener;
58 SfxChildWinFactory* pFact;
59 sal_Bool bHideNotDelete;
60 sal_Bool bVisible;
61 sal_Bool bHideAtToggle;
62 sal_Bool bWantsFocus;
63 SfxModule* pContextModule;
64 SfxWorkWindow* pWorkWin;
67 // -----------------------------------------------------------------------
69 class DisposeListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
71 public:
72 DisposeListener( SfxChildWindow* pOwner ,
73 SfxChildWindow_Impl* pData )
74 : m_pOwner( pOwner )
75 , m_pData ( pData )
78 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aSource ) throw (::com::sun::star::uno::RuntimeException)
80 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xSelfHold( this );
82 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( aSource.Source, ::com::sun::star::uno::UNO_QUERY );
83 if( xComp.is() )
84 xComp->removeEventListener( this );
86 if( m_pOwner && m_pData )
88 m_pData->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >();
90 if ( m_pData->pWorkWin )
92 // m_pOwner and m_pData will be killed
93 m_pData->xFrame = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >();
94 m_pData->pWorkWin->GetBindings().Execute( m_pOwner->GetType() );
96 else
98 delete m_pOwner;
101 m_pOwner = NULL;
102 m_pData = NULL;
106 private:
107 SfxChildWindow* m_pOwner;
108 SfxChildWindow_Impl* m_pData ;
111 // -----------------------------------------------------------------------
113 sal_Bool GetPosSizeFromString( const String& rStr, Point& rPos, Size& rSize )
115 if ( comphelper::string::getTokenCount(rStr, '/') != 4 )
116 return sal_False;
118 xub_StrLen nIdx = 0;
119 rPos.X() = rStr.GetToken(0, '/', nIdx).ToInt32();
120 rPos.Y() = rStr.GetToken(0, '/', nIdx).ToInt32();
121 rSize.Width() = rStr.GetToken(0, '/', nIdx).ToInt32();
122 rSize.Height() = rStr.GetToken(0, '/', nIdx).ToInt32();
124 // negative sizes are invalid
125 if ( rSize.Width() < 0 || rSize.Height() < 0 )
126 return sal_False;
128 return sal_True;
131 sal_Bool GetSplitSizeFromString( const String& rStr, Size& rSize )
133 xub_StrLen nIndex = rStr.Search( ',' );
134 if ( nIndex != STRING_NOTFOUND )
136 String aStr = rStr.Copy( nIndex+1 );
138 sal_Int32 nCount = comphelper::string::getTokenCount(aStr, ';');
139 if ( nCount != 2 )
140 return sal_False;
142 rSize.Width() = aStr.GetToken(0, ';' ).ToInt32();
143 rSize.Height() = aStr.GetToken(1, ';' ).ToInt32();
145 // negative sizes are invalid
146 if ( rSize.Width() < 0 || rSize.Height() < 0 )
147 return sal_False;
149 return sal_True;
152 return sal_False;
155 //=========================================================================
156 SfxChildWindow::SfxChildWindow(Window *pParentWindow, sal_uInt16 nId)
157 : pParent(pParentWindow)
158 , nType(nId)
159 , eChildAlignment(SFX_ALIGN_NOALIGNMENT)
160 , pWindow(0L)
162 pImp = new SfxChildWindow_Impl;
163 pImp->pFact = 0L;
164 pImp->bHideNotDelete = sal_False;
165 pImp->bHideAtToggle = sal_False;
166 pImp->bWantsFocus = sal_True;
167 pImp->bVisible = sal_True;
168 pImp->pContextModule = NULL;
169 pImp->pWorkWin = NULL;
171 pContext = 0L;
172 DBG_CTOR(SfxChildWindow,0);
175 void SfxChildWindow::Destroy()
177 if ( GetFrame().is() )
179 pImp->pWorkWin = NULL;
182 ::com::sun::star::uno::Reference < ::com::sun::star::util::XCloseable > xClose( GetFrame(), ::com::sun::star::uno::UNO_QUERY );
183 if ( xClose.is() )
184 xClose->close( sal_True );
185 else
186 GetFrame()->dispose();
188 catch (const com::sun::star::uno::Exception&)
192 else
193 delete this;
196 //-------------------------------------------------------------------------
197 SfxChildWindow::~SfxChildWindow()
199 DBG_DTOR(SfxChildWindow,0);
200 delete pContext;
201 delete pWindow;
202 delete pImp;
205 //-------------------------------------------------------------------------
206 SfxChildWindow* SfxChildWindow::CreateChildWindow( sal_uInt16 nId,
207 Window *pParent, SfxBindings* pBindings, SfxChildWinInfo& rInfo)
209 SfxChildWindow *pChild=0;
210 SfxChildWinFactory* pFact=0;
211 sal_uInt16 nOldMode = Application::GetSystemWindowMode();
213 // First search for ChildWindow in SDT; "Overloading has to be realized
214 // by using ChildWindowContext
215 SfxApplication *pApp = SFX_APP();
217 SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
218 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
220 pFact = rFactories[nFactory];
221 if ( pFact->nId == nId )
223 SfxChildWinInfo& rFactInfo = pFact->aInfo;
224 if ( rInfo.bVisible )
226 if ( pBindings )
227 pBindings->ENTERREGISTRATIONS();
228 SfxChildWinInfo aInfo = rFactInfo;
229 Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE );
230 pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo );
231 Application::SetSystemWindowMode( nOldMode );
232 if ( pBindings )
233 pBindings->LEAVEREGISTRATIONS();
236 break;
241 SfxDispatcher *pDisp = pBindings->GetDispatcher_Impl();
242 SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
243 if ( !pChild && pMod )
245 SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
246 if ( pFactories )
248 SfxChildWinFactArr_Impl &rFactories = *pFactories;
249 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
251 pFact = rFactories[nFactory];
252 if ( pFact->nId == nId )
254 SfxChildWinInfo& rFactInfo = pFact->aInfo;
255 if ( rInfo.bVisible )
257 if ( pBindings )
258 pBindings->ENTERREGISTRATIONS();
259 SfxChildWinInfo aInfo = rFactInfo;
260 Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE );
261 pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo );
262 Application::SetSystemWindowMode( nOldMode );
263 if ( pBindings )
264 pBindings->LEAVEREGISTRATIONS();
267 break;
273 if ( pChild )
274 pChild->SetFactory_Impl( pFact );
276 DBG_ASSERT(pFact && (pChild || !rInfo.bVisible), "ChildWindow-Typ not registered!");
278 if ( pChild && !pChild->pWindow )
280 DELETEZ(pChild);
281 DBG_WARNING("ChildWindow has no Window!");
284 return pChild;
287 //-------------------------------------------------------------------------
288 void SfxChildWindow::SaveStatus(const SfxChildWinInfo& rInfo)
290 sal_uInt16 nID = GetType();
292 String aWinData( 'V' );
293 aWinData += String::CreateFromInt32( nVersion );
294 aWinData += ',';
295 aWinData += rInfo.bVisible ? 'V' : 'H';
296 aWinData += ',';
297 aWinData += String::CreateFromInt32( rInfo.nFlags );
298 if ( rInfo.aExtraString.Len() )
300 aWinData += ',';
301 aWinData += rInfo.aExtraString;
304 SvtViewOptions aWinOpt( E_WINDOW, String::CreateFromInt32( nID ) );
305 aWinOpt.SetWindowState(rtl::OStringToOUString(rInfo.aWinState, RTL_TEXTENCODING_UTF8));
307 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
308 aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Data") );
309 aSeq[0].Value <<= ::rtl::OUString( aWinData );
310 aWinOpt.SetUserData( aSeq );
312 // ... but save status at runtime!
313 pImp->pFact->aInfo = rInfo;
316 //-------------------------------------------------------------------------
317 void SfxChildWindow::SetAlignment(SfxChildAlignment eAlign)
319 DBG_CHKTHIS(SfxChildWindow,0);
321 eChildAlignment = eAlign;
324 //-------------------------------------------------------------------------
325 SfxChildWinInfo SfxChildWindow::GetInfo() const
327 DBG_CHKTHIS(SfxChildWindow,0);
329 SfxChildWinInfo aInfo;
330 aInfo.aPos = pWindow->GetPosPixel();
331 aInfo.aSize = pWindow->GetSizePixel();
332 if ( pWindow->IsSystemWindow() )
334 sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
335 if ( pWindow->GetStyle() & WB_SIZEABLE )
336 nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
337 aInfo.aWinState = ((SystemWindow*)pWindow)->GetWindowState( nMask );
339 else if ( pWindow->GetType() == RSC_DOCKINGWINDOW )
341 if (((DockingWindow*)pWindow)->GetFloatingWindow() )
342 aInfo.aWinState = ((DockingWindow*)pWindow)->GetFloatingWindow()->GetWindowState();
343 else
345 SfxChildWinInfo aTmpInfo;
346 ((SfxDockingWindow*)pWindow)->FillInfo( aTmpInfo );
347 aInfo.aExtraString = aTmpInfo.aExtraString;
351 aInfo.bVisible = pImp->bVisible;
352 aInfo.nFlags = 0;
353 return aInfo;
356 //-------------------------------------------------------------------------
357 sal_uInt16 SfxChildWindow::GetPosition()
359 return pImp->pFact->nPos;
362 //-------------------------------------------------------------------------
363 void SfxChildWindow::InitializeChildWinFactory_Impl( sal_uInt16 nId, SfxChildWinInfo& rInfo )
365 // load configuration
366 SvtViewOptions aWinOpt( E_WINDOW, String::CreateFromInt32( nId ) );
368 if ( aWinOpt.Exists() )
369 rInfo.bVisible = aWinOpt.IsVisible(); // set state from configuration. Can be overwritten by UserData, see below
371 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
373 ::rtl::OUString aTmp;
374 if ( aSeq.getLength() )
375 aSeq[0].Value >>= aTmp;
377 String aWinData( aTmp );
378 rInfo.aWinState = rtl::OUStringToOString(aWinOpt.GetWindowState(), RTL_TEXTENCODING_UTF8);
381 if ( aWinData.Len() )
383 // Search for version ID
384 if ( aWinData.GetChar((sal_uInt16)0) != 0x0056 ) // 'V' = 56h
385 // A version ID, so do not use
386 return;
388 // Delete 'V'
389 aWinData.Erase(0,1);
391 // Read version
392 char cToken = ',';
393 sal_uInt16 nPos = aWinData.Search( cToken );
394 sal_uInt16 nActVersion = (sal_uInt16)aWinData.Copy( 0, nPos + 1 ).ToInt32();
395 if ( nActVersion != nVersion )
396 return;
398 aWinData.Erase(0,nPos+1);
400 // Load Visibility: is coded as a char
401 rInfo.bVisible = (aWinData.GetChar(0) == 0x0056); // 'V' = 56h
402 aWinData.Erase(0,1);
403 nPos = aWinData.Search( cToken );
404 if (nPos != STRING_NOTFOUND)
406 sal_uInt16 nNextPos = aWinData.Search( cToken, 2 );
407 if ( nNextPos != STRING_NOTFOUND )
409 // there is extra information
410 rInfo.nFlags = (sal_uInt16)aWinData.Copy( nPos+1, nNextPos - nPos - 1 ).ToInt32();
411 aWinData.Erase( nPos, nNextPos-nPos+1 );
412 rInfo.aExtraString = aWinData;
414 else
415 rInfo.nFlags = (sal_uInt16)aWinData.Copy( nPos+1 ).ToInt32();
420 void SfxChildWindow::CreateContext( sal_uInt16 nContextId, SfxBindings& rBindings )
422 SfxChildWindowContext *pCon = NULL;
423 SfxChildWinFactory* pFact=0;
424 SfxApplication *pApp = SFX_APP();
425 SfxDispatcher *pDisp = rBindings.GetDispatcher_Impl();
426 SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
427 if ( pMod )
429 SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
430 if ( pFactories )
432 SfxChildWinFactArr_Impl &rFactories = *pFactories;
433 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
435 pFact = rFactories[nFactory];
436 if ( pFact->nId == GetType() )
438 DBG_ASSERT( pFact->pArr, "No context registered!" );
439 if ( !pFact->pArr )
440 break;
442 SfxChildWinContextFactory *pConFact=0;
443 for ( sal_uInt16 n=0; n<pFact->pArr->Count(); ++n )
445 pConFact = (*pFact->pArr)[n];
446 rBindings.ENTERREGISTRATIONS();
447 if ( pConFact->nContextId == nContextId )
449 SfxChildWinInfo aInfo = pFact->aInfo;
450 pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo );
451 pCon->nContextId = pConFact->nContextId;
452 pImp->pContextModule = pMod;
454 rBindings.LEAVEREGISTRATIONS();
456 break;
462 if ( !pCon )
464 SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
465 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
467 pFact = rFactories[nFactory];
468 if ( pFact->nId == GetType() )
470 DBG_ASSERT( pFact->pArr, "No context registered!" );
471 if ( !pFact->pArr )
472 break;
474 SfxChildWinContextFactory *pConFact=0;
475 for ( sal_uInt16 n=0; n<pFact->pArr->Count(); ++n )
477 pConFact = (*pFact->pArr)[n];
478 rBindings.ENTERREGISTRATIONS();
479 if ( pConFact->nContextId == nContextId )
481 SfxChildWinInfo aInfo = pFact->aInfo;
482 pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo );
483 pCon->nContextId = pConFact->nContextId;
484 pImp->pContextModule = NULL;
486 rBindings.LEAVEREGISTRATIONS();
488 break;
493 if ( !pCon )
495 OSL_FAIL( "No suitable context found! ");
496 return;
499 if ( pContext )
500 delete( pContext );
501 pContext = pCon;
502 pContext->GetWindow()->SetSizePixel( pWindow->GetOutputSizePixel() );
503 pContext->GetWindow()->Show();
506 SfxChildWindowContext::SfxChildWindowContext( sal_uInt16 nId )
507 : pWindow( NULL )
508 , nContextId( nId )
512 SfxChildWindowContext::~SfxChildWindowContext()
514 delete pWindow;
517 FloatingWindow* SfxChildWindowContext::GetFloatingWindow() const
519 Window *pParent = pWindow->GetParent();
520 if ( pParent->GetType() == RSC_DOCKINGWINDOW || pParent->GetType() == RSC_TOOLBOX )
522 return ((DockingWindow*)pParent)->GetFloatingWindow();
524 else if ( pParent->GetType() == RSC_FLOATINGWINDOW )
526 return (FloatingWindow*) pParent;
528 else
530 OSL_FAIL("No FloatingWindow-Context!");
531 return NULL;
535 void SfxChildWindowContext::Resizing( Size& )
539 sal_Bool SfxChildWindowContext::Close()
541 return sal_True;
544 void SfxChildWindow::SetFactory_Impl( SfxChildWinFactory *pF )
546 pImp->pFact = pF;
549 void SfxChildWindow::SetHideNotDelete( sal_Bool bOn )
551 pImp->bHideNotDelete = bOn;
554 sal_Bool SfxChildWindow::IsHideNotDelete() const
556 return pImp->bHideNotDelete;
559 sal_Bool SfxChildWindow::IsHideAtToggle() const
561 return pImp->bHideAtToggle;
564 void SfxChildWindow::SetWantsFocus( sal_Bool bSet )
566 pImp->bWantsFocus = bSet;
569 sal_Bool SfxChildWindow::WantsFocus() const
571 return pImp->bWantsFocus;
574 sal_Bool SfxChildWinInfo::GetExtraData_Impl
576 SfxChildAlignment *pAlign,
577 SfxChildAlignment *pLastAlign,
578 Size *pSize,
579 sal_uInt16 *pLine,
580 sal_uInt16 *pPos
581 ) const
583 // invalid?
584 if ( !aExtraString.Len() )
585 return sal_False;
586 String aStr;
587 sal_uInt16 nPos = aExtraString.SearchAscii("AL:");
588 if ( nPos == STRING_NOTFOUND )
589 return sal_False;
591 // Try to read the alignment string "ALIGN :(...)", but if
592 // it is not present, then use an older version
593 if ( nPos != STRING_NOTFOUND )
595 sal_uInt16 n1 = aExtraString.Search('(', nPos);
596 if ( n1 != STRING_NOTFOUND )
598 sal_uInt16 n2 = aExtraString.Search(')', n1);
599 if ( n2 != STRING_NOTFOUND )
601 // Cut out Alignment string
602 aStr = aExtraString.Copy(nPos, n2 - nPos + 1);
603 aStr.Erase(nPos, n1-nPos+1);
608 // First extract the Alignment
609 if ( !aStr.Len() )
610 return sal_False;
611 if ( pAlign )
612 *pAlign = (SfxChildAlignment) (sal_uInt16) aStr.ToInt32();
614 // then the LastAlignment
615 nPos = aStr.Search(',');
616 if ( nPos == STRING_NOTFOUND )
617 return sal_False;
618 aStr.Erase(0, nPos+1);
619 if ( pLastAlign )
620 *pLastAlign = (SfxChildAlignment) (sal_uInt16) aStr.ToInt32();
622 // Then the splitting information
623 nPos = aStr.Search(',');
624 if ( nPos == STRING_NOTFOUND )
625 // No docking in a Splitwindow
626 return sal_True;
627 aStr.Erase(0, nPos+1);
628 Point aChildPos;
629 Size aChildSize;
630 if ( GetPosSizeFromString( aStr, aChildPos, aChildSize ) )
632 if ( pSize )
633 *pSize = aChildSize;
634 if ( pLine )
635 *pLine = (sal_uInt16) aChildPos.X();
636 if ( pPos )
637 *pPos = (sal_uInt16) aChildPos.Y();
638 return sal_True;
640 return sal_False;
643 sal_Bool SfxChildWindow::IsVisible() const
645 return pImp->bVisible;
648 void SfxChildWindow::SetVisible_Impl( sal_Bool bVis )
650 pImp->bVisible = bVis;
653 void SfxChildWindow::Hide()
655 switch ( pWindow->GetType() )
657 case RSC_DOCKINGWINDOW :
658 ((DockingWindow*)pWindow)->Hide();
659 break;
660 case RSC_TOOLBOX :
661 ((ToolBox*)pWindow)->Hide();
662 break;
663 default:
664 pWindow->Hide();
665 break;
669 void SfxChildWindow::Show( sal_uInt16 nFlags )
671 switch ( pWindow->GetType() )
673 case RSC_DOCKINGWINDOW :
674 ((DockingWindow*)pWindow)->Show( sal_True, nFlags );
675 break;
676 case RSC_TOOLBOX :
677 ((ToolBox*)pWindow)->Show( sal_True, nFlags );
678 break;
679 default:
680 pWindow->Show( sal_True, nFlags );
681 break;
685 Window* SfxChildWindow::GetContextWindow( SfxModule *pModule ) const
687 return pModule == pImp->pContextModule && pContext ? pContext->GetWindow(): 0;
690 void SfxChildWindow::SetWorkWindow_Impl( SfxWorkWindow* pWin )
692 pImp->pWorkWin = pWin;
693 if ( pWin && pWindow->HasChildPathFocus() )
694 pImp->pWorkWin->SetActiveChild_Impl( pWindow );
697 void SfxChildWindow::Activate_Impl()
699 if(pImp->pWorkWin!=NULL)
700 pImp->pWorkWin->SetActiveChild_Impl( pWindow );
703 void SfxChildWindow::Deactivate_Impl()
707 sal_Bool SfxChildWindow::QueryClose()
709 sal_Bool bAllow = sal_True;
711 if ( pImp->xFrame.is() )
713 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xCtrl = pImp->xFrame->getController();
714 if ( xCtrl.is() )
715 bAllow = xCtrl->suspend( sal_True );
718 if ( bAllow )
719 bAllow = !GetWindow()->IsInModalMode();
721 return bAllow;
724 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxChildWindow::GetFrame()
726 return pImp->xFrame;
729 void SfxChildWindow::SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame )
731 // Do nothing if nothing will be changed ...
732 if( pImp->xFrame != rFrame )
734 // ... but stop listening on old frame, if connection exist!
735 if( pImp->xFrame.is() )
736 pImp->xFrame->removeEventListener( pImp->xListener );
738 // If new frame isnt NULL -> we must guarantee valid listener for disposing events.
739 // Use already existing or create new one.
740 if( rFrame.is() )
741 if( !pImp->xListener.is() )
742 pImp->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >( new DisposeListener( this, pImp ) );
744 // Set new frame in data container
745 // and build new listener connection, if neccessary.
746 pImp->xFrame = rFrame;
747 if( pImp->xFrame.is() )
748 pImp->xFrame->addEventListener( pImp->xListener );
752 sal_Bool SfxChildWindow::CanGetFocus() const
754 return !(pImp->pFact->aInfo.nFlags & SFX_CHILDWIN_CANTGETFOCUS);
757 void SfxChildWindowContext::RegisterChildWindowContext(SfxModule* pMod, sal_uInt16 nId, SfxChildWinContextFactory* pFact)
759 SFX_APP()->RegisterChildWindowContext_Impl( pMod, nId, pFact );
762 void SfxChildWindow::RegisterChildWindow(SfxModule* pMod, SfxChildWinFactory* pFact)
764 SFX_APP()->RegisterChildWindow_Impl( pMod, pFact );
767 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */