loplugin:constantparam in svl

Change-Id: If23e43beb401047825641817e09d7fdeb904f9d9
Reviewed-on: https://gerrit.libreoffice.org/23317
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
Noel Grandin 2016-03-17 09:45:22 +02:00 committed by Noel Grandin
parent 16fc620a22
commit 07da25064f
11 changed files with 32 additions and 45 deletions

View File

@ -236,11 +236,11 @@ protected:
, _nPreTag(0) , _nPreTag(0)
{ {
} }
void Construct_Impl( SvStream *pStream, sal_uInt8 nTag ) void Construct_Impl( SvStream *pStream )
{ {
_pStream = pStream; _pStream = pStream;
_bSkipped = false; _bSkipped = false;
_nPreTag = nTag; _nPreTag = SFX_REC_PRETAG_EXT;
} }
inline bool SetHeader_Impl( sal_uInt32 nHeader ); inline bool SetHeader_Impl( sal_uInt32 nHeader );
@ -319,8 +319,7 @@ protected:
} }
void Construct_Impl( SvStream *pStream ) void Construct_Impl( SvStream *pStream )
{ {
SfxMiniRecordReader::Construct_Impl( SfxMiniRecordReader::Construct_Impl( pStream );
pStream, SFX_REC_PRETAG_EXT );
} }
bool FindHeader_Impl( sal_uInt16 nTypes, sal_uInt16 nTag ); bool FindHeader_Impl( sal_uInt16 nTypes, sal_uInt16 nTag );
}; };
@ -444,8 +443,7 @@ protected:
public: public:
SfxMultiVarRecordWriter( SvStream *pStream, SfxMultiVarRecordWriter( SvStream *pStream,
sal_uInt16 nRecordTag, sal_uInt16 nRecordTag );
sal_uInt8 nRecordVer );
virtual ~SfxMultiVarRecordWriter(); virtual ~SfxMultiVarRecordWriter();
void NewContent(); void NewContent();
@ -484,8 +482,7 @@ class SVL_DLLPUBLIC SfxMultiMixRecordWriter: public SfxMultiVarRecordWriter
{ {
public: public:
inline SfxMultiMixRecordWriter( SvStream *pStream, inline SfxMultiMixRecordWriter( SvStream *pStream,
sal_uInt16 nRecordTag, sal_uInt16 nRecordTag );
sal_uInt8 nRecordVer );
void NewContent( sal_uInt16 nTag, sal_uInt8 nVersion ); void NewContent( sal_uInt16 nTag, sal_uInt8 nVersion );
}; };
@ -627,12 +624,10 @@ inline SfxMultiFixRecordWriter::~SfxMultiFixRecordWriter()
* *
* @param pStream target stream in which the record will be created * @param pStream target stream in which the record will be created
* @param nRecordTag tag for the total record * @param nRecordTag tag for the total record
* @param nRecordVer version for the total record
*/ */
inline SfxMultiMixRecordWriter::SfxMultiMixRecordWriter( SvStream* pStream, inline SfxMultiMixRecordWriter::SfxMultiMixRecordWriter( SvStream* pStream,
sal_uInt16 nRecordTag, sal_uInt16 nRecordTag )
sal_uInt8 nRecordVer ) : SfxMultiVarRecordWriter( SFX_REC_TYPE_MIXTAGS, pStream, nRecordTag, 0 )
: SfxMultiVarRecordWriter( SFX_REC_TYPE_MIXTAGS, pStream, nRecordTag, nRecordVer )
{ {
} }

View File

@ -151,7 +151,6 @@ public:
const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const; const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const;
const SfxPoolItem* LoadItem( SvStream &rStream, const SfxPoolItem* LoadItem( SvStream &rStream,
bool bDirect = false,
const SfxItemPool *pRefPool = nullptr ); const SfxItemPool *pRefPool = nullptr );
bool StoreItem( SvStream &rStream, bool StoreItem( SvStream &rStream,
const SfxPoolItem &rItem, const SfxPoolItem &rItem,

View File

@ -57,11 +57,11 @@ struct SfxItemPropertySimpleEntry
} }
SfxItemPropertySimpleEntry(sal_uInt16 _nWID, css::uno::Type const & _rType, SfxItemPropertySimpleEntry(sal_uInt16 _nWID, css::uno::Type const & _rType,
long _nFlags, sal_uInt8 _nMemberId) long _nFlags)
: nWID( _nWID ) : nWID( _nWID )
, aType( _rType ) , aType( _rType )
, nFlags( _nFlags ) , nFlags( _nFlags )
, nMemberId( _nMemberId ) , nMemberId( 0 )
{ {
} }

View File

@ -50,7 +50,7 @@ public:
const SfxItemSet *pPutSet ); const SfxItemSet *pPutSet );
~SfxItemPoolCache(); ~SfxItemPoolCache();
const SfxSetItem& ApplyTo( const SfxSetItem& rSetItem, bool bNew = false ); const SfxSetItem& ApplyTo( const SfxSetItem& rSetItem );
}; };

View File

@ -798,7 +798,7 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac
do do
{ {
const ScPatternAttr* pOldPattern = pData[nPos].pPattern; const ScPatternAttr* pOldPattern = pData[nPos].pPattern;
const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pCache->ApplyTo( *pOldPattern, true ) ); const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pCache->ApplyTo( *pOldPattern ) );
ScDocumentPool::CheckRef( *pOldPattern ); ScDocumentPool::CheckRef( *pOldPattern );
ScDocumentPool::CheckRef( *pNewPattern ); ScDocumentPool::CheckRef( *pNewPattern );
if (pNewPattern != pOldPattern) if (pNewPattern != pOldPattern)

View File

@ -494,7 +494,7 @@ void ScColumn::ApplyPattern( SCROW nRow, const ScPatternAttr& rPatAttr )
// true = keep old content // true = keep old content
const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &aCache.ApplyTo( *pPattern, true ) ); const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &aCache.ApplyTo( *pPattern ) );
ScDocumentPool::CheckRef( *pPattern ); ScDocumentPool::CheckRef( *pPattern );
ScDocumentPool::CheckRef( *pNewPattern ); ScDocumentPool::CheckRef( *pNewPattern );

View File

@ -362,10 +362,9 @@ SfxMultiVarRecordWriter::SfxMultiVarRecordWriter(sal_uInt8 nRecordType,
* for initializing the <SvULong> members. * for initializing the <SvULong> members.
*/ */
SfxMultiVarRecordWriter::SfxMultiVarRecordWriter(SvStream* pStream, SfxMultiVarRecordWriter::SfxMultiVarRecordWriter(SvStream* pStream,
sal_uInt16 nRecordTag, sal_uInt16 nRecordTag)
sal_uInt8 nRecordVer)
: SfxMultiFixRecordWriter( SFX_REC_TYPE_VARSIZE, : SfxMultiFixRecordWriter( SFX_REC_TYPE_VARSIZE,
pStream, nRecordTag, nRecordVer ), pStream, nRecordTag, 0 ),
_nContentVer( 0 ) _nContentVer( 0 )
{ {
} }

View File

@ -142,8 +142,7 @@ void SfxItemPropertyMap::mergeProperties( const uno::Sequence< beans::Property >
SfxItemPropertySimpleEntry aTemp( SfxItemPropertySimpleEntry aTemp(
sal::static_int_cast< sal_Int16 >( pPropArray[nElement].Handle ), //nWID sal::static_int_cast< sal_Int16 >( pPropArray[nElement].Handle ), //nWID
pPropArray[nElement].Type, //aType pPropArray[nElement].Type, //aType
pPropArray[nElement].Attributes, //nFlags pPropArray[nElement].Attributes); //nFlags
0 ); //nMemberId
(*m_pImpl)[pPropArray[nElement].Name] = aTemp; (*m_pImpl)[pPropArray[nElement].Name] = aTemp;
} }
} }

View File

