Commit a5b7e561 authored by claes's avatar claes

Calculation of max input size for attributes improved

parent 6eef3267
/**
* Proview $Id: co_cdh.c,v 1.18 2007-01-04 07:51:42 claes Exp $
* Proview $Id: co_cdh.c,v 1.19 2007-01-18 07:49:00 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -2621,6 +2621,79 @@ void cdh_SuppressSuper( char *out, char *in)
s += 6;
strcpy( out, s);
}
int cdh_TypeToMaxStrSize( pwr_eType type, int attr_size, int attr_elements)
{
int size;
switch( type) {
case pwr_eType_Boolean:
size = 1;
break;
case pwr_eType_Int64:
size = 20;
break;
case pwr_eType_UInt64:
size = 20;
break;
case pwr_eType_Enum:
case pwr_eType_Mask:
case pwr_eType_Status:
case pwr_eType_NetStatus:
case pwr_eType_Int32:
size = 11;
break;
case pwr_eType_UInt32:
size = 10;
break;
case pwr_eType_Int16:
size = 6;
break;
case pwr_eType_UInt16:
size = 5;
break;
case pwr_eType_Int8:
size = 4;
break;
case pwr_eType_UInt8:
size = 3;
break;
case pwr_eType_Char:
size = 1;
break;
case pwr_eType_Float32:
size = 40;
break;
case pwr_eType_Float64:
size = 40;
break;
case pwr_eType_Time:
size = 23;
break;
case pwr_eType_DeltaTime:
size = 40;
break;
case pwr_eType_AttrRef:
size = sizeof(pwr_tAName) - 1;
break;
case pwr_eType_TypeId:
case pwr_eType_ClassId:
case pwr_eType_Objid:
size = sizeof(pwr_tOName) - 1;
break;
case pwr_eType_VolumeId:
size = sizeof(pwr_tObjName) - 1;
break;
case pwr_eType_String:
case pwr_eType_Text:
size = attr_size / attr_elements;
break;
default:
size = 80;
}
return size;
}
/*@}*/
......
/**
* Proview $Id: co_cdh.h,v 1.24 2007-01-04 07:51:42 claes Exp $
* Proview $Id: co_cdh.h,v 1.25 2007-01-18 07:49:00 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1005,6 +1005,8 @@ pwr_sAttrRef cdh_ArefAdd( pwr_sAttrRef *arp1, pwr_sAttrRef *arp2);
void cdh_SuppressSuper( char *out, char *in);
int cdh_TypeToMaxStrSize( pwr_eType type, int attr_size, int attr_elements);
/*@}*/
#ifdef __cplusplus
......
/*
* Proview $Id: wb_wattnav.cpp,v 1.15 2007-01-15 13:23:17 claes Exp $
* Proview $Id: wb_wattnav.cpp,v 1.16 2007-01-18 07:49:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -126,23 +126,8 @@ int WAttNav::check_attr( int *multiline, brow_tObject *node,
wnav_attrvalue_to_string( ldhses, item->type_id, p, init_value,
&len);
free( p);
switch ( item->type_id) {
case pwr_eType_Objid:
case pwr_eType_AttrRef:
case pwr_eType_ClassId:
*size = sizeof(pwr_tOName) - 1;
break;
case pwr_eType_VolumeId:
case pwr_eType_TypeId:
*size = sizeof(pwr_tObjName) - 1;
break;
case pwr_eType_Time:
case pwr_eType_DeltaTime:
*size = 40;
break;
default:
*size = item->size;
}
*size = cdh_TypeToMaxStrSize( (pwr_eType)item->type_id, item->size, 1);
if ( item->type_id == pwr_eType_Text)
*multiline = 1;
else
......
/*
* Proview $Id: wb_wnav.cpp,v 1.34 2007-01-15 13:23:45 claes Exp $
* Proview $Id: wb_wnav.cpp,v 1.35 2007-01-18 07:49:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -739,23 +739,7 @@ int WNav::check_attr_value( brow_tObject node, int *multiline,
&len);
free( p);
switch ( item->type_id) {
case pwr_eType_Objid:
case pwr_eType_AttrRef:
case pwr_eType_ClassId:
*size = sizeof(pwr_tOName) - 1;
break;
case pwr_eType_VolumeId:
case pwr_eType_TypeId:
*size = sizeof(pwr_tObjName) - 1;
break;
case pwr_eType_Time:
case pwr_eType_DeltaTime:
*size = 40;
break;
default:
*size = item->size;
}
*size = cdh_TypeToMaxStrSize( (pwr_eType)item->type_id, item->size, 1);
if ( item->type_id == pwr_eType_Text)
*multiline = 1;
......@@ -780,23 +764,8 @@ int WNav::check_attr_value( brow_tObject node, int *multiline,
&len);
free( p);
switch ( item->type_id) {
case pwr_eType_Objid:
case pwr_eType_AttrRef:
case pwr_eType_ClassId:
*size = sizeof(pwr_tOName) - 1;
break;
case pwr_eType_VolumeId:
case pwr_eType_TypeId:
*size = sizeof(pwr_tObjName) - 1;
break;
case pwr_eType_Time:
case pwr_eType_DeltaTime:
*size = 40;
break;
default:
*size = item->size;
}
*size = cdh_TypeToMaxStrSize( (pwr_eType)item->type_id, item->size, 1);
if ( item->type_id == pwr_eType_Text)
*multiline = 1;
else
......@@ -2689,7 +2658,7 @@ int WNav::volume_attached( ldh_tWBContext wbcontext, ldh_tSesContext ldhsession,
ldhses = ldhsession;
wbctx = wbcontext;
wccm_store_ldhses( (void *)this, ldhses);
if ( window_type != wnav_eWindowType_No)
if ( brow && window_type != wnav_eWindowType_No)
show_volume( pop);
return 1;
}
......
/*
* Proview $Id: xtt_xattnav.cpp,v 1.17 2007-01-15 13:18:00 claes Exp $
* Proview $Id: xtt_xattnav.cpp,v 1.18 2007-01-18 07:49:28 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -115,24 +115,8 @@ int XAttNav::check_attr( int *multiline, brow_tObject *node, char *name,
strcpy( name, item->attr);
sts = gdh_GetAttributeCharacteristics( name, &a_tid, &a_size, &a_offs, &a_elem);
if ( ODD(sts)) {
switch ( item->type_id) {
case pwr_eType_Objid:
case pwr_eType_AttrRef:
case pwr_eType_ClassId:
*size = sizeof(pwr_tAName) - 1;
case pwr_eType_VolumeId:
case pwr_eType_TypeId:
*size = sizeof(pwr_tObjName) - 1;
break;
case pwr_eType_Time:
case pwr_eType_DeltaTime:
*size = 40;
break;
default:
*size = a_size / a_elem;
}
}
if ( ODD(sts))
*size = cdh_TypeToMaxStrSize( (pwr_eType)item->type_id, a_size, a_elem);
else
*size = 80;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment