From db17079fcff6f9a068c499b17f2501cc4c82d10b Mon Sep 17 00:00:00 2001 From: Laurent Godard Date: Fri, 18 Sep 2015 17:06:29 +0200 Subject: tdf#94617 allow to store nStart information greater than sal_Int16 limit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - preserve backward compatibility - nDebugFlag is stored but not used when loaded - Flag nDebugFlag set the top bit to 1 - stores the multiplier of sal_Int16 limit to reach nStart - in load, test this flag bit - rebuild correct nStart - new B_CURVERSION file format for binary storage macro - unit test for big modules Change-Id: Iaa037982d828fef7195615e6eda546b7199a4fe8 Reviewed-on: https://gerrit.libreoffice.org/18926 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- basic/source/classes/sbxmod.cxx | 44 ++++++++++++++++++++++++++++++++++++----- basic/source/inc/filefmt.hxx | 3 ++- 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'basic/source') diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index aaa9db9b6aed..d025cf00f06a 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -77,6 +77,8 @@ #include "sbxmod.hxx" #include "parser.hxx" +#include + using namespace com::sun::star; using namespace com::sun::star::lang; using namespace com::sun::star::reflection; @@ -1068,6 +1070,7 @@ void SbModule::SetVBACompat( bool bCompat ) void SbModule::Run( SbMethod* pMeth ) { SAL_INFO("basic","About to run " << OUStringToOString( pMeth->GetName(), RTL_TEXTENCODING_UTF8 ).getStr() << ", vba compatmode is " << mbVBACompat ); + static sal_uInt16 nMaxCallLevel = 0; bool bDelInst = ( GetSbData()->pInst == NULL ); @@ -1175,7 +1178,9 @@ void SbModule::Run( SbMethod* pMeth ) { GetSbData()->pInst->EnableCompatibility( true ); } + while( pRt->Step() ) {} + if( pRt->pNext ) pRt->pNext->unblock(); @@ -2035,14 +2040,35 @@ bool SbMethod::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { if( !SbxMethod::LoadData( rStrm, 1 ) ) return false; - sal_Int16 n; - rStrm.ReadInt16( n ); + + sal_uInt16 nFlag; + rStrm.ReadUInt16( nFlag ); + sal_Int16 nTempStart = (sal_Int16)nStart; + if( nVer == 2 ) + { rStrm.ReadUInt16( nLine1 ).ReadUInt16( nLine2 ).ReadInt16( nTempStart ).ReadCharAsBool( bInvalid ); + //tdf#94617 + if (nFlag & 0x8000) + { + sal_uInt16 nMult = nFlag & 0x7FFF; + sal_Int16 nMax = std::numeric_limits::max(); + nStart = nMult * nMax + nTempStart; + } + else + { + nStart = nTempStart; + } + } + else + { + nStart = nTempStart; + } + // HACK ue to 'Referenz could not be saved' SetFlag( SBX_NO_MODIFY ); - nStart = nTempStart; + return true; } @@ -2050,11 +2076,19 @@ bool SbMethod::StoreData( SvStream& rStrm ) const { if( !SbxMethod::StoreData( rStrm ) ) return false; - rStrm.WriteInt16( nDebugFlags ) + + //tdf#94617 + sal_Int16 nMax = std::numeric_limits::max(); + sal_Int16 nStartTemp = nStart % nMax; + sal_uInt16 nDebugFlagsTemp = nStart / nMax; + nDebugFlagsTemp |= 0x8000; + + rStrm.WriteUInt16( nDebugFlagsTemp ) .WriteInt16( nLine1 ) .WriteInt16( nLine2 ) - .WriteInt16( nStart ) + .WriteInt16( nStartTemp ) .WriteBool( bInvalid ); + return true; } diff --git a/basic/source/inc/filefmt.hxx b/basic/source/inc/filefmt.hxx index db0b1f6e919f..c9d6ba7c8f95 100644 --- a/basic/source/inc/filefmt.hxx +++ b/basic/source/inc/filefmt.hxx @@ -40,11 +40,12 @@ class SvStream; // Version 11: #29955 force anew compilation because of build-inconsistences // Version 12: aoo#64377 increase code size that basic can handle // tdf#75973 support user defined types B_USERTYPES in password protected macros +// Version 13: tdf#94617 store methods nStart information greater than sal_Int16 limit // #define B_LEGACYVERSION 0x00000011L #define B_EXT_IMG_VERSION 0x00000012L -#define B_CURVERSION 0x00000012L +#define B_CURVERSION 0x00000013L // The file contains either a module- or a library-record. // Those records contain further records. Every record's got -- cgit v1.2.3