summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-11-12 16:03:14 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-11-12 20:25:24 +0000
commitd72b93a5a64ecc5f620a6af999a605385a0b997a (patch)
tree37f84c6f6afeabd943eac2e6d331bd4277cf42f0 /svl
parent6cec5d9725375bc2254e44324610e6f44f1f5143 (diff)
drop pool ver 1 import support
this unloved streaming format is internal only now and used for editengine c&p and (reportedly) autotable format storage. So we shouldn't encounter version 1 files anymore coverity#1242764 Untrusted loop bound Change-Id: If8e5717e997cf915f45f6e9484bb97d472e4dc2f
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/poolio.cxx280
1 files changed, 2 insertions, 278 deletions
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index b86d25a4facb..6c09ef373d64 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -510,13 +510,8 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
pImp->mpMaster->pImp->nMajorVer = pImp->nMajorVer;
pImp->mpMaster->pImp->nMinorVer = pImp->nMinorVer;
- // Old Format?
- if ( pImp->nMajorVer < 2 )
- // pImp->bStreaming is reset by Load1_Impl()
- return Load1_Impl( rStream );
-
- // New Format?
- if ( pImp->nMajorVer > SFX_ITEMPOOL_VER_MAJOR )
+ // Unknown Format
+ if (pImp->nMajorVer < 2 || pImp->nMajorVer > SFX_ITEMPOOL_VER_MAJOR)
{
rStream.SetError(SVSTREAM_FILEFORMAT_ERROR);
pImp->bStreaming = false;
@@ -709,277 +704,6 @@ sal_uInt16 SfxItemPool::GetSize_Impl() const
return pImp->mnEnd - pImp->mnStart + 1;
}
-
-SvStream &SfxItemPool::Load1_Impl(SvStream &rStream)
-{
- // For the Master the Header has already been loaded in Load()
- if ( !pImp->bStreaming )
- {
- // Read the secondary's Header
- CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_STARTPOOL_4 );
- rStream.ReadUChar( pImp->nMajorVer ).ReadUChar( pImp->nMinorVer );
- }
- sal_uInt32 nAttribSize(0);
- OUString aExternName;
- if ( pImp->nMajorVer > 1 || pImp->nMinorVer >= 2 )
- rStream.ReadUInt16( pImp->nLoadingVersion );
- aExternName = readByteString(rStream);
- bool bOwnPool = aExternName == pImp->aName;
- pImp->bStreaming = true;
-
- //! As long as we cannot read foreign ones
- if ( !bOwnPool )
- {
- rStream.SetError(SVSTREAM_FILEFORMAT_ERROR);
- pImp->bStreaming = false;
- return rStream;
- }
-
- // Versions up to 1.3 cannot read WhichMoves
- if ( pImp->nMajorVer == 1 && pImp->nMinorVer <= 2 &&
- pImp->nVersion < pImp->nLoadingVersion )
- {
- rStream.SetError(ERRCODE_IO_WRONGVERSION);
- pImp->bStreaming = false;
- return rStream;
- }
-
- // SizeTable comes after the actual attributes
- rStream.ReadUInt32( nAttribSize );
-
- // Read SizeTable
- sal_uLong nStartPos = rStream.Tell();
- rStream.SeekRel( nAttribSize );
- CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_SIZES );
- sal_uInt32 nSizeTableLen(0);
- rStream.ReadUInt32( nSizeTableLen );
- boost::scoped_array<sal_Char> pBuf(new sal_Char[nSizeTableLen]);
- rStream.Read( pBuf.get(), nSizeTableLen );
- sal_uLong nEndOfSizes = rStream.Tell();
- SvMemoryStream aSizeTable( pBuf.get(), nSizeTableLen, STREAM_READ );
-
- // Starting with version 1.3 the SizeTable contains a versions map
- if ( pImp->nMajorVer > 1 || pImp->nMinorVer >= 3 )
- {
- // Find version map (last sal_uLong of the SizeTable determines position)
- rStream.Seek( nEndOfSizes - sizeof(sal_uInt32) );
- sal_uInt32 nVersionMapPos(0);
- rStream.ReadUInt32( nVersionMapPos );
- rStream.Seek( nVersionMapPos );
-
- // Read version maps
- CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_VERSIONMAP );
- sal_uInt16 nVerCount(0);
- rStream.ReadUInt16( nVerCount );
- for ( sal_uInt16 nVerNo = 0; nVerNo < nVerCount; ++nVerNo )
- {
- // Read Header for single versions
- sal_uInt16 nVersion(0), nHStart(0), nHEnd(0);
- rStream.ReadUInt16( nVersion ).ReadUInt16( nHStart ).ReadUInt16( nHEnd );
- sal_uInt16 nCount = nHEnd - nHStart + 1;
- sal_uInt16 nBytes = (nCount)*sizeof(sal_uInt16);
-
- // Is new version known?
- if ( nVerNo >= pImp->aVersions.size() )
- {
- // Add new version
- sal_uInt16 *pMap = new sal_uInt16[nCount];
- memset(pMap, 0, nCount * sizeof(sal_uInt16));
- for ( sal_uInt16 n = 0; n < nCount; ++n )
- rStream.ReadUInt16( pMap[n] );
- SetVersionMap( nVersion, nHStart, nHEnd, pMap );
- }
- else
- // Skip known versions
- rStream.SeekRel( nBytes );
- }
- }
-
- // Load Items
- rStream.Seek( nStartPos );
- CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ITEMS );
- bool bSecondaryLoaded = false;
- long nSecondaryEnd = 0;
- sal_uInt16 nWhich(0), nSlot(0);
- while ( rStream.ReadUInt16( nWhich ), nWhich )
- {
- // Move WhichId from old version?
- if ( pImp->nLoadingVersion != pImp->nVersion )
- nWhich = GetNewWhich( nWhich );
-
- rStream.ReadUInt16( nSlot );
-
- sal_uInt16 nRef(0), nCount(0), nVersion(0);
- sal_uInt32 nAttrSize(0);
- rStream.ReadUInt16( nVersion ).ReadUInt16( nCount );
-
- //!SFX_ASSERTWARNING( !nSlot || !HasMap() ||
- //! ( nSlot == GetSlotId( nWhich, sal_False ) ) ||
- //! !GetSlotId( nWhich, sal_False ),
- //! nWhich, "Slot/Which mismatch" );
-
- sal_uInt16 nIndex = GetIndex_Impl(nWhich);
- std::vector<SfxPoolItemArray_Impl*>::iterator ppArr = pImp->maPoolItems.begin();
- std::advance(ppArr, nIndex);
- SfxPoolItemArray_Impl *pNewArr = new SfxPoolItemArray_Impl();
- SfxPoolItem *pDefItem = *(pImp->ppStaticDefaults + nIndex);
-
- // Remember position of first Item
- sal_uLong nLastPos = rStream.Tell();
-
- // SfxSetItems could contain Items from secondary Pool
- if ( !bSecondaryLoaded && pImp->mpSecondary && pDefItem->ISA(SfxSetItem) )
- {
- // Seek to end of own Pool
- rStream.Seek(nEndOfSizes);
- CHECK_FILEFORMAT_RELEASE( rStream, SFX_ITEMPOOL_TAG_ENDPOOL, pNewArr );
- CHECK_FILEFORMAT_RELEASE( rStream, SFX_ITEMPOOL_TAG_ENDPOOL, pNewArr );
-
- // Read secondary Pool
- pImp->mpSecondary->Load1_Impl( rStream );
- bSecondaryLoaded = true;
- nSecondaryEnd = rStream.Tell();
-
- // Back to our own Items
- rStream.Seek(nLastPos);
- }
-
- // Read Items
- for ( sal_uInt16 j = 0; j < nCount; ++j )
- {
- sal_uLong nPos = nLastPos;
- rStream.ReadUInt16( nRef );
-
- SfxPoolItem *pItem = 0;
- if ( nRef )
- {
- pItem = pDefItem->Create(rStream, nVersion);
-
- if ( !pImp->mbPersistentRefCounts )
- // Hold onto them until SfxItemPool::LoadCompleted()
- AddRef(*pItem, 1);
- else
- {
- if ( nRef > SFX_ITEMS_OLD_MAXREF )
- pItem->SetKind( convertUInt16ToSfxItemKind(nRef) );
- else
- AddRef(*pItem, nRef);
- }
- }
- //pNewArr->insert( pItem, j );
- pNewArr->push_back( (SfxPoolItem*) pItem );
-
- // Skip the rest of the saved length (newer format)
- nLastPos = rStream.Tell();
-
- aSizeTable.ReadUInt32( nAttrSize );
- SFX_ASSERT( ( nPos + nAttrSize) >= nLastPos,
- nPos,
- "too many bytes read - version mismatch?" );
-
- if (nLastPos < (nPos + nAttrSize))
- {
- nLastPos = nPos + nAttrSize;
- rStream.Seek( nLastPos );
- }
- }
-
- SfxPoolItemArray_Impl *pOldArr = *ppArr;
- *ppArr = pNewArr;
-
- // Remember Items already in the Pool
- bool bEmpty = true;
- if ( 0 != pOldArr )
- for ( size_t n = 0; bEmpty && n < pOldArr->size(); ++n )
- bEmpty = pOldArr->operator[](n) == 0;
- DBG_ASSERTWARNING( bEmpty, "loading non-empty pool" );
- if ( !bEmpty )
- {
- // Find out for all old ones, whether there's a same new one
- for ( size_t nOld = 0; nOld < pOldArr->size(); ++nOld )
- {
- SfxPoolItem *pOldItem = (*pOldArr)[nOld];
- if ( pOldItem )
- {
- bool bFound = false;
- for ( size_t nNew = 0;
- nNew < (*ppArr)->size(); ++nNew )
- {
- SfxPoolItem *&rpNewItem =
- (SfxPoolItem*&)(*ppArr)->operator[](nNew);
-
- if ( rpNewItem && *rpNewItem == *pOldItem )
- {
- AddRef( *pOldItem, rpNewItem->GetRefCount() );
- SetRefCount( *rpNewItem, 0 );
- delete rpNewItem;
- rpNewItem = pOldItem;
- bFound = true;
- SAL_INFO("svl", "reusing item" << pOldItem);
- break;
- }
- }
- SAL_INFO_IF(
- !bFound, "svl", "item not found: " << pOldItem);
- }
- }
- }
- delete pOldArr;
- }
-
- // Read Pool defaults
- if ( pImp->nMajorVer > 1 || pImp->nMinorVer > 0 )
- CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_DEFAULTS );
-
- sal_uLong nLastPos = rStream.Tell();
- while ( rStream.ReadUInt16( nWhich ), nWhich )
- {
- // Move WhichId from old version?
- if ( pImp->nLoadingVersion != pImp->nVersion )
- nWhich = GetNewWhich( nWhich );
-
- rStream.ReadUInt16( nSlot );
-
- sal_uLong nPos = nLastPos;
- sal_uInt32 nSize(0);
- sal_uInt16 nVersion(0);
- rStream.ReadUInt16( nVersion );
-
- SfxPoolItem *pItem =
- ( *( pImp->ppStaticDefaults + GetIndex_Impl(nWhich) ) )
- ->Create( rStream, nVersion );
- pItem->SetKind( SFX_ITEMS_POOLDEFAULT );
- *( pImp->ppPoolDefaults + GetIndex_Impl(nWhich) ) = pItem;
-
- nLastPos = rStream.Tell();
- aSizeTable.ReadUInt32( nSize );
- SFX_ASSERT( ( nPos + nSize) >= nLastPos, nPos,
- "too many bytes read - version mismatch?" );
- if ( nLastPos < (nPos + nSize) )
- rStream.Seek( nPos + nSize );
- }
-
- pBuf.reset();
- rStream.Seek(nEndOfSizes);
- CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ENDPOOL );
- CHECK_FILEFORMAT( rStream, SFX_ITEMPOOL_TAG_ENDPOOL );
-
- if ( pImp->mpSecondary )
- {
- if ( !bSecondaryLoaded )
- pImp->mpSecondary->Load1_Impl( rStream );
- else
- rStream.Seek( nSecondaryEnd );
- }
-
- if ( aExternName != pImp->aName )
- pImp->aName = OUString();
-
- pImp->bStreaming = false;
- return rStream;
-}
-
-
/**
* Loads surrogate from 'rStream' and returns the corresponding SfxPoolItem
* from the rRefPool.