LCOV - code coverage report
Current view: top level - vcl/source/window - dockmgr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 111 726 15.3 %
Date: 2012-08-25 Functions: 24 89 27.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 37 774 4.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <tools/time.hxx>
      31                 :            : #include <tools/rc.h>
      32                 :            : 
      33                 :            : #include <brdwin.hxx>
      34                 :            : #include <svdata.hxx>
      35                 :            : #include <salframe.hxx>
      36                 :            : #include <window.h>
      37                 :            : 
      38                 :            : #include <vcl/event.hxx>
      39                 :            : #include <vcl/floatwin.hxx>
      40                 :            : #include <vcl/dockwin.hxx>
      41                 :            : #include <vcl/toolbox.hxx>
      42                 :            : #include <vcl/svapp.hxx>
      43                 :            : #include <vcl/timer.hxx>
      44                 :            : #include <vcl/lineinfo.hxx>
      45                 :            : #include <vcl/unowrap.hxx>
      46                 :            : 
      47                 :            : 
      48                 :            : // =======================================================================
      49                 :            : 
      50                 :            : #define DOCKWIN_FLOATSTYLES         (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_PINABLE | WB_ROLLABLE )
      51                 :            : 
      52                 :            : // =======================================================================
      53                 :            : 
      54                 :            : 
      55                 :            : // =======================================================================
      56                 :            : 
      57                 :            : class ImplDockFloatWin2 : public FloatingWindow
      58                 :            : {
      59                 :            : private:
      60                 :            :     ImplDockingWindowWrapper*  mpDockWin;
      61                 :            :     sal_uLong           mnLastTicks;
      62                 :            :     Timer           maDockTimer;
      63                 :            :     Timer           maEndDockTimer;
      64                 :            :     Point           maDockPos;
      65                 :            :     Rectangle       maDockRect;
      66                 :            :     sal_Bool            mbInMove;
      67                 :            :     sal_uLong           mnLastUserEvent;
      68                 :            : 
      69                 :            :     DECL_LINK(DockingHdl, void *);
      70                 :            :     DECL_LINK(DockTimerHdl, void *);
      71                 :            :     DECL_LINK(EndDockTimerHdl, void *);
      72                 :            : public:
      73                 :            :     ImplDockFloatWin2( Window* pParent, WinBits nWinBits,
      74                 :            :                       ImplDockingWindowWrapper* pDockingWin );
      75                 :            :     ~ImplDockFloatWin2();
      76                 :            : 
      77                 :            :     virtual void    Move();
      78                 :            :     virtual void    Resize();
      79                 :            :     virtual void    TitleButtonClick( sal_uInt16 nButton );
      80                 :            :     virtual void    Pin();
      81                 :            :     virtual void    Roll();
      82                 :            :     virtual void    PopupModeEnd();
      83                 :            :     virtual void    Resizing( Size& rSize );
      84                 :            :     virtual sal_Bool    Close();
      85                 :            :     using Window::SetPosSizePixel;
      86                 :            :     virtual void    SetPosSizePixel( long nX, long nY,
      87                 :            :                                      long nWidth, long nHeight,
      88                 :            :                                      sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
      89                 :            : 
      90                 :            :     sal_uLong GetLastTicks() const { return mnLastTicks; }
      91                 :            : };
      92                 :            : 
      93                 :            : // =======================================================================
      94                 :            : 
      95                 :          0 : ImplDockFloatWin2::ImplDockFloatWin2( Window* pParent, WinBits nWinBits,
      96                 :            :                                     ImplDockingWindowWrapper* pDockingWin ) :
      97                 :            :         FloatingWindow( pParent, nWinBits ),
      98                 :            :         mpDockWin( pDockingWin ),
      99         [ #  # ]:          0 :         mnLastTicks( Time::GetSystemTicks() ),
     100                 :            :         mbInMove( sal_False ),
     101 [ #  # ][ #  # ]:          0 :         mnLastUserEvent( 0 )
                 [ #  # ]
     102                 :            : {
     103                 :            :     // Daten vom DockingWindow uebernehmen
     104         [ #  # ]:          0 :     if ( pDockingWin )
     105                 :            :     {
     106         [ #  # ]:          0 :         SetSettings( pDockingWin->GetWindow()->GetSettings() );
     107 [ #  # ][ #  # ]:          0 :         Enable( pDockingWin->GetWindow()->IsEnabled(), sal_False );
     108 [ #  # ][ #  # ]:          0 :         EnableInput( pDockingWin->GetWindow()->IsInputEnabled(), sal_False );
     109 [ #  # ][ #  # ]:          0 :         AlwaysEnableInput( pDockingWin->GetWindow()->IsAlwaysEnableInput(), sal_False );
     110 [ #  # ][ #  # ]:          0 :         EnableAlwaysOnTop( pDockingWin->GetWindow()->IsAlwaysOnTopEnabled() );
     111 [ #  # ][ #  # ]:          0 :         SetActivateMode( pDockingWin->GetWindow()->GetActivateMode() );
     112                 :            :     }
     113                 :            : 
     114 [ #  # ][ #  # ]:          0 :     SetBackground( GetSettings().GetStyleSettings().GetFaceColor() );
                 [ #  # ]
     115                 :            : 
     116         [ #  # ]:          0 :     maDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin2, DockTimerHdl ) );
     117         [ #  # ]:          0 :     maDockTimer.SetTimeout( 50 );
     118         [ #  # ]:          0 :     maEndDockTimer.SetTimeoutHdl( LINK( this, ImplDockFloatWin2, EndDockTimerHdl ) );
     119         [ #  # ]:          0 :     maEndDockTimer.SetTimeout( 50 );
     120                 :          0 : }
     121                 :            : 
     122                 :            : // -----------------------------------------------------------------------
     123                 :            : 
     124 [ #  # ][ #  # ]:          0 : ImplDockFloatWin2::~ImplDockFloatWin2()
     125                 :            : {
     126         [ #  # ]:          0 :     if( mnLastUserEvent )
     127         [ #  # ]:          0 :         Application::RemoveUserEvent( mnLastUserEvent );
     128         [ #  # ]:          0 : }
     129                 :            : 
     130                 :            : // -----------------------------------------------------------------------
     131                 :            : 
     132                 :          0 : IMPL_LINK_NOARG(ImplDockFloatWin2, DockTimerHdl)
     133                 :            : {
     134                 :            :     DBG_ASSERT( mpDockWin->IsFloatingMode(), "docktimer called but not floating" );
     135                 :            : 
     136         [ #  # ]:          0 :     maDockTimer.Stop();
     137         [ #  # ]:          0 :     PointerState aState = GetPointerState();
     138                 :            : 
     139         [ #  # ]:          0 :     if( aState.mnState & KEY_MOD1 )
     140                 :            :     {
     141                 :            :         // i43499 CTRL disables docking now
     142 [ #  # ][ #  # ]:          0 :         mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
                 [ #  # ]
     143         [ #  # ]:          0 :         if( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) )
     144         [ #  # ]:          0 :             maDockTimer.Start();
     145                 :            :     }
     146         [ #  # ]:          0 :     else if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
     147                 :            :     {
     148 [ #  # ][ #  # ]:          0 :         mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
                 [ #  # ]
     149         [ #  # ]:          0 :         mpDockWin->EndDocking( maDockRect, sal_False );
     150                 :            :     }
     151                 :            :     else
     152                 :            :     {
     153 [ #  # ][ #  # ]:          0 :         mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
                 [ #  # ]
     154         [ #  # ]:          0 :         maDockTimer.Start();
     155                 :            :     }
     156                 :            : 
     157                 :          0 :     return 0;
     158                 :            : }
     159                 :            : 
     160                 :          0 : IMPL_LINK_NOARG(ImplDockFloatWin2, EndDockTimerHdl)
     161                 :            : {
     162                 :            :     DBG_ASSERT( mpDockWin->IsFloatingMode(), "enddocktimer called but not floating" );
     163                 :            : 
     164         [ #  # ]:          0 :     maEndDockTimer.Stop();
     165         [ #  # ]:          0 :     PointerState aState = GetPointerState();
     166         [ #  # ]:          0 :     if( ! ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) )
     167                 :            :     {
     168 [ #  # ][ #  # ]:          0 :         mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
                 [ #  # ]
     169         [ #  # ]:          0 :         mpDockWin->EndDocking( maDockRect, sal_True );
     170                 :            :     }
     171                 :            :     else
     172                 :            :     {
     173         [ #  # ]:          0 :         maEndDockTimer.Start();
     174                 :            :     }
     175                 :            : 
     176                 :          0 :     return 0;
     177                 :            : }
     178                 :            : 
     179                 :            : 
     180                 :          0 : IMPL_LINK_NOARG(ImplDockFloatWin2, DockingHdl)
     181                 :            : {
     182                 :            :     // called during move of a floating window
     183                 :          0 :     mnLastUserEvent = 0;
     184                 :            : 
     185         [ #  # ]:          0 :     Window *pDockingArea = mpDockWin->GetWindow()->GetParent();
     186         [ #  # ]:          0 :     PointerState aState = pDockingArea->GetPointerState();
     187                 :            : 
     188                 :          0 :     sal_Bool bRealMove = sal_True;
     189 [ #  # ][ #  # ]:          0 :     if( GetStyle() & WB_OWNERDRAWDECORATION )
     190                 :            :     {
     191                 :            :         // for windows with ownerdraw decoration
     192                 :            :         // we allow docking only when the window was moved
     193                 :            :         // by dragging its caption
     194                 :            :         // and ignore move request due to resizing
     195         [ #  # ]:          0 :         Window *pBorder = GetWindow( WINDOW_BORDER );
     196         [ #  # ]:          0 :         if( pBorder != this )
     197                 :            :         {
     198                 :          0 :             Point aPt;
     199 [ #  # ][ #  # ]:          0 :             Rectangle aBorderRect( aPt, pBorder->GetSizePixel() );
     200                 :            :             sal_Int32 nLeft, nTop, nRight, nBottom;
     201         [ #  # ]:          0 :             GetBorder( nLeft, nTop, nRight, nBottom );
     202                 :            :             // limit borderrect to the caption part only and without the resizing borders
     203                 :          0 :             aBorderRect.nBottom = aBorderRect.nTop + nTop;
     204                 :          0 :             aBorderRect.nLeft += nLeft;
     205                 :          0 :             aBorderRect.nRight -= nRight;
     206                 :            : 
     207         [ #  # ]:          0 :             PointerState aBorderState = pBorder->GetPointerState();
     208 [ #  # ][ #  # ]:          0 :             if( aBorderRect.IsInside( aBorderState.maPos ) )
     209                 :          0 :                 bRealMove = sal_True;
     210                 :            :             else
     211                 :          0 :                 bRealMove = sal_False;
     212                 :            :         }
     213                 :            :     }
     214                 :            : 
     215 [ #  # ][ #  # ]:          0 :     if( mpDockWin->IsDockable() &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     216         [ #  # ]:          0 :         mpDockWin->GetWindow()->IsVisible() &&
     217         [ #  # ]:          0 :         (Time::GetSystemTicks() - mnLastTicks > 500) &&
     218                 :            :         ( aState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT ) ) &&
     219                 :          0 :         !(aState.mnState & KEY_MOD1) && // i43499 CTRL disables docking now
     220                 :            :         bRealMove )
     221                 :            :     {
     222 [ #  # ][ #  # ]:          0 :         maDockPos = Point( pDockingArea->OutputToScreenPixel( pDockingArea->AbsoluteScreenToOutputPixel( OutputToAbsoluteScreenPixel( Point() ) ) ) );
                 [ #  # ]
     223 [ #  # ][ #  # ]:          0 :         maDockRect = Rectangle( maDockPos, mpDockWin->GetSizePixel() );
     224                 :            : 
     225                 :            :         // mouse pos in screen pixels
     226         [ #  # ]:          0 :         Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
     227                 :            : 
     228         [ #  # ]:          0 :         if( ! mpDockWin->IsDocking() )
     229         [ #  # ]:          0 :             mpDockWin->StartDocking( aMousePos, maDockRect );
     230                 :            : 
     231         [ #  # ]:          0 :         sal_Bool bFloatMode = mpDockWin->Docking( aMousePos, maDockRect );
     232                 :            : 
     233         [ #  # ]:          0 :         if( ! bFloatMode )
     234                 :            :         {
     235                 :            :             // indicates that the window could be docked at maDockRect
     236                 :            :             maDockRect.SetPos( mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ScreenToOutputPixel(
     237 [ #  # ][ #  # ]:          0 :                  maDockRect.TopLeft() ) );
                 [ #  # ]
     238 [ #  # ][ #  # ]:          0 :             mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->ShowTracking( maDockRect, SHOWTRACK_BIG | SHOWTRACK_WINDOW );
                 [ #  # ]
     239         [ #  # ]:          0 :             maEndDockTimer.Stop();
     240         [ #  # ]:          0 :             DockTimerHdl( this );
     241                 :            :         }
     242                 :            :         else
     243                 :            :         {
     244 [ #  # ][ #  # ]:          0 :             mpDockWin->GetWindow()->GetParent()->ImplGetFrameWindow()->HideTracking();
                 [ #  # ]
     245         [ #  # ]:          0 :             maDockTimer.Stop();
     246         [ #  # ]:          0 :             EndDockTimerHdl( this );
     247                 :            :         }
     248                 :            :     }
     249                 :          0 :     mbInMove = sal_False;
     250                 :          0 :     return 0;
     251                 :            : }
     252                 :            : // -----------------------------------------------------------------------
     253                 :            : 
     254                 :          0 : void ImplDockFloatWin2::Move()
     255                 :            : {
     256         [ #  # ]:          0 :     if( mbInMove )
     257                 :          0 :         return;
     258                 :            : 
     259                 :          0 :     mbInMove = sal_True;
     260                 :          0 :     FloatingWindow::Move();
     261                 :          0 :     mpDockWin->GetWindow()->Move();
     262                 :            : 
     263                 :            :     /*
     264                 :            :      *  note: the window should only dock if KEY_MOD1 is pressed
     265                 :            :      *  and the user releases all mouse buttons. The real problem here
     266                 :            :      *  is that we don't get mouse events (at least not on X)
     267                 :            :      *  if the mouse is on the decoration. So we have to start an
     268                 :            :      *  awkward timer based process that polls the modifier/buttons
     269                 :            :      *  to see whether they are in the right condition shortly after the
     270                 :            :      *  last Move message.
     271                 :            :      */
     272         [ #  # ]:          0 :     if( ! mnLastUserEvent )
     273         [ #  # ]:          0 :         mnLastUserEvent = Application::PostUserEvent( LINK( this, ImplDockFloatWin2, DockingHdl ) );
     274                 :            : }
     275                 :            : 
     276                 :            : // -----------------------------------------------------------------------
     277                 :            : 
     278                 :          0 : void ImplDockFloatWin2::Resize()
     279                 :            : {
     280                 :            :     // forwarding of resize only required if we have no borderwindow ( GetWindow() then returns 'this' )
     281         [ #  # ]:          0 :     if( GetWindow( WINDOW_BORDER ) == this )
     282                 :            :     {
     283         [ #  # ]:          0 :         FloatingWindow::Resize();
     284         [ #  # ]:          0 :         Size aSize( GetSizePixel() );
     285         [ #  # ]:          0 :         mpDockWin->GetWindow()->ImplPosSizeWindow( 0, 0, aSize.Width(), aSize.Height(), WINDOW_POSSIZE_POSSIZE ); // is this needed ???
     286                 :            :     }
     287                 :          0 : }
     288                 :            : 
     289                 :          0 : void ImplDockFloatWin2::SetPosSizePixel( long nX, long nY,
     290                 :            :                                      long nWidth, long nHeight,
     291                 :            :                                      sal_uInt16 nFlags )
     292                 :            : {
     293                 :          0 :     FloatingWindow::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
     294                 :          0 : }
     295                 :            : 
     296                 :            : // -----------------------------------------------------------------------
     297                 :            : 
     298                 :            : 
     299                 :          0 : void ImplDockFloatWin2::TitleButtonClick( sal_uInt16 nButton )
     300                 :            : {
     301                 :          0 :     FloatingWindow::TitleButtonClick( nButton );
     302                 :          0 :     mpDockWin->TitleButtonClick( nButton );
     303                 :          0 : }
     304                 :            : 
     305                 :            : // -----------------------------------------------------------------------
     306                 :            : 
     307                 :          0 : void ImplDockFloatWin2::Pin()
     308                 :            : {
     309                 :          0 :     FloatingWindow::Pin();
     310                 :          0 :     mpDockWin->Pin();
     311                 :          0 : }
     312                 :            : 
     313                 :            : // -----------------------------------------------------------------------
     314                 :            : 
     315                 :          0 : void ImplDockFloatWin2::Roll()
     316                 :            : {
     317                 :          0 :     FloatingWindow::Roll();
     318                 :          0 :     mpDockWin->Roll();
     319                 :          0 : }
     320                 :            : 
     321                 :            : // -----------------------------------------------------------------------
     322                 :            : 
     323                 :          0 : void ImplDockFloatWin2::PopupModeEnd()
     324                 :            : {
     325                 :          0 :     FloatingWindow::PopupModeEnd();
     326                 :          0 :     mpDockWin->PopupModeEnd();
     327                 :          0 : }
     328                 :            : 
     329                 :            : // -----------------------------------------------------------------------
     330                 :            : 
     331                 :          0 : void ImplDockFloatWin2::Resizing( Size& rSize )
     332                 :            : {
     333                 :          0 :     FloatingWindow::Resizing( rSize );
     334                 :          0 :     mpDockWin->Resizing( rSize );
     335                 :          0 : }
     336                 :            : 
     337                 :            : // -----------------------------------------------------------------------
     338                 :            : 
     339                 :          0 : sal_Bool ImplDockFloatWin2::Close()
     340                 :            : {
     341                 :          0 :     return mpDockWin->Close();
     342                 :            : }
     343                 :            : 
     344                 :            : // =======================================================================
     345                 :            : 
     346                 :        209 : DockingManager::DockingManager()
     347                 :            : {
     348                 :        209 : }
     349                 :            : 
     350                 :        158 : DockingManager::~DockingManager()
     351                 :            : {
     352                 :        158 :     ::std::vector< ImplDockingWindowWrapper* >::iterator p;
     353                 :        158 :     p = mDockingWindows.begin();
     354 [ +  - ][ -  + ]:        158 :     for(; p != mDockingWindows.end(); ++p )
     355                 :            :     {
     356 [ #  # ][ #  # ]:          0 :         delete (*p);
     357                 :            :     }
     358                 :        158 :     mDockingWindows.clear();
     359                 :        158 : }
     360                 :            : 
     361                 :    2553585 : ImplDockingWindowWrapper* DockingManager::GetDockingWindowWrapper( const Window *pWindow )
     362                 :            : {
     363                 :    2553585 :     ::std::vector< ImplDockingWindowWrapper* >::iterator p;
     364                 :    2553585 :     p = mDockingWindows.begin();
     365 [ +  - ][ +  + ]:    6615818 :     while( p != mDockingWindows.end() )
     366                 :            :     {
     367         [ +  + ]:    5744229 :         if( (*p)->mpDockingWindow == pWindow )
     368                 :    1681996 :             return (*p);
     369                 :            :         else
     370                 :    4062233 :             ++p;
     371                 :            :     }
     372                 :    2553585 :     return NULL;
     373                 :            : }
     374                 :            : 
     375                 :     176829 : sal_Bool DockingManager::IsDockable( const Window *pWindow )
     376                 :            : {
     377                 :     176829 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     378                 :            : 
     379                 :            :     /*
     380                 :            :     if( pWindow->HasDockingHandler() )
     381                 :            :         return sal_True;
     382                 :            :     */
     383                 :     176829 :     return (pWrapper != NULL);
     384                 :            : }
     385                 :            : 
     386                 :       6859 : sal_Bool DockingManager::IsFloating( const Window *pWindow )
     387                 :            : {
     388                 :       6859 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     389         [ +  - ]:       6859 :     if( pWrapper )
     390                 :       6859 :         return pWrapper->IsFloatingMode();
     391                 :            :     else
     392                 :       6859 :         return sal_False;
     393                 :            : }
     394                 :            : 
     395                 :          0 : sal_Bool DockingManager::IsLocked( const Window *pWindow )
     396                 :            : {
     397                 :          0 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     398 [ #  # ][ #  # ]:          0 :     if( pWrapper && pWrapper->IsLocked() )
                 [ #  # ]
     399                 :          0 :         return sal_True;
     400                 :            :     else
     401                 :          0 :         return sal_False;
     402                 :            : }
     403                 :            : 
     404                 :          0 : void DockingManager::Lock( const Window *pWindow )
     405                 :            : {
     406                 :          0 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     407         [ #  # ]:          0 :     if( pWrapper )
     408                 :          0 :         pWrapper->Lock();
     409                 :          0 : }
     410                 :            : 
     411                 :          0 : void DockingManager::Unlock( const Window *pWindow )
     412                 :            : {
     413                 :          0 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     414         [ #  # ]:          0 :     if( pWrapper )
     415                 :          0 :         pWrapper->Unlock();
     416                 :          0 : }
     417                 :            : 
     418                 :       3709 : void DockingManager::SetFloatingMode( const Window *pWindow, sal_Bool bFloating )
     419                 :            : {
     420                 :       3709 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     421         [ +  - ]:       3709 :     if( pWrapper )
     422                 :       3709 :         pWrapper->SetFloatingMode( bFloating );
     423                 :       3709 : }
     424                 :            : 
     425                 :          0 : void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow, sal_uLong nFlags )
     426                 :            : {
     427                 :          0 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     428         [ #  # ]:          0 :     if( pWrapper )
     429                 :          0 :         pWrapper->StartPopupMode( pParentToolBox, nFlags );
     430                 :          0 : }
     431                 :            : 
     432                 :          0 : void DockingManager::StartPopupMode( ToolBox *pParentToolBox, const Window *pWindow )
     433                 :            : {
     434                 :            :     StartPopupMode( pParentToolBox, pWindow, FLOATWIN_POPUPMODE_ALLOWTEAROFF         |
     435                 :            :                     FLOATWIN_POPUPMODE_NOFOCUSCLOSE         |
     436                 :            :                     FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE  |
     437                 :          0 :                     FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE );
     438                 :          0 : }
     439                 :            : 
     440                 :          0 : sal_Bool DockingManager::IsInPopupMode( const Window *pWindow )
     441                 :            : {
     442                 :          0 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     443 [ #  # ][ #  # ]:          0 :     if( pWrapper && pWrapper->IsInPopupMode() )
                 [ #  # ]
     444                 :          0 :         return sal_True;
     445                 :            :     else
     446                 :          0 :         return sal_False;
     447                 :            : }
     448                 :            : 
     449                 :            : // -----------------------------------------------------------------------
     450                 :            : 
     451                 :          0 : void DockingManager::EndPopupMode( const Window *pWin )
     452                 :            : {
     453                 :          0 :     ImplDockingWindowWrapper *pWrapper = GetDockingWindowWrapper( pWin );
     454 [ #  # ][ #  # ]:          0 :     if( pWrapper && pWrapper->GetFloatingWindow() && pWrapper->GetFloatingWindow()->IsInPopupMode() )
         [ #  # ][ #  # ]
     455                 :          0 :         pWrapper->GetFloatingWindow()->EndPopupMode();
     456                 :          0 : }
     457                 :            : 
     458                 :            : // -----------------------------------------------------------------------
     459                 :            : 
     460                 :       5827 : void DockingManager::AddWindow( const Window *pWindow )
     461                 :            : {
     462         [ +  - ]:       5827 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     463         [ +  - ]:       5827 :     if( pWrapper )
     464                 :       5827 :         return;
     465                 :            :     else
     466 [ +  - ][ +  - ]:       5827 :         pWrapper = new ImplDockingWindowWrapper( pWindow );
     467                 :            : 
     468         [ +  - ]:       5827 :     mDockingWindows.push_back( pWrapper );
     469                 :            : }
     470                 :            : 
     471                 :     122611 : void DockingManager::RemoveWindow( const Window *pWindow )
     472                 :            : {
     473                 :     122611 :     ::std::vector< ImplDockingWindowWrapper* >::iterator p;
     474                 :     122611 :     p = mDockingWindows.begin();
     475 [ +  - ][ +  + ]:     459476 :     while( p != mDockingWindows.end() )
     476                 :            :     {
     477         [ +  + ]:     342510 :         if( (*p)->mpDockingWindow == pWindow )
     478                 :            :         {
     479 [ +  - ][ +  - ]:       5645 :             delete (*p);
     480         [ +  - ]:       5645 :             mDockingWindows.erase( p );
     481                 :       5645 :             break;
     482                 :            :         }
     483                 :            :         else
     484                 :     336865 :             ++p;
     485                 :            :     }
     486                 :     122611 : }
     487                 :            : 
     488                 :       3709 : void DockingManager::SetPosSizePixel( Window *pWindow, long nX, long nY,
     489                 :            :                                     long nWidth, long nHeight,
     490                 :            :                                     sal_uInt16 nFlags )
     491                 :            : {
     492                 :       3709 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     493         [ +  - ]:       3709 :     if( pWrapper )
     494                 :       3709 :         pWrapper->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
     495                 :       3709 : }
     496                 :            : 
     497                 :      15547 : Rectangle DockingManager::GetPosSizePixel( const Window *pWindow )
     498                 :            : {
     499                 :      15547 :     Rectangle aRect;
     500                 :      15547 :     ImplDockingWindowWrapper* pWrapper = GetDockingWindowWrapper( pWindow );
     501         [ +  - ]:      15547 :     if( pWrapper )
     502 [ +  - ][ +  - ]:      15547 :         aRect = Rectangle( pWrapper->GetPosPixel(), pWrapper->GetSizePixel() );
     503                 :            : 
     504                 :      15547 :     return aRect;
     505                 :            : }
     506                 :            : 
     507                 :            : // =======================================================================
     508                 :            : // special floating window for popup mode
     509                 :            : // main purpose: provides tear-off area for undocking
     510                 :            : // =======================================================================
     511                 :            : 
     512                 :            : // if TEAROFF_DASHED defined a single dashed line is used
     513                 :            : // otherwise multiple smaller lines will be painted
     514                 :            : //#define TEAROFF_DASHED
     515                 :            : 
     516                 :            : // size of the drag area
     517                 :            : #ifdef TEAROFF_DASHED
     518                 :            : #define POPUP_DRAGBORDER    2
     519                 :            : #define POPUP_DRAGGRIP      5
     520                 :            : #else
     521                 :            : #define POPUP_DRAGBORDER    3
     522                 :            : #define POPUP_DRAGGRIP      5
     523                 :            : #endif
     524                 :            : #define POPUP_DRAGHEIGHT    (POPUP_DRAGGRIP+POPUP_DRAGBORDER+POPUP_DRAGBORDER)
     525                 :            : #define POPUP_DRAGWIDTH     20
     526                 :            : 
     527                 :            : class ImplPopupFloatWin : public FloatingWindow
     528                 :            : {
     529                 :            : private:
     530                 :            :     ImplDockingWindowWrapper*   mpDockingWin;
     531                 :            :     sal_Bool                        mbHighlight;
     532                 :            :     sal_Bool                        mbMoving;
     533                 :            :     bool                        mbTrackingEnabled;
     534                 :            :     Point                       maDelta;
     535                 :            :     Point                       maTearOffPosition;
     536                 :            :     bool                        mbGripAtBottom;
     537                 :            :     bool                        mbHasGrip;
     538                 :            :     void                        ImplSetBorder();
     539                 :            : 
     540                 :            : public:
     541                 :            :     ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip );
     542                 :            :     ~ImplPopupFloatWin();
     543                 :            : 
     544                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
     545                 :            :     virtual void        Paint( const Rectangle& rRect );
     546                 :            :     virtual void        MouseMove( const MouseEvent& rMEvt );
     547                 :            :     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
     548                 :            :     virtual void        MouseButtonUp( const MouseEvent& rMEvt );
     549                 :            :     virtual void        Tracking( const TrackingEvent& rTEvt );
     550                 :            :     virtual void        Resize();
     551                 :            :     virtual Window*     GetPreferredKeyInputWindow();
     552                 :            : 
     553                 :            :     Rectangle           GetDragRect() const;
     554                 :            :     Point               GetToolboxPosition() const;
     555                 :            :     Point               GetTearOffPosition() const;
     556                 :            :     void                DrawGrip();
     557                 :            :     void                DrawBorder();
     558                 :            : 
     559                 :          0 :     bool                hasGrip() const { return mbHasGrip; }
     560                 :            : };
     561                 :            : 
     562                 :          0 : ImplPopupFloatWin::ImplPopupFloatWin( Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ) :
     563                 :          0 :     FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW)
     564                 :            : {
     565                 :          0 :     mpWindowImpl->mbToolbarFloatingWindow = sal_True;   // indicate window type, required for accessibility
     566                 :            :                                                     // which should not see this window as a toplevel window
     567                 :          0 :     mpDockingWin = pDockingWin;
     568                 :          0 :     mbHighlight = sal_False;
     569                 :          0 :     mbMoving = sal_False;
     570                 :          0 :     mbTrackingEnabled = sal_False;
     571                 :          0 :     mbGripAtBottom = sal_True;
     572                 :          0 :     mbHasGrip = bHasGrip;
     573                 :            : 
     574                 :          0 :     ImplSetBorder();
     575                 :          0 : }
     576                 :            : 
     577                 :          0 : ImplPopupFloatWin::~ImplPopupFloatWin()
     578                 :            : {
     579                 :          0 :     mpDockingWin = NULL;
     580         [ #  # ]:          0 : }
     581                 :            : 
     582                 :          0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ImplPopupFloatWin::CreateAccessible()
     583                 :            : {
     584                 :            :     // switch off direct accessibilty support for this window
     585                 :            : 
     586                 :            :     // this is to avoid appearance of this window as standalone window in the accessibility hierarchy
     587                 :            :     // as this window is only used as a helper for subtoolbars that are not teared-off, the parent toolbar
     588                 :            :     // has to provide accessibility support (as implemented in the toolkit)
     589                 :            :     // so the contained toolbar should appear as child of the correponsing toolbar item of the parent toolbar
     590                 :          0 :     return ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >();
     591                 :            : }
     592                 :            : 
     593                 :          0 : Window* ImplPopupFloatWin::GetPreferredKeyInputWindow()
     594                 :            : {
     595         [ #  # ]:          0 :     if( mpWindowImpl->mpClientWindow )
     596                 :          0 :         return mpWindowImpl->mpClientWindow;
     597                 :            :     else
     598                 :          0 :         return FloatingWindow::GetPreferredKeyInputWindow();
     599                 :            : }
     600                 :            : 
     601                 :            : 
     602                 :          0 : void ImplPopupFloatWin::ImplSetBorder()
     603                 :            : {
     604                 :            :     // although we have no border in the sense of a borderwindow
     605                 :            :     //  we're using a special border for the grip
     606                 :            :     // by setting those members the method SetOutputSizePixel() can
     607                 :            :     //  be used to set the proper window size
     608                 :          0 :     mpWindowImpl->mnTopBorder     = 1;
     609         [ #  # ]:          0 :     if( hasGrip() )
     610                 :          0 :         mpWindowImpl->mnTopBorder += POPUP_DRAGHEIGHT+2;
     611                 :          0 :     mpWindowImpl->mnBottomBorder  = 1;
     612                 :          0 :     mpWindowImpl->mnLeftBorder    = 1;
     613                 :          0 :     mpWindowImpl->mnRightBorder   = 1;
     614                 :          0 : }
     615                 :            : 
     616                 :          0 : void ImplPopupFloatWin::Resize()
     617                 :            : {
     618                 :            :     // the borderview overwrites the border during resize so restore it
     619                 :          0 :     ImplSetBorder();
     620                 :          0 : }
     621                 :            : 
     622                 :          0 : Rectangle ImplPopupFloatWin::GetDragRect() const
     623                 :            : {
     624                 :          0 :     Rectangle aRect;
     625         [ #  # ]:          0 :     if( hasGrip() )
     626                 :            :     {
     627         [ #  # ]:          0 :         aRect = Rectangle( 1,1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
     628         [ #  # ]:          0 :         if( mbGripAtBottom )
     629                 :            :         {
     630                 :          0 :             int height = GetOutputSizePixel().Height();
     631                 :          0 :             aRect.Top() = height - 3 - POPUP_DRAGHEIGHT;
     632                 :          0 :             aRect.Bottom() = aRect.Top() + 1 + POPUP_DRAGHEIGHT;
     633                 :            :         }
     634                 :            :     }
     635                 :          0 :     return aRect;
     636                 :            : }
     637                 :            : 
     638                 :          0 : Point ImplPopupFloatWin::GetToolboxPosition() const
     639                 :            : {
     640                 :            :     // return inner position where a toolbox could be placed
     641 [ #  # ][ #  # ]:          0 :     Point aPt( 1, 1 + ((mbGripAtBottom || !hasGrip()) ? 0 : GetDragRect().getHeight()) );    // grip + border
         [ #  # ][ #  # ]
                 [ #  # ]
     642                 :            : 
     643                 :          0 :     return aPt;
     644                 :            : }
     645                 :            : 
     646                 :          0 : Point ImplPopupFloatWin::GetTearOffPosition() const
     647                 :            : {
     648                 :          0 :     Point aPt( maTearOffPosition );
     649                 :            :     //aPt += GetToolboxPosition();    // remove 'decoration'
     650                 :          0 :     return aPt;
     651                 :            : }
     652                 :            : 
     653                 :          0 : void ImplPopupFloatWin::DrawBorder()
     654                 :            : {
     655         [ #  # ]:          0 :     SetFillColor();
     656                 :          0 :     Point aPt;
     657         [ #  # ]:          0 :     Rectangle aRect( aPt, GetOutputSizePixel() );
     658                 :            : 
     659         [ #  # ]:          0 :     Region oldClipRgn( GetClipRegion( ) );
     660         [ #  # ]:          0 :     Region aClipRgn( aRect );
     661         [ #  # ]:          0 :     Rectangle aItemClipRect( ImplGetItemEdgeClipRect() );
     662 [ #  # ][ #  # ]:          0 :     if( !aItemClipRect.IsEmpty() )
     663                 :            :     {
     664         [ #  # ]:          0 :         aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
     665                 :            : 
     666                 :            :         // draw the excluded border part with the background color of a toolbox
     667 [ #  # ][ #  # ]:          0 :         SetClipRegion( Region( aItemClipRect ) );
                 [ #  # ]
     668         [ #  # ]:          0 :         SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
     669         [ #  # ]:          0 :         DrawRect( aRect );
     670                 :            : 
     671         [ #  # ]:          0 :         aClipRgn.Exclude( aItemClipRect );
     672         [ #  # ]:          0 :         SetClipRegion( aClipRgn );
     673                 :            :     }
     674         [ #  # ]:          0 :     SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
     675         [ #  # ]:          0 :     DrawRect( aRect );
     676 [ #  # ][ #  # ]:          0 :     SetClipRegion( oldClipRgn );
                 [ #  # ]
     677                 :          0 : }
     678                 :            : 
     679                 :          0 : void ImplPopupFloatWin::DrawGrip()
     680                 :            : {
     681                 :          0 :     sal_Bool bLinecolor     = IsLineColor();
     682                 :          0 :     Color aLinecolor    = GetLineColor();
     683                 :          0 :     sal_Bool bFillcolor     = IsFillColor();
     684                 :          0 :     Color aFillcolor    = GetFillColor();
     685                 :            : 
     686                 :            :     // draw background
     687         [ #  # ]:          0 :     Rectangle aRect( GetDragRect() );
     688                 :          0 :     aRect.nTop      += POPUP_DRAGBORDER;
     689                 :          0 :     aRect.nBottom   -= POPUP_DRAGBORDER;
     690                 :          0 :     aRect.nLeft+=3;
     691                 :          0 :     aRect.nRight-=3;
     692                 :            : 
     693         [ #  # ]:          0 :     if( mbHighlight )
     694                 :            :     {
     695         [ #  # ]:          0 :         Erase( aRect );
     696         [ #  # ]:          0 :         DrawSelectionBackground( aRect, 2, sal_False, sal_True, sal_False );
     697                 :            :     }
     698                 :            :     else
     699                 :            :     {
     700         [ #  # ]:          0 :         SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
     701         [ #  # ]:          0 :         SetLineColor();
     702         [ #  # ]:          0 :         DrawRect( aRect );
     703                 :            :     }
     704                 :            : 
     705 [ #  # ][ #  # ]:          0 :     if( !ToolBox::AlwaysLocked() )  // no grip if toolboxes are locked
     706                 :            :     {
     707                 :            : #ifdef TEAROFF_DASHED
     708                 :            :         // draw single dashed line
     709                 :            :         LineInfo aLineInfo( LINE_DASH );
     710                 :            :         aLineInfo.SetDistance( 4 );
     711                 :            :         aLineInfo.SetDashLen( 12 );
     712                 :            :         aLineInfo.SetDashCount( 1 );
     713                 :            : 
     714                 :            :         aRect.nLeft+=2; aRect.nRight-=2;
     715                 :            : 
     716                 :            :         aRect.nTop+=2;
     717                 :            :         aRect.nBottom = aRect.nTop;
     718                 :            :         SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
     719                 :            :         DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
     720                 :            : 
     721                 :            :         if( !mbHighlight )
     722                 :            :         {
     723                 :            :             aRect.nTop++; aRect.nBottom++;
     724                 :            :             SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
     725                 :            :             DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
     726                 :            :         }
     727                 :            : 
     728                 :            : #else
     729                 :            :         // draw several grip lines
     730         [ #  # ]:          0 :         SetFillColor( GetSettings().GetStyleSettings().GetShadowColor() );
     731                 :          0 :         aRect.nTop++;
     732                 :          0 :         aRect.nBottom = aRect.nTop;
     733                 :            : 
     734                 :          0 :         int width = POPUP_DRAGWIDTH;
     735         [ #  # ]:          0 :         while( width >= aRect.getWidth() )
     736                 :          0 :             width -= 4;
     737         [ #  # ]:          0 :         if( width <= 0 )
     738                 :          0 :             width = aRect.getWidth();
     739                 :            :         //aRect.nLeft = aRect.nLeft + (aRect.getWidth() - width) / 2;
     740                 :          0 :         aRect.nLeft = (aRect.nLeft + aRect.nRight - width) / 2;
     741                 :          0 :         aRect.nRight = aRect.nLeft + width;
     742                 :            : 
     743                 :          0 :         int i=0;
     744         [ #  # ]:          0 :         while( i< POPUP_DRAGGRIP )
     745                 :            :         {
     746         [ #  # ]:          0 :             DrawRect( aRect );
     747                 :          0 :             aRect.nTop+=2;
     748                 :          0 :             aRect.nBottom+=2;
     749                 :          0 :             i+=2;
     750                 :            :         }
     751                 :            : #endif
     752                 :            :     }
     753                 :            : 
     754         [ #  # ]:          0 :     if( bLinecolor )
     755         [ #  # ]:          0 :         SetLineColor( aLinecolor );
     756                 :            :     else
     757         [ #  # ]:          0 :         SetLineColor();
     758         [ #  # ]:          0 :     if( bFillcolor )
     759         [ #  # ]:          0 :         SetFillColor( aFillcolor );
     760                 :            :     else
     761         [ #  # ]:          0 :         SetFillColor();
     762                 :          0 : }
     763                 :            : 
     764                 :          0 : void ImplPopupFloatWin::Paint( const Rectangle& )
     765                 :            : {
     766                 :          0 :     Point aPt;
     767         [ #  # ]:          0 :     Rectangle aRect( aPt, GetOutputSizePixel() );
     768 [ #  # ][ #  # ]:          0 :     DrawWallpaper( aRect, Wallpaper( GetSettings().GetStyleSettings().GetFaceGradientColor() ) );
         [ #  # ][ #  # ]
     769         [ #  # ]:          0 :     DrawBorder();
     770         [ #  # ]:          0 :     if( hasGrip() )
     771         [ #  # ]:          0 :         DrawGrip();
     772                 :          0 : }
     773                 :            : 
     774                 :          0 : void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
     775                 :            : {
     776                 :          0 :     Point aMousePos = rMEvt.GetPosPixel();
     777                 :            : 
     778 [ #  # ][ #  # ]:          0 :     if( !ToolBox::AlwaysLocked() )  // no tear off if locking is enabled
     779                 :            :     {
     780 [ #  # ][ #  # ]:          0 :         if( mbTrackingEnabled && rMEvt.IsLeft() && GetDragRect().IsInside( aMousePos ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     781                 :            :         {
     782                 :            :             // start window move
     783                 :          0 :             mbMoving = sal_True;
     784         [ #  # ]:          0 :             StartTracking( STARTTRACK_NOKEYCANCEL );
     785                 :          0 :             return;
     786                 :            :         }
     787 [ #  # ][ #  # ]:          0 :         if( !mbHighlight && GetDragRect().IsInside( aMousePos ) )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     788                 :            :         {
     789                 :          0 :             mbHighlight = sal_True;
     790         [ #  # ]:          0 :             DrawGrip();
     791                 :            :         }
     792 [ #  # ][ #  # ]:          0 :         if( mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     793                 :            :         {
     794                 :          0 :             mbHighlight = sal_False;
     795         [ #  # ]:          0 :             DrawGrip();
     796                 :            :         }
     797                 :            :     }
     798                 :            : }
     799                 :            : 
     800                 :          0 : void ImplPopupFloatWin::MouseButtonUp( const MouseEvent& rMEvt )
     801                 :            : {
     802                 :          0 :     mbTrackingEnabled = false;
     803                 :          0 :     FloatingWindow::MouseButtonUp( rMEvt );
     804                 :          0 : }
     805                 :            : 
     806                 :          0 : void ImplPopupFloatWin::MouseButtonDown( const MouseEvent& rMEvt )
     807                 :            : {
     808                 :          0 :     Point aMousePos = rMEvt.GetPosPixel();
     809 [ #  # ][ #  # ]:          0 :     if( GetDragRect().IsInside( aMousePos ) )
                 [ #  # ]
     810                 :            :     {
     811                 :            :         // get mouse pos at a static window to have a fixed reference point
     812 [ #  # ][ #  # ]:          0 :         PointerState aState = GetParent()->GetPointerState();
     813 [ #  # ][ #  # ]:          0 :         if (ImplHasMirroredGraphics() && IsRTLEnabled())
         [ #  # ][ #  # ]
     814         [ #  # ]:          0 :             ImplMirrorFramePos(aState.maPos);
     815 [ #  # ][ #  # ]:          0 :         maTearOffPosition = GetWindow( WINDOW_BORDER )->GetPosPixel();
     816                 :          0 :         maDelta = aState.maPos - maTearOffPosition;
     817                 :          0 :         mbTrackingEnabled = true;
     818                 :            :     }
     819                 :            :     else
     820                 :            :     {
     821                 :          0 :         mbTrackingEnabled = false;
     822                 :            :     }
     823                 :          0 : }
     824                 :            : 
     825                 :          0 : void ImplPopupFloatWin::Tracking( const TrackingEvent& rTEvt )
     826                 :            : {
     827         [ #  # ]:          0 :     if( mbMoving )
     828                 :            :     {
     829         [ #  # ]:          0 :         if ( rTEvt.IsTrackingEnded() )
     830                 :            :         {
     831                 :          0 :             mbMoving = sal_False;
     832                 :          0 :             EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
     833                 :            :         }
     834         [ #  # ]:          0 :         else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
     835                 :            :         {
     836                 :            :             // move the window according to mouse pos
     837 [ #  # ][ #  # ]:          0 :             PointerState aState = GetParent()->GetPointerState();
     838 [ #  # ][ #  # ]:          0 :             if (ImplHasMirroredGraphics() && IsRTLEnabled())
         [ #  # ][ #  # ]
     839         [ #  # ]:          0 :                 ImplMirrorFramePos(aState.maPos);
     840                 :          0 :             maTearOffPosition = aState.maPos - maDelta;
     841 [ #  # ][ #  # ]:          0 :             GetWindow( WINDOW_BORDER )->SetPosPixel( maTearOffPosition );
     842                 :            :         }
     843                 :            :     }
     844                 :          0 : }
     845                 :            : 
     846                 :            : 
     847                 :            : // =======================================================================
     848                 :            : 
     849                 :       5827 : ImplDockingWindowWrapper::ImplDockingWindowWrapper( const Window *pWindow )
     850                 :            : {
     851                 :       5827 :     ImplInitData();
     852                 :            : 
     853                 :       5827 :     mpDockingWindow = (Window*) pWindow;
     854                 :       5827 :     mpParent        = pWindow->GetParent();
     855                 :       5827 :     mbDockable      = sal_True;
     856                 :       5827 :     mbLocked        = sal_False;
     857                 :       5827 :     mnFloatBits     = WB_BORDER | WB_CLOSEABLE | WB_SIZEABLE | (pWindow->GetStyle() & DOCKWIN_FLOATSTYLES);
     858         [ -  + ]:       5827 :     DockingWindow *pDockWin = dynamic_cast< DockingWindow* > ( mpDockingWindow );
     859         [ +  - ]:       5827 :     if( pDockWin )
     860                 :       5827 :         mnFloatBits = pDockWin->GetFloatStyle();
     861                 :            : 
     862                 :            :     // must be enabled in Window::Notify to prevent permanent docking during mouse move
     863                 :       5827 :     mbStartDockingEnabled = sal_False;
     864                 :       5827 : }
     865                 :            : 
     866                 :      11290 : ImplDockingWindowWrapper::~ImplDockingWindowWrapper()
     867                 :            : {
     868         [ -  + ]:       5645 :     if ( IsFloatingMode() )
     869                 :            :     {
     870                 :          0 :         GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
     871                 :          0 :         SetFloatingMode( sal_False );
     872                 :            :     }
     873         [ -  + ]:      11290 : }
     874                 :            : 
     875                 :            : // -----------------------------------------------------------------------
     876                 :            : 
     877                 :          0 : sal_Bool ImplDockingWindowWrapper::ImplStartDocking( const Point& rPos )
     878                 :            : {
     879         [ #  # ]:          0 :     if ( !mbDockable )
     880                 :          0 :         return sal_False;
     881                 :            : 
     882         [ #  # ]:          0 :     if( !mbStartDockingEnabled )
     883                 :          0 :         return sal_False;
     884                 :            : 
     885                 :          0 :     maMouseOff      = rPos;
     886                 :          0 :     maMouseStart    = maMouseOff;
     887                 :          0 :     mbDocking       = sal_True;
     888                 :          0 :     mbLastFloatMode = IsFloatingMode();
     889                 :          0 :     mbStartFloat    = mbLastFloatMode;
     890                 :            : 
     891                 :            :     // FloatingBorder berechnen
     892                 :            :     FloatingWindow* pWin;
     893         [ #  # ]:          0 :     if ( mpFloatWin )
     894                 :          0 :         pWin = mpFloatWin;
     895                 :            :     else
     896 [ #  # ][ #  # ]:          0 :         pWin = new ImplDockFloatWin2( mpParent, mnFloatBits, NULL );
     897         [ #  # ]:          0 :     pWin->GetBorder( mnDockLeft, mnDockTop, mnDockRight, mnDockBottom );
     898         [ #  # ]:          0 :     if ( !mpFloatWin )
     899 [ #  # ][ #  # ]:          0 :         delete pWin;
     900                 :            : 
     901         [ #  # ]:          0 :     Point   aPos    = GetWindow()->ImplOutputToFrame( Point() );
     902                 :          0 :     Size    aSize   = GetWindow()->GetOutputSizePixel();
     903                 :          0 :     mnTrackX        = aPos.X();
     904                 :          0 :     mnTrackY        = aPos.Y();
     905                 :          0 :     mnTrackWidth    = aSize.Width();
     906                 :          0 :     mnTrackHeight   = aSize.Height();
     907                 :            : 
     908         [ #  # ]:          0 :     if ( mbLastFloatMode )
     909                 :            :     {
     910                 :          0 :         maMouseOff.X()  += mnDockLeft;
     911                 :          0 :         maMouseOff.Y()  += mnDockTop;
     912                 :          0 :         mnTrackX        -= mnDockLeft;
     913                 :          0 :         mnTrackY        -= mnDockTop;
     914                 :          0 :         mnTrackWidth    += mnDockLeft+mnDockRight;
     915                 :          0 :         mnTrackHeight   += mnDockTop+mnDockBottom;
     916                 :            :     }
     917                 :            : 
     918         [ #  # ]:          0 :     Window *pDockingArea = GetWindow()->GetParent();
     919         [ #  # ]:          0 :     Window::PointerState aState = pDockingArea->GetPointerState();
     920                 :            : 
     921                 :            :     // mouse pos in screen pixels
     922         [ #  # ]:          0 :     Point aMousePos = pDockingArea->OutputToScreenPixel( aState.maPos );
     923 [ #  # ][ #  # ]:          0 :     Point aDockPos = Point( pDockingArea->AbsoluteScreenToOutputPixel( GetWindow()->OutputToAbsoluteScreenPixel( GetWindow()->GetPosPixel() ) ) );
                 [ #  # ]
     924 [ #  # ][ #  # ]:          0 :     Rectangle aDockRect( aDockPos, GetWindow()->GetSizePixel() );
     925         [ #  # ]:          0 :     StartDocking( aMousePos, aDockRect );
     926                 :            : 
     927         [ #  # ]:          0 :     GetWindow()->ImplUpdateAll();
     928 [ #  # ][ #  # ]:          0 :     GetWindow()->ImplGetFrameWindow()->ImplUpdateAll();
     929                 :            : 
     930         [ #  # ]:          0 :     GetWindow()->StartTracking( STARTTRACK_KEYMOD );
     931                 :          0 :     return sal_True;
     932                 :            : }
     933                 :            : 
     934                 :            : // =======================================================================
     935                 :            : 
     936                 :       5827 : void ImplDockingWindowWrapper::ImplInitData()
     937                 :            : {
     938                 :       5827 :     mpDockingWindow     = NULL;
     939                 :            : 
     940                 :            :     //GetWindow()->mpWindowImpl->mbDockWin  = sal_True;     // TODO: must be eliminated
     941                 :       5827 :     mpFloatWin          = NULL;
     942                 :       5827 :     mbDockCanceled      = sal_False;
     943                 :       5827 :     mbFloatPrevented    = sal_False;
     944                 :       5827 :     mbDocking           = sal_False;
     945                 :       5827 :     mbPined             = sal_False;
     946                 :       5827 :     mbRollUp            = sal_False;
     947                 :       5827 :     mbDockBtn           = sal_False;
     948                 :       5827 :     mbHideBtn           = sal_False;
     949                 :       5827 :     maMaxOutSize        = Size( SHRT_MAX, SHRT_MAX );
     950                 :       5827 : }
     951                 :            : 
     952                 :            : // -----------------------------------------------------------------------
     953                 :            : 
     954                 :          0 : void ImplDockingWindowWrapper::Tracking( const TrackingEvent& rTEvt )
     955                 :            : {
     956                 :            :     // used during docking of a currently docked window
     957         [ #  # ]:          0 :     if ( mbDocking )
     958                 :            :     {
     959         [ #  # ]:          0 :         if ( rTEvt.IsTrackingEnded() )
     960                 :            :         {
     961                 :          0 :             mbDocking = sal_False;
     962                 :          0 :             GetWindow()->HideTracking();
     963         [ #  # ]:          0 :             if ( rTEvt.IsTrackingCanceled() )
     964                 :            :             {
     965                 :          0 :                 mbDockCanceled = sal_True;
     966 [ #  # ][ #  # ]:          0 :                 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
     967                 :          0 :                 mbDockCanceled = sal_False;
     968                 :            :             }
     969                 :            :             else
     970 [ #  # ][ #  # ]:          0 :                 EndDocking( Rectangle( Point( mnTrackX, mnTrackY ), Size( mnTrackWidth, mnTrackHeight ) ), mbLastFloatMode );
     971                 :            :         }
     972                 :            :         // Docking only upon non-synthetic MouseEvents
     973 [ #  # ][ #  # ]:          0 :         else if ( !rTEvt.GetMouseEvent().IsSynthetic() || rTEvt.GetMouseEvent().IsModifierChanged() )
                 [ #  # ]
     974                 :            :         {
     975                 :          0 :             Point   aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
     976         [ #  # ]:          0 :             Point   aFrameMousePos = GetWindow()->ImplOutputToFrame( aMousePos );
     977         [ #  # ]:          0 :             Size    aFrameSize = GetWindow()->ImplGetFrameWindow()->GetOutputSizePixel();
     978         [ #  # ]:          0 :             if ( aFrameMousePos.X() < 0 )
     979                 :          0 :                 aFrameMousePos.X() = 0;
     980         [ #  # ]:          0 :             if ( aFrameMousePos.Y() < 0 )
     981                 :          0 :                 aFrameMousePos.Y() = 0;
     982         [ #  # ]:          0 :             if ( aFrameMousePos.X() > aFrameSize.Width()-1 )
     983                 :          0 :                 aFrameMousePos.X() = aFrameSize.Width()-1;
     984         [ #  # ]:          0 :             if ( aFrameMousePos.Y() > aFrameSize.Height()-1 )
     985                 :          0 :                 aFrameMousePos.Y() = aFrameSize.Height()-1;
     986         [ #  # ]:          0 :             aMousePos = GetWindow()->ImplFrameToOutput( aFrameMousePos );
     987                 :          0 :             aMousePos.X() -= maMouseOff.X();
     988                 :          0 :             aMousePos.Y() -= maMouseOff.Y();
     989         [ #  # ]:          0 :             Point aPos = GetWindow()->ImplOutputToFrame( aMousePos );
     990         [ #  # ]:          0 :             Rectangle aTrackRect( aPos, Size( mnTrackWidth, mnTrackHeight ) );
     991                 :          0 :             Rectangle aCompRect = aTrackRect;
     992                 :          0 :             aPos.X()    += maMouseOff.X();
     993                 :          0 :             aPos.Y()    += maMouseOff.Y();
     994                 :            : 
     995         [ #  # ]:          0 :             sal_Bool bFloatMode = Docking( aPos, aTrackRect );
     996                 :            : 
     997                 :          0 :             mbFloatPrevented = sal_False;
     998         [ #  # ]:          0 :             if ( mbLastFloatMode != bFloatMode )
     999                 :            :             {
    1000         [ #  # ]:          0 :                 if ( bFloatMode )
    1001                 :            :                 {
    1002                 :          0 :                     aTrackRect.Left()   -= mnDockLeft;
    1003                 :          0 :                     aTrackRect.Top()    -= mnDockTop;
    1004                 :          0 :                     aTrackRect.Right()  += mnDockRight;
    1005                 :          0 :                     aTrackRect.Bottom() += mnDockBottom;
    1006                 :            :                 }
    1007                 :            :                 else
    1008                 :            :                 {
    1009 [ #  # ][ #  # ]:          0 :                     if ( aCompRect == aTrackRect )
    1010                 :            :                     {
    1011                 :          0 :                         aTrackRect.Left()   += mnDockLeft;
    1012                 :          0 :                         aTrackRect.Top()    += mnDockTop;
    1013                 :          0 :                         aTrackRect.Right()  -= mnDockRight;
    1014                 :          0 :                         aTrackRect.Bottom() -= mnDockBottom;
    1015                 :            :                     }
    1016                 :            :                 }
    1017                 :          0 :                 mbLastFloatMode = bFloatMode;
    1018                 :            :             }
    1019                 :            : 
    1020                 :            :             sal_uInt16 nTrackStyle;
    1021         [ #  # ]:          0 :             if ( bFloatMode )
    1022                 :          0 :                 nTrackStyle = SHOWTRACK_OBJECT;
    1023                 :            :             else
    1024                 :          0 :                 nTrackStyle = SHOWTRACK_BIG;
    1025                 :          0 :             Rectangle aShowTrackRect = aTrackRect;
    1026         [ #  # ]:          0 :             aShowTrackRect.SetPos( GetWindow()->ImplFrameToOutput( aShowTrackRect.TopLeft() ) );
    1027                 :            : 
    1028         [ #  # ]:          0 :             GetWindow()->ShowTracking( aShowTrackRect, nTrackStyle );
    1029                 :            : 
    1030                 :            :             // Maus-Offset neu berechnen, da Rechteck veraendert werden
    1031                 :            :             // konnte
    1032                 :          0 :             maMouseOff.X()  = aPos.X() - aTrackRect.Left();
    1033                 :          0 :             maMouseOff.Y()  = aPos.Y() - aTrackRect.Top();
    1034                 :            : 
    1035                 :          0 :             mnTrackX        = aTrackRect.Left();
    1036                 :          0 :             mnTrackY        = aTrackRect.Top();
    1037         [ #  # ]:          0 :             mnTrackWidth    = aTrackRect.GetWidth();
    1038         [ #  # ]:          0 :             mnTrackHeight   = aTrackRect.GetHeight();
    1039                 :            :         }
    1040                 :            :     }
    1041                 :          0 : }
    1042                 :            : 
    1043                 :            : 
    1044                 :            : // -----------------------------------------------------------------------
    1045                 :            : 
    1046                 :          0 : void ImplDockingWindowWrapper::StartDocking( const Point& rPoint, Rectangle& rRect )
    1047                 :            : {
    1048                 :          0 :     DockingData data( rPoint, rRect, IsFloatingMode() );
    1049                 :            : 
    1050         [ #  # ]:          0 :     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_STARTDOCKING, &data );
    1051                 :          0 :     mbDocking = sal_True;
    1052                 :          0 : }
    1053                 :            : 
    1054                 :            : // -----------------------------------------------------------------------
    1055                 :            : 
    1056                 :          0 : sal_Bool ImplDockingWindowWrapper::Docking( const Point& rPoint, Rectangle& rRect )
    1057                 :            : {
    1058                 :          0 :     DockingData data( rPoint, rRect, IsFloatingMode() );
    1059                 :            : 
    1060         [ #  # ]:          0 :     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_DOCKING, &data );
    1061                 :          0 :     rRect = data.maTrackRect;
    1062                 :          0 :     return data.mbFloating;
    1063                 :            : }
    1064                 :            : 
    1065                 :            : // -----------------------------------------------------------------------
    1066                 :            : 
    1067                 :          0 : void ImplDockingWindowWrapper::EndDocking( const Rectangle& rRect, sal_Bool bFloatMode )
    1068                 :            : {
    1069                 :          0 :     Rectangle aRect( rRect );
    1070                 :            : 
    1071         [ #  # ]:          0 :     if ( !IsDockingCanceled() )
    1072                 :            :     {
    1073                 :          0 :         sal_Bool bShow = sal_False;
    1074         [ #  # ]:          0 :         if ( bFloatMode != IsFloatingMode() )
    1075                 :            :         {
    1076         [ #  # ]:          0 :             GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
    1077         [ #  # ]:          0 :             SetFloatingMode( bFloatMode );
    1078                 :          0 :             bShow = sal_True;
    1079         [ #  # ]:          0 :             if ( bFloatMode )
    1080                 :            :             {
    1081                 :            :                 // #i44800# always use outputsize - as in all other places
    1082 [ #  # ][ #  # ]:          0 :                 mpFloatWin->SetOutputSizePixel( aRect.GetSize() );
    1083         [ #  # ]:          0 :                 mpFloatWin->SetPosPixel( aRect.TopLeft() );
    1084                 :            :             }
    1085                 :            :         }
    1086         [ #  # ]:          0 :         if ( !bFloatMode )
    1087                 :            :         {
    1088                 :          0 :             Point aPos = aRect.TopLeft();
    1089 [ #  # ][ #  # ]:          0 :             aPos = GetWindow()->GetParent()->ScreenToOutputPixel( aPos );
    1090 [ #  # ][ #  # ]:          0 :             GetWindow()->SetPosSizePixel( aPos, aRect.GetSize() );
    1091                 :            :         }
    1092                 :            : 
    1093         [ #  # ]:          0 :         if ( bShow )
    1094         [ #  # ]:          0 :             GetWindow()->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
    1095                 :            :     }
    1096                 :            : 
    1097                 :          0 :     EndDockingData data( aRect, IsFloatingMode(), IsDockingCanceled() );
    1098         [ #  # ]:          0 :     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_ENDDOCKING, &data );
    1099                 :            : 
    1100                 :          0 :     mbDocking = sal_False;
    1101                 :            : 
    1102                 :            :     // must be enabled in Window::Notify to prevent permanent docking during mouse move
    1103                 :          0 :     mbStartDockingEnabled = sal_False;
    1104                 :          0 : }
    1105                 :            : 
    1106                 :            : // -----------------------------------------------------------------------
    1107                 :            : 
    1108                 :          0 : sal_Bool ImplDockingWindowWrapper::PrepareToggleFloatingMode()
    1109                 :            : {
    1110                 :          0 :     sal_Bool bFloating = sal_True;
    1111         [ #  # ]:          0 :     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_PREPARETOGGLEFLOATING, &bFloating );
    1112                 :          0 :     return bFloating;
    1113                 :            : }
    1114                 :            : 
    1115                 :            : // -----------------------------------------------------------------------
    1116                 :            : 
    1117                 :          0 : sal_Bool ImplDockingWindowWrapper::Close()
    1118                 :            : {
    1119                 :            :     // TODO: send event
    1120                 :          0 :     return sal_True;
    1121                 :            : }
    1122                 :            : 
    1123                 :            : // -----------------------------------------------------------------------
    1124                 :            : 
    1125                 :          0 : void ImplDockingWindowWrapper::ToggleFloatingMode()
    1126                 :            : {
    1127                 :            :     // notify dockingwindow/toolbox
    1128                 :            :     // note: this must be done *before* notifying the
    1129                 :            :     //       listeners to have the toolbox in the proper state
    1130         [ #  # ]:          0 :     if( GetWindow()->ImplIsDockingWindow() )
    1131                 :          0 :         ((DockingWindow*) GetWindow())->ToggleFloatingMode();
    1132                 :            : 
    1133                 :            :     // now notify listeners
    1134                 :          0 :     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_TOGGLEFLOATING );
    1135                 :            : 
    1136                 :            :     // must be enabled in Window::Notify to prevent permanent docking during mouse move
    1137                 :          0 :     mbStartDockingEnabled = sal_False;
    1138                 :          0 : }
    1139                 :            : 
    1140                 :            : // -----------------------------------------------------------------------
    1141                 :            : 
    1142                 :          0 : void ImplDockingWindowWrapper::TitleButtonClick( sal_uInt16 nType )
    1143                 :            : {
    1144         [ #  # ]:          0 :     if( nType == TITLE_BUTTON_MENU )
    1145                 :            :     {
    1146         [ #  # ]:          0 :         ToolBox *pToolBox = dynamic_cast< ToolBox* >( GetWindow() );
    1147         [ #  # ]:          0 :         if( pToolBox )
    1148                 :            :         {
    1149                 :          0 :             pToolBox->ExecuteCustomMenu();
    1150                 :            :         }
    1151                 :            :     }
    1152         [ #  # ]:          0 :     if( nType == TITLE_BUTTON_DOCKING )
    1153                 :            :     {
    1154                 :          0 :         SetFloatingMode( !IsFloatingMode() );
    1155                 :            :     }
    1156                 :          0 : }
    1157                 :            : 
    1158                 :            : // -----------------------------------------------------------------------
    1159                 :            : 
    1160                 :          0 : void ImplDockingWindowWrapper::Pin()
    1161                 :            : {
    1162                 :            :     // TODO: send event
    1163                 :          0 : }
    1164                 :            : 
    1165                 :            : // -----------------------------------------------------------------------
    1166                 :            : 
    1167                 :          0 : void ImplDockingWindowWrapper::Roll()
    1168                 :            : {
    1169                 :            :     // TODO: send event
    1170                 :          0 : }
    1171                 :            : 
    1172                 :            : // -----------------------------------------------------------------------
    1173                 :            : 
    1174                 :          0 : void ImplDockingWindowWrapper::PopupModeEnd()
    1175                 :            : {
    1176                 :            :     // TODO: send event
    1177                 :          0 : }
    1178                 :            : 
    1179                 :            : // -----------------------------------------------------------------------
    1180                 :            : 
    1181                 :          0 : void ImplDockingWindowWrapper::Resizing( Size& rSize )
    1182                 :            : {
    1183                 :            :     // TODO: add virtual Resizing() to class Window, so we can get rid of class DockingWindow
    1184         [ #  # ]:          0 :     DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >( GetWindow() );
    1185         [ #  # ]:          0 :     if( pDockingWindow )
    1186                 :          0 :         pDockingWindow->Resizing( rSize );
    1187                 :          0 : }
    1188                 :            : 
    1189                 :            : // -----------------------------------------------------------------------
    1190                 :            : 
    1191                 :          0 : void ImplDockingWindowWrapper::ShowTitleButton( sal_uInt16 nButton, sal_Bool bVisible )
    1192                 :            : {
    1193         [ #  # ]:          0 :     if ( mpFloatWin )
    1194                 :          0 :         mpFloatWin->ShowTitleButton( nButton, bVisible );
    1195                 :            :     else
    1196                 :            :     {
    1197         [ #  # ]:          0 :         if ( nButton == TITLE_BUTTON_DOCKING )
    1198                 :          0 :             mbDockBtn = bVisible;
    1199                 :            :         else // if ( nButton == TITLE_BUTTON_HIDE )
    1200                 :          0 :             mbHideBtn = bVisible;
    1201                 :            :     }
    1202                 :          0 : }
    1203                 :            : 
    1204                 :            : // -----------------------------------------------------------------------
    1205                 :            : 
    1206                 :          0 : void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, sal_uLong nFlags )
    1207                 :            : {
    1208                 :            :     // do nothing if window is floating
    1209         [ #  # ]:          0 :     if( IsFloatingMode() )
    1210                 :          0 :         return;
    1211                 :            : 
    1212                 :          0 :     GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
    1213                 :            : 
    1214                 :            :     // prepare reparenting
    1215                 :          0 :     Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
    1216                 :          0 :     mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
    1217         [ #  # ]:          0 :     if( mpOldBorderWin == GetWindow() )
    1218                 :          0 :         mpOldBorderWin = NULL;  // no border window found
    1219                 :            : 
    1220                 :            :     // the new parent for popup mode
    1221         [ #  # ]:          0 :     ImplPopupFloatWin* pWin = new ImplPopupFloatWin( mpParent, this, (nFlags & FLOATWIN_POPUPMODE_ALLOWTEAROFF) != 0 );
    1222                 :            : 
    1223                 :          0 :     pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
    1224         [ #  # ]:          0 :     pWin->SetText( GetWindow()->GetText() );
    1225                 :            : 
    1226         [ #  # ]:          0 :     pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
    1227                 :            : 
    1228                 :          0 :     GetWindow()->mpWindowImpl->mpBorderWindow  = NULL;
    1229                 :          0 :     GetWindow()->mpWindowImpl->mnLeftBorder    = 0;
    1230                 :          0 :     GetWindow()->mpWindowImpl->mnTopBorder     = 0;
    1231                 :          0 :     GetWindow()->mpWindowImpl->mnRightBorder   = 0;
    1232                 :          0 :     GetWindow()->mpWindowImpl->mnBottomBorder  = 0;
    1233                 :            : 
    1234                 :            :     // position toolbox below dragrect
    1235         [ #  # ]:          0 :     GetWindow()->SetPosPixel( pWin->GetToolboxPosition() );
    1236                 :            : 
    1237                 :            :     // reparent borderwindow and window
    1238         [ #  # ]:          0 :     if ( mpOldBorderWin )
    1239                 :          0 :         mpOldBorderWin->SetParent( pWin );
    1240                 :          0 :     GetWindow()->SetParent( pWin );
    1241                 :            : 
    1242                 :            :     // correct border window pointers
    1243                 :          0 :     GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
    1244                 :          0 :     pWin->mpWindowImpl->mpClientWindow = GetWindow();
    1245                 :          0 :     GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
    1246                 :            : 
    1247                 :            :     // set mpFloatWin not until all window positioning is done !!!
    1248                 :            :     // (SetPosPixel etc. check for valid mpFloatWin pointer)
    1249                 :          0 :     mpFloatWin = pWin;
    1250                 :            : 
    1251                 :            :     // if the subtoolbar was opened via keyboard make sure that key events
    1252                 :            :     // will go into subtoolbar
    1253         [ #  # ]:          0 :     if( pParentToolBox->IsKeyEvent() )
    1254                 :          0 :         nFlags |= FLOATWIN_POPUPMODE_GRABFOCUS;
    1255                 :            : 
    1256                 :          0 :     mpFloatWin->StartPopupMode( pParentToolBox, nFlags );
    1257                 :          0 :     GetWindow()->Show();
    1258                 :            : 
    1259         [ #  # ]:          0 :     if( pParentToolBox->IsKeyEvent() )
    1260                 :            :     {
    1261                 :            :         // send HOME key to subtoolbar in order to select first item
    1262         [ #  # ]:          0 :         KeyEvent aEvent( 0, KeyCode( KEY_HOME ) );
    1263 [ #  # ][ #  # ]:          0 :         mpFloatWin->GetPreferredKeyInputWindow()->KeyInput( aEvent );
    1264                 :            :     }
    1265                 :            : }
    1266                 :            : 
    1267                 :          0 : IMPL_LINK_NOARG(ImplDockingWindowWrapper, PopupModeEnd)
    1268                 :            : {
    1269         [ #  # ]:          0 :     GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
    1270                 :            : 
    1271                 :            :     // set parameter for handler before destroying floating window
    1272                 :          0 :     ImplPopupFloatWin *pPopupFloatWin = (ImplPopupFloatWin*) mpFloatWin;
    1273                 :          0 :     EndPopupModeData aData( pPopupFloatWin->GetTearOffPosition(), mpFloatWin->IsPopupModeTearOff() );
    1274                 :            : 
    1275                 :            :     // before deleting change parent back, so we can delete the floating window alone
    1276         [ #  # ]:          0 :     Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
    1277                 :          0 :     GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
    1278         [ #  # ]:          0 :     if ( mpOldBorderWin )
    1279                 :            :     {
    1280         [ #  # ]:          0 :         GetWindow()->SetParent( mpOldBorderWin );
    1281                 :            :         ((ImplBorderWindow*)mpOldBorderWin)->GetBorder(
    1282                 :          0 :             GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
    1283         [ #  # ]:          0 :             GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
    1284         [ #  # ]:          0 :         mpOldBorderWin->Resize();
    1285                 :            :     }
    1286                 :          0 :     GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
    1287         [ #  # ]:          0 :     GetWindow()->SetParent( pRealParent );
    1288                 :          0 :     GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
    1289                 :            : 
    1290 [ #  # ][ #  # ]:          0 :     delete mpFloatWin;
    1291                 :          0 :     mpFloatWin = NULL;
    1292                 :            : 
    1293                 :            :     // call handler - which will destroy the window and thus the wrapper as well !
    1294         [ #  # ]:          0 :     GetWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_ENDPOPUPMODE, &aData );
    1295                 :            : 
    1296                 :          0 :     return 0;
    1297                 :            : }
    1298                 :            : 
    1299                 :            : 
    1300                 :          0 : sal_Bool ImplDockingWindowWrapper::IsInPopupMode() const
    1301                 :            : {
    1302         [ #  # ]:          0 :     if( GetFloatingWindow() )
    1303                 :          0 :         return GetFloatingWindow()->IsInPopupMode();
    1304                 :            :     else
    1305                 :          0 :         return sal_False;
    1306                 :            : }
    1307                 :            : 
    1308                 :            : // -----------------------------------------------------------------------
    1309                 :            : 
    1310                 :       3709 : void ImplDockingWindowWrapper::SetFloatingMode( sal_Bool bFloatMode )
    1311                 :            : {
    1312                 :            :     // do nothing if window is docked and locked
    1313 [ +  - ][ -  + ]:       3709 :     if( !IsFloatingMode() && IsLocked() )
                 [ -  + ]
    1314                 :       3709 :         return;
    1315                 :            : 
    1316         [ -  + ]:       3709 :     if ( IsFloatingMode() != bFloatMode )
    1317                 :            :     {
    1318         [ #  # ]:          0 :         if ( PrepareToggleFloatingMode() )
    1319                 :            :         {
    1320                 :          0 :             sal_Bool bVisible = GetWindow()->IsVisible();
    1321                 :            : 
    1322         [ #  # ]:          0 :             if ( bFloatMode )
    1323                 :            :             {
    1324                 :          0 :                 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
    1325                 :            : 
    1326                 :          0 :                 maDockPos = GetWindow()->GetPosPixel();
    1327                 :            : 
    1328                 :          0 :                 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT );
    1329                 :          0 :                 mpOldBorderWin = GetWindow()->GetWindow( WINDOW_BORDER );
    1330         [ #  # ]:          0 :                 if( mpOldBorderWin == mpDockingWindow )
    1331                 :          0 :                     mpOldBorderWin = NULL;  // no border window found
    1332                 :            : 
    1333                 :            :                 ImplDockFloatWin2* pWin =
    1334                 :            :                     new ImplDockFloatWin2(
    1335                 :            :                                          mpParent,
    1336                 :            :                                          mnFloatBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) ?
    1337                 :            :                                           mnFloatBits | WB_SYSTEMWINDOW
    1338                 :            :                                           | WB_OWNERDRAWDECORATION
    1339                 :            :                                           : mnFloatBits,
    1340 [ #  # ][ #  # ]:          0 :                                          this );
    1341                 :            : 
    1342                 :          0 :                 GetWindow()->mpWindowImpl->mpBorderWindow  = NULL;
    1343                 :          0 :                 GetWindow()->mpWindowImpl->mnLeftBorder    = 0;
    1344                 :          0 :                 GetWindow()->mpWindowImpl->mnTopBorder     = 0;
    1345                 :          0 :                 GetWindow()->mpWindowImpl->mnRightBorder   = 0;
    1346                 :          0 :                 GetWindow()->mpWindowImpl->mnBottomBorder  = 0;
    1347                 :            : 
    1348                 :            :                 // Falls Parent zerstoert wird, muessen wir auch vom
    1349                 :            :                 // BorderWindow den Parent umsetzen
    1350         [ #  # ]:          0 :                 if ( mpOldBorderWin )
    1351                 :          0 :                     mpOldBorderWin->SetParent( pWin );
    1352                 :          0 :                 GetWindow()->SetParent( pWin );
    1353         [ #  # ]:          0 :                 pWin->SetPosPixel( Point() );
    1354                 :            : 
    1355                 :          0 :                 GetWindow()->mpWindowImpl->mpBorderWindow = pWin;
    1356                 :          0 :                 pWin->mpWindowImpl->mpClientWindow = mpDockingWindow;
    1357                 :          0 :                 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
    1358                 :            : 
    1359         [ #  # ]:          0 :                 pWin->SetText( GetWindow()->GetText() );
    1360         [ #  # ]:          0 :                 pWin->SetOutputSizePixel( GetWindow()->GetSizePixel() );
    1361                 :          0 :                 pWin->SetPosPixel( maFloatPos );
    1362                 :            :                 // DockingDaten ans FloatingWindow weiterreichen
    1363                 :          0 :                 pWin->ShowTitleButton( TITLE_BUTTON_DOCKING, mbDockBtn );
    1364                 :          0 :                 pWin->ShowTitleButton( TITLE_BUTTON_HIDE, mbHideBtn );
    1365                 :          0 :                 pWin->SetPin( mbPined );
    1366         [ #  # ]:          0 :                 if ( mbRollUp )
    1367                 :          0 :                     pWin->RollUp();
    1368                 :            :                 else
    1369                 :          0 :                     pWin->RollDown();
    1370                 :          0 :                 pWin->SetRollUpOutputSizePixel( maRollUpOutSize );
    1371                 :          0 :                 pWin->SetMinOutputSizePixel( maMinOutSize );
    1372                 :          0 :                 pWin->SetMaxOutputSizePixel( maMaxOutSize );
    1373                 :            : 
    1374                 :          0 :                 mpFloatWin      = pWin;
    1375                 :            : 
    1376         [ #  # ]:          0 :                 if ( bVisible )
    1377                 :          0 :                     GetWindow()->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
    1378                 :            : 
    1379                 :          0 :                 ToggleFloatingMode();
    1380                 :            :             }
    1381                 :            :             else
    1382                 :            :             {
    1383                 :          0 :                 GetWindow()->Show( sal_False, SHOW_NOFOCUSCHANGE );
    1384                 :            : 
    1385                 :            :                 // FloatingDaten wird im FloatingWindow speichern
    1386                 :          0 :                 maFloatPos      = mpFloatWin->GetPosPixel();
    1387                 :          0 :                 mbDockBtn       = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_DOCKING );
    1388                 :          0 :                 mbHideBtn       = mpFloatWin->IsTitleButtonVisible( TITLE_BUTTON_HIDE );
    1389                 :          0 :                 mbPined         = mpFloatWin->IsPined();
    1390                 :          0 :                 mbRollUp        = mpFloatWin->IsRollUp();
    1391                 :          0 :                 maRollUpOutSize = mpFloatWin->GetRollUpOutputSizePixel();
    1392                 :          0 :                 maMinOutSize    = mpFloatWin->GetMinOutputSizePixel();
    1393                 :          0 :                 maMaxOutSize    = mpFloatWin->GetMaxOutputSizePixel();
    1394                 :            : 
    1395                 :          0 :                 Window* pRealParent = GetWindow()->GetWindow( WINDOW_PARENT ); //mpWindowImpl->mpRealParent;
    1396                 :          0 :                 GetWindow()->mpWindowImpl->mpBorderWindow = NULL;
    1397         [ #  # ]:          0 :                 if ( mpOldBorderWin )
    1398                 :            :                 {
    1399                 :          0 :                     GetWindow()->SetParent( mpOldBorderWin );
    1400                 :            :                     ((ImplBorderWindow*)mpOldBorderWin)->GetBorder(
    1401                 :          0 :                         GetWindow()->mpWindowImpl->mnLeftBorder, GetWindow()->mpWindowImpl->mnTopBorder,
    1402                 :          0 :                         GetWindow()->mpWindowImpl->mnRightBorder, GetWindow()->mpWindowImpl->mnBottomBorder );
    1403                 :          0 :                     mpOldBorderWin->Resize();
    1404                 :            :                 }
    1405                 :          0 :                 GetWindow()->mpWindowImpl->mpBorderWindow = mpOldBorderWin;
    1406                 :          0 :                 GetWindow()->SetParent( pRealParent );
    1407                 :          0 :                 GetWindow()->mpWindowImpl->mpRealParent = pRealParent;
    1408                 :            : 
    1409         [ #  # ]:          0 :                 delete static_cast<ImplDockFloatWin2*>(mpFloatWin);
    1410                 :          0 :                 mpFloatWin = NULL;
    1411                 :          0 :                 GetWindow()->SetPosPixel( maDockPos );
    1412                 :            : 
    1413         [ #  # ]:          0 :                 if ( bVisible )
    1414                 :          0 :                     GetWindow()->Show();
    1415                 :            : 
    1416                 :          0 :                 ToggleFloatingMode();
    1417                 :            : 
    1418                 :            :             }
    1419                 :            :         }
    1420                 :            :     }
    1421                 :            : }
    1422                 :            : 
    1423                 :            : // -----------------------------------------------------------------------
    1424                 :            : 
    1425                 :         18 : void ImplDockingWindowWrapper::SetFloatStyle( WinBits nStyle )
    1426                 :            : {
    1427                 :         18 :     mnFloatBits = nStyle;
    1428                 :         18 : }
    1429                 :            : 
    1430                 :            : // -----------------------------------------------------------------------
    1431                 :            : 
    1432                 :         18 : WinBits ImplDockingWindowWrapper::GetFloatStyle() const
    1433                 :            : {
    1434                 :         18 :     return mnFloatBits;
    1435                 :            : }
    1436                 :            : 
    1437                 :            : // -----------------------------------------------------------------------
    1438                 :            : 
    1439                 :       3709 : void ImplDockingWindowWrapper::SetPosSizePixel( long nX, long nY,
    1440                 :            :                                      long nWidth, long nHeight,
    1441                 :            :                                      sal_uInt16 nFlags )
    1442                 :            : {
    1443         [ -  + ]:       3709 :     if ( mpFloatWin )
    1444                 :          0 :         mpFloatWin->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
    1445                 :            :     else
    1446                 :       3709 :         GetWindow()->SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
    1447                 :       3709 : }
    1448                 :            : 
    1449                 :            : // -----------------------------------------------------------------------
    1450                 :            : 
    1451                 :      15547 : Point ImplDockingWindowWrapper::GetPosPixel() const
    1452                 :            : {
    1453         [ -  + ]:      15547 :     if ( mpFloatWin )
    1454                 :          0 :         return mpFloatWin->GetPosPixel();
    1455                 :            :     else
    1456                 :      15547 :         return mpDockingWindow->GetPosPixel();
    1457                 :            : }
    1458                 :            : 
    1459                 :            : // -----------------------------------------------------------------------
    1460                 :            : 
    1461                 :      15547 : Size ImplDockingWindowWrapper::GetSizePixel() const
    1462                 :            : {
    1463         [ -  + ]:      15547 :     if ( mpFloatWin )
    1464                 :          0 :         return mpFloatWin->GetSizePixel();
    1465                 :            :     else
    1466                 :      15547 :         return mpDockingWindow->GetSizePixel();
    1467                 :            : }
    1468                 :            : 
    1469                 :            : // -----------------------------------------------------------------------
    1470                 :            : // old inlines from DockingWindow
    1471                 :            : // -----------------------------------------------------------------------
    1472                 :            : 
    1473                 :          0 : void ImplDockingWindowWrapper::SetMinOutputSizePixel( const Size& rSize )
    1474                 :            : {
    1475         [ #  # ]:          0 :     if ( mpFloatWin )
    1476                 :          0 :         mpFloatWin->SetMinOutputSizePixel( rSize );
    1477                 :          0 :     maMinOutSize = rSize;
    1478                 :          0 : }
    1479                 :            : 
    1480                 :          0 : void ImplDockingWindowWrapper::SetMaxOutputSizePixel( const Size& rSize )
    1481                 :            : {
    1482         [ #  # ]:          0 :     if ( mpFloatWin )
    1483                 :          0 :         mpFloatWin->SetMaxOutputSizePixel( rSize );
    1484                 :          0 :     maMaxOutSize = rSize;
    1485                 :          0 : }
    1486                 :            : 
    1487                 :     980289 : sal_Bool ImplDockingWindowWrapper::IsFloatingMode() const
    1488                 :            : {
    1489                 :     980289 :     return (mpFloatWin != NULL);
    1490                 :            : }
    1491                 :            : 
    1492                 :            : 
    1493                 :       4063 : void    ImplDockingWindowWrapper::SetDragArea( const Rectangle& rRect )
    1494                 :            : {
    1495                 :       4063 :     maDragArea = rRect;
    1496                 :       4063 : }
    1497                 :            : 
    1498                 :      17319 : Rectangle  ImplDockingWindowWrapper::GetDragArea() const
    1499                 :            : {
    1500                 :      17319 :     return maDragArea;
    1501                 :            : }
    1502                 :            : 
    1503                 :          0 : void ImplDockingWindowWrapper::Lock()
    1504                 :            : {
    1505                 :          0 :     mbLocked = sal_True;
    1506                 :            :     // only toolbars support locking
    1507         [ #  # ]:          0 :     ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
    1508         [ #  # ]:          0 :     if( pToolBox )
    1509                 :          0 :         pToolBox->Lock( mbLocked );
    1510                 :          0 : }
    1511                 :            : 
    1512                 :          0 : void ImplDockingWindowWrapper::Unlock()
    1513                 :            : {
    1514                 :          0 :     mbLocked = sal_False;
    1515                 :            :     // only toolbars support locking
    1516         [ #  # ]:          0 :     ToolBox *pToolBox = dynamic_cast< ToolBox * >( GetWindow() );
    1517         [ #  # ]:          0 :     if( pToolBox )
    1518                 :          0 :         pToolBox->Lock( mbLocked );
    1519                 :          0 : }
    1520                 :            : 
    1521                 :     166295 : sal_Bool ImplDockingWindowWrapper::IsLocked() const
    1522                 :            : {
    1523                 :     166295 :     return mbLocked;
    1524                 :            : }
    1525                 :            : 
    1526                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10