Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / appl / childwin.cxx
blob35e53d6e8892783cd461d4df4c79f701bf10720e
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 <sfx2/bindings.hxx>
36 #include <sfx2/module.hxx>
37 #include <sfx2/dockwin.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include "workwin.hxx"
40 #include "childwinimpl.hxx"
42 static const sal_uInt16 nVersion = 2;
44 SfxChildWinFactory::SfxChildWinFactory( SfxChildWinCtor pTheCtor, sal_uInt16 nID,
45 sal_uInt16 n )
46 : pCtor(pTheCtor)
47 , nId( nID )
48 , nPos(n)
49 , pArr( NULL )
52 SfxChildWinFactory::~SfxChildWinFactory()
54 delete pArr;
57 struct SfxChildWindow_Impl
59 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
60 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xListener;
61 SfxChildWinFactory* pFact;
62 bool bHideNotDelete;
63 bool bVisible;
64 bool bHideAtToggle;
65 bool bWantsFocus;
66 SfxModule* pContextModule;
67 SfxWorkWindow* pWorkWin;
72 class DisposeListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
74 public:
75 DisposeListener( SfxChildWindow* pOwner ,
76 SfxChildWindow_Impl* pData )
77 : m_pOwner( pOwner )
78 , m_pData ( pData )
81 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aSource ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
83 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > xSelfHold( this );
85 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComp( aSource.Source, ::com::sun::star::uno::UNO_QUERY );
86 if( xComp.is() )
87 xComp->removeEventListener( this );
89 if( m_pOwner && m_pData )
91 m_pData->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >();
93 if ( m_pData->pWorkWin )
95 // m_pOwner and m_pData will be killed
96 m_pData->xFrame = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >();
97 m_pData->pWorkWin->GetBindings().Execute( m_pOwner->GetType() );
99 else
101 delete m_pOwner;
104 m_pOwner = NULL;
105 m_pData = NULL;
109 private:
110 SfxChildWindow* m_pOwner;
111 SfxChildWindow_Impl* m_pData ;
116 bool GetPosSizeFromString( const OUString& rStr, Point& rPos, Size& rSize )
118 if ( comphelper::string::getTokenCount(rStr, '/') != 4 )
119 return false;
121 sal_Int32 nIdx = 0;
122 rPos.X() = rStr.getToken(0, '/', nIdx).toInt32();
123 rPos.Y() = rStr.getToken(0, '/', nIdx).toInt32();
124 rSize.Width() = rStr.getToken(0, '/', nIdx).toInt32();
125 rSize.Height() = rStr.getToken(0, '/', nIdx).toInt32();
127 // negative sizes are invalid
128 if ( rSize.Width() < 0 || rSize.Height() < 0 )
129 return false;
131 return true;
134 bool GetSplitSizeFromString( const OUString& rStr, Size& rSize )
136 sal_Int32 nIndex = rStr.indexOf( ',' );
137 if ( nIndex != -1 )
139 OUString aStr = rStr.copy( nIndex+1 );
141 sal_Int32 nCount = comphelper::string::getTokenCount(aStr, ';');
142 if ( nCount != 2 )
143 return false;
145 rSize.Width() = aStr.getToken(0, ';' ).toInt32();
146 rSize.Height() = aStr.getToken(1, ';' ).toInt32();
148 // negative sizes are invalid
149 if ( rSize.Width() < 0 || rSize.Height() < 0 )
150 return false;
152 return true;
155 return false;
159 SfxChildWindow::SfxChildWindow(vcl::Window *pParentWindow, sal_uInt16 nId)
160 : pParent(pParentWindow)
161 , nType(nId)
162 , eChildAlignment(SfxChildAlignment::NOALIGNMENT)
164 pImp = new SfxChildWindow_Impl;
165 pImp->pFact = 0L;
166 pImp->bHideNotDelete = false;
167 pImp->bHideAtToggle = false;
168 pImp->bWantsFocus = true;
169 pImp->bVisible = true;
170 pImp->pContextModule = NULL;
171 pImp->pWorkWin = NULL;
173 pContext = 0L;
176 void SfxChildWindow::Destroy()
178 if ( GetFrame().is() )
180 ClearWorkwin();
183 ::com::sun::star::uno::Reference < ::com::sun::star::util::XCloseable > xClose( GetFrame(), ::com::sun::star::uno::UNO_QUERY );
184 if ( xClose.is() )
185 xClose->close( sal_True );
186 else
187 GetFrame()->dispose();
189 catch (const com::sun::star::uno::Exception&)
193 else
194 delete this;
197 void SfxChildWindow::ClearWorkwin()
199 if (pImp->pWorkWin)
201 if (pImp->pWorkWin->GetActiveChild_Impl() == pWindow)
202 pImp->pWorkWin->SetActiveChild_Impl(NULL);
203 pImp->pWorkWin = NULL;
207 SfxChildWindow::~SfxChildWindow()
209 delete pContext;
210 pContext = NULL;
211 ClearWorkwin();
212 pWindow.disposeAndClear();
213 delete pImp;
214 pImp = NULL;
218 SfxChildWindow* SfxChildWindow::CreateChildWindow( sal_uInt16 nId,
219 vcl::Window *pParent, SfxBindings* pBindings, SfxChildWinInfo& rInfo)
221 SfxChildWindow *pChild=0;
222 SfxChildWinFactory* pFact=0;
223 SystemWindowFlags nOldMode = Application::GetSystemWindowMode();
225 // First search for ChildWindow in SDT; Overlay windows are realized
226 // by using ChildWindowContext
227 SfxApplication *pApp = SfxGetpApp();
229 SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
230 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
232 pFact = &rFactories[nFactory];
233 if ( pFact->nId == nId )
235 SfxChildWinInfo& rFactInfo = pFact->aInfo;
236 if ( rInfo.bVisible )
238 if ( pBindings )
239 pBindings->ENTERREGISTRATIONS();
240 SfxChildWinInfo aInfo = rFactInfo;
241 Application::SetSystemWindowMode( SystemWindowFlags::NOAUTOMODE );
242 pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo );
243 Application::SetSystemWindowMode( nOldMode );
244 if ( pBindings )
245 pBindings->LEAVEREGISTRATIONS();
248 break;
253 SfxDispatcher *pDisp = pBindings ? pBindings->GetDispatcher_Impl() : NULL;
254 SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) : NULL;
255 if (!pChild && pMod)
257 SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
258 if ( pFactories )
260 SfxChildWinFactArr_Impl &rFactories = *pFactories;
261 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
263 pFact = &rFactories[nFactory];
264 if ( pFact->nId == nId )
266 SfxChildWinInfo& rFactInfo = pFact->aInfo;
267 if ( rInfo.bVisible )
269 if ( pBindings )
270 pBindings->ENTERREGISTRATIONS();
271 SfxChildWinInfo aInfo = rFactInfo;
272 Application::SetSystemWindowMode( SystemWindowFlags::NOAUTOMODE );
273 pChild = pFact->pCtor( pParent, nId, pBindings, &aInfo );
274 Application::SetSystemWindowMode( nOldMode );
275 if ( pBindings )
276 pBindings->LEAVEREGISTRATIONS();
279 break;
285 if ( pChild )
286 pChild->SetFactory_Impl( pFact );
288 DBG_ASSERT(pFact && (pChild || !rInfo.bVisible), "ChildWindow-Typ not registered!");
290 if ( pChild && !pChild->pWindow )
292 DELETEZ(pChild);
293 DBG_WARNING("ChildWindow has no Window!");
296 return pChild;
300 void SfxChildWindow::SaveStatus(const SfxChildWinInfo& rInfo)
302 sal_uInt16 nID = GetType();
304 OUStringBuffer aWinData;
305 aWinData.append('V').append(static_cast<sal_Int32>(nVersion)).
306 append(',').append(rInfo.bVisible ? 'V' : 'H').append(',').
307 append(static_cast<sal_Int32>(rInfo.nFlags));
308 if ( !rInfo.aExtraString.isEmpty() )
310 aWinData.append(',');
311 aWinData.append(rInfo.aExtraString);
314 OUString sName(OUString::number(nID));
315 //Try and save window state per-module, e.g. sidebar on in one application
316 //but off in another
317 if (!rInfo.aModule.isEmpty())
318 sName = rInfo.aModule + "/" + sName;
319 SvtViewOptions aWinOpt(E_WINDOW, sName);
320 aWinOpt.SetWindowState(OStringToOUString(rInfo.aWinState, RTL_TEXTENCODING_UTF8));
322 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
323 aSeq[0].Name = "Data";
324 aSeq[0].Value <<= aWinData.makeStringAndClear();
325 aWinOpt.SetUserData( aSeq );
327 // ... but save status at runtime!
328 pImp->pFact->aInfo = rInfo;
332 void SfxChildWindow::SetAlignment(SfxChildAlignment eAlign)
335 eChildAlignment = eAlign;
339 SfxChildWinInfo SfxChildWindow::GetInfo() const
342 SfxChildWinInfo aInfo(pImp->pFact->aInfo);
343 aInfo.aPos = pWindow->GetPosPixel();
344 aInfo.aSize = pWindow->GetSizePixel();
345 if ( pWindow->IsSystemWindow() )
347 sal_uIntPtr nMask = WINDOWSTATE_MASK_POS | WINDOWSTATE_MASK_STATE;
348 if ( pWindow->GetStyle() & WB_SIZEABLE )
349 nMask |= ( WINDOWSTATE_MASK_WIDTH | WINDOWSTATE_MASK_HEIGHT );
350 aInfo.aWinState = static_cast<SystemWindow*>(pWindow.get())->GetWindowState( nMask );
352 else if ( pWindow->GetType() == RSC_DOCKINGWINDOW )
354 if (static_cast<DockingWindow*>(pWindow.get())->GetFloatingWindow() )
355 aInfo.aWinState = static_cast<DockingWindow*>(pWindow.get())->GetFloatingWindow()->GetWindowState();
356 else
358 SfxChildWinInfo aTmpInfo;
359 static_cast<SfxDockingWindow*>(pWindow.get())->FillInfo( aTmpInfo );
360 aInfo.aExtraString = aTmpInfo.aExtraString;
364 aInfo.bVisible = pImp->bVisible;
365 aInfo.nFlags = SfxChildWindowFlags::NONE;
366 return aInfo;
370 sal_uInt16 SfxChildWindow::GetPosition()
372 return pImp->pFact->nPos;
376 void SfxChildWindow::InitializeChildWinFactory_Impl(sal_uInt16 nId, SfxChildWinInfo& rInfo)
378 // load configuration
380 boost::scoped_ptr<SvtViewOptions> xWinOpt;
381 // first see if a module specific id exists
382 if (rInfo.aModule.getLength())
383 xWinOpt.reset(new SvtViewOptions(E_WINDOW, rInfo.aModule + "/" + OUString::number(nId)));
385 // if not then try the generic id
386 if (!xWinOpt || !xWinOpt->Exists())
387 xWinOpt.reset(new SvtViewOptions(E_WINDOW, OUString::number(nId)));
389 if (xWinOpt->Exists() && xWinOpt->HasVisible() )
390 rInfo.bVisible = xWinOpt->IsVisible(); // set state from configuration. Can be overwritten by UserData, see below
392 ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = xWinOpt->GetUserData();
394 OUString aTmp;
395 if ( aSeq.getLength() )
396 aSeq[0].Value >>= aTmp;
398 OUString aWinData( aTmp );
399 rInfo.aWinState = OUStringToOString(xWinOpt->GetWindowState(), RTL_TEXTENCODING_UTF8);
401 if ( !aWinData.isEmpty() )
403 // Search for version ID
404 if ( aWinData[0] != 0x0056 ) // 'V' = 56h
405 // A version ID, so do not use
406 return;
408 // Delete 'V'
409 aWinData = aWinData.copy(1);
411 // Read version
412 char cToken = ',';
413 sal_Int32 nPos = aWinData.indexOf( cToken );
414 sal_uInt16 nActVersion = (sal_uInt16)aWinData.copy( 0, nPos + 1 ).toInt32();
415 if ( nActVersion != nVersion )
416 return;
418 aWinData = aWinData.copy(nPos+1);
420 // Load Visibility: is coded as a char
421 rInfo.bVisible = (aWinData[0] == 0x0056); // 'V' = 56h
422 aWinData = aWinData.copy(1);
423 nPos = aWinData.indexOf( cToken );
424 if (nPos != -1)
426 sal_Int32 nNextPos = aWinData.indexOf( cToken, 2 );
427 if ( nNextPos != -1 )
429 // there is extra information
430 rInfo.nFlags = static_cast<SfxChildWindowFlags>((sal_uInt16)aWinData.copy( nPos+1, nNextPos - nPos - 1 ).toInt32());
431 aWinData = aWinData.replaceAt( nPos, nNextPos-nPos+1, "" );
432 rInfo.aExtraString = aWinData;
434 else
435 rInfo.nFlags = static_cast<SfxChildWindowFlags>((sal_uInt16)aWinData.copy( nPos+1 ).toInt32());
440 void SfxChildWindow::CreateContext( sal_uInt16 nContextId, SfxBindings& rBindings )
442 SfxChildWindowContext *pCon = NULL;
443 SfxChildWinFactory* pFact=0;
444 SfxApplication *pApp = SfxGetpApp();
445 SfxDispatcher *pDisp = rBindings.GetDispatcher_Impl();
446 SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
447 if ( pMod )
449 SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
450 if ( pFactories )
452 SfxChildWinFactArr_Impl &rFactories = *pFactories;
453 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
455 pFact = &rFactories[nFactory];
456 if ( pFact->nId == GetType() )
458 DBG_ASSERT( pFact->pArr, "No context registered!" );
459 if ( !pFact->pArr )
460 break;
462 for ( sal_uInt16 n=0; n<pFact->pArr->size(); ++n )
464 SfxChildWinContextFactory *pConFact = &(*pFact->pArr)[n];
465 rBindings.ENTERREGISTRATIONS();
466 if ( pConFact->nContextId == nContextId )
468 SfxChildWinInfo aInfo = pFact->aInfo;
469 pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo );
470 pCon->nContextId = pConFact->nContextId;
471 pImp->pContextModule = pMod;
473 rBindings.LEAVEREGISTRATIONS();
475 break;
481 if ( !pCon )
483 SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
484 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
486 pFact = &rFactories[nFactory];
487 if ( pFact->nId == GetType() )
489 DBG_ASSERT( pFact->pArr, "No context registered!" );
490 if ( !pFact->pArr )
491 break;
493 for ( sal_uInt16 n=0; n<pFact->pArr->size(); ++n )
495 SfxChildWinContextFactory *pConFact = &(*pFact->pArr)[n];
496 rBindings.ENTERREGISTRATIONS();
497 if ( pConFact->nContextId == nContextId )
499 SfxChildWinInfo aInfo = pFact->aInfo;
500 pCon = pConFact->pCtor( GetWindow(), &rBindings, &aInfo );
501 pCon->nContextId = pConFact->nContextId;
502 pImp->pContextModule = NULL;
504 rBindings.LEAVEREGISTRATIONS();
506 break;
511 if ( !pCon )
513 OSL_FAIL( "No suitable context found! ");
514 return;
517 if ( pContext )
518 delete( pContext );
519 pContext = pCon;
520 pContext->GetWindow()->SetSizePixel( pWindow->GetOutputSizePixel() );
521 pContext->GetWindow()->Show();
524 SfxChildWindowContext::SfxChildWindowContext( sal_uInt16 nId )
525 : nContextId( nId )
529 SfxChildWindowContext::~SfxChildWindowContext()
531 pWindow.disposeAndClear();
534 FloatingWindow* SfxChildWindowContext::GetFloatingWindow() const
536 vcl::Window *pParent = pWindow->GetParent();
537 if (pParent->GetType() == WINDOW_DOCKINGWINDOW || pParent->GetType() == WINDOW_TOOLBOX)
539 return static_cast<DockingWindow*>(pParent)->GetFloatingWindow();
541 else if (pParent->GetType() == WINDOW_FLOATINGWINDOW)
543 return static_cast<FloatingWindow*>(pParent);
545 else
547 OSL_FAIL("No FloatingWindow-Context!");
548 return NULL;
552 void SfxChildWindowContext::Resizing( Size& )
556 void SfxChildWindow::SetFactory_Impl( SfxChildWinFactory *pF )
558 pImp->pFact = pF;
561 void SfxChildWindow::SetHideNotDelete( bool bOn )
563 pImp->bHideNotDelete = bOn;
566 bool SfxChildWindow::IsHideNotDelete() const
568 return pImp->bHideNotDelete;
571 bool SfxChildWindow::IsHideAtToggle() const
573 return pImp->bHideAtToggle;
576 void SfxChildWindow::SetWantsFocus( bool bSet )
578 pImp->bWantsFocus = bSet;
581 bool SfxChildWindow::WantsFocus() const
583 return pImp->bWantsFocus;
586 bool SfxChildWinInfo::GetExtraData_Impl
588 SfxChildAlignment *pAlign,
589 SfxChildAlignment *pLastAlign,
590 Size *pSize,
591 sal_uInt16 *pLine,
592 sal_uInt16 *pPos
593 ) const
595 // invalid?
596 if ( aExtraString.isEmpty() )
597 return false;
598 OUString aStr;
599 sal_Int32 nPos = aExtraString.indexOf("AL:");
600 if ( nPos == -1 )
601 return false;
603 // Try to read the alignment string "ALIGN :(...)", but if
604 // it is not present, then use an older version
605 sal_Int32 n1 = aExtraString.indexOf('(', nPos);
606 if ( n1 != -1 )
608 sal_Int32 n2 = aExtraString.indexOf(')', n1);
609 if ( n2 != -1 )
611 // Cut out Alignment string
612 aStr = aExtraString.copy(nPos, n2 - nPos + 1);
613 aStr = aStr.replaceAt(nPos, n1-nPos+1, "");
617 // First extract the Alignment
618 if ( aStr.isEmpty() )
619 return false;
620 if ( pAlign )
621 *pAlign = (SfxChildAlignment) (sal_uInt16) aStr.toInt32();
623 // then the LastAlignment
624 nPos = aStr.indexOf(',');
625 if ( nPos == -1 )
626 return false;
627 aStr = aStr.copy(nPos+1);
628 if ( pLastAlign )
629 *pLastAlign = (SfxChildAlignment) (sal_uInt16) aStr.toInt32();
631 // Then the splitting information
632 nPos = aStr.indexOf(',');
633 if ( nPos == -1 )
634 // No docking in a Splitwindow
635 return true;
636 aStr = aStr.copy(nPos+1);
637 Point aChildPos;
638 Size aChildSize;
639 if ( GetPosSizeFromString( aStr, aChildPos, aChildSize ) )
641 if ( pSize )
642 *pSize = aChildSize;
643 if ( pLine )
644 *pLine = (sal_uInt16) aChildPos.X();
645 if ( pPos )
646 *pPos = (sal_uInt16) aChildPos.Y();
647 return true;
649 return false;
652 bool SfxChildWindow::IsVisible() const
654 return pImp->bVisible;
657 void SfxChildWindow::SetVisible_Impl( bool bVis )
659 pImp->bVisible = bVis;
662 void SfxChildWindow::Hide()
664 switch ( pWindow->GetType() )
666 case RSC_DOCKINGWINDOW :
667 static_cast<DockingWindow*>(pWindow.get())->Hide();
668 break;
669 case RSC_TOOLBOX :
670 static_cast<ToolBox*>(pWindow.get())->Hide();
671 break;
672 default:
673 pWindow->Hide();
674 break;
678 void SfxChildWindow::Show( sal_uInt16 nFlags )
680 switch ( pWindow->GetType() )
682 case RSC_DOCKINGWINDOW :
683 static_cast<DockingWindow*>(pWindow.get())->Show( true, nFlags );
684 break;
685 case RSC_TOOLBOX :
686 static_cast<ToolBox*>(pWindow.get())->Show( true, nFlags );
687 break;
688 default:
689 pWindow->Show( true, nFlags );
690 break;
694 vcl::Window* SfxChildWindow::GetContextWindow( SfxModule *pModule ) const
696 return pModule == pImp->pContextModule && pContext ? pContext->GetWindow(): 0;
699 void SfxChildWindow::SetWorkWindow_Impl( SfxWorkWindow* pWin )
701 pImp->pWorkWin = pWin;
702 if ( pWin && pWindow->HasChildPathFocus() )
703 pImp->pWorkWin->SetActiveChild_Impl( pWindow );
706 void SfxChildWindow::Activate_Impl()
708 if(pImp->pWorkWin!=NULL)
709 pImp->pWorkWin->SetActiveChild_Impl( pWindow );
712 void SfxChildWindow::Deactivate_Impl()
716 bool SfxChildWindow::QueryClose()
718 bool bAllow = true;
720 if ( pImp->xFrame.is() )
722 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xCtrl = pImp->xFrame->getController();
723 if ( xCtrl.is() )
724 bAllow = xCtrl->suspend( sal_True );
727 if ( bAllow )
728 bAllow = !GetWindow()->IsInModalMode();
730 return bAllow;
733 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxChildWindow::GetFrame()
735 return pImp->xFrame;
738 void SfxChildWindow::SetFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & rFrame )
740 // Do nothing if nothing will be changed ...
741 if( pImp->xFrame != rFrame )
743 // ... but stop listening on old frame, if connection exist!
744 if( pImp->xFrame.is() )
745 pImp->xFrame->removeEventListener( pImp->xListener );
747 // If new frame is not NULL -> we must guarantee valid listener for disposing events.
748 // Use already existing or create new one.
749 if( rFrame.is() )
750 if( !pImp->xListener.is() )
751 pImp->xListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >( new DisposeListener( this, pImp ) );
753 // Set new frame in data container
754 // and build new listener connection, if necessary.
755 pImp->xFrame = rFrame;
756 if( pImp->xFrame.is() )
757 pImp->xFrame->addEventListener( pImp->xListener );
761 bool SfxChildWindow::CanGetFocus() const
763 return !(pImp->pFact->aInfo.nFlags & SfxChildWindowFlags::CANTGETFOCUS);
766 void SfxChildWindowContext::RegisterChildWindowContext(SfxModule* pMod, sal_uInt16 nId, SfxChildWinContextFactory* pFact)
768 SfxGetpApp()->RegisterChildWindowContext_Impl( pMod, nId, pFact );
771 void SfxChildWindow::RegisterChildWindow(SfxModule* pMod, SfxChildWinFactory* pFact)
773 SfxGetpApp()->RegisterChildWindow_Impl( pMod, pFact );
776 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */