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