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