summaryrefslogtreecommitdiff
path: root/sd/source/filter/ppt/propread.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-09-18 12:46:29 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-09-18 13:09:12 +0100
commit8523e57e427ef5b0b7f7067dcdd07f01176d2160 (patch)
treede5e2d46fca72792a454acab53804ff2b3b6ca5c /sd/source/filter/ppt/propread.cxx
parent1fa2398967d85abdd23fb233494d411276853760 (diff)
rework this so we don't read the string, backup and re-read the string again
Change-Id: If2715430a153fd86e7000af2c91bcdfc60464046
Diffstat (limited to 'sd/source/filter/ppt/propread.cxx')
-rw-r--r--sd/source/filter/ppt/propread.cxx75
1 files changed, 36 insertions, 39 deletions
diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx
index cc12ff0a2068..9fd2501ff732 100644
--- a/sd/source/filter/ppt/propread.cxx
+++ b/sd/source/filter/ppt/propread.cxx
@@ -269,10 +269,8 @@ void Section::AddProperty( sal_uInt32 nId, const sal_uInt8* pBuf, sal_uInt32 nBu
maEntries.push_back( new PropEntry( nId, pBuf, nBufSize, mnTextEnc ) );
}
-bool Section::GetDictionary( Dictionary& rDict )
+void Section::GetDictionary(Dictionary& rDict)
{
- bool bRetValue = false;
-
boost::ptr_vector<PropEntry>::iterator iter;
for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
{
@@ -280,48 +278,47 @@ bool Section::GetDictionary( Dictionary& rDict )
break;
}
- if ( iter != maEntries.end() )
+ if (iter == maEntries.end())
+ return;
+
+ SvMemoryStream aStream( iter->mpBuf, iter->mnSize, StreamMode::READ );
+ aStream.Seek( STREAM_SEEK_TO_BEGIN );
+ sal_uInt32 nDictCount(0);
+ aStream.ReadUInt32( nDictCount );
+ for (sal_uInt32 i = 0; i < nDictCount; ++i)
{
- sal_uInt32 nDictCount, nId, nSize, nPos;
- SvMemoryStream aStream( iter->mpBuf, iter->mnSize, StreamMode::READ );
- aStream.Seek( STREAM_SEEK_TO_BEGIN );
- aStream.ReadUInt32( nDictCount );
- for ( sal_uInt32 i = 0; i < nDictCount; i++ )
+ sal_uInt32 nId(0), nSize(0);
+ aStream.ReadUInt32( nId ).ReadUInt32( nSize );
+ if (!nSize)
+ continue;
+ OUString aString;
+ try
{
- aStream.ReadUInt32( nId ).ReadUInt32( nSize );
- if ( nSize )
+ if ( mnTextEnc == RTL_TEXTENCODING_UCS2 )
{
- OUString aString;
- nPos = aStream.Tell();
- try
- {
- sal_Char* pString = new sal_Char[ nSize ];
- aStream.Read( pString, nSize );
- if ( mnTextEnc == RTL_TEXTENCODING_UCS2 )
- {
- nSize >>= 1;
- aStream.Seek( nPos );
- sal_Unicode* pWString = reinterpret_cast<sal_Unicode*>(pString);
- for (sal_uInt32 j = 0; j < nSize; ++j)
- aStream.ReadUInt16(pWString[j]);
- aString = OUString(pWString, lcl_getMaxSafeStrLen(nSize));
- }
- else
- aString = OUString(pString, lcl_getMaxSafeStrLen(nSize), mnTextEnc);
- delete[] pString;
- }
- catch( const std::bad_alloc& )
- {
- OSL_FAIL( "sd Section::GetDictionary bad alloc" );
- }
- if ( aString.isEmpty() )
- break;
- rDict.insert( std::make_pair(aString,nId) );
+ nSize >>= 1;
+ sal_Unicode* pWString = new sal_Unicode[nSize];
+ for (sal_uInt32 j = 0; j < nSize; ++j)
+ aStream.ReadUInt16(pWString[j]);
+ aString = OUString(pWString, lcl_getMaxSafeStrLen(nSize));
+ delete[] pWString;
}
- bRetValue = true;
+ else
+ {
+ sal_Char* pString = new sal_Char[nSize];
+ aStream.Read(pString, nSize);
+ aString = OUString(pString, lcl_getMaxSafeStrLen(nSize), mnTextEnc);
+ delete[] pString;
+ }
+ }
+ catch( const std::bad_alloc& )
+ {
+ OSL_FAIL( "sd Section::GetDictionary bad alloc" );
}
+ if (aString.isEmpty())
+ break;
+ rDict.insert( std::make_pair(aString,nId) );
}
- return bRetValue;
}
void Section::Read( SotStorageStream *pStrm )