summaryrefslogtreecommitdiff
path: root/extensions/source/ole/unoconversionutilities.hxx
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2004-08-02 08:46:25 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2004-08-02 08:46:25 +0000
commit4e599b3bd4bb45af3c9451293bcce3eb56da0e5c (patch)
tree1fe43a1b0d7866e8c8d15bb89f19cc9ee8364c45 /extensions/source/ole/unoconversionutilities.hxx
parentb8326d0eb6de6879af739cad87d24a20d3204dc3 (diff)
INTEGRATION: CWS jl10 (1.15.74); FILE MERGED
2004/07/21 10:47:25 jl 1.15.74.1: #111019# support for UNO type
Diffstat (limited to 'extensions/source/ole/unoconversionutilities.hxx')
-rw-r--r--extensions/source/ole/unoconversionutilities.hxx63
1 files changed, 59 insertions, 4 deletions
diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index bdecc14ff302..59285c1b9efd 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unoconversionutilities.hxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: obo $ $Date: 2004-03-17 13:08:56 $
+ * last change: $Author: rt $ $Date: 2004-08-02 09:46:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,6 +73,8 @@
#include "typelib/typedescription.hxx"
#include "ole2uno.hxx"
+#include "unotypewrapper.hxx"
+
// for some reason DECIMAL_NEG (wtypes.h) which contains BYTE is not resolved.
typedef unsigned char BYTE;
// classes for wrapping uno objects
@@ -575,6 +577,14 @@ void UnoConversionUtilities<T>::variantToAny( const VARIANTARG* pArg, Any& rAny,
else
bFail = true;
break;
+ case TypeClass_TYPE:
+ if(SUCCEEDED(hr = VariantChangeType(& var, &var, 0, VT_UNKNOWN)))
+ variantToAny( & var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
default:
// case TypeClass_SERVICE: break; // meta construct
// case TypeClass_TYPEDEF: break;
@@ -968,6 +978,22 @@ void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny)
pVariant->decVal.Lo64 = value;
break;
}
+ case TypeClass_TYPE:
+ {
+ Type type;
+ rAny >>= type;
+ CComVariant var;
+ if (createUnoTypeWrapper(type.getTypeName(), & var) == false)
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] UnoConversionUtilities<T>::anyToVariant \n"
+ "Error during conversion of UNO type to Automation object!"));
+
+ if (FAILED(VariantCopy(pVariant, &var)))
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] UnoConversionUtilities<T>::anyToVariant \n"
+ "Unexpected error!"));
+ break;
+ }
default:
//TypeClass_SERVICE:
//TypeClass_EXCEPTION:
@@ -1544,7 +1570,30 @@ void UnoConversionUtilities<T>::variantToAny( const VARIANT* pVariant, Any& rAny
case VT_UNKNOWN:
case VT_DISPATCH:
{
- rAny = createOleObjectWrapper( & var);
+ //check if it is a UNO type
+ CComQIPtr<IUnoTypeWrapper> spType((IUnknown*) var.byref);
+ if (spType)
+ {
+ CComBSTR sName;
+ if (FAILED(spType->get_Name(&sName)))
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::variantToAny \n"
+ "Failed to get the type name from a UnoTypeWrapper!"));
+ Type type;
+ if (getType(sName, type) == false)
+ {
+ throw CannotConvertException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::variantToAny \n"
+ "A UNO type with the name: ") + OUString(sName) +
+ OUSTR("does not exist!"),
+ 0, TypeClass_UNKNOWN, FailReason::TYPE_NOT_SUPPORTED,0);
+ }
+ rAny <<= type;
+ }
+ else
+ {
+ rAny = createOleObjectWrapper( & var);
+ }
break;
}
case VT_ERROR:
@@ -1886,7 +1935,13 @@ bool UnoConversionUtilities<T>::convertValueObject( const VARIANTARG *var, Any&
if (varBool == VARIANT_FALSE)
{
if(SUCCEEDED(hr = spValue->GetValue( & bstrType, & varValue)))
- variantToAny( & varValue, any, getType(bstrType));
+ {
+ Type type;
+ if (getType(bstrType, type))
+ variantToAny( & varValue, any, type);
+ else
+ bFail = true;
+ }
else
bFail = true;
}