LCOV - code coverage report
Current view: top level - dbaccess/source/ui/control - SqlNameEdit.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 39 2.6 %
Date: 2015-06-13 12:38:46 Functions: 2 8 25.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/builderfactory.hxx>
      22             : 
      23             : namespace dbaui
      24             : {
      25           0 :     bool isCharOk(sal_Unicode _cChar,bool _bFirstChar,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 :     bool OSQLNameChecker::checkString(const OUString& _sToCheck,
      36             :                                         OUString& _rsCorrected)
      37             :     {
      38           0 :         bool bCorrected = 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 = 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             : using namespace dbaui;
      85             : 
      86           0 : VCL_BUILDER_FACTORY(OSQLNameEdit)
      87          36 : VCL_BUILDER_FACTORY(OSQLNameComboBox)
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11