#define SFX_ITEMS_MAXREF 0xffffffff #define CONVERT_TWIPS 0x80 // Uno conversion for measurement (for MemberId)
// warning, if there is no boolean inside the any this will always return the value false inlinebool Any2Bool( const css::uno::Any&rValue )
{ bool bValue = false; if( !(rValue >>= bValue) )
{
sal_Int32 nNum = 0; if( rValue >>= nNum )
bValue = nNum != 0;
}
return bValue;
}
// Offer simple assert if Item is RefCounted (RefCnt > 1) and thus CANNOT be changed. // This should be used at *all* SfxPoolItem set* methods. Remember that SfxPoolItems // are by design intended to be create-one, read-only, shared data packages #define ASSERT_CHANGE_REFCOUNTED_ITEM \
assert(!GetRefCount() && "ERROR: RefCounted SfxPoolItem CANNOT be changed (!)")
/** Specifies that the property is currently disabled. */
DISABLED = 0x0001,
/** Specifies that the property is currently in a don't care state *andthusinvalid *<br/> *Thisisnormallyusedifaselectionprovidesmorethanonestate *forapropertyatthesametime,sotheItemisover-definedand *hasnovalidstate->invalid
*/
INVALID = 0x0010,
/** Specifies that the property is currently in a default state. */ DEFAULT = 0x0020,
/** The property has been explicitly set to a given value hence we know *wearenottakingthedefaultvalue. *<br/> *Forexample,youmaywanttogetthefontcoloranditmighteither *bethedefaultoneoronethathasbeenexplicitlyset.
*/
SET = 0x0040
};
#ifdef DBG_UTIL // for debugging add a serial number, will be set in the constructor // and count up from zero. If you have a deterministic error case and // see the Item involved in the debugger you can use that number in // the next run to see where that Item gets constructed and how it is // involved/ processed
sal_uInt32 m_nSerialNumber; #endif
// bitfield for Item attributes that are Item-Dependent
// Item is registered at some Pool as default. // m_bStaticDefault: direct Pool Item (CAUTION: // these are not really 'static', but should be) // m_bDynamicDefault: dynamic pool item, e.g. // SfxSetItems which are Pool dependent bool m_bStaticDefault : 1; bool m_bDynamicDefault : 1;
// Item is derived from SfxSetItem -> is Pool-dependent bool m_bIsSetItem : 1;
// Defines if the Item can be shared/RefCounted else it will be cloned. // Default is true - as it should be for all Items. It is needed by some // SW items, so protected to let them set it in constructor. If this could // be fixed at that Items we may remove this again. bool m_bShareable : 1;
// for speedup/buffering we need to identify NameOrIndex // Items quickly bool m_bNameOrIndex : 1;
protected: #ifdef DBG_UTIL // this flag will make debugging item stuff much simpler bool m_bDeleted : 1; #endif
// access ItemInstanceManager for this Item, default // is nullptr. If you overload this it is expected that // you return a ptr to a static, Item-local managed // instance that exists the whole office lifetime. This // usually means to have a static instance directly in the // implementation of the overloaded function (just grep // for examples) virtual ItemInstanceManager* getItemInstanceManager() const;
protected: // constructors are protected; SfxPoolItem is a base // class and ought bot to be constructed (also guaranteed // by pure virtual function ItemType now) explicit SfxPoolItem(sal_uInt16 nWhich);
SfxPoolItem(const SfxPoolItem& rCopy) : SfxPoolItem(rCopy.m_nWhich) {}
public: virtual ~SfxPoolItem();
void SetWhich( sal_uInt16 nId )
{ // can only change the Which before we are in a set
assert(m_nRefCount==0);
m_nWhich = nId;
}
sal_uInt16 Which() const { return m_nWhich; }
SAL_LOPLUGIN_ANNOTATE("mustoverride") virtual SfxItemType ItemType() const = 0;
// StaticWhichCast asserts if the TypedWhichId is not matching its type, otherwise it returns a reference. // You can use StaticWhichCast when you are sure about the type at compile time -- like a static_cast. template<class T> T& StaticWhichCast(TypedWhichId<T> nId)
{
(void)nId;
assert(nId == m_nWhich);
assert(dynamic_cast<T*>(this)); return *static_cast<T*>(this);
} template<class T> const T& StaticWhichCast(TypedWhichId<T> nId) const
{
(void)nId;
assert(nId == m_nWhich);
assert(dynamic_cast<const T*>(this)); return *static_cast<const T*>(this);
} // DynamicWhichCast returns nullptr if the TypedWhichId is not matching its type, otherwise it returns a typed pointer. // it asserts if the TypedWhichId matches its Which, but not the RTTI type. // You can use DynamicWhichCast when you are not sure about the type at compile time -- like a dynamic_cast. template<class T> T* DynamicWhichCast(TypedWhichId<T> nId)
{ if(m_nWhich != nId) return nullptr;
assert(dynamic_cast<T*>(this)); returnstatic_cast<T*>(this);
} template<class T> const T* DynamicWhichCast(TypedWhichId<T> nId) const
{ if(m_nWhich != nId) return nullptr;
assert(dynamic_cast<const T*>(this)); returnstatic_cast<const T*>(this);
} virtualbooloperator==( const SfxPoolItem& ) const = 0; booloperator!=( const SfxPoolItem& rItem ) const
{ return !(*this == rItem); } // Used by HashedItemInstanceManager virtualbool supportsHashCode() const; virtual size_t hashCode() const;
/** @return true if it has a valid string representation */ virtualbool GetPresentation( SfxItemPresentation ePresentation,
MapUnit eCoreMetric,
MapUnit ePresentationMetric,
OUString &rText, const IntlWrapper& rIntlWrapper ) const;
// offering a default implementation that can be use for // each SfxPoolItem (except when !isShareable()). It just // uses an unordered_set holding ptrs to SfxPoolItems added // and SfxPoolItem::operator== to linearly search for one. // Thus this is not the fastest, but as fast as old 'pooled' // stuff - better use an intelligent, pro-Item implementation // that does e.g. hashing or whatever might be feasible for // that specific Item (see other derivations) class SVL_DLLPUBLIC DefaultItemInstanceManager final : public ItemInstanceManager
{
std::unordered_map<sal_uInt16, std::unordered_set<const SfxPoolItem*>> maRegistered;
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.