LCOV - code coverage report
Current view: top level - vcl/source/window - winproc.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 1 1265 0.1 %
Date: 2014-04-14 Functions: 2 53 3.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/debug.hxx>
      21             : #include <tools/time.hxx>
      22             : 
      23             : #include <unotools/localedatawrapper.hxx>
      24             : 
      25             : #include <vcl/i18nhelp.hxx>
      26             : #include <vcl/unohelp.hxx>
      27             : #include <vcl/timer.hxx>
      28             : #include <vcl/event.hxx>
      29             : #include <vcl/settings.hxx>
      30             : #include <vcl/svapp.hxx>
      31             : #include <vcl/cursor.hxx>
      32             : #include <vcl/wrkwin.hxx>
      33             : #include <vcl/floatwin.hxx>
      34             : #include <vcl/dialog.hxx>
      35             : #include <vcl/help.hxx>
      36             : #include <vcl/dockwin.hxx>
      37             : #include <vcl/menu.hxx>
      38             : #include <touch/touch.h>
      39             : 
      40             : #include <svdata.hxx>
      41             : #include <dbggui.hxx>
      42             : #include <salwtype.hxx>
      43             : #include <salframe.hxx>
      44             : #include <accmgr.hxx>
      45             : #include <print.h>
      46             : #include <window.h>
      47             : #include <helpwin.hxx>
      48             : #include <brdwin.hxx>
      49             : #include <salgdi.hxx>
      50             : #include <dndlcon.hxx>
      51             : 
      52             : #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
      53             : #include <com/sun/star/awt/MouseEvent.hpp>
      54             : 
      55             : #define IMPL_MIN_NEEDSYSWIN         49
      56             : 
      57           0 : bool ImplCallPreNotify( NotifyEvent& rEvt )
      58             : {
      59           0 :     return Application::CallEventHooks( rEvt )
      60           0 :         || rEvt.GetWindow()->PreNotify( rEvt );
      61             : }
      62             : 
      63           0 : static bool ImplHandleMouseFloatMode( Window* pChild, const Point& rMousePos,
      64             :                                       sal_uInt16 nCode, sal_uInt16 nSVEvent,
      65             :                                       bool bMouseLeave )
      66             : {
      67           0 :     ImplSVData* pSVData = ImplGetSVData();
      68             : 
      69           0 :     if ( pSVData->maWinData.mpFirstFloat && !pSVData->maWinData.mpCaptureWin &&
      70           0 :          !pSVData->maWinData.mpFirstFloat->ImplIsFloatPopupModeWindow( pChild ) )
      71             :     {
      72             :         /*
      73             :          *  #93895# since floats are system windows, coordinates have
      74             :          *  to be converted to float relative for the hittest
      75             :          */
      76           0 :         sal_uInt16          nHitTest = IMPL_FLOATWIN_HITTEST_OUTSIDE;
      77           0 :         FloatingWindow* pFloat = pSVData->maWinData.mpFirstFloat->ImplFloatHitTest( pChild, rMousePos, nHitTest );
      78             :         FloatingWindow* pLastLevelFloat;
      79             :         sal_uLong           nPopupFlags;
      80           0 :         if ( nSVEvent == EVENT_MOUSEMOVE )
      81             :         {
      82           0 :             if ( bMouseLeave )
      83           0 :                 return true;
      84             : 
      85           0 :             if ( !pFloat || (nHitTest & IMPL_FLOATWIN_HITTEST_RECT) )
      86             :             {
      87           0 :                 if ( pSVData->maHelpData.mpHelpWin && !pSVData->maHelpData.mbKeyboardHelp )
      88           0 :                     ImplDestroyHelpWindow( true );
      89           0 :                 pChild->ImplGetFrame()->SetPointer( POINTER_ARROW );
      90           0 :                 return true;
      91             :             }
      92             :         }
      93             :         else
      94             :         {
      95           0 :             if ( nCode & MOUSE_LEFT )
      96             :             {
      97           0 :                 if ( nSVEvent == EVENT_MOUSEBUTTONDOWN )
      98             :                 {
      99           0 :                     if ( !pFloat )
     100             :                     {
     101           0 :                         pLastLevelFloat = pSVData->maWinData.mpFirstFloat->ImplFindLastLevelFloat();
     102           0 :                         nPopupFlags = pLastLevelFloat->GetPopupModeFlags();
     103           0 :                         pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
     104             : // Erstmal ausgebaut als Hack fuer Bug 53378
     105             : //                        if ( nPopupFlags & FLOATWIN_POPUPMODE_PATHMOUSECANCELCLICK )
     106             : //                            return false;
     107             : //                        else
     108           0 :                             return true;
     109             :                     }
     110           0 :                     else if ( nHitTest & IMPL_FLOATWIN_HITTEST_RECT )
     111             :                     {
     112           0 :                         if ( !(pFloat->GetPopupModeFlags() & FLOATWIN_POPUPMODE_NOMOUSERECTCLOSE) )
     113           0 :                             pFloat->ImplSetMouseDown();
     114           0 :                         return true;
     115             :                     }
     116             :                 }
     117             :                 else
     118             :                 {
     119           0 :                     if ( pFloat )
     120             :                     {
     121           0 :                         if ( nHitTest & IMPL_FLOATWIN_HITTEST_RECT )
     122             :                         {
     123           0 :                             if ( pFloat->ImplIsMouseDown() )
     124           0 :                                 pFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
     125           0 :                             return true;
     126             :                         }
     127             :                     }
     128             :                     else
     129             :                     {
     130           0 :                         pLastLevelFloat = pSVData->maWinData.mpFirstFloat->ImplFindLastLevelFloat();
     131           0 :                         nPopupFlags = pLastLevelFloat->GetPopupModeFlags();
     132           0 :                         if ( !(nPopupFlags & FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE) )
     133             :                         {
     134           0 :                             pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
     135           0 :                             return true;
     136             :                         }
     137             :                     }
     138             :                 }
     139             :             }
     140             :             else
     141             :             {
     142           0 :                 if ( !pFloat )
     143             :                 {
     144           0 :                     pLastLevelFloat = pSVData->maWinData.mpFirstFloat->ImplFindLastLevelFloat();
     145           0 :                     nPopupFlags = pLastLevelFloat->GetPopupModeFlags();
     146           0 :                     if ( nPopupFlags & FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE )
     147             :                     {
     148           0 :                         if ( (nPopupFlags & FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE) &&
     149             :                              (nSVEvent == EVENT_MOUSEBUTTONUP) )
     150           0 :                             return true;
     151           0 :                         pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
     152           0 :                         if ( nPopupFlags & FLOATWIN_POPUPMODE_PATHMOUSECANCELCLICK )
     153           0 :                             return false;
     154             :                         else
     155           0 :                             return true;
     156             :                     }
     157             :                     else
     158           0 :                         return true;
     159             :                 }
     160             :             }
     161             :         }
     162             :     }
     163             : 
     164           0 :     return false;
     165             : }
     166             : 
     167           0 : static void ImplHandleMouseHelpRequest( Window* pChild, const Point& rMousePos )
     168             : {
     169           0 :     ImplSVData* pSVData = ImplGetSVData();
     170           0 :     if ( !pSVData->maHelpData.mpHelpWin ||
     171           0 :          !( pSVData->maHelpData.mpHelpWin->IsWindowOrChild( pChild ) ||
     172           0 :            pChild->IsWindowOrChild( pSVData->maHelpData.mpHelpWin ) ) )
     173             :     {
     174           0 :         sal_uInt16 nHelpMode = 0;
     175           0 :         if ( pSVData->maHelpData.mbQuickHelp )
     176           0 :             nHelpMode = HELPMODE_QUICK;
     177           0 :         if ( pSVData->maHelpData.mbBalloonHelp )
     178           0 :             nHelpMode |= HELPMODE_BALLOON;
     179           0 :         if ( nHelpMode )
     180             :         {
     181           0 :             if ( pChild->IsInputEnabled() && !pChild->IsInModalNonRefMode() )
     182             :             {
     183           0 :                 HelpEvent aHelpEvent( rMousePos, nHelpMode );
     184           0 :                 pSVData->maHelpData.mbRequestingHelp = true;
     185           0 :                 pChild->RequestHelp( aHelpEvent );
     186           0 :                 pSVData->maHelpData.mbRequestingHelp = false;
     187             :             }
     188             :             // #104172# do not kill keyboard activated tooltips
     189           0 :             else if ( pSVData->maHelpData.mpHelpWin && !pSVData->maHelpData.mbKeyboardHelp)
     190             :             {
     191           0 :                 ImplDestroyHelpWindow( true );
     192             :             }
     193             :         }
     194             :     }
     195           0 : }
     196             : 
     197           0 : static void ImplSetMousePointer( Window* pChild )
     198             : {
     199           0 :     ImplSVData* pSVData = ImplGetSVData();
     200           0 :     if ( pSVData->maHelpData.mbExtHelpMode )
     201           0 :         pChild->ImplGetFrame()->SetPointer( POINTER_HELP );
     202             :     else
     203           0 :         pChild->ImplGetFrame()->SetPointer( pChild->ImplGetMousePointer() );
     204           0 : }
     205             : 
     206           0 : static bool ImplCallCommand( Window* pChild, sal_uInt16 nEvt, void* pData = NULL,
     207             :                              bool bMouse = false, Point* pPos = NULL )
     208             : {
     209           0 :     Point aPos;
     210           0 :     if ( pPos )
     211           0 :         aPos = *pPos;
     212             :     else
     213             :     {
     214           0 :         if( bMouse )
     215           0 :             aPos = pChild->GetPointerPosPixel();
     216             :         else
     217             :         {
     218             :             // simulate mouseposition at center of window
     219           0 :             Size aSize( pChild->GetOutputSizePixel() );
     220           0 :             aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
     221             :         }
     222             :     }
     223             : 
     224           0 :     CommandEvent    aCEvt( aPos, nEvt, bMouse, pData );
     225           0 :     NotifyEvent     aNCmdEvt( EVENT_COMMAND, pChild, &aCEvt );
     226           0 :     ImplDelData     aDelData( pChild );
     227           0 :     bool bPreNotify = ImplCallPreNotify( aNCmdEvt );
     228           0 :     if ( aDelData.IsDead() )
     229           0 :         return false;
     230           0 :     if ( !bPreNotify )
     231             :     {
     232           0 :         pChild->ImplGetWindowImpl()->mbCommand = false;
     233           0 :         pChild->Command( aCEvt );
     234             : 
     235           0 :         if( aDelData.IsDead() )
     236           0 :             return false;
     237           0 :         pChild->ImplNotifyKeyMouseCommandEventListeners( aNCmdEvt );
     238           0 :         if ( aDelData.IsDead() )
     239           0 :             return false;
     240           0 :         if ( pChild->ImplGetWindowImpl()->mbCommand )
     241           0 :             return true;
     242             :     }
     243             : 
     244           0 :     return false;
     245             : }
     246             : 
     247             : /*  #i34277# delayed context menu activation;
     248             : *   necessary if there already was a popup menu running.
     249             : */
     250             : 
     251           0 : struct ContextMenuEvent
     252             : {
     253             :     Window*         pWindow;
     254             :     ImplDelData     aDelData;
     255             :     Point           aChildPos;
     256             : };
     257             : 
     258           0 : static long ContextMenuEventLink( void* pCEvent, void* )
     259             : {
     260           0 :     ContextMenuEvent* pEv = (ContextMenuEvent*)pCEvent;
     261             : 
     262           0 :     if( ! pEv->aDelData.IsDead() )
     263             :     {
     264           0 :         pEv->pWindow->ImplRemoveDel( &pEv->aDelData );
     265           0 :         ImplCallCommand( pEv->pWindow, COMMAND_CONTEXTMENU, NULL, true, &pEv->aChildPos );
     266             :     }
     267           0 :     delete pEv;
     268             : 
     269           0 :     return 0;
     270             : }
     271             : 
     272           0 : bool ImplHandleMouseEvent( Window* pWindow, sal_uInt16 nSVEvent, bool bMouseLeave,
     273             :                            long nX, long nY, sal_uLong nMsgTime,
     274             :                            sal_uInt16 nCode, sal_uInt16 nMode )
     275             : {
     276           0 :     ImplSVData* pSVData = ImplGetSVData();
     277           0 :     Point       aMousePos( nX, nY );
     278           0 :     Window*     pChild(NULL);
     279           0 :     bool        bRet(false);
     280           0 :     sal_uInt16  nClicks(0);
     281           0 :     ImplFrameData* pWinFrameData = pWindow->ImplGetFrameData();
     282           0 :     sal_uInt16      nOldCode = pWinFrameData->mnMouseCode;
     283             : 
     284             :     // we need a mousemove event, befor we get a mousebuttondown or a
     285             :     // mousebuttonup event
     286           0 :     if ( (nSVEvent == EVENT_MOUSEBUTTONDOWN) || (nSVEvent == EVENT_MOUSEBUTTONUP) )
     287             :     {
     288           0 :         if ( (nSVEvent == EVENT_MOUSEBUTTONUP) && pSVData->maHelpData.mbExtHelpMode )
     289           0 :             Help::EndExtHelp();
     290           0 :         if ( pSVData->maHelpData.mpHelpWin )
     291             :         {
     292           0 :             if( pWindow->ImplGetWindow() == pSVData->maHelpData.mpHelpWin )
     293             :             {
     294           0 :                 ImplDestroyHelpWindow( false );
     295           0 :                 return true; // pWindow is dead now - avoid crash!
     296             :             }
     297             :             else
     298           0 :                 ImplDestroyHelpWindow( true );
     299             :         }
     300             : 
     301           0 :         if ( (pWinFrameData->mnLastMouseX != nX) ||
     302           0 :              (pWinFrameData->mnLastMouseY != nY) )
     303             :         {
     304           0 :             ImplHandleMouseEvent( pWindow, EVENT_MOUSEMOVE, false, nX, nY, nMsgTime, nCode, nMode );
     305             :         }
     306             :     }
     307             : 
     308             :     // update frame data
     309           0 :     pWinFrameData->mnBeforeLastMouseX = pWinFrameData->mnLastMouseX;
     310           0 :     pWinFrameData->mnBeforeLastMouseY = pWinFrameData->mnLastMouseY;
     311           0 :     pWinFrameData->mnLastMouseX = nX;
     312           0 :     pWinFrameData->mnLastMouseY = nY;
     313           0 :     pWinFrameData->mnMouseCode  = nCode;
     314           0 :     pWinFrameData->mnMouseMode  = nMode & ~(MOUSE_SYNTHETIC | MOUSE_MODIFIERCHANGED);
     315           0 :     if ( bMouseLeave )
     316             :     {
     317           0 :         pWinFrameData->mbMouseIn = false;
     318           0 :         if ( pSVData->maHelpData.mpHelpWin && !pSVData->maHelpData.mbKeyboardHelp )
     319             :         {
     320           0 :             ImplDelData aDelData( pWindow );
     321             : 
     322           0 :             ImplDestroyHelpWindow( true );
     323             : 
     324           0 :             if ( aDelData.IsDead() )
     325           0 :                 return true; // pWindow is dead now - avoid crash! (#122045#)
     326             :         }
     327             :     }
     328             :     else
     329           0 :         pWinFrameData->mbMouseIn = true;
     330             : 
     331             :     DBG_ASSERT( !pSVData->maWinData.mpTrackWin ||
     332             :                 (pSVData->maWinData.mpTrackWin == pSVData->maWinData.mpCaptureWin),
     333             :                 "ImplHandleMouseEvent: TrackWin != CaptureWin" );
     334             : 
     335             :     // AutoScrollMode
     336           0 :     if ( pSVData->maWinData.mpAutoScrollWin && (nSVEvent == EVENT_MOUSEBUTTONDOWN) )
     337             :     {
     338           0 :         pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
     339           0 :         return true;
     340             :     }
     341             : 
     342             :     // find mouse window
     343           0 :     if ( pSVData->maWinData.mpCaptureWin )
     344             :     {
     345           0 :         pChild = pSVData->maWinData.mpCaptureWin;
     346             : 
     347             :         DBG_ASSERT( pWindow == pChild->ImplGetFrameWindow(),
     348             :                     "ImplHandleMouseEvent: mouse event is not sent to capture window" );
     349             : 
     350             :         // java client cannot capture mouse correctly
     351           0 :         if ( pWindow != pChild->ImplGetFrameWindow() )
     352           0 :             return false;
     353             : 
     354           0 :         if ( bMouseLeave )
     355           0 :             return false;
     356             :     }
     357             :     else
     358             :     {
     359           0 :         if ( bMouseLeave )
     360           0 :             pChild = NULL;
     361             :         else
     362           0 :             pChild = pWindow->ImplFindWindow( aMousePos );
     363             :     }
     364             : 
     365             :     // test this because mouse events are buffered in the remote version
     366             :     // and size may not be in sync
     367           0 :     if ( !pChild && !bMouseLeave )
     368           0 :         return false;
     369             : 
     370             :     // execute a few tests and catch the message or implement the status
     371           0 :     if ( pChild )
     372             :     {
     373           0 :         if( pChild->ImplIsAntiparallel() )
     374             :         {
     375             :             // - RTL - re-mirror frame pos at pChild
     376           0 :             const OutputDevice *pChildWinOutDev = pChild->GetOutDev();
     377           0 :             pChildWinOutDev->ReMirror( aMousePos );
     378             :         }
     379             :         // no mouse messages to system object windows ?
     380             :         // !!!KA: Is it OK to comment this out? !!!
     381             : //        if ( pChild->ImplGetWindowImpl()->mpSysObj )
     382             : //            return false;
     383             : 
     384             :         // no mouse messages to disabled windows
     385             :         // #106845# if the window was disabed during capturing we have to pass the mouse events to release capturing
     386           0 :         if ( pSVData->maWinData.mpCaptureWin != pChild && (!pChild->IsEnabled() || !pChild->IsInputEnabled() || pChild->IsInModalNonRefMode() ) )
     387             :         {
     388           0 :             ImplHandleMouseFloatMode( pChild, aMousePos, nCode, nSVEvent, bMouseLeave );
     389           0 :             if ( nSVEvent == EVENT_MOUSEMOVE )
     390             :             {
     391           0 :                 ImplHandleMouseHelpRequest( pChild, aMousePos );
     392           0 :                 if( pWinFrameData->mpMouseMoveWin != pChild )
     393           0 :                     nMode |= MOUSE_ENTERWINDOW;
     394             :             }
     395             : 
     396             :             // Call the hook also, if Window is disabled
     397           0 :             Point aChildPos = pChild->ImplFrameToOutput( aMousePos );
     398           0 :             MouseEvent aMEvt( aChildPos, pWinFrameData->mnClickCount, nMode, nCode, nCode );
     399           0 :             NotifyEvent aNEvt( nSVEvent, pChild, &aMEvt );
     400           0 :             Application::CallEventHooks( aNEvt );
     401             : 
     402           0 :             if( pChild->IsCallHandlersOnInputDisabled() )
     403             :             {
     404           0 :                 pWinFrameData->mpMouseMoveWin = pChild;
     405           0 :                 pChild->ImplNotifyKeyMouseCommandEventListeners( aNEvt );
     406             :             }
     407             : 
     408           0 :             if ( nSVEvent == EVENT_MOUSEBUTTONDOWN )
     409           0 :                 return true;
     410             :             else
     411             :             {
     412             :                 // Set normal MousePointer for disabled windows
     413           0 :                 if ( nSVEvent == EVENT_MOUSEMOVE )
     414           0 :                     ImplSetMousePointer( pChild );
     415             : 
     416           0 :                 return false;
     417             :             }
     418             :         }
     419             : 
     420             :         // End ExtTextInput-Mode, if the user click in the same TopLevel Window
     421           0 :         if ( pSVData->maWinData.mpExtTextInputWin &&
     422           0 :              ((nSVEvent == EVENT_MOUSEBUTTONDOWN) ||
     423             :               (nSVEvent == EVENT_MOUSEBUTTONUP)) )
     424           0 :             pSVData->maWinData.mpExtTextInputWin->EndExtTextInput( EXTTEXTINPUT_END_COMPLETE );
     425             :     }
     426             : 
     427             :     // determine mouse event data
     428           0 :     if ( nSVEvent == EVENT_MOUSEMOVE )
     429             :     {
     430             :         // check if MouseMove belongs to same window and if the
     431             :         // status did not change
     432           0 :         if ( pChild )
     433             :         {
     434           0 :             Point aChildMousePos = pChild->ImplFrameToOutput( aMousePos );
     435           0 :             if ( !bMouseLeave &&
     436           0 :                  (pChild == pWinFrameData->mpMouseMoveWin) &&
     437           0 :                  (aChildMousePos.X() == pWinFrameData->mnLastMouseWinX) &&
     438           0 :                  (aChildMousePos.Y() == pWinFrameData->mnLastMouseWinY) &&
     439           0 :                  (nOldCode == pWinFrameData->mnMouseCode) )
     440             :             {
     441             :                 // set mouse pointer anew, as it could have changed
     442             :                 // due to the mode switch
     443           0 :                 ImplSetMousePointer( pChild );
     444           0 :                 return false;
     445             :             }
     446             : 
     447           0 :             pWinFrameData->mnLastMouseWinX = aChildMousePos.X();
     448           0 :             pWinFrameData->mnLastMouseWinY = aChildMousePos.Y();
     449             :         }
     450             : 
     451             :         // mouse click
     452           0 :         nClicks = pWinFrameData->mnClickCount;
     453             : 
     454             :         // call Start-Drag handler if required
     455             :         // Warning: should be called before Move, as otherwise during
     456             :         // fast mouse movements the applications move to the selection state
     457           0 :         Window* pMouseDownWin = pWinFrameData->mpMouseDownWin;
     458           0 :         if ( pMouseDownWin )
     459             :         {
     460             :             // check for matching StartDrag mode. We only compare
     461             :             // the status of the mouse buttons, such that e. g. Mod1 can
     462             :             // change immediately to the copy mode
     463           0 :             const MouseSettings& rMSettings = pMouseDownWin->GetSettings().GetMouseSettings();
     464           0 :             if ( (nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) ==
     465           0 :                  (rMSettings.GetStartDragCode() & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) )
     466             :             {
     467           0 :                 if ( !pMouseDownWin->ImplGetFrameData()->mbStartDragCalled )
     468             :                 {
     469           0 :                     long nDragW  = rMSettings.GetStartDragWidth();
     470           0 :                     long nDragH  = rMSettings.GetStartDragWidth();
     471             :                     //long nMouseX = nX;
     472             :                     //long nMouseY = nY;
     473           0 :                     long nMouseX = aMousePos.X(); // #106074# use the possibly re-mirrored coordinates (RTL) ! nX,nY are unmodified !
     474           0 :                     long nMouseY = aMousePos.Y();
     475           0 :                     if ( !(((nMouseX-nDragW) <= pMouseDownWin->ImplGetFrameData()->mnFirstMouseX) &&
     476           0 :                            ((nMouseX+nDragW) >= pMouseDownWin->ImplGetFrameData()->mnFirstMouseX)) ||
     477           0 :                          !(((nMouseY-nDragH) <= pMouseDownWin->ImplGetFrameData()->mnFirstMouseY) &&
     478           0 :                            ((nMouseY+nDragH) >= pMouseDownWin->ImplGetFrameData()->mnFirstMouseY)) )
     479             :                     {
     480           0 :                         pMouseDownWin->ImplGetFrameData()->mbStartDragCalled  = true;
     481             : 
     482             :                         // Check if drag source provides it's own recognizer
     483           0 :                         if( pMouseDownWin->ImplGetFrameData()->mbInternalDragGestureRecognizer )
     484             :                         {
     485             :                             // query DropTarget from child window
     486             :                             ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer > xDragGestureRecognizer =
     487           0 :                                 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragGestureRecognizer > ( pMouseDownWin->ImplGetWindowImpl()->mxDNDListenerContainer,
     488           0 :                                     ::com::sun::star::uno::UNO_QUERY );
     489             : 
     490           0 :                             if( xDragGestureRecognizer.is() )
     491             :                             {
     492             :                                 // retrieve mouse position relative to mouse down window
     493             :                                 Point relLoc = pMouseDownWin->ImplFrameToOutput( Point(
     494           0 :                                     pMouseDownWin->ImplGetFrameData()->mnFirstMouseX,
     495           0 :                                     pMouseDownWin->ImplGetFrameData()->mnFirstMouseY ) );
     496             : 
     497             :                                 // create a uno mouse event out of the available data
     498             :                                 ::com::sun::star::awt::MouseEvent aMouseEvent(
     499             :                                     static_cast < ::com::sun::star::uno::XInterface * > ( 0 ),
     500             : #ifdef MACOSX
     501             :                     nCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3),
     502             : #else
     503             :                                     nCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2),
     504             : #endif
     505             :                                     nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE),
     506             :                                     nMouseX,
     507             :                                     nMouseY,
     508             :                                     nClicks,
     509           0 :                                     false );
     510             : 
     511           0 :                                 sal_uLong nCount = Application::ReleaseSolarMutex();
     512             : 
     513             :                                 // FIXME: where do I get Action from ?
     514           0 :                                 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > xDragSource = pMouseDownWin->GetDragSource();
     515             : 
     516           0 :                                 if( xDragSource.is() )
     517             :                                 {
     518           0 :                                     static_cast < DNDListenerContainer * > ( xDragGestureRecognizer.get() )->fireDragGestureEvent( 0,
     519           0 :                                         relLoc.X(), relLoc.Y(), xDragSource, ::com::sun::star::uno::makeAny( aMouseEvent ) );
     520             :                                 }
     521             : 
     522           0 :                                 Application::AcquireSolarMutex( nCount );
     523           0 :                             }
     524             :                         }
     525             :                     }
     526             :                 }
     527             :             }
     528             :             else
     529           0 :                 pMouseDownWin->ImplGetFrameData()->mbStartDragCalled  = true;
     530             :         }
     531             : 
     532             :         // test for mouseleave and mouseenter
     533           0 :         Window* pMouseMoveWin = pWinFrameData->mpMouseMoveWin;
     534           0 :         if ( pChild != pMouseMoveWin )
     535             :         {
     536           0 :             if ( pMouseMoveWin )
     537             :             {
     538           0 :                 Point       aLeaveMousePos = pMouseMoveWin->ImplFrameToOutput( aMousePos );
     539           0 :                 MouseEvent  aMLeaveEvt( aLeaveMousePos, nClicks, nMode | MOUSE_LEAVEWINDOW, nCode, nCode );
     540           0 :                 NotifyEvent aNLeaveEvt( EVENT_MOUSEMOVE, pMouseMoveWin, &aMLeaveEvt );
     541           0 :                 ImplDelData aDelData;
     542           0 :                 ImplDelData aDelData2;
     543           0 :                 pWinFrameData->mbInMouseMove = true;
     544           0 :                 pMouseMoveWin->ImplGetWinData()->mbMouseOver = false;
     545           0 :                 pMouseMoveWin->ImplAddDel( &aDelData );
     546             : 
     547             :                 // A MouseLeave can destroy this window
     548           0 :                 if ( pChild )
     549           0 :                     pChild->ImplAddDel( &aDelData2 );
     550           0 :                 if ( !ImplCallPreNotify( aNLeaveEvt ) )
     551             :                 {
     552           0 :                     pMouseMoveWin->MouseMove( aMLeaveEvt );
     553             :                     // #82968#
     554           0 :                     if( !aDelData.IsDead() )
     555           0 :                         aNLeaveEvt.GetWindow()->ImplNotifyKeyMouseCommandEventListeners( aNLeaveEvt );
     556             :                 }
     557             : 
     558           0 :                 pWinFrameData->mpMouseMoveWin = NULL;
     559           0 :                 pWinFrameData->mbInMouseMove = false;
     560             : 
     561           0 :                 if ( pChild )
     562             :                 {
     563           0 :                     if ( aDelData2.IsDead() )
     564           0 :                         pChild = NULL;
     565             :                     else
     566           0 :                         pChild->ImplRemoveDel( &aDelData2 );
     567             :                 }
     568           0 :                 if ( aDelData.IsDead() )
     569           0 :                     return true;
     570           0 :                 pMouseMoveWin->ImplRemoveDel( &aDelData );
     571             :             }
     572             : 
     573           0 :             nMode |= MOUSE_ENTERWINDOW;
     574             :         }
     575           0 :         pWinFrameData->mpMouseMoveWin = pChild;
     576           0 :         if( pChild )
     577           0 :             pChild->ImplGetWinData()->mbMouseOver = true;
     578             : 
     579             :         // MouseLeave
     580           0 :         if ( !pChild )
     581           0 :             return false;
     582             :     }
     583             :     else
     584             :     {
     585           0 :         if (pChild)
     586             :         {
     587             :             // mouse click
     588           0 :             if ( nSVEvent == EVENT_MOUSEBUTTONDOWN )
     589             :             {
     590           0 :                 const MouseSettings& rMSettings = pChild->GetSettings().GetMouseSettings();
     591           0 :                 sal_uLong   nDblClkTime = rMSettings.GetDoubleClickTime();
     592           0 :                 long    nDblClkW    = rMSettings.GetDoubleClickWidth();
     593           0 :                 long    nDblClkH    = rMSettings.GetDoubleClickHeight();
     594             :                 //long    nMouseX     = nX;
     595             :                 //long    nMouseY     = nY;
     596           0 :                 long nMouseX = aMousePos.X();   // #106074# use the possibly re-mirrored coordinates (RTL) ! nX,nY are unmodified !
     597           0 :                 long nMouseY = aMousePos.Y();
     598             : 
     599           0 :                 if ( (pChild == pChild->ImplGetFrameData()->mpMouseDownWin) &&
     600           0 :                      (nCode == pChild->ImplGetFrameData()->mnFirstMouseCode) &&
     601           0 :                      ((nMsgTime-pChild->ImplGetFrameData()->mnMouseDownTime) < nDblClkTime) &&
     602           0 :                      ((nMouseX-nDblClkW) <= pChild->ImplGetFrameData()->mnFirstMouseX) &&
     603           0 :                      ((nMouseX+nDblClkW) >= pChild->ImplGetFrameData()->mnFirstMouseX) &&
     604           0 :                      ((nMouseY-nDblClkH) <= pChild->ImplGetFrameData()->mnFirstMouseY) &&
     605           0 :                      ((nMouseY+nDblClkH) >= pChild->ImplGetFrameData()->mnFirstMouseY) )
     606             :                 {
     607           0 :                     pChild->ImplGetFrameData()->mnClickCount++;
     608           0 :                     pChild->ImplGetFrameData()->mbStartDragCalled  = true;
     609             :                 }
     610             :                 else
     611             :                 {
     612           0 :                     pChild->ImplGetFrameData()->mpMouseDownWin     = pChild;
     613           0 :                     pChild->ImplGetFrameData()->mnClickCount       = 1;
     614           0 :                     pChild->ImplGetFrameData()->mnFirstMouseX      = nMouseX;
     615           0 :                     pChild->ImplGetFrameData()->mnFirstMouseY      = nMouseY;
     616           0 :                     pChild->ImplGetFrameData()->mnFirstMouseCode   = nCode;
     617           0 :                     pChild->ImplGetFrameData()->mbStartDragCalled  = !((nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) ==
     618           0 :                                                                 (rMSettings.GetStartDragCode() & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)));
     619             :                 }
     620           0 :                 pChild->ImplGetFrameData()->mnMouseDownTime = nMsgTime;
     621             :             }
     622           0 :             nClicks = pChild->ImplGetFrameData()->mnClickCount;
     623             :         }
     624             : 
     625           0 :         pSVData->maAppData.mnLastInputTime = Time::GetSystemTicks();
     626             :     }
     627             : 
     628             :     DBG_ASSERT( pChild, "ImplHandleMouseEvent: pChild == NULL" );
     629             : 
     630           0 :     if (!pChild)
     631           0 :         return false;
     632             : 
     633             :     // create mouse event
     634           0 :     Point aChildPos = pChild->ImplFrameToOutput( aMousePos );
     635           0 :     MouseEvent aMEvt( aChildPos, nClicks, nMode, nCode, nCode );
     636             : 
     637             :     // tracking window gets the mouse events
     638           0 :     if ( pSVData->maWinData.mpTrackWin )
     639           0 :         pChild = pSVData->maWinData.mpTrackWin;
     640             : 
     641             :     // handle FloatingMode
     642           0 :     if ( !pSVData->maWinData.mpTrackWin && pSVData->maWinData.mpFirstFloat )
     643             :     {
     644           0 :         ImplDelData aDelData;
     645           0 :         pChild->ImplAddDel( &aDelData );
     646           0 :         if ( ImplHandleMouseFloatMode( pChild, aMousePos, nCode, nSVEvent, bMouseLeave ) )
     647             :         {
     648           0 :             if ( !aDelData.IsDead() )
     649             :             {
     650           0 :                 pChild->ImplRemoveDel( &aDelData );
     651           0 :                 pChild->ImplGetFrameData()->mbStartDragCalled = true;
     652             :             }
     653           0 :             return true;
     654             :         }
     655             :         else
     656           0 :             pChild->ImplRemoveDel( &aDelData );
     657             :     }
     658             : 
     659             :     // call handler
     660           0 :     bool bDrag = false;
     661           0 :     bool bCallHelpRequest = true;
     662             :     DBG_ASSERT( pChild, "ImplHandleMouseEvent: pChild is NULL" );
     663             : 
     664           0 :     if (!pChild)
     665           0 :         return false;
     666             : 
     667           0 :     ImplDelData aDelData;
     668           0 :     NotifyEvent aNEvt( nSVEvent, pChild, &aMEvt );
     669           0 :     pChild->ImplAddDel( &aDelData );
     670           0 :     if ( nSVEvent == EVENT_MOUSEMOVE )
     671           0 :         pChild->ImplGetFrameData()->mbInMouseMove = true;
     672             : 
     673             :     // bring window into foreground on mouseclick
     674           0 :     if ( nSVEvent == EVENT_MOUSEBUTTONDOWN )
     675             :     {
     676           0 :         if( !pSVData->maWinData.mpFirstFloat && // totop for floating windows in popup would change the focus and would close them immediately
     677           0 :             !(pChild->ImplGetFrameWindow()->GetStyle() & WB_OWNERDRAWDECORATION) )    // ownerdrawdecorated windows must never grab focus
     678           0 :             pChild->ToTop();
     679           0 :         if ( aDelData.IsDead() )
     680           0 :             return true;
     681             :     }
     682             : 
     683           0 :     if ( ImplCallPreNotify( aNEvt ) || aDelData.IsDead() )
     684           0 :         bRet = true;
     685             :     else
     686             :     {
     687           0 :         bRet = false;
     688           0 :         if ( nSVEvent == EVENT_MOUSEMOVE )
     689             :         {
     690           0 :             if ( pSVData->maWinData.mpTrackWin )
     691             :             {
     692           0 :                 TrackingEvent aTEvt( aMEvt );
     693           0 :                 pChild->Tracking( aTEvt );
     694           0 :                 if ( !aDelData.IsDead() )
     695             :                 {
     696             :                     // When ScrollRepeat, we restart the timer
     697           0 :                     if ( pSVData->maWinData.mpTrackTimer &&
     698           0 :                          (pSVData->maWinData.mnTrackFlags & STARTTRACK_SCROLLREPEAT) )
     699           0 :                         pSVData->maWinData.mpTrackTimer->Start();
     700             :                 }
     701           0 :                 bCallHelpRequest = false;
     702           0 :                 bRet = true;
     703             :             }
     704             :             else
     705             :             {
     706             :                 // Auto-ToTop
     707           0 :                 if ( !pSVData->maWinData.mpCaptureWin &&
     708           0 :                      (pChild->GetSettings().GetMouseSettings().GetOptions() & MOUSE_OPTION_AUTOFOCUS) )
     709           0 :                     pChild->ToTop( TOTOP_NOGRABFOCUS );
     710             : 
     711           0 :                 if( aDelData.IsDead() )
     712           0 :                     bCallHelpRequest = false;
     713             :                 else
     714             :                 {
     715             :                     // if the MouseMove handler changes the help window's visibility
     716             :                     // the HelpRequest handler should not be called anymore
     717           0 :                     Window* pOldHelpTextWin = pSVData->maHelpData.mpHelpWin;
     718           0 :                     pChild->ImplGetWindowImpl()->mbMouseMove = false;
     719           0 :                     pChild->MouseMove( aMEvt );
     720           0 :                     if ( pOldHelpTextWin != pSVData->maHelpData.mpHelpWin )
     721           0 :                         bCallHelpRequest = false;
     722             :                 }
     723             :             }
     724             :         }
     725           0 :         else if ( nSVEvent == EVENT_MOUSEBUTTONDOWN )
     726             :         {
     727           0 :             if ( pSVData->maWinData.mpTrackWin &&
     728           0 :                  !(pSVData->maWinData.mnTrackFlags & STARTTRACK_MOUSEBUTTONDOWN) )
     729           0 :                 bRet = true;
     730             :             else
     731             :             {
     732           0 :                 pChild->ImplGetWindowImpl()->mbMouseButtonDown = false;
     733           0 :                 pChild->MouseButtonDown( aMEvt );
     734             :             }
     735             :         }
     736             :         else
     737             :         {
     738           0 :             if ( pSVData->maWinData.mpTrackWin )
     739             :             {
     740           0 :                 pChild->EndTracking();
     741           0 :                 bRet = true;
     742             :             }
     743             :             else
     744             :             {
     745           0 :                 pChild->ImplGetWindowImpl()->mbMouseButtonUp = false;
     746           0 :                 pChild->MouseButtonUp( aMEvt );
     747             :             }
     748             :         }
     749             : 
     750             :         // #82968#
     751           0 :         if ( !aDelData.IsDead() )
     752           0 :             aNEvt.GetWindow()->ImplNotifyKeyMouseCommandEventListeners( aNEvt );
     753             :     }
     754             : 
     755           0 :     if ( aDelData.IsDead() )
     756           0 :         return true;
     757             : 
     758           0 :     if ( nSVEvent == EVENT_MOUSEMOVE )
     759           0 :         pChild->ImplGetWindowImpl()->mpFrameData->mbInMouseMove = false;
     760             : 
     761           0 :     if ( nSVEvent == EVENT_MOUSEMOVE )
     762             :     {
     763           0 :         if ( bCallHelpRequest && !pSVData->maHelpData.mbKeyboardHelp )
     764           0 :             ImplHandleMouseHelpRequest( pChild, pChild->OutputToScreenPixel( aMEvt.GetPosPixel() ) );
     765           0 :         bRet = true;
     766             :     }
     767           0 :     else if ( !bRet )
     768             :     {
     769           0 :         if ( nSVEvent == EVENT_MOUSEBUTTONDOWN )
     770             :         {
     771           0 :             if ( !pChild->ImplGetWindowImpl()->mbMouseButtonDown )
     772           0 :                 bRet = true;
     773             :         }
     774             :         else
     775             :         {
     776           0 :             if ( !pChild->ImplGetWindowImpl()->mbMouseButtonUp )
     777           0 :                 bRet = true;
     778             :         }
     779             :     }
     780             : 
     781           0 :     pChild->ImplRemoveDel( &aDelData );
     782             : 
     783           0 :     if ( nSVEvent == EVENT_MOUSEMOVE )
     784             :     {
     785             :         // set new mouse pointer
     786           0 :         if ( !bMouseLeave )
     787           0 :             ImplSetMousePointer( pChild );
     788             :     }
     789           0 :     else if ( (nSVEvent == EVENT_MOUSEBUTTONDOWN) || (nSVEvent == EVENT_MOUSEBUTTONUP) )
     790             :     {
     791           0 :         if ( !bDrag )
     792             :         {
     793             :             // Command-Events
     794           0 :             if ( /*!bRet &&*/ (nClicks == 1) && (nSVEvent == EVENT_MOUSEBUTTONDOWN) &&
     795             :                  (nCode == MOUSE_MIDDLE) )
     796             :             {
     797           0 :                 sal_uInt16 nMiddleAction = pChild->GetSettings().GetMouseSettings().GetMiddleButtonAction();
     798           0 :                 if ( nMiddleAction == MOUSE_MIDDLE_AUTOSCROLL )
     799           0 :                     bRet = !ImplCallCommand( pChild, COMMAND_STARTAUTOSCROLL, NULL, true, &aChildPos );
     800           0 :                 else if ( nMiddleAction == MOUSE_MIDDLE_PASTESELECTION )
     801           0 :                     bRet = !ImplCallCommand( pChild, COMMAND_PASTESELECTION, NULL, true, &aChildPos );
     802             :             }
     803             :             else
     804             :             {
     805             :                 // ContextMenu
     806           0 :                 const MouseSettings& rMSettings = pChild->GetSettings().GetMouseSettings();
     807           0 :                 if ( (nCode == rMSettings.GetContextMenuCode()) &&
     808           0 :                      (nClicks == rMSettings.GetContextMenuClicks()) )
     809             :                 {
     810           0 :                     bool bContextMenu = (nSVEvent == EVENT_MOUSEBUTTONDOWN);
     811           0 :                     if ( bContextMenu )
     812             :                     {
     813           0 :                         if( pSVData->maAppData.mpActivePopupMenu )
     814             :                         {
     815             :                             /*  #i34277# there already is a context menu open
     816             :                             *   that was probably just closed with EndPopupMode.
     817             :                             *   We need to give the eventual corresponding
     818             :                             *   PopupMenu::Execute a chance to end properly.
     819             :                             *   Therefore delay context menu command and
     820             :                             *   issue only after popping one frame of the
     821             :                             *   Yield stack.
     822             :                             */
     823           0 :                             ContextMenuEvent* pEv = new ContextMenuEvent;
     824           0 :                             pEv->pWindow = pChild;
     825           0 :                             pEv->aChildPos = aChildPos;
     826           0 :                             pChild->ImplAddDel( &pEv->aDelData );
     827           0 :                             Application::PostUserEvent( Link( pEv, ContextMenuEventLink ) );
     828             :                         }
     829             :                         else
     830           0 :                             bRet = ! ImplCallCommand( pChild, COMMAND_CONTEXTMENU, NULL, true, &aChildPos );
     831             :                     }
     832             :                 }
     833             :             }
     834             :         }
     835             :     }
     836             : 
     837           0 :     return bRet;
     838             : }
     839             : 
     840           0 : static Window* ImplGetKeyInputWindow( Window* pWindow )
     841             : {
     842           0 :     ImplSVData* pSVData = ImplGetSVData();
     843             : 
     844             :     // determine last input time
     845           0 :     pSVData->maAppData.mnLastInputTime = Time::GetSystemTicks();
     846             : 
     847             :     // #127104# workaround for destroyed windows
     848           0 :     if( pWindow->ImplGetWindowImpl() == NULL )
     849           0 :         return 0;
     850             : 
     851             :     // find window - is every time the window which has currently the
     852             :     // focus or the last time the focus.
     853             :     // the first floating window always has the focus
     854           0 :     Window* pChild = pSVData->maWinData.mpFirstFloat;
     855           0 :     if( !pChild || ( pChild->ImplGetWindowImpl()->mbFloatWin && !((FloatingWindow *)pChild)->GrabsFocus() ) )
     856           0 :         pChild = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
     857             :     else
     858             :     {
     859             :         // allow floaters to forward keyinput to some member
     860           0 :         pChild = pChild->GetPreferredKeyInputWindow();
     861             :     }
     862             : 
     863             :     // no child - than no input
     864           0 :     if ( !pChild )
     865           0 :         return 0;
     866             : 
     867             :     // We call also KeyInput if we haven't the focus, because on Unix
     868             :     // system this is often the case when a Lookup Choise Window has
     869             :     // the focus - because this windows send the KeyInput directly to
     870             :     // the window without resetting the focus
     871             :     DBG_ASSERTWARNING( pChild == pSVData->maWinData.mpFocusWin,
     872             :                        "ImplHandleKey: Keyboard-Input is sent to a frame without focus" );
     873             : 
     874             :     // no keyinput to disabled windows
     875           0 :     if ( !pChild->IsEnabled() || !pChild->IsInputEnabled() || pChild->IsInModalMode() )
     876           0 :         return 0;
     877             : 
     878           0 :     return pChild;
     879             : }
     880             : 
     881           0 : static bool ImplHandleKey( Window* pWindow, sal_uInt16 nSVEvent,
     882             :                            sal_uInt16 nKeyCode, sal_uInt16 nCharCode, sal_uInt16 nRepeat, bool bForward )
     883             : {
     884           0 :     ImplSVData* pSVData = ImplGetSVData();
     885           0 :     KeyCode     aKeyCode( nKeyCode, nKeyCode );
     886           0 :     sal_uInt16      nEvCode = aKeyCode.GetCode();
     887             : 
     888             :     // allow application key listeners to remove the key event
     889             :     // but make sure we're not forwarding external KeyEvents, (ie where bForward is false)
     890             :     // because those are coming back from the listener itself and MUST be processed
     891           0 :     KeyEvent aKeyEvent( (sal_Unicode)nCharCode, aKeyCode, nRepeat );
     892           0 :     if( bForward )
     893             :     {
     894             :         sal_uInt16 nVCLEvent;
     895           0 :         switch( nSVEvent )
     896             :         {
     897             :             case EVENT_KEYINPUT:
     898           0 :                 nVCLEvent = VCLEVENT_WINDOW_KEYINPUT;
     899           0 :                 break;
     900             :             case EVENT_KEYUP:
     901           0 :                 nVCLEvent = VCLEVENT_WINDOW_KEYUP;
     902           0 :                 break;
     903             :             default:
     904           0 :                 nVCLEvent = 0;
     905           0 :                 break;
     906             :         }
     907           0 :         if( nVCLEvent && pSVData->mpApp->HandleKey( nVCLEvent, pWindow, &aKeyEvent ) )
     908           0 :             return true;
     909             :     }
     910             : 
     911             :     // #i1820# use locale specific decimal separator
     912           0 :     if( nEvCode == KEY_DECIMAL )
     913             :     {
     914           0 :         if( Application::GetSettings().GetMiscSettings().GetEnableLocalizedDecimalSep() )
     915             :         {
     916           0 :             OUString aSep( pWindow->GetSettings().GetLocaleDataWrapper().getNumDecimalSep() );
     917           0 :             nCharCode = (sal_uInt16) aSep[0];
     918             :         }
     919             :     }
     920             : 
     921           0 :     bool bCtrlF6 = (aKeyCode.GetCode() == KEY_F6) && aKeyCode.IsMod1();
     922             : 
     923             :     // determine last input time
     924           0 :     pSVData->maAppData.mnLastInputTime = Time::GetSystemTicks();
     925             : 
     926             :     // handle tracking window
     927           0 :     if ( nSVEvent == EVENT_KEYINPUT )
     928             :     {
     929             : #ifdef DBG_UTIL
     930             :         // #105224# use Ctrl-Alt-Shift-D, Ctrl-Shift-D must be useable by app
     931             :         if ( aKeyCode.IsShift() && aKeyCode.IsMod1() && (aKeyCode.IsMod2() || aKeyCode.IsMod3()) && (aKeyCode.GetCode() == KEY_D) )
     932             :         {
     933             :             DBGGUI_START();
     934             :             return true;
     935             :         }
     936             : #endif
     937             : 
     938           0 :         if ( pSVData->maHelpData.mbExtHelpMode )
     939             :         {
     940           0 :             Help::EndExtHelp();
     941           0 :             if ( nEvCode == KEY_ESCAPE )
     942           0 :                 return true;
     943             :         }
     944           0 :         if ( pSVData->maHelpData.mpHelpWin )
     945           0 :             ImplDestroyHelpWindow( false );
     946             : 
     947             :         // AutoScrollMode
     948           0 :         if ( pSVData->maWinData.mpAutoScrollWin )
     949             :         {
     950           0 :             pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
     951           0 :             if ( nEvCode == KEY_ESCAPE )
     952           0 :                 return true;
     953             :         }
     954             : 
     955           0 :         if ( pSVData->maWinData.mpTrackWin )
     956             :         {
     957           0 :             sal_uInt16 nOrigCode = aKeyCode.GetCode();
     958             : 
     959           0 :             if ( (nOrigCode == KEY_ESCAPE) && !(pSVData->maWinData.mnTrackFlags & STARTTRACK_NOKEYCANCEL) )
     960             :             {
     961           0 :                 pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL | ENDTRACK_KEY );
     962           0 :                 if ( pSVData->maWinData.mpFirstFloat )
     963             :                 {
     964           0 :                     FloatingWindow* pLastLevelFloat = pSVData->maWinData.mpFirstFloat->ImplFindLastLevelFloat();
     965           0 :                     if ( !(pLastLevelFloat->GetPopupModeFlags() & FLOATWIN_POPUPMODE_NOKEYCLOSE) )
     966             :                     {
     967           0 :                         sal_uInt16 nEscCode = aKeyCode.GetCode();
     968             : 
     969           0 :                         if ( nEscCode == KEY_ESCAPE )
     970           0 :                             pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
     971             :                     }
     972             :                 }
     973           0 :                 return true;
     974             :             }
     975           0 :             else if ( nOrigCode == KEY_RETURN )
     976             :             {
     977           0 :                 pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_KEY );
     978           0 :                 return true;
     979             :             }
     980           0 :             else if ( !(pSVData->maWinData.mnTrackFlags & STARTTRACK_KEYINPUT) )
     981           0 :                 return true;
     982             :         }
     983             : 
     984             :         // handle FloatingMode
     985           0 :         if ( pSVData->maWinData.mpFirstFloat )
     986             :         {
     987           0 :             FloatingWindow* pLastLevelFloat = pSVData->maWinData.mpFirstFloat->ImplFindLastLevelFloat();
     988           0 :             if ( !(pLastLevelFloat->GetPopupModeFlags() & FLOATWIN_POPUPMODE_NOKEYCLOSE) )
     989             :             {
     990           0 :                 sal_uInt16 nCode = aKeyCode.GetCode();
     991             : 
     992           0 :                 if ( (nCode == KEY_ESCAPE) || bCtrlF6)
     993             :                 {
     994           0 :                     pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
     995           0 :                     if( !bCtrlF6 )
     996           0 :                         return true;
     997             :                 }
     998             :             }
     999             :         }
    1000             : 
    1001             :         // test for accel
    1002           0 :         if ( pSVData->maAppData.mpAccelMgr )
    1003             :         {
    1004           0 :             if ( pSVData->maAppData.mpAccelMgr->IsAccelKey( aKeyCode, nRepeat ) )
    1005           0 :                 return true;
    1006             :         }
    1007             :     }
    1008             : 
    1009             :     // find window
    1010           0 :     Window* pChild = ImplGetKeyInputWindow( pWindow );
    1011           0 :     if ( !pChild )
    1012           0 :         return false;
    1013             : 
    1014             :     // --- RTL --- mirror cursor keys
    1015           0 :     const OutputDevice *pChildOutDev = pChild->GetOutDev();
    1016           0 :     if( (aKeyCode.GetCode() == KEY_LEFT || aKeyCode.GetCode() == KEY_RIGHT) &&
    1017           0 :       pChildOutDev->HasMirroredGraphics() && pChild->IsRTLEnabled() )
    1018           0 :         aKeyCode = KeyCode( aKeyCode.GetCode() == KEY_LEFT ? KEY_RIGHT : KEY_LEFT, aKeyCode.GetModifier() );
    1019             : 
    1020             :     // call handler
    1021           0 :     ImplDelData aDelData;
    1022           0 :     pChild->ImplAddDel( &aDelData );
    1023             : 
    1024           0 :     KeyEvent    aKeyEvt( (sal_Unicode)nCharCode, aKeyCode, nRepeat );
    1025           0 :     NotifyEvent aNotifyEvt( nSVEvent, pChild, &aKeyEvt );
    1026           0 :     bool bKeyPreNotify = ImplCallPreNotify( aNotifyEvt );
    1027           0 :     bool nRet = true;
    1028             : 
    1029           0 :     if ( !bKeyPreNotify && !aDelData.IsDead() )
    1030             :     {
    1031           0 :         if ( nSVEvent == EVENT_KEYINPUT )
    1032             :         {
    1033           0 :             pChild->ImplGetWindowImpl()->mbKeyInput = false;
    1034           0 :             pChild->KeyInput( aKeyEvt );
    1035             :         }
    1036             :         else
    1037             :         {
    1038           0 :             pChild->ImplGetWindowImpl()->mbKeyUp = false;
    1039           0 :             pChild->KeyUp( aKeyEvt );
    1040             :         }
    1041             :         // #82968#
    1042           0 :         if( !aDelData.IsDead() )
    1043           0 :             aNotifyEvt.GetWindow()->ImplNotifyKeyMouseCommandEventListeners( aNotifyEvt );
    1044             :     }
    1045             : 
    1046           0 :     if ( aDelData.IsDead() )
    1047           0 :         return true;
    1048             : 
    1049           0 :     pChild->ImplRemoveDel( &aDelData );
    1050             : 
    1051           0 :     if ( nSVEvent == EVENT_KEYINPUT )
    1052             :     {
    1053           0 :         if ( !bKeyPreNotify && pChild->ImplGetWindowImpl()->mbKeyInput )
    1054             :         {
    1055           0 :             sal_uInt16 nCode = aKeyCode.GetCode();
    1056             : 
    1057             :             // #101999# is focus in or below toolbox
    1058           0 :             bool bToolboxFocus=false;
    1059           0 :             if( (nCode == KEY_F1) && aKeyCode.IsShift() )
    1060             :             {
    1061           0 :                 Window *pWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
    1062           0 :                 while( pWin )
    1063             :                 {
    1064           0 :                     if( pWin->ImplGetWindowImpl()->mbToolBox )
    1065             :                     {
    1066           0 :                         bToolboxFocus = true;
    1067           0 :                         break;
    1068             :                     }
    1069             :                     else
    1070           0 :                         pWin = pWin->GetParent();
    1071             :                 }
    1072             :             }
    1073             : 
    1074             :             // ContextMenu
    1075           0 :             if ( (nCode == KEY_CONTEXTMENU) || ((nCode == KEY_F10) && aKeyCode.IsShift() && !aKeyCode.IsMod1() && !aKeyCode.IsMod2() ) )
    1076           0 :                 nRet = !ImplCallCommand( pChild, COMMAND_CONTEXTMENU, NULL, false );
    1077           0 :             else if ( ( (nCode == KEY_F2) && aKeyCode.IsShift() ) || ( (nCode == KEY_F1) && aKeyCode.IsMod1() ) ||
    1078             :                 // #101999# no active help when focus in toolbox, simulate BallonHelp instead
    1079           0 :                 ( (nCode == KEY_F1) && aKeyCode.IsShift() && bToolboxFocus ) )
    1080             :             {
    1081             :                 // TipHelp via Keyboard (Shift-F2 or Ctrl-F1)
    1082             :                 // simulate mouseposition at center of window
    1083             : 
    1084           0 :                 Size aSize = pChild->GetOutputSize();
    1085           0 :                 Point aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 );
    1086           0 :                 aPos = pChild->OutputToScreenPixel( aPos );
    1087             : 
    1088           0 :                 HelpEvent aHelpEvent( aPos, HELPMODE_BALLOON );
    1089           0 :                 aHelpEvent.SetKeyboardActivated( true );
    1090           0 :                 pSVData->maHelpData.mbSetKeyboardHelp = true;
    1091           0 :                 pChild->RequestHelp( aHelpEvent );
    1092           0 :                 pSVData->maHelpData.mbSetKeyboardHelp = false;
    1093             :             }
    1094           0 :             else if ( (nCode == KEY_F1) || (nCode == KEY_HELP) )
    1095             :             {
    1096           0 :                 if ( !aKeyCode.GetModifier() )
    1097             :                 {
    1098           0 :                     if ( pSVData->maHelpData.mbContextHelp )
    1099             :                     {
    1100           0 :                         Point       aMousePos = pChild->OutputToScreenPixel( pChild->GetPointerPosPixel() );
    1101           0 :                         HelpEvent   aHelpEvent( aMousePos, HELPMODE_CONTEXT );
    1102           0 :                         pChild->RequestHelp( aHelpEvent );
    1103             :                     }
    1104             :                     else
    1105           0 :                         nRet = false;
    1106             :                 }
    1107           0 :                 else if ( aKeyCode.IsShift() )
    1108             :                 {
    1109           0 :                     if ( pSVData->maHelpData.mbExtHelp )
    1110           0 :                         Help::StartExtHelp();
    1111             :                     else
    1112           0 :                         nRet = false;
    1113           0 :                 }
    1114             :             }
    1115             :             else
    1116             :             {
    1117           0 :                 if ( ImplCallHotKey( aKeyCode ) )
    1118           0 :                     nRet = true;
    1119             :                 else
    1120           0 :                     nRet = false;
    1121             :             }
    1122             :         }
    1123             :     }
    1124             :     else
    1125             :     {
    1126           0 :         if ( !bKeyPreNotify && pChild->ImplGetWindowImpl()->mbKeyUp )
    1127           0 :             nRet = false;
    1128             :     }
    1129             : 
    1130             :     // #105591# send keyinput to parent if we are a floating window and the key was not pocessed yet
    1131           0 :     if( !nRet && pWindow->ImplGetWindowImpl()->mbFloatWin && pWindow->GetParent() && (pWindow->ImplGetWindowImpl()->mpFrame != pWindow->GetParent()->ImplGetWindowImpl()->mpFrame) )
    1132             :     {
    1133           0 :         pChild = pWindow->GetParent();
    1134             : 
    1135             :         // call handler
    1136           0 :         ImplDelData aChildDelData( pChild );
    1137           0 :         KeyEvent    aKEvt( (sal_Unicode)nCharCode, aKeyCode, nRepeat );
    1138           0 :         NotifyEvent aNEvt( nSVEvent, pChild, &aKEvt );
    1139           0 :         bool bPreNotify = ImplCallPreNotify( aNEvt );
    1140           0 :         if ( aChildDelData.IsDead() )
    1141           0 :             return true;
    1142             : 
    1143           0 :         if ( !bPreNotify )
    1144             :         {
    1145           0 :             if ( nSVEvent == EVENT_KEYINPUT )
    1146             :             {
    1147           0 :                 pChild->ImplGetWindowImpl()->mbKeyInput = false;
    1148           0 :                 pChild->KeyInput( aKEvt );
    1149             :             }
    1150             :             else
    1151             :             {
    1152           0 :                 pChild->ImplGetWindowImpl()->mbKeyUp = false;
    1153           0 :                 pChild->KeyUp( aKEvt );
    1154             :             }
    1155             :             // #82968#
    1156           0 :             if( !aChildDelData.IsDead() )
    1157           0 :                 aNEvt.GetWindow()->ImplNotifyKeyMouseCommandEventListeners( aNEvt );
    1158           0 :             if ( aChildDelData.IsDead() )
    1159           0 :                 return true;
    1160             :         }
    1161             : 
    1162           0 :         if( bPreNotify || !pChild->ImplGetWindowImpl()->mbKeyInput )
    1163           0 :             nRet = true;
    1164             :     }
    1165             : 
    1166           0 :     return nRet;
    1167             : }
    1168             : 
    1169           0 : static bool ImplHandleExtTextInput( Window* pWindow,
    1170             :                                     const OUString& rText,
    1171             :                                     const sal_uInt16* pTextAttr,
    1172             :                                     sal_Int32 nCursorPos, sal_uInt16 nCursorFlags )
    1173             : {
    1174           0 :     ImplSVData* pSVData = ImplGetSVData();
    1175           0 :     Window*     pChild = NULL;
    1176             : 
    1177           0 :     int nTries = 200;
    1178           0 :     while( nTries-- )
    1179             :     {
    1180           0 :         pChild = pSVData->maWinData.mpExtTextInputWin;
    1181           0 :         if ( !pChild )
    1182             :         {
    1183           0 :             pChild = ImplGetKeyInputWindow( pWindow );
    1184           0 :             if ( !pChild )
    1185           0 :                 return false;
    1186             :         }
    1187           0 :         if( !pChild->ImplGetWindowImpl()->mpFrameData->mnFocusId )
    1188           0 :             break;
    1189           0 :         Application::Yield();
    1190             :     }
    1191             : 
    1192             :     // If it is the first ExtTextInput call, we inform the information
    1193             :     // and allocate the data, which we must store in this mode
    1194           0 :     ImplWinData* pWinData = pChild->ImplGetWinData();
    1195           0 :     if ( !pChild->ImplGetWindowImpl()->mbExtTextInput )
    1196             :     {
    1197           0 :         pChild->ImplGetWindowImpl()->mbExtTextInput = true;
    1198           0 :         pWinData->mpExtOldText = new OUString;
    1199           0 :         if ( pWinData->mpExtOldAttrAry )
    1200             :         {
    1201           0 :             delete [] pWinData->mpExtOldAttrAry;
    1202           0 :             pWinData->mpExtOldAttrAry = NULL;
    1203             :         }
    1204           0 :         pSVData->maWinData.mpExtTextInputWin = pChild;
    1205           0 :         ImplCallCommand( pChild, COMMAND_STARTEXTTEXTINPUT );
    1206             :     }
    1207             : 
    1208             :     // be aware of being recursively called in StartExtTextInput
    1209           0 :     if ( !pChild->ImplGetWindowImpl()->mbExtTextInput )
    1210           0 :         return false;
    1211             : 
    1212             :     // Test for changes
    1213           0 :     bool bOnlyCursor = false;
    1214           0 :     sal_Int32 nMinLen = std::min( pWinData->mpExtOldText->getLength(), rText.getLength() );
    1215           0 :     sal_Int32 nDeltaStart = 0;
    1216           0 :     while ( nDeltaStart < nMinLen )
    1217             :     {
    1218           0 :         if ( (*pWinData->mpExtOldText)[nDeltaStart] != rText[nDeltaStart] )
    1219           0 :             break;
    1220           0 :         nDeltaStart++;
    1221             :     }
    1222           0 :     if ( pWinData->mpExtOldAttrAry || pTextAttr )
    1223             :     {
    1224           0 :         if ( !pWinData->mpExtOldAttrAry || !pTextAttr )
    1225           0 :             nDeltaStart = 0;
    1226             :         else
    1227             :         {
    1228           0 :             sal_Int32 i = 0;
    1229           0 :             while ( i < nDeltaStart )
    1230             :             {
    1231           0 :                 if ( pWinData->mpExtOldAttrAry[i] != pTextAttr[i] )
    1232             :                 {
    1233           0 :                     nDeltaStart = i;
    1234           0 :                     break;
    1235             :                 }
    1236           0 :                 i++;
    1237             :             }
    1238             :         }
    1239             :     }
    1240           0 :     if ( (nDeltaStart >= nMinLen) &&
    1241           0 :          (pWinData->mpExtOldText->getLength() == rText.getLength()) )
    1242           0 :         bOnlyCursor = true;
    1243             : 
    1244             :     // Call Event and store the information
    1245             :     CommandExtTextInputData aData( rText, pTextAttr,
    1246             :                                    nCursorPos, nCursorFlags,
    1247           0 :                                    bOnlyCursor );
    1248           0 :     *pWinData->mpExtOldText = rText;
    1249           0 :     if ( pWinData->mpExtOldAttrAry )
    1250             :     {
    1251           0 :         delete [] pWinData->mpExtOldAttrAry;
    1252           0 :         pWinData->mpExtOldAttrAry = NULL;
    1253             :     }
    1254           0 :     if ( pTextAttr )
    1255             :     {
    1256           0 :         pWinData->mpExtOldAttrAry = new sal_uInt16[rText.getLength()];
    1257           0 :         memcpy( pWinData->mpExtOldAttrAry, pTextAttr, rText.getLength()*sizeof( sal_uInt16 ) );
    1258             :     }
    1259           0 :     return !ImplCallCommand( pChild, COMMAND_EXTTEXTINPUT, &aData );
    1260             : }
    1261             : 
    1262           0 : static bool ImplHandleEndExtTextInput( Window* /* pWindow */ )
    1263             : {
    1264           0 :     ImplSVData* pSVData = ImplGetSVData();
    1265           0 :     Window*     pChild = pSVData->maWinData.mpExtTextInputWin;
    1266           0 :     bool        nRet = false;
    1267             : 
    1268           0 :     if ( pChild )
    1269             :     {
    1270           0 :         pChild->ImplGetWindowImpl()->mbExtTextInput = false;
    1271           0 :         pSVData->maWinData.mpExtTextInputWin = NULL;
    1272           0 :         ImplWinData* pWinData = pChild->ImplGetWinData();
    1273           0 :         if ( pWinData->mpExtOldText )
    1274             :         {
    1275           0 :             delete pWinData->mpExtOldText;
    1276           0 :             pWinData->mpExtOldText = NULL;
    1277             :         }
    1278           0 :         if ( pWinData->mpExtOldAttrAry )
    1279             :         {
    1280           0 :             delete [] pWinData->mpExtOldAttrAry;
    1281           0 :             pWinData->mpExtOldAttrAry = NULL;
    1282             :         }
    1283           0 :         nRet = !ImplCallCommand( pChild, COMMAND_ENDEXTTEXTINPUT );
    1284             :     }
    1285             : 
    1286           0 :     return nRet;
    1287             : }
    1288             : 
    1289           0 : static void ImplHandleExtTextInputPos( Window* pWindow,
    1290             :                                        Rectangle& rRect, long& rInputWidth,
    1291             :                                        bool * pVertical )
    1292             : {
    1293           0 :     ImplSVData* pSVData = ImplGetSVData();
    1294           0 :     Window*     pChild = pSVData->maWinData.mpExtTextInputWin;
    1295             : 
    1296           0 :     if ( !pChild )
    1297           0 :         pChild = ImplGetKeyInputWindow( pWindow );
    1298             :     else
    1299             :     {
    1300             :         // Test, if the Window is related to the frame
    1301           0 :         if ( !pWindow->ImplIsWindowOrChild( pChild ) )
    1302           0 :             pChild = ImplGetKeyInputWindow( pWindow );
    1303             :     }
    1304             : 
    1305           0 :     if ( pChild )
    1306             :     {
    1307           0 :         const OutputDevice *pChildOutDev = pChild->GetOutDev();
    1308           0 :         ImplCallCommand( pChild, COMMAND_CURSORPOS );
    1309           0 :         const Rectangle* pRect = pChild->GetCursorRect();
    1310           0 :         if ( pRect )
    1311           0 :             rRect = pChildOutDev->ImplLogicToDevicePixel( *pRect );
    1312             :         else
    1313             :         {
    1314           0 :             Cursor* pCursor = pChild->GetCursor();
    1315           0 :             if ( pCursor )
    1316             :             {
    1317           0 :                 Point aPos = pChildOutDev->ImplLogicToDevicePixel( pCursor->GetPos() );
    1318           0 :                 Size aSize = pChild->LogicToPixel( pCursor->GetSize() );
    1319           0 :                 if ( !aSize.Width() )
    1320           0 :                     aSize.Width() = pChild->GetSettings().GetStyleSettings().GetCursorSize();
    1321           0 :                 rRect = Rectangle( aPos, aSize );
    1322             :             }
    1323             :             else
    1324           0 :                 rRect = Rectangle( Point( pChild->GetOutOffXPixel(), pChild->GetOutOffYPixel() ), Size() );
    1325             :         }
    1326           0 :         rInputWidth = pChild->ImplLogicWidthToDevicePixel( pChild->GetCursorExtTextInputWidth() );
    1327           0 :         if ( !rInputWidth )
    1328           0 :             rInputWidth = rRect.GetWidth();
    1329             :     }
    1330           0 :     if (pVertical != 0)
    1331             :         *pVertical
    1332           0 :             = pChild != 0 && pChild->GetInputContext().GetFont().IsVertical();
    1333           0 : }
    1334             : 
    1335           0 : static bool ImplHandleInputContextChange( Window* pWindow, LanguageType eNewLang )
    1336             : {
    1337           0 :     Window* pChild = ImplGetKeyInputWindow( pWindow );
    1338           0 :     CommandInputContextData aData( eNewLang );
    1339           0 :     return !ImplCallCommand( pChild, COMMAND_INPUTCONTEXTCHANGE, &aData );
    1340             : }
    1341             : 
    1342           0 : static bool ImplCallWheelCommand( Window* pWindow, const Point& rPos,
    1343             :                                   const CommandWheelData* pWheelData )
    1344             : {
    1345           0 :     Point               aCmdMousePos = pWindow->ImplFrameToOutput( rPos );
    1346           0 :     CommandEvent        aCEvt( aCmdMousePos, COMMAND_WHEEL, true, pWheelData );
    1347           0 :     NotifyEvent         aNCmdEvt( EVENT_COMMAND, pWindow, &aCEvt );
    1348           0 :     ImplDelData         aDelData( pWindow );
    1349           0 :     bool bPreNotify = ImplCallPreNotify( aNCmdEvt );
    1350           0 :     if ( aDelData.IsDead() )
    1351           0 :         return false;
    1352           0 :     if ( !bPreNotify )
    1353             :     {
    1354           0 :         pWindow->ImplGetWindowImpl()->mbCommand = false;
    1355           0 :         pWindow->Command( aCEvt );
    1356           0 :         if ( aDelData.IsDead() )
    1357           0 :             return false;
    1358           0 :         if ( pWindow->ImplGetWindowImpl()->mbCommand )
    1359           0 :             return true;
    1360             :     }
    1361           0 :     return false;
    1362             : }
    1363             : 
    1364           0 : static bool ImplHandleWheelEvent( Window* pWindow, const SalWheelMouseEvent& rEvt, bool scaleDirectly = false )
    1365             : {
    1366           0 :     ImplDelData aDogTag( pWindow );
    1367             : 
    1368           0 :     ImplSVData* pSVData = ImplGetSVData();
    1369           0 :     if ( pSVData->maWinData.mpAutoScrollWin )
    1370           0 :         pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
    1371           0 :     if ( pSVData->maHelpData.mpHelpWin )
    1372           0 :         ImplDestroyHelpWindow( true );
    1373           0 :     if( aDogTag.IsDead() )
    1374           0 :         return false;
    1375             : 
    1376             :     sal_uInt16 nMode;
    1377           0 :     sal_uInt16 nCode = rEvt.mnCode;
    1378           0 :     bool bHorz = rEvt.mbHorz;
    1379           0 :     bool bPixel = rEvt.mbDeltaIsPixel;
    1380           0 :     if ( scaleDirectly )
    1381           0 :         nMode = COMMAND_WHEEL_ZOOM_SCALE;
    1382           0 :     else if ( nCode & KEY_MOD1 )
    1383           0 :         nMode = COMMAND_WHEEL_ZOOM;
    1384           0 :     else if ( nCode & KEY_MOD2 )
    1385           0 :         nMode = COMMAND_WHEEL_DATAZOOM;
    1386             :     else
    1387             :     {
    1388           0 :         nMode = COMMAND_WHEEL_SCROLL;
    1389             :         // #i85450# interpret shift-wheel as horizontal wheel action
    1390           0 :         if( (nCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)) == KEY_SHIFT )
    1391           0 :             bHorz = true;
    1392             :     }
    1393             : 
    1394           0 :     CommandWheelData    aWheelData( rEvt.mnDelta, rEvt.mnNotchDelta, rEvt.mnScrollLines, nMode, nCode, bHorz, bPixel );
    1395           0 :     Point               aMousePos( rEvt.mnX, rEvt.mnY );
    1396           0 :     bool                bRet = true;
    1397             : 
    1398             :     // first check any floating window ( eg. drop down listboxes)
    1399           0 :     bool bIsFloat = false;
    1400           0 :     Window *pMouseWindow = NULL;
    1401           0 :     if ( pSVData->maWinData.mpFirstFloat && !pSVData->maWinData.mpCaptureWin &&
    1402           0 :          !pSVData->maWinData.mpFirstFloat->ImplIsFloatPopupModeWindow( pWindow ) )
    1403             :     {
    1404           0 :         sal_uInt16 nHitTest = IMPL_FLOATWIN_HITTEST_OUTSIDE;
    1405           0 :         pMouseWindow = pSVData->maWinData.mpFirstFloat->ImplFloatHitTest( pWindow, aMousePos, nHitTest );
    1406             :     }
    1407             :     // then try the window directly beneath the mouse
    1408           0 :     if( !pMouseWindow )
    1409           0 :         pMouseWindow = pWindow->ImplFindWindow( aMousePos );
    1410             :     else
    1411             :     {
    1412             :         // transform coordinates to float window frame coordinates
    1413             :         pMouseWindow = pMouseWindow->ImplFindWindow(
    1414             :                  pMouseWindow->OutputToScreenPixel(
    1415             :                   pMouseWindow->AbsoluteScreenToOutputPixel(
    1416             :                    pWindow->OutputToAbsoluteScreenPixel(
    1417           0 :                     pWindow->ScreenToOutputPixel( aMousePos ) ) ) ) );
    1418           0 :         bIsFloat = true;
    1419             :     }
    1420             : 
    1421           0 :     if ( pMouseWindow &&
    1422           0 :          pMouseWindow->IsEnabled() && pMouseWindow->IsInputEnabled() && ! pMouseWindow->IsInModalMode() )
    1423             :     {
    1424             :         // transform coordinates to float window frame coordinates
    1425             :         Point aRelMousePos( pMouseWindow->OutputToScreenPixel(
    1426             :                              pMouseWindow->AbsoluteScreenToOutputPixel(
    1427             :                               pWindow->OutputToAbsoluteScreenPixel(
    1428           0 :                                pWindow->ScreenToOutputPixel( aMousePos ) ) ) ) );
    1429           0 :         bRet = ImplCallWheelCommand( pMouseWindow, aRelMousePos, &aWheelData );
    1430             :     }
    1431             : 
    1432             :     // if the command was not handled try the focus window
    1433           0 :     if ( bRet )
    1434             :     {
    1435           0 :         Window* pFocusWindow = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
    1436           0 :         if ( pFocusWindow && (pFocusWindow != pMouseWindow) &&
    1437           0 :              (pFocusWindow == pSVData->maWinData.mpFocusWin) )
    1438             :         {
    1439             :             // no wheel-messages to disabled windows
    1440           0 :             if ( pFocusWindow->IsEnabled() && pFocusWindow->IsInputEnabled() && ! pFocusWindow->IsInModalMode() )
    1441             :             {
    1442             :                 // transform coordinates to focus window frame coordinates
    1443             :                 Point aRelMousePos( pFocusWindow->OutputToScreenPixel(
    1444             :                                      pFocusWindow->AbsoluteScreenToOutputPixel(
    1445             :                                       pWindow->OutputToAbsoluteScreenPixel(
    1446           0 :                                        pWindow->ScreenToOutputPixel( aMousePos ) ) ) ) );
    1447           0 :                 bRet = ImplCallWheelCommand( pFocusWindow, aRelMousePos, &aWheelData );
    1448             :             }
    1449             :         }
    1450             :     }
    1451             : 
    1452             :     // close floaters
    1453           0 :     if( ! bIsFloat && pSVData->maWinData.mpFirstFloat )
    1454             :     {
    1455           0 :         FloatingWindow* pLastLevelFloat = pSVData->maWinData.mpFirstFloat->ImplFindLastLevelFloat();
    1456           0 :         if( pLastLevelFloat )
    1457             :         {
    1458           0 :             sal_uLong nPopupFlags = pLastLevelFloat->GetPopupModeFlags();
    1459           0 :             if ( nPopupFlags & FLOATWIN_POPUPMODE_ALLMOUSEBUTTONCLOSE )
    1460             :             {
    1461           0 :                 pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
    1462             :             }
    1463             :         }
    1464             :     }
    1465             : 
    1466           0 :     return !bRet;
    1467             : }
    1468             : 
    1469             : #define IMPL_PAINT_CHECKRTL         ((sal_uInt16)0x0020)
    1470             : 
    1471           0 : static void ImplHandlePaint( Window* pWindow, const Rectangle& rBoundRect, bool bImmediateUpdate )
    1472             : {
    1473             :     // give up background save when sytem paints arrive
    1474           0 :     Window* pSaveBackWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFirstBackWin;
    1475           0 :     while ( pSaveBackWin )
    1476             :     {
    1477           0 :         Window* pNext = pSaveBackWin->ImplGetWindowImpl()->mpOverlapData->mpNextBackWin;
    1478             :         Rectangle aRect( Point( pSaveBackWin->GetOutOffXPixel(), pSaveBackWin->GetOutOffYPixel() ),
    1479           0 :                          Size( pSaveBackWin->GetOutputWidthPixel(), pSaveBackWin->GetOutputHeightPixel() ) );
    1480           0 :         if ( aRect.IsOver( rBoundRect ) )
    1481           0 :             pSaveBackWin->ImplDeleteOverlapBackground();
    1482           0 :         pSaveBackWin = pNext;
    1483             :     }
    1484             : 
    1485             :     // system paint events must be checked for re-mirroring
    1486           0 :     pWindow->ImplGetWindowImpl()->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
    1487             : 
    1488             :     // trigger paint for all windows that live in the new paint region
    1489           0 :     Region aRegion( rBoundRect );
    1490           0 :     pWindow->ImplInvalidateOverlapFrameRegion( aRegion );
    1491           0 :     if( bImmediateUpdate )
    1492             :     {
    1493             :         // #i87663# trigger possible pending resize notifications
    1494             :         // (GetSizePixel does that for us)
    1495           0 :         pWindow->GetSizePixel();
    1496             :         // force drawing inmmediately
    1497           0 :         pWindow->Update();
    1498           0 :     }
    1499           0 : }
    1500             : 
    1501           0 : static void KillOwnPopups( Window* pWindow )
    1502             : {
    1503           0 :     ImplSVData* pSVData = ImplGetSVData();
    1504           0 :     Window *pParent = pWindow->ImplGetWindowImpl()->mpFrameWindow;
    1505           0 :     Window *pChild = pSVData->maWinData.mpFirstFloat;
    1506           0 :     if ( pChild && pParent->ImplIsWindowOrChild( pChild, true ) )
    1507             :     {
    1508           0 :         if ( !(pSVData->maWinData.mpFirstFloat->GetPopupModeFlags() & FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE) )
    1509           0 :             pSVData->maWinData.mpFirstFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
    1510             :     }
    1511           0 : }
    1512             : 
    1513           0 : void ImplHandleResize( Window* pWindow, long nNewWidth, long nNewHeight )
    1514             : {
    1515           0 :     if( pWindow->GetStyle() & (WB_MOVEABLE|WB_SIZEABLE) )
    1516             :     {
    1517           0 :         KillOwnPopups( pWindow );
    1518           0 :         if( pWindow->ImplGetWindow() != ImplGetSVData()->maHelpData.mpHelpWin )
    1519           0 :             ImplDestroyHelpWindow( true );
    1520             :     }
    1521             : 
    1522           0 :     if (
    1523           0 :          (nNewWidth > 0 && nNewHeight > 0) ||
    1524           0 :          pWindow->ImplGetWindow()->ImplGetWindowImpl()->mbAllResize
    1525             :        )
    1526             :     {
    1527           0 :         if ( (nNewWidth != pWindow->GetOutputWidthPixel()) || (nNewHeight != pWindow->GetOutputHeightPixel()) )
    1528             :         {
    1529           0 :             pWindow->mnOutWidth  = nNewWidth;
    1530           0 :             pWindow->mnOutHeight = nNewHeight;
    1531           0 :             pWindow->ImplGetWindowImpl()->mbWaitSystemResize = false;
    1532           0 :             if ( pWindow->IsReallyVisible() )
    1533           0 :                 pWindow->ImplSetClipFlag();
    1534           0 :             if ( pWindow->IsVisible() || pWindow->ImplGetWindow()->ImplGetWindowImpl()->mbAllResize ||
    1535           0 :                 ( pWindow->ImplGetWindowImpl()->mbFrame && pWindow->ImplGetWindowImpl()->mpClientWindow ) )   // propagate resize for system border windows
    1536             :             {
    1537           0 :                 bool bStartTimer = true;
    1538             :                 // use resize buffering for user resizes
    1539             :                 // ownerdraw decorated windows and floating windows can be resized immediately (i.e. synchronously)
    1540           0 :                 if( pWindow->ImplGetWindowImpl()->mbFrame && (pWindow->GetStyle() & WB_SIZEABLE)
    1541           0 :                     && !(pWindow->GetStyle() & WB_OWNERDRAWDECORATION)  // synchronous resize for ownerdraw decorated windows (toolbars)
    1542           0 :                     && !pWindow->ImplGetWindowImpl()->mbFloatWin )             // synchronous resize for floating windows, #i43799#
    1543             :                 {
    1544           0 :                     if( pWindow->ImplGetWindowImpl()->mpClientWindow )
    1545             :                     {
    1546             :                         // #i42750# presentation wants to be informed about resize
    1547             :                         // as early as possible
    1548           0 :                         WorkWindow* pWorkWindow = dynamic_cast<WorkWindow*>(pWindow->ImplGetWindowImpl()->mpClientWindow);
    1549           0 :                         if( ! pWorkWindow || pWorkWindow->IsPresentationMode() )
    1550           0 :                             bStartTimer = false;
    1551             :                     }
    1552             :                     else
    1553             :                     {
    1554           0 :                         WorkWindow* pWorkWindow = dynamic_cast<WorkWindow*>(pWindow);
    1555           0 :                         if( ! pWorkWindow || pWorkWindow->IsPresentationMode() )
    1556           0 :                             bStartTimer = false;
    1557             :                     }
    1558             :                 }
    1559             :                 else
    1560           0 :                     bStartTimer = false;
    1561             : 
    1562           0 :                 if( bStartTimer )
    1563           0 :                     pWindow->ImplGetWindowImpl()->mpFrameData->maResizeTimer.Start();
    1564             :                 else
    1565           0 :                     pWindow->ImplCallResize(); // otherwise menus cannot be positioned
    1566             :             }
    1567             :             else
    1568           0 :                 pWindow->ImplGetWindowImpl()->mbCallResize = true;
    1569             :         }
    1570             :     }
    1571             : 
    1572           0 :     pWindow->ImplGetWindowImpl()->mpFrameData->mbNeedSysWindow = (nNewWidth < IMPL_MIN_NEEDSYSWIN) ||
    1573           0 :                                             (nNewHeight < IMPL_MIN_NEEDSYSWIN);
    1574           0 :     bool bMinimized = (nNewWidth <= 0) || (nNewHeight <= 0);
    1575           0 :     if( bMinimized != pWindow->ImplGetWindowImpl()->mpFrameData->mbMinimized )
    1576           0 :         pWindow->ImplGetWindowImpl()->mpFrameWindow->ImplNotifyIconifiedState( bMinimized );
    1577           0 :     pWindow->ImplGetWindowImpl()->mpFrameData->mbMinimized = bMinimized;
    1578           0 : }
    1579             : 
    1580           0 : static void ImplHandleMove( Window* pWindow )
    1581             : {
    1582           0 :     if( pWindow->ImplGetWindowImpl()->mbFrame && pWindow->ImplIsFloatingWindow() && pWindow->IsReallyVisible() )
    1583             :     {
    1584           0 :         static_cast<FloatingWindow*>(pWindow)->EndPopupMode( FLOATWIN_POPUPMODEEND_TEAROFF );
    1585           0 :         pWindow->ImplCallMove();
    1586             :     }
    1587             : 
    1588           0 :     if( pWindow->GetStyle() & (WB_MOVEABLE|WB_SIZEABLE) )
    1589             :     {
    1590           0 :         KillOwnPopups( pWindow );
    1591           0 :         if( pWindow->ImplGetWindow() != ImplGetSVData()->maHelpData.mpHelpWin )
    1592           0 :             ImplDestroyHelpWindow( true );
    1593             :     }
    1594             : 
    1595           0 :     if ( pWindow->IsVisible() )
    1596           0 :         pWindow->ImplCallMove();
    1597             :     else
    1598           0 :         pWindow->ImplGetWindowImpl()->mbCallMove = true; // make sure the framepos will be updated on the next Show()
    1599             : 
    1600           0 :     if ( pWindow->ImplGetWindowImpl()->mbFrame && pWindow->ImplGetWindowImpl()->mpClientWindow )
    1601           0 :         pWindow->ImplGetWindowImpl()->mpClientWindow->ImplCallMove();   // notify client to update geometry
    1602             : 
    1603           0 : }
    1604             : 
    1605           0 : static void ImplHandleMoveResize( Window* pWindow, long nNewWidth, long nNewHeight )
    1606             : {
    1607           0 :     ImplHandleMove( pWindow );
    1608           0 :     ImplHandleResize( pWindow, nNewWidth, nNewHeight );
    1609           0 : }
    1610             : 
    1611           0 : static void ImplActivateFloatingWindows( Window* pWindow, bool bActive )
    1612             : {
    1613             :     // First check all overlapping windows
    1614           0 :     Window* pTempWindow = pWindow->ImplGetWindowImpl()->mpFirstOverlap;
    1615           0 :     while ( pTempWindow )
    1616             :     {
    1617           0 :         if ( !pTempWindow->GetActivateMode() )
    1618             :         {
    1619           0 :             if ( (pTempWindow->GetType() == WINDOW_BORDERWINDOW) &&
    1620           0 :                  (pTempWindow->ImplGetWindow()->GetType() == WINDOW_FLOATINGWINDOW) )
    1621           0 :                 ((ImplBorderWindow*)pTempWindow)->SetDisplayActive( bActive );
    1622             :         }
    1623             : 
    1624           0 :         ImplActivateFloatingWindows( pTempWindow, bActive );
    1625           0 :         pTempWindow = pTempWindow->ImplGetWindowImpl()->mpNext;
    1626             :     }
    1627           0 : }
    1628             : 
    1629           0 : IMPL_LINK_NOARG(Window, ImplAsyncFocusHdl)
    1630             : {
    1631           0 :     ImplGetWindowImpl()->mpFrameData->mnFocusId = 0;
    1632             : 
    1633             :     // If the status has been preserved, because we got back the focus
    1634             :     // in the meantime, we do nothing
    1635           0 :     bool bHasFocus = ImplGetWindowImpl()->mpFrameData->mbHasFocus || ImplGetWindowImpl()->mpFrameData->mbSysObjFocus;
    1636             : 
    1637             :     // next execute the delayed functions
    1638           0 :     if ( bHasFocus )
    1639             :     {
    1640             :         // redraw all floating windows inactive
    1641           0 :         if ( ImplGetWindowImpl()->mpFrameData->mbStartFocusState != bHasFocus )
    1642           0 :             ImplActivateFloatingWindows( this, bHasFocus );
    1643             : 
    1644           0 :         if ( ImplGetWindowImpl()->mpFrameData->mpFocusWin )
    1645             :         {
    1646           0 :             bool bHandled = false;
    1647           0 :             if ( ImplGetWindowImpl()->mpFrameData->mpFocusWin->IsInputEnabled() &&
    1648           0 :                  ! ImplGetWindowImpl()->mpFrameData->mpFocusWin->IsInModalMode() )
    1649             :             {
    1650           0 :                 if ( ImplGetWindowImpl()->mpFrameData->mpFocusWin->IsEnabled() )
    1651             :                 {
    1652           0 :                     ImplGetWindowImpl()->mpFrameData->mpFocusWin->GrabFocus();
    1653           0 :                     bHandled = true;
    1654             :                 }
    1655           0 :                 else if( ImplGetWindowImpl()->mpFrameData->mpFocusWin->ImplHasDlgCtrl() )
    1656             :                 {
    1657             :                 // #109094# if the focus is restored to a disabled dialog control (was disabled meanwhile)
    1658             :                 // try to move it to the next control
    1659           0 :                     ImplGetWindowImpl()->mpFrameData->mpFocusWin->ImplDlgCtrlNextWindow();
    1660           0 :                     bHandled = true;
    1661             :                 }
    1662             :             }
    1663           0 :             if ( !bHandled )
    1664             :             {
    1665           0 :                 ImplSVData* pSVData = ImplGetSVData();
    1666           0 :                 Window*     pTopLevelWindow = ImplGetWindowImpl()->mpFrameData->mpFocusWin->ImplGetFirstOverlapWindow();
    1667           0 :                 if ( ( ! pTopLevelWindow->IsInputEnabled() || pTopLevelWindow->IsInModalMode() )
    1668           0 :                      && pSVData->maWinData.mpLastExecuteDlg )
    1669           0 :                     pSVData->maWinData.mpLastExecuteDlg->ToTop( TOTOP_RESTOREWHENMIN | TOTOP_GRABFOCUSONLY);
    1670             :                 else
    1671           0 :                     pTopLevelWindow->GrabFocus();
    1672             :             }
    1673             :         }
    1674             :         else
    1675           0 :             GrabFocus();
    1676             :     }
    1677             :     else
    1678             :     {
    1679           0 :         Window* pFocusWin = ImplGetWindowImpl()->mpFrameData->mpFocusWin;
    1680           0 :         if ( pFocusWin )
    1681             :         {
    1682           0 :             ImplSVData* pSVData = ImplGetSVData();
    1683             : 
    1684           0 :             if ( pSVData->maWinData.mpFocusWin == pFocusWin )
    1685             :             {
    1686             :                 // FocusWindow umsetzen
    1687           0 :                 Window* pOverlapWindow = pFocusWin->ImplGetFirstOverlapWindow();
    1688           0 :                 pOverlapWindow->ImplGetWindowImpl()->mpLastFocusWindow = pFocusWin;
    1689           0 :                 pSVData->maWinData.mpFocusWin = NULL;
    1690             : 
    1691           0 :                 if ( pFocusWin->ImplGetWindowImpl()->mpCursor )
    1692           0 :                     pFocusWin->ImplGetWindowImpl()->mpCursor->ImplHide( true );
    1693             : 
    1694             :                 // Deaktivate rufen
    1695           0 :                 Window* pOldFocusWindow = pFocusWin;
    1696           0 :                 if ( pOldFocusWindow )
    1697             :                 {
    1698           0 :                     Window* pOldOverlapWindow = pOldFocusWindow->ImplGetFirstOverlapWindow();
    1699           0 :                     Window* pOldRealWindow = pOldOverlapWindow->ImplGetWindow();
    1700             : 
    1701           0 :                     pOldOverlapWindow->ImplGetWindowImpl()->mbActive = false;
    1702           0 :                     pOldOverlapWindow->Deactivate();
    1703           0 :                     if ( pOldRealWindow != pOldOverlapWindow )
    1704             :                     {
    1705           0 :                         pOldRealWindow->ImplGetWindowImpl()->mbActive = false;
    1706           0 :                         pOldRealWindow->Deactivate();
    1707             :                     }
    1708             :                 }
    1709             : 
    1710             :                 // TrackingMode is ended in ImplHandleLoseFocus
    1711             :                 // To avoid problems with the Unix IME
    1712             :                 // pFocusWin->EndExtTextInput( EXTTEXTINPUT_END_COMPLETE );
    1713             : 
    1714             :                 // XXX #102010# hack for accessibility: do not close the menu,
    1715             :                 // even after focus lost
    1716           0 :                 static const char* pEnv = getenv("SAL_FLOATWIN_NOAPPFOCUSCLOSE");
    1717           0 :                 if( !(pEnv && *pEnv) )
    1718             :                 {
    1719           0 :                     NotifyEvent aNEvt( EVENT_LOSEFOCUS, pFocusWin );
    1720           0 :                     if ( !ImplCallPreNotify( aNEvt ) )
    1721           0 :                         pFocusWin->LoseFocus();
    1722           0 :                     pFocusWin->ImplCallDeactivateListeners( NULL );
    1723           0 :                     GetpApp()->FocusChanged();
    1724             :                 }
    1725             :                 // XXX
    1726             :             }
    1727             :         }
    1728             : 
    1729             :         // Redraw all floating window inactive
    1730           0 :         if ( ImplGetWindowImpl()->mpFrameData->mbStartFocusState != bHasFocus )
    1731           0 :             ImplActivateFloatingWindows( this, bHasFocus );
    1732             :     }
    1733             : 
    1734           0 :     return 0;
    1735             : }
    1736             : 
    1737           0 : static void ImplHandleGetFocus( Window* pWindow )
    1738             : {
    1739           0 :     pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus = true;
    1740             : 
    1741             :     // execute Focus-Events after a delay, such that SystemChildWindows
    1742             :     // do not blink when they receive focus
    1743           0 :     if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId )
    1744             :     {
    1745           0 :         pWindow->ImplGetWindowImpl()->mpFrameData->mbStartFocusState = !pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus;
    1746           0 :         Application::PostUserEvent( pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId, LINK( pWindow, Window, ImplAsyncFocusHdl ) );
    1747           0 :         Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
    1748           0 :         if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor )
    1749           0 :             pFocusWin->ImplGetWindowImpl()->mpCursor->ImplShow();
    1750             :     }
    1751           0 : }
    1752             : 
    1753           0 : static void ImplHandleLoseFocus( Window* pWindow )
    1754             : {
    1755           0 :     ImplSVData* pSVData = ImplGetSVData();
    1756             : 
    1757             :     // Abort the autoscroll if the frame loses focus
    1758           0 :     if ( pSVData->maWinData.mpAutoScrollWin )
    1759           0 :         pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
    1760             : 
    1761             :     // Abort tracking if the frame loses focus
    1762           0 :     if ( pSVData->maWinData.mpTrackWin )
    1763             :     {
    1764           0 :         if ( pSVData->maWinData.mpTrackWin->ImplGetWindowImpl()->mpFrameWindow == pWindow )
    1765           0 :             pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
    1766             :     }
    1767             : 
    1768             :     // here we always terminate the popupmode, also when NOFOCUSCLOSE
    1769             :     // is set, such that we do not show windows during the switch
    1770           0 :     if ( pSVData->maWinData.mpFirstFloat )
    1771             :     {
    1772           0 :         if ( !(pSVData->maWinData.mpFirstFloat->GetPopupModeFlags() & FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE) )
    1773           0 :             pSVData->maWinData.mpFirstFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
    1774             :     }
    1775             : 
    1776           0 :     pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus = false;
    1777             : 
    1778             :     // execute Focus-Events after a delay, such that SystemChildWindows
    1779             :     // do not flicker when they receive focus
    1780           0 :     if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId )
    1781             :     {
    1782           0 :         pWindow->ImplGetWindowImpl()->mpFrameData->mbStartFocusState = !pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus;
    1783           0 :         Application::PostUserEvent( pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId, LINK( pWindow, Window, ImplAsyncFocusHdl ) );
    1784             :     }
    1785             : 
    1786           0 :     Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
    1787           0 :     if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor )
    1788           0 :         pFocusWin->ImplGetWindowImpl()->mpCursor->ImplHide( true );
    1789           0 : }
    1790             : 
    1791           0 : struct DelayedCloseEvent
    1792             : {
    1793             :     Window*         pWindow;
    1794             :     ImplDelData     aDelData;
    1795             : };
    1796             : 
    1797           0 : static long DelayedCloseEventLink( void* pCEvent, void* )
    1798             : {
    1799           0 :     DelayedCloseEvent* pEv = (DelayedCloseEvent*)pCEvent;
    1800             : 
    1801           0 :     if( ! pEv->aDelData.IsDead() )
    1802             :     {
    1803           0 :         pEv->pWindow->ImplRemoveDel( &pEv->aDelData );
    1804             :         // dispatch to correct window type
    1805           0 :         if( pEv->pWindow->IsSystemWindow() )
    1806           0 :             ((SystemWindow*)pEv->pWindow)->Close();
    1807           0 :         else if( pEv->pWindow->ImplIsDockingWindow() )
    1808           0 :             ((DockingWindow*)pEv->pWindow)->Close();
    1809             :     }
    1810           0 :     delete pEv;
    1811             : 
    1812           0 :     return 0;
    1813             : }
    1814             : 
    1815           0 : void ImplHandleClose( Window* pWindow )
    1816             : {
    1817           0 :     ImplSVData* pSVData = ImplGetSVData();
    1818             : 
    1819           0 :     bool bWasPopup = false;
    1820           0 :     if( pWindow->ImplIsFloatingWindow() &&
    1821           0 :         static_cast<FloatingWindow*>(pWindow)->ImplIsInPrivatePopupMode() )
    1822             :     {
    1823           0 :         bWasPopup = true;
    1824             :     }
    1825             : 
    1826             :     // on Close stop all floating modes and end popups
    1827           0 :     if ( pSVData->maWinData.mpFirstFloat )
    1828             :     {
    1829             :         FloatingWindow* pLastLevelFloat;
    1830           0 :         pLastLevelFloat = pSVData->maWinData.mpFirstFloat->ImplFindLastLevelFloat();
    1831           0 :         pLastLevelFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
    1832             :     }
    1833           0 :     if ( pSVData->maHelpData.mbExtHelpMode )
    1834           0 :         Help::EndExtHelp();
    1835           0 :     if ( pSVData->maHelpData.mpHelpWin )
    1836           0 :         ImplDestroyHelpWindow( false );
    1837             :     // AutoScrollMode
    1838           0 :     if ( pSVData->maWinData.mpAutoScrollWin )
    1839           0 :         pSVData->maWinData.mpAutoScrollWin->EndAutoScroll();
    1840             : 
    1841           0 :     if ( pSVData->maWinData.mpTrackWin )
    1842           0 :         pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL | ENDTRACK_KEY );
    1843             : 
    1844           0 :     if (bWasPopup)
    1845           0 :         return;
    1846             : 
    1847           0 :     Window *pWin = pWindow->ImplGetWindow();
    1848           0 :     SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(pWin);
    1849           0 :     if (pSysWin)
    1850             :     {
    1851             :         // See if the custom close handler is set.
    1852           0 :         const Link& rLink = pSysWin->GetCloseHdl();
    1853           0 :         if (rLink.IsSet())
    1854             :         {
    1855           0 :             rLink.Call(pSysWin);
    1856           0 :             return;
    1857             :         }
    1858             :     }
    1859             : 
    1860             :     // check whether close is allowed
    1861           0 :     if ( pWin->IsEnabled() && pWin->IsInputEnabled() && !pWin->IsInModalMode() )
    1862             :     {
    1863           0 :         DelayedCloseEvent* pEv = new DelayedCloseEvent;
    1864           0 :         pEv->pWindow = pWin;
    1865           0 :         pWin->ImplAddDel( &pEv->aDelData );
    1866           0 :         Application::PostUserEvent( Link( pEv, DelayedCloseEventLink ) );
    1867             :     }
    1868             : }
    1869             : 
    1870           0 : static void ImplHandleUserEvent( ImplSVEvent* pSVEvent )
    1871             : {
    1872           0 :     if ( pSVEvent )
    1873             :     {
    1874           0 :         if ( pSVEvent->mbCall && !pSVEvent->maDelData.IsDead() )
    1875             :         {
    1876           0 :             if ( pSVEvent->mpWindow )
    1877             :             {
    1878           0 :                 pSVEvent->mpWindow->ImplRemoveDel( &(pSVEvent->maDelData) );
    1879           0 :                 if ( pSVEvent->mpLink )
    1880           0 :                     pSVEvent->mpLink->Call( pSVEvent->mpData );
    1881             :                 else
    1882           0 :                     pSVEvent->mpWindow->UserEvent( pSVEvent->mnEvent, pSVEvent->mpData );
    1883             :             }
    1884             :             else
    1885             :             {
    1886           0 :                 if ( pSVEvent->mpLink )
    1887           0 :                     pSVEvent->mpLink->Call( pSVEvent->mpData );
    1888             :                 else
    1889           0 :                     GetpApp()->UserEvent( pSVEvent->mnEvent, pSVEvent->mpData );
    1890             :             }
    1891             :         }
    1892             : 
    1893           0 :         delete pSVEvent->mpLink;
    1894           0 :         delete pSVEvent;
    1895             :     }
    1896           0 : }
    1897             : 
    1898           0 : static sal_uInt16 ImplGetMouseMoveMode( SalMouseEvent* pEvent )
    1899             : {
    1900           0 :     sal_uInt16 nMode = 0;
    1901           0 :     if ( !pEvent->mnCode )
    1902           0 :         nMode |= MOUSE_SIMPLEMOVE;
    1903           0 :     if ( (pEvent->mnCode & MOUSE_LEFT) && !(pEvent->mnCode & KEY_MOD1) )
    1904           0 :         nMode |= MOUSE_DRAGMOVE;
    1905           0 :     if ( (pEvent->mnCode & MOUSE_LEFT) && (pEvent->mnCode & KEY_MOD1) )
    1906           0 :         nMode |= MOUSE_DRAGCOPY;
    1907           0 :     return nMode;
    1908             : }
    1909             : 
    1910           0 : static sal_uInt16 ImplGetMouseButtonMode( SalMouseEvent* pEvent )
    1911             : {
    1912           0 :     sal_uInt16 nMode = 0;
    1913           0 :     if ( pEvent->mnButton == MOUSE_LEFT )
    1914           0 :         nMode |= MOUSE_SIMPLECLICK;
    1915           0 :     if ( (pEvent->mnButton == MOUSE_LEFT) && !(pEvent->mnCode & (MOUSE_MIDDLE | MOUSE_RIGHT)) )
    1916           0 :         nMode |= MOUSE_SELECT;
    1917           0 :     if ( (pEvent->mnButton == MOUSE_LEFT) && (pEvent->mnCode & KEY_MOD1) &&
    1918           0 :          !(pEvent->mnCode & (MOUSE_MIDDLE | MOUSE_RIGHT | KEY_SHIFT)) )
    1919           0 :         nMode |= MOUSE_MULTISELECT;
    1920           0 :     if ( (pEvent->mnButton == MOUSE_LEFT) && (pEvent->mnCode & KEY_SHIFT) &&
    1921           0 :          !(pEvent->mnCode & (MOUSE_MIDDLE | MOUSE_RIGHT | KEY_MOD1)) )
    1922           0 :         nMode |= MOUSE_RANGESELECT;
    1923           0 :     return nMode;
    1924             : }
    1925             : 
    1926           0 : inline bool ImplHandleSalMouseLeave( Window* pWindow, SalMouseEvent* pEvent )
    1927             : {
    1928             :     return ImplHandleMouseEvent( pWindow, EVENT_MOUSEMOVE, true,
    1929             :                                  pEvent->mnX, pEvent->mnY,
    1930             :                                  pEvent->mnTime, pEvent->mnCode,
    1931           0 :                                  ImplGetMouseMoveMode( pEvent ) );
    1932             : }
    1933             : 
    1934           0 : inline bool ImplHandleSalMouseMove( Window* pWindow, SalMouseEvent* pEvent )
    1935             : {
    1936             :     return ImplHandleMouseEvent( pWindow, EVENT_MOUSEMOVE, false,
    1937             :                                  pEvent->mnX, pEvent->mnY,
    1938             :                                  pEvent->mnTime, pEvent->mnCode,
    1939           0 :                                  ImplGetMouseMoveMode( pEvent ) );
    1940             : }
    1941             : 
    1942           0 : inline bool ImplHandleSalMouseButtonDown( Window* pWindow, SalMouseEvent* pEvent )
    1943             : {
    1944             :     return ImplHandleMouseEvent( pWindow, EVENT_MOUSEBUTTONDOWN, false,
    1945             :                                  pEvent->mnX, pEvent->mnY,
    1946             :                                  pEvent->mnTime,
    1947             : #ifdef MACOSX
    1948             :                  pEvent->mnButton | (pEvent->mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)),
    1949             : #else
    1950             :                                  pEvent->mnButton | (pEvent->mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)),
    1951             : #endif
    1952           0 :                                  ImplGetMouseButtonMode( pEvent ) );
    1953             : }
    1954             : 
    1955           0 : inline bool ImplHandleSalMouseButtonUp( Window* pWindow, SalMouseEvent* pEvent )
    1956             : {
    1957             :     return ImplHandleMouseEvent( pWindow, EVENT_MOUSEBUTTONUP, false,
    1958             :                                  pEvent->mnX, pEvent->mnY,
    1959             :                                  pEvent->mnTime,
    1960             : #ifdef MACOSX
    1961             :                  pEvent->mnButton | (pEvent->mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3)),
    1962             : #else
    1963             :                                  pEvent->mnButton | (pEvent->mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)),
    1964             : #endif
    1965           0 :                                  ImplGetMouseButtonMode( pEvent ) );
    1966             : }
    1967             : 
    1968           0 : static bool ImplHandleSalMouseActivate( Window* /*pWindow*/, SalMouseActivateEvent* /*pEvent*/ )
    1969             : {
    1970           0 :     return false;
    1971             : }
    1972             : 
    1973           0 : static bool ImplHandleMenuEvent( Window* pWindow, SalMenuEvent* pEvent, sal_uInt16 nEvent )
    1974             : {
    1975             :     // Find SystemWindow and its Menubar and let it dispatch the command
    1976           0 :     bool nRet = false;
    1977           0 :     Window *pWin = pWindow->ImplGetWindowImpl()->mpFirstChild;
    1978           0 :     while ( pWin )
    1979             :     {
    1980           0 :         if ( pWin->ImplGetWindowImpl()->mbSysWin )
    1981           0 :             break;
    1982           0 :         pWin = pWin->ImplGetWindowImpl()->mpNext;
    1983             :     }
    1984           0 :     if( pWin )
    1985             :     {
    1986           0 :         MenuBar *pMenuBar = ((SystemWindow*) pWin)->GetMenuBar();
    1987           0 :         if( pMenuBar )
    1988             :         {
    1989           0 :             switch( nEvent )
    1990             :             {
    1991             :                 case SALEVENT_MENUACTIVATE:
    1992           0 :                     nRet = pMenuBar->HandleMenuActivateEvent( (Menu*) pEvent->mpMenu );
    1993           0 :                     break;
    1994             :                 case SALEVENT_MENUDEACTIVATE:
    1995           0 :                     nRet = pMenuBar->HandleMenuDeActivateEvent( (Menu*) pEvent->mpMenu );
    1996           0 :                     break;
    1997             :                 case SALEVENT_MENUHIGHLIGHT:
    1998           0 :                     nRet = pMenuBar->HandleMenuHighlightEvent( (Menu*) pEvent->mpMenu, pEvent->mnId );
    1999           0 :                     break;
    2000             :                 case SALEVENT_MENUBUTTONCOMMAND:
    2001           0 :                     nRet = pMenuBar->HandleMenuButtonEvent( (Menu*) pEvent->mpMenu, pEvent->mnId );
    2002           0 :                     break;
    2003             :                 case SALEVENT_MENUCOMMAND:
    2004           0 :                     nRet = pMenuBar->HandleMenuCommandEvent( (Menu*) pEvent->mpMenu, pEvent->mnId );
    2005           0 :                     break;
    2006             :                 default:
    2007           0 :                     break;
    2008             :             }
    2009             :         }
    2010             :     }
    2011           0 :     return nRet;
    2012             : }
    2013             : 
    2014           0 : static void ImplHandleSalKeyMod( Window* pWindow, SalKeyModEvent* pEvent )
    2015             : {
    2016           0 :     ImplSVData* pSVData = ImplGetSVData();
    2017           0 :     Window* pTrackWin = pSVData->maWinData.mpTrackWin;
    2018           0 :     if ( pTrackWin )
    2019           0 :         pWindow = pTrackWin;
    2020             : #ifdef MACOSX
    2021             :     sal_uInt16 nOldCode = pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3);
    2022             : #else
    2023           0 :     sal_uInt16 nOldCode = pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2);
    2024             : #endif
    2025           0 :     sal_uInt16 nNewCode = pEvent->mnCode;
    2026           0 :     if ( nOldCode != nNewCode )
    2027             :     {
    2028             : #ifdef MACOSX
    2029             :     nNewCode |= pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & ~(KEY_SHIFT | KEY_MOD1 | KEY_MOD2 | KEY_MOD3);
    2030             : #else
    2031           0 :         nNewCode |= pWindow->ImplGetWindowImpl()->mpFrameData->mnMouseCode & ~(KEY_SHIFT | KEY_MOD1 | KEY_MOD2);
    2032             : #endif
    2033           0 :         pWindow->ImplGetWindowImpl()->mpFrameWindow->ImplCallMouseMove( nNewCode, true );
    2034             :     }
    2035             : 
    2036             :     // #105224# send commandevent to allow special treatment of Ctrl-LeftShift/Ctrl-RightShift etc.
    2037             : 
    2038             :     // find window
    2039           0 :     Window* pChild = ImplGetKeyInputWindow( pWindow );
    2040           0 :     if ( !pChild )
    2041           0 :         return;
    2042             : 
    2043             :     // send modkey events only if useful data is available
    2044           0 :     if( pEvent->mnModKeyCode != 0 )
    2045             :     {
    2046           0 :         CommandModKeyData data( pEvent->mnModKeyCode );
    2047           0 :         ImplCallCommand( pChild, COMMAND_MODKEYCHANGE, &data );
    2048             :     }
    2049             : }
    2050             : 
    2051           0 : static void ImplHandleInputLanguageChange( Window* pWindow )
    2052             : {
    2053             :     // find window
    2054           0 :     Window* pChild = ImplGetKeyInputWindow( pWindow );
    2055           0 :     if ( !pChild )
    2056           0 :         return;
    2057             : 
    2058           0 :     ImplCallCommand( pChild, COMMAND_INPUTLANGUAGECHANGE );
    2059             : }
    2060             : 
    2061           0 : static void ImplHandleSalSettings( sal_uInt16 nEvent )
    2062             : {
    2063           0 :     Application* pApp = GetpApp();
    2064           0 :     if ( !pApp )
    2065           0 :         return;
    2066             : 
    2067           0 :     if ( nEvent == SALEVENT_SETTINGSCHANGED )
    2068             :     {
    2069           0 :         AllSettings aSettings = pApp->GetSettings();
    2070           0 :         pApp->MergeSystemSettings( aSettings );
    2071           0 :         pApp->OverrideSystemSettings( aSettings );
    2072           0 :         pApp->SetSettings( aSettings );
    2073             :     }
    2074             :     else
    2075             :     {
    2076             :         sal_uInt16 nType;
    2077           0 :         switch ( nEvent )
    2078             :         {
    2079             :             case SALEVENT_VOLUMECHANGED:
    2080           0 :                 nType = 0;
    2081           0 :                 break;
    2082             :             case SALEVENT_PRINTERCHANGED:
    2083           0 :                 ImplDeletePrnQueueList();
    2084           0 :                 nType = DATACHANGED_PRINTER;
    2085           0 :                 break;
    2086             :             case SALEVENT_DISPLAYCHANGED:
    2087           0 :                 nType = DATACHANGED_DISPLAY;
    2088           0 :                 break;
    2089             :             case SALEVENT_FONTCHANGED:
    2090           0 :                 OutputDevice::ImplUpdateAllFontData( true );
    2091           0 :                 nType = DATACHANGED_FONTS;
    2092           0 :                 break;
    2093             :             case SALEVENT_DATETIMECHANGED:
    2094           0 :                 nType = DATACHANGED_DATETIME;
    2095           0 :                 break;
    2096             :             case SALEVENT_KEYBOARDCHANGED:
    2097           0 :                 nType = 0;
    2098           0 :                 break;
    2099             :             default:
    2100           0 :                 nType = 0;
    2101           0 :                 break;
    2102             :         }
    2103             : 
    2104           0 :         if ( nType )
    2105             :         {
    2106           0 :             DataChangedEvent aDCEvt( nType );
    2107           0 :             pApp->DataChanged( aDCEvt );
    2108           0 :             pApp->NotifyAllWindows( aDCEvt );
    2109             :         }
    2110             :     }
    2111             : }
    2112             : 
    2113           0 : static void ImplHandleSalExtTextInputPos( Window* pWindow, SalExtTextInputPosEvent* pEvt )
    2114             : {
    2115           0 :     Rectangle aCursorRect;
    2116           0 :     ImplHandleExtTextInputPos( pWindow, aCursorRect, pEvt->mnExtWidth, &pEvt->mbVertical );
    2117           0 :     if ( aCursorRect.IsEmpty() )
    2118             :     {
    2119           0 :         pEvt->mnX       = -1;
    2120           0 :         pEvt->mnY       = -1;
    2121           0 :         pEvt->mnWidth   = -1;
    2122           0 :         pEvt->mnHeight  = -1;
    2123             :     }
    2124             :     else
    2125             :     {
    2126           0 :         pEvt->mnX       = aCursorRect.Left();
    2127           0 :         pEvt->mnY       = aCursorRect.Top();
    2128           0 :         pEvt->mnWidth   = aCursorRect.GetWidth();
    2129           0 :         pEvt->mnHeight  = aCursorRect.GetHeight();
    2130             :     }
    2131           0 : }
    2132             : 
    2133           0 : static bool ImplHandleShowDialog( Window* pWindow, int nDialogId )
    2134             : {
    2135           0 :     if( ! pWindow )
    2136           0 :         return false;
    2137             : 
    2138           0 :     if( pWindow->GetType() == WINDOW_BORDERWINDOW )
    2139             :     {
    2140           0 :         Window* pWrkWin = pWindow->GetWindow( WINDOW_CLIENT );
    2141           0 :         if( pWrkWin )
    2142           0 :             pWindow = pWrkWin;
    2143             :     }
    2144           0 :     CommandDialogData aCmdData( nDialogId );
    2145           0 :     return ImplCallCommand( pWindow, COMMAND_SHOWDIALOG, &aCmdData );
    2146             : }
    2147             : 
    2148           0 : static void ImplHandleSurroundingTextRequest( Window *pWindow,
    2149             :                           OUString& rText,
    2150             :                           Selection &rSelRange )
    2151             : {
    2152           0 :     Window* pChild = ImplGetKeyInputWindow( pWindow );
    2153             : 
    2154           0 :     if ( !pChild )
    2155             :     {
    2156           0 :     rText = OUString();
    2157           0 :     rSelRange.setMin( 0 );
    2158           0 :     rSelRange.setMax( 0 );
    2159             :     }
    2160             :     else
    2161             :     {
    2162           0 :     rText = pChild->GetSurroundingText();
    2163           0 :     Selection aSel = pChild->GetSurroundingTextSelection();
    2164           0 :     rSelRange.setMin( aSel.Min() );
    2165           0 :     rSelRange.setMax( aSel.Max() );
    2166             :     }
    2167           0 : }
    2168             : 
    2169           0 : static void ImplHandleSalSurroundingTextRequest( Window *pWindow,
    2170             :                          SalSurroundingTextRequestEvent *pEvt )
    2171             : {
    2172           0 :     Selection aSelRange;
    2173           0 :     ImplHandleSurroundingTextRequest( pWindow, pEvt->maText, aSelRange );
    2174             : 
    2175           0 :     aSelRange.Justify();
    2176             : 
    2177           0 :     if( aSelRange.Min() < 0 )
    2178           0 :         pEvt->mnStart = 0;
    2179           0 :     else if( aSelRange.Min() > pEvt->maText.getLength() )
    2180           0 :         pEvt->mnStart = pEvt->maText.getLength();
    2181             :     else
    2182           0 :         pEvt->mnStart = aSelRange.Min();
    2183             : 
    2184           0 :     if( aSelRange.Max() < 0 )
    2185           0 :         pEvt->mnStart = 0;
    2186           0 :     else if( aSelRange.Max() > pEvt->maText.getLength() )
    2187           0 :         pEvt->mnEnd = pEvt->maText.getLength();
    2188             :     else
    2189           0 :         pEvt->mnEnd = aSelRange.Max();
    2190           0 : }
    2191             : 
    2192           0 : static void ImplHandleSurroundingTextSelectionChange( Window *pWindow,
    2193             :                               sal_uLong nStart,
    2194             :                               sal_uLong nEnd )
    2195             : {
    2196           0 :     Window* pChild = ImplGetKeyInputWindow( pWindow );
    2197           0 :     if( pChild )
    2198             :     {
    2199           0 :         CommandSelectionChangeData data( nStart, nEnd );
    2200           0 :         ImplCallCommand( pChild, COMMAND_SELECTIONCHANGE, &data );
    2201             :     }
    2202           0 : }
    2203             : 
    2204           0 : static void ImplHandleStartReconversion( Window *pWindow )
    2205             : {
    2206           0 :     Window* pChild = ImplGetKeyInputWindow( pWindow );
    2207           0 :     if( pChild )
    2208           0 :     ImplCallCommand( pChild, COMMAND_PREPARERECONVERSION );
    2209           0 : }
    2210             : 
    2211           0 : static void ImplHandleSalQueryCharPosition( Window *pWindow,
    2212             :                                             SalQueryCharPositionEvent *pEvt )
    2213             : {
    2214           0 :     pEvt->mbValid = false;
    2215           0 :     pEvt->mbVertical = false;
    2216           0 :     pEvt->mnCursorBoundX = 0;
    2217           0 :     pEvt->mnCursorBoundY = 0;
    2218           0 :     pEvt->mnCursorBoundWidth = 0;
    2219           0 :     pEvt->mnCursorBoundHeight = 0;
    2220             : 
    2221           0 :     ImplSVData* pSVData = ImplGetSVData();
    2222           0 :     Window*     pChild = pSVData->maWinData.mpExtTextInputWin;
    2223             : 
    2224           0 :     if ( !pChild )
    2225           0 :         pChild = ImplGetKeyInputWindow( pWindow );
    2226             :     else
    2227             :     {
    2228             :         // Test, if the Window is related to the frame
    2229           0 :         if ( !pWindow->ImplIsWindowOrChild( pChild ) )
    2230           0 :             pChild = ImplGetKeyInputWindow( pWindow );
    2231             :     }
    2232             : 
    2233           0 :     if( pChild )
    2234             :     {
    2235           0 :         ImplCallCommand( pChild, COMMAND_QUERYCHARPOSITION );
    2236             : 
    2237           0 :         ImplWinData* pWinData = pChild->ImplGetWinData();
    2238           0 :         if ( pWinData->mpCompositionCharRects && pEvt->mnCharPos < static_cast<sal_uLong>( pWinData->mnCompositionCharRects ) )
    2239             :         {
    2240           0 :             const OutputDevice *pChildOutDev = pChild->GetOutDev();
    2241           0 :             const Rectangle& aRect = pWinData->mpCompositionCharRects[ pEvt->mnCharPos ];
    2242           0 :             Rectangle aDeviceRect = pChildOutDev->ImplLogicToDevicePixel( aRect );
    2243           0 :             Point aAbsScreenPos = pChild->OutputToAbsoluteScreenPixel( pChild->ScreenToOutputPixel(aDeviceRect.TopLeft()) );
    2244           0 :             pEvt->mnCursorBoundX = aAbsScreenPos.X();
    2245           0 :             pEvt->mnCursorBoundY = aAbsScreenPos.Y();
    2246           0 :             pEvt->mnCursorBoundWidth = aDeviceRect.GetWidth();
    2247           0 :             pEvt->mnCursorBoundHeight = aDeviceRect.GetHeight();
    2248           0 :             pEvt->mbVertical = pWinData->mbVertical;
    2249           0 :             pEvt->mbValid = true;
    2250             :         }
    2251             :     }
    2252           0 : }
    2253             : 
    2254           0 : bool ImplWindowFrameProc( Window* pWindow, SalFrame* /*pFrame*/,
    2255             :                           sal_uInt16 nEvent, const void* pEvent )
    2256             : {
    2257             :     DBG_TESTSOLARMUTEX();
    2258             : 
    2259           0 :     bool nRet = false;
    2260             : 
    2261             :     // #119709# for some unknown reason it is possible to receive events (in this case key events)
    2262             :     // although the corresponding VCL window must have been destroyed already
    2263             :     // at least ImplGetWindowImpl() was NULL in these cases, so check this here
    2264           0 :     if( pWindow->ImplGetWindowImpl() == NULL )
    2265           0 :         return false;
    2266             : 
    2267           0 :     switch ( nEvent )
    2268             :     {
    2269             :         case SALEVENT_MOUSEMOVE:
    2270           0 :             nRet = ImplHandleSalMouseMove( pWindow, (SalMouseEvent*)pEvent );
    2271           0 :             break;
    2272             :         case SALEVENT_EXTERNALMOUSEMOVE:
    2273             :         {
    2274           0 :             MouseEvent*     pMouseEvt = (MouseEvent*) pEvent;
    2275             :             SalMouseEvent   aSalMouseEvent;
    2276             : 
    2277           0 :             aSalMouseEvent.mnTime = Time::GetSystemTicks();
    2278           0 :             aSalMouseEvent.mnX = pMouseEvt->GetPosPixel().X();
    2279           0 :             aSalMouseEvent.mnY = pMouseEvt->GetPosPixel().Y();
    2280           0 :             aSalMouseEvent.mnButton = 0;
    2281           0 :             aSalMouseEvent.mnCode = pMouseEvt->GetButtons() | pMouseEvt->GetModifier();
    2282             : 
    2283           0 :             nRet = ImplHandleSalMouseMove( pWindow, &aSalMouseEvent );
    2284             :         }
    2285           0 :         break;
    2286             :         case SALEVENT_MOUSELEAVE:
    2287           0 :             nRet = ImplHandleSalMouseLeave( pWindow, (SalMouseEvent*)pEvent );
    2288           0 :             break;
    2289             :         case SALEVENT_MOUSEBUTTONDOWN:
    2290           0 :             nRet = ImplHandleSalMouseButtonDown( pWindow, (SalMouseEvent*)pEvent );
    2291           0 :             break;
    2292             :         case SALEVENT_EXTERNALMOUSEBUTTONDOWN:
    2293             :         {
    2294           0 :             MouseEvent*     pMouseEvt = (MouseEvent*) pEvent;
    2295             :             SalMouseEvent   aSalMouseEvent;
    2296             : 
    2297           0 :             aSalMouseEvent.mnTime = Time::GetSystemTicks();
    2298           0 :             aSalMouseEvent.mnX = pMouseEvt->GetPosPixel().X();
    2299           0 :             aSalMouseEvent.mnY = pMouseEvt->GetPosPixel().Y();
    2300           0 :             aSalMouseEvent.mnButton = pMouseEvt->GetButtons();
    2301           0 :             aSalMouseEvent.mnCode = pMouseEvt->GetButtons() | pMouseEvt->GetModifier();
    2302             : 
    2303           0 :             nRet = ImplHandleSalMouseButtonDown( pWindow, &aSalMouseEvent );
    2304             :         }
    2305           0 :         break;
    2306             :         case SALEVENT_MOUSEBUTTONUP:
    2307           0 :             nRet = ImplHandleSalMouseButtonUp( pWindow, (SalMouseEvent*)pEvent );
    2308           0 :             break;
    2309             :         case SALEVENT_EXTERNALMOUSEBUTTONUP:
    2310             :         {
    2311           0 :             MouseEvent*     pMouseEvt = (MouseEvent*) pEvent;
    2312             :             SalMouseEvent   aSalMouseEvent;
    2313             : 
    2314           0 :             aSalMouseEvent.mnTime = Time::GetSystemTicks();
    2315           0 :             aSalMouseEvent.mnX = pMouseEvt->GetPosPixel().X();
    2316           0 :             aSalMouseEvent.mnY = pMouseEvt->GetPosPixel().Y();
    2317           0 :             aSalMouseEvent.mnButton = pMouseEvt->GetButtons();
    2318           0 :             aSalMouseEvent.mnCode = pMouseEvt->GetButtons() | pMouseEvt->GetModifier();
    2319             : 
    2320           0 :             nRet = ImplHandleSalMouseButtonUp( pWindow, &aSalMouseEvent );
    2321             :         }
    2322           0 :         break;
    2323             :         case SALEVENT_MOUSEACTIVATE:
    2324           0 :             nRet = ImplHandleSalMouseActivate( pWindow, (SalMouseActivateEvent*)pEvent );
    2325           0 :             break;
    2326             :         case SALEVENT_KEYINPUT:
    2327             :             {
    2328           0 :             SalKeyEvent* pKeyEvt = (SalKeyEvent*)pEvent;
    2329             :             nRet = ImplHandleKey( pWindow, EVENT_KEYINPUT,
    2330           0 :                 pKeyEvt->mnCode, pKeyEvt->mnCharCode, pKeyEvt->mnRepeat, true );
    2331             :             }
    2332           0 :             break;
    2333             :         case SALEVENT_EXTERNALKEYINPUT:
    2334             :             {
    2335           0 :             KeyEvent* pKeyEvt = (KeyEvent*) pEvent;
    2336             :             nRet = ImplHandleKey( pWindow, EVENT_KEYINPUT,
    2337           0 :                 pKeyEvt->GetKeyCode().GetFullCode(), pKeyEvt->GetCharCode(), pKeyEvt->GetRepeat(), false );
    2338             :             }
    2339           0 :             break;
    2340             :         case SALEVENT_KEYUP:
    2341             :             {
    2342           0 :             SalKeyEvent* pKeyEvt = (SalKeyEvent*)pEvent;
    2343             :             nRet = ImplHandleKey( pWindow, EVENT_KEYUP,
    2344           0 :                 pKeyEvt->mnCode, pKeyEvt->mnCharCode, pKeyEvt->mnRepeat, true );
    2345             :             }
    2346           0 :             break;
    2347             :         case SALEVENT_EXTERNALKEYUP:
    2348             :             {
    2349           0 :             KeyEvent* pKeyEvt = (KeyEvent*) pEvent;
    2350             :             nRet = ImplHandleKey( pWindow, EVENT_KEYUP,
    2351           0 :                 pKeyEvt->GetKeyCode().GetFullCode(), pKeyEvt->GetCharCode(), pKeyEvt->GetRepeat(), false );
    2352             :             }
    2353           0 :             break;
    2354             :         case SALEVENT_KEYMODCHANGE:
    2355           0 :             ImplHandleSalKeyMod( pWindow, (SalKeyModEvent*)pEvent );
    2356           0 :             break;
    2357             : 
    2358             :         case SALEVENT_INPUTLANGUAGECHANGE:
    2359           0 :             ImplHandleInputLanguageChange( pWindow );
    2360           0 :             break;
    2361             : 
    2362             :         case SALEVENT_MENUACTIVATE:
    2363             :         case SALEVENT_MENUDEACTIVATE:
    2364             :         case SALEVENT_MENUHIGHLIGHT:
    2365             :         case SALEVENT_MENUCOMMAND:
    2366             :         case SALEVENT_MENUBUTTONCOMMAND:
    2367           0 :             nRet = ImplHandleMenuEvent( pWindow, (SalMenuEvent*)pEvent, nEvent );
    2368           0 :             break;
    2369             : 
    2370             :         case SALEVENT_WHEELMOUSE:
    2371           0 :             nRet = ImplHandleWheelEvent( pWindow, *(const SalWheelMouseEvent*)pEvent);
    2372           0 :             break;
    2373             : 
    2374             :         case SALEVENT_PAINT:
    2375             :             {
    2376           0 :             SalPaintEvent* pPaintEvt = (SalPaintEvent*)pEvent;
    2377             : 
    2378           0 :             if( Application::GetSettings().GetLayoutRTL() )
    2379             :             {
    2380             :                 // --- RTL --- (mirror paint rect)
    2381           0 :                 SalFrame* pSalFrame = pWindow->ImplGetWindowImpl()->mpFrame;
    2382           0 :                 pPaintEvt->mnBoundX = pSalFrame->maGeometry.nWidth-pPaintEvt->mnBoundWidth-pPaintEvt->mnBoundX;
    2383             :             }
    2384             : 
    2385             :             Rectangle aBoundRect( Point( pPaintEvt->mnBoundX, pPaintEvt->mnBoundY ),
    2386           0 :                                   Size( pPaintEvt->mnBoundWidth, pPaintEvt->mnBoundHeight ) );
    2387           0 :             ImplHandlePaint( pWindow, aBoundRect, pPaintEvt->mbImmediateUpdate );
    2388             :             }
    2389           0 :             break;
    2390             : 
    2391             :         case SALEVENT_MOVE:
    2392           0 :             ImplHandleMove( pWindow );
    2393           0 :             break;
    2394             : 
    2395             :         case SALEVENT_RESIZE:
    2396             :             {
    2397             :             long nNewWidth;
    2398             :             long nNewHeight;
    2399           0 :             pWindow->ImplGetWindowImpl()->mpFrame->GetClientSize( nNewWidth, nNewHeight );
    2400           0 :             ImplHandleResize( pWindow, nNewWidth, nNewHeight );
    2401             :             }
    2402           0 :             break;
    2403             : 
    2404             :         case SALEVENT_MOVERESIZE:
    2405             :             {
    2406           0 :             SalFrameGeometry g = pWindow->ImplGetWindowImpl()->mpFrame->GetGeometry();
    2407           0 :             ImplHandleMoveResize( pWindow, g.nWidth, g.nHeight );
    2408             :             }
    2409           0 :             break;
    2410             : 
    2411             :         case SALEVENT_CLOSEPOPUPS:
    2412             :             {
    2413           0 :             KillOwnPopups( pWindow );
    2414             :             }
    2415           0 :             break;
    2416             : 
    2417             :         case SALEVENT_GETFOCUS:
    2418           0 :             ImplHandleGetFocus( pWindow );
    2419           0 :             break;
    2420             :         case SALEVENT_LOSEFOCUS:
    2421           0 :             ImplHandleLoseFocus( pWindow );
    2422           0 :             break;
    2423             : 
    2424             :         case SALEVENT_CLOSE:
    2425           0 :             ImplHandleClose( pWindow );
    2426           0 :             break;
    2427             : 
    2428             :         case SALEVENT_SHUTDOWN:
    2429             :             {
    2430             :                 static bool bInQueryExit = false;
    2431           0 :                 if( !bInQueryExit )
    2432             :                 {
    2433           0 :                     bInQueryExit = true;
    2434           0 :                     if ( GetpApp()->QueryExit() )
    2435             :                     {
    2436             :                         // Message-Schleife beenden
    2437           0 :                         Application::Quit();
    2438           0 :                         return false;
    2439             :                     }
    2440             :                     else
    2441             :                     {
    2442           0 :                         bInQueryExit = false;
    2443           0 :                         return true;
    2444             :                     }
    2445             :                 }
    2446           0 :                 return false;
    2447             :             }
    2448             : 
    2449             :         case SALEVENT_SETTINGSCHANGED:
    2450             :         case SALEVENT_VOLUMECHANGED:
    2451             :         case SALEVENT_PRINTERCHANGED:
    2452             :         case SALEVENT_DISPLAYCHANGED:
    2453             :         case SALEVENT_FONTCHANGED:
    2454             :         case SALEVENT_DATETIMECHANGED:
    2455             :         case SALEVENT_KEYBOARDCHANGED:
    2456           0 :             ImplHandleSalSettings( nEvent );
    2457           0 :             break;
    2458             : 
    2459             :         case SALEVENT_USEREVENT:
    2460           0 :             ImplHandleUserEvent( (ImplSVEvent*)pEvent );
    2461           0 :             break;
    2462             : 
    2463             :         case SALEVENT_EXTTEXTINPUT:
    2464             :             {
    2465           0 :             SalExtTextInputEvent* pEvt = (SalExtTextInputEvent*)pEvent;
    2466             :             nRet = ImplHandleExtTextInput( pWindow,
    2467             :                                            pEvt->maText, pEvt->mpTextAttr,
    2468           0 :                                            pEvt->mnCursorPos, pEvt->mnCursorFlags );
    2469             :             }
    2470           0 :             break;
    2471             :         case SALEVENT_ENDEXTTEXTINPUT:
    2472           0 :             nRet = ImplHandleEndExtTextInput( pWindow );
    2473           0 :             break;
    2474             :         case SALEVENT_EXTTEXTINPUTPOS:
    2475           0 :             ImplHandleSalExtTextInputPos( pWindow, (SalExtTextInputPosEvent*)pEvent );
    2476           0 :             break;
    2477             :         case SALEVENT_INPUTCONTEXTCHANGE:
    2478           0 :             nRet = ImplHandleInputContextChange( pWindow, ((SalInputContextChangeEvent*)pEvent)->meLanguage );
    2479           0 :             break;
    2480             :         case SALEVENT_SHOWDIALOG:
    2481             :             {
    2482           0 :                 int nDialogID = static_cast<int>(reinterpret_cast<sal_IntPtr>(pEvent));
    2483           0 :                 nRet = ImplHandleShowDialog( pWindow, nDialogID );
    2484             :             }
    2485           0 :             break;
    2486             :         case SALEVENT_SURROUNDINGTEXTREQUEST:
    2487           0 :             ImplHandleSalSurroundingTextRequest( pWindow, (SalSurroundingTextRequestEvent*)pEvent );
    2488           0 :             break;
    2489             :         case SALEVENT_SURROUNDINGTEXTSELECTIONCHANGE:
    2490             :         {
    2491             :             SalSurroundingTextSelectionChangeEvent* pEvt
    2492           0 :              = (SalSurroundingTextSelectionChangeEvent*)pEvent;
    2493             :             ImplHandleSurroundingTextSelectionChange( pWindow,
    2494             :                               pEvt->mnStart,
    2495           0 :                               pEvt->mnEnd );
    2496             :             // Fallthrough really intended?
    2497             :         }
    2498             :         case SALEVENT_STARTRECONVERSION:
    2499           0 :             ImplHandleStartReconversion( pWindow );
    2500           0 :             break;
    2501             :         case SALEVENT_EXTERNALZOOM:
    2502             :             {
    2503           0 :             ZoomEvent* pZoomEvent = (ZoomEvent*) pEvent;
    2504           0 :             SalWheelMouseEvent aSalWheelMouseEvent;
    2505           0 :             aSalWheelMouseEvent.mnTime = Time::GetSystemTicks();
    2506           0 :             aSalWheelMouseEvent.mnX = pZoomEvent->GetCenter().getX();
    2507           0 :             aSalWheelMouseEvent.mnY = pZoomEvent->GetCenter().getY();
    2508             :             // Pass on the scale as a percentage * 100 of current zoom factor
    2509             :             // so to assure zoom granularity
    2510           0 :             aSalWheelMouseEvent.mnDelta = long(double(pZoomEvent->GetScale()) * double(MOBILE_ZOOM_SCALE_MULTIPLIER));
    2511             :             // Other SalWheelMouseEvent fields ignored when the
    2512             :             // scaleDirectly parameter to ImplHandleWheelEvent() is
    2513             :             // true.
    2514           0 :             nRet = ImplHandleWheelEvent( pWindow, aSalWheelMouseEvent, true );
    2515             :             }
    2516           0 :             break;
    2517             :         case SALEVENT_EXTERNALSCROLL:
    2518             :             {
    2519           0 :             ScrollEvent* pScrollEvent = (ScrollEvent*) pEvent;
    2520           0 :             SalWheelMouseEvent aSalWheelMouseEvent;
    2521           0 :             aSalWheelMouseEvent.mnTime = Time::GetSystemTicks();
    2522           0 :             aSalWheelMouseEvent.mbDeltaIsPixel = true;
    2523             :             // event location holds delta values instead
    2524           0 :             aSalWheelMouseEvent.mnX = long(pScrollEvent->GetXOffset());
    2525           0 :             aSalWheelMouseEvent.mnY = long(pScrollEvent->GetYOffset());
    2526           0 :             aSalWheelMouseEvent.mnScrollLines = 0;
    2527           0 :             if (aSalWheelMouseEvent.mnX != 0 || aSalWheelMouseEvent.mnY != 0)
    2528             :             {
    2529           0 :                 nRet = ImplHandleWheelEvent( pWindow, aSalWheelMouseEvent );
    2530             :             }
    2531             :         }
    2532           0 :         break;
    2533             :         case SALEVENT_QUERYCHARPOSITION:
    2534           0 :             ImplHandleSalQueryCharPosition( pWindow, (SalQueryCharPositionEvent*)pEvent );
    2535           0 :             break;
    2536             : #ifdef DBG_UTIL
    2537             :         default:
    2538             :             SAL_WARN( "vcl.layout", "ImplWindowFrameProc(): unknown event (" << nEvent << ")" );
    2539             :             break;
    2540             : #endif
    2541             :     }
    2542             : 
    2543           0 :     return nRet;
    2544           3 : }
    2545             : 
    2546             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10