xref: /aoo42x/main/sfx2/source/appl/workwin.cxx (revision d119d52d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sfx2.hxx"
26 
27 #ifndef GCC
28 #endif
29 
30 #include <stdio.h>
31 #include <hash_map>
32 
33 #include <sfx2/docfile.hxx>
34 #include <sfx2/objsh.hxx>
35 #include <sfx2/app.hxx>
36 #include "workwin.hxx"
37 #include <sfx2/viewfrm.hxx>
38 #include "arrdecl.hxx"
39 #include <sfx2/viewfrm.hxx>
40 #include <sfx2/module.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/dockwin.hxx>
43 #include <sfx2/viewsh.hxx>
44 #include "splitwin.hxx"
45 #include <sfx2/msgpool.hxx>
46 #include "sfx2/sfxresid.hxx"
47 #include <sfx2/objsh.hxx>
48 #include <sfx2/request.hxx>      // SFX_ITEMSET_SET
49 #include <vcl/taskpanelist.hxx>
50 #include <vcl/toolbox.hxx>
51 #include <tools/rcid.h>
52 #include <tools/diagnose_ex.h>
53 #include <toolkit/helper/vclunohelper.hxx>
54 #include <svl/itempool.hxx>
55 #include <svl/itemiter.hxx>
56 #include <svl/whiter.hxx>
57 #include <svl/intitem.hxx>
58 #ifndef _SFXEITEM_HXX //autogen
59 #include <svl/eitem.hxx>
60 #endif
61 #include <com/sun/star/ui/XUIElement.hpp>
62 #include <com/sun/star/frame/XLayoutManager.hpp>
63 #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
64 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
65 #include <com/sun/star/beans/XPropertySet.hpp>
66 #include <com/sun/star/awt/XWindow.hpp>
67 #include <com/sun/star/lang/DisposedException.hpp>
68 
69 using namespace ::com::sun::star;
70 using namespace ::com::sun::star::uno;
71 namespace css = ::com::sun::star;
72 
73 struct ResIdToResName
74 {
75     sal_uInt16      nId;
76     const char* pName;
77 };
78 
79 static const ResIdToResName pToolBarResToName[] =
80 {
81     { 558,      "fullscreenbar"        },
82     { 560,      "standardbar",         },
83     { 18001,    "formsnavigationbar"   },
84     { 18002,    "formsfilterbar"       },
85     { 18003,    "formtextobjectbar"    },
86     { 18004,    "formcontrols"         },
87     { 18005,    "moreformcontrols"     },
88     { 18006,    "formdesign"           },
89     { 20050,    "toolbar"              },      //math
90     { 30001,    "objectbar"            },      //chart
91     { 30513,    "toolbar"              },      //chart
92     { 25005,    "textobjectbar"        },      //calc
93     { 25053,    "drawobjectbar"        },
94     { 25054,    "graphicobjectbar"     },
95     { 25001,    "formatobjectbar"      },
96     { 25006,    "previewbar"           },
97     { 25035,    "toolbar"              },      //calc
98     { 23015,    "bezierobjectbar"      },      //draw/impress
99     { 23019,    "gluepointsobjectbar"  },
100     { 23030,    "graphicobjectbar"     },
101     { 23013,    "drawingobjectbar"     },      //impress
102     { 23016,    "textobjectbar"        },      //impress
103     { 23028,    "textobjectbar"        },      //draw
104     { 23011,    "toolbar"              },      //impress
105     { 23020,    "optionsbar"           },
106     { 23021,    "commontaskbar"        },
107     { 23025,    "toolbar"              },      //draw
108     { 23026,    "optionsbar"           },
109     { 23027,    "drawingobjectbar"     },      //draw
110     { 23017,    "outlinetoolbar"       },      //impress
111     { 23012,    "slideviewtoolbar"     },
112     { 23014,    "slideviewobjectbar"   },
113     { 23283,    "bezierobjectbar"      },      //writer
114     { 23269,    "drawingobjectbar"     },
115     { 23270,    "drawtextobjectbar"    },
116     { 23267,    "frameobjectbar"       },
117     { 23268,    "graphicobjectbar"     },
118     { 23271,    "numobjectbar"         },
119     { 23272,    "oleobjectbar"         },
120     { 23266,    "tableobjectbar"       },
121     { 23265,    "textobjectbar"        },
122     { 20631,    "previewobjectbar"     },      //writer
123     { 20402,    "toolbar"              },      //web
124     { 20403,    "textobjectbar"        },
125     { 23273,    "toolbar"              },      //writer
126     { 20408,    "frameobjectbar"       },      //web
127     { 20410,    "graphicobjectbar"     },
128     { 20411,    "oleobjectbar"         },
129     { 14850,    "macrobar"             },
130     { 10987,    "fontworkobjectbar"    },      //global
131     { 10986,    "extrusionobjectbar"   },
132     { 23022,    "formsobjectbar"       },
133     { 23310,    "viewerbar"            },      //writer (plugin)
134     { 25000,    "viewerbar"            },      //calc   (plugin)
135     { 23023,    "viewerbar"            },      //impress(plugin)
136     { 23024,    "viewerbar"            },      //draw   (plugin)
137     { 23031,    "mediaobjectbar"       },      //draw/impress
138     { 25060,    "mediaobjectbar"       },      //calc
139     { 23311,    "mediaobjectbar"       },      //writer
140     { 0,        ""                     }
141 };
142 
143 DBG_NAME(SfxWorkWindow)
144 
145 //SV_IMPL_OBJARR( SfxObjectBarArr_Impl, SfxObjectBar_Impl );
146 
147 //====================================================================
148 // Sortiert die Children nach ihrem Alignment
149 // Reihenfolge entspricht der im enum SfxChildAlignment (->CHILDWIN.HXX).
150 //
151 
152 // Hilfe, um die "Anderungen am Alignment kompatibal zu machen!
153 
154 
SFX_IMPL_XINTERFACE_3(LayoutManagerListener,OWeakObject,::com::sun::star::frame::XLayoutManagerListener,::com::sun::star::lang::XEventListener,::com::sun::star::lang::XComponent)155 SFX_IMPL_XINTERFACE_3( LayoutManagerListener, OWeakObject, ::com::sun::star::frame::XLayoutManagerListener, ::com::sun::star::lang::XEventListener, ::com::sun::star::lang::XComponent )
156 SFX_IMPL_XTYPEPROVIDER_3( LayoutManagerListener, ::com::sun::star::frame::XLayoutManagerListener, ::com::sun::star::lang::XEventListener, ::com::sun::star::lang::XComponent )
157 
158 LayoutManagerListener::LayoutManagerListener(
159     SfxWorkWindow* pWrkWin ) :
160     m_bHasFrame( sal_False ),
161     m_pWrkWin( pWrkWin ),
162     m_aLayoutManagerPropName( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))
163 {
164 }
165 
~LayoutManagerListener()166 LayoutManagerListener::~LayoutManagerListener()
167 {
168 }
169 
setFrame(const css::uno::Reference<css::frame::XFrame> & xFrame)170 void LayoutManagerListener::setFrame( const css::uno::Reference< css::frame::XFrame >& xFrame )
171 {
172     ::vos::OGuard aGuard( Application::GetSolarMutex() );
173     if ( m_pWrkWin && !m_bHasFrame )
174     {
175         m_xFrame    = xFrame;
176         m_bHasFrame = sal_True;
177 
178         if ( xFrame.is() )
179         {
180             css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
181             css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
182             if ( xPropSet.is() )
183             {
184                 try
185                 {
186                     Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
187 	                aValue >>= xLayoutManager;
188 
189                     if ( xLayoutManager.is() )
190                         xLayoutManager->addLayoutManagerEventListener(
191                             css::uno::Reference< css::frame::XLayoutManagerListener >(
192                                 static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY ));
193 
194                     xPropSet = css::uno::Reference< css::beans::XPropertySet >( xLayoutManager, UNO_QUERY );
195                     if ( xPropSet.is() )
196                     {
197                         aValue = xPropSet->getPropertyValue(
198                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LockCount" )) );
199                         aValue >>= m_pWrkWin->m_nLock;
200                     }
201                 }
202                 catch ( css::lang::DisposedException& )
203                 {
204                 }
205                 catch ( css::uno::RuntimeException& e )
206                 {
207                     throw e;
208                 }
209                 catch ( css::uno::Exception& )
210                 {
211                 }
212             }
213         }
214     }
215 }
216 
217 //---------------------------------------------------------------------------------------------------------
218 //  XComponent
219 //---------------------------------------------------------------------------------------------------------
addEventListener(const css::uno::Reference<css::lang::XEventListener> &)220 void SAL_CALL LayoutManagerListener::addEventListener(
221     const css::uno::Reference< css::lang::XEventListener >& )
222 throw (::com::sun::star::uno::RuntimeException)
223 {
224     // do nothing, only internal class
225 }
226 
removeEventListener(const css::uno::Reference<css::lang::XEventListener> &)227 void SAL_CALL LayoutManagerListener::removeEventListener(
228     const css::uno::Reference< css::lang::XEventListener >& )
229 throw (::com::sun::star::uno::RuntimeException)
230 {
231     // do nothing, only internal class
232 }
233 
dispose()234 void SAL_CALL LayoutManagerListener::dispose()
235 throw( css::uno::RuntimeException )
236 {
237     ::vos::OGuard aGuard( Application::GetSolarMutex() );
238 
239     // reset member
240     m_pWrkWin = 0;
241 
242     css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame.get(), css::uno::UNO_QUERY );
243     if ( xFrame.is() )
244     {
245         m_xFrame = css::uno::Reference< css::frame::XFrame >();
246         m_bHasFrame = sal_False;
247 
248         css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY );
249         css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
250         if ( xPropSet.is() )
251         {
252             try
253             {
254                 css::uno::Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
255 	            aValue >>= xLayoutManager;
256 
257                 // remove as listener from layout manager
258                 if ( xLayoutManager.is() )
259                     xLayoutManager->removeLayoutManagerEventListener(
260                         css::uno::Reference< css::frame::XLayoutManagerListener >(
261                             static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY ));
262             }
263             catch ( css::lang::DisposedException& )
264             {
265             }
266             catch ( css::uno::RuntimeException& e )
267             {
268                 throw e;
269             }
270             catch ( css::uno::Exception& )
271             {
272             }
273         }
274     }
275 }
276 
277 //---------------------------------------------------------------------------------------------------------
278 //  XEventListener
279 //---------------------------------------------------------------------------------------------------------
disposing(const css::lang::EventObject &)280 void SAL_CALL LayoutManagerListener::disposing(
281     const css::lang::EventObject& )
282 throw( css::uno::RuntimeException )
283 {
284     ::vos::OGuard aGuard( Application::GetSolarMutex() );
285     m_pWrkWin = 0;
286     m_bHasFrame = sal_False;
287     m_xFrame = css::uno::Reference< css::frame::XFrame >();
288 }
289 
290 //---------------------------------------------------------------------------------------------------------
291 // XLayoutManagerEventListener
292 //---------------------------------------------------------------------------------------------------------
layoutEvent(const css::lang::EventObject &,::sal_Int16 eLayoutEvent,const css::uno::Any &)293 void SAL_CALL LayoutManagerListener::layoutEvent(
294     const css::lang::EventObject&,
295     ::sal_Int16                   eLayoutEvent,
296     const css::uno::Any&                        )
297 throw (css::uno::RuntimeException)
298 {
299     ::vos::OGuard aGuard( Application::GetSolarMutex() );
300     if ( m_pWrkWin )
301     {
302         if ( eLayoutEvent == css::frame::LayoutManagerEvents::VISIBLE )
303         {
304             m_pWrkWin->MakeVisible_Impl( sal_True );
305             m_pWrkWin->ShowChilds_Impl();
306             m_pWrkWin->ArrangeChilds_Impl( sal_True );
307         }
308         else if ( eLayoutEvent == css::frame::LayoutManagerEvents::INVISIBLE )
309         {
310             m_pWrkWin->MakeVisible_Impl( sal_False );
311             m_pWrkWin->HideChilds_Impl();
312             m_pWrkWin->ArrangeChilds_Impl( sal_True );
313         }
314         else if ( eLayoutEvent == css::frame::LayoutManagerEvents::LOCK )
315         {
316             m_pWrkWin->Lock_Impl( sal_True );
317         }
318         else if ( eLayoutEvent == css::frame::LayoutManagerEvents::UNLOCK )
319         {
320             m_pWrkWin->Lock_Impl( sal_False );
321         }
322     }
323 }
324 
325 //====================================================================
326 
327 typedef std::hash_map< sal_Int32, rtl::OUString > ToolBarResIdToResourceURLMap;
328 
329 static sal_Bool bMapInitialized = sal_False;
330 static ToolBarResIdToResourceURLMap aResIdToResourceURLMap;
331 
GetResourceURLFromResId(sal_uInt16 nResId)332 static rtl::OUString GetResourceURLFromResId( sal_uInt16 nResId )
333 {
334     if ( !bMapInitialized )
335     {
336         osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
337         if ( !bMapInitialized )
338         {
339             sal_Int32 nIndex( 0 );
340             while ( pToolBarResToName[nIndex].nId != 0 )
341             {
342                 rtl::OUString aResourceURL( rtl::OUString::createFromAscii( pToolBarResToName[nIndex].pName ));
343                 aResIdToResourceURLMap.insert( ToolBarResIdToResourceURLMap::value_type(
344                                                     sal_Int32( pToolBarResToName[nIndex].nId ), aResourceURL ));
345                 ++nIndex;
346             }
347             bMapInitialized = sal_True;
348         }
349     }
350 
351     ToolBarResIdToResourceURLMap::const_iterator pIter = aResIdToResourceURLMap.find( nResId );
352     if ( pIter != aResIdToResourceURLMap.end() )
353         return pIter->second;
354     else
355         return rtl::OUString();
356 }
357 
IsAppWorkWinToolbox_Impl(sal_uInt16 nPos)358 sal_Bool IsAppWorkWinToolbox_Impl( sal_uInt16 nPos )
359 {
360 	switch ( nPos )
361 	{
362 		case SFX_OBJECTBAR_APPLICATION :
363 		case SFX_OBJECTBAR_MACRO:
364 		case SFX_OBJECTBAR_FULLSCREEN:
365 			return sal_True;
366 		default:
367 			return sal_False;
368 	}
369 }
370 
TbxMatch(sal_uInt16 nPos)371 sal_uInt16 TbxMatch( sal_uInt16 nPos )
372 {
373     switch ( nPos )
374     {
375         case SFX_OBJECTBAR_APPLICATION :
376             return 0;
377         case SFX_OBJECTBAR_OPTIONS:
378             return 1;
379         case SFX_OBJECTBAR_MACRO:
380             return 2;
381         case SFX_OBJECTBAR_OBJECT:
382             return 3;
383         case SFX_OBJECTBAR_TOOLS:
384             return 4;
385         case SFX_OBJECTBAR_FULLSCREEN:
386         case SFX_OBJECTBAR_COMMONTASK:
387         case SFX_OBJECTBAR_RECORDING:
388             return nPos+1;
389         default:
390             return nPos;
391     }
392 }
393 
ChildAlignValue(SfxChildAlignment eAlign)394 sal_uInt16 ChildAlignValue(SfxChildAlignment eAlign)
395 {
396 	sal_uInt16 ret = 17;
397 
398 	switch (eAlign)
399 	{
400 		case SFX_ALIGN_HIGHESTTOP:
401 			ret = 1;
402 			break;
403 		case SFX_ALIGN_LOWESTBOTTOM:
404 			ret = 2;
405 			break;
406 		case SFX_ALIGN_FIRSTLEFT:
407 			ret = 3;
408 			break;
409 		case SFX_ALIGN_LASTRIGHT:
410 			ret = 4;
411 			break;
412 		case SFX_ALIGN_LEFT:
413 			ret = 5;
414 			break;
415 		case SFX_ALIGN_RIGHT:
416 			ret = 6;
417 			break;
418 		case SFX_ALIGN_FIRSTRIGHT:
419 			ret = 7;
420 			break;
421 		case SFX_ALIGN_LASTLEFT:
422 			ret = 8;
423 			break;
424 		case SFX_ALIGN_TOP:
425 			ret = 9;
426 			break;
427 		case SFX_ALIGN_BOTTOM:
428 			ret = 10;
429 			break;
430 		case SFX_ALIGN_TOOLBOXTOP:
431 			ret = 11;
432 			break;
433 		case SFX_ALIGN_TOOLBOXBOTTOM:
434 			ret = 12;
435 			break;
436 		case SFX_ALIGN_LOWESTTOP:
437 			ret = 13;
438 			break;
439 		case SFX_ALIGN_HIGHESTBOTTOM:
440 			ret = 14;
441 			break;
442 		case SFX_ALIGN_TOOLBOXLEFT:
443 			ret = 15;
444 			break;
445 		case SFX_ALIGN_TOOLBOXRIGHT:
446 			ret = 16;
447 			break;
448 		case SFX_ALIGN_NOALIGNMENT:
449 			break;  // -Wall not handled...
450 	}
451 
452 	return ret;
453 }
454 
ChildTravelValue(SfxChildAlignment eAlign)455 sal_uInt16 ChildTravelValue( SfxChildAlignment eAlign )
456 {
457 	sal_uInt16 ret = 17;
458 
459 	switch (eAlign)
460 	{
461 		case SFX_ALIGN_FIRSTLEFT:
462 			ret = 1;
463 			break;
464 		case SFX_ALIGN_LEFT:
465 			ret = 2;
466 			break;
467 		case SFX_ALIGN_LASTLEFT:
468 			ret = 3;
469 			break;
470 		case SFX_ALIGN_TOOLBOXLEFT:
471 			ret = 4;
472 			break;
473 		case SFX_ALIGN_HIGHESTTOP:
474 			ret = 5;
475 			break;
476 		case SFX_ALIGN_TOP:
477 			ret = 6;
478 			break;
479 		case SFX_ALIGN_TOOLBOXTOP:
480 			ret = 7;
481 			break;
482 		case SFX_ALIGN_LOWESTTOP:
483 			ret = 8;
484 			break;
485 		case SFX_ALIGN_HIGHESTBOTTOM:
486 			ret = 9;
487 			break;
488 		case SFX_ALIGN_TOOLBOXBOTTOM:
489 			ret = 10;
490 			break;
491 		case SFX_ALIGN_BOTTOM:
492 			ret = 11;
493 			break;
494 		case SFX_ALIGN_LOWESTBOTTOM:
495 			ret = 12;
496 			break;
497 		case SFX_ALIGN_TOOLBOXRIGHT:
498 			ret = 13;
499 			break;
500 		case SFX_ALIGN_FIRSTRIGHT:
501 			ret = 14;
502 			break;
503 		case SFX_ALIGN_RIGHT:
504 			ret = 15;
505 			break;
506 		case SFX_ALIGN_LASTRIGHT:
507 			ret = 16;
508 			break;
509 		case SFX_ALIGN_NOALIGNMENT:
510 			break;  // -Wall not handled.
511 	}
512 
513 	return ret;
514 }
515 
Sort_Impl()516 void SfxWorkWindow::Sort_Impl()
517 {
518 	aSortedList.Remove(0, aSortedList.Count());
519 	for (sal_uInt16 i=0; i<pChilds->Count(); i++)
520 	{
521 		SfxChild_Impl *pCli = (*pChilds)[i];
522 		if (pCli)
523 		{
524 			sal_uInt16 k;
525 			for (k=0; k<aSortedList.Count(); k++)
526 //				if ( (*pChilds)[aSortedList[k]]->eAlign > pCli->eAlign )
527 				if (ChildAlignValue((*pChilds)[aSortedList[k]]->eAlign) >
528 					ChildAlignValue(pCli->eAlign))
529 					break;
530 			aSortedList.Insert (i,k);
531 		}
532 	}
533 
534 	bSorted = sal_True;
535 }
536 
537 
538 //====================================================================
539 // ctor f"ur workwin eines Frames
540 
SfxFrameWorkWin_Impl(Window * pWin,SfxFrame * pFrm,SfxFrame * pMaster)541 SfxFrameWorkWin_Impl::SfxFrameWorkWin_Impl( Window *pWin, SfxFrame *pFrm, SfxFrame* pMaster )
542     : SfxWorkWindow(
543         pWin,
544         pFrm->GetCurrentViewFrame()->GetBindings(),
545         pFrm->GetParentFrame() ? pFrm->GetParentFrame()->GetWorkWindow_Impl() : NULL )
546     , pMasterFrame( pMaster )
547     , pFrame( pFrm )
548 {
549 	pConfigShell = pFrm->GetCurrentViewFrame();
550 	if ( pConfigShell && pConfigShell->GetObjectShell() )
551 	{
552 		bShowStatusBar = ( !pConfigShell->GetObjectShell()->IsInPlaceActive() );
553 		bDockingAllowed = sal_True;
554         bInternalDockingAllowed = sal_True;
555 	}
556 
557 	// Die ben"otigten SplitWindows (je eins f"ur jede Seite) werden erzeugt
558 	for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
559 	{
560 		// Die SplitWindows sind direkte ChildWindows des WorkWindows und enthalten
561 		// die angedockten Fenster.
562 
563 		SfxChildAlignment eAlign =
564 						( n == SFX_SPLITWINDOWS_LEFT ? SFX_ALIGN_LEFT :
565 							n == SFX_SPLITWINDOWS_RIGHT ? SFX_ALIGN_RIGHT :
566 							n == SFX_SPLITWINDOWS_TOP ? SFX_ALIGN_TOP :
567 								SFX_ALIGN_BOTTOM );
568 		SfxSplitWindow *pSplitWin = new SfxSplitWindow(pWorkWin, eAlign, this, pParent==0 );
569 		pSplit[n] = pSplitWin;
570 	}
571 
572     //nOrigMode = SFX_VISIBILITY_CLIENT;
573     nOrigMode = SFX_VISIBILITY_STANDARD;
574 	nUpdateMode = SFX_VISIBILITY_STANDARD;
575 }
576 
577 //====================================================================
578 // ctor der Basisklasse
579 
SfxWorkWindow(Window * pWin,SfxBindings & rB,SfxWorkWindow * pParentWorkwin)580 SfxWorkWindow::SfxWorkWindow( Window *pWin, SfxBindings& rB, SfxWorkWindow* pParentWorkwin ) :
581 	pParent( pParentWorkwin ),
582 	pBindings(&rB),
583 	pWorkWin (pWin),
584 	pConfigShell( 0 ),
585     pActiveChild( 0 ),
586 	nChilds( 0 ),
587 	nOrigMode( 0 ),
588 	bSorted( sal_True ),
589 	bDockingAllowed(sal_True),
590     bInternalDockingAllowed(sal_True),
591 	bAllChildsVisible(sal_True),
592     bIsFullScreen( sal_False ),
593     bShowStatusBar( sal_True ),
594     m_nLock( 0 ),
595     m_aStatusBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" )),
596     m_aLayoutManagerPropName( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )),
597     m_aTbxTypeName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" )),
598     m_aProgressBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/progressbar/progressbar" ))
599 {
600 	DBG_CTOR(SfxWorkWindow, 0);
601 	DBG_ASSERT (pBindings, "Keine Bindings!");
602 
603 	pBindings->SetWorkWindow_Impl( this );
604 
605 	pChildWins = new SfxChildWindows_Impl;
606 	pChilds = new SfxChildList_Impl;
607 
608 	// F"ur die ObjectBars wird ein fester Platz in der ChildList reserviert,
609 	// damit sie immer in einer definierten Reihenfolge kommen.
610 	SfxChild_Impl* pChild=0;
611 	for (sal_uInt16 n=0; n < SFX_OBJECTBAR_MAX; ++n)
612 		pChilds->Insert(0,pChild);
613 
614     // create and initialize layout manager listener
615     Reference< com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
616     LayoutManagerListener* pLayoutManagerListener = new LayoutManagerListener( this );
617     m_xLayoutManagerListener = css::uno::Reference< css::lang::XComponent >(
618                                     static_cast< cppu::OWeakObject* >( pLayoutManagerListener ),
619                                         css::uno::UNO_QUERY );
620     pLayoutManagerListener->setFrame( xFrame );
621 }
622 
623 //====================================================================
624 // dtor
625 
~SfxWorkWindow()626 SfxWorkWindow::~SfxWorkWindow()
627 {
628 	DBG_DTOR(SfxWorkWindow, 0);
629 
630 	// SplitWindows l"oschen
631     for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
632 	{
633 		SfxSplitWindow *p = pSplit[n];
634 		if (p->GetWindowCount())
635 			ReleaseChild_Impl(*p);
636         delete p;
637 	}
638 
639 	// Hilfsstruktur f"ur Child-Windows l"oschen
640 	DBG_ASSERT( pChilds->Count() == 0, "dangling childs" );
641 	delete pChilds;
642 	delete pChildWins;
643 
644     if ( m_xLayoutManagerListener.is() )
645         m_xLayoutManagerListener->dispose();
646 }
647 
GetTopWindow() const648 SystemWindow* SfxWorkWindow::GetTopWindow() const
649 {
650     Window* pRet = pWorkWin;
651     while ( pRet && !pRet->IsSystemWindow() )
652         pRet = pRet->GetParent();
653     return (SystemWindow*) pRet;
654 }
655 
Lock_Impl(sal_Bool bLock)656 void SfxWorkWindow::Lock_Impl( sal_Bool bLock )
657 {
658     if ( bLock )
659         m_nLock++;
660     else
661         --m_nLock;
662     if ( m_nLock<0 )
663     {
664         DBG_ERROR("Lock count underflow!");
665         m_nLock = 0;
666     }
667 
668     if ( !m_nLock )
669         ArrangeChilds_Impl();
670 }
671 
ChangeWindow_Impl(Window * pNew)672 void SfxWorkWindow::ChangeWindow_Impl( Window *pNew )
673 {
674 	Window *pOld = pWorkWin;
675 	pWorkWin = pNew;
676 	for ( sal_uInt16 nPos = 0; nPos < pChilds->Count(); ++nPos )
677 	{
678 		SfxChild_Impl *pCli = (*pChilds)[nPos];
679 		if ( pCli && pCli->pWin && pCli->pWin->GetParent() == pOld )
680 		{
681 			pCli->pWin->SetParent( pNew );
682 		}
683 	}
684 }
685 
SaveStatus_Impl()686 void SfxWorkWindow::SaveStatus_Impl()
687 {
688 	sal_uInt16 nCount = pChildWins->Count();
689     for ( sal_uInt16 n=0; n<nCount; n++ )
690 	{
691 		SfxChildWin_Impl* pCW = (*pChildWins)[n];
692 		SfxChildWindow *pChild = pCW->pWin;
693 		if (pChild)
694 		{
695             sal_uInt16 nFlags = pCW->aInfo.nFlags;
696 			pCW->aInfo = pChild->GetInfo();
697             pCW->aInfo.nFlags |= nFlags;
698 			SaveStatus_Impl(pChild, pCW->aInfo);
699 		}
700 	}
701 }
702 
703 //--------------------------------------------------------------------
704 // Hilfsmethode zum Freigeben der Childlisten. Wenn danach nicht der dtor
705 // aufgerufen wird, sondern weiter gearbeitet wird, mu\s wie im ctor von
706 // SfxWorkWindow noch Platz f"ur die Objectbars und SplitWindows reserviert
707 // werden.
708 
DeleteControllers_Impl()709 void SfxWorkWindow::DeleteControllers_Impl()
710 {
711     DBG_CHKTHIS(SfxWorkWindow, 0);
712 
713     // SplitWindows locken (d.h. Resize-Reaktion an den
714     // DockingWindows unterdr"ucken)
715     sal_uInt16 n;
716     for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
717     {
718         SfxSplitWindow *p = pSplit[n];
719        	if (p->GetWindowCount())
720 	    p->Lock();
721     }
722 
723     // Child-Windows l"oschen
724     for ( n=0; n<pChildWins->Count(); )
725     {
726         SfxChildWin_Impl* pCW = (*pChildWins)[n];
727         pChildWins->Remove(n);
728        	SfxChildWindow *pChild = pCW->pWin;
729 	    if (pChild)
730 	    {
731 /*
732             sal_uInt16 nFlags = pCW->aInfo.nFlags;
733             pCW->aInfo = pChild->GetInfo();
734             pCW->aInfo.nFlags |= nFlags;
735             SaveStatus_Impl(pChild, pCW->aInfo);
736 */
737 	        pChild->Hide();
738 
739 	        // Wenn das ChildWindow ein direktes Childfenster ist und nicht
740 	        // in einem SplitWindow liegt, am WorkWindow abmelden.
741 	        // Nach TH ist eine Abmeldung am Splitwindow nicht erforderlich,
742 	        // wenn dieses auch gleich mit zerst"ort wird (s.u.).
743 	        if (pCW->pCli)
744 	            ReleaseChild_Impl(*pChild->GetWindow());
745 	        pCW->pWin = 0;
746 	        pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChild->GetWindow() );
747             pChild->Destroy();
748         }
749 
750 	    delete pCW;
751 
752         // ATTENTION: The array itself is cleared after this loop!!
753         // Therefore we have to set every array entry to zero as it could be
754         // accessed by calling pChild->Destroy().
755         // See task 128307 (Windows)
756         // Window::NotifyAllChilds() calls SfxWorkWindow::DataChanged_Impl for
757         // 8-bit displays (WM_QUERYPALETTECHANGED message due to focus change)!!
758         //(*pChildWins)[n] = 0;
759     }
760 
761     //pChildWins->Remove((sal_uInt16)0, nCount);
762 
763     Reference< com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
764     Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
765     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
766     if ( xPropSet.is() )
767     {
768         try
769         {
770 	        Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
771 	        aValue >>= xLayoutManager;
772         }
773         catch ( Exception& )
774         {
775         }
776     }
777 
778     if ( xLayoutManager.is() )
779     {
780         xLayoutManager->reset();
781 
782         // StatusBar l"oschen
783         ResetStatusBar_Impl();
784 
785         // ObjectBars l"oschen( zuletzt, damit pChilds nicht tote Pointer enh"alt )
786         for ( sal_uInt16 i = 0; i < aObjBarList.size(); i++ )
787         {
788             // Nicht jede Position mu\s belegt sein
789             sal_uInt16 nId = aObjBarList[i].nId;
790             if ( nId )
791                 aObjBarList[i].nId = 0;
792         }
793     }
794 
795     // ObjectBars werden alle auf einmal released, da sie einen
796     // festen zusammenh"angenden  Bereich im Array pChilds belegen
797     pChilds->Remove(0, SFX_OBJECTBAR_MAX);
798     bSorted = sal_False;
799 
800     nChilds = 0;
801 }
802 
803 //====================================================================
804 // Virtuelle Methode zum Anordnen der Childfenster.
805 
ArrangeChilds_Impl(sal_Bool)806 void SfxWorkWindow::ArrangeChilds_Impl( sal_Bool /*bForce*/)
807 {
808     Arrange_Impl();
809 }
810 
ArrangeChilds_Impl(sal_Bool bForce)811 void SfxFrameWorkWin_Impl::ArrangeChilds_Impl( sal_Bool bForce )
812 {
813     if ( pFrame->IsClosing_Impl() || ( m_nLock && !bForce ))
814 		return;
815 
816 	SfxInPlaceClient *pClient = 0;
817     SfxViewFrame *pF = pFrame->GetCurrentViewFrame();
818     if ( pF && pF->GetViewShell() )
819         pClient = pF->GetViewShell()->GetIPClient();
820 
821     if ( pClient )
822         return;
823 
824 	aClientArea = GetTopRect_Impl();
825     if ( aClientArea.IsEmpty() )
826         return;
827 
828 	SvBorder aBorder;
829 	if ( nChilds )
830     {
831         if ( IsVisible_Impl() )
832             aBorder = Arrange_Impl();
833     }
834 
835 	// Wenn das aktuelle Dokument der Applikation einen IPClient enth"alt, mu\s
836 	// dem dazugeh"origen Objekt durch SetTopToolFramePixel der zur Verf"ugung
837 	// stehende Platz zugeteilt werden. Das Objekt zeigt dann seine UITools an
838 	// und setzt den App-Border(->SfxInPlaceEnv_Impl::ArrangeChilds_Impl()).
839 	// Anderenfalls wird hier direkt der AppBorder gesetzt, um evtl. den Border
840 	// zu "uberschreiben, den bisher ein Objekt aus einem anderen Dokument
841 	// gesetzt hatte.
842 	// Das Objekt setzt, wenn es seine UI-Tools wegnimmt, den SetAppBorder nicht,
843 	// damit kein ObjectBar-Zappeln entsteht.
844 	// (->SfxInPlaceEnv_Impl::ArrangeChilds_Impl())
845 
846     pMasterFrame->SetToolSpaceBorderPixel_Impl( aBorder );
847 
848     ArrangeAutoHideWindows( NULL );
849 }
850 
851 //--------------------------------------------------------------------
852 
Arrange_Impl()853 SvBorder SfxWorkWindow::Arrange_Impl()
854 
855 /*	[Beschreibung]
856 
857 	Diese Methode ordnet alle sichtbaren ChildFenster so an, da\s die angedockten
858 	Fenster nach der Sorierreihenfolge von au\sen nach innen aneinander
859 	gesetzt werden. Wenn ein an sich sichtbares Fenster nicht mehr in die
860 	noch freie ClientArea pa\st, wird es auf "nicht sichtbar" gesetzt.
861 
862 */
863 {
864     DBG_CHKTHIS(SfxWorkWindow, 0);
865 
866     aClientArea = GetTopRect_Impl();
867     aUpperClientArea = aClientArea;
868 
869     SvBorder aBorder;
870     if ( !nChilds )
871         return aBorder;
872 
873     if (!bSorted)
874         Sort_Impl();
875 
876     Point aPos;
877     Size aSize;
878     Rectangle aTmp( aClientArea );
879 
880     for ( sal_uInt16 n=0; n<aSortedList.Count(); ++n )
881     {
882         SfxChild_Impl* pCli = (*pChilds)[aSortedList[n]];
883         if ( !pCli->pWin )
884             continue;
885 
886         // Zun"achst nehmen wir an, da\s das Fenster Platz hat
887         pCli->nVisible |= CHILD_FITS_IN;
888 
889         // Nicht sichtbare Fenster "uberspringen
890         if (pCli->nVisible != CHILD_VISIBLE)
891             continue;
892 
893         if ( pCli->bResize )
894             aSize = pCli->aSize;
895         else
896             aSize = pCli->pWin->GetSizePixel();
897 
898         SvBorder aTemp = aBorder;
899         sal_Bool bAllowHiding = sal_True;
900         switch ( pCli->eAlign )
901         {
902             case SFX_ALIGN_HIGHESTTOP:
903             case SFX_ALIGN_TOP:
904             case SFX_ALIGN_TOOLBOXTOP:
905             case SFX_ALIGN_LOWESTTOP:
906                 aSize.Width() = aTmp.GetWidth();
907                 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
908                     aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
909                 bAllowHiding = sal_False;
910                 aBorder.Top() += aSize.Height();
911                 aPos = aTmp.TopLeft();
912                 aTmp.Top() += aSize.Height();
913                 if ( pCli->eAlign == SFX_ALIGN_HIGHESTTOP )
914                     aUpperClientArea.Top() += aSize.Height();
915                 break;
916 
917             case SFX_ALIGN_LOWESTBOTTOM:
918             case SFX_ALIGN_BOTTOM:
919             case SFX_ALIGN_TOOLBOXBOTTOM:
920             case SFX_ALIGN_HIGHESTBOTTOM:
921                 aSize.Width() = aTmp.GetWidth();
922                 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
923                     aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
924                 aBorder.Bottom() += aSize.Height();
925                 aPos = aTmp.BottomLeft();
926                 aPos.Y() -= (aSize.Height()-1);
927                 aTmp.Bottom() -= aSize.Height();
928                 if ( pCli->eAlign == SFX_ALIGN_LOWESTBOTTOM )
929                     aUpperClientArea.Bottom() -= aSize.Height();
930                 break;
931 
932             case SFX_ALIGN_FIRSTLEFT:
933             case SFX_ALIGN_LEFT:
934             case SFX_ALIGN_LASTLEFT:
935             case SFX_ALIGN_TOOLBOXLEFT:
936                 aSize.Height() = aTmp.GetHeight();
937                 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
938                     aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
939                 bAllowHiding = sal_False;
940                 aBorder.Left() += aSize.Width();
941                 aPos = aTmp.TopLeft();
942                 aTmp.Left() += aSize.Width();
943                 if ( pCli->eAlign != SFX_ALIGN_TOOLBOXLEFT )
944                     aUpperClientArea.Left() += aSize.Width();
945                 break;
946 
947             case SFX_ALIGN_FIRSTRIGHT:
948             case SFX_ALIGN_RIGHT:
949             case SFX_ALIGN_LASTRIGHT:
950             case SFX_ALIGN_TOOLBOXRIGHT:
951                 aSize.Height() = aTmp.GetHeight();
952                 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
953                     aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
954                 aBorder.Right() += aSize.Width();
955                 aPos = aTmp.TopRight();
956                 aPos.X() -= (aSize.Width()-1);
957                 aTmp.Right() -= aSize.Width();
958                 if ( pCli->eAlign != SFX_ALIGN_TOOLBOXRIGHT )
959                     aUpperClientArea.Right() -= aSize.Width();
960                 break;
961 
962             default:
963                 pCli->aSize = pCli->pWin->GetSizePixel();
964                 pCli->bResize = sal_False;
965                 continue;
966         }
967 
968         pCli->pWin->SetPosSizePixel( aPos, aSize );
969         pCli->bResize = sal_False;
970         pCli->aSize = aSize;
971         if( bAllowHiding && !RequestTopToolSpacePixel_Impl( aBorder ) )
972         {
973             pCli->nVisible ^= CHILD_FITS_IN;
974             aBorder = aTemp;
975         }
976     }
977 
978     if ( aClientArea.GetWidth() >= aBorder.Left() + aBorder.Right() )
979     {
980         aClientArea.Left() += aBorder.Left();
981         aClientArea.Right() -= aBorder.Right();
982     }
983     else
984     {
985         aBorder.Left() = aClientArea.Left();
986         aBorder.Right() = aClientArea.Right();
987         aClientArea.Right() = aClientArea.Left() = aTmp.Left();
988     }
989 
990     if ( aClientArea.GetHeight() >= aBorder.Top() + aBorder.Bottom() )
991     {
992         aClientArea.Top() += aBorder.Top();
993         aClientArea.Bottom() -= aBorder.Bottom();
994     }
995     else
996     {
997         aBorder.Top() = aClientArea.Top();
998         aBorder.Bottom() = aClientArea.Bottom();
999         aClientArea.Top() = aClientArea.Bottom() = aTmp.Top();
1000     }
1001 
1002     return IsDockingAllowed() ? aBorder : SvBorder();
1003 }
1004 
1005 //--------------------------------------------------------------------
1006 // Close-Handler: die Konfiguration der ChildWindows wird gespeichert.
1007 //
1008 
Close_Impl()1009 void SfxWorkWindow::Close_Impl()
1010 {
1011 	for (sal_uInt16 n=0; n<pChildWins->Count(); n++)
1012 	{
1013 		SfxChildWin_Impl *pCW  = (*pChildWins)[n];
1014 		SfxChildWindow *pChild = pCW->pWin;
1015 		if (pChild)
1016 		{
1017             sal_uInt16 nFlags = pCW->aInfo.nFlags;
1018 			pCW->aInfo = pChild->GetInfo();
1019             pCW->aInfo.nFlags |= nFlags;
1020 			SaveStatus_Impl(pChild, pCW->aInfo);
1021 		}
1022 	}
1023 }
1024 
PrepareClose_Impl()1025 sal_Bool SfxWorkWindow::PrepareClose_Impl()
1026 {
1027 	for (sal_uInt16 n=0; n<pChildWins->Count(); n++)
1028 	{
1029 		SfxChildWin_Impl *pCW  = (*pChildWins)[n];
1030 		SfxChildWindow *pChild = pCW->pWin;
1031 		if ( pChild && !pChild->QueryClose() )
1032 			return sal_False;
1033 	}
1034 
1035 	return sal_True;
1036 }
1037 
1038 //--------------------------------------------------------------------
1039 
RegisterChild_Impl(Window & rWindow,SfxChildAlignment eAlign,sal_Bool bCanGetFocus)1040 SfxChild_Impl* SfxWorkWindow::RegisterChild_Impl( Window& rWindow,
1041 					SfxChildAlignment eAlign, sal_Bool bCanGetFocus )
1042 {
1043 	DBG_CHKTHIS(SfxWorkWindow, 0);
1044 	DBG_ASSERT( pChilds->Count() < 255, "too many childs" );
1045 	DBG_ASSERT( SfxChildAlignValid(eAlign), "invalid align" );
1046 	DBG_ASSERT( !FindChild_Impl(rWindow), "child registered more than once" );
1047 
1048 
1049 	if ( rWindow.GetParent() != pWorkWin )
1050 		rWindow.SetParent( pWorkWin );
1051 
1052 	SfxChild_Impl *pChild = new SfxChild_Impl(rWindow, rWindow.GetSizePixel(),
1053 									eAlign, rWindow.IsVisible());
1054 	pChild->bCanGetFocus = bCanGetFocus;
1055 
1056 	pChilds->Insert(pChilds->Count(), pChild);
1057 	bSorted = sal_False;
1058 	nChilds++;
1059 	return (*pChilds)[pChilds->Count()-1];
1060 }
1061 
1062 //--------------------------------------------------------------------
1063 
AlignChild_Impl(Window & rWindow,const Size & rNewSize,SfxChildAlignment eAlign)1064 void SfxWorkWindow::AlignChild_Impl( Window& rWindow,
1065 											const Size& rNewSize,
1066 											SfxChildAlignment eAlign )
1067 {
1068 	DBG_CHKTHIS(SfxWorkWindow, 0);
1069 //	DBG_ASSERT( pChilds, "aligning unregistered child" );
1070 	DBG_ASSERT( SfxChildAlignValid(eAlign), "invalid align" );
1071 
1072 	SfxChild_Impl *pChild = FindChild_Impl(rWindow);
1073 	if ( pChild )
1074 	{
1075 		if (pChild->eAlign != eAlign)
1076 			bSorted = sal_False;
1077 
1078 		pChild->eAlign = eAlign;
1079 		pChild->aSize = rNewSize;
1080 		pChild->bResize = sal_True;
1081 	}
1082 	else {
1083 		DBG_ERROR( "aligning unregistered child" );
1084     }
1085 }
1086 
1087 //--------------------------------------------------------------------
1088 
ReleaseChild_Impl(Window & rWindow)1089 void SfxWorkWindow::ReleaseChild_Impl( Window& rWindow )
1090 {
1091 	DBG_CHKTHIS(SfxWorkWindow, 0);
1092 //	DBG_ASSERT( pChilds, "releasing unregistered child" );
1093 
1094 	SfxChild_Impl *pChild = 0;
1095 	sal_uInt16 nPos;
1096     for ( nPos = 0; nPos < pChilds->Count(); ++nPos )
1097 	{
1098 		pChild = (*pChilds)[nPos];
1099 		if ( pChild )
1100 		  if ( pChild->pWin == &rWindow )
1101 			break;
1102 	}
1103 
1104     if ( nPos < pChilds->Count() )
1105 	{
1106 		bSorted = sal_False;
1107 		nChilds--;
1108 		pChilds->Remove(nPos);
1109 		delete pChild;
1110 	}
1111 	else {
1112 		DBG_ERROR( "releasing unregistered child" );
1113     }
1114 }
1115 
1116 //--------------------------------------------------------------------
1117 
FindChild_Impl(const Window & rWindow) const1118 SfxChild_Impl* SfxWorkWindow::FindChild_Impl( const Window& rWindow ) const
1119 {
1120 	DBG_CHKTHIS(SfxWorkWindow, 0);
1121 
1122 	SfxChild_Impl *pChild = 0;
1123 	sal_uInt16 nCount = pChilds->Count();
1124 	for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
1125 	{
1126 		pChild = (*pChilds)[nPos];
1127 		if ( pChild )
1128 		  if ( pChild->pWin == &rWindow )
1129 			return pChild;
1130 	}
1131 
1132 	return 0;
1133 }
1134 
1135 //--------------------------------------------------------------------
1136 
ShowChilds_Impl()1137 void SfxWorkWindow::ShowChilds_Impl()
1138 {
1139 	DBG_CHKTHIS(SfxWorkWindow, 0);
1140 
1141     bool bInvisible = ( !IsVisible_Impl() || ( !pWorkWin->IsReallyVisible() && !pWorkWin->IsReallyShown() ));
1142 
1143     SfxChild_Impl *pCli = 0;
1144 	for ( sal_uInt16 nPos = 0; nPos < pChilds->Count(); ++nPos )
1145 	{
1146         SfxChildWin_Impl* pCW = 0;
1147 		pCli = (*pChilds)[nPos];
1148 
1149         if ( pCli && pCli->pWin )
1150         {
1151             // We have to find the SfxChildWin_Impl to retrieve the
1152             // SFX_CHILDWIN flags that can influence visibility.
1153             for (sal_uInt16 n=0; n<pChildWins->Count(); n++)
1154 	        {
1155                 SfxChildWin_Impl* pCWin = (*pChildWins)[n];
1156                 SfxChild_Impl*    pChild  = pCWin->pCli;
1157                 if ( pChild == pCli )
1158                 {
1159                     pCW = pCWin;
1160                     break;
1161                 }
1162             }
1163 
1164             bool bVisible( !bInvisible );
1165             if ( pCW )
1166 		    {
1167                 // Check flag SFX_CHILDWIN_NEVERHIDE that forces us to show
1168                 // the child window even in situations where no child window is
1169                 // visible.
1170                 sal_uInt16 nFlags = pCW->aInfo.nFlags;
1171                 bVisible = !bInvisible || ( bInvisible & (( nFlags & SFX_CHILDWIN_NEVERHIDE ) != 0 ));
1172             }
1173 
1174             if ( CHILD_VISIBLE == (pCli->nVisible & CHILD_VISIBLE) && bVisible )
1175 		    {
1176 			    sal_uInt16 nFlags = pCli->bSetFocus ? 0 : SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE;
1177                 switch ( pCli->pWin->GetType() )
1178 			    {
1179 				    case RSC_DOCKINGWINDOW :
1180                         ((DockingWindow*)pCli->pWin)->Show( sal_True, nFlags );
1181 					    break;
1182 				    case RSC_SPLITWINDOW :
1183                         ((SplitWindow*)pCli->pWin)->Show( sal_True, nFlags );
1184 					    break;
1185 				    default:
1186                         pCli->pWin->Show( sal_True, nFlags );
1187 					    break;
1188 			    }
1189 
1190 			    pCli->bSetFocus = sal_False;
1191 		    }
1192 		    else
1193 		    {
1194 			    switch ( pCli->pWin->GetType() )
1195 			    {
1196 				    case RSC_DOCKINGWINDOW :
1197 					    ((DockingWindow*)pCli->pWin)->Hide();
1198 					    break;
1199 				    default:
1200 					    pCli->pWin->Hide();
1201 					    break;
1202 			    }
1203 		    }
1204         }
1205 	}
1206 }
1207 
1208 //--------------------------------------------------------------------
1209 
HideChilds_Impl()1210 void SfxWorkWindow::HideChilds_Impl()
1211 {
1212 	SfxChild_Impl *pChild = 0;
1213 	for ( sal_uInt16 nPos = pChilds->Count(); nPos > 0; --nPos )
1214 	{
1215 		pChild = (*pChilds)[nPos-1];
1216 		if (pChild && pChild->pWin)
1217 		{
1218 			switch ( pChild->pWin->GetType() )
1219 			{
1220 				case RSC_DOCKINGWINDOW :
1221 					((DockingWindow*)pChild->pWin)->Hide();
1222 					break;
1223 				default:
1224 					pChild->pWin->Hide();
1225 					break;
1226 			}
1227 		}
1228 	}
1229 }
1230 
1231 //------------------------------------------------------------------------
1232 
ResetObjectBars_Impl()1233 void SfxWorkWindow::ResetObjectBars_Impl()
1234 {
1235 	sal_uInt16 n;
1236     for ( n = 0; n < aObjBarList.size(); n++ )
1237         aObjBarList[n].bDestroy = sal_True;
1238 
1239 	for ( n = 0; n < pChildWins->Count(); ++n )
1240 		(*pChildWins)[n]->nId = 0;
1241 }
1242 
NextObjectBar_Impl(sal_uInt16)1243 void SfxWorkWindow::NextObjectBar_Impl( sal_uInt16 )
1244 {
1245 }
1246 
HasNextObjectBar_Impl(sal_uInt16,String *)1247 sal_uInt16 SfxWorkWindow::HasNextObjectBar_Impl( sal_uInt16, String* )
1248 {
1249 	return 0;
1250 }
1251 
1252 //------------------------------------------------------------------------
1253 
SetObjectBar_Impl(sal_uInt16 nPos,sal_uInt32 nResId,SfxInterface * pIFace,const String * pName)1254 void SfxWorkWindow::SetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId,
1255 			SfxInterface* pIFace, const String *pName)
1256 {
1257 	DBG_ASSERT( (nPos & SFX_POSITION_MASK) < SFX_OBJECTBAR_MAX,
1258 				"object bar position overflow" );
1259 
1260 	sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK;
1261 	if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) )
1262 	{
1263 		pParent->SetObjectBar_Impl( nPos, nResId, pIFace, pName );
1264 		return;
1265 	}
1266 
1267 	SfxObjectBar_Impl aObjBar;
1268 	aObjBar.pIFace = pIFace;
1269 	aObjBar.nId = sal::static_int_cast<sal_uInt16>(nResId);
1270     aObjBar.nPos = nRealPos;
1271 	aObjBar.nMode = (nPos & SFX_VISIBILITY_MASK);
1272 	if (pName)
1273 		aObjBar.aName = *pName;
1274 	else
1275 		aObjBar.aName.Erase();
1276 
1277 	for ( sal_uInt16 n=0; n<aObjBarList.size(); n++ )
1278 	{
1279 		if ( aObjBarList[n].nId == aObjBar.nId )
1280 		{
1281             aObjBarList[n] = aObjBar;
1282 			return;
1283 		}
1284 	}
1285 
1286     aObjBarList.push_back( aObjBar );
1287 }
1288 
1289 //------------------------------------------------------------------------
1290 
KnowsObjectBar_Impl(sal_uInt16 nPos) const1291 bool SfxWorkWindow::KnowsObjectBar_Impl( sal_uInt16 nPos ) const
1292 
1293 /*	[Beschreibung]
1294 
1295 	Stellt fest, ob an der betreffenden Position "uberhaupt eine
1296 	Objektleiste zur Verf"ugung stehen w"urde. Ist unabh"agig davon,
1297 	ob diese tats"achlich ein- oder ausgeschaltet ist.
1298 */
1299 
1300 {
1301 	sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK;
1302 	if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) )
1303 		return pParent->KnowsObjectBar_Impl( nPos );
1304 
1305 	for ( sal_uInt16 n=0; n<aObjBarList.size(); n++ )
1306     {
1307         if ( aObjBarList[n].nPos == nRealPos )
1308             return true;
1309     }
1310 
1311     return false;
1312 }
1313 
1314 //------------------------------------------------------------------------
1315 
IsVisible_Impl(sal_uInt16 nMode) const1316 sal_Bool SfxWorkWindow::IsVisible_Impl( sal_uInt16 nMode ) const
1317 {
1318 	switch( nUpdateMode )
1319 	{
1320 		case SFX_VISIBILITY_STANDARD:
1321 			return sal_True;
1322 		case SFX_VISIBILITY_UNVISIBLE:
1323 			return sal_False;
1324 		case SFX_VISIBILITY_PLUGSERVER:
1325 		case SFX_VISIBILITY_PLUGCLIENT:
1326 		case SFX_VISIBILITY_CLIENT:
1327 		case SFX_VISIBILITY_SERVER:
1328 			return !!(nMode & nUpdateMode);
1329 		default:
1330 			return !!(nMode & nOrigMode ) ||
1331 				nOrigMode == SFX_VISIBILITY_STANDARD;
1332 	}
1333 }
1334 
GetObjectBar_Impl(sal_uInt16,sal_uInt32)1335 Window* SfxWorkWindow::GetObjectBar_Impl( sal_uInt16, sal_uInt32 )
1336 {
1337     return NULL;
1338 }
1339 
1340 //------------------------------------------------------------------------
UpdateObjectBars_Impl()1341 void SfxFrameWorkWin_Impl::UpdateObjectBars_Impl()
1342 {
1343     if ( pFrame->IsClosing_Impl() )
1344         return;
1345 
1346 	SfxWorkWindow *pWork = pParent;
1347 	while ( pWork )
1348 	{
1349 		pWork->SfxWorkWindow::UpdateObjectBars_Impl();
1350 		pWork = pWork->GetParent_Impl();
1351 	}
1352 
1353 	SfxWorkWindow::UpdateObjectBars_Impl();
1354 
1355 //	if ( pTask->IsActive() )
1356 	{
1357 		pWork = pParent;
1358 		while ( pWork )
1359 		{
1360 			pWork->ArrangeChilds_Impl();
1361 			pWork = pWork->GetParent_Impl();
1362 		}
1363 
1364 		ArrangeChilds_Impl( sal_False );
1365 
1366 		pWork = pParent;
1367 		while ( pWork )
1368 		{
1369 			pWork->ShowChilds_Impl();
1370 			pWork = pWork->GetParent_Impl();
1371 		}
1372 
1373 		ShowChilds_Impl();
1374 	}
1375 
1376     ShowChilds_Impl();
1377 }
1378 
GetStatusIndicator()1379 Reference< ::com::sun::star::task::XStatusIndicator > SfxWorkWindow::GetStatusIndicator()
1380 {
1381     Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1382     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1383     Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
1384 
1385 	if ( xPropSet.is() )
1386 	{
1387 		Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1388 		aValue >>= xLayoutManager;
1389         if ( xLayoutManager.is() )
1390         {
1391             xLayoutManager->createElement( m_aProgressBarResName );
1392             xLayoutManager->showElement( m_aProgressBarResName );
1393 
1394             Reference< ::com::sun::star::ui::XUIElement > xProgressBar =
1395                 xLayoutManager->getElement( m_aProgressBarResName );
1396             if ( xProgressBar.is() )
1397             {
1398                 xStatusIndicator = Reference< ::com::sun::star::task::XStatusIndicator >(
1399                     xProgressBar->getRealInterface(), UNO_QUERY );
1400             }
1401         }
1402     }
1403 
1404     return xStatusIndicator;
1405 }
1406 
1407 //------------------------------------------------------------------------
1408 
IsPluginMode(SfxObjectShell * pObjShell)1409 sal_Bool SfxWorkWindow::IsPluginMode( SfxObjectShell* pObjShell )
1410 {
1411     if ( pObjShell && pObjShell->GetMedium() )
1412     {
1413         SFX_ITEMSET_ARG( pObjShell->GetMedium()->GetItemSet(), pViewOnlyItem, SfxBoolItem, SID_VIEWONLY, sal_False );
1414         if ( pViewOnlyItem && pViewOnlyItem->GetValue() )
1415             return sal_True;
1416     }
1417 
1418     return sal_False;
1419 }
1420 
1421 //------------------------------------------------------------------------
1422 
GetFrameInterface()1423 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxWorkWindow::GetFrameInterface()
1424 {
1425     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
1426 
1427     SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
1428     if ( pDispatcher )
1429     {
1430         SfxViewFrame* pFrame = pDispatcher->GetFrame();
1431         if ( pFrame )
1432            xFrame = pFrame->GetFrame().GetFrameInterface();
1433     }
1434 
1435     return xFrame;
1436 }
1437 
1438 //------------------------------------------------------------------------
1439 
UpdateObjectBars_Impl()1440 void SfxWorkWindow::UpdateObjectBars_Impl()
1441 {
1442 	// SplitWindows locken (d.h. Resize-Reaktion an den
1443 	// DockingWindows unterdr"ucken)
1444     sal_uInt16 n;
1445     for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
1446     {
1447         SfxSplitWindow *p = pSplit[n];
1448         if (p->GetWindowCount())
1449             p->Lock();
1450     }
1451 
1452     // was man so "ofters braucht, merkt man sich (spart Code und Laufzeit)
1453     SFX_APP();
1454 
1455     Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1456     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1457 
1458 	if ( xPropSet.is() )
1459 	{
1460 		Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1461 		aValue >>= xLayoutManager;
1462     }
1463 
1464     if ( !xLayoutManager.is() )
1465         return;
1466 
1467     sal_Bool       bPluginMode( sal_False );
1468     SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
1469 
1470     if ( pDispatcher )
1471     {
1472         SfxViewFrame* pFrame = pDispatcher->GetFrame();
1473         if ( pFrame )
1474            bPluginMode = IsPluginMode( pFrame->GetObjectShell() );
1475     }
1476 
1477     // "uber alle Toolboxen iterieren
1478     xLayoutManager->lock();
1479 	for ( n = 0; n < aObjBarList.size(); ++n )
1480 	{
1481         sal_uInt16      nId      = aObjBarList[n].nId;
1482         sal_Bool    bDestroy = aObjBarList[n].bDestroy;
1483 
1484         // die Modi bestimmen, f"ur die die ToolBox gilt
1485         sal_uInt16 nTbxMode = aObjBarList[n].nMode;
1486         bool bFullScreenTbx = SFX_VISIBILITY_FULLSCREEN ==
1487                                   ( nTbxMode & SFX_VISIBILITY_FULLSCREEN );
1488         nTbxMode &= ~SFX_VISIBILITY_FULLSCREEN;
1489 		nTbxMode &= ~SFX_VISIBILITY_VIEWER;
1490 
1491 		// wird in diesem Kontext eine ToolBox gefordert?
1492 		bool bModesMatching = ( nUpdateMode && ( nTbxMode & nUpdateMode) == nUpdateMode );
1493         if ( bDestroy )
1494         {
1495             rtl::OUString aTbxId( m_aTbxTypeName );
1496             aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1497             xLayoutManager->destroyElement( aTbxId );
1498         }
1499 		else if ( nId != 0 && ( ( bModesMatching && !bIsFullScreen ) ||
1500                                 ( bIsFullScreen && bFullScreenTbx ) ) )
1501         {
1502             rtl::OUString aTbxId( m_aTbxTypeName );
1503             aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1504             if ( !IsDockingAllowed() && !xLayoutManager->isElementFloating( aTbxId ))
1505                 xLayoutManager->destroyElement( aTbxId );
1506             else
1507             {
1508                 xLayoutManager->requestElement( aTbxId );
1509                 if ( bPluginMode )
1510                     xLayoutManager->lockWindow( aTbxId );
1511             }
1512         }
1513 		else if ( nId != 0 )
1514 		{
1515 		    // ggf. Toolbox an dieser Position l"oschen
1516             rtl::OUString aTbxId( m_aTbxTypeName );
1517             aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1518             xLayoutManager->destroyElement( aTbxId );
1519         }
1520 	}
1521 
1522 	UpdateStatusBar_Impl();
1523 
1524     // unlocking automatically forces Layout
1525     xLayoutManager->unlock();
1526 
1527 	UpdateChildWindows_Impl();
1528 
1529 	// SplitWindows wieder ent-locken
1530 	for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
1531 	{
1532 		SfxSplitWindow *p = pSplit[n];
1533 		if (p->GetWindowCount())
1534 			p->Lock(sal_False);
1535 	}
1536 }
1537 
AllowChildWindowCreation_Impl(const SfxChildWin_Impl & i_rCW) const1538 bool SfxWorkWindow::AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const
1539 {
1540     // or checking the availability of child windows, we need access to the module
1541     const SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
1542     const SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
1543     const SfxModule* pModule = pShell ? pShell->GetModule() : NULL;
1544     ENSURE_OR_RETURN( pModule, "SfxWorkWindow::UpdateChildWindows_Impl: did not find an SfxModule to ask for the child win availability!", true );
1545     return pModule->IsChildWindowAvailable( i_rCW.nId, pViewFrame );
1546 }
1547 
UpdateChildWindows_Impl()1548 void SfxWorkWindow::UpdateChildWindows_Impl()
1549 {
1550 	// alle vorhandenen oder in den Kontext gekommenen ChildWindows
1551 	for ( sal_uInt16 n=0; n<pChildWins->Count(); n++ )
1552 	{
1553 		SfxChildWin_Impl *pCW = (*pChildWins)[n];
1554 		SfxChildWindow *pChildWin = pCW->pWin;
1555 		sal_Bool bCreate = sal_False;
1556         if ( pCW->nId && !pCW->bDisabled  && (pCW->aInfo.nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE || IsVisible_Impl( pCW->nVisibility ) ) )
1557 		{
1558 			// Im Kontext ist ein geeignetes ChildWindow erlaubt;
1559 			// ist es auch eingeschaltet ?
1560 			if ( pChildWin == NULL && pCW->bCreate )
1561 			{
1562                 // Internal docking is only used for embedding into another
1563                 // container. We force the floating state of all floatable
1564                 // child windows.
1565                 if ( !bInternalDockingAllowed )
1566                 {
1567                     // Special case for all non-floatable child windows. We have
1568                     // to prevent the creation here!
1569                     bCreate = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
1570                 }
1571                 else if ( !IsDockingAllowed() || bIsFullScreen ) // || !bInternalDocking )
1572 				{
1573                     // im PresentationMode oder FullScreen nur FloatingWindows
1574 					SfxChildAlignment eAlign;
1575 					if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
1576 						bCreate = ( eAlign == SFX_ALIGN_NOALIGNMENT );
1577 				}
1578 				else
1579 					bCreate = sal_True;
1580 
1581                 if ( bCreate )
1582                     bCreate = AllowChildWindowCreation_Impl( *pCW );
1583 
1584 				// Momentan kein Fenster da, aber es ist eingeschaltet; Fenster
1585 				// und ggf. Context erzeugen
1586 				if ( bCreate )
1587                     CreateChildWin_Impl( pCW, sal_False );
1588 
1589 				if ( !bAllChildsVisible )
1590 				{
1591 					if ( pCW->pCli )
1592 						pCW->pCli->nVisible &= ~CHILD_ACTIVE;
1593 				}
1594 			}
1595 			else if ( pChildWin )
1596 			{
1597 				// Fenster existiert schon; soll es auch sichtbar sein ?
1598                 if ( ( !bIsFullScreen || pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT ) && bAllChildsVisible )
1599 				{
1600 					// Updatemode ist kompatibel; auf jeden Fall wieder einschalten
1601                     bCreate = AllowChildWindowCreation_Impl( *pCW );
1602                     if ( bCreate )
1603                     {
1604 					    if ( pCW->pCli )
1605 					    {
1606 						    // Fenster ist direktes Child
1607                             if ( bAllChildsVisible && ( (IsDockingAllowed() && bInternalDockingAllowed) || pCW->pCli->eAlign == SFX_ALIGN_NOALIGNMENT ) )
1608                                 pCW->pCli->nVisible |= CHILD_NOT_HIDDEN;
1609 					    }
1610                         else
1611                         {
1612                             if ( pCW->bCreate && IsDockingAllowed() && bInternalDockingAllowed )
1613 						        // Fenster liegt in einem SplitWindow
1614 						        ((SfxDockingWindow*)pChildWin->GetWindow())->Reappear_Impl();
1615                         }
1616 
1617 					    if ( pCW->nInterfaceId != pChildWin->GetContextId() )
1618 						    pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
1619                     }
1620 				}
1621 			}
1622 		}
1623 
1624 		if ( pChildWin && !bCreate )
1625 		{
1626 			if ( !pChildWin->QueryClose() || pChildWin->IsHideNotDelete() || Application::IsUICaptured() )
1627 			{
1628 				if ( pCW->pCli )
1629 				{
1630 					if ( pCW->pCli->nVisible & CHILD_NOT_HIDDEN )
1631 						pCW->pCli->nVisible ^= CHILD_NOT_HIDDEN;
1632 				}
1633 				else
1634 					((SfxDockingWindow*)pChildWin->GetWindow())->Disappear_Impl();
1635 			}
1636 			else
1637 				RemoveChildWin_Impl( pCW );
1638 		}
1639 	}
1640 }
1641 
CreateChildWin_Impl(SfxChildWin_Impl * pCW,sal_Bool bSetFocus)1642 void SfxWorkWindow::CreateChildWin_Impl( SfxChildWin_Impl *pCW, sal_Bool bSetFocus )
1643 {
1644 	if ( pCW->aInfo.bVisible != 42 )
1645 		pCW->aInfo.bVisible = sal_True;
1646 
1647     SfxChildWindow *pChildWin = SfxChildWindow::CreateChildWindow( pCW->nId, pWorkWin, &GetBindings(), pCW->aInfo);
1648 	if (pChildWin)
1649 	{
1650 		if ( bSetFocus )
1651 			bSetFocus = pChildWin->WantsFocus();
1652 		pChildWin->SetWorkWindow_Impl( this );
1653 #if 0
1654 		// Enable-Status richtig setzen
1655 		pChildWin->GetWindow()->EnableInput( pCW->bEnable &&
1656             ( pWorkWin->IsInputEnabled() /* || pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT */ ) );
1657 #endif
1658 		// Zumindest der ExtraString wird beim Auswerten ver"andert, also neu holen
1659         SfxChildWinInfo aInfo = pChildWin->GetInfo();
1660         pCW->aInfo.aExtraString = aInfo.aExtraString;
1661         pCW->aInfo.bVisible = aInfo.bVisible;
1662         pCW->aInfo.nFlags |= aInfo.nFlags;
1663 
1664 		// Nein !! Sonst kann man keine Fenster defaultmaessig ausschalten ( Partwindow! )
1665 //		pCW->aInfo.bVisible = sal_True;
1666 
1667 		// Erzeugung war erfolgreich
1668 		GetBindings().Invalidate(pCW->nId);
1669 
1670 		sal_uInt16 nPos = pChildWin->GetPosition();
1671 		if (nPos != CHILDWIN_NOPOS)
1672 		{
1673 			DBG_ASSERT(nPos < SFX_OBJECTBAR_MAX, "Illegal objectbar position!");
1674 			if ((*pChilds)[TbxMatch(nPos)])// &&
1675 //							  pChildWin->GetAlignment() == (*pChilds)[nPos]->eAlign )
1676 			{
1677 				// ChildWindow ersetzt ObjectBar
1678 				(*pChilds)[TbxMatch(nPos)]->nVisible ^= CHILD_NOT_HIDDEN;
1679 			}
1680 		}
1681 
1682 		// make childwin keyboard accessible
1683 		pWorkWin->GetSystemWindow()->GetTaskPaneList()->AddWindow( pChildWin->GetWindow() );
1684 
1685 		pCW->pWin = pChildWin;
1686 
1687 		if ( pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT || pChildWin->GetWindow()->GetParent() == pWorkWin)
1688 		{
1689 			// Das Fenster ist entweder nicht angedockt oder au\serhalb
1690 			// eines SplitWindows angedockt und mu\s daher explizit als
1691 			// Child registriert werden
1692 			pCW->pCli = RegisterChild_Impl(*(pChildWin->GetWindow()), pChildWin->GetAlignment(), pChildWin->CanGetFocus());
1693 			pCW->pCli->nVisible = CHILD_VISIBLE;
1694             if ( pChildWin->GetAlignment() != SFX_ALIGN_NOALIGNMENT && bIsFullScreen )
1695 				pCW->pCli->nVisible ^= CHILD_ACTIVE;
1696 			pCW->pCli->bSetFocus = bSetFocus;
1697 		}
1698 		else
1699 		{
1700 			// Ein angedocktes Fenster, dessen Parent nicht das WorkWindow ist,
1701 			// mu\s in einem SplitWindow liegen und daher nicht explizit
1702 			// registriert werden.
1703 			// Das passiert aber schon bei der Initialisierung des
1704 			// SfxDockingWindows!
1705 		}
1706 
1707 		if ( pCW->nInterfaceId != pChildWin->GetContextId() )
1708 			pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
1709 
1710 		// Information in der INI-Datei sichern
1711         SaveStatus_Impl(pChildWin, pCW->aInfo);
1712 	}
1713 }
1714 
RemoveChildWin_Impl(SfxChildWin_Impl * pCW)1715 void SfxWorkWindow::RemoveChildWin_Impl( SfxChildWin_Impl *pCW )
1716 {
1717 	sal_uInt16 nId = pCW->nSaveId;
1718 	SfxChildWindow *pChildWin = pCW->pWin;
1719 
1720 	// vorhandenes Fenster geht aus dem Kontext und wird daher entfernt
1721 	sal_uInt16 nPos = pChildWin->GetPosition();
1722 	if (nPos != CHILDWIN_NOPOS)
1723 	{
1724 /*
1725 		// ChildWindow "uberlagert einen ObjectBar
1726 		DBG_ASSERT(nPos < SFX_OBJECTBAR_MAX, "Illegal objectbar position!");
1727 		if ((*pChilds)[TbxMatch(nPos)] &&
1728 			(aObjBars[nPos].nMode & nUpdateMode) ) //&&
1729 //						   pChildWin->GetAlignment() == (*pChilds)[nPos]->eAlign )
1730 		{
1731 			// ObjectBar war "uberlagert; jetzt wieder anzeigen
1732 			(*pChilds)[TbxMatch(nPos)]->nVisible ^= CHILD_NOT_HIDDEN;
1733 		}
1734 */
1735 	}
1736 
1737 	// Information in der INI-Datei sichern
1738     sal_uInt16 nFlags = pCW->aInfo.nFlags;
1739     pCW->aInfo = pChildWin->GetInfo();
1740     pCW->aInfo.nFlags |= nFlags;
1741 	SaveStatus_Impl(pChildWin, pCW->aInfo);
1742 
1743 	pChildWin->Hide();
1744 
1745 	if ( pCW->pCli )
1746 	{
1747 		// ChildWindow ist ein direktes ChildWindow und mu\s sich daher
1748 		// beim WorkWindow abmelden
1749 		pCW->pCli = 0;
1750 		ReleaseChild_Impl(*pChildWin->GetWindow());
1751 	}
1752 	else
1753 	{
1754 		// ChildWindow liegt in einem SplitWindow und meldet sich
1755 		// selbst im dtor dort ab
1756 	}
1757 
1758 	pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChildWin->GetWindow() );
1759 	pCW->pWin = 0;
1760 	pChildWin->Destroy();
1761 
1762 	GetBindings().Invalidate( nId );
1763 }
1764 
ResetStatusBar_Impl()1765 void SfxWorkWindow::ResetStatusBar_Impl()
1766 {
1767 	aStatBar.nId = 0;
1768 }
1769 
1770 //--------------------------------------------------------------------
SetStatusBar_Impl(sal_uInt32 nResId,SfxShell *,SfxBindings &)1771 void SfxWorkWindow::SetStatusBar_Impl( sal_uInt32 nResId, SfxShell*, SfxBindings& )
1772 {
1773     if ( nResId && bShowStatusBar && IsVisible_Impl() )
1774 		aStatBar.nId = sal::static_int_cast<sal_uInt16>(nResId);
1775 }
1776 
1777 #define SFX_ITEMTYPE_STATBAR 4
1778 
SetTempStatusBar_Impl(sal_Bool bSet)1779 void SfxWorkWindow::SetTempStatusBar_Impl( sal_Bool bSet )
1780 {
1781     if ( aStatBar.bTemp != bSet && bShowStatusBar && IsVisible_Impl() )
1782 	{
1783 		sal_Bool bOn = sal_False;
1784         sal_Bool bReset = sal_False;
1785         if ( bSet && !aStatBar.nId )
1786         {
1787             bReset = sal_True;
1788             SetStatusBar_Impl( SFX_ITEMTYPE_STATBAR, SFX_APP(), GetBindings() );
1789         }
1790 
1791         if ( aStatBar.nId && aStatBar.bOn && !bIsFullScreen )
1792 			bOn = sal_True;
1793 
1794 		aStatBar.bTemp = bSet;
1795         if ( !bOn || bReset || (!bSet && aStatBar.nId ) )
1796 		{
1797 			// Nur was tun, wenn die Temp-Einstellung wirklich was bewirkt
1798 			UpdateStatusBar_Impl();
1799 			ArrangeChilds_Impl();
1800 			ShowChilds_Impl();
1801 		}
1802 
1803         if ( bReset )
1804             ResetStatusBar_Impl();
1805 	}
1806 }
1807 
UpdateStatusBar_Impl()1808 void SfxWorkWindow::UpdateStatusBar_Impl()
1809 {
1810     Reference< ::com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1811     Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1812 
1813 	Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1814 	aValue >>= xLayoutManager;
1815 
1816 	// keine Statusleiste, wenn keine Id gew"unscht oder bei FullScreenView
1817 	// oder wenn ausgeschaltet
1818     if ( aStatBar.nId && IsDockingAllowed() && bInternalDockingAllowed && bShowStatusBar &&
1819          ( (aStatBar.bOn && !bIsFullScreen) || aStatBar.bTemp ) )
1820 	{
1821 		// Id hat sich ge"andert, also passenden Statusbarmanager erzeugen,
1822 		// dieser "ubernimmt die aktuelle Statusleiste;
1823         if ( xLayoutManager.is() )
1824             xLayoutManager->requestElement( m_aStatusBarResName );
1825 	}
1826 	else
1827 	{
1828 		// Aktuelle StatusBar vernichten
1829 		// Der Manager erzeugt die Statusleiste nur, er zerst"ort sie
1830 		// nicht !
1831         if ( xLayoutManager.is() )
1832             xLayoutManager->destroyElement( m_aStatusBarResName );
1833 	}
1834 }
1835 
1836 //------------------------------------------------------------------------
1837 /*
1838 void SfxWorkWindow::SetObjectBarVisibility_Impl( sal_uInt16 nMask )
1839 {
1840 	switch( nMask )
1841 	{
1842 		case SFX_VISIBILITY_UNVISIBLE:
1843 		case SFX_VISIBILITY_STANDARD:
1844 		case SFX_VISIBILITY_CLIENT:
1845 		case SFX_VISIBILITY_SERVER:
1846 			nOrigMode = nMask;
1847 	}
1848 	if (nMask != nUpdateMode)
1849 		nUpdateMode = nMask;
1850 }*/
1851 
MakeVisible_Impl(sal_Bool bVis)1852 void SfxWorkWindow::MakeVisible_Impl( sal_Bool bVis )
1853 {
1854     if ( bVis )
1855         nOrigMode = SFX_VISIBILITY_STANDARD;
1856     else
1857         nOrigMode = SFX_VISIBILITY_UNVISIBLE;
1858 
1859     if ( nOrigMode != nUpdateMode)
1860         nUpdateMode = nOrigMode;
1861 }
1862 
IsVisible_Impl()1863 sal_Bool SfxWorkWindow::IsVisible_Impl()
1864 {
1865     return nOrigMode != SFX_VISIBILITY_UNVISIBLE;
1866 }
1867 
1868 //------------------------------------------------------------------------
HidePopups_Impl(sal_Bool bHide,sal_Bool bParent,sal_uInt16 nId)1869 void SfxWorkWindow::HidePopups_Impl(sal_Bool bHide, sal_Bool bParent, sal_uInt16 nId )
1870 {
1871 	for ( sal_uInt16 n = 0; n < pChildWins->Count(); ++n )
1872 	{
1873 		SfxChildWindow *pCW = (*pChildWins)[n]->pWin;
1874 		if (pCW && pCW->GetAlignment() == SFX_ALIGN_NOALIGNMENT && pCW->GetType() != nId)
1875 		{
1876 			Window *pWin = pCW->GetWindow();
1877 			SfxChild_Impl *pChild = FindChild_Impl(*pWin);
1878 			if (bHide)
1879 			{
1880 				pChild->nVisible &= ~CHILD_ACTIVE;
1881 				pCW->Hide();
1882 			}
1883 			else
1884 			{
1885 				pChild->nVisible |= CHILD_ACTIVE;
1886 				if ( CHILD_VISIBLE == (pChild->nVisible & CHILD_VISIBLE) )
1887                     pCW->Show( SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1888 			}
1889 		}
1890 	}
1891 
1892 	if ( bParent && pParent )
1893 		pParent->HidePopups_Impl( bHide, bParent, nId );
1894 }
1895 
1896 //------------------------------------------------------------------------
1897 
ConfigChild_Impl(SfxChildIdentifier eChild,SfxDockingConfig eConfig,sal_uInt16 nId)1898 void SfxWorkWindow::ConfigChild_Impl(SfxChildIdentifier eChild,
1899 			SfxDockingConfig eConfig, sal_uInt16 nId)
1900 {
1901 	SfxDockingWindow* pDockWin=0;
1902 	sal_uInt16 nPos = USHRT_MAX;
1903 	Window *pWin=0;
1904 	SfxChildWin_Impl *pCW = 0;
1905 
1906     if ( eChild == SFX_CHILDWIN_OBJECTBAR )
1907 	{
1908         return;
1909 	}
1910 	else
1911 	{
1912         // configure direct childwindow
1913 		for (sal_uInt16 n=0; n<pChildWins->Count(); n++)
1914 		{
1915 			pCW = (*pChildWins)[n];
1916 			SfxChildWindow *pChild = pCW->pWin;
1917             if ( pChild )
1918 			{
1919                 if ( pChild->GetType() == nId )
1920 				{
1921                     if ( pChild->GetWindow()->GetType() == RSC_DOCKINGWINDOW )
1922                         // it's a DockingWindow
1923                         pDockWin = (SfxDockingWindow*) pChild->GetWindow();
1924                     else
1925                         // FloatingWindow or ModelessDialog
1926                         pWin = pChild->GetWindow();
1927 					break;
1928 				}
1929 			}
1930 		}
1931 
1932 		if ( pDockWin )
1933 		{
1934             if ( eChild == SFX_CHILDWIN_DOCKINGWINDOW || pDockWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT )
1935 			{
1936 				if ( eChild == SFX_CHILDWIN_SPLITWINDOW && eConfig == SFX_TOGGLEFLOATMODE)
1937 				{
1938                     // DockingWindow was dragged out of a SplitWindow
1939                     pCW->pCli = RegisterChild_Impl(*pDockWin, pDockWin->GetAlignment(), pCW->pWin->CanGetFocus());
1940 					pCW->pCli->nVisible = CHILD_VISIBLE;
1941 				}
1942 
1943 				pWin = pDockWin;
1944 			}
1945 			else
1946 			{
1947 				SfxSplitWindow *pSplitWin = GetSplitWindow_Impl(pDockWin->GetAlignment());
1948 
1949                 // configure DockingWindow inside a SplitWindow
1950 				if ( eConfig == SFX_TOGGLEFLOATMODE)
1951 				{
1952                     // DockingWindow was dragged into a SplitWindow
1953 					pCW->pCli = 0;
1954 					ReleaseChild_Impl(*pDockWin);
1955 				}
1956 
1957 				pWin = pSplitWin->GetSplitWindow();
1958 				if ( pSplitWin->GetWindowCount() == 1 )
1959                     ((SplitWindow*)pWin)->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1960 			}
1961 		}
1962 
1963         DBG_ASSERT( pCW, "Unknown window!" );
1964         if ( !pCW && pParent )
1965 		{
1966 			pParent->ConfigChild_Impl( eChild, eConfig, nId );
1967 			return;
1968 		}
1969 	}
1970 
1971     if ( !bSorted )
1972         // windows may have been registered and released without an update until now
1973 		Sort_Impl();
1974 
1975 	SfxChild_Impl *pChild = 0;
1976 	sal_uInt16 n;
1977 	for ( n=0; n<aSortedList.Count(); ++n )
1978 	{
1979 		pChild = (*pChilds)[aSortedList[n]];
1980 		if ( pChild )
1981 			if ( pChild->pWin == pWin )
1982 			break;
1983 	}
1984 
1985     if ( n < aSortedList.Count() )
1986         // sometimes called while toggeling float mode
1987         nPos = aSortedList[n];
1988 
1989 	switch ( eConfig )
1990 	{
1991 		case SFX_SETDOCKINGRECTS :
1992 		{
1993             if ( nPos == USHRT_MAX )
1994                 return;
1995 
1996 //			SfxChild_Impl *pChild = (*pChilds)[nPos];
1997 			Rectangle aOuterRect( GetTopRect_Impl() );
1998             aOuterRect.SetPos( pWorkWin->OutputToScreenPixel( aOuterRect.TopLeft() ));
1999             Rectangle aInnerRect( aOuterRect );
2000 			sal_Bool bTbx = (eChild == SFX_CHILDWIN_OBJECTBAR);
2001 
2002 			// Das gerade betroffene Fenster wird bei der Berechnung des
2003 			// inneren Rechtecks mit eingeschlossen!
2004 			for ( sal_uInt16 m=0; m<aSortedList.Count(); ++m )
2005 			{
2006 				sal_uInt16 i=aSortedList[m];
2007 				SfxChild_Impl* pCli = (*pChilds)[i];
2008 
2009                 if ( pCli && pCli->nVisible == CHILD_VISIBLE && pCli->pWin )
2010 				{
2011 					switch ( pCli->eAlign )
2012 					{
2013 						case SFX_ALIGN_TOP:
2014 							// Objekt-Toolboxen kommen immer zuletzt
2015 							//if ( bTbx || i <= nPos)
2016 								aInnerRect.Top() += pCli->aSize.Height();
2017 							break;
2018 
2019 						case SFX_ALIGN_TOOLBOXTOP:
2020 							// Toolbox geht nur vor, wenn nicht h"ohere Position
2021 							if ( bTbx && i <= nPos)
2022 								aInnerRect.Top() += pCli->aSize.Height();
2023 							break;
2024 
2025 						case SFX_ALIGN_HIGHESTTOP:
2026 							// Geht immer vor
2027 							aInnerRect.Top() += pCli->aSize.Height();
2028 							break;
2029 
2030 						case SFX_ALIGN_LOWESTTOP:
2031 							// Wird nur mitgez"ahlt, wenn es das aktuelle Fenster ist
2032 							if ( i == nPos )
2033 								aInnerRect.Top() += pCli->aSize.Height();
2034 							break;
2035 
2036 						case SFX_ALIGN_BOTTOM:
2037 							// Objekt-Toolboxen kommen immer zuletzt
2038 							//if ( bTbx || i <= nPos)
2039 								aInnerRect.Bottom() -= pCli->aSize.Height();
2040 							break;
2041 
2042 						case SFX_ALIGN_TOOLBOXBOTTOM:
2043 							// Toolbox geht nur vor, wenn nicht h"ohere Position
2044 							if ( bTbx && i <= nPos)
2045 								aInnerRect.Bottom() -= pCli->aSize.Height();
2046 							break;
2047 
2048 						case SFX_ALIGN_LOWESTBOTTOM:
2049 							// Geht immer vor
2050 							aInnerRect.Bottom() -= pCli->aSize.Height();
2051 							break;
2052 
2053 						case SFX_ALIGN_HIGHESTBOTTOM:
2054 							// Wird nur mitgez"ahlt, wenn es das aktuelle Fenster ist
2055 							if ( i == nPos )
2056 								aInnerRect.Bottom() -= pCli->aSize.Height();
2057 							break;
2058 
2059 						case SFX_ALIGN_LEFT:
2060 							// Toolboxen kommen immer zuletzt
2061 							//if (bTbx || i <= nPos)
2062 								aInnerRect.Left() += pCli->aSize.Width();
2063 							break;
2064 
2065 						case SFX_ALIGN_TOOLBOXLEFT:
2066 							// Toolboxen kommen immer zuletzt
2067 							if (bTbx && i <= nPos)
2068 								aInnerRect.Left() += pCli->aSize.Width();
2069 							break;
2070 
2071 						case SFX_ALIGN_FIRSTLEFT:
2072 							// Geht immer vor
2073 							aInnerRect.Left() += pCli->aSize.Width();
2074 							break;
2075 
2076 						case SFX_ALIGN_LASTLEFT:
2077 							// Wird nur mitgez"ahlt, wenn es das aktuelle Fenster ist
2078 							if (i == nPos)
2079 								aInnerRect.Left() += pCli->aSize.Width();
2080 
2081 						case SFX_ALIGN_RIGHT:
2082 							// Toolboxen kommen immer zuletzt
2083 							//if (bTbx || i <= nPos)
2084 								aInnerRect.Right() -= pCli->aSize.Width();
2085 							break;
2086 
2087 						case SFX_ALIGN_TOOLBOXRIGHT:
2088 							// Toolboxen kommen immer zuletzt
2089 							if (bTbx && i <= nPos)
2090 								aInnerRect.Right() -= pCli->aSize.Width();
2091 							break;
2092 
2093 						case SFX_ALIGN_FIRSTRIGHT:
2094 							// Wird nur mitgez"ahlt, wenn es das aktuelle Fenster ist
2095 							if (i == nPos)
2096 								aInnerRect.Right() -= pCli->aSize.Width();
2097 							break;
2098 
2099 						case SFX_ALIGN_LASTRIGHT:
2100 							// Geht immer vor
2101 							aInnerRect.Right() -= pCli->aSize.Width();
2102 							break;
2103 
2104 						default:
2105 							break;
2106 					}
2107 				}
2108 			}
2109 
2110             pDockWin->SetDockingRects(aOuterRect, aInnerRect);
2111 			break;
2112 		}
2113 
2114 		case SFX_MOVEDOCKINGWINDOW :
2115 		case SFX_ALIGNDOCKINGWINDOW :
2116 		case SFX_TOGGLEFLOATMODE:
2117 		{
2118             if ( nPos == USHRT_MAX && !pCW )
2119                 return;
2120 
2121             SfxChildAlignment eAlign = SFX_ALIGN_NOALIGNMENT;
2122             SfxChild_Impl *pCli = ( nPos != USHRT_MAX ) ? (*pChilds)[nPos] : 0;
2123             if ( pCli && pDockWin )
2124 			{
2125 				eAlign = pDockWin->GetAlignment();
2126                 if ( eChild == SFX_CHILDWIN_DOCKINGWINDOW || eAlign == SFX_ALIGN_NOALIGNMENT)
2127 				{
2128                     // configuration inside the SplitWindow, no change for the SplitWindows' configuration
2129 					pCli->bResize = sal_True;
2130 					pCli->aSize = pDockWin->GetSizePixel();
2131 				}
2132 			}
2133 
2134             if ( pCli )
2135             {
2136                 if( pCli->eAlign != eAlign )
2137                 {
2138                     bSorted = sal_False;
2139                     pCli->eAlign = eAlign;
2140                 }
2141 
2142                 ArrangeChilds_Impl();
2143                 ShowChilds_Impl();
2144             }
2145 
2146             if ( pCW && pCW->pWin )
2147 			{
2148                 // store changed configuration
2149                 sal_uInt16 nFlags = pCW->aInfo.nFlags;
2150                 pCW->aInfo = pCW->pWin->GetInfo();
2151                 pCW->aInfo.nFlags |= nFlags;
2152 				if ( eConfig != SFX_MOVEDOCKINGWINDOW )
2153 					SaveStatus_Impl( pCW->pWin, pCW->aInfo);
2154 			}
2155 
2156 			break;
2157 		}
2158 	}
2159 }
2160 
2161 
2162 //--------------------------------------------------------------------
2163 
SetChildWindowVisible_Impl(sal_uInt32 lId,sal_Bool bEnabled,sal_uInt16 nMode)2164 void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId, sal_Bool bEnabled, sal_uInt16 nMode )
2165 {
2166 	sal_uInt16 nInter = (sal_uInt16) ( lId >> 16 );
2167 	sal_uInt16 nId = (sal_uInt16) ( lId & 0xFFFF );
2168 
2169 	SfxChildWin_Impl *pCW=NULL;
2170 	SfxWorkWindow *pWork = pParent;
2171 
2172 	// Den obersten parent nehmen; ChildWindows werden immer am WorkWindow
2173 	// der Task bzw. des Frames oder am AppWorkWindow angemeldet
2174 	while ( pWork && pWork->pParent )
2175 		pWork = pWork->pParent;
2176 
2177 	if ( pWork )
2178 	{
2179 		// Dem Parent schon bekannt ?
2180 		sal_uInt16 nCount = pWork->pChildWins->Count();
2181 		for (sal_uInt16 n=0; n<nCount; n++)
2182 			if ((*pWork->pChildWins)[n]->nSaveId == nId)
2183 			{
2184 				pCW = (*pWork->pChildWins)[n];
2185 				break;
2186 			}
2187 	}
2188 
2189 	if ( !pCW )
2190 	{
2191 		// Kein Parent oder dem Parent noch unbekannt, dann bei mir suchen
2192 		sal_uInt16 nCount = pChildWins->Count();
2193 		for (sal_uInt16 n=0; n<nCount; n++)
2194 			if ((*pChildWins)[n]->nSaveId == nId)
2195 			{
2196 				pCW = (*pChildWins)[n];
2197 				break;
2198 			}
2199 	}
2200 
2201 	if ( !pCW )
2202 	{
2203 		// Ist neu, also initialisieren; je nach Flag beim Parent oder bei
2204 		// mir eintragen
2205 		pCW = new SfxChildWin_Impl( lId );
2206 		pCW->nId = nId;
2207 		InitializeChild_Impl( pCW );
2208 		if ( pWork && !( pCW->aInfo.nFlags & SFX_CHILDWIN_TASK ) )
2209 			pWork->pChildWins->Insert( pWork->pChildWins->Count(), pCW );
2210 		else
2211 			pChildWins->Insert( pChildWins->Count(), pCW );
2212 	}
2213 
2214 	pCW->nId = nId;
2215 	if ( nInter )
2216 		pCW->nInterfaceId = nInter;
2217 	pCW->nVisibility = nMode;
2218 	pCW->bEnable = bEnabled;
2219 #if 0
2220 	if ( pCW->pWin )
2221 		pCW->pWin->GetWindow()->EnableInput( bEnabled &&
2222             ( pWorkWin->IsInputEnabled() /* || pCW->pWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT */ ) );
2223 #endif
2224 	pCW->nVisibility = nMode;
2225 }
2226 
2227 //--------------------------------------------------------------------
2228 // Der An/Aus-Status eines ChildWindows wird umgeschaltet.
2229 
ToggleChildWindow_Impl(sal_uInt16 nId,sal_Bool bSetFocus)2230 void SfxWorkWindow::ToggleChildWindow_Impl(sal_uInt16 nId, sal_Bool bSetFocus)
2231 {
2232 	sal_uInt16 nCount = pChildWins->Count();
2233 	sal_uInt16 n;
2234 	for (n=0; n<nCount; n++)
2235 		if ((*pChildWins)[n]->nId == nId)
2236 			break;
2237 
2238 	if ( n<nCount )
2239 	{
2240 		// Das Fenster ist schon bekannt
2241 		SfxChildWin_Impl *pCW = (*pChildWins)[n];
2242 		SfxChildWindow *pChild = pCW->pWin;
2243 
2244         bool bCreationAllowed( true );
2245         if ( !bInternalDockingAllowed )
2246         {
2247             // Special case for all non-floatable child windows. We have
2248             // to prevent the creation here!
2249             bCreationAllowed = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
2250         }
2251 
2252         if ( bCreationAllowed )
2253         {
2254             if ( pCW->bCreate )
2255             {
2256                 if ( pChild )
2257 		        {
2258 			        if ( pChild->QueryClose() )
2259 			        {
2260 				        pCW->bCreate = sal_False;
2261 				        if ( pChild->IsHideAtToggle() )
2262 				        {
2263                             ShowChildWindow_Impl( nId, sal_False, bSetFocus );
2264 				        }
2265 				        else
2266 				        {
2267 					        // Fenster soll ausgeschaltet werdem
2268 					        pChild->SetVisible_Impl( sal_False );
2269 					        RemoveChildWin_Impl( pCW );
2270 				        }
2271 			        }
2272 		        }
2273                 else
2274                 {
2275                     // no actual Window exists, yet => just remember the "switched off" state
2276                     pCW->bCreate = sal_False;
2277                 }
2278             }
2279             else
2280 		    {
2281 			    pCW->bCreate = AllowChildWindowCreation_Impl( *pCW );
2282                 if ( pCW->bCreate )
2283                 {
2284 			        if ( pChild )
2285 			        {
2286                         ShowChildWindow_Impl( nId, sal_True, bSetFocus );
2287 			        }
2288 			        else
2289 			        {
2290 				        // create actual Window
2291 				        CreateChildWin_Impl( pCW, bSetFocus );
2292 				        if ( !pCW->pWin )
2293 					        // no success
2294 					        pCW->bCreate = sal_False;
2295 			        }
2296                 }
2297 		    }
2298         }
2299 
2300 		ArrangeChilds_Impl();
2301 		ShowChilds_Impl();
2302 
2303 		if ( pCW->bCreate && bCreationAllowed )
2304 		{
2305 			if ( !pCW->pCli )
2306 			{
2307 				SfxDockingWindow *pDock =
2308 					(SfxDockingWindow*) pCW->pWin->GetWindow();
2309                 if ( pDock->IsAutoHide_Impl() )
2310 					pDock->AutoShow_Impl();
2311 			}
2312 		}
2313 
2314 		return;
2315 	}
2316 	else if ( pParent )
2317 	{
2318         pParent->ToggleChildWindow_Impl( nId, bSetFocus );
2319 		return;
2320 	}
2321 
2322 #ifdef DBG_UTIL
2323 	nCount = pChildWins->Count();
2324 	for (n=0; n<nCount; n++)
2325 		if ((*pChildWins)[n]->nSaveId == nId)
2326 			break;
2327 
2328 	if ( n < nCount )
2329 	{
2330 		DBG_ERROR("ChildWindow ist nicht im Kontext!");
2331 	}
2332 	else
2333 	{
2334 		DBG_ERROR("ChildWindow ist nicht registriert!");
2335 	}
2336 #endif
2337 }
2338 
2339 //--------------------------------------------------------------------
2340 
HasChildWindow_Impl(sal_uInt16 nId)2341 sal_Bool SfxWorkWindow::HasChildWindow_Impl(sal_uInt16 nId)
2342 {
2343 	sal_uInt16 nCount = pChildWins->Count();
2344 	sal_uInt16 n;
2345 	for (n=0; n<nCount; n++)
2346 		if ((*pChildWins)[n]->nSaveId == nId)
2347 			break;
2348 
2349 	if (n<nCount)
2350 	{
2351 		SfxChildWin_Impl *pCW = (*pChildWins)[n];
2352 		SfxChildWindow *pChild = pCW->pWin;
2353 		return ( pChild && pCW->bCreate );
2354 	}
2355 
2356 	if ( pParent )
2357 		return pParent->HasChildWindow_Impl( nId );
2358 
2359 	return sal_False;
2360 }
2361 
IsFloating(sal_uInt16 nId)2362 sal_Bool SfxWorkWindow::IsFloating( sal_uInt16 nId )
2363 {
2364 	SfxChildWin_Impl *pCW=NULL;
2365 	SfxWorkWindow *pWork = pParent;
2366 
2367 	// Den obersten parent nehmen; ChildWindows werden immer am WorkWindow
2368 	// der Task bzw. des Frames oder am AppWorkWindow angemeldet
2369 	while ( pWork && pWork->pParent )
2370 		pWork = pWork->pParent;
2371 
2372 	if ( pWork )
2373 	{
2374 		// Dem Parent schon bekannt ?
2375 		sal_uInt16 nCount = pWork->pChildWins->Count();
2376 		for (sal_uInt16 n=0; n<nCount; n++)
2377 			if ((*pWork->pChildWins)[n]->nSaveId == nId)
2378 			{
2379 				pCW = (*pWork->pChildWins)[n];
2380 				break;
2381 			}
2382 	}
2383 
2384 	if ( !pCW )
2385 	{
2386 		// Kein Parent oder dem Parent noch unbekannt, dann bei mir suchen
2387 		sal_uInt16 nCount = pChildWins->Count();
2388 		for (sal_uInt16 n=0; n<nCount; n++)
2389 			if ((*pChildWins)[n]->nSaveId == nId)
2390 			{
2391 				pCW = (*pChildWins)[n];
2392 				break;
2393 			}
2394 	}
2395 
2396 	if ( !pCW )
2397 	{
2398 		// Ist neu, also initialisieren; je nach Flag beim Parent oder bei
2399 		// mir eintragen
2400 		pCW = new SfxChildWin_Impl( nId );
2401 		pCW->bEnable = sal_False;
2402 		pCW->nId = 0;
2403 		pCW->nVisibility = 0;
2404 		InitializeChild_Impl( pCW );
2405 		if ( pWork && !( pCW->aInfo.nFlags & SFX_CHILDWIN_TASK ) )
2406 			pWork->pChildWins->Insert( pWork->pChildWins->Count(), pCW );
2407 		else
2408 			pChildWins->Insert( pChildWins->Count(), pCW );
2409 	}
2410 
2411 	SfxChildAlignment eAlign;
2412 	if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
2413 		return( eAlign == SFX_ALIGN_NOALIGNMENT );
2414 	else
2415 		return sal_True;
2416 }
2417 
2418 //--------------------------------------------------------------------
2419 
KnowsChildWindow_Impl(sal_uInt16 nId)2420 sal_Bool SfxWorkWindow::KnowsChildWindow_Impl(sal_uInt16 nId)
2421 {
2422 	SfxChildWin_Impl *pCW=0;
2423 	sal_uInt16 nCount = pChildWins->Count();
2424 	sal_uInt16 n;
2425 	for (n=0; n<nCount; n++)
2426 	{
2427 		pCW = (*pChildWins)[n];
2428 		if ( pCW->nSaveId == nId)
2429 			 break;
2430 	}
2431 
2432 	if (n<nCount)
2433 	{
2434         if ( !(pCW->aInfo.nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE) && !IsVisible_Impl(  pCW->nVisibility ) )
2435 			return sal_False;
2436 		return pCW->bEnable;
2437 	}
2438 	else if ( pParent )
2439 		return pParent->KnowsChildWindow_Impl( nId );
2440 	else
2441 		return sal_False;
2442 }
2443 
2444 //--------------------------------------------------------------------
2445 
SetChildWindow_Impl(sal_uInt16 nId,sal_Bool bOn,sal_Bool bSetFocus)2446 void SfxWorkWindow::SetChildWindow_Impl(sal_uInt16 nId, sal_Bool bOn, sal_Bool bSetFocus)
2447 {
2448 	SfxChildWin_Impl *pCW=NULL;
2449 	SfxWorkWindow *pWork = pParent;
2450 
2451 	// Den obersten parent nehmen; ChildWindows werden immer am WorkWindow
2452 	// der Task bzw. des Frames oder am AppWorkWindow angemeldet
2453 	while ( pWork && pWork->pParent )
2454 		pWork = pWork->pParent;
2455 
2456 	if ( pWork )
2457 	{
2458 		// Dem Parent schon bekannt ?
2459 		sal_uInt16 nCount = pWork->pChildWins->Count();
2460 		for (sal_uInt16 n=0; n<nCount; n++)
2461 			if ((*pWork->pChildWins)[n]->nSaveId == nId)
2462 			{
2463 				pCW = (*pWork->pChildWins)[n];
2464 				break;
2465 			}
2466 	}
2467 
2468 	if ( !pCW )
2469 	{
2470 		// Kein Parent oder dem Parent noch unbekannt, dann bei mir suchen
2471 		sal_uInt16 nCount = pChildWins->Count();
2472 		for (sal_uInt16 n=0; n<nCount; n++)
2473 			if ((*pChildWins)[n]->nSaveId == nId)
2474 			{
2475 				pCW = (*pChildWins)[n];
2476 				pWork = this;
2477 				break;
2478 			}
2479 	}
2480 
2481 	if ( !pCW )
2482 	{
2483 		// Ist neu, also initialisieren; je nach Flag beim Parent oder bei
2484 		// mir eintragen
2485 		pCW = new SfxChildWin_Impl( nId );
2486 		InitializeChild_Impl( pCW );
2487 		if ( !pWork || pCW->aInfo.nFlags & SFX_CHILDWIN_TASK )
2488 			pWork = this;
2489 		pWork->pChildWins->Insert( pWork->pChildWins->Count(), pCW );
2490 	}
2491 
2492     if ( pCW->bCreate != bOn )
2493         pWork->ToggleChildWindow_Impl(nId,bSetFocus);
2494 }
2495 
2496 //--------------------------------------------------------------------
2497 
ShowChildWindow_Impl(sal_uInt16 nId,sal_Bool bVisible,sal_Bool bSetFocus)2498 void SfxWorkWindow::ShowChildWindow_Impl(sal_uInt16 nId, sal_Bool bVisible, sal_Bool bSetFocus)
2499 {
2500 	sal_uInt16 nCount = pChildWins->Count();
2501 	SfxChildWin_Impl* pCW=0;
2502 	sal_uInt16 n;
2503 	for (n=0; n<nCount; n++)
2504 	{
2505 		pCW = (*pChildWins)[n];
2506 		if (pCW->nId == nId)
2507 			break;
2508 	}
2509 
2510 	if ( n<nCount )
2511 	{
2512 		SfxChildWindow *pChildWin = pCW->pWin;
2513 		if ( pChildWin )
2514 		{
2515 			if ( bVisible )
2516 			{
2517 				if ( pCW->pCli )
2518 				{
2519 					pCW->pCli->bSetFocus = bSetFocus;
2520 					pCW->pCli->nVisible = CHILD_VISIBLE;
2521                     pChildWin->Show( bSetFocus && pChildWin->WantsFocus() ? 0 : SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
2522 				}
2523 				else
2524 					((SfxDockingWindow*)pChildWin->GetWindow())->Reappear_Impl();
2525 
2526 			}
2527 			else
2528 			{
2529 				if ( pCW->pCli )
2530 				{
2531 					pCW->pCli->nVisible = CHILD_VISIBLE ^ CHILD_NOT_HIDDEN;
2532 					pCW->pWin->Hide();
2533 				}
2534 				else
2535 					((SfxDockingWindow*)pChildWin->GetWindow())->Disappear_Impl();
2536 
2537 			}
2538 
2539 			ArrangeChilds_Impl();
2540 			ShowChilds_Impl();
2541 		}
2542 		else if ( bVisible )
2543 		{
2544             SetChildWindow_Impl( nId, sal_True, bSetFocus );
2545 			pChildWin = pCW->pWin;
2546 		}
2547 
2548 		if ( pChildWin )
2549 		{
2550 			pChildWin->SetVisible_Impl( bVisible );
2551             sal_uInt16 nFlags = pCW->aInfo.nFlags;
2552             pCW->aInfo = pChildWin->GetInfo();
2553             pCW->aInfo.nFlags |= nFlags;
2554 			if ( !pCW->bCreate )
2555 				SaveStatus_Impl( pChildWin, pCW->aInfo );
2556 		}
2557 
2558 		return;
2559 	}
2560 
2561 	if ( pParent )
2562 	{
2563         pParent->ShowChildWindow_Impl( nId, bVisible, bSetFocus );
2564 		return;
2565 	}
2566 
2567 #ifdef DBG_UTIL
2568 	nCount = pChildWins->Count();
2569 	for (n=0; n<nCount; n++)
2570 		if ((*pChildWins)[n]->nSaveId == nId)
2571 			break;
2572 
2573 	if ( n<nCount )
2574 	{
2575 		DBG_ERROR("ChildWindow ist nicht im Kontext!");
2576 	}
2577 	else
2578 	{
2579 		DBG_ERROR("ChildWindow ist nicht registriert!");
2580 	}
2581 #endif
2582 }
2583 
2584 //--------------------------------------------------------------------
2585 
GetChildWindow_Impl(sal_uInt16 nId)2586 SfxChildWindow* SfxWorkWindow::GetChildWindow_Impl(sal_uInt16 nId)
2587 {
2588 	sal_uInt16 nCount = pChildWins->Count();
2589 	sal_uInt16 n;
2590 	for (n=0; n<nCount; n++)
2591 		if ((*pChildWins)[n]->nSaveId == nId)
2592 			 break;
2593 
2594 	if (n<nCount)
2595 		return (*pChildWins)[n]->pWin;
2596 	else if ( pParent )
2597 		return pParent->GetChildWindow_Impl( nId );
2598 	return 0;
2599 }
2600 
2601 //------------------------------------------------------------------------
2602 
ResetChildWindows_Impl()2603 void SfxWorkWindow::ResetChildWindows_Impl()
2604 {
2605 //	if ( pParent )
2606 //		pParent->ResetChildWindows_Impl();
2607 
2608 	for ( sal_uInt16 n = 0; n < pChildWins->Count(); ++n )
2609 	{
2610 		(*pChildWins)[n]->nId = 0;
2611 		(*pChildWins)[n]->bEnable = sal_False;
2612 	}
2613 }
2614 
2615 //------------------------------------------------------------------------
2616 // Virtuelle Methode, die die Gr"o\se der Fl"ache (client area) des parent
2617 // windows liefert, in der Child-Fenster angeordnet werden k"onnen.
2618 // in der ClientArea des parent findet.
2619 
GetTopRect_Impl()2620 Rectangle SfxWorkWindow::GetTopRect_Impl()
2621 {
2622 	return Rectangle (Point(), pWorkWin->GetOutputSizePixel() );
2623 }
2624 
2625 //------------------------------------------------------------------------
2626 // Virtuelle Methode, die die Gr"o\se der Fl"ache (client area) des parent
2627 // windows liefert, in der Child-Fenster angeordnet werden k"onnen.
2628 // in der ClientArea des parent findet.
2629 
GetTopRect_Impl()2630 Rectangle SfxFrameWorkWin_Impl::GetTopRect_Impl()
2631 {
2632     return pMasterFrame->GetTopOuterRectPixel_Impl();
2633 }
2634 
2635 //------------------------------------------------------------------------
2636 // Virtuelle Methode, um herauszufinden, ob ein Child-Fenster noch Platz
2637 // in der ClientArea des parent findet.
2638 
RequestTopToolSpacePixel_Impl(SvBorder aBorder)2639 sal_Bool SfxWorkWindow::RequestTopToolSpacePixel_Impl( SvBorder aBorder )
2640 {
2641 	if ( !IsDockingAllowed() ||
2642 			aClientArea.GetWidth() < aBorder.Left() + aBorder.Right() ||
2643 			aClientArea.GetHeight() < aBorder.Top() + aBorder.Bottom() )
2644 		return sal_False;
2645 	else
2646 		return sal_True;;
2647 }
2648 
SaveStatus_Impl(SfxChildWindow * pChild,const SfxChildWinInfo & rInfo)2649 void SfxWorkWindow::SaveStatus_Impl(SfxChildWindow *pChild, const SfxChildWinInfo &rInfo)
2650 {
2651 	// Den Status vom Presentation mode wollen wir nicht sichern
2652     if ( IsDockingAllowed() && bInternalDockingAllowed )
2653 		pChild->SaveStatus(rInfo);
2654 }
2655 
InitializeChild_Impl(SfxChildWin_Impl * pCW)2656 void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl *pCW)
2657 {
2658 	SfxChildWinFactory* pFact=0;
2659 	SfxApplication *pApp = SFX_APP();
2660     {
2661 	    SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
2662 	    for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
2663 	    {
2664 		    pFact = rFactories[nFactory];
2665 		    if ( pFact->nId == pCW->nSaveId )
2666 		    {
2667 			    pCW->aInfo   = pFact->aInfo;
2668 			    SfxChildWindow::InitializeChildWinFactory_Impl(
2669 										    pCW->nSaveId, pCW->aInfo);
2670                 pCW->bCreate = pCW->aInfo.bVisible;
2671 			    sal_uInt16 nFlags = pFact->aInfo.nFlags;
2672 			    if ( nFlags & SFX_CHILDWIN_TASK )
2673 				    pCW->aInfo.nFlags |= SFX_CHILDWIN_TASK;
2674 			    if ( nFlags & SFX_CHILDWIN_CANTGETFOCUS )
2675 				    pCW->aInfo.nFlags |= SFX_CHILDWIN_CANTGETFOCUS;
2676                 if ( nFlags & SFX_CHILDWIN_FORCEDOCK )
2677                     pCW->aInfo.nFlags |= SFX_CHILDWIN_FORCEDOCK;
2678 			    pFact->aInfo = pCW->aInfo;
2679 			    return;
2680 		    }
2681 	    }
2682     }
2683 
2684 	SfxDispatcher *pDisp = pBindings->GetDispatcher_Impl();
2685     SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
2686 	if ( pMod )
2687 	{
2688 		SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
2689 		if ( pFactories )
2690 		{
2691 			SfxChildWinFactArr_Impl &rFactories = *pFactories;
2692 			for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
2693 			{
2694 				pFact = rFactories[nFactory];
2695 				if ( pFact->nId == pCW->nSaveId )
2696 				{
2697 					pCW->aInfo   = pFact->aInfo;
2698 					SfxChildWindow::InitializeChildWinFactory_Impl(
2699 												pCW->nSaveId, pCW->aInfo);
2700 					pCW->bCreate = pCW->aInfo.bVisible;
2701 					sal_uInt16 nFlags = pFact->aInfo.nFlags;
2702 					if ( nFlags & SFX_CHILDWIN_TASK )
2703 						pCW->aInfo.nFlags |= SFX_CHILDWIN_TASK;
2704 					if ( nFlags & SFX_CHILDWIN_CANTGETFOCUS )
2705 						pCW->aInfo.nFlags |= SFX_CHILDWIN_CANTGETFOCUS;
2706                     if ( nFlags & SFX_CHILDWIN_FORCEDOCK )
2707                         pCW->aInfo.nFlags |= SFX_CHILDWIN_FORCEDOCK;
2708                     if ( nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE )
2709                         pCW->aInfo.nFlags |= SFX_CHILDWIN_ALWAYSAVAILABLE;
2710 					pFact->aInfo = pCW->aInfo;
2711 					return;
2712 				}
2713 			}
2714 		}
2715 	}
2716 }
2717 /*
2718 SfxStatBar_Impl* SfxWorkWindow::GetStatusBar_Impl()
2719 {
2720     return &aStatBar;
2721 } */
2722 
GetSplitWindow_Impl(SfxChildAlignment eAlign)2723 SfxSplitWindow* SfxWorkWindow::GetSplitWindow_Impl( SfxChildAlignment eAlign )
2724 {
2725 	switch ( eAlign )
2726 	{
2727 		case SFX_ALIGN_TOP:
2728 			return pSplit[2];
2729 
2730 		case SFX_ALIGN_BOTTOM:
2731 			return pSplit[3];
2732 
2733 		case SFX_ALIGN_LEFT:
2734 			return pSplit[0];
2735 
2736 		case SFX_ALIGN_RIGHT:
2737 			return pSplit[1];
2738 
2739 		default:
2740 			return 0;
2741 	}
2742 }
2743 
MakeChildsVisible_Impl(sal_Bool bVis)2744 void SfxWorkWindow::MakeChildsVisible_Impl( sal_Bool bVis )
2745 {
2746 	if ( pParent )
2747 		pParent->MakeChildsVisible_Impl( bVis );
2748 
2749 	bAllChildsVisible = bVis;
2750 	if ( bVis )
2751 	{
2752 		if ( !bSorted )
2753 			Sort_Impl();
2754 		for ( sal_uInt16 n=0; n<aSortedList.Count(); ++n )
2755 		{
2756 			SfxChild_Impl* pCli = (*pChilds)[aSortedList[n]];
2757             if ( (pCli->eAlign == SFX_ALIGN_NOALIGNMENT) || (IsDockingAllowed() && bInternalDockingAllowed) )
2758 				pCli->nVisible |= CHILD_ACTIVE;
2759 		}
2760 	}
2761 	else
2762 	{
2763 		if ( !bSorted )
2764 			Sort_Impl();
2765 		for ( sal_uInt16 n=0; n<aSortedList.Count(); ++n )
2766 		{
2767 			SfxChild_Impl* pCli = (*pChilds)[aSortedList[n]];
2768 			pCli->nVisible &= ~CHILD_ACTIVE;
2769 		}
2770 	}
2771 }
2772 
IsAutoHideMode(const SfxSplitWindow * pSplitWin)2773 sal_Bool SfxWorkWindow::IsAutoHideMode( const SfxSplitWindow *pSplitWin )
2774 {
2775 	for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2776 	{
2777 		if ( pSplit[n] != pSplitWin && pSplit[n]->IsAutoHide( sal_True ) )
2778 			return sal_True;
2779 	}
2780 	return sal_False;
2781 }
2782 
2783 
EndAutoShow_Impl(Point aPos)2784 void SfxWorkWindow::EndAutoShow_Impl( Point aPos )
2785 {
2786 	if ( pParent )
2787         pParent->EndAutoShow_Impl( aPos );
2788 
2789 	for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2790 	{
2791 		SfxSplitWindow *p = pSplit[n];
2792 		if ( p && p->IsAutoHide() )
2793         {
2794             Point aLocalPos = p->ScreenToOutputPixel( aPos );
2795 	    Point aEmptyPoint = Point();
2796             Rectangle aRect( aEmptyPoint, p->GetSizePixel() );
2797             if ( !aRect.IsInside( aLocalPos ) )
2798                 p->FadeOut();
2799         }
2800 	}
2801 }
2802 
ArrangeAutoHideWindows(SfxSplitWindow * pActSplitWin)2803 void SfxWorkWindow::ArrangeAutoHideWindows( SfxSplitWindow *pActSplitWin )
2804 {
2805     if ( m_nLock )
2806         return;
2807 
2808 	if ( pParent )
2809 		pParent->ArrangeAutoHideWindows( pActSplitWin );
2810 
2811     Rectangle aArea( aUpperClientArea );
2812 	for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2813 	{
2814 		// Es werden entweder Dummyfenster oder Fenster im AutoShow-Modus
2815 		// ( nicht gepinned, FadeIn ) behandelt.
2816 		// Nur das "ubergebene Fenster darf unsichtbar sein, denn vielleicht
2817 		// soll daf"ur gerade die Gr"o\se berechnet werden, bevor es angezeigt
2818 		// wird.
2819 		SfxSplitWindow* pSplitWin = pSplit[n];
2820 		sal_Bool bDummyWindow = !pSplitWin->IsFadeIn();
2821 		Window *pDummy = pSplitWin->GetSplitWindow();
2822 		Window *pWin = bDummyWindow ? pDummy : pSplitWin;
2823 		if ( (pSplitWin->IsPinned() && !bDummyWindow) || (!pWin->IsVisible() && pActSplitWin != pSplitWin) )
2824 			continue;
2825 
2826 		// Breite und Position des Dummy-Fensters als Ausgangspunkt
2827 		Size aSize = pDummy->GetSizePixel();
2828 		Point aPos = pDummy->GetPosPixel();
2829 
2830 		switch ( n )
2831 		{
2832 			case ( 0 ) :
2833 			{
2834 				// Linkes SplitWindow
2835 				// Breite vom Fenster selbst holen, wenn nicht das DummyWindow
2836 				if ( !bDummyWindow )
2837 					aSize.Width() = pSplitWin->GetSizePixel().Width();
2838 
2839 				// Wenn links ein Window sichtbar ist, beginnt der freie
2840 				// Bereich rechts davon bzw. bei der Client area
2841 				long nLeft = aPos.X() + aSize.Width();
2842 				if ( nLeft > aArea.Left() )
2843 					aArea.Left() = nLeft;
2844 				break;
2845 			}
2846 			case ( 1 ) :
2847 			{
2848 				// Rechtes SplitWindow
2849 				// Position um Differenz der Breiten korrigieren
2850 				aPos.X() += aSize.Width();
2851 
2852 				// Breite vom Fenster selbst holen, wenn nicht das DummyWindow
2853 				if ( !bDummyWindow )
2854 					aSize.Width() = pSplitWin->GetSizePixel().Width();
2855 
2856 				aPos.X() -= aSize.Width();
2857 
2858 				// Wenn links schon ein Fenster aufgeklappt ist, darf
2859 				// das rechte nicht dar"uber gehen
2860 				if ( aPos.X() < aArea.Left() )
2861 				{
2862 					aPos.X() = aArea.Left();
2863 					aSize.Width() = aArea.GetWidth();
2864 				}
2865 
2866 				// Wenn rechts ein Window sichtbar ist, endet der freie
2867 				// Bereich links davon bzw. bei der Client area
2868 				long nRight = aPos.X();
2869 				if ( nRight < aArea.Right() )
2870 					aArea.Right() = nRight;
2871 				break;
2872 			}
2873 			case ( 2 ) :
2874 			{
2875 				// Oberes SplitWindow
2876 				// H"ohe vom Fenster selbst holen, wenn nicht das DummyWindow
2877 				if ( !bDummyWindow )
2878 					aSize.Height() = pSplitWin->GetSizePixel().Height();
2879 
2880 				// Breite anpassen, je nachdem ob links oder rechts
2881 				// schon ein Fenster aufgeklappt ist
2882 				aPos.X() = aArea.Left();
2883 				aSize.Width() = aArea.GetWidth();
2884 
2885 				// Wenn oben ein Window sichtbar ist, beginnt der freie
2886 				// Bereich darunter bzw. bei der Client Area
2887 				long nTop = aPos.Y() + aSize.Height();
2888 				if ( nTop > aArea.Top() )
2889 					aArea.Top() = nTop;
2890 				break;
2891 			}
2892 			case ( 3 ) :
2893 			{
2894 				// Das untere SplitWindow
2895 				// Position um Differenz der H"ohen korrigieren
2896 				aPos.Y() += aSize.Height();
2897 
2898 				// H"ohe vom Fenster selbst holen, wenn nicht das DummmyWindow
2899 				if ( !bDummyWindow )
2900 					aSize.Height() = pSplitWin->GetSizePixel().Height();
2901 
2902 				aPos.Y() -= aSize.Height();
2903 
2904 				// Breite anpassen, je nachdem ob links oder rechts
2905 				// schon ein Fenster aufgeklappt ist
2906 				aPos.X() = aArea.Left();
2907 				aSize.Width() = aArea.GetWidth();
2908 
2909 				// Wenn oben schon ein Fenster aufgeklappt ist, darf
2910 				// das untere nicht dar"uber gehen
2911 				if ( aPos.Y() < aArea.Top() )
2912 				{
2913 					aPos.Y() = aArea.Top();
2914 					aSize.Height() = aArea.GetHeight();
2915 				}
2916 
2917 				break;
2918 			}
2919 		}
2920 
2921 		if ( !bDummyWindow )
2922 			// Das FadeIn-Window ist ein Float, dessen Koordinaten in
2923 			// Screenkoordinaten gesetzt werden
2924 			pSplitWin->SetPosSizePixel( pWorkWin->OutputToScreenPixel(aPos), aSize );
2925 		else
2926 			// Das angedockte DummyWindow
2927 			pDummy->SetPosSizePixel( aPos, aSize );
2928 	}
2929 }
2930 
GetFreeArea(sal_Bool bAutoHide) const2931 Rectangle SfxWorkWindow::GetFreeArea( sal_Bool bAutoHide ) const
2932 {
2933 	if ( bAutoHide )
2934 	{
2935 		Rectangle aArea( aClientArea );
2936 		for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2937 		{
2938 			if ( pSplit[n]->IsPinned() || !pSplit[n]->IsVisible() )
2939 				continue;
2940 
2941 			Size aSize = pSplit[n]->GetSizePixel();
2942 			switch ( n )
2943 			{
2944 				case ( 0 ) :
2945 					aArea.Left() += aSize.Width();
2946 					break;
2947 				case ( 1 ) :
2948 					aArea.Right() -= aSize.Width();
2949 					break;
2950 				case ( 2 ) :
2951 					aArea.Top() += aSize.Height();
2952 					break;
2953 				case ( 3 ) :
2954 					aArea.Bottom() -= aSize.Height();
2955 					break;
2956 			}
2957 		}
2958 
2959 		return aArea;
2960 	}
2961 	else
2962 		return aClientArea;
2963 }
2964 
SfxChildWinController_Impl(sal_uInt16 nID,SfxWorkWindow * pWork)2965 SfxChildWinController_Impl::SfxChildWinController_Impl( sal_uInt16 nID, SfxWorkWindow *pWork )
2966 	: SfxControllerItem( nID, pWork->GetBindings() )
2967 	, pWorkwin( pWork )
2968 {}
2969 
CreateDispatch(const String &)2970 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SfxWorkWindow::CreateDispatch( const String& )
2971 {
2972 	return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >();
2973 }
2974 
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem *)2975 void SfxChildWinController_Impl::StateChanged(
2976     sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* )
2977 {
2978 	pWorkwin->DisableChildWindow_Impl( nSID, eState == SFX_ITEM_DISABLED );
2979 }
2980 
DisableChildWindow_Impl(sal_uInt16 nId,sal_Bool bDisable)2981 void SfxWorkWindow::DisableChildWindow_Impl( sal_uInt16 nId, sal_Bool bDisable )
2982 {
2983 	sal_uInt16 nCount = pChildWins->Count();
2984 	sal_uInt16 n;
2985 	for (n=0; n<nCount; n++)
2986 		if ((*pChildWins)[n]->nSaveId == nId)
2987 			 break;
2988 	if ( n<nCount && (*pChildWins)[n]->bDisabled != bDisable )
2989 	{
2990 		(*pChildWins)[n]->bDisabled = bDisable;
2991 		UpdateChildWindows_Impl();
2992 		ArrangeChilds_Impl();
2993 		ShowChilds_Impl();
2994 	}
2995 }
2996 
SetActiveChild_Impl(Window * pChild)2997 void SfxWorkWindow::SetActiveChild_Impl( Window *pChild )
2998 {
2999 	pActiveChild = pChild;
3000 }
3001 
GetActiveChild_Impl()3002 Window*	SfxWorkWindow::GetActiveChild_Impl()
3003 {
3004 	return pActiveChild;
3005 }
3006 
ActivateNextChild_Impl(sal_Bool bForward)3007 sal_Bool SfxWorkWindow::ActivateNextChild_Impl( sal_Bool bForward )
3008 {
3009 	// Alle Kinder gem"a\s Liste sortieren
3010 	SvUShorts aList;
3011 	for ( sal_uInt16 i=SFX_OBJECTBAR_MAX; i<pChilds->Count(); i++)
3012 	{
3013 		SfxChild_Impl *pCli = (*pChilds)[i];
3014         if ( pCli && pCli->bCanGetFocus && pCli->pWin )
3015 		{
3016 			sal_uInt16 k;
3017 			for (k=0; k<aList.Count(); k++)
3018 				if ( ChildTravelValue((*pChilds)[aList[k]]->eAlign) > ChildTravelValue(pCli->eAlign) )
3019 					break;
3020 			aList.Insert(i,k);
3021 		}
3022 	}
3023 
3024     if ( aList.Count() == 0 )
3025         return sal_False;
3026 
3027 	sal_uInt16 nTopValue  = ChildTravelValue( SFX_ALIGN_LOWESTTOP );
3028 	for ( sal_uInt16 i=0; i<aList.Count(); i++ )
3029 	{
3030 		SfxChild_Impl* pCli = (*pChilds)[aList[i]];
3031         if ( pCli->pWin && ChildTravelValue( pCli->eAlign ) > nTopValue )
3032 			break;
3033 	}
3034 
3035 	sal_uInt16 n = bForward ? 0 : aList.Count()-1;
3036 	SfxChild_Impl *pAct=NULL;
3037     if ( pActiveChild )
3038 	{
3039 		// Das aktive Fenster suchen
3040 		for ( n=0; n<aList.Count(); n++ )
3041 		{
3042 			SfxChild_Impl* pCli = (*pChilds)[aList[n]];
3043 			if ( pCli && pCli->pWin && ( pCli->pWin == pActiveChild || !pActiveChild ) )
3044 			{
3045 				pAct = pCli;
3046 				break;
3047 			}
3048 		}
3049 	}
3050 
3051     // dummy entries for the container window
3052     aList.Insert( 0xFFFF, 0 );
3053     aList.Insert( 0xFFFF, aList.Count() );
3054     n = n + 1;
3055     if ( pAct )
3056 	{
3057 		for ( sal_uInt16 i=0; i<SFX_SPLITWINDOWS_MAX; i++ )
3058 		{
3059 			// Eventuell ist pAct ein Splitwindow
3060 			SfxSplitWindow *p = pSplit[i];
3061 			if ( pAct->pWin == p )
3062 			{
3063 				if( p->ActivateNextChild_Impl( bForward ) )
3064 					return sal_True;
3065 				break;
3066 			}
3067 		}
3068 
3069 		// pAct ist ein direktes ChildWindow
3070 		// mit dem Nachfolger bzw. Vorg"anger des aktiven Fensters weitermachen
3071 		if ( bForward )
3072             n = n+1;
3073 		else
3074             n = n-1;
3075 
3076         if ( n == 0 || n == aList.Count()-1 )
3077             return sal_False;
3078 	}
3079 
3080 	for( ;; )
3081 	{
3082         SfxChild_Impl* pCli = (*pChilds)[aList[n]];
3083         if ( pCli->pWin )
3084         {
3085             SfxChild_Impl* pNext = pCli;
3086             for ( sal_uInt16 i=0; n<SFX_SPLITWINDOWS_MAX; n++ )
3087             {
3088                 // Eventuell ist pNext ein Splitwindow
3089                 SfxSplitWindow *p = pSplit[i];
3090                 if ( pNext->pWin == p )
3091                 {
3092                     // Das erste/letzte Fenster dort aktivieren
3093                     p->SetActiveWindow_Impl( NULL );
3094                     pNext = NULL;
3095                     if( p->ActivateNextChild_Impl( bForward ) )
3096                         return sal_True;
3097                     break;
3098                 }
3099             }
3100 
3101             if ( pNext )
3102             {
3103                 pNext->pWin->GrabFocus();
3104                 pActiveChild = pNext->pWin;
3105                 return sal_True;
3106             }
3107         }
3108 
3109 		if ( bForward )
3110             n = n+1;
3111 		else
3112             n = n-1;
3113 
3114         if ( n == 0 || n == aList.Count()-1 )
3115 			break;
3116 	}
3117 
3118 	return sal_False;
3119 }
3120 
SetObjectBarCustomizeMode_Impl(sal_Bool)3121 void SfxWorkWindow::SetObjectBarCustomizeMode_Impl( sal_Bool )
3122 {
3123 }
3124 
DataChanged_Impl(const DataChangedEvent &)3125 void SfxWorkWindow::DataChanged_Impl( const DataChangedEvent& )
3126 {
3127 	sal_uInt16 n;
3128     sal_uInt16 nCount = pChildWins->Count();
3129 	for (n=0; n<nCount; n++)
3130 	{
3131         SfxChildWin_Impl*pCW = (*pChildWins)[n];
3132         if ( pCW && pCW->pWin )
3133             pCW->pWin->GetWindow()->UpdateSettings( Application::GetSettings() );
3134     }
3135 
3136     ArrangeChilds_Impl();
3137 }
3138 
3139