2017-05-10 17:21 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbwin/olecore.c
+ added functions which changes default method of NIL conversion to
OLE variant:
__oleVariantNil2Null( [<lNewNil2NullFlag>] ) -> <lPrevNil2NullFlag>
By default NIL values passed to foreign OLE code are converted to
VT_EMPTY variants. __oleVariantNil2Null( .t. ) changes this behavior
so NIL values are converted to VT_NULL variants.
; Warning: This function was added for tests. Looks that it's expected
behavior for communication with MS-Excel and allows to use
NIL as default parameter value but potentially it may create
problems with some custom OLE interfaces so this modification
should be widely tested in real life before we change the
default behavior.
This commit is contained in:
@@ -10,6 +10,21 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2017-05-10 17:21 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* contrib/hbwin/olecore.c
|
||||
+ added functions which changes default method of NIL conversion to
|
||||
OLE variant:
|
||||
__oleVariantNil2Null( [<lNewNil2NullFlag>] ) -> <lPrevNil2NullFlag>
|
||||
By default NIL values passed to foreign OLE code are converted to
|
||||
VT_EMPTY variants. __oleVariantNil2Null( .t. ) changes this behavior
|
||||
so NIL values are converted to VT_NULL variants.
|
||||
; Warning: This function was added for tests. Looks that it's expected
|
||||
behavior for communication with MS-Excel and allows to use
|
||||
NIL as default parameter value but potentially it may create
|
||||
problems with some custom OLE interfaces so this modification
|
||||
should be widely tested in real life before we change the
|
||||
default behavior.
|
||||
|
||||
2017-05-10 16:39 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* contrib/hbwin/olecore.c
|
||||
- removed support for VT_DECIMAL and VT_PTR arrays from
|
||||
|
||||
@@ -432,6 +432,7 @@ DYNAMIC __oleIsDisp
|
||||
DYNAMIC __oleVariantGetType
|
||||
DYNAMIC __oleVariantGetValue
|
||||
DYNAMIC __oleVariantNew
|
||||
DYNAMIC __oleVariantNil2Null
|
||||
DYNAMIC __oleVariantNullDate
|
||||
DYNAMIC __wapi_DEVMODE_Get
|
||||
DYNAMIC __wapi_DEVMODE_New
|
||||
|
||||
@@ -86,6 +86,7 @@ typedef struct
|
||||
{
|
||||
HRESULT lOleError;
|
||||
HB_BOOL fNullDate;
|
||||
HB_BOOL fNil2Null;
|
||||
int iInit;
|
||||
} HB_OLEDATA, * PHB_OLEDATA;
|
||||
|
||||
@@ -93,6 +94,10 @@ static void hb_oleDataInit( void * cargo )
|
||||
{
|
||||
PHB_OLEDATA pOleData = ( PHB_OLEDATA ) cargo;
|
||||
|
||||
/* default settings: */
|
||||
pOleData->fNullDate = HB_FALSE;
|
||||
pOleData->fNil2Null = HB_FALSE;
|
||||
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
if( CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ) == S_OK )
|
||||
#else
|
||||
@@ -148,6 +153,17 @@ static HB_BOOL hb_oleGetNullDateFlag( void )
|
||||
}
|
||||
|
||||
|
||||
static void hb_oleSetNil2NullFlag( HB_BOOL fNil2Null )
|
||||
{
|
||||
hb_getOleData()->fNil2Null = fNil2Null;
|
||||
}
|
||||
|
||||
static HB_BOOL hb_oleGetNil2NullFlag( void )
|
||||
{
|
||||
return hb_getOleData()->fNil2Null;
|
||||
}
|
||||
|
||||
|
||||
static void hb_olecore_init( void * cargo )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
@@ -799,6 +815,7 @@ static void hb_oleItemToVariantRef( VARIANT * pVariant, PHB_ITEM pItem,
|
||||
case HB_IT_TIMESTAMP:
|
||||
{
|
||||
double dDate = hb_itemGetTD( pItem );
|
||||
|
||||
if( dDate == 0 && hb_oleGetNullDateFlag() )
|
||||
{
|
||||
V_VT( pVariant ) = VT_NULL;
|
||||
@@ -896,6 +913,11 @@ static void hb_oleItemToVariantRef( VARIANT * pVariant, PHB_ITEM pItem,
|
||||
}
|
||||
break;
|
||||
|
||||
case HB_IT_NIL:
|
||||
if( hb_oleGetNil2NullFlag() )
|
||||
V_VT( pVariant ) = VT_NULL;
|
||||
/* fallthrough */
|
||||
|
||||
default:
|
||||
if( pVarRef )
|
||||
{
|
||||
@@ -2602,7 +2624,7 @@ HB_FUNC( __OLEVARIANTNEW )
|
||||
hb_errRT_OLE( EG_ARG, 1018, 0, NULL, HB_ERR_FUNCNAME, NULL );
|
||||
}
|
||||
|
||||
/* __oleVariantNullDate( [<lNewNullFlag>] ) -> <lPrevNullFlag> */
|
||||
/* __oleVariantNullDate( [<lNewNullDateFlag>] ) -> <lPrevNullDateFlag> */
|
||||
HB_FUNC( __OLEVARIANTNULLDATE )
|
||||
{
|
||||
hb_retl( hb_oleGetNullDateFlag() );
|
||||
@@ -2610,6 +2632,14 @@ HB_FUNC( __OLEVARIANTNULLDATE )
|
||||
hb_oleSetNullDateFlag( hb_parl( 1 ) );
|
||||
}
|
||||
|
||||
/* __oleVariantNil2Null( [<lNewNil2NullFlag>] ) -> <lPrevNil2NullFlag> */
|
||||
HB_FUNC( __OLEVARIANTNIL2NULL )
|
||||
{
|
||||
hb_retl( hb_oleGetNil2NullFlag() );
|
||||
if( HB_ISLOG( 1 ) )
|
||||
hb_oleSetNil2NullFlag( hb_parl( 1 ) );
|
||||
}
|
||||
|
||||
HB_CALL_ON_STARTUP_BEGIN( _hb_olecore_init_ )
|
||||
hb_vmAtInit( hb_olecore_init, NULL );
|
||||
HB_CALL_ON_STARTUP_END( _hb_olecore_init_ )
|
||||
|
||||
Reference in New Issue
Block a user