From 17154ceafe4b96b43fdc9994736e378d6a11f3e4 Mon Sep 17 00:00:00 2001 From: Andreas Heinisch Date: Wed, 29 Mar 2023 12:01:07 +0200 Subject: tdf#92620 - Adjust error message about exceeding legacy module size Adjusted the error message about exceeding legacy module size and removed the code for saving image version 11. Modules using image version 11 still can be loaded. Saving modules always result in an image version higher than image version 11 depending on the size of the module. In addition, some minor performance issues (construction of the error message and the correct list of modules) were fixed. Change-Id: I3bde9fcc1596b63446193c836fa7b5cb06eb7d97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149687 Tested-by: Jenkins Reviewed-by: Andreas Heinisch --- basic/source/classes/image.cxx | 40 +++++++++------------------------------- basic/source/classes/sbxmod.cxx | 4 ++-- 2 files changed, 11 insertions(+), 33 deletions(-) (limited to 'basic/source/classes') diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index eab5fe9e0905..ee490947029e 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -373,31 +373,13 @@ done: bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) { - bool bLegacy = ( nVer < B_IMG_VERSION_12 ); - - // detect if old code exceeds legacy limits - // if so, then disallow save - if ( bLegacy && ExceedsLegacyLimits() ) - { - SbiImage aEmptyImg; - aEmptyImg.aName = aName; - aEmptyImg.Save( r, B_IMG_VERSION_11 ); - return true; - } // First of all the header sal_uInt64 nStart = SbiOpenRecord( r, FileOffset::Module, 1 ); sal_uInt64 nPos; eCharSet = GetSOStoreTextEncoding( eCharSet ); - if ( bLegacy ) - { - r.WriteInt32( B_IMG_VERSION_11 ); - } - else - { - r.WriteInt32( nVer ); - } - r .WriteInt32( eCharSet ) + r .WriteInt32( nVer ) + .WriteInt32( eCharSet ) .WriteInt32( nDimBase ) .WriteInt16( static_cast(nFlags) ) .WriteInt16( 0 ) @@ -429,17 +411,7 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) if (aCode.size() && r.good()) { nPos = SbiOpenRecord( r, FileOffset::PCode, 1 ); - if ( bLegacy ) - { - PCodeBuffConvertor aNewToLegacy(aCode.data(), aCode.size()); - aNewToLegacy.convert(); - aLegacyPCode = aNewToLegacy.GetBuffer(); - r.WriteBytes(aLegacyPCode.data(), aLegacyPCode.size()); - } - else - { - r.WriteBytes(aCode.data(), aCode.size()); - } + r.WriteBytes(aCode.data(), aCode.size()); SbiCloseRecord( r, nPos ); } // String-Pool? @@ -715,4 +687,10 @@ bool SbiImage::ExceedsLegacyLimits() return (nStringSize > 0xFF00) || (CalcLegacyOffset(aCode.size()) > 0xFF00); } +bool SbiImage::ExceedsImgVersion12Limits() +{ + const sal_Int16 nMax = std::numeric_limits::max(); + return nStringSize >= nMax || CalcLegacyOffset(aCode.size()) >= nMax; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 5b7ee24e1f9c..15e4719569ba 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1667,11 +1667,11 @@ std::pair SbModule::StoreData( SvStream& rStrm ) const } } -bool SbModule::ExceedsLegacyModuleSize() +bool SbModule::ExceedsImgVersion12ModuleSize() { if ( !IsCompiled() ) Compile(); - return pImage && pImage->ExceedsLegacyLimits(); + return pImage && pImage->ExceedsImgVersion12Limits(); } namespace { -- cgit