summaryrefslogtreecommitdiff
path: root/basic/source/classes/image.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/classes/image.cxx')
-rw-r--r--basic/source/classes/image.cxx57
1 files changed, 18 insertions, 39 deletions
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index 229dc8058518..eafb129894ab 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -124,11 +124,11 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
nFlags = static_cast<SbiImageFlags>(nTmpFlags);
eCharSet = nCharSet;
eCharSet = GetSOLoadTextEncoding( eCharSet );
- bBadVer = ( nVersion > B_CURVERSION );
+ bBadVer = ( nVersion > B_IMG_VERSION_13 );
nDimBase = static_cast<sal_uInt16>(lDimBase);
}
- bool bLegacy = ( nVersion < B_EXT_IMG_VERSION );
+ bool bLegacy = ( nVersion < B_IMG_VERSION_12 );
sal_uInt64 nNext;
while( ( nNext = r.Tell() ) < nLast )
@@ -373,31 +373,13 @@ done:
bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
{
- bool bLegacy = ( nVer < B_EXT_IMG_VERSION );
-
- // detect if old code exceeds legacy limits
- // if so, then disallow save
- if ( bLegacy && ExceedsLegacyLimits() )
- {
- SbiImage aEmptyImg;
- aEmptyImg.aName = aName;
- aEmptyImg.Save( r, B_LEGACYVERSION );
- 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_LEGACYVERSION );
- }
- else
- {
- r.WriteInt32( B_CURVERSION );
- }
- r .WriteInt32( eCharSet )
+ r .WriteInt32( nVer )
+ .WriteInt32( eCharSet )
.WriteInt32( nDimBase )
.WriteInt16( static_cast<sal_uInt16>(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<sal_uInt32, sal_uInt16> 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?
@@ -468,7 +440,8 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
// old readers will not read this data after having read legacy data, and will proceed
// straight to the end of the record. So no version restriction here.
r.WriteUInt32(nUnicodeDataMagicNumber);
- write_uInt16s_FromOUString(r, std::u16string_view(pStrings.get(), nStringSize));
+ r.WriteUnicodeOrByteText(std::u16string_view(pStrings.get(), nStringSize),
+ RTL_TEXTENCODING_UNICODE);
SbiCloseRecord( r, nPos );
}
@@ -578,7 +551,7 @@ void SbiImage::MakeStrings( short nSize )
// growing in 1K-Steps
void SbiImage::AddString( const OUString& r )
{
- if( nStringIdx >= short(mvStringOffsets.size()) )
+ if( nStringIdx >= mvStringOffsets.size() )
{
bError = true;
}
@@ -606,7 +579,7 @@ void SbiImage::AddString( const OUString& r )
memcpy( pStrings.get() + nStringOff, r.getStr(), len * sizeof( sal_Unicode ) );
nStringOff = nStringOff + len;
// Last String? The update the size of the buffer
- if( nStringIdx >= short(mvStringOffsets.size()) )
+ if( nStringIdx >= mvStringOffsets.size() )
{
nStringSize = nStringOff;
}
@@ -643,14 +616,14 @@ void SbiImage::AddEnum(SbxObject* pObject) // Register enum type
}
// Note: IDs start with 1
-OUString SbiImage::GetString( short nId, SbxDataType *eType ) const
+OUString SbiImage::GetString( sal_uInt32 nId, SbxDataType *eType ) const
{
- if( nId && nId <= short(mvStringOffsets.size()) )
+ if( nId && nId <= mvStringOffsets.size() )
{
sal_uInt32 nOff = mvStringOffsets[ nId - 1 ];
sal_Unicode* pStr = pStrings.get() + nOff;
- sal_uInt32 nNextOff = (nId < short(mvStringOffsets.size())) ? mvStringOffsets[ nId ] : nStringSize;
+ sal_uInt32 nNextOff = (nId < mvStringOffsets.size()) ? mvStringOffsets[ nId ] : nStringSize;
sal_uInt32 nLen = nNextOff - nOff - 1;
// #i42467: Special treatment for vbNullChar
if (*pStr == 0)
@@ -715,4 +688,10 @@ bool SbiImage::ExceedsLegacyLimits()
return (nStringSize > 0xFF00) || (CalcLegacyOffset(aCode.size()) > 0xFF00);
}
+bool SbiImage::ExceedsImgVersion12Limits()
+{
+ const sal_Int16 nMax = std::numeric_limits<sal_Int16>::max();
+ return nStringSize >= nMax || CalcLegacyOffset(aCode.size()) >= nMax;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */