2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
#include <tools/stream.hxx>
|
2001-08-07 10:20:11 +00:00
|
|
|
#include <tools/tenccvt.hxx>
|
2013-07-01 10:33:48 -05:00
|
|
|
#include <osl/thread.h>
|
2007-06-27 13:18:06 +00:00
|
|
|
#include <basic/sbx.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "sb.hxx"
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <string.h>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "image.hxx"
|
2006-11-01 15:13:02 +00:00
|
|
|
#include <codegen.hxx>
|
2015-06-15 17:58:15 +09:00
|
|
|
#include <memory>
|
2014-07-16 17:41:15 +09:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiImage::SbiImage()
|
|
|
|
{
|
2015-11-10 10:10:36 +01:00
|
|
|
pStringOff = nullptr;
|
|
|
|
pStrings = nullptr;
|
|
|
|
pCode = nullptr;
|
|
|
|
pLegacyPCode = nullptr;
|
2015-02-27 11:22:50 +02:00
|
|
|
nFlags = SbiImageFlags::NONE;
|
2006-11-03 06:39:47 +00:00
|
|
|
nStrings = 0;
|
|
|
|
nStringSize= 0;
|
|
|
|
nCodeSize = 0;
|
2006-11-01 15:13:02 +00:00
|
|
|
nLegacyCodeSize =
|
2000-09-18 15:18:56 +00:00
|
|
|
nDimBase = 0;
|
|
|
|
bInit =
|
2012-08-12 09:07:20 +09:00
|
|
|
bError = false;
|
2012-08-15 09:44:54 +09:00
|
|
|
bFirstInit = true;
|
2011-11-24 12:06:54 +01:00
|
|
|
eCharSet = osl_getThreadTextEncoding();
|
2013-10-05 16:44:30 +01:00
|
|
|
nStringIdx = 0;
|
|
|
|
nStringOff = 0;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SbiImage::~SbiImage()
|
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SbiImage::Clear()
|
|
|
|
{
|
2003-03-18 15:28:40 +00:00
|
|
|
delete[] pStringOff;
|
|
|
|
delete[] pStrings;
|
|
|
|
delete[] pCode;
|
2006-11-01 15:13:02 +00:00
|
|
|
ReleaseLegacyBuffer();
|
2015-11-10 10:10:36 +01:00
|
|
|
pStringOff = nullptr;
|
|
|
|
pStrings = nullptr;
|
|
|
|
pCode = nullptr;
|
2015-02-27 11:22:50 +02:00
|
|
|
nFlags = SbiImageFlags::NONE;
|
2006-11-03 06:39:47 +00:00
|
|
|
nStrings = 0;
|
|
|
|
nStringSize= 0;
|
2006-11-01 15:13:02 +00:00
|
|
|
nLegacyCodeSize = 0;
|
2000-09-18 15:18:56 +00:00
|
|
|
nCodeSize = 0;
|
2011-11-24 12:06:54 +01:00
|
|
|
eCharSet = osl_getThreadTextEncoding();
|
2000-09-18 15:18:56 +00:00
|
|
|
nDimBase = 0;
|
2012-08-12 09:07:20 +09:00
|
|
|
bError = false;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
2009-04-25 00:18:20 +00:00
|
|
|
* Service-Routines for Load/Store
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
2012-08-15 09:44:54 +09:00
|
|
|
bool SbiGood( SvStream& r )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2012-08-15 09:44:54 +09:00
|
|
|
return !r.IsEof() && r.GetError() == SVSTREAM_OK;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Open Record
|
2016-02-24 14:43:38 +01:00
|
|
|
sal_uInt64 SbiOpenRecord( SvStream& r, FileOffset nSignature, sal_uInt16 nElem )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2015-12-31 10:58:37 +01:00
|
|
|
sal_uInt64 nPos = r.Tell();
|
2016-02-24 14:43:38 +01:00
|
|
|
r.WriteUInt16( static_cast<sal_uInt16>( nSignature ) )
|
|
|
|
.WriteInt32( 0 ).WriteUInt16( nElem );
|
2000-09-18 15:18:56 +00:00
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Close Record
|
2015-12-31 10:58:37 +01:00
|
|
|
void SbiCloseRecord( SvStream& r, sal_uInt64 nOff )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2015-12-31 10:58:37 +01:00
|
|
|
sal_uInt64 nPos = r.Tell();
|
2000-09-18 15:18:56 +00:00
|
|
|
r.Seek( nOff + 2 );
|
2015-01-16 08:07:06 +02:00
|
|
|
r.WriteInt32(nPos - nOff - 8 );
|
2000-09-18 15:18:56 +00:00
|
|
|
r.Seek( nPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
2009-04-25 00:18:20 +00:00
|
|
|
* Load/Store
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
2012-08-15 09:44:54 +09:00
|
|
|
bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
|
2006-11-01 15:13:02 +00:00
|
|
|
{
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 nSign, nCount;
|
|
|
|
sal_uInt32 nLen, nOff;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
Clear();
|
2009-04-25 00:18:20 +00:00
|
|
|
// Read Master-Record
|
2014-02-05 10:41:04 +02:00
|
|
|
r.ReadUInt16( nSign ).ReadUInt32( nLen ).ReadUInt16( nCount );
|
2015-12-31 10:58:37 +01:00
|
|
|
sal_uInt64 nLast = r.Tell() + nLen;
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 nCharSet; // System charset
|
|
|
|
sal_uInt32 lDimBase;
|
|
|
|
sal_uInt16 nReserved1;
|
|
|
|
sal_uInt32 nReserved2;
|
|
|
|
sal_uInt32 nReserved3;
|
2012-09-07 04:59:11 +09:00
|
|
|
bool bBadVer = false;
|
2016-02-24 14:43:38 +01:00
|
|
|
if( nSign == static_cast<sal_uInt16>( FileOffset::Module ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2015-02-27 11:22:50 +02:00
|
|
|
sal_uInt16 nTmpFlags;
|
2014-02-05 10:41:04 +02:00
|
|
|
r.ReadUInt32( nVersion ).ReadUInt32( nCharSet ).ReadUInt32( lDimBase )
|
2015-02-27 11:22:50 +02:00
|
|
|
.ReadUInt16( nTmpFlags ).ReadUInt16( nReserved1 ).ReadUInt32( nReserved2 ).ReadUInt32( nReserved3 );
|
|
|
|
nFlags = static_cast<SbiImageFlags>(nTmpFlags);
|
2013-07-01 10:33:48 -05:00
|
|
|
eCharSet = nCharSet;
|
2001-08-07 10:20:11 +00:00
|
|
|
eCharSet = GetSOLoadTextEncoding( eCharSet );
|
2012-09-07 04:59:11 +09:00
|
|
|
bBadVer = ( nVersion > B_CURVERSION );
|
2011-01-10 14:40:57 +01:00
|
|
|
nDimBase = (sal_uInt16) lDimBase;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2006-11-01 15:13:02 +00:00
|
|
|
bool bLegacy = ( nVersion < B_EXT_IMG_VERSION );
|
|
|
|
|
2015-12-31 10:58:37 +01:00
|
|
|
sal_uInt64 nNext;
|
2000-09-18 15:18:56 +00:00
|
|
|
while( ( nNext = r.Tell() ) < nLast )
|
|
|
|
{
|
|
|
|
|
2014-02-05 10:41:04 +02:00
|
|
|
r.ReadUInt16( nSign ).ReadUInt32( nLen ).ReadUInt16( nCount );
|
2000-09-18 15:18:56 +00:00
|
|
|
nNext += nLen + 8;
|
|
|
|
if( r.GetError() == SVSTREAM_OK )
|
|
|
|
{
|
2016-02-24 14:43:38 +01:00
|
|
|
switch( static_cast<FileOffset>( nSign ) )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::Name:
|
2012-01-06 08:50:03 +00:00
|
|
|
aName = r.ReadUniOrByteString(eCharSet);
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::Comment:
|
2012-01-06 08:50:03 +00:00
|
|
|
aComment = r.ReadUniOrByteString(eCharSet );
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::Source:
|
2003-04-23 15:55:53 +00:00
|
|
|
{
|
2012-01-06 08:50:03 +00:00
|
|
|
aOUSource = r.ReadUniOrByteString(eCharSet);
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
2003-04-23 15:55:53 +00:00
|
|
|
}
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::ExtSource:
|
2005-05-18 12:07:10 +00:00
|
|
|
{
|
2014-11-05 16:33:55 +00:00
|
|
|
//assuming an empty string with just the lead 32bit/16bit len indicator
|
|
|
|
const size_t nMinStringSize = (eCharSet == RTL_TEXTENCODING_UNICODE) ? 4 : 2;
|
2015-12-31 10:58:37 +01:00
|
|
|
const sal_uInt64 nMaxStrings = r.remainingSize() / nMinStringSize;
|
2014-11-05 16:33:55 +00:00
|
|
|
if (nCount > nMaxStrings)
|
|
|
|
{
|
|
|
|
SAL_WARN("basic", "Parsing error: " << nMaxStrings <<
|
|
|
|
" max possible entries, but " << nCount << " claimed, truncating");
|
|
|
|
nCount = nMaxStrings;
|
|
|
|
}
|
|
|
|
for( sal_uInt16 j = 0; j < nCount; ++j)
|
2005-05-18 12:07:10 +00:00
|
|
|
{
|
2012-11-06 23:34:23 -06:00
|
|
|
aOUSource += r.ReadUniOrByteString(eCharSet);
|
2005-05-18 12:07:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::PCode:
|
2000-09-18 15:18:56 +00:00
|
|
|
if( bBadVer ) break;
|
|
|
|
pCode = new char[ nLen ];
|
2006-11-01 15:13:02 +00:00
|
|
|
nCodeSize = nLen;
|
2016-06-03 14:45:59 +02:00
|
|
|
r.ReadBytes(pCode, nCodeSize);
|
2006-11-01 15:13:02 +00:00
|
|
|
if ( bLegacy )
|
|
|
|
{
|
|
|
|
ReleaseLegacyBuffer(); // release any previously held buffer
|
2011-01-10 14:40:57 +01:00
|
|
|
nLegacyCodeSize = (sal_uInt16) nCodeSize;
|
2006-11-01 15:13:02 +00:00
|
|
|
pLegacyPCode = pCode;
|
|
|
|
|
2015-01-17 18:13:51 +01:00
|
|
|
PCodeBuffConvertor< sal_uInt16, sal_uInt32 > aLegacyToNew( reinterpret_cast<sal_uInt8*>(pLegacyPCode), nLegacyCodeSize );
|
2006-11-01 15:13:02 +00:00
|
|
|
aLegacyToNew.convert();
|
2015-01-17 18:13:51 +01:00
|
|
|
pCode = reinterpret_cast<char*>(aLegacyToNew.GetBuffer());
|
2006-11-01 15:13:02 +00:00
|
|
|
nCodeSize = aLegacyToNew.GetSize();
|
|
|
|
// we don't release the legacy buffer
|
|
|
|
// right now, thats because the module
|
|
|
|
// needs it to fix up the method
|
|
|
|
// nStart members. When that is done
|
|
|
|
// the module can release the buffer
|
|
|
|
// or it can wait until this routine
|
|
|
|
// is called again or when this class // destructs all of which will trigger
|
|
|
|
// release of the buffer.
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::Publics:
|
|
|
|
case FileOffset::PoolDir:
|
|
|
|
case FileOffset::SymPool:
|
|
|
|
case FileOffset::LineRanges:
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::StringPool:
|
2014-11-14 10:19:24 +00:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
if( bBadVer ) break;
|
2014-11-14 10:19:24 +00:00
|
|
|
//assuming an empty string with just the lead 32bit len indicator
|
2015-12-31 10:58:37 +01:00
|
|
|
const sal_uInt64 nMinStringSize = 4;
|
|
|
|
const sal_uInt64 nMaxStrings = r.remainingSize() / nMinStringSize;
|
2014-11-14 10:19:24 +00:00
|
|
|
if (nCount > nMaxStrings)
|
|
|
|
{
|
|
|
|
SAL_WARN("basic", "Parsing error: " << nMaxStrings <<
|
|
|
|
" max possible entries, but " << nCount << " claimed, truncating");
|
|
|
|
nCount = nMaxStrings;
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
MakeStrings( nCount );
|
2011-02-10 14:48:51 +01:00
|
|
|
short i;
|
2000-09-18 15:18:56 +00:00
|
|
|
for( i = 0; i < nStrings && SbiGood( r ); i++ )
|
|
|
|
{
|
2014-02-05 10:41:04 +02:00
|
|
|
r.ReadUInt32( nOff );
|
2011-01-10 14:40:57 +01:00
|
|
|
pStringOff[ i ] = (sal_uInt16) nOff;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-02-05 10:41:04 +02:00
|
|
|
r.ReadUInt32( nLen );
|
2000-09-18 15:18:56 +00:00
|
|
|
if( SbiGood( r ) )
|
|
|
|
{
|
2003-05-22 10:01:17 +00:00
|
|
|
delete [] pStrings;
|
2000-09-18 15:18:56 +00:00
|
|
|
pStrings = new sal_Unicode[ nLen ];
|
2011-01-10 14:40:57 +01:00
|
|
|
nStringSize = (sal_uInt16) nLen;
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2015-06-15 17:58:15 +09:00
|
|
|
std::unique_ptr<char[]> pByteStrings(new char[ nLen ]);
|
2016-06-03 14:45:59 +02:00
|
|
|
r.ReadBytes(pByteStrings.get(), nStringSize);
|
2006-06-19 16:39:15 +00:00
|
|
|
for( short j = 0; j < nStrings; j++ )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 nOff2 = (sal_uInt16) pStringOff[ j ];
|
2014-07-16 17:41:15 +09:00
|
|
|
OUString aStr( pByteStrings.get() + nOff2, strlen(pByteStrings.get() + nOff2), eCharSet );
|
2012-11-06 23:34:23 -06:00
|
|
|
memcpy( pStrings + nOff2, aStr.getStr(), (aStr.getLength() + 1) * sizeof( sal_Unicode ) );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
|
|
|
break;
|
2014-11-14 10:19:24 +00:00
|
|
|
}
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::UserTypes:
|
2015-08-23 12:52:52 +01:00
|
|
|
{
|
|
|
|
//assuming an empty string with just the lead 32bit/16bit len indicator
|
|
|
|
const size_t nMinStringSize = (eCharSet == RTL_TEXTENCODING_UNICODE) ? 4 : 2;
|
2015-12-31 10:58:37 +01:00
|
|
|
const sal_uInt64 nMinRecordSize = nMinStringSize + sizeof(sal_Int16);
|
|
|
|
const sal_uInt64 nMaxRecords = r.remainingSize() / nMinRecordSize;
|
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>
2015-08-19 17:58:12 +02:00
|
|
|
if (nCount > nMaxRecords)
|
2015-08-23 12:52:52 +01:00
|
|
|
{
|
|
|
|
SAL_WARN("basic", "Parsing error: " << nMaxRecords <<
|
|
|
|
" max possible entries, but " << nCount << " claimed, truncating");
|
|
|
|
nCount = nMaxRecords;
|
|
|
|
}
|
2015-08-17 13:28:16 +02:00
|
|
|
|
|
|
|
// User defined types
|
|
|
|
for (sal_uInt16 i = 0; i < nCount; i++)
|
|
|
|
{
|
|
|
|
OUString aTypeName = r.ReadUniOrByteString(eCharSet);
|
|
|
|
|
2015-09-01 09:25:54 +01:00
|
|
|
sal_uInt16 nTypeMembers;
|
|
|
|
r.ReadUInt16(nTypeMembers);
|
|
|
|
|
2015-12-31 10:58:37 +01:00
|
|
|
const sal_uInt64 nMaxTypeMembers = r.remainingSize() / 8;
|
2015-09-01 09:25:54 +01:00
|
|
|
if (nTypeMembers > nMaxTypeMembers)
|
|
|
|
{
|
|
|
|
SAL_WARN("basic", "Parsing error: " << nMaxTypeMembers <<
|
|
|
|
" max possible entries, but " << nTypeMembers << " claimed, truncating");
|
|
|
|
nTypeMembers = nMaxTypeMembers;
|
|
|
|
}
|
2015-08-17 13:28:16 +02:00
|
|
|
|
|
|
|
SbxObject *pType = new SbxObject(aTypeName);
|
|
|
|
SbxArray *pTypeMembers = pType->GetProperties();
|
|
|
|
|
|
|
|
for (sal_uInt16 j = 0; j < nTypeMembers; j++)
|
|
|
|
{
|
|
|
|
OUString aMemberName = r.ReadUniOrByteString(eCharSet);
|
|
|
|
|
|
|
|
sal_Int16 aIntMemberType;
|
|
|
|
r.ReadInt16(aIntMemberType);
|
|
|
|
SbxDataType aMemberType = static_cast< SbxDataType > ( aIntMemberType );
|
|
|
|
|
|
|
|
SbxProperty *pTypeElem = new SbxProperty( aMemberName, aMemberType );
|
|
|
|
|
|
|
|
sal_uInt32 aIntFlag;
|
|
|
|
r.ReadUInt32(aIntFlag);
|
|
|
|
SbxFlagBits nElemFlags = static_cast< SbxFlagBits > ( aIntFlag );
|
|
|
|
|
|
|
|
pTypeElem->SetFlags(nElemFlags);
|
|
|
|
|
|
|
|
sal_Int16 hasObject;
|
|
|
|
r.ReadInt16(hasObject);
|
|
|
|
|
|
|
|
if (hasObject == 1)
|
|
|
|
{
|
|
|
|
if(aMemberType == SbxOBJECT)
|
|
|
|
{
|
|
|
|
// nested user defined types
|
|
|
|
// declared before use, so it is ok to reference it by name on load
|
|
|
|
OUString aNestedTypeName = r.ReadUniOrByteString(eCharSet);
|
2016-05-21 16:22:07 +02:00
|
|
|
SbxObject* pNestedTypeObj = static_cast< SbxObject* >( rTypes->Find( aNestedTypeName, SbxClassType::Object ) );
|
2015-08-17 13:28:16 +02:00
|
|
|
if (pNestedTypeObj)
|
|
|
|
{
|
|
|
|
SbxObject* pCloneObj = cloneTypeObjectImpl( *pNestedTypeObj );
|
|
|
|
pTypeElem->PutObject( pCloneObj );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// an array
|
|
|
|
SbxDimArray* pArray = new SbxDimArray();
|
|
|
|
|
|
|
|
sal_Int16 isFixedSize;
|
|
|
|
r.ReadInt16(isFixedSize);
|
|
|
|
if (isFixedSize == 1)
|
|
|
|
pArray->setHasFixedSize( true );
|
|
|
|
|
|
|
|
sal_Int32 nDims;
|
|
|
|
r.ReadInt32(nDims);
|
|
|
|
for (sal_Int32 d = 0; d < nDims; d++)
|
|
|
|
{
|
|
|
|
sal_Int32 lBound;
|
|
|
|
sal_Int32 uBound;
|
|
|
|
r.ReadInt32(lBound).ReadInt32(uBound);
|
|
|
|
pArray->unoAddDim32(lBound, uBound);
|
|
|
|
}
|
|
|
|
|
|
|
|
pTypeElem->PutObject( pArray );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pTypeMembers->Insert( pTypeElem, pTypeMembers->Count() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-21 16:22:07 +02:00
|
|
|
pType->Remove( "Name", SbxClassType::DontCare );
|
|
|
|
pType->Remove( "Parent", SbxClassType::DontCare );
|
2015-08-17 13:28:16 +02:00
|
|
|
|
|
|
|
AddType(pType);
|
|
|
|
}
|
|
|
|
break;
|
2015-08-23 12:52:52 +01:00
|
|
|
}
|
2016-02-24 14:43:38 +01:00
|
|
|
case FileOffset::ModEnd:
|
2000-09-18 15:18:56 +00:00
|
|
|
goto done;
|
|
|
|
default:
|
|
|
|
break;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
else
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
break;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
r.Seek( nNext );
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
r.Seek( nLast );
|
|
|
|
if( !SbiGood( r ) )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2012-08-12 09:07:20 +09:00
|
|
|
bError = true;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2012-08-15 09:44:54 +09:00
|
|
|
return !bError;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2012-08-15 09:44:54 +09:00
|
|
|
bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-11-01 15:13:02 +00:00
|
|
|
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 );
|
2012-08-15 09:44:54 +09:00
|
|
|
return true;
|
2006-11-01 15:13:02 +00:00
|
|
|
}
|
2009-04-25 00:18:20 +00:00
|
|
|
// First of all the header
|
2016-02-24 14:43:38 +01:00
|
|
|
sal_uInt64 nStart = SbiOpenRecord( r, FileOffset::Module, 1 );
|
2015-12-31 10:58:37 +01:00
|
|
|
sal_uInt64 nPos;
|
2001-08-07 10:20:11 +00:00
|
|
|
|
|
|
|
eCharSet = GetSOStoreTextEncoding( eCharSet );
|
2006-11-01 15:13:02 +00:00
|
|
|
if ( bLegacy )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2014-09-25 20:16:26 +02:00
|
|
|
r.WriteInt32( B_LEGACYVERSION );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2006-11-01 15:13:02 +00:00
|
|
|
else
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2014-09-25 20:16:26 +02:00
|
|
|
r.WriteInt32( B_CURVERSION );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2014-09-25 20:16:26 +02:00
|
|
|
r .WriteInt32( eCharSet )
|
|
|
|
.WriteInt32( nDimBase )
|
2015-02-27 11:22:50 +02:00
|
|
|
.WriteInt16( static_cast<sal_uInt16>(nFlags) )
|
2015-01-16 08:07:06 +02:00
|
|
|
.WriteInt16( 0 )
|
2014-09-25 20:16:26 +02:00
|
|
|
.WriteInt32( 0 )
|
|
|
|
.WriteInt32( 0 );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// Name?
|
2012-11-06 23:34:23 -06:00
|
|
|
if( !aName.isEmpty() && SbiGood( r ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2016-02-24 14:43:38 +01:00
|
|
|
nPos = SbiOpenRecord( r, FileOffset::Name, 1 );
|
2011-12-21 10:45:54 +00:00
|
|
|
r.WriteUniOrByteString( aName, eCharSet );
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiCloseRecord( r, nPos );
|
|
|
|
}
|
2009-04-25 00:18:20 +00:00
|
|
|
// Comment?
|
2012-11-06 23:34:23 -06:00
|
|
|
if( !aComment.isEmpty() && SbiGood( r ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2016-02-24 14:43:38 +01:00
|
|
|
nPos = SbiOpenRecord( r, FileOffset::Comment, 1 );
|
2011-12-21 10:45:54 +00:00
|
|
|
r.WriteUniOrByteString( aComment, eCharSet );
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiCloseRecord( r, nPos );
|
|
|
|
}
|
|
|
|
// Source?
|
2011-12-10 13:35:14 -02:00
|
|
|
if( !aOUSource.isEmpty() && SbiGood( r ) )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2016-02-24 14:43:38 +01:00
|
|
|
nPos = SbiOpenRecord( r, FileOffset::Source, 1 );
|
2013-07-01 10:33:48 -05:00
|
|
|
r.WriteUniOrByteString( aOUSource, eCharSet );
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiCloseRecord( r, nPos );
|
|
|
|
}
|
2009-04-25 00:18:20 +00:00
|
|
|
// Binary data?
|
2000-09-18 15:18:56 +00:00
|
|
|
if( pCode && SbiGood( r ) )
|
|
|
|
{
|
2016-02-24 14:43:38 +01:00
|
|
|
nPos = SbiOpenRecord( r, FileOffset::PCode, 1 );
|
2006-11-01 15:13:02 +00:00
|
|
|
if ( bLegacy )
|
|
|
|
{
|
|
|
|
ReleaseLegacyBuffer(); // release any previously held buffer
|
2015-01-17 18:13:51 +01:00
|
|
|
PCodeBuffConvertor< sal_uInt32, sal_uInt16 > aNewToLegacy( reinterpret_cast<sal_uInt8*>(pCode), nCodeSize );
|
2006-11-01 15:13:02 +00:00
|
|
|
aNewToLegacy.convert();
|
2015-01-17 18:13:51 +01:00
|
|
|
pLegacyPCode = reinterpret_cast<char*>(aNewToLegacy.GetBuffer());
|
2006-11-01 15:13:02 +00:00
|
|
|
nLegacyCodeSize = aNewToLegacy.GetSize();
|
2016-06-03 14:45:59 +02:00
|
|
|
r.WriteBytes(pLegacyPCode, nLegacyCodeSize);
|
2006-11-01 15:13:02 +00:00
|
|
|
}
|
|
|
|
else
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2016-06-03 14:45:59 +02:00
|
|
|
r.WriteBytes(pCode, nCodeSize);
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiCloseRecord( r, nPos );
|
|
|
|
}
|
|
|
|
// String-Pool?
|
|
|
|
if( nStrings )
|
|
|
|
{
|
2016-02-24 14:43:38 +01:00
|
|
|
nPos = SbiOpenRecord( r, FileOffset::StringPool, nStrings );
|
2009-04-25 00:18:20 +00:00
|
|
|
// For every String:
|
2011-01-10 14:40:57 +01:00
|
|
|
// sal_uInt32 Offset of the Strings in the Stringblock
|
2003-12-01 15:26:51 +00:00
|
|
|
short i;
|
|
|
|
|
|
|
|
for( i = 0; i < nStrings && SbiGood( r ); i++ )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2014-09-25 20:19:30 +02:00
|
|
|
r.WriteUInt32( pStringOff[ i ] );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2009-04-25 00:18:20 +00:00
|
|
|
// Then the String-Block
|
2015-06-15 17:58:15 +09:00
|
|
|
std::unique_ptr<char[]> pByteStrings(new char[ nStringSize ]);
|
2000-09-18 15:18:56 +00:00
|
|
|
for( i = 0; i < nStrings; i++ )
|
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 nOff = (sal_uInt16) pStringOff[ i ];
|
2013-04-07 12:06:47 +02:00
|
|
|
OString aStr(OUStringToOString(OUString(pStrings + nOff), eCharSet));
|
2014-07-16 17:41:15 +09:00
|
|
|
memcpy( pByteStrings.get() + nOff, aStr.getStr(), (aStr.getLength() + 1) * sizeof( char ) );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2014-09-25 20:19:30 +02:00
|
|
|
r.WriteUInt32( nStringSize );
|
2016-06-03 14:45:59 +02:00
|
|
|
r.WriteBytes(pByteStrings.get(), nStringSize);
|
2003-03-18 15:28:40 +00:00
|
|
|
|
2014-07-16 17:41:15 +09:00
|
|
|
pByteStrings.reset();
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiCloseRecord( r, nPos );
|
|
|
|
}
|
2015-08-17 13:28:16 +02:00
|
|
|
// User defined types
|
2015-08-18 13:40:42 +02:00
|
|
|
if (rTypes)
|
2015-08-17 13:28:16 +02:00
|
|
|
{
|
2015-08-18 13:40:42 +02:00
|
|
|
sal_uInt16 nTypes = rTypes->Count();
|
|
|
|
if (nTypes > 0 )
|
2015-08-17 13:28:16 +02:00
|
|
|
{
|
2016-02-24 14:43:38 +01:00
|
|
|
nPos = SbiOpenRecord( r, FileOffset::UserTypes, nTypes );
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
for (sal_uInt16 i = 0; i < nTypes; i++)
|
|
|
|
{
|
|
|
|
SbxObject* pType = static_cast< SbxObject* > ( rTypes->Get(i) );
|
|
|
|
OUString aTypeName = pType->GetClassName();
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
r.WriteUniOrByteString( aTypeName, eCharSet );
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
SbxArray *pTypeMembers = pType->GetProperties();
|
|
|
|
sal_uInt16 nTypeMembers = pTypeMembers->Count();
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
r.WriteInt16(nTypeMembers);
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
for (sal_uInt16 j = 0; j < nTypeMembers; j++)
|
|
|
|
{
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
SbxProperty* pTypeElem = static_cast< SbxProperty* > ( pTypeMembers->Get(j) );
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
OUString aElemName = pTypeElem->GetName();
|
|
|
|
r.WriteUniOrByteString( aElemName, eCharSet );
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
SbxDataType dataType = pTypeElem->GetType();
|
|
|
|
r.WriteInt16(dataType);
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
SbxFlagBits nElemFlags = pTypeElem->GetFlags();
|
|
|
|
r.WriteUInt32(static_cast< sal_uInt32 > (nElemFlags) );
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
SbxBase* pElemObject = pTypeElem->GetObject();
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
if (pElemObject)
|
2015-08-17 13:28:16 +02:00
|
|
|
{
|
2015-08-18 13:40:42 +02:00
|
|
|
r.WriteInt16(1); // has elem Object
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
if( dataType == SbxOBJECT )
|
|
|
|
{
|
|
|
|
// nested user defined types
|
|
|
|
// declared before use, so it is ok to reference it by name on load
|
|
|
|
SbxObject* pNestedType = static_cast< SbxObject* > ( pElemObject );
|
|
|
|
r.WriteUniOrByteString( pNestedType->GetClassName(), eCharSet );
|
|
|
|
}
|
2015-08-17 13:28:16 +02:00
|
|
|
else
|
2015-08-18 13:40:42 +02:00
|
|
|
{
|
|
|
|
// an array
|
|
|
|
SbxDimArray* pArray = static_cast< SbxDimArray* > ( pElemObject );
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
bool bFixedSize = pArray->hasFixedSize();
|
|
|
|
if (bFixedSize)
|
|
|
|
r.WriteInt16(1);
|
|
|
|
else
|
|
|
|
r.WriteInt16(0);
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
sal_Int32 nDims = pArray->GetDims();
|
|
|
|
r.WriteInt32(nDims);
|
|
|
|
|
|
|
|
for (sal_Int32 d = 0; d < nDims; d++)
|
|
|
|
{
|
|
|
|
sal_Int32 lBound;
|
|
|
|
sal_Int32 uBound;
|
|
|
|
pArray->GetDim32(d, lBound, uBound);
|
|
|
|
r.WriteInt32(lBound).WriteInt32(uBound);
|
|
|
|
}
|
2015-08-17 13:28:16 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-18 13:40:42 +02:00
|
|
|
else
|
|
|
|
r.WriteInt16(0); // no elem Object
|
2015-08-17 13:28:16 +02:00
|
|
|
|
2015-08-18 13:40:42 +02:00
|
|
|
}
|
2015-08-17 13:28:16 +02:00
|
|
|
}
|
2015-08-18 13:40:42 +02:00
|
|
|
SbiCloseRecord( r, nPos );
|
2015-08-17 13:28:16 +02:00
|
|
|
}
|
|
|
|
}
|
2009-04-25 00:18:20 +00:00
|
|
|
// Set overall length
|
2000-09-18 15:18:56 +00:00
|
|
|
SbiCloseRecord( r, nStart );
|
|
|
|
if( !SbiGood( r ) )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2012-08-12 09:07:20 +09:00
|
|
|
bError = true;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2012-08-15 09:44:54 +09:00
|
|
|
return !bError;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
2009-04-25 00:18:20 +00:00
|
|
|
* Routines called by the compiler
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
void SbiImage::MakeStrings( short nSize )
|
|
|
|
{
|
2006-11-03 06:39:47 +00:00
|
|
|
nStrings = 0;
|
|
|
|
nStringIdx = 0;
|
|
|
|
nStringOff = 0;
|
2000-09-18 15:18:56 +00:00
|
|
|
nStringSize = 1024;
|
|
|
|
pStrings = new sal_Unicode[ nStringSize ];
|
2011-01-10 14:40:57 +01:00
|
|
|
pStringOff = new sal_uInt32[ nSize ];
|
2015-03-11 09:06:08 +00:00
|
|
|
nStrings = nSize;
|
|
|
|
memset( pStringOff, 0, nSize * sizeof( sal_uInt32 ) );
|
|
|
|
memset( pStrings, 0, nStringSize * sizeof( sal_Unicode ) );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Add a string to StringPool. The String buffer is dynamically
|
|
|
|
// growing in 1K-Steps
|
2012-11-06 23:34:23 -06:00
|
|
|
void SbiImage::AddString( const OUString& r )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
if( nStringIdx >= nStrings )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2012-08-12 09:07:20 +09:00
|
|
|
bError = true;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
if( !bError )
|
|
|
|
{
|
2012-11-06 23:34:23 -06:00
|
|
|
sal_Int32 len = r.getLength() + 1;
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 needed = nStringOff + len;
|
2016-08-03 10:18:16 +05:30
|
|
|
if( needed > 0xFFFFFF00 )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2012-08-12 09:07:20 +09:00
|
|
|
bError = true; // out of mem!
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2006-11-01 15:13:02 +00:00
|
|
|
else if( needed > nStringSize )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 nNewLen = needed + 1024;
|
2005-09-29 17:38:33 +00:00
|
|
|
nNewLen &= 0xFFFFFC00; // trim to 1K border
|
2015-03-11 09:06:08 +00:00
|
|
|
sal_Unicode* p = new sal_Unicode[nNewLen];
|
|
|
|
memcpy( p, pStrings, nStringSize * sizeof( sal_Unicode ) );
|
|
|
|
delete[] pStrings;
|
|
|
|
pStrings = p;
|
|
|
|
nStringSize = sal::static_int_cast< sal_uInt16 >(nNewLen);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
if( !bError )
|
|
|
|
{
|
|
|
|
pStringOff[ nStringIdx++ ] = nStringOff;
|
2012-11-06 23:34:23 -06:00
|
|
|
memcpy( pStrings + nStringOff, r.getStr(), len * sizeof( sal_Unicode ) );
|
2006-10-12 13:25:10 +00:00
|
|
|
nStringOff = nStringOff + len;
|
2009-04-25 00:18:20 +00:00
|
|
|
// Last String? The update the size of the buffer
|
2000-09-18 15:18:56 +00:00
|
|
|
if( nStringIdx >= nStrings )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2000-09-18 15:18:56 +00:00
|
|
|
nStringSize = nStringOff;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Add code block
|
|
|
|
// The block was fetched by the compiler from class SbBuffer and
|
|
|
|
// is already created with new. Additionally it contains all Integers
|
|
|
|
// in Big Endian format, so can be directly read/written.
|
2011-01-10 14:40:57 +01:00
|
|
|
void SbiImage::AddCode( char* p, sal_uInt32 s )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
pCode = p;
|
|
|
|
nCodeSize = s;
|
|
|
|
}
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Add user type
|
|
|
|
void SbiImage::AddType(SbxObject* pObject)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2004-11-15 15:34:02 +00:00
|
|
|
if( !rTypes.Is() )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2004-11-15 15:34:02 +00:00
|
|
|
rTypes = new SbxArray;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
SbxObject *pCopyObject = new SbxObject(*pObject);
|
|
|
|
rTypes->Insert (pCopyObject,rTypes->Count());
|
|
|
|
}
|
|
|
|
|
2004-11-15 15:34:02 +00:00
|
|
|
void SbiImage::AddEnum(SbxObject* pObject) // Register enum type
|
|
|
|
{
|
|
|
|
if( !rEnums.Is() )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2004-11-15 15:34:02 +00:00
|
|
|
rEnums = new SbxArray;
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2004-11-15 15:34:02 +00:00
|
|
|
rEnums->Insert( pObject, rEnums->Count() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2009-04-25 00:18:20 +00:00
|
|
|
* Accessing the image
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Note: IDs start with 1
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString SbiImage::GetString( short nId ) const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
if( nId && nId <= nStrings )
|
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 nOff = pStringOff[ nId - 1 ];
|
2005-03-29 10:47:59 +00:00
|
|
|
sal_Unicode* pStr = pStrings + nOff;
|
|
|
|
|
|
|
|
// #i42467: Special treatment for vbNullChar
|
|
|
|
if( *pStr == 0 )
|
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 nNextOff = (nId < nStrings) ? pStringOff[ nId ] : nStringOff;
|
|
|
|
sal_uInt32 nLen = nNextOff - nOff - 1;
|
2005-03-29 10:47:59 +00:00
|
|
|
if( nLen == 1 )
|
|
|
|
{
|
|
|
|
// Force length 1 and make char 0 afterwards
|
2012-11-06 23:34:23 -06:00
|
|
|
OUString aNullCharStr( (sal_Unicode)0);
|
2005-03-29 10:47:59 +00:00
|
|
|
return aNullCharStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2012-11-06 23:34:23 -06:00
|
|
|
{
|
|
|
|
return OUString(pStr);
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
2012-11-06 23:34:23 -06:00
|
|
|
return OUString();
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2014-03-12 15:36:41 +02:00
|
|
|
const SbxObject* SbiImage::FindType (const OUString& aTypeName) const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2016-05-21 16:22:07 +02:00
|
|
|
return rTypes.Is() ? static_cast<SbxObject*>(rTypes->Find(aTypeName,SbxClassType::Object)) : nullptr;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt16 SbiImage::CalcLegacyOffset( sal_Int32 nOffset )
|
2006-11-01 15:13:02 +00:00
|
|
|
{
|
2015-01-17 18:13:51 +01:00
|
|
|
return SbiCodeGen::calcLegacyOffSet( reinterpret_cast<sal_uInt8*>(pCode), nOffset ) ;
|
2006-11-01 15:13:02 +00:00
|
|
|
}
|
2009-04-25 00:18:20 +00:00
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_uInt32 SbiImage::CalcNewOffset( sal_Int16 nOffset )
|
2006-11-01 15:13:02 +00:00
|
|
|
{
|
2015-01-17 18:13:51 +01:00
|
|
|
return SbiCodeGen::calcNewOffSet( reinterpret_cast<sal_uInt8*>(pLegacyPCode), nOffset ) ;
|
2006-11-01 15:13:02 +00:00
|
|
|
}
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
void SbiImage::ReleaseLegacyBuffer()
|
2006-11-01 15:13:02 +00:00
|
|
|
{
|
|
|
|
delete[] pLegacyPCode;
|
2015-11-10 10:10:36 +01:00
|
|
|
pLegacyPCode = nullptr;
|
2006-11-01 15:13:02 +00:00
|
|
|
nLegacyCodeSize = 0;
|
|
|
|
}
|
|
|
|
|
2012-08-15 09:44:54 +09:00
|
|
|
bool SbiImage::ExceedsLegacyLimits()
|
2006-11-01 15:13:02 +00:00
|
|
|
{
|
2016-08-03 10:18:16 +05:30
|
|
|
return ( nStringSize > 0xFF00 ) || ( CalcLegacyOffset( nCodeSize ) > 0xFF00 );
|
2006-11-01 15:13:02 +00:00
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|