if( auto pDerived = rFormat.DerivedFrom() )
{
pDerived->Add(*this);
m_aSet.SetParent( &pDerived->m_aSet );
} // a few special treatments for attributes
m_aSet.SetModifyAtAttr( this );
}
if( pChgSet != &rFormat.m_aSet ) // was a Set created? delete pChgSet;
}
void SwFormat::Destr()
{ // This happens at an ObjectDying message. Thus put all dependent // ones on DerivedFrom. if (!HasWriterListeners()) return;
m_bFormatInDTOR = true;
if (!DerivedFrom())
{
SwFormat::ResetFormatAttr(RES_PAGEDESC);
SAL_WARN("sw.core", "~SwFormat: format still has clients on death, but parent format is missing: "
<< GetName().toString()); return;
}
PrepareFormatDeath(SwFormatChangeHint(this, DerivedFrom()));
assert(!HasWriterListeners());
}
SwFormat::~SwFormat()
{
Destr();
}
void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint)
{ if (rHint.GetId() == SfxHintId::SwRemoveUnoObject
|| rHint.GetId() == SfxHintId::SwUpdateAttr)
{
SwModify::SwClientNotify(*this, rHint); return;
} if (rHint.GetId() == SfxHintId::SwFormatChange)
{ auto pChangeHint = static_cast<const SwFormatChangeHint*>(&rHint);
InvalidateInSwCache();
// if the format parent will be moved so register my attribute set at // the new one
// skip my own Modify // NB: this still notifies depends even if this condition is not met, which seems non-obvious if(pChangeHint->m_pOldFormat != this && pChangeHint->m_pNewFormat == GetRegisteredIn())
{ // attach Set to new parent
m_aSet.SetParent(DerivedFrom() ? &DerivedFrom()->m_aSet : nullptr);
}
InvalidateInSwFntCache();
SwModify::SwClientNotify(*this, rHint); return;
} if (rHint.GetId() == SfxHintId::SwAttrSetChange)
{ auto pChangeHint = static_cast<const sw::AttrSetChangeHint*>(&rHint);
std::optional<SwAttrSetChg> oOldClientChg, oNewClientChg;
std::optional<sw::AttrSetChangeHint> oDependsHint(std::in_place, pChangeHint->m_pOld, pChangeHint->m_pNew);
InvalidateInSwCache(); // NB: this still notifies depends even if this condition is not met, which seems non-obvious auto pOldAttrSetChg = pChangeHint->m_pOld; auto pNewAttrSetChg = pChangeHint->m_pNew; if (pOldAttrSetChg && pNewAttrSetChg && pOldAttrSetChg->GetTheChgdSet() != &m_aSet)
{ // pass only those that are not set...
oNewClientChg.emplace(*pNewAttrSetChg);
oNewClientChg->GetChgSet()->Differentiate(m_aSet); if(oNewClientChg->Count()) // ... if any
{
oOldClientChg.emplace(*pOldAttrSetChg);
oOldClientChg->GetChgSet()->Differentiate(m_aSet);
oDependsHint.emplace(&*oOldClientChg, &*oNewClientChg);
} else
oDependsHint.reset();
} if(oDependsHint)
{
InvalidateInSwFntCache();
SwModify::SwClientNotify(*this, *oDependsHint);
} return;
} if (rHint.GetId() == SfxHintId::SwObjectDying)
{ auto pDyingHint = static_cast<const sw::ObjectDyingHint*>(&rHint);
InvalidateInSwCache(); // If the dying object is the parent format of this format so // attach this to the parent of the parent
// do not move if this is the topmost format if(GetRegisteredIn() && GetRegisteredIn() == pDyingHint->m_pDying)
{ if(pDyingHint->m_pDying->GetRegisteredIn())
{
SwFormat* pFormat = static_cast<SwFormat*>(pDyingHint->m_pDying); // if parent so register in new parent
pFormat->DerivedFrom()->Add(*this);
m_aSet.SetParent(&DerivedFrom()->m_aSet);
} else
{ // otherwise de-register at least from dying one
EndListeningAll();
m_aSet.SetParent(nullptr);
}
}
InvalidateInSwFntCache();
SwModify::SwClientNotify(*this, rHint); return;
} if (rHint.GetId() != SfxHintId::SwLegacyModify) return; auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
std::optional<sw::LegacyModifyHint> oDependsHint(std::in_place, pLegacy->m_pOld, pLegacy->m_pNew); const sal_uInt16 nWhich = pLegacy->GetWhich();
InvalidateInSwCache(nWhich); if(nWhich != 0)
{ // attribute is defined in this format if(SfxItemState::SET == m_aSet.GetItemState(nWhich, false))
{ // DropCaps might come into this block
SAL_WARN_IF(RES_PARATR_DROP != nWhich, "sw.core", "Hint was sent without sender");
oDependsHint.reset();
}
} if(oDependsHint)
{
InvalidateInSwFntCache(oDependsHint->GetWhich());
SwModify::SwClientNotify(*this, *oDependsHint);
}
}
bool SwFormat::SetDerivedFrom(SwFormat *pDerFrom)
{ if ( pDerFrom )
{ const SwFormat* pFormat = pDerFrom; while ( pFormat != nullptr )
{ if ( pFormat == this ) returnfalse;
pFormat=pFormat->DerivedFrom();
}
} else
{ // nothing provided, search for Dflt format
pDerFrom = this; while ( pDerFrom->DerivedFrom() )
pDerFrom = pDerFrom->DerivedFrom();
} if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) ) returnfalse;
const SfxPoolItem& SwFormat::GetFormatAttr( sal_uInt16 nWhich, bool bInParents ) const
{ if (RES_BACKGROUND == nWhich && supportsFullDrawingLayerFillAttributeSet())
{ // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or makeBackgroundBrushItem (simple fallback is in place and used)"); static std::unique_ptr<SvxBrushItem> aSvxBrushItem; //(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
// fill the local static SvxBrushItem from the current ItemSet so that // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used // as good as possible to create a fallback representation and return that
aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bInParents);
return *aSvxBrushItem;
}
return m_aSet.Get( nWhich, bInParents );
}
SfxItemState SwFormat::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const
{ if (RES_BACKGROUND == nWhich && supportsFullDrawingLayerFillAttributeSet())
{ // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or SwFormat::GetBackgroundStat (simple fallback is in place and used)"); const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
// check if the new fill attributes are used if(aFill && aFill->isUsed())
{ // if yes, fill the local SvxBrushItem using the new fill attributes // as good as possible to have an instance for the pointer to point // to and return as state that it is set static std::unique_ptr<SvxBrushItem> aSvxBrushItem; //(RES_BACKGROUND);
SfxItemState SwFormat::GetBackgroundState(std::unique_ptr<SvxBrushItem>& rItem) const
{ if (supportsFullDrawingLayerFillAttributeSet())
{ // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
// check if the new fill attributes are used if(aFill && aFill->isUsed())
{ // if yes, fill the local SvxBrushItem using the new fill attributes // as good as possible to have an instance for the pointer to point // to and return as state that it is set
rItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND); return SfxItemState::SET;
}
// if not return SfxItemState::DEFAULT to signal that the item is not set return SfxItemState::DEFAULT;
}
if (RES_BACKGROUND == rAttr.Which() && supportsFullDrawingLayerFillAttributeSet())
{ // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST> aTempSet(*m_aSet.GetPool()); const SvxBrushItem& rSource = rAttr.StaticWhichCast(RES_BACKGROUND);
// fill a local ItemSet with the attributes corresponding as good as possible // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these // as ItemSet
setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
// Use local copy to be able to apply needed changes, e.g. call // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
SfxItemSet aTempSet(rSet);
// Need to check for unique item for DrawingLayer items of type NameOrIndex // and evtl. correct that item to ensure unique names for that type. This call may // modify/correct entries inside of the given SfxItemSet
GetDoc().CheckForUniqueItemForLineFillNameOrIndex(aTempSet);
if (supportsFullDrawingLayerFillAttributeSet())
{ if(const SvxBrushItem* pSource = aTempSet.GetItemIfSet(RES_BACKGROUND, false))
{ // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
// copy all items to be set anyways to a local ItemSet with is also prepared for the new // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes // corresponding as good as possible to the new fill properties and set the whole ItemSet
setSvxBrushItemAsFillAttributesToTargetSet(*pSource, aTempSet);
// if Modify is locked then no modifications will be sent; // but call Modify always for FrameFormats const sal_uInt16 nFormatWhich = Which(); if ( IsModifyLocked() ||
( !HasWriterListeners() &&
( RES_GRFFMTCOLL == nFormatWhich ||
RES_TXTFMTCOLL == nFormatWhich ) ) )
{
bRet = m_aSet.Put( aTempSet ); if( bRet )
m_aSet.SetModifyAtAttr( this ); // #i71574# if ( nFormatWhich == RES_TXTFMTCOLL )
{
TextFormatCollFunc::CheckTextFormatCollForDeletionOfAssignmentToOutlineStyle( this );
}
} else
{
SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
bRet = m_aSet.Put_BC( aTempSet, &aOld, &aNew ); if( bRet )
{ // some special treatments for attributes
m_aSet.SetModifyAtAttr( this );
sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
}
} return bRet;
}
// remove Hint using nWhich from array with delta bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
{ if( !m_aSet.Count() ) returnfalse;
if( !nWhich2 || nWhich2 < nWhich1 )
nWhich2 = nWhich1; // then set to 1st ID, only this item
for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
InvalidateInSwFntCache( n ); for( sal_uInt16 n = nWhich1; n < nWhich2 && IsInCache(); ++n )
InvalidateInSwCache( n );
// if Modify is locked then no modifications will be sent if( IsModifyLocked() ) return0 != (( nWhich2 == nWhich1 )
? m_aSet.ClearItem( nWhich1 )
: m_aSet.ClearItem_BC( nWhich1, nWhich2 ));
void SwFormat::SetGrabBagItem(const uno::Any& rVal)
{ if (!m_pGrabBagItem)
m_pGrabBagItem = std::make_shared<SfxGrabBagItem>();
m_pGrabBagItem->PutValue(rVal, 0);
}
std::unique_ptr<SvxBrushItem> SwFormat::makeBackgroundBrushItem(bool bInP) const
{ if (supportsFullDrawingLayerFillAttributeSet())
{ // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
// fill the local static SvxBrushItem from the current ItemSet so that // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used // as good as possible to create a fallback representation and return that return getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bInP);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.