LCOV - code coverage report
Current view: top level - vcl/source/window - window.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 3156 4797 65.8 %
Date: 2014-04-11 Functions: 240 325 73.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <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        8289 : ImplAccessibleInfos::ImplAccessibleInfos()
     126             : {
     127        8289 :     nAccessibleRole = 0xFFFF;
     128        8289 :     pAccessibleName = NULL;
     129        8289 :     pAccessibleDescription = NULL;
     130        8289 :     pLabeledByWindow = NULL;
     131        8289 :     pLabelForWindow = NULL;
     132        8289 :     pMemberOfWindow = NULL;
     133        8289 : }
     134             : 
     135        8261 : ImplAccessibleInfos::~ImplAccessibleInfos()
     136             : {
     137        8261 :     delete pAccessibleName;
     138        8261 :     delete pAccessibleDescription;
     139        8261 : }
     140             : 
     141      116939 : WindowImpl::WindowImpl( WindowType nType )
     142             : {
     143      116939 :     maZoom              = Fraction( 1, 1 );
     144      116939 :     maWinRegion         = Region(true);
     145      116939 :     maWinClipRegion     = Region(true);
     146      116939 :     mpWinData           = NULL;         // Extra Window Data, that we dont need for all windows
     147      116939 :     mpOverlapData       = NULL;         // Overlap Data
     148      116939 :     mpFrameData         = NULL;         // Frame Data
     149      116939 :     mpFrame             = NULL;         // Pointer to frame window
     150      116939 :     mpSysObj            = NULL;
     151      116939 :     mpFrameWindow       = NULL;         // window to top level parent (same as frame window)
     152      116939 :     mpOverlapWindow     = NULL;         // first overlap parent
     153      116939 :     mpBorderWindow      = NULL;         // Border-Window
     154      116939 :     mpClientWindow      = NULL;         // Client-Window of a FrameWindow
     155      116939 :     mpParent            = NULL;         // parent (inkl. BorderWindow)
     156      116939 :     mpRealParent        = NULL;         // real parent (exkl. BorderWindow)
     157      116939 :     mpFirstChild        = NULL;         // first child window
     158      116939 :     mpLastChild         = NULL;         // last child window
     159      116939 :     mpFirstOverlap      = NULL;         // first overlap window (only set in overlap windows)
     160      116939 :     mpLastOverlap       = NULL;         // last overlap window (only set in overlap windows)
     161      116939 :     mpPrev              = NULL;         // prev window
     162      116939 :     mpNext              = NULL;         // next window
     163      116939 :     mpNextOverlap       = NULL;         // next overlap window of frame
     164      116939 :     mpLastFocusWindow   = NULL;         // window for focus restore
     165      116939 :     mpDlgCtrlDownWindow = NULL;         // window for dialog control
     166      116939 :     mpFirstDel          = NULL;         // Dtor notification list
     167      116939 :     mpUserData          = NULL;         // user data
     168      116939 :     mpCursor            = NULL;         // cursor
     169      116939 :     mpControlFont       = NULL;         // font propertie
     170      116939 :     mpVCLXWindow        = NULL;
     171      116939 :     mpAccessibleInfos   = NULL;
     172      116939 :     maControlForeground = Color( COL_TRANSPARENT );     // no foreground set
     173      116939 :     maControlBackground = Color( COL_TRANSPARENT );     // no background set
     174      116939 :     mnLeftBorder        = 0;            // left border
     175      116939 :     mnTopBorder         = 0;            // top border
     176      116939 :     mnRightBorder       = 0;            // right border
     177      116939 :     mnBottomBorder      = 0;            // bottom border
     178      116939 :     mnWidthRequest      = -1;           // width request
     179      116939 :     mnHeightRequest     = -1;           // height request
     180      116939 :     mnX                 = 0;            // X-Position to Parent
     181      116939 :     mnY                 = 0;            // Y-Position to Parent
     182      116939 :     mnAbsScreenX        = 0;            // absolute X-position on screen, used for RTL window positioning
     183      116939 :     mpChildClipRegion   = NULL;         // Child-Clip-Region when ClipChildren
     184      116939 :     mpPaintRegion       = NULL;         // Paint-ClipRegion
     185      116939 :     mnStyle             = 0;            // style (init in ImplInitWindow)
     186      116939 :     mnPrevStyle         = 0;            // prevstyle (set in SetStyle)
     187      116939 :     mnExtendedStyle     = 0;            // extended style (init in ImplInitWindow)
     188      116939 :     mnPrevExtendedStyle = 0;            // prevstyle (set in SetExtendedStyle)
     189      116939 :     mnType              = nType;        // type
     190      116939 :     mnGetFocusFlags     = 0;            // Flags fuer GetFocus()-Aufruf
     191      116939 :     mnWaitCount         = 0;            // Wait-Count (>1 == Warte-MousePointer)
     192      116939 :     mnPaintFlags        = 0;            // Flags for ImplCallPaint
     193      116939 :     mnParentClipMode    = 0;            // Flags for Parent-ClipChildren-Mode
     194      116939 :     mnActivateMode      = 0;            // Will be converted in System/Overlap-Windows
     195      116939 :     mnDlgCtrlFlags      = 0;            // DialogControl-Flags
     196      116939 :     mnLockCount         = 0;            // LockCount
     197      116939 :     meAlwaysInputMode   = AlwaysInputNone; // neither AlwaysEnableInput nor AlwaysDisableInput called
     198      116939 :     meHalign            = VCL_ALIGN_FILL;
     199      116939 :     meValign            = VCL_ALIGN_FILL;
     200      116939 :     mePackType          = VCL_PACK_START;
     201      116939 :     mnPadding           = 0;
     202      116939 :     mnGridHeight        = 1;
     203      116939 :     mnGridLeftAttach    = -1;
     204      116939 :     mnGridTopAttach     = -1;
     205      116939 :     mnGridWidth         = 1;
     206      116939 :     mnBorderWidth       = 0;
     207      116939 :     mnMarginLeft        = 0;
     208      116939 :     mnMarginRight       = 0;
     209      116939 :     mnMarginTop         = 0;
     210      116939 :     mnMarginBottom      = 0;
     211      116939 :     mbFrame             = false;        // true: Window is a frame window
     212      116939 :     mbBorderWin         = false;        // true: Window is a border window
     213      116939 :     mbOverlapWin        = false;        // true: Window is a overlap window
     214      116939 :     mbSysWin            = false;        // true: SystemWindow is the base class
     215      116939 :     mbDialog            = false;        // true: Dialog is the base class
     216      116939 :     mbDockWin           = false;        // true: DockingWindow is the base class
     217      116939 :     mbFloatWin          = false;        // true: FloatingWindow is the base class
     218      116939 :     mbPushButton        = false;        // true: PushButton is the base class
     219      116939 :     mbToolBox           = false;      // true: ToolBox is the base class
     220      116939 :     mbMenuFloatingWindow= false;      // true: MenuFloatingWindow is the base class
     221      116939 :     mbToolbarFloatingWindow= false;       // true: ImplPopupFloatWin is the base class, used for subtoolbars
     222      116939 :     mbSplitter          = false;      // true: Splitter is the base class
     223      116939 :     mbVisible           = false;        // true: Show( sal_True ) called
     224      116939 :     mbOverlapVisible    = false;        // true: Hide called for visible window from ImplHideAllOverlapWindow()
     225      116939 :     mbDisabled          = false;        // true: Enable( sal_False ) called
     226      116939 :     mbInputDisabled     = false;        // true: EnableInput( sal_False ) called
     227      116939 :     mbDropDisabled      = false;        // true: Drop is enabled
     228      116939 :     mbNoUpdate          = false;        // true: SetUpdateMode( sal_False ) called
     229      116939 :     mbNoParentUpdate    = false;        // true: SetParentUpdateMode( sal_False ) called
     230      116939 :     mbActive            = false;        // true: Window Active
     231      116939 :     mbParentActive      = false;        // true: OverlapActive from Parent
     232      116939 :     mbReallyVisible     = false;        // true: this and all parents to an overlapped window are visible
     233      116939 :     mbReallyShown       = false;        // true: this and all parents to an overlapped window are shown
     234      116939 :     mbInInitShow        = false;        // true: we are in InitShow
     235      116939 :     mbChildNotify       = false;        // true: ChildNotify
     236      116939 :     mbChildPtrOverwrite = false;        // true: PointerStyle overwrites Child-Pointer
     237      116939 :     mbNoPtrVisible      = false;        // true: ShowPointer( sal_False ) called
     238      116939 :     mbMouseMove         = false;        // true: BaseMouseMove called
     239      116939 :     mbPaintFrame        = false;        // true: Paint is visible, but not painted
     240      116939 :     mbInPaint           = false;        // true: Inside PaintHdl
     241      116939 :     mbMouseButtonDown   = false;        // true: BaseMouseButtonDown called
     242      116939 :     mbMouseButtonUp     = false;        // true: BaseMouseButtonUp called
     243      116939 :     mbKeyInput          = false;        // true: BaseKeyInput called
     244      116939 :     mbKeyUp             = false;        // true: BaseKeyUp called
     245      116939 :     mbCommand           = false;        // true: BaseCommand called
     246      116939 :     mbDefPos            = true;         // true: Position is not Set
     247      116939 :     mbDefSize           = true;         // true: Size is not Set
     248      116939 :     mbCallMove          = true;         // true: Move must be called by Show
     249      116939 :     mbCallResize        = true;         // true: Resize must be called by Show
     250      116939 :     mbWaitSystemResize  = true;         // true: Wait for System-Resize
     251      116939 :     mbInitWinClipRegion = true;         // true: Calc Window Clip Region
     252      116939 :     mbInitChildRegion   = false;        // true: InitChildClipRegion
     253      116939 :     mbWinRegion         = false;        // true: Window Region
     254      116939 :     mbClipChildren      = false;        // true: Child-window should be clipped
     255      116939 :     mbClipSiblings      = false;        // true: Adjacent Child-window should be clipped
     256      116939 :     mbChildTransparent  = false;        // true: Child-windows are allowed to switch to transparent (incl. Parent-CLIPCHILDREN)
     257      116939 :     mbPaintTransparent  = false;        // true: Paints should be executed on the Parent
     258      116939 :     mbMouseTransparent  = false;        // true: Window is transparent for Mouse
     259      116939 :     mbDlgCtrlStart      = false;        // true: From here on own Dialog-Control
     260      116939 :     mbFocusVisible      = false;        // true: Focus Visible
     261      116939 :     mbUseNativeFocus    = false;
     262      116939 :     mbNativeFocusVisible= false;        // true: native Focus Visible
     263      116939 :     mbInShowFocus       = false;        // prevent recursion
     264      116939 :     mbInHideFocus       = false;        // prevent recursion
     265      116939 :     mbTrackVisible      = false;        // true: Tracking Visible
     266      116939 :     mbControlForeground = false;        // true: Foreground-Property set
     267      116939 :     mbControlBackground = false;        // true: Background-Property set
     268      116939 :     mbAlwaysOnTop       = false;        // true: always visible for all others windows
     269      116939 :     mbCompoundControl   = false;        // true: Composite Control => Listener...
     270      116939 :     mbCompoundControlHasFocus = false;  // true: Composite Control has focus somewhere
     271      116939 :     mbPaintDisabled     = false;        // true: Paint should not be executed
     272      116939 :     mbAllResize         = false;        // true: Also sent ResizeEvents with 0,0
     273      116939 :     mbInDtor            = false;        // true: We're still in Window-Dtor
     274      116939 :     mbExtTextInput      = false;        // true: ExtTextInput-Mode is active
     275      116939 :     mbInFocusHdl        = false;        // true: Within GetFocus-Handler
     276      116939 :     mbCreatedWithToolkit = false;
     277      116939 :     mbSuppressAccessibilityEvents = false; // true: do not send any accessibility events
     278      116939 :     mbDrawSelectionBackground = false;    // true: draws transparent window background to indicate (toolbox) selection
     279      116939 :     mbIsInTaskPaneList = false;           // true: window was added to the taskpanelist in the topmost system window
     280      116939 :     mnNativeBackground  = 0;              // initialize later, depends on type
     281      116939 :     mbCallHandlersDuringInputDisabled = false; // true: call event handlers even if input is disabled
     282      116939 :     mbHelpTextDynamic = false;          // true: append help id in HELP_DEBUG case
     283      116939 :     mbFakeFocusSet = false; // true: pretend as if the window has focus.
     284      116939 :     mbHexpand = false;
     285      116939 :     mbVexpand = false;
     286      116939 :     mbExpand = false;
     287      116939 :     mbFill = true;
     288      116939 :     mbSecondary = false;
     289      116939 :     mbNonHomogeneous = false;
     290      116939 : }
     291             : 
     292      232366 : WindowImpl::~WindowImpl()
     293             : {
     294      116183 :     delete mpChildClipRegion;
     295      116183 :     delete mpAccessibleInfos;
     296      116183 :     delete mpControlFont;
     297      116183 : }
     298             : 
     299             : // helper method to allow inline constructor even for pWindow!=NULL case
     300     3999601 : void ImplDelData::AttachToWindow( const Window* pWindow )
     301             : {
     302     3999601 :     if( pWindow )
     303     3999601 :         const_cast<Window*>(pWindow)->ImplAddDel( this );
     304     3999601 : }
     305             : 
     306             : // define dtor for ImplDelData
     307     5583792 : ImplDelData::~ImplDelData()
     308             : {
     309             :     // #112873# auto remove of ImplDelData
     310             :     // due to this code actively calling ImplRemoveDel() is not mandatory anymore
     311     5583792 :     if( !mbDel && mpWindow )
     312             :     {
     313             :         // the window still exists but we were not removed
     314     3999601 :         const_cast<Window*>(mpWindow)->ImplRemoveDel( this );
     315     3999601 :         mpWindow = NULL;
     316             :     }
     317     5583792 : }
     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      118762 : bool Window::ImplInitGraphics() const
     343             : {
     344             :     DBG_TESTSOLARMUTEX();
     345             : 
     346      118762 :     if ( mpGraphics )
     347           0 :         return true;
     348             : 
     349      118762 :     mbInitLineColor     = true;
     350      118762 :     mbInitFillColor     = true;
     351      118762 :     mbInitFont          = true;
     352      118762 :     mbInitTextColor     = true;
     353      118762 :     mbInitClipRegion    = true;
     354             : 
     355      118762 :     ImplSVData* pSVData = ImplGetSVData();
     356             : 
     357      118762 :     mpGraphics = mpWindowImpl->mpFrame->AcquireGraphics();
     358             :     // try harder if no wingraphics was available directly
     359      118762 :     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      118762 :     if ( mpGraphics )
     391             :     {
     392      118762 :         mpNextGraphics = pSVData->maGDIData.mpFirstWinGraphics;
     393      118762 :         pSVData->maGDIData.mpFirstWinGraphics = const_cast<Window*>(this);
     394      118762 :         if ( mpNextGraphics )
     395      118621 :             mpNextGraphics->mpPrevGraphics = const_cast<Window*>(this);
     396      118762 :         if ( !pSVData->maGDIData.mpLastWinGraphics )
     397         141 :             pSVData->maGDIData.mpLastWinGraphics = const_cast<Window*>(this);
     398             :     }
     399             : 
     400      118762 :     if ( mpGraphics )
     401             :     {
     402      118762 :         mpGraphics->SetXORMode( (ROP_INVERT == meRasterOp) || (ROP_XOR == meRasterOp), ROP_INVERT == meRasterOp );
     403      118762 :         mpGraphics->setAntiAliasB2DDraw(mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW);
     404             :     }
     405             : 
     406      118762 :     return mpGraphics ? true : false;
     407             : }
     408             : 
     409        6686 : void Window::EnableRTL ( bool bEnable )
     410             : {
     411        6686 :     StateChanged( STATE_CHANGE_MIRRORING );
     412        6686 :     OutputDevice::EnableRTL(bEnable);
     413        6686 : }
     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       72959 : void Window::ClipToPaintRegion(Rectangle& rDstRect)
     442             : {
     443       72959 :     const Region aPaintRgn(GetPaintRegion());
     444             : 
     445       72959 :     if (!aPaintRgn.IsNull())
     446       72953 :         rDstRect.Intersection(LogicToPixel(aPaintRgn.GetBoundRect()));
     447       72959 : }
     448             : 
     449      249930 : void Window::ImplReleaseGraphics( bool bRelease )
     450             : {
     451             :     DBG_TESTSOLARMUTEX();
     452             : 
     453      249930 :     if ( !mpGraphics )
     454      381799 :         return;
     455             : 
     456             :     // release the fonts of the physically released graphics device
     457      118061 :     if( bRelease )
     458      118061 :         ImplReleaseFonts();
     459             : 
     460      118061 :     ImplSVData* pSVData = ImplGetSVData();
     461             : 
     462      118061 :     Window* pWindow = (Window*)this;
     463             : 
     464      118061 :     if ( bRelease )
     465      118061 :         pWindow->mpWindowImpl->mpFrame->ReleaseGraphics( mpGraphics );
     466             :     // remove from global LRU list of window graphics
     467      118061 :     if ( mpPrevGraphics )
     468       99993 :         mpPrevGraphics->mpNextGraphics = mpNextGraphics;
     469             :     else
     470       18068 :         pSVData->maGDIData.mpFirstWinGraphics = mpNextGraphics;
     471      118061 :     if ( mpNextGraphics )
     472      117955 :         mpNextGraphics->mpPrevGraphics = mpPrevGraphics;
     473             :     else
     474         106 :         pSVData->maGDIData.mpLastWinGraphics = mpPrevGraphics;
     475             : 
     476      118061 :     mpGraphics      = NULL;
     477      118061 :     mpPrevGraphics  = NULL;
     478      118061 :     mpNextGraphics  = NULL;
     479             : }
     480             : 
     481      377651 : bool Window::HasMirroredGraphics() const
     482             : {
     483      377651 :     const OutputDevice* pOutDev = GetOutDev();
     484      377651 :     return pOutDev->OutputDevice::HasMirroredGraphics();
     485             : }
     486             : 
     487         118 : void Window::ImplInitAppFontData( Window* pWindow )
     488             : {
     489         118 :     ImplSVData* pSVData = ImplGetSVData();
     490         118 :     long nTextHeight = pWindow->GetTextHeight();
     491         118 :     long nTextWidth = pWindow->approximate_char_width() * 8;
     492         118 :     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         118 :     if ( nSymHeight > nTextWidth )
     498           0 :         nTextWidth = nSymHeight;
     499         118 :     else if ( nSymHeight+5 > nTextWidth )
     500           0 :         nTextWidth = nSymHeight+5;
     501         118 :     pSVData->maGDIData.mnAppFontX = nTextWidth * 10 / 8;
     502         118 :     pSVData->maGDIData.mnAppFontY = nTextHeight * 10;
     503             : 
     504             :     // FIXME: this is currently only on OS X, check with other
     505             :     // platforms
     506         118 :     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         118 :     pSVData->maGDIData.mnRealAppFontX = pSVData->maGDIData.mnAppFontX;
     527         118 :     if ( pSVData->maAppData.mnDialogScaleX )
     528         116 :         pSVData->maGDIData.mnAppFontX += (pSVData->maGDIData.mnAppFontX*pSVData->maAppData.mnDialogScaleX)/100;
     529         118 : }
     530             : 
     531         534 : bool Window::ImplCheckUIFont( const Font& rFont )
     532             : {
     533         534 :     if( ImplGetSVData()->maGDIData.mbNativeFontConfig )
     534         427 :         return true;
     535             : 
     536             :     // create a text string using the localized text of important buttons
     537         107 :     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         107 :     const int nTestButtonCount = SAL_N_ELEMENTS(aTestButtons);
     546        1177 :     for( int n = 0; n < nTestButtonCount; ++n )
     547             :     {
     548        1070 :         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        1070 :         const sal_Int32 nLen = aButtonStr.getLength();
     552        1070 :         bool bInside = false;
     553        6634 :         for( int i = 0; i < nLen; ++i ) {
     554        5564 :             const sal_Unicode c = aButtonStr[ i ];
     555        5564 :             if( (c == '('))
     556           0 :                 bInside = true;
     557        5564 :             if( (c == ')'))
     558           0 :                 bInside = false;
     559        5564 :             if( (c == '~')
     560        4494 :             ||  (c == '(') || (c == ')')
     561        4494 :             || ((c >= 'A') && (c <= 'Z') && bInside) )
     562        1070 :                 aButtonStr = aButtonStr.replaceAt( i, 1, " " );
     563             :         }
     564             :         // append sanitized button text to test string
     565        1070 :         aTestText += aButtonStr;
     566        1070 :     }
     567             : 
     568         107 :     const bool bUIFontOk = ( HasGlyphs( rFont, aTestText ) == -1 );
     569         107 :     return bUIFontOk;
     570             : }
     571             : 
     572         534 : void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, bool bCallHdl )
     573             : {
     574         534 :     StyleSettings aTmpSt( rSettings.GetStyleSettings() );
     575         534 :     aTmpSt.SetHighContrastMode( false );
     576         534 :     rSettings.SetStyleSettings( aTmpSt );
     577         534 :     ImplGetFrame()->UpdateSettings( rSettings );
     578             :     // reset default border width for layouters
     579         534 :     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        1068 :     OUString aUserInterfaceFont;
     586         534 :     bool bUseSystemFont = rSettings.GetStyleSettings().GetUseSystemUIFonts();
     587             : 
     588             :     // check whether system UI font can display a typical UI text
     589         534 :     if( bUseSystemFont )
     590         534 :         bUseSystemFont = ImplCheckUIFont( rSettings.GetStyleSettings().GetAppFont() );
     591             : 
     592         534 :     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         534 :     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        1068 :     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         534 :     int maxFontheight = 9; // #107886#: 9 is default for some asian systems, so always allow if requested
     667         534 :     if( GetDesktopRectPixel().getHeight() > 600 )
     668         534 :         maxFontheight = (int) ((( 8.0 * (double) GetDesktopRectPixel().getHeight()) / 600.0) + 1.5);
     669             : 
     670        1068 :     Font aFont = aStyleSettings.GetMenuFont();
     671         534 :     int defFontheight = aFont.GetHeight();
     672         534 :     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         534 :     bool bBrokenLangFontHeight = MsLangId::isCJK(Application::GetSettings().GetUILanguageTag().getLanguageType());
     679         534 :     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         534 :     int toolfontheight = defFontheight;
     684         534 :     if( toolfontheight > 9 )
     685           0 :         toolfontheight = (defFontheight+8) / 2;
     686             : 
     687         534 :     aFont = aStyleSettings.GetAppFont();
     688         534 :     aFont.SetHeight( defFontheight );
     689         534 :     aStyleSettings.SetAppFont( aFont );
     690         534 :     aFont = aStyleSettings.GetTitleFont();
     691         534 :     aFont.SetHeight( defFontheight );
     692         534 :     aStyleSettings.SetTitleFont( aFont );
     693         534 :     aFont = aStyleSettings.GetFloatTitleFont();
     694         534 :     aFont.SetHeight( defFontheight );
     695         534 :     aStyleSettings.SetFloatTitleFont( aFont );
     696             :     // keep menu and help font size from system unless in broken locale size
     697         534 :     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         534 :     aFont = aStyleSettings.GetToolFont();
     715         534 :     aFont.SetHeight( toolfontheight );
     716         534 :     aStyleSettings.SetToolFont( aFont );
     717             : 
     718         534 :     aFont = aStyleSettings.GetLabelFont();
     719         534 :     aFont.SetHeight( defFontheight );
     720         534 :     aStyleSettings.SetLabelFont( aFont );
     721         534 :     aFont = aStyleSettings.GetInfoFont();
     722         534 :     aFont.SetHeight( defFontheight );
     723         534 :     aStyleSettings.SetInfoFont( aFont );
     724         534 :     aFont = aStyleSettings.GetRadioCheckFont();
     725         534 :     aFont.SetHeight( defFontheight );
     726         534 :     aStyleSettings.SetRadioCheckFont( aFont );
     727         534 :     aFont = aStyleSettings.GetPushButtonFont();
     728         534 :     aFont.SetHeight( defFontheight );
     729         534 :     aStyleSettings.SetPushButtonFont( aFont );
     730         534 :     aFont = aStyleSettings.GetFieldFont();
     731         534 :     aFont.SetHeight( defFontheight );
     732         534 :     aStyleSettings.SetFieldFont( aFont );
     733         534 :     aFont = aStyleSettings.GetIconFont();
     734         534 :     aFont.SetHeight( defFontheight );
     735         534 :     aStyleSettings.SetIconFont( aFont );
     736         534 :     aFont = aStyleSettings.GetGroupFont();
     737         534 :     aFont.SetHeight( defFontheight );
     738         534 :     aStyleSettings.SetGroupFont( aFont );
     739             : 
     740         534 :     rSettings.SetStyleSettings( aStyleSettings );
     741             : 
     742         534 :     bool bForceHCMode = false;
     743             : 
     744             :     // auto detect HC mode; if the system already set it to "yes"
     745             :     // (see above) then accept that
     746         534 :     if( !rSettings.GetStyleSettings().GetHighContrastMode() )
     747             :     {
     748         534 :         bool bTmp = false, bAutoHCMode = true;
     749             :         utl::OConfigurationNode aNode = utl::OConfigurationTreeRoot::tryCreateWithComponentContext(
     750             :             comphelper::getProcessComponentContext(),
     751         534 :             OUString("org.openoffice.Office.Common/Accessibility") );    // note: case sensitive !
     752         534 :         if ( aNode.isValid() )
     753             :         {
     754         534 :             ::com::sun::star::uno::Any aValue = aNode.getNodeValue( OUString("AutoDetectSystemHC") );
     755         534 :             if( aValue >>= bTmp )
     756         534 :                 bAutoHCMode = bTmp;
     757             :         }
     758         534 :         if( bAutoHCMode )
     759             :         {
     760           0 :             if( rSettings.GetStyleSettings().GetFaceColor().IsDark() ||
     761           0 :                 rSettings.GetStyleSettings().GetWindowColor().IsDark() )
     762           0 :                 bForceHCMode = true;
     763         534 :         }
     764             :     }
     765             : 
     766         534 :     static const char* pEnvHC = getenv( "SAL_FORCE_HC" );
     767         534 :     if( pEnvHC && *pEnvHC )
     768           0 :         bForceHCMode = true;
     769             : 
     770         534 :     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         534 :     if ( bCallHdl )
     809         660 :         GetpApp()->OverrideSystemSettings( rSettings );
     810         534 : }
     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      116939 : 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      116939 :     mpOutputDevice = (OutputDevice*)this;
     835             : 
     836      116939 :     mpWindowImpl = new WindowImpl( nType );
     837             : 
     838      116939 :     meOutDevType        = OUTDEV_WINDOW;
     839             : 
     840      116939 :     mbEnableRTL         = Application::GetSettings().GetLayoutRTL();         // true: this outdev will be mirrored if RTL window layout (UI mirroring) is globally active
     841      116939 : }
     842             : 
     843      231202 : 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      231202 :     return false;
     854             : #endif
     855             : }
     856             : 
     857      117271 : static sal_Int32 CountDPIScaleFactor(sal_Int32 nDPI)
     858             : {
     859      117271 :     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      117271 :     if (nDPI > 168)
     868           0 :         nResult = std::max(sal_Int32(1), (nDPI + 48) / 96);
     869             : #else
     870             :     (void)nDPI;
     871             : #endif
     872             : 
     873      117271 :     return nResult;
     874             : }
     875             : 
     876      116939 : void Window::ImplInit( Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData )
     877             : {
     878             :     DBG_ASSERT( mpWindowImpl->mbFrame || pParent, "Window::Window(): pParent == NULL" );
     879             : 
     880      116939 :     ImplSVData* pSVData = ImplGetSVData();
     881      116939 :     Window*     pRealParent = pParent;
     882             : 
     883             :     // 3D-Look vererben
     884      116939 :     if ( !mpWindowImpl->mbOverlapWin && pParent && (pParent->GetStyle() & WB_3DLOOK) )
     885       54303 :         nStyle |= WB_3DLOOK;
     886             : 
     887             :     // create border window if necessary
     888      116939 :     if ( !mpWindowImpl->mbFrame && !mpWindowImpl->mbBorderWin && !mpWindowImpl->mpBorderWindow
     889      105366 :          && (nStyle & (WB_BORDER | WB_SYSTEMCHILDWINDOW) ) )
     890             :     {
     891        6976 :         sal_uInt16 nBorderTypeStyle = 0;
     892        6976 :         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        6976 :         ImplBorderWindow* pBorderWin = new ImplBorderWindow( pParent, nStyle & (WB_BORDER | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_NEEDSFOCUS), nBorderTypeStyle );
     902        6976 :         ((Window*)pBorderWin)->mpWindowImpl->mpClientWindow = this;
     903        6976 :         pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
     904        6976 :         mpWindowImpl->mpBorderWindow  = pBorderWin;
     905        6976 :         pParent = mpWindowImpl->mpBorderWindow;
     906             :     }
     907      109963 :     else if( !mpWindowImpl->mbFrame && ! pParent )
     908             :     {
     909           4 :         mpWindowImpl->mbOverlapWin  = true;
     910           4 :         mpWindowImpl->mbFrame = true;
     911             :     }
     912             : 
     913             :     // insert window in list
     914      116939 :     ImplInsertWindow( pParent );
     915      116939 :     mpWindowImpl->mnStyle = nStyle;
     916             : 
     917             :     // Overlap-Window-Data
     918      116939 :     if ( mpWindowImpl->mbOverlapWin )
     919             :     {
     920        4601 :         mpWindowImpl->mpOverlapData                   = new ImplOverlapData;
     921        4601 :         mpWindowImpl->mpOverlapData->mpSaveBackDev    = NULL;
     922        4601 :         mpWindowImpl->mpOverlapData->mpSaveBackRgn    = NULL;
     923        4601 :         mpWindowImpl->mpOverlapData->mpNextBackWin    = NULL;
     924        4601 :         mpWindowImpl->mpOverlapData->mnSaveBackSize   = 0;
     925        4601 :         mpWindowImpl->mpOverlapData->mbSaveBack       = false;
     926        4601 :         mpWindowImpl->mpOverlapData->mnTopLevel       = 1;
     927             :     }
     928             : 
     929      116939 :     if( pParent && ! mpWindowImpl->mbFrame )
     930      112338 :         mbEnableRTL = Application::GetSettings().GetLayoutRTL();
     931             : 
     932             :     // test for frame creation
     933      116939 :     if ( mpWindowImpl->mbFrame )
     934             :     {
     935             :         // create frame
     936        4601 :         sal_uLong nFrameStyle = 0;
     937             : 
     938        4601 :         if ( nStyle & WB_MOVEABLE )
     939        2174 :             nFrameStyle |= SAL_FRAME_STYLE_MOVEABLE;
     940        4601 :         if ( nStyle & WB_SIZEABLE )
     941        2153 :             nFrameStyle |= SAL_FRAME_STYLE_SIZEABLE;
     942        4601 :         if ( nStyle & WB_CLOSEABLE )
     943        4454 :             nFrameStyle |= SAL_FRAME_STYLE_CLOSEABLE;
     944        4601 :         if ( nStyle & WB_APP )
     945           0 :             nFrameStyle |= SAL_FRAME_STYLE_DEFAULT;
     946             :         // check for undecorated floating window
     947        4601 :         if( // 1. floating windows that are not moveable/sizeable (only closeable allowed)
     948        7028 :             ( !(nFrameStyle & ~SAL_FRAME_STYLE_CLOSEABLE) &&
     949       11629 :             ( mpWindowImpl->mbFloatWin || ((GetType() == WINDOW_BORDERWINDOW) && ((ImplBorderWindow*)this)->mbFloatWindow) || (nStyle & WB_SYSTEMFLOATWIN) ) ) ||
     950             :             // 2. borderwindows of floaters with ownerdraw decoration
     951        4614 :             ( ((GetType() == WINDOW_BORDERWINDOW) && ((ImplBorderWindow*)this)->mbFloatWindow && (nStyle & WB_OWNERDRAWDECORATION) ) ) )
     952             :         {
     953        2280 :             nFrameStyle = SAL_FRAME_STYLE_FLOAT;
     954        2280 :             if( nStyle & WB_OWNERDRAWDECORATION )
     955           0 :                 nFrameStyle |= (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_NOSHADOW);
     956        2280 :             if( nStyle & WB_NEEDSFOCUS )
     957           0 :                 nFrameStyle |= SAL_FRAME_STYLE_FLOAT_FOCUSABLE;
     958             :         }
     959        2321 :         else if( mpWindowImpl->mbFloatWin )
     960          17 :             nFrameStyle |= SAL_FRAME_STYLE_TOOLWINDOW;
     961             : 
     962        4601 :         if( nStyle & WB_INTROWIN )
     963           0 :             nFrameStyle |= SAL_FRAME_STYLE_INTRO;
     964        4601 :         if( nStyle & WB_TOOLTIPWIN )
     965           0 :             nFrameStyle |= SAL_FRAME_STYLE_TOOLTIP;
     966             : 
     967        4601 :         if( nStyle & WB_NOSHADOW )
     968        2272 :             nFrameStyle |= SAL_FRAME_STYLE_NOSHADOW;
     969             : 
     970        4601 :         if( nStyle & WB_SYSTEMCHILDWINDOW )
     971           0 :             nFrameStyle |= SAL_FRAME_STYLE_SYSTEMCHILD;
     972             : 
     973        4601 :         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           7 :                 nFrameStyle |= SAL_FRAME_STYLE_DIALOG;
     985             :             default:
     986        4601 :                 break;
     987             :         }
     988             : 
     989        4601 :         SalFrame* pParentFrame = NULL;
     990        4601 :         if ( pParent )
     991        2300 :             pParentFrame = pParent->mpWindowImpl->mpFrame;
     992             :         SalFrame* pFrame;
     993        4601 :         if ( pSystemParentData )
     994           0 :             pFrame = pSVData->mpDefInst->CreateChildFrame( pSystemParentData, nFrameStyle | SAL_FRAME_STYLE_PLUG );
     995             :         else
     996        4601 :             pFrame = pSVData->mpDefInst->CreateFrame( pParentFrame, nFrameStyle );
     997        4601 :         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        4601 :         pFrame->SetCallback( this, ImplWindowFrameProc );
    1006             : 
    1007             :         // set window frame data
    1008        4601 :         mpWindowImpl->mpFrameData     = new ImplFrameData;
    1009        4601 :         mpWindowImpl->mpFrame         = pFrame;
    1010        4601 :         mpWindowImpl->mpFrameWindow   = this;
    1011        4601 :         mpWindowImpl->mpOverlapWindow = this;
    1012             : 
    1013             :         // set frame data
    1014        4601 :         mpWindowImpl->mpFrameData->mpNextFrame        = pSVData->maWinData.mpFirstFrame;
    1015        4601 :         pSVData->maWinData.mpFirstFrame = this;
    1016        4601 :         mpWindowImpl->mpFrameData->mpFirstOverlap     = NULL;
    1017        4601 :         mpWindowImpl->mpFrameData->mpFocusWin         = NULL;
    1018        4601 :         mpWindowImpl->mpFrameData->mpMouseMoveWin     = NULL;
    1019        4601 :         mpWindowImpl->mpFrameData->mpMouseDownWin     = NULL;
    1020        4601 :         mpWindowImpl->mpFrameData->mpFirstBackWin     = NULL;
    1021        4601 :         mpWindowImpl->mpFrameData->mpFontCollection   = pSVData->maGDIData.mpScreenFontList;
    1022        4601 :         mpWindowImpl->mpFrameData->mpFontCache        = pSVData->maGDIData.mpScreenFontCache;
    1023        4601 :         mpWindowImpl->mpFrameData->mnAllSaveBackSize  = 0;
    1024        4601 :         mpWindowImpl->mpFrameData->mnFocusId          = 0;
    1025        4601 :         mpWindowImpl->mpFrameData->mnMouseMoveId      = 0;
    1026        4601 :         mpWindowImpl->mpFrameData->mnLastMouseX       = -1;
    1027        4601 :         mpWindowImpl->mpFrameData->mnLastMouseY       = -1;
    1028        4601 :         mpWindowImpl->mpFrameData->mnBeforeLastMouseX = -1;
    1029        4601 :         mpWindowImpl->mpFrameData->mnBeforeLastMouseY = -1;
    1030        4601 :         mpWindowImpl->mpFrameData->mnFirstMouseX      = -1;
    1031        4601 :         mpWindowImpl->mpFrameData->mnFirstMouseY      = -1;
    1032        4601 :         mpWindowImpl->mpFrameData->mnLastMouseWinX    = -1;
    1033        4601 :         mpWindowImpl->mpFrameData->mnLastMouseWinY    = -1;
    1034        4601 :         mpWindowImpl->mpFrameData->mnModalMode        = 0;
    1035        4601 :         mpWindowImpl->mpFrameData->mnMouseDownTime    = 0;
    1036        4601 :         mpWindowImpl->mpFrameData->mnClickCount       = 0;
    1037        4601 :         mpWindowImpl->mpFrameData->mnFirstMouseCode   = 0;
    1038        4601 :         mpWindowImpl->mpFrameData->mnMouseCode        = 0;
    1039        4601 :         mpWindowImpl->mpFrameData->mnMouseMode        = 0;
    1040        4601 :         mpWindowImpl->mpFrameData->meMapUnit          = MAP_PIXEL;
    1041        4601 :         mpWindowImpl->mpFrameData->mbHasFocus         = false;
    1042        4601 :         mpWindowImpl->mpFrameData->mbInMouseMove      = false;
    1043        4601 :         mpWindowImpl->mpFrameData->mbMouseIn          = false;
    1044        4601 :         mpWindowImpl->mpFrameData->mbStartDragCalled  = false;
    1045        4601 :         mpWindowImpl->mpFrameData->mbNeedSysWindow    = false;
    1046        4601 :         mpWindowImpl->mpFrameData->mbMinimized        = false;
    1047        4601 :         mpWindowImpl->mpFrameData->mbStartFocusState  = false;
    1048        4601 :         mpWindowImpl->mpFrameData->mbInSysObjFocusHdl = false;
    1049        4601 :         mpWindowImpl->mpFrameData->mbInSysObjToTopHdl = false;
    1050        4601 :         mpWindowImpl->mpFrameData->mbSysObjFocus      = false;
    1051        4601 :         if (!ImplDoTiledRendering())
    1052             :         {
    1053        4601 :             mpWindowImpl->mpFrameData->maPaintTimer.SetTimeout( 30 );
    1054        4601 :             mpWindowImpl->mpFrameData->maPaintTimer.SetTimeoutHdl( LINK( this, Window, ImplHandlePaintHdl ) );
    1055             :         }
    1056        4601 :         mpWindowImpl->mpFrameData->maResizeTimer.SetTimeout( 50 );
    1057        4601 :         mpWindowImpl->mpFrameData->maResizeTimer.SetTimeoutHdl( LINK( this, Window, ImplHandleResizeTimerHdl ) );
    1058        4601 :         mpWindowImpl->mpFrameData->mbInternalDragGestureRecognizer = false;
    1059             : 
    1060        4601 :         if ( pRealParent && IsTopWindow() )
    1061             :         {
    1062          19 :             ImplWinData* pParentWinData = pRealParent->ImplGetWinData();
    1063          19 :             pParentWinData->maTopWindowChildren.push_back( this );
    1064             :         }
    1065             :     }
    1066             : 
    1067             :     // init data
    1068      116939 :     mpWindowImpl->mpRealParent = pRealParent;
    1069             : 
    1070             :     // #99318: make sure fontcache and list is available before call to SetSettings
    1071      116939 :     mpFontCollection      = mpWindowImpl->mpFrameData->mpFontCollection;
    1072      116939 :     mpFontCache     = mpWindowImpl->mpFrameData->mpFontCache;
    1073             : 
    1074      116939 :     if ( mpWindowImpl->mbFrame )
    1075             :     {
    1076        4601 :         if ( pParent )
    1077             :         {
    1078        2300 :             mpWindowImpl->mpFrameData->mnDPIX     = pParent->mpWindowImpl->mpFrameData->mnDPIX;
    1079        2300 :             mpWindowImpl->mpFrameData->mnDPIY     = pParent->mpWindowImpl->mpFrameData->mnDPIY;
    1080             :         }
    1081             :         else
    1082             :         {
    1083        2301 :             OutputDevice *pOutDev = GetOutDev();
    1084        2301 :             if ( pOutDev->ImplGetGraphics() )
    1085             :             {
    1086        2301 :                 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        4601 :         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        4758 :         if ( !pSVData->maAppData.mbSettingsInit &&
    1098         157 :              ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN))
    1099             :              )
    1100             :         {
    1101             :             // side effect: ImplUpdateGlobalSettings does an ImplGetFrame()->UpdateSettings
    1102          42 :             ImplUpdateGlobalSettings( *pSVData->maAppData.mpSettings );
    1103          42 :             OutputDevice::SetSettings( *pSVData->maAppData.mpSettings );
    1104          42 :             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        4601 :         if ( nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_APP) )
    1111        2174 :             mpWindowImpl->mpFrame->GetClientSize( mnOutWidth, mnOutHeight );
    1112             :     }
    1113             :     else
    1114             :     {
    1115      112338 :         if ( pParent )
    1116             :         {
    1117      112338 :             if ( !ImplIsOverlapWindow() )
    1118             :             {
    1119      112338 :                 mpWindowImpl->mbDisabled          = pParent->mpWindowImpl->mbDisabled;
    1120      112338 :                 mpWindowImpl->mbInputDisabled     = pParent->mpWindowImpl->mbInputDisabled;
    1121      112338 :                 mpWindowImpl->meAlwaysInputMode   = pParent->mpWindowImpl->meAlwaysInputMode;
    1122             :             }
    1123             : 
    1124      112338 :             OutputDevice::SetSettings( pParent->GetSettings() );
    1125             :         }
    1126             : 
    1127             :     }
    1128             : 
    1129             :     // setup the scale factor for Hi-DPI displays
    1130      116939 :     mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
    1131             : 
    1132      116939 :     const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
    1133      116939 :     sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
    1134      116939 :     mnDPIX          = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
    1135      116939 :     mnDPIY          = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
    1136      116939 :     maFont          = rStyleSettings.GetAppFont();
    1137      116939 :     ImplPointToLogic( maFont );
    1138             : 
    1139      116939 :     if ( nStyle & WB_3DLOOK )
    1140             :     {
    1141       83417 :         SetTextColor( rStyleSettings.GetButtonTextColor() );
    1142       83417 :         SetBackground( Wallpaper( rStyleSettings.GetFaceColor() ) );
    1143             :     }
    1144             :     else
    1145             :     {
    1146       33522 :         SetTextColor( rStyleSettings.GetWindowTextColor() );
    1147       33522 :         SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
    1148             :     }
    1149             : 
    1150      116939 :     ImplUpdatePos();
    1151             : 
    1152             :     // calculate app font res (except for the Intro Window or the default window)
    1153      116939 :     if ( mpWindowImpl->mbFrame && !pSVData->maGDIData.mnAppFontX && ! (nStyle & (WB_INTROWIN|WB_DEFAULTWIN)) )
    1154          98 :         ImplInitAppFontData( this );
    1155             : 
    1156      116939 :     if ( GetAccessibleParentWindow()  && GetParent() != Application::GetDefDialogParent() )
    1157      101216 :         GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDCREATED, this );
    1158      116939 : }
    1159             : 
    1160       14288 : void Window::ImplSetFrameParent( const Window* pParent )
    1161             : {
    1162       14288 :     Window* pFrameWindow = ImplGetSVData()->maWinData.mpFirstFrame;
    1163       92850 :     while( pFrameWindow )
    1164             :     {
    1165             :         // search all frames that are children of this window
    1166             :         // and reparent them
    1167       64274 :         if( ImplIsRealParentPath( pFrameWindow ) )
    1168             :         {
    1169             :             DBG_ASSERT( mpWindowImpl->mpFrame != pFrameWindow->mpWindowImpl->mpFrame, "SetFrameParent to own" );
    1170             :             DBG_ASSERT( mpWindowImpl->mpFrame, "no frame" );
    1171        2446 :             SalFrame* pParentFrame = pParent ? pParent->mpWindowImpl->mpFrame : NULL;
    1172        2446 :             pFrameWindow->mpWindowImpl->mpFrame->SetParent( pParentFrame );
    1173             :         }
    1174       64274 :         pFrameWindow = pFrameWindow->mpWindowImpl->mpFrameData->mpNextFrame;
    1175             :     }
    1176       14288 : }
    1177             : 
    1178      127371 : void Window::ImplInsertWindow( Window* pParent )
    1179             : {
    1180      127371 :     mpWindowImpl->mpParent            = pParent;
    1181      127371 :     mpWindowImpl->mpRealParent        = pParent;
    1182             : 
    1183      127371 :     if ( pParent && !mpWindowImpl->mbFrame )
    1184             :     {
    1185             :         // search frame window and set window frame data
    1186      122760 :         Window* pFrameParent = pParent->mpWindowImpl->mpFrameWindow;
    1187      122760 :         mpWindowImpl->mpFrameData     = pFrameParent->mpWindowImpl->mpFrameData;
    1188      122760 :         mpWindowImpl->mpFrame         = pFrameParent->mpWindowImpl->mpFrame;
    1189      122760 :         mpWindowImpl->mpFrameWindow   = pFrameParent;
    1190      122760 :         mpWindowImpl->mbFrame         = false;
    1191             : 
    1192             :         // search overlap window and insert window in list
    1193      122760 :         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      122760 :             if ( pParent->ImplIsOverlapWindow() )
    1214        6852 :                 mpWindowImpl->mpOverlapWindow = pParent;
    1215             :             else
    1216      115908 :                 mpWindowImpl->mpOverlapWindow = pParent->mpWindowImpl->mpOverlapWindow;
    1217      122760 :             mpWindowImpl->mpPrev = pParent->mpWindowImpl->mpLastChild;
    1218      122760 :             pParent->mpWindowImpl->mpLastChild = this;
    1219      122760 :             if ( !pParent->mpWindowImpl->mpFirstChild )
    1220       38542 :                 pParent->mpWindowImpl->mpFirstChild = this;
    1221             :             else
    1222       84218 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    1223             :         }
    1224             :     }
    1225      127371 : }
    1226             : 
    1227      126615 : void Window::ImplRemoveWindow( bool bRemoveFrameData )
    1228             : {
    1229             :     // remove window from the lists
    1230      126615 :     if ( !mpWindowImpl->mbFrame )
    1231             :     {
    1232      122081 :         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      122081 :             if ( mpWindowImpl->mpPrev )
    1256       53257 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    1257       68824 :             else if ( mpWindowImpl->mpParent )
    1258       68824 :                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
    1259      122081 :             if ( mpWindowImpl->mpNext )
    1260       56275 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    1261       65806 :             else if ( mpWindowImpl->mpParent )
    1262       65806 :                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
    1263             :         }
    1264             : 
    1265      122081 :         mpWindowImpl->mpPrev = NULL;
    1266      122081 :         mpWindowImpl->mpNext = NULL;
    1267             :     }
    1268             : 
    1269      126615 :     if ( bRemoveFrameData )
    1270             :     {
    1271             :         // release the graphic
    1272      121891 :         OutputDevice *pOutDev = GetOutDev();
    1273      121891 :         pOutDev->ImplReleaseGraphics();
    1274             :     }
    1275      126615 : }
    1276             : 
    1277          22 : void Window::reorderWithinParent(sal_uInt16 nNewPosition)
    1278             : {
    1279          22 :     sal_uInt16 nChildCount = 0;
    1280          22 :     Window *pSource = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild;
    1281         102 :     while (pSource)
    1282             :     {
    1283          80 :         if (nChildCount == nNewPosition)
    1284          22 :             break;
    1285          58 :         pSource = pSource->mpWindowImpl->mpNext;
    1286          58 :         nChildCount++;
    1287             :     }
    1288             : 
    1289          22 :     if (pSource == this) //already at the right place
    1290          44 :         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      150166 : void Window::ImplCallResize()
    1310             : {
    1311      150166 :     mpWindowImpl->mbCallResize = false;
    1312             : 
    1313      150166 :     if( GetBackground().IsGradient() )
    1314       26271 :         Invalidate();
    1315             : 
    1316      150166 :     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      150166 :     ImplCallEventListeners( VCLEVENT_WINDOW_RESIZE );
    1321      150166 : }
    1322             : 
    1323      168004 : void Window::ImplCallMove()
    1324             : {
    1325      168004 :     mpWindowImpl->mbCallMove = false;
    1326             : 
    1327      168004 :     if( mpWindowImpl->mbFrame )
    1328             :     {
    1329             :         // update frame position
    1330        2084 :         SalFrame *pParentFrame = NULL;
    1331        2084 :         Window *pParent = ImplGetParent();
    1332        4168 :         while( pParent )
    1333             :         {
    1334          28 :             if( pParent->mpWindowImpl->mpFrame != mpWindowImpl->mpFrame )
    1335             :             {
    1336          28 :                 pParentFrame = pParent->mpWindowImpl->mpFrame;
    1337          28 :                 break;
    1338             :             }
    1339           0 :             pParent = pParent->GetParent();
    1340             :         }
    1341             : 
    1342        2084 :         SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    1343        2084 :         mpWindowImpl->maPos = Point( g.nX, g.nY );
    1344        2084 :         if( pParentFrame )
    1345             :         {
    1346          28 :             g = pParentFrame->GetGeometry();
    1347          28 :             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        2084 :         Window *pClientWin = mpWindowImpl->mpClientWindow;
    1353        6228 :         while( pClientWin )
    1354             :         {
    1355        2060 :             pClientWin->mpWindowImpl->maPos = mpWindowImpl->maPos;
    1356        2060 :             pClientWin = pClientWin->mpWindowImpl->mpClientWindow;
    1357             :         }
    1358             :     }
    1359             : 
    1360      168004 :     Move();
    1361             : 
    1362      168004 :     ImplCallEventListeners( VCLEVENT_WINDOW_MOVE );
    1363      168004 : }
    1364             : 
    1365        1022 : static OString ImplAutoHelpID( ResMgr* pResMgr )
    1366             : {
    1367        1022 :     OString aRet;
    1368             : 
    1369        1022 :     if( pResMgr && Application::IsAutoHelpIdEnabled() )
    1370        1022 :         aRet = pResMgr->GetAutoHelpId();
    1371             : 
    1372        1022 :     return aRet;
    1373             : }
    1374             : 
    1375        1022 : WinBits Window::ImplInitRes( const ResId& rResId )
    1376             : {
    1377        1022 :     GetRes( rResId );
    1378             : 
    1379        1022 :     char* pRes = (char*)GetClassRes();
    1380        1022 :     pRes += 8;
    1381        1022 :     sal_uInt32 nStyle = (sal_uInt32)GetLongRes( (void*)pRes );
    1382        1022 :     rResId.SetWinBits( nStyle );
    1383        1022 :     return nStyle;
    1384             : }
    1385             : 
    1386        1022 : WindowResHeader Window::ImplLoadResHeader( const ResId& rResId )
    1387             : {
    1388        1022 :     WindowResHeader aHeader;
    1389             : 
    1390        1022 :     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        1022 :     aHeader.aHelpId = ImplAutoHelpID( rResId.GetResMgr() );
    1397             : 
    1398             :     // ResourceStyle
    1399        1022 :     aHeader.nRSStyle = ReadLongRes();
    1400             :     // WinBits
    1401        1022 :     ReadLongRes();
    1402             : 
    1403        1022 :     if( aHeader.nObjMask & WINDOW_HELPID )
    1404         954 :         aHeader.aHelpId = ReadByteStringRes();
    1405             : 
    1406        1022 :     return aHeader;
    1407             : }
    1408             : 
    1409        1022 : void Window::ImplLoadRes( const ResId& rResId )
    1410             : {
    1411        1022 :     WindowResHeader aHeader = ImplLoadResHeader( rResId );
    1412             : 
    1413        1022 :     SetHelpId( aHeader.aHelpId );
    1414             : 
    1415        1022 :     sal_uLong nObjMask = aHeader.nObjMask;
    1416             : 
    1417        1022 :     bool  bPos  = false;
    1418        1022 :     bool  bSize = false;
    1419        1022 :     Point aPos;
    1420        1022 :     Size  aSize;
    1421             : 
    1422        1022 :     if ( nObjMask & (WINDOW_XYMAPMODE | WINDOW_X | WINDOW_Y) )
    1423             :     {
    1424             :         // use size as per resource
    1425         307 :         MapUnit ePosMap = MAP_PIXEL;
    1426             : 
    1427         307 :         bPos = true;
    1428             : 
    1429         307 :         if ( nObjMask & WINDOW_XYMAPMODE )
    1430         307 :             ePosMap = (MapUnit)ReadLongRes();
    1431         307 :         if ( nObjMask & WINDOW_X )
    1432         307 :             aPos.X() = ImplLogicUnitToPixelX( ReadLongRes(), ePosMap );
    1433         307 :         if ( nObjMask & WINDOW_Y )
    1434         307 :             aPos.Y() = ImplLogicUnitToPixelY( ReadLongRes(), ePosMap );
    1435             :     }
    1436             : 
    1437        1022 :     if ( nObjMask & (WINDOW_WHMAPMODE | WINDOW_WIDTH | WINDOW_HEIGHT) )
    1438             :     {
    1439             :         // use size as per resource
    1440         988 :         MapUnit eSizeMap = MAP_PIXEL;
    1441             : 
    1442         988 :         bSize = true;
    1443             : 
    1444         988 :         if ( nObjMask & WINDOW_WHMAPMODE )
    1445         988 :             eSizeMap = (MapUnit)ReadLongRes();
    1446         988 :         if ( nObjMask & WINDOW_WIDTH )
    1447         988 :             aSize.Width() = ImplLogicUnitToPixelX( ReadLongRes(), eSizeMap );
    1448         988 :         if ( nObjMask & WINDOW_HEIGHT )
    1449         988 :             aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap );
    1450             :     }
    1451             : 
    1452        1022 :     sal_uLong nRSStyle = aHeader.nRSStyle;
    1453             : 
    1454             :     // looks bad due to optimization
    1455        1022 :     if ( nRSStyle & RSWND_CLIENTSIZE )
    1456             :     {
    1457         115 :         if ( bPos )
    1458          60 :             SetPosPixel( aPos );
    1459         115 :         if ( bSize )
    1460         115 :             SetOutputSizePixel( aSize );
    1461             :     }
    1462         907 :     else if ( bPos && bSize )
    1463         247 :         SetPosSizePixel( aPos, aSize );
    1464         660 :     else if ( bPos )
    1465           0 :         SetPosPixel( aPos );
    1466         660 :     else if ( bSize )
    1467         626 :         SetSizePixel( aSize );
    1468             : 
    1469        1022 :     if ( nRSStyle & RSWND_DISABLED )
    1470           0 :         Enable( false );
    1471             : 
    1472        1022 :     if ( nObjMask & WINDOW_TEXT )
    1473         178 :         SetText( ReadStringRes() );
    1474        1022 :     if ( nObjMask & WINDOW_HELPTEXT )
    1475             :     {
    1476           0 :         SetHelpText( ReadStringRes() );
    1477           0 :         mpWindowImpl->mbHelpTextDynamic = true;
    1478             :     }
    1479        1022 :     if ( nObjMask & WINDOW_QUICKTEXT )
    1480           0 :         SetQuickHelpText( ReadStringRes() );
    1481        1022 :     if ( nObjMask & WINDOW_EXTRALONG )
    1482             :     {
    1483           0 :         sal_uIntPtr nRes = ReadLongRes();
    1484           0 :         SetData( (void*)nRes );
    1485             :     }
    1486        1022 :     if ( nObjMask & WINDOW_UNIQUEID )
    1487           0 :         SetUniqueId( ReadByteStringRes() );
    1488             : 
    1489        1022 :     if ( nObjMask & WINDOW_BORDER_STYLE )
    1490             :     {
    1491           0 :         sal_uInt16 nBorderStyle = (sal_uInt16)ReadLongRes();
    1492           0 :         SetBorderStyle( nBorderStyle );
    1493        1022 :     }
    1494        1022 : }
    1495             : 
    1496      974300 : ImplWinData* Window::ImplGetWinData() const
    1497             : {
    1498      974300 :     if ( !mpWindowImpl->mpWinData )
    1499             :     {
    1500      116418 :         static const char* pNoNWF = getenv( "SAL_NO_NWF" );
    1501             : 
    1502      116418 :         ((Window*)this)->mpWindowImpl->mpWinData = new ImplWinData;
    1503      116418 :         mpWindowImpl->mpWinData->mpExtOldText     = NULL;
    1504      116418 :         mpWindowImpl->mpWinData->mpExtOldAttrAry  = NULL;
    1505      116418 :         mpWindowImpl->mpWinData->mpCursorRect     = NULL;
    1506      116418 :         mpWindowImpl->mpWinData->mnCursorExtWidth = 0;
    1507      116418 :         mpWindowImpl->mpWinData->mpCompositionCharRects = NULL;
    1508      116418 :         mpWindowImpl->mpWinData->mnCompositionCharRects = 0;
    1509      116418 :         mpWindowImpl->mpWinData->mpFocusRect      = NULL;
    1510      116418 :         mpWindowImpl->mpWinData->mpTrackRect      = NULL;
    1511      116418 :         mpWindowImpl->mpWinData->mnTrackFlags     = 0;
    1512      116418 :         mpWindowImpl->mpWinData->mnIsTopWindow  = (sal_uInt16) ~0;  // not initialized yet, 0/1 will indicate TopWindow (see IsTopWindow())
    1513      116418 :         mpWindowImpl->mpWinData->mbMouseOver      = false;
    1514      116418 :         mpWindowImpl->mpWinData->mbEnableNativeWidget = (pNoNWF && *pNoNWF) ? sal_False : sal_True; // sal_True: try to draw this control with native theme API
    1515             :    }
    1516             : 
    1517      974300 :     return mpWindowImpl->mpWinData;
    1518             : }
    1519             : 
    1520         270 : SalGraphics* Window::ImplGetFrameGraphics() const
    1521             : {
    1522         270 :     if ( mpWindowImpl->mpFrameWindow->mpGraphics )
    1523             :     {
    1524         270 :         mpWindowImpl->mpFrameWindow->mbInitClipRegion = true;
    1525             :     }
    1526             :     else
    1527             :     {
    1528           0 :         OutputDevice *pFrameWinOutDev = mpWindowImpl->mpFrameWindow;
    1529           0 :         pFrameWinOutDev->ImplGetGraphics();
    1530             :     }
    1531         270 :     mpWindowImpl->mpFrameWindow->mpGraphics->ResetClipRegion();
    1532         270 :     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      171476 : bool Window::ImplIsRealParentPath( const Window* pWindow ) const
    1604             : {
    1605      171476 :     pWindow = pWindow->GetParent();
    1606      790887 :     while ( pWindow )
    1607             :     {
    1608      452409 :         if ( pWindow == this )
    1609        4474 :             return true;
    1610      447935 :         pWindow = pWindow->GetParent();
    1611             :     }
    1612             : 
    1613      167002 :     return false;
    1614             : }
    1615             : 
    1616      526629 : bool Window::ImplIsChild( const Window* pWindow, bool bSystemWindow ) const
    1617             : {
    1618      400195 :     do
    1619             :     {
    1620      526629 :         if ( !bSystemWindow && pWindow->ImplIsOverlapWindow() )
    1621       98481 :             break;
    1622             : 
    1623      428148 :         pWindow = pWindow->ImplGetParent();
    1624             : 
    1625      428148 :         if ( pWindow == this )
    1626       27953 :             return true;
    1627             :     }
    1628             :     while ( pWindow );
    1629             : 
    1630      114724 :     return false;
    1631             : }
    1632             : 
    1633       46257 : bool Window::ImplIsWindowOrChild( const Window* pWindow, bool bSystemWindow ) const
    1634             : {
    1635       46257 :     if ( this == pWindow )
    1636        1699 :         return true;
    1637       44558 :     return ImplIsChild( pWindow, bSystemWindow );
    1638             : }
    1639             : 
    1640       16577 : int Window::ImplTestMousePointerSet()
    1641             : {
    1642             :     // as soon as mouse is captured, switch mouse-pointer
    1643       16577 :     if ( IsMouseCaptured() )
    1644           0 :         return sal_True;
    1645             : 
    1646             :     // if the mouse is over the window, switch it
    1647       16577 :     Rectangle aClientRect( Point( 0, 0 ), GetOutputSizePixel() );
    1648       16577 :     if ( aClientRect.IsInside( GetPointerPosPixel() ) )
    1649           0 :         return sal_True;
    1650             : 
    1651       16577 :     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       61132 : void Window::ImplResetReallyVisible()
    1697             : {
    1698       61132 :     bool bBecameReallyInvisible = mpWindowImpl->mbReallyVisible;
    1699             : 
    1700       61132 :     mbDevOutput     = false;
    1701       61132 :     mpWindowImpl->mbReallyVisible = false;
    1702       61132 :     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       61132 :     if( bBecameReallyInvisible && ImplIsAccessibleCandidate() )
    1708       56566 :         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       61132 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    1713      122264 :     while ( pWindow )
    1714             :     {
    1715           0 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    1716           0 :             pWindow->ImplResetReallyVisible();
    1717           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1718             :     }
    1719             : 
    1720       61132 :     pWindow = mpWindowImpl->mpFirstChild;
    1721      155331 :     while ( pWindow )
    1722             :     {
    1723       33067 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    1724       17588 :             pWindow->ImplResetReallyVisible();
    1725       33067 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1726             :     }
    1727       61132 : }
    1728             : 
    1729       71977 : 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       71977 :     if( !mpWindowImpl->mbReallyShown )
    1735        1772 :         ImplCallInitShow();
    1736             : 
    1737       71977 :     bool bBecameReallyVisible = !mpWindowImpl->mbReallyVisible;
    1738             : 
    1739       71977 :     mbDevOutput     = true;
    1740       71977 :     mpWindowImpl->mbReallyVisible = true;
    1741       71977 :     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       71977 :     if( bBecameReallyVisible && ImplIsAccessibleCandidate() )
    1748       56839 :         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       71977 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    1753      143954 :     while ( pWindow )
    1754             :     {
    1755           0 :         if ( pWindow->mpWindowImpl->mbVisible )
    1756           0 :             pWindow->ImplSetReallyVisible();
    1757           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1758             :     }
    1759             : 
    1760       71977 :     pWindow = mpWindowImpl->mpFirstChild;
    1761      214321 :     while ( pWindow )
    1762             :     {
    1763       70367 :         if ( pWindow->mpWindowImpl->mbVisible )
    1764       47249 :             pWindow->ImplSetReallyVisible();
    1765       70367 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1766             :     }
    1767       71977 : }
    1768             : 
    1769       61877 : void Window::ImplCallInitShow()
    1770             : {
    1771       61877 :     mpWindowImpl->mbReallyShown   = true;
    1772       61877 :     mpWindowImpl->mbInInitShow    = true;
    1773       61877 :     StateChanged( STATE_CHANGE_INITSHOW );
    1774       61877 :     mpWindowImpl->mbInInitShow    = false;
    1775             : 
    1776       61877 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    1777      123754 :     while ( pWindow )
    1778             :     {
    1779           0 :         if ( pWindow->mpWindowImpl->mbVisible )
    1780           0 :             pWindow->ImplCallInitShow();
    1781           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1782             :     }
    1783             : 
    1784       61877 :     pWindow = mpWindowImpl->mpFirstChild;
    1785      188155 :     while ( pWindow )
    1786             :     {
    1787       64401 :         if ( pWindow->mpWindowImpl->mbVisible )
    1788       35377 :             pWindow->ImplCallInitShow();
    1789       64401 :         pWindow = pWindow->mpWindowImpl->mpNext;
    1790             :     }
    1791       61877 : }
    1792             : 
    1793    11646922 : void Window::ImplAddDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok
    1794             : {
    1795             :     DBG_ASSERT( !pDel->mpWindow, "Window::ImplAddDel(): cannot add ImplDelData twice !" );
    1796    11646922 :     if( !pDel->mpWindow )
    1797             :     {
    1798    11646922 :         pDel->mpWindow = this;  // #112873# store ref to this window, so pDel can remove itself
    1799    11646922 :         pDel->mpNext = mpWindowImpl->mpFirstDel;
    1800    11646922 :         mpWindowImpl->mpFirstDel = pDel;
    1801             :     }
    1802    11646922 : }
    1803             : 
    1804    11646920 : void Window::ImplRemoveDel( ImplDelData* pDel ) // TODO: make "const" when incompatiblity ok
    1805             : {
    1806    11646920 :     pDel->mpWindow = NULL;      // #112873# pDel is not associated with a Window anymore
    1807    11646920 :     if ( mpWindowImpl->mpFirstDel == pDel )
    1808    11646920 :         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    11646920 : }
    1817             : 
    1818       32738 : void Window::ImplInitResolutionSettings()
    1819             : {
    1820             :     // recalculate AppFont-resolution and DPI-resolution
    1821       32738 :     if ( mpWindowImpl->mbFrame )
    1822             :     {
    1823         332 :         const StyleSettings& rStyleSettings = mxSettings->GetStyleSettings();
    1824         332 :         sal_uInt16 nScreenZoom = rStyleSettings.GetScreenZoom();
    1825         332 :         mnDPIX = (mpWindowImpl->mpFrameData->mnDPIX*nScreenZoom)/100;
    1826         332 :         mnDPIY = (mpWindowImpl->mpFrameData->mnDPIY*nScreenZoom)/100;
    1827             : 
    1828             :         // setup the scale factor for Hi-DPI displays
    1829         332 :         mnDPIScaleFactor = CountDPIScaleFactor(mpWindowImpl->mpFrameData->mnDPIY);
    1830         332 :         SetPointFont( rStyleSettings.GetAppFont() );
    1831             :     }
    1832       32406 :     else if ( mpWindowImpl->mpParent )
    1833             :     {
    1834       32406 :         mnDPIX  = mpWindowImpl->mpParent->mnDPIX;
    1835       32406 :         mnDPIY  = mpWindowImpl->mpParent->mnDPIY;
    1836       32406 :         mnDPIScaleFactor = mpWindowImpl->mpParent->mnDPIScaleFactor;
    1837             :     }
    1838             : 
    1839             :     // update the recalculated values for logical units
    1840             :     // and also tools belonging to the values
    1841       32738 :     if ( IsMapMode() )
    1842             :     {
    1843       27422 :         MapMode aMapMode = GetMapMode();
    1844       27422 :         SetMapMode();
    1845       27422 :         SetMapMode( aMapMode );
    1846             :     }
    1847       32738 : }
    1848             : 
    1849      163761 : void Window::ImplPointToLogic( Font& rFont ) const
    1850             : {
    1851      163761 :     Size    aSize = rFont.GetSize();
    1852      163761 :     sal_uInt16  nScreenFontZoom = mxSettings->GetStyleSettings().GetScreenFontZoom();
    1853             : 
    1854      163761 :     if ( aSize.Width() )
    1855             :     {
    1856        4141 :         aSize.Width() *= mpWindowImpl->mpFrameData->mnDPIX;
    1857        4141 :         aSize.Width() += 72/2;
    1858        4141 :         aSize.Width() /= 72;
    1859        4141 :         aSize.Width() *= nScreenFontZoom;
    1860        4141 :         aSize.Width() /= 100;
    1861             :     }
    1862      163761 :     aSize.Height() *= mpWindowImpl->mpFrameData->mnDPIY;
    1863      163761 :     aSize.Height() += 72/2;
    1864      163761 :     aSize.Height() /= 72;
    1865      163761 :     aSize.Height() *= nScreenFontZoom;
    1866      163761 :     aSize.Height() /= 100;
    1867             : 
    1868      163761 :     if ( IsMapModeEnabled() )
    1869           0 :         aSize = PixelToLogic( aSize );
    1870             : 
    1871      163761 :     rFont.SetSize( aSize );
    1872      163761 : }
    1873             : 
    1874           5 : void Window::ImplLogicToPoint( Font& rFont ) const
    1875             : {
    1876           5 :     Size    aSize = rFont.GetSize();
    1877           5 :     sal_uInt16  nScreenFontZoom = mxSettings->GetStyleSettings().GetScreenFontZoom();
    1878             : 
    1879           5 :     if ( IsMapModeEnabled() )
    1880           0 :         aSize = LogicToPixel( aSize );
    1881             : 
    1882           5 :     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           5 :     aSize.Height() *= 100;
    1891           5 :     aSize.Height() /= nScreenFontZoom;
    1892           5 :     aSize.Height() *= 72;
    1893           5 :     aSize.Height() += mpWindowImpl->mpFrameData->mnDPIY/2;
    1894           5 :     aSize.Height() /= mpWindowImpl->mpFrameData->mnDPIY;
    1895             : 
    1896           5 :     rFont.SetSize( aSize );
    1897           5 : }
    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      592590 : bool Window::ImplSetClipFlagChildren( bool bSysObjOnlySmaller )
    2033             : {
    2034      592590 :     bool bUpdate = true;
    2035      592590 :     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      592590 :     mbInitClipRegion = true;
    2064      592590 :     mpWindowImpl->mbInitWinClipRegion = true;
    2065             : 
    2066      592590 :     Window* pWindow = mpWindowImpl->mpFirstChild;
    2067     1646876 :     while ( pWindow )
    2068             :     {
    2069      461696 :         if ( !pWindow->ImplSetClipFlagChildren( bSysObjOnlySmaller ) )
    2070           0 :             bUpdate = false;
    2071      461696 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2072             :     }
    2073             :     }
    2074      592590 :     return bUpdate;
    2075             : }
    2076             : 
    2077        4254 : bool Window::ImplSetClipFlagOverlapWindows( bool bSysObjOnlySmaller )
    2078             : {
    2079        4254 :     bool bUpdate = ImplSetClipFlagChildren( bSysObjOnlySmaller );
    2080             : 
    2081        4254 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    2082        8508 :     while ( pWindow )
    2083             :     {
    2084           0 :         if ( !pWindow->ImplSetClipFlagOverlapWindows( bSysObjOnlySmaller ) )
    2085           0 :             bUpdate = false;
    2086           0 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2087             :     }
    2088             : 
    2089        4254 :     return bUpdate;
    2090             : }
    2091             : 
    2092      130894 : bool Window::ImplSetClipFlag( bool bSysObjOnlySmaller )
    2093             : {
    2094      130894 :     if ( !ImplIsOverlapWindow() )
    2095             :     {
    2096      126640 :         bool bUpdate = ImplSetClipFlagChildren( bSysObjOnlySmaller );
    2097             : 
    2098      126640 :         Window* pParent = ImplGetParent();
    2099      346658 :         if ( pParent &&
    2100      159902 :              ((pParent->GetStyle() & WB_CLIPCHILDREN) || (mpWindowImpl->mnParentClipMode & PARENTCLIPMODE_CLIP)) )
    2101             :         {
    2102       93378 :             pParent->mbInitClipRegion = true;
    2103       93378 :             pParent->mpWindowImpl->mbInitChildRegion = true;
    2104             :         }
    2105             : 
    2106             :         // siblings should recalculate their clip region
    2107      126640 :         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      126640 :         return bUpdate;
    2119             :     }
    2120             :     else
    2121        4254 :         return mpWindowImpl->mpFrameWindow->ImplSetClipFlagOverlapWindows( bSysObjOnlySmaller );
    2122             : }
    2123             : 
    2124      241011 : void Window::ImplIntersectWindowClipRegion( Region& rRegion )
    2125             : {
    2126      241011 :     if ( mpWindowImpl->mbInitWinClipRegion )
    2127       46690 :         ImplInitWinClipRegion();
    2128             : 
    2129      241011 :     rRegion.Intersect( mpWindowImpl->maWinClipRegion );
    2130      241011 : }
    2131             : 
    2132          36 : void Window::ImplIntersectWindowRegion( Region& rRegion )
    2133             : {
    2134             :     rRegion.Intersect( Rectangle( Point( mnOutOffX, mnOutOffY ),
    2135          36 :                                   Size( mnOutWidth, mnOutHeight ) ) );
    2136          36 :     if ( mpWindowImpl->mbWinRegion )
    2137           0 :         rRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    2138          36 : }
    2139             : 
    2140      132236 : void Window::ImplExcludeWindowRegion( Region& rRegion )
    2141             : {
    2142      132236 :     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      132236 :         Point aPoint( mnOutOffX, mnOutOffY );
    2153             :         rRegion.Exclude( Rectangle( aPoint,
    2154      132236 :                                     Size( mnOutWidth, mnOutHeight ) ) );
    2155             :     }
    2156      132236 : }
    2157             : 
    2158        2828 : void Window::ImplExcludeOverlapWindows( Region& rRegion )
    2159             : {
    2160        2828 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    2161        5656 :     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        2828 : }
    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      243858 : void Window::ImplClipBoundaries( Region& rRegion, bool bThis, bool bOverlaps )
    2182             : {
    2183      243858 :     if ( bThis )
    2184       53099 :         ImplIntersectWindowClipRegion( rRegion );
    2185      190759 :     else if ( ImplIsOverlapWindow() )
    2186             :     {
    2187             :         // clip to frame if required
    2188        2847 :         if ( !mpWindowImpl->mbFrame )
    2189           0 :             rRegion.Intersect( Rectangle( Point( 0, 0 ), Size( mpWindowImpl->mpFrameWindow->mnOutWidth, mpWindowImpl->mpFrameWindow->mnOutHeight ) ) );
    2190             : 
    2191        2847 :         if ( bOverlaps && !rRegion.IsEmpty() )
    2192             :         {
    2193             :             // Clip Overlap Siblings
    2194        2828 :             Window* pStartOverlapWindow = this;
    2195        5656 :             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        2828 :             ImplExcludeOverlapWindows( rRegion );
    2208             :         }
    2209             :     }
    2210             :     else
    2211      187912 :         ImplGetParent()->ImplIntersectWindowClipRegion( rRegion );
    2212      243858 : }
    2213             : 
    2214       43889 : bool Window::ImplClipChildren( Region& rRegion )
    2215             : {
    2216       43889 :     bool    bOtherClip = false;
    2217       43889 :     Window* pWindow = mpWindowImpl->mpFirstChild;
    2218      229684 :     while ( pWindow )
    2219             :     {
    2220      141906 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    2221             :         {
    2222             :             // read-out ParentClipMode-Flags
    2223       73789 :             sal_uInt16 nClipMode = pWindow->GetParentClipMode();
    2224      219695 :             if ( !(nClipMode & PARENTCLIPMODE_NOCLIP) &&
    2225      145906 :                  ((nClipMode & PARENTCLIPMODE_CLIP) || (GetStyle() & WB_CLIPCHILDREN)) )
    2226       72953 :                 pWindow->ImplExcludeWindowRegion( rRegion );
    2227             :             else
    2228         836 :                 bOtherClip = true;
    2229             :         }
    2230             : 
    2231      141906 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2232             :     }
    2233             : 
    2234       43889 :     return bOtherClip;
    2235             : }
    2236             : 
    2237         377 : void Window::ImplClipAllChildren( Region& rRegion )
    2238             : {
    2239         377 :     Window* pWindow = mpWindowImpl->mpFirstChild;
    2240        1179 :     while ( pWindow )
    2241             :     {
    2242         425 :         if ( pWindow->mpWindowImpl->mbReallyVisible )
    2243         273 :             pWindow->ImplExcludeWindowRegion( rRegion );
    2244         425 :         pWindow = pWindow->mpWindowImpl->mpNext;
    2245             :     }
    2246         377 : }
    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      127864 : void Window::ImplInitWinClipRegion()
    2264             : {
    2265             :     // Build Window Region
    2266      255728 :     mpWindowImpl->maWinClipRegion = Rectangle( Point( mnOutOffX, mnOutOffY ),
    2267      127864 :                                  Size( mnOutWidth, mnOutHeight ) );
    2268      127864 :     if ( mpWindowImpl->mbWinRegion )
    2269           0 :         mpWindowImpl->maWinClipRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    2270             : 
    2271             :     // ClipSiblings
    2272      127864 :     if ( mpWindowImpl->mbClipSiblings && !ImplIsOverlapWindow() )
    2273           0 :         ImplClipSiblings( mpWindowImpl->maWinClipRegion );
    2274             : 
    2275             :     // Clip Parent Boundaries
    2276      127864 :     ImplClipBoundaries( mpWindowImpl->maWinClipRegion, false, true );
    2277             : 
    2278             :     // Clip Children
    2279      127864 :     if ( (GetStyle() & WB_CLIPCHILDREN) || mpWindowImpl->mbClipChildren )
    2280       40845 :         mpWindowImpl->mbInitChildRegion = true;
    2281             : 
    2282      127864 :     mpWindowImpl->mbInitWinClipRegion = false;
    2283      127864 : }
    2284             : 
    2285       29541 : void Window::ImplInitWinChildClipRegion()
    2286             : {
    2287       29541 :     if ( !mpWindowImpl->mpFirstChild )
    2288             :     {
    2289       11937 :         if ( mpWindowImpl->mpChildClipRegion )
    2290             :         {
    2291          16 :             delete mpWindowImpl->mpChildClipRegion;
    2292          16 :             mpWindowImpl->mpChildClipRegion = NULL;
    2293             :         }
    2294             :     }
    2295             :     else
    2296             :     {
    2297       17604 :         if ( !mpWindowImpl->mpChildClipRegion )
    2298        8596 :             mpWindowImpl->mpChildClipRegion = new Region( mpWindowImpl->maWinClipRegion );
    2299             :         else
    2300        9008 :             *mpWindowImpl->mpChildClipRegion = mpWindowImpl->maWinClipRegion;
    2301             : 
    2302       17604 :         ImplClipChildren( *mpWindowImpl->mpChildClipRegion );
    2303             :     }
    2304             : 
    2305       29541 :     mpWindowImpl->mbInitChildRegion = false;
    2306       29541 : }
    2307             : 
    2308      133264 : Region* Window::ImplGetWinChildClipRegion()
    2309             : {
    2310      133264 :     if ( mpWindowImpl->mbInitWinClipRegion )
    2311       64208 :         ImplInitWinClipRegion();
    2312      133264 :     if ( mpWindowImpl->mbInitChildRegion )
    2313       29541 :         ImplInitWinChildClipRegion();
    2314      133264 :     if ( mpWindowImpl->mpChildClipRegion )
    2315       19645 :         return mpWindowImpl->mpChildClipRegion;
    2316             :     else
    2317      113619 :         return &mpWindowImpl->maWinClipRegion;
    2318             : }
    2319             : 
    2320         323 : void Window::ImplIntersectAndUnionOverlapWindows( const Region& rInterRegion, Region& rRegion )
    2321             : {
    2322         323 :     Window* pWindow = mpWindowImpl->mpFirstOverlap;
    2323         646 :     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         323 : }
    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         323 : void Window::ImplCalcOverlapRegionOverlaps( const Region& rInterRegion, Region& rRegion )
    2350             : {
    2351             :     // Clip Overlap Siblings
    2352             :     Window* pStartOverlapWindow;
    2353         323 :     if ( !ImplIsOverlapWindow() )
    2354         323 :         pStartOverlapWindow = mpWindowImpl->mpOverlapWindow;
    2355             :     else
    2356           0 :         pStartOverlapWindow = this;
    2357         646 :     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         323 :     if ( !ImplIsOverlapWindow() )
    2370         323 :         mpWindowImpl->mpOverlapWindow->ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
    2371             :     else
    2372           0 :         ImplIntersectAndUnionOverlapWindows( rInterRegion, rRegion );
    2373         323 : }
    2374             : 
    2375         323 : void Window::ImplCalcOverlapRegion( const Rectangle& rSourceRect, Region& rRegion,
    2376             :                                     bool bChildren, bool bParent, bool bSiblings )
    2377             : {
    2378         323 :     Region  aRegion( rSourceRect );
    2379         323 :     if ( mpWindowImpl->mbWinRegion )
    2380           0 :         rRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    2381         646 :     Region  aTempRegion;
    2382             :     Window* pWindow;
    2383             : 
    2384         323 :     ImplCalcOverlapRegionOverlaps( aRegion, rRegion );
    2385             : 
    2386             :     // Parent-Boundaries
    2387         323 :     if ( bParent )
    2388             :     {
    2389         323 :         pWindow = this;
    2390         323 :         if ( !ImplIsOverlapWindow() )
    2391             :         {
    2392         323 :             pWindow = ImplGetParent();
    2393        1266 :             do
    2394             :             {
    2395        1589 :                 aTempRegion = aRegion;
    2396        1589 :                 pWindow->ImplExcludeWindowRegion( aTempRegion );
    2397        1589 :                 rRegion.Union( aTempRegion );
    2398        1589 :                 if ( pWindow->ImplIsOverlapWindow() )
    2399         323 :                     break;
    2400        1266 :                 pWindow = pWindow->ImplGetParent();
    2401             :             }
    2402             :             while ( pWindow );
    2403             :         }
    2404         323 :         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         323 :     if ( bSiblings && !ImplIsOverlapWindow() )
    2414             :     {
    2415          20 :         pWindow = mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild;
    2416          64 :         do
    2417             :         {
    2418          64 :             if ( pWindow->mpWindowImpl->mbReallyVisible && (pWindow != this) )
    2419             :             {
    2420          30 :                 aTempRegion = aRegion;
    2421          30 :                 pWindow->ImplIntersectWindowRegion( aTempRegion );
    2422          30 :                 rRegion.Union( aTempRegion );
    2423             :             }
    2424          64 :             pWindow = pWindow->mpWindowImpl->mpNext;
    2425             :         }
    2426             :         while ( pWindow );
    2427             :     }
    2428             : 
    2429         323 :     if ( bChildren )
    2430             :     {
    2431         253 :         pWindow = mpWindowImpl->mpFirstChild;
    2432         530 :         while ( pWindow )
    2433             :         {
    2434          24 :             if ( pWindow->mpWindowImpl->mbReallyVisible )
    2435             :             {
    2436           6 :                 aTempRegion = aRegion;
    2437           6 :                 pWindow->ImplIntersectWindowRegion( aTempRegion );
    2438           6 :                 rRegion.Union( aTempRegion );
    2439             :             }
    2440          24 :             pWindow = pWindow->mpWindowImpl->mpNext;
    2441             :         }
    2442         323 :     }
    2443         323 : }
    2444             : 
    2445      339020 : void Window::ImplCallPaint( const Region* pRegion, sal_uInt16 nPaintFlags )
    2446             : {
    2447      339020 :     Exception aException;
    2448      339020 :     bool bExceptionCaught(false);
    2449             : 
    2450             :     // call PrePaint. PrePaint may add to the invalidate region as well as
    2451             :     // other parameters used below.
    2452      339020 :     PrePaint();
    2453             : 
    2454      339020 :     mpWindowImpl->mbPaintFrame = false;
    2455             : 
    2456      339020 :     if ( nPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
    2457      104486 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALLCHILDREN | (nPaintFlags & IMPL_PAINT_PAINTALL);
    2458      339020 :     if ( nPaintFlags & IMPL_PAINT_PAINTCHILDREN )
    2459      328589 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDREN;
    2460      339020 :     if ( nPaintFlags & IMPL_PAINT_ERASE )
    2461      108341 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE;
    2462      339020 :     if ( nPaintFlags & IMPL_PAINT_CHECKRTL )
    2463       28008 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
    2464      339020 :     if ( !mpWindowImpl->mpFirstChild )
    2465      202754 :         mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALLCHILDREN;
    2466             : 
    2467      339020 :     if ( mpWindowImpl->mbPaintDisabled )
    2468             :     {
    2469        6146 :         if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2470        6112 :             Invalidate( INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
    2471          34 :         else if ( pRegion )
    2472          16 :             Invalidate( *pRegion, INVALIDATE_NOCHILDREN | INVALIDATE_NOERASE | INVALIDATE_NOTRANSPARENT | INVALIDATE_NOCLIPCHILDREN );
    2473      345166 :         return;
    2474             :     }
    2475             : 
    2476      332874 :     nPaintFlags = mpWindowImpl->mnPaintFlags & ~(IMPL_PAINT_PAINT);
    2477             : 
    2478      332874 :     Region* pChildRegion = NULL;
    2479      332874 :     Rectangle aSelectionRect;
    2480      332874 :     if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT )
    2481             :     {
    2482      113505 :         Region* pWinChildClipRegion = ImplGetWinChildClipRegion();
    2483      113505 :         if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2484       67074 :             mpWindowImpl->maInvalidateRegion = *pWinChildClipRegion;
    2485             :         else
    2486             :         {
    2487       46431 :             if ( pRegion )
    2488       34926 :                 mpWindowImpl->maInvalidateRegion.Union( *pRegion );
    2489             : 
    2490       46431 :             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       46431 :             if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
    2499       18537 :                 pChildRegion = new Region( mpWindowImpl->maInvalidateRegion );
    2500       46431 :             mpWindowImpl->maInvalidateRegion.Intersect( *pWinChildClipRegion );
    2501             :         }
    2502      113505 :         mpWindowImpl->mnPaintFlags = 0;
    2503      113505 :         if ( !mpWindowImpl->maInvalidateRegion.IsEmpty() )
    2504             :         {
    2505       75948 :             bool bRestoreCursor = false;
    2506       75948 :             if ( mpWindowImpl->mpCursor )
    2507       10916 :                 bRestoreCursor = mpWindowImpl->mpCursor->ImplSuspend();
    2508             : 
    2509       75948 :             mbInitClipRegion = true;
    2510       75948 :             mpWindowImpl->mbInPaint = true;
    2511             : 
    2512             :             // restore Paint-Region
    2513       75948 :             Region      aPaintRegion( mpWindowImpl->maInvalidateRegion );
    2514       75948 :             Rectangle   aPaintRect = aPaintRegion.GetBoundRect();
    2515             : 
    2516             :             // - RTL - re-mirror paint rect and region at this window
    2517       75948 :             if( ImplIsAntiparallel() )
    2518             :             {
    2519          22 :                 const OutputDevice *pOutDev = GetOutDev();
    2520          22 :                 pOutDev->ReMirror( aPaintRect );
    2521          22 :                 pOutDev->ReMirror( aPaintRegion );
    2522             :             }
    2523       75948 :             aPaintRect = ImplDevicePixelToLogic( aPaintRect);
    2524       75948 :             mpWindowImpl->mpPaintRegion = &aPaintRegion;
    2525       75948 :             mpWindowImpl->maInvalidateRegion.SetEmpty();
    2526             : 
    2527       75948 :             if ( (nPaintFlags & IMPL_PAINT_ERASE) && IsBackground() )
    2528             :             {
    2529       44649 :                 if ( IsClipRegion() )
    2530             :                 {
    2531           0 :                     Region aOldRegion = GetClipRegion();
    2532           0 :                     SetClipRegion();
    2533           0 :                     Erase();
    2534           0 :                     SetClipRegion( aOldRegion );
    2535             :                 }
    2536             :                 else
    2537       44649 :                     Erase();
    2538             :             }
    2539             : 
    2540             :             // #98943# trigger drawing of toolbox selection after all childern are painted
    2541       75948 :             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       75948 :                 Paint( aPaintRect );
    2551             :             }
    2552           0 :             catch(Exception& rException)
    2553             :             {
    2554           0 :                 aException = rException;
    2555           0 :                 bExceptionCaught = true;
    2556             :             }
    2557             : 
    2558       75948 :             if ( mpWindowImpl->mpWinData )
    2559             :             {
    2560       54781 :                 if ( mpWindowImpl->mbFocusVisible )
    2561           3 :                     ImplInvertFocus( *(mpWindowImpl->mpWinData->mpFocusRect) );
    2562             :             }
    2563       75948 :             mpWindowImpl->mbInPaint = false;
    2564       75948 :             mbInitClipRegion = true;
    2565       75948 :             mpWindowImpl->mpPaintRegion = NULL;
    2566       75948 :             if ( mpWindowImpl->mpCursor )
    2567       11124 :                 mpWindowImpl->mpCursor->ImplResume( bRestoreCursor );
    2568             :         }
    2569             :     }
    2570             :     else
    2571      219369 :         mpWindowImpl->mnPaintFlags = 0;
    2572             : 
    2573      332874 :     if ( nPaintFlags & (IMPL_PAINT_PAINTALLCHILDREN | IMPL_PAINT_PAINTCHILDREN) )
    2574             :     {
    2575             :         // Paint from the bottom child window and frontward.
    2576      326420 :         Window* pTempWindow = mpWindowImpl->mpLastChild;
    2577     1145401 :         while ( pTempWindow )
    2578             :         {
    2579      492561 :             if ( pTempWindow->mpWindowImpl->mbVisible )
    2580      319520 :                 pTempWindow->ImplCallPaint( pChildRegion, nPaintFlags );
    2581      492561 :             pTempWindow = pTempWindow->mpWindowImpl->mpPrev;
    2582             :         }
    2583             :     }
    2584             : 
    2585      332874 :     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      332874 :     if( !aSelectionRect.IsEmpty() )
    2593           0 :         DrawSelectionBackground( aSelectionRect, 3, false, true, false );
    2594             : 
    2595      332874 :     delete pChildRegion;
    2596             : 
    2597      332874 :     if(bExceptionCaught)
    2598             :     {
    2599           0 :         throw(aException);
    2600      332874 :     }
    2601             : }
    2602             : 
    2603        8674 : void Window::ImplCallOverlapPaint()
    2604             : {
    2605             :     // emit overlapping windows first
    2606        8674 :     Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
    2607       17348 :     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        8674 :     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        8636 :         ImplCallPaint( NULL, mpWindowImpl->mnPaintFlags /*| IMPL_PAINT_CHECKRTL */);
    2620             :     }
    2621        8674 : }
    2622             : 
    2623      209147 : void Window::ImplPostPaint()
    2624             : {
    2625      209147 :     if ( !ImplDoTiledRendering() && !mpWindowImpl->mpFrameData->maPaintTimer.IsActive() )
    2626       10762 :         mpWindowImpl->mpFrameData->maPaintTimer.Start();
    2627      209147 : }
    2628             : 
    2629       17404 : IMPL_LINK_NOARG(Window, ImplHandlePaintHdl)
    2630             : {
    2631             :     // save paint events until layout is done
    2632        8702 :     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       26106 :     if( !ImplDoTiledRendering() &&
    2640       17404 :         mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
    2641           0 :         mpWindowImpl->mpFrameData->maPaintTimer.Start();
    2642        8702 :     else if ( mpWindowImpl->mbReallyVisible )
    2643        8674 :         ImplCallOverlapPaint();
    2644        8702 :     return 0;
    2645             : }
    2646             : 
    2647        4124 : IMPL_LINK_NOARG(Window, ImplHandleResizeTimerHdl)
    2648             : {
    2649        2062 :     if( mpWindowImpl->mbReallyVisible )
    2650             :     {
    2651          50 :         ImplCallResize();
    2652          50 :         if( ImplDoTiledRendering() )
    2653             :         {
    2654           0 :             ImplHandlePaintHdl(NULL);
    2655             :         }
    2656          50 :         else if( mpWindowImpl->mpFrameData->maPaintTimer.IsActive() )
    2657             :         {
    2658          50 :             mpWindowImpl->mpFrameData->maPaintTimer.Stop();
    2659          50 :             mpWindowImpl->mpFrameData->maPaintTimer.GetTimeoutHdl().Call( NULL );
    2660             :         }
    2661             :     }
    2662             : 
    2663        2062 :     return 0;
    2664             : }
    2665             : 
    2666      209147 : void Window::ImplInvalidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags )
    2667             : {
    2668             :     // set PAINTCHILDREN for all parent windows till the first OverlapWindow
    2669      209147 :     if ( !ImplIsOverlapWindow() )
    2670             :     {
    2671      205149 :         Window* pTempWindow = this;
    2672      205149 :         sal_uInt16 nTranspPaint = IsPaintTransparent() ? IMPL_PAINT_PAINT : 0;
    2673       75768 :         do
    2674             :         {
    2675      270312 :             pTempWindow = pTempWindow->ImplGetParent();
    2676      270312 :             if ( pTempWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTCHILDREN )
    2677      194544 :                 break;
    2678       75768 :             pTempWindow->mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTCHILDREN | nTranspPaint;
    2679       75768 :             if( ! pTempWindow->IsPaintTransparent() )
    2680       75755 :                 nTranspPaint = 0;
    2681             :         }
    2682       75768 :         while ( !pTempWindow->ImplIsOverlapWindow() );
    2683             :     }
    2684             : 
    2685             :     // set Paint-Flags
    2686      209147 :     mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINT;
    2687      209147 :     if ( nFlags & INVALIDATE_CHILDREN )
    2688      175262 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTALLCHILDREN;
    2689      209147 :     if ( !(nFlags & INVALIDATE_NOERASE) )
    2690      190437 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_ERASE;
    2691      209147 :     if ( !pRegion )
    2692       99864 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_PAINTALL;
    2693             : 
    2694             :     // if not everything has to be redrawn, add the region to it
    2695      209147 :     if ( !(mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL) )
    2696       82795 :         mpWindowImpl->maInvalidateRegion.Union( *pRegion );
    2697             : 
    2698             :     // Handle transparent windows correctly: invalidate must be done on the first opaque parent
    2699      421449 :     if( ((IsPaintTransparent() && !(nFlags & INVALIDATE_NOTRANSPARENT)) || (nFlags & INVALIDATE_TRANSPARENT) )
    2700      212297 :             && ImplGetParent() )
    2701             :     {
    2702        3143 :         Window *pParent = ImplGetParent();
    2703        6575 :         while( pParent && pParent->IsPaintTransparent() )
    2704         289 :             pParent = pParent->ImplGetParent();
    2705        3143 :         if( pParent )
    2706             :         {
    2707             :             Region *pChildRegion;
    2708        3143 :             if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALL )
    2709             :                 // invalidate the whole child window region in the parent
    2710         228 :                 pChildRegion = ImplGetWinChildClipRegion();
    2711             :             else
    2712             :                 // invalidate the same region in the parent that has to be repainted in the child
    2713        2915 :                 pChildRegion = &mpWindowImpl->maInvalidateRegion;
    2714             : 
    2715        3143 :             nFlags |= INVALIDATE_CHILDREN;  // paint should also be done on all children
    2716        3143 :             nFlags &= ~INVALIDATE_NOERASE;  // parent should paint and erase to create proper background
    2717        3143 :             pParent->ImplInvalidateFrameRegion( pChildRegion, nFlags );
    2718             :         }
    2719             :     }
    2720      209147 :     ImplPostPaint();
    2721      209147 : }
    2722             : 
    2723        4581 : void Window::ImplInvalidateOverlapFrameRegion( const Region& rRegion )
    2724             : {
    2725        4581 :     Region aRegion = rRegion;
    2726             : 
    2727        4581 :     ImplClipBoundaries( aRegion, true, true );
    2728        4581 :     if ( !aRegion.IsEmpty() )
    2729        2094 :         ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN );
    2730             : 
    2731             :     // now we invalidate the overlapping windows
    2732        4581 :     Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
    2733        9162 :     while ( pTempWindow )
    2734             :     {
    2735           0 :         if ( pTempWindow->IsVisible() )
    2736           0 :             pTempWindow->ImplInvalidateOverlapFrameRegion( rRegion );
    2737             : 
    2738           0 :         pTempWindow = pTempWindow->mpWindowImpl->mpNext;
    2739        4581 :     }
    2740        4581 : }
    2741             : 
    2742       54244 : void Window::ImplInvalidateParentFrameRegion( Region& rRegion )
    2743             : {
    2744       54244 :     if ( mpWindowImpl->mbOverlapWin )
    2745           0 :         mpWindowImpl->mpFrameWindow->ImplInvalidateOverlapFrameRegion( rRegion );
    2746             :     else
    2747             :     {
    2748       54244 :         if( ImplGetParent() )
    2749       54244 :             ImplGetParent()->ImplInvalidateFrameRegion( &rRegion, INVALIDATE_CHILDREN );
    2750             :     }
    2751       54244 : }
    2752             : 
    2753      102640 : void Window::ImplInvalidate( const Region* pRegion, sal_uInt16 nFlags )
    2754             : {
    2755             : 
    2756             :     // reset background storage
    2757      102640 :     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    2758           0 :         ImplInvalidateAllOverlapBackgrounds();
    2759             : 
    2760             :     // check what has to be redrawn
    2761      102640 :     bool bInvalidateAll = !pRegion;
    2762             : 
    2763             :     // take Transparent-Invalidate into account
    2764      102640 :     Window* pOpaqueWindow = this;
    2765      102640 :     if ( (mpWindowImpl->mbPaintTransparent && !(nFlags & INVALIDATE_NOTRANSPARENT)) || (nFlags & INVALIDATE_TRANSPARENT) )
    2766             :     {
    2767        5035 :         Window* pTempWindow = pOpaqueWindow->ImplGetParent();
    2768       10177 :         while ( pTempWindow )
    2769             :         {
    2770        5142 :             if ( !pTempWindow->IsPaintTransparent() )
    2771             :             {
    2772        5035 :                 pOpaqueWindow = pTempWindow;
    2773        5035 :                 nFlags |= INVALIDATE_CHILDREN;
    2774        5035 :                 bInvalidateAll = false;
    2775        5035 :                 break;
    2776             :             }
    2777             : 
    2778         107 :             if ( pTempWindow->ImplIsOverlapWindow() )
    2779           0 :                 break;
    2780             : 
    2781         107 :             pTempWindow = pTempWindow->ImplGetParent();
    2782             :         }
    2783             :     }
    2784             : 
    2785             :     // assemble region
    2786      102640 :     sal_uInt16 nOrgFlags = nFlags;
    2787      102640 :     if ( !(nFlags & (INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN)) )
    2788             :     {
    2789       68136 :         if ( GetStyle() & WB_CLIPCHILDREN )
    2790       29067 :             nFlags |= INVALIDATE_NOCHILDREN;
    2791             :         else
    2792       39069 :             nFlags |= INVALIDATE_CHILDREN;
    2793             :     }
    2794      102640 :     if ( (nFlags & INVALIDATE_NOCHILDREN) && mpWindowImpl->mpFirstChild )
    2795       14408 :         bInvalidateAll = false;
    2796      102640 :     if ( bInvalidateAll )
    2797       54122 :         ImplInvalidateFrameRegion( NULL, nFlags );
    2798             :     else
    2799             :     {
    2800       48518 :         Rectangle   aRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    2801       48518 :         Region      aRegion( aRect );
    2802       48518 :         if ( pRegion )
    2803             :         {
    2804             :             // --- RTL --- remirror region before intersecting it
    2805       39941 :             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       39941 :                 aRegion.Intersect( *pRegion );
    2815             :         }
    2816       48518 :         ImplClipBoundaries( aRegion, true, true );
    2817       48518 :         if ( nFlags & INVALIDATE_NOCHILDREN )
    2818             :         {
    2819       26310 :             nFlags &= ~INVALIDATE_CHILDREN;
    2820       26310 :             if ( !(nFlags & INVALIDATE_NOCLIPCHILDREN) )
    2821             :             {
    2822       26156 :                 if ( nOrgFlags & INVALIDATE_NOCHILDREN )
    2823         377 :                     ImplClipAllChildren( aRegion );
    2824             :                 else
    2825             :                 {
    2826       25779 :                     if ( ImplClipChildren( aRegion ) )
    2827         511 :                         nFlags |= INVALIDATE_CHILDREN;
    2828             :                 }
    2829             :             }
    2830             :         }
    2831       48518 :         if ( !aRegion.IsEmpty() )
    2832       44776 :             ImplInvalidateFrameRegion( &aRegion, nFlags );  // transparency is handled here, pOpaqueWindow not required
    2833             :     }
    2834             : 
    2835      102640 :     if ( nFlags & INVALIDATE_UPDATE )
    2836           0 :         pOpaqueWindow->Update();        // start painting at the opaque parent
    2837      102640 : }
    2838             : 
    2839         324 : void Window::ImplMoveInvalidateRegion( const Rectangle& rRect,
    2840             :                                        long nHorzScroll, long nVertScroll,
    2841             :                                        bool bChildren )
    2842             : {
    2843         324 :     if ( (mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTALL)) == IMPL_PAINT_PAINT )
    2844             :     {
    2845          26 :         Region aTempRegion = mpWindowImpl->maInvalidateRegion;
    2846          26 :         aTempRegion.Intersect( rRect );
    2847          26 :         aTempRegion.Move( nHorzScroll, nVertScroll );
    2848          26 :         mpWindowImpl->maInvalidateRegion.Union( aTempRegion );
    2849             :     }
    2850             : 
    2851         324 :     if ( bChildren && (mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTCHILDREN) )
    2852             :     {
    2853           1 :         Window* pWindow = mpWindowImpl->mpFirstChild;
    2854           3 :         while ( pWindow )
    2855             :         {
    2856           1 :             pWindow->ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, true );
    2857           1 :             pWindow = pWindow->mpWindowImpl->mpNext;
    2858             :         }
    2859             :     }
    2860         324 : }
    2861             : 
    2862         323 : 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         323 :     ImplMoveInvalidateRegion( rRect, nHorzScroll, nVertScroll, bChildren );
    2868             :     // Paint-Region should be shifted, as drawn by the parents
    2869         323 :     if ( !ImplIsOverlapWindow() )
    2870             :     {
    2871         323 :         Region  aPaintAllRegion;
    2872         323 :         Window* pPaintAllWindow = this;
    2873        1589 :         do
    2874             :         {
    2875        1589 :             pPaintAllWindow = pPaintAllWindow->ImplGetParent();
    2876        1589 :             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        1589 :         while ( !pPaintAllWindow->ImplIsOverlapWindow() );
    2888         323 :         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         323 :         }
    2896             :     }
    2897         323 : }
    2898             : 
    2899           6 : void Window::ImplValidateFrameRegion( const Region* pRegion, sal_uInt16 nFlags )
    2900             : {
    2901           6 :     if ( !pRegion )
    2902           6 :         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           6 :     mpWindowImpl->mnPaintFlags &= ~IMPL_PAINT_PAINTALL;
    2929             : 
    2930           6 :     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           6 : }
    2940             : 
    2941           6 : void Window::ImplValidate( const Region* pRegion, sal_uInt16 nFlags )
    2942             : {
    2943             :     // assemble region
    2944           6 :     bool    bValidateAll = !pRegion;
    2945           6 :     sal_uInt16  nOrgFlags = nFlags;
    2946           6 :     if ( !(nFlags & (VALIDATE_CHILDREN | VALIDATE_NOCHILDREN)) )
    2947             :     {
    2948           6 :         if ( GetStyle() & WB_CLIPCHILDREN )
    2949           6 :             nFlags |= VALIDATE_NOCHILDREN;
    2950             :         else
    2951           0 :             nFlags |= VALIDATE_CHILDREN;
    2952             :     }
    2953           6 :     if ( (nFlags & VALIDATE_NOCHILDREN) && mpWindowImpl->mpFirstChild )
    2954           0 :         bValidateAll = false;
    2955           6 :     if ( bValidateAll )
    2956           6 :         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           6 : }
    2979             : 
    2980        2834 : void Window::ImplScroll( const Rectangle& rRect,
    2981             :                          long nHorzScroll, long nVertScroll, sal_uInt16 nFlags )
    2982             : {
    2983        2834 :     if ( !IsDeviceOutputNecessary() )
    2984        4920 :         return;
    2985             : 
    2986         445 :     nHorzScroll = ImplLogicWidthToDevicePixel( nHorzScroll );
    2987         445 :     nVertScroll = ImplLogicHeightToDevicePixel( nVertScroll );
    2988             : 
    2989         445 :     if ( !nHorzScroll && !nVertScroll )
    2990         142 :         return;
    2991             : 
    2992             :     // restore background storage
    2993         303 :     if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    2994           0 :         ImplInvalidateAllOverlapBackgrounds();
    2995             : 
    2996         303 :     if ( mpWindowImpl->mpCursor )
    2997         189 :         mpWindowImpl->mpCursor->ImplSuspend();
    2998             : 
    2999         303 :     sal_uInt16 nOrgFlags = nFlags;
    3000         303 :     if ( !(nFlags & (SCROLL_CHILDREN | SCROLL_NOCHILDREN)) )
    3001             :     {
    3002          59 :         if ( GetStyle() & WB_CLIPCHILDREN )
    3003           8 :             nFlags |= SCROLL_NOCHILDREN;
    3004             :         else
    3005          51 :             nFlags |= SCROLL_CHILDREN;
    3006             :     }
    3007             : 
    3008         303 :     Region  aInvalidateRegion;
    3009         303 :     bool    bScrollChildren = (nFlags & SCROLL_CHILDREN) != 0;
    3010         303 :     bool    bErase = (nFlags & SCROLL_NOERASE) == 0;
    3011             : 
    3012         303 :     if ( !mpWindowImpl->mpFirstChild )
    3013         245 :         bScrollChildren = false;
    3014             : 
    3015         303 :     OutputDevice *pOutDev = GetOutDev();
    3016             : 
    3017             :     // --- RTL --- check if this window requires special action
    3018         303 :     bool bReMirror = ( ImplIsAntiparallel() );
    3019             : 
    3020         303 :     Rectangle aRectMirror( rRect );
    3021         303 :     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         303 :     ImplMoveAllInvalidateRegions( aRectMirror, nHorzScroll, nVertScroll, bScrollChildren );
    3030             : 
    3031         303 :     if ( !(nFlags & SCROLL_NOINVALIDATE) )
    3032             :     {
    3033         303 :         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         303 :         if ( !aInvalidateRegion.IsEmpty() )
    3041             :         {
    3042           2 :             aInvalidateRegion.Move( bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll );
    3043           2 :             bErase = true;
    3044             :         }
    3045         303 :         if ( !(nFlags & SCROLL_NOWINDOWINVALIDATE) )
    3046             :         {
    3047         303 :             Rectangle aDestRect( aRectMirror );
    3048         303 :             aDestRect.Move( bReMirror ? -nHorzScroll : nHorzScroll, nVertScroll );
    3049         303 :             Region aWinInvalidateRegion( aRectMirror );
    3050         303 :             aWinInvalidateRegion.Exclude( aDestRect );
    3051             : 
    3052         303 :             aInvalidateRegion.Union( aWinInvalidateRegion );
    3053             :         }
    3054             :     }
    3055             : 
    3056         303 :     Point aPoint( mnOutOffX, mnOutOffY );
    3057         606 :     Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
    3058         303 :     if ( nFlags & SCROLL_CLIP )
    3059           0 :         aRegion.Intersect( rRect );
    3060         303 :     if ( mpWindowImpl->mbWinRegion )
    3061           0 :         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    3062             : 
    3063         303 :     aRegion.Exclude( aInvalidateRegion );
    3064             : 
    3065         303 :     ImplClipBoundaries( aRegion, false, true );
    3066         303 :     if ( !bScrollChildren )
    3067             :     {
    3068         253 :         if ( nOrgFlags & SCROLL_NOCHILDREN )
    3069           0 :             ImplClipAllChildren( aRegion );
    3070             :         else
    3071         253 :             ImplClipChildren( aRegion );
    3072             :     }
    3073         303 :     if ( mbClipRegion && (nFlags & SCROLL_USECLIPREGION) )
    3074           0 :         aRegion.Intersect( maRegion );
    3075         303 :     if ( !aRegion.IsEmpty() )
    3076             :     {
    3077         250 :         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         250 :         SalGraphics* pGraphics = ImplGetFrameGraphics();
    3096         250 :         if ( pGraphics )
    3097             :         {
    3098         250 :             if( bReMirror )
    3099             :             {
    3100             :                 // --- RTL --- frame coordinates require re-mirroring
    3101           0 :                 pOutDev->ReMirror( aRegion );
    3102             :             }
    3103             : 
    3104         250 :             pOutDev->ImplSelectClipRegion( aRegion, pGraphics );
    3105         500 :             pGraphics->CopyArea( rRect.Left()+nHorzScroll, rRect.Top()+nVertScroll,
    3106             :                                  rRect.Left(), rRect.Top(),
    3107             :                                  rRect.GetWidth(), rRect.GetHeight(),
    3108         750 :                                  SAL_COPYAREA_WINDOWINVALIDATE, this );
    3109             :         }
    3110             : #endif
    3111         250 :         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         303 :     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         303 :         mpWindowImpl->mnPaintFlags |= IMPL_PAINT_CHECKRTL;
    3125             : 
    3126         303 :         sal_uInt16 nPaintFlags = INVALIDATE_CHILDREN;
    3127         303 :         if ( !bErase )
    3128           0 :             nPaintFlags |= INVALIDATE_NOERASE;
    3129         303 :         if ( !bScrollChildren )
    3130             :         {
    3131         253 :             if ( nOrgFlags & SCROLL_NOCHILDREN )
    3132           0 :                 ImplClipAllChildren( aInvalidateRegion );
    3133             :             else
    3134         253 :                 ImplClipChildren( aInvalidateRegion );
    3135             :         }
    3136         303 :         ImplInvalidateFrameRegion( &aInvalidateRegion, nPaintFlags );
    3137             :     }
    3138             : 
    3139         303 :     if ( bScrollChildren )
    3140             :     {
    3141          50 :         Window* pWindow = mpWindowImpl->mpFirstChild;
    3142         153 :         while ( pWindow )
    3143             :         {
    3144          53 :             Point aPos = pWindow->GetPosPixel();
    3145          53 :             aPos += Point( nHorzScroll, nVertScroll );
    3146          53 :             pWindow->SetPosPixel( aPos );
    3147             : 
    3148          53 :             pWindow = pWindow->mpWindowImpl->mpNext;
    3149             :         }
    3150             :     }
    3151             : 
    3152         303 :     if ( nFlags & SCROLL_UPDATE )
    3153           0 :         Update();
    3154             : 
    3155         303 :     if ( mpWindowImpl->mpCursor )
    3156         492 :         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       21265 : void Window::ImplUpdateWindowPtr( Window* pWindow )
    3190             : {
    3191       21265 :     if ( mpWindowImpl->mpFrameWindow != pWindow->mpWindowImpl->mpFrameWindow )
    3192             :     {
    3193             :         // release graphic
    3194       11856 :         OutputDevice *pOutDev = GetOutDev();
    3195       11856 :         pOutDev->ImplReleaseGraphics();
    3196             :     }
    3197             : 
    3198       21265 :     mpWindowImpl->mpFrameData     = pWindow->mpWindowImpl->mpFrameData;
    3199       21265 :     mpWindowImpl->mpFrame         = pWindow->mpWindowImpl->mpFrame;
    3200       21265 :     mpWindowImpl->mpFrameWindow   = pWindow->mpWindowImpl->mpFrameWindow;
    3201       21265 :     if ( pWindow->ImplIsOverlapWindow() )
    3202          28 :         mpWindowImpl->mpOverlapWindow = pWindow;
    3203             :     else
    3204       21237 :         mpWindowImpl->mpOverlapWindow = pWindow->mpWindowImpl->mpOverlapWindow;
    3205             : 
    3206       21265 :     Window* pChild = mpWindowImpl->mpFirstChild;
    3207       56727 :     while ( pChild )
    3208             :     {
    3209       14197 :         pChild->ImplUpdateWindowPtr( pWindow );
    3210       14197 :         pChild = pChild->mpWindowImpl->mpNext;
    3211             :     }
    3212       21265 : }
    3213             : 
    3214       10432 : void Window::ImplUpdateWindowPtr()
    3215             : {
    3216       10432 :     Window* pChild = mpWindowImpl->mpFirstChild;
    3217       27932 :     while ( pChild )
    3218             :     {
    3219        7068 :         pChild->ImplUpdateWindowPtr( this );
    3220        7068 :         pChild = pChild->mpWindowImpl->mpNext;
    3221             :     }
    3222       10432 : }
    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      780472 : bool Window::ImplUpdatePos()
    3252             : {
    3253      780472 :     bool bSysChild = false;
    3254             : 
    3255      780472 :     if ( ImplIsOverlapWindow() )
    3256             :     {
    3257        4611 :         mnOutOffX  = mpWindowImpl->mnX;
    3258        4611 :         mnOutOffY  = mpWindowImpl->mnY;
    3259             :     }
    3260             :     else
    3261             :     {
    3262      775861 :         Window* pParent = ImplGetParent();
    3263             : 
    3264      775861 :         mnOutOffX  = mpWindowImpl->mnX + pParent->mnOutOffX;
    3265      775861 :         mnOutOffY  = mpWindowImpl->mnY + pParent->mnOutOffY;
    3266             :     }
    3267             : 
    3268      780472 :     Window* pChild = mpWindowImpl->mpFirstChild;
    3269     2062156 :     while ( pChild )
    3270             :     {
    3271      501212 :         if ( pChild->ImplUpdatePos() )
    3272           0 :             bSysChild = true;
    3273      501212 :         pChild = pChild->mpWindowImpl->mpNext;
    3274             :     }
    3275             : 
    3276      780472 :     if ( mpWindowImpl->mpSysObj )
    3277           0 :         bSysChild = true;
    3278             : 
    3279      780472 :     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      322596 : void Window::ImplPosSizeWindow( long nX, long nY,
    3296             :                                 long nWidth, long nHeight, sal_uInt16 nFlags )
    3297             : {
    3298      322596 :     bool    bNewPos         = false;
    3299      322596 :     bool    bNewSize        = false;
    3300      322596 :     bool    bCopyBits       = false;
    3301      322596 :     long    nOldOutOffX     = mnOutOffX;
    3302      322596 :     long    nOldOutOffY     = mnOutOffY;
    3303      322596 :     long    nOldOutWidth    = mnOutWidth;
    3304      322596 :     long    nOldOutHeight   = mnOutHeight;
    3305      322596 :     Region* pOverlapRegion  = NULL;
    3306      322596 :     Region* pOldRegion      = NULL;
    3307             : 
    3308      322596 :     if ( IsReallyVisible() )
    3309             :     {
    3310      114608 :         if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    3311           0 :             ImplInvalidateAllOverlapBackgrounds();
    3312             : 
    3313             :         Rectangle aOldWinRect( Point( nOldOutOffX, nOldOutOffY ),
    3314      114608 :                                Size( nOldOutWidth, nOldOutHeight ) );
    3315      114608 :         pOldRegion = new Region( aOldWinRect );
    3316      114608 :         if ( mpWindowImpl->mbWinRegion )
    3317           0 :             pOldRegion->Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    3318             : 
    3319      274360 :         if ( mnOutWidth && mnOutHeight && !mpWindowImpl->mbPaintTransparent &&
    3320      236042 :              !mpWindowImpl->mbInitWinClipRegion && !mpWindowImpl->maWinClipRegion.IsEmpty() &&
    3321       24233 :              !HasPaintEvent() )
    3322        1054 :             bCopyBits = true;
    3323             :     }
    3324             : 
    3325      322596 :     bool bnXRecycled = false; // avoid duplicate mirroring in RTL case
    3326      322596 :     if ( nFlags & WINDOW_POSSIZE_WIDTH )
    3327             :     {
    3328      299530 :         if(!( nFlags & WINDOW_POSSIZE_X ))
    3329             :         {
    3330       71531 :             nX = mpWindowImpl->mnX;
    3331       71531 :             nFlags |= WINDOW_POSSIZE_X;
    3332       71531 :             bnXRecycled = true; // we're using a mnX which was already mirrored in RTL case
    3333             :         }
    3334             : 
    3335      299530 :         if ( nWidth < 0 )
    3336        7001 :             nWidth = 0;
    3337      299530 :         if ( nWidth != mnOutWidth )
    3338             :         {
    3339      101029 :             mnOutWidth = nWidth;
    3340      101029 :             bNewSize = true;
    3341      101029 :             bCopyBits = false;
    3342             :         }
    3343             :     }
    3344      322596 :     if ( nFlags & WINDOW_POSSIZE_HEIGHT )
    3345             :     {
    3346      301567 :         if ( nHeight < 0 )
    3347        3199 :             nHeight = 0;
    3348      301567 :         if ( nHeight != mnOutHeight )
    3349             :         {
    3350      127347 :             mnOutHeight = nHeight;
    3351      127347 :             bNewSize = true;
    3352      127347 :             bCopyBits = false;
    3353             :         }
    3354             :     }
    3355             : 
    3356      322596 :     if ( nFlags & WINDOW_POSSIZE_X )
    3357             :     {
    3358      320551 :         long nOrgX = nX;
    3359             :         // --- RTL ---  (compare the screen coordinates)
    3360      320551 :         Point aPtDev( Point( nX+mnOutOffX, 0 ) );
    3361      320551 :         OutputDevice *pOutDev = GetOutDev();
    3362      320551 :         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      320551 :         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         527 :                 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      320551 :         if ( mpWindowImpl->mnAbsScreenX != aPtDev.X() || nX != mpWindowImpl->mnX || nOrgX != mpWindowImpl->maPos.X() )
    3397             :         {
    3398      114892 :             if ( bCopyBits && !pOverlapRegion )
    3399             :             {
    3400          20 :                 pOverlapRegion = new Region();
    3401             :                 ImplCalcOverlapRegion( Rectangle( Point( mnOutOffX, mnOutOffY ),
    3402             :                                                   Size( mnOutWidth, mnOutHeight ) ),
    3403          20 :                                        *pOverlapRegion, false, true, true );
    3404             :             }
    3405      114892 :             mpWindowImpl->mnX = nX;
    3406      114892 :             mpWindowImpl->maPos.X() = nOrgX;
    3407      114892 :             mpWindowImpl->mnAbsScreenX = aPtDev.X();    // --- RTL --- (store real screen pos)
    3408      114892 :             bNewPos = true;
    3409             :         }
    3410             :     }
    3411      322596 :     if ( nFlags & WINDOW_POSSIZE_Y )
    3412             :     {
    3413             :         // check maPos as well, as it could have been changed for client windows (ImplCallMove())
    3414      249020 :         if ( nY != mpWindowImpl->mnY || nY != mpWindowImpl->maPos.Y() )
    3415             :         {
    3416       84321 :             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       84321 :             mpWindowImpl->mnY = nY;
    3424       84321 :             mpWindowImpl->maPos.Y() = nY;
    3425       84321 :             bNewPos = true;
    3426             :         }
    3427             :     }
    3428             : 
    3429      322596 :     if ( bNewPos || bNewSize )
    3430             :     {
    3431      214995 :         bool bUpdateSysObjPos = false;
    3432      214995 :         if ( bNewPos )
    3433      151889 :             bUpdateSysObjPos = ImplUpdatePos();
    3434             : 
    3435             :         // the borderwindow always specifies the position for its client window
    3436      214995 :         if ( mpWindowImpl->mpBorderWindow )
    3437       38977 :             mpWindowImpl->maPos = mpWindowImpl->mpBorderWindow->mpWindowImpl->maPos;
    3438             : 
    3439      214995 :         if ( mpWindowImpl->mpClientWindow )
    3440             :         {
    3441             :             mpWindowImpl->mpClientWindow->ImplPosSizeWindow( mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder,
    3442             :                                                mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder,
    3443       17492 :                                                mnOutWidth-mpWindowImpl->mpClientWindow->mpWindowImpl->mnLeftBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnRightBorder,
    3444       17492 :                                                mnOutHeight-mpWindowImpl->mpClientWindow->mpWindowImpl->mnTopBorder-mpWindowImpl->mpClientWindow->mpWindowImpl->mnBottomBorder,
    3445             :                                                WINDOW_POSSIZE_X | WINDOW_POSSIZE_Y |
    3446       34984 :                                                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       17492 :             mpWindowImpl->mpClientWindow->mpWindowImpl->maPos = mpWindowImpl->maPos;
    3450       17492 :             if ( bNewPos )
    3451             :             {
    3452        8425 :                 if ( mpWindowImpl->mpClientWindow->IsVisible() )
    3453             :                 {
    3454        5366 :                     mpWindowImpl->mpClientWindow->ImplCallMove();
    3455             :                 }
    3456             :                 else
    3457             :                 {
    3458        3059 :                     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      214995 :         if ( IsVisible() )
    3466             :         {
    3467      118737 :             if ( bNewPos )
    3468             :             {
    3469       94101 :                 ImplCallMove();
    3470             :             }
    3471      118737 :             if ( bNewSize )
    3472             :             {
    3473       79646 :                 ImplCallResize();
    3474             :             }
    3475             :         }
    3476             :         else
    3477             :         {
    3478       96258 :             if ( bNewPos )
    3479       57788 :                 mpWindowImpl->mbCallMove = true;
    3480       96258 :             if ( bNewSize )
    3481       81079 :                 mpWindowImpl->mbCallResize = true;
    3482             :         }
    3483             : 
    3484      214995 :         bool bUpdateSysObjClip = false;
    3485      214995 :         if ( IsReallyVisible() )
    3486             :         {
    3487       62569 :             if ( bNewPos || bNewSize )
    3488             :             {
    3489             :                 // reset background storage
    3490       62569 :                 if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mpSaveBackDev )
    3491           0 :                     ImplDeleteOverlapBackground();
    3492       62569 :                 if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    3493           0 :                     ImplInvalidateAllOverlapBackgrounds();
    3494             :                 // set Clip-Flag
    3495       62569 :                 bUpdateSysObjClip = !ImplSetClipFlag( true );
    3496             :             }
    3497             : 
    3498             :             // invalidate window content ?
    3499       62569 :             if ( bNewPos || (mnOutWidth > nOldOutWidth) || (mnOutHeight > nOldOutHeight) )
    3500             :             {
    3501       50730 :                 if ( bNewPos )
    3502             :                 {
    3503       45762 :                     bool bInvalidate = false;
    3504       45762 :                     bool bParentPaint = true;
    3505       45762 :                     if ( !ImplIsOverlapWindow() )
    3506       45762 :                         bParentPaint = mpWindowImpl->mpParent->IsPaintEnabled();
    3507       45762 :                     if ( bCopyBits && bParentPaint && !HasPaintEvent() )
    3508             :                     {
    3509          20 :                         Point aPoint( mnOutOffX, mnOutOffY );
    3510             :                         Region aRegion( Rectangle( aPoint,
    3511          20 :                                                    Size( mnOutWidth, mnOutHeight ) ) );
    3512          20 :                         if ( mpWindowImpl->mbWinRegion )
    3513           0 :                             aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    3514          20 :                         ImplClipBoundaries( aRegion, false, true );
    3515          20 :                         if ( !pOverlapRegion->IsEmpty() )
    3516             :                         {
    3517           0 :                             pOverlapRegion->Move( mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY );
    3518           0 :                             aRegion.Exclude( *pOverlapRegion );
    3519             :                         }
    3520          20 :                         if ( !aRegion.IsEmpty() )
    3521             :                         {
    3522             :                             // adapt Paint areas
    3523             :                             ImplMoveAllInvalidateRegions( Rectangle( Point( nOldOutOffX, nOldOutOffY ),
    3524             :                                                                      Size( nOldOutWidth, nOldOutHeight ) ),
    3525             :                                                           mnOutOffX-nOldOutOffX, mnOutOffY-nOldOutOffY,
    3526          20 :                                                           true );
    3527          20 :                             SalGraphics* pGraphics = ImplGetFrameGraphics();
    3528          20 :                             if ( pGraphics )
    3529             :                             {
    3530             : 
    3531          20 :                                 OutputDevice *pOutDev = GetOutDev();
    3532          20 :                                 const bool bSelectClipRegion = pOutDev->ImplSelectClipRegion( aRegion, pGraphics );
    3533          20 :                                 if ( bSelectClipRegion )
    3534             :                                 {
    3535             :                                     pGraphics->CopyArea( mnOutOffX, mnOutOffY,
    3536             :                                                          nOldOutOffX, nOldOutOffY,
    3537             :                                                          nOldOutWidth, nOldOutHeight,
    3538          20 :                                                          SAL_COPYAREA_WINDOWINVALIDATE, this );
    3539             :                                 }
    3540             :                                 else
    3541           0 :                                     bInvalidate = true;
    3542             :                             }
    3543             :                             else
    3544           0 :                                 bInvalidate = true;
    3545          20 :                             if ( !bInvalidate )
    3546             :                             {
    3547          20 :                                 if ( !pOverlapRegion->IsEmpty() )
    3548           0 :                                     ImplInvalidateFrameRegion( pOverlapRegion, INVALIDATE_CHILDREN );
    3549             :                             }
    3550             :                         }
    3551             :                         else
    3552           0 :                             bInvalidate = true;
    3553             :                     }
    3554             :                     else
    3555       45742 :                         bInvalidate = true;
    3556       45762 :                     if ( bInvalidate )
    3557       45742 :                         ImplInvalidateFrameRegion( NULL, INVALIDATE_CHILDREN );
    3558             :                 }
    3559             :                 else
    3560             :                 {
    3561        4968 :                     Point aPoint( mnOutOffX, mnOutOffY );
    3562             :                     Region aRegion( Rectangle( aPoint,
    3563        4968 :                                                Size( mnOutWidth, mnOutHeight ) ) );
    3564        4968 :                     aRegion.Exclude( *pOldRegion );
    3565        4968 :                     if ( mpWindowImpl->mbWinRegion )
    3566           0 :                         aRegion.Intersect( ImplPixelToDevicePixel( mpWindowImpl->maWinRegion ) );
    3567        4968 :                     ImplClipBoundaries( aRegion, false, true );
    3568        4968 :                     if ( !aRegion.IsEmpty() )
    3569        4723 :                         ImplInvalidateFrameRegion( &aRegion, INVALIDATE_CHILDREN );
    3570             :                 }
    3571             :             }
    3572             : 
    3573             :             // invalidate Parent or Overlaps
    3574       79376 :             if ( bNewPos ||
    3575       30975 :                  (mnOutWidth < nOldOutWidth) || (mnOutHeight < nOldOutHeight) )
    3576             :             {
    3577       57604 :                 Region aRegion( *pOldRegion );
    3578       57604 :                 if ( !mpWindowImpl->mbPaintTransparent )
    3579       57421 :                     ImplExcludeWindowRegion( aRegion );
    3580       57604 :                 ImplClipBoundaries( aRegion, false, true );
    3581       57604 :                 if ( !aRegion.IsEmpty() && !mpWindowImpl->mpBorderWindow )
    3582       15000 :                     ImplInvalidateParentFrameRegion( aRegion );
    3583             :             }
    3584             :         }
    3585             : 
    3586             :         // adapt system objects
    3587      214995 :         if ( bUpdateSysObjClip )
    3588           0 :             ImplUpdateSysObjClip();
    3589      214995 :         if ( bUpdateSysObjPos )
    3590           0 :             ImplUpdateSysObjPos();
    3591      214995 :         if ( bNewSize && mpWindowImpl->mpSysObj )
    3592           0 :             mpWindowImpl->mpSysObj->SetPosSize( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight );
    3593             :     }
    3594             : 
    3595      322596 :     delete pOverlapRegion;
    3596      322596 :     delete pOldRegion;
    3597      322596 : }
    3598             : 
    3599        4077 : void Window::ImplToBottomChild()
    3600             : {
    3601        4077 :     if ( !ImplIsOverlapWindow() && !mpWindowImpl->mbReallyVisible && (mpWindowImpl->mpParent->mpWindowImpl->mpLastChild != this) )
    3602             :     {
    3603             :         // put the window to the end of the list
    3604         754 :         if ( mpWindowImpl->mpPrev )
    3605           0 :             mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    3606             :         else
    3607         754 :             mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
    3608         754 :         mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    3609         754 :         mpWindowImpl->mpPrev = mpWindowImpl->mpParent->mpWindowImpl->mpLastChild;
    3610         754 :         mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this;
    3611         754 :         mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    3612         754 :         mpWindowImpl->mpNext = NULL;
    3613             :     }
    3614        4077 : }
    3615             : 
    3616        2722 : void Window::ImplCalcToTop( ImplCalcToTopData* pPrevData )
    3617             : {
    3618             :     DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplCalcToTop(): Is not a OverlapWindow" );
    3619             : 
    3620        2722 :     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        2722 : }
    3642             : 
    3643        2722 : void Window::ImplToTop( sal_uInt16 nFlags )
    3644             : {
    3645             :     DBG_ASSERT( ImplIsOverlapWindow(), "Window::ImplToTop(): Is not a OverlapWindow" );
    3646             : 
    3647        2722 :     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        4828 :         if ( !mpWindowImpl->mpFrameData->mbHasFocus &&
    3652        4212 :              !mpWindowImpl->mpFrameData->mbSysObjFocus &&
    3653        4212 :              !mpWindowImpl->mpFrameData->mbInSysObjFocusHdl &&
    3654        2106 :              !mpWindowImpl->mpFrameData->mbInSysObjToTopHdl )
    3655             :         {
    3656             :             // do not bring floating windows on the client to top
    3657        2106 :             if( !ImplGetClientWindow() || !(ImplGetClientWindow()->GetStyle() & WB_SYSTEMFLOATWIN) )
    3658             :             {
    3659        2106 :                 sal_uInt16 nSysFlags = 0;
    3660        2106 :                 if ( nFlags & TOTOP_RESTOREWHENMIN )
    3661          60 :                     nSysFlags |= SAL_FRAME_TOTOP_RESTOREWHENMIN;
    3662        2106 :                 if ( nFlags & TOTOP_FOREGROUNDTASK )
    3663           0 :                     nSysFlags |= SAL_FRAME_TOTOP_FOREGROUNDTASK;
    3664        2106 :                 if ( nFlags & TOTOP_GRABFOCUSONLY )
    3665           0 :                     nSysFlags |= SAL_FRAME_TOTOP_GRABFOCUS_ONLY;
    3666        2106 :                 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        2722 : }
    3732             : 
    3733        2722 : void Window::ImplStartToTop( sal_uInt16 nFlags )
    3734             : {
    3735             :     ImplCalcToTopData   aStartData;
    3736             :     ImplCalcToTopData*  pCurData;
    3737             :     ImplCalcToTopData*  pNextData;
    3738             :     Window* pOverlapWindow;
    3739        2722 :     if ( ImplIsOverlapWindow() )
    3740        2059 :         pOverlapWindow = this;
    3741             :     else
    3742         663 :         pOverlapWindow = mpWindowImpl->mpOverlapWindow;
    3743             : 
    3744             :     // first calculate paint areas
    3745        2722 :     Window* pTempOverlapWindow = pOverlapWindow;
    3746        2722 :     aStartData.mpNext = NULL;
    3747        2722 :     pCurData = &aStartData;
    3748        2722 :     do
    3749             :     {
    3750        2722 :         pTempOverlapWindow->ImplCalcToTop( pCurData );
    3751        2722 :         if ( pCurData->mpNext )
    3752           0 :             pCurData = pCurData->mpNext;
    3753        2722 :         pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpOverlapWindow;
    3754             :     }
    3755        2722 :     while ( !pTempOverlapWindow->mpWindowImpl->mbFrame );
    3756             :     // next calculate the paint areas of the ChildOverlap windows
    3757        2722 :     pTempOverlapWindow = mpWindowImpl->mpFirstOverlap;
    3758        5444 :     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        2722 :     pTempOverlapWindow = pOverlapWindow;
    3768        2722 :     do
    3769             :     {
    3770        2722 :         pTempOverlapWindow->ImplToTop( nFlags );
    3771        2722 :         pTempOverlapWindow = pTempOverlapWindow->mpWindowImpl->mpOverlapWindow;
    3772             :     }
    3773        2722 :     while ( !pTempOverlapWindow->mpWindowImpl->mbFrame );
    3774             :     // as last step invalidate the invalid areas
    3775        2722 :     pCurData = aStartData.mpNext;
    3776        5444 :     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        2722 : }
    3785             : 
    3786        2722 : void Window::ImplFocusToTop( sal_uInt16 nFlags, bool bReallyVisible )
    3787             : {
    3788             :     // do we need to fetch the focus?
    3789        2722 :     if ( !(nFlags & TOTOP_NOGRABFOCUS) )
    3790             :     {
    3791             :         // first window with GrabFocus-Activate gets the focus
    3792        2722 :         Window* pFocusWindow = this;
    3793        6107 :         while ( !pFocusWindow->ImplIsOverlapWindow() )
    3794             :         {
    3795             :             // if the window has no BorderWindow, we
    3796             :             // should always find the belonging BorderWindow
    3797         663 :             if ( !pFocusWindow->mpWindowImpl->mpBorderWindow )
    3798             :             {
    3799           0 :                 if ( pFocusWindow->mpWindowImpl->mnActivateMode & ACTIVATE_MODE_GRABFOCUS )
    3800           0 :                     break;
    3801             :             }
    3802         663 :             pFocusWindow = pFocusWindow->ImplGetParent();
    3803             :         }
    3804        5440 :         if ( (pFocusWindow->mpWindowImpl->mnActivateMode & ACTIVATE_MODE_GRABFOCUS) &&
    3805        2718 :              !pFocusWindow->HasChildPathFocus( true ) )
    3806        2120 :             pFocusWindow->GrabFocus();
    3807             :     }
    3808             : 
    3809        2722 :     if ( bReallyVisible )
    3810         656 :         ImplGenerateMouseMove();
    3811        2722 : }
    3812             : 
    3813       73439 : void Window::ImplShowAllOverlaps()
    3814             : {
    3815       73439 :     Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
    3816      146878 :     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       73439 : }
    3827             : 
    3828       73090 : void Window::ImplHideAllOverlaps()
    3829             : {
    3830       73090 :     Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
    3831      146180 :     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       73090 : }
    3842             : 
    3843        4187 : void Window::ImplCallMouseMove( sal_uInt16 nMouseCode, bool bModChanged )
    3844             : {
    3845        4187 :     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        4187 : }
    3867             : 
    3868      211116 : void Window::ImplGenerateMouseMove()
    3869             : {
    3870      211116 :     if ( !mpWindowImpl->mpFrameData->mnMouseMoveId )
    3871        6225 :         Application::PostUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId, LINK( mpWindowImpl->mpFrameWindow, Window, ImplGenerateMouseMoveHdl ) );
    3872      211116 : }
    3873             : 
    3874        8374 : IMPL_LINK_NOARG(Window, ImplGenerateMouseMoveHdl)
    3875             : {
    3876        4187 :     mpWindowImpl->mpFrameData->mnMouseMoveId = 0;
    3877        4187 :     Window* pCaptureWin = ImplGetSVData()->maWinData.mpCaptureWin;
    3878        4187 :     if( ! pCaptureWin ||
    3879           0 :         (pCaptureWin->mpWindowImpl && pCaptureWin->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame)
    3880             :     )
    3881             :     {
    3882        4187 :         ImplCallMouseMove( mpWindowImpl->mpFrameData->mnMouseCode );
    3883             :     }
    3884        4187 :     return 0;
    3885             : }
    3886             : 
    3887           9 : void Window::ImplInvertFocus( const Rectangle& rRect )
    3888             : {
    3889           9 :     InvertTracking( rRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
    3890           9 : }
    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       13425 : static bool IsWindowFocused(const WindowImpl& rWinImpl)
    3970             : {
    3971       13425 :     if (rWinImpl.mpSysObj)
    3972           0 :         return true;
    3973             : 
    3974       13425 :     if (rWinImpl.mpFrameData->mbHasFocus)
    3975       11298 :         return true;
    3976             : 
    3977        2127 :     if (rWinImpl.mbFakeFocusSet)
    3978           0 :         return true;
    3979             : 
    3980        2127 :     return false;
    3981             : }
    3982             : 
    3983       19213 : void Window::ImplGrabFocus( sal_uInt16 nFlags )
    3984             : {
    3985             :     // #143570# no focus for destructing windows
    3986       19213 :     if( mpWindowImpl->mbInDtor )
    3987        9750 :         return;
    3988             : 
    3989             :     // some event listeners do really bad stuff
    3990             :     // => prepare for the worst
    3991       17378 :     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       17378 :     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        7776 :         if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) &&
    4004        3824 :              !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) &&
    4005        3824 :              mpWindowImpl->mpLastFocusWindow->IsEnabled() &&
    4006        7775 :              mpWindowImpl->mpLastFocusWindow->IsInputEnabled() &&
    4007        1911 :              ! mpWindowImpl->mpLastFocusWindow->IsInModalMode()
    4008             :              )
    4009        1911 :             mpWindowImpl->mpLastFocusWindow->GrabFocus();
    4010             :         else
    4011        2041 :             mpWindowImpl->mpClientWindow->GrabFocus();
    4012        3952 :         return;
    4013             :     }
    4014       13426 :     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          15 :         if ( mpWindowImpl->mpLastFocusWindow && (mpWindowImpl->mpLastFocusWindow != this) &&
    4020           0 :              !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) &&
    4021           0 :              mpWindowImpl->mpLastFocusWindow->IsEnabled() &&
    4022           9 :              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       13426 :     if ( !IsEnabled() || !IsInputEnabled() || IsInModalNonRefMode() )
    4033           1 :         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       13425 :     ImplSVData* pSVData = ImplGetSVData();
    4040             : 
    4041       13425 :     bool bAsyncFocusWaiting = false;
    4042       13425 :     Window *pFrame = pSVData->maWinData.mpFirstFrame;
    4043       64994 :     while( pFrame  )
    4044             :     {
    4045       38144 :         if( pFrame != mpWindowImpl->mpFrameWindow && pFrame->mpWindowImpl->mpFrameData->mnFocusId )
    4046             :         {
    4047           0 :             bAsyncFocusWaiting = true;
    4048           0 :             break;
    4049             :         }
    4050       38144 :         pFrame = pFrame->mpWindowImpl->mpFrameData->mpNextFrame;
    4051             :     }
    4052             : 
    4053       13425 :     bool bHasFocus = IsWindowFocused(*mpWindowImpl);
    4054             : 
    4055       13425 :     bool bMustNotGrabFocus = false;
    4056             :     // #100242#, check parent hierarchy if some floater prohibits grab focus
    4057             : 
    4058       13425 :     Window *pParent = this;
    4059       74802 :     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       47952 :         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       47952 :         pParent = pParent->mpWindowImpl->mpParent;
    4069             :     }
    4070             : 
    4071       13425 :     if ( ( pSVData->maWinData.mpFocusWin != this && ! mpWindowImpl->mbInDtor ) || ( bAsyncFocusWaiting && !bHasFocus && !bMustNotGrabFocus ) )
    4072             :     {
    4073             :         // EndExtTextInput if it is not the same window
    4074       13372 :         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       13372 :         Window* pOverlapWindow = ImplGetFirstOverlapWindow();
    4080       13372 :         pOverlapWindow->mpWindowImpl->mpLastFocusWindow = this;
    4081       13372 :         mpWindowImpl->mpFrameData->mpFocusWin = this;
    4082             : 
    4083       13372 :         if( !bHasFocus )
    4084             :         {
    4085             :             // menu windows never get the system focus
    4086             :             // the application will keep the focus
    4087        2127 :             if( bMustNotGrabFocus )
    4088        2127 :                 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        2127 :                 mpWindowImpl->mpFrame->ToTop( SAL_FRAME_TOTOP_GRABFOCUS | SAL_FRAME_TOTOP_GRABFOCUS_ONLY );
    4095        2127 :                 return;
    4096             :             }
    4097             :         }
    4098             : 
    4099       11245 :         Window* pOldFocusWindow = pSVData->maWinData.mpFocusWin;
    4100       11245 :         ImplDelData aOldFocusDel( pOldFocusWindow );
    4101             : 
    4102       11245 :         pSVData->maWinData.mpFocusWin = this;
    4103             : 
    4104       11245 :         if ( pOldFocusWindow )
    4105             :         {
    4106             :             // Cursor hidden
    4107        9374 :             if ( pOldFocusWindow->mpWindowImpl->mpCursor )
    4108        1535 :                 pOldFocusWindow->mpWindowImpl->mpCursor->ImplHide( true );
    4109             :         }
    4110             : 
    4111             :         // !!!!! due to old SV-Office Activate/Deactivate handling
    4112             :         // !!!!! first as before
    4113       11245 :         if ( pOldFocusWindow )
    4114             :         {
    4115             :             // remember Focus
    4116        9374 :             Window* pOldOverlapWindow = pOldFocusWindow->ImplGetFirstOverlapWindow();
    4117        9374 :             Window* pNewOverlapWindow = ImplGetFirstOverlapWindow();
    4118        9374 :             if ( pOldOverlapWindow != pNewOverlapWindow )
    4119           0 :                 ImplCallFocusChangeActivate( pNewOverlapWindow, pOldOverlapWindow );
    4120             :         }
    4121             :         else
    4122             :         {
    4123        1871 :             Window* pNewOverlapWindow = ImplGetFirstOverlapWindow();
    4124        1871 :             Window* pNewRealWindow = pNewOverlapWindow->ImplGetWindow();
    4125        1871 :             pNewOverlapWindow->mpWindowImpl->mbActive = true;
    4126        1871 :             pNewOverlapWindow->Activate();
    4127        1871 :             if ( pNewRealWindow != pNewOverlapWindow )
    4128             :             {
    4129        1868 :                 pNewRealWindow->mpWindowImpl->mbActive = true;
    4130        1868 :                 pNewRealWindow->Activate();
    4131             :             }
    4132             :         }
    4133             : 
    4134             :         // call Get- and LoseFocus
    4135       11245 :         if ( pOldFocusWindow && ! aOldFocusDel.IsDead() )
    4136             :         {
    4137        9374 :             if ( pOldFocusWindow->IsTracking() &&
    4138           0 :                  (pSVData->maWinData.mnTrackFlags & STARTTRACK_FOCUSCANCEL) )
    4139           0 :                 pOldFocusWindow->EndTracking( ENDTRACK_CANCEL | ENDTRACK_FOCUS );
    4140        9374 :             NotifyEvent aNEvt( EVENT_LOSEFOCUS, pOldFocusWindow );
    4141        9374 :             if ( !ImplCallPreNotify( aNEvt ) )
    4142        9374 :                 pOldFocusWindow->LoseFocus();
    4143        9374 :             pOldFocusWindow->ImplCallDeactivateListeners( this );
    4144             :         }
    4145             : 
    4146       11245 :         if ( pSVData->maWinData.mpFocusWin == this )
    4147             :         {
    4148       11245 :             if ( mpWindowImpl->mpSysObj )
    4149             :             {
    4150           0 :                 mpWindowImpl->mpFrameData->mpFocusWin = this;
    4151           0 :                 if ( !mpWindowImpl->mpFrameData->mbInSysObjFocusHdl )
    4152           0 :                     mpWindowImpl->mpSysObj->GrabFocus();
    4153             :             }
    4154             : 
    4155       11245 :             if ( pSVData->maWinData.mpFocusWin == this )
    4156             :             {
    4157       11245 :                 if ( mpWindowImpl->mpCursor )
    4158        1555 :                     mpWindowImpl->mpCursor->ImplShow();
    4159       11245 :                 mpWindowImpl->mbInFocusHdl = true;
    4160       11245 :                 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       20619 :                 if( pOldFocusWindow &&
    4165       20619 :                     ! aOldFocusDel.IsDead() &&
    4166        9374 :                     ( pOldFocusWindow->GetDialogControlFlags() & WINDOW_DLGCTRL_FLOATWIN_POPUPMODEEND_CANCEL ) )
    4167           0 :                     mpWindowImpl->mnGetFocusFlags |= GETFOCUS_FLOATWIN_POPUPMODEEND_CANCEL;
    4168       11245 :                 NotifyEvent aNEvt( EVENT_GETFOCUS, this );
    4169       11245 :                 if ( !ImplCallPreNotify( aNEvt ) && !aDogTag.IsDead() )
    4170       11245 :                     GetFocus();
    4171       11245 :                 if( !aDogTag.IsDead() )
    4172       11245 :                     ImplCallActivateListeners( (pOldFocusWindow && ! aOldFocusDel.IsDead()) ? pOldFocusWindow : NULL );
    4173       11245 :                 if( !aDogTag.IsDead() )
    4174             :                 {
    4175       11245 :                     mpWindowImpl->mnGetFocusFlags = 0;
    4176       11245 :                     mpWindowImpl->mbInFocusHdl = false;
    4177             :                 }
    4178             :             }
    4179             :         }
    4180             : 
    4181       11245 :         GetpApp()->FocusChanged();
    4182       11245 :         ImplNewInputContext();
    4183       11298 :     }
    4184             : }
    4185             : 
    4186           2 : void Window::ImplGrabFocusToDocument( sal_uInt16 nFlags )
    4187             : {
    4188           2 :     Window *pWin = this;
    4189           6 :     while( pWin )
    4190             :     {
    4191           4 :         if( !pWin->GetParent() )
    4192             :         {
    4193           2 :             pWin->ImplGetFrameWindow()->GetWindow( WINDOW_CLIENT )->ImplGrabFocus(nFlags);
    4194           4 :             return;
    4195             :         }
    4196           2 :         pWin = pWin->GetParent();
    4197             :     }
    4198             : }
    4199             : 
    4200       12253 : void Window::ImplNewInputContext()
    4201             : {
    4202       12253 :     ImplSVData* pSVData = ImplGetSVData();
    4203       12253 :     Window*     pFocusWin = pSVData->maWinData.mpFocusWin;
    4204       12253 :     if ( !pFocusWin )
    4205        8470 :         return;
    4206             : 
    4207             :     // Is InputContext changed?
    4208       12253 :     const InputContext& rInputContext = pFocusWin->GetInputContext();
    4209       12253 :     if ( rInputContext == pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext )
    4210        8470 :         return;
    4211             : 
    4212        3783 :     pFocusWin->mpWindowImpl->mpFrameData->maOldInputContext = rInputContext;
    4213             : 
    4214             :     SalInputContext         aNewContext;
    4215        3783 :     const Font&             rFont = rInputContext.GetFont();
    4216        3783 :     const OUString&         rFontName = rFont.GetName();
    4217        3783 :     ImplFontEntry*          pFontEntry = NULL;
    4218        3783 :     aNewContext.mpFont = NULL;
    4219        3783 :     if (!rFontName.isEmpty())
    4220             :     {
    4221         398 :         OutputDevice *pFocusWinOutDev = pFocusWin->GetOutDev();
    4222         398 :         Size aSize = pFocusWinOutDev->ImplLogicToDevicePixel( rFont.GetSize() );
    4223         398 :         if ( !aSize.Height() )
    4224             :         {
    4225             :             // only set default sizes if the font height in logical
    4226             :             // coordinates equals 0
    4227         376 :             if ( rFont.GetSize().Height() )
    4228           0 :                 aSize.Height() = 1;
    4229             :             else
    4230         376 :                 aSize.Height() = (12*pFocusWin->mnDPIY)/72;
    4231             :         }
    4232             :         pFontEntry = pFocusWin->mpFontCache->GetFontEntry( pFocusWin->mpFontCollection,
    4233         398 :                          rFont, aSize, static_cast<float>(aSize.Height()) );
    4234         398 :         if ( pFontEntry )
    4235         398 :             aNewContext.mpFont = &pFontEntry->maFontSelData;
    4236             :     }
    4237        3783 :     aNewContext.meLanguage  = rFont.GetLanguage();
    4238        3783 :     aNewContext.mnOptions   = rInputContext.GetOptions();
    4239        3783 :     pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext );
    4240             : 
    4241        3783 :     if ( pFontEntry )
    4242         398 :         pFocusWin->mpFontCache->Release( pFontEntry );
    4243             : }
    4244             : 
    4245      100554 : Window::Window( WindowType nType )
    4246             : {
    4247      100554 :     ImplInitWindowData( nType );
    4248      100554 : }
    4249             : 
    4250       16385 : Window::Window( Window* pParent, WinBits nStyle )
    4251             : {
    4252             : 
    4253       16385 :     ImplInitWindowData( WINDOW_WINDOW );
    4254       16385 :     ImplInit( pParent, nStyle, NULL );
    4255       16385 : }
    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      232388 : Window::~Window()
    4294             : {
    4295      116183 :     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      116183 :     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      116183 :     uno::Reference< rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
    4305      116183 :     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      116183 :     mpWindowImpl->mbInDtor = true;
    4314             : 
    4315      116183 :     ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
    4316             : 
    4317             :     // do not send child events for frames that were registered as native frames
    4318      116183 :     if( !ImplIsAccessibleNativeFrame() && mpWindowImpl->mbReallyVisible )
    4319       29209 :         if ( ImplIsAccessibleCandidate() && GetAccessibleParentWindow() )
    4320       29207 :             GetAccessibleParentWindow()->ImplCallEventListeners( VCLEVENT_WINDOW_CHILDDESTROYED, this );
    4321             : 
    4322             :     // remove associated data structures from dockingmanager
    4323      116183 :     ImplGetDockingManager()->RemoveWindow( this );
    4324             : 
    4325             :     // remove ownerdraw decorated windows from list in the top-most frame window
    4326      116183 :     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      232366 :     ::com::sun::star::uno::Reference < ::com::sun::star::lang::XComponent > xDnDComponent( mpWindowImpl->mxDNDListenerContainer, ::com::sun::star::uno::UNO_QUERY );
    4337             : 
    4338      116183 :     if( xDnDComponent.is() )
    4339       13331 :         xDnDComponent->dispose();
    4340             : 
    4341      116183 :     if( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
    4342             :     {
    4343             :         try
    4344             :         {
    4345             :             // deregister drop target listener
    4346        4524 :             if( mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
    4347             :             {
    4348             :                 uno::Reference< XDragGestureRecognizer > xDragGestureRecognizer =
    4349        1151 :                     uno::Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
    4350        1151 :                 if( xDragGestureRecognizer.is() )
    4351             :                 {
    4352           0 :                     xDragGestureRecognizer->removeDragGestureListener(
    4353           0 :                         uno::Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
    4354             :                 }
    4355             : 
    4356        1151 :                 mpWindowImpl->mpFrameData->mxDropTarget->removeDropTargetListener( mpWindowImpl->mpFrameData->mxDropTargetListener );
    4357        1151 :                 mpWindowImpl->mpFrameData->mxDropTargetListener.clear();
    4358             :             }
    4359             : 
    4360             :             // shutdown drag and drop for this frame window
    4361        4524 :             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        4524 :             if( xComponent.is() )
    4366        1151 :                 xComponent->dispose();
    4367             :         }
    4368           0 :         catch (const Exception&)
    4369             :         {
    4370             :             // can be safely ignored here.
    4371             :         }
    4372             :     }
    4373             : 
    4374      116183 :     UnoWrapperBase* pWrapper = Application::GetUnoWrapper( false );
    4375      116183 :     if ( pWrapper )
    4376      116079 :         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      116183 :     if ( mpWindowImpl->mxAccessible.is() )
    4382             :     {
    4383         261 :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> xC( mpWindowImpl->mxAccessible, ::com::sun::star::uno::UNO_QUERY );
    4384         261 :         if ( xC.is() )
    4385         244 :             xC->dispose();
    4386             :     }
    4387             : 
    4388      116183 :     ImplSVData* pSVData = ImplGetSVData();
    4389             : 
    4390      116183 :     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      116183 :     if ( pSVData->maWinData.mpTrackWin == this )
    4403           0 :         EndTracking();
    4404      116183 :     if ( pSVData->maWinData.mpCaptureWin == this )
    4405           0 :         ReleaseMouse();
    4406      116183 :     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      116183 :     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      116183 :     remove_from_all_size_groups();
    4539             : 
    4540             :     // clear mnemonic labels
    4541      232366 :     std::vector<FixedText*> aMnemonicLabels(list_mnemonic_labels());
    4542      348549 :     for (std::vector<FixedText*>::iterator aI = aMnemonicLabels.begin();
    4543      232366 :         aI != aMnemonicLabels.end(); ++aI)
    4544             :     {
    4545           0 :         remove_mnemonic_label(*aI);
    4546             :     }
    4547             : 
    4548             :     // hide window in order to trigger the Paint-Handling
    4549      116183 :     Hide();
    4550             : 
    4551             :     // announce the window is to be destroyed
    4552             :     {
    4553      116183 :         NotifyEvent aNEvt( EVENT_DESTROY, this );
    4554      116183 :         Notify( aNEvt );
    4555             :     }
    4556             : 
    4557             :     // EndExtTextInputMode
    4558      116183 :     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      116183 :     bool bHasFocussedChild = false;
    4567      116183 :     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      116183 :     Window* pOverlapWindow = ImplGetFirstOverlapWindow();
    4583      116183 :     if ( pSVData->maWinData.mpFocusWin == this
    4584      110669 :         || bHasFocussedChild )  // #122232#, see above, try some cleanup
    4585             :     {
    4586        5514 :         if ( mpWindowImpl->mbFrame )
    4587             :         {
    4588           3 :             pSVData->maWinData.mpFocusWin = NULL;
    4589           3 :             pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
    4590           3 :             GetpApp()->FocusChanged();
    4591             :         }
    4592             :         else
    4593             :         {
    4594        5511 :             Window* pParent = GetParent();
    4595        5511 :             Window* pBorderWindow = mpWindowImpl->mpBorderWindow;
    4596             :         // when windows overlap, give focus to the parent
    4597             :         // of the next FrameWindow
    4598        5511 :             if ( pBorderWindow )
    4599             :             {
    4600        3654 :                 if ( pBorderWindow->ImplIsOverlapWindow() )
    4601        1834 :                     pParent = pBorderWindow->mpWindowImpl->mpOverlapWindow;
    4602             :             }
    4603        1857 :             else if ( ImplIsOverlapWindow() )
    4604           0 :                 pParent = mpWindowImpl->mpOverlapWindow;
    4605             : 
    4606        5511 :             if ( pParent && pParent->IsEnabled() && pParent->IsInputEnabled() && ! pParent->IsInModalMode() )
    4607        5510 :                 pParent->GrabFocus();
    4608             :             else
    4609           1 :                 mpWindowImpl->mpFrameWindow->GrabFocus();
    4610             : 
    4611             :             // If the focus was set back to 'this' set it to nothing
    4612        5511 :             if ( pSVData->maWinData.mpFocusWin == this )
    4613             :             {
    4614        1836 :                 pSVData->maWinData.mpFocusWin = NULL;
    4615        1836 :                 pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
    4616        1836 :                 GetpApp()->FocusChanged();
    4617             :             }
    4618             :         }
    4619             :     }
    4620             : 
    4621      232366 :     if ( pOverlapWindow != 0 &&
    4622      116183 :          pOverlapWindow->mpWindowImpl->mpLastFocusWindow == this )
    4623         214 :         pOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
    4624             : 
    4625             :     // reset hint for DefModalDialogParent
    4626      116183 :     if( pSVData->maWinData.mpActiveApplicationFrame == this )
    4627        1839 :         pSVData->maWinData.mpActiveApplicationFrame = NULL;
    4628             : 
    4629             :     // reset marked windows
    4630      116183 :     if ( mpWindowImpl->mpFrameData != 0 )
    4631             :     {
    4632      116183 :         if ( mpWindowImpl->mpFrameData->mpFocusWin == this )
    4633        2053 :             mpWindowImpl->mpFrameData->mpFocusWin = NULL;
    4634      116183 :         if ( mpWindowImpl->mpFrameData->mpMouseMoveWin == this )
    4635           0 :             mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
    4636      116183 :         if ( mpWindowImpl->mpFrameData->mpMouseDownWin == this )
    4637           0 :             mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
    4638             :     }
    4639             : 
    4640             :     // reset Deactivate-Window
    4641      116183 :     if ( pSVData->maWinData.mpLastDeacWin == this )
    4642           0 :         pSVData->maWinData.mpLastDeacWin = NULL;
    4643             : 
    4644      116183 :     if ( mpWindowImpl->mbFrame && mpWindowImpl->mpFrameData )
    4645             :     {
    4646        4524 :         if ( mpWindowImpl->mpFrameData->mnFocusId )
    4647          33 :             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnFocusId );
    4648        4524 :         if ( mpWindowImpl->mpFrameData->mnMouseMoveId )
    4649        2033 :             Application::RemoveUserEvent( mpWindowImpl->mpFrameData->mnMouseMoveId );
    4650             :     }
    4651             : 
    4652             :     // release SalGraphics
    4653      116183 :     OutputDevice *pOutDev = GetOutDev();
    4654      116183 :     pOutDev->ImplReleaseGraphics();
    4655             : 
    4656             :     // notify ImplDelData subscribers of this window about the window deletion
    4657      116183 :     ImplDelData* pDelData = mpWindowImpl->mpFirstDel;
    4658      232368 :     while ( pDelData )
    4659             :     {
    4660           2 :         pDelData->mbDel = true;
    4661           2 :         pDelData->mpWindow = NULL;  // #112873# pDel is not associated with a Window anymore
    4662           2 :         pDelData = pDelData->mpNext;
    4663             :     }
    4664             : 
    4665             :     // remove window from the lists
    4666      116183 :     ImplRemoveWindow( true );
    4667             : 
    4668             :     // de-register as "top window child" at our parent, if necessary
    4669      116183 :     if ( mpWindowImpl->mbFrame )
    4670             :     {
    4671        4524 :         bool bIsTopWindow = mpWindowImpl->mpWinData && ( mpWindowImpl->mpWinData->mnIsTopWindow == 1 );
    4672        4524 :         if ( mpWindowImpl->mpRealParent && bIsTopWindow )
    4673             :         {
    4674          19 :             ImplWinData* pParentWinData = mpWindowImpl->mpRealParent->ImplGetWinData();
    4675             : 
    4676             :             ::std::list< Window* >::iterator myPos = ::std::find( pParentWinData->maTopWindowChildren.begin(),
    4677          19 :                 pParentWinData->maTopWindowChildren.end(), this );
    4678             :             DBG_ASSERT( myPos != pParentWinData->maTopWindowChildren.end(), "Window::~Window: inconsistency in top window chain!" );
    4679          19 :             if ( myPos != pParentWinData->maTopWindowChildren.end() )
    4680          17 :                 pParentWinData->maTopWindowChildren.erase( myPos );
    4681             :         }
    4682             :     }
    4683             : 
    4684             :     // cleanup Extra Window Data, TODO: add and use ImplWinData destructor
    4685      116183 :     if ( mpWindowImpl->mpWinData )
    4686             :     {
    4687      116079 :         if ( mpWindowImpl->mpWinData->mpExtOldText )
    4688           0 :             delete mpWindowImpl->mpWinData->mpExtOldText;
    4689      116079 :         if ( mpWindowImpl->mpWinData->mpExtOldAttrAry )
    4690           0 :             delete mpWindowImpl->mpWinData->mpExtOldAttrAry;
    4691      116079 :         if ( mpWindowImpl->mpWinData->mpCursorRect )
    4692           0 :             delete mpWindowImpl->mpWinData->mpCursorRect;
    4693      116079 :         if ( mpWindowImpl->mpWinData->mpCompositionCharRects)
    4694           0 :             delete[] mpWindowImpl->mpWinData->mpCompositionCharRects;
    4695      116079 :         if ( mpWindowImpl->mpWinData->mpFocusRect )
    4696           4 :             delete mpWindowImpl->mpWinData->mpFocusRect;
    4697      116079 :         if ( mpWindowImpl->mpWinData->mpTrackRect )
    4698           0 :             delete mpWindowImpl->mpWinData->mpTrackRect;
    4699             : 
    4700      116079 :         delete mpWindowImpl->mpWinData;
    4701             :     }
    4702             : 
    4703             :     // cleanup overlap related window data
    4704      116183 :     if ( mpWindowImpl->mpOverlapData )
    4705        4524 :         delete mpWindowImpl->mpOverlapData;
    4706             : 
    4707             :     // remove BorderWindow or Frame window data
    4708      116183 :     if ( mpWindowImpl->mpBorderWindow )
    4709       11438 :         delete mpWindowImpl->mpBorderWindow;
    4710      104745 :     else if ( mpWindowImpl->mbFrame )
    4711             :     {
    4712        4524 :         if ( pSVData->maWinData.mpFirstFrame == this )
    4713        2952 :             pSVData->maWinData.mpFirstFrame = mpWindowImpl->mpFrameData->mpNextFrame;
    4714             :         else
    4715             :         {
    4716        1572 :             Window* pSysWin = pSVData->maWinData.mpFirstFrame;
    4717        4464 :             while ( pSysWin->mpWindowImpl->mpFrameData->mpNextFrame != this )
    4718        1320 :                 pSysWin = pSysWin->mpWindowImpl->mpFrameData->mpNextFrame;
    4719        1572 :             pSysWin->mpWindowImpl->mpFrameData->mpNextFrame = mpWindowImpl->mpFrameData->mpNextFrame;
    4720             :         }
    4721        4524 :         mpWindowImpl->mpFrame->SetCallback( NULL, NULL );
    4722        4524 :         pSVData->mpDefInst->DestroyFrame( mpWindowImpl->mpFrame );
    4723        4524 :         delete mpWindowImpl->mpFrameData;
    4724             :     }
    4725             : 
    4726             :     // should be the last statements
    4727      232366 :     delete mpWindowImpl; mpWindowImpl = NULL;
    4728      116205 : }
    4729             : 
    4730        6099 : void Window::doLazyDelete()
    4731             : {
    4732        6099 :     SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(this);
    4733        6099 :     DockingWindow* pDockWin = dynamic_cast<DockingWindow*>(this);
    4734        6099 :     if( pSysWin || ( pDockWin && pDockWin->IsFloatingMode() ) )
    4735             :     {
    4736          10 :         Show( false );
    4737          10 :         SetParent( ImplGetDefaultWindow() );
    4738             :     }
    4739        6099 :     vcl::LazyDeletor<Window>::Delete( this );
    4740        6099 : }
    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      323745 : void Window::PrePaint()
    4788             : {
    4789      323745 : }
    4790             : 
    4791        7184 : void Window::Paint( const Rectangle& rRect )
    4792             : {
    4793        7184 :     ImplCallEventListeners( VCLEVENT_WINDOW_PAINT, (void*)&rRect );
    4794        7184 : }
    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      167800 : void Window::Move() {}
    4805             : 
    4806       84432 : void Window::Resize() {}
    4807             : 
    4808        6036 : void Window::Activate() {}
    4809             : 
    4810        2363 : void Window::Deactivate() {}
    4811             : 
    4812        7484 : void Window::GetFocus()
    4813             : {
    4814        7484 :     if ( HasFocus() && mpWindowImpl->mpLastFocusWindow && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) )
    4815             :     {
    4816           3 :         ImplDelData aDogtag( this );
    4817           3 :         mpWindowImpl->mpLastFocusWindow->GrabFocus();
    4818           3 :         if( aDogtag.IsDead() )
    4819        7484 :             return;
    4820             :     }
    4821             : 
    4822        7484 :     NotifyEvent aNEvt( EVENT_GETFOCUS, this );
    4823        7484 :     Notify( aNEvt );
    4824             : }
    4825             : 
    4826        9391 : void Window::LoseFocus()
    4827             : {
    4828        9391 :     NotifyEvent aNEvt( EVENT_LOSEFOCUS, this );
    4829        9391 :     Notify( aNEvt );
    4830        9391 : }
    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      671853 : void Window::StateChanged( StateChangedType eType )
    4904             : {
    4905      671853 :     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      469104 :             break;
    4919             :         //stuff that does invalidate the layout
    4920             :         default:
    4921      202749 :             queue_resize();
    4922      202749 :             break;
    4923             :     }
    4924      671853 : }
    4925             : 
    4926        2737 : void Window::DataChanged( const DataChangedEvent& )
    4927             : {
    4928        2737 : }
    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       82776 : bool Window::PreNotify( NotifyEvent& rNEvt )
    5030             : {
    5031       82776 :     bool bDone = false;
    5032       82776 :     if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
    5033       62122 :         bDone = mpWindowImpl->mpParent->PreNotify( rNEvt );
    5034             : 
    5035       82776 :     if ( !bDone )
    5036             :     {
    5037       82776 :         if( rNEvt.GetType() == EVENT_GETFOCUS )
    5038             :         {
    5039       43247 :             bool bCompoundFocusChanged = false;
    5040       43247 :             if ( mpWindowImpl->mbCompoundControl && !mpWindowImpl->mbCompoundControlHasFocus && HasChildPathFocus() )
    5041             :             {
    5042           2 :                 mpWindowImpl->mbCompoundControlHasFocus = true;
    5043           2 :                 bCompoundFocusChanged = true;
    5044             :             }
    5045             : 
    5046       43247 :             if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
    5047       11247 :                 ImplCallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
    5048             :         }
    5049       39529 :         else if( rNEvt.GetType() == EVENT_LOSEFOCUS )
    5050             :         {
    5051       39529 :             bool bCompoundFocusChanged = false;
    5052       39529 :             if ( mpWindowImpl->mbCompoundControl && mpWindowImpl->mbCompoundControlHasFocus && !HasChildPathFocus() )
    5053             :             {
    5054           2 :                 mpWindowImpl->mbCompoundControlHasFocus = false ;
    5055           2 :                 bCompoundFocusChanged = true;
    5056             :             }
    5057             : 
    5058       39529 :             if ( bCompoundFocusChanged || ( rNEvt.GetWindow() == this ) )
    5059        9409 :                 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       82776 :     return bDone;
    5068             : }
    5069             : 
    5070      391224 : bool Window::Notify( NotifyEvent& rNEvt )
    5071             : {
    5072      391224 :     bool nRet = false;
    5073             : 
    5074             :     // check for docking window
    5075             :     // but do nothing if window is docked and locked
    5076      391224 :     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
    5077      391224 :     if( pWrapper && !( !pWrapper->IsFloatingMode() && pWrapper->IsLocked() ) )
    5078             :     {
    5079       11612 :         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       11612 :         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       11612 :         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      391224 :     if ( (GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
    5144             :     {
    5145             :         // if the parent also has dialog control activated, the parent takes over control
    5146       61589 :         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       61589 :         else if ( (rNEvt.GetType() == EVENT_GETFOCUS) || (rNEvt.GetType() == EVENT_LOSEFOCUS) )
    5155             :         {
    5156        4121 :             ImplDlgCtrlFocusChanged( rNEvt.GetWindow(), rNEvt.GetType() == EVENT_GETFOCUS );
    5157       14004 :             if ( (rNEvt.GetWindow() == this) && (rNEvt.GetType() == EVENT_GETFOCUS) &&
    5158        7944 :                  !(GetStyle() & WB_TABSTOP) && !(mpWindowImpl->mnDlgCtrlFlags & WINDOW_DLGCTRL_WANTFOCUS) )
    5159             :             {
    5160          81 :                 sal_uInt16 n = 0;
    5161          81 :                 Window* pFirstChild = ImplGetDlgWindow( n, DLGWINDOW_FIRST );
    5162          81 :                 if ( pFirstChild )
    5163          11 :                     pFirstChild->ImplControlFocus();
    5164             :             }
    5165             :         }
    5166             :     }
    5167             : 
    5168      391224 :     if ( !nRet )
    5169             :     {
    5170      391224 :         if ( mpWindowImpl->mpParent && !ImplIsOverlapWindow() )
    5171      303465 :             nRet = mpWindowImpl->mpParent->Notify( rNEvt );
    5172             :     }
    5173             : 
    5174      391224 :     return nRet;
    5175             : }
    5176             : 
    5177     1403113 : 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     1403113 :     CallEventListeners( nEvent, pData );
    5186     1403113 : }
    5187             : 
    5188     1553952 : void Window::CallEventListeners( sal_uLong nEvent, void* pData )
    5189             : {
    5190     1553952 :     VclWindowEvent aEvent( this, nEvent, pData );
    5191             : 
    5192     3107904 :     ImplDelData aDelData;
    5193     1553952 :     ImplAddDel( &aDelData );
    5194             : 
    5195     1553952 :     ImplGetSVData()->mpApp->ImplCallEventListeners( &aEvent );
    5196             : 
    5197     1553952 :     if ( aDelData.IsDead() )
    5198           0 :         return;
    5199             : 
    5200     1553952 :     mpWindowImpl->maEventListeners.Call( &aEvent );
    5201             : 
    5202     1553952 :     if ( aDelData.IsDead() )
    5203           0 :         return;
    5204             : 
    5205     1553952 :     ImplRemoveDel( &aDelData );
    5206             : 
    5207     1553952 :     Window* pWindow = this;
    5208     9200606 :     while ( pWindow )
    5209             :     {
    5210     6092702 :         pWindow->ImplAddDel( &aDelData );
    5211             : 
    5212     6092702 :         pWindow->mpWindowImpl->maChildEventListeners.Call( &aEvent );
    5213             : 
    5214     6092702 :         if ( aDelData.IsDead() )
    5215           0 :             return;
    5216             : 
    5217     6092702 :         pWindow->ImplRemoveDel( &aDelData );
    5218             : 
    5219     6092702 :         pWindow = pWindow->GetParent();
    5220     1553952 :     }
    5221             : }
    5222             : 
    5223           0 : void Window::FireVclEvent( VclSimpleEvent* pEvent )
    5224             : {
    5225           0 :     ImplGetSVData()->mpApp->ImplCallEventListeners(pEvent);
    5226           0 : }
    5227             : 
    5228       49005 : void Window::AddEventListener( const Link& rEventListener )
    5229             : {
    5230       49005 :     mpWindowImpl->maEventListeners.addListener( rEventListener );
    5231       49005 : }
    5232             : 
    5233       75774 : void Window::RemoveEventListener( const Link& rEventListener )
    5234             : {
    5235       75774 :     mpWindowImpl->maEventListeners.removeListener( rEventListener );
    5236       75774 : }
    5237             : 
    5238        4068 : void Window::AddChildEventListener( const Link& rEventListener )
    5239             : {
    5240        4068 :     mpWindowImpl->maChildEventListeners.addListener( rEventListener );
    5241        4068 : }
    5242             : 
    5243        4064 : void Window::RemoveChildEventListener( const Link& rEventListener )
    5244             : {
    5245        4064 :     mpWindowImpl->maChildEventListeners.removeListener( rEventListener );
    5246        4064 : }
    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       35198 : void Window::SetStyle( WinBits nStyle )
    5316             : {
    5317             : 
    5318       35198 :     if ( mpWindowImpl->mnStyle != nStyle )
    5319             :     {
    5320       12017 :         mpWindowImpl->mnPrevStyle = mpWindowImpl->mnStyle;
    5321       12017 :         mpWindowImpl->mnStyle = nStyle;
    5322       12017 :         StateChanged( STATE_CHANGE_STYLE );
    5323             :     }
    5324       35198 : }
    5325             : 
    5326       44530 : void Window::SetExtendedStyle( WinBits nExtendedStyle )
    5327             : {
    5328             : 
    5329       44530 :     if ( mpWindowImpl->mnExtendedStyle != nExtendedStyle )
    5330             :     {
    5331        3466 :         Window* pWindow = ImplGetBorderWindow();
    5332        3466 :         if( ! pWindow )
    5333           0 :             pWindow = this;
    5334        3466 :         if( pWindow->mpWindowImpl->mbFrame )
    5335             :         {
    5336        3466 :             SalExtStyle nExt = 0;
    5337        3466 :             if( (nExtendedStyle & WB_EXT_DOCUMENT) )
    5338        2069 :                 nExt |= SAL_FRAME_EXT_STYLE_DOCUMENT;
    5339        3466 :             if( (nExtendedStyle & WB_EXT_DOCMODIFIED) )
    5340         656 :                 nExt |= SAL_FRAME_EXT_STYLE_DOCMODIFIED;
    5341             : 
    5342        3466 :             pWindow->ImplGetFrame()->SetExtendedFrameStyle( nExt );
    5343             :         }
    5344        3466 :         mpWindowImpl->mnPrevExtendedStyle = mpWindowImpl->mnExtendedStyle;
    5345        3466 :         mpWindowImpl->mnExtendedStyle = nExtendedStyle;
    5346        3466 :         StateChanged( STATE_CHANGE_EXTENDEDSTYLE );
    5347             :     }
    5348       44530 : }
    5349             : 
    5350        5631 : SystemWindow* Window::GetSystemWindow() const
    5351             : {
    5352             : 
    5353        5631 :     const Window* pWin = this;
    5354       18701 :     while ( pWin && !pWin->IsSystemWindow() )
    5355        7439 :         pWin  = pWin->GetParent();
    5356        5631 :     return (SystemWindow*)pWin;
    5357             : }
    5358             : 
    5359        2431 : void Window::SetBorderStyle( sal_uInt16 nBorderStyle )
    5360             : {
    5361             : 
    5362        2431 :     if ( mpWindowImpl->mpBorderWindow )
    5363             :     {
    5364        2381 :         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        2381 :             if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
    5392        2381 :                  ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->SetBorderStyle( nBorderStyle );
    5393             :             else
    5394           0 :                 mpWindowImpl->mpBorderWindow->SetBorderStyle( nBorderStyle );
    5395             :         }
    5396             :     }
    5397        2431 : }
    5398             : 
    5399           8 : sal_uInt16 Window::GetBorderStyle() const
    5400             : {
    5401             : 
    5402           8 :     if ( mpWindowImpl->mpBorderWindow )
    5403             :     {
    5404           8 :         if ( mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW )
    5405           8 :             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          96 : void Window::SetMouseTransparent( bool bTransparent )
    5451             : {
    5452             : 
    5453          96 :     if ( mpWindowImpl->mpBorderWindow )
    5454          21 :         mpWindowImpl->mpBorderWindow->SetMouseTransparent( bTransparent );
    5455             : 
    5456          96 :     if( mpWindowImpl->mpSysObj )
    5457           0 :         mpWindowImpl->mpSysObj->SetMouseTransparent( bTransparent );
    5458             : 
    5459          96 :     mpWindowImpl->mbMouseTransparent = bTransparent;
    5460          96 : }
    5461             : 
    5462       26587 : 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       26587 :     if( bTransparent && mpWindowImpl->mbFrame )
    5467       26587 :         return;
    5468             : 
    5469       26587 :     if ( mpWindowImpl->mpBorderWindow )
    5470         101 :         mpWindowImpl->mpBorderWindow->SetPaintTransparent( bTransparent );
    5471             : 
    5472       26587 :     mpWindowImpl->mbPaintTransparent = bTransparent;
    5473             : }
    5474             : 
    5475        6790 : void Window::SetInputContext( const InputContext& rInputContext )
    5476             : {
    5477             : 
    5478        6790 :     mpWindowImpl->maInputContext = rInputContext;
    5479        6790 :     if ( !mpWindowImpl->mbInFocusHdl && HasFocus() )
    5480        1008 :         ImplNewInputContext();
    5481        6790 : }
    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       28087 : void Window::SetSettings( const AllSettings& rSettings )
    5544             : {
    5545       28087 :     SetSettings( rSettings, false );
    5546       28087 : }
    5547             : 
    5548       30738 : void Window::SetSettings( const AllSettings& rSettings, bool bChild )
    5549             : {
    5550             : 
    5551       30738 :     if ( mpWindowImpl->mpBorderWindow )
    5552             :     {
    5553         680 :         mpWindowImpl->mpBorderWindow->SetSettings( rSettings, false );
    5554         680 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    5555             :              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
    5556           0 :             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->SetSettings( rSettings, true );
    5557             :     }
    5558             : 
    5559       30738 :     AllSettings aOldSettings(*mxSettings);
    5560       30738 :     OutputDevice::SetSettings( rSettings );
    5561       30738 :     sal_uLong nChangeFlags = aOldSettings.GetChangeFlags( rSettings );
    5562             : 
    5563             :     // recalculate AppFont-resolution and DPI-resolution
    5564       30738 :     ImplInitResolutionSettings();
    5565             : 
    5566       30738 :     if ( nChangeFlags )
    5567             :     {
    5568        1514 :         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags );
    5569        1514 :         DataChanged( aDCEvt );
    5570             :     }
    5571             : 
    5572       30738 :     if ( bChild || mpWindowImpl->mbChildNotify )
    5573             :     {
    5574        1971 :         Window* pChild = mpWindowImpl->mpFirstChild;
    5575        5209 :         while ( pChild )
    5576             :         {
    5577        1267 :             pChild->SetSettings( rSettings, bChild );
    5578        1267 :             pChild = pChild->mpWindowImpl->mpNext;
    5579             :         }
    5580       30738 :     }
    5581       30738 : }
    5582             : 
    5583        2000 : void Window::UpdateSettings( const AllSettings& rSettings, bool bChild )
    5584             : {
    5585             : 
    5586        2000 :     if ( mpWindowImpl->mpBorderWindow )
    5587             :     {
    5588         373 :         mpWindowImpl->mpBorderWindow->UpdateSettings( rSettings, false );
    5589         373 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    5590             :              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
    5591           2 :             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->UpdateSettings( rSettings, true );
    5592             :     }
    5593             : 
    5594        2000 :     AllSettings aOldSettings(*mxSettings);
    5595        2000 :     sal_uLong nChangeFlags = mxSettings->Update( mxSettings->GetWindowUpdate(), rSettings );
    5596        2000 :     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        2000 :     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        4000 :     MouseSettings aSet( mxSettings->GetMouseSettings() );
    5611        2000 :     aSet.SetWheelBehavior( aOldSettings.GetMouseSettings().GetWheelBehavior() );
    5612        2000 :     mxSettings->SetMouseSettings( aSet );
    5613             : 
    5614        2000 :     if( (nChangeFlags & SETTINGS_STYLE) && IsBackground() )
    5615             :     {
    5616        1244 :         Wallpaper aWallpaper = GetBackground();
    5617        1244 :         if( !aWallpaper.IsBitmap() && !aWallpaper.IsGradient() )
    5618             :         {
    5619         940 :             if ( mpWindowImpl->mnStyle & WB_3DLOOK )
    5620             :             {
    5621         614 :                 if (aOldSettings.GetStyleSettings().GetFaceColor() != rSettings.GetStyleSettings().GetFaceColor())
    5622           0 :                     SetBackground( Wallpaper( rSettings.GetStyleSettings().GetFaceColor() ) );
    5623             :             }
    5624             :             else
    5625             :             {
    5626         326 :                 if (aOldSettings.GetStyleSettings().GetWindowColor() != rSettings.GetStyleSettings().GetWindowColor())
    5627           0 :                     SetBackground( Wallpaper( rSettings.GetStyleSettings().GetWindowColor() ) );
    5628             :             }
    5629        1244 :         }
    5630             :     }
    5631             : 
    5632        2000 :     if ( nChangeFlags )
    5633             :     {
    5634        2000 :         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, &aOldSettings, nChangeFlags );
    5635        2000 :         DataChanged( aDCEvt );
    5636             :         // notify data change handler
    5637        2000 :         ImplCallEventListeners( VCLEVENT_WINDOW_DATACHANGED, &aDCEvt);
    5638             :     }
    5639             : 
    5640        2000 :     if ( bChild || mpWindowImpl->mbChildNotify )
    5641             :     {
    5642        1625 :         Window* pChild = mpWindowImpl->mpFirstChild;
    5643        4541 :         while ( pChild )
    5644             :         {
    5645        1291 :             pChild->UpdateSettings( rSettings, bChild );
    5646        1291 :             pChild = pChild->mpWindowImpl->mpNext;
    5647             :         }
    5648        2000 :     }
    5649        2000 : }
    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       46822 : void Window::SetPointFont( const Font& rFont )
    5665             : {
    5666             : 
    5667       46822 :     Font aFont = rFont;
    5668       46822 :     ImplPointToLogic( aFont );
    5669       46822 :     SetFont( aFont );
    5670       46822 : }
    5671             : 
    5672           5 : Font Window::GetPointFont() const
    5673             : {
    5674             : 
    5675           5 :     Font aFont = GetFont();
    5676           5 :     ImplLogicToPoint( aFont );
    5677           5 :     return aFont;
    5678             : }
    5679             : 
    5680       26245 : void Window::SetParentClipMode( sal_uInt16 nMode )
    5681             : {
    5682             : 
    5683       26245 :     if ( mpWindowImpl->mpBorderWindow )
    5684         100 :         mpWindowImpl->mpBorderWindow->SetParentClipMode( nMode );
    5685             :     else
    5686             :     {
    5687       26145 :         if ( !ImplIsOverlapWindow() )
    5688             :         {
    5689       26145 :             mpWindowImpl->mnParentClipMode = nMode;
    5690       26145 :             if ( nMode & PARENTCLIPMODE_CLIP )
    5691           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mbClipChildren = true;
    5692             :         }
    5693             :     }
    5694       26245 : }
    5695             : 
    5696       78667 : sal_uInt16 Window::GetParentClipMode() const
    5697             : {
    5698             : 
    5699       78667 :     if ( mpWindowImpl->mpBorderWindow )
    5700        1451 :         return mpWindowImpl->mpBorderWindow->GetParentClipMode();
    5701             :     else
    5702       77216 :         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         202 : Region Window::GetWindowClipRegionPixel( sal_uInt16 nFlags ) const
    5844             : {
    5845             : 
    5846         202 :     Region aWinClipRegion;
    5847             : 
    5848         202 :     if ( nFlags & WINDOW_GETCLIPREGION_NOCHILDREN )
    5849             :     {
    5850         202 :         if ( mpWindowImpl->mbInitWinClipRegion )
    5851           0 :             ((Window*)this)->ImplInitWinClipRegion();
    5852         202 :         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         202 :     if ( nFlags & WINDOW_GETCLIPREGION_NULL )
    5867             :     {
    5868         202 :         Rectangle   aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    5869         202 :         Region      aWinRegion( aWinRect );
    5870             : 
    5871         202 :         if ( aWinRegion == aWinClipRegion )
    5872         202 :             aWinClipRegion.SetNull();
    5873             :     }
    5874             : 
    5875         202 :     aWinClipRegion.Move( -mnOutOffX, -mnOutOffY );
    5876             : 
    5877         202 :     return aWinClipRegion;
    5878             : }
    5879             : 
    5880      101988 : Region Window::GetPaintRegion() const
    5881             : {
    5882             : 
    5883      101988 :     if ( mpWindowImpl->mpPaintRegion )
    5884             :     {
    5885      101982 :         Region aRegion = *mpWindowImpl->mpPaintRegion;
    5886      101982 :         aRegion.Move( -mnOutOffX, -mnOutOffY );
    5887      101982 :         return PixelToLogic( aRegion );
    5888             :     }
    5889             :     else
    5890             :     {
    5891           6 :         Region aPaintRegion(true);
    5892           6 :         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       18661 : static SystemWindow *ImplGetLastSystemWindow( Window *pWin )
    5921             : {
    5922             :     // get the most top-level system window, the one that contains the taskpanelist
    5923       18661 :     SystemWindow *pSysWin = NULL;
    5924       18661 :     if( !pWin )
    5925           0 :         return pSysWin;
    5926       18661 :     Window *pMyParent = pWin;
    5927      108799 :     while ( pMyParent )
    5928             :     {
    5929       71477 :         if ( pMyParent->IsSystemWindow() )
    5930       18655 :             pSysWin = (SystemWindow*)pMyParent;
    5931       71477 :         pMyParent = pMyParent->GetParent();
    5932             :     }
    5933       18661 :     return pSysWin;
    5934             : }
    5935             : 
    5936       14288 : 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       14288 :     if( pNewParent == this )
    5942           0 :         return;
    5943             : 
    5944             :     // check if the taskpanelist would change and move the window pointer accordingly
    5945       14288 :     SystemWindow *pSysWin = ImplGetLastSystemWindow(this);
    5946       14288 :     SystemWindow *pNewSysWin = NULL;
    5947       14288 :     bool bChangeTaskPaneList = false;
    5948       14288 :     if( pSysWin && pSysWin->ImplIsInTaskPaneList( this ) )
    5949             :     {
    5950        4373 :         pNewSysWin = ImplGetLastSystemWindow( pNewParent );
    5951        4373 :         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       14288 :     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       14288 :     ImplSetFrameParent( pNewParent );
    5968             : 
    5969       14288 :     if ( mpWindowImpl->mpBorderWindow )
    5970             :     {
    5971        3844 :         mpWindowImpl->mpRealParent = pNewParent;
    5972        3844 :         mpWindowImpl->mpBorderWindow->SetParent( pNewParent );
    5973        3844 :         return;
    5974             :     }
    5975             : 
    5976       10444 :     if ( mpWindowImpl->mpParent == pNewParent )
    5977          12 :         return;
    5978             : 
    5979       10432 :     if ( mpWindowImpl->mbFrame )
    5980          10 :         mpWindowImpl->mpFrame->SetParent( pNewParent->mpWindowImpl->mpFrame );
    5981             : 
    5982       10432 :     bool bVisible = IsVisible();
    5983       10432 :     Show( false, SHOW_NOFOCUSCHANGE );
    5984             : 
    5985             :     // check if the overlap window changes
    5986             :     Window* pOldOverlapWindow;
    5987       10432 :     Window* pNewOverlapWindow = NULL;
    5988       10432 :     if ( ImplIsOverlapWindow() )
    5989          10 :         pOldOverlapWindow = NULL;
    5990             :     else
    5991             :     {
    5992       10422 :         pNewOverlapWindow = pNewParent->ImplGetFirstOverlapWindow();
    5993       10422 :         if ( mpWindowImpl->mpOverlapWindow != pNewOverlapWindow )
    5994        5698 :             pOldOverlapWindow = mpWindowImpl->mpOverlapWindow;
    5995             :         else
    5996        4724 :             pOldOverlapWindow = NULL;
    5997             :     }
    5998             : 
    5999             :     // convert windows in the hierarchy
    6000       10432 :     bool bFocusOverlapWin = HasChildPathFocus( true );
    6001       10432 :     bool bFocusWin = HasChildPathFocus();
    6002       10432 :     bool bNewFrame = pNewParent->mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow;
    6003       10432 :     if ( bNewFrame )
    6004             :     {
    6005        5708 :         if ( mpWindowImpl->mpFrameData->mpFocusWin )
    6006             :         {
    6007        2975 :             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpFocusWin ) )
    6008           0 :                 mpWindowImpl->mpFrameData->mpFocusWin = NULL;
    6009             :         }
    6010        5708 :         if ( mpWindowImpl->mpFrameData->mpMouseMoveWin )
    6011             :         {
    6012           0 :             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpMouseMoveWin ) )
    6013           0 :                 mpWindowImpl->mpFrameData->mpMouseMoveWin = NULL;
    6014             :         }
    6015        5708 :         if ( mpWindowImpl->mpFrameData->mpMouseDownWin )
    6016             :         {
    6017           0 :             if ( IsWindowOrChild( mpWindowImpl->mpFrameData->mpMouseDownWin ) )
    6018           0 :                 mpWindowImpl->mpFrameData->mpMouseDownWin = NULL;
    6019             :         }
    6020             :     }
    6021       10432 :     ImplRemoveWindow( bNewFrame );
    6022       10432 :     ImplInsertWindow( pNewParent );
    6023       10432 :     if ( mpWindowImpl->mnParentClipMode & PARENTCLIPMODE_CLIP )
    6024           0 :         pNewParent->mpWindowImpl->mbClipChildren = true;
    6025       10432 :     ImplUpdateWindowPtr();
    6026       10432 :     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       10432 :     if ( ImplIsOverlapWindow() )
    6033             :     {
    6034          10 :         if ( bNewFrame )
    6035             :         {
    6036          10 :             Window* pOverlapWindow = mpWindowImpl->mpFirstOverlap;
    6037          20 :             while ( pOverlapWindow )
    6038             :             {
    6039           0 :                 Window* pNextOverlapWindow = pOverlapWindow->mpWindowImpl->mpNext;
    6040           0 :                 pOverlapWindow->ImplUpdateOverlapWindowPtr( bNewFrame );
    6041           0 :                 pOverlapWindow = pNextOverlapWindow;
    6042             :             }
    6043             :         }
    6044             :     }
    6045       10422 :     else if ( pOldOverlapWindow )
    6046             :     {
    6047             :         // reset Focus-Save
    6048        5698 :         if ( bFocusWin ||
    6049        2975 :              (pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow &&
    6050        2975 :               IsWindowOrChild( pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow )) )
    6051           0 :             pOldOverlapWindow->mpWindowImpl->mpLastFocusWindow = NULL;
    6052             : 
    6053        5698 :         Window* pOverlapWindow = pOldOverlapWindow->mpWindowImpl->mpFirstOverlap;
    6054       11396 :         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        5698 :         if ( HasChildPathFocus( true ) )
    6064           0 :             ImplCallFocusChangeActivate( pNewOverlapWindow, pOldOverlapWindow );
    6065             :     }
    6066             : 
    6067             :     // also convert Activate-Status
    6068       10432 :     if ( bNewFrame )
    6069             :     {
    6070        9550 :         if ( (GetType() == WINDOW_BORDERWINDOW) &&
    6071        3842 :              (ImplGetWindow()->GetType() == WINDOW_FLOATINGWINDOW) )
    6072           8 :             ((ImplBorderWindow*)this)->SetDisplayActive( mpWindowImpl->mpFrameData->mbHasFocus );
    6073             :     }
    6074             : 
    6075             :     // when required give focus to new frame if
    6076             :     // FocusWindow is changed with SetParent()
    6077       10432 :     if ( bFocusOverlapWin )
    6078             :     {
    6079          17 :         mpWindowImpl->mpFrameData->mpFocusWin = Application::GetFocusWindow();
    6080          17 :         if ( !mpWindowImpl->mpFrameData->mbHasFocus )
    6081             :         {
    6082           0 :             mpWindowImpl->mpFrame->ToTop( 0 );
    6083             :         }
    6084             :     }
    6085             : 
    6086             :     // Assure DragSource and DropTarget members are created
    6087       10432 :     if ( bNewFrame )
    6088             :     {
    6089        5708 :             GetDropTarget();
    6090             :     }
    6091             : 
    6092       10432 :     if( bChangeTaskPaneList )
    6093           0 :         pNewSysWin->GetTaskPaneList()->AddWindow( this );
    6094             : 
    6095       10432 :     if( (GetStyle() & WB_OWNERDRAWDECORATION) && mpWindowImpl->mbFrame )
    6096           0 :         ImplGetOwnerDrawList().push_back( this );
    6097             : 
    6098       10432 :     if ( bVisible )
    6099          70 :         Show( true, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
    6100             : }
    6101             : 
    6102      361563 : void Window::Show( bool bVisible, sal_uInt16 nFlags )
    6103             : {
    6104             : 
    6105      361563 :     if ( mpWindowImpl->mbVisible == bVisible )
    6106      430068 :         return;
    6107             : 
    6108      146529 :     ImplDelData aDogTag( this );
    6109             : 
    6110      146529 :     bool bRealVisibilityChanged = false;
    6111      146529 :     mpWindowImpl->mbVisible = bVisible;
    6112             : 
    6113      146529 :     if ( !bVisible )
    6114             :     {
    6115       73090 :         ImplHideAllOverlaps();
    6116       73090 :         if( aDogTag.IsDead() )
    6117           0 :             return;
    6118             : 
    6119       73090 :         if ( mpWindowImpl->mpBorderWindow )
    6120             :         {
    6121        8752 :             bool bOldUpdate = mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate;
    6122        8752 :             if ( mpWindowImpl->mbNoParentUpdate )
    6123           0 :                 mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = true;
    6124        8752 :             mpWindowImpl->mpBorderWindow->Show( false, nFlags );
    6125        8752 :             mpWindowImpl->mpBorderWindow->mpWindowImpl->mbNoParentUpdate = bOldUpdate;
    6126             :         }
    6127       64338 :         else if ( mpWindowImpl->mbFrame )
    6128             :         {
    6129        2097 :             mpWindowImpl->mbSuppressAccessibilityEvents = true;
    6130        2097 :             mpWindowImpl->mpFrame->Show( false, false );
    6131             :         }
    6132             : 
    6133       73090 :         StateChanged( STATE_CHANGE_VISIBLE );
    6134             : 
    6135       73090 :         if ( mpWindowImpl->mbReallyVisible )
    6136             :         {
    6137       43544 :             Region  aInvRegion;
    6138       43544 :             bool    bSaveBack = false;
    6139             : 
    6140       43544 :             if ( ImplIsOverlapWindow() && !mpWindowImpl->mbFrame )
    6141             :             {
    6142           0 :                 if ( ImplRestoreOverlapBackground( aInvRegion ) )
    6143           0 :                     bSaveBack = true;
    6144             :             }
    6145             : 
    6146       43544 :             if ( !bSaveBack )
    6147             :             {
    6148       43544 :                 if ( mpWindowImpl->mbInitWinClipRegion )
    6149       16966 :                     ImplInitWinClipRegion();
    6150       43544 :                 aInvRegion = mpWindowImpl->maWinClipRegion;
    6151             :             }
    6152             : 
    6153       43544 :             if( aDogTag.IsDead() )
    6154           0 :                 return;
    6155             : 
    6156       43544 :             bRealVisibilityChanged = mpWindowImpl->mbReallyVisible;
    6157       43544 :             ImplResetReallyVisible();
    6158       43544 :             ImplSetClipFlag();
    6159             : 
    6160       43544 :             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       43544 :             if ( !mpWindowImpl->mbFrame )
    6174             :             {
    6175       41447 :                 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       36714 :                     const int workaround_border = 5;
    6185       36714 :                     Rectangle aBounds( aInvRegion.GetBoundRect() );
    6186       36714 :                     aBounds.Left()      -= workaround_border;
    6187       36714 :                     aBounds.Top()       -= workaround_border;
    6188       36714 :                     aBounds.Right()     += workaround_border;
    6189       36714 :                     aBounds.Bottom()    += workaround_border;
    6190       36714 :                     aInvRegion = aBounds;
    6191             :                 }
    6192       41447 :                 if ( !mpWindowImpl->mbNoParentUpdate && !(nFlags & SHOW_NOPARENTUPDATE) )
    6193             :                 {
    6194       41399 :                     if ( !aInvRegion.IsEmpty() )
    6195       39244 :                         ImplInvalidateParentFrameRegion( aInvRegion );
    6196             :                 }
    6197       41447 :                 ImplGenerateMouseMove();
    6198       43544 :             }
    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       73443 :         if( mpWindowImpl->mbFrame && GetParent() && GetParent()->IsCompoundControl() &&
    6207           4 :             GetParent()->IsNativeWidgetEnabled() != IsNativeWidgetEnabled() )
    6208           0 :             EnableNativeWidget( GetParent()->IsNativeWidgetEnabled() );
    6209             : 
    6210       73439 :         if ( mpWindowImpl->mbCallMove )
    6211             :         {
    6212       68537 :             ImplCallMove();
    6213             :         }
    6214       73439 :         if ( mpWindowImpl->mbCallResize )
    6215             :         {
    6216       68012 :             ImplCallResize();
    6217             :         }
    6218             : 
    6219       73439 :         StateChanged( STATE_CHANGE_VISIBLE );
    6220             : 
    6221             :         Window* pTestParent;
    6222       73439 :         if ( ImplIsOverlapWindow() )
    6223        2105 :             pTestParent = mpWindowImpl->mpOverlapWindow;
    6224             :         else
    6225       71334 :             pTestParent = ImplGetParent();
    6226       73439 :         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       24728 :             ImplCallInitShow();
    6231             : 
    6232             :             // If it is a SystemWindow it automatically pops up on top of
    6233             :             // all other windows if needed.
    6234       24728 :             if ( ImplIsOverlapWindow() && !(nFlags & SHOW_NOACTIVATE) )
    6235             :             {
    6236        2059 :                 ImplStartToTop(( nFlags & SHOW_FOREGROUNDTASK ) ? TOTOP_FOREGROUNDTASK : 0 );
    6237        2059 :                 ImplFocusToTop( 0, false );
    6238             :             }
    6239             : 
    6240             :             // save background
    6241       24728 :             if ( mpWindowImpl->mpOverlapData && mpWindowImpl->mpOverlapData->mbSaveBack )
    6242           0 :                 ImplSaveOverlapBackground();
    6243             :             // adjust mpWindowImpl->mbReallyVisible
    6244       24728 :             bRealVisibilityChanged = !mpWindowImpl->mbReallyVisible;
    6245       24728 :             ImplSetReallyVisible();
    6246             : 
    6247             :             // assure clip rectangles will be recalculated
    6248       24728 :             ImplSetClipFlag();
    6249             : 
    6250       24728 :             if ( !mpWindowImpl->mbFrame )
    6251             :             {
    6252       22623 :                 sal_uInt16 nInvalidateFlags = INVALIDATE_CHILDREN;
    6253       22623 :                 if( ! IsPaintTransparent() )
    6254       18466 :                     nInvalidateFlags |= INVALIDATE_NOTRANSPARENT;
    6255       22623 :                 ImplInvalidate( NULL, nInvalidateFlags );
    6256       22623 :                 ImplGenerateMouseMove();
    6257             :             }
    6258             :         }
    6259             : 
    6260       73439 :         if ( mpWindowImpl->mpBorderWindow )
    6261        8790 :             mpWindowImpl->mpBorderWindow->Show( true, nFlags );
    6262       64649 :         else if ( mpWindowImpl->mbFrame )
    6263             :         {
    6264             :             // #106431#, hide SplashScreen
    6265        2105 :             ImplSVData* pSVData = ImplGetSVData();
    6266        2105 :             if ( !pSVData->mpIntroWindow )
    6267             :             {
    6268             :                 // The right way would be just to call this (not even in the 'if')
    6269        2105 :                 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        2105 :             mpWindowImpl->mbSuppressAccessibilityEvents = false;
    6280             : 
    6281        2105 :             mpWindowImpl->mbPaintFrame = true;
    6282        2105 :             bool bNoActivate = (nFlags & (SHOW_NOACTIVATE|SHOW_NOFOCUSCHANGE)) ? sal_True : sal_False;
    6283        2105 :             mpWindowImpl->mpFrame->Show( true, bNoActivate );
    6284        2105 :             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        2105 :             if ( mpWindowImpl->mbWaitSystemResize )
    6290             :             {
    6291             :                 long nOutWidth;
    6292             :                 long nOutHeight;
    6293          49 :                 mpWindowImpl->mpFrame->GetClientSize( nOutWidth, nOutHeight );
    6294          49 :                 ImplHandleResize( this, nOutWidth, nOutHeight );
    6295             :             }
    6296             :         }
    6297             : 
    6298       73439 :         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       73439 :         ImplShowAllOverlaps();
    6309             :     }
    6310             : 
    6311      146529 :     if( aDogTag.IsDead() )
    6312           0 :         return;
    6313             :     // invalidate all saved backgrounds
    6314      146529 :     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      146529 :     if ( !bRealVisibilityChanged )
    6323       78257 :         ImplCallEventListeners( mpWindowImpl->mbVisible ? VCLEVENT_WINDOW_SHOW : VCLEVENT_WINDOW_HIDE, NULL );
    6324      146529 :     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      473428 : Size Window::GetSizePixel() const
    6353             : {
    6354      473428 :     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      473428 :     if( mpWindowImpl->mpFrameData->maResizeTimer.IsActive() )
    6362             :     {
    6363        2060 :         ImplDelData aDogtag( this );
    6364        2060 :         mpWindowImpl->mpFrameData->maResizeTimer.Stop();
    6365        2060 :         mpWindowImpl->mpFrameData->maResizeTimer.GetTimeoutHdl().Call( NULL );
    6366        2060 :         if( aDogtag.IsDead() )
    6367           0 :             return Size(0,0);
    6368             :     }
    6369             : 
    6370      473428 :     return Size( mnOutWidth+mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder,
    6371      946856 :                  mnOutHeight+mpWindowImpl->mnTopBorder+mpWindowImpl->mnBottomBorder );
    6372             : }
    6373             : 
    6374       76222 : void Window::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
    6375             :                                sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
    6376             : {
    6377       76222 :     rLeftBorder     = mpWindowImpl->mnLeftBorder;
    6378       76222 :     rTopBorder      = mpWindowImpl->mnTopBorder;
    6379       76222 :     rRightBorder    = mpWindowImpl->mnRightBorder;
    6380       76222 :     rBottomBorder   = mpWindowImpl->mnBottomBorder;
    6381       76222 : }
    6382             : 
    6383       58527 : void Window::Enable( bool bEnable, bool bChild )
    6384             : {
    6385             : 
    6386       58527 :     if ( !bEnable )
    6387             :     {
    6388             :         // the tracking mode will be stopped or the capture will be stolen
    6389             :         // when a window is disabled,
    6390       20431 :         if ( IsTracking() )
    6391           0 :             EndTracking( ENDTRACK_CANCEL );
    6392       20431 :         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       20431 :         if ( HasFocus() )
    6399         327 :             ImplDlgCtrlNextWindow();
    6400             :     }
    6401             : 
    6402       58527 :     if ( mpWindowImpl->mpBorderWindow )
    6403             :     {
    6404        8188 :         mpWindowImpl->mpBorderWindow->Enable( bEnable, false );
    6405        8188 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    6406             :              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
    6407         760 :             ((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       58527 :     ImplSVData* pSVData = ImplGetSVData();
    6413       96623 :     if( bEnable &&
    6414       45947 :         pSVData->maWinData.mpFocusWin == NULL &&
    6415         899 :         mpWindowImpl->mpFrameData->mbHasFocus &&
    6416         899 :         mpWindowImpl->mpFrameData->mpFocusWin == this )
    6417           8 :         pSVData->maWinData.mpFocusWin = this;
    6418             : 
    6419       58527 :     if ( mpWindowImpl->mbDisabled != !bEnable )
    6420             :     {
    6421       33524 :         mpWindowImpl->mbDisabled = !bEnable;
    6422       33524 :         if ( mpWindowImpl->mpSysObj )
    6423           0 :             mpWindowImpl->mpSysObj->Enable( bEnable && !mpWindowImpl->mbInputDisabled );
    6424       33524 :         StateChanged( STATE_CHANGE_ENABLE );
    6425             : 
    6426       33524 :         ImplCallEventListeners( bEnable ? VCLEVENT_WINDOW_ENABLED : VCLEVENT_WINDOW_DISABLED );
    6427             :     }
    6428             : 
    6429       58527 :     if ( bChild || mpWindowImpl->mbChildNotify )
    6430             :     {
    6431       49794 :         Window* pChild = mpWindowImpl->mpFirstChild;
    6432      136027 :         while ( pChild )
    6433             :         {
    6434       36439 :             pChild->Enable( bEnable, bChild );
    6435       36439 :             pChild = pChild->mpWindowImpl->mpNext;
    6436             :         }
    6437             :     }
    6438             : 
    6439       58527 :     if ( IsReallyVisible() )
    6440       35634 :         ImplGenerateMouseMove();
    6441       58527 : }
    6442             : 
    6443          96 : void Window::SetCallHandlersOnInputDisabled( bool bCall )
    6444             : {
    6445          96 :     mpWindowImpl->mbCallHandlersDuringInputDisabled = bCall ? sal_True : sal_False;
    6446             : 
    6447          96 :     Window* pChild = mpWindowImpl->mpFirstChild;
    6448         192 :     while ( pChild )
    6449             :     {
    6450           0 :         pChild->SetCallHandlersOnInputDisabled( bCall );
    6451           0 :         pChild = pChild->mpWindowImpl->mpNext;
    6452             :     }
    6453          96 : }
    6454             : 
    6455           0 : bool Window::IsCallHandlersOnInputDisabled() const
    6456             : {
    6457           0 :     return mpWindowImpl->mbCallHandlersDuringInputDisabled ? true : false;
    6458             : }
    6459             : 
    6460       17596 : void Window::EnableInput( bool bEnable, bool bChild )
    6461             : {
    6462             : 
    6463       17596 :     bool bNotify = (bEnable != mpWindowImpl->mbInputDisabled);
    6464       17596 :     if ( mpWindowImpl->mpBorderWindow )
    6465             :     {
    6466        1312 :         mpWindowImpl->mpBorderWindow->EnableInput( bEnable, false );
    6467        1312 :         if ( (mpWindowImpl->mpBorderWindow->GetType() == WINDOW_BORDERWINDOW) &&
    6468             :              ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow )
    6469          26 :             ((ImplBorderWindow*)mpWindowImpl->mpBorderWindow)->mpMenuBarWindow->EnableInput( bEnable, true );
    6470             :     }
    6471             : 
    6472       17596 :     if ( (! bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputEnabled) ||
    6473        9876 :          (  bEnable && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled) )
    6474             :     {
    6475             :         // automatically stop the tracking mode or steal capture
    6476             :         // if the window is disabled
    6477       17564 :         if ( !bEnable )
    6478             :         {
    6479        7720 :             if ( IsTracking() )
    6480           0 :                 EndTracking( ENDTRACK_CANCEL );
    6481        7720 :             if ( IsMouseCaptured() )
    6482           0 :                 ReleaseMouse();
    6483             :         }
    6484             : 
    6485       17564 :         if ( mpWindowImpl->mbInputDisabled != !bEnable )
    6486             :         {
    6487       14894 :             mpWindowImpl->mbInputDisabled = !bEnable;
    6488       14894 :             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       17596 :     ImplSVData* pSVData = ImplGetSVData();
    6496       27472 :     if( bEnable &&
    6497       10637 :         pSVData->maWinData.mpFocusWin == NULL &&
    6498         170 :         mpWindowImpl->mpFrameData->mbHasFocus &&
    6499         170 :         mpWindowImpl->mpFrameData->mpFocusWin == this )
    6500           0 :         pSVData->maWinData.mpFocusWin = this;
    6501             : 
    6502       17596 :     if ( bChild || mpWindowImpl->mbChildNotify )
    6503             :     {
    6504       16188 :         Window* pChild = mpWindowImpl->mpFirstChild;
    6505       47255 :         while ( pChild )
    6506             :         {
    6507       14879 :             pChild->EnableInput( bEnable, bChild );
    6508       14879 :             pChild = pChild->mpWindowImpl->mpNext;
    6509             :         }
    6510             :     }
    6511             : 
    6512       17596 :     if ( IsReallyVisible() )
    6513        9013 :         ImplGenerateMouseMove();
    6514             : 
    6515             :     // #104827# notify parent
    6516       17596 :     if ( bNotify )
    6517             :     {
    6518        2670 :         NotifyEvent aNEvt( bEnable ? EVENT_INPUTENABLE : EVENT_INPUTDISABLE, this );
    6519        2670 :         Notify( aNEvt );
    6520             :     }
    6521       17596 : }
    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          96 : void Window::AlwaysDisableInput( bool bAlways, bool bChild )
    6617             : {
    6618             : 
    6619          96 :     if ( mpWindowImpl->mpBorderWindow )
    6620           0 :         mpWindowImpl->mpBorderWindow->AlwaysDisableInput( bAlways, false );
    6621             : 
    6622          96 :     if( bAlways && mpWindowImpl->meAlwaysInputMode != AlwaysInputDisabled )
    6623             :     {
    6624          96 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputDisabled;
    6625             : 
    6626         192 :         if ( bAlways )
    6627          96 :             EnableInput( false, false );
    6628             :     }
    6629           0 :     else if( ! bAlways && mpWindowImpl->meAlwaysInputMode == AlwaysInputDisabled )
    6630             :     {
    6631           0 :         mpWindowImpl->meAlwaysInputMode = AlwaysInputNone;
    6632             :     }
    6633             : 
    6634          96 :     if ( bChild || mpWindowImpl->mbChildNotify )
    6635             :     {
    6636          96 :         Window* pChild = mpWindowImpl->mpFirstChild;
    6637         192 :         while ( pChild )
    6638             :         {
    6639           0 :             pChild->AlwaysDisableInput( bAlways, bChild );
    6640           0 :             pChild = pChild->mpWindowImpl->mpNext;
    6641             :         }
    6642             :     }
    6643          96 : }
    6644             : 
    6645        9170 : void Window::SetActivateMode( sal_uInt16 nMode )
    6646             : {
    6647             : 
    6648        9170 :     if ( mpWindowImpl->mpBorderWindow )
    6649        4573 :         mpWindowImpl->mpBorderWindow->SetActivateMode( nMode );
    6650             : 
    6651        9170 :     if ( mpWindowImpl->mnActivateMode != nMode )
    6652             :     {
    6653        4590 :         mpWindowImpl->mnActivateMode = nMode;
    6654             : 
    6655             :         // possibly trigger Decativate/Activate
    6656        4590 :         if ( mpWindowImpl->mnActivateMode )
    6657             :         {
    6658        4586 :             if ( (mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW)) &&
    6659        2293 :                  !HasChildPathFocus( true ) )
    6660             :             {
    6661        2293 :                 mpWindowImpl->mbActive = false;
    6662        2293 :                 Deactivate();
    6663             :             }
    6664             :         }
    6665             :         else
    6666             :         {
    6667        2297 :             if ( !mpWindowImpl->mbActive || (GetType() == WINDOW_BORDERWINDOW) )
    6668             :             {
    6669        2297 :                 mpWindowImpl->mbActive = true;
    6670        2297 :                 Activate();
    6671             :             }
    6672             :         }
    6673             :     }
    6674        9170 : }
    6675             : 
    6676         663 : void Window::ToTop( sal_uInt16 nFlags )
    6677             : {
    6678             : 
    6679         663 :     ImplStartToTop( nFlags );
    6680         663 :     ImplFocusToTop( nFlags, IsReallyVisible() );
    6681         663 : }
    6682             : 
    6683          38 : void Window::SetZOrder( Window* pRefWindow, sal_uInt16 nFlags )
    6684             : {
    6685             : 
    6686          38 :     if ( mpWindowImpl->mpBorderWindow )
    6687             :     {
    6688           7 :         mpWindowImpl->mpBorderWindow->SetZOrder( pRefWindow, nFlags );
    6689           7 :         return;
    6690             :     }
    6691             : 
    6692          31 :     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          31 :     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          69 :     while ( pRefWindow && pRefWindow->mpWindowImpl->mpBorderWindow )
    6710           7 :         pRefWindow = pRefWindow->mpWindowImpl->mpBorderWindow;
    6711          31 :     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          31 :     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          31 :     else if ( nFlags & WINDOW_ZORDER_BEHIND )
    6754             :     {
    6755          31 :         if ( pRefWindow->mpWindowImpl->mpNext == this )
    6756          30 :             return;
    6757             : 
    6758           1 :         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           1 :             if ( mpWindowImpl->mpPrev )
    6774           0 :                 mpWindowImpl->mpPrev->mpWindowImpl->mpNext = mpWindowImpl->mpNext;
    6775             :             else
    6776           1 :                 mpWindowImpl->mpParent->mpWindowImpl->mpFirstChild = mpWindowImpl->mpNext;
    6777           1 :             if ( mpWindowImpl->mpNext )
    6778           1 :                 mpWindowImpl->mpNext->mpWindowImpl->mpPrev = mpWindowImpl->mpPrev;
    6779             :             else
    6780           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = mpWindowImpl->mpPrev;
    6781           1 :             if ( !pRefWindow->mpWindowImpl->mpNext )
    6782           0 :                 mpWindowImpl->mpParent->mpWindowImpl->mpLastChild = this;
    6783             :         }
    6784             : 
    6785           1 :         mpWindowImpl->mpPrev = pRefWindow;
    6786           1 :         mpWindowImpl->mpNext = pRefWindow->mpWindowImpl->mpNext;
    6787           1 :         if ( mpWindowImpl->mpNext )
    6788           1 :             mpWindowImpl->mpNext->mpWindowImpl->mpPrev = this;
    6789           1 :         mpWindowImpl->mpPrev->mpWindowImpl->mpNext = this;
    6790             :     }
    6791             : 
    6792           1 :     if ( IsReallyVisible() )
    6793             :     {
    6794             :         // restore background storage
    6795           1 :         if ( mpWindowImpl->mpFrameData->mpFirstBackWin )
    6796           0 :             ImplInvalidateAllOverlapBackgrounds();
    6797             : 
    6798           1 :         if ( mpWindowImpl->mbInitWinClipRegion || !mpWindowImpl->maWinClipRegion.IsEmpty() )
    6799             :         {
    6800           1 :             bool bInitWinClipRegion = mpWindowImpl->mbInitWinClipRegion;
    6801           1 :             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           1 :             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      286541 : void Window::setPosSizePixel( long nX, long nY,
    6871             :                               long nWidth, long nHeight, sal_uInt16 nFlags )
    6872             : {
    6873             : 
    6874      286541 :     bool bHasValidSize = !mpWindowImpl->mbDefSize;
    6875             : 
    6876      286541 :     if ( nFlags & WINDOW_POSSIZE_POS )
    6877      210025 :         mpWindowImpl->mbDefPos = false;
    6878      286541 :     if ( nFlags & WINDOW_POSSIZE_SIZE )
    6879      265500 :         mpWindowImpl->mbDefSize = false;
    6880             : 
    6881             :     // The top BorderWindow is the window which is to be positioned
    6882      286541 :     Window* pWindow = this;
    6883      598921 :     while ( pWindow->mpWindowImpl->mpBorderWindow )
    6884       25839 :         pWindow = pWindow->mpWindowImpl->mpBorderWindow;
    6885             : 
    6886      286541 :     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        2969 :         long nOldWidth  = pWindow->mnOutWidth;
    6892             : 
    6893        2969 :         if ( !(nFlags & WINDOW_POSSIZE_WIDTH) )
    6894          18 :             nWidth = pWindow->mnOutWidth;
    6895        2969 :         if ( !(nFlags & WINDOW_POSSIZE_HEIGHT) )
    6896          18 :             nHeight = pWindow->mnOutHeight;
    6897             : 
    6898        2969 :         sal_uInt16 nSysFlags=0;
    6899        2969 :         Window *pParent = GetParent();
    6900             : 
    6901        2969 :         if( nFlags & WINDOW_POSSIZE_WIDTH )
    6902        2951 :             nSysFlags |= SAL_FRAME_POSSIZE_WIDTH;
    6903        2969 :         if( nFlags & WINDOW_POSSIZE_HEIGHT )
    6904        2951 :             nSysFlags |= SAL_FRAME_POSSIZE_HEIGHT;
    6905        2969 :         if( nFlags & WINDOW_POSSIZE_X )
    6906             :         {
    6907          29 :             nSysFlags |= SAL_FRAME_POSSIZE_X;
    6908          29 :             if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
    6909             :             {
    6910           0 :                 nX += pParent->mnOutOffX;
    6911             :             }
    6912          29 :             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        2969 :         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         778 :             if ( pParent )
    6926             :             {
    6927         777 :                 OutputDevice *pParentOutDev = pParent->GetOutDev();
    6928         777 :                 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        2969 :         if( nFlags & WINDOW_POSSIZE_Y )
    6952             :         {
    6953          29 :             nSysFlags |= SAL_FRAME_POSSIZE_Y;
    6954          29 :             if( pParent && (pWindow->GetStyle() & WB_SYSTEMCHILDWINDOW) )
    6955             :             {
    6956           0 :                 nY += pParent->mnOutOffY;
    6957             :             }
    6958             :         }
    6959             : 
    6960        2969 :         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        2951 :             SystemWindow *pSystemWindow = dynamic_cast< SystemWindow* >( pWindow );
    6966        2951 :             if( pSystemWindow )
    6967             :             {
    6968          97 :                 Size aMinSize = pSystemWindow->GetMinOutputSizePixel();
    6969          97 :                 Size aMaxSize = pSystemWindow->GetMaxOutputSizePixel();
    6970          97 :                 if( nWidth < aMinSize.Width() )
    6971           0 :                     nWidth = aMinSize.Width();
    6972          97 :                 if( nHeight < aMinSize.Height() )
    6973           0 :                     nHeight = aMinSize.Height();
    6974             : 
    6975          97 :                 if( nWidth > aMaxSize.Width() )
    6976           0 :                     nWidth = aMaxSize.Width();
    6977          97 :                 if( nHeight > aMaxSize.Height() )
    6978           0 :                     nHeight = aMaxSize.Height();
    6979             :             }
    6980             :         }
    6981             : 
    6982        2969 :         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        2969 :         ImplHandleResize( pWindow, nWidth, nHeight );
    6989             :     }
    6990             :     else
    6991             :     {
    6992      283572 :         pWindow->ImplPosSizeWindow( nX, nY, nWidth, nHeight, nFlags );
    6993      283572 :         if ( IsReallyVisible() )
    6994      101743 :             ImplGenerateMouseMove();
    6995             :     }
    6996      286541 : }
    6997             : 
    6998      217125 : Point Window::GetPosPixel() const
    6999             : {
    7000      217125 :     return mpWindowImpl->maPos;
    7001             : }
    7002             : 
    7003       11456 : Rectangle Window::GetDesktopRectPixel() const
    7004             : {
    7005       11456 :     Rectangle rRect;
    7006       11456 :     mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrame->GetWorkArea( rRect );
    7007       11456 :     return rRect;
    7008             : }
    7009             : 
    7010       20832 : Point Window::OutputToScreenPixel( const Point& rPos ) const
    7011             : {
    7012             :     // relative to top level parent
    7013       20832 :     return Point( rPos.X()+mnOutOffX, rPos.Y()+mnOutOffY );
    7014             : }
    7015             : 
    7016        1404 : Point Window::ScreenToOutputPixel( const Point& rPos ) const
    7017             : {
    7018             :     // relative to top level parent
    7019        1404 :     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          56 : Point Window::OutputToAbsoluteScreenPixel( const Point& rPos ) const
    7060             : {
    7061             :     // relative to the screen
    7062          56 :     Point p = OutputToScreenPixel( rPos );
    7063          56 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    7064          56 :     p.X() += g.nX;
    7065          56 :     p.Y() += g.nY;
    7066          56 :     return p;
    7067             : }
    7068             : 
    7069        1157 : Point Window::AbsoluteScreenToOutputPixel( const Point& rPos ) const
    7070             : {
    7071             :     // relative to the screen
    7072        1157 :     Point p = ScreenToOutputPixel( rPos );
    7073        1157 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    7074        1157 :     p.X() -= g.nX;
    7075        1157 :     p.Y() -= g.nY;
    7076        1157 :     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       18178 : Rectangle Window::GetWindowExtentsRelative( Window *pRelativeWindow ) const
    7097             : {
    7098             :     // with decoration
    7099       18178 :     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       18178 : Rectangle Window::ImplGetWindowExtentsRelative( Window *pRelativeWindow, bool bClientOnly ) const
    7109             : {
    7110       18178 :     SalFrameGeometry g = mpWindowImpl->mpFrame->GetGeometry();
    7111             :     // make sure we use the extent of our border window,
    7112             :     // otherwise we miss a few pixels
    7113       18178 :     const Window *pWin = (!bClientOnly && mpWindowImpl->mpBorderWindow) ? mpWindowImpl->mpBorderWindow : this;
    7114             : 
    7115       18178 :     Point aPos( pWin->OutputToScreenPixel( Point(0,0) ) );
    7116       18178 :     aPos.X() += g.nX;
    7117       18178 :     aPos.Y() += g.nY;
    7118       18178 :     Size aSize ( pWin->GetSizePixel() );
    7119             :     // #104088# do not add decoration to the workwindow to be compatible to java accessibility api
    7120       18178 :     if( !bClientOnly && (mpWindowImpl->mbFrame || (mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame && GetType() != WINDOW_WORKWINDOW)) )
    7121             :     {
    7122         962 :         aPos.X() -= g.nLeftDecoration;
    7123         962 :         aPos.Y() -= g.nTopDecoration;
    7124         962 :         aSize.Width() += g.nLeftDecoration + g.nRightDecoration;
    7125         962 :         aSize.Height() += g.nTopDecoration + g.nBottomDecoration;
    7126             :     }
    7127       18178 :     if( pRelativeWindow )
    7128             :     {
    7129             :         // #106399# express coordinates relative to borderwindow
    7130        1145 :         Window *pRelWin = (!bClientOnly && pRelativeWindow->mpWindowImpl->mpBorderWindow) ? pRelativeWindow->mpWindowImpl->mpBorderWindow : pRelativeWindow;
    7131        1145 :         aPos = pRelWin->AbsoluteScreenToOutputPixel( aPos );
    7132             :     }
    7133       18178 :     return Rectangle( aPos, aSize );
    7134             : }
    7135             : 
    7136        2363 : void Window::Scroll( long nHorzScroll, long nVertScroll, sal_uInt16 nFlags )
    7137             : {
    7138             : 
    7139             :     ImplScroll( Rectangle( Point( mnOutOffX, mnOutOffY ),
    7140             :                            Size( mnOutWidth, mnOutHeight ) ),
    7141        2363 :                 nHorzScroll, nVertScroll, nFlags & ~SCROLL_CLIP );
    7142        2363 : }
    7143             : 
    7144         476 : void Window::Scroll( long nHorzScroll, long nVertScroll,
    7145             :                      const Rectangle& rRect, sal_uInt16 nFlags )
    7146             : {
    7147             : 
    7148         476 :     OutputDevice *pOutDev = GetOutDev();
    7149         476 :     Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
    7150         476 :     aRect.Intersection( Rectangle( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) ) );
    7151         476 :     if ( !aRect.IsEmpty() )
    7152         471 :         ImplScroll( aRect, nHorzScroll, nVertScroll, nFlags );
    7153         476 : }
    7154             : 
    7155      166962 : void Window::Invalidate( sal_uInt16 nFlags )
    7156             : {
    7157             : 
    7158      166962 :     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
    7159      293848 :         return;
    7160             : 
    7161       40076 :     ImplInvalidate( NULL, nFlags );
    7162             : }
    7163             : 
    7164       52594 : void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
    7165             : {
    7166             : 
    7167       52594 :     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
    7168       63625 :         return;
    7169             : 
    7170       41563 :     OutputDevice *pOutDev = GetOutDev();
    7171       41563 :     Rectangle aRect = pOutDev->ImplLogicToDevicePixel( rRect );
    7172       41563 :     if ( !aRect.IsEmpty() )
    7173             :     {
    7174       39706 :         Region aRegion( aRect );
    7175       39706 :         ImplInvalidate( &aRegion, nFlags );
    7176             :     }
    7177             : }
    7178             : 
    7179         411 : void Window::Invalidate( const Region& rRegion, sal_uInt16 nFlags )
    7180             : {
    7181             : 
    7182         411 :     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
    7183         411 :         return;
    7184             : 
    7185         411 :     if ( rRegion.IsNull() )
    7186           0 :         ImplInvalidate( NULL, nFlags );
    7187             :     else
    7188             :     {
    7189         411 :         Region aRegion = ImplPixelToDevicePixel( LogicToPixel( rRegion ) );
    7190         411 :         if ( !aRegion.IsEmpty() )
    7191         235 :             ImplInvalidate( &aRegion, nFlags );
    7192             :     }
    7193             : }
    7194             : 
    7195           6 : void Window::Validate( sal_uInt16 nFlags )
    7196             : {
    7197             : 
    7198           6 :     if ( !IsDeviceOutputNecessary() || !mnOutWidth || !mnOutHeight )
    7199           6 :         return;
    7200             : 
    7201           6 :     ImplValidate( NULL, nFlags );
    7202             : }
    7203             : 
    7204       37328 : bool Window::HasPaintEvent() const
    7205             : {
    7206             : 
    7207       37328 :     if ( !mpWindowImpl->mbReallyVisible )
    7208        3794 :         return false;
    7209             : 
    7210       33534 :     if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
    7211        1212 :         return true;
    7212             : 
    7213       32322 :     if ( mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINT )
    7214        9057 :         return true;
    7215             : 
    7216       23265 :     if ( !ImplIsOverlapWindow() )
    7217             :     {
    7218       23265 :         const Window* pTempWindow = this;
    7219       14145 :         do
    7220             :         {
    7221       34973 :             pTempWindow = pTempWindow->ImplGetParent();
    7222       34973 :             if ( pTempWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINTCHILDREN | IMPL_PAINT_PAINTALLCHILDREN) )
    7223       20828 :                 return true;
    7224             :         }
    7225       14145 :         while ( !pTempWindow->ImplIsOverlapWindow() );
    7226             :     }
    7227             : 
    7228        2437 :     return false;
    7229             : }
    7230             : 
    7231       45041 : void Window::Update()
    7232             : {
    7233             : 
    7234       45041 :     if ( mpWindowImpl->mpBorderWindow )
    7235             :     {
    7236         187 :         mpWindowImpl->mpBorderWindow->Update();
    7237         187 :         return;
    7238             :     }
    7239             : 
    7240       44854 :     if ( !mpWindowImpl->mbReallyVisible )
    7241        8880 :         return;
    7242             : 
    7243       35974 :     bool bFlush = false;
    7244       35974 :     if ( mpWindowImpl->mpFrameWindow->mpWindowImpl->mbPaintFrame )
    7245             :     {
    7246        2629 :         Point aPoint( 0, 0 );
    7247        2629 :         Region aRegion( Rectangle( aPoint, Size( mnOutWidth, mnOutHeight ) ) );
    7248        2629 :         ImplInvalidateOverlapFrameRegion( aRegion );
    7249        2629 :         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       35974 :     Window* pUpdateWindow = this;
    7255       35974 :     Window* pWindow = pUpdateWindow;
    7256       72025 :     while ( !pWindow->ImplIsOverlapWindow() )
    7257             :     {
    7258       36051 :         if ( !pWindow->mpWindowImpl->mbPaintTransparent )
    7259             :         {
    7260       35974 :             pUpdateWindow = pWindow;
    7261       35974 :             break;
    7262             :         }
    7263          77 :         pWindow = pWindow->ImplGetParent();
    7264             :     }
    7265             :     // In order to limit drawing, an update only draws the window which
    7266             :     // has PAINTALLCHILDREN set
    7267       35974 :     pWindow = pUpdateWindow;
    7268      104460 :     do
    7269             :     {
    7270      140434 :         if ( pWindow->mpWindowImpl->mnPaintFlags & IMPL_PAINT_PAINTALLCHILDREN )
    7271       18900 :             pUpdateWindow = pWindow;
    7272      140434 :         if ( pWindow->ImplIsOverlapWindow() )
    7273       35974 :             break;
    7274      104460 :         pWindow = pWindow->ImplGetParent();
    7275             :     }
    7276             :     while ( pWindow );
    7277             : 
    7278             :     // if there is something to paint, trigger a Paint
    7279       35974 :     if ( pUpdateWindow->mpWindowImpl->mnPaintFlags & (IMPL_PAINT_PAINT | IMPL_PAINT_PAINTCHILDREN) )
    7280             :     {
    7281       10864 :         ImplDelData aDogTag(this);
    7282             : 
    7283             :         // trigger an update also for system windows on top of us,
    7284             :         // otherwise holes would remain
    7285       10864 :          Window* pUpdateOverlapWindow = ImplGetFirstOverlapWindow()->mpWindowImpl->mpFirstOverlap;
    7286       21728 :          while ( pUpdateOverlapWindow )
    7287             :          {
    7288           0 :              pUpdateOverlapWindow->Update();
    7289           0 :              pUpdateOverlapWindow = pUpdateOverlapWindow->mpWindowImpl->mpNext;
    7290             :          }
    7291             : 
    7292       10864 :         pUpdateWindow->ImplCallPaint( NULL, pUpdateWindow->mpWindowImpl->mnPaintFlags );
    7293             : 
    7294       10864 :         if (aDogTag.IsDead())
    7295           0 :            return;
    7296       10864 :         bFlush = true;
    7297             :     }
    7298             : 
    7299       35974 :     if ( bFlush )
    7300       10864 :         Flush();
    7301             : }
    7302             : 
    7303       49178 : void Window::Flush()
    7304             : {
    7305             : 
    7306       49178 :     const Rectangle aWinRect( Point( mnOutOffX, mnOutOffY ), Size( mnOutWidth, mnOutHeight ) );
    7307       49178 :     mpWindowImpl->mpFrame->Flush( aWinRect );
    7308       49178 : }
    7309             : 
    7310           0 : void Window::Sync()
    7311             : {
    7312             : 
    7313           0 :     mpWindowImpl->mpFrame->Sync();
    7314           0 : }
    7315             : 
    7316      196263 : void Window::SetUpdateMode( bool bUpdate )
    7317             : {
    7318             : 
    7319      196263 :     mpWindowImpl->mbNoUpdate = !bUpdate;
    7320      196263 :     StateChanged( STATE_CHANGE_UPDATEMODE );
    7321      196263 : }
    7322             : 
    7323       19200 : void Window::GrabFocus()
    7324             : {
    7325             : 
    7326       19200 :     ImplGrabFocus( 0 );
    7327       19200 : }
    7328             : 
    7329       52423 : 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       52423 :     return (this == ImplGetSVData()->maWinData.mpFocusWin);
    7345             : }
    7346             : 
    7347           2 : void Window::GrabFocusToDocument()
    7348             : {
    7349           2 :     ImplGrabFocusToDocument(0);
    7350           2 : }
    7351             : 
    7352           0 : void Window::SetFakeFocus( bool bFocus )
    7353             : {
    7354           0 :     ImplGetWindowImpl()->mbFakeFocusSet = bFocus;
    7355           0 : }
    7356             : 
    7357       50118 : 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       50118 :     Window* pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
    7370       50118 :     if ( pFocusWin )
    7371       38938 :         return ImplIsWindowOrChild( pFocusWin, bSystemWindow );
    7372       11180 :     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        1175 : void Window::ReleaseMouse()
    7395             : {
    7396             : 
    7397        1175 :     ImplSVData* pSVData = ImplGetSVData();
    7398             : 
    7399             :     DBG_ASSERTWARNING( pSVData->maWinData.mpCaptureWin == this,
    7400             :                        "Window::ReleaseMouse(): window doesn't have the mouse capture" );
    7401             : 
    7402        1175 :     if ( pSVData->maWinData.mpCaptureWin == this )
    7403             :     {
    7404           0 :         pSVData->maWinData.mpCaptureWin = NULL;
    7405           0 :         mpWindowImpl->mpFrame->CaptureMouse( false );
    7406           0 :         ImplGenerateMouseMove();
    7407             :     }
    7408        1175 : }
    7409             : 
    7410       45009 : bool Window::IsMouseCaptured() const
    7411             : {
    7412             : 
    7413       45009 :     return (this == ImplGetSVData()->maWinData.mpCaptureWin);
    7414             : }
    7415             : 
    7416       13860 : void Window::SetPointer( const Pointer& rPointer )
    7417             : {
    7418             : 
    7419       13860 :     if ( mpWindowImpl->maPointer == rPointer )
    7420       15255 :         return;
    7421             : 
    7422       12465 :     mpWindowImpl->maPointer   = rPointer;
    7423             : 
    7424             :     // possibly immediately move pointer
    7425       12465 :     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       19270 : Point Window::GetPointerPosPixel()
    7464             : {
    7465             : 
    7466       19270 :     Point aPos( mpWindowImpl->mpFrameData->mnLastMouseX, mpWindowImpl->mpFrameData->mnLastMouseY );
    7467       19270 :     if( ImplIsAntiparallel() )
    7468             :     {
    7469             :         // --- RTL --- (re-mirror mouse pos at this window)
    7470          16 :         const OutputDevice *pOutDev = GetOutDev();
    7471          16 :         pOutDev->ReMirror( aPos );
    7472             :     }
    7473       19270 :     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         245 : Window::PointerState Window::GetPointerState()
    7503             : {
    7504         245 :     PointerState aState;
    7505         245 :     aState.mnState = 0;
    7506             : 
    7507         245 :     if (mpWindowImpl->mpFrame)
    7508             :     {
    7509         245 :         SalFrame::SalPointerState aSalPointerState;
    7510             : 
    7511         245 :         aSalPointerState = mpWindowImpl->mpFrame->GetPointerState();
    7512         245 :         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         245 :         aState.maPos = ImplFrameToOutput( aSalPointerState.maPos );
    7519         245 :         aState.mnState = aSalPointerState.mnState;
    7520             :     }
    7521         245 :     return aState;
    7522             : }
    7523             : 
    7524        6128 : bool Window::IsMouseOver()
    7525             : {
    7526        6128 :     return ImplGetWinData()->mbMouseOver;
    7527             : }
    7528             : 
    7529        3694 : void Window::EnterWait()
    7530             : {
    7531             : 
    7532        3694 :     mpWindowImpl->mnWaitCount++;
    7533             : 
    7534        3694 :     if ( mpWindowImpl->mnWaitCount == 1 )
    7535             :     {
    7536             :         // possibly immediately move pointer
    7537        2056 :         if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
    7538           0 :             mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
    7539             :     }
    7540        3694 : }
    7541             : 
    7542        3694 : void Window::LeaveWait()
    7543             : {
    7544             : 
    7545        3694 :     if ( mpWindowImpl->mnWaitCount )
    7546             :     {
    7547        3694 :         mpWindowImpl->mnWaitCount--;
    7548             : 
    7549        3694 :         if ( !mpWindowImpl->mnWaitCount )
    7550             :         {
    7551             :             // possibly immediately move pointer
    7552        2056 :             if ( !mpWindowImpl->mpFrameData->mbInMouseMove && ImplTestMousePointerSet() )
    7553           0 :                 mpWindowImpl->mpFrame->SetPointer( ImplGetMousePointer() );
    7554             :         }
    7555             :     }
    7556        3694 : }
    7557             : 
    7558       16710 : void Window::SetCursor( Cursor* pCursor )
    7559             : {
    7560             : 
    7561       16710 :     if ( mpWindowImpl->mpCursor != pCursor )
    7562             :     {
    7563       16710 :         if ( mpWindowImpl->mpCursor )
    7564        8322 :             mpWindowImpl->mpCursor->ImplHide( true );
    7565       16710 :         mpWindowImpl->mpCursor = pCursor;
    7566       16710 :         if ( pCursor )
    7567        8388 :             pCursor->ImplShow();
    7568             :     }
    7569       16710 : }
    7570             : 
    7571       17334 : void Window::SetText( const OUString& rStr )
    7572             : {
    7573       17334 :     if (rStr == mpWindowImpl->maText)
    7574       19516 :         return;
    7575             : 
    7576       15152 :     OUString oldTitle( mpWindowImpl->maText );
    7577       15152 :     mpWindowImpl->maText = rStr;
    7578             : 
    7579       15152 :     if ( mpWindowImpl->mpBorderWindow )
    7580        4309 :         mpWindowImpl->mpBorderWindow->SetText( rStr );
    7581       10843 :     else if ( mpWindowImpl->mbFrame )
    7582        4309 :         mpWindowImpl->mpFrame->SetTitle( rStr );
    7583             : 
    7584       15152 :     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       15152 :     if ( IsReallyVisible() )
    7591             :     {
    7592        6680 :         Window* pWindow = GetAccessibleRelationLabelFor();
    7593        6680 :         if ( pWindow && pWindow != this )
    7594           0 :             pWindow->ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldTitle );
    7595             :     }
    7596             : 
    7597       15152 :     StateChanged( STATE_CHANGE_TEXT );
    7598             : }
    7599             : 
    7600       26387 : OUString Window::GetText() const
    7601             : {
    7602             : 
    7603       26387 :     return mpWindowImpl->maText;
    7604             : }
    7605             : 
    7606           0 : OUString Window::GetDisplayText() const
    7607             : {
    7608             : 
    7609           0 :     return GetText();
    7610             : }
    7611             : 
    7612        4483 : const Wallpaper& Window::GetDisplayBackground() const
    7613             : {
    7614             :     // FIXME: fix issue 52349, need to fix this really in
    7615             :     // all NWF enabled controls
    7616        4483 :     const ToolBox* pTB = dynamic_cast<const ToolBox*>(this);
    7617        4483 :     if( pTB )
    7618             :     {
    7619        3723 :         if( IsNativeWidgetEnabled() )
    7620        3723 :             return pTB->ImplGetToolBoxPrivateData()->maDisplayBackground;
    7621             :     }
    7622             : 
    7623         760 :     if( !IsBackground() )
    7624             :     {
    7625           0 :         if( mpWindowImpl->mpParent )
    7626           0 :             return mpWindowImpl->mpParent->GetDisplayBackground();
    7627             :     }
    7628             : 
    7629         760 :     const Wallpaper& rBack = GetBackground();
    7630        2280 :     if( ! rBack.IsBitmap() &&
    7631        1520 :         ! rBack.IsGradient() &&
    7632        1520 :         rBack.GetColor().GetColor() == COL_TRANSPARENT &&
    7633             :         mpWindowImpl->mpParent )
    7634           0 :             return mpWindowImpl->mpParent->GetDisplayBackground();
    7635         760 :     return rBack;
    7636             : }
    7637             : 
    7638        2124 : const OUString& Window::GetHelpText() const
    7639             : {
    7640             : 
    7641        2124 :     OUString aStrHelpId( OStringToOUString( GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
    7642        2124 :     bool bStrHelpId = !aStrHelpId.isEmpty();
    7643             : 
    7644        2124 :     if ( !mpWindowImpl->maHelpText.getLength() && bStrHelpId )
    7645             :     {
    7646          32 :         if ( !IsDialog() && (mpWindowImpl->mnType != WINDOW_TABPAGE) && (mpWindowImpl->mnType != WINDOW_FLOATINGWINDOW) )
    7647             :         {
    7648          32 :             Help* pHelp = Application::GetHelp();
    7649          32 :             if ( pHelp )
    7650             :             {
    7651          32 :                 ((Window*)this)->mpWindowImpl->maHelpText = pHelp->GetHelpText( aStrHelpId, this );
    7652          32 :                 mpWindowImpl->mbHelpTextDynamic = false;
    7653             :             }
    7654             :         }
    7655             :     }
    7656        2092 :     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        2124 :     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         109 : sal_uInt16 Window::GetChildCount() const
    7681             : {
    7682             : 
    7683         109 :     sal_uInt16  nChildCount = 0;
    7684         109 :     Window* pChild = mpWindowImpl->mpFirstChild;
    7685         407 :     while ( pChild )
    7686             :     {
    7687         189 :         nChildCount++;
    7688         189 :         pChild = pChild->mpWindowImpl->mpNext;
    7689             :     }
    7690             : 
    7691         109 :     return nChildCount;
    7692             : }
    7693             : 
    7694          73 : Window* Window::GetChild( sal_uInt16 nChild ) const
    7695             : {
    7696             : 
    7697          73 :     sal_uInt16  nChildCount = 0;
    7698          73 :     Window* pChild = mpWindowImpl->mpFirstChild;
    7699         190 :     while ( pChild )
    7700             :     {
    7701         117 :         if ( nChild == nChildCount )
    7702          73 :             return pChild;
    7703          44 :         pChild = pChild->mpWindowImpl->mpNext;
    7704          44 :         nChildCount++;
    7705             :     }
    7706             : 
    7707           0 :     return NULL;
    7708             : }
    7709             : 
    7710      692445 : Window* Window::GetWindow( sal_uInt16 nType ) const
    7711             : {
    7712             : 
    7713      692445 :     switch ( nType )
    7714             :     {
    7715             :         case WINDOW_PARENT:
    7716           0 :             return mpWindowImpl->mpRealParent;
    7717             : 
    7718             :         case WINDOW_FIRSTCHILD:
    7719      165643 :             return mpWindowImpl->mpFirstChild;
    7720             : 
    7721             :         case WINDOW_LASTCHILD:
    7722        8437 :             return mpWindowImpl->mpLastChild;
    7723             : 
    7724             :         case WINDOW_PREV:
    7725         838 :             return mpWindowImpl->mpPrev;
    7726             : 
    7727             :         case WINDOW_NEXT:
    7728       82896 :             return mpWindowImpl->mpNext;
    7729             : 
    7730             :         case WINDOW_FIRSTOVERLAP:
    7731      116079 :             return mpWindowImpl->mpFirstOverlap;
    7732             : 
    7733             :         case WINDOW_LASTOVERLAP:
    7734           0 :             return mpWindowImpl->mpLastOverlap;
    7735             : 
    7736             :         case WINDOW_OVERLAP:
    7737      116079 :             if ( ImplIsOverlapWindow() )
    7738        4472 :                 return (Window*)this;
    7739             :             else
    7740      111607 :                 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       55808 :             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       30584 :             if ( mpWindowImpl->mpBorderWindow )
    7759       13375 :                 return mpWindowImpl->mpBorderWindow->GetWindow( WINDOW_BORDER );
    7760       17209 :             return (Window*)this;
    7761             : 
    7762             :         case WINDOW_FIRSTTOPWINDOWCHILD:
    7763      116079 :             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           2 :             if ( !mpWindowImpl->mpRealParent )
    7785           0 :                 return NULL;
    7786           2 :             const ::std::list< Window* >& rTopWindows( mpWindowImpl->mpRealParent->ImplGetWinData()->maTopWindowChildren );
    7787             :             ::std::list< Window* >::const_iterator myPos =
    7788           2 :                 ::std::find( rTopWindows.begin(), rTopWindows.end(), this );
    7789           2 :             if ( ( myPos == rTopWindows.end() ) || ( ++myPos == rTopWindows.end() ) )
    7790           2 :                 return NULL;
    7791           0 :             return *myPos;
    7792             :         }
    7793             : 
    7794             :     }
    7795             : 
    7796           0 :     return NULL;
    7797             : }
    7798             : 
    7799         236 : bool Window::IsChild( const Window* pWindow, bool bSystemWindow ) const
    7800             : {
    7801             : 
    7802         236 :     do
    7803             :     {
    7804         236 :         if ( !bSystemWindow && pWindow->ImplIsOverlapWindow() )
    7805           0 :             break;
    7806             : 
    7807         236 :         pWindow = pWindow->ImplGetParent();
    7808             : 
    7809         236 :         if ( pWindow == this )
    7810           0 :             return true;
    7811             :     }
    7812             :     while ( pWindow );
    7813             : 
    7814          60 :     return false;
    7815             : }
    7816             : 
    7817       54774 : bool Window::IsWindowOrChild( const Window* pWindow, bool bSystemWindow ) const
    7818             : {
    7819             : 
    7820       54774 :     if ( this == pWindow )
    7821           0 :         return true;
    7822       54774 :     return ImplIsChild( pWindow, bSystemWindow );
    7823             : }
    7824             : 
    7825        5687 : const SystemEnvData* Window::GetSystemData() const
    7826             : {
    7827             : 
    7828        5687 :     return mpWindowImpl->mpFrame ? mpWindowImpl->mpFrame->GetSystemData() : NULL;
    7829             : }
    7830             : 
    7831          21 : ::com::sun::star::uno::Any Window::GetSystemDataAny() const
    7832             : {
    7833          21 :     ::com::sun::star::uno::Any aRet;
    7834          21 :     const SystemEnvData* pSysData = GetSystemData();
    7835          21 :     if( pSysData )
    7836             :     {
    7837          21 :         ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( (sal_Int8*)pSysData, pSysData->nSize );
    7838          21 :         aRet <<= aSeq;
    7839             :     }
    7840          21 :     return aRet;
    7841             : }
    7842             : 
    7843       81455 : 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       81455 :     mpWindowImpl->mxWindowPeer.clear();
    7848       81455 :     mpWindowImpl->mxWindowPeer = xPeer;
    7849             : 
    7850       81455 :     mpWindowImpl->mpVCLXWindow = pVCLXWindow;
    7851       81455 : }
    7852             : 
    7853      262991 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > Window::GetComponentInterface( sal_Bool bCreate )
    7854             : {
    7855      262991 :     if ( !mpWindowImpl->mxWindowPeer.is() && bCreate )
    7856             :     {
    7857       38402 :         UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
    7858       38402 :         if ( pWrapper )
    7859       38402 :             mpWindowImpl->mxWindowPeer = pWrapper->GetWindowInterface( this, true );
    7860             :     }
    7861      262991 :     return mpWindowImpl->mxWindowPeer;
    7862             : }
    7863             : 
    7864        2448 : void Window::SetComponentInterface( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xIFace )
    7865             : {
    7866        2448 :     UnoWrapperBase* pWrapper = Application::GetUnoWrapper();
    7867             :     DBG_ASSERT( pWrapper, "SetComponentInterface: No Wrapper!" );
    7868        2448 :     if ( pWrapper )
    7869        2448 :         pWrapper->SetWindowInterface( this, xIFace );
    7870        2448 : }
    7871             : 
    7872       22680 : void Window::ImplCallDeactivateListeners( Window *pNew )
    7873             : {
    7874             :     // no deactivation if the newly activated window is my child
    7875       22680 :     if ( !pNew || !ImplIsChild( pNew ) )
    7876             :     {
    7877       13306 :         ImplDelData aDogtag( this );
    7878       13306 :         ImplCallEventListeners( VCLEVENT_WINDOW_DEACTIVATE );
    7879       13306 :         if( aDogtag.IsDead() )
    7880       22680 :             return;
    7881             : 
    7882             :         // #100759#, avoid walking the wrong frame's hierarchy
    7883             :         //           eg, undocked docking windows (ImplDockFloatWin)
    7884       13306 :         if ( ImplGetParent() && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow )
    7885       13271 :             ImplGetParent()->ImplCallDeactivateListeners( pNew );
    7886             :     }
    7887             : }
    7888             : 
    7889       24678 : void Window::ImplCallActivateListeners( Window *pOld )
    7890             : {
    7891             :     // no activation if the old active window is my child
    7892       24678 :     if ( !pOld || !ImplIsChild( pOld ) )
    7893             :     {
    7894       15304 :         ImplDelData aDogtag( this );
    7895       15304 :         ImplCallEventListeners( VCLEVENT_WINDOW_ACTIVATE, pOld );
    7896       15304 :         if( aDogtag.IsDead() )
    7897       24678 :             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       15304 :         if ( ImplGetParent() ) /* && mpWindowImpl->mpFrameWindow == ImplGetParent()->mpWindowImpl->mpFrameWindow ) */
    7909       13433 :             ImplGetParent()->ImplCallActivateListeners( pOld );
    7910        1871 :         else if( (mpWindowImpl->mnStyle & WB_INTROWIN) == 0 )
    7911             :         {
    7912             :             // top level frame reached: store hint for DefModalDialogParent
    7913        1871 :             ImplGetSVData()->maWinData.mpActiveApplicationFrame = mpWindowImpl->mpFrameWindow;
    7914       15304 :         }
    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       78112 : uno::Reference< XDropTarget > Window::GetDropTarget()
    7939             : {
    7940             : 
    7941       78112 :     if( ! mpWindowImpl->mxDNDListenerContainer.is() )
    7942             :     {
    7943       13383 :         sal_Int8 nDefaultActions = 0;
    7944             : 
    7945       13383 :         if( mpWindowImpl->mpFrameData )
    7946             :         {
    7947       13383 :             if( ! mpWindowImpl->mpFrameData->mxDropTarget.is() )
    7948             :             {
    7949             :                 // initialization is done in GetDragSource
    7950        5666 :                 uno::Reference< XDragSource > xDragSource = GetDragSource();
    7951             :             }
    7952             : 
    7953       13383 :             if( mpWindowImpl->mpFrameData->mxDropTarget.is() )
    7954             :             {
    7955        8870 :                 nDefaultActions = mpWindowImpl->mpFrameData->mxDropTarget->getDefaultActions();
    7956             : 
    7957        8870 :                 if( ! mpWindowImpl->mpFrameData->mxDropTargetListener.is() )
    7958             :                 {
    7959        1153 :                     mpWindowImpl->mpFrameData->mxDropTargetListener = new DNDEventDispatcher( mpWindowImpl->mpFrameWindow );
    7960             : 
    7961             :                     try
    7962             :                     {
    7963        1153 :                         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        1153 :                             uno::Reference< XDragGestureRecognizer > (mpWindowImpl->mpFrameData->mxDragSource, UNO_QUERY);
    7968             : 
    7969        1153 :                         if( xDragGestureRecognizer.is() )
    7970             :                         {
    7971           0 :                             xDragGestureRecognizer->addDragGestureListener(
    7972           0 :                                 uno::Reference< XDragGestureListener > (mpWindowImpl->mpFrameData->mxDropTargetListener, UNO_QUERY));
    7973             :                         }
    7974             :                         else
    7975        1153 :                             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       13383 :         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       78112 :     return uno::Reference< XDropTarget > ( mpWindowImpl->mxDNDListenerContainer, UNO_QUERY );
    7994             : }
    7995             : 
    7996        5667 : uno::Reference< XDragSource > Window::GetDragSource()
    7997             : {
    7998             : 
    7999             : #if HAVE_FEATURE_DESKTOP
    8000             : 
    8001        5667 :     if( mpWindowImpl->mpFrameData )
    8002             :     {
    8003        5667 :         if( ! mpWindowImpl->mpFrameData->mxDragSource.is() )
    8004             :         {
    8005             :             try
    8006             :             {
    8007        5666 :                 uno::Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
    8008        5666 :                 const SystemEnvData * pEnvData = GetSystemData();
    8009             : 
    8010        5666 :                 if( pEnvData )
    8011             :                 {
    8012       11332 :                     Sequence< Any > aDragSourceAL( 2 ), aDropTargetAL( 2 );
    8013       11332 :                     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        5666 :                     aDragSourceSN = "com.sun.star.datatransfer.dnd.X11DragSource";
    8028        5666 :                     aDropTargetSN = "com.sun.star.datatransfer.dnd.X11DropTarget";
    8029             : 
    8030        5666 :                     aDragSourceAL[ 0 ] = makeAny( Application::GetDisplayConnection() );
    8031        5666 :                     aDropTargetAL[ 0 ] = makeAny( Application::GetDisplayConnection() );
    8032        5666 :                     aDropTargetAL[ 1 ] = makeAny( (sal_Size)(pEnvData->aShellWindow) );
    8033             : #endif
    8034        5666 :                     if( !aDragSourceSN.isEmpty() )
    8035             :                         mpWindowImpl->mpFrameData->mxDragSource.set(
    8036       11332 :                             xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aDragSourceSN, aDragSourceAL, xContext ),
    8037        5666 :                             UNO_QUERY );
    8038             : 
    8039        5666 :                     if( !aDropTargetSN.isEmpty() )
    8040             :                         mpWindowImpl->mpFrameData->mxDropTarget.set(
    8041       11332 :                            xContext->getServiceManager()->createInstanceWithArgumentsAndContext( aDropTargetSN, aDropTargetAL, xContext ),
    8042       11332 :                            UNO_QUERY );
    8043        5666 :                 }
    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        5667 :         return mpWindowImpl->mpFrameData->mxDragSource;
    8056             :     }
    8057             : #endif
    8058           0 :     return uno::Reference< XDragSource > ();
    8059             : }
    8060             : 
    8061       22855 : uno::Reference< XDragGestureRecognizer > Window::GetDragGestureRecognizer()
    8062             : {
    8063       22855 :     return uno::Reference< XDragGestureRecognizer > ( GetDropTarget(), UNO_QUERY );
    8064             : }
    8065             : 
    8066        5009 : uno::Reference< XClipboard > Window::GetClipboard()
    8067             : {
    8068             : 
    8069        5009 :     if( mpWindowImpl->mpFrameData )
    8070             :     {
    8071        5009 :         if( ! mpWindowImpl->mpFrameData->mxClipboard.is() )
    8072             :         {
    8073             :             try
    8074             :             {
    8075             :                 mpWindowImpl->mpFrameData->mxClipboard
    8076        2771 :                     = css::datatransfer::clipboard::SystemClipboard::create(
    8077         694 :                         comphelper::getProcessComponentContext());
    8078             :             }
    8079        1383 :             catch (css::uno::DeploymentException & e)
    8080             :             {
    8081             :                 SAL_WARN(
    8082             :                     "vcl.window",
    8083             :                     "ignoring DeploymentException \"" << e.Message << "\"");
    8084             :             }
    8085             :         }
    8086             : 
    8087        5009 :         return mpWindowImpl->mpFrameData->mxClipboard;
    8088             :     }
    8089             : 
    8090           0 :     return static_cast < XClipboard * > (0);
    8091             : }
    8092             : 
    8093         233 : uno::Reference< XClipboard > Window::GetPrimarySelection()
    8094             : {
    8095             : 
    8096         233 :     if( mpWindowImpl->mpFrameData )
    8097             :     {
    8098         233 :         if( ! mpWindowImpl->mpFrameData->mxSelection.is() )
    8099             :         {
    8100             :             try
    8101             :             {
    8102         169 :                 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         338 :                 css::uno::Sequence<css::uno::Any> args(1);
    8108         169 :                 args[0] <<= OUString("PRIMARY");
    8109             :                 mpWindowImpl->mpFrameData->mxSelection.set(
    8110         338 :                     (xContext->getServiceManager()->
    8111             :                      createInstanceWithArgumentsAndContext(
    8112             :                          "com.sun.star.datatransfer.clipboard.SystemClipboard",
    8113         169 :                          args, xContext)),
    8114         494 :                     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         156 :             catch (css::uno::RuntimeException & e)
    8123             :             {
    8124             :                 SAL_WARN(
    8125             :                     "vcl.window",
    8126             :                     "ignoring RuntimeException \"" << e.Message << "\"");
    8127             :             }
    8128             :         }
    8129             : 
    8130         233 :         return mpWindowImpl->mpFrameData->mxSelection;
    8131             :     }
    8132             : 
    8133           0 :     return static_cast < XClipboard * > (0);
    8134             : }
    8135             : 
    8136             : // Accessibility
    8137             : 
    8138        2908 : ::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        2908 :     if ( !mpWindowImpl->mxAccessible.is() && bCreate )
    8151         273 :         mpWindowImpl->mxAccessible = CreateAccessible();
    8152             : 
    8153        2908 :     return mpWindowImpl->mxAccessible;
    8154             : }
    8155             : 
    8156         220 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > Window::CreateAccessible()
    8157             : {
    8158         220 :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAcc( GetComponentInterface( sal_True ), ::com::sun::star::uno::UNO_QUERY );
    8159         220 :     return xAcc;
    8160             : }
    8161             : 
    8162        2075 : void Window::SetAccessible( ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > x )
    8163             : {
    8164        2075 :     mpWindowImpl->mxAccessible = x;
    8165        2075 : }
    8166             : 
    8167             : // skip all border windows that are no top level frames
    8168      431980 : bool Window::ImplIsAccessibleCandidate() const
    8169             : {
    8170      431980 :     if( !mpWindowImpl->mbBorderWin )
    8171      378542 :         return true;
    8172             :     else
    8173             :         // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menus!) are closeable
    8174       53438 :         if( mpWindowImpl->mbFrame && mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) )
    8175       12672 :             return true;
    8176             :         else
    8177       40766 :             return false;
    8178             : }
    8179             : 
    8180      404534 : bool Window::ImplIsAccessibleNativeFrame() const
    8181             : {
    8182      404534 :     if( mpWindowImpl->mbFrame )
    8183             :         // #101741 do not check for WB_CLOSEABLE because undecorated floaters (like menus!) are closeable
    8184       11804 :         if( (mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE)) )
    8185        4729 :             return true;
    8186             :         else
    8187        7075 :             return false;
    8188             :     else
    8189      392730 :         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      286936 : Window* Window::GetAccessibleParentWindow() const
    8231             : {
    8232      286936 :     if ( ImplIsAccessibleNativeFrame() )
    8233        2374 :         return NULL;
    8234             : 
    8235      284562 :     Window* pParent = mpWindowImpl->mpParent;
    8236      284562 :     if( GetType() == WINDOW_MENUBARWINDOW )
    8237             :     {
    8238             :         // report the menubar as a child of THE workwindow
    8239        4201 :         Window *pWorkWin = GetParent()->mpWindowImpl->mpFirstChild;
    8240       10038 :         while( pWorkWin && (pWorkWin == this) )
    8241        1636 :             pWorkWin = pWorkWin->mpWindowImpl->mpNext;
    8242        4201 :         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      565288 :     else if( GetType() == WINDOW_FLOATINGWINDOW &&
    8251      280373 :         mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame &&
    8252           6 :         !PopupMenuFloatingWindow::isPopupMenu(this))
    8253             :     {
    8254           6 :         pParent = mpWindowImpl->mpBorderWindow;
    8255             :     }
    8256      280355 :     else if( pParent && !pParent->ImplIsAccessibleCandidate() )
    8257             :     {
    8258       31609 :         pParent = pParent->mpWindowImpl->mpParent;
    8259             :     }
    8260      284562 :     return pParent;
    8261             : }
    8262             : 
    8263        1100 : sal_uInt16 Window::GetAccessibleChildWindowCount()
    8264             : {
    8265        1100 :     sal_uInt16 nChildren = 0;
    8266        1100 :     Window* pChild = mpWindowImpl->mpFirstChild;
    8267        9011 :     while( pChild )
    8268             :     {
    8269        6811 :         if( pChild->IsVisible() )
    8270        3725 :             nChildren++;
    8271        6811 :         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        1100 :     if( GetType() == WINDOW_BORDERWINDOW )
    8292             :     {
    8293         396 :         if( ((ImplBorderWindow *) this)->mpMenuBarWindow &&
    8294         198 :             ((ImplBorderWindow *) this)->mpMenuBarWindow->IsVisible()
    8295             :             )
    8296         198 :             --nChildren;
    8297             :     }
    8298         902 :     else if( GetType() == WINDOW_WORKWINDOW )
    8299             :     {
    8300         768 :         if( ((WorkWindow *) this)->GetMenuBar() &&
    8301         512 :             ((WorkWindow *) this)->GetMenuBar()->GetWindow() &&
    8302         256 :             ((WorkWindow *) this)->GetMenuBar()->GetWindow()->IsVisible()
    8303             :             )
    8304         256 :             ++nChildren;
    8305             :     }
    8306             : 
    8307        1100 :     return nChildren;
    8308             : }
    8309             : 
    8310         249 : Window* Window::GetAccessibleChildWindow( sal_uInt16 n )
    8311             : {
    8312             :     // report the menubarwindow as a the first child of THE workwindow
    8313         249 :     if( GetType() == WINDOW_WORKWINDOW && ((WorkWindow *) this)->GetMenuBar() )
    8314             :     {
    8315          42 :         if( n == 0 )
    8316             :         {
    8317          14 :             MenuBar *pMenuBar = ((WorkWindow *) this)->GetMenuBar();
    8318          14 :             if( pMenuBar->GetWindow() && pMenuBar->GetWindow()->IsVisible() )
    8319          14 :                 return pMenuBar->GetWindow();
    8320             :         }
    8321             :         else
    8322          28 :             --n;
    8323             :     }
    8324             : 
    8325             :     // transform n to child number including invisible children
    8326         235 :     sal_uInt16 nChildren = n;
    8327         235 :     Window* pChild = mpWindowImpl->mpFirstChild;
    8328         952 :     while( pChild )
    8329             :     {
    8330         717 :         if( pChild->IsVisible() )
    8331             :         {
    8332         440 :             if( ! nChildren )
    8333         235 :                 break;
    8334         205 :             nChildren--;
    8335             :         }
    8336         482 :         pChild = pChild->mpWindowImpl->mpNext;
    8337             :     }
    8338             : 
    8339         235 :     if( GetType() == WINDOW_BORDERWINDOW && pChild && pChild->GetType() == WINDOW_MENUBARWINDOW )
    8340             :     {
    8341          18 :         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         235 :     if ( pChild && ( pChild->GetType() == WINDOW_BORDERWINDOW ) && ( pChild->GetChildCount() == 1 ) )
    8367             :     {
    8368          23 :         pChild = pChild->GetChild( 0 );
    8369             :     }
    8370         235 :     return pChild;
    8371             : }
    8372             : 
    8373        4545 : void Window::SetAccessibleRole( sal_uInt16 nRole )
    8374             : {
    8375        4545 :     if ( !mpWindowImpl->mpAccessibleInfos )
    8376        4545 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8377             : 
    8378             :     DBG_ASSERT( mpWindowImpl->mpAccessibleInfos->nAccessibleRole == 0xFFFF, "AccessibleRole already set!" );
    8379        4545 :     mpWindowImpl->mpAccessibleInfos->nAccessibleRole = nRole;
    8380        4545 : }
    8381             : 
    8382        2052 : sal_uInt16 Window::getDefaultAccessibleRole() const
    8383             : {
    8384        2052 :     sal_uInt16 nRole = 0xFFFF;
    8385        2052 :     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           8 :         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          12 :         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          47 :         case WINDOW_SCROLLBAR: nRole = accessibility::AccessibleRole::SCROLL_BAR; break;
    8451             : 
    8452             :         case WINDOW_SLIDER:
    8453             :         case WINDOW_SPLITTER:
    8454          45 :         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          43 :         case WINDOW_TOOLBOX: nRole = accessibility::AccessibleRole::TOOL_BAR; break;
    8468           3 :         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          53 :                                                                       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         384 :         case WINDOW_WORKWINDOW: nRole = accessibility::AccessibleRole::ROOT_PANE; break;
    8483             : 
    8484          42 :         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        1415 :             if (ImplIsAccessibleNativeFrame() )
    8498         198 :                 nRole = accessibility::AccessibleRole::FRAME;
    8499        1217 :             else if( IsScrollable() )
    8500         713 :                 nRole = accessibility::AccessibleRole::SCROLL_PANE;
    8501         504 :             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         504 :                 nRole = accessibility::AccessibleRole::PANEL;
    8508             :     }
    8509        2052 :     return nRole;
    8510             : }
    8511             : 
    8512        2052 : sal_uInt16 Window::GetAccessibleRole() const
    8513             : {
    8514             :     using namespace ::com::sun::star;
    8515             : 
    8516        2052 :     sal_uInt16 nRole = mpWindowImpl->mpAccessibleInfos ? mpWindowImpl->mpAccessibleInfos->nAccessibleRole : 0xFFFF;
    8517        2052 :     if ( nRole == 0xFFFF )
    8518        2052 :         nRole = getDefaultAccessibleRole();
    8519        2052 :     return nRole;
    8520             : }
    8521             : 
    8522        3744 : void Window::SetAccessibleName( const OUString& rName )
    8523             : {
    8524        3744 :    if ( !mpWindowImpl->mpAccessibleInfos )
    8525        3744 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8526             : 
    8527        3744 :     OUString oldName = GetAccessibleName();
    8528             : 
    8529        3744 :     delete mpWindowImpl->mpAccessibleInfos->pAccessibleName;
    8530        3744 :     mpWindowImpl->mpAccessibleInfos->pAccessibleName = new OUString( rName );
    8531             : 
    8532        3744 :     ImplCallEventListeners( VCLEVENT_WINDOW_FRAMETITLECHANGED, &oldName );
    8533        3744 : }
    8534             : 
    8535        4443 : OUString Window::GetAccessibleName() const
    8536             : {
    8537        4443 :     if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleName)
    8538          22 :         return *mpWindowImpl->mpAccessibleInfos->pAccessibleName;
    8539        4421 :     return getDefaultAccessibleName();
    8540             : }
    8541             : 
    8542        4421 : OUString Window::getDefaultAccessibleName() const
    8543             : {
    8544        4421 :     OUString aAccessibleName;
    8545        4421 :     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        2071 :             Window *pLabel = GetAccessibleRelationLabeledBy();
    8571        2071 :             if ( pLabel && pLabel != this )
    8572           0 :                 aAccessibleName = pLabel->GetText();
    8573        2071 :             if (aAccessibleName.isEmpty())
    8574        2071 :                 aAccessibleName = GetQuickHelpText();
    8575             :         }
    8576        2071 :         break;
    8577             : 
    8578             :         case WINDOW_IMAGEBUTTON:
    8579             :         case WINDOW_PUSHBUTTON:
    8580        1388 :             aAccessibleName = GetText();
    8581        1388 :             if (aAccessibleName.isEmpty())
    8582             :             {
    8583        1388 :                 aAccessibleName = GetQuickHelpText();
    8584        1388 :                 if (aAccessibleName.isEmpty())
    8585        1388 :                     aAccessibleName = GetHelpText();
    8586             :             }
    8587        1388 :         break;
    8588             : 
    8589             :         case WINDOW_TOOLBOX:
    8590         228 :             aAccessibleName = GetText();
    8591         228 :             if( aAccessibleName.isEmpty() )
    8592         222 :                 aAccessibleName = "Tool Bar";
    8593         228 :             break;
    8594             : 
    8595             :         case WINDOW_MOREBUTTON:
    8596           0 :             aAccessibleName = mpWindowImpl->maText;
    8597           0 :             break;
    8598             : 
    8599             :         default:
    8600         734 :             aAccessibleName = GetText();
    8601         734 :             break;
    8602             :     }
    8603             : 
    8604        4421 :     return GetNonMnemonicString( aAccessibleName );
    8605             : }
    8606             : 
    8607          48 : void Window::SetAccessibleDescription( const OUString& rDescription )
    8608             : {
    8609          48 :    if ( ! mpWindowImpl->mpAccessibleInfos )
    8610           0 :         mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
    8611             : 
    8612             :     DBG_ASSERT( !mpWindowImpl->mpAccessibleInfos->pAccessibleDescription, "AccessibleDescription already set!" );
    8613          48 :     delete mpWindowImpl->mpAccessibleInfos->pAccessibleDescription;
    8614          48 :     mpWindowImpl->mpAccessibleInfos->pAccessibleDescription = new OUString( rDescription );
    8615          48 : }
    8616             : 
    8617         784 : OUString Window::GetAccessibleDescription() const
    8618             : {
    8619         784 :     OUString aAccessibleDescription;
    8620         784 :     if ( mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pAccessibleDescription )
    8621             :     {
    8622          48 :         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         736 :         const Window* pWin = ((Window *)this)->ImplGetWindow();
    8629         736 :         if ( pWin->GetType() == WINDOW_HELPTEXTWINDOW )
    8630           0 :             aAccessibleDescription = pWin->GetHelpText();
    8631             :         else
    8632         736 :             aAccessibleDescription = GetHelpText();
    8633             :     }
    8634             : 
    8635         784 :     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           5 : Window* Window::GetAccessibleRelationMemberOf() const
    8660             : {
    8661           5 :     if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pMemberOfWindow)
    8662           0 :         return mpWindowImpl->mpAccessibleInfos->pMemberOfWindow;
    8663             : 
    8664           5 :     if (!isContainerWindow(this) && !isContainerWindow(GetParent()))
    8665           5 :         return getLegacyNonLayoutAccessibleRelationMemberOf();
    8666             : 
    8667           0 :     return NULL;
    8668             : }
    8669             : 
    8670        6685 : Window* Window::getAccessibleRelationLabelFor() const
    8671             : {
    8672        6685 :     if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabelForWindow)
    8673           0 :         return mpWindowImpl->mpAccessibleInfos->pLabelForWindow;
    8674             : 
    8675        6685 :     return NULL;
    8676             : }
    8677             : 
    8678        6685 : Window* Window::GetAccessibleRelationLabelFor() const
    8679             : {
    8680        6685 :     Window* pWindow = getAccessibleRelationLabelFor();
    8681             : 
    8682        6685 :     if (pWindow)
    8683           0 :         return pWindow;
    8684             : 
    8685        6685 :     if (!isContainerWindow(this) && !isContainerWindow(GetParent()))
    8686        6685 :         return getLegacyNonLayoutAccessibleRelationLabelFor();
    8687             : 
    8688           0 :     return NULL;
    8689             : }
    8690             : 
    8691        2076 : Window* Window::GetAccessibleRelationLabeledBy() const
    8692             : {
    8693        2076 :     if (mpWindowImpl->mpAccessibleInfos && mpWindowImpl->mpAccessibleInfos->pLabeledByWindow)
    8694           0 :         return mpWindowImpl->mpAccessibleInfos->pLabeledByWindow;
    8695             : 
    8696        2076 :     std::vector<FixedText*> aMnemonicLabels(list_mnemonic_labels());
    8697        2076 :     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        2076 :     if (!isContainerWindow(this) && !isContainerWindow(GetParent()))
    8711        2076 :         return getLegacyNonLayoutAccessibleRelationLabeledBy();
    8712             : 
    8713           0 :     return NULL;
    8714             : }
    8715             : 
    8716       23732 : bool Window::IsAccessibilityEventsSuppressed( bool bTraverseParentPath )
    8717             : {
    8718       23732 :     if( !bTraverseParentPath )
    8719         768 :         return mpWindowImpl->mbSuppressAccessibilityEvents;
    8720             :     else
    8721             :     {
    8722       22964 :         Window *pParent = this;
    8723      160571 :         while ( pParent && pParent->mpWindowImpl)
    8724             :         {
    8725      115896 :             if( pParent->mpWindowImpl->mbSuppressAccessibilityEvents )
    8726        1253 :                 return true;
    8727             :             else
    8728      114643 :                 pParent = pParent->mpWindowImpl->mpParent; // do not use GetParent() to find borderwindows that are frames
    8729             :         }
    8730       21711 :         return false;
    8731             :     }
    8732             : }
    8733             : 
    8734        1536 : void Window::SetAccessibilityEventsSuppressed(bool bSuppressed)
    8735             : {
    8736        1536 :     mpWindowImpl->mbSuppressAccessibilityEvents = bSuppressed;
    8737        1536 : }
    8738             : 
    8739         205 : void Window::RecordLayoutData( vcl::ControlLayoutData* pLayout, const Rectangle& rRect )
    8740             : {
    8741         205 :     if( ! mpOutDevData )
    8742             :     {
    8743           1 :         OutputDevice *pOutDev = GetOutDev();
    8744           1 :         pOutDev->ImplInitOutDevData();
    8745             :     }
    8746             :     assert(mpOutDevData);
    8747         205 :     mpOutDevData->mpRecordLayout = pLayout;
    8748         205 :     mpOutDevData->maRecordRect = rRect;
    8749         205 :     Paint( rRect );
    8750         205 :     mpOutDevData->mpRecordLayout = NULL;
    8751         205 : }
    8752             : 
    8753           5 : void Window::DrawSelectionBackground( const Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly )
    8754             : {
    8755           5 :     DrawSelectionBackground( rRect, highlight, bChecked, bDrawBorder, bDrawExtBorderOnly, 0, NULL, NULL );
    8756           5 : }
    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        3740 : 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        3740 :     if( rRect.IsEmpty() )
    8774        3740 :         return;
    8775             : 
    8776        3740 :     bool bRoundEdges = nCornerRadius > 0;
    8777             : 
    8778        3740 :     const StyleSettings& rStyles = GetSettings().GetStyleSettings();
    8779             : 
    8780             :     // colors used for item highlighting
    8781        3740 :     Color aSelectionBorderCol( pPaintColor ? *pPaintColor : rStyles.GetHighlightColor() );
    8782        3740 :     Color aSelectionFillCol( aSelectionBorderCol );
    8783             : 
    8784        3740 :     bool bDark = rStyles.GetFaceColor().IsDark();
    8785        3740 :     bool bBright = ( rStyles.GetFaceColor() == Color( COL_WHITE ) );
    8786             : 
    8787        3740 :     int c1 = aSelectionBorderCol.GetLuminance();
    8788        3740 :     int c2 = GetDisplayBackground().GetColor().GetLuminance();
    8789             : 
    8790        3740 :     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        3740 :     if( bRoundEdges )
    8802             :     {
    8803        3735 :         if( aSelectionBorderCol.IsDark() )
    8804        3735 :             aSelectionBorderCol.IncreaseLuminance( 128 );
    8805             :         else
    8806           0 :             aSelectionBorderCol.DecreaseLuminance( 128 );
    8807             :     }
    8808             : 
    8809        3740 :     Rectangle aRect( rRect );
    8810        3740 :     if( bDrawExtBorderOnly )
    8811             :     {
    8812           0 :         --aRect.Left();
    8813           0 :         --aRect.Top();
    8814           0 :         ++aRect.Right();
    8815           0 :         ++aRect.Bottom();
    8816             :     }
    8817        3740 :     Color oldFillCol = GetFillColor();
    8818        3740 :     Color oldLineCol = GetLineColor();
    8819             : 
    8820        3740 :     if( bDrawBorder )
    8821        3740 :         SetLineColor( bDark ? Color(COL_WHITE) : ( bBright ? Color(COL_BLACK) : aSelectionBorderCol ) );
    8822             :     else
    8823           0 :         SetLineColor();
    8824             : 
    8825        3740 :     sal_uInt16 nPercent = 0;
    8826        3740 :     if( !highlight )
    8827             :     {
    8828        3734 :         if( bDark )
    8829           0 :             aSelectionFillCol = COL_BLACK;
    8830             :         else
    8831        3734 :             nPercent = 80;  // just checked (light)
    8832             :     }
    8833             :     else
    8834             :     {
    8835           6 :         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           6 :         else if( bChecked || highlight == 1 )
    8849             :         {
    8850           8 :             if( bDark )
    8851           0 :                 aSelectionFillCol = COL_GRAY;
    8852           4 :             else if ( bBright )
    8853             :             {
    8854           0 :                 aSelectionFillCol = COL_BLACK;
    8855           0 :                 SetLineColor( COL_BLACK );
    8856           0 :                 nPercent = 0;
    8857             :             }
    8858             :             else
    8859           4 :                 nPercent = bRoundEdges ? 60 : 35;          // selected, pressed or checked ( very dark )
    8860             :         }
    8861             :         else
    8862             :         {
    8863           2 :             if( bDark )
    8864           0 :                 aSelectionFillCol = COL_LIGHTGRAY;
    8865           2 :             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           2 :                 nPercent = 70;          // selected ( dark )
    8876             :         }
    8877             :     }
    8878             : 
    8879        3740 :     if( bDark && bDrawExtBorderOnly )
    8880             :     {
    8881           0 :         SetFillColor();
    8882           0 :         if( pSelectionTextColor )
    8883           0 :             *pSelectionTextColor = rStyles.GetHighlightTextColor();
    8884             :     }
    8885             :     else
    8886             :     {
    8887        3740 :         SetFillColor( aSelectionFillCol );
    8888        3740 :         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        3740 :     if( bDark )
    8899             :     {
    8900           0 :         DrawRect( aRect );
    8901             :     }
    8902             :     else
    8903             :     {
    8904        3740 :         if( bRoundEdges )
    8905             :         {
    8906        3735 :             Polygon aPoly( aRect, nCornerRadius, nCornerRadius );
    8907        7470 :             PolyPolygon aPolyPoly( aPoly );
    8908        7470 :             DrawTransparent( aPolyPoly, nPercent );
    8909             :         }
    8910             :         else
    8911             :         {
    8912           5 :             Polygon aPoly( aRect );
    8913          10 :             PolyPolygon aPolyPoly( aPoly );
    8914          10 :             DrawTransparent( aPolyPoly, nPercent );
    8915             :         }
    8916             :     }
    8917             : 
    8918        3740 :     SetFillColor( oldFillCol );
    8919        3740 :     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        1217 : bool Window::IsScrollable() const
    8930             : {
    8931             :     // check for scrollbars
    8932        1217 :     Window *pChild = mpWindowImpl->mpFirstChild;
    8933        6876 :     while( pChild )
    8934             :     {
    8935        5155 :         if( pChild->GetType() == WINDOW_SCROLLBAR )
    8936         713 :             return true;
    8937             :         else
    8938        4442 :             pChild = pChild->mpWindowImpl->mpNext;
    8939             :     }
    8940         504 :     return false;
    8941             : }
    8942             : 
    8943      201778 : bool Window::IsTopWindow() const
    8944             : {
    8945      201778 :     if ( mpWindowImpl->mbInDtor )
    8946           0 :         return false;
    8947             : 
    8948             :     // topwindows must be frames or they must have a borderwindow which is a frame
    8949      201778 :     if( !mpWindowImpl->mbFrame && (!mpWindowImpl->mpBorderWindow || (mpWindowImpl->mpBorderWindow && !mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame) ) )
    8950           0 :         return false;
    8951             : 
    8952      201778 :     ImplGetWinData();
    8953      201778 :     if( mpWindowImpl->mpWinData->mnIsTopWindow == (sal_uInt16)~0)    // still uninitialized
    8954             :     {
    8955             :         // #113722#, cache result of expensive queryInterface call
    8956        8743 :         Window *pThisWin = (Window*)this;
    8957        8743 :         uno::Reference< XTopWindow > xTopWindow( pThisWin->GetComponentInterface(), UNO_QUERY );
    8958        8743 :         pThisWin->mpWindowImpl->mpWinData->mnIsTopWindow = xTopWindow.is() ? 1 : 0;
    8959             :     }
    8960      201778 :     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       26845 : bool Window::IsInModalMode() const
    8970             : {
    8971       26845 :     return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0);
    8972             : }
    8973             : 
    8974       13425 : bool Window::IsInModalNonRefMode() const
    8975             : {
    8976       13425 :     if(mpWindowImpl->mnStyle & WB_REFMODE)
    8977           0 :         return false;
    8978             : 
    8979       13425 :     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       21894 : void Window::ImplIsInTaskPaneList( bool mbIsInTaskList )
    9012             : {
    9013       21894 :     mpWindowImpl->mbIsInTaskPaneList = mbIsInTaskList;
    9014       21894 : }
    9015             : 
    9016          71 : void Window::ImplNotifyIconifiedState( bool bIconified )
    9017             : {
    9018          71 :     mpWindowImpl->mpFrameWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
    9019             :     // #109206# notify client window as well to have toolkit topwindow listeners notified
    9020          71 :     if( mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow && mpWindowImpl->mpFrameWindow != mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow )
    9021          17 :         mpWindowImpl->mpFrameWindow->mpWindowImpl->mpClientWindow->ImplCallEventListeners( bIconified ? VCLEVENT_WINDOW_MINIMIZE : VCLEVENT_WINDOW_NORMALIZE );
    9022          71 : }
    9023             : 
    9024          17 : bool Window::HasActiveChildFrame()
    9025             : {
    9026          17 :     bool bRet = false;
    9027          17 :     Window *pFrameWin = ImplGetSVData()->maWinData.mpFirstFrame;
    9028         137 :     while( pFrameWin )
    9029             :     {
    9030         103 :         if( pFrameWin != mpWindowImpl->mpFrameWindow )
    9031             :         {
    9032          86 :             bool bDecorated = false;
    9033          86 :             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          86 :             if( pChildFrame && pChildFrame->ImplIsFloatingWindow() )
    9040          69 :                 bDecorated = ((FloatingWindow*) pChildFrame)->GetTitleType() != FLOATWIN_TITLE_NONE;
    9041          86 :             if( bDecorated || (pFrameWin->mpWindowImpl->mnStyle & (WB_MOVEABLE | WB_SIZEABLE) ) )
    9042           1 :                 if( pChildFrame && pChildFrame->IsVisible() && pChildFrame->IsActive() )
    9043             :                 {
    9044           1 :                     if( ImplIsChild( pChildFrame, true ) )
    9045             :                     {
    9046           0 :                         bRet = true;
    9047           0 :                         break;
    9048             :                     }
    9049             :                 }
    9050             :         }
    9051         103 :         pFrameWin = pFrameWin->mpWindowImpl->mpFrameData->mpNextFrame;
    9052             :     }
    9053          17 :     return bRet;
    9054             : }
    9055             : 
    9056        1719 : LanguageType Window::GetInputLanguage() const
    9057             : {
    9058        1719 :     return mpWindowImpl->mpFrame->GetInputLanguage();
    9059             : }
    9060             : 
    9061       31110 : void Window::EnableNativeWidget( bool bEnable )
    9062             : {
    9063       31110 :     static const char* pNoNWF = getenv( "SAL_NO_NWF" );
    9064       31110 :     if( pNoNWF && *pNoNWF )
    9065           0 :         bEnable = false;
    9066             : 
    9067       31110 :     if( bEnable != ImplGetWinData()->mbEnableNativeWidget )
    9068             :     {
    9069        6049 :         ImplGetWinData()->mbEnableNativeWidget = bEnable;
    9070             : 
    9071             :         // send datachanged event to allow for internal changes required for NWF
    9072             :         // like clipmode, transparency, etc.
    9073        6049 :         DataChangedEvent aDCEvt( DATACHANGED_SETTINGS, mxSettings.get(), SETTINGS_STYLE );
    9074        6049 :         DataChanged( aDCEvt );
    9075             : 
    9076             :         // sometimes the borderwindow is queried, so keep it in sync
    9077        6049 :         if( mpWindowImpl->mpBorderWindow )
    9078        2076 :             mpWindowImpl->mpBorderWindow->ImplGetWinData()->mbEnableNativeWidget = bEnable;
    9079             :     }
    9080             : 
    9081             :     // push down, useful for compound controls
    9082       31110 :     Window *pChild = mpWindowImpl->mpFirstChild;
    9083       86366 :     while( pChild )
    9084             :     {
    9085       24146 :         pChild->EnableNativeWidget( bEnable );
    9086       24146 :         pChild = pChild->mpWindowImpl->mpNext;
    9087             :     }
    9088       31110 : }
    9089             : 
    9090      611029 : bool Window::IsNativeWidgetEnabled() const
    9091             : {
    9092      611029 :     return ImplGetWinData()->mbEnableNativeWidget;
    9093             : }
    9094             : 
    9095             : #ifdef WNT // see #140456#
    9096             : #include <win/salframe.h>
    9097             : #endif
    9098             : 
    9099          21 : 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          21 :     uno::Reference< rendering::XCanvas > xCanvas( mpWindowImpl->mxCanvas );
    9105             : 
    9106             :     // canvas still valid? Then we're done.
    9107          21 :     if( xCanvas.is() )
    9108           0 :         return xCanvas;
    9109             : 
    9110          42 :     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          21 :     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          21 :     const SystemChildWindow* pSysChild = dynamic_cast< const SystemChildWindow* >( this );
    9123          21 :     if( pSysChild )
    9124             :     {
    9125           0 :         aArg[ 1 ] = pSysChild->GetSystemDataAny();
    9126           0 :         aArg[ 5 ] = pSysChild->GetSystemGfxDataAny();
    9127             :     }
    9128             :     else
    9129             :     {
    9130          21 :         aArg[ 1 ] = GetSystemDataAny();
    9131          21 :         aArg[ 5 ] = GetSystemGfxDataAny();
    9132             :     }
    9133             : 
    9134          21 :     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          21 :         aArg[ 2 ] = makeAny( ::com::sun::star::awt::Rectangle( mnOutOffX, mnOutOffY, mnOutWidth, mnOutHeight ) );
    9140             : 
    9141          21 :     aArg[ 3 ] = makeAny( mpWindowImpl->mbAlwaysOnTop ? sal_True : sal_False );
    9142          42 :     aArg[ 4 ] = makeAny( uno::Reference< awt::XWindow >(
    9143          21 :                              const_cast<Window*>(this)->GetComponentInterface(),
    9144          21 :                              uno::UNO_QUERY ));
    9145             : 
    9146          42 :     uno::Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
    9147             : 
    9148             :     // Create canvas instance with window handle
    9149             : 
    9150             :     static ::vcl::DeleteUnoReferenceOnDeinit<lang::XMultiComponentFactory> xStaticCanvasFactory(
    9151          21 :         rendering::CanvasFactory::create( xContext ) );
    9152          42 :     uno::Reference<lang::XMultiComponentFactory> xCanvasFactory(xStaticCanvasFactory.get());
    9153             : 
    9154          21 :     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          21 :             xCanvas.set( xCanvasFactory->createInstanceWithArgumentsAndContext(
    9178             :                              bSpriteCanvas ?
    9179             :                              OUString( "com.sun.star.rendering.SpriteCanvas" ) :
    9180             :                              OUString( "com.sun.star.rendering.Canvas" ),
    9181             :                              aArg,
    9182          21 :                              xContext ),
    9183          21 :                          UNO_QUERY );
    9184             : 
    9185             : #ifdef WNT
    9186             :         }
    9187             : #endif
    9188          21 :         mpWindowImpl->mxCanvas = xCanvas;
    9189             :     }
    9190             : 
    9191             :     // no factory??? Empty reference, then.
    9192          21 :     return xCanvas;
    9193             : }
    9194             : 
    9195          21 : uno::Reference< rendering::XCanvas > Window::GetCanvas() const
    9196             : {
    9197          21 :     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        7635 : void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rPos )
    9208             : {
    9209        7635 :     bool bRVisible = mpWindowImpl->mbReallyVisible;
    9210        7635 :     mpWindowImpl->mbReallyVisible = mpWindowImpl->mbVisible;
    9211        7635 :     bool bDevOutput = mbDevOutput;
    9212        7635 :     mbDevOutput = true;
    9213             : 
    9214        7635 :     const OutputDevice *pOutDev = GetOutDev();
    9215        7635 :     long nOldDPIX = pOutDev->ImplGetDPIX();
    9216        7635 :     long nOldDPIY = pOutDev->ImplGetDPIY();
    9217        7635 :     mnDPIX = i_pTargetOutDev->ImplGetDPIX();
    9218        7635 :     mnDPIY = i_pTargetOutDev->ImplGetDPIY();
    9219        7635 :     bool bOutput = IsOutputEnabled();
    9220        7635 :     EnableOutput();
    9221             : 
    9222             :     DBG_ASSERT( GetMapMode().GetMapUnit() == MAP_PIXEL, "MapMode must be PIXEL based" );
    9223        7635 :     if ( GetMapMode().GetMapUnit() != MAP_PIXEL )
    9224        7635 :         return;
    9225             : 
    9226             :     // preserve graphicsstate
    9227        7635 :     Push();
    9228        7635 :     Region aClipRegion( GetClipRegion() );
    9229        7635 :     SetClipRegion();
    9230             : 
    9231        7635 :     GDIMetaFile* pOldMtf = GetConnectMetaFile();
    9232       15270 :     GDIMetaFile aMtf;
    9233        7635 :     SetConnectMetaFile( &aMtf );
    9234             : 
    9235             :     // put a push action to metafile
    9236        7635 :     Push();
    9237             :     // copy graphics state to metafile
    9238       15270 :     Font aCopyFont = GetFont();
    9239        7635 :     if( nOldDPIX != mnDPIX || nOldDPIY != mnDPIY )
    9240             :     {
    9241           0 :         aCopyFont.SetHeight( aCopyFont.GetHeight() * mnDPIY / nOldDPIY );
    9242           0 :         aCopyFont.SetWidth( aCopyFont.GetWidth() * mnDPIX / nOldDPIX );
    9243             :     }
    9244        7635 :     SetFont( aCopyFont );
    9245        7635 :     SetTextColor( GetTextColor() );
    9246        7635 :     if( IsLineColor() )
    9247        7410 :         SetLineColor( GetLineColor() );
    9248             :     else
    9249         225 :         SetLineColor();
    9250        7635 :     if( IsFillColor() )
    9251        7635 :         SetFillColor( GetFillColor() );
    9252             :     else
    9253           0 :         SetFillColor();
    9254        7635 :     if( IsTextLineColor() )
    9255           0 :         SetTextLineColor( GetTextLineColor() );
    9256             :     else
    9257        7635 :         SetTextLineColor();
    9258        7635 :     if( IsOverlineColor() )
    9259           0 :         SetOverlineColor( GetOverlineColor() );
    9260             :     else
    9261        7635 :         SetOverlineColor();
    9262        7635 :     if( IsTextFillColor() )
    9263          43 :         SetTextFillColor( GetTextFillColor() );
    9264             :     else
    9265        7592 :         SetTextFillColor();
    9266        7635 :     SetTextAlign( GetTextAlign() );
    9267        7635 :     SetRasterOp( GetRasterOp() );
    9268        7635 :     if( IsRefPoint() )
    9269           0 :         SetRefPoint( GetRefPoint() );
    9270             :     else
    9271        7635 :         SetRefPoint();
    9272        7635 :     SetLayoutMode( GetLayoutMode() );
    9273        7635 :     SetDigitLanguage( GetDigitLanguage() );
    9274        7635 :     Rectangle aPaintRect( Point( 0, 0 ), GetOutputSizePixel() );
    9275        7635 :     aClipRegion.Intersect( aPaintRect );
    9276        7635 :     SetClipRegion( aClipRegion );
    9277             : 
    9278             :     // do the actual paint
    9279             : 
    9280             :     // background
    9281        7635 :     if( ! IsPaintTransparent() && IsBackground() && ! (GetParentClipMode() & PARENTCLIPMODE_NOCLIP ) )
    9282        3427 :         Erase();
    9283             :     // foreground
    9284        7635 :     Paint( aPaintRect );
    9285             :     // put a pop action to metafile
    9286        7635 :     Pop();
    9287             : 
    9288        7635 :     SetConnectMetaFile( pOldMtf );
    9289        7635 :     EnableOutput( bOutput );
    9290        7635 :     mpWindowImpl->mbReallyVisible = bRVisible;
    9291             : 
    9292             :     // paint metafile to VDev
    9293        7635 :     VirtualDevice* pMaskedDevice = new VirtualDevice( *i_pTargetOutDev, 0, 0 );
    9294        7635 :     pMaskedDevice->SetOutputSizePixel( GetOutputSizePixel() );
    9295        7635 :     pMaskedDevice->EnableRTL( IsRTLEnabled() );
    9296        7635 :     aMtf.WindStart();
    9297        7635 :     aMtf.Play( pMaskedDevice );
    9298       15270 :     BitmapEx aBmpEx( pMaskedDevice->GetBitmapEx( Point( 0, 0 ), pMaskedDevice->GetOutputSizePixel() ) );
    9299        7635 :     i_pTargetOutDev->DrawBitmapEx( i_rPos, aBmpEx );
    9300             :     // get rid of virtual device now so they don't pile up during recursive calls
    9301        7635 :     delete pMaskedDevice, pMaskedDevice = NULL;
    9302             : 
    9303       13380 :     for( Window* pChild = mpWindowImpl->mpFirstChild; pChild; pChild = pChild->mpWindowImpl->mpNext )
    9304             :     {
    9305        5745 :         if( pChild->mpWindowImpl->mpFrame == mpWindowImpl->mpFrame && pChild->IsVisible() )
    9306             :         {
    9307        4906 :             long nDeltaX = pChild->mnOutOffX - mnOutOffX;
    9308             : 
    9309        4906 :             if( pOutDev->HasMirroredGraphics() )
    9310           0 :                 nDeltaX = mnOutWidth - nDeltaX - pChild->mnOutWidth;
    9311        4906 :             long nDeltaY = pChild->GetOutOffYPixel() - GetOutOffYPixel();
    9312        4906 :             Point aPos( i_rPos );
    9313        4906 :             Point aDelta( nDeltaX, nDeltaY );
    9314        4906 :             aPos += aDelta;
    9315        4906 :             pChild->ImplPaintToDevice( i_pTargetOutDev, aPos );
    9316             :         }
    9317             :     }
    9318             : 
    9319             :     // restore graphics state
    9320        7635 :     Pop();
    9321             : 
    9322        7635 :     EnableOutput( bOutput );
    9323        7635 :     mpWindowImpl->mbReallyVisible = bRVisible;
    9324        7635 :     mbDevOutput = bDevOutput;
    9325        7635 :     mnDPIX = nOldDPIX;
    9326       15270 :     mnDPIY = nOldDPIY;
    9327             : }
    9328             : 
    9329        2729 : 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        2729 :     Window* pRealParent = NULL;
    9337        2729 :     if( ! mpWindowImpl->mbVisible )
    9338             :     {
    9339        2729 :         Window* pTempParent = ImplGetDefaultWindow();
    9340        2729 :         if( pTempParent )
    9341        2729 :             pTempParent->EnableChildTransparentMode();
    9342        2729 :         pRealParent = GetParent();
    9343        2729 :         SetParent( pTempParent );
    9344             :         // trigger correct visibility flags for children
    9345        2729 :         Show();
    9346        2729 :         Hide();
    9347             :     }
    9348             : 
    9349        2729 :     bool bVisible = mpWindowImpl->mbVisible;
    9350        2729 :     mpWindowImpl->mbVisible = true;
    9351             : 
    9352        2729 :     if( mpWindowImpl->mpBorderWindow )
    9353        1918 :         mpWindowImpl->mpBorderWindow->ImplPaintToDevice( pDev, rPos );
    9354             :     else
    9355         811 :         ImplPaintToDevice( pDev, rPos );
    9356             : 
    9357        2729 :     mpWindowImpl->mbVisible = bVisible;
    9358             : 
    9359        2729 :     if( pRealParent )
    9360        2729 :         SetParent( pRealParent );
    9361        2729 : }
    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         516 : }
    9380             : 
    9381             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10