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