basic/source/classes/image.cxx |  103 +++++++++++++++++++++--------------------
 1 file changed, 53 insertions(+), 50 deletions(-)

New commits:
commit 6e403346634113f7b5d582774864baa4555b2843
Author: Laurent Godard <lgodard.li...@laposte.net>
Date:   Tue Aug 18 13:40:42 2015 +0200

    null pointer guard if no user defined types declared at the module level
    
    Change-Id: I368a168c636e4029e9cd9bbe4a4df5d9b846c923
    Reviewed-on: https://gerrit.libreoffice.org/17834
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index bc6fa3a..ef468dc 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -443,79 +443,82 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
         SbiCloseRecord( r, nPos );
     }
     // User defined types
-    sal_uInt16 nTypes = rTypes->Count();
-    if (nTypes > 0 )
+    if (rTypes)
     {
-        nPos = SbiOpenRecord( r, B_SBXOBJECTS, nTypes );
-
-        for (sal_uInt16 i = 0; i < nTypes; i++)
+        sal_uInt16 nTypes = rTypes->Count();
+        if (nTypes > 0 )
         {
-            SbxObject* pType = static_cast< SbxObject* > ( rTypes->Get(i) );
-            OUString aTypeName = pType->GetClassName();
+            nPos = SbiOpenRecord( r, B_SBXOBJECTS, nTypes );
 
-            r.WriteUniOrByteString( aTypeName, eCharSet );
+            for (sal_uInt16 i = 0; i < nTypes; i++)
+            {
+                SbxObject* pType = static_cast< SbxObject* > ( rTypes->Get(i) 
);
+                OUString aTypeName = pType->GetClassName();
 
-            SbxArray  *pTypeMembers = pType->GetProperties();
-            sal_uInt16 nTypeMembers = pTypeMembers->Count();
+                r.WriteUniOrByteString( aTypeName, eCharSet );
 
-            r.WriteInt16(nTypeMembers);
+                SbxArray  *pTypeMembers = pType->GetProperties();
+                sal_uInt16 nTypeMembers = pTypeMembers->Count();
 
-            for (sal_uInt16 j = 0; j < nTypeMembers; j++)
-            {
+                r.WriteInt16(nTypeMembers);
 
-                SbxProperty* pTypeElem = static_cast< SbxProperty* > ( 
pTypeMembers->Get(j) );
+                for (sal_uInt16 j = 0; j < nTypeMembers; j++)
+                {
 
-                OUString aElemName = pTypeElem->GetName();
-                r.WriteUniOrByteString( aElemName, eCharSet );
+                    SbxProperty* pTypeElem = static_cast< SbxProperty* > ( 
pTypeMembers->Get(j) );
 
-                SbxDataType dataType =   pTypeElem->GetType();
-                r.WriteInt16(dataType);
+                    OUString aElemName = pTypeElem->GetName();
+                    r.WriteUniOrByteString( aElemName, eCharSet );
 
-                SbxFlagBits nElemFlags = pTypeElem->GetFlags();
-                r.WriteUInt32(static_cast< sal_uInt32 > (nElemFlags) );
+                    SbxDataType dataType =   pTypeElem->GetType();
+                    r.WriteInt16(dataType);
 
-                SbxBase* pElemObject = pTypeElem->GetObject();
+                    SbxFlagBits nElemFlags = pTypeElem->GetFlags();
+                    r.WriteUInt32(static_cast< sal_uInt32 > (nElemFlags) );
 
-                if (pElemObject)
-                {
-                    r.WriteInt16(1); // has elem Object
+                    SbxBase* pElemObject = pTypeElem->GetObject();
 
-                    if( dataType == SbxOBJECT )
+                    if (pElemObject)
                     {
-                        // nested user defined types
-                        // declared before use, so it is ok to reference it by 
name on load
-                        SbxObject* pNestedType = static_cast< SbxObject* > ( 
pElemObject );
-                        r.WriteUniOrByteString( pNestedType->GetClassName(), 
eCharSet );
-                    }
-                    else
-                    {
-                        // an array
-                        SbxDimArray* pArray = static_cast< SbxDimArray* > ( 
pElemObject );
+                        r.WriteInt16(1); // has elem Object
 
-                        bool bFixedSize = pArray->hasFixedSize();
-                        if (bFixedSize)
-                            r.WriteInt16(1);
+                        if( dataType == SbxOBJECT )
+                        {
+                            // nested user defined types
+                            // declared before use, so it is ok to reference 
it by name on load
+                            SbxObject* pNestedType = static_cast< SbxObject* > 
( pElemObject );
+                            r.WriteUniOrByteString( 
pNestedType->GetClassName(), eCharSet );
+                        }
                         else
-                            r.WriteInt16(0);
+                        {
+                            // an array
+                            SbxDimArray* pArray = static_cast< SbxDimArray* > 
( pElemObject );
 
-                        sal_Int32 nDims = pArray->GetDims();
-                        r.WriteInt32(nDims);
+                            bool bFixedSize = pArray->hasFixedSize();
+                            if (bFixedSize)
+                                r.WriteInt16(1);
+                            else
+                                r.WriteInt16(0);
 
-                        for (sal_Int32 d = 0; d < nDims; d++)
-                        {
-                            sal_Int32 lBound;
-                            sal_Int32 uBound;
-                            pArray->GetDim32(d, lBound, uBound);
-                            r.WriteInt32(lBound).WriteInt32(uBound);
+                            sal_Int32 nDims = pArray->GetDims();
+                            r.WriteInt32(nDims);
+
+                            for (sal_Int32 d = 0; d < nDims; d++)
+                            {
+                                sal_Int32 lBound;
+                                sal_Int32 uBound;
+                                pArray->GetDim32(d, lBound, uBound);
+                                r.WriteInt32(lBound).WriteInt32(uBound);
+                            }
                         }
                     }
-                }
-                else
-                    r.WriteInt16(0); // no elem Object
+                    else
+                        r.WriteInt16(0); // no elem Object
 
+                }
             }
+        SbiCloseRecord( r, nPos );
         }
-    SbiCloseRecord( r, nPos );
     }
     // Set overall length
     SbiCloseRecord( r, nStart );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to