1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: childwin.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 #ifndef _TOOLBOX_HXX //autogen
35 #include <vcl/toolbox.hxx>
38 #include <tools/rcid.h>
40 #include <svtools/viewoptions.hxx>
41 #include <com/sun/star/frame/XController.hpp>
42 #include <com/sun/star/frame/XFrame.hpp>
43 #include <com/sun/star/util/XCloseable.hpp>
44 #include <cppuhelper/implbase1.hxx>
49 #include <sfx2/childwin.hxx>
50 #include <sfx2/app.hxx>
51 #include "arrdecl.hxx"
52 #include <sfx2/bindings.hxx>
53 #include <sfx2/module.hxx>
54 #include <sfx2/dockwin.hxx>
55 #include <sfx2/dispatch.hxx>
56 #include "workwin.hxx"
58 static const sal_uInt16 nVersion
= 2;
60 DBG_NAME(SfxChildWindow
)
62 SV_IMPL_PTRARR( SfxChildWinContextArr_Impl
, SfxChildWinContextFactory
* );
64 struct SfxChildWindow_Impl
66 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> xFrame
;
67 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> xListener
;
68 SfxChildWinFactory
* pFact
;
69 sal_Bool bHideNotDelete
;
71 sal_Bool bHideAtToggle
;
73 SfxModule
* pContextModule
;
74 SfxWorkWindow
* pWorkWin
;
77 // -----------------------------------------------------------------------
79 class DisposeListener
: public ::cppu::WeakImplHelper1
< ::com::sun::star::lang::XEventListener
>
82 DisposeListener( SfxChildWindow
* pOwner
,
83 SfxChildWindow_Impl
* pData
)
88 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aSource
) throw (::com::sun::star::uno::RuntimeException
)
90 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
> xSelfHold( this );
92 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> xComp( aSource
.Source
, ::com::sun::star::uno::UNO_QUERY
);
94 xComp
->removeEventListener( this );
96 if( m_pOwner
&& m_pData
)
98 m_pData
->xListener
= ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>();
100 if ( m_pData
->pWorkWin
)
102 // m_pOwner and m_pData will be killed
103 m_pData
->xFrame
= ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>();
104 m_pData
->pWorkWin
->GetBindings().Execute( m_pOwner
->GetType() );
117 SfxChildWindow
* m_pOwner
;
118 SfxChildWindow_Impl
* m_pData
;
121 // -----------------------------------------------------------------------
123 sal_Bool
GetPosSizeFromString( const String
& rStr
, Point
& rPos
, Size
& rSize
)
125 if ( rStr
.GetTokenCount('/') != 4 )
129 rPos
.X() = rStr
.GetToken(0, '/', nIdx
).ToInt32();
130 rPos
.Y() = rStr
.GetToken(0, '/', nIdx
).ToInt32();
131 rSize
.Width() = rStr
.GetToken(0, '/', nIdx
).ToInt32();
132 rSize
.Height() = rStr
.GetToken(0, '/', nIdx
).ToInt32();
134 // negative sizes are invalid
135 if ( rSize
.Width() < 0 || rSize
.Height() < 0 )
141 sal_Bool
GetSplitSizeFromString( const String
& rStr
, Size
& rSize
)
143 xub_StrLen nIndex
= rStr
.Search( ',' );
144 if ( nIndex
!= STRING_NOTFOUND
)
146 String aStr
= rStr
.Copy( nIndex
+1 );
148 sal_Int32 nCount
= aStr
.GetTokenCount(';');
152 rSize
.Width() = aStr
.GetToken(0, ';' ).ToInt32();
153 rSize
.Height() = aStr
.GetToken(1, ';' ).ToInt32();
155 // negative sizes are invalid
156 if ( rSize
.Width() < 0 || rSize
.Height() < 0 )
165 //=========================================================================
166 SfxChildWindow::SfxChildWindow(Window
*pParentWindow
, sal_uInt16 nId
)
167 : pParent(pParentWindow
)
169 , eChildAlignment(SFX_ALIGN_NOALIGNMENT
)
172 pImp
= new SfxChildWindow_Impl
;
174 pImp
->bHideNotDelete
= sal_False
;
175 pImp
->bHideAtToggle
= sal_False
;
176 pImp
->bWantsFocus
= sal_True
;
177 pImp
->bVisible
= sal_True
;
178 pImp
->pContextModule
= NULL
;
179 pImp
->pWorkWin
= NULL
;
182 DBG_CTOR(SfxChildWindow
,0);
185 void SfxChildWindow::Destroy()
187 if ( GetFrame().is() )
189 pImp
->pWorkWin
= NULL
;
192 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XCloseable
> xClose( GetFrame(), ::com::sun::star::uno::UNO_QUERY
);
194 xClose
->close( sal_True
);
196 GetFrame()->dispose();
198 catch ( com::sun::star::uno::Exception
& )
206 //-------------------------------------------------------------------------
207 SfxChildWindow::~SfxChildWindow()
209 DBG_DTOR(SfxChildWindow
,0);
217 //-------------------------------------------------------------------------
218 SfxChildWindow
* SfxChildWindow::CreateChildWindow( sal_uInt16 nId
,
219 Window
*pParent
, SfxBindings
* pBindings
, SfxChildWinInfo
& rInfo
)
221 SfxChildWindow
*pChild
=0;
222 SfxChildWinFactory
* pFact
=0;
223 sal_uInt16 nOldMode
= Application::GetSystemWindowMode();
225 // Zuerst ChildWindow im SDT suchen; "Uberlagerungen m"ussen mit einem
226 // ChildWindowContext realisiert werden
227 SfxApplication
*pApp
= SFX_APP();
229 SfxChildWinFactArr_Impl
&rFactories
= pApp
->GetChildWinFactories_Impl();
230 for ( sal_uInt16 nFactory
= 0; nFactory
< rFactories
.Count(); ++nFactory
)
232 pFact
= rFactories
[nFactory
];
233 if ( pFact
->nId
== nId
)
235 SfxChildWinInfo
& rFactInfo
= pFact
->aInfo
;
236 if ( rInfo
.bVisible
)
239 pBindings
->ENTERREGISTRATIONS();
240 SfxChildWinInfo aInfo
= rFactInfo
;
241 Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE
);
242 pChild
= pFact
->pCtor( pParent
, nId
, pBindings
, &aInfo
);
243 Application::SetSystemWindowMode( nOldMode
);
245 pBindings
->LEAVEREGISTRATIONS();
253 SfxDispatcher
*pDisp
= pBindings
->GetDispatcher_Impl();
254 SfxModule
*pMod
= pDisp
? SfxModule::GetActiveModule( pDisp
->GetFrame() ) :0;
255 if ( !pChild
&& pMod
)
257 SfxChildWinFactArr_Impl
*pFactories
= pMod
->GetChildWinFactories_Impl();
260 SfxChildWinFactArr_Impl
&rFactories
= *pFactories
;
261 for ( sal_uInt16 nFactory
= 0; nFactory
< rFactories
.Count(); ++nFactory
)
263 pFact
= rFactories
[nFactory
];
264 if ( pFact
->nId
== nId
)
266 SfxChildWinInfo
& rFactInfo
= pFact
->aInfo
;
267 if ( rInfo
.bVisible
)
270 pBindings
->ENTERREGISTRATIONS();
271 SfxChildWinInfo aInfo
= rFactInfo
;
272 Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_NOAUTOMODE
);
273 pChild
= pFact
->pCtor( pParent
, nId
, pBindings
, &aInfo
);
274 Application::SetSystemWindowMode( nOldMode
);
276 pBindings
->LEAVEREGISTRATIONS();
286 pChild
->SetFactory_Impl( pFact
);
288 DBG_ASSERT(pFact
&& (pChild
|| !rInfo
.bVisible
), "ChildWindow-Typ nicht registriert!");
290 if ( pChild
&& !pChild
->pWindow
)
293 DBG_WARNING("ChildWindow hat kein Fenster!");
299 //-------------------------------------------------------------------------
300 void SfxChildWindow::SaveStatus(const SfxChildWinInfo
& rInfo
)
302 sal_uInt16 nID
= GetType();
304 String
aWinData( 'V' );
305 aWinData
+= String::CreateFromInt32( nVersion
);
307 aWinData
+= rInfo
.bVisible
? 'V' : 'H';
309 aWinData
+= String::CreateFromInt32( rInfo
.nFlags
);
310 if ( rInfo
.aExtraString
.Len() )
313 aWinData
+= rInfo
.aExtraString
;
316 SvtViewOptions
aWinOpt( E_WINDOW
, String::CreateFromInt32( nID
) );
317 // aWinOpt.SetPosition( rInfo.aPos.X(), rInfo.aPos.Y() );
318 // aWinOpt.SetSize( rInfo.aSize.Width(), rInfo.aSize.Height() );
319 aWinOpt
.SetWindowState( String( rInfo
.aWinState
, RTL_TEXTENCODING_UTF8
) );
321 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> aSeq(1);
322 aSeq
[0].Name
= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Data") );
323 aSeq
[0].Value
<<= ::rtl::OUString( aWinData
);
324 aWinOpt
.SetUserData( aSeq
);
326 // ... but save status at runtime!
327 pImp
->pFact
->aInfo
= rInfo
;
330 //-------------------------------------------------------------------------
331 void SfxChildWindow::SetAlignment(SfxChildAlignment eAlign
)
333 DBG_CHKTHIS(SfxChildWindow
,0);
335 eChildAlignment
= eAlign
;
338 //-------------------------------------------------------------------------
339 void SfxChildWindow::SetPosSizePixel(const Point
& rPoint
, Size
& rSize
)
341 DBG_CHKTHIS(SfxChildWindow
,0);
343 pWindow
->SetPosSizePixel(rPoint
, rSize
);
346 //-------------------------------------------------------------------------
347 SfxChildWinInfo
SfxChildWindow::GetInfo() const
349 DBG_CHKTHIS(SfxChildWindow
,0);
351 SfxChildWinInfo aInfo
;
352 aInfo
.aPos
= pWindow
->GetPosPixel();
353 aInfo
.aSize
= pWindow
->GetSizePixel();
354 if ( pWindow
->IsSystemWindow() )
356 ULONG nMask
= WINDOWSTATE_MASK_POS
| WINDOWSTATE_MASK_STATE
;
357 if ( pWindow
->GetStyle() & WB_SIZEABLE
)
358 nMask
|= ( WINDOWSTATE_MASK_WIDTH
| WINDOWSTATE_MASK_HEIGHT
);
359 aInfo
.aWinState
= ((SystemWindow
*)pWindow
)->GetWindowState( nMask
);
361 else if ( pWindow
->GetType() == RSC_DOCKINGWINDOW
)
363 if (((DockingWindow
*)pWindow
)->GetFloatingWindow() )
364 aInfo
.aWinState
= ((DockingWindow
*)pWindow
)->GetFloatingWindow()->GetWindowState();
367 SfxChildWinInfo aTmpInfo
;
368 ((SfxDockingWindow
*)pWindow
)->FillInfo( aTmpInfo
);
369 aInfo
.aExtraString
= aTmpInfo
.aExtraString
;
373 aInfo
.bVisible
= pImp
->bVisible
;
378 //-------------------------------------------------------------------------
379 sal_uInt16
SfxChildWindow::GetPosition()
381 return pImp
->pFact
->nPos
;
385 static void ImplWindowStateFromStr( Point rPos
, Size rSize
, const ByteString
& rStr
)
387 ULONG nValidMask
= 0;
388 xub_StrLen nIndex
= 0;
389 ByteString aTokenStr
;
391 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
392 if ( aTokenStr
.Len() )
394 rPos
.X() = aTokenStr
.ToInt32();
395 nValidMask
|= WINDOWSTATE_MASK_X
;
398 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
399 if ( aTokenStr
.Len() )
401 rPos
.Y() = aTokenStr
.ToInt32();
402 nValidMask
|= WINDOWSTATE_MASK_Y
;
405 aTokenStr
= rStr
.GetToken( 0, ',', nIndex
);
406 if ( aTokenStr
.Len() )
408 rSize
.Width() = aTokenStr
.ToInt32();
409 nValidMask
|= WINDOWSTATE_MASK_WIDTH
;
412 aTokenStr
= rStr
.GetToken( 0, ';', nIndex
);
413 if ( aTokenStr
.Len() )
415 rSize
.Height() = aTokenStr
.ToInt32();
416 nValidMask
|= WINDOWSTATE_MASK_HEIGHT
;
421 //-------------------------------------------------------------------------
422 void SfxChildWindow::InitializeChildWinFactory_Impl( sal_uInt16 nId
, SfxChildWinInfo
& rInfo
)
424 // load configuration
425 SvtViewOptions
aWinOpt( E_WINDOW
, String::CreateFromInt32( nId
) );
427 if ( aWinOpt
.Exists() )
428 rInfo
.bVisible
= aWinOpt
.IsVisible(); // set state from configuration. Can be overwritten by UserData, see below
430 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> aSeq
= aWinOpt
.GetUserData();
432 ::rtl::OUString aTmp
;
433 if ( aSeq
.getLength() )
434 aSeq
[0].Value
>>= aTmp
;
436 String
aWinData( aTmp
);
437 rInfo
.aWinState
= ByteString( String(aWinOpt
.GetWindowState()), RTL_TEXTENCODING_UTF8
);
439 //ImplWindowStateFromStr( rInfo.aPos, rInfo.aSize, ByteString( aWinState, RTL_TEXTENCODING_UTF8 ) );
441 if ( aWinData
.Len() )
443 // Nach Versionskennung suchen
444 if ( aWinData
.GetChar((sal_uInt16
)0) != 0x0056 ) // 'V' = 56h
445 // Keine Versionskennung, daher nicht verwenden
453 sal_uInt16 nPos
= aWinData
.Search( cToken
);
454 sal_uInt16 nActVersion
= (sal_uInt16
)aWinData
.Copy( 0, nPos
+ 1 ).ToInt32();
455 if ( nActVersion
!= nVersion
)
458 aWinData
.Erase(0,nPos
+1);
460 //aWinOpt.GetPosition( rInfo.aPos.X(), rInfo.aPos.Y() );
461 //aWinOpt.GetSize( rInfo.aSize.Width(), rInfo.aSize.Height() );
463 // Sichtbarkeit laden: ist als ein char codiert
464 rInfo
.bVisible
= (aWinData
.GetChar(0) == 0x0056); // 'V' = 56h
466 nPos
= aWinData
.Search( cToken
);
467 if (nPos
!= STRING_NOTFOUND
)
469 USHORT nNextPos
= aWinData
.Search( cToken
, 2 );
470 if ( nNextPos
!= STRING_NOTFOUND
)
472 // es gibt noch Extra-Information
473 rInfo
.nFlags
= (sal_uInt16
)aWinData
.Copy( nPos
+1, nNextPos
- nPos
- 1 ).ToInt32();
474 aWinData
.Erase( nPos
, nNextPos
-nPos
+1 );
475 rInfo
.aExtraString
= aWinData
;
478 rInfo
.nFlags
= (sal_uInt16
)aWinData
.Copy( nPos
+1 ).ToInt32();
483 void SfxChildWindow::CreateContext( sal_uInt16 nContextId
, SfxBindings
& rBindings
)
485 SfxChildWindowContext
*pCon
= NULL
;
486 SfxChildWinFactory
* pFact
=0;
487 SfxApplication
*pApp
= SFX_APP();
488 SfxDispatcher
*pDisp
= rBindings
.GetDispatcher_Impl();
489 SfxModule
*pMod
= pDisp
? SfxModule::GetActiveModule( pDisp
->GetFrame() ) :0;
492 SfxChildWinFactArr_Impl
*pFactories
= pMod
->GetChildWinFactories_Impl();
495 SfxChildWinFactArr_Impl
&rFactories
= *pFactories
;
496 for ( sal_uInt16 nFactory
= 0; nFactory
< rFactories
.Count(); ++nFactory
)
498 pFact
= rFactories
[nFactory
];
499 if ( pFact
->nId
== GetType() )
501 DBG_ASSERT( pFact
->pArr
, "Kein Kontext angemeldet!" );
505 SfxChildWinContextFactory
*pConFact
=0;
506 for ( sal_uInt16 n
=0; n
<pFact
->pArr
->Count(); ++n
)
508 pConFact
= (*pFact
->pArr
)[n
];
509 rBindings
.ENTERREGISTRATIONS();
510 if ( pConFact
->nContextId
== nContextId
)
512 SfxChildWinInfo aInfo
= pFact
->aInfo
;
513 pCon
= pConFact
->pCtor( GetWindow(), &rBindings
, &aInfo
);
514 pCon
->nContextId
= pConFact
->nContextId
;
515 pImp
->pContextModule
= pMod
;
517 rBindings
.LEAVEREGISTRATIONS();
527 SfxChildWinFactArr_Impl
&rFactories
= pApp
->GetChildWinFactories_Impl();
528 for ( sal_uInt16 nFactory
= 0; nFactory
< rFactories
.Count(); ++nFactory
)
530 pFact
= rFactories
[nFactory
];
531 if ( pFact
->nId
== GetType() )
533 DBG_ASSERT( pFact
->pArr
, "Kein Kontext angemeldet!" );
537 SfxChildWinContextFactory
*pConFact
=0;
538 for ( sal_uInt16 n
=0; n
<pFact
->pArr
->Count(); ++n
)
540 pConFact
= (*pFact
->pArr
)[n
];
541 rBindings
.ENTERREGISTRATIONS();
542 if ( pConFact
->nContextId
== nContextId
)
544 SfxChildWinInfo aInfo
= pFact
->aInfo
;
545 pCon
= pConFact
->pCtor( GetWindow(), &rBindings
, &aInfo
);
546 pCon
->nContextId
= pConFact
->nContextId
;
547 pImp
->pContextModule
= NULL
;
549 rBindings
.LEAVEREGISTRATIONS();
558 DBG_ERROR( "Kein geeigneter Context gefunden!" );
565 pContext
->GetWindow()->SetSizePixel( pWindow
->GetOutputSizePixel() );
566 pContext
->GetWindow()->Show();
569 SfxChildWindowContext::SfxChildWindowContext( sal_uInt16 nId
)
575 SfxChildWindowContext::~SfxChildWindowContext()
580 FloatingWindow
* SfxChildWindowContext::GetFloatingWindow() const
582 Window
*pParent
= pWindow
->GetParent();
583 if ( pParent
->GetType() == RSC_DOCKINGWINDOW
|| pParent
->GetType() == RSC_TOOLBOX
)
585 return ((DockingWindow
*)pParent
)->GetFloatingWindow();
587 else if ( pParent
->GetType() == RSC_FLOATINGWINDOW
)
589 return (FloatingWindow
*) pParent
;
593 DBG_ERROR("Kein FloatingWindow-Context!");
598 SfxChildAlignment
SfxChildWindowContext::GetAlignment() const
600 Window
*pParent
= pWindow
->GetParent();
601 if ( pParent
->GetType() == RSC_DOCKINGWINDOW
)
603 return ((SfxDockingWindow
*)pParent
)->GetAlignment();
605 else if ( pParent
->GetType() == RSC_TOOLBOX
)
607 HACK(noch nicht verwendet und noch nicht implementiert
);
608 return SFX_ALIGN_NOALIGNMENT
;
611 return SFX_ALIGN_NOALIGNMENT
;
614 void SfxChildWindowContext::Resizing( Size
& )
618 sal_Bool
SfxChildWindowContext::Close()
623 void SfxChildWindow::SetFactory_Impl( SfxChildWinFactory
*pF
)
628 void SfxChildWindow::SetHideNotDelete( sal_Bool bOn
)
630 pImp
->bHideNotDelete
= bOn
;
633 sal_Bool
SfxChildWindow::IsHideNotDelete() const
635 return pImp
->bHideNotDelete
;
638 void SfxChildWindow::SetHideAtToggle( sal_Bool bOn
)
640 pImp
->bHideAtToggle
= bOn
;
643 sal_Bool
SfxChildWindow::IsHideAtToggle() const
645 return pImp
->bHideAtToggle
;
648 void SfxChildWindow::SetWantsFocus( BOOL bSet
)
650 pImp
->bWantsFocus
= bSet
;
653 sal_Bool
SfxChildWindow::WantsFocus() const
655 return pImp
->bWantsFocus
;
658 sal_Bool
SfxChildWinInfo::GetExtraData_Impl
660 SfxChildAlignment
*pAlign
,
661 SfxChildAlignment
*pLastAlign
,
668 if ( !aExtraString
.Len() )
671 sal_uInt16 nPos
= aExtraString
.SearchAscii("AL:");
672 if ( nPos
== STRING_NOTFOUND
)
675 // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
676 // er nicht vorhanden ist, liegt eine "altere Version vor
677 if ( nPos
!= STRING_NOTFOUND
)
679 sal_uInt16 n1
= aExtraString
.Search('(', nPos
);
680 if ( n1
!= STRING_NOTFOUND
)
682 sal_uInt16 n2
= aExtraString
.Search(')', n1
);
683 if ( n2
!= STRING_NOTFOUND
)
685 // Alignment-String herausschneiden
686 aStr
= aExtraString
.Copy(nPos
, n2
- nPos
+ 1);
687 aStr
.Erase(nPos
, n1
-nPos
+1);
692 // Zuerst das Alignment extrahieren
696 *pAlign
= (SfxChildAlignment
) (sal_uInt16
) aStr
.ToInt32();
698 // Dann das LastAlignment
699 nPos
= aStr
.Search(',');
700 if ( nPos
== STRING_NOTFOUND
)
702 aStr
.Erase(0, nPos
+1);
704 *pLastAlign
= (SfxChildAlignment
) (sal_uInt16
) aStr
.ToInt32();
706 // Dann die Splitting-Informationen
707 nPos
= aStr
.Search(',');
708 if ( nPos
== STRING_NOTFOUND
)
709 // Dockt nicht in einem Splitwindow
711 aStr
.Erase(0, nPos
+1);
714 if ( GetPosSizeFromString( aStr
, aChildPos
, aChildSize
) )
719 *pLine
= (sal_uInt16
) aChildPos
.X();
721 *pPos
= (sal_uInt16
) aChildPos
.Y();
727 sal_Bool
SfxChildWindow::IsVisible() const
729 return pImp
->bVisible
;
732 void SfxChildWindow::SetVisible_Impl( sal_Bool bVis
)
734 pImp
->bVisible
= bVis
;
737 void SfxChildWindow::Hide()
739 switch ( pWindow
->GetType() )
741 case RSC_DOCKINGWINDOW
:
742 ((DockingWindow
*)pWindow
)->Hide();
745 ((ToolBox
*)pWindow
)->Hide();
755 void SfxChildWindow::Show( USHORT nFlags
)
757 switch ( pWindow
->GetType() )
759 case RSC_DOCKINGWINDOW
:
760 ((DockingWindow
*)pWindow
)->Show( TRUE
, nFlags
);
763 ((ToolBox
*)pWindow
)->Show( TRUE
, nFlags
);
766 pWindow
->Show( TRUE
, nFlags
);
771 Window
* SfxChildWindow::GetContextWindow( SfxModule
*pModule
) const
773 return pModule
== pImp
->pContextModule
&& pContext
? pContext
->GetWindow(): 0;
776 void SfxChildWindow::SetWorkWindow_Impl( SfxWorkWindow
* pWin
)
778 pImp
->pWorkWin
= pWin
;
779 if ( pWin
&& pWindow
->HasChildPathFocus() )
780 pImp
->pWorkWin
->SetActiveChild_Impl( pWindow
);
783 //SfxWorkWindow* SfxChildWindow::GetWorkWindow_Impl() const
785 // return pImp->pWorkWin;
788 void SfxChildWindow::Activate_Impl()
790 if(pImp
->pWorkWin
!=NULL
) //@#60568#
791 pImp
->pWorkWin
->SetActiveChild_Impl( pWindow
);
794 void SfxChildWindow::Deactivate_Impl()
796 // pImp->pWorkWin->SetActiveChild_Impl( NULL );
799 sal_Bool
SfxChildWindow::QueryClose()
801 sal_Bool bAllow
= sal_True
;
803 if ( pImp
->xFrame
.is() )
805 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
> xCtrl
= pImp
->xFrame
->getController();
807 bAllow
= xCtrl
->suspend( sal_True
);
811 bAllow
= !GetWindow()->IsInModalMode();
816 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> SfxChildWindow::GetFrame()
821 void SfxChildWindow::SetFrame( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> & rFrame
)
823 // Do nothing if nothing will be changed ...
824 if( pImp
->xFrame
!= rFrame
)
826 // ... but stop listening on old frame, if connection exist!
827 if( pImp
->xFrame
.is() )
828 pImp
->xFrame
->removeEventListener( pImp
->xListener
);
830 // If new frame isnt NULL -> we must guarantee valid listener for disposing events.
831 // Use already existing or create new one.
833 if( !pImp
->xListener
.is() )
834 pImp
->xListener
= ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>( new DisposeListener( this, pImp
) );
836 // Set new frame in data container
837 // and build new listener connection, if neccessary.
838 pImp
->xFrame
= rFrame
;
839 if( pImp
->xFrame
.is() )
840 pImp
->xFrame
->addEventListener( pImp
->xListener
);
844 sal_Bool
SfxChildWindow::CanGetFocus() const
846 return !(pImp
->pFact
->aInfo
.nFlags
& SFX_CHILDWIN_CANTGETFOCUS
);
849 void SfxChildWindowContext::RegisterChildWindowContext(SfxModule
* pMod
, USHORT nId
, SfxChildWinContextFactory
* pFact
)
851 SFX_APP()->RegisterChildWindowContext_Impl( pMod
, nId
, pFact
);
854 void SfxChildWindow::RegisterChildWindow(SfxModule
* pMod
, SfxChildWinFactory
* pFact
)
856 SFX_APP()->RegisterChildWindow_Impl( pMod
, pFact
);