Subject | TIB_CharCase, option ccProper in new version IBO |
---|---|
Author | Jan Šustr |
Post date | 2014-12-09T15:32:23Z |
Hello everyone,
During migration IBO from 5.2.0 to 5.5.5 I find different behavior strings
when have charcase property set to proper. In earlier version was only first letter set to UPCASE in first word.
Now is changed first letter of each word in string. For me is suitable earlier behavior. than I add new option to IB_CharCase.
During migration IBO from 5.2.0 to 5.5.5 I find different behavior strings
when have charcase property set to proper. In earlier version was only first letter set to UPCASE in first word.
Now is changed first letter of each word in string. For me is suitable earlier behavior. than I add new option to IB_CharCase.
I thing may be helpful for
everyone in future, than this is changed code:
Regards Jan
IB_Utils
----------
TIB_CharCase = (
ccNormal, // no special character case processing
ccUpperCase, // all characters to upper case
ccLowerCase, // all characters to lower case
ccProperCase, // words are "Proper Cased"
ccFirstUpperCase // the first letter is uppercase
);
IB_Components
-------------
line 24215
procedure TIB_Statement.SysUpdateCharCase( Afield: TIB_Column );
begin
with AField do
begin
case GetColAttrChar( AField,
FieldsCharCase,
IB_Connection.FieldsCharCase ) of
'P': FCharCase := ccProper;
'U': FCharCase := ccUpper;
'L': FCharCase := ccLower;
'F': FCharCase := ccFirstUp; // <-------
else FCharCase := ccNormal;
end;
end;
end;
procedure TIB_Column.SysApplyCharCase( var AValue: string );
var
ii: integer;
tmpStr: string;
begin
case CharCase of
ccUpper: AValue := AnsiUpperCase( AValue );
ccLower: AValue := AnsiLowerCase( AValue );
ccProper:
begin
{todo: This is a very poor way of handling proper case.}
tmpStr := iboLowerCase( AValue );
if iboLength( tmpStr ) > 0 then
begin
AValue := iboUpperCase(tmpStr[1]);
for ii := 2 to iboLength( tmpStr ) do
AValue := AValue + ConvCharCase( tmpStr[ii-1],
tmpStr[ii], ccProperCase );
end;
end;
ccFirstUp: // <-----------
if AVAlue<>'' then
AValue[1]:= UpCase(AValue[1]);
end;
end;
procedure TIB_Column.SysApplyCharCase( var AValue: widestring );
var
ii: integer;
tmpStr: widestring;
begin
case CharCase of
ccUpper: AValue := AnsiUpperCase( AValue );
ccLower: AValue := AnsiLowerCase( AValue );
ccProper:
begin
{todo: This is a very poor way of handling proper case.}
tmpStr := iboLowerCase( AValue );
if iboLength( tmpStr ) > 0 then
begin
AValue := iboUpperCase(tmpStr[1]);
for ii := 2 to iboLength( tmpStr ) do
AValue := AValue + ConvCharCase( tmpStr[ii-1],
tmpStr[ii], ccProperCase );
end;
end;
ccFirstUp: // <-----------
if AVAlue<>'' then
AValue[1]:= UpCase(AValue[1]);
end;
end;
procedure TIB_Column.SetCharCase( AValue: TIB_CharCase );
begin
if FCharCase <> AValue then
with Statement.FieldsCharCase do
case AValue of
ccUpper: LinkValues[ BestFieldName ] := 'UPPER';
ccLower: LinkValues[ BestFieldName ] := 'LOWER';
ccProper: LinkValues[ BestFieldName ] := 'PROPER';
ccFirstUp: LinkValues[ BestFieldName ] := 'FIRSTUP';
else LinkValues[ BestFieldName ] := 'NORMAL';
end;
end;
IB_Controls
-----------
^H, ^V, ^X, #32..#255:
begin
if EditCanModify then
begin
if ( {ibo}Length( Text ) = 0 ) and
( Field <> nil) and
(( FieldCharCase = ccProper )or
( FieldCharCase = ccFirstUp )) // <--------
then
Key := AnsiUpperCase( Key )[1];
end
else
Key := #0; // dont allow change
IB_Grid
-------
if ( CharCase = ccUpper ) or
(( CharCase = ccProper ) and
(( iboLength( FEditText ) = 0 ) or
( iboLength( FEditText ) = iboLength( SelText )))) or
(( CharCase = ccFirstUp ) and // <--------
(( iboLength( FEditText ) = 0 ))) // <--------
then
Key := (PChar(AnsiUpperCase( Key )))^ //Okstring
else
if CharCase = ccLower then
Key := (PChar(AnsiLowerCase( Key )))^; //Okstring
IBC_CustomLAbel
---------------
ccUpperCase: Text := iboUpperCase( Text );
ccLowerCase: Text := iboLowerCase( Text );
ccProperCase:
begin
tmpStr := iboLowerCase( Text );
if iboLength( tmpStr ) > 0 then
begin
Text := iboUpperCase(tmpStr[1]);
for i := 2 to iboLength( tmpStr ) do
Text := Text + ConvCharCase( tmpStr[i-1],
tmpStr[i],
CharCase );
end;
end;
ccFirstUpperCase: // <-----------
if Text<>'' then
Text[1]:= UpCase(Text[1]);
end; {case}
--
IB_Utils
----------
>>>>line 130
TIB_CharCase = (
ccNormal, // no special character case processing
ccUpperCase, // all characters to upper case
ccLowerCase, // all characters to lower case
ccProperCase, // words are "Proper Cased"
ccFirstUpperCase // the first letter is uppercase
);
IB_Components
-------------
>>>>>line 11074TIB_CharCase = ( ccNormal, ccUpper, ccLower, ccProper, ccFirstUp );
line 24215
procedure TIB_Statement.SysUpdateCharCase( Afield: TIB_Column );
begin
with AField do
begin
case GetColAttrChar( AField,
FieldsCharCase,
IB_Connection.FieldsCharCase ) of
'P': FCharCase := ccProper;
'U': FCharCase := ccUpper;
'L': FCharCase := ccLower;
'F': FCharCase := ccFirstUp; // <-------
else FCharCase := ccNormal;
end;
end;
end;
>>>>line 49385
procedure TIB_Column.SysApplyCharCase( var AValue: string );
var
ii: integer;
tmpStr: string;
begin
case CharCase of
ccUpper: AValue := AnsiUpperCase( AValue );
ccLower: AValue := AnsiLowerCase( AValue );
ccProper:
begin
{todo: This is a very poor way of handling proper case.}
tmpStr := iboLowerCase( AValue );
if iboLength( tmpStr ) > 0 then
begin
AValue := iboUpperCase(tmpStr[1]);
for ii := 2 to iboLength( tmpStr ) do
AValue := AValue + ConvCharCase( tmpStr[ii-1],
tmpStr[ii], ccProperCase );
end;
end;
ccFirstUp: // <-----------
if AVAlue<>'' then
AValue[1]:= UpCase(AValue[1]);
end;
end;
procedure TIB_Column.SysApplyCharCase( var AValue: widestring );
var
ii: integer;
tmpStr: widestring;
begin
case CharCase of
ccUpper: AValue := AnsiUpperCase( AValue );
ccLower: AValue := AnsiLowerCase( AValue );
ccProper:
begin
{todo: This is a very poor way of handling proper case.}
tmpStr := iboLowerCase( AValue );
if iboLength( tmpStr ) > 0 then
begin
AValue := iboUpperCase(tmpStr[1]);
for ii := 2 to iboLength( tmpStr ) do
AValue := AValue + ConvCharCase( tmpStr[ii-1],
tmpStr[ii], ccProperCase );
end;
end;
ccFirstUp: // <-----------
if AVAlue<>'' then
AValue[1]:= UpCase(AValue[1]);
end;
end;
>>>>>>>>>>line 51480
procedure TIB_Column.SetCharCase( AValue: TIB_CharCase );
begin
if FCharCase <> AValue then
with Statement.FieldsCharCase do
case AValue of
ccUpper: LinkValues[ BestFieldName ] := 'UPPER';
ccLower: LinkValues[ BestFieldName ] := 'LOWER';
ccProper: LinkValues[ BestFieldName ] := 'PROPER';
ccFirstUp: LinkValues[ BestFieldName ] := 'FIRSTUP';
else LinkValues[ BestFieldName ] := 'NORMAL';
end;
end;
IB_Controls
-----------
>>>>>>>>line 2020case Key of
^H, ^V, ^X, #32..#255:
begin
if EditCanModify then
begin
if ( {ibo}Length( Text ) = 0 ) and
( Field <> nil) and
(( FieldCharCase = ccProper )or
( FieldCharCase = ccFirstUp )) // <--------
then
Key := AnsiUpperCase( Key )[1];
end
else
Key := #0; // dont allow change
IB_Grid
-------
>>>>>>line2535{todo: this needs work!!!}
if ( CharCase = ccUpper ) or
(( CharCase = ccProper ) and
(( iboLength( FEditText ) = 0 ) or
( iboLength( FEditText ) = iboLength( SelText )))) or
(( CharCase = ccFirstUp ) and // <--------
(( iboLength( FEditText ) = 0 ))) // <--------
then
Key := (PChar(AnsiUpperCase( Key )))^ //Okstring
else
if CharCase = ccLower then
Key := (PChar(AnsiLowerCase( Key )))^; //Okstring
IBC_CustomLAbel
---------------
>>>>>line 460case CharCase of
ccUpperCase: Text := iboUpperCase( Text );
ccLowerCase: Text := iboLowerCase( Text );
ccProperCase:
begin
tmpStr := iboLowerCase( Text );
if iboLength( tmpStr ) > 0 then
begin
Text := iboUpperCase(tmpStr[1]);
for i := 2 to iboLength( tmpStr ) do
Text := Text + ConvCharCase( tmpStr[i-1],
tmpStr[i],
CharCase );
end;
end;
ccFirstUpperCase: // <-----------
if Text<>'' then
Text[1]:= UpCase(Text[1]);
end; {case}
--
S pozdravem