@ -1339,7 +1339,7 @@ void SfxItemSet::Load
{ {
// Load Surrogate/Item and resolve Surrogate // Load Surrogate/Item and resolve Surrogate
const SfxPoolItem *pItem = const SfxPoolItem *pItem =
m_pPool->LoadItem( rStream, false/*bDirect*/, pRefPool ); m_pPool->LoadItem( rStream, pRefPool );
// Did we load an Item or resolve a Surrogate? // Did we load an Item or resolve a Surrogate?
if ( pItem ) if ( pItem )

View File

@ -59,7 +59,7 @@ SfxItemPoolCache::~SfxItemPoolCache()
} }
const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem, bool bNew ) const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem )
{ {
DBG_ASSERT( pPool == rOrigItem.GetItemSet().GetPool(), "invalid Pool" ); DBG_ASSERT( pPool == rOrigItem.GetItemSet().GetPool(), "invalid Pool" );
DBG_ASSERT( IsDefaultItem( &rOrigItem ) || IsPooledItem( &rOrigItem ), DBG_ASSERT( IsDefaultItem( &rOrigItem ) || IsPooledItem( &rOrigItem ),
@ -75,8 +75,7 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem, bool b
if ( rMapEntry.pPoolItem != &rOrigItem ) if ( rMapEntry.pPoolItem != &rOrigItem )
{ {
rMapEntry.pPoolItem->AddRef(2); // One for the cache rMapEntry.pPoolItem->AddRef(2); // One for the cache
if ( bNew ) pPool->Put( rOrigItem ); //FIXME: AddRef?
pPool->Put( rOrigItem ); //FIXME: AddRef?
} }
return *rMapEntry.pPoolItem; return *rMapEntry.pPoolItem;
} }
@ -98,8 +97,7 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem, bool b
// Adapt refcount; one each for the cache // Adapt refcount; one each for the cache
pNewPoolItem->AddRef( pNewPoolItem != &rOrigItem ? 2 : 1 ); pNewPoolItem->AddRef( pNewPoolItem != &rOrigItem ? 2 : 1 );
if ( bNew ) pPool->Put( rOrigItem ); //FIXME: AddRef?
pPool->Put( rOrigItem ); //FIXME: AddRef?
// Add the transformation to the cache // Add the transformation to the cache
SfxItemModifyImpl aModify; SfxItemModifyImpl aModify;

View File

@ -154,7 +154,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// VersionMaps // VersionMaps
{ {
SfxMultiVarRecordWriter aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP, 0 ); SfxMultiVarRecordWriter aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP );
for ( size_t nVerNo = 0; nVerNo < pImp->aVersions.size(); ++nVerNo ) for ( size_t nVerNo = 0; nVerNo < pImp->aVersions.size(); ++nVerNo )
{ {
aVerRec.NewContent(); aVerRec.NewContent();
@ -176,7 +176,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// Pooled Items // Pooled Items
{ {
SfxMultiMixRecordWriter aWhichIdsRec( &rStream, SFX_ITEMPOOL_REC_WHICHIDS, 0 ); SfxMultiMixRecordWriter aWhichIdsRec( &rStream, SFX_ITEMPOOL_REC_WHICHIDS );
// First write the atomic Items and then write the Sets (important when loading) // First write the atomic Items and then write the Sets (important when loading)
for (int ft = 0 ; ft < 2 && !rStream.GetError(); ft++) for (int ft = 0 ; ft < 2 && !rStream.GetError(); ft++)
@ -209,7 +209,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
rStream.WriteUInt32( nCount ); rStream.WriteUInt32( nCount );
// Write Items // Write Items
SfxMultiMixRecordWriter aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS, 0 ); SfxMultiMixRecordWriter aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS );
for ( size_t j = 0; j < nCount; ++j ) for ( size_t j = 0; j < nCount; ++j )
{ {
// Get Item // Get Item
@ -254,7 +254,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
// Save the set Defaults (PoolDefaults) // Save the set Defaults (PoolDefaults)
if ( !rStream.GetError() ) if ( !rStream.GetError() )
{ {
SfxMultiMixRecordWriter aDefsRec( &rStream, SFX_ITEMPOOL_REC_DEFAULTS, 0 ); SfxMultiMixRecordWriter aDefsRec( &rStream, SFX_ITEMPOOL_REC_DEFAULTS );
sal_uInt16 nCount = GetSize_Impl(); sal_uInt16 nCount = GetSize_Impl();
for ( sal_uInt16 n = 0; n < nCount; ++n ) for ( sal_uInt16 n = 0; n < nCount; ++n )
{ {
@ -1187,7 +1187,7 @@ bool SfxItemPool::StoreItem( SvStream &rStream, const SfxPoolItem &rItem,
/** /**
* If pRefPool==-1 => do not put! * If pRefPool==-1 => do not put!
*/ */
const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, bool bDirect, const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream,
const SfxItemPool *pRefPool ) const SfxItemPool *pRefPool )
{ {
sal_uInt16 nWhich(0), nSlot(0); // nSurrogate; sal_uInt16 nWhich(0), nSlot(0); // nSurrogate;
@ -1228,19 +1228,16 @@ const SfxPoolItem* SfxItemPool::LoadItem( SvStream &rStream, bool bDirect,
// Are we loading via surrogate? // Are we loading via surrogate?
const SfxPoolItem *pItem = nullptr; const SfxPoolItem *pItem = nullptr;
if ( !bDirect ) // WhichId known in this version?
{ if ( nWhich )
// WhichId known in this version? // Load surrogate and react if none present
if ( nWhich ) pItem = LoadSurrogate( rStream, nWhich, nSlot, pRefPool );
// Load surrogate and react if none present else
pItem = LoadSurrogate( rStream, nWhich, nSlot, pRefPool ); // Else skip it
else rStream.SeekRel( sizeof(sal_uInt16) );
// Else skip it
rStream.SeekRel( sizeof(sal_uInt16) );
}
// Is loaded directly (not via surrogate)? // Is loaded directly (not via surrogate)?
if ( bDirect || ( nWhich && !pItem ) ) if ( nWhich && !pItem )
{ {
// bDirekt or not IsPoolable() => Load Item directly // bDirekt or not IsPoolable() => Load Item directly
sal_uInt16 nVersion(0); sal_uInt16 nVersion(0);