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