bump product version to 4.2.0.1
[LibreOffice.git] / sfx2 / source / appl / childwin.cxx
blobe51bea83fb16f4e1ce5b91017bfad937158497fb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <boost/scoped_ptr.hpp>
21 #include <vcl/toolbox.hxx>
22 #include <tools/rcid.h>
23 #include <unotools/moduleoptions.hxx>
24 #include <unotools/viewoptions.hxx>
25 #include <com/sun/star/frame/ModuleManager.hpp>
26 #include <com/sun/star/frame/XController.hpp>
27 #include <com/sun/star/frame/XFrame.hpp>
28 #include <com/sun/star/util/XCloseable.hpp>
29 #include <comphelper/processfactory.hxx>
30 #include <comphelper/string.hxx>
31 #include <cppuhelper/implbase1.hxx>
33 #include <sfx2/childwin.hxx>
34 #include <sfx2/app.hxx>
35 #include "arrdecl.hxx"
36 #include <sfx2/bindings.hxx>
37 #include <sfx2/module.hxx>
38 #include <sfx2/dockwin.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include "workwin.hxx"
42 static const sal_uInt16 nVersion = 2;
44 DBG_NAME(SfxChildWindow)
46 struct SfxChildWindow_Impl
48 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
49 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xListener;
50 SfxChildWinFactory* pFact;
51 sal_Bool bHideNotDelete;
52 sal_Bool bVisible;
53 sal_Bool bHideAtToggle;
54 sal_Bool bWantsFocus;
55 SfxModule* pContextModule;
56 SfxWorkWindow* pWorkWin;
59 // -----------------------------------------------------------------------
61 class DisposeListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
63 public:
64 DisposeListener( SfxChildWindow* pOwner ,
65 SfxChildWindow_Impl* pData )
66 : m_pOwner( pOwner )
67 , m_pData ( pData )
70 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aSource ) throw (::com::sun::star::uno::RuntimeException)
72 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xSelfHold( this );
74 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( aSource.Source, ::com::sun::star::uno::UNO_QUERY );
75 if( xComp.is() )
76 xComp->removeEventListener( this );
78 if( m_pOwner && m_pData )
80 m_pData->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >();
82 if ( m_pData->pWorkWin )
84 // m_pOwner and m_pData will be killed
85 m_pData->xFrame = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >();
86 m_pData->pWorkWin->GetBindings().Execute( m_pOwner->GetType() );
88 else
90 delete m_pOwner;
93 m_pOwner = NULL;
94 m_pData = NULL;
98 private:
99 SfxChildWindow* m_pOwner;
100 SfxChildWindow_Impl* m_pData ;
103 // -----------------------------------------------------------------------
105 sal_Bool GetPosSizeFromString( const OUString& rStr, Point& rPos, Size& rSize )
107 if ( comphelper::string::getTokenCount(rStr, '/') != 4 )
108 return sal_False;
110 sal_Int32 nIdx = 0;
111 rPos.X() = rStr.getToken(0, '/', nIdx).toInt32();
112 rPos.Y() = rStr.getToken(0, '/', nIdx).toInt32();
113 rSize.Width() = rStr.getToken(0, '/', nIdx).toInt32();
114 rSize.Height() = rStr.getToken(0, '/', nIdx).toInt32();
116 // negative sizes are invalid
117 if ( rSize.Width() < 0 || rSize.Height() < 0 )
118 return sal_False;
120 return sal_True;
123 sal_Bool GetSplitSizeFromString( const OUString& rStr, Size& rSize )
125 sal_Int32 nIndex = rStr.indexOf( ',' );
126 if ( nIndex != -1 )
128 OUString aStr = rStr.copy( nIndex+1 );
130 sal_Int32 nCount = comphelper::string::getTokenCount(aStr, ';');
131 if ( nCount != 2 )
132 return sal_False;
134 rSize.Width() = aStr.getToken(0, ';' ).toInt32();
135 rSize.Height() = aStr.getToken(1, ';' ).toInt32();
137 // negative sizes are invalid
138 if ( rSize.Width() < 0 || rSize.Height() < 0 )
139 return sal_False;
141 return sal_True;
144 return sal_False;
147 //=========================================================================
148 SfxChildWindow::SfxChildWindow(Window *pParentWindow, sal_uInt16 nId)
149 : pParent(pParentWindow)
150 , nType(nId)
151 , eChildAlignment(SFX_ALIGN_NOALIGNMENT)
152 , pWindow(0L)
154 pImp = new SfxChildWindow_Impl;
155 pImp->pFact = 0L;
156 pImp->bHideNotDelete = sal_False;
157 pImp->bHideAtToggle = sal_False;
158 pImp->bWantsFocus = sal_True;
159 pImp->bVisible = sal_True;
160 pImp->pContextModule = NULL;
161 pImp->pWorkWin = NULL;
163 pContext = 0L;
164 DBG_CTOR(SfxChildWindow,0);
167 void SfxChildWindow::Destroy()
169 if ( GetFrame().is() )
171 pImp->pWorkWin = NULL;
174 ::com::sun::star::uno::Reference < ::com::sun::star::util::XCloseable > xClose( GetFrame(), ::com::sun::star::uno::UNO_QUERY );
175 if ( xClose.is() )
176 xClose->close( sal_True );
177 else
178 GetFrame()->dispose();
180 catch (const com::sun::star::uno::Exception&)
184 else
185 delete this;
188 //-------------------------------------------------------------------------
189 SfxChildWindow::~SfxChildWindow()
191 DBG_DTOR(SfxChildWindow,0);
192 delete pContext;
193 delete pWindow;
194 delete pImp;
197 //-------------------------------------------------------------------------
198 SfxChildWindow* SfxChildWindow::CreateChildWindow( sal_uInt16 nId,
199 Window *pParent, SfxBindings* pBindings, SfxChildWinInfo& rInfo)
201 SfxChildWindow *pChild=0;
202 SfxChildWinFactory* pFact=0;
203 sal_uInt16 nOldMode = Application::GetSystemWindowMode();
205 // First search for ChildWindow in SDT; "Overloading has to be realized
206 // by using ChildWindowContext
207 SfxApplication *pApp = SFX_APP();
209 SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
210 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
212 pFact = rFactories[nFactory];
213 if ( pFact->nId == nId )
215 SfxChildWinInfo& rFactInfo = pFact->aInfo;
216 if ( rInfo.bVisible )
218 if ( pBindings )
219 pBindings->ENTERREGISTRATIONS();
220 SfxChildWinInfo aInfo = rFactInfo;
221 Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE );
222 pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo );
223 Application::SetSystemWindowMode( nOldMode );
224 if ( pBindings )
225 pBindings->LEAVEREGISTRATIONS();
228 break;
233 SfxDispatcher *pDisp = pBindings->GetDispatcher_Impl();
234 SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
235 if ( !pChild && pMod )
237 SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
238 if ( pFactories )
240 SfxChildWinFactArr_Impl &rFactories = *pFactories;
241 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
243 pFact = rFactories[nFactory];
244 if ( pFact->nId == nId )
246 SfxChildWinInfo& rFactInfo = pFact->aInfo;
247 if ( rInfo.bVisible )
249 if ( pBindings )
250 pBindings->ENTERREGISTRATIONS();
251 SfxChildWinInfo aInfo = rFactInfo;
252 Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE );
253 pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo );
254 Application::SetSystemWindowMode( nOldMode );
255 if ( pBindings )
256 pBindings->LEAVEREGISTRATIONS();
259 break;
265 if ( pChild )
266 pChild->SetFactory_Impl( pFact );
268 DBG_ASSERT(pFact && (pChild || !rInfo.bVisible), "ChildWindow-Typ not registered!");
270 if ( pChild && !pChild->pWindow )
272 DELETEZ(pChild);
273 DBG_WARNING("ChildWindow has no Window!");
276 return pChild;
279 //-------------------------------------------------------------------------
280 void SfxChildWindow::SaveStatus(const SfxChildWinInfo& rInfo)
282 sal_uInt16 nID = GetType();
284 OUStringBuffer aWinData;
285 aWinData.append('V').append(static_cast<sal_Int32>(nVersion)).
286 append(',').append(rInfo.bVisible ? 'V' : 'H').append(',').
287 append(static_cast<sal_Int32>(rInfo.nFlags));
288 if ( !rInfo.aExtraString.isEmpty() )
290 aWinData.append(',');
291 aWinData.append(rInfo.aExtraString);
294 OUString sName(OUString::number(nID));
295 //Try and save window state per-module, e.g. sidebar on in one application
296 //but off in another
297 if (!rInfo.aModule.isEmpty())
298 sName = rInfo.aModule + "/" + sName;
299 SvtViewOptions aWinOpt(E_WINDOW, sName);
300 aWinOpt.SetWindowState(OStringToOUString(rInfo.aWinState, RTL_TEXTENCODING_UTF8));
302 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
303 aSeq[0].Name = "Data";
304 aSeq[0].Value <<= aWinData.makeStringAndClear();
305 aWinOpt.SetUserData( aSeq );
307 // ... but save status at runtime!
308 pImp->pFact->aInfo = rInfo;
311 //-------------------------------------------------------------------------
312 void SfxChildWindow::SetAlignment(SfxChildAlignment eAlign)
314 DBG_CHKTHIS(SfxChildWindow,0);
316 eChildAlignment = eAlign;
319 //-------------------------------------------------------------------------
320 SfxChildWinInfo SfxChildWindow::GetInfo() const
322 DBG_CHKTHIS(SfxChildWindow,0);
324 SfxChildWinInfo aInfo(pImp->pFact->aInfo);
325 aInfo.aPos = pWindow->GetPosPixel();
326 aInfo.aSize = pWindow->GetSizePixel();
327 if ( pWindow->IsSystemWindow() )
329 sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
330 if ( pWindow->GetStyle() & WB_SIZEABLE )
331 nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
332 aInfo.aWinState = ((SystemWindow*)pWindow)->GetWindowState( nMask );
334 else if ( pWindow->GetType() == RSC_DOCKINGWINDOW )
336 if (((DockingWindow*)pWindow)->GetFloatingWindow() )
337 aInfo.aWinState = ((DockingWindow*)pWindow)->GetFloatingWindow()->GetWindowState();
338 else
340 SfxChildWinInfo aTmpInfo;
341 ((SfxDockingWindow*)pWindow)->FillInfo( aTmpInfo );
342 aInfo.aExtraString = aTmpInfo.aExtraString;
346 aInfo.bVisible = pImp->bVisible;
347 aInfo.nFlags = 0;
348 return aInfo;
351 //-------------------------------------------------------------------------
352 sal_uInt16 SfxChildWindow::GetPosition()
354 return pImp->pFact->nPos;
357 //-------------------------------------------------------------------------
358 void SfxChildWindow::InitializeChildWinFactory_Impl(sal_uInt16 nId, SfxChildWinInfo& rInfo)
360 // load configuration
362 boost::scoped_ptr<SvtViewOptions> xWinOpt;
363 // first see if a module specific id exists
364 if (rInfo.aModule.getLength())
365 xWinOpt.reset(new SvtViewOptions(E_WINDOW, rInfo.aModule + "/" + OUString::number(nId)));
367 // if not then try the generic id
368 if (!xWinOpt || !xWinOpt->Exists())
369 xWinOpt.reset(new SvtViewOptions(E_WINDOW, OUString::number(nId)));
371 if (xWinOpt->Exists() && xWinOpt->HasVisible() )
372 rInfo.bVisible = xWinOpt->IsVisible(); // set state from configuration. Can be overwritten by UserData, see below
374 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = xWinOpt->GetUserData();
376 OUString aTmp;
377 if ( aSeq.getLength() )
378 aSeq[0].Value >>= aTmp;
380 OUString aWinData( aTmp );
381 rInfo.aWinState = OUStringToOString(xWinOpt->GetWindowState(), RTL_TEXTENCODING_UTF8);
384 if ( !aWinData.isEmpty() )
386 // Search for version ID
387 if ( aWinData[0] != 0x0056 ) // 'V' = 56h
388 // A version ID, so do not use
389 return;
391 // Delete 'V'
392 aWinData = aWinData.copy(1);
394 // Read version
395 char cToken = ',';
396 sal_Int32 nPos = aWinData.indexOf( cToken );
397 sal_uInt16 nActVersion = (sal_uInt16)aWinData.copy( 0, nPos + 1 ).toInt32();
398 if ( nActVersion != nVersion )
399 return;
401 aWinData = aWinData.copy(nPos+1);
403 // Load Visibility: is coded as a char
404 rInfo.bVisible = (aWinData[0] == 0x0056); // 'V' = 56h
405 aWinData = aWinData.copy(1);
406 nPos = aWinData.indexOf( cToken );
407 if (nPos != -1)
409 sal_Int32 nNextPos = aWinData.indexOf( cToken, 2 );
410 if ( nNextPos != -1 )
412 // there is extra information
413 rInfo.nFlags = (sal_uInt16)aWinData.copy( nPos+1, nNextPos - nPos - 1 ).toInt32();
414 aWinData = aWinData.replaceAt( nPos, nNextPos-nPos+1, "" );
415 rInfo.aExtraString = aWinData;
417 else
418 rInfo.nFlags = (sal_uInt16)aWinData.copy( nPos+1 ).toInt32();
423 void SfxChildWindow::CreateContext( sal_uInt16 nContextId, SfxBindings& rBindings )
425 SfxChildWindowContext *pCon = NULL;
426 SfxChildWinFactory* pFact=0;
427 SfxApplication *pApp = SFX_APP();
428 SfxDispatcher *pDisp = rBindings.GetDispatcher_Impl();
429 SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
430 if ( pMod )
432 SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
433 if ( pFactories )
435 SfxChildWinFactArr_Impl &rFactories = *pFactories;
436 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
438 pFact = rFactories[nFactory];
439 if ( pFact->nId == GetType() )
441 DBG_ASSERT( pFact->pArr, "No context registered!" );
442 if ( !pFact->pArr )
443 break;
445 for ( sal_uInt16 n=0; n<pFact->pArr->size(); ++n )
447 SfxChildWinContextFactory *pConFact = &(*pFact->pArr)[n];
448 rBindings.ENTERREGISTRATIONS();
449 if ( pConFact->nContextId == nContextId )
451 SfxChildWinInfo aInfo = pFact->aInfo;
452 pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo );
453 pCon->nContextId = pConFact->nContextId;
454 pImp->pContextModule = pMod;
456 rBindings.LEAVEREGISTRATIONS();
458 break;
464 if ( !pCon )
466 SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
467 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
469 pFact = rFactories[nFactory];
470 if ( pFact->nId == GetType() )
472 DBG_ASSERT( pFact->pArr, "No context registered!" );
473 if ( !pFact->pArr )
474 break;
476 for ( sal_uInt16 n=0; n<pFact->pArr->size(); ++n )
478 SfxChildWinContextFactory *pConFact = &(*pFact->pArr)[n];
479 rBindings.ENTERREGISTRATIONS();
480 if ( pConFact->nContextId == nContextId )
482 SfxChildWinInfo aInfo = pFact->aInfo;
483 pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo );
484 pCon->nContextId = pConFact->nContextId;
485 pImp->pContextModule = NULL;
487 rBindings.LEAVEREGISTRATIONS();
489 break;
494 if ( !pCon )
496 OSL_FAIL( "No suitable context found! ");
497 return;
500 if ( pContext )
501 delete( pContext );
502 pContext = pCon;
503 pContext->GetWindow()->SetSizePixel( pWindow->GetOutputSizePixel() );
504 pContext->GetWindow()->Show();
507 SfxChildWindowContext::SfxChildWindowContext( sal_uInt16 nId )
508 : pWindow( NULL )
509 , nContextId( nId )
513 SfxChildWindowContext::~SfxChildWindowContext()
515 delete pWindow;
518 FloatingWindow* SfxChildWindowContext::GetFloatingWindow() const
520 Window *pParent = pWindow->GetParent();
521 if ( pParent->GetType() == RSC_DOCKINGWINDOW || pParent->GetType() == RSC_TOOLBOX )
523 return ((DockingWindow*)pParent)->GetFloatingWindow();
525 else if ( pParent->GetType() == RSC_FLOATINGWINDOW )
527 return (FloatingWindow*) pParent;
529 else
531 OSL_FAIL("No FloatingWindow-Context!");
532 return NULL;
536 void SfxChildWindowContext::Resizing( Size& )
540 sal_Bool SfxChildWindowContext::Close()
542 return sal_True;
545 void SfxChildWindow::SetFactory_Impl( SfxChildWinFactory *pF )
547 pImp->pFact = pF;
550 void SfxChildWindow::SetHideNotDelete( sal_Bool bOn )
552 pImp->bHideNotDelete = bOn;
555 sal_Bool SfxChildWindow::IsHideNotDelete() const
557 return pImp->bHideNotDelete;
560 sal_Bool SfxChildWindow::IsHideAtToggle() const
562 return pImp->bHideAtToggle;
565 void SfxChildWindow::SetWantsFocus( sal_Bool bSet )
567 pImp->bWantsFocus = bSet;
570 sal_Bool SfxChildWindow::WantsFocus() const
572 return pImp->bWantsFocus;
575 sal_Bool SfxChildWinInfo::GetExtraData_Impl
577 SfxChildAlignment *pAlign,
578 SfxChildAlignment *pLastAlign,
579 Size *pSize,
580 sal_uInt16 *pLine,
581 sal_uInt16 *pPos
582 ) const
584 // invalid?
585 if ( aExtraString.isEmpty() )
586 return sal_False;
587 OUString aStr;
588 sal_Int32 nPos = aExtraString.indexOf("AL:");
589 if ( nPos == -1 )
590 return sal_False;
592 // Try to read the alignment string "ALIGN :(...)", but if
593 // it is not present, then use an older version
594 sal_Int32 n1 = aExtraString.indexOf('(', nPos);
595 if ( n1 != -1 )
597 sal_Int32 n2 = aExtraString.indexOf(')', n1);
598 if ( n2 != -1 )
600 // Cut out Alignment string
601 aStr = aExtraString.copy(nPos, n2 - nPos + 1);
602 aStr = aStr.replaceAt(nPos, n1-nPos+1, "");
606 // First extract the Alignment
607 if ( aStr.isEmpty() )
608 return sal_False;
609 if ( pAlign )
610 *pAlign = (SfxChildAlignment) (sal_uInt16) aStr.toInt32();
612 // then the LastAlignment
613 nPos = aStr.indexOf(',');
614 if ( nPos == -1 )
615 return sal_False;
616 aStr = aStr.copy(nPos+1);
617 if ( pLastAlign )
618 *pLastAlign = (SfxChildAlignment) (sal_uInt16) aStr.toInt32();
620 // Then the splitting information
621 nPos = aStr.indexOf(',');
622 if ( nPos == -1 )
623 // No docking in a Splitwindow
624 return sal_True;
625 aStr = aStr.copy(nPos+1);
626 Point aChildPos;
627 Size aChildSize;
628 if ( GetPosSizeFromString( aStr, aChildPos, aChildSize ) )
630 if ( pSize )
631 *pSize = aChildSize;
632 if ( pLine )
633 *pLine = (sal_uInt16) aChildPos.X();
634 if ( pPos )
635 *pPos = (sal_uInt16) aChildPos.Y();
636 return sal_True;
638 return sal_False;
641 sal_Bool SfxChildWindow::IsVisible() const
643 return pImp->bVisible;
646 void SfxChildWindow::SetVisible_Impl( sal_Bool bVis )
648 pImp->bVisible = bVis;
651 void SfxChildWindow::Hide()
653 switch ( pWindow->GetType() )
655 case RSC_DOCKINGWINDOW :
656 ((DockingWindow*)pWindow)->Hide();
657 break;
658 case RSC_TOOLBOX :
659 ((ToolBox*)pWindow)->Hide();
660 break;
661 default:
662 pWindow->Hide();
663 break;
667 void SfxChildWindow::Show( sal_uInt16 nFlags )
669 switch ( pWindow->GetType() )
671 case RSC_DOCKINGWINDOW :
672 ((DockingWindow*)pWindow)->Show( sal_True, nFlags );
673 break;
674 case RSC_TOOLBOX :
675 ((ToolBox*)pWindow)->Show( sal_True, nFlags );
676 break;
677 default:
678 pWindow->Show( sal_True, nFlags );
679 break;
683 Window* SfxChildWindow::GetContextWindow( SfxModule *pModule ) const
685 return pModule == pImp->pContextModule && pContext ? pContext->GetWindow(): 0;
688 void SfxChildWindow::SetWorkWindow_Impl( SfxWorkWindow* pWin )
690 pImp->pWorkWin = pWin;
691 if ( pWin && pWindow->HasChildPathFocus() )
692 pImp->pWorkWin->SetActiveChild_Impl( pWindow );
695 void SfxChildWindow::Activate_Impl()
697 if(pImp->pWorkWin!=NULL)
698 pImp->pWorkWin->SetActiveChild_Impl( pWindow );
701 void SfxChildWindow::Deactivate_Impl()
705 sal_Bool SfxChildWindow::QueryClose()
707 sal_Bool bAllow = sal_True;
709 if ( pImp->xFrame.is() )
711 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xCtrl = pImp->xFrame->getController();
712 if ( xCtrl.is() )
713 bAllow = xCtrl->suspend( sal_True );
716 if ( bAllow )
717 bAllow = !GetWindow()->IsInModalMode();
719 return bAllow;
722 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxChildWindow::GetFrame()
724 return pImp->xFrame;
727 void SfxChildWindow::SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame )
729 // Do nothing if nothing will be changed ...
730 if( pImp->xFrame != rFrame )
732 // ... but stop listening on old frame, if connection exist!
733 if( pImp->xFrame.is() )
734 pImp->xFrame->removeEventListener( pImp->xListener );
736 // If new frame isnt NULL -> we must guarantee valid listener for disposing events.
737 // Use already existing or create new one.
738 if( rFrame.is() )
739 if( !pImp->xListener.is() )
740 pImp->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >( new DisposeListener( this, pImp ) );
742 // Set new frame in data container
743 // and build new listener connection, if necessary.
744 pImp->xFrame = rFrame;
745 if( pImp->xFrame.is() )
746 pImp->xFrame->addEventListener( pImp->xListener );
750 sal_Bool SfxChildWindow::CanGetFocus() const
752 return !(pImp->pFact->aInfo.nFlags & SFX_CHILDWIN_CANTGETFOCUS);
755 void SfxChildWindowContext::RegisterChildWindowContext(SfxModule* pMod, sal_uInt16 nId, SfxChildWinContextFactory* pFact)
757 SFX_APP()->RegisterChildWindowContext_Impl( pMod, nId, pFact );
760 void SfxChildWindow::RegisterChildWindow(SfxModule* pMod, SfxChildWinFactory* pFact)
762 SFX_APP()->RegisterChildWindow_Impl( pMod, pFact );
765 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */