2001-03-14 06:36:48 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:15:45 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-03-14 06:36:48 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-03-14 06:36:48 +00:00
|
|
|
*
|
2008-04-10 13:15:45 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-03-14 06:36:48 +00:00
|
|
|
*
|
2008-04-10 13:15:45 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-03-14 06:36:48 +00:00
|
|
|
*
|
2008-04-10 13:15:45 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-03-14 06:36:48 +00:00
|
|
|
*
|
2008-04-10 13:15:45 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-03-14 06:36:48 +00:00
|
|
|
*
|
2008-04-10 13:15:45 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-03-14 06:36:48 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 06:00:36 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_dbaccess.hxx"
|
2001-03-14 06:36:48 +00:00
|
|
|
#include "SqlNameEdit.hxx"
|
|
|
|
namespace dbaui
|
|
|
|
{
|
|
|
|
//------------------------------------------------------------------
|
2001-03-27 12:05:17 +00:00
|
|
|
sal_Bool isCharOk(sal_Unicode _cChar,sal_Bool _bFirstChar,sal_Bool _bUpperCase,const ::rtl::OUString& _sAllowedChars)
|
2001-03-14 06:36:48 +00:00
|
|
|
{
|
2008-12-11 07:05:03 +00:00
|
|
|
return (
|
|
|
|
(_cChar >= 'A' && _cChar <= 'Z') ||
|
|
|
|
_cChar == '_' ||
|
|
|
|
_sAllowedChars.indexOf(_cChar) != -1 ||
|
2001-03-27 12:05:17 +00:00
|
|
|
(!_bFirstChar && (_cChar >= '0' && _cChar <= '9')) ||
|
2008-12-11 07:05:03 +00:00
|
|
|
(!_bUpperCase && (_cChar >= 'a' && _cChar <= 'z'))
|
|
|
|
);
|
2001-03-27 12:05:17 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
2001-07-16 06:56:28 +00:00
|
|
|
sal_Bool OSQLNameChecker::checkString( const ::rtl::OUString& _sOldValue,
|
|
|
|
const ::rtl::OUString& _sToCheck,
|
|
|
|
::rtl::OUString& _rsCorrected)
|
2001-03-27 12:05:17 +00:00
|
|
|
{
|
2001-07-16 06:56:28 +00:00
|
|
|
sal_Bool bCorrected = sal_False;
|
2001-12-14 14:04:08 +00:00
|
|
|
if ( m_bCheck )
|
2001-03-14 06:36:48 +00:00
|
|
|
{
|
2001-07-16 06:56:28 +00:00
|
|
|
XubString sSavedValue = _sOldValue;
|
|
|
|
XubString sText = _sToCheck;
|
|
|
|
xub_StrLen nMatch = 0;
|
2001-12-14 14:04:08 +00:00
|
|
|
for ( xub_StrLen i=nMatch;i < sText.Len(); ++i )
|
2001-03-14 06:36:48 +00:00
|
|
|
{
|
2001-12-14 14:04:08 +00:00
|
|
|
if ( !isCharOk( sText.GetBuffer()[i], i == 0, m_bOnlyUpperCase, m_sAllowedChars ) )
|
2001-07-06 08:01:35 +00:00
|
|
|
{
|
2001-12-14 14:04:08 +00:00
|
|
|
_rsCorrected += sText.Copy( nMatch, i - nMatch );
|
2001-07-16 06:56:28 +00:00
|
|
|
bCorrected = sal_True;
|
2001-12-14 14:04:08 +00:00
|
|
|
nMatch = i + 1;
|
2001-07-06 08:01:35 +00:00
|
|
|
}
|
2001-03-14 06:36:48 +00:00
|
|
|
}
|
2001-12-14 14:04:08 +00:00
|
|
|
_rsCorrected += sText.Copy( nMatch, sText.Len() - nMatch );
|
2001-03-14 06:36:48 +00:00
|
|
|
}
|
2001-07-16 06:56:28 +00:00
|
|
|
return bCorrected;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void OSQLNameEdit::Modify()
|
|
|
|
{
|
|
|
|
::rtl::OUString sCorrected;
|
2001-12-14 14:04:08 +00:00
|
|
|
if ( checkString( GetSavedValue(),GetText(),sCorrected ) )
|
|
|
|
{
|
|
|
|
Selection aSel = GetSelection();
|
|
|
|
aSel.setMax( aSel.getMin() );
|
|
|
|
SetText( sCorrected, aSel );
|
|
|
|
|
|
|
|
SaveValue();
|
|
|
|
}
|
2001-03-27 12:05:17 +00:00
|
|
|
Edit::Modify();
|
2001-03-14 06:36:48 +00:00
|
|
|
}
|
2001-07-16 06:56:28 +00:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
void OSQLNameComboBox::Modify()
|
|
|
|
{
|
|
|
|
::rtl::OUString sCorrected;
|
2001-12-14 14:04:08 +00:00
|
|
|
if ( checkString( GetSavedValue(),GetText(),sCorrected ) )
|
2001-07-16 06:56:28 +00:00
|
|
|
{
|
2001-12-14 14:04:08 +00:00
|
|
|
Selection aSel = GetSelection();
|
|
|
|
aSel.setMax( aSel.getMin() );
|
|
|
|
SetText( sCorrected );
|
|
|
|
|
2001-07-16 06:56:28 +00:00
|
|
|
SaveValue();
|
|
|
|
}
|
|
|
|
ComboBox::Modify();
|
|
|
|
}
|
2001-03-14 06:36:48 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|