diff options
author | Laurent Godard <lgodard.libre@laposte.net> | 2015-08-19 17:58:12 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-08-31 10:14:12 +0000 |
commit | 8a7b7b7b72c299bc9a96815814c1452be7f662c1 (patch) | |
tree | 21e8788438b97cfebf75e87dea3fb6c88ec5db15 | |
parent | 9093585317de876c2f04a01b5c3ea137114341c0 (diff) |
New identifier for save/open macro with user defined types
no version bump but B_USERTYPE defined
fix test from commit de26ef85 that should be nMaxRecords
tested full round trip on password protected document (ie. use binary storage)
master --(0)--> master --(1)--> libreoffice 4.4 --(2)--> master --(3)--> master
(0) in master, User type supported, big module supported
(1) in libreoffice 4.4, user type not supported, big module supported, no loss of code
(2) in master, user type not supported, big module not found, no loss of code
it is OK as libreoffice 4.4 saves to LegacyVersion
(3) in master, User type supported, big module supported (all is restored)
it is OK as module was saved with CURRENT_VERSION (see sbxmod.cxx)
Change-Id: I237cf7de70adf1a755be1bc30987b21c43b6ab35
Reviewed-on: https://gerrit.libreoffice.org/17871
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | basic/source/classes/image.cxx | 6 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 5 | ||||
-rw-r--r-- | basic/source/inc/filefmt.hxx | 30 | ||||
-rw-r--r-- | basic/source/uno/scriptcont.cxx | 5 | ||||
-rw-r--r-- | include/basic/sbmod.hxx | 1 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/testTypePassword.ods | bin | 15201 -> 15163 bytes |
6 files changed, 35 insertions, 12 deletions
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index 703dbd41b7e1..3faabae95793 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -240,13 +240,13 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) } break; } - case B_SBXOBJECTS: + case B_USERTYPES: { //assuming an empty string with just the lead 32bit/16bit len indicator const size_t nMinStringSize = (eCharSet == RTL_TEXTENCODING_UNICODE) ? 4 : 2; const size_t nMinRecordSize = nMinStringSize + sizeof(sal_Int16); const size_t nMaxRecords = r.remainingSize() / nMinRecordSize; - if (nCount > nMinRecordSize) + if (nCount > nMaxRecords) { SAL_WARN("basic", "Parsing error: " << nMaxRecords << " max possible entries, but " << nCount << " claimed, truncating"); @@ -458,7 +458,7 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) sal_uInt16 nTypes = rTypes->Count(); if (nTypes > 0 ) { - nPos = SbiOpenRecord( r, B_SBXOBJECTS, nTypes ); + nPos = SbiOpenRecord( r, B_USERTYPES, nTypes ); for (sal_uInt16 i = 0; i < nTypes; i++) { diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 364199cae1ec..5dc17c04ef41 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1803,11 +1803,6 @@ bool SbModule::HasExeCode() } // Store only image, no source -bool SbModule::StoreBinaryData( SvStream& rStrm ) -{ - return StoreBinaryData( rStrm, 0 ); -} - bool SbModule::StoreBinaryData( SvStream& rStrm, sal_uInt16 nVer ) { bool bRet = Compile(); diff --git a/basic/source/inc/filefmt.hxx b/basic/source/inc/filefmt.hxx index 9b294a8c2028..db0b1f6e919f 100644 --- a/basic/source/inc/filefmt.hxx +++ b/basic/source/inc/filefmt.hxx @@ -38,10 +38,13 @@ class SvStream; // Version F: #57844 introduction of SvNumberformat::StringToDouble // Version 10: #29955 generate for-loop-level in Statement-PCodes // 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 +// #define B_LEGACYVERSION 0x00000011L -#define B_CURVERSION 0x00000012L #define B_EXT_IMG_VERSION 0x00000012L +#define B_CURVERSION 0x00000012L // The file contains either a module- or a library-record. // Those records contain further records. Every record's got @@ -69,6 +72,9 @@ class SvStream; #define B_SBXOBJECTS 0x5853 // SX SBX objects #define B_EXTSOURCE 0x5345 // ES extended source +#define B_USERTYPES 0x4369 // UT user defined types + + // A library record contains only module records // sal_uInt16 identifier BL // sal_uInt32 the record's length @@ -153,6 +159,28 @@ class SvStream; // sal_uInt16 number of objects // .... object data +// user defined types B_USERTYPES : +// sal_uInt16 identifier UT +// sal_uInt32 the record's length +// sal_uInt16 number of types +// Data for every user defined type: +// string instance type name +// sal_Int16 number of type members +// Data for every type member: +// string name +// sal_Int16 type +// sal_uInt32 flags +// sal_Int16 hasObjects (0/1) +// If hasObjects +// If member type is nested type +// string nested type name +// Else (array declaration) +// sal_Int16 isFixedSize (0/1) +// sal_Int32 number of dimensions +// Data for every dimension: +// sal_Int32 lower bound +// sal_Int32 upper bound + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index c7df851a09e3..91ecc7057b3b 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -18,6 +18,7 @@ */ #include "scriptcont.hxx" +#include <filefmt.hxx> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/xml/sax/Parser.hpp> #include <com/sun/star/xml/sax/InputSource.hpp> @@ -623,7 +624,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons throw uno::RuntimeException(); } SvMemoryStream aMemStream; - /*sal_Bool bStore = */pMod->StoreBinaryData( aMemStream ); + /*sal_Bool bStore = */pMod->StoreBinaryData( aMemStream, B_CURVERSION ); sal_Size nSize = aMemStream.Tell(); Sequence< sal_Int8 > aBinSeq( nSize ); @@ -766,7 +767,7 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE ); SvMemoryStream aMemStream; - /*sal_Bool bStore = */pMod->StoreBinaryData( aMemStream ); + /*sal_Bool bStore = */pMod->StoreBinaryData( aMemStream, B_CURVERSION ); sal_Size nSize = aMemStream.Tell(); Sequence< sal_Int8 > aBinSeq( nSize ); diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx index 18683b7ee5cb..e0fcfe517e97 100644 --- a/include/basic/sbmod.hxx +++ b/include/basic/sbmod.hxx @@ -117,7 +117,6 @@ public: void ClearAllBP(); // Store only image, no source (needed for new password protection) - bool StoreBinaryData( SvStream& ); bool StoreBinaryData( SvStream&, sal_uInt16 nVer ); bool LoadBinaryData( SvStream& ); bool ExceedsLegacyModuleSize(); diff --git a/sc/qa/extras/testdocuments/testTypePassword.ods b/sc/qa/extras/testdocuments/testTypePassword.ods Binary files differindex ff8b27b4811c..f56ec640c4ac 100644 --- a/sc/qa/extras/testdocuments/testTypePassword.ods +++ b/sc/qa/extras/testdocuments/testTypePassword.ods |