[Libreoffice-commits] .: 2 commits - extensions/source

Noel Power noelp at kemper.freedesktop.org
Thu Feb 23 06:57:25 PST 2012


 extensions/source/ole/unoconversionutilities.hxx |   67 ++++++++---------------
 1 file changed, 26 insertions(+), 41 deletions(-)

New commits:
commit a6ff118c4fdb3af7702c463d995df38742da3464
Author: Joachim Lingner <jl at openoffice.org>
Date:   Thu Feb 23 12:38:36 2012 +0000

    default conversion of sequences is now again SAFEARRAY of VARIANTs #fdo46165
    
    cws jl166 patch: #i117010# default conversion of sequences is now again SAFEARRAY of VARIANTs

diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index 7cdcea0..97782cc 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -1318,47 +1318,32 @@ SAFEARRAY*  UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq)
 
     typelib_TypeDescription* pSeqElementDesc= NULL;
     TYPELIB_DANGER_GET( &pSeqElementDesc, pSeqElementTypeRef);
+    sal_Int32 nElementSize= pSeqElementDesc->nSize;
+    n= punoSeq->nElements;
 
-    // try to find VARIANT type that is related to the UNO type of the sequence elements
-    // the sequence as a sequence element should be handled in a special way
-    VARTYPE eTargetElementType = VT_EMPTY;
-    if ( pSeqElementDesc->eTypeClass != TypeClass_SEQUENCE )
-        eTargetElementType = mapTypeClassToVartype( static_cast< TypeClass >( pSeqElementDesc->eTypeClass ) );
+    SAFEARRAYBOUND rgsabound[1];
+    rgsabound[0].lLbound = 0;
+    rgsabound[0].cElements = n;
+    VARIANT oleElement;
+    long safeI[1];
 
-    if ( eTargetElementType != VT_EMPTY )
-        pArray = createUnoSequenceWrapper( rSeq, eTargetElementType );
+    pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
 
-    if ( !pArray )
-    {
-        sal_Int32 nElementSize= pSeqElementDesc->nSize;
-        n= punoSeq->nElements;
-
-        SAFEARRAYBOUND rgsabound[1];
-        rgsabound[0].lLbound = 0;
-        rgsabound[0].cElements = n;
-        VARIANT oleElement;
-        long safeI[1];
-
-        pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
-
-        Any unoElement;
-        //      sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->pElements;
-        sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->elements;
+    Any unoElement;
+    sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->elements;
 
-        for (sal_uInt32 i = 0; i < n; i++)
-        {
-            unoElement.setValue( pSeqData + i * nElementSize, pSeqElementDesc);
-            VariantInit(&oleElement);
+    for (sal_uInt32 i = 0; i < n; i++)
+    {
+        unoElement.setValue( pSeqData + i * nElementSize, pSeqElementDesc);
+        VariantInit(&oleElement);
 
-            anyToVariant(&oleElement, unoElement);
+        anyToVariant(&oleElement, unoElement);
 
-            safeI[0] = i;
-            SafeArrayPutElement(pArray, safeI, &oleElement);
+        safeI[0] = i;
+        SafeArrayPutElement(pArray, safeI, &oleElement);
 
-            VariantClear(&oleElement);
-        }
+        VariantClear(&oleElement);
     }
-
     TYPELIB_DANGER_RELEASE( pSeqElementDesc);
 
     return pArray;
commit 985ad082a56cd4bc47cd230e11f1cd771e08f9de
Author: Noel Power <noel.power at novell.com>
Date:   Thu Feb 23 12:36:05 2012 +0000

    Revert "fix handling of SAFEARRAY(s) returned as variant in olebridge (fdo#38441)"
    
    This reverts commit 3fcb94311fd7dd40c05ca132e3a30a888316cbbe.

diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index c94b0bc..7cdcea0 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -134,7 +134,7 @@ public:
     /** @exception com.sun.star.lang.IllegalArgumentException
         If rSeq does not contain a sequence then the exception is thrown.
     */
-    VARTYPE createUnoSequenceWrapper(const Any& rSeq, SAFEARRAY*& pOutArray );
+    SAFEARRAY*  createUnoSequenceWrapper(const Any& rSeq);
     /** @exception com.sun.star.lang.IllegalArgumentException
         If rSeq does not contain a sequence or elemtype has no proper value
         then the exception is thrown.
@@ -779,12 +779,11 @@ void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny)
         }
         case TypeClass_SEQUENCE:        // sequence ??? SafeArray descriptor
         {
-            SAFEARRAY* pOutArray = NULL;
-            VARTYPE eArrayType = createUnoSequenceWrapper(rAny, pOutArray );
-            if (pOutArray)
+            SAFEARRAY* pArray = createUnoSequenceWrapper(rAny);
+            if (pArray)
             {
-                V_VT(pVariant) = VT_ARRAY | eArrayType;
-                V_ARRAY(pVariant) = pOutArray;
+                V_VT(pVariant) = VT_ARRAY | VT_VARIANT;
+                V_ARRAY(pVariant) = pArray;
             }
             else
             {
@@ -1296,8 +1295,9 @@ void  UnoConversionUtilities<T>::getElementCountAndTypeOfSequence( const Any& rS
 
 
 template<class T>
-VARTYPE UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq,  SAFEARRAY*& pArray)
+SAFEARRAY*  UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq)
 {
+    SAFEARRAY* pArray = NULL;
     sal_uInt32 n = 0;
 
     if( rSeq.getValueTypeClass() != TypeClass_SEQUENCE )
@@ -1361,7 +1361,7 @@ VARTYPE UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq,  SA
 
     TYPELIB_DANGER_RELEASE( pSeqElementDesc);
 
-    return eTargetElementType;
+    return pArray;
 }
 
 /* The argument rObj can contain


More information about the Libreoffice-commits mailing list