Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / appl / workwin.cxx
blob5f6d001ad6e4b510e17f675b152c3e86d7ef5ac7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <stdio.h>
31 #include <boost/unordered_map.hpp>
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/module.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <sfx2/dockwin.hxx>
42 #include <sfx2/viewsh.hxx>
43 #include "splitwin.hxx"
44 #include <sfx2/msgpool.hxx>
45 #include "sfx2/sfxresid.hxx"
46 #include <sfx2/request.hxx> // SFX_ITEMSET_SET
47 #include <vcl/taskpanelist.hxx>
48 #include <vcl/toolbox.hxx>
49 #include <tools/rcid.h>
50 #include <tools/diagnose_ex.h>
51 #include <toolkit/helper/vclunohelper.hxx>
52 #include <svl/itempool.hxx>
53 #include <svl/itemiter.hxx>
54 #include <svl/whiter.hxx>
55 #include <svl/intitem.hxx>
56 #include <svl/eitem.hxx>
57 #include <com/sun/star/ui/XUIElement.hpp>
58 #include <com/sun/star/frame/XLayoutManager.hpp>
59 #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
60 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
61 #include <com/sun/star/beans/XPropertySet.hpp>
62 #include <com/sun/star/awt/XWindow.hpp>
63 #include <com/sun/star/lang/DisposedException.hpp>
65 using namespace ::com::sun::star;
66 using namespace ::com::sun::star::uno;
67 namespace css = ::com::sun::star;
69 struct ResIdToResName
71 sal_uInt16 nId;
72 const char* pName;
75 static const ResIdToResName pToolBarResToName[] =
77 { 558, "fullscreenbar" },
78 { 560, "standardbar", },
79 { 18001, "formsnavigationbar" },
80 { 18002, "formsfilterbar" },
81 { 18003, "formtextobjectbar" },
82 { 18004, "formcontrols" },
83 { 18005, "moreformcontrols" },
84 { 18006, "formdesign" },
85 { 20050, "toolbar" }, //math
86 { 30001, "objectbar" }, //chart
87 { 30513, "toolbar" }, //chart
88 { 25005, "textobjectbar" }, //calc
89 { 25053, "drawobjectbar" },
90 { 25054, "graphicobjectbar" },
91 { 25001, "formatobjectbar" },
92 { 25006, "previewbar" },
93 { 25035, "toolbar" }, //calc
94 { 23015, "bezierobjectbar" }, //draw/impress
95 { 23019, "gluepointsobjectbar" },
96 { 23030, "graphicobjectbar" },
97 { 23013, "drawingobjectbar" }, //impress
98 { 23016, "textobjectbar" }, //impress
99 { 23028, "textobjectbar" }, //draw
100 { 23011, "toolbar" }, //impress
101 { 23020, "optionsbar" },
102 { 23021, "commontaskbar" },
103 { 23025, "toolbar" }, //draw
104 { 23026, "optionsbar" },
105 { 23027, "drawingobjectbar" }, //draw
106 { 23017, "outlinetoolbar" }, //impress
107 { 23012, "slideviewtoolbar" },
108 { 23014, "slideviewobjectbar" },
109 { 23283, "bezierobjectbar" }, //writer
110 { 23269, "drawingobjectbar" },
111 { 23270, "drawtextobjectbar" },
112 { 23267, "frameobjectbar" },
113 { 23268, "graphicobjectbar" },
114 { 23271, "numobjectbar" },
115 { 23272, "oleobjectbar" },
116 { 23266, "tableobjectbar" },
117 { 23265, "textobjectbar" },
118 { 20631, "previewobjectbar" }, //writer
119 { 20402, "toolbar" }, //web
120 { 20403, "textobjectbar" },
121 { 23273, "toolbar" }, //writer
122 { 20408, "frameobjectbar" }, //web
123 { 20410, "graphicobjectbar" },
124 { 20411, "oleobjectbar" },
125 { 14850, "macrobar" },
126 { 10987, "fontworkobjectbar" }, //global
127 { 10986, "extrusionobjectbar" },
128 { 23022, "formsobjectbar" },
129 { 23310, "viewerbar" }, //writer (plugin)
130 { 25000, "viewerbar" }, //calc (plugin)
131 { 23023, "viewerbar" }, //impress(plugin)
132 { 23024, "viewerbar" }, //draw (plugin)
133 { 23031, "mediaobjectbar" }, //draw/impress
134 { 25060, "mediaobjectbar" }, //calc
135 { 23311, "mediaobjectbar" }, //writer
136 { 23313, "navigationobjectbar" }, //writer
137 { 0, "" }
140 DBG_NAME(SfxWorkWindow)
142 //SV_IMPL_OBJARR( SfxObjectBarArr_Impl, SfxObjectBar_Impl );
144 //====================================================================
145 // Sort the Children according their alignment
146 // The order corresponds to the enum SfxChildAlignment (->CHILDWIN.HXX).
149 // Help to make changes to the alignment compatible!
152 SFX_IMPL_XINTERFACE_3( LayoutManagerListener, OWeakObject, ::com::sun::star::frame::XLayoutManagerListener, ::com::sun::star::lang::XEventListener, ::com::sun::star::lang::XComponent )
153 SFX_IMPL_XTYPEPROVIDER_3( LayoutManagerListener, ::com::sun::star::frame::XLayoutManagerListener, ::com::sun::star::lang::XEventListener, ::com::sun::star::lang::XComponent )
155 LayoutManagerListener::LayoutManagerListener(
156 SfxWorkWindow* pWrkWin ) :
157 m_bHasFrame( sal_False ),
158 m_pWrkWin( pWrkWin ),
159 m_aLayoutManagerPropName( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))
163 LayoutManagerListener::~LayoutManagerListener()
167 void LayoutManagerListener::setFrame( const css::uno::Reference< css::frame::XFrame >& xFrame )
169 SolarMutexGuard aGuard;
170 if ( m_pWrkWin && !m_bHasFrame )
172 m_xFrame = xFrame;
173 m_bHasFrame = sal_True;
175 if ( xFrame.is() )
177 css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
178 css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
179 if ( xPropSet.is() )
183 Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
184 aValue >>= xLayoutManager;
186 if ( xLayoutManager.is() )
187 xLayoutManager->addLayoutManagerEventListener(
188 css::uno::Reference< css::frame::XLayoutManagerListener >(
189 static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY ));
191 xPropSet = css::uno::Reference< css::beans::XPropertySet >( xLayoutManager, UNO_QUERY );
192 if ( xPropSet.is() )
194 aValue = xPropSet->getPropertyValue(
195 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LockCount" )) );
196 aValue >>= m_pWrkWin->m_nLock;
199 catch ( css::lang::DisposedException& )
202 catch ( const css::uno::RuntimeException& )
204 throw;
206 catch ( css::uno::Exception& )
214 //---------------------------------------------------------------------------------------------------------
215 // XComponent
216 //---------------------------------------------------------------------------------------------------------
217 void SAL_CALL LayoutManagerListener::addEventListener(
218 const css::uno::Reference< css::lang::XEventListener >& )
219 throw (::com::sun::star::uno::RuntimeException)
221 // do nothing, only internal class
224 void SAL_CALL LayoutManagerListener::removeEventListener(
225 const css::uno::Reference< css::lang::XEventListener >& )
226 throw (::com::sun::star::uno::RuntimeException)
228 // do nothing, only internal class
231 void SAL_CALL LayoutManagerListener::dispose()
232 throw( css::uno::RuntimeException )
234 SolarMutexGuard aGuard;
236 // reset member
237 m_pWrkWin = 0;
239 css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame.get(), css::uno::UNO_QUERY );
240 if ( xFrame.is() )
242 m_xFrame = css::uno::Reference< css::frame::XFrame >();
243 m_bHasFrame = sal_False;
245 css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY );
246 css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
247 if ( xPropSet.is() )
251 css::uno::Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
252 aValue >>= xLayoutManager;
254 // remove as listener from layout manager
255 if ( xLayoutManager.is() )
256 xLayoutManager->removeLayoutManagerEventListener(
257 css::uno::Reference< css::frame::XLayoutManagerListener >(
258 static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY ));
260 catch ( css::lang::DisposedException& )
263 catch ( const css::uno::RuntimeException& )
265 throw;
267 catch ( css::uno::Exception& )
274 //---------------------------------------------------------------------------------------------------------
275 // XEventListener
276 //---------------------------------------------------------------------------------------------------------
277 void SAL_CALL LayoutManagerListener::disposing(
278 const css::lang::EventObject& )
279 throw( css::uno::RuntimeException )
281 SolarMutexGuard aGuard;
282 m_pWrkWin = 0;
283 m_bHasFrame = sal_False;
284 m_xFrame = css::uno::Reference< css::frame::XFrame >();
287 //---------------------------------------------------------------------------------------------------------
288 // XLayoutManagerEventListener
289 //---------------------------------------------------------------------------------------------------------
290 void SAL_CALL LayoutManagerListener::layoutEvent(
291 const css::lang::EventObject&,
292 ::sal_Int16 eLayoutEvent,
293 const css::uno::Any& )
294 throw (css::uno::RuntimeException)
296 SolarMutexGuard aGuard;
297 if ( m_pWrkWin )
299 if ( eLayoutEvent == css::frame::LayoutManagerEvents::VISIBLE )
301 m_pWrkWin->MakeVisible_Impl( sal_True );
302 m_pWrkWin->ShowChildren_Impl();
303 m_pWrkWin->ArrangeChildren_Impl( sal_True );
305 else if ( eLayoutEvent == css::frame::LayoutManagerEvents::INVISIBLE )
307 m_pWrkWin->MakeVisible_Impl( sal_False );
308 m_pWrkWin->HideChildren_Impl();
309 m_pWrkWin->ArrangeChildren_Impl( sal_True );
311 else if ( eLayoutEvent == css::frame::LayoutManagerEvents::LOCK )
313 m_pWrkWin->Lock_Impl( sal_True );
315 else if ( eLayoutEvent == css::frame::LayoutManagerEvents::UNLOCK )
317 m_pWrkWin->Lock_Impl( sal_False );
322 namespace
324 class FilledToolBarResIdToResourceURLMap
326 private:
327 typedef boost::unordered_map< sal_Int32, rtl::OUString > ToolBarResIdToResourceURLMap;
328 ToolBarResIdToResourceURLMap m_aResIdToResourceURLMap;
329 public:
330 FilledToolBarResIdToResourceURLMap()
332 sal_Int32 nIndex( 0 );
333 while ( pToolBarResToName[nIndex].nId != 0 )
335 rtl::OUString aResourceURL( rtl::OUString::createFromAscii( pToolBarResToName[nIndex].pName ));
336 m_aResIdToResourceURLMap.insert( ToolBarResIdToResourceURLMap::value_type(
337 sal_Int32( pToolBarResToName[nIndex].nId ), aResourceURL ));
338 ++nIndex;
342 rtl::OUString findURL(sal_uInt16 nResId) const
344 ToolBarResIdToResourceURLMap::const_iterator aIter = m_aResIdToResourceURLMap.find( nResId );
345 if ( aIter != m_aResIdToResourceURLMap.end() )
346 return aIter->second;
347 return rtl::OUString();
351 class theFilledToolBarResIdToResourceURLMap
352 : public rtl::Static<FilledToolBarResIdToResourceURLMap,
353 theFilledToolBarResIdToResourceURLMap>
358 static rtl::OUString GetResourceURLFromResId( sal_uInt16 nResId )
360 return theFilledToolBarResIdToResourceURLMap::get().findURL(nResId);
363 sal_Bool IsAppWorkWinToolbox_Impl( sal_uInt16 nPos )
365 switch ( nPos )
367 case SFX_OBJECTBAR_APPLICATION :
368 case SFX_OBJECTBAR_MACRO:
369 case SFX_OBJECTBAR_FULLSCREEN:
370 return sal_True;
371 default:
372 return sal_False;
376 sal_uInt16 TbxMatch( sal_uInt16 nPos )
378 switch ( nPos )
380 case SFX_OBJECTBAR_APPLICATION :
381 return 0;
382 case SFX_OBJECTBAR_OPTIONS:
383 return 1;
384 case SFX_OBJECTBAR_MACRO:
385 return 2;
386 case SFX_OBJECTBAR_OBJECT:
387 return 3;
388 case SFX_OBJECTBAR_TOOLS:
389 return 4;
390 case SFX_OBJECTBAR_FULLSCREEN:
391 case SFX_OBJECTBAR_COMMONTASK:
392 case SFX_OBJECTBAR_RECORDING:
393 return nPos+1;
394 default:
395 return nPos;
399 sal_uInt16 ChildAlignValue(SfxChildAlignment eAlign)
401 sal_uInt16 ret = 17;
403 switch (eAlign)
405 case SFX_ALIGN_HIGHESTTOP:
406 ret = 1;
407 break;
408 case SFX_ALIGN_LOWESTBOTTOM:
409 ret = 2;
410 break;
411 case SFX_ALIGN_FIRSTLEFT:
412 ret = 3;
413 break;
414 case SFX_ALIGN_LASTRIGHT:
415 ret = 4;
416 break;
417 case SFX_ALIGN_LEFT:
418 ret = 5;
419 break;
420 case SFX_ALIGN_RIGHT:
421 ret = 6;
422 break;
423 case SFX_ALIGN_FIRSTRIGHT:
424 ret = 7;
425 break;
426 case SFX_ALIGN_LASTLEFT:
427 ret = 8;
428 break;
429 case SFX_ALIGN_TOP:
430 ret = 9;
431 break;
432 case SFX_ALIGN_BOTTOM:
433 ret = 10;
434 break;
435 case SFX_ALIGN_TOOLBOXTOP:
436 ret = 11;
437 break;
438 case SFX_ALIGN_TOOLBOXBOTTOM:
439 ret = 12;
440 break;
441 case SFX_ALIGN_LOWESTTOP:
442 ret = 13;
443 break;
444 case SFX_ALIGN_HIGHESTBOTTOM:
445 ret = 14;
446 break;
447 case SFX_ALIGN_TOOLBOXLEFT:
448 ret = 15;
449 break;
450 case SFX_ALIGN_TOOLBOXRIGHT:
451 ret = 16;
452 break;
453 case SFX_ALIGN_NOALIGNMENT:
454 break; // -Wall not handled...
457 return ret;
460 sal_uInt16 ChildTravelValue( SfxChildAlignment eAlign )
462 sal_uInt16 ret = 17;
464 switch (eAlign)
466 case SFX_ALIGN_FIRSTLEFT:
467 ret = 1;
468 break;
469 case SFX_ALIGN_LEFT:
470 ret = 2;
471 break;
472 case SFX_ALIGN_LASTLEFT:
473 ret = 3;
474 break;
475 case SFX_ALIGN_TOOLBOXLEFT:
476 ret = 4;
477 break;
478 case SFX_ALIGN_HIGHESTTOP:
479 ret = 5;
480 break;
481 case SFX_ALIGN_TOP:
482 ret = 6;
483 break;
484 case SFX_ALIGN_TOOLBOXTOP:
485 ret = 7;
486 break;
487 case SFX_ALIGN_LOWESTTOP:
488 ret = 8;
489 break;
490 case SFX_ALIGN_HIGHESTBOTTOM:
491 ret = 9;
492 break;
493 case SFX_ALIGN_TOOLBOXBOTTOM:
494 ret = 10;
495 break;
496 case SFX_ALIGN_BOTTOM:
497 ret = 11;
498 break;
499 case SFX_ALIGN_LOWESTBOTTOM:
500 ret = 12;
501 break;
502 case SFX_ALIGN_TOOLBOXRIGHT:
503 ret = 13;
504 break;
505 case SFX_ALIGN_FIRSTRIGHT:
506 ret = 14;
507 break;
508 case SFX_ALIGN_RIGHT:
509 ret = 15;
510 break;
511 case SFX_ALIGN_LASTRIGHT:
512 ret = 16;
513 break;
514 case SFX_ALIGN_NOALIGNMENT:
515 break; // -Wall not handled.
518 return ret;
521 void SfxWorkWindow::Sort_Impl()
523 aSortedList.clear();
524 for (sal_uInt16 i=0; i<pChildren->Count(); i++)
526 SfxChild_Impl *pCli = (*pChildren)[i];
527 if (pCli)
529 sal_uInt16 k;
530 for (k=0; k<aSortedList.size(); k++)
531 if (ChildAlignValue((*pChildren)[aSortedList[k]]->eAlign) >
532 ChildAlignValue(pCli->eAlign))
533 break;
534 aSortedList.insert( aSortedList.begin() + k, i );
538 bSorted = sal_True;
542 //====================================================================
543 // constructor for workwin of a Frame
545 SfxFrameWorkWin_Impl::SfxFrameWorkWin_Impl( Window *pWin, SfxFrame *pFrm, SfxFrame* pMaster )
546 : SfxWorkWindow(
547 pWin,
548 pFrm->GetCurrentViewFrame()->GetBindings(),
549 pFrm->GetParentFrame() ? pFrm->GetParentFrame()->GetWorkWindow_Impl() : NULL )
550 , pMasterFrame( pMaster )
551 , pFrame( pFrm )
553 pConfigShell = pFrm->GetCurrentViewFrame();
554 if ( pConfigShell && pConfigShell->GetObjectShell() )
556 bShowStatusBar = ( !pConfigShell->GetObjectShell()->IsInPlaceActive() );
557 bDockingAllowed = sal_True;
558 bInternalDockingAllowed = sal_True;
561 // The required split windows (one for each side) can be created
562 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
564 // The SplitWindows excludes direct ChildWindows of the WorkWindows
565 // and receives the docked window.
567 SfxChildAlignment eAlign =
568 ( n == SFX_SPLITWINDOWS_LEFT ? SFX_ALIGN_LEFT :
569 n == SFX_SPLITWINDOWS_RIGHT ? SFX_ALIGN_RIGHT :
570 n == SFX_SPLITWINDOWS_TOP ? SFX_ALIGN_TOP :
571 SFX_ALIGN_BOTTOM );
572 SfxSplitWindow *pSplitWin = new SfxSplitWindow(pWorkWin, eAlign, this, pParent==0 );
573 pSplit[n] = pSplitWin;
576 nOrigMode = SFX_VISIBILITY_STANDARD;
577 nUpdateMode = SFX_VISIBILITY_STANDARD;
580 //====================================================================
581 // Constructor of the base class
583 SfxWorkWindow::SfxWorkWindow( Window *pWin, SfxBindings& rB, SfxWorkWindow* pParentWorkwin ) :
584 pParent( pParentWorkwin ),
585 pBindings(&rB),
586 pWorkWin (pWin),
587 pConfigShell( 0 ),
588 pActiveChild( 0 ),
589 nChildren( 0 ),
590 nOrigMode( 0 ),
591 bSorted( sal_True ),
592 bDockingAllowed(sal_True),
593 bInternalDockingAllowed(sal_True),
594 bAllChildrenVisible(sal_True),
595 bIsFullScreen( sal_False ),
596 bShowStatusBar( sal_True ),
597 m_nLock( 0 ),
598 m_aStatusBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" )),
599 m_aLayoutManagerPropName( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )),
600 m_aTbxTypeName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" )),
601 m_aProgressBarResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/progressbar/progressbar" ))
603 DBG_CTOR(SfxWorkWindow, 0);
604 DBG_ASSERT (pBindings, "No Bindings!");
606 pBindings->SetWorkWindow_Impl( this );
608 pChildWins = new SfxChildWindows_Impl;
609 pChildren = new SfxChildList_Impl;
611 // For the ObjectBars a integral place in the Childlist is reserved,
612 // so that they always come in a defined order.
613 SfxChild_Impl* pChild=0;
614 for (sal_uInt16 n=0; n < SFX_OBJECTBAR_MAX; ++n)
615 pChildren->Insert(0,pChild);
617 // create and initialize layout manager listener
618 Reference< com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
619 LayoutManagerListener* pLayoutManagerListener = new LayoutManagerListener( this );
620 m_xLayoutManagerListener = css::uno::Reference< css::lang::XComponent >(
621 static_cast< cppu::OWeakObject* >( pLayoutManagerListener ),
622 css::uno::UNO_QUERY );
623 pLayoutManagerListener->setFrame( xFrame );
626 //====================================================================
627 // Destructor
629 SfxWorkWindow::~SfxWorkWindow()
631 DBG_DTOR(SfxWorkWindow, 0);
633 // Delete SplitWindows
634 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
636 SfxSplitWindow *p = pSplit[n];
637 if (p->GetWindowCount())
638 ReleaseChild_Impl(*p);
639 delete p;
642 // Delete help structure for Child-Windows
643 DBG_ASSERT( pChildren->Count() == 0, "dangling children" );
644 delete pChildren;
645 delete pChildWins;
647 if ( m_xLayoutManagerListener.is() )
648 m_xLayoutManagerListener->dispose();
651 void SfxWorkWindow::Lock_Impl( sal_Bool bLock )
653 if ( bLock )
654 m_nLock++;
655 else
656 --m_nLock;
657 if ( m_nLock<0 )
659 OSL_FAIL("Lock count underflow!");
660 m_nLock = 0;
663 if ( !m_nLock )
664 ArrangeChildren_Impl();
667 //--------------------------------------------------------------------
668 // Helper method to release the child lists. Should the destructor not be
669 // called after this, instead work continues, then space for the object bars
670 // and split windows has to be reserved in the same way as in the constructor
671 // of SfxWorkWindow.
673 void SfxWorkWindow::DeleteControllers_Impl()
675 DBG_CHKTHIS(SfxWorkWindow, 0);
677 // Lock SplitWindows (which means supressing the Resize-Reaction of the
678 // DockingWindows)
679 sal_uInt16 n;
680 for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
682 SfxSplitWindow *p = pSplit[n];
683 if (p->GetWindowCount())
684 p->Lock();
687 // Delete Child-Windows
688 for ( n=0; n<pChildWins->Count(); )
690 SfxChildWin_Impl* pCW = (*pChildWins)[n];
691 pChildWins->Remove(n);
692 SfxChildWindow *pChild = pCW->pWin;
693 if (pChild)
695 pChild->Hide();
697 // If the child window is a direct child window and not in a
698 // SplitWindow, cancel it at the workwindow.
699 // After TH a cancellation on the SplitWindow is not necessary
700 // since this window is also destroyed (see below).
701 if (pCW->pCli)
702 ReleaseChild_Impl(*pChild->GetWindow());
703 pCW->pWin = 0;
704 pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChild->GetWindow() );
705 pChild->Destroy();
708 delete pCW;
710 // ATTENTION: The array itself is cleared after this loop!!
711 // Therefore we have to set every array entry to zero as it could be
712 // accessed by calling pChild->Destroy().
713 // Window::NotifyAllChildren() calls SfxWorkWindow::DataChanged_Impl for
714 // 8-bit displays (WM_QUERYPALETTECHANGED message due to focus change)!!
717 Reference< com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
718 Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
719 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
720 if ( xPropSet.is() )
724 Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
725 aValue >>= xLayoutManager;
727 catch ( Exception& )
732 if ( xLayoutManager.is() )
734 xLayoutManager->reset();
736 // Delete StatusBar
737 ResetStatusBar_Impl();
739 // Delete ObjectBars (this is done last, so that pChildren does not
740 // receive dead Pointers)
741 for ( sal_uInt16 i = 0; i < aObjBarList.size(); i++ )
743 // Not every position must be occupied
744 sal_uInt16 nId = aObjBarList[i].nId;
745 if ( nId )
746 aObjBarList[i].nId = 0;
750 // ObjectBars are all released at once, since they occupy a
751 // fixed contiguous area in the array pChild
752 pChildren->Remove(0, SFX_OBJECTBAR_MAX);
753 bSorted = sal_False;
755 nChildren = 0;
758 //====================================================================
759 // Virtual method for placing the child window.
761 void SfxWorkWindow::ArrangeChildren_Impl( sal_Bool /*bForce*/)
763 Arrange_Impl();
766 void SfxFrameWorkWin_Impl::ArrangeChildren_Impl( sal_Bool bForce )
768 if ( pFrame->IsClosing_Impl() || ( m_nLock && !bForce ))
769 return;
771 SfxInPlaceClient *pClient = 0;
772 SfxViewFrame *pF = pFrame->GetCurrentViewFrame();
773 if ( pF && pF->GetViewShell() )
774 pClient = pF->GetViewShell()->GetIPClient();
776 if ( pClient )
777 return;
779 aClientArea = GetTopRect_Impl();
780 if ( aClientArea.IsEmpty() )
781 return;
783 SvBorder aBorder;
784 if ( nChildren )
786 if ( IsVisible_Impl() )
787 aBorder = Arrange_Impl();
789 // If the current application document contains a IPClient, then the
790 // object through SetTopToolFramePixel has to be assigned the available
791 // space. The object will then point to its UITools and sets the app border
792 // (-> SfxInPlaceEnv_Impl:: ArrangeChildren_Impl ()). Otherwise the
793 // app border is set here directly to possibly overwrite the Border that
794 // was set by an object from another document. The object does not set
795 // the SetAppBorder when it removes its UI tools so that no-dithering
796 // ObjectBar arises.
797 // (->SfxInPlaceEnv_Impl::ArrangeChildren_Impl())
799 pMasterFrame->SetToolSpaceBorderPixel_Impl( aBorder );
801 ArrangeAutoHideWindows( NULL );
804 //--------------------------------------------------------------------
806 SvBorder SfxWorkWindow::Arrange_Impl()
808 /* [Description]
810 This method organizes all visible child windows so that the docked window
811 sorted in order from the outside to the inside are placed after one
812 another. If a visible window does not fit anymore into the free
813 ClientArea, it is set to "not visible".
816 DBG_CHKTHIS(SfxWorkWindow, 0);
818 aClientArea = GetTopRect_Impl();
819 aUpperClientArea = aClientArea;
821 SvBorder aBorder;
822 if ( !nChildren )
823 return aBorder;
825 if (!bSorted)
826 Sort_Impl();
828 Point aPos;
829 Size aSize;
830 Rectangle aTmp( aClientArea );
832 for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
834 SfxChild_Impl* pCli = (*pChildren)[aSortedList[n]];
835 if ( !pCli->pWin )
836 continue;
838 // First, we assume that there is room for the window.
839 pCli->nVisible |= CHILD_FITS_IN;
841 // Skip invisiable windows
842 if (pCli->nVisible != CHILD_VISIBLE)
843 continue;
845 if ( pCli->bResize )
846 aSize = pCli->aSize;
847 else
848 aSize = pCli->pWin->GetSizePixel();
850 SvBorder aTemp = aBorder;
851 sal_Bool bAllowHiding = sal_True;
852 switch ( pCli->eAlign )
854 case SFX_ALIGN_HIGHESTTOP:
855 case SFX_ALIGN_TOP:
856 case SFX_ALIGN_TOOLBOXTOP:
857 case SFX_ALIGN_LOWESTTOP:
858 aSize.Width() = aTmp.GetWidth();
859 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
860 aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
861 bAllowHiding = sal_False;
862 aBorder.Top() += aSize.Height();
863 aPos = aTmp.TopLeft();
864 aTmp.Top() += aSize.Height();
865 if ( pCli->eAlign == SFX_ALIGN_HIGHESTTOP )
866 aUpperClientArea.Top() += aSize.Height();
867 break;
869 case SFX_ALIGN_LOWESTBOTTOM:
870 case SFX_ALIGN_BOTTOM:
871 case SFX_ALIGN_TOOLBOXBOTTOM:
872 case SFX_ALIGN_HIGHESTBOTTOM:
873 aSize.Width() = aTmp.GetWidth();
874 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
875 aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
876 aBorder.Bottom() += aSize.Height();
877 aPos = aTmp.BottomLeft();
878 aPos.Y() -= (aSize.Height()-1);
879 aTmp.Bottom() -= aSize.Height();
880 if ( pCli->eAlign == SFX_ALIGN_LOWESTBOTTOM )
881 aUpperClientArea.Bottom() -= aSize.Height();
882 break;
884 case SFX_ALIGN_FIRSTLEFT:
885 case SFX_ALIGN_LEFT:
886 case SFX_ALIGN_LASTLEFT:
887 case SFX_ALIGN_TOOLBOXLEFT:
888 aSize.Height() = aTmp.GetHeight();
889 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
890 aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
891 bAllowHiding = sal_False;
892 aBorder.Left() += aSize.Width();
893 aPos = aTmp.TopLeft();
894 aTmp.Left() += aSize.Width();
895 if ( pCli->eAlign != SFX_ALIGN_TOOLBOXLEFT )
896 aUpperClientArea.Left() += aSize.Width();
897 break;
899 case SFX_ALIGN_FIRSTRIGHT:
900 case SFX_ALIGN_RIGHT:
901 case SFX_ALIGN_LASTRIGHT:
902 case SFX_ALIGN_TOOLBOXRIGHT:
903 aSize.Height() = aTmp.GetHeight();
904 if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
905 aSize = ((SplitWindow *)(pCli->pWin))->CalcLayoutSizePixel( aSize );
906 aBorder.Right() += aSize.Width();
907 aPos = aTmp.TopRight();
908 aPos.X() -= (aSize.Width()-1);
909 aTmp.Right() -= aSize.Width();
910 if ( pCli->eAlign != SFX_ALIGN_TOOLBOXRIGHT )
911 aUpperClientArea.Right() -= aSize.Width();
912 break;
914 default:
915 pCli->aSize = pCli->pWin->GetSizePixel();
916 pCli->bResize = sal_False;
917 continue;
920 pCli->pWin->SetPosSizePixel( aPos, aSize );
921 pCli->bResize = sal_False;
922 pCli->aSize = aSize;
923 if( bAllowHiding && !RequestTopToolSpacePixel_Impl( aBorder ) )
925 pCli->nVisible ^= CHILD_FITS_IN;
926 aBorder = aTemp;
930 if ( aClientArea.GetWidth() >= aBorder.Left() + aBorder.Right() )
932 aClientArea.Left() += aBorder.Left();
933 aClientArea.Right() -= aBorder.Right();
935 else
937 aBorder.Left() = aClientArea.Left();
938 aBorder.Right() = aClientArea.Right();
939 aClientArea.Right() = aClientArea.Left() = aTmp.Left();
942 if ( aClientArea.GetHeight() >= aBorder.Top() + aBorder.Bottom() )
944 aClientArea.Top() += aBorder.Top();
945 aClientArea.Bottom() -= aBorder.Bottom();
947 else
949 aBorder.Top() = aClientArea.Top();
950 aBorder.Bottom() = aClientArea.Bottom();
951 aClientArea.Top() = aClientArea.Bottom() = aTmp.Top();
954 return IsDockingAllowed() ? aBorder : SvBorder();
957 sal_Bool SfxWorkWindow::PrepareClose_Impl()
959 for (sal_uInt16 n=0; n<pChildWins->Count(); n++)
961 SfxChildWin_Impl *pCW = (*pChildWins)[n];
962 SfxChildWindow *pChild = pCW->pWin;
963 if ( pChild && !pChild->QueryClose() )
964 return sal_False;
967 return sal_True;
970 //--------------------------------------------------------------------
972 SfxChild_Impl* SfxWorkWindow::RegisterChild_Impl( Window& rWindow,
973 SfxChildAlignment eAlign, sal_Bool bCanGetFocus )
975 DBG_CHKTHIS(SfxWorkWindow, 0);
976 DBG_ASSERT( pChildren->Count() < 255, "too many children" );
977 DBG_ASSERT( SfxChildAlignValid(eAlign), "invalid align" );
978 DBG_ASSERT( !FindChild_Impl(rWindow), "child registered more than once" );
981 if ( rWindow.GetParent() != pWorkWin )
982 rWindow.SetParent( pWorkWin );
984 SfxChild_Impl *pChild = new SfxChild_Impl(rWindow, rWindow.GetSizePixel(),
985 eAlign, rWindow.IsVisible());
986 pChild->bCanGetFocus = bCanGetFocus;
988 pChildren->Insert(pChildren->Count(), pChild);
989 bSorted = sal_False;
990 nChildren++;
991 return (*pChildren)[pChildren->Count()-1];
994 //--------------------------------------------------------------------
996 void SfxWorkWindow::ReleaseChild_Impl( Window& rWindow )
998 DBG_CHKTHIS(SfxWorkWindow, 0);
1000 SfxChild_Impl *pChild = 0;
1001 sal_uInt16 nPos;
1002 for ( nPos = 0; nPos < pChildren->Count(); ++nPos )
1004 pChild = (*pChildren)[nPos];
1005 if ( pChild )
1006 if ( pChild->pWin == &rWindow )
1007 break;
1010 if ( nPos < pChildren->Count() )
1012 bSorted = sal_False;
1013 nChildren--;
1014 pChildren->Remove(nPos);
1015 delete pChild;
1017 else {
1018 OSL_FAIL( "releasing unregistered child" );
1022 //--------------------------------------------------------------------
1024 SfxChild_Impl* SfxWorkWindow::FindChild_Impl( const Window& rWindow ) const
1026 DBG_CHKTHIS(SfxWorkWindow, 0);
1028 SfxChild_Impl *pChild = 0;
1029 sal_uInt16 nCount = pChildren->Count();
1030 for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
1032 pChild = (*pChildren)[nPos];
1033 if ( pChild )
1034 if ( pChild->pWin == &rWindow )
1035 return pChild;
1038 return 0;
1041 //--------------------------------------------------------------------
1043 void SfxWorkWindow::ShowChildren_Impl()
1045 DBG_CHKTHIS(SfxWorkWindow, 0);
1047 bool bInvisible = ( !IsVisible_Impl() || ( !pWorkWin->IsReallyVisible() && !pWorkWin->IsReallyShown() ));
1049 SfxChild_Impl *pCli = 0;
1050 for ( sal_uInt16 nPos = 0; nPos < pChildren->Count(); ++nPos )
1052 SfxChildWin_Impl* pCW = 0;
1053 pCli = (*pChildren)[nPos];
1055 if ( pCli && pCli->pWin )
1057 // We have to find the SfxChildWin_Impl to retrieve the
1058 // SFX_CHILDWIN flags that can influence visibility.
1059 for (sal_uInt16 n=0; n<pChildWins->Count(); n++)
1061 SfxChildWin_Impl* pCWin = (*pChildWins)[n];
1062 SfxChild_Impl* pChild = pCWin->pCli;
1063 if ( pChild == pCli )
1065 pCW = pCWin;
1066 break;
1070 bool bVisible( !bInvisible );
1071 if ( pCW )
1073 // Check flag SFX_CHILDWIN_NEVERHIDE that forces us to show
1074 // the child window even in situations where no child window is
1075 // visible.
1076 sal_uInt16 nFlags = pCW->aInfo.nFlags;
1077 bVisible = !bInvisible || (( nFlags & SFX_CHILDWIN_NEVERHIDE ) != 0 );
1080 if ( CHILD_VISIBLE == (pCli->nVisible & CHILD_VISIBLE) && bVisible )
1082 sal_uInt16 nFlags = pCli->bSetFocus ? 0 : SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE;
1083 switch ( pCli->pWin->GetType() )
1085 case RSC_DOCKINGWINDOW :
1086 ((DockingWindow*)pCli->pWin)->Show( sal_True, nFlags );
1087 break;
1088 case RSC_SPLITWINDOW :
1089 ((SplitWindow*)pCli->pWin)->Show( sal_True, nFlags );
1090 break;
1091 default:
1092 pCli->pWin->Show( sal_True, nFlags );
1093 break;
1096 pCli->bSetFocus = sal_False;
1098 else
1100 switch ( pCli->pWin->GetType() )
1102 case RSC_DOCKINGWINDOW :
1103 ((DockingWindow*)pCli->pWin)->Hide();
1104 break;
1105 default:
1106 pCli->pWin->Hide();
1107 break;
1114 //--------------------------------------------------------------------
1116 void SfxWorkWindow::HideChildren_Impl()
1118 SfxChild_Impl *pChild = 0;
1119 for ( sal_uInt16 nPos = pChildren->Count(); nPos > 0; --nPos )
1121 pChild = (*pChildren)[nPos-1];
1122 if (pChild && pChild->pWin)
1124 switch ( pChild->pWin->GetType() )
1126 case RSC_DOCKINGWINDOW :
1127 ((DockingWindow*)pChild->pWin)->Hide();
1128 break;
1129 default:
1130 pChild->pWin->Hide();
1131 break;
1137 //------------------------------------------------------------------------
1139 void SfxWorkWindow::ResetObjectBars_Impl()
1141 sal_uInt16 n;
1142 for ( n = 0; n < aObjBarList.size(); n++ )
1143 aObjBarList[n].bDestroy = sal_True;
1145 for ( n = 0; n < pChildWins->Count(); ++n )
1146 (*pChildWins)[n]->nId = 0;
1149 //------------------------------------------------------------------------
1151 void SfxWorkWindow::SetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId,
1152 SfxInterface* pIFace, const String *pName)
1154 DBG_ASSERT( (nPos & SFX_POSITION_MASK) < SFX_OBJECTBAR_MAX,
1155 "object bar position overflow" );
1157 sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK;
1158 if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) )
1160 pParent->SetObjectBar_Impl( nPos, nResId, pIFace, pName );
1161 return;
1164 SfxObjectBar_Impl aObjBar;
1165 aObjBar.pIFace = pIFace;
1166 aObjBar.nId = sal::static_int_cast<sal_uInt16>(nResId);
1167 aObjBar.nPos = nRealPos;
1168 aObjBar.nMode = (nPos & SFX_VISIBILITY_MASK);
1169 if (pName)
1170 aObjBar.aName = *pName;
1171 else
1172 aObjBar.aName.Erase();
1174 for ( sal_uInt16 n=0; n<aObjBarList.size(); n++ )
1176 if ( aObjBarList[n].nId == aObjBar.nId )
1178 aObjBarList[n] = aObjBar;
1179 return;
1183 aObjBarList.push_back( aObjBar );
1186 //------------------------------------------------------------------------
1188 bool SfxWorkWindow::KnowsObjectBar_Impl( sal_uInt16 nPos ) const
1190 /* [Description]
1192 Determines if a object list is available at the position in question.
1193 This is independent for the fact whether it is actually turned on or off.
1197 sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK;
1198 if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) )
1199 return pParent->KnowsObjectBar_Impl( nPos );
1201 for ( sal_uInt16 n=0; n<aObjBarList.size(); n++ )
1203 if ( aObjBarList[n].nPos == nRealPos )
1204 return true;
1207 return false;
1210 //------------------------------------------------------------------------
1212 sal_Bool SfxWorkWindow::IsVisible_Impl( sal_uInt16 nMode ) const
1214 switch( nUpdateMode )
1216 case SFX_VISIBILITY_STANDARD:
1217 return sal_True;
1218 case SFX_VISIBILITY_UNVISIBLE:
1219 return sal_False;
1220 case SFX_VISIBILITY_PLUGSERVER:
1221 case SFX_VISIBILITY_PLUGCLIENT:
1222 case SFX_VISIBILITY_CLIENT:
1223 case SFX_VISIBILITY_SERVER:
1224 return !!(nMode & nUpdateMode);
1225 default:
1226 return !!(nMode & nOrigMode ) ||
1227 nOrigMode == SFX_VISIBILITY_STANDARD;
1231 void SfxFrameWorkWin_Impl::UpdateObjectBars_Impl()
1233 if ( pFrame->IsClosing_Impl() )
1234 return;
1236 SfxWorkWindow *pWork = pParent;
1237 while ( pWork )
1239 pWork->SfxWorkWindow::UpdateObjectBars_Impl();
1240 pWork = pWork->GetParent_Impl();
1243 SfxWorkWindow::UpdateObjectBars_Impl();
1246 pWork = pParent;
1247 while ( pWork )
1249 pWork->ArrangeChildren_Impl();
1250 pWork = pWork->GetParent_Impl();
1253 ArrangeChildren_Impl( sal_False );
1255 pWork = pParent;
1256 while ( pWork )
1258 pWork->ShowChildren_Impl();
1259 pWork = pWork->GetParent_Impl();
1262 ShowChildren_Impl();
1265 ShowChildren_Impl();
1268 Reference< ::com::sun::star::task::XStatusIndicator > SfxWorkWindow::GetStatusIndicator()
1270 Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1271 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1272 Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
1274 if ( xPropSet.is() )
1276 Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1277 aValue >>= xLayoutManager;
1278 if ( xLayoutManager.is() )
1280 xLayoutManager->createElement( m_aProgressBarResName );
1281 xLayoutManager->showElement( m_aProgressBarResName );
1283 Reference< ::com::sun::star::ui::XUIElement > xProgressBar =
1284 xLayoutManager->getElement( m_aProgressBarResName );
1285 if ( xProgressBar.is() )
1287 xStatusIndicator = Reference< ::com::sun::star::task::XStatusIndicator >(
1288 xProgressBar->getRealInterface(), UNO_QUERY );
1293 return xStatusIndicator;
1296 //------------------------------------------------------------------------
1298 sal_Bool SfxWorkWindow::IsPluginMode( SfxObjectShell* pObjShell )
1300 if ( pObjShell && pObjShell->GetMedium() )
1302 SFX_ITEMSET_ARG( pObjShell->GetMedium()->GetItemSet(), pViewOnlyItem, SfxBoolItem, SID_VIEWONLY, sal_False );
1303 if ( pViewOnlyItem && pViewOnlyItem->GetValue() )
1304 return sal_True;
1307 return sal_False;
1310 //------------------------------------------------------------------------
1312 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxWorkWindow::GetFrameInterface()
1314 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
1316 SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
1317 if ( pDispatcher )
1319 SfxViewFrame* pFrame = pDispatcher->GetFrame();
1320 if ( pFrame )
1321 xFrame = pFrame->GetFrame().GetFrameInterface();
1324 return xFrame;
1327 //------------------------------------------------------------------------
1329 void SfxWorkWindow::UpdateObjectBars_Impl()
1331 // Lock SplitWindows (which means supressing the Resize-Reaction of the
1332 // DockingWindows)
1333 sal_uInt16 n;
1334 for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
1336 SfxSplitWindow *p = pSplit[n];
1337 if (p->GetWindowCount())
1338 p->Lock();
1341 // you realize what is needed often (saves Code and execution time)
1342 SFX_APP();
1344 Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1345 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1347 if ( xPropSet.is() )
1349 Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1350 aValue >>= xLayoutManager;
1353 if ( !xLayoutManager.is() )
1354 return;
1356 sal_Bool bPluginMode( sal_False );
1357 SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
1359 if ( pDispatcher )
1361 SfxViewFrame* pFrame = pDispatcher->GetFrame();
1362 if ( pFrame )
1363 bPluginMode = IsPluginMode( pFrame->GetObjectShell() );
1366 // Iterate over all Toolboxes
1367 xLayoutManager->lock();
1368 for ( n = 0; n < aObjBarList.size(); ++n )
1370 sal_uInt16 nId = aObjBarList[n].nId;
1371 sal_Bool bDestroy = aObjBarList[n].bDestroy;
1373 // Determine the vaild mode for the ToolBox
1374 sal_uInt16 nTbxMode = aObjBarList[n].nMode;
1375 bool bFullScreenTbx = SFX_VISIBILITY_FULLSCREEN ==
1376 ( nTbxMode & SFX_VISIBILITY_FULLSCREEN );
1377 nTbxMode &= ~SFX_VISIBILITY_FULLSCREEN;
1378 nTbxMode &= ~SFX_VISIBILITY_VIEWER;
1380 // Is a ToolBox required in this context ?
1381 bool bModesMatching = ( nUpdateMode && ( nTbxMode & nUpdateMode) == nUpdateMode );
1382 if ( bDestroy )
1384 rtl::OUString aTbxId( m_aTbxTypeName );
1385 aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1386 xLayoutManager->destroyElement( aTbxId );
1388 else if ( nId != 0 && ( ( bModesMatching && !bIsFullScreen ) ||
1389 ( bIsFullScreen && bFullScreenTbx ) ) )
1391 rtl::OUString aTbxId( m_aTbxTypeName );
1392 aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1393 if ( !IsDockingAllowed() && !xLayoutManager->isElementFloating( aTbxId ))
1394 xLayoutManager->destroyElement( aTbxId );
1395 else
1397 xLayoutManager->requestElement( aTbxId );
1398 if ( bPluginMode )
1399 xLayoutManager->lockWindow( aTbxId );
1402 else if ( nId != 0 )
1404 // Delete the Toolbox at this Position if possible
1405 rtl::OUString aTbxId( m_aTbxTypeName );
1406 aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1407 xLayoutManager->destroyElement( aTbxId );
1411 UpdateStatusBar_Impl();
1413 // unlocking automatically forces Layout
1414 xLayoutManager->unlock();
1416 UpdateChildWindows_Impl();
1418 // Unlock the SplitWindows again
1419 for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
1421 SfxSplitWindow *p = pSplit[n];
1422 if (p->GetWindowCount())
1423 p->Lock(sal_False);
1427 bool SfxWorkWindow::AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const
1429 // or checking the availability of child windows, we need access to the module
1430 const SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
1431 const SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
1432 const SfxModule* pModule = pShell ? pShell->GetModule() : NULL;
1433 ENSURE_OR_RETURN( pModule, "SfxWorkWindow::UpdateChildWindows_Impl: did not find an SfxModule to ask for the child win availability!", true );
1434 return pModule->IsChildWindowAvailable( i_rCW.nId, pViewFrame );
1437 void SfxWorkWindow::UpdateChildWindows_Impl()
1439 // any current or in the context available Childwindows
1440 for ( sal_uInt16 n=0; n<pChildWins->Count(); n++ )
1442 SfxChildWin_Impl *pCW = (*pChildWins)[n];
1443 SfxChildWindow *pChildWin = pCW->pWin;
1444 sal_Bool bCreate = sal_False;
1445 if ( pCW->nId && !pCW->bDisabled && (pCW->aInfo.nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE || IsVisible_Impl( pCW->nVisibility ) ) )
1447 // In the context is an appropriate ChildWindow allowed;
1448 // it is also turned on?
1449 if ( pChildWin == NULL && pCW->bCreate )
1451 // Internal docking is only used for embedding into another
1452 // container. We force the floating state of all floatable
1453 // child windows.
1454 if ( !bInternalDockingAllowed )
1456 // Special case for all non-floatable child windows. We have
1457 // to prevent the creation here!
1458 bCreate = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
1460 else if ( !IsDockingAllowed() || bIsFullScreen ) // || !bInternalDocking )
1462 // In Presentation mode or FullScreen only FloatingWindows
1463 SfxChildAlignment eAlign;
1464 if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
1465 bCreate = ( eAlign == SFX_ALIGN_NOALIGNMENT );
1467 else
1468 bCreate = sal_True;
1470 if ( bCreate )
1471 bCreate = AllowChildWindowCreation_Impl( *pCW );
1473 // Currently, no window here, but it is enabled; windows
1474 // Create window and if possible theContext
1475 if ( bCreate )
1476 CreateChildWin_Impl( pCW, sal_False );
1478 if ( !bAllChildrenVisible )
1480 if ( pCW->pCli )
1481 pCW->pCli->nVisible &= ~CHILD_ACTIVE;
1484 else if ( pChildWin )
1486 // Window already exists, it should also be visible?
1487 if ( ( !bIsFullScreen || pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT ) && bAllChildrenVisible )
1489 // Update Mode is compatible; definitely enable it
1490 bCreate = AllowChildWindowCreation_Impl( *pCW );
1491 if ( bCreate )
1493 if ( pCW->pCli )
1495 // The window is a direct Child
1496 if ( bAllChildrenVisible && ( (IsDockingAllowed() && bInternalDockingAllowed) || pCW->pCli->eAlign == SFX_ALIGN_NOALIGNMENT ) )
1497 pCW->pCli->nVisible |= CHILD_NOT_HIDDEN;
1499 else
1501 if ( pCW->bCreate && IsDockingAllowed() && bInternalDockingAllowed )
1502 // The window ia within a SplitWindow
1503 ((SfxDockingWindow*)pChildWin->GetWindow())->Reappear_Impl();
1506 if ( pCW->nInterfaceId != pChildWin->GetContextId() )
1507 pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
1513 if ( pChildWin && !bCreate )
1515 if ( !pChildWin->QueryClose() || pChildWin->IsHideNotDelete() || Application::IsUICaptured() )
1517 if ( pCW->pCli )
1519 if ( pCW->pCli->nVisible & CHILD_NOT_HIDDEN )
1520 pCW->pCli->nVisible ^= CHILD_NOT_HIDDEN;
1522 else
1523 ((SfxDockingWindow*)pChildWin->GetWindow())->Disappear_Impl();
1525 else
1526 RemoveChildWin_Impl( pCW );
1531 void SfxWorkWindow::CreateChildWin_Impl( SfxChildWin_Impl *pCW, sal_Bool bSetFocus )
1533 if ( pCW->aInfo.bVisible != 42 )
1534 pCW->aInfo.bVisible = sal_True;
1536 SfxChildWindow *pChildWin = SfxChildWindow::CreateChildWindow( pCW->nId, pWorkWin, &GetBindings(), pCW->aInfo);
1537 if (pChildWin)
1539 if ( bSetFocus )
1540 bSetFocus = pChildWin->WantsFocus();
1541 pChildWin->SetWorkWindow_Impl( this );
1543 // At least the extra string is changed during the evaluation,
1544 // also get it anewed
1545 SfxChildWinInfo aInfo = pChildWin->GetInfo();
1546 pCW->aInfo.aExtraString = aInfo.aExtraString;
1547 pCW->aInfo.bVisible = aInfo.bVisible;
1548 pCW->aInfo.nFlags |= aInfo.nFlags;
1550 // The creation was successful
1551 GetBindings().Invalidate(pCW->nId);
1553 sal_uInt16 nPos = pChildWin->GetPosition();
1554 if (nPos != CHILDWIN_NOPOS)
1556 DBG_ASSERT(nPos < SFX_OBJECTBAR_MAX, "Illegal objectbar position!");
1557 if ((*pChildren)[TbxMatch(nPos)])// &&
1559 // ChildWindow replaces ObjectBar
1560 (*pChildren)[TbxMatch(nPos)]->nVisible ^= CHILD_NOT_HIDDEN;
1564 // make childwin keyboard accessible
1565 pWorkWin->GetSystemWindow()->GetTaskPaneList()->AddWindow( pChildWin->GetWindow() );
1567 pCW->pWin = pChildWin;
1569 if ( pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT || pChildWin->GetWindow()->GetParent() == pWorkWin)
1571 // The window is not docked or docked outside of one split windows
1572 // and must therefore be registered explicitly as a Child
1573 pCW->pCli = RegisterChild_Impl(*(pChildWin->GetWindow()), pChildWin->GetAlignment(), pChildWin->CanGetFocus());
1574 pCW->pCli->nVisible = CHILD_VISIBLE;
1575 if ( pChildWin->GetAlignment() != SFX_ALIGN_NOALIGNMENT && bIsFullScreen )
1576 pCW->pCli->nVisible ^= CHILD_ACTIVE;
1577 pCW->pCli->bSetFocus = bSetFocus;
1579 else
1581 // A docked window which parent is not a WorkingWindow, must lie
1582 // in a SplitWindow and thus not be explicitly registered.
1583 // This happens already in the initialization of SfxDockingWindows!
1586 if ( pCW->nInterfaceId != pChildWin->GetContextId() )
1587 pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
1589 // Save the information in the INI file
1590 SaveStatus_Impl(pChildWin, pCW->aInfo);
1594 void SfxWorkWindow::RemoveChildWin_Impl( SfxChildWin_Impl *pCW )
1596 sal_uInt16 nId = pCW->nSaveId;
1597 SfxChildWindow *pChildWin = pCW->pWin;
1599 // Save the information in the INI file
1600 sal_uInt16 nFlags = pCW->aInfo.nFlags;
1601 pCW->aInfo = pChildWin->GetInfo();
1602 pCW->aInfo.nFlags |= nFlags;
1603 SaveStatus_Impl(pChildWin, pCW->aInfo);
1605 pChildWin->Hide();
1607 if ( pCW->pCli )
1609 // Child window is a direct child window and must therefore unregister
1610 // itself from the WorkWindow
1611 pCW->pCli = 0;
1612 ReleaseChild_Impl(*pChildWin->GetWindow());
1614 else
1616 // ChildWindow is within a SplitWindow and unregister itself in
1617 // the destructor.
1620 pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChildWin->GetWindow() );
1621 pCW->pWin = 0;
1622 pChildWin->Destroy();
1624 GetBindings().Invalidate( nId );
1627 void SfxWorkWindow::ResetStatusBar_Impl()
1629 aStatBar.nId = 0;
1632 //--------------------------------------------------------------------
1633 void SfxWorkWindow::SetStatusBar_Impl( sal_uInt32 nResId, SfxShell*, SfxBindings& )
1635 if ( nResId && bShowStatusBar && IsVisible_Impl() )
1636 aStatBar.nId = sal::static_int_cast<sal_uInt16>(nResId);
1639 void SfxWorkWindow::UpdateStatusBar_Impl()
1641 Reference< ::com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1642 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1644 Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1645 aValue >>= xLayoutManager;
1647 // No status bar, if no ID is required or when in FullScreenView or
1648 // if disabled
1649 if ( aStatBar.nId && IsDockingAllowed() && bInternalDockingAllowed && bShowStatusBar &&
1650 ( (aStatBar.bOn && !bIsFullScreen) || aStatBar.bTemp ) )
1652 // Id has changed, thus create a suitable Statusbarmanager, this takes
1653 // over the current status bar;
1654 if ( xLayoutManager.is() )
1655 xLayoutManager->requestElement( m_aStatusBarResName );
1657 else
1659 // Destroy the current StatusBar
1660 // The Manager only creates the Status bar, does not destroy it.
1661 if ( xLayoutManager.is() )
1662 xLayoutManager->destroyElement( m_aStatusBarResName );
1666 void SfxWorkWindow::MakeVisible_Impl( sal_Bool bVis )
1668 if ( bVis )
1669 nOrigMode = SFX_VISIBILITY_STANDARD;
1670 else
1671 nOrigMode = SFX_VISIBILITY_UNVISIBLE;
1673 if ( nOrigMode != nUpdateMode)
1674 nUpdateMode = nOrigMode;
1677 sal_Bool SfxWorkWindow::IsVisible_Impl()
1679 return nOrigMode != SFX_VISIBILITY_UNVISIBLE;
1682 //------------------------------------------------------------------------
1683 void SfxWorkWindow::HidePopups_Impl(sal_Bool bHide, sal_Bool bParent, sal_uInt16 nId )
1685 for ( sal_uInt16 n = 0; n < pChildWins->Count(); ++n )
1687 SfxChildWindow *pCW = (*pChildWins)[n]->pWin;
1688 if (pCW && pCW->GetAlignment() == SFX_ALIGN_NOALIGNMENT && pCW->GetType() != nId)
1690 Window *pWin = pCW->GetWindow();
1691 SfxChild_Impl *pChild = FindChild_Impl(*pWin);
1692 if (bHide)
1694 pChild->nVisible &= ~CHILD_ACTIVE;
1695 pCW->Hide();
1697 else
1699 pChild->nVisible |= CHILD_ACTIVE;
1700 if ( CHILD_VISIBLE == (pChild->nVisible & CHILD_VISIBLE) )
1701 pCW->Show( SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1706 if ( bParent && pParent )
1707 pParent->HidePopups_Impl( bHide, bParent, nId );
1710 //------------------------------------------------------------------------
1712 void SfxWorkWindow::ConfigChild_Impl(SfxChildIdentifier eChild,
1713 SfxDockingConfig eConfig, sal_uInt16 nId)
1715 SfxDockingWindow* pDockWin=0;
1716 sal_uInt16 nPos = USHRT_MAX;
1717 Window *pWin=0;
1718 SfxChildWin_Impl *pCW = 0;
1720 if ( eChild == SFX_CHILDWIN_OBJECTBAR )
1722 return;
1724 else
1726 // configure direct childwindow
1727 for (sal_uInt16 n=0; n<pChildWins->Count(); n++)
1729 pCW = (*pChildWins)[n];
1730 SfxChildWindow *pChild = pCW->pWin;
1731 if ( pChild )
1733 if ( pChild->GetType() == nId )
1735 if ( pChild->GetWindow()->GetType() == RSC_DOCKINGWINDOW )
1736 // it's a DockingWindow
1737 pDockWin = (SfxDockingWindow*) pChild->GetWindow();
1738 else
1739 // FloatingWindow or ModelessDialog
1740 pWin = pChild->GetWindow();
1741 break;
1746 if ( pDockWin )
1748 if ( eChild == SFX_CHILDWIN_DOCKINGWINDOW || pDockWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT )
1750 if ( eChild == SFX_CHILDWIN_SPLITWINDOW && eConfig == SFX_TOGGLEFLOATMODE)
1752 // DockingWindow was dragged out of a SplitWindow
1753 pCW->pCli = RegisterChild_Impl(*pDockWin, pDockWin->GetAlignment(), pCW->pWin->CanGetFocus());
1754 pCW->pCli->nVisible = CHILD_VISIBLE;
1757 pWin = pDockWin;
1759 else
1761 SfxSplitWindow *pSplitWin = GetSplitWindow_Impl(pDockWin->GetAlignment());
1763 // configure DockingWindow inside a SplitWindow
1764 if ( eConfig == SFX_TOGGLEFLOATMODE)
1766 // DockingWindow was dragged into a SplitWindow
1767 pCW->pCli = 0;
1768 ReleaseChild_Impl(*pDockWin);
1771 pWin = pSplitWin->GetSplitWindow();
1772 if ( pSplitWin->GetWindowCount() == 1 )
1773 ((SplitWindow*)pWin)->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1777 DBG_ASSERT( pCW, "Unknown window!" );
1778 if ( !pCW && pParent )
1780 pParent->ConfigChild_Impl( eChild, eConfig, nId );
1781 return;
1785 if ( !bSorted )
1786 // windows may have been registered and released without an update until now
1787 Sort_Impl();
1789 SfxChild_Impl *pChild = 0;
1790 sal_uInt16 n;
1791 for ( n=0; n<aSortedList.size(); ++n )
1793 pChild = (*pChildren)[aSortedList[n]];
1794 if ( pChild )
1795 if ( pChild->pWin == pWin )
1796 break;
1799 if ( n < aSortedList.size() )
1800 // sometimes called while toggeling float mode
1801 nPos = aSortedList[n];
1803 switch ( eConfig )
1805 case SFX_SETDOCKINGRECTS :
1807 if ( nPos == USHRT_MAX )
1808 return;
1810 Rectangle aOuterRect( GetTopRect_Impl() );
1811 aOuterRect.SetPos( pWorkWin->OutputToScreenPixel( aOuterRect.TopLeft() ));
1812 Rectangle aInnerRect( aOuterRect );
1813 sal_Bool bTbx = (eChild == SFX_CHILDWIN_OBJECTBAR);
1815 // The current affected window is included in the calculation of
1816 // the inner rectangle!
1817 for ( sal_uInt16 m=0; m<aSortedList.size(); ++m )
1819 sal_uInt16 i=aSortedList[m];
1820 SfxChild_Impl* pCli = (*pChildren)[i];
1822 if ( pCli && pCli->nVisible == CHILD_VISIBLE && pCli->pWin )
1824 switch ( pCli->eAlign )
1826 case SFX_ALIGN_TOP:
1827 // Objekt-Toolboxes come always last
1828 aInnerRect.Top() += pCli->aSize.Height();
1829 break;
1831 case SFX_ALIGN_TOOLBOXTOP:
1832 // Toolbox has priority, if no higher Position
1833 if ( bTbx && i <= nPos)
1834 aInnerRect.Top() += pCli->aSize.Height();
1835 break;
1837 case SFX_ALIGN_HIGHESTTOP:
1838 // Always performed first
1839 aInnerRect.Top() += pCli->aSize.Height();
1840 break;
1842 case SFX_ALIGN_LOWESTTOP:
1843 // Is only counted if it is the current window
1844 if ( i == nPos )
1845 aInnerRect.Top() += pCli->aSize.Height();
1846 break;
1848 case SFX_ALIGN_BOTTOM:
1849 // Objekt-Toolboxes come always last
1850 aInnerRect.Bottom() -= pCli->aSize.Height();
1851 break;
1853 case SFX_ALIGN_TOOLBOXBOTTOM:
1854 // Toolbox has priority, if no higher Position
1855 if ( bTbx && i <= nPos)
1856 aInnerRect.Bottom() -= pCli->aSize.Height();
1857 break;
1859 case SFX_ALIGN_LOWESTBOTTOM:
1860 // Always performed first
1861 aInnerRect.Bottom() -= pCli->aSize.Height();
1862 break;
1864 case SFX_ALIGN_HIGHESTBOTTOM:
1865 // Is only counted if it is the current window
1866 if ( i == nPos )
1867 aInnerRect.Bottom() -= pCli->aSize.Height();
1868 break;
1870 case SFX_ALIGN_LEFT:
1871 // Toolboxes come always last
1872 aInnerRect.Left() += pCli->aSize.Width();
1873 break;
1875 case SFX_ALIGN_TOOLBOXLEFT:
1876 // Toolboxes come always last
1877 if (bTbx && i <= nPos)
1878 aInnerRect.Left() += pCli->aSize.Width();
1879 break;
1881 case SFX_ALIGN_FIRSTLEFT:
1882 // Always performed first
1883 aInnerRect.Left() += pCli->aSize.Width();
1884 break;
1886 case SFX_ALIGN_LASTLEFT:
1887 // Is only counted if it is the current window
1888 if (i == nPos)
1889 aInnerRect.Left() += pCli->aSize.Width();
1891 case SFX_ALIGN_RIGHT:
1892 // Toolboxes come always last
1893 aInnerRect.Right() -= pCli->aSize.Width();
1894 break;
1896 case SFX_ALIGN_TOOLBOXRIGHT:
1897 // Toolboxes come always last
1898 if (bTbx && i <= nPos)
1899 aInnerRect.Right() -= pCli->aSize.Width();
1900 break;
1902 case SFX_ALIGN_FIRSTRIGHT:
1903 // Is only counted if it is the current window
1904 if (i == nPos)
1905 aInnerRect.Right() -= pCli->aSize.Width();
1906 break;
1908 case SFX_ALIGN_LASTRIGHT:
1909 // Always performed first
1910 aInnerRect.Right() -= pCli->aSize.Width();
1911 break;
1913 default:
1914 break;
1919 pDockWin->SetDockingRects(aOuterRect, aInnerRect);
1920 break;
1923 case SFX_MOVEDOCKINGWINDOW :
1924 case SFX_ALIGNDOCKINGWINDOW :
1925 case SFX_TOGGLEFLOATMODE:
1927 if ( nPos == USHRT_MAX && !pCW )
1928 return;
1930 SfxChildAlignment eAlign = SFX_ALIGN_NOALIGNMENT;
1931 SfxChild_Impl *pCli = ( nPos != USHRT_MAX ) ? (*pChildren)[nPos] : 0;
1932 if ( pCli && pDockWin )
1934 eAlign = pDockWin->GetAlignment();
1935 if ( eChild == SFX_CHILDWIN_DOCKINGWINDOW || eAlign == SFX_ALIGN_NOALIGNMENT)
1937 // configuration inside the SplitWindow, no change for the SplitWindows' configuration
1938 pCli->bResize = sal_True;
1939 pCli->aSize = pDockWin->GetSizePixel();
1943 if ( pCli )
1945 if( pCli->eAlign != eAlign )
1947 bSorted = sal_False;
1948 pCli->eAlign = eAlign;
1951 ArrangeChildren_Impl();
1952 ShowChildren_Impl();
1955 if ( pCW && pCW->pWin )
1957 // store changed configuration
1958 sal_uInt16 nFlags = pCW->aInfo.nFlags;
1959 pCW->aInfo = pCW->pWin->GetInfo();
1960 pCW->aInfo.nFlags |= nFlags;
1961 if ( eConfig != SFX_MOVEDOCKINGWINDOW )
1962 SaveStatus_Impl( pCW->pWin, pCW->aInfo);
1965 break;
1970 //--------------------------------------------------------------------
1972 void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId, sal_Bool bEnabled, sal_uInt16 nMode )
1974 sal_uInt16 nInter = (sal_uInt16) ( lId >> 16 );
1975 sal_uInt16 nId = (sal_uInt16) ( lId & 0xFFFF );
1977 SfxChildWin_Impl *pCW=NULL;
1978 SfxWorkWindow *pWork = pParent;
1980 // Get the top parent, child windows are alwas registered at the
1981 // task of the WorkWindow for example the frame or on AppWorkWindow
1982 while ( pWork && pWork->pParent )
1983 pWork = pWork->pParent;
1985 if ( pWork )
1987 // The Parent already known?
1988 sal_uInt16 nCount = pWork->pChildWins->Count();
1989 for (sal_uInt16 n=0; n<nCount; n++)
1990 if ((*pWork->pChildWins)[n]->nSaveId == nId)
1992 pCW = (*pWork->pChildWins)[n];
1993 break;
1997 if ( !pCW )
1999 // If no Parent or the Parent us still unknown, then search here
2000 sal_uInt16 nCount = pChildWins->Count();
2001 for (sal_uInt16 n=0; n<nCount; n++)
2002 if ((*pChildWins)[n]->nSaveId == nId)
2004 pCW = (*pChildWins)[n];
2005 break;
2009 if ( !pCW )
2011 // If new, then initialize, add this here depending on the flag or
2012 // the Parent
2013 pCW = new SfxChildWin_Impl( lId );
2014 pCW->nId = nId;
2015 InitializeChild_Impl( pCW );
2016 if ( pWork && !( pCW->aInfo.nFlags & SFX_CHILDWIN_TASK ) )
2017 pWork->pChildWins->Insert( pWork->pChildWins->Count(), pCW );
2018 else
2019 pChildWins->Insert( pChildWins->Count(), pCW );
2022 pCW->nId = nId;
2023 if ( nInter )
2024 pCW->nInterfaceId = nInter;
2025 pCW->nVisibility = nMode;
2026 pCW->bEnable = bEnabled;
2027 pCW->nVisibility = nMode;
2030 //--------------------------------------------------------------------
2031 // The on/of-Status of a ChildWindows is switched
2033 void SfxWorkWindow::ToggleChildWindow_Impl(sal_uInt16 nId, sal_Bool bSetFocus)
2035 sal_uInt16 nCount = pChildWins->Count();
2036 sal_uInt16 n;
2037 for (n=0; n<nCount; n++)
2038 if ((*pChildWins)[n]->nId == nId)
2039 break;
2041 if ( n<nCount )
2043 // The Window is aleady known
2044 SfxChildWin_Impl *pCW = (*pChildWins)[n];
2045 SfxChildWindow *pChild = pCW->pWin;
2047 bool bCreationAllowed( true );
2048 if ( !bInternalDockingAllowed )
2050 // Special case for all non-floatable child windows. We have
2051 // to prevent the creation here!
2052 bCreationAllowed = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
2055 if ( bCreationAllowed )
2057 if ( pCW->bCreate )
2059 if ( pChild )
2061 if ( pChild->QueryClose() )
2063 pCW->bCreate = sal_False;
2064 if ( pChild->IsHideAtToggle() )
2066 ShowChildWindow_Impl( nId, sal_False, bSetFocus );
2068 else
2070 // The Window should be switched off
2071 pChild->SetVisible_Impl( sal_False );
2072 RemoveChildWin_Impl( pCW );
2076 else
2078 // no actual Window exists, yet => just remember the "switched off" state
2079 pCW->bCreate = sal_False;
2082 else
2084 pCW->bCreate = AllowChildWindowCreation_Impl( *pCW );
2085 if ( pCW->bCreate )
2087 if ( pChild )
2089 ShowChildWindow_Impl( nId, sal_True, bSetFocus );
2091 else
2093 // create actual Window
2094 CreateChildWin_Impl( pCW, bSetFocus );
2095 if ( !pCW->pWin )
2096 // no success
2097 pCW->bCreate = sal_False;
2103 ArrangeChildren_Impl();
2104 ShowChildren_Impl();
2106 if ( pCW->bCreate && bCreationAllowed )
2108 if ( !pCW->pCli )
2110 SfxDockingWindow *pDock =
2111 (SfxDockingWindow*) pCW->pWin->GetWindow();
2112 if ( pDock->IsAutoHide_Impl() )
2113 pDock->AutoShow_Impl();
2117 return;
2119 else if ( pParent )
2121 pParent->ToggleChildWindow_Impl( nId, bSetFocus );
2122 return;
2125 #ifdef DBG_UTIL
2126 nCount = pChildWins->Count();
2127 for (n=0; n<nCount; n++)
2128 if ((*pChildWins)[n]->nSaveId == nId)
2129 break;
2131 if ( n < nCount )
2133 OSL_FAIL("The ChildWindow is not in context!");
2135 else
2137 OSL_FAIL("The ChildWindow is not registered!");
2139 #endif
2142 //--------------------------------------------------------------------
2144 sal_Bool SfxWorkWindow::HasChildWindow_Impl(sal_uInt16 nId)
2146 sal_uInt16 nCount = pChildWins->Count();
2147 sal_uInt16 n;
2148 for (n=0; n<nCount; n++)
2149 if ((*pChildWins)[n]->nSaveId == nId)
2150 break;
2152 if (n<nCount)
2154 SfxChildWin_Impl *pCW = (*pChildWins)[n];
2155 SfxChildWindow *pChild = pCW->pWin;
2156 return ( pChild && pCW->bCreate );
2159 if ( pParent )
2160 return pParent->HasChildWindow_Impl( nId );
2162 return sal_False;
2165 sal_Bool SfxWorkWindow::IsFloating( sal_uInt16 nId )
2167 SfxChildWin_Impl *pCW=NULL;
2168 SfxWorkWindow *pWork = pParent;
2170 // Get the top parent, child windows are alwas registered at the
2171 // task of the WorkWindow for example the frame or on AppWorkWindow
2172 while ( pWork && pWork->pParent )
2173 pWork = pWork->pParent;
2175 if ( pWork )
2177 // The Parent already known?
2178 sal_uInt16 nCount = pWork->pChildWins->Count();
2179 for (sal_uInt16 n=0; n<nCount; n++)
2180 if ((*pWork->pChildWins)[n]->nSaveId == nId)
2182 pCW = (*pWork->pChildWins)[n];
2183 break;
2187 if ( !pCW )
2189 // If no Parent or the Parent us still unknown, then search here
2190 sal_uInt16 nCount = pChildWins->Count();
2191 for (sal_uInt16 n=0; n<nCount; n++)
2192 if ((*pChildWins)[n]->nSaveId == nId)
2194 pCW = (*pChildWins)[n];
2195 break;
2199 if ( !pCW )
2201 // If new, then initialize, add this here depending on the flag or
2202 // the Parent
2203 pCW = new SfxChildWin_Impl( nId );
2204 pCW->bEnable = sal_False;
2205 pCW->nId = 0;
2206 pCW->nVisibility = 0;
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 );
2214 SfxChildAlignment eAlign;
2215 if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
2216 return( eAlign == SFX_ALIGN_NOALIGNMENT );
2217 else
2218 return sal_True;
2221 //--------------------------------------------------------------------
2223 sal_Bool SfxWorkWindow::KnowsChildWindow_Impl(sal_uInt16 nId)
2225 SfxChildWin_Impl *pCW=0;
2226 sal_uInt16 nCount = pChildWins->Count();
2227 sal_uInt16 n;
2228 for (n=0; n<nCount; n++)
2230 pCW = (*pChildWins)[n];
2231 if ( pCW->nSaveId == nId)
2232 break;
2235 if (n<nCount)
2237 if ( !(pCW->aInfo.nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE) && !IsVisible_Impl( pCW->nVisibility ) )
2238 return sal_False;
2239 return pCW->bEnable;
2241 else if ( pParent )
2242 return pParent->KnowsChildWindow_Impl( nId );
2243 else
2244 return sal_False;
2247 //--------------------------------------------------------------------
2249 void SfxWorkWindow::SetChildWindow_Impl(sal_uInt16 nId, sal_Bool bOn, sal_Bool bSetFocus)
2251 SfxChildWin_Impl *pCW=NULL;
2252 SfxWorkWindow *pWork = pParent;
2254 // Get the top parent, child windows are alwas registered at the
2255 // task of the WorkWindow for example the frame or on AppWorkWindow
2256 while ( pWork && pWork->pParent )
2257 pWork = pWork->pParent;
2259 if ( pWork )
2261 // The Parent already known?
2262 sal_uInt16 nCount = pWork->pChildWins->Count();
2263 for (sal_uInt16 n=0; n<nCount; n++)
2264 if ((*pWork->pChildWins)[n]->nSaveId == nId)
2266 pCW = (*pWork->pChildWins)[n];
2267 break;
2271 if ( !pCW )
2273 // If no Parent or the Parent us still unknown, then search here
2274 sal_uInt16 nCount = pChildWins->Count();
2275 for (sal_uInt16 n=0; n<nCount; n++)
2276 if ((*pChildWins)[n]->nSaveId == nId)
2278 pCW = (*pChildWins)[n];
2279 pWork = this;
2280 break;
2284 if ( !pCW )
2286 // If new, then initialize, add this here depending on the flag or
2287 // the Parent
2288 pCW = new SfxChildWin_Impl( nId );
2289 InitializeChild_Impl( pCW );
2290 if ( !pWork || pCW->aInfo.nFlags & SFX_CHILDWIN_TASK )
2291 pWork = this;
2292 pWork->pChildWins->Insert( pWork->pChildWins->Count(), pCW );
2295 if ( pCW->bCreate != bOn )
2296 pWork->ToggleChildWindow_Impl(nId,bSetFocus);
2299 //--------------------------------------------------------------------
2301 void SfxWorkWindow::ShowChildWindow_Impl(sal_uInt16 nId, sal_Bool bVisible, sal_Bool bSetFocus)
2303 sal_uInt16 nCount = pChildWins->Count();
2304 SfxChildWin_Impl* pCW=0;
2305 sal_uInt16 n;
2306 for (n=0; n<nCount; n++)
2308 pCW = (*pChildWins)[n];
2309 if (pCW->nId == nId)
2310 break;
2313 if ( n<nCount )
2315 SfxChildWindow *pChildWin = pCW->pWin;
2316 if ( pChildWin )
2318 if ( bVisible )
2320 if ( pCW->pCli )
2322 pCW->pCli->bSetFocus = bSetFocus;
2323 pCW->pCli->nVisible = CHILD_VISIBLE;
2324 pChildWin->Show( bSetFocus && pChildWin->WantsFocus() ? 0 : SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
2326 else
2327 ((SfxDockingWindow*)pChildWin->GetWindow())->Reappear_Impl();
2330 else
2332 if ( pCW->pCli )
2334 pCW->pCli->nVisible = CHILD_VISIBLE ^ CHILD_NOT_HIDDEN;
2335 pCW->pWin->Hide();
2337 else
2338 ((SfxDockingWindow*)pChildWin->GetWindow())->Disappear_Impl();
2342 ArrangeChildren_Impl();
2343 ShowChildren_Impl();
2345 else if ( bVisible )
2347 SetChildWindow_Impl( nId, sal_True, bSetFocus );
2348 pChildWin = pCW->pWin;
2351 if ( pChildWin )
2353 pChildWin->SetVisible_Impl( bVisible );
2354 sal_uInt16 nFlags = pCW->aInfo.nFlags;
2355 pCW->aInfo = pChildWin->GetInfo();
2356 pCW->aInfo.nFlags |= nFlags;
2357 if ( !pCW->bCreate )
2358 SaveStatus_Impl( pChildWin, pCW->aInfo );
2361 return;
2364 if ( pParent )
2366 pParent->ShowChildWindow_Impl( nId, bVisible, bSetFocus );
2367 return;
2370 #ifdef DBG_UTIL
2371 nCount = pChildWins->Count();
2372 for (n=0; n<nCount; n++)
2373 if ((*pChildWins)[n]->nSaveId == nId)
2374 break;
2376 if ( n<nCount )
2378 OSL_FAIL("The ChildWindow is not in context!");
2380 else
2382 OSL_FAIL("The ChildWindow is not registered");
2384 #endif
2387 //--------------------------------------------------------------------
2389 SfxChildWindow* SfxWorkWindow::GetChildWindow_Impl(sal_uInt16 nId)
2391 sal_uInt16 nCount = pChildWins->Count();
2392 sal_uInt16 n;
2393 for (n=0; n<nCount; n++)
2394 if ((*pChildWins)[n]->nSaveId == nId)
2395 break;
2397 if (n<nCount)
2398 return (*pChildWins)[n]->pWin;
2399 else if ( pParent )
2400 return pParent->GetChildWindow_Impl( nId );
2401 return 0;
2404 //------------------------------------------------------------------------
2406 void SfxWorkWindow::ResetChildWindows_Impl()
2408 for ( sal_uInt16 n = 0; n < pChildWins->Count(); ++n )
2410 (*pChildWins)[n]->nId = 0;
2411 (*pChildWins)[n]->bEnable = sal_False;
2415 //------------------------------------------------------------------------
2416 // Virtual method that returns the size of the area (client area) of the
2417 // parent windows, in which the ChildWindow can be fitted.
2419 Rectangle SfxWorkWindow::GetTopRect_Impl()
2421 return Rectangle (Point(), pWorkWin->GetOutputSizePixel() );
2424 //------------------------------------------------------------------------
2425 // Virtual method that returns the size of the area (client area) of the
2426 // parent windows, in which the ChildWindow can be fitted.
2428 Rectangle SfxFrameWorkWin_Impl::GetTopRect_Impl()
2430 return pMasterFrame->GetTopOuterRectPixel_Impl();
2433 //------------------------------------------------------------------------
2434 // Virtual method to find out if there is room for a ChildWindow in the
2435 // client area of the parent.
2437 sal_Bool SfxWorkWindow::RequestTopToolSpacePixel_Impl( SvBorder aBorder )
2439 if ( !IsDockingAllowed() ||
2440 aClientArea.GetWidth() < aBorder.Left() + aBorder.Right() ||
2441 aClientArea.GetHeight() < aBorder.Top() + aBorder.Bottom() )
2442 return sal_False;
2443 else
2444 return sal_True;;
2447 void SfxWorkWindow::SaveStatus_Impl(SfxChildWindow *pChild, const SfxChildWinInfo &rInfo)
2449 // The Status of the Presentation mode is not saved
2450 if ( IsDockingAllowed() && bInternalDockingAllowed )
2451 pChild->SaveStatus(rInfo);
2454 void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl *pCW)
2456 SfxChildWinFactory* pFact=0;
2457 SfxApplication *pApp = SFX_APP();
2459 SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
2460 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
2462 pFact = rFactories[nFactory];
2463 if ( pFact->nId == pCW->nSaveId )
2465 pCW->aInfo = pFact->aInfo;
2466 SfxChildWindow::InitializeChildWinFactory_Impl(
2467 pCW->nSaveId, pCW->aInfo);
2468 pCW->bCreate = pCW->aInfo.bVisible;
2469 sal_uInt16 nFlags = pFact->aInfo.nFlags;
2470 if ( nFlags & SFX_CHILDWIN_TASK )
2471 pCW->aInfo.nFlags |= SFX_CHILDWIN_TASK;
2472 if ( nFlags & SFX_CHILDWIN_CANTGETFOCUS )
2473 pCW->aInfo.nFlags |= SFX_CHILDWIN_CANTGETFOCUS;
2474 if ( nFlags & SFX_CHILDWIN_FORCEDOCK )
2475 pCW->aInfo.nFlags |= SFX_CHILDWIN_FORCEDOCK;
2476 pFact->aInfo = pCW->aInfo;
2477 return;
2482 SfxDispatcher *pDisp = pBindings->GetDispatcher_Impl();
2483 SfxModule *pMod = pDisp ? SfxModule::GetActiveModule( pDisp->GetFrame() ) :0;
2484 if ( pMod )
2486 SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
2487 if ( pFactories )
2489 SfxChildWinFactArr_Impl &rFactories = *pFactories;
2490 for ( sal_uInt16 nFactory = 0; nFactory < rFactories.Count(); ++nFactory )
2492 pFact = rFactories[nFactory];
2493 if ( pFact->nId == pCW->nSaveId )
2495 pCW->aInfo = pFact->aInfo;
2496 SfxChildWindow::InitializeChildWinFactory_Impl(
2497 pCW->nSaveId, pCW->aInfo);
2498 pCW->bCreate = pCW->aInfo.bVisible;
2499 sal_uInt16 nFlags = pFact->aInfo.nFlags;
2500 if ( nFlags & SFX_CHILDWIN_TASK )
2501 pCW->aInfo.nFlags |= SFX_CHILDWIN_TASK;
2502 if ( nFlags & SFX_CHILDWIN_CANTGETFOCUS )
2503 pCW->aInfo.nFlags |= SFX_CHILDWIN_CANTGETFOCUS;
2504 if ( nFlags & SFX_CHILDWIN_FORCEDOCK )
2505 pCW->aInfo.nFlags |= SFX_CHILDWIN_FORCEDOCK;
2506 if ( nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE )
2507 pCW->aInfo.nFlags |= SFX_CHILDWIN_ALWAYSAVAILABLE;
2508 pFact->aInfo = pCW->aInfo;
2509 return;
2516 SfxSplitWindow* SfxWorkWindow::GetSplitWindow_Impl( SfxChildAlignment eAlign )
2518 switch ( eAlign )
2520 case SFX_ALIGN_TOP:
2521 return pSplit[2];
2523 case SFX_ALIGN_BOTTOM:
2524 return pSplit[3];
2526 case SFX_ALIGN_LEFT:
2527 return pSplit[0];
2529 case SFX_ALIGN_RIGHT:
2530 return pSplit[1];
2532 default:
2533 return 0;
2537 void SfxWorkWindow::MakeChildrenVisible_Impl( sal_Bool bVis )
2539 if ( pParent )
2540 pParent->MakeChildrenVisible_Impl( bVis );
2542 bAllChildrenVisible = bVis;
2543 if ( bVis )
2545 if ( !bSorted )
2546 Sort_Impl();
2547 for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
2549 SfxChild_Impl* pCli = (*pChildren)[aSortedList[n]];
2550 if ( (pCli->eAlign == SFX_ALIGN_NOALIGNMENT) || (IsDockingAllowed() && bInternalDockingAllowed) )
2551 pCli->nVisible |= CHILD_ACTIVE;
2554 else
2556 if ( !bSorted )
2557 Sort_Impl();
2558 for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
2560 SfxChild_Impl* pCli = (*pChildren)[aSortedList[n]];
2561 pCli->nVisible &= ~CHILD_ACTIVE;
2566 sal_Bool SfxWorkWindow::IsAutoHideMode( const SfxSplitWindow *pSplitWin )
2568 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2570 if ( pSplit[n] != pSplitWin && pSplit[n]->IsAutoHide( sal_True ) )
2571 return sal_True;
2573 return sal_False;
2577 void SfxWorkWindow::EndAutoShow_Impl( Point aPos )
2579 if ( pParent )
2580 pParent->EndAutoShow_Impl( aPos );
2582 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2584 SfxSplitWindow *p = pSplit[n];
2585 if ( p && p->IsAutoHide() )
2587 Point aLocalPos = p->ScreenToOutputPixel( aPos );
2588 Point aEmptyPoint = Point();
2589 Rectangle aRect( aEmptyPoint, p->GetSizePixel() );
2590 if ( !aRect.IsInside( aLocalPos ) )
2591 p->FadeOut();
2596 void SfxWorkWindow::ArrangeAutoHideWindows( SfxSplitWindow *pActSplitWin )
2598 if ( m_nLock )
2599 return;
2601 if ( pParent )
2602 pParent->ArrangeAutoHideWindows( pActSplitWin );
2604 Rectangle aArea( aUpperClientArea );
2605 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2607 // Either dummy window or window in the auto-show-mode are processed
2608 // (not pinned, FadeIn).
2609 // Only the abandoned window may be invisible, because perhaps its
2610 // size is just beeing calculated before it is displayed.
2611 SfxSplitWindow* pSplitWin = pSplit[n];
2612 sal_Bool bDummyWindow = !pSplitWin->IsFadeIn();
2613 Window *pDummy = pSplitWin->GetSplitWindow();
2614 Window *pWin = bDummyWindow ? pDummy : pSplitWin;
2615 if ( (pSplitWin->IsPinned() && !bDummyWindow) || (!pWin->IsVisible() && pActSplitWin != pSplitWin) )
2616 continue;
2618 // Width and position of the dummy window as a starting point
2619 Size aSize = pDummy->GetSizePixel();
2620 Point aPos = pDummy->GetPosPixel();
2622 switch ( n )
2624 case ( 0 ) :
2626 // Left SplitWindow
2627 // Get the width of the Window yourself, if no DummyWindow
2628 if ( !bDummyWindow )
2629 aSize.Width() = pSplitWin->GetSizePixel().Width();
2631 // If a Window is visable to the left, then the free region
2632 // starts to the right from it, for example at the Client area
2633 long nLeft = aPos.X() + aSize.Width();
2634 if ( nLeft > aArea.Left() )
2635 aArea.Left() = nLeft;
2636 break;
2638 case ( 1 ) :
2640 // Right SplitWindow
2641 // Position to correct the difference of the widths
2642 aPos.X() += aSize.Width();
2644 // Get the width of the Window yourself, if no DummyWindow
2645 if ( !bDummyWindow )
2646 aSize.Width() = pSplitWin->GetSizePixel().Width();
2648 aPos.X() -= aSize.Width();
2650 // If already a window is opened at the left side, then the
2651 // right is not allowed to overlap this one.
2652 if ( aPos.X() < aArea.Left() )
2654 aPos.X() = aArea.Left();
2655 aSize.Width() = aArea.GetWidth();
2658 // If a Window is visable to the right, then the free region
2659 // starts to the left from it, for example at the Client area
2660 long nRight = aPos.X();
2661 if ( nRight < aArea.Right() )
2662 aArea.Right() = nRight;
2663 break;
2665 case ( 2 ) :
2667 // Top SplitWindow
2668 // Get the height of the Window yourself, if no DummyWindow
2669 if ( !bDummyWindow )
2670 aSize.Height() = pSplitWin->GetSizePixel().Height();
2673 // Adjust width with regard to if a Window is already open
2674 // to the left or right
2675 aPos.X() = aArea.Left();
2676 aSize.Width() = aArea.GetWidth();
2678 // If a Window is visable at the top, then the free region
2679 // starts beneath it, for example at the Client area
2680 long nTop = aPos.Y() + aSize.Height();
2681 if ( nTop > aArea.Top() )
2682 aArea.Top() = nTop;
2683 break;
2685 case ( 3 ) :
2687 // The bottom SplitWindow
2688 // Position to correct the difference of the heights
2689 aPos.Y() += aSize.Height();
2691 // Get the height of the Window yourself, if no DummyWindow
2692 if ( !bDummyWindow )
2693 aSize.Height() = pSplitWin->GetSizePixel().Height();
2695 aPos.Y() -= aSize.Height();
2697 // Adjust width with regard to if a Window is already open
2698 // to the left or right.
2699 aPos.X() = aArea.Left();
2700 aSize.Width() = aArea.GetWidth();
2702 // If already a window is opened at the top, then the
2703 // bottom one is not allowed to overlap this one.
2704 if ( aPos.Y() < aArea.Top() )
2706 aPos.Y() = aArea.Top();
2707 aSize.Height() = aArea.GetHeight();
2710 break;
2714 if ( !bDummyWindow )
2715 // the FadeIn-Window is a Floating window, which coordinates are
2716 // set in Screen coordinates.
2717 pSplitWin->SetPosSizePixel( pWorkWin->OutputToScreenPixel(aPos), aSize );
2718 else
2719 // the docked DummyWindow
2720 pDummy->SetPosSizePixel( aPos, aSize );
2724 Rectangle SfxWorkWindow::GetFreeArea( sal_Bool bAutoHide ) const
2726 if ( bAutoHide )
2728 Rectangle aArea( aClientArea );
2729 for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2731 if ( pSplit[n]->IsPinned() || !pSplit[n]->IsVisible() )
2732 continue;
2734 Size aSize = pSplit[n]->GetSizePixel();
2735 switch ( n )
2737 case ( 0 ) :
2738 aArea.Left() += aSize.Width();
2739 break;
2740 case ( 1 ) :
2741 aArea.Right() -= aSize.Width();
2742 break;
2743 case ( 2 ) :
2744 aArea.Top() += aSize.Height();
2745 break;
2746 case ( 3 ) :
2747 aArea.Bottom() -= aSize.Height();
2748 break;
2752 return aArea;
2754 else
2755 return aClientArea;
2758 void SfxWorkWindow::SetActiveChild_Impl( Window *pChild )
2760 pActiveChild = pChild;
2763 sal_Bool SfxWorkWindow::ActivateNextChild_Impl( sal_Bool bForward )
2765 // Sort all children under list
2766 std::vector<sal_uInt16> aList;
2767 for ( sal_uInt16 i=SFX_OBJECTBAR_MAX; i<pChildren->Count(); i++)
2769 SfxChild_Impl *pCli = (*pChildren)[i];
2770 if ( pCli && pCli->bCanGetFocus && pCli->pWin )
2772 sal_uInt16 k;
2773 for (k=0; k<aList.size(); k++)
2774 if ( ChildTravelValue((*pChildren)[aList[k]]->eAlign) > ChildTravelValue(pCli->eAlign) )
2775 break;
2776 aList.insert( aList.begin() + k, i );
2780 if ( aList.empty() )
2781 return sal_False;
2783 sal_uInt16 nTopValue = ChildTravelValue( SFX_ALIGN_LOWESTTOP );
2784 for ( sal_uInt16 i=0; i<aList.size(); i++ )
2786 SfxChild_Impl* pCli = (*pChildren)[aList[i]];
2787 if ( pCli->pWin && ChildTravelValue( pCli->eAlign ) > nTopValue )
2788 break;
2791 sal_uInt16 n = bForward ? 0 : aList.size()-1;
2792 SfxChild_Impl *pAct=NULL;
2793 if ( pActiveChild )
2795 // Look for the active window
2796 for ( n=0; n<aList.size(); n++ )
2798 SfxChild_Impl* pCli = (*pChildren)[aList[n]];
2799 if ( pCli && pCli->pWin && ( pCli->pWin == pActiveChild || !pActiveChild ) )
2801 pAct = pCli;
2802 break;
2807 // dummy entries for the container window
2808 aList.insert( aList.begin(), 0xFFFF );
2809 aList.push_back( 0xFFFF );
2810 n = n + 1;
2811 if ( pAct )
2813 for ( sal_uInt16 i=0; i<SFX_SPLITWINDOWS_MAX; i++ )
2815 // Maybe the pNext is a Splitwindow
2816 SfxSplitWindow *p = pSplit[i];
2817 if ( pAct->pWin == p )
2819 if( p->ActivateNextChild_Impl( bForward ) )
2820 return sal_True;
2821 break;
2825 // pAct is a direct ChildWindow
2826 // continue with the successor or predecessor of the active window
2827 if ( bForward )
2828 n = n+1;
2829 else
2830 n = n-1;
2832 if ( n == 0 || n == aList.size()-1 )
2833 return sal_False;
2836 for( ;; )
2838 SfxChild_Impl* pCli = (*pChildren)[aList[n]];
2839 if ( pCli->pWin )
2841 SfxChild_Impl* pNext = pCli;
2842 for ( sal_uInt16 i=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2844 // Maybe the pNext is a Splitwindow
2845 SfxSplitWindow *p = pSplit[i];
2846 if ( pNext->pWin == p )
2848 // Activate the first/last window
2849 p->SetActiveWindow_Impl( NULL );
2850 pNext = NULL;
2851 if( p->ActivateNextChild_Impl( bForward ) )
2852 return sal_True;
2853 break;
2857 if ( pNext )
2859 pNext->pWin->GrabFocus();
2860 pActiveChild = pNext->pWin;
2861 return sal_True;
2865 if ( bForward )
2866 n = n+1;
2867 else
2868 n = n-1;
2870 if ( n == 0 || n == aList.size()-1 )
2871 break;
2874 return sal_False;
2877 void SfxWorkWindow::DataChanged_Impl( const DataChangedEvent& )
2879 sal_uInt16 n;
2880 sal_uInt16 nCount = pChildWins->Count();
2881 for (n=0; n<nCount; n++)
2883 SfxChildWin_Impl*pCW = (*pChildWins)[n];
2884 if ( pCW && pCW->pWin )
2885 pCW->pWin->GetWindow()->UpdateSettings( Application::GetSettings() );
2888 ArrangeChildren_Impl();
2891 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */