LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - newdatatype.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 27 0.0 %
Date: 2012-08-25 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : #include "newdatatype.hxx"
      30                 :            : #include "newdatatype.hrc"
      31                 :            : 
      32                 :            : #include "modulepcr.hxx"
      33                 :            : #include "formresid.hrc"
      34                 :            : 
      35                 :            : //........................................................................
      36                 :            : namespace pcr
      37                 :            : {
      38                 :            : //........................................................................
      39                 :            : 
      40                 :            :     //====================================================================
      41                 :            :     //= NewDataTypeDialog
      42                 :            :     //====================================================================
      43                 :            :     //--------------------------------------------------------------------
      44                 :          0 :     NewDataTypeDialog::NewDataTypeDialog( Window* _pParent, const ::rtl::OUString& _rNameBase, const ::std::vector< ::rtl::OUString >& _rProhibitedNames )
      45                 :            :         :ModalDialog( _pParent, PcrRes( RID_DLG_NEW_DATA_TYPE ) )
      46                 :            :         ,m_aLabel   ( this, PcrRes( FT_LABEL  ) )
      47                 :            :         ,m_aName    ( this, PcrRes( ED_NAME   ) )
      48                 :            :         ,m_aOK      ( this, PcrRes( PB_OK     ) )
      49                 :            :         ,m_aCancel  ( this, PcrRes( PB_CANCEL ) )
      50                 :          0 :         ,m_aProhibitedNames( _rProhibitedNames.begin(), _rProhibitedNames.end() )
      51                 :            :     {
      52                 :          0 :         FreeResource();
      53                 :            : 
      54                 :          0 :         m_aName.SetModifyHdl( LINK( this, NewDataTypeDialog, OnNameModified ) );
      55                 :            : 
      56                 :            :         // find an initial name
      57                 :            :         // for this, first remove trailing digits
      58                 :          0 :         sal_Int32 nStripUntil = _rNameBase.getLength();
      59                 :          0 :         while ( nStripUntil > 0 )
      60                 :            :         {
      61                 :          0 :             sal_Unicode nChar = _rNameBase[ --nStripUntil ];
      62                 :          0 :             if ( ( nChar < '0' ) || ( nChar > '9' ) )
      63                 :            :             {
      64                 :          0 :                 if ( nChar == ' ' )
      65                 :          0 :                     --nStripUntil;  // strip the space, too
      66                 :          0 :                 break;
      67                 :            :             }
      68                 :            :         }
      69                 :            : 
      70                 :          0 :         String sNameBase( _rNameBase.copy( 0, nStripUntil ? nStripUntil + 1 : 0 ) );
      71                 :          0 :         sNameBase.Append( ' ' );
      72                 :          0 :         String sInitialName;
      73                 :          0 :         sal_Int32 nPostfixNumber = 1;
      74                 :          0 :         do
      75                 :            :         {
      76                 :          0 :             ( sInitialName = sNameBase ) += rtl::OUString::valueOf(nPostfixNumber++);
      77                 :            :         }
      78                 :          0 :         while ( m_aProhibitedNames.find( sInitialName ) != m_aProhibitedNames.end() );
      79                 :            : 
      80                 :          0 :         m_aName.SetText( sInitialName );
      81                 :          0 :         OnNameModified( NULL );
      82                 :          0 :     }
      83                 :            : 
      84                 :            :     //--------------------------------------------------------------------
      85                 :          0 :     IMPL_LINK( NewDataTypeDialog, OnNameModified, void*, /*_pNotInterestedIn*/ )
      86                 :            :     {
      87                 :          0 :         String sCurrentName = GetName();
      88                 :          0 :         bool bNameIsOK = ( sCurrentName.Len() > 0 )
      89                 :          0 :                       && ( m_aProhibitedNames.find( sCurrentName ) == m_aProhibitedNames.end() );
      90                 :            : 
      91                 :          0 :         m_aOK.Enable( bNameIsOK );
      92                 :            : 
      93                 :          0 :         return 0L;
      94                 :            :     }
      95                 :            : 
      96                 :            : //........................................................................
      97                 :            : } // namespace pcr
      98                 :            : //........................................................................
      99                 :            : 
     100                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10