LCOV - code coverage report
Current view: top level - vcl/source/window - dialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 108 444 24.3 %
Date: 2012-08-25 Functions: 13 37 35.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 67 585 11.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <tools/debug.hxx>
      30                 :            : 
      31                 :            : #include <tools/rc.h>
      32                 :            : #include <svdata.hxx>
      33                 :            : #include <window.h>
      34                 :            : #include <brdwin.hxx>
      35                 :            : 
      36                 :            : #include <rtl/strbuf.hxx>
      37                 :            : #include <sal/log.hxx>
      38                 :            : 
      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                 :            : 
      49                 :            : #ifdef ANDROID
      50                 :            : #include <osl/detail/android-bootstrap.h>
      51                 :            : #endif
      52                 :            : 
      53                 :            : // =======================================================================
      54                 :            : 
      55                 :          0 : static rtl::OString ImplGetDialogText( Dialog* pDialog )
      56                 :            : {
      57                 :            :     rtl::OStringBuffer aErrorStr(rtl::OUStringToOString(
      58 [ #  # ][ #  # ]:          0 :         pDialog->GetText(), RTL_TEXTENCODING_UTF8));
         [ #  # ][ #  # ]
                 [ #  # ]
      59 [ #  # ][ #  # ]:          0 :     if ( (pDialog->GetType() == WINDOW_MESSBOX) ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      60         [ #  # ]:          0 :          (pDialog->GetType() == WINDOW_INFOBOX) ||
      61         [ #  # ]:          0 :          (pDialog->GetType() == WINDOW_WARNINGBOX) ||
      62         [ #  # ]:          0 :          (pDialog->GetType() == WINDOW_ERRORBOX) ||
      63         [ #  # ]:          0 :          (pDialog->GetType() == WINDOW_QUERYBOX) )
      64                 :            :     {
      65         [ #  # ]:          0 :         aErrorStr.append(", ");
      66                 :            :         aErrorStr.append(rtl::OUStringToOString(
      67 [ #  # ][ #  # ]:          0 :             ((MessBox*)pDialog)->GetMessText(), RTL_TEXTENCODING_UTF8));
                 [ #  # ]
      68                 :            :     }
      69                 :          0 :     return aErrorStr.makeStringAndClear();
      70                 :            : }
      71                 :            : 
      72                 :            : // =======================================================================
      73                 :            : 
      74                 :          2 : static sal_Bool ImplIsMnemonicCtrl( Window* pWindow )
      75                 :            : {
      76         [ -  + ]:          2 :     if( ! pWindow->GetSettings().GetStyleSettings().GetAutoMnemonic() )
      77                 :          0 :         return sal_False;
      78                 :            : 
      79   [ +  -  +  -  :          8 :     if ( (pWindow->GetType() == WINDOW_RADIOBUTTON) ||
             +  -  -  + ]
                 [ -  + ]
      80                 :          2 :          (pWindow->GetType() == WINDOW_CHECKBOX) ||
      81                 :          2 :          (pWindow->GetType() == WINDOW_TRISTATEBOX) ||
      82                 :          2 :          (pWindow->GetType() == WINDOW_PUSHBUTTON) )
      83                 :          0 :         return sal_True;
      84                 :            : 
      85         [ +  - ]:          2 :     if ( pWindow->GetType() == WINDOW_FIXEDTEXT )
      86                 :            :     {
      87         [ -  + ]:          2 :         if ( pWindow->GetStyle() & (WB_INFO | WB_NOLABEL) )
      88                 :          0 :             return sal_False;
      89                 :          2 :         Window* pNextWindow = pWindow->GetWindow( WINDOW_NEXT );
      90         [ +  - ]:          2 :         if ( !pNextWindow )
      91                 :          2 :             return sal_False;
      92                 :          0 :         pNextWindow = pNextWindow->GetWindow( WINDOW_CLIENT );
      93 [ #  # ][ #  #  :          0 :         if ( !(pNextWindow->GetStyle() & WB_TABSTOP) ||
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
      94                 :          0 :              (pNextWindow->GetType() == WINDOW_FIXEDTEXT) ||
      95                 :          0 :              (pNextWindow->GetType() == WINDOW_GROUPBOX) ||
      96                 :          0 :              (pNextWindow->GetType() == WINDOW_RADIOBUTTON) ||
      97                 :          0 :              (pNextWindow->GetType() == WINDOW_CHECKBOX) ||
      98                 :          0 :              (pNextWindow->GetType() == WINDOW_TRISTATEBOX) ||
      99                 :          0 :              (pNextWindow->GetType() == WINDOW_PUSHBUTTON) )
     100                 :          0 :             return sal_False;
     101                 :            : 
     102                 :          0 :         return sal_True;
     103                 :            :     }
     104                 :            : 
     105                 :          2 :     return sal_False;
     106                 :            : }
     107                 :            : 
     108                 :            : // -----------------------------------------------------------------------
     109                 :            : 
     110                 :            : // Called by native error dialog popup implementations
     111                 :          0 : void ImplHideSplash()
     112                 :            : {
     113                 :          0 :     ImplSVData* pSVData = ImplGetSVData();
     114         [ #  # ]:          0 :     if( pSVData->mpIntroWindow )
     115                 :          0 :             pSVData->mpIntroWindow->Hide();
     116                 :          0 : }
     117                 :            : 
     118                 :            : // -----------------------------------------------------------------------
     119                 :            : 
     120                 :          2 : void ImplWindowAutoMnemonic( Window* pWindow )
     121                 :            : {
     122         [ +  - ]:          2 :     MnemonicGenerator   aMnemonicGenerator;
     123                 :            :     Window*                 pGetChild;
     124                 :            :     Window*                 pChild;
     125                 :            : 
     126                 :            :     // Die schon vergebenen Mnemonics registieren
     127         [ +  - ]:          2 :     pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
     128         [ +  + ]:          4 :     while ( pGetChild )
     129                 :            :     {
     130         [ +  - ]:          2 :         pChild = pGetChild->ImplGetWindow();
     131 [ +  - ][ +  - ]:          2 :         aMnemonicGenerator.RegisterMnemonic( pChild->GetText() );
                 [ +  - ]
     132         [ +  - ]:          2 :         pGetChild = pGetChild->GetWindow( WINDOW_NEXT );
     133                 :            :     }
     134                 :            : 
     135                 :            :     // Bei TabPages auch noch die Controls vom Dialog beruecksichtigen
     136 [ +  - ][ -  + ]:          2 :     if ( pWindow->GetType() == WINDOW_TABPAGE )
     137                 :            :     {
     138         [ #  # ]:          0 :         Window* pParent = pWindow->GetParent();
     139 [ #  # ][ #  # ]:          0 :         if ( pParent->GetType() == WINDOW_TABCONTROL )
     140         [ #  # ]:          0 :             pParent = pParent->GetParent();
     141                 :            : 
     142 [ #  # ][ #  # ]:          0 :         if ( (pParent->GetStyle() & (WB_DIALOGCONTROL | WB_NODIALOGCONTROL)) == WB_DIALOGCONTROL )
     143                 :            :         {
     144         [ #  # ]:          0 :             pGetChild = pParent->GetWindow( WINDOW_FIRSTCHILD );
     145         [ #  # ]:          0 :             while ( pGetChild )
     146                 :            :             {
     147         [ #  # ]:          0 :                 pChild = pGetChild->ImplGetWindow();
     148 [ #  # ][ #  # ]:          0 :                 aMnemonicGenerator.RegisterMnemonic( pChild->GetText() );
                 [ #  # ]
     149         [ #  # ]:          0 :                 pGetChild = pGetChild->GetWindow( WINDOW_NEXT );
     150                 :            :             }
     151                 :            :         }
     152                 :            :     }
     153                 :            : 
     154                 :            :     // Die Mnemonics an die Controls vergeben, die noch keinen haben
     155         [ +  - ]:          2 :     pGetChild = pWindow->GetWindow( WINDOW_FIRSTCHILD );
     156         [ +  + ]:          4 :     while ( pGetChild )
     157                 :            :     {
     158         [ +  - ]:          2 :         pChild = pGetChild->ImplGetWindow();
     159 [ +  - ][ -  + ]:          2 :         if ( ImplIsMnemonicCtrl( pChild ) )
     160                 :            :         {
     161         [ #  # ]:          0 :             XubString aText = pChild->GetText();
     162 [ #  # ][ #  # ]:          0 :             if ( aMnemonicGenerator.CreateMnemonic( aText ) )
     163 [ #  # ][ #  # ]:          0 :                 pChild->SetText( aText );
     164                 :            :         }
     165                 :            : 
     166         [ +  - ]:          2 :         pGetChild = pGetChild->GetWindow( WINDOW_NEXT );
     167         [ +  - ]:          2 :     }
     168                 :          2 : }
     169                 :            : 
     170                 :            : // =======================================================================
     171                 :            : 
     172                 :          0 : static PushButton* ImplGetDefaultButton( Dialog* pDialog )
     173                 :            : {
     174                 :          0 :     Window* pChild = pDialog->GetWindow( WINDOW_FIRSTCHILD );
     175         [ #  # ]:          0 :     while ( pChild )
     176                 :            :     {
     177         [ #  # ]:          0 :         if ( pChild->ImplIsPushButton() )
     178                 :            :         {
     179                 :          0 :             PushButton* pPushButton = (PushButton*)pChild;
     180         [ #  # ]:          0 :             if ( pPushButton->ImplIsDefButton() )
     181                 :          0 :                 return pPushButton;
     182                 :            :         }
     183                 :            : 
     184                 :          0 :         pChild = pChild->GetWindow( WINDOW_NEXT );
     185                 :            :     }
     186                 :            : 
     187                 :          0 :     return NULL;
     188                 :            : }
     189                 :            : 
     190                 :            : // -----------------------------------------------------------------------
     191                 :            : 
     192                 :          0 : static PushButton* ImplGetOKButton( Dialog* pDialog )
     193                 :            : {
     194                 :          0 :     Window* pChild = pDialog->GetWindow( WINDOW_FIRSTCHILD );
     195         [ #  # ]:          0 :     while ( pChild )
     196                 :            :     {
     197         [ #  # ]:          0 :         if ( pChild->GetType() == WINDOW_OKBUTTON )
     198                 :          0 :             return (PushButton*)pChild;
     199                 :            : 
     200                 :          0 :         pChild = pChild->GetWindow( WINDOW_NEXT );
     201                 :            :     }
     202                 :            : 
     203                 :          0 :     return NULL;
     204                 :            : }
     205                 :            : 
     206                 :            : // -----------------------------------------------------------------------
     207                 :            : 
     208                 :          0 : static PushButton* ImplGetCancelButton( Dialog* pDialog )
     209                 :            : {
     210                 :          0 :     Window* pChild = pDialog->GetWindow( WINDOW_FIRSTCHILD );
     211         [ #  # ]:          0 :     while ( pChild )
     212                 :            :     {
     213         [ #  # ]:          0 :         if ( pChild->GetType() == WINDOW_CANCELBUTTON )
     214                 :          0 :             return (PushButton*)pChild;
     215                 :            : 
     216                 :          0 :         pChild = pChild->GetWindow( WINDOW_NEXT );
     217                 :            :     }
     218                 :            : 
     219                 :          0 :     return NULL;
     220                 :            : }
     221                 :            : 
     222                 :            : // -----------------------------------------------------------------------
     223                 :            : 
     224                 :          2 : static void ImplMouseAutoPos( Dialog* pDialog )
     225                 :            : {
     226                 :          2 :     sal_uLong nMouseOptions = pDialog->GetSettings().GetMouseSettings().GetOptions();
     227         [ -  + ]:          2 :     if ( nMouseOptions & MOUSE_OPTION_AUTOCENTERPOS )
     228                 :            :     {
     229                 :          0 :         Size aSize = pDialog->GetOutputSizePixel();
     230         [ #  # ]:          0 :         pDialog->SetPointerPosPixel( Point( aSize.Width()/2, aSize.Height()/2 ) );
     231                 :            :     }
     232         [ -  + ]:          2 :     else if ( nMouseOptions & MOUSE_OPTION_AUTODEFBTNPOS )
     233                 :            :     {
     234         [ #  # ]:          0 :         Window* pWindow = ImplGetDefaultButton( pDialog );
     235         [ #  # ]:          0 :         if ( !pWindow )
     236         [ #  # ]:          0 :             pWindow = ImplGetOKButton( pDialog );
     237         [ #  # ]:          0 :         if ( !pWindow )
     238         [ #  # ]:          0 :             pWindow = ImplGetCancelButton( pDialog );
     239         [ #  # ]:          0 :         if ( !pWindow )
     240                 :          0 :             pWindow = pDialog;
     241                 :          0 :         Size aSize = pWindow->GetOutputSizePixel();
     242         [ #  # ]:          0 :         pWindow->SetPointerPosPixel( Point( aSize.Width()/2, aSize.Height()/2 ) );
     243                 :            :     }
     244                 :          2 : }
     245                 :            : 
     246                 :            : // =======================================================================
     247                 :            : 
     248                 :            : struct DialogImpl
     249                 :            : {
     250                 :            :     long    mnResult;
     251                 :            :     bool    mbStartedModal;
     252                 :            :     Link    maEndDialogHdl;
     253                 :            : 
     254                 :          2 :     DialogImpl() : mnResult( -1 ), mbStartedModal( false ) {}
     255                 :            : };
     256                 :            : 
     257                 :            : // =======================================================================
     258                 :            : 
     259                 :          2 : void Dialog::ImplInitDialogData()
     260                 :            : {
     261                 :          2 :     mpWindowImpl->mbDialog  = sal_True;
     262                 :          2 :     mpDialogParent          = NULL;
     263                 :          2 :     mpPrevExecuteDlg        = NULL;
     264                 :          2 :     mbInExecute             = sal_False;
     265                 :          2 :     mbOldSaveBack           = sal_False;
     266                 :          2 :     mbInClose               = sal_False;
     267                 :          2 :     mbModalMode             = sal_False;
     268                 :          2 :     mnMousePositioned       = 0;
     269         [ +  - ]:          2 :     mpDialogImpl            = new DialogImpl;
     270                 :          2 : }
     271                 :            : 
     272                 :            : // -----------------------------------------------------------------------
     273                 :            : 
     274                 :          2 : void Dialog::ImplInit( Window* pParent, WinBits nStyle )
     275                 :            : {
     276                 :          2 :     sal_uInt16 nSysWinMode = Application::GetSystemWindowMode();
     277                 :            : 
     278         [ +  - ]:          2 :     if ( !(nStyle & WB_NODIALOGCONTROL) )
     279                 :          2 :         nStyle |= WB_DIALOGCONTROL;
     280                 :          2 :     nStyle |= WB_ROLLABLE;
     281                 :            : 
     282                 :            :     // Now, all Dialogs are per default system windows !!!
     283                 :          2 :     nStyle |= WB_SYSTEMWINDOW;
     284                 :            : 
     285                 :            : 
     286                 :            :     // parent is NULL: get the default Dialog parent
     287         [ +  - ]:          2 :     if ( !pParent )
     288                 :            :     {
     289                 :          2 :         pParent = Application::GetDefDialogParent();
     290 [ -  + ][ +  - ]:          2 :         if ( !pParent && !(nStyle & WB_SYSTEMWINDOW) )
     291                 :          0 :             pParent = ImplGetSVData()->maWinData.mpAppWin;
     292                 :            : 
     293                 :            :         // If Parent is disabled, then we search for a modal dialog
     294                 :            :         // in this frame
     295 [ -  + ][ #  # ]:          2 :         if ( pParent && (!pParent->IsInputEnabled() || pParent->IsInModalMode()) )
         [ #  # ][ -  + ]
     296                 :            :         {
     297                 :          0 :             ImplSVData* pSVData = ImplGetSVData();
     298                 :          0 :             Dialog*     pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
     299         [ #  # ]:          0 :             while ( pExeDlg )
     300                 :            :             {
     301                 :            :                 // Nur wenn er sichtbar und enabled ist
     302   [ #  #  #  #  :          0 :                 if ( pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild( pExeDlg, sal_True ) &&
          #  #  #  #  #  
              # ][ #  # ]
     303                 :          0 :                      pExeDlg->IsReallyVisible() &&
     304                 :          0 :                      pExeDlg->IsEnabled() && pExeDlg->IsInputEnabled() && !pExeDlg->IsInModalMode() )
     305                 :            :                 {
     306                 :          0 :                     pParent = pExeDlg;
     307                 :          0 :                     break;
     308                 :            :                 }
     309                 :            : 
     310                 :          0 :                 pExeDlg = pExeDlg->mpPrevExecuteDlg;
     311                 :            :             }
     312                 :            :         }
     313                 :            :     }
     314                 :            :     // DIALOG_NO_PARENT: explicitly don't have a parent for this Dialog
     315         [ #  # ]:          0 :     else if( pParent == DIALOG_NO_PARENT )
     316                 :          0 :         pParent = NULL;
     317                 :            : 
     318                 :            : 
     319 [ -  + ][ #  # ]:          2 :     if ( !pParent || (nStyle & WB_SYSTEMWINDOW) ||
         [ #  # ][ #  # ]
                 [ #  # ]
     320                 :          0 :          (pParent->mpWindowImpl->mpFrameData->mbNeedSysWindow && !(nSysWinMode & SYSTEMWINDOW_MODE_NOAUTOMODE)) ||
     321                 :            :          (nSysWinMode & SYSTEMWINDOW_MODE_DIALOG) )
     322                 :            :     {
     323                 :            :         // create window with a small border ?
     324         [ -  + ]:          2 :         if ( (nStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE)) == WB_BORDER )
     325                 :            :         {
     326         [ #  # ]:          0 :             ImplBorderWindow* pBorderWin  = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_FRAME );
     327                 :          0 :             SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
     328                 :          0 :             pBorderWin->mpWindowImpl->mpClientWindow = this;
     329                 :          0 :             pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
     330                 :          0 :             mpWindowImpl->mpBorderWindow  = pBorderWin;
     331                 :          0 :             mpWindowImpl->mpRealParent    = pParent;
     332                 :            :         }
     333                 :            :         else
     334                 :            :         {
     335                 :          2 :             mpWindowImpl->mbFrame         = sal_True;
     336                 :          2 :             mpWindowImpl->mbOverlapWin    = sal_True;
     337                 :          2 :             SystemWindow::ImplInit( pParent, (nStyle & (WB_MOVEABLE | WB_SIZEABLE | WB_ROLLABLE | WB_CLOSEABLE | WB_STANDALONE)) | WB_CLOSEABLE, NULL );
     338                 :            :             // Now set all style bits
     339                 :          2 :             mpWindowImpl->mnStyle = nStyle;
     340                 :          2 :         }
     341                 :            :     }
     342                 :            :     else
     343                 :            :     {
     344         [ #  # ]:          0 :         ImplBorderWindow* pBorderWin  = new ImplBorderWindow( pParent, nStyle, BORDERWINDOW_STYLE_OVERLAP | BORDERWINDOW_STYLE_BORDER );
     345                 :          0 :         SystemWindow::ImplInit( pBorderWin, nStyle & ~WB_BORDER, NULL );
     346                 :          0 :         pBorderWin->mpWindowImpl->mpClientWindow = this;
     347                 :          0 :         pBorderWin->GetBorder( mpWindowImpl->mnLeftBorder, mpWindowImpl->mnTopBorder, mpWindowImpl->mnRightBorder, mpWindowImpl->mnBottomBorder );
     348                 :          0 :         mpWindowImpl->mpBorderWindow  = pBorderWin;
     349                 :          0 :         mpWindowImpl->mpRealParent    = pParent;
     350                 :            :     }
     351                 :            : 
     352                 :          2 :     SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
     353                 :            : 
     354                 :          2 :     ImplInitSettings();
     355                 :          2 : }
     356                 :            : 
     357                 :            : // -----------------------------------------------------------------------
     358                 :            : 
     359                 :          4 : void Dialog::ImplInitSettings()
     360                 :            : {
     361                 :            :     // user override
     362         [ +  + ]:          4 :     if ( IsControlBackground() )
     363 [ +  - ][ +  - ]:          2 :         SetBackground( GetControlBackground() );
                 [ +  - ]
     364                 :            :     // NWF background
     365         [ -  + ]:          2 :     else if( IsNativeControlSupported( CTRL_WINDOW_BACKGROUND, PART_BACKGROUND_DIALOG ) )
     366                 :            :     {
     367                 :          0 :         mpWindowImpl->mnNativeBackground = PART_BACKGROUND_DIALOG;
     368                 :          0 :         EnableChildTransparentMode( sal_True );
     369                 :            :     }
     370                 :            :     // fallback to settings color
     371                 :            :     else
     372         [ +  - ]:          2 :         SetBackground( GetSettings().GetStyleSettings().GetDialogColor() );
     373                 :            : 
     374                 :          4 : }
     375                 :            : 
     376                 :            : // -----------------------------------------------------------------------
     377                 :            : 
     378                 :          0 : Dialog::Dialog( WindowType nType ) :
     379                 :          0 :     SystemWindow( nType )
     380                 :            : {
     381         [ #  # ]:          0 :     ImplInitDialogData();
     382                 :          0 : }
     383                 :            : 
     384                 :            : // -----------------------------------------------------------------------
     385                 :            : 
     386                 :          2 : Dialog::Dialog( Window* pParent, WinBits nStyle ) :
     387                 :          2 :     SystemWindow( WINDOW_DIALOG )
     388                 :            : {
     389         [ +  - ]:          2 :     ImplInitDialogData();
     390         [ +  - ]:          2 :     ImplInit( pParent, nStyle );
     391                 :          2 : }
     392                 :            : 
     393                 :            : // -----------------------------------------------------------------------
     394                 :            : 
     395                 :          2 : Dialog::~Dialog()
     396                 :            : {
     397                 :          2 :     delete mpDialogImpl;
     398                 :          2 :     mpDialogImpl = NULL;
     399         [ -  + ]:          4 : }
     400                 :            : 
     401                 :            : // -----------------------------------------------------------------------
     402                 :            : 
     403                 :          0 : IMPL_LINK_NOARG(Dialog, ImplAsyncCloseHdl)
     404                 :            : {
     405                 :          0 :     Close();
     406                 :          0 :     return 0;
     407                 :            : }
     408                 :            : 
     409                 :            : // -----------------------------------------------------------------------
     410                 :            : 
     411                 :          8 : long Dialog::Notify( NotifyEvent& rNEvt )
     412                 :            : {
     413                 :            :     // Zuerst Basisklasse rufen wegen TabSteuerung
     414                 :          8 :     long nRet = SystemWindow::Notify( rNEvt );
     415         [ +  - ]:          8 :     if ( !nRet )
     416                 :            :     {
     417         [ -  + ]:          8 :         if ( rNEvt.GetType() == EVENT_KEYINPUT )
     418                 :            :         {
     419         [ #  # ]:          0 :             const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
     420                 :          0 :             KeyCode         aKeyCode = pKEvt->GetKeyCode();
     421                 :          0 :             sal_uInt16          nKeyCode = aKeyCode.GetCode();
     422                 :            : 
     423 [ #  # ][ #  # ]:          0 :             if ( (nKeyCode == KEY_ESCAPE) &&
         [ #  # ][ #  # ]
                 [ #  # ]
     424 [ #  # ][ #  # ]:          0 :                  ((GetStyle() & WB_CLOSEABLE) || ImplGetCancelButton( this ) || ImplGetOKButton( this )) )
                 [ #  # ]
     425                 :            :             {
     426                 :            :                 // #i89505# for the benefit of slightly mentally challenged implementations
     427                 :            :                 // like e.g. SfxModelessDialog which destroy themselves inside Close()
     428                 :            :                 // post this Close asynchronous so we can leave our key handler before
     429                 :            :                 // we get destroyed
     430 [ #  # ][ #  # ]:          0 :                 PostUserEvent( LINK( this, Dialog, ImplAsyncCloseHdl ), this );
     431                 :          0 :                 return sal_True;
     432                 :            :             }
     433                 :            :         }
     434         [ +  + ]:          8 :         else if ( rNEvt.GetType() == EVENT_GETFOCUS )
     435                 :            :         {
     436                 :            :             // make sure the dialog is still modal
     437                 :            :             // changing focus between application frames may
     438                 :            :             // have re-enabled input for our parent
     439 [ -  + ][ #  # ]:          2 :             if( mbInExecute && mbModalMode )
     440                 :            :             {
     441                 :            :                 // do not change modal counter (pSVData->maAppData.mnModalDialog)
     442                 :          0 :                 SetModalInputMode( sal_False );
     443                 :          0 :                 SetModalInputMode( sal_True );
     444                 :            : 
     445                 :            :                 // #93022# def-button might have changed after show
     446         [ #  # ]:          0 :                 if( !mnMousePositioned )
     447                 :            :                 {
     448                 :          0 :                     mnMousePositioned = 1;
     449                 :          0 :                     ImplMouseAutoPos( this );
     450                 :            :                 }
     451                 :            : 
     452                 :            :             }
     453                 :            :         }
     454                 :            :     }
     455                 :            : 
     456                 :          8 :     return nRet;
     457                 :            : }
     458                 :            : 
     459                 :            : // -----------------------------------------------------------------------
     460                 :            : 
     461                 :          8 : void Dialog::StateChanged( StateChangedType nType )
     462                 :            : {
     463                 :          8 :     SystemWindow::StateChanged( nType );
     464                 :            : 
     465         [ +  + ]:          8 :     if ( nType == STATE_CHANGE_INITSHOW )
     466                 :            :     {
     467         [ +  - ]:          2 :         if ( GetSettings().GetStyleSettings().GetAutoMnemonic() )
     468                 :          2 :             ImplWindowAutoMnemonic( this );
     469                 :            : 
     470 [ -  + ][ #  # ]:          2 :         if ( !HasChildPathFocus() || HasFocus() )
                 [ +  - ]
     471                 :          2 :             GrabFocusToFirstControl();
     472         [ -  + ]:          2 :         if ( !(GetStyle() & WB_CLOSEABLE) )
     473                 :            :         {
     474 [ #  # ][ #  # ]:          0 :             if ( ImplGetCancelButton( this ) || ImplGetOKButton( this ) )
                 [ #  # ]
     475                 :            :             {
     476         [ #  # ]:          0 :                 if ( ImplGetBorderWindow() )
     477                 :          0 :                     ((ImplBorderWindow*)ImplGetBorderWindow())->SetCloser();
     478                 :            :             }
     479                 :            :         }
     480                 :            : 
     481                 :          2 :         ImplMouseAutoPos( this );
     482                 :            :     }
     483         [ +  + ]:          6 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     484                 :            :     {
     485                 :          2 :         ImplInitSettings();
     486                 :          2 :         Invalidate();
     487                 :            :     }
     488                 :          8 : }
     489                 :            : 
     490                 :            : // -----------------------------------------------------------------------
     491                 :            : 
     492                 :          0 : void Dialog::DataChanged( const DataChangedEvent& rDCEvt )
     493                 :            : {
     494                 :          0 :     SystemWindow::DataChanged( rDCEvt );
     495                 :            : 
     496         [ #  # ]:          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
           [ #  #  #  # ]
     497                 :          0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     498                 :            :     {
     499                 :          0 :         ImplInitSettings();
     500                 :          0 :         Invalidate();
     501                 :            :     }
     502                 :          0 : }
     503                 :            : 
     504                 :            : // -----------------------------------------------------------------------
     505                 :            : 
     506                 :          0 : sal_Bool Dialog::Close()
     507                 :            : {
     508         [ #  # ]:          0 :     ImplDelData aDelData;
     509         [ #  # ]:          0 :     ImplAddDel( &aDelData );
     510                 :            :     //liuchen 2009-7-22, support Excel VBA UserForm_QueryClose event
     511                 :          0 :     mnCancelClose = 0;
     512         [ #  # ]:          0 :     ImplCallEventListeners( VCLEVENT_WINDOW_CLOSE );
     513                 :            :         // basic boolean ( and what the user might use in the event handler) can
     514                 :            :     // be ambiguous ( e.g. basic true = -1 )
     515                 :            :     // test agains 0 ( false ) and assume anything else is true
     516                 :            :     // ( Note: ) this used to work ( something changes somewhere )
     517         [ #  # ]:          0 :     if (mnCancelClose != 0)
     518                 :            :     {
     519                 :          0 :         return sal_False;
     520                 :            :     }
     521                 :            :     //liuchen 2009-7-22
     522         [ #  # ]:          0 :     if ( aDelData.IsDead() )
     523                 :          0 :         return sal_False;
     524         [ #  # ]:          0 :     ImplRemoveDel( &aDelData );
     525                 :            : 
     526 [ #  # ][ #  # ]:          0 :     if ( mpWindowImpl->mxWindowPeer.is() && IsCreatedWithToolkit() && !IsInExecute() )
         [ #  # ][ #  # ]
                 [ #  # ]
     527                 :          0 :         return sal_False;
     528                 :            : 
     529                 :          0 :     mbInClose = sal_True;
     530                 :            : 
     531 [ #  # ][ #  # ]:          0 :     if ( !(GetStyle() & WB_CLOSEABLE) )
     532                 :            :     {
     533                 :          0 :         sal_Bool bRet = sal_True;
     534         [ #  # ]:          0 :         ImplAddDel( &aDelData );
     535         [ #  # ]:          0 :         PushButton* pButton = ImplGetCancelButton( this );
     536         [ #  # ]:          0 :         if ( pButton )
     537         [ #  # ]:          0 :             pButton->Click();
     538                 :            :         else
     539                 :            :         {
     540         [ #  # ]:          0 :             pButton = ImplGetOKButton( this );
     541         [ #  # ]:          0 :             if ( pButton )
     542         [ #  # ]:          0 :                 pButton->Click();
     543                 :            :             else
     544                 :          0 :                 bRet = sal_False;
     545                 :            :         }
     546         [ #  # ]:          0 :         if ( aDelData.IsDead() )
     547                 :          0 :             return sal_True;
     548         [ #  # ]:          0 :         ImplRemoveDel( &aDelData );
     549                 :          0 :         return bRet;
     550                 :            :     }
     551                 :            : 
     552         [ #  # ]:          0 :     if ( IsInExecute() )
     553                 :            :     {
     554         [ #  # ]:          0 :         EndDialog( sal_False );
     555                 :          0 :         mbInClose = sal_False;
     556                 :          0 :         return sal_True;
     557                 :            :     }
     558                 :            :     else
     559                 :            :     {
     560                 :          0 :         mbInClose = sal_False;
     561         [ #  # ]:          0 :         return SystemWindow::Close();
     562         [ #  # ]:          0 :     }
     563                 :            : }
     564                 :            : 
     565                 :            : // -----------------------------------------------------------------------
     566                 :            : 
     567                 :          0 : sal_Bool Dialog::ImplStartExecuteModal()
     568                 :            : {
     569                 :            : #ifdef ANDROID
     570                 :            :     // If a non-NativeActivity app, we shouldn't be showing any dialogs
     571                 :            :     if (lo_get_app() == NULL) {
     572                 :            :         fprintf(stderr, "%s: Should not do anything, returning false\n", __FUNCTION__);
     573                 :            :         return sal_False;
     574                 :            :     }
     575                 :            : #endif
     576                 :            : 
     577         [ #  # ]:          0 :     if ( mbInExecute )
     578                 :            :     {
     579                 :            : #ifdef DBG_UTIL
     580                 :            :         rtl::OStringBuffer aErrorStr;
     581                 :            :         aErrorStr.append(RTL_CONSTASCII_STRINGPARAM("Dialog::StartExecuteModal() is called in Dialog::StartExecuteModal(): "));
     582                 :            :         aErrorStr.append(ImplGetDialogText(this));
     583                 :            :         OSL_FAIL(aErrorStr.getStr());
     584                 :            : #endif
     585                 :          0 :         return sal_False;
     586                 :            :     }
     587                 :            : 
     588      [ #  #  # ]:          0 :     switch ( Application::GetDialogCancelMode() )
     589                 :            :     {
     590                 :            :     case Application::DIALOG_CANCEL_OFF:
     591                 :          0 :         break;
     592                 :            :     case Application::DIALOG_CANCEL_SILENT:
     593                 :            :         SAL_INFO(
     594                 :            :             "vcl",
     595                 :            :             "Dialog \"" << ImplGetDialogText(this).getStr()
     596                 :            :                 << "\"cancelled in silent mode");
     597                 :          0 :         return sal_False;
     598                 :            :     default:
     599                 :            :         assert(false); // this cannot happen
     600                 :            :         // fall through
     601                 :            :     case Application::DIALOG_CANCEL_FATAL:
     602                 :            :         throw Application::DialogCancelledException(
     603 [ #  # ][ #  # ]:          0 :             ImplGetDialogText(this).getStr());
     604                 :            :     }
     605                 :            : 
     606                 :            : #ifdef DBG_UTIL
     607                 :            :     Window* pParent = GetParent();
     608                 :            :     if ( pParent )
     609                 :            :     {
     610                 :            :         pParent = pParent->ImplGetFirstOverlapWindow();
     611                 :            :         DBG_ASSERT( pParent->IsReallyVisible(),
     612                 :            :                     "Dialog::StartExecuteModal() - Parent not visible" );
     613                 :            :         DBG_ASSERT( pParent->IsInputEnabled(),
     614                 :            :                     "Dialog::StartExecuteModal() - Parent input disabled, use another parent to ensure modality!" );
     615                 :            :         DBG_ASSERT( ! pParent->IsInModalMode(),
     616                 :            :                     "Dialog::StartExecuteModal() - Parent already modally disabled, use another parent to ensure modality!" );
     617                 :            : 
     618                 :            :     }
     619                 :            : #endif
     620                 :            : 
     621                 :          0 :     ImplSVData* pSVData = ImplGetSVData();
     622                 :            : 
     623                 :            :     // Dialoge, die sich in Execute befinden, miteinander verketten
     624                 :          0 :     mpPrevExecuteDlg = pSVData->maWinData.mpLastExecuteDlg;
     625                 :          0 :     pSVData->maWinData.mpLastExecuteDlg = this;
     626                 :            : 
     627                 :            :     // Capture beenden, damit der Dialog bedient werden kann
     628         [ #  # ]:          0 :     if ( pSVData->maWinData.mpTrackWin )
     629                 :          0 :         pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL );
     630         [ #  # ]:          0 :     if ( pSVData->maWinData.mpCaptureWin )
     631                 :          0 :         pSVData->maWinData.mpCaptureWin->ReleaseMouse();
     632                 :          0 :     EnableInput( sal_True, sal_True );
     633                 :            : 
     634         [ #  # ]:          0 :     if ( GetParent() )
     635                 :            :     {
     636         [ #  # ]:          0 :         NotifyEvent aNEvt( EVENT_EXECUTEDIALOG, this );
     637 [ #  # ][ #  # ]:          0 :         GetParent()->Notify( aNEvt );
     638                 :            :     }
     639                 :          0 :     mbInExecute = sal_True;
     640                 :          0 :     SetModalInputMode( sal_True );
     641                 :          0 :     mbOldSaveBack = IsSaveBackgroundEnabled();
     642                 :          0 :     EnableSaveBackground();
     643                 :            : 
     644                 :            :     // FIXME: no layouting, workaround some clipping issues
     645                 :          0 :     ImplAdjustNWFSizes();
     646                 :            : 
     647                 :          0 :     Show();
     648                 :            : 
     649                 :          0 :     pSVData->maAppData.mnModalMode++;
     650                 :          0 :     return sal_True;
     651                 :            : }
     652                 :            : 
     653                 :            : // -----------------------------------------------------------------------
     654                 :            : 
     655                 :          0 : void Dialog::ImplEndExecuteModal()
     656                 :            : {
     657                 :          0 :     ImplSVData* pSVData = ImplGetSVData();
     658                 :          0 :     pSVData->maAppData.mnModalMode--;
     659                 :          0 : }
     660                 :            : 
     661                 :            : // -----------------------------------------------------------------------
     662                 :            : 
     663                 :          0 : short Dialog::Execute()
     664                 :            : {
     665 [ #  # ][ #  # ]:          0 :     if ( !ImplStartExecuteModal() )
     666                 :          0 :         return 0;
     667                 :            : 
     668         [ #  # ]:          0 :     ImplDelData aDelData;
     669         [ #  # ]:          0 :     ImplAddDel( &aDelData );
     670                 :            : 
     671                 :            : #ifdef DBG_UTIL
     672                 :            :     ImplDelData aParentDelData;
     673                 :            :     Window* pDialogParent = mpDialogParent;
     674                 :            :     if( pDialogParent )
     675                 :            :         pDialogParent->ImplAddDel( &aParentDelData );
     676                 :            : #endif
     677                 :            : 
     678                 :            :     // Yield util EndDialog is called or dialog gets destroyed
     679                 :            :     // (the latter should not happen, but better safe than sorry
     680 [ #  # ][ #  # ]:          0 :     while ( !aDelData.IsDead() && mbInExecute )
                 [ #  # ]
     681         [ #  # ]:          0 :         Application::Yield();
     682                 :            : 
     683         [ #  # ]:          0 :     ImplEndExecuteModal();
     684                 :            : 
     685                 :            : #ifdef DBG_UTIL
     686                 :            :     if( pDialogParent  )
     687                 :            :     {
     688                 :            :         if( ! aParentDelData.IsDead() )
     689                 :            :             pDialogParent->ImplRemoveDel( &aParentDelData );
     690                 :            :         else
     691                 :            :             OSL_FAIL( "Dialog::Execute() - Parent of dialog destroyed in Execute()" );
     692                 :            :     }
     693                 :            : #endif
     694         [ #  # ]:          0 :     if ( !aDelData.IsDead() )
     695         [ #  # ]:          0 :         ImplRemoveDel( &aDelData );
     696                 :            : #ifdef DBG_UTIL
     697                 :            :     else
     698                 :            :     {
     699                 :            :         OSL_FAIL( "Dialog::Execute() - Dialog destroyed in Execute()" );
     700                 :            :     }
     701                 :            : #endif
     702                 :            : 
     703                 :          0 :     long nRet = mpDialogImpl->mnResult;
     704                 :          0 :     mpDialogImpl->mnResult = -1;
     705         [ #  # ]:          0 :     return (short)nRet;
     706                 :            : }
     707                 :            : 
     708                 :            : // -----------------------------------------------------------------------
     709                 :            : 
     710                 :            : // virtual
     711                 :          0 : void Dialog::StartExecuteModal( const Link& rEndDialogHdl )
     712                 :            : {
     713         [ #  # ]:          0 :     if ( !ImplStartExecuteModal() )
     714                 :          0 :         return;
     715                 :            : 
     716                 :          0 :     mpDialogImpl->maEndDialogHdl = rEndDialogHdl;
     717                 :          0 :     mpDialogImpl->mbStartedModal = true;
     718                 :            : }
     719                 :            : 
     720                 :            : // -----------------------------------------------------------------------
     721                 :            : 
     722                 :          0 : void Dialog::EndDialog( long nResult )
     723                 :            : {
     724         [ #  # ]:          0 :     if ( mbInExecute )
     725                 :            :     {
     726                 :          0 :         SetModalInputMode( sal_False );
     727                 :            : 
     728                 :            :         // Dialog aus der Kette der Dialoge die in Execute stehen entfernen
     729                 :          0 :         ImplSVData* pSVData = ImplGetSVData();
     730                 :          0 :         Dialog* pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
     731         [ #  # ]:          0 :         while ( pExeDlg )
     732                 :            :         {
     733         [ #  # ]:          0 :             if ( pExeDlg == this )
     734                 :            :             {
     735                 :          0 :                 pSVData->maWinData.mpLastExecuteDlg = mpPrevExecuteDlg;
     736                 :          0 :                 break;
     737                 :            :             }
     738                 :          0 :             pExeDlg = pExeDlg->mpPrevExecuteDlg;
     739                 :            :         }
     740                 :            :         // set focus to previous modal dialogue if it is modal for
     741                 :            :         // the same frame parent (or NULL)
     742         [ #  # ]:          0 :         if( mpPrevExecuteDlg )
     743                 :            :         {
     744                 :          0 :             Window* pFrameParent = ImplGetFrameWindow()->ImplGetParent();
     745                 :          0 :             Window* pPrevFrameParent = mpPrevExecuteDlg->ImplGetFrameWindow()->ImplGetParent();
     746 [ #  # ][ #  # ]:          0 :             if( ( !pFrameParent && !pPrevFrameParent ) ||
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     747                 :          0 :                 ( pFrameParent && pPrevFrameParent && pFrameParent->ImplGetFrame() == pPrevFrameParent->ImplGetFrame() )
     748                 :            :                 )
     749                 :            :             {
     750                 :          0 :                 mpPrevExecuteDlg->GrabFocus();
     751                 :            :             }
     752                 :            :         }
     753                 :          0 :         mpPrevExecuteDlg = NULL;
     754                 :            : 
     755                 :          0 :         Hide();
     756                 :          0 :         EnableSaveBackground( mbOldSaveBack );
     757         [ #  # ]:          0 :         if ( GetParent() )
     758                 :            :         {
     759         [ #  # ]:          0 :             NotifyEvent aNEvt( EVENT_ENDEXECUTEDIALOG, this );
     760 [ #  # ][ #  # ]:          0 :             GetParent()->Notify( aNEvt );
     761                 :            :         }
     762                 :            : 
     763                 :          0 :         mpDialogImpl->mnResult = nResult;
     764                 :            : 
     765         [ #  # ]:          0 :         if ( mpDialogImpl->mbStartedModal )
     766                 :            :         {
     767                 :          0 :             ImplEndExecuteModal();
     768                 :          0 :             mpDialogImpl->maEndDialogHdl.Call( this );
     769                 :            : 
     770                 :          0 :             mpDialogImpl->maEndDialogHdl = Link();
     771                 :          0 :             mpDialogImpl->mbStartedModal = false;
     772                 :          0 :             mpDialogImpl->mnResult = -1;
     773                 :            :         }
     774                 :          0 :         mbInExecute = sal_False;
     775                 :            :     }
     776                 :          0 : }
     777                 :            : 
     778                 :            : // -----------------------------------------------------------------------
     779                 :            : 
     780                 :          0 : long Dialog::GetResult() const
     781                 :            : {
     782                 :          0 :     return mpDialogImpl->mnResult;
     783                 :            : }
     784                 :            : 
     785                 :            : // -----------------------------------------------------------------------
     786                 :            : 
     787                 :          0 : void Dialog::EndAllDialogs( Window* pParent )
     788                 :            : {
     789                 :          0 :    ImplSVData*  pSVData = ImplGetSVData();
     790                 :            :    Dialog*      pTempModDialog;
     791                 :          0 :    Dialog*      pModDialog = pSVData->maWinData.mpLastExecuteDlg;
     792         [ #  # ]:          0 :    while ( pModDialog )
     793                 :            :    {
     794                 :          0 :      pTempModDialog = pModDialog->mpPrevExecuteDlg;
     795 [ #  # ][ #  # ]:          0 :      if( !pParent || ( pParent && pParent->IsWindowOrChild( pModDialog, sal_True ) ) )
         [ #  # ][ #  # ]
     796                 :            :      {
     797                 :          0 :         pModDialog->EndDialog( sal_False );
     798         [ #  # ]:          0 :         pModDialog->PostUserEvent( Link() );
     799                 :            :      }
     800                 :          0 :      pModDialog = pTempModDialog;
     801                 :            :    }
     802                 :          0 : }
     803                 :            : 
     804                 :            : // -----------------------------------------------------------------------
     805                 :            : 
     806                 :          0 : void Dialog::SetModalInputMode( sal_Bool bModal )
     807                 :            : {
     808         [ #  # ]:          0 :     if ( bModal == mbModalMode )
     809                 :          0 :         return;
     810                 :            : 
     811                 :          0 :     ImplSVData* pSVData = ImplGetSVData();
     812                 :          0 :     mbModalMode = bModal;
     813         [ #  # ]:          0 :     if ( bModal )
     814                 :            :     {
     815                 :          0 :         pSVData->maAppData.mnModalDialog++;
     816                 :            : 
     817                 :            :         // Diable the prev Modal Dialog, because our dialog must close at first,
     818                 :            :         // before the other dialog can be closed (because the other dialog
     819                 :            :         // is on stack since our dialog returns)
     820 [ #  # ][ #  # ]:          0 :         if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, sal_True ) )
                 [ #  # ]
     821                 :          0 :             mpPrevExecuteDlg->EnableInput( sal_False, sal_True, sal_True, this );
     822                 :            : 
     823                 :            :         // determine next overlap dialog parent
     824                 :          0 :         Window* pParent = GetParent();
     825         [ #  # ]:          0 :         if ( pParent )
     826                 :            :         {
     827                 :            :             // #103716# dialogs should always be modal to the whole frame window
     828                 :            :             // #115933# disable the whole frame hierarchie, useful if our parent
     829                 :            :             // is a modeless dialog
     830                 :          0 :             mpDialogParent = pParent->mpWindowImpl->mpFrameWindow;
     831                 :          0 :             mpDialogParent->ImplIncModalCount();
     832                 :            :         }
     833                 :            : 
     834                 :            :     }
     835                 :            :     else
     836                 :            :     {
     837                 :          0 :         pSVData->maAppData.mnModalDialog--;
     838                 :            : 
     839         [ #  # ]:          0 :         if ( mpDialogParent )
     840                 :            :         {
     841                 :            :             // #115933# re-enable the whole frame hierarchie again (see above)
     842                 :            :             // note that code in getfocus assures that we do not accidentally enable
     843                 :            :             // windows that were disabled before
     844                 :          0 :             mpDialogParent->ImplDecModalCount();
     845                 :            :         }
     846                 :            : 
     847                 :            :         // Enable the prev Modal Dialog
     848 [ #  # ][ #  # ]:          0 :         if ( mpPrevExecuteDlg && !mpPrevExecuteDlg->IsWindowOrChild( this, sal_True ) )
                 [ #  # ]
     849                 :            :         {
     850                 :          0 :             mpPrevExecuteDlg->EnableInput( sal_True, sal_True, sal_True, this );
     851                 :            :             // ensure continued modality of prev dialog
     852                 :            :             // do not change modality counter
     853                 :          0 :             mpPrevExecuteDlg->SetModalInputMode( sal_False );
     854                 :          0 :             mpPrevExecuteDlg->SetModalInputMode( sal_True );
     855                 :            :         }
     856                 :            :     }
     857                 :            : }
     858                 :            : 
     859                 :            : // -----------------------------------------------------------------------
     860                 :            : 
     861                 :          0 : void Dialog::SetModalInputMode( sal_Bool bModal, sal_Bool bSubModalDialogs )
     862                 :            : {
     863         [ #  # ]:          0 :     if ( bSubModalDialogs )
     864                 :            :     {
     865                 :          0 :         Window* pOverlap = ImplGetFirstOverlapWindow();
     866                 :          0 :         pOverlap = pOverlap->mpWindowImpl->mpFirstOverlap;
     867         [ #  # ]:          0 :         while ( pOverlap )
     868                 :            :         {
     869         [ #  # ]:          0 :             if ( pOverlap->IsDialog() )
     870                 :          0 :                 ((Dialog*)pOverlap)->SetModalInputMode( bModal, sal_True );
     871                 :          0 :             pOverlap = pOverlap->mpWindowImpl->mpNext;
     872                 :            :         }
     873                 :            :     }
     874                 :            : 
     875                 :          0 :     SetModalInputMode( bModal );
     876                 :          0 : }
     877                 :            : 
     878                 :            : // -----------------------------------------------------------------------
     879                 :            : 
     880                 :          2 : void Dialog::GrabFocusToFirstControl()
     881                 :            : {
     882                 :            :     Window* pFocusControl;
     883                 :            : 
     884                 :            :     // Wenn Dialog den Focus hat, versuchen wr trotzdem
     885                 :            :     // ein Focus-Control zu finden
     886         [ -  + ]:          2 :     if ( HasFocus() )
     887                 :          0 :         pFocusControl = NULL;
     888                 :            :     else
     889                 :            :     {
     890                 :            :         // Wenn schon ein Child-Fenster mal den Focus hatte,
     891                 :            :         // dann dieses bevorzugen
     892                 :          2 :         pFocusControl = ImplGetFirstOverlapWindow()->mpWindowImpl->mpLastFocusWindow;
     893                 :            :         // Control aus der Dialog-Steuerung suchen
     894         [ -  + ]:          2 :         if ( pFocusControl )
     895                 :          0 :             pFocusControl = ImplFindDlgCtrlWindow( pFocusControl );
     896                 :            :     }
     897                 :            :     // Kein Control hatte vorher den Focus, oder das Control
     898                 :            :     // befindet sich nicht in der Tab-Steuerung, dann das erste
     899                 :            :     // Control in der TabSteuerung den Focus geben
     900   [ -  +  #  #  :          2 :     if ( !pFocusControl ||
          #  #  #  #  #  
              # ][ +  - ]
     901                 :          0 :          !(pFocusControl->GetStyle() & WB_TABSTOP) ||
     902                 :          0 :          !pFocusControl->IsVisible() ||
     903                 :          0 :          !pFocusControl->IsEnabled() || !pFocusControl->IsInputEnabled() )
     904                 :            :     {
     905                 :          2 :         sal_uInt16 n = 0;
     906                 :          2 :         pFocusControl = ImplGetDlgWindow( n, DLGWINDOW_FIRST );
     907                 :            :     }
     908         [ -  + ]:          2 :     if ( pFocusControl )
     909                 :          0 :         pFocusControl->ImplControlFocus( GETFOCUS_INIT );
     910                 :          2 : }
     911                 :            : 
     912                 :          0 : void Dialog::GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
     913                 :            : {
     914         [ #  # ]:          0 :     ImplBorderWindow aImplWin( (Window*)this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
     915                 :            : //  aImplWin.SetText( GetText() );
     916                 :            : //  aImplWin.SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
     917                 :            : //  aImplWin.SetDisplayActive( sal_True );
     918                 :            : //  aImplWin.InitView();
     919 [ #  # ][ #  # ]:          0 :     aImplWin.GetBorder( rLeftBorder, rTopBorder, rRightBorder, rBottomBorder );
     920                 :          0 : }
     921                 :            : 
     922                 :            : 
     923                 :          0 : void Dialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong )
     924                 :            : {
     925         [ #  # ]:          0 :     Point aPos = pDev->LogicToPixel( rPos );
     926         [ #  # ]:          0 :     Size aSize = pDev->LogicToPixel( rSize );
     927                 :            : 
     928         [ #  # ]:          0 :     Wallpaper aWallpaper = GetBackground();
     929 [ #  # ][ #  # ]:          0 :     if ( !aWallpaper.IsBitmap() )
     930         [ #  # ]:          0 :         ImplInitSettings();
     931                 :            : 
     932         [ #  # ]:          0 :     pDev->Push();
     933         [ #  # ]:          0 :     pDev->SetMapMode();
     934         [ #  # ]:          0 :     pDev->SetLineColor();
     935                 :            : 
     936 [ #  # ][ #  # ]:          0 :     if ( aWallpaper.IsBitmap() )
     937 [ #  # ][ #  # ]:          0 :         pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
                 [ #  # ]
     938                 :            :     else
     939                 :            :     {
     940 [ #  # ][ #  # ]:          0 :         pDev->SetFillColor( aWallpaper.GetColor() );
     941 [ #  # ][ #  # ]:          0 :         pDev->DrawRect( Rectangle( aPos, aSize ) );
     942                 :            :     }
     943                 :            : 
     944 [ #  # ][ #  # ]:          0 :     if (!( GetStyle() & WB_NOBORDER ))
     945                 :            :     {
     946         [ #  # ]:          0 :         ImplBorderWindow aImplWin( this, WB_BORDER|WB_STDWORK, BORDERWINDOW_STYLE_OVERLAP );
     947 [ #  # ][ #  # ]:          0 :         aImplWin.SetText( GetText() );
                 [ #  # ]
     948         [ #  # ]:          0 :         aImplWin.SetPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
     949         [ #  # ]:          0 :         aImplWin.SetDisplayActive( sal_True );
     950         [ #  # ]:          0 :         aImplWin.InitView();
     951                 :            : 
     952 [ #  # ][ #  # ]:          0 :         aImplWin.Draw( Rectangle( aPos, aSize ), pDev, aPos );
                 [ #  # ]
     953                 :            :     }
     954                 :            : 
     955 [ #  # ][ #  # ]:          0 :     pDev->Pop();
     956                 :          0 : }
     957                 :            : 
     958                 :            : // -----------------------------------------------------------------------
     959                 :            : 
     960                 :          0 : ModelessDialog::ModelessDialog( Window* pParent, const ResId& rResId ) :
     961                 :          0 :     Dialog( WINDOW_MODELESSDIALOG )
     962                 :            : {
     963                 :          0 :     rResId.SetRT( RSC_MODELESSDIALOG );
     964         [ #  # ]:          0 :     WinBits nStyle = ImplInitRes( rResId );
     965         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
     966         [ #  # ]:          0 :     ImplLoadRes( rResId );
     967                 :            : 
     968         [ #  # ]:          0 :     if ( !(nStyle & WB_HIDE) )
     969         [ #  # ]:          0 :         Show();
     970                 :          0 : }
     971                 :            : 
     972                 :            : // =======================================================================
     973                 :            : 
     974                 :          0 : ModalDialog::ModalDialog( Window* pParent, WinBits nStyle ) :
     975                 :          0 :     Dialog( WINDOW_MODALDIALOG )
     976                 :            : {
     977         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
     978                 :          0 : }
     979                 :            : 
     980                 :            : // -----------------------------------------------------------------------
     981                 :            : 
     982                 :          0 : ModalDialog::ModalDialog( Window* pParent, const ResId& rResId ) :
     983                 :          0 :     Dialog( WINDOW_MODALDIALOG )
     984                 :            : {
     985                 :          0 :     rResId.SetRT( RSC_MODALDIALOG );
     986 [ #  # ][ #  # ]:          0 :     ImplInit( pParent, ImplInitRes( rResId ) );
     987         [ #  # ]:          0 :     ImplLoadRes( rResId );
     988                 :          0 : }
     989                 :            : 
     990                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10