////////////////////////////////////////////////////////////////////////////// // list of classes derived from SfxPoolItem // removed, but use 'grep DECLARE_ITEM_TYPE_FUNCTION' to get a complete list // of Items that may get incarnated during office runtime //////////////////////////////////////////////////////////////////////////////
// count globally allocated Items. Exclude Static/DynamicDefaults to // get the number without the PoolDefaultItems that will be freed with // the Pool. This also excludes the two InvalidOrDisabledItem's used // for INVALID_POOL_ITEM/DISABLED_POOL_ITEM for (constauto& rCandidate : incarnatedSfxPoolItems()) if (!rCandidate->isStaticDefault() && !rCandidate->isDynamicDefault())
aRetval++; return aRetval;
} void listAllocatedSfxPoolItems()
{
SAL_INFO("svl.items", "ITEM: List of still allocated SfxPoolItems:"); for (constauto& rCandidate : incarnatedSfxPoolItems())
{ if (!rCandidate->isStaticDefault() && !rCandidate->isDynamicDefault())
SAL_INFO("svl.items", " ITEM: WhichID: " << rCandidate->Which() << " SerialNumber: "
<< rCandidate->getSerialNumber()
<< " Class: " << typeid(*rCandidate).name());
}
} #endif
const SfxPoolItem* DefaultItemInstanceManager::find(const SfxPoolItem& rItem) const
{ auto it = maRegistered.find(rItem.Which()); if (it == maRegistered.end()) return nullptr; for (constauto& rCandidate : it->second) if (*rCandidate == rItem) return rCandidate;
size_t SfxPoolItem::hashCode() const
{
assert(false
&& "this should never be called, classes should implement both supportsHashCode() and " "hashCode(), or neither"); return0;
}
/** *Thisvirtualmethodallowstogetatextualrepresentationofthevalue *fortheSfxPoolItemsubclasses.ItshouldbeoverriddenbyallUI-relevant *SfxPoolItemsubclasses. * *BecausetheunitofmeasureofthevalueintheSfxItemPoolisonly *queryablevia@seeSfxItemPool::GetMetric(sal_uInt16)const(andnot *viatheSfxPoolIteminstanceorsubclass,theownunitofmeasureis *passedto'eCoreMetric'. * *Thecorrespondingunitofmeasureispassedas'ePresentationMetric'. * * *@returnSfxItemPresentationSfxItemPresentation::Nameless *Atextualrepresentation(ifapplicable *withaunitofmeasure)couldbecreated, *butitdoesn'tcontainanysemanticmeaning * *SfxItemPresentation::Complete *Acompletetextualrepresentationcouldbe *createdwithsemanticmeaning(ifapplicable *withunitofmeasure) * *Example: * *pSvxFontItem->GetPresentation(SFX_PRESENTATION_NAMELESS,...) *"12pt"withreturnSfxItemPresentation::Nameless * *pSvxColorItem->GetPresentation(SFX_PRESENTATION_COMPLETE,...) *"red"withreturnSfxItemPresentation::Nameless *BecausetheSvxColorItemdoesnotknowwhichcoloritrepresents *itcannotprovideaname,whichiscommunicatedbythereturnvalue * *pSvxBorderItem->GetPresentation(SFX_PRESENTATION_COMPLETE,...) *"1cmtopborder,2cmleftborder,0.2cmbottomborder,..."
*/ bool SfxPoolItem::GetPresentation(
SfxItemPresentation /*ePresentation*/, // IN: how we should format
MapUnit /*eCoreMetric*/, // IN: current metric of the SfxPoolItems
MapUnit /*ePresentationMetric*/, // IN: target metric of the presentation
OUString& /*rText*/, // OUT: textual representation const IntlWrapper&) const
{ returnfalse;
}
// cast to void* to not trigger [loplugin:itemcompare] return (static_cast<constvoid*>(pItem1) == static_cast<constvoid*>(pItem2));
}
bool SfxPoolItem::areSame(const SfxPoolItem* pItem1, const SfxPoolItem* pItem2)
{ if (pItem1 == pItem2) // pointer compare, this handles already // nullptr, INVALID_POOL_ITEM, DISABLED_POOL_ITEM // and if any Item is indeed handed over twice returntrue;
if (nullptr == pItem1 || nullptr == pItem2) // one ptr is nullptr, not both, that would // have triggered above returnfalse;
if (pItem1->Which() != pItem2->Which()) // WhichIDs differ (fast) returnfalse;
if (pItem1->ItemType() != pItem2->ItemType()) // types differ (fast) returnfalse;
// return content compare using operator== at last return *pItem1 == *pItem2;
}
bool SfxPoolItem::areSame(const SfxPoolItem& rItem1, const SfxPoolItem& rItem2)
{ if (&rItem1 == &rItem2) // still use pointer compare, this handles already // nullptr, INVALID_POOL_ITEM, SfxVoidItem // and if any Item is indeed handed over twice returntrue;
if (rItem1.Which() != rItem2.Which()) // WhichIDs differ (fast) returnfalse;
if (rItem1.ItemType() != rItem2.ItemType()) // types differ (fast) returnfalse;
// return content compare using operator== at last return rItem1 == rItem2;
}
namespace
{ // tdf#164745 make InvalidItem and DisabledItem two classes to // avoid that op== sees them as equal class InvalidItem final : public SfxPoolItem
{ virtualbooloperator==(const SfxPoolItem&) const override { returntrue; } virtual SfxPoolItem* Clone(SfxItemPool*) const override { return nullptr; }
public: // make it StaticDefaultItem to process similar to these // which is plausible (never change and are not allowed to)
DECLARE_ITEM_TYPE_FUNCTION(InvalidItem)
InvalidItem()
: SfxPoolItem(0)
{
setStaticDefault();
}
}; class DisabledItem final : public SfxPoolItem
{ virtualbooloperator==(const SfxPoolItem&) const override { returntrue; } virtual SfxPoolItem* Clone(SfxItemPool*) const override { return nullptr; }
public: // make it StaticDefaultItem to process similar to these // which is plausible (never change and are not allowed to)
DECLARE_ITEM_TYPE_FUNCTION(DisabledItem)
DisabledItem()
: SfxPoolItem(0)
{
setStaticDefault();
}
};
InvalidItem aInvalidItem;
DisabledItem aDisabledItem;
}
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.