diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-08-17 11:38:54 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-08-17 22:03:34 +0200 |
commit | d7d9d3cf1a529cfe99fb1b5ae65967c54e9f23bb (patch) | |
tree | 0e329095bed13ec6f97276a105f698355d885ccf /basic | |
parent | b6e508fc47ecb3650fd82c5e174e6d6a084e9ec6 (diff) |
tdf#135799: properly load arrays in user-defined types from image
This requires to reset Fixed flag temporarily, as in SbiParser::DefType
for non-image case.
And save the dimensions of the arrays in the custom types correctly:
the dimensions are numbered from 1, not from 0.
The existing unit test (that happened to not test anything actually)
was fixed.
Change-Id: I48c6b6d5d735d9972a2c0dd40345d5db75f87f39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100877
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/image.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index bb4d8409573f..eb127e755f1f 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -265,7 +265,7 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) nCount = nMaxRecords; } - // User defined types + // User defined types; ref.: SbiParser::DefType for (sal_uInt16 i = 0; i < nCount; i++) { OUString aTypeName = r.ReadUniOrByteString(eCharSet); @@ -320,7 +320,8 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) else { // an array - SbxDimArray* pArray = new SbxDimArray(); + SbxDimArray* pArray = new SbxDimArray( + static_cast<SbxDataType>(aMemberType & 0x0FFF)); sal_Int16 isFixedSize; r.ReadInt16(isFixedSize); @@ -337,7 +338,12 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) pArray->unoAddDim32(lBound, uBound); } + const SbxFlagBits nSavFlags = pTypeElem->GetFlags(); + // need to reset the FIXED flag + // when calling PutObject ( because the type will not match Object ) + pTypeElem->ResetFlag(SbxFlagBits::Fixed); pTypeElem->PutObject( pArray ); + pTypeElem->SetFlags(nSavFlags); } } @@ -538,7 +544,7 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) sal_Int32 nDims = pArray->GetDims32(); r.WriteInt32(nDims); - for (sal_Int32 d = 0; d < nDims; d++) + for (sal_Int32 d = 1; d <= nDims; d++) { sal_Int32 lBound; sal_Int32 uBound; |