LCOV - code coverage report
Current view: top level - vcl/source/window - window.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 1 4797 0.1 %
Date: 2014-04-14 Functions: 2 325 0.6 %
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 <config_features.h>
      21             : 
      22             : #include <i18nlangtag/mslangid.hxx>
      23             : 
      24             : #include "tools/time.hxx"
      25             : #include "tools/debug.hxx"
      26             : #include "tools/rc.h"
      27             : 
      28             : #include "unotools/fontcfg.hxx"
      29             : #include "unotools/confignode.hxx"
      30             : 
      31             : #include "vcl/layout.hxx"
      32             : #include "vcl/salgtype.hxx"
      33             : #include "vcl/event.hxx"
      34             : #include "vcl/fixed.hxx"
      35             : #include "vcl/help.hxx"
      36             : #include "vcl/cursor.hxx"
      37             : #include "vcl/svapp.hxx"
      38             : #include "vcl/window.hxx"
      39             : #include "vcl/syswin.hxx"
      40             : #include "vcl/syschild.hxx"
      41             : #include "vcl/dockwin.hxx"
      42             : #include "vcl/menu.hxx"
      43             : #include "vcl/wrkwin.hxx"
      44             : #include "vcl/wall.hxx"
      45             : #include "vcl/gradient.hxx"
      46             : #include "vcl/button.hxx"
      47             : #include "vcl/taskpanelist.hxx"
      48             : #include "vcl/dialog.hxx"
      49             : #include "vcl/unowrap.hxx"
      50             : #include "vcl/gdimtf.hxx"
      51             : #include "vcl/pdfextoutdevdata.hxx"
      52             : #include "vcl/popupmenuwindow.hxx"
      53             : #include "vcl/lazydelete.hxx"
      54             : #include "vcl/virdev.hxx"
      55             : #include "vcl/settings.hxx"
      56             : 
      57             : // declare system types in sysdata.hxx
      58             : #include "svsys.h"
      59             : #include "vcl/sysdata.hxx"
      60             : 
      61             : #include "salframe.hxx"
      62             : #include "salobj.hxx"
      63             : #include "salinst.hxx"
      64             : #include "salgdi.hxx"
      65             : #include "svdata.hxx"
      66             : #include "dbggui.hxx"
      67             : #include "outfont.hxx"
      68             : #include "window.h"
      69             : #include "toolbox.h"
      70             : #include "outdev.h"
      71             : #include "PhysicalFontCollection.hxx"
      72             : #include "brdwin.hxx"
      73             : #include "helpwin.hxx"
      74             : #include "sallayout.hxx"
      75             : #include "dndlcon.hxx"
      76             : #include "dndevdis.hxx"
      77             : 
      78             : #include "com/sun/star/accessibility/XAccessible.hpp"
      79             : #include "com/sun/star/accessibility/AccessibleRole.hpp"
      80             : #include "com/sun/star/awt/XWindowPeer.hpp"
      81             : #include "com/sun/star/awt/XTopWindow.hpp"
      82             : #include "com/sun/star/awt/XWindow.hpp"
      83             : #include "com/sun/star/awt/XDisplayConnection.hpp"
      84             : #include "com/sun/star/datatransfer/dnd/XDragSource.hpp"
      85             : #include "com/sun/star/datatransfer/dnd/XDropTarget.hpp"
      86             : #include "com/sun/star/datatransfer/clipboard/XClipboard.hpp"
      87             : #include "com/sun/star/datatransfer/clipboard/SystemClipboard.hpp"
      88             : #include "com/sun/star/lang/XInitialization.hpp"
      89             : #include "com/sun/star/lang/XComponent.hpp"
      90             : #include "com/sun/star/lang/XServiceName.hpp"
      91             : #include "com/sun/star/rendering/CanvasFactory.hpp"
      92             : #include "com/sun/star/rendering/XCanvas.hpp"
      93             : #include "com/sun/star/rendering/XSpriteCanvas.hpp"
      94             : #include "comphelper/processfactory.hxx"
      95             : 
      96             : #include <sal/macros.h>
      97             : #include <rtl/strbuf.hxx>
      98             : 
      99             : #include <set>
     100             : #include <typeinfo>
     101             : 
     102             : using namespace ::com::sun::star::uno;
     103             : using namespace ::com::sun::star::lang;
     104             : using namespace ::com::sun::star::datatransfer::clipboard;
     105             : using namespace ::com::sun::star::datatransfer::dnd;
     106             : using namespace ::com::sun::star;
     107             : using namespace com::sun;
     108             : 
     109             : using ::com::sun::star::awt::XTopWindow;
     110             : 
     111             : #define IMPL_PAINT_PAINT            ((sal_uInt16)0x0001)
     112             : #define IMPL_PAINT_PAINTALL         ((sal_uInt16)0x0002)
     113             : #define IMPL_PAINT_PAINTALLCHILDREN   ((sal_uInt16)0x0004)
     114             : #define IMPL_PAINT_PAINTCHILDREN      ((sal_uInt16)0x0008)
     115             : #define IMPL_PAINT_ERASE            ((sal_uInt16)0x0010)
     116             : #define IMPL_PAINT_CHECKRTL         ((sal_uInt16)0x0020)
     117             : 
     118             : struct ImplCalcToTopData
     119             : {
     120             :     ImplCalcToTopData*  mpNext;
     121             :     Window*             mpWindow;
     122             :     Region*             mpInvalidateRegion;
     123             : };
     124             : 
     125           0 : ImplAccessibleInfos::ImplAccessibleInfos()
     126             : {
     127           0 :     nAccessibleRole = 0xFFFF;
     128           0 :     pAccessibleName = NULL;
     129           0 :     pAccessibleDescription = NULL;
     130           0 :     pLabeledByWindow = NULL;
     131           0 :     pLabelForWindow = NULL;
     132           0 :     pMemberOfWindow = NULL;
     133           0 : }
     134             : 
     135           0 : ImplAccessibleInfos::~ImplAccessibleInfos()
     136             : {
     137           0 :     delete pAccessibleName;
     138           0 :     delete pAccessibleDescription;
     139           0 : }
     140             : 
     141           0 : WindowImpl::WindowImpl( WindowType nType )
     142             : {
     143           0 :     maZoom              = Fraction( 1, 1 );
     144           0 :     maWinRegion         = Region(true);
     145           0 :     maWinClipRegion     = Region(true);
     146           0 :     mpWinData           = NULL;         // Extra Window Data, that we dont need for all windows
     147           0 :     mpOverlapData       = NULL;         // Overlap Data
     148           0 :     mpFrameData         = NULL;         // Frame Data
     149           0 :     mpFrame             = NULL;         // Pointer to frame window
     150           0 :     mpSysObj            = NULL;
     151           0 :     mpFrameWindow       = NULL;         // window to top level parent (same as frame window)
     152           0 :     mpOverlapWindow     = NULL;         // first overlap parent
     153           0 :     mpBorderWindow      = NULL;         // Border-Window
     154           0 :     mpClientWindow      = NULL;         // Client-Window of a FrameWindow
     155           0 :     mpParent            = NULL;         // parent (inkl. BorderWindow)
     156           0 :     mpRealParent        = NULL;         // real parent (exkl. BorderWindow)
     157           0 :     mpFirstChild        = NULL;         // first child window
     158           0 :     mpLastChild         = NULL;         // last child window
     159           0 :     mpFirstOverlap      = NULL;         // first overlap window (only set in overlap windows)
     160           0 :     mpLastOverlap       = NULL;         // last overlap window (only set in overlap windows)
     161           0 :     mpPrev              = NULL;         // prev window
     162           0 :     mpNext              = NULL;         // next window
     163           0 :     mpNextOverlap       = NULL;         // next overlap window of frame
     164           0 :     mpLastFocusWindow   = NULL;         // window for focus restore
     165           0 :     mpDlgCtrlDownWindow = NULL;         // window for dialog control
     166           0 :     mpFirstDel          = NULL;         // Dtor notification list
     167           0 :     mpUserData          = NULL;         // user data
     168           0 :     mpCursor            = NULL;         // cursor
     169           0 :     mpControlFont       = NULL;         // font propertie
     170           0 :     mpVCLXWindow        = NULL;
     171           0 :     mpAccessibleInfos   = NULL;
     172           0 :     maControlForeground = Color( COL_TRANSPARENT );     // no foreground set
     173           0 :     maControlBackground = Color( COL_TRANSPARENT );     // no background set
     174           0 :     mnLeftBorder        = 0;            // left border
     175           0 :     mnTopBorder         = 0;            // top border
     176           0 :     mnRightBorder       = 0;            // right border
     177           0 :     mnBottomBorder      = 0;            // bottom border
     178           0 :     mnWidthRequest      = -1;           // width request
     179           0 :     mnHeightRequest     = -1;           // height request
     180           0 :     mnX                 = 0;            // X-Position to Parent
     181           0 :     mnY                 = 0;            // Y-Position to Parent
     182           0 :     mnAbsScreenX        = 0;            // absolute X-position on screen, used for RTL window positioning
     183           0 :     mpChildClipRegion   = NULL;         // Child-Clip-Region when ClipChildren
     184           0 :     mpPaintRegion       = NULL;         // Paint-ClipRegion
     185           0 :     mnStyle             = 0;            // style (init in ImplInitWindow)
     186           0 :     mnPrevStyle         = 0;            // prevstyle (set in SetStyle)
     187           0 :     mnExtendedStyle     = 0;            // extended style (init in ImplInitWindow)
     188           0 :     mnPrevExtendedStyle = 0;            // prevstyle (set in SetExtendedStyle)
     189           0 :     mnType              = nType;        // type
     190           0 :     mnGetFocusFlags     = 0;            // Flags fuer GetFocus()-Aufruf
     191           0 :     mnWaitCount         = 0;            // Wait-Count (>1 == Warte-MousePointer)
     192           0 :     mnPaintFlags        = 0;            // Flags for ImplCallPaint
     193           0 :     mnParentClipMode    = 0;            // Flags for Parent-ClipChildren-Mode
     194           0 :     mnActivateMode      = 0;            // Will be converted in System/Overlap-Windows
     195           0 :     mnDlgCtrlFlags      = 0;            // DialogControl-Flags
     196           0 :     mnLockCount         = 0;            // LockCount
     197           0 :     meAlwaysInputMode   = AlwaysInputNone; // neither AlwaysEnableInput nor AlwaysDisableInput called
     198           0 :     meHalign            = VCL_ALIGN_FILL;
     199           0 :     meValign            = VCL_ALIGN_FILL;
     200           0 :     mePackType          = VCL_PACK_START;
     201           0 :     mnPadding           = 0;
     202           0 :     mnGridHeight        = 1;
     203           0 :     mnGridLeftAttach    = -1;
     204           0 :     mnGridTopAttach     = -1;
     205           0 :     mnGridWidth         = 1;
     206           0 :     mnBorderWidth       = 0;
     207           0 :     mnMarginLeft        = 0;
     208           0 :     mnMarginRight       = 0;
     209           0 :     mnMarginTop         = 0;
     210           0 :     mnMarginBottom      = 0;
     211           0 :     mbFrame             = false;        // true: Window is a frame window
     212           0 :     mbBorderWin         = false;        // true: Window is a border window
     213           0 :     mbOverlapWin        = false;        // true: Window is a overlap window
     214           0 :     mbSysWin            = false;        // true: SystemWindow is the base class
     215           0 :     mbDialog            = false;        // true: Dialog is the base class
     216           0 :     mbDockWin           = false;        // true: DockingWindow is the base class
     217           0 :     mbFloatWin          = false;        // true: FloatingWindow is the base class
     218           0 :     mbPushButton        = false;        // true: PushButton is the base class
     219           0 :     mbToolBox           = false;      // true: ToolBox is the base class
     220           0 :     mbMenuFloatingWindow= false;      // true: MenuFloatingWindow is the base class
     221           0 :     mbToolbarFloatingWindow= false;       // true: ImplPopupFloatWin is the base class, used for subtoolbars
     222           0 :     mbSplitter          = false;      // true: Splitter is the base class
     223           0 :     mbVisible           = false;        // true: Show( sal_True ) called
     224           0 :     mbOverlapVisible    = false;        // true: Hide called for visible window from ImplHideAllOverlapWindow()
     225           0 :     mbDisabled          = false;        // true: Enable( sal_False ) called
     226           0 :     mbInputDisabled     = false;        // true: EnableInput( sal_False ) called
     227           0 :     mbDropDisabled      = false;        // true: Drop is enabled
     228           0 :     mbNoUpdate          = false;        // true: SetUpdateMode( sal_False ) called
     229           0 :     mbNoParentUpdate    = false;        // true: SetParentUpdateMode( sal_False ) called
     230           0 :     mbActive            = false;        // true: Window Active
     231           0 :     mbParentActive      = false;        // true: OverlapActive from Parent
     232           0 :     mbReallyVisible     = false;        // true: this and all parents to an overlapped window are visible
     233           0 :     mbReallyShown       = false;        // true: this and all parents to an overlapped window are shown
     234           0 :     mbInInitShow        = false;        // true: we are in InitShow
     235           0 :     mbChildNotify       = false;        // true: ChildNotify
     236           0 :     mbChildPtrOverwrite = false;        // true: PointerStyle overwrites Child-Pointer
     237           0 :     mbNoPtrVisible      = false;        // true: ShowPointer( sal_False ) called
     238           0 :     mbMouseMove         = false;        // true: BaseMouseMove called
     239           0 :     mbPaintFrame        = false;        // true: Paint is visible, but not painted
     240           0 :     mbInPaint           = false;        // true: Inside PaintHdl
     241           0 :     mbMouseButtonDown   = false;        // true: BaseMouseButtonDown called
     242           0 :     mbMouseButtonUp     = false;        // true: BaseMouseButtonUp called
     243           0 :     mbKeyInput          = false;        // true: BaseKeyInput called
     244           0 :     mbKeyUp             = false;        // true: BaseKeyUp called
     245           0 :     mbCommand           = false;        // true: BaseCommand called
     246           0 :     mbDefPos            = true;         // true: Position is not Set
     247           0 :     mbDefSize           = true;         // true: Size is not Set
     248           0 :     mbCallMove          = true;         // true: Move must be called by Show
     249           0 :     mbCallResize        = true;         // true: Resize must be called by Show
     250           0 :     mbWaitSystemResize  = true;         // true: Wait for System-Resize
     251           0 :     mbInitWinClipRegion = true;         // true: Calc Window Clip Region
     252           0 :     mbInitChildRegion   = false;        // true: InitChildClipRegion
     253           0 :     mbWinRegion         = false;        // true: Window Region
     254           0 :     mbClipChildren      = false;        // true: Child-window should be clipped
     255           0 :     mbClipSiblings      = false;        // true: Adjacent Child-window should be clipped
     256           0 :     mbChildTransparent  = false;        // true: Child-windows are allowed to switch to transparent (incl. Parent-CLIPCHILDREN)
     257           0 :     mbPaintTransparent  = false;        // true: Paints should be executed on the Parent
     258           0 :     mbMouseTransparent  = false;        // true: Window is transparent for Mouse
     259           0 :     mbDlgCtrlStart      = false;        // true: From here on own Dialog-Control
     260           0 :     mbFocusVisible      = false;        // true: Focus Visible
     261           0 :     mbUseNativeFocus    = false;
     262           0 :     mbNativeFocusVisible= false;        // true: native Focus Visible
     263           0 :     mbInShowFocus       = false;        // prevent recursion
     264           0 :     mbInHideFocus       = false;        // prevent recursion
     265           0 :     mbTrackVisible      = false;        // true: Tracking Visible
     266           0 :     mbControlForeground = false;        // true: Foreground-Property set
     267           0 :     mbControlBackground = false;        // true: Background-Property set
     268           0 :     mbAlwaysOnTop       = false;        // true: always visible for all others windows
     269           0 :     mbCompoundControl   = false;        // true: Composite Control => Listener...
     270           0 :     mbCompoundControlHasFocus = false;  // true: Composite Control has focus somewhere
     271           0 :     mbPaintDisabled     = false;        // true: Paint should not be executed
     272           0 :     mbAllResize         = false;        // true: Also sent ResizeEvents with 0,0
     273           0 :     mbInDtor            = false;        // true: We're still in Window-Dtor
     274           0 :     mbExtTextInput      = false;        // true: ExtTextInput-Mode is active
     275           0 :     mbInFocusHdl        = false;        // true: Within GetFocus-Handler
     276           0 :     mbCreatedWithToolkit = false;
     277           0 :     mbSuppressAccessibilityEvents = false; // true: do not send any accessibility events
     278           0 :     mbDrawSelectionBackground = false;    // true: draws transparent window background to indicate (toolbox) selection
     279           0 :     mbIsInTaskPaneList = false;           // true: window was added to the taskpanelist in the topmost system window
     280           0 :     mnNativeBackground  = 0;              // initialize later, depends on type
     281           0 :     mbCallHandlersDuringInputDisabled = false; // true: call event handlers even if input is disabled
     282           0 :     mbHelpTextDynamic = false;          // true: append help id in HELP_DEBUG case
     283           0 :     mbFakeFocusSet = false; // true: pretend as if the window has focus.
     284           0 :     mbHexpand = false;
     285           0 :     mbVexpand = false;
     286           0 :     mbExpand = false;
     287           0 :     mbFill = true;
     288           0 :     mbSecondary = false;
     289           0 :     mbNonHomogeneous = false;
     290           0 : }
     291             : 
     292           0 : WindowImpl::~WindowImpl()
     293             : {
     294           0 :     delete mpChildClipRegion;
     295           0 :     delete mpAccessibleInfos;
     296           0 :     delete mpControlFont;
     297           0 : }
     298             : 
     299             : // helper method to allow inline constructor even for pWindow!=NULL case
     300           0 : void ImplDelData::AttachToWindow( const Window* pWindow )
     301             : {
     302           0 :     if( pWindow )
     303           0 :         const_cast<Window*>(pWindow)->ImplAddDel( this );
     304           0 : }
     305             : 
     306             : // define dtor for ImplDelData
     307           0 : ImplDelData::~ImplDelData()
     308             : {
     309             :     // #112873# auto remove of ImplDelData
     310             :     // due to this code actively calling ImplRemoveDel() is not mandatory anymore
     311           0 :     if( !mbDel && mpWindow )
     312             :     {
     313             :         // the window still exists but we were not removed
     314           0 :         const_cast<Window*>(mpWindow)->ImplRemoveDel( this );
     315           0 :         mpWindow = NULL;
     316             :     }
     317           0 : }
     318             : 
     319             : #ifdef DBG_UTIL
     320             : const char* ImplDbgCheckWindow( const void* pObj )
     321             : {
     322             :     DBG_TESTSOLARMUTEX();
     323             : 
     324             :     const Window* pWindow = (Window*)pObj;
     325             : 
     326             :     if ( (pWindow->GetType() < WINDOW_FIRST) || (pWindow->GetType() > WINDOW_LAST) )
     327             :         return "Window data overwrite";
     328             : 
     329             :     // check window-chain
     330             :     Window* pChild = pWindow->mpWindowImpl->mpFirstChild;
     331             :     while ( pChild )
     332             :     {
     333             :         if ( pChild->mpWindowImpl->mpParent != pWindow )
     334             :             return "Child-Window-Parent wrong";
     335             :         pChild = pChild->mpWindowImpl->mpNext;
     336             :     }
     337             : 
     338             :     return NULL;
     339             : }
     340             : #endif
     341             : 
     342           0 : bool Window::ImplInitGraphics() const
     343             : {
     344             :     DBG_TESTSOLARMUTEX();
     345             : 
     346           0 :     if ( mpGraphics )
     347           0 :         return true;
     348             : 
     349           0 :     mbInitLineColor     = true;
     350           0 :     mbInitFillColor     = true;
     351           0 :     mbInitFont          = true;
     352           0 :     mbInitTextColor     = true;
     353           0 :     mbInitClipRegion    = true;
     354             : 
     355           0 :     ImplSVData* pSVData = ImplGetSVData();
     356             : 
     357           0 :     mpGraphics = mpWindowImpl->mpFrame->AcquireGraphics();
     358             :     // try harder if no wingraphics was available directly
     359           0 :     if ( !mpGraphics )
     360             :     {
     361             :         // find another output device in the same frame
     362           0 :         OutputDevice* pReleaseOutDev = pSVData->maGDIData.mpLastWinGraphics;
     363           0 :         while ( pReleaseOutDev )
     364             :         {
     365           0 :             if ( ((Window*)pReleaseOutDev)->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame )
     366           0 :                 break;
     367           0 :             pReleaseOutDev = pReleaseOutDev->mpPrevGraphics;
     368             :         }
     369             : 
     370           0 :         if ( pReleaseOutDev )
     371             :         {
     372             :             // steal the wingraphics from the other outdev
     373           0 :             mpGraphics = pReleaseOutDev->mpGraphics;
     374           0 :             pReleaseOutDev->ImplReleaseGraphics( false );
     375             :         }
     376             :         else
     377             :         {
     378             :             // if needed retry after releasing least recently used wingraphics
     379           0 :             while ( !mpGraphics )
     380             :             {
     381           0 :                 if ( !pSVData->maGDIData.mpLastWinGraphics )
     382           0 :                     break;
     383           0 :                 pSVData->maGDIData.mpLastWinGraphics->ImplReleaseGraphics();
     384           0 :                 mpGraphics = mpWindowImpl->mpFrame->AcquireGraphics();
     385             :             }
     386             :         }
     387             :     }
     388             : 
     389             :     // update global LRU list of wingraphics
     390           0 :     if ( mpGraphics )
     391             :     {
     392           0 :         mpNextGraphics = pSVData->maGDIData.mpFirstWinGraphics;
     393           0 :         pSVData->maGDIData.mpFirstWinGraphics = const_cast<Window*>(this);
     394           0 :         if ( mpNextGraphics )
     395           0 :             mpNextGraphics->mpPrevGraphics = const_cast<Window*>(this);
     396           0 :         if ( !pSVData->maGDIData.mpLastWinGraphics )
     397           0 :             pSVData->maGDIData.mpLastWinGraphics = const_cast<Window*>(this);
     398             :     }
     399             : 
     400           0 :     if ( mpGraphics )
     401             :     {
     402           0 :         mpGraphics->SetXORMode( (ROP_INVERT == meRasterOp) || (ROP_XOR == meRasterOp), ROP_INVERT == meRasterOp );
     403           0 :         mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW);
     404             :     }
     405             : 
     406           0 :     return mpGraphics ? true : false;
     407             : }
     408             : 
     409           0 : void Window::EnableRTL ( bool bEnable )
     410             : {
     411           0 :     StateChanged( STATE_CHANGE_MIRRORING );
     412           0 :     OutputDevice::EnableRTL(bEnable);
     413           0 : }
     414             : 
     415           0 : void Window::CopyAreaFinal( SalTwoRect& aPosAry, sal_uInt32 nFlags )
     416             : {
     417           0 :     if (aPosAry.mnSrcWidth == 0 || aPosAry.mnSrcHeight == 0 || aPosAry.mnDestWidth == 0 || aPosAry.mnDestHeight == 0)
     418           0 :         return;
     419             : 
     420           0 :     if (nFlags & COPYAREA_WINDOWINVALIDATE)
     421             :     {
     422             :         const Rectangle aSrcRect(Point(aPosAry.mnSrcX, aPosAry.mnSrcY),
     423           0 :                 Size(aPosAry.mnSrcWidth, aPosAry.mnSrcHeight));
     424             : 
     425             :         ImplMoveAllInvalidateRegions(aSrcRect,
     426             :                 aPosAry.mnDestX-aPosAry.mnSrcX,
     427             :                 aPosAry.mnDestY-aPosAry.mnSrcY,
     428           0 :                 false);
     429             : 
     430             :         mpGraphics->CopyArea(aPosAry.mnDestX, aPosAry.mnDestY,
     431             :                 aPosAry.mnSrcX, aPosAry.mnSrcY,
     432             :                 aPosAry.mnSrcWidth, aPosAry.mnSrcHeight,
     433           0 :                 SAL_COPYAREA_WINDOWINVALIDATE, this);
     434             : 
     435           0 :         return;
     436             :     }
     437             : 
     438           0 :     OutputDevice::CopyAreaFinal(aPosAry, nFlags);
     439             : }
     440             : 
     441           0 : void Window::ClipToPaintRegion(Rectangle& rDstRect)
     442             : {
     443           0 :     const Region aPaintRgn(GetPaintRegion());
     444             : 
     445           0 :     if (!aPaintRgn.IsNull())
     446           0 :         rDstRect.Intersection(LogicToPixel(aPaintRgn.GetBoundRect()));
     447           0 : }
     448             : 
     449           0 : void Window::ImplReleaseGraphics( bool bRelease )
     450             : {
     451             :     DBG_TESTSOLARMUTEX();
     452             : 
     453           0 :     if ( !mpGraphics )
     454           0 :         return;
     455             : 
     456             :     // release the fonts of the physically released graphics device
     457           0 :     if( bRelease )
     458           0 :         ImplReleaseFonts();
     459             : 
     460           0 :     ImplSVData* pSVData = ImplGetSVData();
     461             : 
     462           0 :     Window* pWindow = (Window*)this;
     463             : 
     464           0 :     if ( bRelease )
     465           0 :         pWindow->mpWindowImpl->mpFrame->ReleaseGraphics( mpGraphics );
     466             :     // remove from global LRU list of window graphics
     467           0 :     if ( mpPrevGraphics )
     468           0 :         mpPrevGraphics->mpNextGraphics = mpNextGraphics;
     469             :     else
     470           0 :         pSVData->maGDIData.mpFirstWinGraphics = mpNextGraphics;
     471           0 :     if ( mpNextGraphics )
     472           0 :         mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
     473             :     else
     474           0 :         pSVData->maGDIData.mpLastWinGraphics = mpPrevGraphics;
     475             : 
     476           0 :     mpGraphics      = NULL;
     477           0 :     mpPrevGraphics  = NULL;
     478           0 :     mpNextGraphics  = NULL;
     479             : }
     480             : 
     481           0 : bool Window::HasMirroredGraphics() const
     482             : {
     483           0 :     const OutputDevice* pOutDev = GetOutDev();
     484           0 :     return pOutDev->OutputDevice::HasMirroredGraphics();
     485             : }
     486             : 
     487           0 : void Window::ImplInitAppFontData( Window* pWindow )
     488             : {
     489           0 :     ImplSVData* pSVData = ImplGetSVData();
     490           0 :     long nTextHeight = pWindow->GetTextHeight();
     491           0 :     long nTextWidth = pWindow->approximate_char_width() * 8;
     492           0 :     long nSymHeight = nTextHeight*4;
     493             :     // Make the basis wider if the font is too narrow
     494             :     // such that the dialog looks symmetrical and does not become too narrow.
     495             :     // Add some extra space when the dialog has the same width,
     496             :     // as a little more space is better.
     497           0 :     if ( nSymHeight > nTextWidth )
     498           0 :         nTextWidth = nSymHeight;
     499           0 :     else if ( nSymHeight+5 > nTextWidth )
     500           0 :         nTextWidth = nSymHeight+5;
     501           0 :     pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8;
     502           0 :     pSVData->maGDIData.mnAppFontY = nTextHeight * 10;
     503             : 
     504             :     // FIXME: this is currently only on OS X, check with other
     505             :     // platforms
     506           0 :     if( pSVData->maNWFData.mbNoFocusRects )
     507             :     {
     508             :         // try to find out whether there is a large correction
     509             :         // of control sizes, if yes, make app font scalings larger
     510             :         // so dialog positioning is not completely off
     511           0 :         ImplControlValue aControlValue;
     512           0 :         Rectangle aCtrlRegion( Point(), Size( nTextWidth < 10 ? 10 : nTextWidth, nTextHeight < 10 ? 10 : nTextHeight ) );
     513           0 :         Rectangle aBoundingRgn( aCtrlRegion );
     514           0 :         Rectangle aContentRgn( aCtrlRegion );
     515           0 :         if( pWindow->GetNativeControlRegion( CTRL_EDITBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
     516             :                                              CTRL_STATE_ENABLED, aControlValue, OUString(),
     517           0 :                                              aBoundingRgn, aContentRgn ) )
     518             :         {
     519             :             // comment: the magical +6 is for the extra border in bordered
     520             :             // (which is the standard) edit fields
     521           0 :             if( aContentRgn.GetHeight() - nTextHeight > (nTextHeight+4)/4 )
     522           0 :                 pSVData->maGDIData.mnAppFontY = (aContentRgn.GetHeight()-4) * 10;
     523           0 :         }
     524             :     }
     525             : 
     526           0 :     pSVData->maGDIData.mnRealAppFontX = pSVData->maGDIData.mnAppFontX;
     527           0 :     if ( pSVData->maAppData.mnDialogScaleX )
     528           0 :         pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100;
     529           0 : }
     530             : 
     531           0 : bool Window::ImplCheckUIFont( const Font& rFont )
     532             : {
     533           0 :     if( ImplGetSVData()->maGDIData.mbNativeFontConfig )
     534           0 :         return true;
     535             : 
     536             :     // create a text string using the localized text of important buttons
     537           0 :     OUString aTestText;
     538             :     static const StandardButtonType aTestButtons[] =
     539             :     {
     540             :         BUTTON_OK, BUTTON_CANCEL, BUTTON_CLOSE, BUTTON_ABORT,
     541             :         BUTTON_YES, BUTTON_NO, BUTTON_MORE, BUTTON_IGNORE,
     542             :         BUTTON_RETRY, BUTTON_HELP
     543             :     };
     544             : 
     545           0 :     const int nTestButtonCount = SAL_N_ELEMENTS(aTestButtons);
     546           0 :     for( int n = 0; n < nTestButtonCount; ++n )
     547             :     {
     548           0 :         OUString aButtonStr = Button::GetStandardText( aTestButtons[n] );
     549             :         // #i115432# ignore mnemonic+accelerator part of each string
     550             :         // TODO: use a string filtering method when it becomes available
     551           0 :         const sal_Int32 nLen = aButtonStr.getLength();
     552           0 :         bool bInside = false;
     553           0 :         for( int i = 0; i < nLen; ++i ) {
     554           0 :             const sal_Unicode c = aButtonStr[ i ];
     555           0 :             if( (c == '('))
     556           0 :                 bInside = true;
     557           0 :             if( (c == ')'))
     558           0 :                 bInside = false;
     559           0 :             if( (c == '~')
     560           0 :             ||  (c == '(') || (c == ')')
     561           0 :             || ((c >= 'A') && (c <= 'Z') && bInside) )
     562           0 :                 aButtonStr = aButtonStr.replaceAt( i, 1, " " );
     563             :         }
     564             :         // append sanitized button text to test string
     565           0 :         aTestText += aButtonStr;
     566           0 :     }
     567             : 
     568           0 :     const bool bUIFontOk = ( HasGlyphs( rFont, aTestText ) == -1 );
     569           0 :     return bUIFontOk;
     570             : }
     571             : 
     572           0 : void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, bool bCallHdl )
     573             : {
     574           0 :     StyleSettings aTmpSt( rSettings.GetStyleSettings() );
     575           0 :     aTmpSt.SetHighContrastMode( false );
     576           0 :     rSettings.SetStyleSettings( aTmpSt );
     577           0 :     ImplGetFrame()->UpdateSettings( rSettings );
     578             :     // reset default border width for layouters
     579           0 :     ImplGetSVData()->maAppData.mnDefaultLayoutBorder = -1;
     580             : 
     581             :     // Verify availability of the configured UI font, otherwise choose "Andale Sans UI"
     582             : 
     583             :     // WTF, what makes Andale Sans UI a suitable cross-platform fallback font?
     584             : 
     585           0 :     OUString aUserInterfaceFont;
     586           0 :     bool bUseSystemFont = rSettings.GetStyleSettings().GetUseSystemUIFonts();
     587             : 
     588             :     // check whether system UI font can display a typical UI text
     589           0 :     if( bUseSystemFont )
     590           0 :         bUseSystemFont = ImplCheckUIFont( rSettings.GetStyleSettings().GetAppFont() );
     591             : 
     592           0 :     if ( !bUseSystemFont )
     593             :     {
     594           0 :         OutputDevice *pOutDev = GetOutDev();
     595           0 :         pOutDev->ImplInitFontList();
     596           0 :         OUString aConfigFont = utl::DefaultFontConfiguration::get().getUserInterfaceFont( rSettings.GetUILanguageTag() );
     597           0 :         sal_Int32 nIndex = 0;
     598           0 :         while( nIndex != -1 )
     599             :         {
     600           0 :             OUString aName( aConfigFont.getToken( 0, ';', nIndex ) );
     601           0 :             if ( !aName.isEmpty() && mpWindowImpl->mpFrameData->mpFontCollection->FindFontFamily( aName ) )
     602             :             {
     603           0 :                 aUserInterfaceFont = aConfigFont;
     604           0 :                 break;
     605             :             }
     606           0 :         }
     607             : 
     608           0 :         if ( aUserInterfaceFont.isEmpty() )
     609             :         {
     610           0 :             OUString aFallbackFont ("Andale Sans UI" );
     611           0 :             if ( mpWindowImpl->mpFrameData->mpFontCollection->FindFontFamily( aFallbackFont ) )
     612           0 :                 aUserInterfaceFont = aFallbackFont;
     613           0 :         }
     614             :     }
     615             : 
     616           0 :     if ( !bUseSystemFont && !aUserInterfaceFont.isEmpty() )
     617             :     {
     618           0 :         StyleSettings aStyleSettings = rSettings.GetStyleSettings();
     619           0 :         Font aFont = aStyleSettings.GetAppFont();
     620           0 :         aFont.SetName( aUserInterfaceFont );
     621           0 :         aStyleSettings.SetAppFont( aFont );
     622           0 :         aFont = aStyleSettings.GetHelpFont();
     623           0 :         aFont.SetName( aUserInterfaceFont );
     624           0 :         aStyleSettings.SetHelpFont( aFont );
     625           0 :         aFont = aStyleSettings.GetTitleFont();
     626           0 :         aFont.SetName( aUserInterfaceFont );
     627           0 :         aStyleSettings.SetTitleFont( aFont );
     628           0 :         aFont = aStyleSettings.GetFloatTitleFont();
     629           0 :         aFont.SetName( aUserInterfaceFont );
     630           0 :         aStyleSettings.SetFloatTitleFont( aFont );
     631           0 :         aFont = aStyleSettings.GetMenuFont();
     632           0 :         aFont.SetName( aUserInterfaceFont );
     633           0 :         aStyleSettings.SetMenuFont( aFont );
     634           0 :         aFont = aStyleSettings.GetToolFont();
     635           0 :         aFont.SetName( aUserInterfaceFont );
     636           0 :         aStyleSettings.SetToolFont( aFont );
     637           0 :         aFont = aStyleSettings.GetLabelFont();
     638           0 :         aFont.SetName( aUserInterfaceFont );
     639           0 :         aStyleSettings.SetLabelFont( aFont );
     640           0 :         aFont = aStyleSettings.GetInfoFont();
     641           0 :         aFont.SetName( aUserInterfaceFont );
     642           0 :         aStyleSettings.SetInfoFont( aFont );
     643           0 :         aFont = aStyleSettings.GetRadioCheckFont();
     644           0 :         aFont.SetName( aUserInterfaceFont );
     645           0 :         aStyleSettings.SetRadioCheckFont( aFont );
     646           0 :         aFont = aStyleSettings.GetPushButtonFont();
     647           0 :         aFont.SetName( aUserInterfaceFont );
     648           0 :         aStyleSettings.SetPushButtonFont( aFont );
     649           0 :         aFont = aStyleSettings.GetFieldFont();
     650           0 :         aFont.SetName( aUserInterfaceFont );
     651           0 :         aStyleSettings.SetFieldFont( aFont );
     652           0 :         aFont = aStyleSettings.GetIconFont();
     653           0 :         aFont.SetName( aUserInterfaceFont );
     654           0 :         aStyleSettings.SetIconFont( aFont );
     655           0 :         aFont = aStyleSettings.GetGroupFont();
     656           0 :         aFont.SetName( aUserInterfaceFont );
     657           0 :         aStyleSettings.SetGroupFont( aFont );
     658           0 :         rSettings.SetStyleSettings( aStyleSettings );
     659             :     }
     660             : 
     661           0 :     StyleSettings aStyleSettings = rSettings.GetStyleSettings();
     662             :     // #97047: Force all fonts except Menu and Help to a fixed height
     663             :     // to avoid UI scaling due to large fonts
     664             :     // - but allow bigger fonts on bigger screens (i16682, i21238)
     665             :     //   dialogs were designed to fit 800x600 with an 8pt font, so scale accordingly
     666           0 :     int maxFontheight = 9; // #107886#: 9 is default for some asian systems, so always allow if requested
     667           0 :     if( GetDesktopRectPixel().getHeight() > 600 )
     668           0 :         maxFontheight = (int) ((( 8.0 * (double) GetDesktopRectPixel().getHeight()) / 600.0) + 1.5);
     669             : 
     670           0 :     Font aFont = aStyleSettings.GetMenuFont();
     671           0 :     int defFontheight = aFont.GetHeight();
     672           0 :     if( defFontheight > maxFontheight )
     673           0 :         defFontheight = maxFontheight;
     674             : 
     675             :     // if the UI is korean, chinese or another locale
     676             :     // where the system font size is kown to be often too small to
     677             :     // generate readable fonts enforce a minimum font size of 9 points
     678           0 :     bool bBrokenLangFontHeight = MsLangId::isCJK(Application::GetSettings().GetUILanguageTag().getLanguageType());
     679           0 :     if (bBrokenLangFontHeight)
     680           0 :         defFontheight = std::max(9, defFontheight);
     681             : 
     682             :     // i22098, toolfont will be scaled differently to avoid bloated rulers and status bars for big fonts
     683           0 :     int toolfontheight = defFontheight;
     684           0 :     if( toolfontheight > 9 )
     685           0 :         toolfontheight = (defFontheight+8) / 2;
     686             : 
     687           0 :     aFont = aStyleSettings.GetAppFont();
     688           0 :     aFont.SetHeight( defFontheight );
     689           0 :     aStyleSettings.SetAppFont( aFont );
     690           0 :     aFont = aStyleSettings.GetTitleFont();
     691           0 :     aFont.SetHeight( defFontheight );
     692           0 :     aStyleSettings.SetTitleFont( aFont );
     693           0 :     aFont = aStyleSettings.GetFloatTitleFont();
     694           0 :     aFont.SetHeight( defFontheight );
     695           0 :     aStyleSettings.SetFloatTitleFont( aFont );
     696             :     // keep menu and help font size from system unless in broken locale size
     697           0 :     if( bBrokenLangFontHeight )
     698             :     {
     699           0 :         aFont = aStyleSettings.GetMenuFont();
     700           0 :         if( aFont.GetHeight() < defFontheight )
     701             :         {
     702           0 :             aFont.SetHeight( defFontheight );
     703           0 :             aStyleSettings.SetMenuFont( aFont );
     704             :         }
     705           0 :         aFont = aStyleSettings.GetHelpFont();
     706           0 :         if( aFont.GetHeight() < defFontheight )
     707             :         {
     708           0 :             aFont.SetHeight( defFontheight );
     709           0 :             aStyleSettings.SetHelpFont( aFont );
     710             :         }
     711             :     }
     712             : 
     713             :     // use different height for toolfont
     714           0 :     aFont = aStyleSettings.GetToolFont();
     715           0 :     aFont.SetHeight( toolfontheight );
     716           0 :     aStyleSettings.SetToolFont( aFont );
     717             : 
     718           0 :     aFont = aStyleSettings.GetLabelFont();
     719           0 :     aFont.SetHeight( defFontheight );
     720           0 :     aStyleSettings.SetLabelFont( aFont );
     721           0 :     aFont = aStyleSettings.GetInfoFont();
     722           0 :     aFont.SetHeight( defFontheight );
     723           0 :     aStyleSettings.SetInfoFont( aFont );
     724           0 :     aFont = aStyleSettings.GetRadioCheckFont();
     725           0 :     aFont.SetHeight( defFontheight );
     726           0 :     aStyleSettings.SetRadioCheckFont( aFont );
     727           0 :     aFont = aStyleSettings.GetPushButtonFont();
     728           0 :     aFont.SetHeight( defFontheight );
     729           0 :     aStyleSettings.SetPushButtonFont( aFont );
     730           0 :     aFont = aStyleSettings.GetFieldFont();
     731           0 :     aFont.SetHeight( defFontheight );
     732           0 :     aStyleSettings.SetFieldFont( aFont );
     733           0 :     aFont = aStyleSettings.GetIconFont();
     734           0 :     aFont.SetHeight( defFontheight );
     735           0 :     aStyleSettings.SetIconFont( aFont );
     736           0 :     aFont = aStyleSettings.GetGroupFont();
     737           0 :     aFont.SetHeight( defFontheight );
     738           0 :     aStyleSettings.SetGroupFont( aFont );
     739             : 
     740           0 :     rSettings.SetStyleSettings( aStyleSettings );
     741             : 
     742           0 :     bool bForceHCMode = false;
     743             : 
     744             :     // auto detect HC mode; if the system already set it to "yes"
     745             :     // (see above) then accept that
     746           0 :     if( !rSettings.GetStyleSettings().GetHighContrastMode() )
     747             :     {
     748           0 :         bool bTmp = false, bAutoHCMode = true;
     749             :         utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithComponentContext(
     750             :             comphelper::getProcessComponentContext(),
     751           0 :             OUString("org.openoffice.Office.Common/Accessibility") );    // note: case sensitive !
     752           0 :         if ( aNode.isValid() )
     753             :         {
     754           0 :             ::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString("AutoDetectSystemHC") );
     755           0 :             if( aValue >>= bTmp )
     756           0 :                 bAutoHCMode = bTmp;
     757             :         }
     758           0 :         if( bAutoHCMode )
     759             :         {
     760           0 :             if( rSettings.GetStyleSettings().GetFaceColor().IsDark() ||
     761           0 :                 rSettings.GetStyleSettings().GetWindowColor().IsDark() )
     762           0 :                 bForceHCMode = true;
     763           0 :         }
     764             :     }
     765             : 
     766           0 :     static const char* pEnvHC = getenv( "SAL_FORCE_HC" );
     767           0 :     if( pEnvHC && *pEnvHC )
     768           0 :         bForceHCMode = true;
     769             : 
     770           0 :     if( bForceHCMode )
     771             :     {
     772           0 :         aStyleSettings = rSettings.GetStyleSettings();
     773           0 :         aStyleSettings.SetHighContrastMode( true );
     774           0 :         rSettings.SetStyleSettings( aStyleSettings );
     775             :     }
     776             : 
     777             : #if defined(DBG_UTIL)
     778             :     // If needed, set AppFont to bold, in order to check
     779             :     // if there is enough space available for texts on other systems
     780             :     if ( DbgIsBoldAppFont() )
     781             :     {
     782             :         aStyleSettings = rSettings.GetStyleSettings();
     783             :         aFont = aStyleSettings.GetAppFont();
     784             :         aFont.SetWeight( WEIGHT_BOLD );
     785             :         aStyleSettings.SetAppFont( aFont );
     786             :         aFont = aStyleSettings.GetGroupFont();
     787             :         aFont.SetWeight( WEIGHT_BOLD );
     788             :         aStyleSettings.SetGroupFont( aFont );
     789             :         aFont = aStyleSettings.GetLabelFont();
     790             :         aFont.SetWeight( WEIGHT_BOLD );
     791             :         aStyleSettings.SetLabelFont( aFont );
     792             :         aFont = aStyleSettings.GetRadioCheckFont();
     793             :         aFont.SetWeight( WEIGHT_BOLD );
     794             :         aStyleSettings.SetRadioCheckFont( aFont );
     795             :         aFont = aStyleSettings.GetPushButtonFont();
     796             :         aFont.SetWeight( WEIGHT_BOLD );
     797             :         aStyleSettings.SetPushButtonFont( aFont );
     798             :         aFont = aStyleSettings.GetFieldFont();
     799             :         aFont.SetWeight( WEIGHT_BOLD );
     800             :         aStyleSettings.SetFieldFont( aFont );
     801             :         aFont = aStyleSettings.GetIconFont();
     802             :         aFont.SetWeight( WEIGHT_BOLD );
     803             :         aStyleSettings.SetIconFont( aFont );
     804             :         rSettings.SetStyleSettings( aStyleSettings );
     805             :     }
     806             : #endif
     807             : 
     808           0 :     if ( bCallHdl )
     809           0 :         GetpApp()->OverrideSystemSettings( rSettings );
     810           0 : }
     811             : 
     812           0 : MouseEvent ImplTranslateMouseEvent( const MouseEvent& rE, Window* pSource, Window* pDest )
     813             : {
     814           0 :     Point aPos = pSource->OutputToScreenPixel( rE.GetPosPixel() );
     815           0 :     aPos = pDest->ScreenToOutputPixel( aPos );
     816           0 :     return MouseEvent( aPos, rE.GetClicks(), rE.GetMode(), rE.GetButtons(), rE.GetModifier() );
     817             : }
     818             : 
     819           0 : CommandEvent ImplTranslateCommandEvent( const CommandEvent& rCEvt, Window* pSource, Window* pDest )
     820             : {
     821           0 :     if ( !rCEvt.IsMouseEvent() )
     822           0 :         return rCEvt;
     823             : 
     824           0 :     Point aPos = pSource->OutputToScreenPixel( rCEvt.GetMousePosPixel() );
     825           0 :     aPos = pDest->ScreenToOutputPixel( aPos );
     826           0 :     return CommandEvent( aPos, rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() );
     827             : }
     828             : 
     829           0 : void Window::ImplInitWindowData( WindowType nType )
     830             : {
     831             :     // We will eventually being removing the inheritance of OutputDevice from Window.
     832             :     // It will be replaced with a composition relationship. A Window will use an OutputDevice,
     833             :     // it will not *be* an OutputDevice
     834           0 :     mpOutputDevice = (OutputDevice*)this;
     835             : 
     836           0 :     mpWindowImpl = new WindowImpl( nType );
     837             : 
     838           0 :     meOutDevType        = OUTDEV_WINDOW;
     839             : 
     840           0 :     mbEnableRTL         = Application::GetSettings().GetLayoutRTL();         // true: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active
     841           0 : }
     842             : 
     843           0 : static bool ImplDoTiledRendering()
     844             : {
     845             : #if !HAVE_FEATURE_DESKTOP
     846             :     // We do tiled rendering only for iOS at the moment, actually, but
     847             :     // let's see what happens if we assume it for Android, too.
     848             :     return true;
     849             : #else
     850             :     // We need some way to know globally if this process will use
     851             :     // tiled rendering or not. Or should this be a per-window setting?
     852             :     // Or what?
     853           0 :     return false;
     854             : #endif
     855             : }
     856             : 
     857           0 : static sal_Int32 CountDPIScaleFactor(sal_Int32 nDPI)
     858             : {
     859           0 :     sal_Int32 nResult = 1;
     860             : 
     861             : #ifndef MACOSX
     862             :     // Setting of HiDPI is unfortunately all only a heuristic; and to add
     863             :     // insult to an injury, the system is constantly lying to us about
     864             :     // the DPI and whatnot
     865             :     // eg. fdo#77059 - set the value from which we do consider the
     866             :     // screen hi-dpi to greater than 168
     867           0 :     if (nDPI > 168)
     868           0 :         nResult = std::max(sal_Int32(1), (nDPI + 48) / 96);
     869             : #else
     870             :     (void)nDPI;
     871             : #endif
     872             : 
     873           0 :     return nResult;
     874             : }
     875             : 
     876           0 : void Window::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
     877             : {
     878             :     DBG_ASSERT( mpWindowImpl->mbFrame || pParent, "Window::Window(): pParent == NULL" );
     879             : 
     880           0 :     ImplSVData* pSVData = ImplGetSVData();
     881           0 :     Window*     pRealParent = pParent;
     882             : 
     883             :     // 3D-Look vererben
     884           0 :     if ( !mpWindowImpl->mbOverlapWin && pParent && (pParent->GetStyle() & WB_3DLOOK) )
     885           0 :         nStyle |= WB_3DLOOK;
     886             : 
     887             :     // create border window if necessary
     888           0 :     if ( !mpWindowImpl->mbFrame && !mpWindowImpl->mbBorderWin && !mpWindowImpl->mpBorderWindow
     889           0 :          && (nStyle & (WB_BORDER | WB_SYSTEMCHILDWINDOW) ) )
     890             :     {
     891           0 :         sal_uInt16 nBorderTypeStyle = 0;
     892           0 :         if( (nStyle & WB_SYSTEMCHILDWINDOW) )
     893             :         {
     894             :             // handle WB_SYSTEMCHILDWINDOW
     895             :             // these should be analogous to a top level frame; meaning they
     896             :             // should have a border window with style BORDERWINDOW_STYLE_FRAME
     897             :             // which controls their size
     898           0 :             nBorderTypeStyle |= BORDERWINDOW_STYLE_FRAME;
     899           0 :             nStyle |= WB_BORDER;
     900             :         }
     901           0 :         ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
     902           0 :         ((Window*)pBorderWin)->mpWindowImpl->mpClientWindow = this;
     903           0 :         pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
     904           0 :         mpWindowImpl->mpBorderWindow  = pBorderWin;
     905           0 :         pParent = mpWindowImpl->mpBorderWindow;
     906             :     }
     907           0 :     else if( !mpWindowImpl->mbFrame && ! pParent )
     908             :     {
     909           0 :         mpWindowImpl->mbOverlapWin  = true;
     910           0 :         mpWindowImpl->mbFrame = true;
     911             :     }
     912             : 
     913             :     // insert window in list
     914           0 :     ImplInsertWindow( pParent );
     915           0 :     mpWindowImpl->mnStyle = nStyle;
     916             : 
     917             :     // Overlap-Window-Data
     918           0 :     if ( mpWindowImpl->mbOverlapWin )
     919             :     {
     920           0 :         mpWindowImpl->mpOverlapData                   = new ImplOverlapData;
     921           0 :         mpWindowImpl->mpOverlapData->mpSaveBackDev    = NULL;
     922           0 :         mpWindowImpl->mpOverlapData->mpSaveBackRgn    = NULL;
     923           0 :         mpWindowImpl->mpOverlapData->mpNextBackWin    = NULL;
     924           0 :         mpWindowImpl->mpOverlapData->mnSaveBackSize   = 0;
     925           0 :         mpWindowImpl->mpOverlapData->mbSaveBack       = false;
     926           0 :         mpWindowImpl->mpOverlapData->mnTopLevel       = 1;
     927             :     }
     928             : 
     929           0 :     if( pParent && ! mpWindowImpl->mbFrame )
     930           0 :         mbEnableRTL = Application::GetSettings().GetLayoutRTL();
     931             : 
     932             :     // test for frame creation
     933           0 :     if ( mpWindowImpl->mbFrame )
     934             :     {
     935             :         // create frame
     936           0 :         sal_uLong nFrameStyle = 0;
     937             : 
     938           0 :         if ( nStyle & WB_MOVEABLE )
     939           0 :             nFrameStyle |= SAL_FRAME_STYLE_MOVEABLE;
     940           0 :         if ( nStyle & WB_SIZEABLE )
     941           0 :             nFrameStyle |= SAL_FRAME_STYLE_SIZEABLE;
     942           0 :         if ( nStyle & WB_CLOSEABLE )
     943           0 :             nFrameStyle |= SAL_FRAME_STYLE_CLOSEABLE;
     944           0 :         if ( nStyle & WB_APP )
     945           0 :             nFrameStyle |= SAL_FRAME_STYLE_DEFAULT;
     946             :         // check for undecorated floating window
     947           0 :         if( // 1. floating windows that are not moveable/sizeable (only closeable allowed)
     948           0 :             ( !(nFrameStyle & ~SAL_FRAME_STYLE_CLOSEABLE) &&
     949           0 :             ( mpWindowImpl->mbFloatWin || ((GetType() == WINDOW_BORDERWINDOW) && ((ImplBorderWindow*)this)->mbFloatWindow) || (nStyle & WB_SYSTEMFLOATWIN) ) ) ||
     950             :             // 2. borderwindows of floaters with ownerdraw decoration
     951           0 :             ( ((GetType() == WINDOW_BORDERWINDOW) && ((ImplBorderWindow*)this)->mbFloatWindow && (nStyle & WB_OWNERDRAWDECORATION) ) ) )
     952             :         {
     953           0 :             nFrameStyle = SAL_FRAME_STYLE_FLOAT;
     954           0 :             if( nStyle & WB_OWNERDRAWDECORATION )
     955           0 :                 nFrameStyle |= (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_NOSHADOW);
     956           0 :             if( nStyle & WB_NEEDSFOCUS )
     957           0 :                 nFrameStyle |= SAL_FRAME_STYLE_FLOAT_FOCUSABLE;
     958             :         }
     959           0 :         else if( mpWindowImpl->mbFloatWin )
     960           0 :             nFrameStyle |= SAL_FRAME_STYLE_TOOLWINDOW;
     961             : 
     962           0 :         if( nStyle & WB_INTROWIN )
     963           0 :             nFrameStyle |= SAL_FRAME_STYLE_INTRO;
     964           0 :         if( nStyle & WB_TOOLTIPWIN )
     965           0 :             nFrameStyle |= SAL_FRAME_STYLE_TOOLTIP;
     966             : 
     967           0 :         if( nStyle & WB_NOSHADOW )
     968           0 :             nFrameStyle |= SAL_FRAME_STYLE_NOSHADOW;
     969             : 
     970           0 :         if( nStyle & WB_SYSTEMCHILDWINDOW )
     971           0 :             nFrameStyle |= SAL_FRAME_STYLE_SYSTEMCHILD;
     972             : 
     973           0 :         switch (mpWindowImpl->mnType)
     974             :         {
     975             :             case WINDOW_DIALOG:
     976             :             case WINDOW_TABDIALOG:
     977             :             case WINDOW_MODALDIALOG:
     978             :             case WINDOW_MODELESSDIALOG:
     979             :             case WINDOW_MESSBOX:
     980             :             case WINDOW_INFOBOX:
     981             :             case WINDOW_WARNINGBOX:
     982             :             case WINDOW_ERRORBOX:
     983             :             case WINDOW_QUERYBOX:
     984           0 :                 nFrameStyle |= SAL_FRAME_STYLE_DIALOG;
     985             :             default:
     986           0 :                 break;
     987             :         }
     988             : 
     989           0 :         SalFrame* pParentFrame = NULL;
     990           0 :         if ( pParent )
     991           0 :             pParentFrame = pParent->mpWindowImpl->mpFrame;
     992             :         SalFrame* pFrame;
     993           0 :         if ( pSystemParentData )
     994           0 :             pFrame = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SAL_FRAME_STYLE_PLUG );
     995             :         else
     996           0 :             pFrame = pSVData->mpDefInst->CreateFrame( pParentFrame, nFrameStyle );
     997           0 :         if ( !pFrame )
     998             :         {
     999             :             // do not abort but throw an exception, may be the current thread terminates anyway (plugin-scenario)
    1000             :             throw ::com::sun::star::uno::RuntimeException(
    1001             :                 OUString( "Could not create system window!"  ),
    1002           0 :                 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
    1003             :         }
    1004             : 
    1005           0 :         pFrame->SetCallback( this, ImplWindowFrameProc );
    1006             : 
    1007             :         // set window frame data
    1008           0 :         mpWindowImpl->mpFrameData     = new ImplFrameData;
    1009           0 :         mpWindowImpl->mpFrame         = pFrame;
    1010           0 :         mpWindowImpl->mpFrameWindow   = this;
    1011           0 :         mpWindowImpl->mpOverlapWindow = this;
    1012             : 
    1013             :         // set frame data
    1014           0 :         mpWindowImpl->mpFrameData->mpNextFrame        = pSVData->maWinData.mpFirstFrame;
    1015           0 :         pSVData->maWinData.mpFirstFrame = this;
    1016           0 :         mpWindowImpl->mpFrameData->mpFirstOverlap     = NULL;
    1017           0 :         mpWindowImpl->mpFrameData->mpFocusWin         = NULL;
    1018           0 :         mpWindowImpl->mpFrameData->mpMouseMoveWin     = NULL;
    1019           0 :         mpWindowImpl->mpFrameData->mpMouseDownWin     = NULL;
    1020           0 :         mpWindowImpl->mpFrameData->mpFirstBackWin     = NULL;
    1021           0 :         mpWindowImpl->mpFrameData->mpFontCollection   = pSVData->maGDIData.mpScreenFontList;
    1022           0 :         mpWindowImpl->mpFrameData->mpFontCache        = pSVData->maGDIData.mpScreenFontCache;
    1023           0 :         mpWindowImpl->mpFrameData->mnAllSaveBackSize  = 0;
    1024           0 :         mpWindowImpl->mpFrameData->mnFocusId          = 0;
    1025           0 :         mpWindowImpl->mpFrameData->mnMouseMoveId      = 0;
    1026           0 :         mpWindowImpl->mpFrameData->mnLastMouseX       = -1;
    1027           0 :         mpWindowImpl->mpFrameData->mnLastMouseY       = -1;
    1028           0 :         mpWindowImpl->mpFrameData->mnBeforeLastMouseX = -1;
    1029           0 :         mpWindowImpl->mpFrameData->mnBeforeLastMouseY = -1;
    1030           0 :         mpWindowImpl->mpFrameData->mnFirstMouseX      = -1;
    1031           0 :         mpWindowImpl->mpFrameData->mnFirstMouseY      = -1;
    1032           0 :         mpWindowImpl->mpFrameData->mnLastMouseWinX    = -1;
    1033           0 :         mpWindowImpl->mpFrameData->mnLastMouseWinY    = -1;
    1034           0 :         mpWindowImpl->mpFrameData->mnModalMode        = 0;
    1035           0 :         mpWindowImpl->mpFrameData->mnMouseDownTime    = 0;
    1036           0 :         mpWindowImpl->mpFrameData->mnClickCount       = 0;
    1037           0 :         mpWindowImpl->mpFrameData->mnFirstMouseCode   = 0;
    1038           0 :         mpWindowImpl->mpFrameData->mnMouseCode        = 0;
    1039           0 :         mpWindowImpl->mpFrameData->mnMouseMode        = 0;
    1040           0 :         mpWindowImpl->mpFrameData->meMapUnit          = MAP_PIXEL;
    1041           0 :         mpWindowImpl->mpFrameData->mbHasFocus         = false;
    1042           0 :         mpWindowImpl->mpFrameData->mbInMouseMove      = false;
    1043           0 :         mpWindowImpl->mpFrameData->mbMouseIn          = false;
    1044           0 :         mpWindowImpl->mpFrameData->mbStartDragCalled  = false;
    1045           0 :         mpWindowImpl->mpFrameData->mbNeedSysWindow    = false;
    1046           0 :         mpWindowImpl->mpFrameData->mbMinimized        = false;
    1047           0 :         mpWindowImpl->mpFrameData->mbStartFocusState  = false;
    1048           0 :         mpWindowImpl->mpFrameData->mbInSysObjFocusHdl = false;
    1049           0 :         mpWindowImpl->mpFrameData->mbInSysObjToTopHdl = false;
    1050           0 :         mpWindowImpl->mpFrameData->mbSysObjFocus      = false;
    1051           0 :         if (!ImplDoTiledRendering())
    1052             :         {
    1053           0 :             mpWindowImpl->mpFrameData->maPaintTimer.SetTimeout( 30 );
    1054           0 :             mpWindowImpl->mpFrameData->maPaintTimer.SetTimeoutHdl( LINK( this, Window, ImplHandlePaintHdl ) );
    1055             :         }
    1056           0 :         mpWindowImpl->mpFrameData->maResizeTimer.SetTimeout( 50 );
    1057           0 :         mpWindowImpl->mpFrameData->maResizeTimer.SetTimeoutHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) );
    1058           0 :         mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = false;
    1059             : 
    1060           0 :         if ( pRealParent && IsTopWindow() )
    1061             :         {
    1062           0 :             ImplWinData* pParentWinData = pRealParent->ImplGetWinData();
    1063           0 :             pParentWinData->maTopWindowChildren.push_back( this );
    1064             :         }
    1065             :     }
    1066             : 
    1067             :     // init data
    1068           0 :     mpWindowImpl->mpRealParent = pRealParent;
    1069             : 
    1070             :     // #99318: make sure fontcache and list is available before call to SetSettings
    1071           0 :     mpFontCollection      = mpWindowImpl->mpFrameData->mpFontCollection;
    1072           0 :     mpFontCache     = mpWindowImpl->mpFrameData->mpFontCache;
    1073             : 
    1074           0 :     if ( mpWindowImpl->mbFrame )
    1075             :     {
    1076           0 :         if ( pParent )
    1077             :         {
    1078           0 :             mpWindowImpl->mpFrameData->mnDPIX     = pParent->mpWindowImpl->mpFrameData->mnDPIX;
    1079           0 :             mpWindowImpl->mpFrameData->mnDPIY     = pParent->mpWindowImpl->mpFrameData->mnDPIY;
    1080             :         }
    1081             :         else
    1082             :         {
    1083           0 :             OutputDevice *pOutDev = GetOutDev();
    1084           0 :             if ( pOutDev->ImplGetGraphics() )
    1085             :             {
    1086           0 :                 mpGraphics->GetResolution( mpWindowImpl->mpFrameData->mnDPIX, mpWindowImpl->mpFrameData->mnDPIY );
    1087             :             }
    1088             :         }
    1089             : 
    1090             :         // add ownerdraw decorated frame windows to list in the top-most frame window
    1091             :         // so they can be hidden on lose focus
    1092           0 :         if( nStyle & WB_OWNERDRAWDECORATION )
    1093           0 :             ImplGetOwnerDrawList().push_back( this );
    1094             : 
    1095             :         // delay settings initialization until first "real" frame
    1096             :         // this relies on the IntroWindow not needing any system settings
    1097           0 :         if ( !pSVData->maAppData.mbSettingsInit &&
    1098           0 :              ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN))
    1099             :              )
    1100             :         {
    1101             :             // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
    1102           0 :             ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
    1103           0 :             OutputDevice::SetSettings( *pSVData->maAppData.mpSettings );
    1104           0 :             pSVData->maAppData.mbSettingsInit = true;
    1105             :         }
    1106             : 
    1107             :         // If we create a Window with default size, query this
    1108             :         // size directly, because we want resize all Controls to
    1109             :         // the correct size before we display the window
    1110           0 :         if ( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_APP) )
    1111           0 :             mpWindowImpl->mpFrame->GetClientSize( mnOutWidth, mnOutHeight );
    1112             :     }
    1113             :     else
    1114             :     {
    1115           0 :         if ( pParent )
    1116             :         {
    1117           0 :             if ( !ImplIsOverlapWindow() )
    1118             :             {
    1119           0 :                 mpWindowImpl->mbDisabled          = pParent->mpWindowImpl->mbDisabled;
    1120           0 :                 mpWindowImpl->mbInputDisabled     = pParent->mpWindowImpl->mbInputDisabled;
    1121           0 :                 mpWindowImpl->meAlwaysInputMode   = pParent->mpWindowImpl->meAlwaysInputMode;
    1122             :             }
    1123             : 
    1124           0 :             OutputDevice::SetSettings( pParent->GetSettings() );
    1125             :         }
    1126             : 
    1127             :     }
    1128             : 
    1129             :     // setup the scale factor for Hi-DPI displays
    1130           0 :     mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
    1131             : 
    1132           0 :     const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
    1133           0 :     sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
    1134           0 :     mnDPIX          = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
    1135           0 :     mnDPIY          = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
    1136           0 :     maFont          = rStyleSettings.GetAppFont();
    1137           0 :     ImplPointToLogic( maFont );
    1138             : 
    1139           0 :     if ( nStyle & WB_3DLOOK )
    1140             :     {
    1141           0 :         SetTextColor( rStyleSettings.GetButtonTextColor() );
    1142           0 :         SetBackground( Wallpaper( rStyleSettings.GetFaceColor() ) );
    1143             :     }
    1144             :     else
    1145             :     {
    1146           0 :         SetTextColor( rStyleSettings.GetWindowTextColor() );
    1147           0 :         SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
    1148             :     }
    1149             : 
    1150           0 :     ImplUpdatePos();
    1151             : 
    1152             :     // calculate app font res (except for the Intro Window or the default window)
    1153           0 :     if ( mpWindowImpl->mbFrame && !pSVData->maGDIData.mnAppFontX && ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) )
    1154           0 :         ImplInitAppFontData( this );
    1155             : 
    1156           0 :     if ( GetAccessibleParentWindow()  && GetParent() != Application::GetDefDialogParent() )
    1157           0 :         GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDCREATED, this );
    1158           0 : }
    1159             : 
    1160           0 : void Window::ImplSetFrameParent( const Window* pParent )
    1161             : {
    1162           0 :     Window* pFrameWindow = ImplGetSVData()->maWinData.mpFirstFrame;
    1163           0 :     while( pFrameWindow )
    1164             :     {
    1165             :         // search all frames that are children of this window
    1166             :         // and reparent them
    1167           0 :         if( ImplIsRealParentPath( pFrameWindow ) )
    1168             :         {
    1169             :             DBG_ASSERT( mpWindowImpl->mpFrame != pFrameWindow->mpWindowImpl->mpFrame, "SetFrameParent to own" );
    1170             :             DBG_ASSERT( mpWindowImpl->mpFrame, "no frame" );
    1171           0 :             SalFrame* pParentFrame = pParent ? pParent->mpWindowImpl->mpFrame : NULL;
    1172           0 :             pFrameWindow->mpWindowImpl->mpFrame->SetParent( pParentFrame );
    1173             :         }
    1174           0 :         pFrameWindow = pFrameWindow->mpWindowImpl->mpFrameData->mpNextFrame;
    1175             :     }
    1176           0 : }
    1177             : 
    1178           0 : void Window::ImplInsertWindow( Window* pParent )
    1179             : {
    1180           0 :     mpWindowImpl->mpParent            = pParent;
    1181           0 :     mpWindowImpl->mpRealParent        = pParent;
    1182             : 
    1183           0 :     if ( pParent && !mpWindowImpl->mbFrame )
    1184             :     {
    1185             :         // search frame window and set window frame data
    1186           0 :         Window* pFrameParent = pParent->mpWindowImpl->mpFrameWindow;
    1187           0 :         mpWindowImpl->mpFrameData     = pFrameParent->mpWindowImpl->mpFrameData;
    1188           0 :         mpWindowImpl->mpFrame         = pFrameParent->mpWindowImpl->mpFrame;
    1189           0 :         mpWindowImpl->mpFrameWindow   = pFrameParent;
    1190           0 :         mpWindowImpl->mbFrame         = false;
    1191             : 
    1192             :         // search overlap window and insert window in list
    1193           0 :         if ( ImplIsOverlapWindow() )
    1194             :         {
    1195           0 :             Window* pFirstOverlapParent = pParent;
    1196           0 :             while ( !pFirstOverlapParent->ImplIsOverlapWindow() )
    1197           0 :                 pFirstOverlapParent = pFirstOverlapParent->ImplGetParent();
    1198           0 :             mpWindowImpl->mpOverlapWindow = pFirstOverlapParent;
    1199             : 
    1200           0 :             mpWindowImpl->mpNextOverlap = mpWindowImpl->mpFrameData->mpFirstOverlap;
    1201           0 :             mpWindowImpl->mpFrameData->mpFirstOverlap = this;
    1202             : 
    1203             :             // Overlap-Windows are by default the uppermost
    1204           0 :             mpWindowImpl->mpNext = pFirstOverlapParent->mpWindowImpl->mpFirstOverlap;
    1205           0 :             pFirstOverlapParent->mpWindowImpl->mpFirstOverlap = this;
    1206           0 :             if ( !pFirstOverlapParent->mpWindowImpl->mpLastOverlap )
    1207           0 :                 pFirstOverlapParent->mpWindowImpl->mpLastOverlap = this;
    1208             :             else
    1209           0 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this;
    1210             :         }
    1211             :         else
    1212             :         {
    1213           0 :             if ( pParent->ImplIsOverlapWindow() )
    1214           0 :                 mpWindowImpl->mpOverlapWindow = pParent;
    1215             :             else
    1216           0 :                 mpWindowImpl->mpOverlapWindow = pParent->mpWindowImpl->mpOverlapWindow;
    1217           0 :             mpWindowImpl->mpPrev = pParent->mpWindowImpl->mpLastChild;
    1218           0 :             pParent->mpWindowImpl->mpLastChild = this;
    1219           0 :             if ( !pParent->mpWindowImpl->mpFirstChild )
    1220           0 :                 pParent->mpWindowImpl->mpFirstChild = this;
    1221             :             else
    1222           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    1223             :         }
    1224             :     }
    1225           0 : }
    1226             : 
    1227           0 : void Window::ImplRemoveWindow( bool bRemoveFrameData )
    1228             : {
    1229             :     // remove window from the lists
    1230           0 :     if ( !mpWindowImpl->mbFrame )
    1231             :     {
    1232           0 :         if ( ImplIsOverlapWindow() )
    1233             :         {
    1234           0 :             if ( mpWindowImpl->mpFrameData->mpFirstOverlap == this )
    1235           0 :                 mpWindowImpl->mpFrameData->mpFirstOverlap = mpWindowImpl->mpNextOverlap;
    1236             :             else
    1237             :             {
    1238           0 :                 Window* pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
    1239           0 :                 while ( pTempWin->mpWindowImpl->mpNextOverlap != this )
    1240           0 :                     pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
    1241           0 :                 pTempWin->mpWindowImpl->mpNextOverlap = mpWindowImpl->mpNextOverlap;
    1242             :             }
    1243             : 
    1244           0 :             if ( mpWindowImpl->mpPrev )
    1245           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    1246             :             else
    1247           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext;
    1248           0 :             if ( mpWindowImpl->mpNext )
    1249           0 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    1250             :             else
    1251           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev;
    1252             :         }
    1253             :         else
    1254             :         {
    1255           0 :             if ( mpWindowImpl->mpPrev )
    1256           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    1257           0 :             else if ( mpWindowImpl->mpParent )
    1258           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
    1259           0 :             if ( mpWindowImpl->mpNext )
    1260           0 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    1261           0 :             else if ( mpWindowImpl->mpParent )
    1262           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
    1263             :         }
    1264             : 
    1265           0 :         mpWindowImpl->mpPrev = NULL;
    1266           0 :         mpWindowImpl->mpNext = NULL;
    1267             :     }
    1268             : 
    1269           0 :     if ( bRemoveFrameData )
    1270             :     {
    1271             :         // release the graphic
    1272           0 :         OutputDevice *pOutDev = GetOutDev();
    1273           0 :         pOutDev->ImplReleaseGraphics();
    1274             :     }
    1275           0 : }
    1276             : 
    1277           0 : void Window::reorderWithinParent(sal_uInt16 nNewPosition)
    1278             : {
    1279           0 :     sal_uInt16 nChildCount = 0;
    1280           0 :     Window *pSource = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild;
    1281           0 :     while (pSource)
    1282             :     {
    1283           0 :         if (nChildCount == nNewPosition)
    1284           0 :             break;
    1285           0 :         pSource = pSource->mpWindowImpl->mpNext;
    1286           0 :         nChildCount++;
    1287             :     }
    1288             : 
    1289           0 :     if (pSource == this) //already at the right place
    1290           0 :         return;
    1291             : 
    1292           0 :     ImplRemoveWindow(false);
    1293             : 
    1294           0 :     if (pSource)
    1295             :     {
    1296           0 :         mpWindowImpl->mpNext = pSource;
    1297           0 :         mpWindowImpl->mpPrev = pSource->mpWindowImpl->mpPrev;
    1298           0 :         pSource->mpWindowImpl->mpPrev = this;
    1299             :     }
    1300             :     else
    1301           0 :         mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this;
    1302             : 
    1303           0 :     if (mpWindowImpl->mpPrev)
    1304           0 :         mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    1305             :     else
    1306           0 :         mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = this;
    1307             : }
    1308             : 
    1309           0 : void Window::ImplCallResize()
    1310             : {
    1311           0 :     mpWindowImpl->mbCallResize = false;
    1312             : 
    1313           0 :     if( GetBackground().IsGradient() )
    1314           0 :         Invalidate();
    1315             : 
    1316           0 :     Resize();
    1317             : 
    1318             :     // #88419# Most classes don't call the base class in Resize() and Move(),
    1319             :     // => Call ImpleResize/Move instead of Resize/Move directly...
    1320           0 :     ImplCallEventListeners( VCLEVENT_WINDOW_RESIZE );
    1321           0 : }
    1322             : 
    1323           0 : void Window::ImplCallMove()
    1324             : {
    1325           0 :     mpWindowImpl->mbCallMove = false;
    1326             : 
    1327           0 :     if( mpWindowImpl->mbFrame )
    1328             :     {
    1329             :         // update frame position
    1330           0 :         SalFrame *pParentFrame = NULL;
    1331           0 :         Window *pParent = ImplGetParent();
    1332           0 :         while( pParent )
    1333             :         {
    1334           0 :             if( pParent->mpWindowImpl->mpFrame != mpWindowImpl->mpFrame )
    1335             :             {
    1336           0 :                 pParentFrame = pParent->mpWindowImpl->mpFrame;
    1337           0 :                 break;
    1338             :             }
    1339           0 :             pParent = pParent->GetParent();
    1340             :         }
    1341             : 
    1342           0 :         SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    1343           0 :         mpWindowImpl->maPos = Point( g.nX, g.nY );
    1344           0 :         if( pParentFrame )
    1345             :         {
    1346           0 :             g = pParentFrame->GetGeometry();
    1347           0 :             mpWindowImpl->maPos -= Point( g.nX, g.nY );
    1348             :         }
    1349             :         // the client window and and all its subclients have the same position as the borderframe
    1350             :         // this is important for floating toolbars where the borderwindow is a floating window
    1351             :         // which has another borderwindow (ie the system floating window)
    1352           0 :         Window *pClientWin = mpWindowImpl->mpClientWindow;
    1353           0 :         while( pClientWin )
    1354             :         {
    1355           0 :             pClientWin->mpWindowImpl->maPos = mpWindowImpl->maPos;
    1356           0 :             pClientWin = pClientWin->mpWindowImpl->mpClientWindow;
    1357             :         }
    1358             :     }
    1359             : 
    1360           0 :     Move();
    1361             : 
    1362           0 :     ImplCallEventListeners( VCLEVENT_WINDOW_MOVE );
    1363           0 : }
    1364             : 
    1365           0 : static OString ImplAutoHelpID( ResMgr* pResMgr )
    1366             : {
    1367           0 :     OString aRet;
    1368             : 
    1369           0 :     if( pResMgr && Application::IsAutoHelpIdEnabled() )
    1370           0 :         aRet = pResMgr->GetAutoHelpId();
    1371             : 
    1372           0 :     return aRet;
    1373             : }
    1374             : 
    1375           0 : WinBits Window::ImplInitRes( const ResId& rResId )
    1376             : {
    1377           0 :     GetRes( rResId );
    1378             : 
    1379           0 :     char* pRes = (char*)GetClassRes();
    1380           0 :     pRes += 8;
    1381           0 :     sal_uInt32 nStyle = (sal_uInt32)GetLongRes( (void*)pRes );
    1382           0 :     rResId.SetWinBits( nStyle );
    1383           0 :     return nStyle;
    1384             : }
    1385             : 
    1386           0 : WindowResHeader Window::ImplLoadResHeader( const ResId& rResId )
    1387             : {
    1388           0 :     WindowResHeader aHeader;
    1389             : 
    1390           0 :     aHeader.nObjMask = ReadLongRes();
    1391             : 
    1392             :     // we need to calculate auto helpids before the resource gets closed
    1393             :     // if the resource  only contains flags, it will be closed before we try to read a help id
    1394             :     // so we always create an auto help id that might be overwritten later
    1395             :     // HelpId
    1396           0 :     aHeader.aHelpId = ImplAutoHelpID( rResId.GetResMgr() );
    1397             : 
    1398             :     // ResourceStyle
    1399           0 :     aHeader.nRSStyle = ReadLongRes();
    1400             :     // WinBits
    1401           0 :     ReadLongRes();
    1402             : 
    1403           0 :     if( aHeader.nObjMask & WINDOW_HELPID )
    1404           0 :         aHeader.aHelpId = ReadByteStringRes();
    1405             : 
    1406           0 :     return aHeader;
    1407             : }
    1408             : 
    1409           0 : void Window::ImplLoadRes( const ResId& rResId )
    1410             : {
    1411           0 :     WindowResHeader aHeader = ImplLoadResHeader( rResId );
    1412             : 
    1413           0 :     SetHelpId( aHeader.aHelpId );
    1414             : 
    1415           0 :     sal_uLong nObjMask = aHeader.nObjMask;
    1416             : 
    1417           0 :     bool  bPos  = false;
    1418           0 :     bool  bSize = false;
    1419           0 :     Point aPos;
    1420           0 :     Size  aSize;
    1421             : 
    1422           0 :     if ( nObjMask & (WINDOW_XYMAPMODE | WINDOW_X | WINDOW_Y) )
    1423             :     {
    1424             :         // use size as per resource
    1425           0 :         MapUnit ePosMap = MAP_PIXEL;
    1426             : 
    1427           0 :         bPos = true;
    1428             : 
    1429           0 :         if ( nObjMask & WINDOW_XYMAPMODE )
    1430           0 :             ePosMap = (MapUnit)ReadLongRes();
    1431           0 :         if ( nObjMask & WINDOW_X )
    1432           0 :             aPos.X() = ImplLogicUnitToPixelX( ReadLongRes(), ePosMap );
    1433           0 :         if ( nObjMask & WINDOW_Y )
    1434           0 :             aPos.Y() = ImplLogicUnitToPixelY( ReadLongRes(), ePosMap );
    1435             :     }
    1436             : 
    1437           0 :     if ( nObjMask & (WINDOW_WHMAPMODE | WINDOW_WIDTH | WINDOW_HEIGHT) )
    1438             :     {
    1439             :         // use size as per resource
    1440           0 :         MapUnit eSizeMap = MAP_PIXEL;
    1441             : 
    1442           0 :         bSize = true;
    1443             : 
    1444           0 :         if ( nObjMask & WINDOW_WHMAPMODE )
    1445           0 :             eSizeMap = (MapUnit)ReadLongRes();
    1446           0 :         if ( nObjMask & WINDOW_WIDTH )
    1447           0 :             aSize.Width() = ImplLogicUnitToPixelX( ReadLongRes(), eSizeMap );
    1448           0 :         if ( nObjMask & WINDOW_HEIGHT )
    1449           0 :             aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap );
    1450             :     }
    1451             : 
    1452           0 :     sal_uLong nRSStyle = aHeader.nRSStyle;
    1453             : 
    1454             :     // looks bad due to optimization
    1455           0 :     if ( nRSStyle & RSWND_CLIENTSIZE )
    1456             :     {
    1457           0 :         if ( bPos )
    1458           0 :             SetPosPixel( aPos );
    1459           0 :         if ( bSize )
    1460           0 :             SetOutputSizePixel( aSize );
    1461             :     }
    1462           0 :     else if ( bPos && bSize )
    1463           0 :         SetPosSizePixel( aPos, aSize );
    1464           0 :     else if ( bPos )
    1465           0 :         SetPosPixel( aPos );
    1466           0 :     else if ( bSize )
    1467           0 :         SetSizePixel( aSize );
    1468             : 
    1469           0 :     if ( nRSStyle & RSWND_DISABLED )
    1470           0 :         Enable( false );
    1471             : 
    1472           0 :     if ( nObjMask & WINDOW_TEXT )
    1473           0 :         SetText( ReadStringRes() );
    1474           0 :     if ( nObjMask & WINDOW_HELPTEXT )
    1475             :     {
    1476           0 :         SetHelpText( ReadStringRes() );
    1477           0 :         mpWindowImpl->mbHelpTextDynamic = true;
    1478             :     }
    1479           0 :     if ( nObjMask & WINDOW_QUICKTEXT )
    1480           0 :         SetQuickHelpText( ReadStringRes() );
    1481           0 :     if ( nObjMask & WINDOW_EXTRALONG )
    1482             :     {
    1483           0 :         sal_uIntPtr nRes = ReadLongRes();
    1484           0 :         SetData( (void*)nRes );
    1485             :     }
    1486           0 :     if ( nObjMask & WINDOW_UNIQUEID )
    1487           0 :         SetUniqueId( ReadByteStringRes() );
    1488             : 
    1489           0 :     if ( nObjMask & WINDOW_BORDER_STYLE )
    1490             :     {
    1491           0 :         sal_uInt16 nBorderStyle = (sal_uInt16)ReadLongRes();
    1492           0 :         SetBorderStyle( nBorderStyle );
    1493           0 :     }
    1494           0 : }
    1495             : 
    1496           0 : ImplWinData* Window::ImplGetWinData() const
    1497             : {
    1498           0 :     if ( !mpWindowImpl->mpWinData )
    1499             :     {
    1500           0 :         static const char* pNoNWF = getenv( "SAL_NO_NWF" );
    1501             : 
    1502           0 :         ((Window*)this)->mpWindowImpl->mpWinData = new ImplWinData;
    1503           0 :         mpWindowImpl->mpWinData->mpExtOldText     = NULL;
    1504           0 :         mpWindowImpl->mpWinData->mpExtOldAttrAry  = NULL;
    1505           0 :         mpWindowImpl->mpWinData->mpCursorRect     = NULL;
    1506           0 :         mpWindowImpl->mpWinData->mnCursorExtWidth = 0;
    1507           0 :         mpWindowImpl->mpWinData->mpCompositionCharRects = NULL;
    1508           0 :         mpWindowImpl->mpWinData->mnCompositionCharRects = 0;
    1509           0 :         mpWindowImpl->mpWinData->mpFocusRect      = NULL;
    1510           0 :         mpWindowImpl->mpWinData->mpTrackRect      = NULL;
    1511           0 :         mpWindowImpl->mpWinData->mnTrackFlags     = 0;
    1512           0 :         mpWindowImpl->mpWinData->mnIsTopWindow  = (sal_uInt16) ~0;  // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow())
    1513           0 :         mpWindowImpl->mpWinData->mbMouseOver      = false;
    1514           0 :         mpWindowImpl->mpWinData->mbEnableNativeWidget = (pNoNWF && *pNoNWF) ? sal_False : sal_True; // sal_True: try to draw this control with native theme API
    1515             :    }
    1516             : 
    1517           0 :     return mpWindowImpl->mpWinData;
    1518             : }
    1519             : 
    1520           0 : SalGraphics* Window::ImplGetFrameGraphics() const
    1521             : {
    1522           0 :     if ( mpWindowImpl->mpFrameWindow->mpGraphics )
    1523             :     {
    1524           0 :         mpWindowImpl->mpFrameWindow->mbInitClipRegion = true;
    1525             :     }
    1526             :     else
    1527             :     {
    1528           0 :         OutputDevice *pFrameWinOutDev = mpWindowImpl->mpFrameWindow;
    1529           0 :         pFrameWinOutDev->ImplGetGraphics();
    1530             :     }
    1531           0 :     mpWindowImpl->mpFrameWindow->mpGraphics->ResetClipRegion();
    1532           0 :     return mpWindowImpl->mpFrameWindow->mpGraphics;
    1533             : }
    1534             : 
    1535           0 : Window* Window::ImplFindWindow( const Point& rFramePos )
    1536             : {
    1537             :     Window* pTempWindow;
    1538             :     Window* pFindWindow;
    1539             : 
    1540             :     // first check all overlapping windows
    1541           0 :     pTempWindow = mpWindowImpl->mpFirstOverlap;
    1542           0 :     while ( pTempWindow )
    1543             :     {
    1544           0 :         pFindWindow = pTempWindow->ImplFindWindow( rFramePos );
    1545           0 :         if ( pFindWindow )
    1546           0 :             return pFindWindow;
    1547           0 :         pTempWindow = pTempWindow->mpWindowImpl->mpNext;
    1548             :     }
    1549             : 
    1550             :     // then we check our window
    1551           0 :     if ( !mpWindowImpl->mbVisible )
    1552           0 :         return NULL;
    1553             : 
    1554           0 :     sal_uInt16 nHitTest = ImplHitTest( rFramePos );
    1555           0 :     if ( nHitTest & WINDOW_HITTEST_INSIDE )
    1556             :     {
    1557             :         // and then we check all child windows
    1558           0 :         pTempWindow = mpWindowImpl->mpFirstChild;
    1559           0 :         while ( pTempWindow )
    1560             :         {
    1561           0 :             pFindWindow = pTempWindow->ImplFindWindow( rFramePos );
    1562           0 :             if ( pFindWindow )
    1563           0 :                 return pFindWindow;
    1564           0 :             pTempWindow = pTempWindow->mpWindowImpl->mpNext;
    1565             :         }
    1566             : 
    1567           0 :         if ( nHitTest & WINDOW_HITTEST_TRANSPARENT )
    1568           0 :             return NULL;
    1569             :         else
    1570           0 :             return this;
    1571             :     }
    1572             : 
    1573           0 :     return NULL;
    1574             : }
    1575             : 
    1576           0 : sal_uInt16 Window::ImplHitTest( const Point& rFramePos )
    1577             : {
    1578           0 :     Point aFramePos( rFramePos );
    1579           0 :     if( ImplIsAntiparallel() )
    1580             :     {
    1581             :         // - RTL - re-mirror frame pos at this window
    1582           0 :         const OutputDevice *pOutDev = GetOutDev();
    1583           0 :         pOutDev->ReMirror( aFramePos );
    1584             :     }
    1585           0 :     Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    1586           0 :     if ( !aRect.IsInside( aFramePos ) )
    1587           0 :         return 0;
    1588           0 :     if ( mpWindowImpl->mbWinRegion )
    1589             :     {
    1590           0 :         Point aTempPos = aFramePos;
    1591           0 :         aTempPos.X() -= mnOutOffX;
    1592           0 :         aTempPos.Y() -= mnOutOffY;
    1593           0 :         if ( !mpWindowImpl->maWinRegion.IsInside( aTempPos ) )
    1594           0 :             return 0;
    1595             :     }
    1596             : 
    1597           0 :     sal_uInt16 nHitTest = WINDOW_HITTEST_INSIDE;
    1598           0 :     if ( mpWindowImpl->mbMouseTransparent )
    1599           0 :         nHitTest |= WINDOW_HITTEST_TRANSPARENT;
    1600           0 :     return nHitTest;
    1601             : }
    1602             : 
    1603           0 : bool Window::ImplIsRealParentPath( const Window* pWindow ) const
    1604             : {
    1605           0 :     pWindow = pWindow->GetParent();
    1606           0 :     while ( pWindow )
    1607             :     {
    1608           0 :         if ( pWindow == this )
    1609           0 :             return true;
    1610           0 :         pWindow = pWindow->GetParent();
    1611             :     }
    1612             : 
    1613           0 :     return false;
    1614             : }
    1615             : 
    1616           0 : bool Window::ImplIsChild( const Window* pWindow, bool bSystemWindow ) const
    1617             : {
    1618           0 :     do
    1619             :     {
    1620           0 :         if ( !bSystemWindow && pWindow->ImplIsOverlapWindow() )
    1621           0 :             break;
    1622             : 
    1623           0 :         pWindow = pWindow->ImplGetParent();
    1624             : 
    1625           0 :         if ( pWindow == this )
    1626           0 :             return true;
    1627             :     }
    1628             :     while ( pWindow );
    1629             : 
    1630           0 :     return false;
    1631             : }
    1632             : 
    1633           0 : bool Window::ImplIsWindowOrChild( const Window* pWindow, bool bSystemWindow ) const
    1634             : {
    1635           0 :     if ( this == pWindow )
    1636           0 :         return true;
    1637           0 :     return ImplIsChild( pWindow, bSystemWindow );
    1638             : }
    1639             : 
    1640           0 : int Window::ImplTestMousePointerSet()
    1641             : {
    1642             :     // as soon as mouse is captured, switch mouse-pointer
    1643           0 :     if ( IsMouseCaptured() )
    1644           0 :         return sal_True;
    1645             : 
    1646             :     // if the mouse is over the window, switch it
    1647           0 :     Rectangle aClientRect( Point( 0, 0 ), GetOutputSizePixel() );
    1648           0 :     if ( aClientRect.IsInside( GetPointerPosPixel() ) )
    1649           0 :         return sal_True;
    1650             : 
    1651           0 :     return sal_False;
    1652             : }
    1653             : 
    1654           0 : PointerStyle Window::ImplGetMousePointer() const
    1655             : {
    1656             :     PointerStyle    ePointerStyle;
    1657           0 :     bool            bWait = false;
    1658             : 
    1659           0 :     if ( IsEnabled() && IsInputEnabled() && ! IsInModalMode() )
    1660           0 :         ePointerStyle = GetPointer().GetStyle();
    1661             :     else
    1662           0 :         ePointerStyle = POINTER_ARROW;
    1663             : 
    1664           0 :     const Window* pWindow = this;
    1665           0 :     do
    1666             :     {
    1667             :         // when the pointer is not visible stop the search, as
    1668             :         // this status should not be overwritten
    1669           0 :         if ( pWindow->mpWindowImpl->mbNoPtrVisible )
    1670           0 :             return POINTER_NULL;
    1671             : 
    1672           0 :         if ( !bWait )
    1673             :         {
    1674           0 :             if ( pWindow->mpWindowImpl->mnWaitCount )
    1675             :             {
    1676           0 :                 ePointerStyle = POINTER_WAIT;
    1677           0 :                 bWait = true;
    1678             :             }
    1679             :             else
    1680             :             {
    1681           0 :                 if ( pWindow->mpWindowImpl->mbChildPtrOverwrite )
    1682           0 :                     ePointerStyle = pWindow->GetPointer().GetStyle();
    1683             :             }
    1684             :         }
    1685             : 
    1686           0 :         if ( pWindow->ImplIsOverlapWindow() )
    1687           0 :             break;
    1688             : 
    1689           0 :         pWindow = pWindow->ImplGetParent();
    1690             :     }
    1691             :     while ( pWindow );
    1692             : 
    1693           0 :     return ePointerStyle;
    1694             : }
    1695             : 
    1696           0 : void Window::ImplResetReallyVisible()
    1697             : {
    1698           0 :     bool bBecameReallyInvisible = mpWindowImpl->mbReallyVisible;
    1699             : 
    1700           0 :     mbDevOutput     = false;
    1701           0 :     mpWindowImpl->mbReallyVisible = false;
    1702           0 :     mpWindowImpl->mbReallyShown   = false;
    1703             : 
    1704             :     // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge.
    1705             :     // For this, the data member of the event must not be NULL.
    1706             :     // Previously, we did this in Window::Show, but there some events got lost in certain situations.
    1707           0 :     if( bBecameReallyInvisible && ImplIsAccessibleCandidate() )
    1708           0 :         ImplCallEventListeners( VCLEVENT_WINDOW_HIDE, this );
    1709             :         // TODO. It's kind of a hack that we're re-using the VCLEVENT_WINDOW_HIDE. Normally, we should
    1710             :         // introduce another event which explicitly triggers the Accessibility implementations.
    1711             : 
    1712           0 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    1713           0 :     while ( pWindow )
    1714             :     {
    1715           0 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    1716           0 :             pWindow->ImplResetReallyVisible();
    1717           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1718             :     }
    1719             : 
    1720           0 :     pWindow = mpWindowImpl->mpFirstChild;
    1721           0 :     while ( pWindow )
    1722             :     {
    1723           0 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    1724           0 :             pWindow->ImplResetReallyVisible();
    1725           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1726             :     }
    1727           0 : }
    1728             : 
    1729           0 : void Window::ImplSetReallyVisible()
    1730             : {
    1731             :     // #i43594# it is possible that INITSHOW was never send, because the visibility state changed between
    1732             :     // ImplCallInitShow() and ImplSetReallyVisible() when called from Show()
    1733             :     // mbReallyShown is a useful indicator
    1734           0 :     if( !mpWindowImpl->mbReallyShown )
    1735           0 :         ImplCallInitShow();
    1736             : 
    1737           0 :     bool bBecameReallyVisible = !mpWindowImpl->mbReallyVisible;
    1738             : 
    1739           0 :     mbDevOutput     = true;
    1740           0 :     mpWindowImpl->mbReallyVisible = true;
    1741           0 :     mpWindowImpl->mbReallyShown   = true;
    1742             : 
    1743             :     // the SHOW/HIDE events serve as indicators to send child creation/destroy events to the access bridge.
    1744             :     // For this, the data member of the event must not be NULL.
    1745             :     // Previously, we did this in Window::Show, but there some events got lost in certain situations. Now
    1746             :     // we're doing it when the visibility really changes
    1747           0 :     if( bBecameReallyVisible && ImplIsAccessibleCandidate() )
    1748           0 :         ImplCallEventListeners( VCLEVENT_WINDOW_SHOW, this );
    1749             :         // TODO. It's kind of a hack that we're re-using the VCLEVENT_WINDOW_SHOW. Normally, we should
    1750             :         // introduce another event which explicitly triggers the Accessibility implementations.
    1751             : 
    1752           0 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    1753           0 :     while ( pWindow )
    1754             :     {
    1755           0 :         if ( pWindow->mpWindowImpl->mbVisible )
    1756           0 :             pWindow->ImplSetReallyVisible();
    1757           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1758             :     }
    1759             : 
    1760           0 :     pWindow = mpWindowImpl->mpFirstChild;
    1761           0 :     while ( pWindow )
    1762             :     {
    1763           0 :         if ( pWindow->mpWindowImpl->mbVisible )
    1764           0 :             pWindow->ImplSetReallyVisible();
    1765           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1766             :     }
    1767           0 : }
    1768             : 
    1769           0 : void Window::ImplCallInitShow()
    1770             : {
    1771           0 :     mpWindowImpl->mbReallyShown   = true;
    1772           0 :     mpWindowImpl->mbInInitShow    = true;
    1773           0 :     StateChanged( STATE_CHANGE_INITSHOW );
    1774           0 :     mpWindowImpl->mbInInitShow    = false;
    1775             : 
    1776           0 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    1777           0 :     while ( pWindow )
    1778             :     {
    1779           0 :         if ( pWindow->mpWindowImpl->mbVisible )
    1780           0 :             pWindow->ImplCallInitShow();
    1781           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1782             :     }
    1783             : 
    1784           0 :     pWindow = mpWindowImpl->mpFirstChild;
    1785           0 :     while ( pWindow )
    1786             :     {
    1787           0 :         if ( pWindow->mpWindowImpl->mbVisible )
    1788           0 :             pWindow->ImplCallInitShow();
    1789           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1790             :     }
    1791           0 : }
    1792             : 
    1793           0 : void Window::ImplAddDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok
    1794             : {
    1795             :     DBG_ASSERT( !pDel->mpWindow, "Window::ImplAddDel(): cannot add ImplDelData twice !" );
    1796           0 :     if( !pDel->mpWindow )
    1797             :     {
    1798           0 :         pDel->mpWindow = this;  // #112873# store ref to this window, so pDel can remove itself
    1799           0 :         pDel->mpNext = mpWindowImpl->mpFirstDel;
    1800           0 :         mpWindowImpl->mpFirstDel = pDel;
    1801             :     }
    1802           0 : }
    1803             : 
    1804           0 : void Window::ImplRemoveDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok
    1805             : {
    1806           0 :     pDel->mpWindow = NULL;      // #112873# pDel is not associated with a Window anymore
    1807           0 :     if ( mpWindowImpl->mpFirstDel == pDel )
    1808           0 :         mpWindowImpl->mpFirstDel = pDel->mpNext;
    1809             :     else
    1810             :     {
    1811           0 :         ImplDelData* pData = mpWindowImpl->mpFirstDel;
    1812           0 :         while ( pData->mpNext != pDel )
    1813           0 :             pData = pData->mpNext;
    1814           0 :         pData->mpNext = pDel->mpNext;
    1815             :     }
    1816           0 : }
    1817             : 
    1818           0 : void Window::ImplInitResolutionSettings()
    1819             : {
    1820             :     // recalculate AppFont-resolution and DPI-resolution
    1821           0 :     if ( mpWindowImpl->mbFrame )
    1822             :     {
    1823           0 :         const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
    1824           0 :         sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
    1825           0 :         mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
    1826           0 :         mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
    1827             : 
    1828             :         // setup the scale factor for Hi-DPI displays
    1829           0 :         mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
    1830           0 :         SetPointFont( rStyleSettings.GetAppFont() );
    1831             :     }
    1832           0 :     else if ( mpWindowImpl->mpParent )
    1833             :     {
    1834           0 :         mnDPIX  = mpWindowImpl->mpParent->mnDPIX;
    1835           0 :         mnDPIY  = mpWindowImpl->mpParent->mnDPIY;
    1836           0 :         mnDPIScaleFactor = mpWindowImpl->mpParent->mnDPIScaleFactor;
    1837             :     }
    1838             : 
    1839             :     // update the recalculated values for logical units
    1840             :     // and also tools belonging to the values
    1841           0 :     if ( IsMapMode() )
    1842             :     {
    1843           0 :         MapMode aMapMode = GetMapMode();
    1844           0 :         SetMapMode();
    1845           0 :         SetMapMode( aMapMode );
    1846             :     }
    1847           0 : }
    1848             : 
    1849           0 : void Window::ImplPointToLogic( Font& rFont ) const
    1850             : {
    1851           0 :     Size    aSize = rFont.GetSize();
    1852           0 :     sal_uInt16  nScreenFontZoom = mxSettings->GetStyleSettings().GetScreenFontZoom();
    1853             : 
    1854           0 :     if ( aSize.Width() )
    1855             :     {
    1856           0 :         aSize.Width() *= mpWindowImpl->mpFrameData->mnDPIX;
    1857           0 :         aSize.Width() += 72/2;
    1858           0 :         aSize.Width() /= 72;
    1859           0 :         aSize.Width() *= nScreenFontZoom;
    1860           0 :         aSize.Width() /= 100;
    1861             :     }
    1862           0 :     aSize.Height() *= mpWindowImpl->mpFrameData->mnDPIY;
    1863           0 :     aSize.Height() += 72/2;
    1864           0 :     aSize.Height() /= 72;
    1865           0 :     aSize.Height() *= nScreenFontZoom;
    1866           0 :     aSize.Height() /= 100;
    1867             : 
    1868           0 :     if ( IsMapModeEnabled() )
    1869           0 :         aSize = PixelToLogic( aSize );
    1870             : 
    1871           0 :     rFont.SetSize( aSize );
    1872           0 : }
    1873             : 
    1874           0 : void Window::ImplLogicToPoint( Font& rFont ) const
    1875             : {
    1876           0 :     Size    aSize = rFont.GetSize();
    1877           0 :     sal_uInt16  nScreenFontZoom = mxSettings->GetStyleSettings().GetScreenFontZoom();
    1878             : 
    1879           0 :     if ( IsMapModeEnabled() )
    1880           0 :         aSize = LogicToPixel( aSize );
    1881             : 
    1882           0 :     if ( aSize.Width() )
    1883             :     {
    1884           0 :         aSize.Width() *= 100;
    1885           0 :         aSize.Width() /= nScreenFontZoom;
    1886           0 :         aSize.Width() *= 72;
    1887           0 :         aSize.Width() += mpWindowImpl->mpFrameData->mnDPIX/2;
    1888           0 :         aSize.Width() /= mpWindowImpl->mpFrameData->mnDPIX;
    1889             :     }
    1890           0 :     aSize.Height() *= 100;
    1891           0 :     aSize.Height() /= nScreenFontZoom;
    1892           0 :     aSize.Height() *= 72;
    1893           0 :     aSize.Height() += mpWindowImpl->mpFrameData->mnDPIY/2;
    1894           0 :     aSize.Height() /= mpWindowImpl->mpFrameData->mnDPIY;
    1895             : 
    1896           0 :     rFont.SetSize( aSize );
    1897           0 : }
    1898             : 
    1899           0 : bool Window::ImplSysObjClip( const Region* pOldRegion )
    1900             : {
    1901           0 :     bool bUpdate = true;
    1902             : 
    1903           0 :     if ( mpWindowImpl->mpSysObj )
    1904             :     {
    1905           0 :         bool bVisibleState = mpWindowImpl->mbReallyVisible;
    1906             : 
    1907           0 :         if ( bVisibleState )
    1908             :         {
    1909           0 :             Region* pWinChildClipRegion = ImplGetWinChildClipRegion();
    1910             : 
    1911           0 :             if ( !pWinChildClipRegion->IsEmpty() )
    1912             :             {
    1913           0 :                 if ( pOldRegion )
    1914             :                 {
    1915           0 :                     Region aNewRegion = *pWinChildClipRegion;
    1916           0 :                     pWinChildClipRegion->Intersect( *pOldRegion );
    1917           0 :                     bUpdate = aNewRegion == *pWinChildClipRegion;
    1918             :                 }
    1919             : 
    1920           0 :                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    1921           0 :                     ImplInvalidateAllOverlapBackgrounds();
    1922             : 
    1923           0 :                 Region      aRegion = *pWinChildClipRegion;
    1924           0 :                 Rectangle   aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    1925           0 :                 Region      aWinRectRegion( aWinRect );
    1926           0 :                 sal_uInt16      nClipFlags = mpWindowImpl->mpSysObj->GetClipRegionType();
    1927             : 
    1928           0 :                 if ( aRegion == aWinRectRegion )
    1929           0 :                     mpWindowImpl->mpSysObj->ResetClipRegion();
    1930             :                 else
    1931             :                 {
    1932           0 :                     if ( nClipFlags & SAL_OBJECT_CLIP_EXCLUDERECTS )
    1933             :                     {
    1934           0 :                         aWinRectRegion.Exclude( aRegion );
    1935           0 :                         aRegion = aWinRectRegion;
    1936             :                     }
    1937           0 :                     if ( !(nClipFlags & SAL_OBJECT_CLIP_ABSOLUTE) )
    1938           0 :                         aRegion.Move( -mnOutOffX, -mnOutOffY );
    1939             : 
    1940             :                     // ClipRegion setzen/updaten
    1941           0 :                     RectangleVector aRectangles;
    1942           0 :                     aRegion.GetRegionRectangles(aRectangles);
    1943           0 :                     mpWindowImpl->mpSysObj->BeginSetClipRegion(aRectangles.size());
    1944             : 
    1945           0 :                     for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
    1946             :                     {
    1947             :                         mpWindowImpl->mpSysObj->UnionClipRegion(
    1948             :                             aRectIter->Left(),
    1949             :                             aRectIter->Top(),
    1950             :                             aRectIter->GetWidth(),   // orig nWidth was ((R - L) + 1), same as GetWidth does
    1951           0 :                             aRectIter->GetHeight()); // same for height
    1952             :                     }
    1953             : 
    1954           0 :                     mpWindowImpl->mpSysObj->EndSetClipRegion();
    1955             : 
    1956             :                     //long                nX;
    1957             :                     //long                nY;
    1958             :                     //long                nWidth;
    1959             :                     //long                nHeight;
    1960             :                     //sal_uLong               nRectCount;
    1961             :                     //ImplRegionInfo      aInfo;
    1962             :                     //sal_Bool                bRegionRect;
    1963             : 
    1964             :                     //nRectCount = aRegion.GetRectCount();
    1965             :                     //mpWindowImpl->mpSysObj->BeginSetClipRegion( nRectCount );
    1966             :                     //bRegionRect = aRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
    1967             :                     //while ( bRegionRect )
    1968             :                     //{
    1969             :                     //    mpWindowImpl->mpSysObj->UnionClipRegion( nX, nY, nWidth, nHeight );
    1970             :                     //    bRegionRect = aRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
    1971             :                     //}
    1972             :                     //mpWindowImpl->mpSysObj->EndSetClipRegion();
    1973           0 :                 }
    1974             :             }
    1975             :             else
    1976           0 :                 bVisibleState = false;
    1977             :         }
    1978             : 
    1979             :         // Visible-Status updaten
    1980           0 :         mpWindowImpl->mpSysObj->Show( bVisibleState );
    1981             :     }
    1982             : 
    1983           0 :     return bUpdate;
    1984             : }
    1985             : 
    1986           0 : void Window::ImplUpdateSysObjChildrenClip()
    1987             : {
    1988           0 :     if ( mpWindowImpl->mpSysObj && mpWindowImpl->mbInitWinClipRegion )
    1989           0 :         ImplSysObjClip( NULL );
    1990             : 
    1991           0 :     Window* pWindow = mpWindowImpl->mpFirstChild;
    1992           0 :     while ( pWindow )
    1993             :     {
    1994           0 :         pWindow->ImplUpdateSysObjChildrenClip();
    1995           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1996             :     }
    1997           0 : }
    1998             : 
    1999           0 : void Window::ImplUpdateSysObjOverlapsClip()
    2000             : {
    2001           0 :     ImplUpdateSysObjChildrenClip();
    2002             : 
    2003           0 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    2004           0 :     while ( pWindow )
    2005             :     {
    2006           0 :         pWindow->ImplUpdateSysObjOverlapsClip();
    2007           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2008             :     }
    2009           0 : }
    2010             : 
    2011           0 : void Window::ImplUpdateSysObjClip()
    2012             : {
    2013           0 :     if ( !ImplIsOverlapWindow() )
    2014             :     {
    2015           0 :         ImplUpdateSysObjChildrenClip();
    2016             : 
    2017             :         // siblings should recalculate their clip region
    2018           0 :         if ( mpWindowImpl->mbClipSiblings )
    2019             :         {
    2020           0 :             Window* pWindow = mpWindowImpl->mpNext;
    2021           0 :             while ( pWindow )
    2022             :             {
    2023           0 :                 pWindow->ImplUpdateSysObjChildrenClip();
    2024           0 :                 pWindow = pWindow->mpWindowImpl->mpNext;
    2025             :             }
    2026             :         }
    2027             :     }
    2028             :     else
    2029           0 :         mpWindowImpl->mpFrameWindow->ImplUpdateSysObjOverlapsClip();
    2030           0 : }
    2031             : 
    2032           0 : bool Window::ImplSetClipFlagChildren( bool bSysObjOnlySmaller )
    2033             : {
    2034           0 :     bool bUpdate = true;
    2035           0 :     if ( mpWindowImpl->mpSysObj )
    2036             :     {
    2037           0 :         Region* pOldRegion = NULL;
    2038           0 :         if ( bSysObjOnlySmaller && !mpWindowImpl->mbInitWinClipRegion )
    2039           0 :             pOldRegion = new Region( mpWindowImpl->maWinClipRegion );
    2040             : 
    2041           0 :         mbInitClipRegion = true;
    2042           0 :         mpWindowImpl->mbInitWinClipRegion = true;
    2043             : 
    2044           0 :         Window* pWindow = mpWindowImpl->mpFirstChild;
    2045           0 :         while ( pWindow )
    2046             :         {
    2047           0 :             if ( !pWindow->ImplSetClipFlagChildren( bSysObjOnlySmaller ) )
    2048           0 :                 bUpdate = false;
    2049           0 :             pWindow = pWindow->mpWindowImpl->mpNext;
    2050             :         }
    2051             : 
    2052           0 :         if ( !ImplSysObjClip( pOldRegion ) )
    2053             :         {
    2054           0 :             mbInitClipRegion = true;
    2055           0 :             mpWindowImpl->mbInitWinClipRegion = true;
    2056           0 :             bUpdate = false;
    2057             :         }
    2058             : 
    2059           0 :         delete pOldRegion;
    2060             :     }
    2061             :     else
    2062             :     {
    2063           0 :     mbInitClipRegion = true;
    2064           0 :     mpWindowImpl->mbInitWinClipRegion = true;
    2065             : 
    2066           0 :     Window* pWindow = mpWindowImpl->mpFirstChild;
    2067           0 :     while ( pWindow )
    2068             :     {
    2069           0 :         if ( !pWindow->ImplSetClipFlagChildren( bSysObjOnlySmaller ) )
    2070           0 :             bUpdate = false;
    2071           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2072             :     }
    2073             :     }
    2074           0 :     return bUpdate;
    2075             : }
    2076             : 
    2077           0 : bool Window::ImplSetClipFlagOverlapWindows( bool bSysObjOnlySmaller )
    2078             : {
    2079           0 :     bool bUpdate = ImplSetClipFlagChildren( bSysObjOnlySmaller );
    2080             : 
    2081           0 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    2082           0 :     while ( pWindow )
    2083             :     {
    2084           0 :         if ( !pWindow->ImplSetClipFlagOverlapWindows( bSysObjOnlySmaller ) )
    2085           0 :             bUpdate = false;
    2086           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2087             :     }
    2088             : 
    2089           0 :     return bUpdate;
    2090             : }
    2091             : 
    2092           0 : bool Window::ImplSetClipFlag( bool bSysObjOnlySmaller )
    2093             : {
    2094           0 :     if ( !ImplIsOverlapWindow() )
    2095             :     {
    2096           0 :         bool bUpdate = ImplSetClipFlagChildren( bSysObjOnlySmaller );
    2097             : 
    2098           0 :         Window* pParent = ImplGetParent();
    2099           0 :         if ( pParent &&
    2100           0 :              ((pParent->GetStyle() & WB_CLIPCHILDREN) || (mpWindowImpl->mnParentClipMode & PARENTCLIPMODE_CLIP)) )
    2101             :         {
    2102           0 :             pParent->mbInitClipRegion = true;
    2103           0 :             pParent->mpWindowImpl->mbInitChildRegion = true;
    2104             :         }
    2105             : 
    2106             :         // siblings should recalculate their clip region
    2107           0 :         if ( mpWindowImpl->mbClipSiblings )
    2108             :         {
    2109           0 :             Window* pWindow = mpWindowImpl->mpNext;
    2110           0 :             while ( pWindow )
    2111             :             {
    2112           0 :                 if ( !pWindow->ImplSetClipFlagChildren( bSysObjOnlySmaller ) )
    2113           0 :                     bUpdate = false;
    2114           0 :                 pWindow = pWindow->mpWindowImpl->mpNext;
    2115             :             }
    2116             :         }
    2117             : 
    2118           0 :         return bUpdate;
    2119             :     }
    2120             :     else
    2121           0 :         return mpWindowImpl->mpFrameWindow->ImplSetClipFlagOverlapWindows( bSysObjOnlySmaller );
    2122             : }
    2123             : 
    2124           0 : void Window::ImplIntersectWindowClipRegion( Region& rRegion )
    2125             : {
    2126           0 :     if ( mpWindowImpl->mbInitWinClipRegion )
    2127           0 :         ImplInitWinClipRegion();
    2128             : 
    2129           0 :     rRegion.Intersect( mpWindowImpl->maWinClipRegion );
    2130           0 : }
    2131             : 
    2132           0 : void Window::ImplIntersectWindowRegion( Region& rRegion )
    2133             : {
    2134             :     rRegion.Intersect( Rectangle( Point( mnOutOffX, mnOutOffY ),
    2135           0 :                                   Size( mnOutWidth, mnOutHeight ) ) );
    2136           0 :     if ( mpWindowImpl->mbWinRegion )
    2137           0 :         rRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    2138           0 : }
    2139             : 
    2140           0 : void Window::ImplExcludeWindowRegion( Region& rRegion )
    2141             : {
    2142           0 :     if ( mpWindowImpl->mbWinRegion )
    2143             :     {
    2144           0 :         Point aPoint( mnOutOffX, mnOutOffY );
    2145             :         Region aRegion( Rectangle( aPoint,
    2146           0 :                                    Size( mnOutWidth, mnOutHeight ) ) );
    2147           0 :         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    2148           0 :         rRegion.Exclude( aRegion );
    2149             :     }
    2150             :     else
    2151             :     {
    2152           0 :         Point aPoint( mnOutOffX, mnOutOffY );
    2153             :         rRegion.Exclude( Rectangle( aPoint,
    2154           0 :                                     Size( mnOutWidth, mnOutHeight ) ) );
    2155             :     }
    2156           0 : }
    2157             : 
    2158           0 : void Window::ImplExcludeOverlapWindows( Region& rRegion )
    2159             : {
    2160           0 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    2161           0 :     while ( pWindow )
    2162             :     {
    2163           0 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    2164             :         {
    2165           0 :             pWindow->ImplExcludeWindowRegion( rRegion );
    2166           0 :             pWindow->ImplExcludeOverlapWindows( rRegion );
    2167             :         }
    2168             : 
    2169           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2170             :     }
    2171           0 : }
    2172             : 
    2173           0 : void Window::ImplExcludeOverlapWindows2( Region& rRegion )
    2174             : {
    2175           0 :     if ( mpWindowImpl->mbReallyVisible )
    2176           0 :         ImplExcludeWindowRegion( rRegion );
    2177             : 
    2178           0 :     ImplExcludeOverlapWindows( rRegion );
    2179           0 : }
    2180             : 
    2181           0 : void Window::ImplClipBoundaries( Region& rRegion, bool bThis, bool bOverlaps )
    2182             : {
    2183           0 :     if ( bThis )
    2184           0 :         ImplIntersectWindowClipRegion( rRegion );
    2185           0 :     else if ( ImplIsOverlapWindow() )
    2186             :     {
    2187             :         // clip to frame if required
    2188           0 :         if ( !mpWindowImpl->mbFrame )
    2189           0 :             rRegion.Intersect( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) );
    2190             : 
    2191           0 :         if ( bOverlaps && !rRegion.IsEmpty() )
    2192             :         {
    2193             :             // Clip Overlap Siblings
    2194           0 :             Window* pStartOverlapWindow = this;
    2195           0 :             while ( !pStartOverlapWindow->mpWindowImpl->mbFrame )
    2196             :             {
    2197           0 :                 Window* pOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
    2198           0 :                 while ( pOverlapWindow && (pOverlapWindow != pStartOverlapWindow) )
    2199             :                 {
    2200           0 :                     pOverlapWindow->ImplExcludeOverlapWindows2( rRegion );
    2201           0 :                     pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
    2202             :                 }
    2203           0 :                 pStartOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow;
    2204             :             }
    2205             : 
    2206             :             // Clip Child Overlap Windows
    2207           0 :             ImplExcludeOverlapWindows( rRegion );
    2208             :         }
    2209             :     }
    2210             :     else
    2211           0 :         ImplGetParent()->ImplIntersectWindowClipRegion( rRegion );
    2212           0 : }
    2213             : 
    2214           0 : bool Window::ImplClipChildren( Region& rRegion )
    2215             : {
    2216           0 :     bool    bOtherClip = false;
    2217           0 :     Window* pWindow = mpWindowImpl->mpFirstChild;
    2218           0 :     while ( pWindow )
    2219             :     {
    2220           0 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    2221             :         {
    2222             :             // read-out ParentClipMode-Flags
    2223           0 :             sal_uInt16 nClipMode = pWindow->GetParentClipMode();
    2224           0 :             if ( !(nClipMode & PARENTCLIPMODE_NOCLIP) &&
    2225           0 :                  ((nClipMode & PARENTCLIPMODE_CLIP) || (GetStyle() & WB_CLIPCHILDREN)) )
    2226           0 :                 pWindow->ImplExcludeWindowRegion( rRegion );
    2227             :             else
    2228           0 :                 bOtherClip = true;
    2229             :         }
    2230             : 
    2231           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2232             :     }
    2233             : 
    2234           0 :     return bOtherClip;
    2235             : }
    2236             : 
    2237           0 : void Window::ImplClipAllChildren( Region& rRegion )
    2238             : {
    2239           0 :     Window* pWindow = mpWindowImpl->mpFirstChild;
    2240           0 :     while ( pWindow )
    2241             :     {
    2242           0 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    2243           0 :             pWindow->ImplExcludeWindowRegion( rRegion );
    2244           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2245             :     }
    2246           0 : }
    2247             : 
    2248           0 : void Window::ImplClipSiblings( Region& rRegion )
    2249             : {
    2250           0 :     Window* pWindow = ImplGetParent()->mpWindowImpl->mpFirstChild;
    2251           0 :     while ( pWindow )
    2252             :     {
    2253           0 :         if ( pWindow == this )
    2254           0 :             break;
    2255             : 
    2256           0 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    2257           0 :             pWindow->ImplExcludeWindowRegion( rRegion );
    2258             : 
    2259           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2260             :     }
    2261           0 : }
    2262             : 
    2263           0 : void Window::ImplInitWinClipRegion()
    2264             : {
    2265             :     // Build Window Region
    2266           0 :     mpWindowImpl->maWinClipRegion = Rectangle( Point( mnOutOffX, mnOutOffY ),
    2267           0 :                                  Size( mnOutWidth, mnOutHeight ) );
    2268           0 :     if ( mpWindowImpl->mbWinRegion )
    2269           0 :         mpWindowImpl->maWinClipRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    2270             : 
    2271             :     // ClipSiblings
    2272           0 :     if ( mpWindowImpl->mbClipSiblings && !ImplIsOverlapWindow() )
    2273           0 :         ImplClipSiblings( mpWindowImpl->maWinClipRegion );
    2274             : 
    2275             :     // Clip Parent Boundaries
    2276           0 :     ImplClipBoundaries( mpWindowImpl->maWinClipRegion, false, true );
    2277             : 
    2278             :     // Clip Children
    2279           0 :     if ( (GetStyle() & WB_CLIPCHILDREN) || mpWindowImpl->mbClipChildren )
    2280           0 :         mpWindowImpl->mbInitChildRegion = true;
    2281             : 
    2282           0 :     mpWindowImpl->mbInitWinClipRegion = false;
    2283           0 : }
    2284             : 
    2285           0 : void Window::ImplInitWinChildClipRegion()
    2286             : {
    2287           0 :     if ( !mpWindowImpl->mpFirstChild )
    2288             :     {
    2289           0 :         if ( mpWindowImpl->mpChildClipRegion )
    2290             :         {
    2291           0 :             delete mpWindowImpl->mpChildClipRegion;
    2292           0 :             mpWindowImpl->mpChildClipRegion = NULL;
    2293             :         }
    2294             :     }
    2295             :     else
    2296             :     {
    2297           0 :         if ( !mpWindowImpl->mpChildClipRegion )
    2298           0 :             mpWindowImpl->mpChildClipRegion = new Region( mpWindowImpl->maWinClipRegion );
    2299             :         else
    2300           0 :             *mpWindowImpl->mpChildClipRegion = mpWindowImpl->maWinClipRegion;
    2301             : 
    2302           0 :         ImplClipChildren( *mpWindowImpl->mpChildClipRegion );
    2303             :     }
    2304             : 
    2305           0 :     mpWindowImpl->mbInitChildRegion = false;
    2306           0 : }
    2307             : 
    2308           0 : Region* Window::ImplGetWinChildClipRegion()
    2309             : {
    2310           0 :     if ( mpWindowImpl->mbInitWinClipRegion )
    2311           0 :         ImplInitWinClipRegion();
    2312           0 :     if ( mpWindowImpl->mbInitChildRegion )
    2313           0 :         ImplInitWinChildClipRegion();
    2314           0 :     if ( mpWindowImpl->mpChildClipRegion )
    2315           0 :         return mpWindowImpl->mpChildClipRegion;
    2316             :     else
    2317           0 :         return &mpWindowImpl->maWinClipRegion;
    2318             : }
    2319             : 
    2320           0 : void Window::ImplIntersectAndUnionOverlapWindows( const Region& rInterRegion, Region& rRegion )
    2321             : {
    2322           0 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    2323           0 :     while ( pWindow )
    2324             :     {
    2325           0 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    2326             :         {
    2327           0 :             Region aTempRegion( rInterRegion );
    2328           0 :             pWindow->ImplIntersectWindowRegion( aTempRegion );
    2329           0 :             rRegion.Union( aTempRegion );
    2330           0 :             pWindow->ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
    2331             :         }
    2332             : 
    2333           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2334             :     }
    2335           0 : }
    2336             : 
    2337           0 : void Window::ImplIntersectAndUnionOverlapWindows2( const Region& rInterRegion, Region& rRegion )
    2338             : {
    2339           0 :     if ( mpWindowImpl->mbReallyVisible )
    2340             :     {
    2341           0 :         Region aTempRegion( rInterRegion );
    2342           0 :         ImplIntersectWindowRegion( aTempRegion );
    2343           0 :         rRegion.Union( aTempRegion );
    2344             :     }
    2345             : 
    2346           0 :     ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
    2347           0 : }
    2348             : 
    2349           0 : void Window::ImplCalcOverlapRegionOverlaps( const Region& rInterRegion, Region& rRegion )
    2350             : {
    2351             :     // Clip Overlap Siblings
    2352             :     Window* pStartOverlapWindow;
    2353           0 :     if ( !ImplIsOverlapWindow() )
    2354           0 :         pStartOverlapWindow = mpWindowImpl->mpOverlapWindow;
    2355             :     else
    2356           0 :         pStartOverlapWindow = this;
    2357           0 :     while ( !pStartOverlapWindow->mpWindowImpl->mbFrame )
    2358             :     {
    2359           0 :         Window* pOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
    2360           0 :         while ( pOverlapWindow && (pOverlapWindow != pStartOverlapWindow) )
    2361             :         {
    2362           0 :             pOverlapWindow->ImplIntersectAndUnionOverlapWindows2( rInterRegion, rRegion );
    2363           0 :             pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
    2364             :         }
    2365           0 :         pStartOverlapWindow = pStartOverlapWindow->mpWindowImpl->mpOverlapWindow;
    2366             :     }
    2367             : 
    2368             :     // Clip Child Overlap Windows
    2369           0 :     if ( !ImplIsOverlapWindow() )
    2370           0 :         mpWindowImpl->mpOverlapWindow->ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
    2371             :     else
    2372           0 :         ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
    2373           0 : }
    2374             : 
    2375           0 : void Window::ImplCalcOverlapRegion( const Rectangle& rSourceRect, Region& rRegion,
    2376             :                                     bool bChildren, bool bParent, bool bSiblings )
    2377             : {
    2378           0 :     Region  aRegion( rSourceRect );
    2379           0 :     if ( mpWindowImpl->mbWinRegion )
    2380           0 :         rRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    2381           0 :     Region  aTempRegion;
    2382             :     Window* pWindow;
    2383             : 
    2384           0 :     ImplCalcOverlapRegionOverlaps( aRegion, rRegion );
    2385             : 
    2386             :     // Parent-Boundaries
    2387           0 :     if ( bParent )
    2388             :     {
    2389           0 :         pWindow = this;
    2390           0 :         if ( !ImplIsOverlapWindow() )
    2391             :         {
    2392           0 :             pWindow = ImplGetParent();
    2393           0 :             do
    2394             :             {
    2395           0 :                 aTempRegion = aRegion;
    2396           0 :                 pWindow->ImplExcludeWindowRegion( aTempRegion );
    2397           0 :                 rRegion.Union( aTempRegion );
    2398           0 :                 if ( pWindow->ImplIsOverlapWindow() )
    2399           0 :                     break;
    2400           0 :                 pWindow = pWindow->ImplGetParent();
    2401             :             }
    2402             :             while ( pWindow );
    2403             :         }
    2404           0 :         if ( pWindow && !pWindow->mpWindowImpl->mbFrame )
    2405             :         {
    2406           0 :             aTempRegion = aRegion;
    2407           0 :             aTempRegion.Exclude( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) );
    2408           0 :             rRegion.Union( aTempRegion );
    2409             :         }
    2410             :     }
    2411             : 
    2412             :     // Siblings
    2413           0 :     if ( bSiblings && !ImplIsOverlapWindow() )
    2414             :     {
    2415           0 :         pWindow = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild;
    2416           0 :         do
    2417             :         {
    2418           0 :             if ( pWindow->mpWindowImpl->mbReallyVisible && (pWindow != this) )
    2419             :             {
    2420           0 :                 aTempRegion = aRegion;
    2421           0 :                 pWindow->ImplIntersectWindowRegion( aTempRegion );
    2422           0 :                 rRegion.Union( aTempRegion );
    2423             :             }
    2424           0 :             pWindow = pWindow->mpWindowImpl->mpNext;
    2425             :         }
    2426             :         while ( pWindow );
    2427             :     }
    2428             : 
    2429           0 :     if ( bChildren )
    2430             :     {
    2431           0 :         pWindow = mpWindowImpl->mpFirstChild;
    2432           0 :         while ( pWindow )
    2433             :         {
    2434           0 :             if ( pWindow->mpWindowImpl->mbReallyVisible )
    2435             :             {
    2436           0 :                 aTempRegion = aRegion;
    2437           0 :                 pWindow->ImplIntersectWindowRegion( aTempRegion );
    2438           0 :                 rRegion.Union( aTempRegion );
    2439             :             }
    2440           0 :             pWindow = pWindow->mpWindowImpl->mpNext;
    2441             :         }
    2442           0 :     }
    2443           0 : }
    2444             : 
    2445           0 : void Window::ImplCallPaint( const Region* pRegion, sal_uInt16 nPaintFlags )
    2446             : {
    2447           0 :     Exception aException;
    2448           0 :     bool bExceptionCaught(false);
    2449             : 
    2450             :     // call PrePaint. PrePaint may add to the invalidate region as well as
    2451             :     // other parameters used below.
    2452           0 :     PrePaint();
    2453             : 
    2454           0 :     mpWindowImpl->mbPaintFrame = false;
    2455             : 
    2456           0 :     if ( nPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
    2457           0 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALLCHILDREN | (nPaintFlags & IMPL_PAINT_PAINTALL);
    2458           0 :     if ( nPaintFlags & IMPL_PAINT_PAINTCHILDREN )
    2459           0 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDREN;
    2460           0 :     if ( nPaintFlags & IMPL_PAINT_ERASE )
    2461           0 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE;
    2462           0 :     if ( nPaintFlags & IMPL_PAINT_CHECKRTL )
    2463           0 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
    2464           0 :     if ( !mpWindowImpl->mpFirstChild )
    2465           0 :         mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALLCHILDREN;
    2466             : 
    2467           0 :     if ( mpWindowImpl->mbPaintDisabled )
    2468             :     {
    2469           0 :         if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2470           0 :             Invalidate( INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
    2471           0 :         else if ( pRegion )
    2472           0 :             Invalidate( *pRegion, INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
    2473           0 :         return;
    2474             :     }
    2475             : 
    2476           0 :     nPaintFlags = mpWindowImpl->mnPaintFlags & ~(IMPL_PAINT_PAINT);
    2477             : 
    2478           0 :     Region* pChildRegion = NULL;
    2479           0 :     Rectangle aSelectionRect;
    2480           0 :     if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT )
    2481             :     {
    2482           0 :         Region* pWinChildClipRegion = ImplGetWinChildClipRegion();
    2483           0 :         if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2484           0 :             mpWindowImpl->maInvalidateRegion = *pWinChildClipRegion;
    2485             :         else
    2486             :         {
    2487           0 :             if ( pRegion )
    2488           0 :                 mpWindowImpl->maInvalidateRegion.Union( *pRegion );
    2489             : 
    2490           0 :             if( mpWindowImpl->mpWinData && mpWindowImpl->mbTrackVisible )
    2491             :                 /* #98602# need to repaint all children within the
    2492             :                * tracking rectangle, so the following invert
    2493             :                * operation takes places without traces of the previous
    2494             :                * one.
    2495             :                */
    2496           0 :                 mpWindowImpl->maInvalidateRegion.Union( *mpWindowImpl->mpWinData->mpTrackRect );
    2497             : 
    2498           0 :             if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
    2499           0 :                 pChildRegion = new Region( mpWindowImpl->maInvalidateRegion );
    2500           0 :             mpWindowImpl->maInvalidateRegion.Intersect( *pWinChildClipRegion );
    2501             :         }
    2502           0 :         mpWindowImpl->mnPaintFlags = 0;
    2503           0 :         if ( !mpWindowImpl->maInvalidateRegion.IsEmpty() )
    2504             :         {
    2505           0 :             bool bRestoreCursor = false;
    2506           0 :             if ( mpWindowImpl->mpCursor )
    2507           0 :                 bRestoreCursor = mpWindowImpl->mpCursor->ImplSuspend();
    2508             : 
    2509           0 :             mbInitClipRegion = true;
    2510           0 :             mpWindowImpl->mbInPaint = true;
    2511             : 
    2512             :             // restore Paint-Region
    2513           0 :             Region      aPaintRegion( mpWindowImpl->maInvalidateRegion );
    2514           0 :             Rectangle   aPaintRect = aPaintRegion.GetBoundRect();
    2515             : 
    2516             :             // - RTL - re-mirror paint rect and region at this window
    2517           0 :             if( ImplIsAntiparallel() )
    2518             :             {
    2519           0 :                 const OutputDevice *pOutDev = GetOutDev();
    2520           0 :                 pOutDev->ReMirror( aPaintRect );
    2521           0 :                 pOutDev->ReMirror( aPaintRegion );
    2522             :             }
    2523           0 :             aPaintRect = ImplDevicePixelToLogic( aPaintRect);
    2524           0 :             mpWindowImpl->mpPaintRegion = &aPaintRegion;
    2525           0 :             mpWindowImpl->maInvalidateRegion.SetEmpty();
    2526             : 
    2527           0 :             if ( (nPaintFlags & IMPL_PAINT_ERASE) && IsBackground() )
    2528             :             {
    2529           0 :                 if ( IsClipRegion() )
    2530             :                 {
    2531           0 :                     Region aOldRegion = GetClipRegion();
    2532           0 :                     SetClipRegion();
    2533           0 :                     Erase();
    2534           0 :                     SetClipRegion( aOldRegion );
    2535             :                 }
    2536             :                 else
    2537           0 :                     Erase();
    2538             :             }
    2539             : 
    2540             :             // #98943# trigger drawing of toolbox selection after all childern are painted
    2541           0 :             if( mpWindowImpl->mbDrawSelectionBackground )
    2542           0 :                 aSelectionRect = aPaintRect;
    2543             : 
    2544             :             // Paint can throw exceptions; to not have a situation where
    2545             :             // mpWindowImpl->mbInPaint keeps to be on true (and other
    2546             :             // settings, too) better catch here to avoid to go completely out of
    2547             :             // this method without executing the after-paint stuff
    2548             :             try
    2549             :             {
    2550           0 :                 Paint( aPaintRect );
    2551             :             }
    2552           0 :             catch(Exception& rException)
    2553             :             {
    2554           0 :                 aException = rException;
    2555           0 :                 bExceptionCaught = true;
    2556             :             }
    2557             : 
    2558           0 :             if ( mpWindowImpl->mpWinData )
    2559             :             {
    2560           0 :                 if ( mpWindowImpl->mbFocusVisible )
    2561           0 :                     ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
    2562             :             }
    2563           0 :             mpWindowImpl->mbInPaint = false;
    2564           0 :             mbInitClipRegion = true;
    2565           0 :             mpWindowImpl->mpPaintRegion = NULL;
    2566           0 :             if ( mpWindowImpl->mpCursor )
    2567           0 :                 mpWindowImpl->mpCursor->ImplResume( bRestoreCursor );
    2568             :         }
    2569             :     }
    2570             :     else
    2571           0 :         mpWindowImpl->mnPaintFlags = 0;
    2572             : 
    2573           0 :     if ( nPaintFlags & (IMPL_PAINT_PAINTALLCHILDREN | IMPL_PAINT_PAINTCHILDREN) )
    2574             :     {
    2575             :         // Paint from the bottom child window and frontward.
    2576           0 :         Window* pTempWindow = mpWindowImpl->mpLastChild;
    2577           0 :         while ( pTempWindow )
    2578             :         {
    2579           0 :             if ( pTempWindow->mpWindowImpl->mbVisible )
    2580           0 :                 pTempWindow->ImplCallPaint( pChildRegion, nPaintFlags );
    2581           0 :             pTempWindow = pTempWindow->mpWindowImpl->mpPrev;
    2582             :         }
    2583             :     }
    2584             : 
    2585           0 :     if ( mpWindowImpl->mpWinData && mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
    2586             :         /* #98602# need to invert the tracking rect AFTER
    2587             :         * the children have painted
    2588             :         */
    2589           0 :         InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags );
    2590             : 
    2591             :     // #98943# draw toolbox selection
    2592           0 :     if( !aSelectionRect.IsEmpty() )
    2593           0 :         DrawSelectionBackground( aSelectionRect, 3, false, true, false );
    2594             : 
    2595           0 :     delete pChildRegion;
    2596             : 
    2597           0 :     if(bExceptionCaught)
    2598             :     {
    2599           0 :         throw(aException);
    2600           0 :     }
    2601             : }
    2602             : 
    2603           0 : void Window::ImplCallOverlapPaint()
    2604             : {
    2605             :     // emit overlapping windows first
    2606           0 :     Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
    2607           0 :     while ( pTempWindow )
    2608             :     {
    2609           0 :         if ( pTempWindow->mpWindowImpl->mbReallyVisible )
    2610           0 :             pTempWindow->ImplCallOverlapPaint();
    2611           0 :         pTempWindow = pTempWindow->mpWindowImpl->mpNext;
    2612             :     }
    2613             : 
    2614             :     // only then ourself
    2615           0 :     if ( mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDREN) )
    2616             :     {
    2617             :         // - RTL - notify ImplCallPaint to check for re-mirroring (CHECKRTL)
    2618             :         //         because we were called from the Sal layer
    2619           0 :         ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */);
    2620             :     }
    2621           0 : }
    2622             : 
    2623           0 : void Window::ImplPostPaint()
    2624             : {
    2625           0 :     if ( !ImplDoTiledRendering() && !mpWindowImpl->mpFrameData->maPaintTimer.IsActive() )
    2626           0 :         mpWindowImpl->mpFrameData->maPaintTimer.Start();
    2627           0 : }
    2628             : 
    2629           0 : IMPL_LINK_NOARG(Window, ImplHandlePaintHdl)
    2630             : {
    2631             :     // save paint events until layout is done
    2632           0 :     if (!ImplDoTiledRendering() && IsDialog() && static_cast<const Dialog*>(this)->hasPendingLayout())
    2633             :     {
    2634           0 :         mpWindowImpl->mpFrameData->maPaintTimer.Start();
    2635           0 :         return 0;
    2636             :     }
    2637             : 
    2638             :     // save paint events until resizing is done
    2639           0 :     if( !ImplDoTiledRendering() &&
    2640           0 :         mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
    2641           0 :         mpWindowImpl->mpFrameData->maPaintTimer.Start();
    2642           0 :     else if ( mpWindowImpl->mbReallyVisible )
    2643           0 :         ImplCallOverlapPaint();
    2644           0 :     return 0;
    2645             : }
    2646             : 
    2647           0 : IMPL_LINK_NOARG(Window, ImplHandleResizeTimerHdl)
    2648             : {
    2649           0 :     if( mpWindowImpl->mbReallyVisible )
    2650             :     {
    2651           0 :         ImplCallResize();
    2652           0 :         if( ImplDoTiledRendering() )
    2653             :         {
    2654           0 :             ImplHandlePaintHdl(NULL);
    2655             :         }
    2656           0 :         else if( mpWindowImpl->mpFrameData->maPaintTimer.IsActive() )
    2657             :         {
    2658           0 :             mpWindowImpl->mpFrameData->maPaintTimer.Stop();
    2659           0 :             mpWindowImpl->mpFrameData->maPaintTimer.GetTimeoutHdl().Call( NULL );
    2660             :         }
    2661             :     }
    2662             : 
    2663           0 :     return 0;
    2664             : }
    2665             : 
    2666           0 : void Window::ImplInvalidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags )
    2667             : {
    2668             :     // set PAINTCHILDREN for all parent windows till the first OverlapWindow
    2669           0 :     if ( !ImplIsOverlapWindow() )
    2670             :     {
    2671           0 :         Window* pTempWindow = this;
    2672           0 :         sal_uInt16 nTranspPaint = IsPaintTransparent() ? IMPL_PAINT_PAINT : 0;
    2673           0 :         do
    2674             :         {
    2675           0 :             pTempWindow = pTempWindow->ImplGetParent();
    2676           0 :             if ( pTempWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTCHILDREN )
    2677           0 :                 break;
    2678           0 :             pTempWindow->mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDREN | nTranspPaint;
    2679           0 :             if( ! pTempWindow->IsPaintTransparent() )
    2680           0 :                 nTranspPaint = 0;
    2681             :         }
    2682           0 :         while ( !pTempWindow->ImplIsOverlapWindow() );
    2683             :     }
    2684             : 
    2685             :     // set Paint-Flags
    2686           0 :     mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT;
    2687           0 :     if ( nFlags & INVALIDATE_CHILDREN )
    2688           0 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTALLCHILDREN;
    2689           0 :     if ( !(nFlags & INVALIDATE_NOERASE) )
    2690           0 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE;
    2691           0 :     if ( !pRegion )
    2692           0 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTALL;
    2693             : 
    2694             :     // if not everything has to be redrawn, add the region to it
    2695           0 :     if ( !(mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL) )
    2696           0 :         mpWindowImpl->maInvalidateRegion.Union( *pRegion );
    2697             : 
    2698             :     // Handle transparent windows correctly: invalidate must be done on the first opaque parent
    2699           0 :     if( ((IsPaintTransparent() && !(nFlags & INVALIDATE_NOTRANSPARENT)) || (nFlags & INVALIDATE_TRANSPARENT) )
    2700           0 :             && ImplGetParent() )
    2701             :     {
    2702           0 :         Window *pParent = ImplGetParent();
    2703           0 :         while( pParent && pParent->IsPaintTransparent() )
    2704           0 :             pParent = pParent->ImplGetParent();
    2705           0 :         if( pParent )
    2706             :         {
    2707             :             Region *pChildRegion;
    2708           0 :             if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2709             :                 // invalidate the whole child window region in the parent
    2710           0 :                 pChildRegion = ImplGetWinChildClipRegion();
    2711             :             else
    2712             :                 // invalidate the same region in the parent that has to be repainted in the child
    2713           0 :                 pChildRegion = &mpWindowImpl->maInvalidateRegion;
    2714             : 
    2715           0 :             nFlags |= INVALIDATE_CHILDREN;  // paint should also be done on all children
    2716           0 :             nFlags &= ~INVALIDATE_NOERASE;  // parent should paint and erase to create proper background
    2717           0 :             pParent->ImplInvalidateFrameRegion( pChildRegion, nFlags );
    2718             :         }
    2719             :     }
    2720           0 :     ImplPostPaint();
    2721           0 : }
    2722             : 
    2723           0 : void Window::ImplInvalidateOverlapFrameRegion( const Region& rRegion )
    2724             : {
    2725           0 :     Region aRegion = rRegion;
    2726             : 
    2727           0 :     ImplClipBoundaries( aRegion, true, true );
    2728           0 :     if ( !aRegion.IsEmpty() )
    2729           0 :         ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN );
    2730             : 
    2731             :     // now we invalidate the overlapping windows
    2732           0 :     Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
    2733           0 :     while ( pTempWindow )
    2734             :     {
    2735           0 :         if ( pTempWindow->IsVisible() )
    2736           0 :             pTempWindow->ImplInvalidateOverlapFrameRegion( rRegion );
    2737             : 
    2738           0 :         pTempWindow = pTempWindow->mpWindowImpl->mpNext;
    2739           0 :     }
    2740           0 : }
    2741             : 
    2742           0 : void Window::ImplInvalidateParentFrameRegion( Region& rRegion )
    2743             : {
    2744           0 :     if ( mpWindowImpl->mbOverlapWin )
    2745           0 :         mpWindowImpl->mpFrameWindow->ImplInvalidateOverlapFrameRegion( rRegion );
    2746             :     else
    2747             :     {
    2748           0 :         if( ImplGetParent() )
    2749           0 :             ImplGetParent()->ImplInvalidateFrameRegion( &rRegion, INVALIDATE_CHILDREN );
    2750             :     }
    2751           0 : }
    2752             : 
    2753           0 : void Window::ImplInvalidate( const Region* pRegion, sal_uInt16 nFlags )
    2754             : {
    2755             : 
    2756             :     // reset background storage
    2757           0 :     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    2758           0 :         ImplInvalidateAllOverlapBackgrounds();
    2759             : 
    2760             :     // check what has to be redrawn
    2761           0 :     bool bInvalidateAll = !pRegion;
    2762             : 
    2763             :     // take Transparent-Invalidate into account
    2764           0 :     Window* pOpaqueWindow = this;
    2765           0 :     if ( (mpWindowImpl->mbPaintTransparent && !(nFlags & INVALIDATE_NOTRANSPARENT)) || (nFlags & INVALIDATE_TRANSPARENT) )
    2766             :     {
    2767           0 :         Window* pTempWindow = pOpaqueWindow->ImplGetParent();
    2768           0 :         while ( pTempWindow )
    2769             :         {
    2770           0 :             if ( !pTempWindow->IsPaintTransparent() )
    2771             :             {
    2772           0 :                 pOpaqueWindow = pTempWindow;
    2773           0 :                 nFlags |= INVALIDATE_CHILDREN;
    2774           0 :                 bInvalidateAll = false;
    2775           0 :                 break;
    2776             :             }
    2777             : 
    2778           0 :             if ( pTempWindow->ImplIsOverlapWindow() )
    2779           0 :                 break;
    2780             : 
    2781           0 :             pTempWindow = pTempWindow->ImplGetParent();
    2782             :         }
    2783             :     }
    2784             : 
    2785             :     // assemble region
    2786           0 :     sal_uInt16 nOrgFlags = nFlags;
    2787           0 :     if ( !(nFlags & (INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN)) )
    2788             :     {
    2789           0 :         if ( GetStyle() & WB_CLIPCHILDREN )
    2790           0 :             nFlags |= INVALIDATE_NOCHILDREN;
    2791             :         else
    2792           0 :             nFlags |= INVALIDATE_CHILDREN;
    2793             :     }
    2794           0 :     if ( (nFlags & INVALIDATE_NOCHILDREN) && mpWindowImpl->mpFirstChild )
    2795           0 :         bInvalidateAll = false;
    2796           0 :     if ( bInvalidateAll )
    2797           0 :         ImplInvalidateFrameRegion( NULL, nFlags );
    2798             :     else
    2799             :     {
    2800           0 :         Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    2801           0 :         Region      aRegion( aRect );
    2802           0 :         if ( pRegion )
    2803             :         {
    2804             :             // --- RTL --- remirror region before intersecting it
    2805           0 :             if ( ImplIsAntiparallel() )
    2806             :             {
    2807           0 :                 const OutputDevice *pOutDev = GetOutDev();
    2808             : 
    2809           0 :                 Region aRgn( *pRegion );
    2810           0 :                 pOutDev->ReMirror( aRgn );
    2811           0 :                 aRegion.Intersect( aRgn );
    2812             :             }
    2813             :             else
    2814           0 :                 aRegion.Intersect( *pRegion );
    2815             :         }
    2816           0 :         ImplClipBoundaries( aRegion, true, true );
    2817           0 :         if ( nFlags & INVALIDATE_NOCHILDREN )
    2818             :         {
    2819           0 :             nFlags &= ~INVALIDATE_CHILDREN;
    2820           0 :             if ( !(nFlags & INVALIDATE_NOCLIPCHILDREN) )
    2821             :             {
    2822           0 :                 if ( nOrgFlags & INVALIDATE_NOCHILDREN )
    2823           0 :                     ImplClipAllChildren( aRegion );
    2824             :                 else
    2825             :                 {
    2826           0 :                     if ( ImplClipChildren( aRegion ) )
    2827           0 :                         nFlags |= INVALIDATE_CHILDREN;
    2828             :                 }
    2829             :             }
    2830             :         }
    2831           0 :         if ( !aRegion.IsEmpty() )
    2832           0 :             ImplInvalidateFrameRegion( &aRegion, nFlags );  // transparency is handled here, pOpaqueWindow not required
    2833             :     }
    2834             : 
    2835           0 :     if ( nFlags & INVALIDATE_UPDATE )
    2836           0 :         pOpaqueWindow->Update();        // start painting at the opaque parent
    2837           0 : }
    2838             : 
    2839           0 : void Window::ImplMoveInvalidateRegion( const Rectangle& rRect,
    2840             :                                        long nHorzScroll, long nVertScroll,
    2841             :                                        bool bChildren )
    2842             : {
    2843           0 :     if ( (mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALL)) == IMPL_PAINT_PAINT )
    2844             :     {
    2845           0 :         Region aTempRegion = mpWindowImpl->maInvalidateRegion;
    2846           0 :         aTempRegion.Intersect( rRect );
    2847           0 :         aTempRegion.Move( nHorzScroll, nVertScroll );
    2848           0 :         mpWindowImpl->maInvalidateRegion.Union( aTempRegion );
    2849             :     }
    2850             : 
    2851           0 :     if ( bChildren && (mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTCHILDREN) )
    2852             :     {
    2853           0 :         Window* pWindow = mpWindowImpl->mpFirstChild;
    2854           0 :         while ( pWindow )
    2855             :         {
    2856           0 :             pWindow->ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, true );
    2857           0 :             pWindow = pWindow->mpWindowImpl->mpNext;
    2858             :         }
    2859             :     }
    2860           0 : }
    2861             : 
    2862           0 : void Window::ImplMoveAllInvalidateRegions( const Rectangle& rRect,
    2863             :                                            long nHorzScroll, long nVertScroll,
    2864             :                                            bool bChildren )
    2865             : {
    2866             :     // also shift Paint-Region when paints need processing
    2867           0 :     ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, bChildren );
    2868             :     // Paint-Region should be shifted, as drawn by the parents
    2869           0 :     if ( !ImplIsOverlapWindow() )
    2870             :     {
    2871           0 :         Region  aPaintAllRegion;
    2872           0 :         Window* pPaintAllWindow = this;
    2873           0 :         do
    2874             :         {
    2875           0 :             pPaintAllWindow = pPaintAllWindow->ImplGetParent();
    2876           0 :             if ( pPaintAllWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
    2877             :             {
    2878           0 :                 if ( pPaintAllWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2879             :                 {
    2880           0 :                     aPaintAllRegion.SetEmpty();
    2881           0 :                     break;
    2882             :                 }
    2883             :                 else
    2884           0 :                     aPaintAllRegion.Union( pPaintAllWindow->mpWindowImpl->maInvalidateRegion );
    2885             :             }
    2886             :         }
    2887           0 :         while ( !pPaintAllWindow->ImplIsOverlapWindow() );
    2888           0 :         if ( !aPaintAllRegion.IsEmpty() )
    2889             :         {
    2890           0 :             aPaintAllRegion.Move( nHorzScroll, nVertScroll );
    2891           0 :             sal_uInt16 nPaintFlags = 0;
    2892           0 :             if ( bChildren )
    2893           0 :                 mpWindowImpl->mnPaintFlags |= INVALIDATE_CHILDREN;
    2894           0 :             ImplInvalidateFrameRegion( &aPaintAllRegion, nPaintFlags );
    2895           0 :         }
    2896             :     }
    2897           0 : }
    2898             : 
    2899           0 : void Window::ImplValidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags )
    2900             : {
    2901           0 :     if ( !pRegion )
    2902           0 :         mpWindowImpl->maInvalidateRegion.SetEmpty();
    2903             :     else
    2904             :     {
    2905             :         // when all child windows have to be drawn we need to invalidate them before doing so
    2906           0 :         if ( (mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDREN) && mpWindowImpl->mpFirstChild )
    2907             :         {
    2908           0 :             Region aChildRegion = mpWindowImpl->maInvalidateRegion;
    2909           0 :             if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2910             :             {
    2911           0 :                 Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    2912           0 :                 aChildRegion = aRect;
    2913             :             }
    2914           0 :             Window* pChild = mpWindowImpl->mpFirstChild;
    2915           0 :             while ( pChild )
    2916             :             {
    2917           0 :                 pChild->Invalidate( aChildRegion, INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT );
    2918           0 :                 pChild = pChild->mpWindowImpl->mpNext;
    2919           0 :             }
    2920             :         }
    2921           0 :         if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2922             :         {
    2923           0 :             Rectangle aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    2924           0 :             mpWindowImpl->maInvalidateRegion = aRect;
    2925             :         }
    2926           0 :         mpWindowImpl->maInvalidateRegion.Exclude( *pRegion );
    2927             :     }
    2928           0 :     mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALL;
    2929             : 
    2930           0 :     if ( nFlags & VALIDATE_CHILDREN )
    2931             :     {
    2932           0 :         Window* pChild = mpWindowImpl->mpFirstChild;
    2933           0 :         while ( pChild )
    2934             :         {
    2935           0 :             pChild->ImplValidateFrameRegion( pRegion, nFlags );
    2936           0 :             pChild = pChild->mpWindowImpl->mpNext;
    2937             :         }
    2938             :     }
    2939           0 : }
    2940             : 
    2941           0 : void Window::ImplValidate( const Region* pRegion, sal_uInt16 nFlags )
    2942             : {
    2943             :     // assemble region
    2944           0 :     bool    bValidateAll = !pRegion;
    2945           0 :     sal_uInt16  nOrgFlags = nFlags;
    2946           0 :     if ( !(nFlags & (VALIDATE_CHILDREN | VALIDATE_NOCHILDREN)) )
    2947             :     {
    2948           0 :         if ( GetStyle() & WB_CLIPCHILDREN )
    2949           0 :             nFlags |= VALIDATE_NOCHILDREN;
    2950             :         else
    2951           0 :             nFlags |= VALIDATE_CHILDREN;
    2952             :     }
    2953           0 :     if ( (nFlags & VALIDATE_NOCHILDREN) && mpWindowImpl->mpFirstChild )
    2954           0 :         bValidateAll = false;
    2955           0 :     if ( bValidateAll )
    2956           0 :         ImplValidateFrameRegion( NULL, nFlags );
    2957             :     else
    2958             :     {
    2959           0 :         Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    2960           0 :         Region      aRegion( aRect );
    2961           0 :         if ( pRegion )
    2962           0 :             aRegion.Intersect( *pRegion );
    2963           0 :         ImplClipBoundaries( aRegion, true, true );
    2964           0 :         if ( nFlags & VALIDATE_NOCHILDREN )
    2965             :         {
    2966           0 :             nFlags &= ~VALIDATE_CHILDREN;
    2967           0 :             if ( nOrgFlags & VALIDATE_NOCHILDREN )
    2968           0 :                 ImplClipAllChildren( aRegion );
    2969             :             else
    2970             :             {
    2971           0 :                 if ( ImplClipChildren( aRegion ) )
    2972           0 :                     nFlags |= VALIDATE_CHILDREN;
    2973             :             }
    2974             :         }
    2975           0 :         if ( !aRegion.IsEmpty() )
    2976           0 :             ImplValidateFrameRegion( &aRegion, nFlags );
    2977             :     }
    2978           0 : }
    2979             : 
    2980           0 : void Window::ImplScroll( const Rectangle& rRect,
    2981             :                          long nHorzScroll, long nVertScroll, sal_uInt16 nFlags )
    2982             : {
    2983           0 :     if ( !IsDeviceOutputNecessary() )
    2984           0 :         return;
    2985             : 
    2986           0 :     nHorzScroll = ImplLogicWidthToDevicePixel( nHorzScroll );
    2987           0 :     nVertScroll = ImplLogicHeightToDevicePixel( nVertScroll );
    2988             : 
    2989           0 :     if ( !nHorzScroll && !nVertScroll )
    2990           0 :         return;
    2991             : 
    2992             :     // restore background storage
    2993           0 :     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    2994           0 :         ImplInvalidateAllOverlapBackgrounds();
    2995             : 
    2996           0 :     if ( mpWindowImpl->mpCursor )
    2997           0 :         mpWindowImpl->mpCursor->ImplSuspend();
    2998             : 
    2999           0 :     sal_uInt16 nOrgFlags = nFlags;
    3000           0 :     if ( !(nFlags & (SCROLL_CHILDREN | SCROLL_NOCHILDREN)) )
    3001             :     {
    3002           0 :         if ( GetStyle() & WB_CLIPCHILDREN )
    3003           0 :             nFlags |= SCROLL_NOCHILDREN;
    3004             :         else
    3005           0 :             nFlags |= SCROLL_CHILDREN;
    3006             :     }
    3007             : 
    3008           0 :     Region  aInvalidateRegion;
    3009           0 :     bool    bScrollChildren = (nFlags & SCROLL_CHILDREN) != 0;
    3010           0 :     bool    bErase = (nFlags & SCROLL_NOERASE) == 0;
    3011             : 
    3012           0 :     if ( !mpWindowImpl->mpFirstChild )
    3013           0 :         bScrollChildren = false;
    3014             : 
    3015           0 :     OutputDevice *pOutDev = GetOutDev();
    3016             : 
    3017             :     // --- RTL --- check if this window requires special action
    3018           0 :     bool bReMirror = ( ImplIsAntiparallel() );
    3019             : 
    3020           0 :     Rectangle aRectMirror( rRect );
    3021           0 :     if( bReMirror )
    3022             :     {
    3023             :         // --- RTL --- make sure the invalidate region of this window is
    3024             :         // computed in the same coordinate space as the one from the overlap windows
    3025           0 :         pOutDev->ReMirror( aRectMirror );
    3026             :     }
    3027             : 
    3028             :     // adapt paint areas
    3029           0 :     ImplMoveAllInvalidateRegions( aRectMirror, nHorzScroll, nVertScroll, bScrollChildren );
    3030             : 
    3031           0 :     if ( !(nFlags & SCROLL_NOINVALIDATE) )
    3032             :     {
    3033           0 :         ImplCalcOverlapRegion( aRectMirror, aInvalidateRegion, !bScrollChildren, true, false );
    3034             : 
    3035             :         // --- RTL ---
    3036             :         // if the scrolling on the device is performed in the opposite direction
    3037             :         // then move the overlaps in that direction to compute the invalidate region
    3038             :         // on the correct side, i.e., revert nHorzScroll
    3039             : 
    3040           0 :         if ( !aInvalidateRegion.IsEmpty() )
    3041             :         {
    3042           0 :             aInvalidateRegion.Move( bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll );
    3043           0 :             bErase = true;
    3044             :         }
    3045           0 :         if ( !(nFlags & SCROLL_NOWINDOWINVALIDATE) )
    3046             :         {
    3047           0 :             Rectangle aDestRect( aRectMirror );
    3048           0 :             aDestRect.Move( bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll );
    3049           0 :             Region aWinInvalidateRegion( aRectMirror );
    3050           0 :             aWinInvalidateRegion.Exclude( aDestRect );
    3051             : 
    3052           0 :             aInvalidateRegion.Union( aWinInvalidateRegion );
    3053             :         }
    3054             :     }
    3055             : 
    3056           0 :     Point aPoint( mnOutOffX, mnOutOffY );
    3057           0 :     Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
    3058           0 :     if ( nFlags & SCROLL_CLIP )
    3059           0 :         aRegion.Intersect( rRect );
    3060           0 :     if ( mpWindowImpl->mbWinRegion )
    3061           0 :         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    3062             : 
    3063           0 :     aRegion.Exclude( aInvalidateRegion );
    3064             : 
    3065           0 :     ImplClipBoundaries( aRegion, false, true );
    3066           0 :     if ( !bScrollChildren )
    3067             :     {
    3068           0 :         if ( nOrgFlags & SCROLL_NOCHILDREN )
    3069           0 :             ImplClipAllChildren( aRegion );
    3070             :         else
    3071           0 :             ImplClipChildren( aRegion );
    3072             :     }
    3073           0 :     if ( mbClipRegion && (nFlags & SCROLL_USECLIPREGION) )
    3074           0 :         aRegion.Intersect( maRegion );
    3075           0 :     if ( !aRegion.IsEmpty() )
    3076             :     {
    3077           0 :         if ( mpWindowImpl->mpWinData )
    3078             :         {
    3079           0 :             if ( mpWindowImpl->mbFocusVisible )
    3080           0 :                 ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
    3081           0 :             if ( mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
    3082           0 :                 InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags );
    3083             :         }
    3084             : #ifndef IOS
    3085             :         // This seems completely unnecessary with tiled rendering, and
    3086             :         // causes the "AquaSalGraphics::copyArea() for non-layered
    3087             :         // graphics" message. Presumably we should bypass this on all
    3088             :         // platforms when dealing with a "window" that uses tiled
    3089             :         // rendering at the moment. Unclear how to figure that out,
    3090             :         // though. Also unclear whether we actually could just not
    3091             :         // create a "frame window", whatever that exactly is, in the
    3092             :         // tiled rendering case, or at least for platforms where tiles
    3093             :         // rendering is all there is.
    3094             : 
    3095           0 :         SalGraphics* pGraphics = ImplGetFrameGraphics();
    3096           0 :         if ( pGraphics )
    3097             :         {
    3098           0 :             if( bReMirror )
    3099             :             {
    3100             :                 // --- RTL --- frame coordinates require re-mirroring
    3101           0 :                 pOutDev->ReMirror( aRegion );
    3102             :             }
    3103             : 
    3104           0 :             pOutDev->ImplSelectClipRegion( aRegion, pGraphics );
    3105           0 :             pGraphics->CopyArea( rRect.Left()+nHorzScroll, rRect.Top()+nVertScroll,
    3106             :                                  rRect.Left(), rRect.Top(),
    3107             :                                  rRect.GetWidth(), rRect.GetHeight(),
    3108           0 :                                  SAL_COPYAREA_WINDOWINVALIDATE, this );
    3109             :         }
    3110             : #endif
    3111           0 :         if ( mpWindowImpl->mpWinData )
    3112             :         {
    3113           0 :             if ( mpWindowImpl->mbFocusVisible )
    3114           0 :                 ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
    3115           0 :             if ( mpWindowImpl->mbTrackVisible && (mpWindowImpl->mpWinData->mnTrackFlags & SHOWTRACK_WINDOW) )
    3116           0 :                 InvertTracking( *(mpWindowImpl->mpWinData->mpTrackRect), mpWindowImpl->mpWinData->mnTrackFlags );
    3117             :         }
    3118             :     }
    3119             : 
    3120           0 :     if ( !aInvalidateRegion.IsEmpty() )
    3121             :     {
    3122             :         // --- RTL --- the invalidate region for this windows is already computed in frame coordinates
    3123             :         // so it has to be re-mirrored before calling the Paint-handler
    3124           0 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
    3125             : 
    3126           0 :         sal_uInt16 nPaintFlags = INVALIDATE_CHILDREN;
    3127           0 :         if ( !bErase )
    3128           0 :             nPaintFlags |= INVALIDATE_NOERASE;
    3129           0 :         if ( !bScrollChildren )
    3130             :         {
    3131           0 :             if ( nOrgFlags & SCROLL_NOCHILDREN )
    3132           0 :                 ImplClipAllChildren( aInvalidateRegion );
    3133             :             else
    3134           0 :                 ImplClipChildren( aInvalidateRegion );
    3135             :         }
    3136           0 :         ImplInvalidateFrameRegion( &aInvalidateRegion, nPaintFlags );
    3137             :     }
    3138             : 
    3139           0 :     if ( bScrollChildren )
    3140             :     {
    3141           0 :         Window* pWindow = mpWindowImpl->mpFirstChild;
    3142           0 :         while ( pWindow )
    3143             :         {
    3144           0 :             Point aPos = pWindow->GetPosPixel();
    3145           0 :             aPos += Point( nHorzScroll, nVertScroll );
    3146           0 :             pWindow->SetPosPixel( aPos );
    3147             : 
    3148           0 :             pWindow = pWindow->mpWindowImpl->mpNext;
    3149             :         }
    3150             :     }
    3151             : 
    3152           0 :     if ( nFlags & SCROLL_UPDATE )
    3153           0 :         Update();
    3154             : 
    3155           0 :     if ( mpWindowImpl->mpCursor )
    3156           0 :         mpWindowImpl->mpCursor->ImplResume();
    3157             : }
    3158             : 
    3159           0 : void Window::ImplUpdateAll( bool bOverlapWindows )
    3160             : {
    3161           0 :     if ( !mpWindowImpl->mbReallyVisible )
    3162           0 :         return;
    3163             : 
    3164           0 :     bool bFlush = false;
    3165           0 :     if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
    3166             :     {
    3167           0 :         Point aPoint( 0, 0 );
    3168           0 :         Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
    3169           0 :         ImplInvalidateOverlapFrameRegion( aRegion );
    3170           0 :         if ( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) )
    3171           0 :             bFlush = true;
    3172             :     }
    3173             : 
    3174             :     // an update changes the OverlapWindow, such that for later paints
    3175             :     // not too much has to be drawn, if ALLCHILDREN etc. is set
    3176           0 :     Window* pWindow = ImplGetFirstOverlapWindow();
    3177           0 :     if ( bOverlapWindows )
    3178           0 :         pWindow->ImplCallOverlapPaint();
    3179             :     else
    3180             :     {
    3181           0 :         if ( pWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDREN) )
    3182           0 :             pWindow->ImplCallPaint( NULL, pWindow->mpWindowImpl->mnPaintFlags );
    3183             :     }
    3184             : 
    3185           0 :     if ( bFlush )
    3186           0 :         Flush();
    3187             : }
    3188             : 
    3189           0 : void Window::ImplUpdateWindowPtr( Window* pWindow )
    3190             : {
    3191           0 :     if ( mpWindowImpl->mpFrameWindow != pWindow->mpWindowImpl->mpFrameWindow )
    3192             :     {
    3193             :         // release graphic
    3194           0 :         OutputDevice *pOutDev = GetOutDev();
    3195           0 :         pOutDev->ImplReleaseGraphics();
    3196             :     }
    3197             : 
    3198           0 :     mpWindowImpl->mpFrameData     = pWindow->mpWindowImpl->mpFrameData;
    3199           0 :     mpWindowImpl->mpFrame         = pWindow->mpWindowImpl->mpFrame;
    3200           0 :     mpWindowImpl->mpFrameWindow   = pWindow->mpWindowImpl->mpFrameWindow;
    3201           0 :     if ( pWindow->ImplIsOverlapWindow() )
    3202           0 :         mpWindowImpl->mpOverlapWindow = pWindow;
    3203             :     else
    3204           0 :         mpWindowImpl->mpOverlapWindow = pWindow->mpWindowImpl->mpOverlapWindow;
    3205             : 
    3206           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    3207           0 :     while ( pChild )
    3208             :     {
    3209           0 :         pChild->ImplUpdateWindowPtr( pWindow );
    3210           0 :         pChild = pChild->mpWindowImpl->mpNext;
    3211             :     }
    3212           0 : }
    3213             : 
    3214           0 : void Window::ImplUpdateWindowPtr()
    3215             : {
    3216           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    3217           0 :     while ( pChild )
    3218             :     {
    3219           0 :         pChild->ImplUpdateWindowPtr( this );
    3220           0 :         pChild = pChild->mpWindowImpl->mpNext;
    3221             :     }
    3222           0 : }
    3223             : 
    3224           0 : void Window::ImplUpdateOverlapWindowPtr( bool bNewFrame )
    3225             : {
    3226           0 :     bool bVisible = IsVisible();
    3227           0 :     Show( false );
    3228           0 :     ImplRemoveWindow( bNewFrame );
    3229           0 :     Window* pRealParent = mpWindowImpl->mpRealParent;
    3230           0 :     ImplInsertWindow( ImplGetParent() );
    3231           0 :     mpWindowImpl->mpRealParent = pRealParent;
    3232           0 :     ImplUpdateWindowPtr();
    3233           0 :     if ( ImplUpdatePos() )
    3234           0 :         ImplUpdateSysObjPos();
    3235             : 
    3236           0 :     if ( bNewFrame )
    3237             :     {
    3238           0 :         Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
    3239           0 :         while ( pOverlapWindow )
    3240             :         {
    3241           0 :             Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
    3242           0 :             pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame );
    3243           0 :             pOverlapWindow = pNextOverlapWindow;
    3244             :         }
    3245             :     }
    3246             : 
    3247           0 :     if ( bVisible )
    3248           0 :         Show( true );
    3249           0 : }
    3250             : 
    3251           0 : bool Window::ImplUpdatePos()
    3252             : {
    3253           0 :     bool bSysChild = false;
    3254             : 
    3255           0 :     if ( ImplIsOverlapWindow() )
    3256             :     {
    3257           0 :         mnOutOffX  = mpWindowImpl->mnX;
    3258           0 :         mnOutOffY  = mpWindowImpl->mnY;
    3259             :     }
    3260             :     else
    3261             :     {
    3262           0 :         Window* pParent = ImplGetParent();
    3263             : 
    3264           0 :         mnOutOffX  = mpWindowImpl->mnX + pParent->mnOutOffX;
    3265           0 :         mnOutOffY  = mpWindowImpl->mnY + pParent->mnOutOffY;
    3266             :     }
    3267             : 
    3268           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    3269           0 :     while ( pChild )
    3270             :     {
    3271           0 :         if ( pChild->ImplUpdatePos() )
    3272           0 :             bSysChild = true;
    3273           0 :         pChild = pChild->mpWindowImpl->mpNext;
    3274             :     }
    3275             : 
    3276           0 :     if ( mpWindowImpl->mpSysObj )
    3277           0 :         bSysChild = true;
    3278             : 
    3279           0 :     return bSysChild;
    3280             : }
    3281             : 
    3282           0 : void Window::ImplUpdateSysObjPos()
    3283             : {
    3284           0 :     if ( mpWindowImpl->mpSysObj )
    3285           0 :         mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
    3286             : 
    3287           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    3288           0 :     while ( pChild )
    3289             :     {
    3290           0 :         pChild->ImplUpdateSysObjPos();
    3291           0 :         pChild = pChild->mpWindowImpl->mpNext;
    3292             :     }
    3293           0 : }
    3294             : 
    3295           0 : void Window::ImplPosSizeWindow( long nX, long nY,
    3296             :                                 long nWidth, long nHeight, sal_uInt16 nFlags )
    3297             : {
    3298           0 :     bool    bNewPos         = false;
    3299           0 :     bool    bNewSize        = false;
    3300           0 :     bool    bCopyBits       = false;
    3301           0 :     long    nOldOutOffX     = mnOutOffX;
    3302           0 :     long    nOldOutOffY     = mnOutOffY;
    3303           0 :     long    nOldOutWidth    = mnOutWidth;
    3304           0 :     long    nOldOutHeight   = mnOutHeight;
    3305           0 :     Region* pOverlapRegion  = NULL;
    3306           0 :     Region* pOldRegion      = NULL;
    3307             : 
    3308           0 :     if ( IsReallyVisible() )
    3309             :     {
    3310           0 :         if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    3311           0 :             ImplInvalidateAllOverlapBackgrounds();
    3312             : 
    3313             :         Rectangle aOldWinRect( Point( nOldOutOffX, nOldOutOffY ),
    3314           0 :                                Size( nOldOutWidth, nOldOutHeight ) );
    3315           0 :         pOldRegion = new Region( aOldWinRect );
    3316           0 :         if ( mpWindowImpl->mbWinRegion )
    3317           0 :             pOldRegion->Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    3318             : 
    3319           0 :         if ( mnOutWidth && mnOutHeight && !mpWindowImpl->mbPaintTransparent &&
    3320           0 :              !mpWindowImpl->mbInitWinClipRegion && !mpWindowImpl->maWinClipRegion.IsEmpty() &&
    3321           0 :              !HasPaintEvent() )
    3322           0 :             bCopyBits = true;
    3323             :     }
    3324             : 
    3325           0 :     bool bnXRecycled = false; // avoid duplicate mirroring in RTL case
    3326           0 :     if ( nFlags & WINDOW_POSSIZE_WIDTH )
    3327             :     {
    3328           0 :         if(!( nFlags & WINDOW_POSSIZE_X ))
    3329             :         {
    3330           0 :             nX = mpWindowImpl->mnX;
    3331           0 :             nFlags |= WINDOW_POSSIZE_X;
    3332           0 :             bnXRecycled = true; // we're using a mnX which was already mirrored in RTL case
    3333             :         }
    3334             : 
    3335           0 :         if ( nWidth < 0 )
    3336           0 :             nWidth = 0;
    3337           0 :         if ( nWidth != mnOutWidth )
    3338             :         {
    3339           0 :             mnOutWidth = nWidth;
    3340           0 :             bNewSize = true;
    3341           0 :             bCopyBits = false;
    3342             :         }
    3343             :     }
    3344           0 :     if ( nFlags & WINDOW_POSSIZE_HEIGHT )
    3345             :     {
    3346           0 :         if ( nHeight < 0 )
    3347           0 :             nHeight = 0;
    3348           0 :         if ( nHeight != mnOutHeight )
    3349             :         {
    3350           0 :             mnOutHeight = nHeight;
    3351           0 :             bNewSize = true;
    3352           0 :             bCopyBits = false;
    3353             :         }
    3354             :     }
    3355             : 
    3356           0 :     if ( nFlags & WINDOW_POSSIZE_X )
    3357             :     {
    3358           0 :         long nOrgX = nX;
    3359             :         // --- RTL ---  (compare the screen coordinates)
    3360           0 :         Point aPtDev( Point( nX+mnOutOffX, 0 ) );
    3361           0 :         OutputDevice *pOutDev = GetOutDev();
    3362           0 :         if( pOutDev->HasMirroredGraphics() )
    3363             :         {
    3364           0 :             mpGraphics->mirror( aPtDev.X(), this );
    3365             : 
    3366             :             // #106948# always mirror our pos if our parent is not mirroring, even
    3367             :             // if we are also not mirroring
    3368             :             // --- RTL --- check if parent is in different coordinates
    3369           0 :             if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
    3370             :             {
    3371             :                 // --- RTL --- (re-mirror at parent window)
    3372           0 :                 nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX;
    3373             :             }
    3374             :             /* #i99166# An LTR window in RTL UI that gets sized only would be
    3375             :                expected to not moved its upper left point
    3376             :             */
    3377           0 :             if( bnXRecycled )
    3378             :             {
    3379           0 :                 if( ImplIsAntiparallel() )
    3380             :                 {
    3381           0 :                     aPtDev.X() = mpWindowImpl->mnAbsScreenX;
    3382           0 :                     nOrgX = mpWindowImpl->maPos.X();
    3383             :                 }
    3384             :             }
    3385             :         }
    3386           0 :         else if( !bnXRecycled && mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
    3387             :         {
    3388             :             // mirrored window in LTR UI
    3389             :             {
    3390             :                 // --- RTL --- (re-mirror at parent window)
    3391           0 :                 nX = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - nX;
    3392             :             }
    3393             :         }
    3394             : 
    3395             :         // check maPos as well, as it could have been changed for client windows (ImplCallMove())
    3396           0 :         if ( mpWindowImpl->mnAbsScreenX != aPtDev.X() || nX != mpWindowImpl->mnX || nOrgX != mpWindowImpl->maPos.X() )
    3397             :         {
    3398           0 :             if ( bCopyBits && !pOverlapRegion )
    3399             :             {
    3400           0 :                 pOverlapRegion = new Region();
    3401             :                 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
    3402             :                                                   Size( mnOutWidth, mnOutHeight ) ),
    3403           0 :                                        *pOverlapRegion, false, true, true );
    3404             :             }
    3405           0 :             mpWindowImpl->mnX = nX;
    3406           0 :             mpWindowImpl->maPos.X() = nOrgX;
    3407           0 :             mpWindowImpl->mnAbsScreenX = aPtDev.X();    // --- RTL --- (store real screen pos)
    3408           0 :             bNewPos = true;
    3409             :         }
    3410             :     }
    3411           0 :     if ( nFlags & WINDOW_POSSIZE_Y )
    3412             :     {
    3413             :         // check maPos as well, as it could have been changed for client windows (ImplCallMove())
    3414           0 :         if ( nY != mpWindowImpl->mnY || nY != mpWindowImpl->maPos.Y() )
    3415             :         {
    3416           0 :             if ( bCopyBits && !pOverlapRegion )
    3417             :             {
    3418           0 :                 pOverlapRegion = new Region();
    3419             :                 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
    3420             :                                                   Size( mnOutWidth, mnOutHeight ) ),
    3421           0 :                                        *pOverlapRegion, false, true, true );
    3422             :             }
    3423           0 :             mpWindowImpl->mnY = nY;
    3424           0 :             mpWindowImpl->maPos.Y() = nY;
    3425           0 :             bNewPos = true;
    3426             :         }
    3427             :     }
    3428             : 
    3429           0 :     if ( bNewPos || bNewSize )
    3430             :     {
    3431           0 :         bool bUpdateSysObjPos = false;
    3432           0 :         if ( bNewPos )
    3433           0 :             bUpdateSysObjPos = ImplUpdatePos();
    3434             : 
    3435             :         // the borderwindow always specifies the position for its client window
    3436           0 :         if ( mpWindowImpl->mpBorderWindow )
    3437           0 :             mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos;
    3438             : 
    3439           0 :         if ( mpWindowImpl->mpClientWindow )
    3440             :         {
    3441             :             mpWindowImpl->mpClientWindow->ImplPosSizeWindow( mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder,
    3442             :                                                mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder,
    3443           0 :                                                mnOutWidth-mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder,
    3444           0 :                                                mnOutHeight-mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder,
    3445             :                                                WINDOW_POSSIZE_X | WINDOW_POSSIZE_Y |
    3446           0 :                                                WINDOW_POSSIZE_WIDTH | WINDOW_POSSIZE_HEIGHT );
    3447             :             // Wenn wir ein ClientWindow haben, dann hat dieses fuer die
    3448             :             // Applikation auch die Position des FloatingWindows
    3449           0 :             mpWindowImpl->mpClientWindow->mpWindowImpl->maPos = mpWindowImpl->maPos;
    3450           0 :             if ( bNewPos )
    3451             :             {
    3452           0 :                 if ( mpWindowImpl->mpClientWindow->IsVisible() )
    3453             :                 {
    3454           0 :                     mpWindowImpl->mpClientWindow->ImplCallMove();
    3455             :                 }
    3456             :                 else
    3457             :                 {
    3458           0 :                     mpWindowImpl->mpClientWindow->mpWindowImpl->mbCallMove = true;
    3459             :                 }
    3460             :             }
    3461             :         }
    3462             : 
    3463             :         // Move()/Resize() will be called only for Show(), such that
    3464             :         // at least one is called before Show()
    3465           0 :         if ( IsVisible() )
    3466             :         {
    3467           0 :             if ( bNewPos )
    3468             :             {
    3469           0 :                 ImplCallMove();
    3470             :             }
    3471           0 :             if ( bNewSize )
    3472             :             {
    3473           0 :                 ImplCallResize();
    3474             :             }
    3475             :         }
    3476             :         else
    3477             :         {
    3478           0 :             if ( bNewPos )
    3479           0 :                 mpWindowImpl->mbCallMove = true;
    3480           0 :             if ( bNewSize )
    3481           0 :                 mpWindowImpl->mbCallResize = true;
    3482             :         }
    3483             : 
    3484           0 :         bool bUpdateSysObjClip = false;
    3485           0 :         if ( IsReallyVisible() )
    3486             :         {
    3487           0 :             if ( bNewPos || bNewSize )
    3488             :             {
    3489             :                 // reset background storage
    3490           0 :                 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
    3491           0 :                     ImplDeleteOverlapBackground();
    3492           0 :                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    3493           0 :                     ImplInvalidateAllOverlapBackgrounds();
    3494             :                 // set Clip-Flag
    3495           0 :                 bUpdateSysObjClip = !ImplSetClipFlag( true );
    3496             :             }
    3497             : 
    3498             :             // invalidate window content ?
    3499           0 :             if ( bNewPos || (mnOutWidth > nOldOutWidth) || (mnOutHeight > nOldOutHeight) )
    3500             :             {
    3501           0 :                 if ( bNewPos )
    3502             :                 {
    3503           0 :                     bool bInvalidate = false;
    3504           0 :                     bool bParentPaint = true;
    3505           0 :                     if ( !ImplIsOverlapWindow() )
    3506           0 :                         bParentPaint = mpWindowImpl->mpParent->IsPaintEnabled();
    3507           0 :                     if ( bCopyBits && bParentPaint && !HasPaintEvent() )
    3508             :                     {
    3509           0 :                         Point aPoint( mnOutOffX, mnOutOffY );
    3510             :                         Region aRegion( Rectangle( aPoint,
    3511           0 :                                                    Size( mnOutWidth, mnOutHeight ) ) );
    3512           0 :                         if ( mpWindowImpl->mbWinRegion )
    3513           0 :                             aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    3514           0 :                         ImplClipBoundaries( aRegion, false, true );
    3515           0 :                         if ( !pOverlapRegion->IsEmpty() )
    3516             :                         {
    3517           0 :                             pOverlapRegion->Move( mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY );
    3518           0 :                             aRegion.Exclude( *pOverlapRegion );
    3519             :                         }
    3520           0 :                         if ( !aRegion.IsEmpty() )
    3521             :                         {
    3522             :                             // adapt Paint areas
    3523             :                             ImplMoveAllInvalidateRegions( Rectangle( Point( nOldOutOffX, nOldOutOffY ),
    3524             :                                                                      Size( nOldOutWidth, nOldOutHeight ) ),
    3525             :                                                           mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY,
    3526           0 :                                                           true );
    3527           0 :                             SalGraphics* pGraphics = ImplGetFrameGraphics();
    3528           0 :                             if ( pGraphics )
    3529             :                             {
    3530             : 
    3531           0 :                                 OutputDevice *pOutDev = GetOutDev();
    3532           0 :                                 const bool bSelectClipRegion = pOutDev->ImplSelectClipRegion( aRegion, pGraphics );
    3533           0 :                                 if ( bSelectClipRegion )
    3534             :                                 {
    3535             :                                     pGraphics->CopyArea( mnOutOffX, mnOutOffY,
    3536             :                                                          nOldOutOffX, nOldOutOffY,
    3537             :                                                          nOldOutWidth, nOldOutHeight,
    3538           0 :                                                          SAL_COPYAREA_WINDOWINVALIDATE, this );
    3539             :                                 }
    3540             :                                 else
    3541           0 :                                     bInvalidate = true;
    3542             :                             }
    3543             :                             else
    3544           0 :                                 bInvalidate = true;
    3545           0 :                             if ( !bInvalidate )
    3546             :                             {
    3547           0 :                                 if ( !pOverlapRegion->IsEmpty() )
    3548           0 :                                     ImplInvalidateFrameRegion( pOverlapRegion, INVALIDATE_CHILDREN );
    3549             :                             }
    3550             :                         }
    3551             :                         else
    3552           0 :                             bInvalidate = true;
    3553             :                     }
    3554             :                     else
    3555           0 :                         bInvalidate = true;
    3556           0 :                     if ( bInvalidate )
    3557           0 :                         ImplInvalidateFrameRegion( NULL, INVALIDATE_CHILDREN );
    3558             :                 }
    3559             :                 else
    3560             :                 {
    3561           0 :                     Point aPoint( mnOutOffX, mnOutOffY );
    3562             :                     Region aRegion( Rectangle( aPoint,
    3563           0 :                                                Size( mnOutWidth, mnOutHeight ) ) );
    3564           0 :                     aRegion.Exclude( *pOldRegion );
    3565           0 :                     if ( mpWindowImpl->mbWinRegion )
    3566           0 :                         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    3567           0 :                     ImplClipBoundaries( aRegion, false, true );
    3568           0 :                     if ( !aRegion.IsEmpty() )
    3569           0 :                         ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN );
    3570             :                 }
    3571             :             }
    3572             : 
    3573             :             // invalidate Parent or Overlaps
    3574           0 :             if ( bNewPos ||
    3575           0 :                  (mnOutWidth < nOldOutWidth) || (mnOutHeight < nOldOutHeight) )
    3576             :             {
    3577           0 :                 Region aRegion( *pOldRegion );
    3578           0 :                 if ( !mpWindowImpl->mbPaintTransparent )
    3579           0 :                     ImplExcludeWindowRegion( aRegion );
    3580           0 :                 ImplClipBoundaries( aRegion, false, true );
    3581           0 :                 if ( !aRegion.IsEmpty() && !mpWindowImpl->mpBorderWindow )
    3582           0 :                     ImplInvalidateParentFrameRegion( aRegion );
    3583             :             }
    3584             :         }
    3585             : 
    3586             :         // adapt system objects
    3587           0 :         if ( bUpdateSysObjClip )
    3588           0 :             ImplUpdateSysObjClip();
    3589           0 :         if ( bUpdateSysObjPos )
    3590           0 :             ImplUpdateSysObjPos();
    3591           0 :         if ( bNewSize && mpWindowImpl->mpSysObj )
    3592           0 :             mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
    3593             :     }
    3594             : 
    3595           0 :     delete pOverlapRegion;
    3596           0 :     delete pOldRegion;
    3597           0 : }
    3598             : 
    3599           0 : void Window::ImplToBottomChild()
    3600             : {
    3601           0 :     if ( !ImplIsOverlapWindow() && !mpWindowImpl->mbReallyVisible && (mpWindowImpl->mpParent->mpWindowImpl->mpLastChild != this) )
    3602             :     {
    3603             :         // put the window to the end of the list
    3604           0 :         if ( mpWindowImpl->mpPrev )
    3605           0 :             mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    3606             :         else
    3607           0 :             mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
    3608           0 :         mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    3609           0 :         mpWindowImpl->mpPrev = mpWindowImpl->mpParent->mpWindowImpl->mpLastChild;
    3610           0 :         mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this;
    3611           0 :         mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    3612           0 :         mpWindowImpl->mpNext = NULL;
    3613             :     }
    3614           0 : }
    3615             : 
    3616           0 : void Window::ImplCalcToTop( ImplCalcToTopData* pPrevData )
    3617             : {
    3618             :     DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplCalcToTop(): Is not a OverlapWindow" );
    3619             : 
    3620           0 :     if ( !mpWindowImpl->mbFrame )
    3621             :     {
    3622           0 :         if ( IsReallyVisible() )
    3623             :         {
    3624             :             // calculate region, where the window overlaps with other windows
    3625           0 :             Point aPoint( mnOutOffX, mnOutOffY );
    3626             :             Region  aRegion( Rectangle( aPoint,
    3627           0 :                                         Size( mnOutWidth, mnOutHeight ) ) );
    3628           0 :             Region  aInvalidateRegion;
    3629           0 :             ImplCalcOverlapRegionOverlaps( aRegion, aInvalidateRegion );
    3630             : 
    3631           0 :             if ( !aInvalidateRegion.IsEmpty() )
    3632             :             {
    3633           0 :                 ImplCalcToTopData* pData    = new ImplCalcToTopData;
    3634           0 :                 pPrevData->mpNext           = pData;
    3635           0 :                 pData->mpNext               = NULL;
    3636           0 :                 pData->mpWindow             = this;
    3637           0 :                 pData->mpInvalidateRegion   = new Region( aInvalidateRegion );
    3638           0 :             }
    3639             :         }
    3640             :     }
    3641           0 : }
    3642             : 
    3643           0 : void Window::ImplToTop( sal_uInt16 nFlags )
    3644             : {
    3645             :     DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplToTop(): Is not a OverlapWindow" );
    3646             : 
    3647           0 :     if ( mpWindowImpl->mbFrame )
    3648             :     {
    3649             :         // on a mouse click in the external window, it is the latter's
    3650             :         // responsibility to assure our frame is put in front
    3651           0 :         if ( !mpWindowImpl->mpFrameData->mbHasFocus &&
    3652           0 :              !mpWindowImpl->mpFrameData->mbSysObjFocus &&
    3653           0 :              !mpWindowImpl->mpFrameData->mbInSysObjFocusHdl &&
    3654           0 :              !mpWindowImpl->mpFrameData->mbInSysObjToTopHdl )
    3655             :         {
    3656             :             // do not bring floating windows on the client to top
    3657           0 :             if( !ImplGetClientWindow() || !(ImplGetClientWindow()->GetStyle() & WB_SYSTEMFLOATWIN) )
    3658             :             {
    3659           0 :                 sal_uInt16 nSysFlags = 0;
    3660           0 :                 if ( nFlags & TOTOP_RESTOREWHENMIN )
    3661           0 :                     nSysFlags |= SAL_FRAME_TOTOP_RESTOREWHENMIN;
    3662           0 :                 if ( nFlags & TOTOP_FOREGROUNDTASK )
    3663           0 :                     nSysFlags |= SAL_FRAME_TOTOP_FOREGROUNDTASK;
    3664           0 :                 if ( nFlags & TOTOP_GRABFOCUSONLY )
    3665           0 :                     nSysFlags |= SAL_FRAME_TOTOP_GRABFOCUS_ONLY;
    3666           0 :                 mpWindowImpl->mpFrame->ToTop( nSysFlags );
    3667             :             }
    3668             :         }
    3669             :     }
    3670             :     else
    3671             :     {
    3672           0 :         if ( mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap != this )
    3673             :         {
    3674             :             // remove window from the list
    3675           0 :             mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    3676           0 :             if ( mpWindowImpl->mpNext )
    3677           0 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    3678             :             else
    3679           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev;
    3680             : 
    3681             :             // take AlwaysOnTop into account
    3682           0 :             bool    bOnTop = IsAlwaysOnTopEnabled();
    3683           0 :             Window* pNextWin = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
    3684           0 :             if ( !bOnTop )
    3685             :             {
    3686           0 :                 while ( pNextWin )
    3687             :                 {
    3688           0 :                     if ( !pNextWin->IsAlwaysOnTopEnabled() )
    3689           0 :                         break;
    3690           0 :                     pNextWin = pNextWin->mpWindowImpl->mpNext;
    3691             :                 }
    3692             :             }
    3693             : 
    3694             :             // check TopLevel
    3695           0 :             sal_uInt8 nTopLevel = mpWindowImpl->mpOverlapData->mnTopLevel;
    3696           0 :             while ( pNextWin )
    3697             :             {
    3698           0 :                 if ( (bOnTop != pNextWin->IsAlwaysOnTopEnabled()) ||
    3699           0 :                      (nTopLevel <= pNextWin->mpWindowImpl->mpOverlapData->mnTopLevel) )
    3700           0 :                     break;
    3701           0 :                 pNextWin = pNextWin->mpWindowImpl->mpNext;
    3702             :             }
    3703             : 
    3704             :             // add the window to the list again
    3705           0 :             mpWindowImpl->mpNext = pNextWin;
    3706           0 :             if ( pNextWin )
    3707             :             {
    3708           0 :                 mpWindowImpl->mpPrev = pNextWin->mpWindowImpl->mpPrev;
    3709           0 :                 pNextWin->mpWindowImpl->mpPrev = this;
    3710             :             }
    3711             :             else
    3712             :             {
    3713           0 :                 mpWindowImpl->mpPrev = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap;
    3714           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = this;
    3715             :             }
    3716           0 :             if ( mpWindowImpl->mpPrev )
    3717           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    3718             :             else
    3719           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = this;
    3720             : 
    3721             :             // recalculate ClipRegion of this and all overlapping windows
    3722           0 :             if ( IsReallyVisible() )
    3723             :             {
    3724             :                 // reset background storage
    3725           0 :                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    3726           0 :                     ImplInvalidateAllOverlapBackgrounds();
    3727           0 :                 mpWindowImpl->mpOverlapWindow->ImplSetClipFlagOverlapWindows();
    3728             :             }
    3729             :         }
    3730             :     }
    3731           0 : }
    3732             : 
    3733           0 : void Window::ImplStartToTop( sal_uInt16 nFlags )
    3734             : {
    3735             :     ImplCalcToTopData   aStartData;
    3736             :     ImplCalcToTopData*  pCurData;
    3737             :     ImplCalcToTopData*  pNextData;
    3738             :     Window* pOverlapWindow;
    3739           0 :     if ( ImplIsOverlapWindow() )
    3740           0 :         pOverlapWindow = this;
    3741             :     else
    3742           0 :         pOverlapWindow = mpWindowImpl->mpOverlapWindow;
    3743             : 
    3744             :     // first calculate paint areas
    3745           0 :     Window* pTempOverlapWindow = pOverlapWindow;
    3746           0 :     aStartData.mpNext = NULL;
    3747           0 :     pCurData = &aStartData;
    3748           0 :     do
    3749             :     {
    3750           0 :         pTempOverlapWindow->ImplCalcToTop( pCurData );
    3751           0 :         if ( pCurData->mpNext )
    3752           0 :             pCurData = pCurData->mpNext;
    3753           0 :         pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpOverlapWindow;
    3754             :     }
    3755           0 :     while ( !pTempOverlapWindow->mpWindowImpl->mbFrame );
    3756             :     // next calculate the paint areas of the ChildOverlap windows
    3757           0 :     pTempOverlapWindow = mpWindowImpl->mpFirstOverlap;
    3758           0 :     while ( pTempOverlapWindow )
    3759             :     {
    3760           0 :         pTempOverlapWindow->ImplCalcToTop( pCurData );
    3761           0 :         if ( pCurData->mpNext )
    3762           0 :             pCurData = pCurData->mpNext;
    3763           0 :         pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpNext;
    3764             :     }
    3765             : 
    3766             :     // and next change the windows list
    3767           0 :     pTempOverlapWindow = pOverlapWindow;
    3768           0 :     do
    3769             :     {
    3770           0 :         pTempOverlapWindow->ImplToTop( nFlags );
    3771           0 :         pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpOverlapWindow;
    3772             :     }
    3773           0 :     while ( !pTempOverlapWindow->mpWindowImpl->mbFrame );
    3774             :     // as last step invalidate the invalid areas
    3775           0 :     pCurData = aStartData.mpNext;
    3776           0 :     while ( pCurData )
    3777             :     {
    3778           0 :         pCurData->mpWindow->ImplInvalidateFrameRegion( pCurData->mpInvalidateRegion, INVALIDATE_CHILDREN );
    3779           0 :         pNextData = pCurData->mpNext;
    3780           0 :         delete pCurData->mpInvalidateRegion;
    3781           0 :         delete pCurData;
    3782           0 :         pCurData = pNextData;
    3783             :     }
    3784           0 : }
    3785             : 
    3786           0 : void Window::ImplFocusToTop( sal_uInt16 nFlags, bool bReallyVisible )
    3787             : {
    3788             :     // do we need to fetch the focus?
    3789           0 :     if ( !(nFlags & TOTOP_NOGRABFOCUS) )
    3790             :     {
    3791             :         // first window with GrabFocus-Activate gets the focus
    3792           0 :         Window* pFocusWindow = this;
    3793           0 :         while ( !pFocusWindow->ImplIsOverlapWindow() )
    3794             :         {
    3795             :             // if the window has no BorderWindow, we
    3796             :             // should always find the belonging BorderWindow
    3797           0 :             if ( !pFocusWindow->mpWindowImpl->mpBorderWindow )
    3798             :             {
    3799           0 :                 if ( pFocusWindow->mpWindowImpl->mnActivateMode & ACTIVATE_MODE_GRABFOCUS )
    3800           0 :                     break;
    3801             :             }
    3802           0 :             pFocusWindow = pFocusWindow->ImplGetParent();
    3803             :         }
    3804           0 :         if ( (pFocusWindow->mpWindowImpl->mnActivateMode & ACTIVATE_MODE_GRABFOCUS) &&
    3805           0 :              !pFocusWindow->HasChildPathFocus( true ) )
    3806           0 :             pFocusWindow->GrabFocus();
    3807             :     }
    3808             : 
    3809           0 :     if ( bReallyVisible )
    3810           0 :         ImplGenerateMouseMove();
    3811           0 : }
    3812             : 
    3813           0 : void Window::ImplShowAllOverlaps()
    3814             : {
    3815           0 :     Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
    3816           0 :     while ( pOverlapWindow )
    3817             :     {
    3818           0 :         if ( pOverlapWindow->mpWindowImpl->mbOverlapVisible )
    3819             :         {
    3820           0 :             pOverlapWindow->Show( true, SHOW_NOACTIVATE );
    3821           0 :             pOverlapWindow->mpWindowImpl->mbOverlapVisible = false;
    3822             :         }
    3823             : 
    3824           0 :         pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
    3825             :     }
    3826           0 : }
    3827             : 
    3828           0 : void Window::ImplHideAllOverlaps()
    3829             : {
    3830           0 :     Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
    3831           0 :     while ( pOverlapWindow )
    3832             :     {
    3833           0 :         if ( pOverlapWindow->IsVisible() )
    3834             :         {
    3835           0 :             pOverlapWindow->mpWindowImpl->mbOverlapVisible = true;
    3836           0 :             pOverlapWindow->Show( false );
    3837             :         }
    3838             : 
    3839           0 :         pOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
    3840             :     }
    3841           0 : }
    3842             : 
    3843           0 : void Window::ImplCallMouseMove( sal_uInt16 nMouseCode, bool bModChanged )
    3844             : {
    3845           0 :     if ( mpWindowImpl->mpFrameData->mbMouseIn && mpWindowImpl->mpFrameWindow->mpWindowImpl->mbReallyVisible )
    3846             :     {
    3847           0 :         sal_uLong   nTime   = Time::GetSystemTicks();
    3848           0 :         long    nX      = mpWindowImpl->mpFrameData->mnLastMouseX;
    3849           0 :         long    nY      = mpWindowImpl->mpFrameData->mnLastMouseY;
    3850           0 :         sal_uInt16  nCode   = nMouseCode;
    3851           0 :         sal_uInt16  nMode   = mpWindowImpl->mpFrameData->mnMouseMode;
    3852             :         bool    bLeave;
    3853             :         // check for MouseLeave
    3854           0 :         if ( ((nX < 0) || (nY < 0) ||
    3855           0 :               (nX >= mpWindowImpl->mpFrameWindow->mnOutWidth) ||
    3856           0 :               (nY >= mpWindowImpl->mpFrameWindow->mnOutHeight)) &&
    3857           0 :              !ImplGetSVData()->maWinData.mpCaptureWin )
    3858           0 :             bLeave = true;
    3859             :         else
    3860           0 :             bLeave = false;
    3861           0 :         nMode |= MOUSE_SYNTHETIC;
    3862           0 :         if ( bModChanged )
    3863           0 :             nMode |= MOUSE_MODIFIERCHANGED;
    3864           0 :         ImplHandleMouseEvent( mpWindowImpl->mpFrameWindow, EVENT_MOUSEMOVE, bLeave, nX, nY, nTime, nCode, nMode );
    3865             :     }
    3866           0 : }
    3867             : 
    3868           0 : void Window::ImplGenerateMouseMove()
    3869             : {
    3870           0 :     if ( !mpWindowImpl->mpFrameData->mnMouseMoveId )
    3871           0 :         Application::PostUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId, LINK( mpWindowImpl->mpFrameWindow, Window, ImplGenerateMouseMoveHdl ) );
    3872           0 : }
    3873             : 
    3874           0 : IMPL_LINK_NOARG(Window, ImplGenerateMouseMoveHdl)
    3875             : {
    3876           0 :     mpWindowImpl->mpFrameData->mnMouseMoveId = 0;
    3877           0 :     Window* pCaptureWin = ImplGetSVData()->maWinData.mpCaptureWin;
    3878           0 :     if( ! pCaptureWin ||
    3879           0 :         (pCaptureWin->mpWindowImpl && pCaptureWin->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame)
    3880             :     )
    3881             :     {
    3882           0 :         ImplCallMouseMove( mpWindowImpl->mpFrameData->mnMouseCode );
    3883             :     }
    3884           0 :     return 0;
    3885             : }
    3886             : 
    3887           0 : void Window::ImplInvertFocus( const Rectangle& rRect )
    3888             : {
    3889           0 :     InvertTracking( rRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
    3890           0 : }
    3891             : 
    3892           0 : void Window::ImplCallFocusChangeActivate( Window* pNewOverlapWindow,
    3893             :                                           Window* pOldOverlapWindow )
    3894             : {
    3895           0 :     ImplSVData* pSVData = ImplGetSVData();
    3896             :     Window*     pNewRealWindow;
    3897             :     Window*     pOldRealWindow;
    3898           0 :     bool bCallActivate = true;
    3899           0 :     bool bCallDeactivate = true;
    3900             : 
    3901           0 :     pOldRealWindow = pOldOverlapWindow->ImplGetWindow();
    3902           0 :     pNewRealWindow = pNewOverlapWindow->ImplGetWindow();
    3903           0 :     if ( (pOldRealWindow->GetType() != WINDOW_FLOATINGWINDOW) ||
    3904           0 :          pOldRealWindow->GetActivateMode() )
    3905             :     {
    3906           0 :         if ( (pNewRealWindow->GetType() == WINDOW_FLOATINGWINDOW) &&
    3907           0 :              !pNewRealWindow->GetActivateMode() )
    3908             :         {
    3909           0 :             pSVData->maWinData.mpLastDeacWin = pOldOverlapWindow;
    3910           0 :             bCallDeactivate = false;
    3911             :         }
    3912             :     }
    3913           0 :     else if ( (pNewRealWindow->GetType() != WINDOW_FLOATINGWINDOW) ||
    3914           0 :               pNewRealWindow->GetActivateMode() )
    3915             :     {
    3916           0 :         if ( pSVData->maWinData.mpLastDeacWin )
    3917             :         {
    3918           0 :             if ( pSVData->maWinData.mpLastDeacWin == pNewOverlapWindow )
    3919           0 :                 bCallActivate = false;
    3920             :             else
    3921             :             {
    3922           0 :                 Window* pLastRealWindow = pSVData->maWinData.mpLastDeacWin->ImplGetWindow();
    3923           0 :                 pSVData->maWinData.mpLastDeacWin->mpWindowImpl->mbActive = false;
    3924           0 :                 pSVData->maWinData.mpLastDeacWin->Deactivate();
    3925           0 :                 if ( pLastRealWindow != pSVData->maWinData.mpLastDeacWin )
    3926             :                 {
    3927           0 :                     pLastRealWindow->mpWindowImpl->mbActive = true;
    3928           0 :                     pLastRealWindow->Activate();
    3929             :                 }
    3930             :             }
    3931           0 :             pSVData->maWinData.mpLastDeacWin = NULL;
    3932             :         }
    3933             :     }
    3934             : 
    3935           0 :     if ( bCallDeactivate )
    3936             :     {
    3937           0 :         if( pOldOverlapWindow->mpWindowImpl->mbActive )
    3938             :         {
    3939           0 :             pOldOverlapWindow->mpWindowImpl->mbActive = false;
    3940           0 :             pOldOverlapWindow->Deactivate();
    3941             :         }
    3942           0 :         if ( pOldRealWindow != pOldOverlapWindow )
    3943             :         {
    3944           0 :             if( pOldRealWindow->mpWindowImpl->mbActive )
    3945             :             {
    3946           0 :                 pOldRealWindow->mpWindowImpl->mbActive = false;
    3947           0 :                 pOldRealWindow->Deactivate();
    3948             :             }
    3949             :         }
    3950             :     }
    3951           0 :     if ( bCallActivate && ! pNewOverlapWindow->mpWindowImpl->mbActive )
    3952             :     {
    3953           0 :         if( ! pNewOverlapWindow->mpWindowImpl->mbActive )
    3954             :         {
    3955           0 :             pNewOverlapWindow->mpWindowImpl->mbActive = true;
    3956           0 :             pNewOverlapWindow->Activate();
    3957             :         }
    3958           0 :         if ( pNewRealWindow != pNewOverlapWindow )
    3959             :         {
    3960           0 :             if( ! pNewRealWindow->mpWindowImpl->mbActive )
    3961             :             {
    3962           0 :                 pNewRealWindow->mpWindowImpl->mbActive = true;
    3963           0 :                 pNewRealWindow->Activate();
    3964             :             }
    3965             :         }
    3966             :     }
    3967           0 : }
    3968             : 
    3969           0 : static bool IsWindowFocused(const WindowImpl& rWinImpl)
    3970             : {
    3971           0 :     if (rWinImpl.mpSysObj)
    3972           0 :         return true;
    3973             : 
    3974           0 :     if (rWinImpl.mpFrameData->mbHasFocus)
    3975           0 :         return true;
    3976             : 
    3977           0 :     if (rWinImpl.mbFakeFocusSet)
    3978           0 :         return true;
    3979             : 
    3980           0 :     return false;
    3981             : }
    3982             : 
    3983           0 : void Window::ImplGrabFocus( sal_uInt16 nFlags )
    3984             : {
    3985             :     // #143570# no focus for destructing windows
    3986           0 :     if( mpWindowImpl->mbInDtor )
    3987           0 :         return;
    3988             : 
    3989             :     // some event listeners do really bad stuff
    3990             :     // => prepare for the worst
    3991           0 :     ImplDelData aDogTag( this );
    3992             : 
    3993             :     // Currently the client window should always get the focus
    3994             :     // Should the border window at some point be focusable
    3995             :     // we need to change all GrabFocus() instances in VCL,
    3996             :     // e.g. in ToTop()
    3997             : 
    3998           0 :     if ( mpWindowImpl->mpClientWindow )
    3999             :     {
    4000             :         // For a lack of design we need a little hack here to
    4001             :         // ensure that dialogs on close pass the focus back to
    4002             :         // the correct window
    4003           0 :         if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) &&
    4004           0 :              !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) &&
    4005           0 :              mpWindowImpl->mpLastFocusWindow->IsEnabled() &&
    4006           0 :              mpWindowImpl->mpLastFocusWindow->IsInputEnabled() &&
    4007           0 :              ! mpWindowImpl->mpLastFocusWindow->IsInModalMode()
    4008             :              )
    4009           0 :             mpWindowImpl->mpLastFocusWindow->GrabFocus();
    4010             :         else
    4011           0 :             mpWindowImpl->mpClientWindow->GrabFocus();
    4012           0 :         return;
    4013             :     }
    4014           0 :     else if ( mpWindowImpl->mbFrame )
    4015             :     {
    4016             :         // For a lack of design we need a little hack here to
    4017             :         // ensure that dialogs on close pass the focus back to
    4018             :         // the correct window
    4019           0 :         if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) &&
    4020           0 :              !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) &&
    4021           0 :              mpWindowImpl->mpLastFocusWindow->IsEnabled() &&
    4022           0 :              mpWindowImpl->mpLastFocusWindow->IsInputEnabled() &&
    4023           0 :              ! mpWindowImpl->mpLastFocusWindow->IsInModalMode()
    4024             :              )
    4025             :         {
    4026           0 :             mpWindowImpl->mpLastFocusWindow->GrabFocus();
    4027           0 :             return;
    4028             :         }
    4029             :     }
    4030             : 
    4031             :     // If the Window is disabled, then we don't change the focus
    4032           0 :     if ( !IsEnabled() || !IsInputEnabled() || IsInModalNonRefMode() )
    4033           0 :         return;
    4034             : 
    4035             :     // we only need to set the focus if it is not already set
    4036             :     // note: if some other frame is waiting for an asynchrounous focus event
    4037             :     // we also have to post an asynchronous focus event for this frame
    4038             :     // which is done using ToTop
    4039           0 :     ImplSVData* pSVData = ImplGetSVData();
    4040             : 
    4041           0 :     bool bAsyncFocusWaiting = false;
    4042           0 :     Window *pFrame = pSVData->maWinData.mpFirstFrame;
    4043           0 :     while( pFrame  )
    4044             :     {
    4045           0 :         if( pFrame != mpWindowImpl->mpFrameWindow && pFrame->mpWindowImpl->mpFrameData->mnFocusId )
    4046             :         {
    4047           0 :             bAsyncFocusWaiting = true;
    4048           0 :             break;
    4049             :         }
    4050           0 :         pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
    4051             :     }
    4052             : 
    4053           0 :     bool bHasFocus = IsWindowFocused(*mpWindowImpl);
    4054             : 
    4055           0 :     bool bMustNotGrabFocus = false;
    4056             :     // #100242#, check parent hierarchy if some floater prohibits grab focus
    4057             : 
    4058           0 :     Window *pParent = this;
    4059           0 :     while( pParent )
    4060             :     {
    4061             :         // #102158#, ignore grabfocus only if the floating parent grabs keyboard focus by itself (GrabsFocus())
    4062             :         // otherwise we cannot set the focus in a floating toolbox
    4063           0 :         if( ( (pParent->mpWindowImpl->mbFloatWin && ((FloatingWindow*)pParent)->GrabsFocus()) || ( pParent->GetStyle() & WB_SYSTEMFLOATWIN ) ) && !( pParent->GetStyle() & WB_MOVEABLE ) )
    4064             :         {
    4065           0 :             bMustNotGrabFocus = true;
    4066           0 :             break;
    4067             :         }
    4068           0 :         pParent = pParent->mpWindowImpl->mpParent;
    4069             :     }
    4070             : 
    4071           0 :     if ( ( pSVData->maWinData.mpFocusWin != this && ! mpWindowImpl->mbInDtor ) || ( bAsyncFocusWaiting && !bHasFocus && !bMustNotGrabFocus ) )
    4072             :     {
    4073             :         // EndExtTextInput if it is not the same window
    4074           0 :         if ( pSVData->maWinData.mpExtTextInputWin &&
    4075           0 :              (pSVData->maWinData.mpExtTextInputWin != this) )
    4076           0 :             pSVData->maWinData.mpExtTextInputWin->EndExtTextInput( EXTTEXTINPUT_END_COMPLETE );
    4077             : 
    4078             :         // mark this windows as the last FocusWindow
    4079           0 :         Window* pOverlapWindow = ImplGetFirstOverlapWindow();
    4080           0 :         pOverlapWindow->mpWindowImpl->mpLastFocusWindow = this;
    4081           0 :         mpWindowImpl->mpFrameData->mpFocusWin = this;
    4082             : 
    4083           0 :         if( !bHasFocus )
    4084             :         {
    4085             :             // menu windows never get the system focus
    4086             :             // the application will keep the focus
    4087           0 :             if( bMustNotGrabFocus )
    4088           0 :                 return;
    4089             :             else
    4090             :             {
    4091             :                 // here we already switch focus as ToTop()
    4092             :                 // should not give focus to another window
    4093             :                 //DBG_WARNING( "Window::GrabFocus() - Frame doesn't have the focus" );
    4094           0 :                 mpWindowImpl->mpFrame->ToTop( SAL_FRAME_TOTOP_GRABFOCUS | SAL_FRAME_TOTOP_GRABFOCUS_ONLY );
    4095           0 :                 return;
    4096             :             }
    4097             :         }
    4098             : 
    4099           0 :         Window* pOldFocusWindow = pSVData->maWinData.mpFocusWin;
    4100           0 :         ImplDelData aOldFocusDel( pOldFocusWindow );
    4101             : 
    4102           0 :         pSVData->maWinData.mpFocusWin = this;
    4103             : 
    4104           0 :         if ( pOldFocusWindow )
    4105             :         {
    4106             :             // Cursor hidden
    4107           0 :             if ( pOldFocusWindow->mpWindowImpl->mpCursor )
    4108           0 :                 pOldFocusWindow->mpWindowImpl->mpCursor->ImplHide( true );
    4109             :         }
    4110             : 
    4111             :         // !!!!! due to old SV-Office Activate/Deactivate handling
    4112             :         // !!!!! first as before
    4113           0 :         if ( pOldFocusWindow )
    4114             :         {
    4115             :             // remember Focus
    4116           0 :             Window* pOldOverlapWindow = pOldFocusWindow->ImplGetFirstOverlapWindow();
    4117           0 :             Window* pNewOverlapWindow = ImplGetFirstOverlapWindow();
    4118           0 :             if ( pOldOverlapWindow != pNewOverlapWindow )
    4119           0 :                 ImplCallFocusChangeActivate( pNewOverlapWindow, pOldOverlapWindow );
    4120             :         }
    4121             :         else
    4122             :         {
    4123           0 :             Window* pNewOverlapWindow = ImplGetFirstOverlapWindow();
    4124           0 :             Window* pNewRealWindow = pNewOverlapWindow->ImplGetWindow();
    4125           0 :             pNewOverlapWindow->mpWindowImpl->mbActive = true;
    4126           0 :             pNewOverlapWindow->Activate();
    4127           0 :             if ( pNewRealWindow != pNewOverlapWindow )
    4128             :             {
    4129           0 :                 pNewRealWindow->mpWindowImpl->mbActive = true;
    4130           0 :                 pNewRealWindow->Activate();
    4131             :             }
    4132             :         }
    4133             : 
    4134             :         // call Get- and LoseFocus
    4135           0 :         if ( pOldFocusWindow && ! aOldFocusDel.IsDead() )
    4136             :         {
    4137           0 :             if ( pOldFocusWindow->IsTracking() &&
    4138           0 :                  (pSVData->maWinData.mnTrackFlags & STARTTRACK_FOCUSCANCEL) )
    4139           0 :                 pOldFocusWindow->EndTracking( ENDTRACK_CANCEL | ENDTRACK_FOCUS );
    4140           0 :             NotifyEvent aNEvt( EVENT_LOSEFOCUS, pOldFocusWindow );
    4141           0 :             if ( !ImplCallPreNotify( aNEvt ) )
    4142           0 :                 pOldFocusWindow->LoseFocus();
    4143           0 :             pOldFocusWindow->ImplCallDeactivateListeners( this );
    4144             :         }
    4145             : 
    4146           0 :         if ( pSVData->maWinData.mpFocusWin == this )
    4147             :         {
    4148           0 :             if ( mpWindowImpl->mpSysObj )
    4149             :             {
    4150           0 :                 mpWindowImpl->mpFrameData->mpFocusWin = this;
    4151           0 :                 if ( !mpWindowImpl->mpFrameData->mbInSysObjFocusHdl )
    4152           0 :                     mpWindowImpl->mpSysObj->GrabFocus();
    4153             :             }
    4154             : 
    4155           0 :             if ( pSVData->maWinData.mpFocusWin == this )
    4156             :             {
    4157           0 :                 if ( mpWindowImpl->mpCursor )
    4158           0 :                     mpWindowImpl->mpCursor->ImplShow();
    4159           0 :                 mpWindowImpl->mbInFocusHdl = true;
    4160           0 :                 mpWindowImpl->mnGetFocusFlags = nFlags;
    4161             :                 // if we're changing focus due to closing a popup floating window
    4162             :                 // notify the new focus window so it can restore the inner focus
    4163             :                 // eg, toolboxes can select their recent active item
    4164           0 :                 if( pOldFocusWindow &&
    4165           0 :                     ! aOldFocusDel.IsDead() &&
    4166           0 :                     ( pOldFocusWindow->GetDialogControlFlags() & WINDOW_DLGCTRL_FLOATWIN_POPUPMODEEND_CANCEL ) )
    4167           0 :                     mpWindowImpl->mnGetFocusFlags |= GETFOCUS_FLOATWIN_POPUPMODEEND_CANCEL;
    4168           0 :                 NotifyEvent aNEvt( EVENT_GETFOCUS, this );
    4169           0 :                 if ( !ImplCallPreNotify( aNEvt ) && !aDogTag.IsDead() )
    4170           0 :                     GetFocus();
    4171           0 :                 if( !aDogTag.IsDead() )
    4172           0 :                     ImplCallActivateListeners( (pOldFocusWindow && ! aOldFocusDel.IsDead()) ? pOldFocusWindow : NULL );
    4173           0 :                 if( !aDogTag.IsDead() )
    4174             :                 {
    4175           0 :                     mpWindowImpl->mnGetFocusFlags = 0;
    4176           0 :                     mpWindowImpl->mbInFocusHdl = false;
    4177             :                 }
    4178             :             }
    4179             :         }
    4180             : 
    4181           0 :         GetpApp()->FocusChanged();
    4182           0 :         ImplNewInputContext();
    4183           0 :     }
    4184             : }
    4185             : 
    4186           0 : void Window::ImplGrabFocusToDocument( sal_uInt16 nFlags )
    4187             : {
    4188           0 :     Window *pWin = this;
    4189           0 :     while( pWin )
    4190             :     {
    4191           0 :         if( !pWin->GetParent() )
    4192             :         {
    4193           0 :             pWin->ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->ImplGrabFocus(nFlags);
    4194           0 :             return;
    4195             :         }
    4196           0 :         pWin = pWin->GetParent();
    4197             :     }
    4198             : }
    4199             : 
    4200           0 : void Window::ImplNewInputContext()
    4201             : {
    4202           0 :     ImplSVData* pSVData = ImplGetSVData();
    4203           0 :     Window*     pFocusWin = pSVData->maWinData.mpFocusWin;
    4204           0 :     if ( !pFocusWin )
    4205           0 :         return;
    4206             : 
    4207             :     // Is InputContext changed?
    4208           0 :     const InputContext& rInputContext = pFocusWin->GetInputContext();
    4209           0 :     if ( rInputContext == pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext )
    4210           0 :         return;
    4211             : 
    4212           0 :     pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext = rInputContext;
    4213             : 
    4214             :     SalInputContext         aNewContext;
    4215           0 :     const Font&             rFont = rInputContext.GetFont();
    4216           0 :     const OUString&         rFontName = rFont.GetName();
    4217           0 :     ImplFontEntry*          pFontEntry = NULL;
    4218           0 :     aNewContext.mpFont = NULL;
    4219           0 :     if (!rFontName.isEmpty())
    4220             :     {
    4221           0 :         OutputDevice *pFocusWinOutDev = pFocusWin->GetOutDev();
    4222           0 :         Size aSize = pFocusWinOutDev->ImplLogicToDevicePixel( rFont.GetSize() );
    4223           0 :         if ( !aSize.Height() )
    4224             :         {
    4225             :             // only set default sizes if the font height in logical
    4226             :             // coordinates equals 0
    4227           0 :             if ( rFont.GetSize().Height() )
    4228           0 :                 aSize.Height() = 1;
    4229             :             else
    4230           0 :                 aSize.Height() = (12*pFocusWin->mnDPIY)/72;
    4231             :         }
    4232             :         pFontEntry = pFocusWin->mpFontCache->GetFontEntry( pFocusWin->mpFontCollection,
    4233           0 :                          rFont, aSize, static_cast<float>(aSize.Height()) );
    4234           0 :         if ( pFontEntry )
    4235           0 :             aNewContext.mpFont = &pFontEntry->maFontSelData;
    4236             :     }
    4237           0 :     aNewContext.meLanguage  = rFont.GetLanguage();
    4238           0 :     aNewContext.mnOptions   = rInputContext.GetOptions();
    4239           0 :     pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext );
    4240             : 
    4241           0 :     if ( pFontEntry )
    4242           0 :         pFocusWin->mpFontCache->Release( pFontEntry );
    4243             : }
    4244             : 
    4245           0 : Window::Window( WindowType nType )
    4246             : {
    4247           0 :     ImplInitWindowData( nType );
    4248           0 : }
    4249             : 
    4250           0 : Window::Window( Window* pParent, WinBits nStyle )
    4251             : {
    4252             : 
    4253           0 :     ImplInitWindowData( WINDOW_WINDOW );
    4254           0 :     ImplInit( pParent, nStyle, NULL );
    4255           0 : }
    4256             : 
    4257           0 : Window::Window( Window* pParent, const ResId& rResId )
    4258           0 :     : mpWindowImpl(NULL)
    4259             : {
    4260           0 :     rResId.SetRT( RSC_WINDOW );
    4261           0 :     WinBits nStyle = ImplInitRes( rResId );
    4262           0 :     ImplInitWindowData( WINDOW_WINDOW );
    4263           0 :     ImplInit( pParent, nStyle, NULL );
    4264           0 :     ImplLoadRes( rResId );
    4265             : 
    4266           0 :     if ( !(nStyle & WB_HIDE) )
    4267           0 :         Show();
    4268           0 : }
    4269             : 
    4270             : #if OSL_DEBUG_LEVEL > 0
    4271             : namespace
    4272             : {
    4273             :     OString lcl_createWindowInfo(const Window& i_rWindow)
    4274             :     {
    4275             :         // skip border windows, they don't carry information which helps diagnosing the problem
    4276             :         const Window* pWindow( &i_rWindow );
    4277             :         while ( pWindow && ( pWindow->GetType() == WINDOW_BORDERWINDOW ) )
    4278             :             pWindow = pWindow->GetWindow( WINDOW_FIRSTCHILD );
    4279             :         if ( !pWindow )
    4280             :             pWindow = &i_rWindow;
    4281             : 
    4282             :         OStringBuffer aErrorString;
    4283             :         aErrorString.append(' ');
    4284             :         aErrorString.append(typeid( *pWindow ).name());
    4285             :         aErrorString.append(" (");
    4286             :         aErrorString.append(OUStringToOString(pWindow->GetText(), RTL_TEXTENCODING_UTF8));
    4287             :         aErrorString.append(")");
    4288             :         return aErrorString.makeStringAndClear();
    4289             :     }
    4290             : }
    4291             : #endif
    4292             : 
    4293           0 : Window::~Window()
    4294             : {
    4295           0 :     vcl::LazyDeletor<Window>::Undelete( this );
    4296             : 
    4297             :     DBG_ASSERT( !mpWindowImpl->mbInDtor, "~Window - already in DTOR!" );
    4298             : 
    4299             :     // remove Key and Mouse events issued by Application::PostKey/MouseEvent
    4300           0 :     Application::RemoveMouseAndKeyEvents( this );
    4301             : 
    4302             :     // Dispose of the canvas implementation (which, currently, has an
    4303             :     // own wrapper window as a child to this one.
    4304           0 :     uno::Reference< rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
    4305           0 :     if( xCanvas.is() )
    4306             :     {
    4307             :         uno::Reference < lang::XComponent > xCanvasComponent( xCanvas,
    4308           0 :                                                               uno::UNO_QUERY );
    4309           0 :         if( xCanvasComponent.is() )
    4310           0 :             xCanvasComponent->dispose();
    4311             :     }
    4312             : 
    4313           0 :     mpWindowImpl->mbInDtor = true;
    4314             : 
    4315           0 :     ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
    4316             : 
    4317             :     // do not send child events for frames that were registered as native frames
    4318           0 :     if( !ImplIsAccessibleNativeFrame() && mpWindowImpl->mbReallyVisible )
    4319           0 :         if ( ImplIsAccessibleCandidate() && GetAccessibleParentWindow() )
    4320           0 :             GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDDESTROYED, this );
    4321             : 
    4322             :     // remove associated data structures from dockingmanager
    4323           0 :     ImplGetDockingManager()->RemoveWindow( this );
    4324             : 
    4325             :     // remove ownerdraw decorated windows from list in the top-most frame window
    4326           0 :     if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
    4327             :     {
    4328           0 :         ::std::vector< Window* >& rList = ImplGetOwnerDrawList();
    4329           0 :         ::std::vector< Window* >::iterator p;
    4330           0 :         p = ::std::find( rList.begin(), rList.end(), this );
    4331           0 :         if( p != rList.end() )
    4332           0 :             rList.erase( p );
    4333             :     }
    4334             : 
    4335             :     // shutdown drag and drop
    4336           0 :     ::com::sun::star::uno::Reference < ::com::sun::star::lang::XComponent > xDnDComponent( mpWindowImpl->mxDNDListenerContainer, ::com::sun::star::uno::UNO_QUERY );
    4337             : 
    4338           0 :     if( xDnDComponent.is() )
    4339           0 :         xDnDComponent->dispose();
    4340             : 
    4341           0 :     if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
    4342             :     {
    4343             :         try
    4344             :         {
    4345             :             // deregister drop target listener
    4346           0 :             if( mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
    4347             :             {
    4348             :                 uno::Reference< XDragGestureRecognizer > xDragGestureRecognizer =
    4349           0 :                     uno::Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
    4350           0 :                 if( xDragGestureRecognizer.is() )
    4351             :                 {
    4352           0 :                     xDragGestureRecognizer->removeDragGestureListener(
    4353           0 :                         uno::Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
    4354             :                 }
    4355             : 
    4356           0 :                 mpWindowImpl->mpFrameData->mxDropTarget->removeDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener );
    4357           0 :                 mpWindowImpl->mpFrameData->mxDropTargetListener.clear();
    4358             :             }
    4359             : 
    4360             :             // shutdown drag and drop for this frame window
    4361           0 :             uno::Reference< XComponent > xComponent( mpWindowImpl->mpFrameData->mxDropTarget, UNO_QUERY );
    4362             : 
    4363             :             // DNDEventDispatcher does not hold a reference of the DropTarget,
    4364             :             // so it's ok if it does not support XComponent
    4365           0 :             if( xComponent.is() )
    4366           0 :                 xComponent->dispose();
    4367             :         }
    4368           0 :         catch (const Exception&)
    4369             :         {
    4370             :             // can be safely ignored here.
    4371             :         }
    4372             :     }
    4373             : 
    4374           0 :     UnoWrapperBase* pWrapper = Application::GetUnoWrapper( false );
    4375           0 :     if ( pWrapper )
    4376           0 :         pWrapper->WindowDestroyed( this );
    4377             : 
    4378             :     // MT: Must be called after WindowDestroyed!
    4379             :     // Otherwise, if the accessible is a VCLXWindow, it will try to destroy this window again!
    4380             :     // But accessibility implementations from applications need this dispose.
    4381           0 :     if ( mpWindowImpl->mxAccessible.is() )
    4382             :     {
    4383           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> xC( mpWindowImpl->mxAccessible, ::com::sun::star::uno::UNO_QUERY );
    4384           0 :         if ( xC.is() )
    4385           0 :             xC->dispose();
    4386             :     }
    4387             : 
    4388           0 :     ImplSVData* pSVData = ImplGetSVData();
    4389             : 
    4390           0 :     if ( pSVData->maHelpData.mpHelpWin && (pSVData->maHelpData.mpHelpWin->GetParent() == this) )
    4391           0 :         ImplDestroyHelpWindow( true );
    4392             : 
    4393             :     DBG_ASSERT( pSVData->maWinData.mpTrackWin != this,
    4394             :                 "Window::~Window(): Window is in TrackingMode" );
    4395             :     DBG_ASSERT( pSVData->maWinData.mpCaptureWin != this,
    4396             :                 "Window::~Window(): Window has the mouse captured" );
    4397             :     // #103442# DefModalDialogParent is now determined on-the-fly, so this pointer is unimportant now
    4398             :     //DBG_ASSERT( pSVData->maWinData.mpDefDialogParent != this,
    4399             :     //            "Window::~Window(): Window is DefModalDialogParent" );
    4400             : 
    4401             :     // due to old compatibility
    4402           0 :     if ( pSVData->maWinData.mpTrackWin == this )
    4403           0 :         EndTracking();
    4404           0 :     if ( pSVData->maWinData.mpCaptureWin == this )
    4405           0 :         ReleaseMouse();
    4406           0 :     if ( pSVData->maWinData.mpDefDialogParent == this )
    4407           0 :         pSVData->maWinData.mpDefDialogParent = NULL;
    4408             : 
    4409             : #if OSL_DEBUG_LEVEL > 0
    4410             :     if ( true ) // always perform these tests in non-pro versions
    4411             :     {
    4412             :         OStringBuffer aErrorStr;
    4413             :         bool        bError = false;
    4414             :         Window*     pTempWin;
    4415             :         if (mpWindowImpl->mpFrameData != 0)
    4416             :         {
    4417             :             pTempWin = mpWindowImpl->mpFrameData->mpFirstOverlap;
    4418             :             while ( pTempWin )
    4419             :             {
    4420             :                 if ( ImplIsRealParentPath( pTempWin ) )
    4421             :                 {
    4422             :                     bError = true;
    4423             :                     aErrorStr.append(lcl_createWindowInfo(*pTempWin));
    4424             :                 }
    4425             :                 pTempWin = pTempWin->mpWindowImpl->mpNextOverlap;
    4426             :             }
    4427             :             if ( bError )
    4428             :             {
    4429             :                 OStringBuffer aTempStr;
    4430             :                 aTempStr.append("Window (");
    4431             :                 aTempStr.append(OUStringToOString(GetText(),
    4432             :                                                        RTL_TEXTENCODING_UTF8));
    4433             :                 aTempStr.append(") with live SystemWindows destroyed: ");
    4434             :                 aTempStr.append(aErrorStr.toString());
    4435             :                 OSL_FAIL(aTempStr.getStr());
    4436             :                 // abort in non-pro version, this must be fixed!
    4437             :                 GetpApp()->Abort(OStringToOUString(
    4438             :                                      aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));
    4439             :             }
    4440             :         }
    4441             : 
    4442             :         bError = false;
    4443             :         pTempWin = pSVData->maWinData.mpFirstFrame;
    4444             :         while ( pTempWin )
    4445             :         {
    4446             :             if ( ImplIsRealParentPath( pTempWin ) )
    4447             :             {
    4448             :                 bError = true;
    4449             :                 aErrorStr.append(lcl_createWindowInfo(*pTempWin));
    4450             :             }
    4451             :             pTempWin = pTempWin->mpWindowImpl->mpFrameData->mpNextFrame;
    4452             :         }
    4453             :         if ( bError )
    4454             :         {
    4455             :             OStringBuffer aTempStr( "Window (" );
    4456             :             aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
    4457             :             aTempStr.append(") with live SystemWindows destroyed: ");
    4458             :             aTempStr.append(aErrorStr.toString());
    4459             :             OSL_FAIL( aTempStr.getStr() );
    4460             :             GetpApp()->Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));   // abort in non-pro version, this must be fixed!
    4461             :         }
    4462             : 
    4463             :         if ( mpWindowImpl->mpFirstChild )
    4464             :         {
    4465             :             OStringBuffer aTempStr("Window (");
    4466             :             aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
    4467             :             aTempStr.append(") with live children destroyed: ");
    4468             :             pTempWin = mpWindowImpl->mpFirstChild;
    4469             :             while ( pTempWin )
    4470             :             {
    4471             :                 aTempStr.append(lcl_createWindowInfo(*pTempWin));
    4472             :                 pTempWin = pTempWin->mpWindowImpl->mpNext;
    4473             :             }
    4474             :             OSL_FAIL( aTempStr.getStr() );
    4475             :             GetpApp()->Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));   // abort in non-pro version, this must be fixed!
    4476             :         }
    4477             : 
    4478             :         if ( mpWindowImpl->mpFirstOverlap )
    4479             :         {
    4480             :             OStringBuffer aTempStr("Window (");
    4481             :             aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
    4482             :             aTempStr.append(") with live SystemWindows destroyed: ");
    4483             :             pTempWin = mpWindowImpl->mpFirstOverlap;
    4484             :             while ( pTempWin )
    4485             :             {
    4486             :                 aTempStr.append(lcl_createWindowInfo(*pTempWin));
    4487             :                 pTempWin = pTempWin->mpWindowImpl->mpNext;
    4488             :             }
    4489             :             OSL_FAIL( aTempStr.getStr() );
    4490             :             GetpApp()->Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));   // abort in non-pro version, this must be fixed!
    4491             :         }
    4492             : 
    4493             :         Window* pMyParent = this;
    4494             :         SystemWindow* pMySysWin = NULL;
    4495             : 
    4496             :         while ( pMyParent )
    4497             :         {
    4498             :             if ( pMyParent->IsSystemWindow() )
    4499             :                 pMySysWin = (SystemWindow*)pMyParent;
    4500             :             pMyParent = pMyParent->GetParent();
    4501             :         }
    4502             :         if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
    4503             :         {
    4504             :             OStringBuffer aTempStr("Window (");
    4505             :             aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
    4506             :             aTempStr.append(") still in TaskPanelList!");
    4507             :             OSL_FAIL( aTempStr.getStr() );
    4508             :             GetpApp()->Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8));   // abort in non-pro version, this must be fixed!
    4509             :         }
    4510             :     }
    4511             : #endif
    4512             : 
    4513           0 :     if( mpWindowImpl->mbIsInTaskPaneList )
    4514             :     {
    4515           0 :         Window* pMyParent = this;
    4516           0 :         SystemWindow* pMySysWin = NULL;
    4517             : 
    4518           0 :         while ( pMyParent )
    4519             :         {
    4520           0 :             if ( pMyParent->IsSystemWindow() )
    4521           0 :                 pMySysWin = (SystemWindow*)pMyParent;
    4522           0 :             pMyParent = pMyParent->GetParent();
    4523             :         }
    4524           0 :         if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) )
    4525             :         {
    4526           0 :             pMySysWin->GetTaskPaneList()->RemoveWindow( this );
    4527             :         }
    4528             :         else
    4529             :         {
    4530           0 :             OStringBuffer aTempStr("Window (");
    4531           0 :             aTempStr.append(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
    4532           0 :             aTempStr.append(") not found in TaskPanelList!");
    4533           0 :             OSL_FAIL( aTempStr.getStr() );
    4534             :         }
    4535             :     }
    4536             : 
    4537             :     // remove from size-group if necessary
    4538           0 :     remove_from_all_size_groups();
    4539             : 
    4540             :     // clear mnemonic labels
    4541           0 :     std::vector<FixedText*> aMnemonicLabels(list_mnemonic_labels());
    4542           0 :     for (std::vector<FixedText*>::iterator aI = aMnemonicLabels.begin();
    4543           0 :         aI != aMnemonicLabels.end(); ++aI)
    4544             :     {
    4545           0 :         remove_mnemonic_label(*aI);
    4546             :     }
    4547             : 
    4548             :     // hide window in order to trigger the Paint-Handling
    4549           0 :     Hide();
    4550             : 
    4551             :     // announce the window is to be destroyed
    4552             :     {
    4553           0 :         NotifyEvent aNEvt( EVENT_DESTROY, this );
    4554           0 :         Notify( aNEvt );
    4555             :     }
    4556             : 
    4557             :     // EndExtTextInputMode
    4558           0 :     if ( pSVData->maWinData.mpExtTextInputWin == this )
    4559             :     {
    4560           0 :         EndExtTextInput( EXTTEXTINPUT_END_COMPLETE );
    4561           0 :         if ( pSVData->maWinData.mpExtTextInputWin == this )
    4562           0 :             pSVData->maWinData.mpExtTextInputWin = NULL;
    4563             :     }
    4564             : 
    4565             :     // check if the focus window is our child
    4566           0 :     bool bHasFocussedChild = false;
    4567           0 :     if( pSVData->maWinData.mpFocusWin && ImplIsRealParentPath( pSVData->maWinData.mpFocusWin ) )
    4568             :     {
    4569             :         // #122232#, this must not happen and is an application bug ! but we try some cleanup to hopefully avoid crashes, see below
    4570           0 :         bHasFocussedChild = true;
    4571             : #if OSL_DEBUG_LEVEL > 0
    4572             :         OStringBuffer aTempStr("Window (");
    4573             :         aTempStr.append(OUStringToOString(GetText(),
    4574             :             RTL_TEXTENCODING_UTF8)).
    4575             :                 append(") with focussed child window destroyed ! THIS WILL LEAD TO CRASHES AND MUST BE FIXED !");
    4576             :         OSL_FAIL( aTempStr.getStr() );
    4577             :         GetpApp()->Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ));   // abort in non-pro version, this must be fixed!
    4578             : #endif
    4579             :     }
    4580             : 
    4581             :     // if we get focus pass focus to another window
    4582           0 :     Window* pOverlapWindow = ImplGetFirstOverlapWindow();
    4583           0 :     if ( pSVData->maWinData.mpFocusWin == this
    4584           0 :         || bHasFocussedChild )  // #122232#, see above, try some cleanup
    4585             :     {
    4586           0 :         if ( mpWindowImpl->mbFrame )
    4587             :         {
    4588           0 :             pSVData->maWinData.mpFocusWin = NULL;
    4589           0 :             pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
    4590           0 :             GetpApp()->FocusChanged();
    4591             :         }
    4592             :         else
    4593             :         {
    4594           0 :             Window* pParent = GetParent();
    4595           0 :             Window* pBorderWindow = mpWindowImpl->mpBorderWindow;
    4596             :         // when windows overlap, give focus to the parent
    4597             :         // of the next FrameWindow
    4598           0 :             if ( pBorderWindow )
    4599             :             {
    4600           0 :                 if ( pBorderWindow->ImplIsOverlapWindow() )
    4601           0 :                     pParent = pBorderWindow->mpWindowImpl->mpOverlapWindow;
    4602             :             }
    4603           0 :             else if ( ImplIsOverlapWindow() )
    4604           0 :                 pParent = mpWindowImpl->mpOverlapWindow;
    4605             : 
    4606           0 :             if ( pParent && pParent->IsEnabled() && pParent->IsInputEnabled() && ! pParent->IsInModalMode() )
    4607           0 :                 pParent->GrabFocus();
    4608             :             else
    4609           0 :                 mpWindowImpl->mpFrameWindow->GrabFocus();
    4610             : 
    4611             :             // If the focus was set back to 'this' set it to nothing
    4612           0 :             if ( pSVData->maWinData.mpFocusWin == this )
    4613             :             {
    4614           0 :                 pSVData->maWinData.mpFocusWin = NULL;
    4615           0 :                 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
    4616           0 :                 GetpApp()->FocusChanged();
    4617             :             }
    4618             :         }
    4619             :     }
    4620             : 
    4621           0 :     if ( pOverlapWindow != 0 &&
    4622           0 :          pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this )
    4623           0 :         pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
    4624             : 
    4625             :     // reset hint for DefModalDialogParent
    4626           0 :     if( pSVData->maWinData.mpActiveApplicationFrame == this )
    4627           0 :         pSVData->maWinData.mpActiveApplicationFrame = NULL;
    4628             : 
    4629             :     // reset marked windows
    4630           0 :     if ( mpWindowImpl->mpFrameData != 0 )
    4631             :     {
    4632           0 :         if ( mpWindowImpl->mpFrameData->mpFocusWin == this )
    4633           0 :             mpWindowImpl->mpFrameData->mpFocusWin = NULL;
    4634           0 :         if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this )
    4635           0 :             mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
    4636           0 :         if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this )
    4637           0 :             mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
    4638             :     }
    4639             : 
    4640             :     // reset Deactivate-Window
    4641           0 :     if ( pSVData->maWinData.mpLastDeacWin == this )
    4642           0 :         pSVData->maWinData.mpLastDeacWin = NULL;
    4643             : 
    4644           0 :     if ( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
    4645             :     {
    4646           0 :         if ( mpWindowImpl->mpFrameData->mnFocusId )
    4647           0 :             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId );
    4648           0 :         if ( mpWindowImpl->mpFrameData->mnMouseMoveId )
    4649           0 :             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId );
    4650             :     }
    4651             : 
    4652             :     // release SalGraphics
    4653           0 :     OutputDevice *pOutDev = GetOutDev();
    4654           0 :     pOutDev->ImplReleaseGraphics();
    4655             : 
    4656             :     // notify ImplDelData subscribers of this window about the window deletion
    4657           0 :     ImplDelData* pDelData = mpWindowImpl->mpFirstDel;
    4658           0 :     while ( pDelData )
    4659             :     {
    4660           0 :         pDelData->mbDel = true;
    4661           0 :         pDelData->mpWindow = NULL;  // #112873# pDel is not associated with a Window anymore
    4662           0 :         pDelData = pDelData->mpNext;
    4663             :     }
    4664             : 
    4665             :     // remove window from the lists
    4666           0 :     ImplRemoveWindow( true );
    4667             : 
    4668             :     // de-register as "top window child" at our parent, if necessary
    4669           0 :     if ( mpWindowImpl->mbFrame )
    4670             :     {
    4671           0 :         bool bIsTopWindow = mpWindowImpl->mpWinData && ( mpWindowImpl->mpWinData->mnIsTopWindow == 1 );
    4672           0 :         if ( mpWindowImpl->mpRealParent && bIsTopWindow )
    4673             :         {
    4674           0 :             ImplWinData* pParentWinData = mpWindowImpl->mpRealParent->ImplGetWinData();
    4675             : 
    4676             :             ::std::list< Window* >::iterator myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(),
    4677           0 :                 pParentWinData->maTopWindowChildren.end(), this );
    4678             :             DBG_ASSERT( myPos != pParentWinData->maTopWindowChildren.end(), "Window::~Window: inconsistency in top window chain!" );
    4679           0 :             if ( myPos != pParentWinData->maTopWindowChildren.end() )
    4680           0 :                 pParentWinData->maTopWindowChildren.erase( myPos );
    4681             :         }
    4682             :     }
    4683             : 
    4684             :     // cleanup Extra Window Data, TODO: add and use ImplWinData destructor
    4685           0 :     if ( mpWindowImpl->mpWinData )
    4686             :     {
    4687           0 :         if ( mpWindowImpl->mpWinData->mpExtOldText )
    4688           0 :             delete mpWindowImpl->mpWinData->mpExtOldText;
    4689           0 :         if ( mpWindowImpl->mpWinData->mpExtOldAttrAry )
    4690           0 :             delete mpWindowImpl->mpWinData->mpExtOldAttrAry;
    4691           0 :         if ( mpWindowImpl->mpWinData->mpCursorRect )
    4692           0 :             delete mpWindowImpl->mpWinData->mpCursorRect;
    4693           0 :         if ( mpWindowImpl->mpWinData->mpCompositionCharRects)
    4694           0 :             delete[] mpWindowImpl->mpWinData->mpCompositionCharRects;
    4695           0 :         if ( mpWindowImpl->mpWinData->mpFocusRect )
    4696           0 :             delete mpWindowImpl->mpWinData->mpFocusRect;
    4697           0 :         if ( mpWindowImpl->mpWinData->mpTrackRect )
    4698           0 :             delete mpWindowImpl->mpWinData->mpTrackRect;
    4699             : 
    4700           0 :         delete mpWindowImpl->mpWinData;
    4701             :     }
    4702             : 
    4703             :     // cleanup overlap related window data
    4704           0 :     if ( mpWindowImpl->mpOverlapData )
    4705           0 :         delete mpWindowImpl->mpOverlapData;
    4706             : 
    4707             :     // remove BorderWindow or Frame window data
    4708           0 :     if ( mpWindowImpl->mpBorderWindow )
    4709           0 :         delete mpWindowImpl->mpBorderWindow;
    4710           0 :     else if ( mpWindowImpl->mbFrame )
    4711             :     {
    4712           0 :         if ( pSVData->maWinData.mpFirstFrame == this )
    4713           0 :             pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
    4714             :         else
    4715             :         {
    4716           0 :             Window* pSysWin = pSVData->maWinData.mpFirstFrame;
    4717           0 :             while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame != this )
    4718           0 :                 pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame;
    4719           0 :             pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame;
    4720             :         }
    4721           0 :         mpWindowImpl->mpFrame->SetCallback( NULL, NULL );
    4722           0 :         pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame );
    4723           0 :         delete mpWindowImpl->mpFrameData;
    4724             :     }
    4725             : 
    4726             :     // should be the last statements
    4727           0 :     delete mpWindowImpl; mpWindowImpl = NULL;
    4728           0 : }
    4729             : 
    4730           0 : void Window::doLazyDelete()
    4731             : {
    4732           0 :     SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(this);
    4733           0 :     DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(this);
    4734           0 :     if( pSysWin || ( pDockWin && pDockWin->IsFloatingMode() ) )
    4735             :     {
    4736           0 :         Show( false );
    4737           0 :         SetParent( ImplGetDefaultWindow() );
    4738             :     }
    4739           0 :     vcl::LazyDeletor<Window>::Delete( this );
    4740           0 : }
    4741             : 
    4742           0 : sal_uInt16 Window::GetIndicatorState() const
    4743             : {
    4744           0 :     return mpWindowImpl->mpFrame->GetIndicatorState().mnState;
    4745             : }
    4746             : 
    4747           0 : void Window::SimulateKeyPress( sal_uInt16 nKeyCode ) const
    4748             : {
    4749           0 :     mpWindowImpl->mpFrame->SimulateKeyPress(nKeyCode);
    4750           0 : }
    4751             : 
    4752           0 : void Window::MouseMove( const MouseEvent& rMEvt )
    4753             : {
    4754           0 :     NotifyEvent aNEvt( EVENT_MOUSEMOVE, this, &rMEvt );
    4755           0 :     if ( !Notify( aNEvt ) )
    4756           0 :         mpWindowImpl->mbMouseMove = true;
    4757           0 : }
    4758             : 
    4759           0 : void Window::MouseButtonDown( const MouseEvent& rMEvt )
    4760             : {
    4761           0 :     NotifyEvent aNEvt( EVENT_MOUSEBUTTONDOWN, this, &rMEvt );
    4762           0 :     if ( !Notify( aNEvt ) )
    4763           0 :         mpWindowImpl->mbMouseButtonDown = true;
    4764           0 : }
    4765             : 
    4766           0 : void Window::MouseButtonUp( const MouseEvent& rMEvt )
    4767             : {
    4768           0 :     NotifyEvent aNEvt( EVENT_MOUSEBUTTONUP, this, &rMEvt );
    4769           0 :     if ( !Notify( aNEvt ) )
    4770           0 :         mpWindowImpl->mbMouseButtonUp = true;
    4771           0 : }
    4772             : 
    4773           0 : void Window::KeyInput( const KeyEvent& rKEvt )
    4774             : {
    4775           0 :     NotifyEvent aNEvt( EVENT_KEYINPUT, this, &rKEvt );
    4776           0 :     if ( !Notify( aNEvt ) )
    4777           0 :         mpWindowImpl->mbKeyInput = true;
    4778           0 : }
    4779             : 
    4780           0 : void Window::KeyUp( const KeyEvent& rKEvt )
    4781             : {
    4782           0 :     NotifyEvent aNEvt( EVENT_KEYUP, this, &rKEvt );
    4783           0 :     if ( !Notify( aNEvt ) )
    4784           0 :         mpWindowImpl->mbKeyUp = true;
    4785           0 : }
    4786             : 
    4787           0 : void Window::PrePaint()
    4788             : {
    4789           0 : }
    4790             : 
    4791           0 : void Window::Paint( const Rectangle& rRect )
    4792             : {
    4793           0 :     ImplCallEventListeners( VCLEVENT_WINDOW_PAINT, (void*)&rRect );
    4794           0 : }
    4795             : 
    4796           0 : void Window::PostPaint()
    4797             : {
    4798           0 : }
    4799             : 
    4800           0 : void Window::Draw( OutputDevice*, const Point&, const Size&, sal_uLong )
    4801             : {
    4802           0 : }
    4803             : 
    4804           0 : void Window::Move() {}
    4805             : 
    4806           0 : void Window::Resize() {}
    4807             : 
    4808           0 : void Window::Activate() {}
    4809             : 
    4810           0 : void Window::Deactivate() {}
    4811             : 
    4812           0 : void Window::GetFocus()
    4813             : {
    4814           0 :     if ( HasFocus() && mpWindowImpl->mpLastFocusWindow && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) )
    4815             :     {
    4816           0 :         ImplDelData aDogtag( this );
    4817           0 :         mpWindowImpl->mpLastFocusWindow->GrabFocus();
    4818           0 :         if( aDogtag.IsDead() )
    4819           0 :             return;
    4820             :     }
    4821             : 
    4822           0 :     NotifyEvent aNEvt( EVENT_GETFOCUS, this );
    4823           0 :     Notify( aNEvt );
    4824             : }
    4825             : 
    4826           0 : void Window::LoseFocus()
    4827             : {
    4828           0 :     NotifyEvent aNEvt( EVENT_LOSEFOCUS, this );
    4829           0 :     Notify( aNEvt );
    4830           0 : }
    4831             : 
    4832           0 : void Window::RequestHelp( const HelpEvent& rHEvt )
    4833             : {
    4834             :     // if Balloon-Help is requested, show the balloon
    4835             :     // with help text set
    4836           0 :     if ( rHEvt.GetMode() & HELPMODE_BALLOON )
    4837             :     {
    4838           0 :         OUString rStr = GetHelpText();
    4839           0 :         if ( rStr.isEmpty() )
    4840           0 :             rStr = GetQuickHelpText();
    4841           0 :         if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() )
    4842           0 :             ImplGetParent()->RequestHelp( rHEvt );
    4843             :         else
    4844           0 :             Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), rStr );
    4845             :     }
    4846           0 :     else if ( rHEvt.GetMode() & HELPMODE_QUICK )
    4847             :     {
    4848           0 :         const OUString& rStr = GetQuickHelpText();
    4849           0 :         if ( rStr.isEmpty() && ImplGetParent() && !ImplIsOverlapWindow() )
    4850           0 :             ImplGetParent()->RequestHelp( rHEvt );
    4851             :         else
    4852             :         {
    4853           0 :             Point aPos = GetPosPixel();
    4854           0 :             if ( ImplGetParent() && !ImplIsOverlapWindow() )
    4855           0 :                 aPos = ImplGetParent()->OutputToScreenPixel( aPos );
    4856           0 :             Rectangle   aRect( aPos, GetSizePixel() );
    4857           0 :             OUString      aHelpText;
    4858           0 :             if ( !rStr.isEmpty() )
    4859           0 :                 aHelpText = GetHelpText();
    4860           0 :             Help::ShowQuickHelp( this, aRect, rStr, aHelpText, QUICKHELP_CTRLTEXT );
    4861             :         }
    4862             :     }
    4863             :     else
    4864             :     {
    4865           0 :         OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
    4866           0 :         if ( aStrHelpId.isEmpty() && ImplGetParent() )
    4867           0 :             ImplGetParent()->RequestHelp( rHEvt );
    4868             :         else
    4869             :         {
    4870           0 :             Help* pHelp = Application::GetHelp();
    4871           0 :             if ( pHelp )
    4872             :             {
    4873           0 :                 if( !aStrHelpId.isEmpty() )
    4874           0 :                     pHelp->Start( aStrHelpId, this );
    4875             :                 else
    4876           0 :                     pHelp->Start( OUString( OOO_HELP_INDEX  ), this );
    4877             :             }
    4878           0 :         }
    4879             :     }
    4880           0 : }
    4881             : 
    4882           0 : void Window::Command( const CommandEvent& rCEvt )
    4883             : {
    4884           0 :     ImplCallEventListeners( VCLEVENT_WINDOW_COMMAND, (void*)&rCEvt );
    4885             : 
    4886           0 :     NotifyEvent aNEvt( EVENT_COMMAND, this, &rCEvt );
    4887           0 :     if ( !Notify( aNEvt ) )
    4888           0 :         mpWindowImpl->mbCommand = true;
    4889           0 : }
    4890             : 
    4891           0 : void Window::Tracking( const TrackingEvent& rTEvt )
    4892             : {
    4893             : 
    4894           0 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
    4895           0 :     if( pWrapper )
    4896           0 :         pWrapper->Tracking( rTEvt );
    4897           0 : }
    4898             : 
    4899           0 : void Window::UserEvent( sal_uLong, void* )
    4900             : {
    4901           0 : }
    4902             : 
    4903           0 : void Window::StateChanged( StateChangedType eType )
    4904             : {
    4905           0 :     switch (eType)
    4906             :     {
    4907             :         //stuff that doesn't invalidate the layout
    4908             :         case STATE_CHANGE_CONTROLFOREGROUND:
    4909             :         case STATE_CHANGE_CONTROLBACKGROUND:
    4910             :         case STATE_CHANGE_TRANSPARENT:
    4911             :         case STATE_CHANGE_UPDATEMODE:
    4912             :         case STATE_CHANGE_READONLY:
    4913             :         case STATE_CHANGE_ENABLE:
    4914             :         case STATE_CHANGE_STATE:
    4915             :         case STATE_CHANGE_DATA:
    4916             :         case STATE_CHANGE_INITSHOW:
    4917             :         case STATE_CHANGE_CONTROL_FOCUS:
    4918           0 :             break;
    4919             :         //stuff that does invalidate the layout
    4920             :         default:
    4921           0 :             queue_resize();
    4922           0 :             break;
    4923             :     }
    4924           0 : }
    4925             : 
    4926           0 : void Window::DataChanged( const DataChangedEvent& )
    4927             : {
    4928           0 : }
    4929             : 
    4930           0 : void Window::ImplNotifyKeyMouseCommandEventListeners( NotifyEvent& rNEvt )
    4931             : {
    4932           0 :     if( rNEvt.GetType() == EVENT_COMMAND )
    4933             :     {
    4934           0 :         const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
    4935           0 :         if ( pCEvt->GetCommand() != COMMAND_CONTEXTMENU )
    4936             :             // non context menu events are not to be notified up the chain
    4937             :             // so we return immediately
    4938           0 :             return;
    4939             : 
    4940           0 :         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
    4941             :         {
    4942           0 :             if ( rNEvt.GetWindow() == this )
    4943             :                 // not interested in: The event listeners are already called in ::Command,
    4944             :                 // and calling them here a second time doesn't make sense
    4945             :                 ;
    4946             :             else
    4947             :             {
    4948           0 :                 CommandEvent aCommandEvent = ImplTranslateCommandEvent( *pCEvt, rNEvt.GetWindow(), this );
    4949           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_COMMAND, &aCommandEvent );
    4950             :             }
    4951             :         }
    4952             :     }
    4953             : 
    4954             :     // #82968# notify event listeners for mouse and key events separately and
    4955             :     // not in PreNotify ( as for focus listeners )
    4956             :     // this allows for processing those events internally first and pass it to
    4957             :     // the toolkit later
    4958             : 
    4959           0 :     ImplDelData aDelData;
    4960           0 :     ImplAddDel( &aDelData );
    4961             : 
    4962           0 :     if( rNEvt.GetType() == EVENT_MOUSEMOVE )
    4963             :     {
    4964           0 :         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
    4965             :         {
    4966           0 :             if ( rNEvt.GetWindow() == this )
    4967           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, (void*)rNEvt.GetMouseEvent() );
    4968             :             else
    4969             :             {
    4970           0 :                 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
    4971           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEMOVE, &aMouseEvent );
    4972             :             }
    4973             :         }
    4974             :     }
    4975           0 :     else if( rNEvt.GetType() == EVENT_MOUSEBUTTONUP )
    4976             :     {
    4977           0 :         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
    4978             :         {
    4979           0 :             if ( rNEvt.GetWindow() == this )
    4980           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, (void*)rNEvt.GetMouseEvent() );
    4981             :             else
    4982             :             {
    4983           0 :                 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
    4984           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, &aMouseEvent );
    4985             :             }
    4986             :         }
    4987             :     }
    4988           0 :     else if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
    4989             :     {
    4990           0 :         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
    4991             :         {
    4992           0 :             if ( rNEvt.GetWindow() == this )
    4993           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, (void*)rNEvt.GetMouseEvent() );
    4994             :             else
    4995             :             {
    4996           0 :                 MouseEvent aMouseEvent = ImplTranslateMouseEvent( *rNEvt.GetMouseEvent(), rNEvt.GetWindow(), this );
    4997           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, &aMouseEvent );
    4998             :             }
    4999             :         }
    5000             :     }
    5001           0 :     else if( rNEvt.GetType() == EVENT_KEYINPUT )
    5002             :     {
    5003           0 :         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
    5004           0 :             ImplCallEventListeners( VCLEVENT_WINDOW_KEYINPUT, (void*)rNEvt.GetKeyEvent() );
    5005             :     }
    5006           0 :     else if( rNEvt.GetType() == EVENT_KEYUP )
    5007             :     {
    5008           0 :         if ( mpWindowImpl->mbCompoundControl || ( rNEvt.GetWindow() == this ) )
    5009           0 :             ImplCallEventListeners( VCLEVENT_WINDOW_KEYUP, (void*)rNEvt.GetKeyEvent() );
    5010             :     }
    5011             : 
    5012           0 :     if ( aDelData.IsDead() )
    5013           0 :         return;
    5014           0 :     ImplRemoveDel( &aDelData );
    5015             : 
    5016             :     // #106721# check if we're part of a compound control and notify
    5017           0 :     Window *pParent = ImplGetParent();
    5018           0 :     while( pParent )
    5019             :     {
    5020           0 :         if( pParent->IsCompoundControl() )
    5021             :         {
    5022           0 :             pParent->ImplNotifyKeyMouseCommandEventListeners( rNEvt );
    5023           0 :             break;
    5024             :         }
    5025           0 :         pParent = pParent->ImplGetParent();
    5026           0 :     }
    5027             : }
    5028             : 
    5029           0 : bool Window::PreNotify( NotifyEvent& rNEvt )
    5030             : {
    5031           0 :     bool bDone = false;
    5032           0 :     if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
    5033           0 :         bDone = mpWindowImpl->mpParent->PreNotify( rNEvt );
    5034             : 
    5035           0 :     if ( !bDone )
    5036             :     {
    5037           0 :         if( rNEvt.GetType() == EVENT_GETFOCUS )
    5038             :         {
    5039           0 :             bool bCompoundFocusChanged = false;
    5040           0 :             if ( mpWindowImpl->mbCompoundControl && !mpWindowImpl->mbCompoundControlHasFocus && HasChildPathFocus() )
    5041             :             {
    5042           0 :                 mpWindowImpl->mbCompoundControlHasFocus = true;
    5043           0 :                 bCompoundFocusChanged = true;
    5044             :             }
    5045             : 
    5046           0 :             if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
    5047           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
    5048             :         }
    5049           0 :         else if( rNEvt.GetType() == EVENT_LOSEFOCUS )
    5050             :         {
    5051           0 :             bool bCompoundFocusChanged = false;
    5052           0 :             if ( mpWindowImpl->mbCompoundControl && mpWindowImpl->mbCompoundControlHasFocus && !HasChildPathFocus() )
    5053             :             {
    5054           0 :                 mpWindowImpl->mbCompoundControlHasFocus = false ;
    5055           0 :                 bCompoundFocusChanged = true;
    5056             :             }
    5057             : 
    5058           0 :             if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
    5059           0 :                 ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS );
    5060             :         }
    5061             : 
    5062             :         // #82968# mouse and key events will be notified after processing ( in ImplNotifyKeyMouseCommandEventListeners() )!
    5063             :         //    see also ImplHandleMouseEvent(), ImplHandleKey()
    5064             : 
    5065             :     }
    5066             : 
    5067           0 :     return bDone;
    5068             : }
    5069             : 
    5070           0 : bool Window::Notify( NotifyEvent& rNEvt )
    5071             : {
    5072           0 :     bool nRet = false;
    5073             : 
    5074             :     // check for docking window
    5075             :     // but do nothing if window is docked and locked
    5076           0 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
    5077           0 :     if( pWrapper && !( !pWrapper->IsFloatingMode() && pWrapper->IsLocked() ) )
    5078             :     {
    5079           0 :         if ( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
    5080             :         {
    5081           0 :             const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
    5082           0 :             bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
    5083           0 :             if ( pMEvt->IsLeft() )
    5084             :             {
    5085           0 :                 if ( pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) )
    5086             :                 {
    5087             :                     // ctrl double click toggles floating mode
    5088           0 :                     pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
    5089           0 :                     return true;
    5090             :                 }
    5091           0 :                 else if ( pMEvt->GetClicks() == 1 && bHit)
    5092             :                 {
    5093             :                     // allow start docking during mouse move
    5094           0 :                     pWrapper->ImplEnableStartDocking();
    5095           0 :                     return true;
    5096             :                 }
    5097             :             }
    5098             :         }
    5099           0 :         else if ( rNEvt.GetType() == EVENT_MOUSEMOVE )
    5100             :         {
    5101           0 :             const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
    5102           0 :             bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
    5103           0 :             if ( pMEvt->IsLeft() )
    5104             :             {
    5105             :                 // check if a single click initiated this sequence ( ImplStartDockingEnabled() )
    5106             :                 // check if window is docked and
    5107           0 :                 if( pWrapper->ImplStartDockingEnabled() && !pWrapper->IsFloatingMode() &&
    5108           0 :                     !pWrapper->IsDocking() && bHit )
    5109             :                 {
    5110           0 :                     Point   aPos = pMEvt->GetPosPixel();
    5111           0 :                     Window* pWindow = rNEvt.GetWindow();
    5112           0 :                     if ( pWindow != this )
    5113             :                     {
    5114           0 :                         aPos = pWindow->OutputToScreenPixel( aPos );
    5115           0 :                         aPos = ScreenToOutputPixel( aPos );
    5116             :                     }
    5117           0 :                     pWrapper->ImplStartDocking( aPos );
    5118             :                 }
    5119           0 :                 return true;
    5120             :             }
    5121             :         }
    5122           0 :         else if( rNEvt.GetType() == EVENT_KEYINPUT )
    5123             :         {
    5124           0 :             const KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode();
    5125           0 :             if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() &&
    5126           0 :                 rKey.IsShift() && rKey.IsMod1() )
    5127             :             {
    5128           0 :                 pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
    5129             :                 /* At this point the floating toolbar frame does not have the
    5130             :                  * input focus since these frames don't get the focus per default
    5131             :                  * To enable keyboard handling of this toolbar set the input focus
    5132             :                  * to the frame. This needs to be done with ToTop since GrabFocus
    5133             :                  * would not notice any change since "this" already has the focus.
    5134             :                  */
    5135           0 :                 if( pWrapper->IsFloatingMode() )
    5136           0 :                     ToTop( TOTOP_GRABFOCUSONLY );
    5137           0 :                 return true;
    5138             :             }
    5139             :         }
    5140             :     }
    5141             : 
    5142             :     // manage the dialogs
    5143           0 :     if ( (GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
    5144             :     {
    5145             :         // if the parent also has dialog control activated, the parent takes over control
    5146           0 :         if ( (rNEvt.GetType() == EVENT_KEYINPUT) || (rNEvt.GetType() == EVENT_KEYUP) )
    5147             :         {
    5148           0 :             if ( ImplIsOverlapWindow() ||
    5149           0 :                  ((getNonLayoutRealParent(this)->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) != WB_DIALOGCONTROL) )
    5150             :             {
    5151           0 :                 nRet = ImplDlgCtrl( *rNEvt.GetKeyEvent(), rNEvt.GetType() == EVENT_KEYINPUT );
    5152             :             }
    5153             :         }
    5154           0 :         else if ( (rNEvt.GetType() == EVENT_GETFOCUS) || (rNEvt.GetType() == EVENT_LOSEFOCUS) )
    5155             :         {
    5156           0 :             ImplDlgCtrlFocusChanged( rNEvt.GetWindow(), rNEvt.GetType() == EVENT_GETFOCUS );
    5157           0 :             if ( (rNEvt.GetWindow() == this) && (rNEvt.GetType() == EVENT_GETFOCUS) &&
    5158           0 :                  !(GetStyle() & WB_TABSTOP) && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) )
    5159             :             {
    5160           0 :                 sal_uInt16 n = 0;
    5161           0 :                 Window* pFirstChild = ImplGetDlgWindow( n, DLGWINDOW_FIRST );
    5162           0 :                 if ( pFirstChild )
    5163           0 :                     pFirstChild->ImplControlFocus();
    5164             :             }
    5165             :         }
    5166             :     }
    5167             : 
    5168           0 :     if ( !nRet )
    5169             :     {
    5170           0 :         if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
    5171           0 :             nRet = mpWindowImpl->mpParent->Notify( rNEvt );
    5172             :     }
    5173             : 
    5174           0 :     return nRet;
    5175             : }
    5176             : 
    5177           0 : void Window::ImplCallEventListeners( sal_uLong nEvent, void* pData )
    5178             : {
    5179             :     // The implementation was moved to CallEventListeners(),
    5180             :     // because derived classes in svtools must be able to
    5181             :     // call the event listeners and ImplCallEventListeners()
    5182             :     // is not exported.
    5183             :     // TODO: replace ImplCallEventListeners() by CallEventListeners() in vcl
    5184             : 
    5185           0 :     CallEventListeners( nEvent, pData );
    5186           0 : }
    5187             : 
    5188           0 : void Window::CallEventListeners( sal_uLong nEvent, void* pData )
    5189             : {
    5190           0 :     VclWindowEvent aEvent( this, nEvent, pData );
    5191             : 
    5192           0 :     ImplDelData aDelData;
    5193           0 :     ImplAddDel( &aDelData );
    5194             : 
    5195           0 :     ImplGetSVData()->mpApp->ImplCallEventListeners( &aEvent );
    5196             : 
    5197           0 :     if ( aDelData.IsDead() )
    5198           0 :         return;
    5199             : 
    5200           0 :     mpWindowImpl->maEventListeners.Call( &aEvent );
    5201             : 
    5202           0 :     if ( aDelData.IsDead() )
    5203           0 :         return;
    5204             : 
    5205           0 :     ImplRemoveDel( &aDelData );
    5206             : 
    5207           0 :     Window* pWindow = this;
    5208           0 :     while ( pWindow )
    5209             :     {
    5210           0 :         pWindow->ImplAddDel( &aDelData );
    5211             : 
    5212           0 :         pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent );
    5213             : 
    5214           0 :         if ( aDelData.IsDead() )
    5215           0 :             return;
    5216             : 
    5217           0 :         pWindow->ImplRemoveDel( &aDelData );
    5218             : 
    5219           0 :         pWindow = pWindow->GetParent();
    5220           0 :     }
    5221             : }
    5222             : 
    5223           0 : void Window::FireVclEvent( VclSimpleEvent* pEvent )
    5224             : {
    5225           0 :     ImplGetSVData()->mpApp->ImplCallEventListeners(pEvent);
    5226           0 : }
    5227             : 
    5228           0 : void Window::AddEventListener( const Link& rEventListener )
    5229             : {
    5230           0 :     mpWindowImpl->maEventListeners.addListener( rEventListener );
    5231           0 : }
    5232             : 
    5233           0 : void Window::RemoveEventListener( const Link& rEventListener )
    5234             : {
    5235           0 :     mpWindowImpl->maEventListeners.removeListener( rEventListener );
    5236           0 : }
    5237             : 
    5238           0 : void Window::AddChildEventListener( const Link& rEventListener )
    5239             : {
    5240           0 :     mpWindowImpl->maChildEventListeners.addListener( rEventListener );
    5241           0 : }
    5242             : 
    5243           0 : void Window::RemoveChildEventListener( const Link& rEventListener )
    5244             : {
    5245           0 :     mpWindowImpl->maChildEventListeners.removeListener( rEventListener );
    5246           0 : }
    5247             : 
    5248           0 : sal_uLong Window::PostUserEvent( const Link& rLink, void* pCaller )
    5249             : {
    5250             :     sal_uLong nEventId;
    5251           0 :     PostUserEvent( nEventId, rLink, pCaller );
    5252           0 :     return nEventId;
    5253             : }
    5254             : 
    5255           0 : bool Window::PostUserEvent( sal_uLong& rEventId, const Link& rLink, void* pCaller )
    5256             : {
    5257             : 
    5258           0 :     ImplSVEvent* pSVEvent = new ImplSVEvent;
    5259           0 :     pSVEvent->mnEvent   = 0;
    5260           0 :     pSVEvent->mpData    = pCaller;
    5261           0 :     pSVEvent->mpLink    = new Link( rLink );
    5262           0 :     pSVEvent->mpWindow  = this;
    5263           0 :     pSVEvent->mbCall    = true;
    5264           0 :     ImplAddDel( &(pSVEvent->maDelData) );
    5265           0 :     rEventId = (sal_uLong)pSVEvent;
    5266           0 :     if ( mpWindowImpl->mpFrame->PostEvent( pSVEvent ) )
    5267           0 :         return true;
    5268             :     else
    5269             :     {
    5270           0 :         rEventId = 0;
    5271           0 :         ImplRemoveDel( &(pSVEvent->maDelData) );
    5272           0 :         delete pSVEvent;
    5273           0 :         return false;
    5274             :     }
    5275             : }
    5276             : 
    5277           0 : void Window::RemoveUserEvent( sal_uLong nUserEvent )
    5278             : {
    5279             : 
    5280           0 :     ImplSVEvent* pSVEvent = (ImplSVEvent*)nUserEvent;
    5281             : 
    5282             :     DBG_ASSERT( pSVEvent->mpWindow == this,
    5283             :                 "Window::RemoveUserEvent(): Event doesn't send to this window or is already removed" );
    5284             :     DBG_ASSERT( pSVEvent->mbCall,
    5285             :                 "Window::RemoveUserEvent(): Event is already removed" );
    5286             : 
    5287           0 :     if ( pSVEvent->mpWindow )
    5288             :     {
    5289           0 :         pSVEvent->mpWindow->ImplRemoveDel( &(pSVEvent->maDelData) );
    5290           0 :         pSVEvent->mpWindow = NULL;
    5291             :     }
    5292             : 
    5293           0 :     pSVEvent->mbCall = false;
    5294           0 : }
    5295             : 
    5296           0 : bool Window::IsLocked( bool bChildren ) const
    5297             : {
    5298           0 :     if ( mpWindowImpl->mnLockCount != 0 )
    5299           0 :         return true;
    5300             : 
    5301           0 :     if ( bChildren || mpWindowImpl->mbChildNotify )
    5302             :     {
    5303           0 :         Window* pChild = mpWindowImpl->mpFirstChild;
    5304           0 :         while ( pChild )
    5305             :         {
    5306           0 :             if ( pChild->IsLocked( true ) )
    5307           0 :                 return true;
    5308           0 :             pChild = pChild->mpWindowImpl->mpNext;
    5309             :         }
    5310             :     }
    5311             : 
    5312           0 :     return false;
    5313             : }
    5314             : 
    5315           0 : void Window::SetStyle( WinBits nStyle )
    5316             : {
    5317             : 
    5318           0 :     if ( mpWindowImpl->mnStyle != nStyle )
    5319             :     {
    5320           0 :         mpWindowImpl->mnPrevStyle = mpWindowImpl->mnStyle;
    5321           0 :         mpWindowImpl->mnStyle = nStyle;
    5322           0 :         StateChanged( STATE_CHANGE_STYLE );
    5323             :     }
    5324           0 : }
    5325             : 
    5326           0 : void Window::SetExtendedStyle( WinBits nExtendedStyle )
    5327             : {
    5328             : 
    5329           0 :     if ( mpWindowImpl->mnExtendedStyle != nExtendedStyle )
    5330             :     {
    5331           0 :         Window* pWindow = ImplGetBorderWindow();
    5332           0 :         if( ! pWindow )
    5333           0 :             pWindow = this;
    5334           0 :         if( pWindow->mpWindowImpl->mbFrame )
    5335             :         {
    5336           0 :             SalExtStyle nExt = 0;
    5337           0 :             if( (nExtendedStyle & WB_EXT_DOCUMENT) )
    5338           0 :                 nExt |= SAL_FRAME_EXT_STYLE_DOCUMENT;
    5339           0 :             if( (nExtendedStyle & WB_EXT_DOCMODIFIED) )
    5340           0 :                 nExt |= SAL_FRAME_EXT_STYLE_DOCMODIFIED;
    5341             : 
    5342           0 :             pWindow->ImplGetFrame()->SetExtendedFrameStyle( nExt );
    5343             :         }
    5344           0 :         mpWindowImpl->mnPrevExtendedStyle = mpWindowImpl->mnExtendedStyle;
    5345           0 :         mpWindowImpl->mnExtendedStyle = nExtendedStyle;
    5346           0 :         StateChanged( STATE_CHANGE_EXTENDEDSTYLE );
    5347             :     }
    5348           0 : }
    5349             : 
    5350           0 : SystemWindow* Window::GetSystemWindow() const
    5351             : {
    5352             : 
    5353           0 :     const Window* pWin = this;
    5354           0 :     while ( pWin && !pWin->IsSystemWindow() )
    5355           0 :         pWin  = pWin->GetParent();
    5356           0 :     return (SystemWindow*)pWin;
    5357             : }
    5358             : 
    5359           0 : void Window::SetBorderStyle( sal_uInt16 nBorderStyle )
    5360             : {
    5361             : 
    5362           0 :     if ( mpWindowImpl->mpBorderWindow )
    5363             :     {
    5364           0 :         if( nBorderStyle == WINDOW_BORDER_REMOVEBORDER &&
    5365           0 :             ! mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame &&
    5366             :             mpWindowImpl->mpBorderWindow->mpWindowImpl->mpParent
    5367             :             )
    5368             :         {
    5369             :             // this is a little awkward: some controls (e.g. svtools ProgressBar)
    5370             :             // cannot avoid getting constructed with WB_BORDER but want to disable
    5371             :             // borders in case of NWF drawing. So they need a method to remove their border window
    5372           0 :             Window* pBorderWin = mpWindowImpl->mpBorderWindow;
    5373             :             // remove us as border window's client
    5374           0 :             pBorderWin->mpWindowImpl->mpClientWindow = NULL;
    5375           0 :             mpWindowImpl->mpBorderWindow = NULL;
    5376           0 :             mpWindowImpl->mpRealParent = pBorderWin->mpWindowImpl->mpParent;
    5377             :             // reparent us above the border window
    5378           0 :             SetParent( pBorderWin->mpWindowImpl->mpParent );
    5379             :             // set us to the position and size of our previous border
    5380           0 :             Point aBorderPos( pBorderWin->GetPosPixel() );
    5381           0 :             Size aBorderSize( pBorderWin->GetSizePixel() );
    5382           0 :             setPosSizePixel( aBorderPos.X(), aBorderPos.Y(), aBorderSize.Width(), aBorderSize.Height() );
    5383             :             // release border window
    5384           0 :             delete pBorderWin;
    5385             : 
    5386             :             // set new style bits
    5387           0 :             SetStyle( GetStyle() & (~WB_BORDER) );
    5388             :         }
    5389             :         else
    5390             :         {
    5391           0 :             if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
    5392           0 :                  ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetBorderStyle( nBorderStyle );
    5393             :             else
    5394           0 :                 mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
    5395             :         }
    5396             :     }
    5397           0 : }
    5398             : 
    5399           0 : sal_uInt16 Window::GetBorderStyle() const
    5400             : {
    5401             : 
    5402           0 :     if ( mpWindowImpl->mpBorderWindow )
    5403             :     {
    5404           0 :         if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
    5405           0 :             return ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->GetBorderStyle();
    5406             :         else
    5407           0 :             return mpWindowImpl->mpBorderWindow->GetBorderStyle();
    5408             :     }
    5409             : 
    5410           0 :     return 0;
    5411             : }
    5412             : 
    5413           0 : long Window::CalcTitleWidth() const
    5414             : {
    5415             : 
    5416           0 :     if ( mpWindowImpl->mpBorderWindow )
    5417             :     {
    5418           0 :         if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
    5419           0 :             return ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->CalcTitleWidth();
    5420             :         else
    5421           0 :             return mpWindowImpl->mpBorderWindow->CalcTitleWidth();
    5422             :     }
    5423           0 :     else if ( mpWindowImpl->mbFrame && (mpWindowImpl->mnStyle & WB_MOVEABLE) )
    5424             :     {
    5425             :         // we guess the width for frame windows as we do not know the
    5426             :         // border of external dialogs
    5427           0 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    5428           0 :         Font aFont = GetFont();
    5429           0 :         ((Window*)this)->SetPointFont( rStyleSettings.GetTitleFont() );
    5430           0 :         long nTitleWidth = GetTextWidth( GetText() );
    5431           0 :         ((Window*)this)->SetFont( aFont );
    5432           0 :         nTitleWidth += rStyleSettings.GetTitleHeight() * 3;
    5433           0 :         nTitleWidth += rStyleSettings.GetBorderSize() * 2;
    5434           0 :         nTitleWidth += 10;
    5435           0 :         return nTitleWidth;
    5436             :     }
    5437             : 
    5438           0 :     return 0;
    5439             : }
    5440             : 
    5441           0 : void Window::EnableClipSiblings( bool bClipSiblings )
    5442             : {
    5443             : 
    5444           0 :     if ( mpWindowImpl->mpBorderWindow )
    5445           0 :         mpWindowImpl->mpBorderWindow->EnableClipSiblings( bClipSiblings );
    5446             : 
    5447           0 :     mpWindowImpl->mbClipSiblings = bClipSiblings;
    5448           0 : }
    5449             : 
    5450           0 : void Window::SetMouseTransparent( bool bTransparent )
    5451             : {
    5452             : 
    5453           0 :     if ( mpWindowImpl->mpBorderWindow )
    5454           0 :         mpWindowImpl->mpBorderWindow->SetMouseTransparent( bTransparent );
    5455             : 
    5456           0 :     if( mpWindowImpl->mpSysObj )
    5457           0 :         mpWindowImpl->mpSysObj->SetMouseTransparent( bTransparent );
    5458             : 
    5459           0 :     mpWindowImpl->mbMouseTransparent = bTransparent;
    5460           0 : }
    5461             : 
    5462           0 : void Window::SetPaintTransparent( bool bTransparent )
    5463             : {
    5464             : 
    5465             :     // transparency is not useful for frames as the background would have to be provided by a different frame
    5466           0 :     if( bTransparent && mpWindowImpl->mbFrame )
    5467           0 :         return;
    5468             : 
    5469           0 :     if ( mpWindowImpl->mpBorderWindow )
    5470           0 :         mpWindowImpl->mpBorderWindow->SetPaintTransparent( bTransparent );
    5471             : 
    5472           0 :     mpWindowImpl->mbPaintTransparent = bTransparent;
    5473             : }
    5474             : 
    5475           0 : void Window::SetInputContext( const InputContext& rInputContext )
    5476             : {
    5477             : 
    5478           0 :     mpWindowImpl->maInputContext = rInputContext;
    5479           0 :     if ( !mpWindowImpl->mbInFocusHdl && HasFocus() )
    5480           0 :         ImplNewInputContext();
    5481           0 : }
    5482             : 
    5483           0 : void Window::EndExtTextInput( sal_uInt16 nFlags )
    5484             : {
    5485             : 
    5486           0 :     if ( mpWindowImpl->mbExtTextInput )
    5487           0 :         ImplGetFrame()->EndExtTextInput( nFlags );
    5488           0 : }
    5489             : 
    5490           0 : void Window::SetCursorRect( const Rectangle* pRect, long nExtTextInputWidth )
    5491             : {
    5492             : 
    5493           0 :     ImplWinData* pWinData = ImplGetWinData();
    5494           0 :     if ( pWinData->mpCursorRect )
    5495             :     {
    5496           0 :         if ( pRect )
    5497           0 :             *pWinData->mpCursorRect = *pRect;
    5498             :         else
    5499             :         {
    5500           0 :             delete pWinData->mpCursorRect;
    5501           0 :             pWinData->mpCursorRect = NULL;
    5502             :         }
    5503             :     }
    5504             :     else
    5505             :     {
    5506           0 :         if ( pRect )
    5507           0 :             pWinData->mpCursorRect = new Rectangle( *pRect );
    5508             :     }
    5509             : 
    5510           0 :     pWinData->mnCursorExtWidth = nExtTextInputWidth;
    5511             : 
    5512           0 : }
    5513             : 
    5514           0 : const Rectangle* Window::GetCursorRect() const
    5515             : {
    5516             : 
    5517           0 :     ImplWinData* pWinData = ImplGetWinData();
    5518           0 :     return pWinData->mpCursorRect;
    5519             : }
    5520             : 
    5521           0 : long Window::GetCursorExtTextInputWidth() const
    5522             : {
    5523             : 
    5524           0 :     ImplWinData* pWinData = ImplGetWinData();
    5525           0 :     return pWinData->mnCursorExtWidth;
    5526             : }
    5527             : 
    5528           0 : void Window::SetCompositionCharRect( const Rectangle* pRect, long nCompositionLength, bool bVertical ) {
    5529             : 
    5530           0 :     ImplWinData* pWinData = ImplGetWinData();
    5531           0 :     delete[] pWinData->mpCompositionCharRects;
    5532           0 :     pWinData->mbVertical = bVertical;
    5533           0 :     pWinData->mpCompositionCharRects = NULL;
    5534           0 :     pWinData->mnCompositionCharRects = nCompositionLength;
    5535           0 :     if ( pRect && (nCompositionLength > 0) )
    5536             :     {
    5537           0 :         pWinData->mpCompositionCharRects = new Rectangle[nCompositionLength];
    5538           0 :         for (long i = 0; i < nCompositionLength; ++i)
    5539           0 :             pWinData->mpCompositionCharRects[i] = pRect[i];
    5540             :     }
    5541           0 : }
    5542             : 
    5543           0 : void Window::SetSettings( const AllSettings& rSettings )
    5544             : {
    5545           0 :     SetSettings( rSettings, false );
    5546           0 : }
    5547             : 
    5548           0 : void Window::SetSettings( const AllSettings& rSettings, bool bChild )
    5549             : {
    5550             : 
    5551           0 :     if ( mpWindowImpl->mpBorderWindow )
    5552             :     {
    5553           0 :         mpWindowImpl->mpBorderWindow->SetSettings( rSettings, false );
    5554           0 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    5555             :              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
    5556           0 :             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->SetSettings( rSettings, true );
    5557             :     }
    5558             : 
    5559           0 :     AllSettings aOldSettings(*mxSettings);
    5560           0 :     OutputDevice::SetSettings( rSettings );
    5561           0 :     sal_uLong nChangeFlags = aOldSettings.GetChangeFlags( rSettings );
    5562             : 
    5563             :     // recalculate AppFont-resolution and DPI-resolution
    5564           0 :     ImplInitResolutionSettings();
    5565             : 
    5566           0 :     if ( nChangeFlags )
    5567             :     {
    5568           0 :         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags );
    5569           0 :         DataChanged( aDCEvt );
    5570             :     }
    5571             : 
    5572           0 :     if ( bChild || mpWindowImpl->mbChildNotify )
    5573             :     {
    5574           0 :         Window* pChild = mpWindowImpl->mpFirstChild;
    5575           0 :         while ( pChild )
    5576             :         {
    5577           0 :             pChild->SetSettings( rSettings, bChild );
    5578           0 :             pChild = pChild->mpWindowImpl->mpNext;
    5579             :         }
    5580           0 :     }
    5581           0 : }
    5582             : 
    5583           0 : void Window::UpdateSettings( const AllSettings& rSettings, bool bChild )
    5584             : {
    5585             : 
    5586           0 :     if ( mpWindowImpl->mpBorderWindow )
    5587             :     {
    5588           0 :         mpWindowImpl->mpBorderWindow->UpdateSettings( rSettings, false );
    5589           0 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    5590             :              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
    5591           0 :             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->UpdateSettings( rSettings, true );
    5592             :     }
    5593             : 
    5594           0 :     AllSettings aOldSettings(*mxSettings);
    5595           0 :     sal_uLong nChangeFlags = mxSettings->Update( mxSettings->GetWindowUpdate(), rSettings );
    5596           0 :     nChangeFlags |= SETTINGS_IN_UPDATE_SETTINGS; // Set this flag so the receiver of the data changed
    5597             :                                                  // event can distinguish between the changing of global
    5598             :                                                  // setting and a local change ( with SetSettings )
    5599             : 
    5600             :     // recalculate AppFont-resolution and DPI-resolution
    5601           0 :     ImplInitResolutionSettings();
    5602             : 
    5603             :     /* #i73785#
    5604             :     *  do not overwrite a WheelBehavior with false
    5605             :     *  this looks kind of a hack, but WheelBehavior
    5606             :     *  is always a local change, not a system property,
    5607             :     *  so we can spare all our users the hassle of reacting on
    5608             :     *  this in their respective DataChanged.
    5609             :     */
    5610           0 :     MouseSettings aSet( mxSettings->GetMouseSettings() );
    5611           0 :     aSet.SetWheelBehavior( aOldSettings.GetMouseSettings().GetWheelBehavior() );
    5612           0 :     mxSettings->SetMouseSettings( aSet );
    5613             : 
    5614           0 :     if( (nChangeFlags & SETTINGS_STYLE) && IsBackground() )
    5615             :     {
    5616           0 :         Wallpaper aWallpaper = GetBackground();
    5617           0 :         if( !aWallpaper.IsBitmap() && !aWallpaper.IsGradient() )
    5618             :         {
    5619           0 :             if ( mpWindowImpl->mnStyle & WB_3DLOOK )
    5620             :             {
    5621           0 :                 if (aOldSettings.GetStyleSettings().GetFaceColor() != rSettings.GetStyleSettings().GetFaceColor())
    5622           0 :                     SetBackground( Wallpaper( rSettings.GetStyleSettings().GetFaceColor() ) );
    5623             :             }
    5624             :             else
    5625             :             {
    5626           0 :                 if (aOldSettings.GetStyleSettings().GetWindowColor() != rSettings.GetStyleSettings().GetWindowColor())
    5627           0 :                     SetBackground( Wallpaper( rSettings.GetStyleSettings().GetWindowColor() ) );
    5628             :             }
    5629           0 :         }
    5630             :     }
    5631             : 
    5632           0 :     if ( nChangeFlags )
    5633             :     {
    5634           0 :         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags );
    5635           0 :         DataChanged( aDCEvt );
    5636             :         // notify data change handler
    5637           0 :         ImplCallEventListeners( VCLEVENT_WINDOW_DATACHANGED, &aDCEvt);
    5638             :     }
    5639             : 
    5640           0 :     if ( bChild || mpWindowImpl->mbChildNotify )
    5641             :     {
    5642           0 :         Window* pChild = mpWindowImpl->mpFirstChild;
    5643           0 :         while ( pChild )
    5644             :         {
    5645           0 :             pChild->UpdateSettings( rSettings, bChild );
    5646           0 :             pChild = pChild->mpWindowImpl->mpNext;
    5647             :         }
    5648           0 :     }
    5649           0 : }
    5650             : 
    5651           0 : void Window::NotifyAllChildren( DataChangedEvent& rDCEvt )
    5652             : {
    5653             : 
    5654           0 :     DataChanged( rDCEvt );
    5655             : 
    5656           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    5657           0 :     while ( pChild )
    5658             :     {
    5659           0 :         pChild->NotifyAllChildren( rDCEvt );
    5660           0 :         pChild = pChild->mpWindowImpl->mpNext;
    5661             :     }
    5662           0 : }
    5663             : 
    5664           0 : void Window::SetPointFont( const Font& rFont )
    5665             : {
    5666             : 
    5667           0 :     Font aFont = rFont;
    5668           0 :     ImplPointToLogic( aFont );
    5669           0 :     SetFont( aFont );
    5670           0 : }
    5671             : 
    5672           0 : Font Window::GetPointFont() const
    5673             : {
    5674             : 
    5675           0 :     Font aFont = GetFont();
    5676           0 :     ImplLogicToPoint( aFont );
    5677           0 :     return aFont;
    5678             : }
    5679             : 
    5680           0 : void Window::SetParentClipMode( sal_uInt16 nMode )
    5681             : {
    5682             : 
    5683           0 :     if ( mpWindowImpl->mpBorderWindow )
    5684           0 :         mpWindowImpl->mpBorderWindow->SetParentClipMode( nMode );
    5685             :     else
    5686             :     {
    5687           0 :         if ( !ImplIsOverlapWindow() )
    5688             :         {
    5689           0 :             mpWindowImpl->mnParentClipMode = nMode;
    5690           0 :             if ( nMode & PARENTCLIPMODE_CLIP )
    5691           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mbClipChildren = true;
    5692             :         }
    5693             :     }
    5694           0 : }
    5695             : 
    5696           0 : sal_uInt16 Window::GetParentClipMode() const
    5697             : {
    5698             : 
    5699           0 :     if ( mpWindowImpl->mpBorderWindow )
    5700           0 :         return mpWindowImpl->mpBorderWindow->GetParentClipMode();
    5701             :     else
    5702           0 :         return mpWindowImpl->mnParentClipMode;
    5703             : }
    5704             : 
    5705           0 : void Window::SetWindowRegionPixel()
    5706             : {
    5707             : 
    5708           0 :     if ( mpWindowImpl->mpBorderWindow )
    5709           0 :         mpWindowImpl->mpBorderWindow->SetWindowRegionPixel();
    5710           0 :     else if( mpWindowImpl->mbFrame )
    5711             :     {
    5712           0 :         mpWindowImpl->maWinRegion = Region(true);
    5713           0 :         mpWindowImpl->mbWinRegion = false;
    5714           0 :         mpWindowImpl->mpFrame->ResetClipRegion();
    5715             :     }
    5716             :     else
    5717             :     {
    5718           0 :         if ( mpWindowImpl->mbWinRegion )
    5719             :         {
    5720           0 :             mpWindowImpl->maWinRegion = Region(true);
    5721           0 :             mpWindowImpl->mbWinRegion = false;
    5722           0 :             ImplSetClipFlag();
    5723             : 
    5724           0 :             if ( IsReallyVisible() )
    5725             :             {
    5726             :                 // restore background storage
    5727           0 :                 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
    5728           0 :                     ImplDeleteOverlapBackground();
    5729           0 :                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    5730           0 :                     ImplInvalidateAllOverlapBackgrounds();
    5731           0 :                 Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    5732           0 :                 Region      aRegion( aRect );
    5733           0 :                 ImplInvalidateParentFrameRegion( aRegion );
    5734             :             }
    5735             :         }
    5736             :     }
    5737           0 : }
    5738             : 
    5739           0 : void Window::SetWindowRegionPixel( const Region& rRegion )
    5740             : {
    5741             : 
    5742           0 :     if ( mpWindowImpl->mpBorderWindow )
    5743           0 :         mpWindowImpl->mpBorderWindow->SetWindowRegionPixel( rRegion );
    5744           0 :     else if( mpWindowImpl->mbFrame )
    5745             :     {
    5746           0 :         if( !rRegion.IsNull() )
    5747             :         {
    5748           0 :             mpWindowImpl->maWinRegion = rRegion;
    5749           0 :             mpWindowImpl->mbWinRegion = ! rRegion.IsEmpty();
    5750             : 
    5751           0 :             if( mpWindowImpl->mbWinRegion )
    5752             :             {
    5753             :                 // set/update ClipRegion
    5754           0 :                 RectangleVector aRectangles;
    5755           0 :                 mpWindowImpl->maWinRegion.GetRegionRectangles(aRectangles);
    5756           0 :                 mpWindowImpl->mpFrame->BeginSetClipRegion(aRectangles.size());
    5757             : 
    5758           0 :                 for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
    5759             :                 {
    5760             :                     mpWindowImpl->mpFrame->UnionClipRegion(
    5761             :                         aRectIter->Left(),
    5762             :                         aRectIter->Top(),
    5763             :                         aRectIter->GetWidth(),       // orig nWidth was ((R - L) + 1), same as GetWidth does
    5764           0 :                         aRectIter->GetHeight());     // same for height
    5765             :                 }
    5766             : 
    5767           0 :                 mpWindowImpl->mpFrame->EndSetClipRegion();
    5768             : 
    5769             :                 //long                nX;
    5770             :                 //long                nY;
    5771             :                 //long                nWidth;
    5772             :                 //long                nHeight;
    5773             :                 //sal_uLong               nRectCount;
    5774             :                 //ImplRegionInfo      aInfo;
    5775             :                 //sal_Bool                bRegionRect;
    5776             : 
    5777             :                 //nRectCount = mpWindowImpl->maWinRegion.GetRectCount();
    5778             :                 //mpWindowImpl->mpFrame->BeginSetClipRegion( nRectCount );
    5779             :                 //bRegionRect = mpWindowImpl->maWinRegion.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
    5780             :                 //while ( bRegionRect )
    5781             :                 //{
    5782             :                 //    mpWindowImpl->mpFrame->UnionClipRegion( nX, nY, nWidth, nHeight );
    5783             :                 //    bRegionRect = mpWindowImpl->maWinRegion.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
    5784             :                 //}
    5785             :                 //mpWindowImpl->mpFrame->EndSetClipRegion();
    5786             :             }
    5787             :             else
    5788           0 :                 SetWindowRegionPixel();
    5789             :         }
    5790             :         else
    5791           0 :             SetWindowRegionPixel();
    5792             :     }
    5793             :     else
    5794             :     {
    5795           0 :         if ( rRegion.IsNull() )
    5796             :         {
    5797           0 :             if ( mpWindowImpl->mbWinRegion )
    5798             :             {
    5799           0 :                 mpWindowImpl->maWinRegion = Region(true);
    5800           0 :                 mpWindowImpl->mbWinRegion = false;
    5801           0 :                 ImplSetClipFlag();
    5802             :             }
    5803             :         }
    5804             :         else
    5805             :         {
    5806           0 :             mpWindowImpl->maWinRegion = rRegion;
    5807           0 :             mpWindowImpl->mbWinRegion = true;
    5808           0 :             ImplSetClipFlag();
    5809             :         }
    5810             : 
    5811           0 :         if ( IsReallyVisible() )
    5812             :         {
    5813             :             // restore background storage
    5814           0 :             if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
    5815           0 :                 ImplDeleteOverlapBackground();
    5816           0 :             if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    5817           0 :                 ImplInvalidateAllOverlapBackgrounds();
    5818           0 :             Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    5819           0 :             Region      aRegion( aRect );
    5820           0 :             ImplInvalidateParentFrameRegion( aRegion );
    5821             :         }
    5822             :     }
    5823           0 : }
    5824             : 
    5825           0 : const Region& Window::GetWindowRegionPixel() const
    5826             : {
    5827             : 
    5828           0 :     if ( mpWindowImpl->mpBorderWindow )
    5829           0 :         return mpWindowImpl->mpBorderWindow->GetWindowRegionPixel();
    5830             :     else
    5831           0 :         return mpWindowImpl->maWinRegion;
    5832             : }
    5833             : 
    5834           0 : bool Window::IsWindowRegionPixel() const
    5835             : {
    5836             : 
    5837           0 :     if ( mpWindowImpl->mpBorderWindow )
    5838           0 :         return mpWindowImpl->mpBorderWindow->IsWindowRegionPixel();
    5839             :     else
    5840           0 :         return mpWindowImpl->mbWinRegion;
    5841             : }
    5842             : 
    5843           0 : Region Window::GetWindowClipRegionPixel( sal_uInt16 nFlags ) const
    5844             : {
    5845             : 
    5846           0 :     Region aWinClipRegion;
    5847             : 
    5848           0 :     if ( nFlags & WINDOW_GETCLIPREGION_NOCHILDREN )
    5849             :     {
    5850           0 :         if ( mpWindowImpl->mbInitWinClipRegion )
    5851           0 :             ((Window*)this)->ImplInitWinClipRegion();
    5852           0 :         aWinClipRegion = mpWindowImpl->maWinClipRegion;
    5853             :     }
    5854             :     else
    5855             :     {
    5856           0 :         Region* pWinChildClipRegion = ((Window*)this)->ImplGetWinChildClipRegion();
    5857           0 :         aWinClipRegion = *pWinChildClipRegion;
    5858             :         // --- RTL --- remirror clip region before passing it to somebody
    5859           0 :         if( ImplIsAntiparallel() )
    5860             :         {
    5861           0 :             const OutputDevice *pOutDev = GetOutDev();
    5862           0 :             pOutDev->ReMirror( aWinClipRegion );
    5863             :         }
    5864             :     }
    5865             : 
    5866           0 :     if ( nFlags & WINDOW_GETCLIPREGION_NULL )
    5867             :     {
    5868           0 :         Rectangle   aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    5869           0 :         Region      aWinRegion( aWinRect );
    5870             : 
    5871           0 :         if ( aWinRegion == aWinClipRegion )
    5872           0 :             aWinClipRegion.SetNull();
    5873             :     }
    5874             : 
    5875           0 :     aWinClipRegion.Move( -mnOutOffX, -mnOutOffY );
    5876             : 
    5877           0 :     return aWinClipRegion;
    5878             : }
    5879             : 
    5880           0 : Region Window::GetPaintRegion() const
    5881             : {
    5882             : 
    5883           0 :     if ( mpWindowImpl->mpPaintRegion )
    5884             :     {
    5885           0 :         Region aRegion = *mpWindowImpl->mpPaintRegion;
    5886           0 :         aRegion.Move( -mnOutOffX, -mnOutOffY );
    5887           0 :         return PixelToLogic( aRegion );
    5888             :     }
    5889             :     else
    5890             :     {
    5891           0 :         Region aPaintRegion(true);
    5892           0 :         return aPaintRegion;
    5893             :     }
    5894             : }
    5895             : 
    5896           0 : void Window::ExpandPaintClipRegion( const Region& rRegion )
    5897             : {
    5898           0 :     if( mpWindowImpl->mpPaintRegion )
    5899             :     {
    5900           0 :         Region aPixRegion = LogicToPixel( rRegion );
    5901           0 :         Region aDevPixRegion = ImplPixelToDevicePixel( aPixRegion );
    5902             : 
    5903           0 :         Region aWinChildRegion = *ImplGetWinChildClipRegion();
    5904             :         // --- RTL -- only this region is in frame coordinates, so re-mirror it
    5905           0 :         if( ImplIsAntiparallel() )
    5906             :         {
    5907           0 :             const OutputDevice *pOutDev = GetOutDev();
    5908           0 :             pOutDev->ReMirror( aWinChildRegion );
    5909             :         }
    5910             : 
    5911           0 :         aDevPixRegion.Intersect( aWinChildRegion );
    5912           0 :         if( ! aDevPixRegion.IsEmpty() )
    5913             :         {
    5914           0 :             mpWindowImpl->mpPaintRegion->Union( aDevPixRegion );
    5915           0 :             mbInitClipRegion = true;
    5916           0 :         }
    5917             :     }
    5918           0 : }
    5919             : 
    5920           0 : static SystemWindow *ImplGetLastSystemWindow( Window *pWin )
    5921             : {
    5922             :     // get the most top-level system window, the one that contains the taskpanelist
    5923           0 :     SystemWindow *pSysWin = NULL;
    5924           0 :     if( !pWin )
    5925           0 :         return pSysWin;
    5926           0 :     Window *pMyParent = pWin;
    5927           0 :     while ( pMyParent )
    5928             :     {
    5929           0 :         if ( pMyParent->IsSystemWindow() )
    5930           0 :             pSysWin = (SystemWindow*)pMyParent;
    5931           0 :         pMyParent = pMyParent->GetParent();
    5932             :     }
    5933           0 :     return pSysWin;
    5934             : }
    5935             : 
    5936           0 : void Window::SetParent( Window* pNewParent )
    5937             : {
    5938             :     DBG_ASSERT( pNewParent, "Window::SetParent(): pParent == NULL" );
    5939             :     DBG_ASSERT( pNewParent != this, "someone tried to reparent a window to itself" );
    5940             : 
    5941           0 :     if( pNewParent == this )
    5942           0 :         return;
    5943             : 
    5944             :     // check if the taskpanelist would change and move the window pointer accordingly
    5945           0 :     SystemWindow *pSysWin = ImplGetLastSystemWindow(this);
    5946           0 :     SystemWindow *pNewSysWin = NULL;
    5947           0 :     bool bChangeTaskPaneList = false;
    5948           0 :     if( pSysWin && pSysWin->ImplIsInTaskPaneList( this ) )
    5949             :     {
    5950           0 :         pNewSysWin = ImplGetLastSystemWindow( pNewParent );
    5951           0 :         if( pNewSysWin && pNewSysWin != pSysWin )
    5952             :         {
    5953           0 :             bChangeTaskPaneList = true;
    5954           0 :             pSysWin->GetTaskPaneList()->RemoveWindow( this );
    5955             :         }
    5956             :     }
    5957             :     // remove ownerdraw decorated windows from list in the top-most frame window
    5958           0 :     if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
    5959             :     {
    5960           0 :         ::std::vector< Window* >& rList = ImplGetOwnerDrawList();
    5961           0 :         ::std::vector< Window* >::iterator p;
    5962           0 :         p = ::std::find( rList.begin(), rList.end(), this );
    5963           0 :         if( p != rList.end() )
    5964           0 :             rList.erase( p );
    5965             :     }
    5966             : 
    5967           0 :     ImplSetFrameParent( pNewParent );
    5968             : 
    5969           0 :     if ( mpWindowImpl->mpBorderWindow )
    5970             :     {
    5971           0 :         mpWindowImpl->mpRealParent = pNewParent;
    5972           0 :         mpWindowImpl->mpBorderWindow->SetParent( pNewParent );
    5973           0 :         return;
    5974             :     }
    5975             : 
    5976           0 :     if ( mpWindowImpl->mpParent == pNewParent )
    5977           0 :         return;
    5978             : 
    5979           0 :     if ( mpWindowImpl->mbFrame )
    5980           0 :         mpWindowImpl->mpFrame->SetParent( pNewParent->mpWindowImpl->mpFrame );
    5981             : 
    5982           0 :     bool bVisible = IsVisible();
    5983           0 :     Show( false, SHOW_NOFOCUSCHANGE );
    5984             : 
    5985             :     // check if the overlap window changes
    5986             :     Window* pOldOverlapWindow;
    5987           0 :     Window* pNewOverlapWindow = NULL;
    5988           0 :     if ( ImplIsOverlapWindow() )
    5989           0 :         pOldOverlapWindow = NULL;
    5990             :     else
    5991             :     {
    5992           0 :         pNewOverlapWindow = pNewParent->ImplGetFirstOverlapWindow();
    5993           0 :         if ( mpWindowImpl->mpOverlapWindow != pNewOverlapWindow )
    5994           0 :             pOldOverlapWindow = mpWindowImpl->mpOverlapWindow;
    5995             :         else
    5996           0 :             pOldOverlapWindow = NULL;
    5997             :     }
    5998             : 
    5999             :     // convert windows in the hierarchy
    6000           0 :     bool bFocusOverlapWin = HasChildPathFocus( true );
    6001           0 :     bool bFocusWin = HasChildPathFocus();
    6002           0 :     bool bNewFrame = pNewParent->mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow;
    6003           0 :     if ( bNewFrame )
    6004             :     {
    6005           0 :         if ( mpWindowImpl->mpFrameData->mpFocusWin )
    6006             :         {
    6007           0 :             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpFocusWin ) )
    6008           0 :                 mpWindowImpl->mpFrameData->mpFocusWin = NULL;
    6009             :         }
    6010           0 :         if ( mpWindowImpl->mpFrameData->mpMouseMoveWin )
    6011             :         {
    6012           0 :             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpMouseMoveWin ) )
    6013           0 :                 mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
    6014             :         }
    6015           0 :         if ( mpWindowImpl->mpFrameData->mpMouseDownWin )
    6016             :         {
    6017           0 :             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpMouseDownWin ) )
    6018           0 :                 mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
    6019             :         }
    6020             :     }
    6021           0 :     ImplRemoveWindow( bNewFrame );
    6022           0 :     ImplInsertWindow( pNewParent );
    6023           0 :     if ( mpWindowImpl->mnParentClipMode & PARENTCLIPMODE_CLIP )
    6024           0 :         pNewParent->mpWindowImpl->mbClipChildren = true;
    6025           0 :     ImplUpdateWindowPtr();
    6026           0 :     if ( ImplUpdatePos() )
    6027           0 :         ImplUpdateSysObjPos();
    6028             : 
    6029             :     // If the Overlap-Window has changed, we need to test whether
    6030             :     // OverlapWindows that had the Child window as their parent
    6031             :     // need to be put into the window hierarchy.
    6032           0 :     if ( ImplIsOverlapWindow() )
    6033             :     {
    6034           0 :         if ( bNewFrame )
    6035             :         {
    6036           0 :             Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
    6037           0 :             while ( pOverlapWindow )
    6038             :             {
    6039           0 :                 Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
    6040           0 :                 pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame );
    6041           0 :                 pOverlapWindow = pNextOverlapWindow;
    6042             :             }
    6043             :         }
    6044             :     }
    6045           0 :     else if ( pOldOverlapWindow )
    6046             :     {
    6047             :         // reset Focus-Save
    6048           0 :         if ( bFocusWin ||
    6049           0 :              (pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow &&
    6050           0 :               IsWindowOrChild( pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow )) )
    6051           0 :             pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
    6052             : 
    6053           0 :         Window* pOverlapWindow = pOldOverlapWindow->mpWindowImpl->mpFirstOverlap;
    6054           0 :         while ( pOverlapWindow )
    6055             :         {
    6056           0 :             Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
    6057           0 :             if ( ImplIsRealParentPath( pOverlapWindow->ImplGetWindow() ) )
    6058           0 :                 pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame );
    6059           0 :             pOverlapWindow = pNextOverlapWindow;
    6060             :         }
    6061             : 
    6062             :         // update activate-status at next overlap window
    6063           0 :         if ( HasChildPathFocus( true ) )
    6064           0 :             ImplCallFocusChangeActivate( pNewOverlapWindow, pOldOverlapWindow );
    6065             :     }
    6066             : 
    6067             :     // also convert Activate-Status
    6068           0 :     if ( bNewFrame )
    6069             :     {
    6070           0 :         if ( (GetType() == WINDOW_BORDERWINDOW) &&
    6071           0 :              (ImplGetWindow()->GetType() == WINDOW_FLOATINGWINDOW) )
    6072           0 :             ((ImplBorderWindow*)this)->SetDisplayActive( mpWindowImpl->mpFrameData->mbHasFocus );
    6073             :     }
    6074             : 
    6075             :     // when required give focus to new frame if
    6076             :     // FocusWindow is changed with SetParent()
    6077           0 :     if ( bFocusOverlapWin )
    6078             :     {
    6079           0 :         mpWindowImpl->mpFrameData->mpFocusWin = Application::GetFocusWindow();
    6080           0 :         if ( !mpWindowImpl->mpFrameData->mbHasFocus )
    6081             :         {
    6082           0 :             mpWindowImpl->mpFrame->ToTop( 0 );
    6083             :         }
    6084             :     }
    6085             : 
    6086             :     // Assure DragSource and DropTarget members are created
    6087           0 :     if ( bNewFrame )
    6088             :     {
    6089           0 :             GetDropTarget();
    6090             :     }
    6091             : 
    6092           0 :     if( bChangeTaskPaneList )
    6093           0 :         pNewSysWin->GetTaskPaneList()->AddWindow( this );
    6094             : 
    6095           0 :     if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
    6096           0 :         ImplGetOwnerDrawList().push_back( this );
    6097             : 
    6098           0 :     if ( bVisible )
    6099           0 :         Show( true, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
    6100             : }
    6101             : 
    6102           0 : void Window::Show( bool bVisible, sal_uInt16 nFlags )
    6103             : {
    6104             : 
    6105           0 :     if ( mpWindowImpl->mbVisible == bVisible )
    6106           0 :         return;
    6107             : 
    6108           0 :     ImplDelData aDogTag( this );
    6109             : 
    6110           0 :     bool bRealVisibilityChanged = false;
    6111           0 :     mpWindowImpl->mbVisible = bVisible;
    6112             : 
    6113           0 :     if ( !bVisible )
    6114             :     {
    6115           0 :         ImplHideAllOverlaps();
    6116           0 :         if( aDogTag.IsDead() )
    6117           0 :             return;
    6118             : 
    6119           0 :         if ( mpWindowImpl->mpBorderWindow )
    6120             :         {
    6121           0 :             bool bOldUpdate = mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate;
    6122           0 :             if ( mpWindowImpl->mbNoParentUpdate )
    6123           0 :                 mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = true;
    6124           0 :             mpWindowImpl->mpBorderWindow->Show( false, nFlags );
    6125           0 :             mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = bOldUpdate;
    6126             :         }
    6127           0 :         else if ( mpWindowImpl->mbFrame )
    6128             :         {
    6129           0 :             mpWindowImpl->mbSuppressAccessibilityEvents = true;
    6130           0 :             mpWindowImpl->mpFrame->Show( false, false );
    6131             :         }
    6132             : 
    6133           0 :         StateChanged( STATE_CHANGE_VISIBLE );
    6134             : 
    6135           0 :         if ( mpWindowImpl->mbReallyVisible )
    6136             :         {
    6137           0 :             Region  aInvRegion;
    6138           0 :             bool    bSaveBack = false;
    6139             : 
    6140           0 :             if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
    6141             :             {
    6142           0 :                 if ( ImplRestoreOverlapBackground( aInvRegion ) )
    6143           0 :                     bSaveBack = true;
    6144             :             }
    6145             : 
    6146           0 :             if ( !bSaveBack )
    6147             :             {
    6148           0 :                 if ( mpWindowImpl->mbInitWinClipRegion )
    6149           0 :                     ImplInitWinClipRegion();
    6150           0 :                 aInvRegion = mpWindowImpl->maWinClipRegion;
    6151             :             }
    6152             : 
    6153           0 :             if( aDogTag.IsDead() )
    6154           0 :                 return;
    6155             : 
    6156           0 :             bRealVisibilityChanged = mpWindowImpl->mbReallyVisible;
    6157           0 :             ImplResetReallyVisible();
    6158           0 :             ImplSetClipFlag();
    6159             : 
    6160           0 :             if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
    6161             :             {
    6162             :                 // convert focus
    6163           0 :                 if ( !(nFlags & SHOW_NOFOCUSCHANGE) && HasChildPathFocus() )
    6164             :                 {
    6165           0 :                     if ( mpWindowImpl->mpOverlapWindow->IsEnabled() &&
    6166           0 :                          mpWindowImpl->mpOverlapWindow->IsInputEnabled() &&
    6167           0 :                          ! mpWindowImpl->mpOverlapWindow->IsInModalMode()
    6168             :                          )
    6169           0 :                         mpWindowImpl->mpOverlapWindow->GrabFocus();
    6170             :                 }
    6171             :             }
    6172             : 
    6173           0 :             if ( !mpWindowImpl->mbFrame )
    6174             :             {
    6175           0 :                 if( mpWindowImpl->mpWinData && mpWindowImpl->mpWinData->mbEnableNativeWidget )
    6176             :                 {
    6177             :                     /*
    6178             :                     * #i48371# native theming: some themes draw outside the control
    6179             :                     * area we tell them to (bad thing, but we cannot do much about it ).
    6180             :                     * On hiding these controls they get invalidated with their window rectangle
    6181             :                     * which leads to the parts outside the control area being left and not
    6182             :                     * invalidated. Workaround: invalidate an area on the parent, too
    6183             :                     */
    6184           0 :                     const int workaround_border = 5;
    6185           0 :                     Rectangle aBounds( aInvRegion.GetBoundRect() );
    6186           0 :                     aBounds.Left()      -= workaround_border;
    6187           0 :                     aBounds.Top()       -= workaround_border;
    6188           0 :                     aBounds.Right()     += workaround_border;
    6189           0 :                     aBounds.Bottom()    += workaround_border;
    6190           0 :                     aInvRegion = aBounds;
    6191             :                 }
    6192           0 :                 if ( !mpWindowImpl->mbNoParentUpdate && !(nFlags & SHOW_NOPARENTUPDATE) )
    6193             :                 {
    6194           0 :                     if ( !aInvRegion.IsEmpty() )
    6195           0 :                         ImplInvalidateParentFrameRegion( aInvRegion );
    6196             :                 }
    6197           0 :                 ImplGenerateMouseMove();
    6198           0 :             }
    6199             :         }
    6200             :     }
    6201             :     else
    6202             :     {
    6203             :         // inherit native widget flag for form controls
    6204             :         // required here, because frames never show up in the child hierarchy - which should be fixed....
    6205             :         // eg, the drop down of a combobox which is a system floating window
    6206           0 :         if( mpWindowImpl->mbFrame && GetParent() && GetParent()->IsCompoundControl() &&
    6207           0 :             GetParent()->IsNativeWidgetEnabled() != IsNativeWidgetEnabled() )
    6208           0 :             EnableNativeWidget( GetParent()->IsNativeWidgetEnabled() );
    6209             : 
    6210           0 :         if ( mpWindowImpl->mbCallMove )
    6211             :         {
    6212           0 :             ImplCallMove();
    6213             :         }
    6214           0 :         if ( mpWindowImpl->mbCallResize )
    6215             :         {
    6216           0 :             ImplCallResize();
    6217             :         }
    6218             : 
    6219           0 :         StateChanged( STATE_CHANGE_VISIBLE );
    6220             : 
    6221             :         Window* pTestParent;
    6222           0 :         if ( ImplIsOverlapWindow() )
    6223           0 :             pTestParent = mpWindowImpl->mpOverlapWindow;
    6224             :         else
    6225           0 :             pTestParent = ImplGetParent();
    6226           0 :         if ( mpWindowImpl->mbFrame || pTestParent->mpWindowImpl->mbReallyVisible )
    6227             :         {
    6228             :             // if a window becomes visible, send all child windows a StateChange,
    6229             :             // such that these can initialise themselves
    6230           0 :             ImplCallInitShow();
    6231             : 
    6232             :             // If it is a SystemWindow it automatically pops up on top of
    6233             :             // all other windows if needed.
    6234           0 :             if ( ImplIsOverlapWindow() && !(nFlags & SHOW_NOACTIVATE) )
    6235             :             {
    6236           0 :                 ImplStartToTop(( nFlags & SHOW_FOREGROUNDTASK ) ? TOTOP_FOREGROUNDTASK : 0 );
    6237           0 :                 ImplFocusToTop( 0, false );
    6238             :             }
    6239             : 
    6240             :             // save background
    6241           0 :             if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mbSaveBack )
    6242           0 :                 ImplSaveOverlapBackground();
    6243             :             // adjust mpWindowImpl->mbReallyVisible
    6244           0 :             bRealVisibilityChanged = !mpWindowImpl->mbReallyVisible;
    6245           0 :             ImplSetReallyVisible();
    6246             : 
    6247             :             // assure clip rectangles will be recalculated
    6248           0 :             ImplSetClipFlag();
    6249             : 
    6250           0 :             if ( !mpWindowImpl->mbFrame )
    6251             :             {
    6252           0 :                 sal_uInt16 nInvalidateFlags = INVALIDATE_CHILDREN;
    6253           0 :                 if( ! IsPaintTransparent() )
    6254           0 :                     nInvalidateFlags |= INVALIDATE_NOTRANSPARENT;
    6255           0 :                 ImplInvalidate( NULL, nInvalidateFlags );
    6256           0 :                 ImplGenerateMouseMove();
    6257             :             }
    6258             :         }
    6259             : 
    6260           0 :         if ( mpWindowImpl->mpBorderWindow )
    6261           0 :             mpWindowImpl->mpBorderWindow->Show( true, nFlags );
    6262           0 :         else if ( mpWindowImpl->mbFrame )
    6263             :         {
    6264             :             // #106431#, hide SplashScreen
    6265           0 :             ImplSVData* pSVData = ImplGetSVData();
    6266           0 :             if ( !pSVData->mpIntroWindow )
    6267             :             {
    6268             :                 // The right way would be just to call this (not even in the 'if')
    6269           0 :                 GetpApp()->InitFinished();
    6270             :             }
    6271           0 :             else if ( !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
    6272             :             {
    6273             :                 // ... but the VCL splash is broken, and it needs this
    6274             :                 // (for ./soffice slot:5500)
    6275           0 :                 pSVData->mpIntroWindow->Hide();
    6276             :             }
    6277             : 
    6278             :             //DBG_ASSERT( !mpWindowImpl->mbSuppressAccessibilityEvents, "Window::Show() - Frame reactivated");
    6279           0 :             mpWindowImpl->mbSuppressAccessibilityEvents = false;
    6280             : 
    6281           0 :             mpWindowImpl->mbPaintFrame = true;
    6282           0 :             bool bNoActivate = (nFlags & (SHOW_NOACTIVATE|SHOW_NOFOCUSCHANGE)) ? sal_True : sal_False;
    6283           0 :             mpWindowImpl->mpFrame->Show( true, bNoActivate );
    6284           0 :             if( aDogTag.IsDead() )
    6285           0 :                 return;
    6286             : 
    6287             :             // Query the correct size of the window, if we are waiting for
    6288             :             // a system resize
    6289           0 :             if ( mpWindowImpl->mbWaitSystemResize )
    6290             :             {
    6291             :                 long nOutWidth;
    6292             :                 long nOutHeight;
    6293           0 :                 mpWindowImpl->mpFrame->GetClientSize( nOutWidth, nOutHeight );
    6294           0 :                 ImplHandleResize( this, nOutWidth, nOutHeight );
    6295             :             }
    6296             :         }
    6297             : 
    6298           0 :         if( aDogTag.IsDead() )
    6299           0 :             return;
    6300             : 
    6301             : #if OSL_DEBUG_LEVEL > 0
    6302             :         if ( IsDialog() || (GetType() == WINDOW_TABPAGE) || (GetType() == WINDOW_DOCKINGWINDOW) )
    6303             :         {
    6304             :             DBG_DIALOGTEST( this );
    6305             :         }
    6306             : #endif
    6307             : 
    6308           0 :         ImplShowAllOverlaps();
    6309             :     }
    6310             : 
    6311           0 :     if( aDogTag.IsDead() )
    6312           0 :         return;
    6313             :     // invalidate all saved backgrounds
    6314           0 :     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    6315           0 :         ImplInvalidateAllOverlapBackgrounds();
    6316             : 
    6317             :     // the SHOW/HIDE events also serve as indicators to send child creation/destroy events to the access bridge
    6318             :     // However, the access bridge only uses this event if the data member is not NULL (it's kind of a hack that
    6319             :     // we re-use the SHOW/HIDE events this way, with this particular semantics).
    6320             :     // Since #104887#, the notifications for the access bridge are done in Impl(Set|Reset)ReallyVisible. Here, we
    6321             :     // now only notify with a NULL data pointer, for all other clients except the access bridge.
    6322           0 :     if ( !bRealVisibilityChanged )
    6323           0 :         ImplCallEventListeners( mpWindowImpl->mbVisible ? VCLEVENT_WINDOW_SHOW : VCLEVENT_WINDOW_HIDE, NULL );
    6324           0 :     if( aDogTag.IsDead() )
    6325           0 :         return;
    6326             : 
    6327             :     // #107575#, if a floating windows is shown that grabs the focus, we have to notify the toolkit about it
    6328             :     // ImplGrabFocus() is not called in this case
    6329             :     // Because this might lead to problems the task will be shifted to 6.y
    6330             :     // Note: top-level context menus are registered at the access bridge after being shown,
    6331             :     // so this will probably not help here....
    6332             :     /*
    6333             :     if( mpWindowImpl->mbFloatWin && ((FloatingWindow*) this )->GrabsFocus() )
    6334             :     {
    6335             :         ImplSVData* pSVData = ImplGetSVData();
    6336             :         if( !mpWindowImpl->mbVisible )
    6337             :         {
    6338             :             ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS );
    6339             :             if( pSVData->maWinData.mpFocusWin )
    6340             :                 pSVData->maWinData.mpFocusWin->ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
    6341             :         }
    6342             :         else
    6343             :         {
    6344             :             if( pSVData->maWinData.mpFocusWin )
    6345             :                 pSVData->maWinData.mpFocusWin->ImplCallEventListeners( VCLEVENT_WINDOW_LOSEFOCUS );
    6346             :             ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
    6347             :         }
    6348             :     }
    6349             :     */
    6350             : }
    6351             : 
    6352           0 : Size Window::GetSizePixel() const
    6353             : {
    6354           0 :     if (!mpWindowImpl)
    6355             :     {
    6356             :         SAL_WARN("vcl.layout", "WTF no windowimpl");
    6357           0 :         return Size(0,0);
    6358             :     }
    6359             : 
    6360             :     // #i43257# trigger pending resize handler to assure correct window sizes
    6361           0 :     if( mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
    6362             :     {
    6363           0 :         ImplDelData aDogtag( this );
    6364           0 :         mpWindowImpl->mpFrameData->maResizeTimer.Stop();
    6365           0 :         mpWindowImpl->mpFrameData->maResizeTimer.GetTimeoutHdl().Call( NULL );
    6366           0 :         if( aDogtag.IsDead() )
    6367           0 :             return Size(0,0);
    6368             :     }
    6369             : 
    6370           0 :     return Size( mnOutWidth+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
    6371           0 :                  mnOutHeight+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
    6372             : }
    6373             : 
    6374           0 : void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
    6375             :                                sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
    6376             : {
    6377           0 :     rLeftBorder     = mpWindowImpl->mnLeftBorder;
    6378           0 :     rTopBorder      = mpWindowImpl->mnTopBorder;
    6379           0 :     rRightBorder    = mpWindowImpl->mnRightBorder;
    6380           0 :     rBottomBorder   = mpWindowImpl->mnBottomBorder;
    6381           0 : }
    6382             : 
    6383           0 : void Window::Enable( bool bEnable, bool bChild )
    6384             : {
    6385             : 
    6386           0 :     if ( !bEnable )
    6387             :     {
    6388             :         // the tracking mode will be stopped or the capture will be stolen
    6389             :         // when a window is disabled,
    6390           0 :         if ( IsTracking() )
    6391           0 :             EndTracking( ENDTRACK_CANCEL );
    6392           0 :         if ( IsMouseCaptured() )
    6393           0 :             ReleaseMouse();
    6394             :         // try to pass focus to the next control
    6395             :         // if the window has focus and is contained in the dialog control
    6396             :         // mpWindowImpl->mbDisabled should only be set after a call of ImplDlgCtrlNextWindow().
    6397             :         // Otherwise ImplDlgCtrlNextWindow() should be used
    6398           0 :         if ( HasFocus() )
    6399           0 :             ImplDlgCtrlNextWindow();
    6400             :     }
    6401             : 
    6402           0 :     if ( mpWindowImpl->mpBorderWindow )
    6403             :     {
    6404           0 :         mpWindowImpl->mpBorderWindow->Enable( bEnable, false );
    6405           0 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    6406             :              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
    6407           0 :             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->Enable( bEnable, true );
    6408             :     }
    6409             : 
    6410             :     // #i56102# restore app focus win in case the
    6411             :     // window was disabled when the frame focus changed
    6412           0 :     ImplSVData* pSVData = ImplGetSVData();
    6413           0 :     if( bEnable &&
    6414           0 :         pSVData->maWinData.mpFocusWin == NULL &&
    6415           0 :         mpWindowImpl->mpFrameData->mbHasFocus &&
    6416           0 :         mpWindowImpl->mpFrameData->mpFocusWin == this )
    6417           0 :         pSVData->maWinData.mpFocusWin = this;
    6418             : 
    6419           0 :     if ( mpWindowImpl->mbDisabled != !bEnable )
    6420             :     {
    6421           0 :         mpWindowImpl->mbDisabled = !bEnable;
    6422           0 :         if ( mpWindowImpl->mpSysObj )
    6423           0 :             mpWindowImpl->mpSysObj->Enable( bEnable && !mpWindowImpl->mbInputDisabled );
    6424           0 :         StateChanged( STATE_CHANGE_ENABLE );
    6425             : 
    6426           0 :         ImplCallEventListeners( bEnable ? VCLEVENT_WINDOW_ENABLED : VCLEVENT_WINDOW_DISABLED );
    6427             :     }
    6428             : 
    6429           0 :     if ( bChild || mpWindowImpl->mbChildNotify )
    6430             :     {
    6431           0 :         Window* pChild = mpWindowImpl->mpFirstChild;
    6432           0 :         while ( pChild )
    6433             :         {
    6434           0 :             pChild->Enable( bEnable, bChild );
    6435           0 :             pChild = pChild->mpWindowImpl->mpNext;
    6436             :         }
    6437             :     }
    6438             : 
    6439           0 :     if ( IsReallyVisible() )
    6440           0 :         ImplGenerateMouseMove();
    6441           0 : }
    6442             : 
    6443           0 : void Window::SetCallHandlersOnInputDisabled( bool bCall )
    6444             : {
    6445           0 :     mpWindowImpl->mbCallHandlersDuringInputDisabled = bCall ? sal_True : sal_False;
    6446             : 
    6447           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    6448           0 :     while ( pChild )
    6449             :     {
    6450           0 :         pChild->SetCallHandlersOnInputDisabled( bCall );
    6451           0 :         pChild = pChild->mpWindowImpl->mpNext;
    6452             :     }
    6453           0 : }
    6454             : 
    6455           0 : bool Window::IsCallHandlersOnInputDisabled() const
    6456             : {
    6457           0 :     return mpWindowImpl->mbCallHandlersDuringInputDisabled ? true : false;
    6458             : }
    6459             : 
    6460           0 : void Window::EnableInput( bool bEnable, bool bChild )
    6461             : {
    6462             : 
    6463           0 :     bool bNotify = (bEnable != mpWindowImpl->mbInputDisabled);
    6464           0 :     if ( mpWindowImpl->mpBorderWindow )
    6465             :     {
    6466           0 :         mpWindowImpl->mpBorderWindow->EnableInput( bEnable, false );
    6467           0 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    6468             :              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
    6469           0 :             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->EnableInput( bEnable, true );
    6470             :     }
    6471             : 
    6472           0 :     if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) ||
    6473           0 :          (  bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled) )
    6474             :     {
    6475             :         // automatically stop the tracking mode or steal capture
    6476             :         // if the window is disabled
    6477           0 :         if ( !bEnable )
    6478             :         {
    6479           0 :             if ( IsTracking() )
    6480           0 :                 EndTracking( ENDTRACK_CANCEL );
    6481           0 :             if ( IsMouseCaptured() )
    6482           0 :                 ReleaseMouse();
    6483             :         }
    6484             : 
    6485           0 :         if ( mpWindowImpl->mbInputDisabled != !bEnable )
    6486             :         {
    6487           0 :             mpWindowImpl->mbInputDisabled = !bEnable;
    6488           0 :             if ( mpWindowImpl->mpSysObj )
    6489           0 :                 mpWindowImpl->mpSysObj->Enable( !mpWindowImpl->mbDisabled && bEnable );
    6490             :         }
    6491             :     }
    6492             : 
    6493             :     // #i56102# restore app focus win in case the
    6494             :     // window was disabled when the frame focus changed
    6495           0 :     ImplSVData* pSVData = ImplGetSVData();
    6496           0 :     if( bEnable &&
    6497           0 :         pSVData->maWinData.mpFocusWin == NULL &&
    6498           0 :         mpWindowImpl->mpFrameData->mbHasFocus &&
    6499           0 :         mpWindowImpl->mpFrameData->mpFocusWin == this )
    6500           0 :         pSVData->maWinData.mpFocusWin = this;
    6501             : 
    6502           0 :     if ( bChild || mpWindowImpl->mbChildNotify )
    6503             :     {
    6504           0 :         Window* pChild = mpWindowImpl->mpFirstChild;
    6505           0 :         while ( pChild )
    6506             :         {
    6507           0 :             pChild->EnableInput( bEnable, bChild );
    6508           0 :             pChild = pChild->mpWindowImpl->mpNext;
    6509             :         }
    6510             :     }
    6511             : 
    6512           0 :     if ( IsReallyVisible() )
    6513           0 :         ImplGenerateMouseMove();
    6514             : 
    6515             :     // #104827# notify parent
    6516           0 :     if ( bNotify )
    6517             :     {
    6518           0 :         NotifyEvent aNEvt( bEnable ? EVENT_INPUTENABLE : EVENT_INPUTDISABLE, this );
    6519           0 :         Notify( aNEvt );
    6520             :     }
    6521           0 : }
    6522             : 
    6523           0 : void Window::EnableInput( bool bEnable, bool bChild, bool bSysWin,
    6524             :                           const Window* pExcludeWindow )
    6525             : {
    6526             : 
    6527           0 :     EnableInput( bEnable, bChild );
    6528           0 :     if ( bSysWin )
    6529             :     {
    6530             :         // pExculeWindow is the first Overlap-Frame --> if this
    6531             :         // shouldn't be the case, than this must be changed in dialog.cxx
    6532           0 :         if( pExcludeWindow )
    6533           0 :             pExcludeWindow = pExcludeWindow->ImplGetFirstOverlapWindow();
    6534           0 :         Window* pSysWin = mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mpFirstOverlap;
    6535           0 :         while ( pSysWin )
    6536             :         {
    6537             :             // Is Window in the path from this window
    6538           0 :             if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pSysWin, true ) )
    6539             :             {
    6540             :                 // Is Window not in the exclude window path or not the
    6541             :                 // exclude window, than change the status
    6542           0 :                 if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pSysWin, true ) )
    6543           0 :                     pSysWin->EnableInput( bEnable, bChild );
    6544             :             }
    6545           0 :             pSysWin = pSysWin->mpWindowImpl->mpNextOverlap;
    6546             :         }
    6547             : 
    6548             :         // enable/disable floating system windows as well
    6549           0 :         Window* pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
    6550           0 :         while ( pFrameWin )
    6551             :         {
    6552           0 :             if( pFrameWin->ImplIsFloatingWindow() )
    6553             :             {
    6554             :                 // Is Window in the path from this window
    6555           0 :                 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( pFrameWin, true ) )
    6556             :                 {
    6557             :                     // Is Window not in the exclude window path or not the
    6558             :                     // exclude window, than change the status
    6559           0 :                     if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( pFrameWin, true ) )
    6560           0 :                         pFrameWin->EnableInput( bEnable, bChild );
    6561             :                 }
    6562             :             }
    6563           0 :             pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
    6564             :         }
    6565             : 
    6566             :         // the same for ownerdraw floating windows
    6567           0 :         if( mpWindowImpl->mbFrame )
    6568             :         {
    6569           0 :             ::std::vector< Window* >& rList = mpWindowImpl->mpFrameData->maOwnerDrawList;
    6570           0 :             ::std::vector< Window* >::iterator p = rList.begin();
    6571           0 :             while( p != rList.end() )
    6572             :             {
    6573             :                 // Is Window in the path from this window
    6574           0 :                 if ( ImplGetFirstOverlapWindow()->ImplIsWindowOrChild( (*p), true ) )
    6575             :                 {
    6576             :                     // Is Window not in the exclude window path or not the
    6577             :                     // exclude window, than change the status
    6578           0 :                     if ( !pExcludeWindow || !pExcludeWindow->ImplIsWindowOrChild( (*p), true ) )
    6579           0 :                         (*p)->EnableInput( bEnable, bChild );
    6580             :                 }
    6581           0 :                 ++p;
    6582             :             }
    6583             :         }
    6584             :     }
    6585           0 : }
    6586             : 
    6587           0 : void Window::AlwaysEnableInput( bool bAlways, bool bChild )
    6588             : {
    6589             : 
    6590           0 :     if ( mpWindowImpl->mpBorderWindow )
    6591           0 :         mpWindowImpl->mpBorderWindow->AlwaysEnableInput( bAlways, false );
    6592             : 
    6593           0 :     if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled )
    6594             :     {
    6595           0 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputEnabled;
    6596             : 
    6597           0 :         if ( bAlways )
    6598           0 :             EnableInput( true, false );
    6599             :     }
    6600           0 :     else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputEnabled )
    6601             :     {
    6602           0 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
    6603             :     }
    6604             : 
    6605           0 :     if ( bChild || mpWindowImpl->mbChildNotify )
    6606             :     {
    6607           0 :         Window* pChild = mpWindowImpl->mpFirstChild;
    6608           0 :         while ( pChild )
    6609             :         {
    6610           0 :             pChild->AlwaysEnableInput( bAlways, bChild );
    6611           0 :             pChild = pChild->mpWindowImpl->mpNext;
    6612             :         }
    6613             :     }
    6614           0 : }
    6615             : 
    6616           0 : void Window::AlwaysDisableInput( bool bAlways, bool bChild )
    6617             : {
    6618             : 
    6619           0 :     if ( mpWindowImpl->mpBorderWindow )
    6620           0 :         mpWindowImpl->mpBorderWindow->AlwaysDisableInput( bAlways, false );
    6621             : 
    6622           0 :     if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled )
    6623             :     {
    6624           0 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputDisabled;
    6625             : 
    6626           0 :         if ( bAlways )
    6627           0 :             EnableInput( false, false );
    6628             :     }
    6629           0 :     else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputDisabled )
    6630             :     {
    6631           0 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
    6632             :     }
    6633             : 
    6634           0 :     if ( bChild || mpWindowImpl->mbChildNotify )
    6635             :     {
    6636           0 :         Window* pChild = mpWindowImpl->mpFirstChild;
    6637           0 :         while ( pChild )
    6638             :         {
    6639           0 :             pChild->AlwaysDisableInput( bAlways, bChild );
    6640           0 :             pChild = pChild->mpWindowImpl->mpNext;
    6641             :         }
    6642             :     }
    6643           0 : }
    6644             : 
    6645           0 : void Window::SetActivateMode( sal_uInt16 nMode )
    6646             : {
    6647             : 
    6648           0 :     if ( mpWindowImpl->mpBorderWindow )
    6649           0 :         mpWindowImpl->mpBorderWindow->SetActivateMode( nMode );
    6650             : 
    6651           0 :     if ( mpWindowImpl->mnActivateMode != nMode )
    6652             :     {
    6653           0 :         mpWindowImpl->mnActivateMode = nMode;
    6654             : 
    6655             :         // possibly trigger Decativate/Activate
    6656           0 :         if ( mpWindowImpl->mnActivateMode )
    6657             :         {
    6658           0 :             if ( (mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW)) &&
    6659           0 :                  !HasChildPathFocus( true ) )
    6660             :             {
    6661           0 :                 mpWindowImpl->mbActive = false;
    6662           0 :                 Deactivate();
    6663             :             }
    6664             :         }
    6665             :         else
    6666             :         {
    6667           0 :             if ( !mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW) )
    6668             :             {
    6669           0 :                 mpWindowImpl->mbActive = true;
    6670           0 :                 Activate();
    6671             :             }
    6672             :         }
    6673             :     }
    6674           0 : }
    6675             : 
    6676           0 : void Window::ToTop( sal_uInt16 nFlags )
    6677             : {
    6678             : 
    6679           0 :     ImplStartToTop( nFlags );
    6680           0 :     ImplFocusToTop( nFlags, IsReallyVisible() );
    6681           0 : }
    6682             : 
    6683           0 : void Window::SetZOrder( Window* pRefWindow, sal_uInt16 nFlags )
    6684             : {
    6685             : 
    6686           0 :     if ( mpWindowImpl->mpBorderWindow )
    6687             :     {
    6688           0 :         mpWindowImpl->mpBorderWindow->SetZOrder( pRefWindow, nFlags );
    6689           0 :         return;
    6690             :     }
    6691             : 
    6692           0 :     if ( nFlags & WINDOW_ZORDER_FIRST )
    6693             :     {
    6694           0 :         if ( ImplIsOverlapWindow() )
    6695           0 :             pRefWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
    6696             :         else
    6697           0 :             pRefWindow = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild;
    6698           0 :         nFlags |= WINDOW_ZORDER_BEFOR;
    6699             :     }
    6700           0 :     else if ( nFlags & WINDOW_ZORDER_LAST )
    6701             :     {
    6702           0 :         if ( ImplIsOverlapWindow() )
    6703           0 :             pRefWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap;
    6704             :         else
    6705           0 :             pRefWindow = mpWindowImpl->mpParent->mpWindowImpl->mpLastChild;
    6706           0 :         nFlags |= WINDOW_ZORDER_BEHIND;
    6707             :     }
    6708             : 
    6709           0 :     while ( pRefWindow && pRefWindow->mpWindowImpl->mpBorderWindow )
    6710           0 :         pRefWindow = pRefWindow->mpWindowImpl->mpBorderWindow;
    6711           0 :     if (!pRefWindow || pRefWindow == this || mpWindowImpl->mbFrame)
    6712           0 :         return;
    6713             : 
    6714             :     DBG_ASSERT( pRefWindow->mpWindowImpl->mpParent == mpWindowImpl->mpParent, "Window::SetZOrder() - pRefWindow has other parent" );
    6715           0 :     if ( nFlags & WINDOW_ZORDER_BEFOR )
    6716             :     {
    6717           0 :         if ( pRefWindow->mpWindowImpl->mpPrev == this )
    6718           0 :             return;
    6719             : 
    6720           0 :         if ( ImplIsOverlapWindow() )
    6721             :         {
    6722           0 :             if ( mpWindowImpl->mpPrev )
    6723           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    6724             :             else
    6725           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext;
    6726           0 :             if ( mpWindowImpl->mpNext )
    6727           0 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    6728             :             else
    6729           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev;
    6730           0 :             if ( !pRefWindow->mpWindowImpl->mpPrev )
    6731           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = this;
    6732             :         }
    6733             :         else
    6734             :         {
    6735           0 :             if ( mpWindowImpl->mpPrev )
    6736           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    6737             :             else
    6738           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
    6739           0 :             if ( mpWindowImpl->mpNext )
    6740           0 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    6741             :             else
    6742           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
    6743           0 :             if ( !pRefWindow->mpWindowImpl->mpPrev )
    6744           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = this;
    6745             :         }
    6746             : 
    6747           0 :         mpWindowImpl->mpPrev = pRefWindow->mpWindowImpl->mpPrev;
    6748           0 :         mpWindowImpl->mpNext = pRefWindow;
    6749           0 :         if ( mpWindowImpl->mpPrev )
    6750           0 :             mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    6751           0 :         mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this;
    6752             :     }
    6753           0 :     else if ( nFlags & WINDOW_ZORDER_BEHIND )
    6754             :     {
    6755           0 :         if ( pRefWindow->mpWindowImpl->mpNext == this )
    6756           0 :             return;
    6757             : 
    6758           0 :         if ( ImplIsOverlapWindow() )
    6759             :         {
    6760           0 :             if ( mpWindowImpl->mpPrev )
    6761           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    6762             :             else
    6763           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap = mpWindowImpl->mpNext;
    6764           0 :             if ( mpWindowImpl->mpNext )
    6765           0 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    6766             :             else
    6767           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = mpWindowImpl->mpPrev;
    6768           0 :             if ( !pRefWindow->mpWindowImpl->mpNext )
    6769           0 :                 mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpLastOverlap = this;
    6770             :         }
    6771             :         else
    6772             :         {
    6773           0 :             if ( mpWindowImpl->mpPrev )
    6774           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    6775             :             else
    6776           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
    6777           0 :             if ( mpWindowImpl->mpNext )
    6778           0 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    6779             :             else
    6780           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
    6781           0 :             if ( !pRefWindow->mpWindowImpl->mpNext )
    6782           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this;
    6783             :         }
    6784             : 
    6785           0 :         mpWindowImpl->mpPrev = pRefWindow;
    6786           0 :         mpWindowImpl->mpNext = pRefWindow->mpWindowImpl->mpNext;
    6787           0 :         if ( mpWindowImpl->mpNext )
    6788           0 :             mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this;
    6789           0 :         mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    6790             :     }
    6791             : 
    6792           0 :     if ( IsReallyVisible() )
    6793             :     {
    6794             :         // restore background storage
    6795           0 :         if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    6796           0 :             ImplInvalidateAllOverlapBackgrounds();
    6797             : 
    6798           0 :         if ( mpWindowImpl->mbInitWinClipRegion || !mpWindowImpl->maWinClipRegion.IsEmpty() )
    6799             :         {
    6800           0 :             bool bInitWinClipRegion = mpWindowImpl->mbInitWinClipRegion;
    6801           0 :             ImplSetClipFlag();
    6802             : 
    6803             :             // When ClipRegion was not initialised, assume
    6804             :             // the window has not been sent, therefore do not
    6805             :             // trigger any Invalidates. This is an optimization
    6806             :             // for HTML documents with many controls. If this
    6807             :             // check gives problems, a flag should be introduced
    6808             :             // which tracks whether the window has already been
    6809             :             // emitted after Show
    6810           0 :             if ( !bInitWinClipRegion )
    6811             :             {
    6812             :                 // Invalidate all windows which are next to each other
    6813             :                 // Is INCOMPLETE !!!
    6814           0 :                 Rectangle   aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    6815           0 :                 Window*     pWindow = NULL;
    6816           0 :                 if ( ImplIsOverlapWindow() )
    6817             :                 {
    6818           0 :                     if ( mpWindowImpl->mpOverlapWindow )
    6819           0 :                         pWindow = mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpFirstOverlap;
    6820             :                 }
    6821             :                 else
    6822           0 :                     pWindow = ImplGetParent()->mpWindowImpl->mpFirstChild;
    6823             :                 // Invalidate all windows in front of us and which are covered by us
    6824           0 :                 while ( pWindow )
    6825             :                 {
    6826           0 :                     if ( pWindow == this )
    6827           0 :                         break;
    6828             :                     Rectangle aCompRect( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ),
    6829           0 :                                          Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) );
    6830           0 :                     if ( aWinRect.IsOver( aCompRect ) )
    6831           0 :                         pWindow->Invalidate( INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT );
    6832           0 :                     pWindow = pWindow->mpWindowImpl->mpNext;
    6833             :                 }
    6834             : 
    6835             :                 // If we are covered by a window in the background
    6836             :                 // we should redraw it
    6837           0 :                 while ( pWindow )
    6838             :                 {
    6839           0 :                     if ( pWindow != this )
    6840             :                     {
    6841             :                         Rectangle aCompRect( Point( pWindow->mnOutOffX, pWindow->mnOutOffY ),
    6842           0 :                                              Size( pWindow->mnOutWidth, pWindow->mnOutHeight ) );
    6843           0 :                         if ( aWinRect.IsOver( aCompRect ) )
    6844             :                         {
    6845           0 :                             Invalidate( INVALIDATE_CHILDREN | INVALIDATE_NOTRANSPARENT );
    6846           0 :                             break;
    6847             :                         }
    6848             :                     }
    6849           0 :                     pWindow = pWindow->mpWindowImpl->mpNext;
    6850             :                 }
    6851             :             }
    6852             :         }
    6853             :     }
    6854             : }
    6855             : 
    6856           0 : void Window::EnableAlwaysOnTop( bool bEnable )
    6857             : {
    6858             : 
    6859           0 :     mpWindowImpl->mbAlwaysOnTop = bEnable;
    6860             : 
    6861           0 :     if ( mpWindowImpl->mpBorderWindow )
    6862           0 :         mpWindowImpl->mpBorderWindow->EnableAlwaysOnTop( bEnable );
    6863           0 :     else if ( bEnable && IsReallyVisible() )
    6864           0 :         ToTop();
    6865             : 
    6866           0 :     if ( mpWindowImpl->mbFrame )
    6867           0 :         mpWindowImpl->mpFrame->SetAlwaysOnTop( bEnable );
    6868           0 : }
    6869             : 
    6870           0 : void Window::setPosSizePixel( long nX, long nY,
    6871             :                               long nWidth, long nHeight, sal_uInt16 nFlags )
    6872             : {
    6873             : 
    6874           0 :     bool bHasValidSize = !mpWindowImpl->mbDefSize;
    6875             : 
    6876           0 :     if ( nFlags & WINDOW_POSSIZE_POS )
    6877           0 :         mpWindowImpl->mbDefPos = false;
    6878           0 :     if ( nFlags & WINDOW_POSSIZE_SIZE )
    6879           0 :         mpWindowImpl->mbDefSize = false;
    6880             : 
    6881             :     // The top BorderWindow is the window which is to be positioned
    6882           0 :     Window* pWindow = this;
    6883           0 :     while ( pWindow->mpWindowImpl->mpBorderWindow )
    6884           0 :         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
    6885             : 
    6886           0 :     if ( pWindow->mpWindowImpl->mbFrame )
    6887             :     {
    6888             :         // Note: if we're positioning a frame, the coordinates are interpreted
    6889             :         // as being the top-left corner of the window's client area and NOT
    6890             :         // as the position of the border ! (due to limitations of several UNIX window managers)
    6891           0 :         long nOldWidth  = pWindow->mnOutWidth;
    6892             : 
    6893           0 :         if ( !(nFlags & WINDOW_POSSIZE_WIDTH) )
    6894           0 :             nWidth = pWindow->mnOutWidth;
    6895           0 :         if ( !(nFlags & WINDOW_POSSIZE_HEIGHT) )
    6896           0 :             nHeight = pWindow->mnOutHeight;
    6897             : 
    6898           0 :         sal_uInt16 nSysFlags=0;
    6899           0 :         Window *pParent = GetParent();
    6900             : 
    6901           0 :         if( nFlags & WINDOW_POSSIZE_WIDTH )
    6902           0 :             nSysFlags |= SAL_FRAME_POSSIZE_WIDTH;
    6903           0 :         if( nFlags & WINDOW_POSSIZE_HEIGHT )
    6904           0 :             nSysFlags |= SAL_FRAME_POSSIZE_HEIGHT;
    6905           0 :         if( nFlags & WINDOW_POSSIZE_X )
    6906             :         {
    6907           0 :             nSysFlags |= SAL_FRAME_POSSIZE_X;
    6908           0 :             if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
    6909             :             {
    6910           0 :                 nX += pParent->mnOutOffX;
    6911             :             }
    6912           0 :             if( pParent && pParent->ImplIsAntiparallel() )
    6913             :             {
    6914             :                 // --- RTL --- (re-mirror at parent window)
    6915           0 :                 Rectangle aRect( Point ( nX, nY ), Size( nWidth, nHeight ) );
    6916           0 :                 const OutputDevice *pParentOutDev = pParent->GetOutDev();
    6917           0 :                 pParentOutDev->ReMirror( aRect );
    6918           0 :                 nX = aRect.Left();
    6919             :             }
    6920             :         }
    6921           0 :         if( !(nFlags & WINDOW_POSSIZE_X) && bHasValidSize && pWindow->mpWindowImpl->mpFrame->maGeometry.nWidth )
    6922             :         {
    6923             :             // --- RTL ---  make sure the old right aligned position is not changed
    6924             :             //              system windows will always grow to the right
    6925           0 :             if ( pParent )
    6926             :             {
    6927           0 :                 OutputDevice *pParentOutDev = pParent->GetOutDev();
    6928           0 :                 if( pParentOutDev->HasMirroredGraphics() )
    6929             :                 {
    6930           0 :                     long myWidth = nOldWidth;
    6931           0 :                     if( !myWidth )
    6932           0 :                         myWidth = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth;
    6933           0 :                     if( !myWidth )
    6934           0 :                         myWidth = nWidth;
    6935           0 :                     nFlags |= WINDOW_POSSIZE_X;
    6936           0 :                     nSysFlags |= SAL_FRAME_POSSIZE_X;
    6937           0 :                     nX = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX -
    6938           0 :                         mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration;
    6939           0 :                     nX = pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nLeftDecoration +
    6940           0 :                         pParent->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nWidth - myWidth - 1 - mpWindowImpl->mpFrame->GetUnmirroredGeometry().nX;
    6941           0 :                     if(!(nFlags & WINDOW_POSSIZE_Y))
    6942             :                     {
    6943           0 :                         nFlags |= WINDOW_POSSIZE_Y;
    6944           0 :                         nSysFlags |= SAL_FRAME_POSSIZE_Y;
    6945           0 :                         nY = mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY - pWindow->GetParent()->mpWindowImpl->mpFrame->GetUnmirroredGeometry().nY -
    6946           0 :                             mpWindowImpl->mpFrame->GetUnmirroredGeometry().nTopDecoration;
    6947             :                     }
    6948             :                 }
    6949             :             }
    6950             :         }
    6951           0 :         if( nFlags & WINDOW_POSSIZE_Y )
    6952             :         {
    6953           0 :             nSysFlags |= SAL_FRAME_POSSIZE_Y;
    6954           0 :             if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
    6955             :             {
    6956           0 :                 nY += pParent->mnOutOffY;
    6957             :             }
    6958             :         }
    6959             : 
    6960           0 :         if( nSysFlags & (SAL_FRAME_POSSIZE_WIDTH|SAL_FRAME_POSSIZE_HEIGHT) )
    6961             :         {
    6962             :             // check for min/max client size and adjust size accordingly
    6963             :             // otherwise it may happen that the resize event is ignored, i.e. the old size remains
    6964             :             // unchanged but ImplHandleResize() is called with the wrong size
    6965           0 :             SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( pWindow );
    6966           0 :             if( pSystemWindow )
    6967             :             {
    6968           0 :                 Size aMinSize = pSystemWindow->GetMinOutputSizePixel();
    6969           0 :                 Size aMaxSize = pSystemWindow->GetMaxOutputSizePixel();
    6970           0 :                 if( nWidth < aMinSize.Width() )
    6971           0 :                     nWidth = aMinSize.Width();
    6972           0 :                 if( nHeight < aMinSize.Height() )
    6973           0 :                     nHeight = aMinSize.Height();
    6974             : 
    6975           0 :                 if( nWidth > aMaxSize.Width() )
    6976           0 :                     nWidth = aMaxSize.Width();
    6977           0 :                 if( nHeight > aMaxSize.Height() )
    6978           0 :                     nHeight = aMaxSize.Height();
    6979             :             }
    6980             :         }
    6981             : 
    6982           0 :         pWindow->mpWindowImpl->mpFrame->SetPosSize( nX, nY, nWidth, nHeight, nSysFlags );
    6983             : 
    6984             :         // Resize should be called directly. If we havn't
    6985             :         // set the correct size, we get a second resize from
    6986             :         // the system with the correct size. This can be happened
    6987             :         // if the size is to small or to large.
    6988           0 :         ImplHandleResize( pWindow, nWidth, nHeight );
    6989             :     }
    6990             :     else
    6991             :     {
    6992           0 :         pWindow->ImplPosSizeWindow( nX, nY, nWidth, nHeight, nFlags );
    6993           0 :         if ( IsReallyVisible() )
    6994           0 :             ImplGenerateMouseMove();
    6995             :     }
    6996           0 : }
    6997             : 
    6998           0 : Point Window::GetPosPixel() const
    6999             : {
    7000           0 :     return mpWindowImpl->maPos;
    7001             : }
    7002             : 
    7003           0 : Rectangle Window::GetDesktopRectPixel() const
    7004             : {
    7005           0 :     Rectangle rRect;
    7006           0 :     mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrame->GetWorkArea( rRect );
    7007           0 :     return rRect;
    7008             : }
    7009             : 
    7010           0 : Point Window::OutputToScreenPixel( const Point& rPos ) const
    7011             : {
    7012             :     // relative to top level parent
    7013           0 :     return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
    7014             : }
    7015             : 
    7016           0 : Point Window::ScreenToOutputPixel( const Point& rPos ) const
    7017             : {
    7018             :     // relative to top level parent
    7019           0 :     return Point( rPos.X()-mnOutOffX, rPos.Y()-mnOutOffY );
    7020             : }
    7021             : 
    7022           0 : long Window::ImplGetUnmirroredOutOffX()
    7023             : {
    7024             :     // revert mnOutOffX changes that were potentially made in ImplPosSizeWindow
    7025           0 :     long offx = mnOutOffX;
    7026           0 :     OutputDevice *pOutDev = GetOutDev();
    7027           0 :     if( pOutDev->HasMirroredGraphics() )
    7028             :     {
    7029           0 :         if( mpWindowImpl->mpParent && !mpWindowImpl->mpParent->mpWindowImpl->mbFrame && mpWindowImpl->mpParent->ImplIsAntiparallel() )
    7030             :         {
    7031           0 :             if ( !ImplIsOverlapWindow() )
    7032           0 :                 offx -= mpWindowImpl->mpParent->mnOutOffX;
    7033             : 
    7034           0 :             offx = mpWindowImpl->mpParent->mnOutWidth - mnOutWidth - offx;
    7035             : 
    7036           0 :             if ( !ImplIsOverlapWindow() )
    7037           0 :                 offx += mpWindowImpl->mpParent->mnOutOffX;
    7038             : 
    7039             :         }
    7040             :     }
    7041           0 :     return offx;
    7042             : }
    7043             : 
    7044             : // normalized screen pixel are independent of mirroring
    7045           0 : Point Window::OutputToNormalizedScreenPixel( const Point& rPos ) const
    7046             : {
    7047             :     // relative to top level parent
    7048           0 :     long offx = ((Window*) this)->ImplGetUnmirroredOutOffX();
    7049           0 :     return Point( rPos.X()+offx, rPos.Y()+mnOutOffY );
    7050             : }
    7051             : 
    7052           0 : Point Window::NormalizedScreenToOutputPixel( const Point& rPos ) const
    7053             : {
    7054             :     // relative to top level parent
    7055           0 :     long offx = ((Window*) this)->ImplGetUnmirroredOutOffX();
    7056           0 :     return Point( rPos.X()-offx, rPos.Y()-mnOutOffY );
    7057             : }
    7058             : 
    7059           0 : Point Window::OutputToAbsoluteScreenPixel( const Point& rPos ) const
    7060             : {
    7061             :     // relative to the screen
    7062           0 :     Point p = OutputToScreenPixel( rPos );
    7063           0 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    7064           0 :     p.X() += g.nX;
    7065           0 :     p.Y() += g.nY;
    7066           0 :     return p;
    7067             : }
    7068             : 
    7069           0 : Point Window::AbsoluteScreenToOutputPixel( const Point& rPos ) const
    7070             : {
    7071             :     // relative to the screen
    7072           0 :     Point p = ScreenToOutputPixel( rPos );
    7073           0 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    7074           0 :     p.X() -= g.nX;
    7075           0 :     p.Y() -= g.nY;
    7076           0 :     return p;
    7077             : }
    7078             : 
    7079           0 : Rectangle Window::ImplOutputToUnmirroredAbsoluteScreenPixel( const Rectangle &rRect ) const
    7080             : {
    7081             :     // this method creates unmirrored screen coordinates to be compared with the desktop
    7082             :     // and is used for positioning of RTL popup windows correctly on the screen
    7083           0 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetUnmirroredGeometry();
    7084             : 
    7085           0 :     Point p1 = OutputToScreenPixel( rRect.TopRight() );
    7086           0 :     p1.X() = g.nX+g.nWidth-p1.X();
    7087           0 :     p1.Y() += g.nY;
    7088             : 
    7089           0 :     Point p2 = OutputToScreenPixel( rRect.BottomLeft() );
    7090           0 :     p2.X() = g.nX+g.nWidth-p2.X();
    7091           0 :     p2.Y() += g.nY;
    7092             : 
    7093           0 :     return Rectangle( p1, p2 );
    7094             : }
    7095             : 
    7096           0 : Rectangle Window::GetWindowExtentsRelative( Window *pRelativeWindow ) const
    7097             : {
    7098             :     // with decoration
    7099           0 :     return ImplGetWindowExtentsRelative( pRelativeWindow, false );
    7100             : }
    7101             : 
    7102           0 : Rectangle Window::GetClientWindowExtentsRelative( Window *pRelativeWindow ) const
    7103             : {
    7104             :     // without decoration
    7105           0 :     return ImplGetWindowExtentsRelative( pRelativeWindow, true );
    7106             : }
    7107             : 
    7108           0 : Rectangle Window::ImplGetWindowExtentsRelative( Window *pRelativeWindow, bool bClientOnly ) const
    7109             : {
    7110           0 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    7111             :     // make sure we use the extent of our border window,
    7112             :     // otherwise we miss a few pixels
    7113           0 :     const Window *pWin = (!bClientOnly && mpWindowImpl->mpBorderWindow) ? mpWindowImpl->mpBorderWindow : this;
    7114             : 
    7115           0 :     Point aPos( pWin->OutputToScreenPixel( Point(0,0) ) );
    7116           0 :     aPos.X() += g.nX;
    7117           0 :     aPos.Y() += g.nY;
    7118           0 :     Size aSize ( pWin->GetSizePixel() );
    7119             :     // #104088# do not add decoration to the workwindow to be compatible to java accessibility api
    7120           0 :     if( !bClientOnly && (mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame && GetType() != WINDOW_WORKWINDOW)) )
    7121             :     {
    7122           0 :         aPos.X() -= g.nLeftDecoration;
    7123           0 :         aPos.Y() -= g.nTopDecoration;
    7124           0 :         aSize.Width() += g.nLeftDecoration + g.nRightDecoration;
    7125           0 :         aSize.Height() += g.nTopDecoration + g.nBottomDecoration;
    7126             :     }
    7127           0 :     if( pRelativeWindow )
    7128             :     {
    7129             :         // #106399# express coordinates relative to borderwindow
    7130           0 :         Window *pRelWin = (!bClientOnly && pRelativeWindow->mpWindowImpl->mpBorderWindow) ? pRelativeWindow->mpWindowImpl->mpBorderWindow : pRelativeWindow;
    7131           0 :         aPos = pRelWin->AbsoluteScreenToOutputPixel( aPos );
    7132             :     }
    7133           0 :     return Rectangle( aPos, aSize );
    7134             : }
    7135             : 
    7136           0 : void Window::Scroll( long nHorzScroll, long nVertScroll, sal_uInt16 nFlags )
    7137             : {
    7138             : 
    7139             :     ImplScroll( Rectangle( Point( mnOutOffX, mnOutOffY ),
    7140             :                            Size( mnOutWidth, mnOutHeight ) ),
    7141           0 :                 nHorzScroll, nVertScroll, nFlags & ~SCROLL_CLIP );
    7142           0 : }
    7143             : 
    7144           0 : void Window::Scroll( long nHorzScroll, long nVertScroll,
    7145             :                      const Rectangle& rRect, sal_uInt16 nFlags )
    7146             : {
    7147             : 
    7148           0 :     OutputDevice *pOutDev = GetOutDev();
    7149           0 :     Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
    7150           0 :     aRect.Intersection( Rectangle( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ) );
    7151           0 :     if ( !aRect.IsEmpty() )
    7152           0 :         ImplScroll( aRect, nHorzScroll, nVertScroll, nFlags );
    7153           0 : }
    7154             : 
    7155           0 : void Window::Invalidate( sal_uInt16 nFlags )
    7156             : {
    7157             : 
    7158           0 :     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
    7159           0 :         return;
    7160             : 
    7161           0 :     ImplInvalidate( NULL, nFlags );
    7162             : }
    7163             : 
    7164           0 : void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
    7165             : {
    7166             : 
    7167           0 :     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
    7168           0 :         return;
    7169             : 
    7170           0 :     OutputDevice *pOutDev = GetOutDev();
    7171           0 :     Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
    7172           0 :     if ( !aRect.IsEmpty() )
    7173             :     {
    7174           0 :         Region aRegion( aRect );
    7175           0 :         ImplInvalidate( &aRegion, nFlags );
    7176             :     }
    7177             : }
    7178             : 
    7179           0 : void Window::Invalidate( const Region& rRegion, sal_uInt16 nFlags )
    7180             : {
    7181             : 
    7182           0 :     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
    7183           0 :         return;
    7184             : 
    7185           0 :     if ( rRegion.IsNull() )
    7186           0 :         ImplInvalidate( NULL, nFlags );
    7187             :     else
    7188             :     {
    7189           0 :         Region aRegion = ImplPixelToDevicePixel( LogicToPixel( rRegion ) );
    7190           0 :         if ( !aRegion.IsEmpty() )
    7191           0 :             ImplInvalidate( &aRegion, nFlags );
    7192             :     }
    7193             : }
    7194             : 
    7195           0 : void Window::Validate( sal_uInt16 nFlags )
    7196             : {
    7197             : 
    7198           0 :     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
    7199           0 :         return;
    7200             : 
    7201           0 :     ImplValidate( NULL, nFlags );
    7202             : }
    7203             : 
    7204           0 : bool Window::HasPaintEvent() const
    7205             : {
    7206             : 
    7207           0 :     if ( !mpWindowImpl->mbReallyVisible )
    7208           0 :         return false;
    7209             : 
    7210           0 :     if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
    7211           0 :         return true;
    7212             : 
    7213           0 :     if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT )
    7214           0 :         return true;
    7215             : 
    7216           0 :     if ( !ImplIsOverlapWindow() )
    7217             :     {
    7218           0 :         const Window* pTempWindow = this;
    7219           0 :         do
    7220             :         {
    7221           0 :             pTempWindow = pTempWindow->ImplGetParent();
    7222           0 :             if ( pTempWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINTCHILDREN | IMPL_PAINT_PAINTALLCHILDREN) )
    7223           0 :                 return true;
    7224             :         }
    7225           0 :         while ( !pTempWindow->ImplIsOverlapWindow() );
    7226             :     }
    7227             : 
    7228           0 :     return false;
    7229             : }
    7230             : 
    7231           0 : void Window::Update()
    7232             : {
    7233             : 
    7234           0 :     if ( mpWindowImpl->mpBorderWindow )
    7235             :     {
    7236           0 :         mpWindowImpl->mpBorderWindow->Update();
    7237           0 :         return;
    7238             :     }
    7239             : 
    7240           0 :     if ( !mpWindowImpl->mbReallyVisible )
    7241           0 :         return;
    7242             : 
    7243           0 :     bool bFlush = false;
    7244           0 :     if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
    7245             :     {
    7246           0 :         Point aPoint( 0, 0 );
    7247           0 :         Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
    7248           0 :         ImplInvalidateOverlapFrameRegion( aRegion );
    7249           0 :         if ( mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) )
    7250           0 :             bFlush = true;
    7251             :     }
    7252             : 
    7253             :     // First we should skip all windows which are Paint-Transparent
    7254           0 :     Window* pUpdateWindow = this;
    7255           0 :     Window* pWindow = pUpdateWindow;
    7256           0 :     while ( !pWindow->ImplIsOverlapWindow() )
    7257             :     {
    7258           0 :         if ( !pWindow->mpWindowImpl->mbPaintTransparent )
    7259             :         {
    7260           0 :             pUpdateWindow = pWindow;
    7261           0 :             break;
    7262             :         }
    7263           0 :         pWindow = pWindow->ImplGetParent();
    7264             :     }
    7265             :     // In order to limit drawing, an update only draws the window which
    7266             :     // has PAINTALLCHILDREN set
    7267           0 :     pWindow = pUpdateWindow;
    7268           0 :     do
    7269             :     {
    7270           0 :         if ( pWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
    7271           0 :             pUpdateWindow = pWindow;
    7272           0 :         if ( pWindow->ImplIsOverlapWindow() )
    7273           0 :             break;
    7274           0 :         pWindow = pWindow->ImplGetParent();
    7275             :     }
    7276             :     while ( pWindow );
    7277             : 
    7278             :     // if there is something to paint, trigger a Paint
    7279           0 :     if ( pUpdateWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDREN) )
    7280             :     {
    7281           0 :         ImplDelData aDogTag(this);
    7282             : 
    7283             :         // trigger an update also for system windows on top of us,
    7284             :         // otherwise holes would remain
    7285           0 :          Window* pUpdateOverlapWindow = ImplGetFirstOverlapWindow()->mpWindowImpl->mpFirstOverlap;
    7286           0 :          while ( pUpdateOverlapWindow )
    7287             :          {
    7288           0 :              pUpdateOverlapWindow->Update();
    7289           0 :              pUpdateOverlapWindow = pUpdateOverlapWindow->mpWindowImpl->mpNext;
    7290             :          }
    7291             : 
    7292           0 :         pUpdateWindow->ImplCallPaint( NULL, pUpdateWindow->mpWindowImpl->mnPaintFlags );
    7293             : 
    7294           0 :         if (aDogTag.IsDead())
    7295           0 :            return;
    7296           0 :         bFlush = true;
    7297             :     }
    7298             : 
    7299           0 :     if ( bFlush )
    7300           0 :         Flush();
    7301             : }
    7302             : 
    7303           0 : void Window::Flush()
    7304             : {
    7305             : 
    7306           0 :     const Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    7307           0 :     mpWindowImpl->mpFrame->Flush( aWinRect );
    7308           0 : }
    7309             : 
    7310           0 : void Window::Sync()
    7311             : {
    7312             : 
    7313           0 :     mpWindowImpl->mpFrame->Sync();
    7314           0 : }
    7315             : 
    7316           0 : void Window::SetUpdateMode( bool bUpdate )
    7317             : {
    7318             : 
    7319           0 :     mpWindowImpl->mbNoUpdate = !bUpdate;
    7320           0 :     StateChanged( STATE_CHANGE_UPDATEMODE );
    7321           0 : }
    7322             : 
    7323           0 : void Window::GrabFocus()
    7324             : {
    7325             : 
    7326           0 :     ImplGrabFocus( 0 );
    7327           0 : }
    7328             : 
    7329           0 : bool Window::HasFocus() const
    7330             : {
    7331             : 
    7332             :     // #107575# the first floating window always has the keyboard focus, see also winproc.cxx: ImplGetKeyInputWindow()
    7333             :     //  task was shifted to 6.y, so its commented out
    7334             :     /*
    7335             :     Window* pFocusWin = ImplGetSVData()->maWinData.mpFirstFloat;
    7336             :     if( pFocusWin && pFocusWin->mpWindowImpl->mbFloatWin && ((FloatingWindow *)pFocusWin)->GrabsFocus() )
    7337             :         pFocusWin = pFocusWin->GetPreferredKeyInputWindow();
    7338             :     else
    7339             :         pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
    7340             : 
    7341             :     return (this == pFocusWin);
    7342             :     */
    7343             : 
    7344           0 :     return (this == ImplGetSVData()->maWinData.mpFocusWin);
    7345             : }
    7346             : 
    7347           0 : void Window::GrabFocusToDocument()
    7348             : {
    7349           0 :     ImplGrabFocusToDocument(0);
    7350           0 : }
    7351             : 
    7352           0 : void Window::SetFakeFocus( bool bFocus )
    7353             : {
    7354           0 :     ImplGetWindowImpl()->mbFakeFocusSet = bFocus;
    7355           0 : }
    7356             : 
    7357           0 : bool Window::HasChildPathFocus( bool bSystemWindow ) const
    7358             : {
    7359             : 
    7360             :     // #107575#, the first floating window always has the keyboard focus, see also winproc.cxx: ImplGetKeyInputWindow()
    7361             :     //  task was shifted to 6.y, so its commented out
    7362             :     /*
    7363             :     Window* pFocusWin = ImplGetSVData()->maWinData.mpFirstFloat;
    7364             :     if( pFocusWin && pFocusWin->mpWindowImpl->mbFloatWin && ((FloatingWindow *)pFocusWin)->GrabsFocus() )
    7365             :         pFocusWin = pFocusWin->GetPreferredKeyInputWindow();
    7366             :     else
    7367             :         pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
    7368             :     */
    7369           0 :     Window* pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
    7370           0 :     if ( pFocusWin )
    7371           0 :         return ImplIsWindowOrChild( pFocusWin, bSystemWindow );
    7372           0 :     return false;
    7373             : }
    7374             : 
    7375           0 : void Window::CaptureMouse()
    7376             : {
    7377             : 
    7378           0 :     ImplSVData* pSVData = ImplGetSVData();
    7379             : 
    7380             :     // possibly stop tracking
    7381           0 :     if ( pSVData->maWinData.mpTrackWin != this )
    7382             :     {
    7383           0 :         if ( pSVData->maWinData.mpTrackWin )
    7384           0 :             pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
    7385             :     }
    7386             : 
    7387           0 :     if ( pSVData->maWinData.mpCaptureWin != this )
    7388             :     {
    7389           0 :         pSVData->maWinData.mpCaptureWin = this;
    7390           0 :         mpWindowImpl->mpFrame->CaptureMouse( true );
    7391             :     }
    7392           0 : }
    7393             : 
    7394           0 : void Window::ReleaseMouse()
    7395             : {
    7396             : 
    7397           0 :     ImplSVData* pSVData = ImplGetSVData();
    7398             : 
    7399             :     DBG_ASSERTWARNING( pSVData->maWinData.mpCaptureWin == this,
    7400             :                        "Window::ReleaseMouse(): window doesn't have the mouse capture" );
    7401             : 
    7402           0 :     if ( pSVData->maWinData.mpCaptureWin == this )
    7403             :     {
    7404           0 :         pSVData->maWinData.mpCaptureWin = NULL;
    7405           0 :         mpWindowImpl->mpFrame->CaptureMouse( false );
    7406           0 :         ImplGenerateMouseMove();
    7407             :     }
    7408           0 : }
    7409             : 
    7410           0 : bool Window::IsMouseCaptured() const
    7411             : {
    7412             : 
    7413           0 :     return (this == ImplGetSVData()->maWinData.mpCaptureWin);
    7414             : }
    7415             : 
    7416           0 : void Window::SetPointer( const Pointer& rPointer )
    7417             : {
    7418             : 
    7419           0 :     if ( mpWindowImpl->maPointer == rPointer )
    7420           0 :         return;
    7421             : 
    7422           0 :     mpWindowImpl->maPointer   = rPointer;
    7423             : 
    7424             :     // possibly immediately move pointer
    7425           0 :     if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
    7426           0 :         mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
    7427             : }
    7428             : 
    7429           0 : void Window::EnableChildPointerOverwrite( bool bOverwrite )
    7430             : {
    7431             : 
    7432           0 :     if ( mpWindowImpl->mbChildPtrOverwrite == bOverwrite )
    7433           0 :         return;
    7434             : 
    7435           0 :     mpWindowImpl->mbChildPtrOverwrite  = bOverwrite;
    7436             : 
    7437             :     // possibly immediately move pointer
    7438           0 :     if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
    7439           0 :         mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
    7440             : }
    7441             : 
    7442           0 : void Window::SetPointerPosPixel( const Point& rPos )
    7443             : {
    7444           0 :     Point aPos = ImplOutputToFrame( rPos );
    7445           0 :     const OutputDevice *pOutDev = GetOutDev();
    7446           0 :     if( pOutDev->HasMirroredGraphics() )
    7447             :     {
    7448           0 :         if( !IsRTLEnabled() )
    7449             :         {
    7450             :             // --- RTL --- (re-mirror mouse pos at this window)
    7451           0 :             pOutDev->ReMirror( aPos );
    7452             :         }
    7453             :         // mirroring is required here, SetPointerPos bypasses SalGraphics
    7454           0 :         mpGraphics->mirror( aPos.X(), this );
    7455             :     }
    7456           0 :     else if( ImplIsAntiparallel() )
    7457             :     {
    7458           0 :         pOutDev->ReMirror( aPos );
    7459             :     }
    7460           0 :     mpWindowImpl->mpFrame->SetPointerPos( aPos.X(), aPos.Y() );
    7461           0 : }
    7462             : 
    7463           0 : Point Window::GetPointerPosPixel()
    7464             : {
    7465             : 
    7466           0 :     Point aPos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
    7467           0 :     if( ImplIsAntiparallel() )
    7468             :     {
    7469             :         // --- RTL --- (re-mirror mouse pos at this window)
    7470           0 :         const OutputDevice *pOutDev = GetOutDev();
    7471           0 :         pOutDev->ReMirror( aPos );
    7472             :     }
    7473           0 :     return ImplFrameToOutput( aPos );
    7474             : }
    7475             : 
    7476           0 : Point Window::GetLastPointerPosPixel()
    7477             : {
    7478             : 
    7479           0 :     Point aPos( mpWindowImpl->mpFrameData->mnBeforeLastMouseX, mpWindowImpl->mpFrameData->mnBeforeLastMouseY );
    7480           0 :     if( ImplIsAntiparallel() )
    7481             :     {
    7482             :         // --- RTL --- (re-mirror mouse pos at this window)
    7483           0 :         const OutputDevice *pOutDev = GetOutDev();
    7484           0 :         pOutDev->ReMirror( aPos );
    7485             :     }
    7486           0 :     return ImplFrameToOutput( aPos );
    7487             : }
    7488             : 
    7489           0 : void Window::ShowPointer( bool bVisible )
    7490             : {
    7491             : 
    7492           0 :     if ( mpWindowImpl->mbNoPtrVisible != !bVisible )
    7493             :     {
    7494           0 :         mpWindowImpl->mbNoPtrVisible = !bVisible;
    7495             : 
    7496             :         // possibly immediately move pointer
    7497           0 :         if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
    7498           0 :             mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
    7499             :     }
    7500           0 : }
    7501             : 
    7502           0 : Window::PointerState Window::GetPointerState()
    7503             : {
    7504           0 :     PointerState aState;
    7505           0 :     aState.mnState = 0;
    7506             : 
    7507           0 :     if (mpWindowImpl->mpFrame)
    7508             :     {
    7509           0 :         SalFrame::SalPointerState aSalPointerState;
    7510             : 
    7511           0 :         aSalPointerState = mpWindowImpl->mpFrame->GetPointerState();
    7512           0 :         if( ImplIsAntiparallel() )
    7513             :         {
    7514             :             // --- RTL --- (re-mirror mouse pos at this window)
    7515           0 :             const OutputDevice *pOutDev = GetOutDev();
    7516           0 :             pOutDev->ReMirror( aSalPointerState.maPos );
    7517             :         }
    7518           0 :         aState.maPos = ImplFrameToOutput( aSalPointerState.maPos );
    7519           0 :         aState.mnState = aSalPointerState.mnState;
    7520             :     }
    7521           0 :     return aState;
    7522             : }
    7523             : 
    7524           0 : bool Window::IsMouseOver()
    7525             : {
    7526           0 :     return ImplGetWinData()->mbMouseOver;
    7527             : }
    7528             : 
    7529           0 : void Window::EnterWait()
    7530             : {
    7531             : 
    7532           0 :     mpWindowImpl->mnWaitCount++;
    7533             : 
    7534           0 :     if ( mpWindowImpl->mnWaitCount == 1 )
    7535             :     {
    7536             :         // possibly immediately move pointer
    7537           0 :         if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
    7538           0 :             mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
    7539             :     }
    7540           0 : }
    7541             : 
    7542           0 : void Window::LeaveWait()
    7543             : {
    7544             : 
    7545           0 :     if ( mpWindowImpl->mnWaitCount )
    7546             :     {
    7547           0 :         mpWindowImpl->mnWaitCount--;
    7548             : 
    7549           0 :         if ( !mpWindowImpl->mnWaitCount )
    7550             :         {
    7551             :             // possibly immediately move pointer
    7552           0 :             if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
    7553           0 :                 mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
    7554             :         }
    7555             :     }
    7556           0 : }
    7557             : 
    7558           0 : void Window::SetCursor( Cursor* pCursor )
    7559             : {
    7560             : 
    7561           0 :     if ( mpWindowImpl->mpCursor != pCursor )
    7562             :     {
    7563           0 :         if ( mpWindowImpl->mpCursor )
    7564           0 :             mpWindowImpl->mpCursor->ImplHide( true );
    7565           0 :         mpWindowImpl->mpCursor = pCursor;
    7566           0 :         if ( pCursor )
    7567           0 :             pCursor->ImplShow();
    7568             :     }
    7569           0 : }
    7570             : 
    7571           0 : void Window::SetText( const OUString& rStr )
    7572             : {
    7573           0 :     if (rStr == mpWindowImpl->maText)
    7574           0 :         return;
    7575             : 
    7576           0 :     OUString oldTitle( mpWindowImpl->maText );
    7577           0 :     mpWindowImpl->maText = rStr;
    7578             : 
    7579           0 :     if ( mpWindowImpl->mpBorderWindow )
    7580           0 :         mpWindowImpl->mpBorderWindow->SetText( rStr );
    7581           0 :     else if ( mpWindowImpl->mbFrame )
    7582           0 :         mpWindowImpl->mpFrame->SetTitle( rStr );
    7583             : 
    7584           0 :     ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
    7585             : 
    7586             :     // #107247# needed for accessibility
    7587             :     // The VCLEVENT_WINDOW_FRAMETITLECHANGED is (mis)used to notify accessible name changes.
    7588             :     // Therefore a window, which is labeled by this window, must also notify an accessible
    7589             :     // name change.
    7590           0 :     if ( IsReallyVisible() )
    7591             :     {
    7592           0 :         Window* pWindow = GetAccessibleRelationLabelFor();
    7593           0 :         if ( pWindow && pWindow != this )
    7594           0 :             pWindow->ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
    7595             :     }
    7596             : 
    7597           0 :     StateChanged( STATE_CHANGE_TEXT );
    7598             : }
    7599             : 
    7600           0 : OUString Window::GetText() const
    7601             : {
    7602             : 
    7603           0 :     return mpWindowImpl->maText;
    7604             : }
    7605             : 
    7606           0 : OUString Window::GetDisplayText() const
    7607             : {
    7608             : 
    7609           0 :     return GetText();
    7610             : }
    7611             : 
    7612           0 : const Wallpaper& Window::GetDisplayBackground() const
    7613             : {
    7614             :     // FIXME: fix issue 52349, need to fix this really in
    7615             :     // all NWF enabled controls
    7616           0 :     const ToolBox* pTB = dynamic_cast<const ToolBox*>(this);
    7617           0 :     if( pTB )
    7618             :     {
    7619           0 :         if( IsNativeWidgetEnabled() )
    7620           0 :             return pTB->ImplGetToolBoxPrivateData()->maDisplayBackground;
    7621             :     }
    7622             : 
    7623           0 :     if( !IsBackground() )
    7624             :     {
    7625           0 :         if( mpWindowImpl->mpParent )
    7626           0 :             return mpWindowImpl->mpParent->GetDisplayBackground();
    7627             :     }
    7628             : 
    7629           0 :     const Wallpaper& rBack = GetBackground();
    7630           0 :     if( ! rBack.IsBitmap() &&
    7631           0 :         ! rBack.IsGradient() &&
    7632           0 :         rBack.GetColor().GetColor() == COL_TRANSPARENT &&
    7633             :         mpWindowImpl->mpParent )
    7634           0 :             return mpWindowImpl->mpParent->GetDisplayBackground();
    7635           0 :     return rBack;
    7636             : }
    7637             : 
    7638           0 : const OUString& Window::GetHelpText() const
    7639             : {
    7640             : 
    7641           0 :     OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
    7642           0 :     bool bStrHelpId = !aStrHelpId.isEmpty();
    7643             : 
    7644           0 :     if ( !mpWindowImpl->maHelpText.getLength() && bStrHelpId )
    7645             :     {
    7646           0 :         if ( !IsDialog() && (mpWindowImpl->mnType != WINDOW_TABPAGE) && (mpWindowImpl->mnType != WINDOW_FLOATINGWINDOW) )
    7647             :         {
    7648           0 :             Help* pHelp = Application::GetHelp();
    7649           0 :             if ( pHelp )
    7650             :             {
    7651           0 :                 ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( aStrHelpId, this );
    7652           0 :                 mpWindowImpl->mbHelpTextDynamic = false;
    7653             :             }
    7654             :         }
    7655             :     }
    7656           0 :     else if( mpWindowImpl->mbHelpTextDynamic && bStrHelpId )
    7657             :     {
    7658           0 :         static const char* pEnv = getenv( "HELP_DEBUG" );
    7659           0 :         if( pEnv && *pEnv )
    7660             :         {
    7661           0 :             OUStringBuffer aTxt( 64+mpWindowImpl->maHelpText.getLength() );
    7662           0 :             aTxt.append( mpWindowImpl->maHelpText );
    7663           0 :             aTxt.appendAscii( "\n------------------\n" );
    7664           0 :             aTxt.append( OUString( aStrHelpId ) );
    7665           0 :             mpWindowImpl->maHelpText = aTxt.makeStringAndClear();
    7666             :         }
    7667           0 :         mpWindowImpl->mbHelpTextDynamic = false;
    7668             :     }
    7669             : 
    7670           0 :     return mpWindowImpl->maHelpText;
    7671             : }
    7672             : 
    7673           0 : Window* Window::FindWindow( const Point& rPos ) const
    7674             : {
    7675             : 
    7676           0 :     Point aPos = OutputToScreenPixel( rPos );
    7677           0 :     return ((Window*)this)->ImplFindWindow( aPos );
    7678             : }
    7679             : 
    7680           0 : sal_uInt16 Window::GetChildCount() const
    7681             : {
    7682             : 
    7683           0 :     sal_uInt16  nChildCount = 0;
    7684           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    7685           0 :     while ( pChild )
    7686             :     {
    7687           0 :         nChildCount++;
    7688           0 :         pChild = pChild->mpWindowImpl->mpNext;
    7689             :     }
    7690             : 
    7691           0 :     return nChildCount;
    7692             : }
    7693             : 
    7694           0 : Window* Window::GetChild( sal_uInt16 nChild ) const
    7695             : {
    7696             : 
    7697           0 :     sal_uInt16  nChildCount = 0;
    7698           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    7699           0 :     while ( pChild )
    7700             :     {
    7701           0 :         if ( nChild == nChildCount )
    7702           0 :             return pChild;
    7703           0 :         pChild = pChild->mpWindowImpl->mpNext;
    7704           0 :         nChildCount++;
    7705             :     }
    7706             : 
    7707           0 :     return NULL;
    7708             : }
    7709             : 
    7710           0 : Window* Window::GetWindow( sal_uInt16 nType ) const
    7711             : {
    7712             : 
    7713           0 :     switch ( nType )
    7714             :     {
    7715             :         case WINDOW_PARENT:
    7716           0 :             return mpWindowImpl->mpRealParent;
    7717             : 
    7718             :         case WINDOW_FIRSTCHILD:
    7719           0 :             return mpWindowImpl->mpFirstChild;
    7720             : 
    7721             :         case WINDOW_LASTCHILD:
    7722           0 :             return mpWindowImpl->mpLastChild;
    7723             : 
    7724             :         case WINDOW_PREV:
    7725           0 :             return mpWindowImpl->mpPrev;
    7726             : 
    7727             :         case WINDOW_NEXT:
    7728           0 :             return mpWindowImpl->mpNext;
    7729             : 
    7730             :         case WINDOW_FIRSTOVERLAP:
    7731           0 :             return mpWindowImpl->mpFirstOverlap;
    7732             : 
    7733             :         case WINDOW_LASTOVERLAP:
    7734           0 :             return mpWindowImpl->mpLastOverlap;
    7735             : 
    7736             :         case WINDOW_OVERLAP:
    7737           0 :             if ( ImplIsOverlapWindow() )
    7738           0 :                 return (Window*)this;
    7739             :             else
    7740           0 :                 return mpWindowImpl->mpOverlapWindow;
    7741             : 
    7742             :         case WINDOW_PARENTOVERLAP:
    7743           0 :             if ( ImplIsOverlapWindow() )
    7744           0 :                 return mpWindowImpl->mpOverlapWindow;
    7745             :             else
    7746           0 :                 return mpWindowImpl->mpOverlapWindow->mpWindowImpl->mpOverlapWindow;
    7747             : 
    7748             :         case WINDOW_CLIENT:
    7749           0 :             return ((Window*)this)->ImplGetWindow();
    7750             : 
    7751             :         case WINDOW_REALPARENT:
    7752           0 :             return ImplGetParent();
    7753             : 
    7754             :         case WINDOW_FRAME:
    7755           0 :             return mpWindowImpl->mpFrameWindow;
    7756             : 
    7757             :         case WINDOW_BORDER:
    7758           0 :             if ( mpWindowImpl->mpBorderWindow )
    7759           0 :                 return mpWindowImpl->mpBorderWindow->GetWindow( WINDOW_BORDER );
    7760           0 :             return (Window*)this;
    7761             : 
    7762             :         case WINDOW_FIRSTTOPWINDOWCHILD:
    7763           0 :             return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.begin();
    7764             : 
    7765             :         case WINDOW_LASTTOPWINDOWCHILD:
    7766           0 :             return ImplGetWinData()->maTopWindowChildren.empty() ? NULL : *ImplGetWinData()->maTopWindowChildren.rbegin();
    7767             : 
    7768             :         case WINDOW_PREVTOPWINDOWSIBLING:
    7769             :         {
    7770           0 :             if ( !mpWindowImpl->mpRealParent )
    7771           0 :                 return NULL;
    7772           0 :             const ::std::list< Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
    7773             :             ::std::list< Window* >::const_iterator myPos =
    7774           0 :                 ::std::find( rTopWindows.begin(), rTopWindows.end(), this );
    7775           0 :             if ( myPos == rTopWindows.end() )
    7776           0 :                 return NULL;
    7777           0 :             if ( myPos == rTopWindows.begin() )
    7778           0 :                 return NULL;
    7779           0 :             return *--myPos;
    7780             :         }
    7781             : 
    7782             :         case WINDOW_NEXTTOPWINDOWSIBLING:
    7783             :         {
    7784           0 :             if ( !mpWindowImpl->mpRealParent )
    7785           0 :                 return NULL;
    7786           0 :             const ::std::list< Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
    7787             :             ::std::list< Window* >::const_iterator myPos =
    7788           0 :                 ::std::find( rTopWindows.begin(), rTopWindows.end(), this );
    7789           0 :             if ( ( myPos == rTopWindows.end() ) || ( ++myPos == rTopWindows.end() ) )
    7790           0 :                 return NULL;
    7791           0 :             return *myPos;
    7792             :         }
    7793             : 
    7794             :     }
    7795             : 
    7796           0 :     return NULL;
    7797             : }
    7798             : 
    7799           0 : bool Window::IsChild( const Window* pWindow, bool bSystemWindow ) const
    7800             : {
    7801             : 
    7802           0 :     do
    7803             :     {
    7804           0 :         if ( !bSystemWindow && pWindow->ImplIsOverlapWindow() )
    7805           0 :             break;
    7806             : 
    7807           0 :         pWindow = pWindow->ImplGetParent();
    7808             : 
    7809           0 :         if ( pWindow == this )
    7810           0 :             return true;
    7811             :     }
    7812             :     while ( pWindow );
    7813             : 
    7814           0 :     return false;
    7815             : }
    7816             : 
    7817           0 : bool Window::IsWindowOrChild( const Window* pWindow, bool bSystemWindow ) const
    7818             : {
    7819             : 
    7820           0 :     if ( this == pWindow )
    7821           0 :         return true;
    7822           0 :     return ImplIsChild( pWindow, bSystemWindow );
    7823             : }
    7824             : 
    7825           0 : const SystemEnvData* Window::GetSystemData() const
    7826             : {
    7827             : 
    7828           0 :     return mpWindowImpl->mpFrame ? mpWindowImpl->mpFrame->GetSystemData() : NULL;
    7829             : }
    7830             : 
    7831           0 : ::com::sun::star::uno::Any Window::GetSystemDataAny() const
    7832             : {
    7833           0 :     ::com::sun::star::uno::Any aRet;
    7834           0 :     const SystemEnvData* pSysData = GetSystemData();
    7835           0 :     if( pSysData )
    7836             :     {
    7837           0 :         ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( (sal_Int8*)pSysData, pSysData->nSize );
    7838           0 :         aRet <<= aSeq;
    7839             :     }
    7840           0 :     return aRet;
    7841             : }
    7842             : 
    7843           0 : void Window::SetWindowPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xPeer, VCLXWindow* pVCLXWindow  )
    7844             : {
    7845             :     // be safe against re-entrance: first clear the old ref, then assign the new one
    7846             :     // #133706# / 2006-03-30 / frank.schoenheit@sun.com
    7847           0 :     mpWindowImpl->mxWindowPeer.clear();
    7848           0 :     mpWindowImpl->mxWindowPeer = xPeer;
    7849             : 
    7850           0 :     mpWindowImpl->mpVCLXWindow = pVCLXWindow;
    7851           0 : }
    7852             : 
    7853           0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > Window::GetComponentInterface( sal_Bool bCreate )
    7854             : {
    7855           0 :     if ( !mpWindowImpl->mxWindowPeer.is() && bCreate )
    7856             :     {
    7857           0 :         UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
    7858           0 :         if ( pWrapper )
    7859           0 :             mpWindowImpl->mxWindowPeer = pWrapper->GetWindowInterface( this, true );
    7860             :     }
    7861           0 :     return mpWindowImpl->mxWindowPeer;
    7862             : }
    7863             : 
    7864           0 : void Window::SetComponentInterface( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xIFace )
    7865             : {
    7866           0 :     UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
    7867             :     DBG_ASSERT( pWrapper, "SetComponentInterface: No Wrapper!" );
    7868           0 :     if ( pWrapper )
    7869           0 :         pWrapper->SetWindowInterface( this, xIFace );
    7870           0 : }
    7871             : 
    7872           0 : void Window::ImplCallDeactivateListeners( Window *pNew )
    7873             : {
    7874             :     // no deactivation if the newly activated window is my child
    7875           0 :     if ( !pNew || !ImplIsChild( pNew ) )
    7876             :     {
    7877           0 :         ImplDelData aDogtag( this );
    7878           0 :         ImplCallEventListeners( VCLEVENT_WINDOW_DEACTIVATE );
    7879           0 :         if( aDogtag.IsDead() )
    7880           0 :             return;
    7881             : 
    7882             :         // #100759#, avoid walking the wrong frame's hierarchy
    7883             :         //           eg, undocked docking windows (ImplDockFloatWin)
    7884           0 :         if ( ImplGetParent() && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow )
    7885           0 :             ImplGetParent()->ImplCallDeactivateListeners( pNew );
    7886             :     }
    7887             : }
    7888             : 
    7889           0 : void Window::ImplCallActivateListeners( Window *pOld )
    7890             : {
    7891             :     // no activation if the old active window is my child
    7892           0 :     if ( !pOld || !ImplIsChild( pOld ) )
    7893             :     {
    7894           0 :         ImplDelData aDogtag( this );
    7895           0 :         ImplCallEventListeners( VCLEVENT_WINDOW_ACTIVATE, pOld );
    7896           0 :         if( aDogtag.IsDead() )
    7897           0 :             return;
    7898             : 
    7899             :         // #106298# revoke the change for 105369, because this change
    7900             :         //          disabled the activate event for the parent,
    7901             :         //          if the parent is a compound control
    7902             :         //if( !GetParent() || !GetParent()->IsCompoundControl() )
    7903             :         //{
    7904             :             // #100759#, avoid walking the wrong frame's hierarchy
    7905             :             //           eg, undocked docking windows (ImplDockFloatWin)
    7906             :             // #104714#, revert the changes for 100759 because it has a side effect when pOld is a dialog
    7907             :             //           additionally the gallery is not dockable anymore, so 100759 canot occur
    7908           0 :         if ( ImplGetParent() ) /* && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow ) */
    7909           0 :             ImplGetParent()->ImplCallActivateListeners( pOld );
    7910           0 :         else if( (mpWindowImpl->mnStyle & WB_INTROWIN) == 0 )
    7911             :         {
    7912             :             // top level frame reached: store hint for DefModalDialogParent
    7913           0 :             ImplGetSVData()->maWinData.mpActiveApplicationFrame = mpWindowImpl->mpFrameWindow;
    7914           0 :         }
    7915             :         //}
    7916             :     }
    7917             : }
    7918             : 
    7919           0 : bool Window::ImplStopDnd()
    7920             : {
    7921           0 :     bool bRet = false;
    7922           0 :     if( mpWindowImpl->mpFrameData && mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
    7923             :     {
    7924           0 :         bRet = true;
    7925           0 :         mpWindowImpl->mpFrameData->mxDropTarget.clear();
    7926           0 :         mpWindowImpl->mpFrameData->mxDragSource.clear();
    7927           0 :         mpWindowImpl->mpFrameData->mxDropTargetListener.clear();
    7928             :     }
    7929             : 
    7930           0 :     return bRet;
    7931             : }
    7932             : 
    7933           0 : void Window::ImplStartDnd()
    7934             : {
    7935           0 :     GetDropTarget();
    7936           0 : }
    7937             : 
    7938           0 : uno::Reference< XDropTarget > Window::GetDropTarget()
    7939             : {
    7940             : 
    7941           0 :     if( ! mpWindowImpl->mxDNDListenerContainer.is() )
    7942             :     {
    7943           0 :         sal_Int8 nDefaultActions = 0;
    7944             : 
    7945           0 :         if( mpWindowImpl->mpFrameData )
    7946             :         {
    7947           0 :             if( ! mpWindowImpl->mpFrameData->mxDropTarget.is() )
    7948             :             {
    7949             :                 // initialization is done in GetDragSource
    7950           0 :                 uno::Reference< XDragSource > xDragSource = GetDragSource();
    7951             :             }
    7952             : 
    7953           0 :             if( mpWindowImpl->mpFrameData->mxDropTarget.is() )
    7954             :             {
    7955           0 :                 nDefaultActions = mpWindowImpl->mpFrameData->mxDropTarget->getDefaultActions();
    7956             : 
    7957           0 :                 if( ! mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
    7958             :                 {
    7959           0 :                     mpWindowImpl->mpFrameData->mxDropTargetListener = new DNDEventDispatcher( mpWindowImpl->mpFrameWindow );
    7960             : 
    7961             :                     try
    7962             :                     {
    7963           0 :                         mpWindowImpl->mpFrameData->mxDropTarget->addDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener );
    7964             : 
    7965             :                         // register also as drag gesture listener if directly supported by drag source
    7966             :                         uno::Reference< XDragGestureRecognizer > xDragGestureRecognizer =
    7967           0 :                             uno::Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
    7968             : 
    7969           0 :                         if( xDragGestureRecognizer.is() )
    7970             :                         {
    7971           0 :                             xDragGestureRecognizer->addDragGestureListener(
    7972           0 :                                 uno::Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
    7973             :                         }
    7974             :                         else
    7975           0 :                             mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = true;
    7976             : 
    7977             :                     }
    7978           0 :                     catch (const RuntimeException&)
    7979             :                     {
    7980             :                         // release all instances
    7981           0 :                         mpWindowImpl->mpFrameData->mxDropTarget.clear();
    7982           0 :                         mpWindowImpl->mpFrameData->mxDragSource.clear();
    7983             :                     }
    7984             :                 }
    7985             :             }
    7986             : 
    7987             :         }
    7988             : 
    7989           0 :         mpWindowImpl->mxDNDListenerContainer = static_cast < XDropTarget * > ( new DNDListenerContainer( nDefaultActions ) );
    7990             :     }
    7991             : 
    7992             :     // this object is located in the same process, so there will be no runtime exception
    7993           0 :     return uno::Reference< XDropTarget > ( mpWindowImpl->mxDNDListenerContainer, UNO_QUERY );
    7994             : }
    7995             : 
    7996           0 : uno::Reference< XDragSource > Window::GetDragSource()
    7997             : {
    7998             : 
    7999             : #if HAVE_FEATURE_DESKTOP
    8000             : 
    8001           0 :     if( mpWindowImpl->mpFrameData )
    8002             :     {
    8003           0 :         if( ! mpWindowImpl->mpFrameData->mxDragSource.is() )
    8004             :         {
    8005             :             try
    8006             :             {
    8007           0 :                 uno::Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
    8008           0 :                 const SystemEnvData * pEnvData = GetSystemData();
    8009             : 
    8010           0 :                 if( pEnvData )
    8011             :                 {
    8012           0 :                     Sequence< Any > aDragSourceAL( 2 ), aDropTargetAL( 2 );
    8013           0 :                     OUString aDragSourceSN, aDropTargetSN;
    8014             : #if defined WNT
    8015             :                     aDragSourceSN = "com.sun.star.datatransfer.dnd.OleDragSource";
    8016             :                     aDropTargetSN = "com.sun.star.datatransfer.dnd.OleDropTarget";
    8017             :                     aDragSourceAL[ 1 ] = makeAny( static_cast<sal_uInt64>( reinterpret_cast<sal_IntPtr>(pEnvData->hWnd) ) );
    8018             :                     aDropTargetAL[ 0 ] = makeAny( static_cast<sal_uInt64>( reinterpret_cast<sal_IntPtr>(pEnvData->hWnd) ) );
    8019             : #elif defined MACOSX
    8020             :             /* FIXME: Mac OS X specific dnd interface does not exist! *
    8021             :              * Using Windows based dnd as a temporary solution        */
    8022             :                     aDragSourceSN = "com.sun.star.datatransfer.dnd.OleDragSource";
    8023             :                     aDropTargetSN = "com.sun.star.datatransfer.dnd.OleDropTarget";
    8024             :                     aDragSourceAL[ 1 ] = makeAny( static_cast<sal_uInt64>( reinterpret_cast<sal_IntPtr>(pEnvData->mpNSView) ) );
    8025             :                     aDropTargetAL[ 0 ] = makeAny( static_cast<sal_uInt64>( reinterpret_cast<sal_IntPtr>(pEnvData->mpNSView) ) );
    8026             : #elif HAVE_FEATURE_X11
    8027           0 :                     aDragSourceSN = "com.sun.star.datatransfer.dnd.X11DragSource";
    8028           0 :                     aDropTargetSN = "com.sun.star.datatransfer.dnd.X11DropTarget";
    8029             : 
    8030           0 :                     aDragSourceAL[ 0 ] = makeAny( Application::GetDisplayConnection() );
    8031           0 :                     aDropTargetAL[ 0 ] = makeAny( Application::GetDisplayConnection() );
    8032           0 :                     aDropTargetAL[ 1 ] = makeAny( (sal_Size)(pEnvData->aShellWindow) );
    8033             : #endif
    8034           0 :                     if( !aDragSourceSN.isEmpty() )
    8035             :                         mpWindowImpl->mpFrameData->mxDragSource.set(
    8036           0 :                             xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aDragSourceSN, aDragSourceAL, xContext ),
    8037           0 :                             UNO_QUERY );
    8038             : 
    8039           0 :                     if( !aDropTargetSN.isEmpty() )
    8040             :                         mpWindowImpl->mpFrameData->mxDropTarget.set(
    8041           0 :                            xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aDropTargetSN, aDropTargetAL, xContext ),
    8042           0 :                            UNO_QUERY );
    8043           0 :                 }
    8044             :             }
    8045             : 
    8046             :             // createInstance can throw any exception
    8047           0 :             catch (const Exception&)
    8048             :             {
    8049             :                 // release all instances
    8050           0 :                 mpWindowImpl->mpFrameData->mxDropTarget.clear();
    8051           0 :                 mpWindowImpl->mpFrameData->mxDragSource.clear();
    8052             :             }
    8053             :         }
    8054             : 
    8055           0 :         return mpWindowImpl->mpFrameData->mxDragSource;
    8056             :     }
    8057             : #endif
    8058           0 :     return uno::Reference< XDragSource > ();
    8059             : }
    8060             : 
    8061           0 : uno::Reference< XDragGestureRecognizer > Window::GetDragGestureRecognizer()
    8062             : {
    8063           0 :     return uno::Reference< XDragGestureRecognizer > ( GetDropTarget(), UNO_QUERY );
    8064             : }
    8065             : 
    8066           0 : uno::Reference< XClipboard > Window::GetClipboard()
    8067             : {
    8068             : 
    8069           0 :     if( mpWindowImpl->mpFrameData )
    8070             :     {
    8071           0 :         if( ! mpWindowImpl->mpFrameData->mxClipboard.is() )
    8072             :         {
    8073             :             try
    8074             :             {
    8075             :                 mpWindowImpl->mpFrameData->mxClipboard
    8076           0 :                     = css::datatransfer::clipboard::SystemClipboard::create(
    8077           0 :                         comphelper::getProcessComponentContext());
    8078             :             }
    8079           0 :             catch (css::uno::DeploymentException & e)
    8080             :             {
    8081             :                 SAL_WARN(
    8082             :                     "vcl.window",
    8083             :                     "ignoring DeploymentException \"" << e.Message << "\"");
    8084             :             }
    8085             :         }
    8086             : 
    8087           0 :         return mpWindowImpl->mpFrameData->mxClipboard;
    8088             :     }
    8089             : 
    8090           0 :     return static_cast < XClipboard * > (0);
    8091             : }
    8092             : 
    8093           0 : uno::Reference< XClipboard > Window::GetPrimarySelection()
    8094             : {
    8095             : 
    8096           0 :     if( mpWindowImpl->mpFrameData )
    8097             :     {
    8098           0 :         if( ! mpWindowImpl->mpFrameData->mxSelection.is() )
    8099             :         {
    8100             :             try
    8101             :             {
    8102           0 :                 uno::Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
    8103             : 
    8104             : #if HAVE_FEATURE_X11
    8105             :                 // A hack, making the primary selection available as an instance
    8106             :                 // of the SystemClipboard service on X11:
    8107           0 :                 css::uno::Sequence<css::uno::Any> args(1);
    8108           0 :                 args[0] <<= OUString("PRIMARY");
    8109             :                 mpWindowImpl->mpFrameData->mxSelection.set(
    8110           0 :                     (xContext->getServiceManager()->
    8111             :                      createInstanceWithArgumentsAndContext(
    8112             :                          "com.sun.star.datatransfer.clipboard.SystemClipboard",
    8113           0 :                          args, xContext)),
    8114           0 :                     css::uno::UNO_QUERY_THROW);
    8115             : #       else
    8116             :                 static uno::Reference< XClipboard > s_xSelection(
    8117             :                     xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.datatransfer.clipboard.GenericClipboard", xContext ), UNO_QUERY );
    8118             : 
    8119             :                 mpWindowImpl->mpFrameData->mxSelection = s_xSelection;
    8120             : #       endif
    8121             :             }
    8122           0 :             catch (css::uno::RuntimeException & e)
    8123             :             {
    8124             :                 SAL_WARN(
    8125             :                     "vcl.window",
    8126             :                     "ignoring RuntimeException \"" << e.Message << "\"");
    8127             :             }
    8128             :         }
    8129             : 
    8130           0 :         return mpWindowImpl->mpFrameData->mxSelection;
    8131             :     }
    8132             : 
    8133           0 :     return static_cast < XClipboard * > (0);
    8134             : }
    8135             : 
    8136             : // Accessibility
    8137             : 
    8138           0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > Window::GetAccessible( bool bCreate )
    8139             : {
    8140             :     // do not optimize hierarchy for the top level border win (ie, when there is no parent)
    8141             :     /* // do not optimize accessible hierarchy at all to better reflect real VCL hierarchy
    8142             :     if ( GetParent() && ( GetType() == WINDOW_BORDERWINDOW ) && ( GetChildCount() == 1 ) )
    8143             :     //if( !ImplIsAccessibleCandidate() )
    8144             :     {
    8145             :         Window* pChild = GetAccessibleChildWindow( 0 );
    8146             :         if ( pChild )
    8147             :             return pChild->GetAccessible();
    8148             :     }
    8149             :     */
    8150           0 :     if ( !mpWindowImpl->mxAccessible.is() && bCreate )
    8151           0 :         mpWindowImpl->mxAccessible = CreateAccessible();
    8152             : 
    8153           0 :     return mpWindowImpl->mxAccessible;
    8154             : }
    8155             : 
    8156           0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > Window::CreateAccessible()
    8157             : {
    8158           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc( GetComponentInterface( sal_True ), ::com::sun::star::uno::UNO_QUERY );
    8159           0 :     return xAcc;
    8160             : }
    8161             : 
    8162           0 : void Window::SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > x )
    8163             : {
    8164           0 :     mpWindowImpl->mxAccessible = x;
    8165           0 : }
    8166             : 
    8167             : // skip all border windows that are no top level frames
    8168           0 : bool Window::ImplIsAccessibleCandidate() const
    8169             : {
    8170           0 :     if( !mpWindowImpl->mbBorderWin )
    8171           0 :         return true;
    8172             :     else
    8173             :         // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menus!) are closeable
    8174           0 :         if( mpWindowImpl->mbFrame && mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) )
    8175           0 :             return true;
    8176             :         else
    8177           0 :             return false;
    8178             : }
    8179             : 
    8180           0 : bool Window::ImplIsAccessibleNativeFrame() const
    8181             : {
    8182           0 :     if( mpWindowImpl->mbFrame )
    8183             :         // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menus!) are closeable
    8184           0 :         if( (mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE)) )
    8185           0 :             return true;
    8186             :         else
    8187           0 :             return false;
    8188             :     else
    8189           0 :         return false;
    8190             : }
    8191             : 
    8192           0 : sal_uInt16 Window::ImplGetAccessibleCandidateChildWindowCount( sal_uInt16 nFirstWindowType ) const
    8193             : {
    8194           0 :     sal_uInt16  nChildren = 0;
    8195           0 :     Window* pChild = GetWindow( nFirstWindowType );
    8196           0 :     while ( pChild )
    8197             :     {
    8198           0 :         if( pChild->ImplIsAccessibleCandidate() )
    8199           0 :             nChildren++;
    8200             :         else
    8201           0 :             nChildren = sal::static_int_cast<sal_uInt16>(nChildren + pChild->ImplGetAccessibleCandidateChildWindowCount( WINDOW_FIRSTCHILD ));
    8202           0 :         pChild = pChild->mpWindowImpl->mpNext;
    8203             :     }
    8204           0 :     return nChildren;
    8205             : }
    8206             : 
    8207           0 : Window* Window::ImplGetAccessibleCandidateChild( sal_uInt16 nChild, sal_uInt16& rChildCount, sal_uInt16 nFirstWindowType, bool bTopLevel ) const
    8208             : {
    8209             : 
    8210           0 :     if( bTopLevel )
    8211           0 :         rChildCount = 0;
    8212             : 
    8213           0 :     Window* pChild = GetWindow( nFirstWindowType );
    8214           0 :     while ( pChild )
    8215             :     {
    8216           0 :         Window *pTmpChild = pChild;
    8217             : 
    8218           0 :         if( !pChild->ImplIsAccessibleCandidate() )
    8219           0 :             pTmpChild = pChild->ImplGetAccessibleCandidateChild( nChild, rChildCount, WINDOW_FIRSTCHILD, false );
    8220             : 
    8221           0 :         if ( nChild == rChildCount )
    8222           0 :             return pTmpChild;
    8223           0 :         pChild = pChild->mpWindowImpl->mpNext;
    8224           0 :         rChildCount++;
    8225             :     }
    8226             : 
    8227           0 :     return NULL;
    8228             : }
    8229             : 
    8230           0 : Window* Window::GetAccessibleParentWindow() const
    8231             : {
    8232           0 :     if ( ImplIsAccessibleNativeFrame() )
    8233           0 :         return NULL;
    8234             : 
    8235           0 :     Window* pParent = mpWindowImpl->mpParent;
    8236           0 :     if( GetType() == WINDOW_MENUBARWINDOW )
    8237             :     {
    8238             :         // report the menubar as a child of THE workwindow
    8239           0 :         Window *pWorkWin = GetParent()->mpWindowImpl->mpFirstChild;
    8240           0 :         while( pWorkWin && (pWorkWin == this) )
    8241           0 :             pWorkWin = pWorkWin->mpWindowImpl->mpNext;
    8242           0 :         pParent = pWorkWin;
    8243             :     }
    8244             :     // If this is a floating window which has a native border window, then that border should be reported as
    8245             :     // the accessible parent, unless the floating window is a PopupMenuFloatingWindow
    8246             : 
    8247             :     // The logic here has to match that of AccessibleFactory::createAccessibleContext in
    8248             :     // accessibility/source/helper/acc_factory.cxx to avoid PopupMenuFloatingWindow
    8249             :     // becoming a11y parents of themselves
    8250           0 :     else if( GetType() == WINDOW_FLOATINGWINDOW &&
    8251           0 :         mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame &&
    8252           0 :         !PopupMenuFloatingWindow::isPopupMenu(this))
    8253             :     {
    8254           0 :         pParent = mpWindowImpl->mpBorderWindow;
    8255             :     }
    8256           0 :     else if( pParent && !pParent->ImplIsAccessibleCandidate() )
    8257             :     {
    8258           0 :         pParent = pParent->mpWindowImpl->mpParent;
    8259             :     }
    8260           0 :     return pParent;
    8261             : }
    8262             : 
    8263           0 : sal_uInt16 Window::GetAccessibleChildWindowCount()
    8264             : {
    8265           0 :     sal_uInt16 nChildren = 0;
    8266           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    8267           0 :     while( pChild )
    8268             :     {
    8269           0 :         if( pChild->IsVisible() )
    8270           0 :             nChildren++;
    8271           0 :         pChild = pChild->mpWindowImpl->mpNext;
    8272             :     }
    8273             : 
    8274             :     // #107176# ignore overlapwindows
    8275             :     // this only affects non-system floating windows
    8276             :     // which are either not accessible (like the HelpAgent) or should be changed to system windows anyway
    8277             :     /*
    8278             :     if( ImplIsOverlapWindow() )
    8279             :     {
    8280             :         Window* pOverlap = GetWindow( WINDOW_FIRSTOVERLAP );
    8281             :         while ( pOverlap )
    8282             :         {
    8283             :             if( pOverlap->IsVisible() )
    8284             :                 nChildren++;
    8285             :             pOverlap = pOverlap->GetWindow( WINDOW_NEXT );
    8286             :         }
    8287             :     }
    8288             :     */
    8289             : 
    8290             :     // report the menubarwindow as a child of THE workwindow
    8291           0 :     if( GetType() == WINDOW_BORDERWINDOW )
    8292             :     {
    8293           0 :         if( ((ImplBorderWindow *) this)->mpMenuBarWindow &&
    8294           0 :             ((ImplBorderWindow *) this)->mpMenuBarWindow->IsVisible()
    8295             :             )
    8296           0 :             --nChildren;
    8297             :     }
    8298           0 :     else if( GetType() == WINDOW_WORKWINDOW )
    8299             :     {
    8300           0 :         if( ((WorkWindow *) this)->GetMenuBar() &&
    8301           0 :             ((WorkWindow *) this)->GetMenuBar()->GetWindow() &&
    8302           0 :             ((WorkWindow *) this)->GetMenuBar()->GetWindow()->IsVisible()
    8303             :             )
    8304           0 :             ++nChildren;
    8305             :     }
    8306             : 
    8307           0 :     return nChildren;
    8308             : }
    8309             : 
    8310           0 : Window* Window::GetAccessibleChildWindow( sal_uInt16 n )
    8311             : {
    8312             :     // report the menubarwindow as a the first child of THE workwindow
    8313           0 :     if( GetType() == WINDOW_WORKWINDOW && ((WorkWindow *) this)->GetMenuBar() )
    8314             :     {
    8315           0 :         if( n == 0 )
    8316             :         {
    8317           0 :             MenuBar *pMenuBar = ((WorkWindow *) this)->GetMenuBar();
    8318           0 :             if( pMenuBar->GetWindow() && pMenuBar->GetWindow()->IsVisible() )
    8319           0 :                 return pMenuBar->GetWindow();
    8320             :         }
    8321             :         else
    8322           0 :             --n;
    8323             :     }
    8324             : 
    8325             :     // transform n to child number including invisible children
    8326           0 :     sal_uInt16 nChildren = n;
    8327           0 :     Window* pChild = mpWindowImpl->mpFirstChild;
    8328           0 :     while( pChild )
    8329             :     {
    8330           0 :         if( pChild->IsVisible() )
    8331             :         {
    8332           0 :             if( ! nChildren )
    8333           0 :                 break;
    8334           0 :             nChildren--;
    8335             :         }
    8336           0 :         pChild = pChild->mpWindowImpl->mpNext;
    8337             :     }
    8338             : 
    8339           0 :     if( GetType() == WINDOW_BORDERWINDOW && pChild && pChild->GetType() == WINDOW_MENUBARWINDOW )
    8340             :     {
    8341           0 :         do pChild = pChild->mpWindowImpl->mpNext; while( pChild && ! pChild->IsVisible() );
    8342             :         DBG_ASSERT( pChild, "GetAccessibleChildWindow(): wrong index in border window");
    8343             :     }
    8344             :     if ( !pChild )
    8345             :     {
    8346             :         // #107176# ignore overlapwindows
    8347             :         /*
    8348             :         if( ImplIsOverlapWindow() )
    8349             :         {
    8350             :             Window* pOverlap = GetWindow( WINDOW_FIRSTOVERLAP );
    8351             :             while ( !pChild && pOverlap )
    8352             :             {
    8353             :                 if ( !nChildren && pOverlap->IsVisible() )
    8354             :                 {
    8355             :                     pChild = pOverlap;
    8356             :                     break;
    8357             :                 }
    8358             :                 pOverlap = pOverlap->GetWindow( WINDOW_NEXT );
    8359             :                 if( pOverlap && pOverlap->IsVisible() )
    8360             :                     nChildren--;
    8361             :             }
    8362             :         }
    8363             :         */
    8364             : 
    8365             :     }
    8366           0 :     if ( pChild && ( pChild->GetType() == WINDOW_BORDERWINDOW ) && ( pChild->GetChildCount() == 1 ) )
    8367             :     {
    8368           0 :         pChild = pChild->GetChild( 0 );
    8369             :     }
    8370           0 :     return pChild;
    8371             : }
    8372             : 
    8373           0 : void Window::SetAccessibleRole( sal_uInt16 nRole )
    8374             : {
    8375           0 :     if ( !mpWindowImpl->mpAccessibleInfos )
    8376           0 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8377             : 
    8378             :     DBG_ASSERT( mpWindowImpl->mpAccessibleInfos->nAccessibleRole == 0xFFFF, "AccessibleRole already set!" );
    8379           0 :     mpWindowImpl->mpAccessibleInfos->nAccessibleRole = nRole;
    8380           0 : }
    8381             : 
    8382           0 : sal_uInt16 Window::getDefaultAccessibleRole() const
    8383             : {
    8384           0 :     sal_uInt16 nRole = 0xFFFF;
    8385           0 :     switch ( GetType() )
    8386             :     {
    8387             :         case WINDOW_MESSBOX:    // MT: Would be nice to have special roles!
    8388             :         case WINDOW_INFOBOX:
    8389             :         case WINDOW_WARNINGBOX:
    8390             :         case WINDOW_ERRORBOX:
    8391           0 :         case WINDOW_QUERYBOX: nRole = accessibility::AccessibleRole::ALERT; break;
    8392             : 
    8393             :         case WINDOW_MODELESSDIALOG:
    8394             :         case WINDOW_MODALDIALOG:
    8395             :         case WINDOW_SYSTEMDIALOG:
    8396             :         case WINDOW_PRINTERSETUPDIALOG:
    8397             :         case WINDOW_PRINTDIALOG:
    8398             :         case WINDOW_TABDIALOG:
    8399             :         case WINDOW_BUTTONDIALOG:
    8400           0 :         case WINDOW_DIALOG: nRole = accessibility::AccessibleRole::DIALOG; break;
    8401             : 
    8402             :         case WINDOW_PUSHBUTTON:
    8403             :         case WINDOW_OKBUTTON:
    8404             :         case WINDOW_CANCELBUTTON:
    8405             :         case WINDOW_HELPBUTTON:
    8406             :         case WINDOW_IMAGEBUTTON:
    8407             :         case WINDOW_MOREBUTTON:
    8408             :         case WINDOW_SPINBUTTON:
    8409           0 :         case WINDOW_BUTTON: nRole = accessibility::AccessibleRole::PUSH_BUTTON; break;
    8410           0 :         case WINDOW_MENUBUTTON: nRole = accessibility::AccessibleRole::BUTTON_MENU; break;
    8411             : 
    8412           0 :         case WINDOW_PATHDIALOG: nRole = accessibility::AccessibleRole::DIRECTORY_PANE; break;
    8413           0 :         case WINDOW_FILEDIALOG: nRole = accessibility::AccessibleRole::FILE_CHOOSER; break;
    8414           0 :         case WINDOW_COLORDIALOG: nRole = accessibility::AccessibleRole::COLOR_CHOOSER; break;
    8415           0 :         case WINDOW_FONTDIALOG: nRole = accessibility::AccessibleRole::FONT_CHOOSER; break;
    8416             : 
    8417           0 :         case WINDOW_RADIOBUTTON: nRole = accessibility::AccessibleRole::RADIO_BUTTON; break;
    8418             :         case WINDOW_TRISTATEBOX:
    8419           0 :         case WINDOW_CHECKBOX: nRole = accessibility::AccessibleRole::CHECK_BOX; break;
    8420             : 
    8421           0 :         case WINDOW_MULTILINEEDIT: nRole = accessibility::AccessibleRole::SCROLL_PANE; break;
    8422             : 
    8423             :         case WINDOW_PATTERNFIELD:
    8424             :         case WINDOW_CALCINPUTLINE:
    8425           0 :         case WINDOW_EDIT: nRole = ( GetStyle() & WB_PASSWORD ) ? (accessibility::AccessibleRole::PASSWORD_TEXT) : (accessibility::AccessibleRole::TEXT); break;
    8426             : 
    8427             :         case WINDOW_PATTERNBOX:
    8428             :         case WINDOW_NUMERICBOX:
    8429             :         case WINDOW_METRICBOX:
    8430             :         case WINDOW_CURRENCYBOX:
    8431             :         case WINDOW_LONGCURRENCYBOX:
    8432           0 :         case WINDOW_COMBOBOX: nRole = accessibility::AccessibleRole::COMBO_BOX; break;
    8433             : 
    8434             :         case WINDOW_LISTBOX:
    8435           0 :         case WINDOW_MULTILISTBOX: nRole = accessibility::AccessibleRole::LIST; break;
    8436             : 
    8437           0 :         case WINDOW_TREELISTBOX: nRole = accessibility::AccessibleRole::TREE; break;
    8438             : 
    8439           0 :         case WINDOW_FIXEDTEXT: nRole = accessibility::AccessibleRole::LABEL; break;
    8440             :         case WINDOW_FIXEDLINE:
    8441           0 :             if( !GetText().isEmpty() )
    8442           0 :                 nRole = accessibility::AccessibleRole::LABEL;
    8443             :             else
    8444           0 :                 nRole = accessibility::AccessibleRole::SEPARATOR;
    8445           0 :             break;
    8446             : 
    8447             :         case WINDOW_FIXEDBITMAP:
    8448           0 :         case WINDOW_FIXEDIMAGE: nRole = accessibility::AccessibleRole::ICON; break;
    8449           0 :         case WINDOW_GROUPBOX: nRole = accessibility::AccessibleRole::GROUP_BOX; break;
    8450           0 :         case WINDOW_SCROLLBAR: nRole = accessibility::AccessibleRole::SCROLL_BAR; break;
    8451             : 
    8452             :         case WINDOW_SLIDER:
    8453             :         case WINDOW_SPLITTER:
    8454           0 :         case WINDOW_SPLITWINDOW: nRole = accessibility::AccessibleRole::SPLIT_PANE; break;
    8455             : 
    8456             :         case WINDOW_DATEBOX:
    8457             :         case WINDOW_TIMEBOX:
    8458             :         case WINDOW_DATEFIELD:
    8459           0 :         case WINDOW_TIMEFIELD: nRole = accessibility::AccessibleRole::DATE_EDITOR; break;
    8460             : 
    8461             :         case WINDOW_NUMERICFIELD:
    8462             :         case WINDOW_METRICFIELD:
    8463             :         case WINDOW_CURRENCYFIELD:
    8464             :         case WINDOW_LONGCURRENCYFIELD:
    8465           0 :         case WINDOW_SPINFIELD: nRole = accessibility::AccessibleRole::SPIN_BOX; break;
    8466             : 
    8467           0 :         case WINDOW_TOOLBOX: nRole = accessibility::AccessibleRole::TOOL_BAR; break;
    8468           0 :         case WINDOW_STATUSBAR: nRole = accessibility::AccessibleRole::STATUS_BAR; break;
    8469             : 
    8470           0 :         case WINDOW_TABPAGE: nRole = accessibility::AccessibleRole::PANEL; break;
    8471           0 :         case WINDOW_TABCONTROL: nRole = accessibility::AccessibleRole::PAGE_TAB_LIST; break;
    8472             : 
    8473             :         case WINDOW_DOCKINGWINDOW:
    8474             :         case WINDOW_SYSWINDOW:      nRole = (mpWindowImpl->mbFrame) ? accessibility::AccessibleRole::FRAME :
    8475           0 :                                                                       accessibility::AccessibleRole::PANEL; break;
    8476             : 
    8477           0 :         case WINDOW_FLOATINGWINDOW: nRole = ( mpWindowImpl->mbFrame ||
    8478           0 :                                              (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) ||
    8479           0 :                                              (GetStyle() & WB_OWNERDRAWDECORATION) ) ? accessibility::AccessibleRole::FRAME :
    8480           0 :                                                                                        accessibility::AccessibleRole::WINDOW; break;
    8481             : 
    8482           0 :         case WINDOW_WORKWINDOW: nRole = accessibility::AccessibleRole::ROOT_PANE; break;
    8483             : 
    8484           0 :         case WINDOW_SCROLLBARBOX: nRole = accessibility::AccessibleRole::FILLER; break;
    8485             : 
    8486           0 :         case WINDOW_HELPTEXTWINDOW: nRole = accessibility::AccessibleRole::TOOL_TIP; break;
    8487             : 
    8488           0 :         case WINDOW_RULER: nRole = accessibility::AccessibleRole::RULER; break;
    8489             : 
    8490           0 :         case WINDOW_SCROLLWINDOW: nRole = accessibility::AccessibleRole::SCROLL_PANE; break;
    8491             : 
    8492             :         case WINDOW_WINDOW:
    8493             :         case WINDOW_CONTROL:
    8494             :         case WINDOW_BORDERWINDOW:
    8495             :         case WINDOW_SYSTEMCHILDWINDOW:
    8496             :         default:
    8497           0 :             if (ImplIsAccessibleNativeFrame() )
    8498           0 :                 nRole = accessibility::AccessibleRole::FRAME;
    8499           0 :             else if( IsScrollable() )
    8500           0 :                 nRole = accessibility::AccessibleRole::SCROLL_PANE;
    8501           0 :             else if( ((Window*)this)->ImplGetWindow()->IsMenuFloatingWindow() )
    8502           0 :                 nRole = accessibility::AccessibleRole::WINDOW;      // #106002#, contextmenus are windows (i.e. toplevel)
    8503             :             else
    8504             :                 // #104051# WINDOW seems to be a bad default role, use LAYEREDPANE instead
    8505             :                 // a WINDOW is interpreted as a top-level window, which is typically not the case
    8506             :                 //nRole = accessibility::AccessibleRole::WINDOW;
    8507           0 :                 nRole = accessibility::AccessibleRole::PANEL;
    8508             :     }
    8509           0 :     return nRole;
    8510             : }
    8511             : 
    8512           0 : sal_uInt16 Window::GetAccessibleRole() const
    8513             : {
    8514             :     using namespace ::com::sun::star;
    8515             : 
    8516           0 :     sal_uInt16 nRole = mpWindowImpl->mpAccessibleInfos ? mpWindowImpl->mpAccessibleInfos->nAccessibleRole : 0xFFFF;
    8517           0 :     if ( nRole == 0xFFFF )
    8518           0 :         nRole = getDefaultAccessibleRole();
    8519           0 :     return nRole;
    8520             : }
    8521             : 
    8522           0 : void Window::SetAccessibleName( const OUString& rName )
    8523             : {
    8524           0 :    if ( !mpWindowImpl->mpAccessibleInfos )
    8525           0 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8526             : 
    8527           0 :     OUString oldName = GetAccessibleName();
    8528             : 
    8529           0 :     delete mpWindowImpl->mpAccessibleInfos->pAccessibleName;
    8530           0 :     mpWindowImpl->mpAccessibleInfos->pAccessibleName = new OUString( rName );
    8531             : 
    8532           0 :     ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldName );
    8533           0 : }
    8534             : 
    8535           0 : OUString Window::GetAccessibleName() const
    8536             : {
    8537           0 :     if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleName)
    8538           0 :         return *mpWindowImpl->mpAccessibleInfos->pAccessibleName;
    8539           0 :     return getDefaultAccessibleName();
    8540             : }
    8541             : 
    8542           0 : OUString Window::getDefaultAccessibleName() const
    8543             : {
    8544           0 :     OUString aAccessibleName;
    8545           0 :     switch ( GetType() )
    8546             :     {
    8547             :         case WINDOW_MULTILINEEDIT:
    8548             :         case WINDOW_PATTERNFIELD:
    8549             :         case WINDOW_NUMERICFIELD:
    8550             :         case WINDOW_METRICFIELD:
    8551             :         case WINDOW_CURRENCYFIELD:
    8552             :         case WINDOW_LONGCURRENCYFIELD:
    8553             :         case WINDOW_CALCINPUTLINE:
    8554             :         case WINDOW_EDIT:
    8555             : 
    8556             :         case WINDOW_DATEBOX:
    8557             :         case WINDOW_TIMEBOX:
    8558             :         case WINDOW_CURRENCYBOX:
    8559             :         case WINDOW_LONGCURRENCYBOX:
    8560             :         case WINDOW_DATEFIELD:
    8561             :         case WINDOW_TIMEFIELD:
    8562             :         case WINDOW_SPINFIELD:
    8563             : 
    8564             :         case WINDOW_COMBOBOX:
    8565             :         case WINDOW_LISTBOX:
    8566             :         case WINDOW_MULTILISTBOX:
    8567             :         case WINDOW_TREELISTBOX:
    8568             :         case WINDOW_METRICBOX:
    8569             :         {
    8570           0 :             Window *pLabel = GetAccessibleRelationLabeledBy();
    8571           0 :             if ( pLabel && pLabel != this )
    8572           0 :                 aAccessibleName = pLabel->GetText();
    8573           0 :             if (aAccessibleName.isEmpty())
    8574           0 :                 aAccessibleName = GetQuickHelpText();
    8575             :         }
    8576           0 :         break;
    8577             : 
    8578             :         case WINDOW_IMAGEBUTTON:
    8579             :         case WINDOW_PUSHBUTTON:
    8580           0 :             aAccessibleName = GetText();
    8581           0 :             if (aAccessibleName.isEmpty())
    8582             :             {
    8583           0 :                 aAccessibleName = GetQuickHelpText();
    8584           0 :                 if (aAccessibleName.isEmpty())
    8585           0 :                     aAccessibleName = GetHelpText();
    8586             :             }
    8587           0 :         break;
    8588             : 
    8589             :         case WINDOW_TOOLBOX:
    8590           0 :             aAccessibleName = GetText();
    8591           0 :             if( aAccessibleName.isEmpty() )
    8592           0 :                 aAccessibleName = "Tool Bar";
    8593           0 :             break;
    8594             : 
    8595             :         case WINDOW_MOREBUTTON:
    8596           0 :             aAccessibleName = mpWindowImpl->maText;
    8597           0 :             break;
    8598             : 
    8599             :         default:
    8600           0 :             aAccessibleName = GetText();
    8601           0 :             break;
    8602             :     }
    8603             : 
    8604           0 :     return GetNonMnemonicString( aAccessibleName );
    8605             : }
    8606             : 
    8607           0 : void Window::SetAccessibleDescription( const OUString& rDescription )
    8608             : {
    8609           0 :    if ( ! mpWindowImpl->mpAccessibleInfos )
    8610           0 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8611             : 
    8612             :     DBG_ASSERT( !mpWindowImpl->mpAccessibleInfos->pAccessibleDescription, "AccessibleDescription already set!" );
    8613           0 :     delete mpWindowImpl->mpAccessibleInfos->pAccessibleDescription;
    8614           0 :     mpWindowImpl->mpAccessibleInfos->pAccessibleDescription = new OUString( rDescription );
    8615           0 : }
    8616             : 
    8617           0 : OUString Window::GetAccessibleDescription() const
    8618             : {
    8619           0 :     OUString aAccessibleDescription;
    8620           0 :     if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleDescription )
    8621             :     {
    8622           0 :         aAccessibleDescription = *mpWindowImpl->mpAccessibleInfos->pAccessibleDescription;
    8623             :     }
    8624             :     else
    8625             :     {
    8626             :         // Special code for help text windows. ZT asks the border window for the
    8627             :         // description so we have to forward this request to our inner window.
    8628           0 :         const Window* pWin = ((Window *)this)->ImplGetWindow();
    8629           0 :         if ( pWin->GetType() == WINDOW_HELPTEXTWINDOW )
    8630           0 :             aAccessibleDescription = pWin->GetHelpText();
    8631             :         else
    8632           0 :             aAccessibleDescription = GetHelpText();
    8633             :     }
    8634             : 
    8635           0 :     return aAccessibleDescription;
    8636             : }
    8637             : 
    8638           0 : void Window::SetAccessibleRelationLabeledBy( Window* pLabeledBy )
    8639             : {
    8640           0 :     if ( !mpWindowImpl->mpAccessibleInfos )
    8641           0 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8642           0 :     mpWindowImpl->mpAccessibleInfos->pLabeledByWindow = pLabeledBy;
    8643           0 : }
    8644             : 
    8645           0 : void Window::SetAccessibleRelationLabelFor( Window* pLabelFor )
    8646             : {
    8647           0 :     if ( !mpWindowImpl->mpAccessibleInfos )
    8648           0 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8649           0 :     mpWindowImpl->mpAccessibleInfos->pLabelForWindow = pLabelFor;
    8650           0 : }
    8651             : 
    8652           0 : void Window::SetAccessibleRelationMemberOf( Window* pMemberOfWin )
    8653             : {
    8654           0 :     if ( !mpWindowImpl->mpAccessibleInfos )
    8655           0 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8656           0 :     mpWindowImpl->mpAccessibleInfos->pMemberOfWindow = pMemberOfWin;
    8657           0 : }
    8658             : 
    8659           0 : Window* Window::GetAccessibleRelationMemberOf() const
    8660             : {
    8661           0 :     if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pMemberOfWindow)
    8662           0 :         return mpWindowImpl->mpAccessibleInfos->pMemberOfWindow;
    8663             : 
    8664           0 :     if (!isContainerWindow(this) && !isContainerWindow(GetParent()))
    8665           0 :         return getLegacyNonLayoutAccessibleRelationMemberOf();
    8666             : 
    8667           0 :     return NULL;
    8668             : }
    8669             : 
    8670           0 : Window* Window::getAccessibleRelationLabelFor() const
    8671             : {
    8672           0 :     if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabelForWindow)
    8673           0 :         return mpWindowImpl->mpAccessibleInfos->pLabelForWindow;
    8674             : 
    8675           0 :     return NULL;
    8676             : }
    8677             : 
    8678           0 : Window* Window::GetAccessibleRelationLabelFor() const
    8679             : {
    8680           0 :     Window* pWindow = getAccessibleRelationLabelFor();
    8681             : 
    8682           0 :     if (pWindow)
    8683           0 :         return pWindow;
    8684             : 
    8685           0 :     if (!isContainerWindow(this) && !isContainerWindow(GetParent()))
    8686           0 :         return getLegacyNonLayoutAccessibleRelationLabelFor();
    8687             : 
    8688           0 :     return NULL;
    8689             : }
    8690             : 
    8691           0 : Window* Window::GetAccessibleRelationLabeledBy() const
    8692             : {
    8693           0 :     if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabeledByWindow)
    8694           0 :         return mpWindowImpl->mpAccessibleInfos->pLabeledByWindow;
    8695             : 
    8696           0 :     std::vector<FixedText*> aMnemonicLabels(list_mnemonic_labels());
    8697           0 :     if (!aMnemonicLabels.empty())
    8698             :     {
    8699             :         //if we have multiple labels, then prefer the first that is visible
    8700           0 :         for (std::vector<FixedText*>::iterator
    8701           0 :             aI = aMnemonicLabels.begin(), aEnd = aMnemonicLabels.end(); aI != aEnd; ++aI)
    8702             :         {
    8703           0 :             Window *pCandidate = *aI;
    8704           0 :             if (pCandidate->IsVisible())
    8705           0 :                 return pCandidate;
    8706             :         }
    8707           0 :         return aMnemonicLabels[0];
    8708             :     }
    8709             : 
    8710           0 :     if (!isContainerWindow(this) && !isContainerWindow(GetParent()))
    8711           0 :         return getLegacyNonLayoutAccessibleRelationLabeledBy();
    8712             : 
    8713           0 :     return NULL;
    8714             : }
    8715             : 
    8716           0 : bool Window::IsAccessibilityEventsSuppressed( bool bTraverseParentPath )
    8717             : {
    8718           0 :     if( !bTraverseParentPath )
    8719           0 :         return mpWindowImpl->mbSuppressAccessibilityEvents;
    8720             :     else
    8721             :     {
    8722           0 :         Window *pParent = this;
    8723           0 :         while ( pParent && pParent->mpWindowImpl)
    8724             :         {
    8725           0 :             if( pParent->mpWindowImpl->mbSuppressAccessibilityEvents )
    8726           0 :                 return true;
    8727             :             else
    8728           0 :                 pParent = pParent->mpWindowImpl->mpParent; // do not use GetParent() to find borderwindows that are frames
    8729             :         }
    8730           0 :         return false;
    8731             :     }
    8732             : }
    8733             : 
    8734           0 : void Window::SetAccessibilityEventsSuppressed(bool bSuppressed)
    8735             : {
    8736           0 :     mpWindowImpl->mbSuppressAccessibilityEvents = bSuppressed;
    8737           0 : }
    8738             : 
    8739           0 : void Window::RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect )
    8740             : {
    8741           0 :     if( ! mpOutDevData )
    8742             :     {
    8743           0 :         OutputDevice *pOutDev = GetOutDev();
    8744           0 :         pOutDev->ImplInitOutDevData();
    8745             :     }
    8746             :     assert(mpOutDevData);
    8747           0 :     mpOutDevData->mpRecordLayout = pLayout;
    8748           0 :     mpOutDevData->maRecordRect = rRect;
    8749           0 :     Paint( rRect );
    8750           0 :     mpOutDevData->mpRecordLayout = NULL;
    8751           0 : }
    8752             : 
    8753           0 : void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly )
    8754             : {
    8755           0 :     DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, NULL, NULL );
    8756           0 : }
    8757             : 
    8758           0 : void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly, Color* pSelectionTextColor )
    8759             : {
    8760           0 :     DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, pSelectionTextColor, NULL );
    8761           0 : }
    8762             : 
    8763           0 : void Window::DrawSelectionBackground( const Rectangle& rRect,
    8764             :                                       sal_uInt16 highlight,
    8765             :                                       bool bChecked,
    8766             :                                       bool bDrawBorder,
    8767             :                                       bool bDrawExtBorderOnly,
    8768             :                                       long nCornerRadius,
    8769             :                                       Color* pSelectionTextColor,
    8770             :                                       Color* pPaintColor
    8771             :                                       )
    8772             : {
    8773           0 :     if( rRect.IsEmpty() )
    8774           0 :         return;
    8775             : 
    8776           0 :     bool bRoundEdges = nCornerRadius > 0;
    8777             : 
    8778           0 :     const StyleSettings& rStyles = GetSettings().GetStyleSettings();
    8779             : 
    8780             :     // colors used for item highlighting
    8781           0 :     Color aSelectionBorderCol( pPaintColor ? *pPaintColor : rStyles.GetHighlightColor() );
    8782           0 :     Color aSelectionFillCol( aSelectionBorderCol );
    8783             : 
    8784           0 :     bool bDark = rStyles.GetFaceColor().IsDark();
    8785           0 :     bool bBright = ( rStyles.GetFaceColor() == Color( COL_WHITE ) );
    8786             : 
    8787           0 :     int c1 = aSelectionBorderCol.GetLuminance();
    8788           0 :     int c2 = GetDisplayBackground().GetColor().GetLuminance();
    8789             : 
    8790           0 :     if( !bDark && !bBright && abs( c2-c1 ) < (pPaintColor ? 40 : 75) )
    8791             :     {
    8792             :         // constrast too low
    8793             :         sal_uInt16 h,s,b;
    8794           0 :         aSelectionFillCol.RGBtoHSB( h, s, b );
    8795           0 :         if( b > 50 )    b -= 40;
    8796           0 :         else            b += 40;
    8797           0 :         aSelectionFillCol.SetColor( Color::HSBtoRGB( h, s, b ) );
    8798           0 :         aSelectionBorderCol = aSelectionFillCol;
    8799             :     }
    8800             : 
    8801           0 :     if( bRoundEdges )
    8802             :     {
    8803           0 :         if( aSelectionBorderCol.IsDark() )
    8804           0 :             aSelectionBorderCol.IncreaseLuminance( 128 );
    8805             :         else
    8806           0 :             aSelectionBorderCol.DecreaseLuminance( 128 );
    8807             :     }
    8808             : 
    8809           0 :     Rectangle aRect( rRect );
    8810           0 :     if( bDrawExtBorderOnly )
    8811             :     {
    8812           0 :         --aRect.Left();
    8813           0 :         --aRect.Top();
    8814           0 :         ++aRect.Right();
    8815           0 :         ++aRect.Bottom();
    8816             :     }
    8817           0 :     Color oldFillCol = GetFillColor();
    8818           0 :     Color oldLineCol = GetLineColor();
    8819             : 
    8820           0 :     if( bDrawBorder )
    8821           0 :         SetLineColor( bDark ? Color(COL_WHITE) : ( bBright ? Color(COL_BLACK) : aSelectionBorderCol ) );
    8822             :     else
    8823           0 :         SetLineColor();
    8824             : 
    8825           0 :     sal_uInt16 nPercent = 0;
    8826           0 :     if( !highlight )
    8827             :     {
    8828           0 :         if( bDark )
    8829           0 :             aSelectionFillCol = COL_BLACK;
    8830             :         else
    8831           0 :             nPercent = 80;  // just checked (light)
    8832             :     }
    8833             :     else
    8834             :     {
    8835           0 :         if( bChecked && highlight == 2 )
    8836             :         {
    8837           0 :             if( bDark )
    8838           0 :                 aSelectionFillCol = COL_LIGHTGRAY;
    8839           0 :             else if ( bBright )
    8840             :             {
    8841           0 :                 aSelectionFillCol = COL_BLACK;
    8842           0 :                 SetLineColor( COL_BLACK );
    8843           0 :                 nPercent = 0;
    8844             :             }
    8845             :             else
    8846           0 :                 nPercent = bRoundEdges ? 40 : 20;          // selected, pressed or checked ( very dark )
    8847             :         }
    8848           0 :         else if( bChecked || highlight == 1 )
    8849             :         {
    8850           0 :             if( bDark )
    8851           0 :                 aSelectionFillCol = COL_GRAY;
    8852           0 :             else if ( bBright )
    8853             :             {
    8854           0 :                 aSelectionFillCol = COL_BLACK;
    8855           0 :                 SetLineColor( COL_BLACK );
    8856           0 :                 nPercent = 0;
    8857             :             }
    8858             :             else
    8859           0 :                 nPercent = bRoundEdges ? 60 : 35;          // selected, pressed or checked ( very dark )
    8860             :         }
    8861             :         else
    8862             :         {
    8863           0 :             if( bDark )
    8864           0 :                 aSelectionFillCol = COL_LIGHTGRAY;
    8865           0 :             else if ( bBright )
    8866             :             {
    8867           0 :                 aSelectionFillCol = COL_BLACK;
    8868           0 :                 SetLineColor( COL_BLACK );
    8869           0 :                 if( highlight == 3 )
    8870           0 :                     nPercent = 80;
    8871             :                 else
    8872           0 :                     nPercent = 0;
    8873             :             }
    8874             :             else
    8875           0 :                 nPercent = 70;          // selected ( dark )
    8876             :         }
    8877             :     }
    8878             : 
    8879           0 :     if( bDark && bDrawExtBorderOnly )
    8880             :     {
    8881           0 :         SetFillColor();
    8882           0 :         if( pSelectionTextColor )
    8883           0 :             *pSelectionTextColor = rStyles.GetHighlightTextColor();
    8884             :     }
    8885             :     else
    8886             :     {
    8887           0 :         SetFillColor( aSelectionFillCol );
    8888           0 :         if( pSelectionTextColor )
    8889             :         {
    8890           0 :             Color aTextColor = IsControlBackground() ? GetControlForeground() : rStyles.GetButtonTextColor();
    8891           0 :             Color aHLTextColor = rStyles.GetHighlightTextColor();
    8892           0 :             int nTextDiff = abs(aSelectionFillCol.GetLuminance() - aTextColor.GetLuminance());
    8893           0 :             int nHLDiff = abs(aSelectionFillCol.GetLuminance() - aHLTextColor.GetLuminance());
    8894           0 :             *pSelectionTextColor = (nHLDiff >= nTextDiff) ? aHLTextColor : aTextColor;
    8895             :         }
    8896             :     }
    8897             : 
    8898           0 :     if( bDark )
    8899             :     {
    8900           0 :         DrawRect( aRect );
    8901             :     }
    8902             :     else
    8903             :     {
    8904           0 :         if( bRoundEdges )
    8905             :         {
    8906           0 :             Polygon aPoly( aRect, nCornerRadius, nCornerRadius );
    8907           0 :             PolyPolygon aPolyPoly( aPoly );
    8908           0 :             DrawTransparent( aPolyPoly, nPercent );
    8909             :         }
    8910             :         else
    8911             :         {
    8912           0 :             Polygon aPoly( aRect );
    8913           0 :             PolyPolygon aPolyPoly( aPoly );
    8914           0 :             DrawTransparent( aPolyPoly, nPercent );
    8915             :         }
    8916             :     }
    8917             : 
    8918           0 :     SetFillColor( oldFillCol );
    8919           0 :     SetLineColor( oldLineCol );
    8920             : }
    8921             : 
    8922             : // controls should return the window that gets the
    8923             : // focus by default, so keyevents can be sent to that window directly
    8924           0 : Window* Window::GetPreferredKeyInputWindow()
    8925             : {
    8926           0 :     return this;
    8927             : }
    8928             : 
    8929           0 : bool Window::IsScrollable() const
    8930             : {
    8931             :     // check for scrollbars
    8932           0 :     Window *pChild = mpWindowImpl->mpFirstChild;
    8933           0 :     while( pChild )
    8934             :     {
    8935           0 :         if( pChild->GetType() == WINDOW_SCROLLBAR )
    8936           0 :             return true;
    8937             :         else
    8938           0 :             pChild = pChild->mpWindowImpl->mpNext;
    8939             :     }
    8940           0 :     return false;
    8941             : }
    8942             : 
    8943           0 : bool Window::IsTopWindow() const
    8944             : {
    8945           0 :     if ( mpWindowImpl->mbInDtor )
    8946           0 :         return false;
    8947             : 
    8948             :     // topwindows must be frames or they must have a borderwindow which is a frame
    8949           0 :     if( !mpWindowImpl->mbFrame && (!mpWindowImpl->mpBorderWindow || (mpWindowImpl->mpBorderWindow && !mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) ) )
    8950           0 :         return false;
    8951             : 
    8952           0 :     ImplGetWinData();
    8953           0 :     if( mpWindowImpl->mpWinData->mnIsTopWindow == (sal_uInt16)~0)    // still uninitialized
    8954             :     {
    8955             :         // #113722#, cache result of expensive queryInterface call
    8956           0 :         Window *pThisWin = (Window*)this;
    8957           0 :         uno::Reference< XTopWindow > xTopWindow( pThisWin->GetComponentInterface(), UNO_QUERY );
    8958           0 :         pThisWin->mpWindowImpl->mpWinData->mnIsTopWindow = xTopWindow.is() ? 1 : 0;
    8959             :     }
    8960           0 :     return mpWindowImpl->mpWinData->mnIsTopWindow == 1 ? sal_True : sal_False;
    8961             : }
    8962             : 
    8963           0 : void Window::ImplMirrorFramePos( Point &pt ) const
    8964             : {
    8965           0 :     pt.X() = mpWindowImpl->mpFrame->maGeometry.nWidth-1-pt.X();
    8966           0 : }
    8967             : 
    8968             : // frame based modal counter (dialogs are not modal to the whole application anymore)
    8969           0 : bool Window::IsInModalMode() const
    8970             : {
    8971           0 :     return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0);
    8972             : }
    8973             : 
    8974           0 : bool Window::IsInModalNonRefMode() const
    8975             : {
    8976           0 :     if(mpWindowImpl->mnStyle & WB_REFMODE)
    8977           0 :         return false;
    8978             : 
    8979           0 :     return IsInModalMode();
    8980             : }
    8981             : 
    8982           0 : void Window::ImplIncModalCount()
    8983             : {
    8984           0 :     Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
    8985           0 :     Window* pParent = pFrameWindow;
    8986           0 :     while( pFrameWindow )
    8987             :     {
    8988           0 :         pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode++;
    8989           0 :         while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
    8990             :         {
    8991           0 :             pParent = pParent->GetParent();
    8992             :         }
    8993           0 :         pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL;
    8994             :     }
    8995           0 : }
    8996           0 : void Window::ImplDecModalCount()
    8997             : {
    8998           0 :     Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
    8999           0 :     Window* pParent = pFrameWindow;
    9000           0 :     while( pFrameWindow )
    9001             :     {
    9002           0 :         pFrameWindow->mpWindowImpl->mpFrameData->mnModalMode--;
    9003           0 :         while( pParent && pParent->mpWindowImpl->mpFrameWindow == pFrameWindow )
    9004             :         {
    9005           0 :             pParent = pParent->GetParent();
    9006             :         }
    9007           0 :         pFrameWindow = pParent ? pParent->mpWindowImpl->mpFrameWindow : NULL;
    9008             :     }
    9009           0 : }
    9010             : 
    9011           0 : void Window::ImplIsInTaskPaneList( bool mbIsInTaskList )
    9012             : {
    9013           0 :     mpWindowImpl->mbIsInTaskPaneList = mbIsInTaskList;
    9014           0 : }
    9015             : 
    9016           0 : void Window::ImplNotifyIconifiedState( bool bIconified )
    9017             : {
    9018           0 :     mpWindowImpl->mpFrameWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
    9019             :     // #109206# notify client window as well to have toolkit topwindow listeners notified
    9020           0 :     if( mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow && mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow )
    9021           0 :         mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
    9022           0 : }
    9023             : 
    9024           0 : bool Window::HasActiveChildFrame()
    9025             : {
    9026           0 :     bool bRet = false;
    9027           0 :     Window *pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
    9028           0 :     while( pFrameWin )
    9029             :     {
    9030           0 :         if( pFrameWin != mpWindowImpl->mpFrameWindow )
    9031             :         {
    9032           0 :             bool bDecorated = false;
    9033           0 :             Window *pChildFrame = pFrameWin->ImplGetWindow();
    9034             :             // #i15285# unfortunately WB_MOVEABLE is the same as WB_TABSTOP which can
    9035             :             // be removed for ToolBoxes to influence the keyboard accessibility
    9036             :             // thus WB_MOVEABLE is no indicator for decoration anymore
    9037             :             // but FloatingWindows carry this information in their TitleType...
    9038             :             // TODO: avoid duplicate WinBits !!!
    9039           0 :             if( pChildFrame && pChildFrame->ImplIsFloatingWindow() )
    9040           0 :                 bDecorated = ((FloatingWindow*) pChildFrame)->GetTitleType() != FLOATWIN_TITLE_NONE;
    9041           0 :             if( bDecorated || (pFrameWin->mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) )
    9042           0 :                 if( pChildFrame && pChildFrame->IsVisible() && pChildFrame->IsActive() )
    9043             :                 {
    9044           0 :                     if( ImplIsChild( pChildFrame, true ) )
    9045             :                     {
    9046           0 :                         bRet = true;
    9047           0 :                         break;
    9048             :                     }
    9049             :                 }
    9050             :         }
    9051           0 :         pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
    9052             :     }
    9053           0 :     return bRet;
    9054             : }
    9055             : 
    9056           0 : LanguageType Window::GetInputLanguage() const
    9057             : {
    9058           0 :     return mpWindowImpl->mpFrame->GetInputLanguage();
    9059             : }
    9060             : 
    9061           0 : void Window::EnableNativeWidget( bool bEnable )
    9062             : {
    9063           0 :     static const char* pNoNWF = getenv( "SAL_NO_NWF" );
    9064           0 :     if( pNoNWF && *pNoNWF )
    9065           0 :         bEnable = false;
    9066             : 
    9067           0 :     if( bEnable != ImplGetWinData()->mbEnableNativeWidget )
    9068             :     {
    9069           0 :         ImplGetWinData()->mbEnableNativeWidget = bEnable;
    9070             : 
    9071             :         // send datachanged event to allow for internal changes required for NWF
    9072             :         // like clipmode, transparency, etc.
    9073           0 :         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, mxSettings.get(), SETTINGS_STYLE );
    9074           0 :         DataChanged( aDCEvt );
    9075             : 
    9076             :         // sometimes the borderwindow is queried, so keep it in sync
    9077           0 :         if( mpWindowImpl->mpBorderWindow )
    9078           0 :             mpWindowImpl->mpBorderWindow->ImplGetWinData()->mbEnableNativeWidget = bEnable;
    9079             :     }
    9080             : 
    9081             :     // push down, useful for compound controls
    9082           0 :     Window *pChild = mpWindowImpl->mpFirstChild;
    9083           0 :     while( pChild )
    9084             :     {
    9085           0 :         pChild->EnableNativeWidget( bEnable );
    9086           0 :         pChild = pChild->mpWindowImpl->mpNext;
    9087             :     }
    9088           0 : }
    9089             : 
    9090           0 : bool Window::IsNativeWidgetEnabled() const
    9091             : {
    9092           0 :     return ImplGetWinData()->mbEnableNativeWidget;
    9093             : }
    9094             : 
    9095             : #ifdef WNT // see #140456#
    9096             : #include <win/salframe.h>
    9097             : #endif
    9098             : 
    9099           0 : uno::Reference< rendering::XCanvas > Window::ImplGetCanvas( const Size& rFullscreenSize,
    9100             :                                                        bool        bFullscreen,
    9101             :                                                        bool        bSpriteCanvas ) const
    9102             : {
    9103             :     // try to retrieve hard reference from weak member
    9104           0 :     uno::Reference< rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
    9105             : 
    9106             :     // canvas still valid? Then we're done.
    9107           0 :     if( xCanvas.is() )
    9108           0 :         return xCanvas;
    9109             : 
    9110           0 :     Sequence< Any > aArg(6);
    9111             : 
    9112             :     // Feed any with operating system's window handle
    9113             : 
    9114             :     // common: first any is VCL pointer to window (for VCL canvas)
    9115           0 :     aArg[ 0 ] = makeAny( reinterpret_cast<sal_Int64>(this) );
    9116             : 
    9117             :     // TODO(Q1): Make GetSystemData method virtual
    9118             : 
    9119             :     // check whether we're a SysChild: have to fetch system data
    9120             :     // directly from SystemChildWindow, because the GetSystemData
    9121             :     // method is unfortunately not virtual
    9122           0 :     const SystemChildWindow* pSysChild = dynamic_cast< const SystemChildWindow* >( this );
    9123           0 :     if( pSysChild )
    9124             :     {
    9125           0 :         aArg[ 1 ] = pSysChild->GetSystemDataAny();
    9126           0 :         aArg[ 5 ] = pSysChild->GetSystemGfxDataAny();
    9127             :     }
    9128             :     else
    9129             :     {
    9130           0 :         aArg[ 1 ] = GetSystemDataAny();
    9131           0 :         aArg[ 5 ] = GetSystemGfxDataAny();
    9132             :     }
    9133             : 
    9134           0 :     if( bFullscreen )
    9135           0 :         aArg[ 2 ] = makeAny( ::com::sun::star::awt::Rectangle( 0, 0,
    9136           0 :                                                                rFullscreenSize.Width(),
    9137           0 :                                                                rFullscreenSize.Height() ) );
    9138             :     else
    9139           0 :         aArg[ 2 ] = makeAny( ::com::sun::star::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ) );
    9140             : 
    9141           0 :     aArg[ 3 ] = makeAny( mpWindowImpl->mbAlwaysOnTop ? sal_True : sal_False );
    9142           0 :     aArg[ 4 ] = makeAny( uno::Reference< awt::XWindow >(
    9143           0 :                              const_cast<Window*>(this)->GetComponentInterface(),
    9144           0 :                              uno::UNO_QUERY ));
    9145             : 
    9146           0 :     uno::Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
    9147             : 
    9148             :     // Create canvas instance with window handle
    9149             : 
    9150             :     static ::vcl::DeleteUnoReferenceOnDeinit<lang::XMultiComponentFactory> xStaticCanvasFactory(
    9151           0 :         rendering::CanvasFactory::create( xContext ) );
    9152           0 :     uno::Reference<lang::XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
    9153             : 
    9154           0 :     if(xCanvasFactory.is())
    9155             :     {
    9156             : #ifdef WNT
    9157             :         // see #140456# - if we're running on a multiscreen setup,
    9158             :         // request special, multi-screen safe sprite canvas
    9159             :         // implementation (not DX5 canvas, as it cannot cope with
    9160             :         // surfaces spanning multiple displays). Note: canvas
    9161             :         // (without sprite) stays the same)
    9162             :         const sal_uInt32 nDisplay = static_cast< WinSalFrame* >( mpWindowImpl->mpFrame )->mnDisplay;
    9163             :         if( (nDisplay >= Application::GetScreenCount()) )
    9164             :         {
    9165             :             xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
    9166             :                                  bSpriteCanvas ?
    9167             :                                  OUString( "com.sun.star.rendering.SpriteCanvas.MultiScreen" ) :
    9168             :                                  OUString( "com.sun.star.rendering.Canvas.MultiScreen" ),
    9169             :                                  aArg,
    9170             :                                  xContext ),
    9171             :                              UNO_QUERY );
    9172             : 
    9173             :         }
    9174             :         else
    9175             :         {
    9176             : #endif
    9177           0 :             xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
    9178             :                              bSpriteCanvas ?
    9179             :                              OUString( "com.sun.star.rendering.SpriteCanvas" ) :
    9180             :                              OUString( "com.sun.star.rendering.Canvas" ),
    9181             :                              aArg,
    9182           0 :                              xContext ),
    9183           0 :                          UNO_QUERY );
    9184             : 
    9185             : #ifdef WNT
    9186             :         }
    9187             : #endif
    9188           0 :         mpWindowImpl->mxCanvas = xCanvas;
    9189             :     }
    9190             : 
    9191             :     // no factory??? Empty reference, then.
    9192           0 :     return xCanvas;
    9193             : }
    9194             : 
    9195           0 : uno::Reference< rendering::XCanvas > Window::GetCanvas() const
    9196             : {
    9197           0 :     return ImplGetCanvas( Size(), false, false );
    9198             : }
    9199             : 
    9200           0 : uno::Reference< rendering::XSpriteCanvas > Window::GetSpriteCanvas() const
    9201             : {
    9202             :     uno::Reference< rendering::XSpriteCanvas > xSpriteCanvas(
    9203           0 :         ImplGetCanvas( Size(), false, true ), uno::UNO_QUERY );
    9204           0 :     return xSpriteCanvas;
    9205             : }
    9206             : 
    9207           0 : void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rPos )
    9208             : {
    9209           0 :     bool bRVisible = mpWindowImpl->mbReallyVisible;
    9210           0 :     mpWindowImpl->mbReallyVisible = mpWindowImpl->mbVisible;
    9211           0 :     bool bDevOutput = mbDevOutput;
    9212           0 :     mbDevOutput = true;
    9213             : 
    9214           0 :     const OutputDevice *pOutDev = GetOutDev();
    9215           0 :     long nOldDPIX = pOutDev->ImplGetDPIX();
    9216           0 :     long nOldDPIY = pOutDev->ImplGetDPIY();
    9217           0 :     mnDPIX = i_pTargetOutDev->ImplGetDPIX();
    9218           0 :     mnDPIY = i_pTargetOutDev->ImplGetDPIY();
    9219           0 :     bool bOutput = IsOutputEnabled();
    9220           0 :     EnableOutput();
    9221             : 
    9222             :     DBG_ASSERT( GetMapMode().GetMapUnit() == MAP_PIXEL, "MapMode must be PIXEL based" );
    9223           0 :     if ( GetMapMode().GetMapUnit() != MAP_PIXEL )
    9224           0 :         return;
    9225             : 
    9226             :     // preserve graphicsstate
    9227           0 :     Push();
    9228           0 :     Region aClipRegion( GetClipRegion() );
    9229           0 :     SetClipRegion();
    9230             : 
    9231           0 :     GDIMetaFile* pOldMtf = GetConnectMetaFile();
    9232           0 :     GDIMetaFile aMtf;
    9233           0 :     SetConnectMetaFile( &aMtf );
    9234             : 
    9235             :     // put a push action to metafile
    9236           0 :     Push();
    9237             :     // copy graphics state to metafile
    9238           0 :     Font aCopyFont = GetFont();
    9239           0 :     if( nOldDPIX != mnDPIX || nOldDPIY != mnDPIY )
    9240             :     {
    9241           0 :         aCopyFont.SetHeight( aCopyFont.GetHeight() * mnDPIY / nOldDPIY );
    9242           0 :         aCopyFont.SetWidth( aCopyFont.GetWidth() * mnDPIX / nOldDPIX );
    9243             :     }
    9244           0 :     SetFont( aCopyFont );
    9245           0 :     SetTextColor( GetTextColor() );
    9246           0 :     if( IsLineColor() )
    9247           0 :         SetLineColor( GetLineColor() );
    9248             :     else
    9249           0 :         SetLineColor();
    9250           0 :     if( IsFillColor() )
    9251           0 :         SetFillColor( GetFillColor() );
    9252             :     else
    9253           0 :         SetFillColor();
    9254           0 :     if( IsTextLineColor() )
    9255           0 :         SetTextLineColor( GetTextLineColor() );
    9256             :     else
    9257           0 :         SetTextLineColor();
    9258           0 :     if( IsOverlineColor() )
    9259           0 :         SetOverlineColor( GetOverlineColor() );
    9260             :     else
    9261           0 :         SetOverlineColor();
    9262           0 :     if( IsTextFillColor() )
    9263           0 :         SetTextFillColor( GetTextFillColor() );
    9264             :     else
    9265           0 :         SetTextFillColor();
    9266           0 :     SetTextAlign( GetTextAlign() );
    9267           0 :     SetRasterOp( GetRasterOp() );
    9268           0 :     if( IsRefPoint() )
    9269           0 :         SetRefPoint( GetRefPoint() );
    9270             :     else
    9271           0 :         SetRefPoint();
    9272           0 :     SetLayoutMode( GetLayoutMode() );
    9273           0 :     SetDigitLanguage( GetDigitLanguage() );
    9274           0 :     Rectangle aPaintRect( Point( 0, 0 ), GetOutputSizePixel() );
    9275           0 :     aClipRegion.Intersect( aPaintRect );
    9276           0 :     SetClipRegion( aClipRegion );
    9277             : 
    9278             :     // do the actual paint
    9279             : 
    9280             :     // background
    9281           0 :     if( ! IsPaintTransparent() && IsBackground() && ! (GetParentClipMode() & PARENTCLIPMODE_NOCLIP ) )
    9282           0 :         Erase();
    9283             :     // foreground
    9284           0 :     Paint( aPaintRect );
    9285             :     // put a pop action to metafile
    9286           0 :     Pop();
    9287             : 
    9288           0 :     SetConnectMetaFile( pOldMtf );
    9289           0 :     EnableOutput( bOutput );
    9290           0 :     mpWindowImpl->mbReallyVisible = bRVisible;
    9291             : 
    9292             :     // paint metafile to VDev
    9293           0 :     VirtualDevice* pMaskedDevice = new VirtualDevice( *i_pTargetOutDev, 0, 0 );
    9294           0 :     pMaskedDevice->SetOutputSizePixel( GetOutputSizePixel() );
    9295           0 :     pMaskedDevice->EnableRTL( IsRTLEnabled() );
    9296           0 :     aMtf.WindStart();
    9297           0 :     aMtf.Play( pMaskedDevice );
    9298           0 :     BitmapEx aBmpEx( pMaskedDevice->GetBitmapEx( Point( 0, 0 ), pMaskedDevice->GetOutputSizePixel() ) );
    9299           0 :     i_pTargetOutDev->DrawBitmapEx( i_rPos, aBmpEx );
    9300             :     // get rid of virtual device now so they don't pile up during recursive calls
    9301           0 :     delete pMaskedDevice, pMaskedDevice = NULL;
    9302             : 
    9303           0 :     for( Window* pChild = mpWindowImpl->mpFirstChild; pChild; pChild = pChild->mpWindowImpl->mpNext )
    9304             :     {
    9305           0 :         if( pChild->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame && pChild->IsVisible() )
    9306             :         {
    9307           0 :             long nDeltaX = pChild->mnOutOffX - mnOutOffX;
    9308             : 
    9309           0 :             if( pOutDev->HasMirroredGraphics() )
    9310           0 :                 nDeltaX = mnOutWidth - nDeltaX - pChild->mnOutWidth;
    9311           0 :             long nDeltaY = pChild->GetOutOffYPixel() - GetOutOffYPixel();
    9312           0 :             Point aPos( i_rPos );
    9313           0 :             Point aDelta( nDeltaX, nDeltaY );
    9314           0 :             aPos += aDelta;
    9315           0 :             pChild->ImplPaintToDevice( i_pTargetOutDev, aPos );
    9316             :         }
    9317             :     }
    9318             : 
    9319             :     // restore graphics state
    9320           0 :     Pop();
    9321             : 
    9322           0 :     EnableOutput( bOutput );
    9323           0 :     mpWindowImpl->mbReallyVisible = bRVisible;
    9324           0 :     mbDevOutput = bDevOutput;
    9325           0 :     mnDPIX = nOldDPIX;
    9326           0 :     mnDPIY = nOldDPIY;
    9327             : }
    9328             : 
    9329           0 : void Window::PaintToDevice( OutputDevice* pDev, const Point& rPos, const Size& /*rSize*/ )
    9330             : {
    9331             :     // FIXME: scaling: currently this is for pixel copying only
    9332             : 
    9333             :     DBG_ASSERT( ! pDev->HasMirroredGraphics(), "PaintToDevice to mirroring graphics" );
    9334             :     DBG_ASSERT( ! pDev->IsRTLEnabled(), "PaintToDevice to mirroring device" );
    9335             : 
    9336           0 :     Window* pRealParent = NULL;
    9337           0 :     if( ! mpWindowImpl->mbVisible )
    9338             :     {
    9339           0 :         Window* pTempParent = ImplGetDefaultWindow();
    9340           0 :         if( pTempParent )
    9341           0 :             pTempParent->EnableChildTransparentMode();
    9342           0 :         pRealParent = GetParent();
    9343           0 :         SetParent( pTempParent );
    9344             :         // trigger correct visibility flags for children
    9345           0 :         Show();
    9346           0 :         Hide();
    9347             :     }
    9348             : 
    9349           0 :     bool bVisible = mpWindowImpl->mbVisible;
    9350           0 :     mpWindowImpl->mbVisible = true;
    9351             : 
    9352           0 :     if( mpWindowImpl->mpBorderWindow )
    9353           0 :         mpWindowImpl->mpBorderWindow->ImplPaintToDevice( pDev, rPos );
    9354             :     else
    9355           0 :         ImplPaintToDevice( pDev, rPos );
    9356             : 
    9357           0 :     mpWindowImpl->mbVisible = bVisible;
    9358             : 
    9359           0 :     if( pRealParent )
    9360           0 :         SetParent( pRealParent );
    9361           0 : }
    9362             : 
    9363           0 : OUString Window::GetSurroundingText() const
    9364             : {
    9365           0 :   return OUString();
    9366             : }
    9367             : 
    9368           0 : Selection Window::GetSurroundingTextSelection() const
    9369             : {
    9370           0 :   return Selection( 0, 0 );
    9371             : }
    9372             : 
    9373           0 : bool Window::UsePolyPolygonForComplexGradient()
    9374             : {
    9375           0 :     if ( meRasterOp != ROP_OVERPAINT )
    9376           0 :         return true;
    9377             : 
    9378           0 :     return false;
    9379           3 : }
    9380             : 
    9381             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10