Kaydet (Commit) 77da600b authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1426167 refactor to be less obscure

no logic change intended

Change-Id: I10ef6038351b2808c2030aa55f05e078d80345ae
Reviewed-on: https://gerrit.libreoffice.org/46609Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 9cca2ca9
...@@ -2546,58 +2546,61 @@ bool SwFrameFormat::supportsFullDrawingLayerFillAttributeSet() const ...@@ -2546,58 +2546,61 @@ bool SwFrameFormat::supportsFullDrawingLayerFillAttributeSet() const
void SwFrameFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) void SwFrameFormat::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
{ {
SwFormatHeader const *pH = nullptr; if (pNew)
SwFormatFooter const *pF = nullptr;
const sal_uInt16 nWhich = pNew ? pNew->Which() : 0;
if( RES_ATTRSET_CHG == nWhich )
{ {
static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->GetItemState( SwFormatHeader const *pH = nullptr;
RES_HEADER, false, reinterpret_cast<const SfxPoolItem**>(&pH) ); SwFormatFooter const *pF = nullptr;
static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->GetItemState(
RES_FOOTER, false, reinterpret_cast<const SfxPoolItem**>(&pF) ); const sal_uInt16 nWhich = pNew->Which();
// reset fill information if( RES_ATTRSET_CHG == nWhich )
if (maFillAttributes.get() && supportsFullDrawingLayerFillAttributeSet())
{ {
SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()); static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->GetItemState(
bool bReset(false); RES_HEADER, false, reinterpret_cast<const SfxPoolItem**>(&pH) );
static_cast<const SwAttrSetChg*>(pNew)->GetChgSet()->GetItemState(
RES_FOOTER, false, reinterpret_cast<const SfxPoolItem**>(&pF) );
for(const SfxPoolItem* pItem = aIter.FirstItem(); pItem && !bReset; pItem = aIter.NextItem()) // reset fill information
if (maFillAttributes.get() && supportsFullDrawingLayerFillAttributeSet())
{ {
bReset = !IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST; SfxItemIter aIter(*static_cast<const SwAttrSetChg*>(pNew)->GetChgSet());
} bool bReset(false);
if(bReset) for(const SfxPoolItem* pItem = aIter.FirstItem(); pItem && !bReset; pItem = aIter.NextItem())
{ {
maFillAttributes.reset(); bReset = !IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST;
}
if(bReset)
{
maFillAttributes.reset();
}
} }
} }
} else if(RES_FMT_CHG == nWhich)
else if(RES_FMT_CHG == nWhich)
{
// reset fill information on format change (e.g. style changed)
if (maFillAttributes.get() && supportsFullDrawingLayerFillAttributeSet())
{ {
maFillAttributes.reset(); // reset fill information on format change (e.g. style changed)
if (maFillAttributes.get() && supportsFullDrawingLayerFillAttributeSet())
{
maFillAttributes.reset();
}
} }
} else if( RES_HEADER == nWhich )
else if( RES_HEADER == nWhich ) pH = static_cast<const SwFormatHeader*>(pNew);
pH = static_cast<const SwFormatHeader*>(pNew); else if( RES_FOOTER == nWhich )
else if( RES_FOOTER == nWhich ) pF = static_cast<const SwFormatFooter*>(pNew);
pF = static_cast<const SwFormatFooter*>(pNew);
if( pH && pH->IsActive() && !pH->GetHeaderFormat() ) if( pH && pH->IsActive() && !pH->GetHeaderFormat() )
{ //If he doesn't have one, I'll add one { //If he doesn't have one, I'll add one
SwFrameFormat *pFormat = GetDoc()->getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::HEADER, nullptr ); SwFrameFormat *pFormat = GetDoc()->getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::HEADER, nullptr );
const_cast<SwFormatHeader *>(pH)->RegisterToFormat( *pFormat ); const_cast<SwFormatHeader *>(pH)->RegisterToFormat( *pFormat );
} }
if( pF && pF->IsActive() && !pF->GetFooterFormat() ) if( pF && pF->IsActive() && !pF->GetFooterFormat() )
{ //If he doesn't have one, I'll add one { //If he doesn't have one, I'll add one
SwFrameFormat *pFormat = GetDoc()->getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::FOOTER, nullptr ); SwFrameFormat *pFormat = GetDoc()->getIDocumentLayoutAccess().MakeLayoutFormat( RndStdIds::FOOTER, nullptr );
const_cast<SwFormatFooter *>(pF)->RegisterToFormat( *pFormat ); const_cast<SwFormatFooter *>(pF)->RegisterToFormat( *pFormat );
}
} }
SwFormat::Modify( pOld, pNew ); SwFormat::Modify( pOld, pNew );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment