LCOV - code coverage report
Current view: top level - dbaccess/source/ui/control - SqlNameEdit.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 41 0.0 %
Date: 2014-04-14 Functions: 0 6 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 "SqlNameEdit.hxx"
      21             : #include <vcl/builder.hxx>
      22             : 
      23             : namespace dbaui
      24             : {
      25           0 :     sal_Bool isCharOk(sal_Unicode _cChar,sal_Bool _bFirstChar,sal_Bool _bUpperCase,const OUString& _sAllowedChars)
      26             :     {
      27             :         return  (
      28           0 :                  (_cChar >= 'A' && _cChar <= 'Z') ||
      29           0 :                  _cChar == '_' ||
      30           0 :                  _sAllowedChars.indexOf(_cChar) != -1 ||
      31           0 :                  (!_bFirstChar && (_cChar >= '0' && _cChar <= '9')) ||
      32           0 :                  (!_bUpperCase && (_cChar >= 'a' && _cChar <= 'z'))
      33           0 :                 );
      34             :     }
      35           0 :     sal_Bool OSQLNameChecker::checkString(const OUString& _sToCheck,
      36             :                                         OUString& _rsCorrected)
      37             :     {
      38           0 :         sal_Bool bCorrected = sal_False;
      39           0 :         if ( m_bCheck )
      40             :         {
      41           0 :             OUString sText = _sToCheck;
      42           0 :             sal_Int32 nMatch = 0;
      43           0 :             for (sal_Int32 i = nMatch; i < sText.getLength(); ++i)
      44             :             {
      45           0 :                 if ( !isCharOk( sText[i], i == 0, m_bOnlyUpperCase, m_sAllowedChars ) )
      46             :                 {
      47           0 :                     _rsCorrected += sText.copy(nMatch, i - nMatch);
      48           0 :                     bCorrected = sal_True;
      49           0 :                     nMatch = i + 1;
      50             :                 }
      51             :             }
      52           0 :             _rsCorrected += sText.copy( nMatch, sText.getLength() - nMatch );
      53             :         }
      54           0 :         return bCorrected;
      55             :     }
      56           0 :     void OSQLNameEdit::Modify()
      57             :     {
      58           0 :         OUString sCorrected;
      59           0 :         if ( checkString( GetText(),sCorrected ) )
      60             :         {
      61           0 :             Selection aSel = GetSelection();
      62           0 :             aSel.setMax( aSel.getMin() );
      63           0 :             SetText( sCorrected, aSel );
      64             : 
      65           0 :             SaveValue();
      66             :         }
      67           0 :         Edit::Modify();
      68           0 :     }
      69           0 :     void OSQLNameComboBox::Modify()
      70             :     {
      71           0 :         OUString sCorrected;
      72           0 :         if ( checkString( GetText(),sCorrected ) )
      73             :         {
      74           0 :             Selection aSel = GetSelection();
      75           0 :             aSel.setMax( aSel.getMin() );
      76           0 :             SetText( sCorrected );
      77             : 
      78           0 :             SaveValue();
      79             :         }
      80           0 :         ComboBox::Modify();
      81           0 :     }
      82             : }
      83             : 
      84           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeOSQLNameEdit(Window *pParent, VclBuilder::stringmap &)
      85             : {
      86           0 :     return new dbaui::OSQLNameEdit(pParent);
      87             : }
      88             : 
      89           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeOSQLNameComboBox(Window *pParent, VclBuilder::stringmap &)
      90             : {
      91           0 :     return new dbaui::OSQLNameComboBox(pParent);
      92             : }
      93             : 
      94             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10