LCOV - code coverage report
Current view: top level - vcl/source/window - msgbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 308 0.0 %
Date: 2012-08-25 Functions: 0 31 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 348 0.0 %

           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                 :            : 
      30                 :            : #include <tools/rc.h>
      31                 :            : 
      32                 :            : #include <svids.hrc>
      33                 :            : #include <svdata.hxx>
      34                 :            : #include <brdwin.hxx>
      35                 :            : #include <window.h>
      36                 :            : 
      37                 :            : #include <vcl/metric.hxx>
      38                 :            : #include <vcl/svapp.hxx>
      39                 :            : #include <vcl/wrkwin.hxx>
      40                 :            : #include <vcl/fixed.hxx>
      41                 :            : #include <vcl/vclmedit.hxx>
      42                 :            : #include <vcl/msgbox.hxx>
      43                 :            : #include <vcl/button.hxx>
      44                 :            : #include <vcl/mnemonic.hxx>
      45                 :            : 
      46                 :            : 
      47                 :            : 
      48                 :            : // =======================================================================
      49                 :            : 
      50                 :          0 : static void ImplInitMsgBoxImageList()
      51                 :            : {
      52                 :          0 :     ImplSVData* pSVData = ImplGetSVData();
      53         [ #  # ]:          0 :     if ( !pSVData->maWinData.mpMsgBoxImgList )
      54                 :            :     {
      55                 :          0 :         ResMgr* pResMgr = ImplGetResMgr();
      56         [ #  # ]:          0 :         pSVData->maWinData.mpMsgBoxImgList = new ImageList(4);
      57         [ #  # ]:          0 :         if( pResMgr )
      58                 :            :         {
      59                 :          0 :             Color aNonAlphaMask( 0xC0, 0xC0, 0xC0 );
      60                 :            :             pSVData->maWinData.mpMsgBoxImgList->InsertFromHorizontalBitmap
      61         [ #  # ]:          0 :                 ( ResId( SV_RESID_BITMAP_MSGBOX, *pResMgr ), 4, &aNonAlphaMask );
      62                 :            :         }
      63                 :            :     }
      64                 :          0 : }
      65                 :            : 
      66                 :            : // =======================================================================
      67                 :            : 
      68                 :          0 : void MessBox::ImplInitMessBoxData()
      69                 :            : {
      70                 :          0 :     mpVCLMultiLineEdit  = NULL;
      71                 :          0 :     mpFixedImage        = NULL;
      72                 :          0 :     mbHelpBtn           = sal_False;
      73                 :          0 :     mpCheckBox          = NULL;
      74                 :          0 :     mbCheck             = sal_False;
      75                 :          0 : }
      76                 :            : 
      77                 :            : // -----------------------------------------------------------------------
      78                 :            : 
      79                 :          0 : void MessBox::ImplInitButtons()
      80                 :            : {
      81                 :          0 :     WinBits nStyle = GetStyle();
      82                 :          0 :     sal_uInt16  nOKFlags = BUTTONDIALOG_OKBUTTON;
      83                 :          0 :     sal_uInt16  nCancelFlags = BUTTONDIALOG_CANCELBUTTON;
      84                 :          0 :     sal_uInt16  nRetryFlags = 0;
      85                 :          0 :     sal_uInt16  nYesFlags = 0;
      86                 :          0 :     sal_uInt16  nNoFlags = 0;
      87                 :            : 
      88         [ #  # ]:          0 :     if ( nStyle & WB_OK_CANCEL )
      89                 :            :     {
      90         [ #  # ]:          0 :         if ( nStyle & WB_DEF_CANCEL )
      91                 :          0 :             nCancelFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
      92                 :            :         else // WB_DEF_OK
      93                 :          0 :             nOKFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
      94                 :            : 
      95                 :          0 :         AddButton( BUTTON_OK, BUTTONID_OK, nOKFlags );
      96                 :          0 :         AddButton( BUTTON_CANCEL, BUTTONID_CANCEL, nCancelFlags );
      97                 :            :     }
      98         [ #  # ]:          0 :     else if ( nStyle & WB_YES_NO )
      99                 :            :     {
     100         [ #  # ]:          0 :         if ( nStyle & WB_DEF_YES )
     101                 :          0 :             nYesFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     102                 :            :         else // WB_DEF_NO
     103                 :          0 :             nNoFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     104                 :          0 :         nNoFlags |= BUTTONDIALOG_CANCELBUTTON;
     105                 :            : 
     106                 :          0 :         AddButton( BUTTON_YES, BUTTONID_YES, nYesFlags );
     107                 :          0 :         AddButton( BUTTON_NO, BUTTONID_NO, nNoFlags );
     108                 :            :     }
     109         [ #  # ]:          0 :     else if ( nStyle & WB_YES_NO_CANCEL )
     110                 :            :     {
     111         [ #  # ]:          0 :         if ( nStyle & WB_DEF_YES )
     112                 :          0 :             nYesFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     113         [ #  # ]:          0 :         else if ( nStyle & WB_DEF_NO )
     114                 :          0 :             nNoFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     115                 :            :         else
     116                 :          0 :             nCancelFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     117                 :            : 
     118                 :          0 :         AddButton( BUTTON_YES, BUTTONID_YES, nYesFlags );
     119                 :          0 :         AddButton( BUTTON_NO, BUTTONID_NO, nNoFlags );
     120                 :          0 :         AddButton( BUTTON_CANCEL, BUTTONID_CANCEL, nCancelFlags );
     121                 :            :     }
     122         [ #  # ]:          0 :     else if ( nStyle & WB_RETRY_CANCEL )
     123                 :            :     {
     124         [ #  # ]:          0 :         if ( nStyle & WB_DEF_CANCEL )
     125                 :          0 :             nCancelFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     126                 :            :         else // WB_DEF_RETRY
     127                 :          0 :             nRetryFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     128                 :            : 
     129                 :          0 :         AddButton( BUTTON_RETRY, BUTTONID_RETRY, nRetryFlags );
     130                 :          0 :         AddButton( BUTTON_CANCEL, BUTTONID_CANCEL, nCancelFlags );
     131                 :            :     }
     132         [ #  # ]:          0 :     else if ( nStyle & WB_ABORT_RETRY_IGNORE )
     133                 :            :     {
     134                 :          0 :         sal_uInt16 nAbortFlags = 0;
     135                 :          0 :         sal_uInt16 nIgnoreFlags = 0;
     136                 :            : 
     137         [ #  # ]:          0 :         if ( nStyle & WB_DEF_CANCEL )
     138                 :          0 :             nAbortFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     139         [ #  # ]:          0 :         else if ( nStyle & WB_DEF_RETRY )
     140                 :          0 :             nRetryFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     141         [ #  # ]:          0 :         else if ( nStyle & WB_DEF_IGNORE )
     142                 :          0 :             nIgnoreFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     143                 :            : 
     144                 :          0 :         AddButton( BUTTON_ABORT, BUTTONID_CANCEL, nAbortFlags );
     145                 :          0 :         AddButton( BUTTON_RETRY, BUTTONID_RETRY, nRetryFlags );
     146                 :          0 :         AddButton( BUTTON_IGNORE, BUTTONID_IGNORE, nIgnoreFlags );
     147                 :            :     }
     148         [ #  # ]:          0 :     else if ( nStyle & WB_OK )
     149                 :            :     {
     150                 :          0 :         nOKFlags |= BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON;
     151                 :            : 
     152                 :          0 :         AddButton( BUTTON_OK, BUTTONID_OK, nOKFlags );
     153                 :            :     }
     154                 :          0 : }
     155                 :            : 
     156                 :            : // -----------------------------------------------------------------------
     157                 :            : 
     158                 :          0 : MessBox::MessBox( Window* pParent, WinBits nStyle,
     159                 :            :                   const XubString& rTitle, const XubString& rMessage ) :
     160                 :            :     ButtonDialog( WINDOW_MESSBOX ),
     161 [ #  # ][ #  # ]:          0 :     maMessText( rMessage )
                 [ #  # ]
     162                 :            : {
     163                 :          0 :     ImplInitMessBoxData();
     164         [ #  # ]:          0 :     ImplInit( pParent, nStyle | WB_MOVEABLE | WB_HORZ | WB_CENTER );
     165         [ #  # ]:          0 :     ImplInitButtons();
     166                 :            : 
     167         [ #  # ]:          0 :     if ( rTitle.Len() )
     168         [ #  # ]:          0 :         SetText( rTitle );
     169                 :          0 : }
     170                 :            : 
     171                 :            : // -----------------------------------------------------------------------
     172                 :            : 
     173                 :          0 : MessBox::MessBox( Window* pParent, const ResId& rResId ) :
     174 [ #  # ][ #  # ]:          0 :     ButtonDialog( WINDOW_MESSBOX )
                 [ #  # ]
     175                 :            : {
     176                 :          0 :     ImplInitMessBoxData();
     177                 :            : 
     178         [ #  # ]:          0 :     GetRes( rResId.SetRT( RSC_MESSBOX ) );
     179         [ #  # ]:          0 :     sal_uInt16 nHiButtons   = ReadShortRes();
     180         [ #  # ]:          0 :     sal_uInt16 nLoButtons   = ReadShortRes();
     181         [ #  # ]:          0 :     sal_uInt16 nHiDefButton = ReadShortRes();
     182         [ #  # ]:          0 :     sal_uInt16 nLoDefButton = ReadShortRes();
     183         [ #  # ]:          0 :     rtl::OString aHelpId( ReadByteStringRes() );
     184         [ #  # ]:          0 :     /* sal_uInt16 bSysModal = */ ReadShortRes();
     185         [ #  # ]:          0 :     SetHelpId( aHelpId );
     186                 :            :     WinBits nBits = (((sal_uLong)nHiButtons << 16) + nLoButtons) |
     187                 :          0 :                     (((sal_uLong)nHiDefButton << 16) + nLoDefButton);
     188         [ #  # ]:          0 :     ImplInit( pParent, nBits | WB_MOVEABLE | WB_HORZ | WB_CENTER );
     189                 :            : 
     190         [ #  # ]:          0 :     ImplLoadRes( rResId );
     191         [ #  # ]:          0 :     ImplInitButtons();
     192                 :          0 : }
     193                 :            : 
     194                 :            : // -----------------------------------------------------------------------
     195                 :            : 
     196                 :          0 : void MessBox::ImplLoadRes( const ResId& )
     197                 :            : {
     198 [ #  # ][ #  # ]:          0 :     SetText(     ReadStringRes() );
                 [ #  # ]
     199 [ #  # ][ #  # ]:          0 :     SetMessText( ReadStringRes() );
                 [ #  # ]
     200 [ #  # ][ #  # ]:          0 :     SetHelpText( ReadStringRes() );
                 [ #  # ]
     201                 :          0 : }
     202                 :            : 
     203                 :            : // -----------------------------------------------------------------------
     204                 :            : 
     205 [ #  # ][ #  # ]:          0 : MessBox::~MessBox()
                 [ #  # ]
     206                 :            : {
     207 [ #  # ][ #  # ]:          0 :     delete mpVCLMultiLineEdit;
     208 [ #  # ][ #  # ]:          0 :     delete mpFixedImage;
     209 [ #  # ][ #  # ]:          0 :     delete mpCheckBox;
     210         [ #  # ]:          0 : }
     211                 :            : 
     212                 :            : // -----------------------------------------------------------------------
     213                 :            : 
     214                 :          0 : void MessBox::ImplPosControls()
     215                 :            : {
     216 [ #  # ][ #  # ]:          0 :     if ( !GetHelpId().isEmpty() )
     217                 :            :     {
     218         [ #  # ]:          0 :         if ( !mbHelpBtn )
     219                 :            :         {
     220         [ #  # ]:          0 :             AddButton( BUTTON_HELP, BUTTONID_HELP, BUTTONDIALOG_HELPBUTTON, 3 );
     221                 :          0 :             mbHelpBtn = sal_True;
     222                 :            :         }
     223                 :            :     }
     224                 :            :     else
     225                 :            :     {
     226         [ #  # ]:          0 :         if ( mbHelpBtn )
     227                 :            :         {
     228         [ #  # ]:          0 :             RemoveButton( BUTTONID_HELP );
     229                 :          0 :             mbHelpBtn = sal_False;
     230                 :            :         }
     231                 :            :     }
     232                 :            : 
     233         [ #  # ]:          0 :     XubString       aMessText( maMessText );
     234         [ #  # ]:          0 :     TextRectInfo    aTextInfo;
     235         [ #  # ]:          0 :     Rectangle       aRect( 0, 0, 30000, 30000 );
     236         [ #  # ]:          0 :     Rectangle       aFormatRect;
     237                 :          0 :     Point           aTextPos( IMPL_DIALOG_OFFSET, IMPL_DIALOG_OFFSET+IMPL_MSGBOX_OFFSET_EXTRA_Y );
     238                 :          0 :     Size            aImageSize;
     239                 :          0 :     Size            aPageSize;
     240                 :          0 :     Size            aMEditSize;
     241                 :            :     long            nTitleWidth;
     242         [ #  # ]:          0 :     long            nButtonSize = ImplGetButtonSize();
     243 [ #  # ][ #  # ]:          0 :     long            nMaxWidth = GetDesktopRectPixel().GetWidth()-8;
     244                 :            :     long            nMaxLineWidth;
     245                 :            :     long            nWidth;
     246                 :          0 :     WinBits         nWinStyle = WB_LEFT | WB_WORDBREAK | WB_NOLABEL;
     247                 :          0 :     sal_uInt16          nTextStyle = TEXT_DRAW_MULTILINE | TEXT_DRAW_TOP | TEXT_DRAW_LEFT;
     248                 :            : 
     249 [ #  # ][ #  # ]:          0 :     delete mpVCLMultiLineEdit;
     250         [ #  # ]:          0 :     if ( mpFixedImage )
     251                 :            :     {
     252 [ #  # ][ #  # ]:          0 :         delete mpFixedImage;
     253                 :          0 :         mpFixedImage = NULL;
     254                 :            :     }
     255         [ #  # ]:          0 :     if ( mpCheckBox )
     256                 :            :     {
     257         [ #  # ]:          0 :         mbCheck = mpCheckBox->IsChecked();
     258 [ #  # ][ #  # ]:          0 :         delete mpCheckBox;
     259                 :          0 :         mpCheckBox = NULL;
     260                 :            :     }
     261                 :            : 
     262                 :            : 
     263                 :            :     // Message-Text um Tabs bereinigen
     264                 :          0 :     rtl::OUString   aTabStr("    ");
     265                 :          0 :     sal_uInt16      nIndex = 0;
     266         [ #  # ]:          0 :     while ( nIndex != STRING_NOTFOUND )
     267 [ #  # ][ #  # ]:          0 :         nIndex = aMessText.SearchAndReplace( rtl::OUString('\t'), aTabStr, nIndex );
         [ #  # ][ #  # ]
                 [ #  # ]
     268                 :            : 
     269                 :            :     // Wenn Fenster zu schmall, machen wir Dialog auch breiter
     270         [ #  # ]:          0 :     if ( mpWindowImpl->mbFrame )
     271                 :          0 :         nMaxWidth = 630;
     272         [ #  # ]:          0 :     else if ( nMaxWidth < 120 )
     273                 :          0 :         nMaxWidth = 120;
     274                 :            : 
     275                 :          0 :     nMaxWidth -= mpWindowImpl->mnLeftBorder+mpWindowImpl->mnRightBorder+4;
     276                 :            : 
     277                 :            :     // MessageBox sollte min. so breit sein, das auch Title sichtbar ist
     278                 :            :     // Extra-Width for Closer, because Closer is set after this call
     279         [ #  # ]:          0 :     nTitleWidth = CalcTitleWidth();
     280                 :          0 :     nTitleWidth += mpWindowImpl->mnTopBorder;
     281                 :            : 
     282                 :          0 :     nMaxWidth -= (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2);
     283                 :            : 
     284                 :            :     // Wenn wir ein Image haben, dann deren Groesse ermitteln und das
     285                 :            :     // entsprechende Control anlegen und positionieren
     286         [ #  # ]:          0 :     aImageSize = maImage.GetSizePixel();
     287         [ #  # ]:          0 :     if ( aImageSize.Width() )
     288                 :            :     {
     289                 :          0 :         aImageSize.Width()  += 4;
     290                 :          0 :         aImageSize.Height() += 4;
     291                 :          0 :         aTextPos.X() += aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE;
     292 [ #  # ][ #  # ]:          0 :         mpFixedImage = new FixedImage( this );
     293                 :            :         mpFixedImage->SetPosSizePixel( Point( IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_X,
     294                 :            :                                               IMPL_DIALOG_OFFSET-2+IMPL_MSGBOX_OFFSET_EXTRA_Y ),
     295         [ #  # ]:          0 :                                        aImageSize );
     296         [ #  # ]:          0 :         mpFixedImage->SetImage( maImage );
     297         [ #  # ]:          0 :         mpFixedImage->Show();
     298                 :          0 :         nMaxWidth -= aImageSize.Width()+IMPL_SEP_MSGBOX_IMAGE;
     299                 :            :     }
     300                 :            :     else
     301                 :          0 :         aTextPos.X() += IMPL_MSGBOX_OFFSET_EXTRA_X;
     302                 :            : 
     303                 :            :     // Maximale Zeilenlaenge ohne Wordbreak ermitteln
     304         [ #  # ]:          0 :     aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo );
     305         [ #  # ]:          0 :     nMaxLineWidth = aFormatRect.GetWidth();
     306                 :          0 :     nTextStyle |= TEXT_DRAW_WORDBREAK;
     307                 :            : 
     308                 :            :     // Breite fuer Textformatierung ermitteln
     309         [ #  # ]:          0 :     if ( nMaxLineWidth > 450 )
     310                 :          0 :         nWidth = 450;
     311         [ #  # ]:          0 :     else if ( nMaxLineWidth > 300 )
     312                 :          0 :         nWidth = nMaxLineWidth+5;
     313                 :            :     else
     314                 :          0 :         nWidth = 300;
     315         [ #  # ]:          0 :     if ( nButtonSize > nWidth )
     316                 :          0 :         nWidth = nButtonSize-(aTextPos.X()-IMPL_DIALOG_OFFSET);
     317         [ #  # ]:          0 :     if ( nWidth > nMaxWidth )
     318                 :          0 :         nWidth = nMaxWidth;
     319                 :            : 
     320                 :          0 :     aRect.Right() = nWidth;
     321         [ #  # ]:          0 :     aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo );
     322         [ #  # ]:          0 :     if ( aTextInfo.GetMaxLineWidth() > nWidth )
     323                 :            :     {
     324                 :          0 :         nWidth = aTextInfo.GetMaxLineWidth()+8;
     325                 :          0 :         aRect.Right() = nWidth;
     326         [ #  # ]:          0 :         aFormatRect = GetTextRect( aRect, aMessText, nTextStyle, &aTextInfo );
     327                 :            :     }
     328                 :            : 
     329                 :            :     // Style fuer VCLMultiLineEdit ermitteln
     330                 :          0 :     aMEditSize.Width()  = aTextInfo.GetMaxLineWidth()+1;
     331         [ #  # ]:          0 :     aMEditSize.Height() = aFormatRect.GetHeight();
     332                 :          0 :     aPageSize.Width()   = aImageSize.Width();
     333         [ #  # ]:          0 :     if ( aMEditSize.Height() < aImageSize.Height() )
     334                 :            :     {
     335                 :          0 :         nWinStyle |= WB_VCENTER;
     336                 :          0 :         aPageSize.Height()  = aImageSize.Height();
     337                 :          0 :         aMEditSize.Height() = aImageSize.Height();
     338                 :            :     }
     339                 :            :     else
     340                 :            :     {
     341                 :          0 :         nWinStyle |= WB_TOP;
     342                 :          0 :         aPageSize.Height()  = aMEditSize.Height();
     343                 :            :     }
     344         [ #  # ]:          0 :     if ( aImageSize.Width() )
     345                 :          0 :         aPageSize.Width() += IMPL_SEP_MSGBOX_IMAGE;
     346                 :          0 :     aPageSize.Width()  += (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_X*2);
     347                 :          0 :     aPageSize.Width()  += aMEditSize.Width()+1;
     348                 :          0 :     aPageSize.Height() += (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2);
     349                 :            : 
     350         [ #  # ]:          0 :     if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH )
     351                 :          0 :         aPageSize.Width() = IMPL_MINSIZE_MSGBOX_WIDTH;
     352         [ #  # ]:          0 :     if ( aPageSize.Width() < nTitleWidth )
     353                 :          0 :         aPageSize.Width() = nTitleWidth;
     354                 :            : 
     355         [ #  # ]:          0 :     if ( maCheckBoxText.Len() )
     356                 :            :     {
     357                 :          0 :         Size aMinCheckboxSize ( aMEditSize );
     358         [ #  # ]:          0 :         if ( aPageSize.Width() < IMPL_MINSIZE_MSGBOX_WIDTH+80 )
     359                 :            :         {
     360                 :          0 :             aPageSize.Width() = IMPL_MINSIZE_MSGBOX_WIDTH+80;
     361                 :          0 :             aMinCheckboxSize.Width() += 80;
     362                 :            :         }
     363                 :            : 
     364                 :            :         // #104492# auto mnemonics for CJK strings may increase the length, so measure the
     365                 :            :         // checkbox length including a temporary mnemonic, the correct auto mnemonic will be
     366                 :            :         // generated later in the dialog (see init_show)
     367                 :            : 
     368         [ #  # ]:          0 :         String aMnemonicString( maCheckBoxText );
     369         [ #  # ]:          0 :         if( GetSettings().GetStyleSettings().GetAutoMnemonic() )
     370                 :            :         {
     371 [ #  # ][ #  # ]:          0 :             if( aMnemonicString == GetNonMnemonicString( maCheckBoxText ) )
         [ #  # ][ #  # ]
     372                 :            :             {
     373                 :            :                 // no mnemonic found -> create one
     374         [ #  # ]:          0 :                 MnemonicGenerator aMnemonicGenerator;
     375 [ #  # ][ #  # ]:          0 :                 aMnemonicGenerator.CreateMnemonic( aMnemonicString );
     376                 :            :             }
     377                 :            :         }
     378                 :            : 
     379 [ #  # ][ #  # ]:          0 :         mpCheckBox = new CheckBox( this );
     380         [ #  # ]:          0 :         mpCheckBox->Check( mbCheck );
     381         [ #  # ]:          0 :         mpCheckBox->SetText( aMnemonicString );
     382 [ #  # ][ #  # ]:          0 :         mpCheckBox->SetStyle( mpCheckBox->GetStyle() | WB_WORDBREAK );
     383 [ #  # ][ #  # ]:          0 :         mpCheckBox->SetHelpId( GetHelpId() );   // DR: Check box and dialog have same HID
     384                 :            : 
     385                 :            :         // align checkbox with message text
     386         [ #  # ]:          0 :         Size aSize = mpCheckBox->CalcMinimumSize( aMinCheckboxSize.Width() );
     387                 :            : 
     388                 :            :         // now set the original non-mnemonic string
     389         [ #  # ]:          0 :         mpCheckBox->SetText( maCheckBoxText );
     390                 :            : 
     391                 :          0 :         Point aPos( aTextPos );
     392                 :          0 :         aPos.Y() += aMEditSize.Height() + (IMPL_DIALOG_OFFSET)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2);
     393                 :            : 
     394                 :            :         // increase messagebox
     395                 :          0 :         aPageSize.Height() += aSize.Height() + (IMPL_DIALOG_OFFSET*2)+(IMPL_MSGBOX_OFFSET_EXTRA_Y*2);
     396                 :            : 
     397         [ #  # ]:          0 :         mpCheckBox->SetPosSizePixel( aPos, aSize );
     398 [ #  # ][ #  # ]:          0 :         mpCheckBox->Show();
     399                 :            :     }
     400                 :            : 
     401 [ #  # ][ #  # ]:          0 :     mpVCLMultiLineEdit = new VCLMultiLineEdit( this, nWinStyle );
     402         [ #  # ]:          0 :     mpVCLMultiLineEdit->SetText( aMessText );
     403         [ #  # ]:          0 :     mpVCLMultiLineEdit->SetPosSizePixel( aTextPos, aMEditSize );
     404         [ #  # ]:          0 :     mpVCLMultiLineEdit->Show();
     405         [ #  # ]:          0 :     mpVCLMultiLineEdit->SetPaintTransparent(sal_True);
     406         [ #  # ]:          0 :     SetPageSizePixel( aPageSize );
     407                 :          0 : }
     408                 :            : 
     409                 :            : // -----------------------------------------------------------------------
     410                 :            : 
     411                 :          0 : void MessBox::StateChanged( StateChangedType nType )
     412                 :            : {
     413         [ #  # ]:          0 :     if ( nType == STATE_CHANGE_INITSHOW )
     414                 :            :     {
     415                 :          0 :         ImplPosControls();
     416                 :            :     }
     417                 :          0 :     ButtonDialog::StateChanged( nType );
     418                 :          0 : }
     419                 :            : 
     420                 :            : // -----------------------------------------------------------------------
     421                 :            : 
     422                 :          0 : sal_Bool MessBox::GetCheckBoxState() const
     423                 :            : {
     424         [ #  # ]:          0 :     return mpCheckBox ? mpCheckBox->IsChecked() : mbCheck;
     425                 :            : }
     426                 :            : 
     427                 :            : // -----------------------------------------------------------------------
     428                 :            : 
     429                 :          0 : void MessBox::SetCheckBoxState( sal_Bool bCheck )
     430                 :            : {
     431         [ #  # ]:          0 :     if( mpCheckBox ) mpCheckBox->Check( bCheck );
     432                 :          0 :     mbCheck = bCheck;
     433                 :          0 : }
     434                 :            : 
     435                 :            : // -----------------------------------------------------------------------
     436                 :            : 
     437                 :          0 : Size MessBox::GetOptimalSize(WindowSizeType eType) const
     438                 :            : {
     439         [ #  # ]:          0 :     switch( eType ) {
     440                 :            :     case WINDOWSIZE_MINIMUM:
     441                 :            :         // FIXME: base me on the font size ?
     442                 :          0 :         return Size( 250, 100 );
     443                 :            :     default:
     444                 :          0 :         return Window::GetOptimalSize( eType );
     445                 :            :     }
     446                 :            : }
     447                 :            : 
     448                 :            : // ============================================================================
     449                 :            : 
     450                 :          0 : void InfoBox::ImplInitInfoBoxData()
     451                 :            : {
     452                 :            :     // Default Text is the display title from the application
     453         [ #  # ]:          0 :     if ( !GetText().Len() )
     454         [ #  # ]:          0 :         SetText( Application::GetDisplayName() );
     455                 :            : 
     456         [ #  # ]:          0 :     SetImage( InfoBox::GetStandardImage() );
     457                 :          0 : }
     458                 :            : 
     459                 :            : // -----------------------------------------------------------------------
     460                 :            : 
     461                 :          0 : InfoBox::InfoBox( Window* pParent, const XubString& rMessage ) :
     462                 :          0 :     MessBox( pParent, WB_OK | WB_DEF_OK, ImplGetSVEmptyStr(), rMessage )
     463                 :            : {
     464         [ #  # ]:          0 :     ImplInitInfoBoxData();
     465                 :          0 : }
     466                 :            : 
     467                 :            : // -----------------------------------------------------------------------
     468                 :            : 
     469                 :          0 : InfoBox::InfoBox( Window* pParent, const ResId & rResId ) :
     470                 :          0 :     MessBox( pParent, rResId.SetRT( RSC_INFOBOX ) )
     471                 :            : {
     472         [ #  # ]:          0 :     ImplInitInfoBoxData();
     473                 :          0 : }
     474                 :            : 
     475                 :            : // -----------------------------------------------------------------------
     476                 :            : 
     477                 :          0 : Image InfoBox::GetStandardImage()
     478                 :            : {
     479                 :          0 :     ImplInitMsgBoxImageList();
     480                 :          0 :     return ImplGetSVData()->maWinData.mpMsgBoxImgList->GetImage( 4 );
     481                 :            : }
     482                 :            : 
     483                 :            : // ============================================================================
     484                 :            : 
     485                 :          0 : void WarningBox::ImplInitWarningBoxData()
     486                 :            : {
     487                 :            :     // Default Text is the display title from the application
     488         [ #  # ]:          0 :     if ( !GetText().Len() )
     489         [ #  # ]:          0 :         SetText( Application::GetDisplayName() );
     490                 :            : 
     491         [ #  # ]:          0 :     SetImage( WarningBox::GetStandardImage() );
     492                 :          0 : }
     493                 :            : 
     494                 :            : // -----------------------------------------------------------------------
     495                 :            : 
     496                 :          0 : WarningBox::WarningBox( Window* pParent, WinBits nStyle,
     497                 :            :                         const XubString& rMessage ) :
     498                 :          0 :     MessBox( pParent, nStyle, ImplGetSVEmptyStr(), rMessage )
     499                 :            : {
     500         [ #  # ]:          0 :     ImplInitWarningBoxData();
     501                 :          0 : }
     502                 :            : 
     503                 :            : // -----------------------------------------------------------------------
     504                 :            : 
     505                 :          0 : WarningBox::WarningBox( Window* pParent, const ResId& rResId ) :
     506                 :          0 :     MessBox( pParent, rResId.SetRT( RSC_WARNINGBOX ) )
     507                 :            : {
     508         [ #  # ]:          0 :     ImplInitWarningBoxData();
     509                 :          0 : }
     510                 :            : 
     511                 :            : // -----------------------------------------------------------------------
     512                 :            : 
     513                 :          0 : void WarningBox::SetDefaultCheckBoxText()
     514                 :            : {
     515                 :          0 :     ResMgr* pResMgr = ImplGetResMgr();
     516         [ #  # ]:          0 :     if( pResMgr )
     517 [ #  # ][ #  # ]:          0 :         maCheckBoxText = ResId(SV_STDTEXT_DONTWARNAGAIN, *pResMgr).toString();
     518                 :          0 : }
     519                 :            : 
     520                 :            : // -----------------------------------------------------------------------
     521                 :            : 
     522                 :          0 : Image WarningBox::GetStandardImage()
     523                 :            : {
     524                 :          0 :     ImplInitMsgBoxImageList();
     525                 :          0 :     return ImplGetSVData()->maWinData.mpMsgBoxImgList->GetImage( 3 );
     526                 :            : }
     527                 :            : 
     528                 :            : // ============================================================================
     529                 :            : 
     530                 :          0 : void ErrorBox::ImplInitErrorBoxData()
     531                 :            : {
     532                 :            :     // Default Text is the display title from the application
     533         [ #  # ]:          0 :     if ( !GetText().Len() )
     534         [ #  # ]:          0 :         SetText( Application::GetDisplayName() );
     535                 :            : 
     536         [ #  # ]:          0 :     SetImage( ErrorBox::GetStandardImage() );
     537                 :          0 : }
     538                 :            : 
     539                 :            : // -----------------------------------------------------------------------
     540                 :            : 
     541                 :          0 : ErrorBox::ErrorBox( Window* pParent, WinBits nStyle,
     542                 :            :                     const XubString& rMessage ) :
     543                 :          0 :     MessBox( pParent, nStyle, ImplGetSVEmptyStr(), rMessage )
     544                 :            : {
     545         [ #  # ]:          0 :     ImplInitErrorBoxData();
     546                 :          0 : }
     547                 :            : 
     548                 :            : // -----------------------------------------------------------------------
     549                 :            : 
     550                 :          0 : ErrorBox::ErrorBox( Window* pParent, const ResId& rResId ) :
     551                 :          0 :     MessBox( pParent, rResId.SetRT( RSC_ERRORBOX ) )
     552                 :            : {
     553         [ #  # ]:          0 :     ImplInitErrorBoxData();
     554                 :          0 : }
     555                 :            : 
     556                 :            : // -----------------------------------------------------------------------
     557                 :            : 
     558                 :          0 : Image ErrorBox::GetStandardImage()
     559                 :            : {
     560                 :            :     try
     561                 :            :     {
     562         [ #  # ]:          0 :         ImplInitMsgBoxImageList();
     563                 :            :     }
     564         [ #  # ]:          0 :     catch (const ::com::sun::star::uno::Exception &)
     565                 :            :     {
     566                 :            :         // During early bootstrap we can have no initialized
     567                 :            :         // ucb and hence no ability to get this image, so nop.
     568         [ #  # ]:          0 :         return Image();
     569                 :            :     }
     570                 :          0 :     return ImplGetSVData()->maWinData.mpMsgBoxImgList->GetImage( 1 );
     571                 :            : }
     572                 :            : 
     573                 :            : // ============================================================================
     574                 :            : 
     575                 :          0 : void QueryBox::ImplInitQueryBoxData()
     576                 :            : {
     577                 :            :     // Default Text is the display title from the application
     578         [ #  # ]:          0 :     if ( !GetText().Len() )
     579         [ #  # ]:          0 :         SetText( Application::GetDisplayName() );
     580                 :            : 
     581         [ #  # ]:          0 :     SetImage( QueryBox::GetStandardImage() );
     582                 :          0 : }
     583                 :            : 
     584                 :            : // -----------------------------------------------------------------------
     585                 :            : 
     586                 :          0 : QueryBox::QueryBox( Window* pParent, WinBits nStyle, const XubString& rMessage ) :
     587                 :          0 :     MessBox( pParent, nStyle, ImplGetSVEmptyStr(), rMessage )
     588                 :            : {
     589         [ #  # ]:          0 :     ImplInitQueryBoxData();
     590                 :          0 : }
     591                 :            : 
     592                 :            : // -----------------------------------------------------------------------
     593                 :            : 
     594                 :          0 : QueryBox::QueryBox( Window* pParent, const ResId& rResId ) :
     595                 :          0 :     MessBox( pParent, rResId.SetRT( RSC_QUERYBOX ) )
     596                 :            : {
     597         [ #  # ]:          0 :     ImplInitQueryBoxData();
     598                 :          0 : }
     599                 :            : 
     600                 :            : // -----------------------------------------------------------------------
     601                 :            : 
     602                 :          0 : void QueryBox::SetDefaultCheckBoxText()
     603                 :            : {
     604                 :          0 :     ResMgr* pResMgr = ImplGetResMgr();
     605         [ #  # ]:          0 :     if( pResMgr )
     606 [ #  # ][ #  # ]:          0 :         maCheckBoxText = ResId(SV_STDTEXT_DONTASKAGAIN, *pResMgr).toString();
     607                 :          0 : }
     608                 :            : 
     609                 :            : // -----------------------------------------------------------------------
     610                 :            : 
     611                 :          0 : Image QueryBox::GetStandardImage()
     612                 :            : {
     613                 :          0 :     ImplInitMsgBoxImageList();
     614                 :          0 :     return ImplGetSVData()->maWinData.mpMsgBoxImgList->GetImage( 2 );
     615                 :            : }
     616                 :            : 
     617                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10