LCOV - code coverage report
Current view: top level - vcl/source/window - dialog.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 163 566 28.8 %
Date: 2014-11-03 Functions: 21 57 36.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <config_features.h>
      21             : 
      22             : #include <com/sun/star/beans/XPropertySet.hpp>
      23             : #include <com/sun/star/util/thePathSettings.hpp>
      24             : #include <comphelper/processfactory.hxx>
      25             : #include <osl/file.hxx>
      26             : 
      27             : #include <tools/debug.hxx>
      28             : 
      29             : #include <tools/rc.h>
      30             : #include <svdata.hxx>
      31             : #include <window.h>
      32             : #include <brdwin.hxx>
      33             : 
      34             : #include <rtl/strbuf.hxx>
      35             : #include <sal/log.hxx>
      36             : 
      37             : #include <vcl/builder.hxx>
      38             : #include <vcl/layout.hxx>
      39             : #include <vcl/svapp.hxx>
      40             : #include <vcl/event.hxx>
      41             : #include <vcl/wrkwin.hxx>
      42             : #include <vcl/button.hxx>
      43             : #include <vcl/mnemonic.hxx>
      44             : #include <vcl/dialog.hxx>
      45             : #include <vcl/decoview.hxx>
      46             : #include <vcl/msgbox.hxx>
      47             : #include <vcl/unowrap.hxx>
      48             : #include <vcl/settings.hxx>
      49             : 
      50             : #include <iostream>
      51             : 
      52             : #if !HAVE_FEATURE_DESKTOP
      53             : #include <touch/touch.h>
      54             : #endif
      55             : 
      56           0 : static OString ImplGetDialogText( Dialog* pDialog )
      57             : {
      58             :     OStringBuffer aErrorStr(OUStringToOString(
      59           0 :         pDialog->GetText(), RTL_TEXTENCODING_UTF8));
      60           0 :     if ( (pDialog->GetType() == WINDOW_MESSBOX) ||
      61           0 :          (pDialog->GetType() == WINDOW_INFOBOX) ||
      62           0 :          (pDialog->GetType() == WINDOW_WARNINGBOX) ||
      63           0 :          (pDialog->GetType() == WINDOW_ERRORBOX) ||
      64           0 :          (pDialog->GetType() == WINDOW_QUERYBOX) )
      65             :     {
      66           0 :         aErrorStr.append(", ");
      67             :         aErrorStr.append(OUStringToOString(
      68           0 :             static_cast<MessBox*>(pDialog)->GetMessText(), RTL_TEXTENCODING_UTF8));
      69             :     }
      70           0 :     return aErrorStr.makeStringAndClear();
      71             : }
      72             : 
      73         838 : static bool ImplIsMnemonicCtrl( vcl::Window* pWindow )
      74             : {
      75         838 :     if( ! pWindow->GetSettings().GetStyleSettings().GetAutoMnemonic() )
      76           0 :         return false;
      77             : 
      78        2514 :     if ( (pWindow->GetType() == WINDOW_RADIOBUTTON) ||
      79        1676 :          (pWindow->GetType() == WINDOW_CHECKBOX) ||
      80        2514 :          (pWindow->GetType() == WINDOW_TRISTATEBOX) ||
      81         838 :          (pWindow->GetType() == WINDOW_PUSHBUTTON) )
      82           0 :         return true;
      83             : 
      84         838 :     if ( pWindow->GetType() == WINDOW_FIXEDTEXT )
      85             :     {
      86           2 :         FixedText *pText = static_cast<FixedText*>(pWindow);
      87           2 :         if (pText->get_mnemonic_widget())
      88           0 :             return true;
      89             :         //This is the legacy pre-layout logic which we retain
      90             :         //until we can be sure we can remove it
      91           2 :         if ( pWindow->GetStyle() & (WB_INFO | WB_NOLABEL) )
      92           0 :             return false;
      93           2 :         vcl::Window* pNextWindow = pWindow->GetWindow( WINDOW_NEXT );
      94           2 :         if ( !pNextWindow )
      95           2 :             return false;
      96           0 :         pNextWindow = pNextWindow->GetWindow( WINDOW_CLIENT );
      97           0 :         if ( !(pNextWindow->GetStyle() & WB_TABSTOP) ||
      98           0 :              (pNextWindow->GetType() == WINDOW_FIXEDTEXT) ||
      99           0 :              (pNextWindow->GetType() == WINDOW_GROUPBOX) ||
     100           0 :              (pNextWindow->GetType() == WINDOW_RADIOBUTTON) ||
     101           0 :              (pNextWindow->GetType() == WINDOW_CHECKBOX) ||
     102           0 :              (pNextWindow->GetType() == WINDOW_TRISTATEBOX) ||
     103           0 :              (pNextWindow->GetType() == WINDOW_PUSHBUTTON) )
     104           0 :             return false;
     105             : 
     106           0 :         return true;
     107             :     }
     108             : 
     109         836 :     return false;
     110             : }
     111             : 
     112             : // Called by native error dialog popup implementations
     113           0 : void ImplHideSplash()
     114             : {
     115           0 :     ImplSVData* pSVData = ImplGetSVData();
     116           0 :     if( pSVData->mpIntroWindow )
     117           0 :             pSVData->mpIntroWindow->Hide();
     118           0 : }
     119             : 
     120             : //Get next window after pChild of a pTopLevel window as
     121             : //if any intermediate layout widgets didn't exist
     122      228109 : vcl::Window * nextLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChild)
     123             : {
     124      228109 :     vcl::Window *pLastChild = pChild;
     125             : 
     126      228109 :     if (isContainerWindow(*pChild))
     127        1972 :         pChild = pChild->GetWindow(WINDOW_FIRSTCHILD);
     128             :     else
     129      226137 :         pChild = pChild->GetWindow(WINDOW_NEXT);
     130             : 
     131      461634 :     while (!pChild)
     132             :     {
     133       61859 :         vcl::Window *pParent = pLastChild->GetParent();
     134       61859 :         if (!pParent)
     135         358 :             return NULL;
     136       61501 :         if (pParent == pTopLevel)
     137       56085 :             return NULL;
     138        5416 :         pLastChild = pParent;
     139        5416 :         pChild = pParent->GetWindow(WINDOW_NEXT);
     140             :     }
     141             : 
     142      171666 :     if (pChild && isContainerWindow(*pChild))
     143        1384 :         pChild = nextLogicalChildOfParent(pTopLevel, pChild);
     144             : 
     145      171666 :     return pChild;
     146             : }
     147             : 
     148           0 : vcl::Window * prevLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChild)
     149             : {
     150           0 :     vcl::Window *pLastChild = pChild;
     151             : 
     152           0 :     if (isContainerWindow(*pChild))
     153           0 :         pChild = pChild->GetWindow(WINDOW_LASTCHILD);
     154             :     else
     155           0 :         pChild = pChild->GetWindow(WINDOW_PREV);
     156             : 
     157           0 :     while (!pChild)
     158             :     {
     159           0 :         vcl::Window *pParent = pLastChild->GetParent();
     160           0 :         if (!pParent)
     161           0 :             return NULL;
     162           0 :         if (pParent == pTopLevel)
     163           0 :             return NULL;
     164           0 :         pLastChild = pParent;
     165           0 :         pChild = pParent->GetWindow(WINDOW_PREV);
     166             :     }
     167             : 
     168           0 :     if (pChild && isContainerWindow(*pChild))
     169           0 :         pChild = prevLogicalChildOfParent(pTopLevel, pChild);
     170             : 
     171           0 :     return pChild;
     172             : }
     173             : 
     174             : //Get first window of a pTopLevel window as
     175             : //if any intermediate layout widgets didn't exist
     176      186044 : vcl::Window * firstLogicalChildOfParent(vcl::Window *pTopLevel)
     177             : {
     178      186044 :     vcl::Window *pChild = pTopLevel->GetWindow(WINDOW_FIRSTCHILD);
     179      186044 :     if (pChild && isContainerWindow(*pChild))
     180         452 :         pChild = nextLogicalChildOfParent(pTopLevel, pChild);
     181      186044 :     return pChild;
     182             : }
     183             : 
     184          98 : void ImplWindowAutoMnemonic( vcl::Window* pWindow )
     185             : {
     186          98 :     MnemonicGenerator   aMnemonicGenerator;
     187             :     vcl::Window*                 pGetChild;
     188             :     vcl::Window*                 pChild;
     189             : 
     190             :     // register the assigned mnemonics
     191          98 :     pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
     192        1034 :     while ( pGetChild )
     193             :     {
     194         838 :         pChild = pGetChild->ImplGetWindow();
     195         838 :         aMnemonicGenerator.RegisterMnemonic( pChild->GetText() );
     196         838 :         pGetChild = nextLogicalChildOfParent(pWindow, pGetChild);
     197             :     }
     198             : 
     199             :     // take the Controls of the dialog into account for TabPages
     200          98 :     if ( pWindow->GetType() == WINDOW_TABPAGE )
     201             :     {
     202           0 :         vcl::Window* pParent = pWindow->GetParent();
     203           0 :         if ( pParent->GetType() == WINDOW_TABCONTROL )
     204           0 :             pParent = pParent->GetParent();
     205             : 
     206           0 :         if ( (pParent->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
     207             :         {
     208           0 :             pGetChild = pParent->GetWindow( WINDOW_FIRSTCHILD );
     209           0 :             while ( pGetChild )
     210             :             {
     211           0 :                 pChild = pGetChild->ImplGetWindow();
     212           0 :                 aMnemonicGenerator.RegisterMnemonic( pChild->GetText() );
     213           0 :                 pGetChild = nextLogicalChildOfParent(pWindow, pGetChild);
     214             :             }
     215             :         }
     216             :     }
     217             : 
     218             :     // assign mnemonics to Controls which have none
     219          98 :     pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
     220        1034 :     while ( pGetChild )
     221             :     {
     222         838 :         pChild = pGetChild->ImplGetWindow();
     223         838 :         if ( ImplIsMnemonicCtrl( pChild ) )
     224             :         {
     225           0 :             OUString aText = pChild->GetText();
     226           0 :             OUString aNewText = aMnemonicGenerator.CreateMnemonic( aText );
     227           0 :             if ( aText != aNewText )
     228           0 :                 pChild->SetText( aNewText );
     229             :         }
     230             : 
     231         838 :         pGetChild = nextLogicalChildOfParent(pWindow, pGetChild);
     232          98 :     }
     233          98 : }
     234             : 
     235           0 : static VclButtonBox* getActionArea(Dialog *pDialog)
     236             : {
     237           0 :     VclButtonBox *pButtonBox = NULL;
     238           0 :     if (pDialog->isLayoutEnabled())
     239             :     {
     240           0 :         vcl::Window *pBox = pDialog->GetWindow(WINDOW_FIRSTCHILD);
     241           0 :         vcl::Window *pChild = pBox->GetWindow(WINDOW_LASTCHILD);
     242           0 :         while (pChild)
     243             :         {
     244           0 :             pButtonBox = dynamic_cast<VclButtonBox*>(pChild);
     245           0 :             if (pButtonBox)
     246           0 :                 break;
     247           0 :             pChild = pChild->GetWindow(WINDOW_PREV);
     248             :         }
     249             :     }
     250           0 :     return pButtonBox;
     251             : }
     252             : 
     253           0 : static vcl::Window* getActionAreaButtonList(Dialog *pDialog)
     254             : {
     255           0 :     VclButtonBox* pButtonBox = getActionArea(pDialog);
     256           0 :     if (pButtonBox)
     257           0 :         return pButtonBox->GetWindow(WINDOW_FIRSTCHILD);
     258           0 :     return pDialog->GetWindow(WINDOW_FIRSTCHILD);
     259             : }
     260             : 
     261           0 : static PushButton* ImplGetDefaultButton( Dialog* pDialog )
     262             : {
     263           0 :     vcl::Window* pChild = getActionAreaButtonList(pDialog);
     264           0 :     while ( pChild )
     265             :     {
     266           0 :         if ( pChild->ImplIsPushButton() )
     267             :         {
     268           0 :             PushButton* pPushButton = static_cast<PushButton*>(pChild);
     269           0 :             if ( pPushButton->ImplIsDefButton() )
     270           0 :                 return pPushButton;
     271             :         }
     272             : 
     273           0 :         pChild = pChild->GetWindow( WINDOW_NEXT );
     274             :     }
     275             : 
     276           0 :     return NULL;
     277             : }
     278             : 
     279           0 : static PushButton* ImplGetOKButton( Dialog* pDialog )
     280             : {
     281           0 :     vcl::Window* pChild = getActionAreaButtonList(pDialog);
     282           0 :     while ( pChild )
     283             :     {
     284           0 :         if ( pChild->GetType() == WINDOW_OKBUTTON )
     285           0 :             return static_cast<PushButton*>(pChild);
     286             : 
     287           0 :         pChild = pChild->GetWindow( WINDOW_NEXT );
     288             :     }
     289             : 
     290           0 :     return NULL;
     291             : }
     292             : 
     293           0 : static PushButton* ImplGetCancelButton( Dialog* pDialog )
     294             : {
     295           0 :     vcl::Window* pChild = getActionAreaButtonList(pDialog);
     296             : 
     297           0 :     while ( pChild )
     298             :     {
     299           0 :         if ( pChild->GetType() == WINDOW_CANCELBUTTON )
     300           0 :             return static_cast<PushButton*>(pChild);
     301             : 
     302           0 :         pChild = pChild->GetWindow( WINDOW_NEXT );
     303             :     }
     304             : 
     305           0 :     return NULL;
     306             : }
     307             : 
     308           6 : static void ImplMouseAutoPos( Dialog* pDialog )
     309             : {
     310           6 :     sal_uLong nMouseOptions = pDialog->GetSettings().GetMouseSettings().GetOptions();
     311           6 :     if ( nMouseOptions & MOUSE_OPTION_AUTOCENTERPOS )
     312             :     {
     313           0 :         Size aSize = pDialog->GetOutputSizePixel();
     314           0 :         pDialog->SetPointerPosPixel( Point( aSize.Width()/2, aSize.Height()/2 ) );
     315             :     }
     316           6 :     else if ( nMouseOptions & MOUSE_OPTION_AUTODEFBTNPOS )
     317             :     {
     318           0 :         vcl::Window* pWindow = ImplGetDefaultButton( pDialog );
     319           0 :         if ( !pWindow )
     320           0 :             pWindow = ImplGetOKButton( pDialog );
     321           0 :         if ( !pWindow )
     322           0 :             pWindow = ImplGetCancelButton( pDialog );
     323           0 :         if ( !pWindow )
     324           0 :             pWindow = pDialog;
     325           0 :         Size aSize = pWindow->GetOutputSizePixel();
     326           0 :         pWindow->SetPointerPosPixel( Point( aSize.Width()/2, aSize.Height()/2 ) );
     327             :     }
     328           6 : }
     329             : 
     330             : struct DialogImpl
     331             : {
     332             :     long    mnResult;
     333             :     bool    mbStartedModal;
     334             :     Link    maEndDialogHdl;
     335             : 
     336          14 :     DialogImpl() : mnResult( -1 ), mbStartedModal( false ) {}
     337             : };
     338             : 
     339          14 : void Dialog::ImplInitDialogData()
     340             : {
     341          14 :     mpWindowImpl->mbDialog  = true;
     342          14 :     mpPrevExecuteDlg        = NULL;
     343          14 :     mbInExecute             = false;
     344          14 :     mbOldSaveBack           = false;
     345          14 :     mbInClose               = false;
     346          14 :     mbModalMode             = false;
     347          14 :     mpContentArea           = NULL;
     348          14 :     mpActionArea            = NULL;
     349          14 :     mnMousePositioned       = 0;
     350          14 :     mpDialogImpl            = new DialogImpl;
     351          14 : }
     352             : 
     353          14 : void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle )
     354             : {
     355          14 :     sal_uInt16 nSysWinMode = Application::GetSystemWindowMode();
     356             : 
     357          14 :     if ( !(nStyle & WB_NODIALOGCONTROL) )
     358          14 :         nStyle |= WB_DIALOGCONTROL;
     359          14 :     nStyle |= WB_ROLLABLE;
     360             : 
     361             :     // Now, all Dialogs are per default system windows !!!
     362          14 :     nStyle |= WB_SYSTEMWINDOW;
     363             : 
     364             :     // parent is NULL: get the default Dialog parent
     365          14 :     if ( !pParent )
     366             :     {
     367           4 :         pParent = Application::GetDefDialogParent();
     368           4 :         if ( !pParent && !(nStyle & WB_SYSTEMWINDOW) )
     369           0 :             pParent = ImplGetSVData()->maWinData.mpAppWin;
     370             : 
     371             :         // If Parent is disabled, then we search for a modal dialog
     372             :         // in this frame
     373           4 :         if ( pParent && (!pParent->IsInputEnabled() || pParent->IsInModalMode()) )
     374             :         {
     375           0 :             ImplSVData* pSVData = ImplGetSVData();
     376           0 :             Dialog*     pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
     377           0 :             while ( pExeDlg )
     378             :             {
     379             :                 // only if visible and enabled
     380           0 :                 if ( pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild( pExeDlg, true ) &&
     381           0 :                      pExeDlg->IsReallyVisible() &&
     382           0 :                      pExeDlg->IsEnabled() && pExeDlg->IsInputEnabled() && !pExeDlg->IsInModalMode() )
     383             :                 {
     384           0 :                     pParent = pExeDlg;
     385           0 :                     break;
     386             :                 }
     387             : 
     388           0 :                 pExeDlg = pExeDlg->mpPrevExecuteDlg;
     389             :             }
     390             :         }
     391             :     }
     392             :     // DIALOG_NO_PARENT: explicitly don't have a parent for this Dialog
     393          10 :     else if( pParent == DIALOG_NO_PARENT )
     394           6 :         pParent = NULL;
     395             : 
     396          14 :     if ( !pParent || (nStyle & WB_SYSTEMWINDOW) ||
     397           0 :          (pParent->mpWindowImpl->mpFrameData->mbNeedSysWindow && !(nSysWinMode & SYSTEMWINDOW_MODE_NOAUTOMODE)) ||
     398           0 :          (nSysWinMode & SYSTEMWINDOW_MODE_DIALOG) )
     399             :     {
     400             :         // create window with a small border ?
     401          14 :         if ( (nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER )
     402             :         {
     403           0 :             ImplBorderWindow* pBorderWin  = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_FRAME );
     404           0 :             SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
     405           0 :             pBorderWin->mpWindowImpl->mpClientWindow = this;
     406           0 :             pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
     407           0 :             mpWindowImpl->mpBorderWindow  = pBorderWin;
     408           0 :             mpWindowImpl->mpRealParent    = pParent;
     409             :         }
     410             :         else
     411             :         {
     412          14 :             mpWindowImpl->mbFrame         = true;
     413          14 :             mpWindowImpl->mbOverlapWin    = true;
     414          14 :             SystemWindow::ImplInit( pParent, (nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_CLOSEABLE | WB_STANDALONE)) | WB_CLOSEABLE, NULL );
     415             :             // Now set all style bits
     416          14 :             mpWindowImpl->mnStyle = nStyle;
     417          14 :         }
     418             :     }
     419             :     else
     420             :     {
     421           0 :         ImplBorderWindow* pBorderWin  = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_OVERLAP | BORDERWINDOW_STYLE_BORDER );
     422           0 :         SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
     423           0 :         pBorderWin->mpWindowImpl->mpClientWindow = this;
     424           0 :         pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
     425           0 :         mpWindowImpl->mpBorderWindow  = pBorderWin;
     426           0 :         mpWindowImpl->mpRealParent    = pParent;
     427             :     }
     428             : 
     429          14 :     SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
     430             : 
     431          14 :     ImplInitSettings();
     432          14 : }
     433             : 
     434          22 : void Dialog::ImplInitSettings()
     435             : {
     436             :     // user override
     437          22 :     if ( IsControlBackground() )
     438           8 :         SetBackground( GetControlBackground() );
     439             :     // NWF background
     440          14 :     else if( IsNativeControlSupported( CTRL_WINDOW_BACKGROUND, PART_BACKGROUND_DIALOG ) )
     441             :     {
     442           0 :         mpWindowImpl->mnNativeBackground = PART_BACKGROUND_DIALOG;
     443           0 :         EnableChildTransparentMode( true );
     444             :     }
     445             :     // fallback to settings color
     446             :     else
     447          14 :         SetBackground( GetSettings().GetStyleSettings().GetDialogColor() );
     448          22 : }
     449             : 
     450           0 : Dialog::Dialog( WindowType nType )
     451           0 :     : SystemWindow( nType )
     452             : {
     453           0 :     ImplInitDialogData();
     454           0 : }
     455             : 
     456        2254 : OUString VclBuilderContainer::getUIRootDir()
     457             : {
     458             :     /*to-do, check if user config has an override before using shared one, etc*/
     459             :     css::uno::Reference< css::util::XPathSettings > xPathSettings = css::util::thePathSettings::get(
     460        2254 :         ::comphelper::getProcessComponentContext() );
     461             : 
     462        2254 :     OUString sShareLayer = xPathSettings->getBasePathShareLayer();
     463             : 
     464             :     // "UIConfig" is a "multi path" ... use first part only here!
     465        2254 :     sal_Int32 nPos = sShareLayer.indexOf(';');
     466        2254 :     if (nPos > 0)
     467           0 :         sShareLayer = sShareLayer.copy(0, nPos);
     468             : 
     469             :     // Note: May be an user uses URLs without a final slash! Check it ...
     470        2254 :     if (!sShareLayer.endsWith("/"))
     471        2254 :         sShareLayer += "/";
     472             : 
     473        2254 :     sShareLayer += "soffice.cfg/";
     474             :     /*to-do, can we merge all this foo with existing soffice.cfg finding code, etc*/
     475        2254 :     return sShareLayer;
     476             : }
     477             : 
     478             : //we can't change sizeable after the fact, so need to defer until we know and then
     479             : //do the init. Find the real parent stashed in mpDialogParent.
     480           0 : void Dialog::doDeferredInit(WinBits nBits)
     481             : {
     482           0 :     vcl::Window *pParent = mpDialogParent;
     483           0 :     mpDialogParent = NULL;
     484           0 :     ImplInit(pParent, nBits);
     485           0 :     mbIsDefferedInit = false;
     486           0 : }
     487             : 
     488           0 : Dialog::Dialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
     489           0 :     : SystemWindow(WINDOW_DIALOG)
     490             : {
     491           0 :     ImplInitDialogData();
     492           0 :     loadUI(pParent, rID, rUIXMLDescription);
     493           0 : }
     494             : 
     495           0 : Dialog::Dialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, WindowType nType)
     496           0 :     : SystemWindow(nType)
     497             : {
     498           0 :     ImplInitDialogData();
     499           0 :     loadUI(pParent, rID, rUIXMLDescription);
     500           0 : }
     501             : 
     502          14 : Dialog::Dialog(vcl::Window* pParent, WinBits nStyle)
     503          14 :     : SystemWindow(WINDOW_DIALOG)
     504             : {
     505          14 :     ImplInitDialogData();
     506          14 :     ImplInit( pParent, nStyle );
     507          14 : }
     508             : 
     509           0 : void Dialog::set_action_area(VclButtonBox* pActionArea)
     510             : {
     511           0 :     mpActionArea = pActionArea;
     512           0 : }
     513             : 
     514           0 : void Dialog::set_content_area(VclBox* pContentArea)
     515             : {
     516           0 :     mpContentArea = pContentArea;
     517           0 : }
     518             : 
     519           0 : void Dialog::settingOptimalLayoutSize(VclBox *pBox)
     520             : {
     521             :     const DialogStyle& rDialogStyle =
     522           0 :         GetSettings().GetStyleSettings().GetDialogStyle();
     523           0 :     pBox->set_border_width(rDialogStyle.content_area_border);
     524           0 :     pBox->set_spacing(pBox->get_spacing() +
     525           0 :         rDialogStyle.content_area_spacing);
     526             : 
     527           0 :     VclButtonBox *pActionArea = getActionArea(this);
     528           0 :     if (pActionArea)
     529             :     {
     530           0 :         pActionArea->set_border_width(rDialogStyle.action_area_border);
     531           0 :         pActionArea->set_spacing(rDialogStyle.button_spacing);
     532             :     }
     533           0 : }
     534             : 
     535          28 : Dialog::~Dialog()
     536             : {
     537          14 :     delete mpDialogImpl;
     538          14 :     mpDialogImpl = NULL;
     539          14 : }
     540             : 
     541           0 : IMPL_LINK_NOARG(Dialog, ImplAsyncCloseHdl)
     542             : {
     543           0 :     Close();
     544           0 :     return 0;
     545             : }
     546             : 
     547         154 : bool Dialog::Notify( NotifyEvent& rNEvt )
     548             : {
     549             :     // first call the base class due to Tab control
     550         154 :     bool nRet = SystemWindow::Notify( rNEvt );
     551         154 :     if ( !nRet )
     552             :     {
     553         154 :         if ( rNEvt.GetType() == EVENT_KEYINPUT )
     554             :         {
     555           0 :             const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
     556           0 :             vcl::KeyCode    aKeyCode = pKEvt->GetKeyCode();
     557           0 :             sal_uInt16      nKeyCode = aKeyCode.GetCode();
     558             : 
     559           0 :             if ( (nKeyCode == KEY_ESCAPE) &&
     560           0 :                  ((GetStyle() & WB_CLOSEABLE) || ImplGetCancelButton( this ) || ImplGetOKButton( this )) )
     561             :             {
     562             :                 // #i89505# for the benefit of slightly mentally challenged implementations
     563             :                 // like e.g. SfxModelessDialog which destroy themselves inside Close()
     564             :                 // post this Close asynchronous so we can leave our key handler before
     565             :                 // we get destroyed
     566           0 :                 PostUserEvent( LINK( this, Dialog, ImplAsyncCloseHdl ), this );
     567           0 :                 return true;
     568             :             }
     569             :         }
     570         154 :         else if ( rNEvt.GetType() == EVENT_GETFOCUS )
     571             :         {
     572             :             // make sure the dialog is still modal
     573             :             // changing focus between application frames may
     574             :             // have re-enabled input for our parent
     575           6 :             if( mbInExecute && mbModalMode )
     576             :             {
     577             :                 // do not change modal counter (pSVData->maAppData.mnModalDialog)
     578           0 :                 SetModalInputMode( false );
     579           0 :                 SetModalInputMode( true );
     580             : 
     581             :                 // #93022# def-button might have changed after show
     582           0 :                 if( !mnMousePositioned )
     583             :                 {
     584           0 :                     mnMousePositioned = 1;
     585           0 :                     ImplMouseAutoPos( this );
     586             :                 }
     587             : 
     588             :             }
     589             :         }
     590             :     }
     591             : 
     592         154 :     return nRet;
     593             : }
     594             : 
     595             : //What we really want here is something that gives the available width and
     596             : //height of a users screen, taking away the space taken up the OS
     597             : //taskbar, menus, etc.
     598          68 : Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize)
     599             : {
     600          68 :     long w = rScreenSize.Width();
     601          68 :     if (w <= 800)
     602           0 :         w -= 15;
     603          68 :     else if (w <= 1024)
     604          68 :         w -= 65;
     605             :     else
     606           0 :         w -= 115;
     607             : 
     608          68 :     long h = rScreenSize.Height();
     609          68 :     if (h <= 768)
     610          68 :         h -= 50;
     611             :     else
     612           0 :         h -= 100;
     613             : 
     614          68 :     return Size(w, h);
     615             : }
     616             : 
     617          26 : void Dialog::StateChanged( StateChangedType nType )
     618             : {
     619          26 :     if (nType == StateChangedType::INITSHOW)
     620             :     {
     621           6 :         DoInitialLayout();
     622             : 
     623           6 :         if ( !HasChildPathFocus() || HasFocus() )
     624           6 :             GrabFocusToFirstControl();
     625           6 :         if ( !(GetStyle() & WB_CLOSEABLE) )
     626             :         {
     627           0 :             if ( ImplGetCancelButton( this ) || ImplGetOKButton( this ) )
     628             :             {
     629           0 :                 if ( ImplGetBorderWindow() )
     630           0 :                     static_cast<ImplBorderWindow*>(ImplGetBorderWindow())->SetCloseButton();
     631             :             }
     632             :         }
     633             : 
     634           6 :         ImplMouseAutoPos( this );
     635             :     }
     636             : 
     637          26 :     SystemWindow::StateChanged( nType );
     638             : 
     639          26 :     if (nType == StateChangedType::CONTROLBACKGROUND)
     640             :     {
     641           8 :         ImplInitSettings();
     642           8 :         Invalidate();
     643             :     }
     644          26 : }
     645             : 
     646           0 : void Dialog::DataChanged( const DataChangedEvent& rDCEvt )
     647             : {
     648           0 :     SystemWindow::DataChanged( rDCEvt );
     649             : 
     650           0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
     651           0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     652             :     {
     653           0 :         ImplInitSettings();
     654           0 :         Invalidate();
     655             :     }
     656           0 : }
     657             : 
     658           0 : bool Dialog::Close()
     659             : {
     660           0 :     ImplDelData aDelData;
     661           0 :     ImplAddDel( &aDelData );
     662           0 :     ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
     663           0 :     if ( aDelData.IsDead() )
     664           0 :         return false;
     665           0 :     ImplRemoveDel( &aDelData );
     666             : 
     667           0 :     if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() && !IsInExecute() )
     668           0 :         return false;
     669             : 
     670           0 :     mbInClose = true;
     671             : 
     672           0 :     if ( !(GetStyle() & WB_CLOSEABLE) )
     673             :     {
     674           0 :         bool bRet = true;
     675           0 :         ImplAddDel( &aDelData );
     676           0 :         PushButton* pButton = ImplGetCancelButton( this );
     677           0 :         if ( pButton )
     678           0 :             pButton->Click();
     679             :         else
     680             :         {
     681           0 :             pButton = ImplGetOKButton( this );
     682           0 :             if ( pButton )
     683           0 :                 pButton->Click();
     684             :             else
     685           0 :                 bRet = false;
     686             :         }
     687           0 :         if ( aDelData.IsDead() )
     688           0 :             return true;
     689           0 :         ImplRemoveDel( &aDelData );
     690           0 :         return bRet;
     691             :     }
     692             : 
     693           0 :     if ( IsInExecute() )
     694             :     {
     695           0 :         EndDialog( RET_CANCEL );
     696           0 :         mbInClose = false;
     697           0 :         return true;
     698             :     }
     699             :     else
     700             :     {
     701           0 :         mbInClose = false;
     702           0 :         return SystemWindow::Close();
     703           0 :     }
     704             : }
     705             : 
     706           0 : bool Dialog::ImplStartExecuteModal()
     707             : {
     708           0 :     if ( mbInExecute )
     709             :     {
     710             : #ifdef DBG_UTIL
     711             :         OStringBuffer aErrorStr;
     712             :         aErrorStr.append("Dialog::StartExecuteModal() is called in Dialog::StartExecuteModal(): ");
     713             :         aErrorStr.append(ImplGetDialogText(this));
     714             :         OSL_FAIL(aErrorStr.getStr());
     715             : #endif
     716           0 :         return false;
     717             :     }
     718             : 
     719           0 :     switch ( Application::GetDialogCancelMode() )
     720             :     {
     721             :     case Application::DIALOG_CANCEL_OFF:
     722           0 :         break;
     723             :     case Application::DIALOG_CANCEL_SILENT:
     724             :         SAL_INFO(
     725             :             "vcl",
     726             :             "Dialog \"" << ImplGetDialogText(this).getStr()
     727             :                 << "\"cancelled in silent mode");
     728           0 :         return false;
     729             :     default:
     730             :         assert(false && "this cannot happen");
     731             :         // fall through
     732             :     case Application::DIALOG_CANCEL_FATAL:
     733           0 :         std::abort();
     734             :     }
     735             : 
     736             : #ifdef DBG_UTIL
     737             :     vcl::Window* pParent = GetParent();
     738             :     if ( pParent )
     739             :     {
     740             :         pParent = pParent->ImplGetFirstOverlapWindow();
     741             :         DBG_ASSERT( pParent->IsReallyVisible(),
     742             :                     "Dialog::StartExecuteModal() - Parent not visible" );
     743             :         DBG_ASSERT( pParent->IsInputEnabled(),
     744             :                     "Dialog::StartExecuteModal() - Parent input disabled, use another parent to ensure modality!" );
     745             :         DBG_ASSERT( ! pParent->IsInModalMode(),
     746             :                     "Dialog::StartExecuteModal() - Parent already modally disabled, use another parent to ensure modality!" );
     747             : 
     748             :     }
     749             : #endif
     750             : 
     751           0 :     ImplSVData* pSVData = ImplGetSVData();
     752             : 
     753             :      // link all dialogs which are being executed
     754           0 :     mpPrevExecuteDlg = pSVData->maWinData.mpLastExecuteDlg;
     755           0 :     pSVData->maWinData.mpLastExecuteDlg = this;
     756             : 
     757             :     // stop capturing, in order to have control over the dialog
     758           0 :     if ( pSVData->maWinData.mpTrackWin )
     759           0 :         pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
     760           0 :     if ( pSVData->maWinData.mpCaptureWin )
     761           0 :         pSVData->maWinData.mpCaptureWin->ReleaseMouse();
     762           0 :     EnableInput( true, true );
     763             : 
     764           0 :     if ( GetParent() )
     765             :     {
     766           0 :         NotifyEvent aNEvt( EVENT_EXECUTEDIALOG, this );
     767           0 :         GetParent()->Notify( aNEvt );
     768             :     }
     769           0 :     mbInExecute = true;
     770           0 :     SetModalInputMode( true );
     771           0 :     mbOldSaveBack = IsSaveBackgroundEnabled();
     772           0 :     EnableSaveBackground();
     773             : 
     774             :     // FIXME: no layouting, workaround some clipping issues
     775           0 :     ImplAdjustNWFSizes();
     776             : 
     777           0 :     Show();
     778             : 
     779           0 :     pSVData->maAppData.mnModalMode++;
     780           0 :     return true;
     781             : }
     782             : 
     783           0 : void Dialog::ImplEndExecuteModal()
     784             : {
     785           0 :     ImplSVData* pSVData = ImplGetSVData();
     786           0 :     pSVData->maAppData.mnModalMode--;
     787           0 : }
     788             : 
     789           0 : short Dialog::Execute()
     790             : {
     791             : #if HAVE_FEATURE_DESKTOP
     792             : 
     793           0 :     setDeferredProperties();
     794             : 
     795           0 :     if ( !ImplStartExecuteModal() )
     796           0 :         return 0;
     797             : 
     798           0 :     ImplDelData aDelData;
     799           0 :     ImplAddDel( &aDelData );
     800             : 
     801             : #ifdef DBG_UTIL
     802             :     ImplDelData aParentDelData;
     803             :     vcl::Window* pDialogParent = mpDialogParent;
     804             :     if( pDialogParent )
     805             :         pDialogParent->ImplAddDel( &aParentDelData );
     806             : #endif
     807             : 
     808             :     // Yield util EndDialog is called or dialog gets destroyed
     809             :     // (the latter should not happen, but better safe than sorry
     810           0 :     while ( !aDelData.IsDead() && mbInExecute )
     811           0 :         Application::Yield();
     812             : 
     813           0 :     ImplEndExecuteModal();
     814             : 
     815             : #ifdef DBG_UTIL
     816             :     if( pDialogParent  )
     817             :     {
     818             :         if( ! aParentDelData.IsDead() )
     819             :             pDialogParent->ImplRemoveDel( &aParentDelData );
     820             :         else
     821             :             OSL_FAIL( "Dialog::Execute() - Parent of dialog destroyed in Execute()" );
     822             :     }
     823             : #endif
     824           0 :     if ( !aDelData.IsDead() )
     825           0 :         ImplRemoveDel( &aDelData );
     826             : #ifdef DBG_UTIL
     827             :     else
     828             :     {
     829             :         OSL_FAIL( "Dialog::Execute() - Dialog destroyed in Execute()" );
     830             :     }
     831             : #endif
     832             : 
     833           0 :     long nRet = mpDialogImpl->mnResult;
     834           0 :     mpDialogImpl->mnResult = -1;
     835           0 :     return (short)nRet;
     836             : 
     837             : #else
     838             : 
     839             :     MLODialogKind kind;
     840             : 
     841             :     switch (GetType())
     842             :     {
     843             :     case WINDOW_MESSBOX:
     844             :         kind = MLODialogMessage;
     845             :         break;
     846             :     case WINDOW_INFOBOX:
     847             :         kind = MLODialogInformation;
     848             :         break;
     849             :     case WINDOW_WARNINGBOX:
     850             :         kind = MLODialogWarning;
     851             :         break;
     852             :     case WINDOW_ERRORBOX:
     853             :         kind = MLODialogError;
     854             :         break;
     855             :     case WINDOW_QUERYBOX:
     856             :         kind = MLODialogQuery;
     857             :         break;
     858             :     default:
     859             :         SAL_WARN("vcl", "Dialog::Execute: Unhandled window type %d" << GetType());
     860             :         kind = MLODialogInformation;
     861             :         break;
     862             :     }
     863             : 
     864             :     MLODialogResult result = touch_ui_dialog_modal(kind, ImplGetDialogText(this).getStr());
     865             : 
     866             :     switch (result)
     867             :     {
     868             :     case MLODialogOK:
     869             :         return RET_OK;
     870             :     case MLODialogCancel:
     871             :         return RET_CANCEL;
     872             :     case MLODialogNo:
     873             :         return RET_NO;
     874             :     case MLODialogYes:
     875             :         return RET_YES;
     876             :     case MLODialogRetry:
     877             :         return RET_RETRY;
     878             :     case MLODialogIgnore:
     879             :         return RET_IGNORE;
     880             :     default:
     881             :         SAL_WARN("vcl", "Dialog::Execute: Unhandled dialog result %d" << result);
     882             :         return RET_OK;
     883             :     }
     884             : 
     885             : #endif
     886             : }
     887             : 
     888             : // virtual
     889           0 : void Dialog::StartExecuteModal( const Link& rEndDialogHdl )
     890             : {
     891           0 :     if ( !ImplStartExecuteModal() )
     892           0 :         return;
     893             : 
     894           0 :     mpDialogImpl->maEndDialogHdl = rEndDialogHdl;
     895           0 :     mpDialogImpl->mbStartedModal = true;
     896             : }
     897             : 
     898           0 : void Dialog::EndDialog( long nResult )
     899             : {
     900           0 :     if ( mbInExecute )
     901             :     {
     902           0 :         SetModalInputMode( false );
     903             : 
     904             :         // remove dialog from the list of dialogs which are being executed
     905           0 :         ImplSVData* pSVData = ImplGetSVData();
     906           0 :         Dialog* pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
     907           0 :         while ( pExeDlg )
     908             :         {
     909           0 :             if ( pExeDlg == this )
     910             :             {
     911           0 :                 pSVData->maWinData.mpLastExecuteDlg = mpPrevExecuteDlg;
     912           0 :                 break;
     913             :             }
     914           0 :             pExeDlg = pExeDlg->mpPrevExecuteDlg;
     915             :         }
     916             :         // set focus to previous modal dialogue if it is modal for
     917             :         // the same frame parent (or NULL)
     918           0 :         if( mpPrevExecuteDlg )
     919             :         {
     920           0 :             vcl::Window* pFrameParent = ImplGetFrameWindow()->ImplGetParent();
     921           0 :             vcl::Window* pPrevFrameParent = mpPrevExecuteDlg->ImplGetFrameWindow()->ImplGetParent();
     922           0 :             if( ( !pFrameParent && !pPrevFrameParent ) ||
     923           0 :                 ( pFrameParent && pPrevFrameParent && pFrameParent->ImplGetFrame() == pPrevFrameParent->ImplGetFrame() )
     924             :                 )
     925             :             {
     926           0 :                 mpPrevExecuteDlg->GrabFocus();
     927             :             }
     928             :         }
     929           0 :         mpPrevExecuteDlg = NULL;
     930             : 
     931           0 :         Hide();
     932           0 :         EnableSaveBackground( mbOldSaveBack );
     933           0 :         if ( GetParent() )
     934             :         {
     935           0 :             NotifyEvent aNEvt( EVENT_ENDEXECUTEDIALOG, this );
     936           0 :             GetParent()->Notify( aNEvt );
     937             :         }
     938             : 
     939           0 :         mpDialogImpl->mnResult = nResult;
     940             : 
     941           0 :         if ( mpDialogImpl->mbStartedModal )
     942             :         {
     943           0 :             ImplEndExecuteModal();
     944           0 :             mpDialogImpl->maEndDialogHdl.Call( this );
     945             : 
     946           0 :             mpDialogImpl->maEndDialogHdl = Link();
     947           0 :             mpDialogImpl->mbStartedModal = false;
     948           0 :             mpDialogImpl->mnResult = -1;
     949             :         }
     950           0 :         mbInExecute = false;
     951             :     }
     952           0 : }
     953             : 
     954           0 : long Dialog::GetResult() const
     955             : {
     956           0 :     return mpDialogImpl->mnResult;
     957             : }
     958             : 
     959           0 : void Dialog::EndAllDialogs( vcl::Window* pParent )
     960             : {
     961           0 :    ImplSVData*  pSVData = ImplGetSVData();
     962             :    Dialog*      pTempModDialog;
     963           0 :    Dialog*      pModDialog = pSVData->maWinData.mpLastExecuteDlg;
     964           0 :    while ( pModDialog )
     965             :    {
     966           0 :      pTempModDialog = pModDialog->mpPrevExecuteDlg;
     967           0 :      if( !pParent || ( pParent && pParent->IsWindowOrChild( pModDialog, true ) ) )
     968             :      {
     969           0 :         pModDialog->EndDialog( RET_CANCEL );
     970           0 :         pModDialog->PostUserEvent( Link() );
     971             :      }
     972           0 :      pModDialog = pTempModDialog;
     973             :    }
     974           0 : }
     975             : 
     976           0 : void Dialog::SetModalInputMode( bool bModal )
     977             : {
     978           0 :     if ( bModal == mbModalMode )
     979           0 :         return;
     980             : 
     981           0 :     ImplSVData* pSVData = ImplGetSVData();
     982           0 :     mbModalMode = bModal;
     983           0 :     if ( bModal )
     984             :     {
     985           0 :         pSVData->maAppData.mnModalDialog++;
     986             : 
     987             :         // Diable the prev Modal Dialog, because our dialog must close at first,
     988             :         // before the other dialog can be closed (because the other dialog
     989             :         // is on stack since our dialog returns)
     990           0 :         if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, true ) )
     991           0 :             mpPrevExecuteDlg->EnableInput( false, true, true, this );
     992             : 
     993             :         // determine next overlap dialog parent
     994           0 :         vcl::Window* pParent = GetParent();
     995           0 :         if ( pParent )
     996             :         {
     997             :             // #103716# dialogs should always be modal to the whole frame window
     998             :             // #115933# disable the whole frame hierarchy, useful if our parent
     999             :             // is a modeless dialog
    1000           0 :             mpDialogParent = pParent->mpWindowImpl->mpFrameWindow;
    1001           0 :             mpDialogParent->ImplIncModalCount();
    1002             :         }
    1003             : 
    1004             :     }
    1005             :     else
    1006             :     {
    1007           0 :         pSVData->maAppData.mnModalDialog--;
    1008             : 
    1009           0 :         if ( mpDialogParent )
    1010             :         {
    1011             :             // #115933# re-enable the whole frame hierarchy again (see above)
    1012             :             // note that code in getfocus assures that we do not accidentally enable
    1013             :             // windows that were disabled before
    1014           0 :             mpDialogParent->ImplDecModalCount();
    1015             :         }
    1016             : 
    1017             :         // Enable the prev Modal Dialog
    1018           0 :         if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, true ) )
    1019             :         {
    1020           0 :             mpPrevExecuteDlg->EnableInput( true, true, true, this );
    1021             :             // ensure continued modality of prev dialog
    1022             :             // do not change modality counter
    1023             : 
    1024             :             // #i119994# need find the last modal dialog before reactive it
    1025           0 :             Dialog * pPrevModalDlg = mpPrevExecuteDlg;
    1026             : 
    1027           0 :             while( pPrevModalDlg && !pPrevModalDlg->IsModalInputMode() )
    1028           0 :                 pPrevModalDlg = pPrevModalDlg->mpPrevExecuteDlg;
    1029             : 
    1030           0 :             if( pPrevModalDlg &&
    1031           0 :             ( pPrevModalDlg == mpPrevExecuteDlg
    1032           0 :                 || !pPrevModalDlg->IsWindowOrChild( this, true ) ) )
    1033             :             {
    1034           0 :                 mpPrevExecuteDlg->SetModalInputMode( false );
    1035           0 :                 mpPrevExecuteDlg->SetModalInputMode( true );
    1036             :             }
    1037             :         }
    1038             :     }
    1039             : }
    1040             : 
    1041           0 : void Dialog::SetModalInputMode( bool bModal, bool bSubModalDialogs )
    1042             : {
    1043           0 :     if ( bSubModalDialogs )
    1044             :     {
    1045           0 :         vcl::Window* pOverlap = ImplGetFirstOverlapWindow();
    1046           0 :         pOverlap = pOverlap->mpWindowImpl->mpFirstOverlap;
    1047           0 :         while ( pOverlap )
    1048             :         {
    1049           0 :             if ( pOverlap->IsDialog() )
    1050           0 :                 static_cast<Dialog*>(pOverlap)->SetModalInputMode( bModal, true );
    1051           0 :             pOverlap = pOverlap->mpWindowImpl->mpNext;
    1052             :         }
    1053             :     }
    1054             : 
    1055           0 :     SetModalInputMode( bModal );
    1056           0 : }
    1057             : 
    1058           6 : void Dialog::GrabFocusToFirstControl()
    1059             : {
    1060             :     vcl::Window* pFocusControl;
    1061             : 
    1062             :     // find focus control, even if the dialog has focus
    1063           6 :     if ( HasFocus() )
    1064           0 :         pFocusControl = NULL;
    1065             :     else
    1066             :     {
    1067             :         // prefer a child window which had focus before
    1068           6 :         pFocusControl = ImplGetFirstOverlapWindow()->mpWindowImpl->mpLastFocusWindow;
    1069             :         // find the control out of the dialog control
    1070           6 :         if ( pFocusControl )
    1071           0 :             pFocusControl = ImplFindDlgCtrlWindow( pFocusControl );
    1072             :     }
    1073             :     // no control had the focus before or the control is not
    1074             :     // part of the tab-control, now give focus to the
    1075             :     // first control in the tab-control
    1076           6 :     if ( !pFocusControl ||
    1077           0 :          !(pFocusControl->GetStyle() & WB_TABSTOP) ||
    1078           0 :          !isVisibleInLayout(pFocusControl) ||
    1079           6 :          !isEnabledInLayout(pFocusControl) || !pFocusControl->IsInputEnabled() )
    1080             :     {
    1081           6 :         sal_uInt16 n = 0;
    1082           6 :         pFocusControl = ImplGetDlgWindow( n, DLGWINDOW_FIRST );
    1083             :     }
    1084           6 :     if ( pFocusControl )
    1085           0 :         pFocusControl->ImplControlFocus( GETFOCUS_INIT );
    1086           6 : }
    1087             : 
    1088           0 : void Dialog::GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
    1089             : {
    1090           0 :     ImplBorderWindow aImplWin( (vcl::Window*)this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
    1091           0 :     aImplWin.GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
    1092           0 : }
    1093             : 
    1094           0 : void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong )
    1095             : {
    1096           0 :     Point aPos = pDev->LogicToPixel( rPos );
    1097           0 :     Size aSize = pDev->LogicToPixel( rSize );
    1098             : 
    1099           0 :     Wallpaper aWallpaper = GetBackground();
    1100           0 :     if ( !aWallpaper.IsBitmap() )
    1101           0 :         ImplInitSettings();
    1102             : 
    1103           0 :     pDev->Push();
    1104           0 :     pDev->SetMapMode();
    1105           0 :     pDev->SetLineColor();
    1106             : 
    1107           0 :     if ( aWallpaper.IsBitmap() )
    1108           0 :         pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
    1109             :     else
    1110             :     {
    1111           0 :         pDev->SetFillColor( aWallpaper.GetColor() );
    1112           0 :         pDev->DrawRect( Rectangle( aPos, aSize ) );
    1113             :     }
    1114             : 
    1115           0 :     if (!( GetStyle() & WB_NOBORDER ))
    1116             :     {
    1117           0 :         ImplBorderWindow aImplWin( this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
    1118           0 :         aImplWin.SetText( GetText() );
    1119           0 :         aImplWin.setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
    1120           0 :         aImplWin.SetDisplayActive( true );
    1121           0 :         aImplWin.InitView();
    1122             : 
    1123           0 :         aImplWin.Draw( Rectangle( aPos, aSize ), pDev, aPos );
    1124             :     }
    1125             : 
    1126           0 :     pDev->Pop();
    1127           0 : }
    1128             : 
    1129         238 : void Dialog::queue_resize(StateChangedType eReason)
    1130             : {
    1131         238 :     if (IsInClose())
    1132         238 :         return;
    1133         238 :     SystemWindow::queue_resize(eReason);
    1134             : }
    1135             : 
    1136           0 : bool Dialog::set_property(const OString &rKey, const OString &rValue)
    1137             : {
    1138           0 :     if (rKey == "border-width")
    1139           0 :         set_border_width(rValue.toInt32());
    1140             :     else
    1141           0 :         return SystemWindow::set_property(rKey, rValue);
    1142           0 :     return true;
    1143             : }
    1144             : 
    1145       14700 : VclBuilderContainer::VclBuilderContainer()
    1146       14700 :     : m_pUIBuilder(NULL)
    1147             : {
    1148       14700 : }
    1149             : 
    1150       14682 : VclBuilderContainer::~VclBuilderContainer()
    1151             : {
    1152       14682 :     delete m_pUIBuilder;
    1153       14682 : }
    1154             : 
    1155           0 : ModelessDialog::ModelessDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
    1156           0 :     : Dialog(pParent, rID, rUIXMLDescription, WINDOW_MODELESSDIALOG)
    1157             : {
    1158           0 : }
    1159             : 
    1160           0 : ModalDialog::ModalDialog( vcl::Window* pParent, WinBits nStyle ) :
    1161           0 :     Dialog( WINDOW_MODALDIALOG )
    1162             : {
    1163           0 :     ImplInit( pParent, nStyle );
    1164           0 : }
    1165             : 
    1166           0 : ModalDialog::ModalDialog( vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription ) :
    1167           0 :     Dialog(pParent, rID, rUIXMLDescription, WINDOW_MODALDIALOG)
    1168             : {
    1169        1233 : }
    1170             : 
    1171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10