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

Generated by: LCOV version 1.10