LCOV - code coverage report
Current view: top level - libreoffice/cui/source/dialogs - dlgname.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 100 0.0 %
Date: 2012-12-27 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <tools/shl.hxx>
      21             : #include <vcl/msgbox.hxx>
      22             : 
      23             : #include <cuires.hrc>
      24             : 
      25             : #include "dlgname.hxx"
      26             : #include "defdlgname.hxx"
      27             : #include "dlgname.hrc"
      28             : #include <dialmgr.hxx>
      29             : 
      30             : #define MAX_DESCRIPTION_LINES   ((long)5)
      31             : 
      32             : /*************************************************************************
      33             : |*
      34             : |* Dialog for editing a name
      35             : |*
      36             : \************************************************************************/
      37             : 
      38           0 : SvxNameDialog::SvxNameDialog( Window* pWindow, const String& rName, const String& rDesc ) :
      39           0 :     ModalDialog     ( pWindow, CUI_RES( RID_SVXDLG_NAME ) ),
      40           0 :     aFtDescription      ( this, CUI_RES( FT_DESCRIPTION ) ),
      41           0 :     aEdtName            ( this, CUI_RES( EDT_STRING ) ),
      42           0 :     aBtnOK              ( this, CUI_RES( BTN_OK ) ),
      43           0 :     aBtnCancel          ( this, CUI_RES( BTN_CANCEL ) ),
      44           0 :     aBtnHelp            ( this, CUI_RES( BTN_HELP ) )
      45             : {
      46           0 :     FreeResource();
      47             : 
      48           0 :     aFtDescription.SetText( rDesc );
      49           0 :     aEdtName.SetText( rName );
      50           0 :     aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
      51           0 :     ModifyHdl(&aEdtName);
      52           0 :     aEdtName.SetModifyHdl(LINK(this, SvxNameDialog, ModifyHdl));
      53             : 
      54             :     // dynamic height of the description field
      55           0 :     Size aSize = aFtDescription.GetSizePixel();
      56           0 :     long nTxtWidth = aFtDescription.GetCtrlTextWidth( rDesc );
      57           0 :     if ( nTxtWidth > aSize.Width() )
      58             :     {
      59           0 :         long nLines = Min( ( nTxtWidth / aSize.Width() + 1 ), MAX_DESCRIPTION_LINES );
      60           0 :         long nHeight = aSize.Height();
      61           0 :         aSize.Height() = nHeight * nLines;
      62           0 :         aFtDescription.SetSizePixel( aSize );
      63           0 :         Point aPnt = aEdtName.GetPosPixel();
      64           0 :         aPnt.Y() += ( aSize.Height() - nHeight );
      65           0 :         aEdtName.SetPosPixel( aPnt );
      66             :     }
      67           0 : }
      68             : 
      69           0 : IMPL_LINK_NOARG(SvxNameDialog, ModifyHdl)
      70             : {
      71           0 :     if(aCheckNameHdl.IsSet())
      72           0 :         aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
      73           0 :     return 0;
      74             : }
      75             : 
      76             : ///////////////////////////////////////////////////////////////////////////////////////////////
      77             : // #i68101#
      78             : // Dialog for editing Object Name
      79             : // plus uniqueness-callback-linkHandler
      80             : 
      81           0 : SvxObjectNameDialog::SvxObjectNameDialog(
      82             :     Window* pWindow,
      83             :     const String& rName)
      84           0 : :   ModalDialog(pWindow, CUI_RES(RID_SVXDLG_OBJECT_NAME)),
      85           0 :     aFtName(this, CUI_RES(NTD_FT_NAME)),
      86           0 :     aEdtName(this, CUI_RES(NTD_EDT_NAME)),
      87           0 :     aFlSeparator(this, CUI_RES(FL_SEPARATOR_A)),
      88           0 :     aBtnHelp(this, CUI_RES(BTN_HELP)),
      89           0 :     aBtnOK(this, CUI_RES(BTN_OK)),
      90           0 :     aBtnCancel(this, CUI_RES(BTN_CANCEL))
      91             : {
      92           0 :     FreeResource();
      93             : 
      94             :     // set name
      95           0 :     aEdtName.SetText(rName);
      96             : 
      97             :     // activate name
      98           0 :     aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
      99           0 :     ModifyHdl(&aEdtName);
     100           0 :     aEdtName.SetModifyHdl(LINK(this, SvxObjectNameDialog, ModifyHdl));
     101           0 : }
     102             : 
     103           0 : IMPL_LINK_NOARG(SvxObjectNameDialog, ModifyHdl)
     104             : {
     105           0 :     if(aCheckNameHdl.IsSet())
     106             :     {
     107           0 :         aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
     108             :     }
     109             : 
     110           0 :     return 0;
     111             : }
     112             : 
     113             : ///////////////////////////////////////////////////////////////////////////////////////////////
     114             : // #i68101#
     115             : // Dialog for editing Object Title and Description
     116             : 
     117           0 : SvxObjectTitleDescDialog::SvxObjectTitleDescDialog(
     118             :     Window* pWindow,
     119             :     const String& rTitle,
     120             :     const String& rDescription)
     121           0 : :   ModalDialog(pWindow, CUI_RES(RID_SVXDLG_OBJECT_TITLE_DESC)),
     122           0 :     aFtTitle(this, CUI_RES(NTD_FT_TITLE)),
     123           0 :     aEdtTitle(this, CUI_RES(NTD_EDT_TITLE)),
     124           0 :     aFtDescription(this, CUI_RES(NTD_FT_DESC)),
     125           0 :     aEdtDescription(this, CUI_RES(NTD_EDT_DESC)),
     126           0 :     aFlSeparator(this, CUI_RES(FL_SEPARATOR_B)),
     127           0 :     aBtnHelp(this, CUI_RES(BTN_HELP)),
     128           0 :     aBtnOK(this, CUI_RES(BTN_OK)),
     129           0 :     aBtnCancel(this, CUI_RES(BTN_CANCEL))
     130             : {
     131           0 :     FreeResource();
     132             : 
     133             :     // set title & desc
     134           0 :     aEdtTitle.SetText(rTitle);
     135           0 :     aEdtDescription.SetText(rDescription);
     136             : 
     137             :     // activate title
     138           0 :     aEdtTitle.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
     139           0 : }
     140             : 
     141             : ///////////////////////////////////////////////////////////////////////////////////////////////
     142             : 
     143             : /*************************************************************************
     144             : |*
     145             : |* dialog for cancelling, saving or adding
     146             : |*
     147             : \************************************************************************/
     148             : 
     149           0 : SvxMessDialog::SvxMessDialog( Window* pWindow, const String& rText, const String& rDesc, Image* pImg ) :
     150           0 :     ModalDialog     ( pWindow, CUI_RES( RID_SVXDLG_MESSBOX ) ),
     151           0 :     aFtDescription      ( this, CUI_RES( FT_DESCRIPTION ) ),
     152           0 :     aBtn1               ( this, CUI_RES( BTN_1 ) ),
     153           0 :     aBtn2               ( this, CUI_RES( BTN_2 ) ),
     154           0 :     aBtnCancel          ( this, CUI_RES( BTN_CANCEL ) ),
     155           0 :     aFtImage            ( this )
     156             : {
     157           0 :     FreeResource();
     158             : 
     159           0 :     if( pImg )
     160             :     {
     161           0 :         pImage = new Image( *pImg );
     162           0 :         aFtImage.SetImage( *pImage );
     163           0 :         aFtImage.SetStyle( ( aFtImage.GetStyle()/* | WB_NOTABSTOP */) & ~WB_3DLOOK );
     164           0 :         aFtImage.SetPosSizePixel( LogicToPixel( Point( 3, 6 ), MAP_APPFONT ),
     165           0 :                                   aFtImage.GetImage().GetSizePixel() );
     166           0 :         aFtImage.Show();
     167             :     }
     168             : 
     169           0 :     SetText( rText );
     170           0 :     aFtDescription.SetText( rDesc );
     171             : 
     172           0 :     aBtn1.SetClickHdl( LINK( this, SvxMessDialog, Button1Hdl ) );
     173           0 :     aBtn2.SetClickHdl( LINK( this, SvxMessDialog, Button2Hdl ) );
     174           0 : }
     175             : 
     176           0 : SvxMessDialog::~SvxMessDialog()
     177             : {
     178           0 :     if( pImage )
     179           0 :         delete pImage;
     180           0 : }
     181             : 
     182             : /*************************************************************************/
     183             : 
     184           0 : IMPL_LINK_NOARG_INLINE_START(SvxMessDialog, Button1Hdl)
     185             : {
     186           0 :     EndDialog( RET_BTN_1 );
     187           0 :     return 0;
     188             : }
     189           0 : IMPL_LINK_NOARG_INLINE_END(SvxMessDialog, Button1Hdl)
     190             : 
     191             : /*************************************************************************/
     192             : 
     193           0 : IMPL_LINK_NOARG_INLINE_START(SvxMessDialog, Button2Hdl)
     194             : {
     195           0 :     EndDialog( RET_BTN_2 );
     196           0 :     return 0;
     197             : }
     198           0 : IMPL_LINK_NOARG_INLINE_END(SvxMessDialog, Button2Hdl)
     199             : 
     200             : /*************************************************************************/
     201             : 
     202           0 : void SvxMessDialog::SetButtonText( sal_uInt16 nBtnId, const String& rNewTxt )
     203             : {
     204           0 :     switch ( nBtnId )
     205             :     {
     206             :         case MESS_BTN_1:
     207           0 :             aBtn1.SetText( rNewTxt );
     208           0 :             break;
     209             : 
     210             :         case MESS_BTN_2:
     211           0 :             aBtn2.SetText( rNewTxt );
     212           0 :             break;
     213             : 
     214             :         default:
     215             :             OSL_FAIL( "Falsche Button-Nummer!!!" );
     216             :     }
     217           0 : }
     218             : 
     219             : 
     220             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10