Subject | RE: [IBO] TIB_CharCase, option ccProper in new version IBO |
---|---|
Author | IBO Support List |
Post date | 2015-01-30T17:21:09Z |
These enhancements will be in the next version of
IBO.
Thanks,
Jason Wharton
From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Tuesday, December 9, 2014 8:32 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] TIB_CharCase, option ccProper in new version IBO
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
----------
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
-------------
TIB_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;
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
-----------
case 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
-------
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
---------------
case 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}
--
IB_Utils
----------
>>>>line 130TIB_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
-------------
>>>>>line11074
TIB_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 49385procedure 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;
>>>>>>>>>>line51480
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
-----------
>>>>>>>>line2020
case 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
---------------
>>>>>line460
case 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