xref: /trunk/main/sfx2/source/dialog/splitwin.cxx (revision cefeec7bb27224fc81e0a32928b713d8e79c148c)
1cdf0e10cSrcweir /*************************************************************************
2cdf0e10cSrcweir  *
3cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4cdf0e10cSrcweir  *
5cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6cdf0e10cSrcweir  *
7cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8cdf0e10cSrcweir  *
9cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10cdf0e10cSrcweir  *
11cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14cdf0e10cSrcweir  *
15cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20cdf0e10cSrcweir  *
21cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25cdf0e10cSrcweir  *
26cdf0e10cSrcweir  ************************************************************************/
27cdf0e10cSrcweir 
28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifdef SOLARIS
32cdf0e10cSrcweir // HACK: prevent conflict between STLPORT and Workshop headers on Solaris 8
33cdf0e10cSrcweir #include <ctime>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #ifndef _WRKWIN_HXX //autogen
39cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
42cdf0e10cSrcweir #ifndef GCC
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <vcl/timer.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "splitwin.hxx"
48cdf0e10cSrcweir #include "workwin.hxx"
49cdf0e10cSrcweir #include <sfx2/dockwin.hxx>
50cdf0e10cSrcweir #include <sfx2/app.hxx>
51cdf0e10cSrcweir #include "dialog.hrc"
52cdf0e10cSrcweir #include "sfx2/sfxresid.hxx"
53cdf0e10cSrcweir #include <sfx2/mnumgr.hxx>
54cdf0e10cSrcweir #include "virtmenu.hxx"
55cdf0e10cSrcweir #include <sfx2/msgpool.hxx>
56cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir using namespace ::com::sun::star::uno;
59cdf0e10cSrcweir using namespace ::rtl;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #define VERSION 1
62cdf0e10cSrcweir #define nPixel  30L
63cdf0e10cSrcweir #define USERITEM_NAME           OUString::createFromAscii( "UserItem" )
64cdf0e10cSrcweir 
65cdf0e10cSrcweir struct SfxDock_Impl
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     sal_uInt16              nType;
68cdf0e10cSrcweir     SfxDockingWindow*   pWin;           // SplitWindow hat dieses Fenster
69cdf0e10cSrcweir     sal_Bool                bNewLine;
70cdf0e10cSrcweir     sal_Bool                bHide;          // SplitWindow hatte dieses Fenster
71cdf0e10cSrcweir     long                nSize;
72cdf0e10cSrcweir };
73cdf0e10cSrcweir 
74cdf0e10cSrcweir typedef SfxDock_Impl* SfxDockPtr;
75cdf0e10cSrcweir SV_DECL_PTRARR_DEL( SfxDockArr_Impl, SfxDockPtr, 4, 4)
76cdf0e10cSrcweir SV_IMPL_PTRARR( SfxDockArr_Impl, SfxDockPtr);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir class SfxEmptySplitWin_Impl : public SplitWindow
79cdf0e10cSrcweir {
80cdf0e10cSrcweir /*  [Beschreibung]
81cdf0e10cSrcweir 
82*cefeec7bSAlexandro Colorado     SfxEmptySplitWin_Impldow is an empty split window replacing the SfxSplitWindow
83*cefeec7bSAlexandro Colorado     in AutoHide mode. Itworks as a placeholder to receive mouse MouseMoves.
84*cefeec7bSAlexandro Colorado     the actual light split window display
85cdf0e10cSrcweir */
86cdf0e10cSrcweir friend class SfxSplitWindow;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     SfxSplitWindow*     pOwner;
89cdf0e10cSrcweir     sal_Bool                bFadeIn;
90cdf0e10cSrcweir     sal_Bool                bAutoHide;
91cdf0e10cSrcweir     sal_Bool                bSplit;
92cdf0e10cSrcweir     sal_Bool                bEndAutoHide;
93cdf0e10cSrcweir     Timer               aTimer;
94cdf0e10cSrcweir     Point               aLastPos;
95cdf0e10cSrcweir     sal_uInt16              nState;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir                         SfxEmptySplitWin_Impl( SfxSplitWindow *pParent )
98cdf0e10cSrcweir                             : SplitWindow( pParent->GetParent(), WinBits( WB_BORDER | WB_3DLOOK ) )
99cdf0e10cSrcweir                             , pOwner( pParent )
100cdf0e10cSrcweir                             , bFadeIn( sal_False )
101cdf0e10cSrcweir                             , bAutoHide( sal_False )
102cdf0e10cSrcweir                             , bSplit( sal_False )
103cdf0e10cSrcweir                             , bEndAutoHide( sal_False )
104cdf0e10cSrcweir                             , nState( 1 )
105cdf0e10cSrcweir                         {
106cdf0e10cSrcweir                             aTimer.SetTimeoutHdl(
107cdf0e10cSrcweir                                 LINK(pOwner, SfxSplitWindow, TimerHdl ) );
108cdf0e10cSrcweir                             aTimer.SetTimeout( 200 );
109cdf0e10cSrcweir //                            EnableDrop( sal_True );
110cdf0e10cSrcweir                             SetAlign( pOwner->GetAlign() );
111cdf0e10cSrcweir                             Actualize();
112cdf0e10cSrcweir                             ShowAutoHideButton( pOwner->IsAutoHideButtonVisible() );
113cdf0e10cSrcweir                             ShowFadeInHideButton( sal_True );
114cdf0e10cSrcweir                         }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir                         ~SfxEmptySplitWin_Impl()
117cdf0e10cSrcweir                         {
118cdf0e10cSrcweir                             aTimer.Stop();
119cdf0e10cSrcweir                         }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     virtual void        MouseMove( const MouseEvent& );
122cdf0e10cSrcweir     virtual void        AutoHide();
123cdf0e10cSrcweir     virtual void        FadeIn();
124cdf0e10cSrcweir     void                Actualize();
125cdf0e10cSrcweir };
126cdf0e10cSrcweir 
127cdf0e10cSrcweir void SfxEmptySplitWin_Impl::Actualize()
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     Size aSize( pOwner->GetSizePixel() );
130cdf0e10cSrcweir     switch ( pOwner->GetAlign() )
131cdf0e10cSrcweir     {
132cdf0e10cSrcweir         case WINDOWALIGN_LEFT:
133cdf0e10cSrcweir         case WINDOWALIGN_RIGHT:
134cdf0e10cSrcweir             aSize.Width() = GetFadeInSize();
135cdf0e10cSrcweir             break;
136cdf0e10cSrcweir         case WINDOWALIGN_TOP:
137cdf0e10cSrcweir         case WINDOWALIGN_BOTTOM:
138cdf0e10cSrcweir             aSize.Height() = GetFadeInSize();
139cdf0e10cSrcweir             break;
140cdf0e10cSrcweir     }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     SetSizePixel( aSize );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir void SfxEmptySplitWin_Impl::AutoHide()
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     pOwner->SetPinned_Impl( !pOwner->bPinned );
148cdf0e10cSrcweir     pOwner->SaveConfig_Impl();
149cdf0e10cSrcweir     bAutoHide = sal_True;
150cdf0e10cSrcweir     FadeIn();
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir void SfxEmptySplitWin_Impl::FadeIn()
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     if (!bAutoHide )
156cdf0e10cSrcweir         bAutoHide = IsFadeNoButtonMode();
157cdf0e10cSrcweir     pOwner->SetFadeIn_Impl( sal_True );
158cdf0e10cSrcweir     pOwner->Show_Impl();
159cdf0e10cSrcweir     if ( bAutoHide )
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir         // Timer zum Schlie\sen aufsetzen; der Aufrufer mu\s selbst sicherstellen,
162cdf0e10cSrcweir         // da\s das Window nicht gleich wieder zu geht ( z.B. durch Setzen des
163cdf0e10cSrcweir         // Focus oder einen modal mode )
164cdf0e10cSrcweir         aLastPos = GetPointerPosPixel();
165cdf0e10cSrcweir         aTimer.Start();
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir     else
168cdf0e10cSrcweir         pOwner->SaveConfig_Impl();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir //-------------------------------------------------------------------------
172cdf0e10cSrcweir 
173cdf0e10cSrcweir void SfxSplitWindow::MouseButtonDown( const MouseEvent& rMEvt )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     if ( rMEvt.GetClicks() != 2 )
176cdf0e10cSrcweir         SplitWindow::MouseButtonDown( rMEvt );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir void SfxEmptySplitWin_Impl::MouseMove( const MouseEvent& rMEvt )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     SplitWindow::MouseMove( rMEvt );
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir //-------------------------------------------------------------------------
185cdf0e10cSrcweir 
186cdf0e10cSrcweir SfxSplitWindow::SfxSplitWindow( Window* pParent, SfxChildAlignment eAl,
187cdf0e10cSrcweir         SfxWorkWindow *pW, sal_Bool bWithButtons, WinBits nBits )
188cdf0e10cSrcweir 
189cdf0e10cSrcweir /*  [Beschreibung]
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     Ein SfxSplitWindow verbirgt die rekursive Struktur des SV-Splitwindows
192cdf0e10cSrcweir     nach au\sen, indem es einen tabellenartigen Aufbau mit Zeilen und Spalten
193cdf0e10cSrcweir     ( also maximale Rekursionstiefe 2 ) simuliert.
194cdf0e10cSrcweir     Au\erdem sichert es die Persistenz der Anordnung der SfxDockingWindows.
195cdf0e10cSrcweir */
196cdf0e10cSrcweir 
197cdf0e10cSrcweir :   SplitWindow ( pParent, nBits | WB_HIDE ),
198cdf0e10cSrcweir     eAlign(eAl),
199cdf0e10cSrcweir     pWorkWin(pW),
200cdf0e10cSrcweir     pDockArr( new SfxDockArr_Impl ),
201cdf0e10cSrcweir     bLocked(sal_False),
202cdf0e10cSrcweir     bPinned(sal_True),
203cdf0e10cSrcweir     pEmptyWin(NULL),
204cdf0e10cSrcweir     pActive(NULL)
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     if ( bWithButtons )
207cdf0e10cSrcweir     {
208cdf0e10cSrcweir         ShowAutoHideButton( sal_False );    // no autohide button (pin) anymore
209cdf0e10cSrcweir         ShowFadeOutButton( sal_True );
210cdf0e10cSrcweir     }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir     // SV-Alignment setzen
213cdf0e10cSrcweir     WindowAlign eTbxAlign;
214cdf0e10cSrcweir     switch ( eAlign )
215cdf0e10cSrcweir     {
216cdf0e10cSrcweir         case SFX_ALIGN_LEFT:
217cdf0e10cSrcweir             eTbxAlign = WINDOWALIGN_LEFT;
218cdf0e10cSrcweir             break;
219cdf0e10cSrcweir         case SFX_ALIGN_RIGHT:
220cdf0e10cSrcweir             eTbxAlign = WINDOWALIGN_RIGHT;
221cdf0e10cSrcweir             break;
222cdf0e10cSrcweir         case SFX_ALIGN_TOP:
223cdf0e10cSrcweir             eTbxAlign = WINDOWALIGN_TOP;
224cdf0e10cSrcweir             break;
225cdf0e10cSrcweir         case SFX_ALIGN_BOTTOM:
226cdf0e10cSrcweir             eTbxAlign = WINDOWALIGN_BOTTOM;
227cdf0e10cSrcweir             bPinned = sal_True;
228cdf0e10cSrcweir             break;
229cdf0e10cSrcweir         default:
230cdf0e10cSrcweir             eTbxAlign = WINDOWALIGN_TOP;  // some sort of default...
231cdf0e10cSrcweir             break;  // -Wall lots not handled..
232cdf0e10cSrcweir     }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     SetAlign (eTbxAlign);
235cdf0e10cSrcweir     pEmptyWin = new SfxEmptySplitWin_Impl( this );
236cdf0e10cSrcweir     if ( bPinned )
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         pEmptyWin->bFadeIn = sal_True;
239cdf0e10cSrcweir         pEmptyWin->nState = 2;
240cdf0e10cSrcweir     }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir     if ( bWithButtons )
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir         // Konfiguration einlesen
245cdf0e10cSrcweir         String aWindowId = String::CreateFromAscii("SplitWindow");
246cdf0e10cSrcweir         aWindowId += String::CreateFromInt32( (sal_Int32) eTbxAlign );
247cdf0e10cSrcweir         SvtViewOptions aWinOpt( E_WINDOW, aWindowId );
248cdf0e10cSrcweir         String aWinData;
249cdf0e10cSrcweir         Any aUserItem = aWinOpt.GetUserItem( USERITEM_NAME );
250cdf0e10cSrcweir         OUString aTemp;
251cdf0e10cSrcweir         if ( aUserItem >>= aTemp )
252cdf0e10cSrcweir             aWinData = String( aTemp );
253cdf0e10cSrcweir         if ( aWinData.Len() && aWinData.GetChar( (sal_uInt16) 0 ) == 'V' )
254cdf0e10cSrcweir         {
255cdf0e10cSrcweir             pEmptyWin->nState = (sal_uInt16) aWinData.GetToken( 1, ',' ).ToInt32();
256cdf0e10cSrcweir             if ( pEmptyWin->nState & 2 )
257cdf0e10cSrcweir                 pEmptyWin->bFadeIn = sal_True;
258cdf0e10cSrcweir             //bPinned = !( pEmptyWin->nState & 1 );
259cdf0e10cSrcweir             bPinned = sal_True; // always assume pinned - floating mode not used anymore
260cdf0e10cSrcweir 
261cdf0e10cSrcweir             sal_uInt16 i=2;
262cdf0e10cSrcweir             sal_uInt16 nCount = (sal_uInt16) aWinData.GetToken(i++, ',').ToInt32();
263cdf0e10cSrcweir             for ( sal_uInt16 n=0; n<nCount; n++ )
264cdf0e10cSrcweir             {
265cdf0e10cSrcweir                 SfxDock_Impl *pDock = new SfxDock_Impl;
266cdf0e10cSrcweir                 pDock->pWin = 0;
267cdf0e10cSrcweir                 pDock->bNewLine = sal_False;
268cdf0e10cSrcweir                 pDock->bHide = sal_True;
269cdf0e10cSrcweir                 pDock->nType = (sal_uInt16) aWinData.GetToken(i++, ',').ToInt32();
270cdf0e10cSrcweir                 if ( !pDock->nType )
271cdf0e10cSrcweir                 {
272cdf0e10cSrcweir                     // K"onnte NewLine bedeuten
273cdf0e10cSrcweir                     pDock->nType = (sal_uInt16) aWinData.GetToken(i++, ',').ToInt32();
274cdf0e10cSrcweir                     if ( !pDock->nType )
275cdf0e10cSrcweir                     {
276cdf0e10cSrcweir                         // Lesefehler
277cdf0e10cSrcweir                         delete pDock;
278cdf0e10cSrcweir                         break;
279cdf0e10cSrcweir                     }
280cdf0e10cSrcweir                     else
281cdf0e10cSrcweir                         pDock->bNewLine = sal_True;
282cdf0e10cSrcweir                 }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir                 pDockArr->Insert(pDock,n);
285cdf0e10cSrcweir             }
286cdf0e10cSrcweir         }
287cdf0e10cSrcweir     }
288cdf0e10cSrcweir     else
289cdf0e10cSrcweir     {
290cdf0e10cSrcweir         bPinned = sal_True;
291cdf0e10cSrcweir         pEmptyWin->bFadeIn = sal_True;
292cdf0e10cSrcweir         pEmptyWin->nState = 2;
293cdf0e10cSrcweir     }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir     SetAutoHideState( !bPinned );
296cdf0e10cSrcweir     pEmptyWin->SetAutoHideState( !bPinned );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir //-------------------------------------------------------------------------
300cdf0e10cSrcweir 
301cdf0e10cSrcweir SfxSplitWindow::~SfxSplitWindow()
302cdf0e10cSrcweir {
303cdf0e10cSrcweir     if ( !pWorkWin->GetParent_Impl() )
304cdf0e10cSrcweir         SaveConfig_Impl();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     if ( pEmptyWin )
307cdf0e10cSrcweir     {
308cdf0e10cSrcweir         // pOwner auf NULL setzen, sonst versucht pEmptyWin, nochmal zu
309cdf0e10cSrcweir         // l"oschen; es wird n"amlich von au\sen immer das Fenster deleted,
310cdf0e10cSrcweir         // das gerade angedockt ist
311cdf0e10cSrcweir         pEmptyWin->pOwner = NULL;
312cdf0e10cSrcweir         delete pEmptyWin;
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     delete pDockArr;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir void SfxSplitWindow::SaveConfig_Impl()
319cdf0e10cSrcweir {
320cdf0e10cSrcweir     // Konfiguration abspeichern
321cdf0e10cSrcweir     String aWinData('V');
322cdf0e10cSrcweir     aWinData += String::CreateFromInt32( VERSION );
323cdf0e10cSrcweir     aWinData += ',';
324cdf0e10cSrcweir     aWinData += String::CreateFromInt32( pEmptyWin->nState );
325cdf0e10cSrcweir     aWinData += ',';
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     sal_uInt16 nCount = 0;
328cdf0e10cSrcweir     sal_uInt16 n;
329cdf0e10cSrcweir     for ( n=0; n<pDockArr->Count(); n++ )
330cdf0e10cSrcweir     {
331cdf0e10cSrcweir         SfxDock_Impl *pDock = (*pDockArr)[n];
332cdf0e10cSrcweir         if ( pDock->bHide || pDock->pWin )
333cdf0e10cSrcweir             nCount++;
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     aWinData += String::CreateFromInt32( nCount );
337cdf0e10cSrcweir 
338cdf0e10cSrcweir     for ( n=0; n<pDockArr->Count(); n++ )
339cdf0e10cSrcweir     {
340cdf0e10cSrcweir         SfxDock_Impl *pDock = (*pDockArr)[n];
341cdf0e10cSrcweir         if ( !pDock->bHide && !pDock->pWin )
342cdf0e10cSrcweir             continue;
343cdf0e10cSrcweir         if ( pDock->bNewLine )
344cdf0e10cSrcweir             aWinData += DEFINE_CONST_UNICODE(",0");
345cdf0e10cSrcweir         aWinData += ',';
346cdf0e10cSrcweir         aWinData += String::CreateFromInt32( pDock->nType);
347cdf0e10cSrcweir     }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir     String aWindowId = String::CreateFromAscii("SplitWindow");
350cdf0e10cSrcweir     aWindowId += String::CreateFromInt32( (sal_Int32) GetAlign() );
351cdf0e10cSrcweir     SvtViewOptions aWinOpt( E_WINDOW, aWindowId );
352cdf0e10cSrcweir     aWinOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aWinData ) ) );
353cdf0e10cSrcweir }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir //-------------------------------------------------------------------------
356cdf0e10cSrcweir 
357cdf0e10cSrcweir void SfxSplitWindow::StartSplit()
358cdf0e10cSrcweir {
359cdf0e10cSrcweir     long nSize = 0;
360cdf0e10cSrcweir     Size aSize = GetSizePixel();
361cdf0e10cSrcweir 
362cdf0e10cSrcweir     if ( pEmptyWin )
363cdf0e10cSrcweir     {
364cdf0e10cSrcweir         pEmptyWin->bFadeIn = sal_True;
365cdf0e10cSrcweir         pEmptyWin->bSplit = sal_True;
366cdf0e10cSrcweir     }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir     Rectangle aRect = pWorkWin->GetFreeArea( !bPinned );
369cdf0e10cSrcweir     switch ( GetAlign() )
370cdf0e10cSrcweir     {
371cdf0e10cSrcweir         case WINDOWALIGN_LEFT:
372cdf0e10cSrcweir         case WINDOWALIGN_RIGHT:
373cdf0e10cSrcweir             nSize = aSize.Width() + aRect.GetWidth();
374cdf0e10cSrcweir             break;
375cdf0e10cSrcweir         case WINDOWALIGN_TOP:
376cdf0e10cSrcweir         case WINDOWALIGN_BOTTOM:
377cdf0e10cSrcweir             nSize = aSize.Height() + aRect.GetHeight();
378cdf0e10cSrcweir             break;
379cdf0e10cSrcweir     }
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     SetMaxSizePixel( nSize );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir //-------------------------------------------------------------------------
385cdf0e10cSrcweir 
386cdf0e10cSrcweir void SfxSplitWindow::SplitResize()
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     if ( bPinned )
389cdf0e10cSrcweir     {
390cdf0e10cSrcweir         pWorkWin->ArrangeChilds_Impl();
391cdf0e10cSrcweir         pWorkWin->ShowChilds_Impl();
392cdf0e10cSrcweir     }
393cdf0e10cSrcweir     else
394cdf0e10cSrcweir         pWorkWin->ArrangeAutoHideWindows( this );
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir //-------------------------------------------------------------------------
398cdf0e10cSrcweir 
399cdf0e10cSrcweir void SfxSplitWindow::Split()
400cdf0e10cSrcweir {
401cdf0e10cSrcweir     if ( pEmptyWin )
402cdf0e10cSrcweir         pEmptyWin->bSplit = sal_False;
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     SplitWindow::Split();
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     sal_uInt16 nCount = pDockArr->Count();
407cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<nCount; n++ )
408cdf0e10cSrcweir     {
409cdf0e10cSrcweir         SfxDock_Impl *pD = (*pDockArr)[n];
410cdf0e10cSrcweir         if ( pD->pWin )
411cdf0e10cSrcweir         {
412cdf0e10cSrcweir             sal_uInt16 nId = pD->nType;
413cdf0e10cSrcweir             long nSize    = GetItemSize( nId, SWIB_FIXED );
414cdf0e10cSrcweir             long nSetSize = GetItemSize( GetSet( nId ) );
415cdf0e10cSrcweir             Size aSize;
416cdf0e10cSrcweir 
417cdf0e10cSrcweir             if ( IsHorizontal() )
418cdf0e10cSrcweir             {
419cdf0e10cSrcweir                 aSize.Width()  = nSize;
420cdf0e10cSrcweir                 aSize.Height() = nSetSize;
421cdf0e10cSrcweir             }
422cdf0e10cSrcweir             else
423cdf0e10cSrcweir             {
424cdf0e10cSrcweir                 aSize.Width()  = nSetSize;
425cdf0e10cSrcweir                 aSize.Height() = nSize;
426cdf0e10cSrcweir             }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir             pD->pWin->SetItemSize_Impl( aSize );
429cdf0e10cSrcweir         }
430cdf0e10cSrcweir     }
431cdf0e10cSrcweir 
432cdf0e10cSrcweir     SaveConfig_Impl();
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir //-------------------------------------------------------------------------
436cdf0e10cSrcweir 
437cdf0e10cSrcweir void SfxSplitWindow::InsertWindow( SfxDockingWindow* pDockWin, const Size& rSize)
438cdf0e10cSrcweir 
439cdf0e10cSrcweir /*  [Beschreibung]
440cdf0e10cSrcweir 
441*cefeec7bSAlexandro Colorado     To insert SfxDockingWindows with no position can also be transfered.
442*cefeec7bSAlexandro Colorado     The SfxSplitWindow then searches out the noted recently transfered
443*cefeec7bSAlexandro Colorado     to the newly SfxDockingWindow or it depends on the last.
444cdf0e10cSrcweir 
445cdf0e10cSrcweir */
446cdf0e10cSrcweir {
447*cefeec7bSAlexandro Colorado     short nLine = -1;       // so first window can be set to 0 nLine high
448cdf0e10cSrcweir     sal_uInt16 nL;
449cdf0e10cSrcweir     sal_uInt16 nPos = 0;
450cdf0e10cSrcweir     sal_Bool bNewLine = sal_True;
451cdf0e10cSrcweir     sal_Bool bSaveConfig = sal_False;
452cdf0e10cSrcweir     SfxDock_Impl *pFoundDock=0;
453cdf0e10cSrcweir     sal_uInt16 nCount = pDockArr->Count();
454cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<nCount; n++ )
455cdf0e10cSrcweir     {
456cdf0e10cSrcweir         SfxDock_Impl *pDock = (*pDockArr)[n];
457cdf0e10cSrcweir         if ( pDock->bNewLine )
458cdf0e10cSrcweir         {
459*cefeec7bSAlexandro Colorado             // The window opens a new line
460cdf0e10cSrcweir             if ( pFoundDock )
461*cefeec7bSAlexandro Colorado                 // But behind the window just inserted
462cdf0e10cSrcweir                 break;
463cdf0e10cSrcweir 
464*cefeec7bSAlexandro Colorado             // new line
465cdf0e10cSrcweir             nPos = 0;
466cdf0e10cSrcweir             bNewLine = sal_True;
467cdf0e10cSrcweir         }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir         if ( pDock->pWin )
470cdf0e10cSrcweir         {
471*cefeec7bSAlexandro Colorado             // It is at this point just a window
472cdf0e10cSrcweir             if ( bNewLine && !pFoundDock )
473cdf0e10cSrcweir             {
474*cefeec7bSAlexandro Colorado                 // It is not known, in which real line is the one
475cdf0e10cSrcweir                 GetWindowPos( pDock->pWin, nL, nPos );
476cdf0e10cSrcweir                 nLine = (short) nL;
477cdf0e10cSrcweir             }
478cdf0e10cSrcweir 
479cdf0e10cSrcweir             if ( !pFoundDock )
480cdf0e10cSrcweir             {
481*cefeec7bSAlexandro Colorado                 // before the window is attached
482cdf0e10cSrcweir                 nPos++;
483cdf0e10cSrcweir             }
484cdf0e10cSrcweir 
485*cefeec7bSAlexandro Colorado             // Line is now open
486cdf0e10cSrcweir             bNewLine = sal_False;
487cdf0e10cSrcweir             if ( pFoundDock )
488cdf0e10cSrcweir                 break;
489cdf0e10cSrcweir         }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir         if ( pDock->nType == pDockWin->GetType() )
492cdf0e10cSrcweir         {
493*cefeec7bSAlexandro Colorado             DBG_ASSERT( !pFoundDock && !pDock->pWin, "Window is already available!");
494cdf0e10cSrcweir             pFoundDock = pDock;
495cdf0e10cSrcweir             if ( !bNewLine )
496cdf0e10cSrcweir                 break;
497cdf0e10cSrcweir             else
498cdf0e10cSrcweir             {
499*cefeec7bSAlexandro Colorado                 // It was most recently a new series started, but not found a
500*cefeec7bSAlexandro Colorado                 // window above it, so keep looking if nochein window follows
501*cefeec7bSAlexandro Colorado                 // this line to bNewLine to set correctly. But it must be nLine
502*cefeec7bSAlexandro Colorado                 // or nPos shouldn't be changed.
503cdf0e10cSrcweir                 nLine++;
504cdf0e10cSrcweir             }
505cdf0e10cSrcweir         }
506cdf0e10cSrcweir     }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir     if ( !pFoundDock )
509cdf0e10cSrcweir     {
510cdf0e10cSrcweir         // Nicht gefunden, am Ende einf"ugen
511cdf0e10cSrcweir         pFoundDock = new SfxDock_Impl;
512cdf0e10cSrcweir         pFoundDock->bHide = sal_True;
513cdf0e10cSrcweir         pDockArr->Insert( pFoundDock, nCount );
514cdf0e10cSrcweir         pFoundDock->nType = pDockWin->GetType();
515cdf0e10cSrcweir         nLine++;
516cdf0e10cSrcweir         nPos = 0;
517cdf0e10cSrcweir         bNewLine = sal_True;
518cdf0e10cSrcweir         pFoundDock->bNewLine = bNewLine;
519cdf0e10cSrcweir         bSaveConfig = sal_True;
520cdf0e10cSrcweir     }
521cdf0e10cSrcweir 
522cdf0e10cSrcweir     pFoundDock->pWin = pDockWin;
523cdf0e10cSrcweir     pFoundDock->bHide = sal_False;
524cdf0e10cSrcweir     InsertWindow_Impl( pFoundDock, rSize, nLine, nPos, bNewLine );
525cdf0e10cSrcweir     if ( bSaveConfig )
526cdf0e10cSrcweir         SaveConfig_Impl();
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir //-------------------------------------------------------------------------
530cdf0e10cSrcweir 
531cdf0e10cSrcweir void SfxSplitWindow::ReleaseWindow_Impl(SfxDockingWindow *pDockWin, sal_Bool bSave)
532cdf0e10cSrcweir 
533cdf0e10cSrcweir /*  [Beschreibung]
534cdf0e10cSrcweir 
535*cefeec7bSAlexandro Colorado     The DockinWindow is no longer stored in the  internal data.
536cdf0e10cSrcweir */
537cdf0e10cSrcweir 
538cdf0e10cSrcweir {
539cdf0e10cSrcweir     SfxDock_Impl *pDock=0;
540cdf0e10cSrcweir     sal_uInt16 nCount = pDockArr->Count();
541cdf0e10cSrcweir     sal_Bool bFound = sal_False;
542cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<nCount; n++ )
543cdf0e10cSrcweir     {
544cdf0e10cSrcweir         pDock = (*pDockArr)[n];
545cdf0e10cSrcweir         if ( pDock->nType == pDockWin->GetType() )
546cdf0e10cSrcweir         {
547cdf0e10cSrcweir             if ( pDock->bNewLine && n<nCount-1 )
548cdf0e10cSrcweir                 (*pDockArr)[n+1]->bNewLine = sal_True;
549cdf0e10cSrcweir 
550cdf0e10cSrcweir             // Fenster hat schon eine Position, die vergessen wir
551cdf0e10cSrcweir             bFound = sal_True;
552cdf0e10cSrcweir             pDockArr->Remove(n);
553cdf0e10cSrcweir             break;
554cdf0e10cSrcweir         }
555cdf0e10cSrcweir     }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir     if ( bFound )
558cdf0e10cSrcweir         delete pDock;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir     if ( bSave )
561cdf0e10cSrcweir         SaveConfig_Impl();
562cdf0e10cSrcweir }
563cdf0e10cSrcweir 
564cdf0e10cSrcweir //-------------------------------------------------------------------------
565cdf0e10cSrcweir 
566cdf0e10cSrcweir void SfxSplitWindow::MoveWindow( SfxDockingWindow* pDockWin, const Size& rSize,
567cdf0e10cSrcweir                         sal_uInt16 nLine, sal_uInt16 nPos, sal_Bool bNewLine)
568cdf0e10cSrcweir 
569cdf0e10cSrcweir /*  [Beschreibung]
570cdf0e10cSrcweir 
571cdf0e10cSrcweir     Das DockingWindow wird innerhalb des Splitwindows verschoben.
572cdf0e10cSrcweir 
573cdf0e10cSrcweir */
574cdf0e10cSrcweir 
575cdf0e10cSrcweir {
576cdf0e10cSrcweir     sal_uInt16 nL, nP;
577cdf0e10cSrcweir     GetWindowPos( pDockWin, nL, nP );
578cdf0e10cSrcweir 
579cdf0e10cSrcweir     if ( nLine > nL && GetItemCount( GetItemId( nL, 0 ) ) == 1 )
580cdf0e10cSrcweir     {
581cdf0e10cSrcweir         // Wenn das letzte Fenster aus seiner Zeile entfernt wird, rutscht
582cdf0e10cSrcweir         // alles eine Zeile nach vorne!
583cdf0e10cSrcweir         nLine--;
584cdf0e10cSrcweir     }
585cdf0e10cSrcweir /*
586cdf0e10cSrcweir     else if ( nLine == nL && nPos > nP )
587cdf0e10cSrcweir     {
588cdf0e10cSrcweir         nPos--;
589cdf0e10cSrcweir     }
590cdf0e10cSrcweir */
591cdf0e10cSrcweir     RemoveWindow( pDockWin );
592cdf0e10cSrcweir     InsertWindow( pDockWin, rSize, nLine, nPos, bNewLine );
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir //-------------------------------------------------------------------------
596cdf0e10cSrcweir 
597cdf0e10cSrcweir void SfxSplitWindow::InsertWindow( SfxDockingWindow* pDockWin, const Size& rSize,
598cdf0e10cSrcweir                         sal_uInt16 nLine, sal_uInt16 nPos, sal_Bool bNewLine)
599cdf0e10cSrcweir 
600cdf0e10cSrcweir /*  [Beschreibung]
601cdf0e10cSrcweir 
602cdf0e10cSrcweir     Das DockingWindow wird in dieses Splitwindow geschoben und soll die
603cdf0e10cSrcweir     "ubergebene Position und Gr"o\se haben.
604cdf0e10cSrcweir 
605cdf0e10cSrcweir */
606cdf0e10cSrcweir {
607cdf0e10cSrcweir     ReleaseWindow_Impl( pDockWin, sal_False );
608cdf0e10cSrcweir     SfxDock_Impl *pDock = new SfxDock_Impl;
609cdf0e10cSrcweir     pDock->bHide = sal_False;
610cdf0e10cSrcweir     pDock->nType = pDockWin->GetType();
611cdf0e10cSrcweir     pDock->bNewLine = bNewLine;
612cdf0e10cSrcweir     pDock->pWin = pDockWin;
613cdf0e10cSrcweir 
614abd9d880SPedro Giffuni     DBG_ASSERT( nPos==0 || !bNewLine, "Wrong Parameter!");
615cdf0e10cSrcweir     if ( bNewLine )
616cdf0e10cSrcweir         nPos = 0;
617cdf0e10cSrcweir 
618b7d87b09SAlexandro Colorado     // The window introduced before the first window are suffices that the
619b7d87b09SAlexandro Colorado     // body or a greater position as the pDockWin.
620abd9d880SPedro Giffuni     sal_uInt16 nLastWindowIdx(0);
621cdf0e10cSrcweir 
622b7d87b09SAlexandro Colorado     // If window not found, is inserted as the first
623cdf0e10cSrcweir     sal_uInt16 nInsertPos = 0;
624cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<nCount; n++ )
625cdf0e10cSrcweir     {
626cdf0e10cSrcweir         SfxDock_Impl *pD = (*pDockArr)[n];
627cdf0e10cSrcweir 
628cdf0e10cSrcweir         if (pD->pWin)
629cdf0e10cSrcweir         {
630cdf0e10cSrcweir             // Ein angedocktes Fenster wurde gefunden
631cdf0e10cSrcweir             // Wenn kein geeignetes Fenster hinter der gew"unschten Einf"ugeposition
632cdf0e10cSrcweir             // gefunden wird, wird am Ende eingef"ugt
633cdf0e10cSrcweir             nInsertPos = nCount;
634abd9d880SPedro Giffuni             nLastWindowIdx = n;
635cdf0e10cSrcweir             sal_uInt16 nL=0, nP=0;
636cdf0e10cSrcweir             GetWindowPos( pD->pWin, nL, nP );
637cdf0e10cSrcweir 
638cdf0e10cSrcweir             if ( (nL == nLine && nP == nPos) || nL > nLine )
639cdf0e10cSrcweir             {
640abd9d880SPedro Giffuni                 DBG_ASSERT( nL == nLine || bNewLine || nPos > 0, "Wrong Parameter!" );
641cdf0e10cSrcweir                 if ( nL == nLine && nPos == 0 && !bNewLine )
642cdf0e10cSrcweir                 {
643abd9d880SPedro Giffuni                     DBG_ASSERT(pD->bNewLine, "No new line?");
644cdf0e10cSrcweir 
645cdf0e10cSrcweir                     // Das Fenster wird auf nPos==0 eingeschoben
646cdf0e10cSrcweir                     pD->bNewLine = sal_False;
647cdf0e10cSrcweir                     pDock->bNewLine = sal_True;
648cdf0e10cSrcweir                 }
649cdf0e10cSrcweir 
650abd9d880SPedro Giffuni                 nInsertPos = n != 0 ? nLastWindowIdx + 1 : 0;    // ignore all non-windows after the last window
651cdf0e10cSrcweir                 break;
652cdf0e10cSrcweir             }
653cdf0e10cSrcweir         }
654cdf0e10cSrcweir     }
655abd9d880SPedro Giffuni     if (nInsertPos == nCount && nLastWindowIdx != nCount - 1)
656abd9d880SPedro Giffuni     {
657abd9d880SPedro Giffuni         nInsertPos = nLastWindowIdx + 1;    // ignore all non-windows after the last window
658abd9d880SPedro Giffuni     }
659cdf0e10cSrcweir 
660cdf0e10cSrcweir     pDockArr->Insert(pDock, nInsertPos);
661cdf0e10cSrcweir     InsertWindow_Impl( pDock, rSize, nLine, nPos, bNewLine );
662cdf0e10cSrcweir     SaveConfig_Impl();
663cdf0e10cSrcweir }
664cdf0e10cSrcweir 
665cdf0e10cSrcweir //-------------------------------------------------------------------------
666cdf0e10cSrcweir 
667cdf0e10cSrcweir void SfxSplitWindow::InsertWindow_Impl( SfxDock_Impl* pDock,
668cdf0e10cSrcweir                         const Size& rSize,
669cdf0e10cSrcweir                         sal_uInt16 nLine, sal_uInt16 nPos, sal_Bool bNewLine)
670cdf0e10cSrcweir 
671cdf0e10cSrcweir /*  [Beschreibung]
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     F"ugt ein DockingWindow ein und veranla\st die Neuberechnung der Gr"o\se
674cdf0e10cSrcweir     des Splitwindows.
675cdf0e10cSrcweir */
676cdf0e10cSrcweir 
677cdf0e10cSrcweir {
678cdf0e10cSrcweir     SfxDockingWindow* pDockWin = pDock->pWin;
679cdf0e10cSrcweir 
680cdf0e10cSrcweir     sal_uInt16 nItemBits = pDockWin->GetWinBits_Impl();
681cdf0e10cSrcweir 
682cdf0e10cSrcweir     long nWinSize, nSetSize;
683cdf0e10cSrcweir     if ( IsHorizontal() )
684cdf0e10cSrcweir     {
685cdf0e10cSrcweir         nWinSize = rSize.Width();
686cdf0e10cSrcweir         nSetSize = rSize.Height();
687cdf0e10cSrcweir     }
688cdf0e10cSrcweir     else
689cdf0e10cSrcweir     {
690cdf0e10cSrcweir         nSetSize = rSize.Width();
691cdf0e10cSrcweir         nWinSize = rSize.Height();
692cdf0e10cSrcweir     }
693cdf0e10cSrcweir 
694cdf0e10cSrcweir     pDock->nSize = nWinSize;
695cdf0e10cSrcweir 
696cdf0e10cSrcweir     sal_Bool bUpdateMode = IsUpdateMode();
697cdf0e10cSrcweir     if ( bUpdateMode )
698cdf0e10cSrcweir         SetUpdateMode( sal_False );
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     if ( bNewLine || nLine == GetItemCount( 0 ) )
701cdf0e10cSrcweir     {
702cdf0e10cSrcweir         // Es soll nicht in eine vorhandene Zeile eingef"ugt werden, sondern
703cdf0e10cSrcweir         // eine neue erzeugt werden
704cdf0e10cSrcweir 
705cdf0e10cSrcweir         sal_uInt16 nId = 1;
706cdf0e10cSrcweir         for ( sal_uInt16 n=0; n<GetItemCount(0); n++ )
707cdf0e10cSrcweir         {
708cdf0e10cSrcweir             if ( GetItemId(n) >= nId )
709cdf0e10cSrcweir                 nId = GetItemId(n)+1;
710cdf0e10cSrcweir         }
711cdf0e10cSrcweir 
712cdf0e10cSrcweir         // Eine neue nLine-te Zeile erzeugen
713cdf0e10cSrcweir         sal_uInt16 nBits = nItemBits;
714cdf0e10cSrcweir         if ( GetAlign() == WINDOWALIGN_TOP || GetAlign() == WINDOWALIGN_BOTTOM )
715cdf0e10cSrcweir             nBits |= SWIB_COLSET;
716cdf0e10cSrcweir         InsertItem( nId, nSetSize, nLine, 0, nBits );
717cdf0e10cSrcweir     }
718cdf0e10cSrcweir 
719cdf0e10cSrcweir     // In Zeile mit Position nLine das Fenster einf"ugen
720cdf0e10cSrcweir     // ItemWindowSize auf "Prozentual" setzen, da SV dann das Umgr"o\sern
721cdf0e10cSrcweir     // so macht, wie man erwartet; "Pixel" macht eigentlich nur Sinn, wenn
722cdf0e10cSrcweir     // auch Items mit prozentualen oder relativen Gr"o\sen dabei sind.
723cdf0e10cSrcweir     nItemBits |= SWIB_PERCENTSIZE;
724cdf0e10cSrcweir     bLocked = sal_True;
725cdf0e10cSrcweir     sal_uInt16 nSet = GetItemId( nLine );
726cdf0e10cSrcweir     InsertItem( pDockWin->GetType(), pDockWin, nWinSize, nPos, nSet, nItemBits );
727cdf0e10cSrcweir 
728cdf0e10cSrcweir     // Splitwindows werden im SFX einmal angelegt und beim Einf"ugen des ersten
729cdf0e10cSrcweir     // DockingWindows sichtbar gemacht.
730cdf0e10cSrcweir     if ( GetItemCount( 0 ) == 1 && GetItemCount( 1 ) == 1 )
731cdf0e10cSrcweir     {
732cdf0e10cSrcweir         // Das Neuarrangieren am WorkWindow und ein Show() auf das SplitWindow
733cdf0e10cSrcweir         // wird vom SfxDockingwindow veranla\st (->SfxWorkWindow::ConfigChild_Impl)
734cdf0e10cSrcweir         if ( !bPinned && !IsFloatingMode() )
735cdf0e10cSrcweir         {
736cdf0e10cSrcweir             bPinned = sal_True;
737cdf0e10cSrcweir             sal_Bool bFadeIn = ( pEmptyWin->nState & 2 ) != 0;
738cdf0e10cSrcweir             pEmptyWin->bFadeIn = sal_False;
739cdf0e10cSrcweir             SetPinned_Impl( sal_False );
740cdf0e10cSrcweir             pEmptyWin->Actualize();
741cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::InsertWindow_Impl - registering empty Splitwindow" );
742cdf0e10cSrcweir             pWorkWin->RegisterChild_Impl( *GetSplitWindow(), eAlign, sal_True )->nVisible = CHILD_VISIBLE;
743cdf0e10cSrcweir             pWorkWin->ArrangeChilds_Impl();
744cdf0e10cSrcweir             if ( bFadeIn )
745cdf0e10cSrcweir                 FadeIn();
746cdf0e10cSrcweir         }
747cdf0e10cSrcweir         else
748cdf0e10cSrcweir         {
749cdf0e10cSrcweir             sal_Bool bFadeIn = ( pEmptyWin->nState & 2 ) != 0;
750cdf0e10cSrcweir             pEmptyWin->bFadeIn = sal_False;
751cdf0e10cSrcweir             pEmptyWin->Actualize();
752cdf0e10cSrcweir #ifdef DBG_UTIL
753cdf0e10cSrcweir             if ( !bPinned || !pEmptyWin->bFadeIn )
754cdf0e10cSrcweir             {
755cdf0e10cSrcweir                 DBG_TRACE( "SfxSplitWindow::InsertWindow_Impl - registering empty Splitwindow" );
756cdf0e10cSrcweir             }
757cdf0e10cSrcweir             else
758cdf0e10cSrcweir             {
759cdf0e10cSrcweir                 DBG_TRACE( "SfxSplitWindow::InsertWindow_Impl - registering real Splitwindow" );
760cdf0e10cSrcweir             }
761cdf0e10cSrcweir #endif
762cdf0e10cSrcweir             pWorkWin->RegisterChild_Impl( *GetSplitWindow(), eAlign, sal_True )->nVisible = CHILD_VISIBLE;
763cdf0e10cSrcweir             pWorkWin->ArrangeChilds_Impl();
764cdf0e10cSrcweir             if ( bFadeIn )
765cdf0e10cSrcweir                 FadeIn();
766cdf0e10cSrcweir         }
767cdf0e10cSrcweir 
768cdf0e10cSrcweir         pWorkWin->ShowChilds_Impl();
769cdf0e10cSrcweir     }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir     if ( bUpdateMode )
772cdf0e10cSrcweir         SetUpdateMode( sal_True );
773cdf0e10cSrcweir     bLocked = sal_False;
774cdf0e10cSrcweir }
775cdf0e10cSrcweir 
776cdf0e10cSrcweir //-------------------------------------------------------------------------
777cdf0e10cSrcweir 
778cdf0e10cSrcweir void SfxSplitWindow::RemoveWindow( SfxDockingWindow* pDockWin, sal_Bool bHide )
779cdf0e10cSrcweir 
780cdf0e10cSrcweir /*  [Beschreibung]
781cdf0e10cSrcweir 
782cdf0e10cSrcweir     Entfernt ein DockingWindow. Wenn es das letzte war, wird das SplitWindow
783cdf0e10cSrcweir     gehidet.
784cdf0e10cSrcweir */
785cdf0e10cSrcweir {
786cdf0e10cSrcweir     sal_uInt16 nSet = GetSet( pDockWin->GetType() );
787cdf0e10cSrcweir 
788cdf0e10cSrcweir     // Splitwindows werden im SFX einmal angelegt und nach dem Entfernen
789cdf0e10cSrcweir     // des letzten DockingWindows unsichtbar gemacht.
790cdf0e10cSrcweir     if ( GetItemCount( nSet ) == 1 && GetItemCount( 0 ) == 1 )
791cdf0e10cSrcweir     {
792cdf0e10cSrcweir         // Das Neuarrangieren am WorkWindow wird vom SfxDockingwindow
793cdf0e10cSrcweir         // veranla\st!
794cdf0e10cSrcweir         Hide();
795cdf0e10cSrcweir         pEmptyWin->aTimer.Stop();
796cdf0e10cSrcweir         sal_uInt16 nRealState = pEmptyWin->nState;
797cdf0e10cSrcweir         FadeOut_Impl();
798cdf0e10cSrcweir         pEmptyWin->Hide();
799cdf0e10cSrcweir #ifdef DBG_UTIL
800cdf0e10cSrcweir         if ( !bPinned || !pEmptyWin->bFadeIn )
801cdf0e10cSrcweir         {
802cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::RemoveWindow - releasing empty Splitwindow" );
803cdf0e10cSrcweir         }
804cdf0e10cSrcweir         else
805cdf0e10cSrcweir         {
806cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::RemoveWindow - releasing real Splitwindow" );
807cdf0e10cSrcweir         }
808cdf0e10cSrcweir #endif
809cdf0e10cSrcweir         pWorkWin->ReleaseChild_Impl( *GetSplitWindow() );
810cdf0e10cSrcweir         pEmptyWin->nState = nRealState;
811cdf0e10cSrcweir         pWorkWin->ArrangeAutoHideWindows( this );
812cdf0e10cSrcweir     }
813cdf0e10cSrcweir 
814cdf0e10cSrcweir     SfxDock_Impl *pDock=0;
815cdf0e10cSrcweir     sal_uInt16 nCount = pDockArr->Count();
816cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<nCount; n++ )
817cdf0e10cSrcweir     {
818cdf0e10cSrcweir         pDock = (*pDockArr)[n];
819cdf0e10cSrcweir         if ( pDock->nType == pDockWin->GetType() )
820cdf0e10cSrcweir         {
821cdf0e10cSrcweir             pDock->pWin = 0;
822cdf0e10cSrcweir             pDock->bHide = bHide;
823cdf0e10cSrcweir             break;
824cdf0e10cSrcweir         }
825cdf0e10cSrcweir     }
826cdf0e10cSrcweir 
827cdf0e10cSrcweir     // Fenster removen, und wenn es das letzte der Zeile war, auch die Zeile
828cdf0e10cSrcweir     // ( Zeile = ItemSet )
829cdf0e10cSrcweir     sal_Bool bUpdateMode = IsUpdateMode();
830cdf0e10cSrcweir     if ( bUpdateMode )
831cdf0e10cSrcweir         SetUpdateMode( sal_False );
832cdf0e10cSrcweir     bLocked = sal_True;
833cdf0e10cSrcweir 
834cdf0e10cSrcweir     RemoveItem( pDockWin->GetType() );
835cdf0e10cSrcweir 
836cdf0e10cSrcweir     if ( nSet && !GetItemCount( nSet ) )
837cdf0e10cSrcweir         RemoveItem( nSet );
838cdf0e10cSrcweir 
839cdf0e10cSrcweir     if ( bUpdateMode )
840cdf0e10cSrcweir         SetUpdateMode( sal_True );
841cdf0e10cSrcweir     bLocked = sal_False;
842cdf0e10cSrcweir };
843cdf0e10cSrcweir 
844cdf0e10cSrcweir //-------------------------------------------------------------------------
845cdf0e10cSrcweir 
846cdf0e10cSrcweir sal_Bool SfxSplitWindow::GetWindowPos( const SfxDockingWindow* pWindow,
847cdf0e10cSrcweir                                         sal_uInt16& rLine, sal_uInt16& rPos ) const
848cdf0e10cSrcweir /*  [Beschreibung]
849cdf0e10cSrcweir 
850cdf0e10cSrcweir     Liefert die Id des Itemsets und die des Items f"ur das "ubergebene
851cdf0e10cSrcweir     DockingWindow in der alten Zeilen/Spalten-Bezeichnung zur"uck.
852cdf0e10cSrcweir */
853cdf0e10cSrcweir 
854cdf0e10cSrcweir {
855cdf0e10cSrcweir     sal_uInt16 nSet = GetSet ( pWindow->GetType() );
856cdf0e10cSrcweir     if ( nSet == SPLITWINDOW_ITEM_NOTFOUND )
857cdf0e10cSrcweir         return sal_False;
858cdf0e10cSrcweir 
859cdf0e10cSrcweir     rPos  = GetItemPos( pWindow->GetType(), nSet );
860cdf0e10cSrcweir     rLine = GetItemPos( nSet );
861cdf0e10cSrcweir     return sal_True;
862cdf0e10cSrcweir }
863cdf0e10cSrcweir 
864cdf0e10cSrcweir //-------------------------------------------------------------------------
865cdf0e10cSrcweir 
866cdf0e10cSrcweir sal_Bool SfxSplitWindow::GetWindowPos( const Point& rTestPos,
867cdf0e10cSrcweir                                       sal_uInt16& rLine, sal_uInt16& rPos ) const
868cdf0e10cSrcweir /*  [Beschreibung]
869cdf0e10cSrcweir 
870cdf0e10cSrcweir     Liefert die Id des Itemsets und die des Items f"ur das DockingWindow
871cdf0e10cSrcweir     an der "ubergebenen Position in der alten Zeilen/Spalten-Bezeichnung
872cdf0e10cSrcweir     zur"uck.
873cdf0e10cSrcweir */
874cdf0e10cSrcweir 
875cdf0e10cSrcweir {
876cdf0e10cSrcweir     sal_uInt16 nId = GetItemId( rTestPos );
877cdf0e10cSrcweir     if ( nId == 0 )
878cdf0e10cSrcweir         return sal_False;
879cdf0e10cSrcweir 
880cdf0e10cSrcweir     sal_uInt16 nSet = GetSet ( nId );
881cdf0e10cSrcweir     rPos  = GetItemPos( nId, nSet );
882cdf0e10cSrcweir     rLine = GetItemPos( nSet );
883cdf0e10cSrcweir     return sal_True;
884cdf0e10cSrcweir }
885cdf0e10cSrcweir 
886cdf0e10cSrcweir //-------------------------------------------------------------------------
887cdf0e10cSrcweir 
888cdf0e10cSrcweir sal_uInt16 SfxSplitWindow::GetLineCount() const
889cdf0e10cSrcweir 
890cdf0e10cSrcweir /*  [Beschreibung]
891cdf0e10cSrcweir 
892cdf0e10cSrcweir     Liefert die Zeilenzahl = Zahl der Sub-Itemsets im Root-Set.
893cdf0e10cSrcweir */
894cdf0e10cSrcweir {
895cdf0e10cSrcweir     return GetItemCount( 0 );
896cdf0e10cSrcweir }
897cdf0e10cSrcweir 
898cdf0e10cSrcweir //-------------------------------------------------------------------------
899cdf0e10cSrcweir 
900cdf0e10cSrcweir long SfxSplitWindow::GetLineSize( sal_uInt16 nLine ) const
901cdf0e10cSrcweir 
902cdf0e10cSrcweir /*  [Beschreibung]
903cdf0e10cSrcweir 
904cdf0e10cSrcweir     Liefert die "Zeilenh"ohe" des nLine-ten Itemsets.
905cdf0e10cSrcweir */
906cdf0e10cSrcweir {
907cdf0e10cSrcweir     sal_uInt16 nId = GetItemId( nLine );
908cdf0e10cSrcweir     return GetItemSize( nId );
909cdf0e10cSrcweir }
910cdf0e10cSrcweir 
911cdf0e10cSrcweir //-------------------------------------------------------------------------
912cdf0e10cSrcweir 
913cdf0e10cSrcweir sal_uInt16 SfxSplitWindow::GetWindowCount( sal_uInt16 nLine ) const
914cdf0e10cSrcweir 
915cdf0e10cSrcweir /*  [Beschreibung]
916cdf0e10cSrcweir 
917cdf0e10cSrcweir     Liefert die
918cdf0e10cSrcweir */
919cdf0e10cSrcweir {
920cdf0e10cSrcweir     sal_uInt16 nId = GetItemId( nLine );
921cdf0e10cSrcweir     return GetItemCount( nId );
922cdf0e10cSrcweir }
923cdf0e10cSrcweir 
924cdf0e10cSrcweir //-------------------------------------------------------------------------
925cdf0e10cSrcweir 
926cdf0e10cSrcweir sal_uInt16 SfxSplitWindow::GetWindowCount() const
927cdf0e10cSrcweir 
928cdf0e10cSrcweir /*  [Beschreibung]
929cdf0e10cSrcweir 
930cdf0e10cSrcweir     Liefert die Gesamtzahl aller Fenstert
931cdf0e10cSrcweir */
932cdf0e10cSrcweir {
933cdf0e10cSrcweir     return GetItemCount( 0 );
934cdf0e10cSrcweir }
935cdf0e10cSrcweir 
936cdf0e10cSrcweir //-------------------------------------------------------------------------
937cdf0e10cSrcweir 
938cdf0e10cSrcweir void SfxSplitWindow::Command( const CommandEvent& rCEvt )
939cdf0e10cSrcweir {
940cdf0e10cSrcweir     SplitWindow::Command( rCEvt );
941cdf0e10cSrcweir }
942cdf0e10cSrcweir 
943cdf0e10cSrcweir //-------------------------------------------------------------------------
944cdf0e10cSrcweir 
945cdf0e10cSrcweir IMPL_LINK( SfxSplitWindow, TimerHdl, Timer*, pTimer)
946cdf0e10cSrcweir {
947cdf0e10cSrcweir     if ( pTimer )
948cdf0e10cSrcweir         pTimer->Stop();
949cdf0e10cSrcweir 
950cdf0e10cSrcweir     if ( CursorIsOverRect( sal_False ) || !pTimer )
951cdf0e10cSrcweir     {
952cdf0e10cSrcweir         // Wenn der Mauszeiger innerhalb des Fensters liegt, SplitWindow anzeigen
953cdf0e10cSrcweir         // und Timer zum Schlie\sen aufsetzen
954cdf0e10cSrcweir         pEmptyWin->bAutoHide = sal_True;
955cdf0e10cSrcweir         if ( !IsVisible() )
956cdf0e10cSrcweir             pEmptyWin->FadeIn();
957cdf0e10cSrcweir 
958cdf0e10cSrcweir         pEmptyWin->aLastPos = GetPointerPosPixel();
959cdf0e10cSrcweir         pEmptyWin->aTimer.Start();
960cdf0e10cSrcweir     }
961cdf0e10cSrcweir     else if ( pEmptyWin->bAutoHide )
962cdf0e10cSrcweir     {
963cdf0e10cSrcweir         if ( GetPointerPosPixel() != pEmptyWin->aLastPos )
964cdf0e10cSrcweir         {
965cdf0e10cSrcweir             // Die Maus wurd innerhalb der Timerlaugzeit bewegt, also erst einmal
966cdf0e10cSrcweir             // nichts tun
967cdf0e10cSrcweir             pEmptyWin->aLastPos = GetPointerPosPixel();
968cdf0e10cSrcweir             pEmptyWin->aTimer.Start();
969cdf0e10cSrcweir             return 0L;
970cdf0e10cSrcweir         }
971cdf0e10cSrcweir 
972cdf0e10cSrcweir         // Speziell f"ur TF_AUTOSHOW_ON_MOUSEMOVE :
973cdf0e10cSrcweir         // Wenn das Fenster nicht sichtbar ist, gibt es nichts zu tun
974cdf0e10cSrcweir         // (Benutzer ist einfach mit der Maus "uber pEmptyWin gefahren)
975cdf0e10cSrcweir         if ( IsVisible() )
976cdf0e10cSrcweir         {
977cdf0e10cSrcweir             pEmptyWin->bEndAutoHide = sal_False;
978cdf0e10cSrcweir             if ( !Application::IsInModalMode() &&
979cdf0e10cSrcweir                   !PopupMenu::IsInExecute() &&
980cdf0e10cSrcweir                   !pEmptyWin->bSplit && !HasChildPathFocus( sal_True ) )
981cdf0e10cSrcweir             {
982cdf0e10cSrcweir                 // W"ahrend ein modaler Dialog oder ein Popupmenu offen sind
983cdf0e10cSrcweir                 // oder w"ahrend des Splittens auf keinen Fall zumachen; auch
984cdf0e10cSrcweir                 // solange eines der Children den Focus hat, bleibt das
985cdf0e10cSrcweir                 // das Fenster offen
986cdf0e10cSrcweir                 pEmptyWin->bEndAutoHide = sal_True;
987cdf0e10cSrcweir             }
988cdf0e10cSrcweir 
989cdf0e10cSrcweir             if ( pEmptyWin->bEndAutoHide )
990cdf0e10cSrcweir             {
991cdf0e10cSrcweir                 // Von mir aus kann Schlu\s sein mit AutoShow
992cdf0e10cSrcweir                 // Aber vielleicht will noch ein anderes SfxSplitWindow offen bleiben,
993cdf0e10cSrcweir                 // dann bleiben auch alle anderen offen
994cdf0e10cSrcweir                 if ( !pWorkWin->IsAutoHideMode( this ) )
995cdf0e10cSrcweir                 {
996cdf0e10cSrcweir                     FadeOut_Impl();
997cdf0e10cSrcweir                     pWorkWin->ArrangeAutoHideWindows( this );
998cdf0e10cSrcweir                 }
999cdf0e10cSrcweir                 else
1000cdf0e10cSrcweir                 {
1001cdf0e10cSrcweir                     pEmptyWin->aLastPos = GetPointerPosPixel();
1002cdf0e10cSrcweir                     pEmptyWin->aTimer.Start();
1003cdf0e10cSrcweir                 }
1004cdf0e10cSrcweir             }
1005cdf0e10cSrcweir             else
1006cdf0e10cSrcweir             {
1007cdf0e10cSrcweir                 pEmptyWin->aLastPos = GetPointerPosPixel();
1008cdf0e10cSrcweir                 pEmptyWin->aTimer.Start();
1009cdf0e10cSrcweir             }
1010cdf0e10cSrcweir         }
1011cdf0e10cSrcweir     }
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir     return 0L;
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir //-------------------------------------------------------------------------
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir sal_Bool SfxSplitWindow::CursorIsOverRect( sal_Bool bForceAdding ) const
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir     sal_Bool bVisible = IsVisible();
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir     // Auch das kollabierte SplitWindow ber"ucksichtigen
1023cdf0e10cSrcweir     Point aPos = pEmptyWin->GetParent()->OutputToScreenPixel( pEmptyWin->GetPosPixel() );
1024cdf0e10cSrcweir     Size aSize = pEmptyWin->GetSizePixel();
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir     if ( bForceAdding )
1027cdf0e10cSrcweir     {
1028cdf0e10cSrcweir         // Um +/- ein paar Pixel erweitern, sonst ist es zu nerv"os
1029cdf0e10cSrcweir         aPos.X() -= nPixel;
1030cdf0e10cSrcweir         aPos.Y() -= nPixel;
1031cdf0e10cSrcweir         aSize.Width() += 2 * nPixel;
1032cdf0e10cSrcweir         aSize.Height() += 2 * nPixel;
1033cdf0e10cSrcweir     }
1034cdf0e10cSrcweir 
1035cdf0e10cSrcweir     Rectangle aRect( aPos, aSize );
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir     if ( bVisible )
1038cdf0e10cSrcweir     {
1039cdf0e10cSrcweir         Point aVisPos = GetPosPixel();
1040cdf0e10cSrcweir         Size aVisSize = GetSizePixel();
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir         // Um +/- ein paar Pixel erweitern, sonst ist es zu nerv"os
1043cdf0e10cSrcweir         aVisPos.X() -= nPixel;
1044cdf0e10cSrcweir         aVisPos.Y() -= nPixel;
1045cdf0e10cSrcweir         aVisSize.Width() += 2 * nPixel;
1046cdf0e10cSrcweir         aVisSize.Height() += 2 * nPixel;
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir         Rectangle aVisRect( aVisPos, aVisSize );
1049cdf0e10cSrcweir         aRect = aRect.GetUnion( aVisRect );
1050cdf0e10cSrcweir     }
1051cdf0e10cSrcweir 
1052cdf0e10cSrcweir     if ( aRect.IsInside( OutputToScreenPixel( ((Window*)this)->GetPointerPosPixel() ) ) )
1053cdf0e10cSrcweir         return sal_True;
1054cdf0e10cSrcweir     return sal_False;
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir //-------------------------------------------------------------------------
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir SplitWindow* SfxSplitWindow::GetSplitWindow()
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir     if ( !bPinned || !pEmptyWin->bFadeIn )
1062cdf0e10cSrcweir         return pEmptyWin;
1063cdf0e10cSrcweir     return this;
1064cdf0e10cSrcweir }
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir //-------------------------------------------------------------------------
1067cdf0e10cSrcweir sal_Bool SfxSplitWindow::IsFadeIn() const
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir     return pEmptyWin->bFadeIn;
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir sal_Bool SfxSplitWindow::IsAutoHide( sal_Bool bSelf ) const
1073cdf0e10cSrcweir {
1074cdf0e10cSrcweir     return bSelf ? pEmptyWin->bAutoHide && !pEmptyWin->bEndAutoHide : pEmptyWin->bAutoHide;
1075cdf0e10cSrcweir }
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir //-------------------------------------------------------------------------
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir void SfxSplitWindow::SetPinned_Impl( sal_Bool bOn )
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir     if ( bPinned == bOn )
1082cdf0e10cSrcweir         return;
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir     bPinned = bOn;
1085cdf0e10cSrcweir     if ( GetItemCount( 0 ) == 0 )
1086cdf0e10cSrcweir         return;
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir     if ( !bOn )
1089cdf0e10cSrcweir     {
1090cdf0e10cSrcweir         pEmptyWin->nState |= 1;
1091cdf0e10cSrcweir         if ( pEmptyWin->bFadeIn )
1092cdf0e10cSrcweir         {
1093cdf0e10cSrcweir             // Ersatzfenster anmelden
1094cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::SetPinned_Impl - releasing real Splitwindow" );
1095cdf0e10cSrcweir             pWorkWin->ReleaseChild_Impl( *this );
1096cdf0e10cSrcweir             Hide();
1097cdf0e10cSrcweir             pEmptyWin->Actualize();
1098cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::SetPinned_Impl - registering empty Splitwindow" );
1099cdf0e10cSrcweir             pWorkWin->RegisterChild_Impl( *pEmptyWin, eAlign, sal_True )->nVisible = CHILD_VISIBLE;
1100cdf0e10cSrcweir         }
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir         Point aPos( GetPosPixel() );
1103cdf0e10cSrcweir         aPos = GetParent()->OutputToScreenPixel( aPos );
1104cdf0e10cSrcweir         SetFloatingPos( aPos );
1105cdf0e10cSrcweir         SetFloatingMode( sal_True );
1106cdf0e10cSrcweir         GetFloatingWindow()->SetOutputSizePixel( GetOutputSizePixel() );
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir         if ( pEmptyWin->bFadeIn )
1109cdf0e10cSrcweir             Show();
1110cdf0e10cSrcweir     }
1111cdf0e10cSrcweir     else
1112cdf0e10cSrcweir     {
1113cdf0e10cSrcweir         pEmptyWin->nState &= ~1;
1114cdf0e10cSrcweir         SetOutputSizePixel( GetFloatingWindow()->GetOutputSizePixel() );
1115cdf0e10cSrcweir         SetFloatingMode( sal_False );
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir         if ( pEmptyWin->bFadeIn )
1118cdf0e10cSrcweir         {
1119cdf0e10cSrcweir             // Ersatzfenster abmelden
1120cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::SetPinned_Impl - releasing empty Splitwindow" );
1121cdf0e10cSrcweir             pWorkWin->ReleaseChild_Impl( *pEmptyWin );
1122cdf0e10cSrcweir             pEmptyWin->Hide();
1123cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::SetPinned_Impl - registering real Splitwindow" );
1124cdf0e10cSrcweir             pWorkWin->RegisterChild_Impl( *this, eAlign, sal_True )->nVisible = CHILD_VISIBLE;
1125cdf0e10cSrcweir         }
1126cdf0e10cSrcweir     }
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir     SetAutoHideState( !bPinned );
1129cdf0e10cSrcweir     pEmptyWin->SetAutoHideState( !bPinned );
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir //-------------------------------------------------------------------------
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir void SfxSplitWindow::SetFadeIn_Impl( sal_Bool bOn )
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir     if ( bOn == pEmptyWin->bFadeIn )
1137cdf0e10cSrcweir         return;
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir     if ( GetItemCount( 0 ) == 0 )
1140cdf0e10cSrcweir         return;
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir     pEmptyWin->bFadeIn = bOn;
1143cdf0e10cSrcweir     if ( bOn )
1144cdf0e10cSrcweir     {
1145cdf0e10cSrcweir         pEmptyWin->nState |= 2;
1146cdf0e10cSrcweir         if ( IsFloatingMode() )
1147cdf0e10cSrcweir         {
1148cdf0e10cSrcweir             // FloatingWindow ist nicht sichtbar, also anzeigen
1149cdf0e10cSrcweir             pWorkWin->ArrangeAutoHideWindows( this );
1150cdf0e10cSrcweir             Show();
1151cdf0e10cSrcweir         }
1152cdf0e10cSrcweir         else
1153cdf0e10cSrcweir         {
1154cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::SetFadeIn_Impl - releasing empty Splitwindow" );
1155cdf0e10cSrcweir             pWorkWin->ReleaseChild_Impl( *pEmptyWin );
1156cdf0e10cSrcweir             pEmptyWin->Hide();
1157cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::SetFadeIn_Impl - registering real Splitwindow" );
1158cdf0e10cSrcweir             pWorkWin->RegisterChild_Impl( *this, eAlign, sal_True )->nVisible = CHILD_VISIBLE;
1159cdf0e10cSrcweir             pWorkWin->ArrangeChilds_Impl();
1160cdf0e10cSrcweir             pWorkWin->ShowChilds_Impl();
1161cdf0e10cSrcweir         }
1162cdf0e10cSrcweir     }
1163cdf0e10cSrcweir     else
1164cdf0e10cSrcweir     {
1165cdf0e10cSrcweir         pEmptyWin->bAutoHide = sal_False;
1166cdf0e10cSrcweir         pEmptyWin->nState &= ~2;
1167cdf0e10cSrcweir         if ( !IsFloatingMode() )
1168cdf0e10cSrcweir         {
1169cdf0e10cSrcweir             // Das Fenster "schwebt" nicht, soll aber ausgeblendet werden,
1170cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::SetFadeIn_Impl - releasing real Splitwindow" );
1171cdf0e10cSrcweir             pWorkWin->ReleaseChild_Impl( *this );
1172cdf0e10cSrcweir             Hide();
1173cdf0e10cSrcweir             pEmptyWin->Actualize();
1174cdf0e10cSrcweir             DBG_TRACE( "SfxSplitWindow::SetFadeIn_Impl - registering empty Splitwindow" );
1175cdf0e10cSrcweir             pWorkWin->RegisterChild_Impl( *pEmptyWin, eAlign, sal_True )->nVisible = CHILD_VISIBLE;
1176cdf0e10cSrcweir             pWorkWin->ArrangeChilds_Impl();
1177cdf0e10cSrcweir             pWorkWin->ShowChilds_Impl();
1178cdf0e10cSrcweir             pWorkWin->ArrangeAutoHideWindows( this );
1179cdf0e10cSrcweir         }
1180cdf0e10cSrcweir         else
1181cdf0e10cSrcweir         {
1182cdf0e10cSrcweir             Hide();
1183cdf0e10cSrcweir             pWorkWin->ArrangeAutoHideWindows( this );
1184cdf0e10cSrcweir         }
1185cdf0e10cSrcweir     }
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir void SfxSplitWindow::AutoHide()
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir     // Wenn dieser Handler am "echten" SplitWindow aufgerufen wird, ist es
1191cdf0e10cSrcweir     // entweder angedockt und soll "schwebend" angezeigt werden oder umgekehrt
1192cdf0e10cSrcweir     if ( !bPinned )
1193cdf0e10cSrcweir     {
1194cdf0e10cSrcweir         // Es "schwebt", also wieder andocken
1195cdf0e10cSrcweir         SetPinned_Impl( sal_True );
1196cdf0e10cSrcweir         pWorkWin->ArrangeChilds_Impl();
1197cdf0e10cSrcweir     }
1198cdf0e10cSrcweir     else
1199cdf0e10cSrcweir     {
1200cdf0e10cSrcweir         // In den "Schwebezustand" bringen
1201cdf0e10cSrcweir         SetPinned_Impl( sal_False );
1202cdf0e10cSrcweir         pWorkWin->ArrangeChilds_Impl();
1203cdf0e10cSrcweir         pWorkWin->ArrangeAutoHideWindows( this );
1204cdf0e10cSrcweir     }
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir     pWorkWin->ShowChilds_Impl();
1207cdf0e10cSrcweir     SaveConfig_Impl();
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir void SfxSplitWindow::FadeOut_Impl()
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir     if ( pEmptyWin->aTimer.IsActive() )
1213cdf0e10cSrcweir     {
1214cdf0e10cSrcweir         pEmptyWin->bAutoHide = sal_False;
1215cdf0e10cSrcweir         pEmptyWin->aTimer.Stop();
1216cdf0e10cSrcweir     }
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir     SetFadeIn_Impl( sal_False );
1219cdf0e10cSrcweir     Show_Impl();
1220cdf0e10cSrcweir }
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir void SfxSplitWindow::FadeOut()
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir     FadeOut_Impl();
1225cdf0e10cSrcweir     SaveConfig_Impl();
1226cdf0e10cSrcweir }
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir void SfxSplitWindow::FadeIn()
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir     SetFadeIn_Impl( sal_True );
1231cdf0e10cSrcweir     Show_Impl();
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir void SfxSplitWindow::Show_Impl()
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir     sal_uInt16 nCount = pDockArr->Count();
1237cdf0e10cSrcweir     for ( sal_uInt16 n=0; n<nCount; n++ )
1238cdf0e10cSrcweir     {
1239cdf0e10cSrcweir         SfxDock_Impl *pDock = (*pDockArr)[n];
1240cdf0e10cSrcweir         if ( pDock->pWin )
1241cdf0e10cSrcweir             pDock->pWin->FadeIn( pEmptyWin->bFadeIn );
1242cdf0e10cSrcweir     }
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir /*
1245cdf0e10cSrcweir void SfxSplitWindow::Pin_Impl( sal_Bool bPin )
1246cdf0e10cSrcweir {
1247cdf0e10cSrcweir     if ( bPinned != bPin )
1248cdf0e10cSrcweir         AutoHide();
1249cdf0e10cSrcweir }
1250cdf0e10cSrcweir */
1251cdf0e10cSrcweir sal_Bool SfxSplitWindow::ActivateNextChild_Impl( sal_Bool bForward )
1252cdf0e10cSrcweir {
1253cdf0e10cSrcweir     // Wenn kein pActive, auf erstes bzw. letztes Fenster gehen ( bei !bForward wird erst in der loop dekrementiert )
1254cdf0e10cSrcweir     sal_uInt16 nCount = pDockArr->Count();
1255cdf0e10cSrcweir     sal_uInt16 n = bForward ? 0 : nCount;
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir     // Wenn Focus innerhalb, dann ein Fenster vor oder zur"uck, wenn m"oglich
1258cdf0e10cSrcweir     if ( pActive )
1259cdf0e10cSrcweir     {
1260cdf0e10cSrcweir         // Aktives Fenster ermitteln
1261cdf0e10cSrcweir         for ( n=0; n<nCount; n++ )
1262cdf0e10cSrcweir         {
1263cdf0e10cSrcweir             SfxDock_Impl *pD = (*pDockArr)[n];
1264cdf0e10cSrcweir             if ( pD->pWin && pD->pWin->HasChildPathFocus() )
1265cdf0e10cSrcweir                 break;
1266cdf0e10cSrcweir         }
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir         if ( bForward )
1269cdf0e10cSrcweir             // ein Fenster weiter ( wenn dann n>nCount, wird die Schleife unten gar nicht durchlaufen )
1270cdf0e10cSrcweir             n++;
1271cdf0e10cSrcweir     }
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir     if ( bForward )
1274cdf0e10cSrcweir     {
1275cdf0e10cSrcweir         // N"achstes Fenster suchen
1276cdf0e10cSrcweir         for ( sal_uInt16 nNext=n; nNext<nCount; nNext++ )
1277cdf0e10cSrcweir         {
1278cdf0e10cSrcweir             SfxDock_Impl *pD = (*pDockArr)[nNext];
1279cdf0e10cSrcweir             if ( pD->pWin )
1280cdf0e10cSrcweir             {
1281cdf0e10cSrcweir                 pD->pWin->GrabFocus();
1282cdf0e10cSrcweir                 return sal_True;
1283cdf0e10cSrcweir             }
1284cdf0e10cSrcweir         }
1285cdf0e10cSrcweir     }
1286cdf0e10cSrcweir     else
1287cdf0e10cSrcweir     {
1288cdf0e10cSrcweir         // Vorheriges Fenster suchen
1289cdf0e10cSrcweir         for ( sal_uInt16 nNext=n; nNext--; )
1290cdf0e10cSrcweir         {
1291cdf0e10cSrcweir             SfxDock_Impl *pD = (*pDockArr)[nNext];
1292cdf0e10cSrcweir             if ( pD->pWin )
1293cdf0e10cSrcweir             {
1294cdf0e10cSrcweir                 pD->pWin->GrabFocus();
1295cdf0e10cSrcweir                 return sal_True;
1296cdf0e10cSrcweir             }
1297cdf0e10cSrcweir         }
1298cdf0e10cSrcweir     }
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir     return sal_False;
1301cdf0e10cSrcweir }
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir void SfxSplitWindow::SetActiveWindow_Impl( SfxDockingWindow* pWin )
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir     pActive = pWin;
1306cdf0e10cSrcweir     pWorkWin->SetActiveChild_Impl( this );
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir 
1310