diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2025-01-09 11:51:33 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2025-01-10 19:38:37 +0100 |
commit | 9304f13db61dc101ff1c121277c344a472c2951a (patch) | |
tree | 837bf672c5e529964a7e29ea97cbce7a142ea405 /include/svl | |
parent | 77e536c61a20cbf77207dbf599a88bd21e8ecc27 (diff) |
ITEM: Refactor ItemType
ItemType is useful and faster than RTTI. Until now it was
implemented by a 16-bit member in the base class, plus
(potentially) all constructors having to hand a value
in at item construction type (of type SfxItemType) to
get that member set correctly.
This works, but there is no reliable way to guarantee
coverage, and there have already been cases with missing
SfxItemType - these fallback to '0' and thus all Items
with ItemType() == 0 are assumed equal and might be
static_cast'ed to the wrong classes. Note that I
identified *35* Items that had no correct ItemType
set/implemented actually. It also uses 16-bit per
incarnated Item at runtime.
I thought and realized now a more systematic approach
to do that with a pure virtual function at the Item
itself. That can also be secured by a clang compiler
plugin in the future to keep it working. It uses one
virtual function per derived class, no longer space
in incarnated Items. Also the constructors will get
more simple again.
But the main aspect is security - we cannot afford
Items potentially being held as equal if they are not.
Unfortunately C++ does not offer something like a
'strict pure virtual function' that would force to
be overloaded in every derivation, but the used
methotology and adding a clang test is reasonably
safe.
Have now done the cleanup of previous method.
Change-Id: I04768285f1e9b73d64b0bb87df401944b5d35678
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180017
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'include/svl')
-rw-r--r-- | include/svl/cenumitm.hxx | 3 | ||||
-rw-r--r-- | include/svl/cintitem.hxx | 24 | ||||
-rw-r--r-- | include/svl/eitem.hxx | 11 | ||||
-rw-r--r-- | include/svl/flagitem.hxx | 5 | ||||
-rw-r--r-- | include/svl/globalnameitem.hxx | 1 | ||||
-rw-r--r-- | include/svl/grabbagitem.hxx | 1 | ||||
-rw-r--r-- | include/svl/ilstitem.hxx | 1 | ||||
-rw-r--r-- | include/svl/imageitm.hxx | 1 | ||||
-rw-r--r-- | include/svl/int64item.hxx | 1 | ||||
-rw-r--r-- | include/svl/intitem.hxx | 33 | ||||
-rw-r--r-- | include/svl/lckbitem.hxx | 1 | ||||
-rw-r--r-- | include/svl/macitem.hxx | 3 | ||||
-rw-r--r-- | include/svl/metitem.hxx | 3 | ||||
-rw-r--r-- | include/svl/poolitem.hxx | 117 | ||||
-rw-r--r-- | include/svl/ptitem.hxx | 1 | ||||
-rw-r--r-- | include/svl/rectitem.hxx | 1 | ||||
-rw-r--r-- | include/svl/rngitem.hxx | 1 | ||||
-rw-r--r-- | include/svl/setitem.hxx | 7 | ||||
-rw-r--r-- | include/svl/slstitm.hxx | 1 | ||||
-rw-r--r-- | include/svl/srchitem.hxx | 1 | ||||
-rw-r--r-- | include/svl/stritem.hxx | 10 | ||||
-rw-r--r-- | include/svl/visitem.hxx | 3 | ||||
-rw-r--r-- | include/svl/voiditem.hxx | 1 |
23 files changed, 135 insertions, 96 deletions
diff --git a/include/svl/cenumitm.hxx b/include/svl/cenumitm.hxx index 292648d0f572..d40d3768a3db 100644 --- a/include/svl/cenumitm.hxx +++ b/include/svl/cenumitm.hxx @@ -26,11 +26,12 @@ class SVL_DLLPUBLIC SfxEnumItemInterface: public SfxPoolItem { protected: - explicit SfxEnumItemInterface(sal_uInt16 which, SfxItemType eItemType): SfxPoolItem(which, eItemType) {} + explicit SfxEnumItemInterface(sal_uInt16 which): SfxPoolItem(which) {} SfxEnumItemInterface(const SfxEnumItemInterface &) = default; public: + DECLARE_ITEM_TYPE_FUNCTION(SfxEnumItemInterface) virtual bool operator ==(const SfxPoolItem & rItem) const override; diff --git a/include/svl/cintitem.hxx b/include/svl/cintitem.hxx index 17becbaba92c..57644cd9c4e1 100644 --- a/include/svl/cintitem.hxx +++ b/include/svl/cintitem.hxx @@ -29,9 +29,9 @@ class SVL_DLLPUBLIC CntByteItem: public SfxPoolItem sal_uInt8 m_nValue; public: - - CntByteItem(sal_uInt16 which, sal_uInt8 nTheValue, SfxItemType eItemType = SfxItemType::CntByteItemType): - SfxPoolItem(which, eItemType), m_nValue(nTheValue) {} + DECLARE_ITEM_TYPE_FUNCTION(CntByteItem) + CntByteItem(sal_uInt16 which, sal_uInt8 nTheValue): + SfxPoolItem(which), m_nValue(nTheValue) {} virtual bool operator ==(const SfxPoolItem & rItem) const override; @@ -62,9 +62,9 @@ class SVL_DLLPUBLIC CntUInt16Item: public SfxPoolItem sal_uInt16 m_nValue; public: - - CntUInt16Item(sal_uInt16 which, sal_uInt16 nTheValue, SfxItemType eItemType = SfxItemType::CntUInt16ItemType): - SfxPoolItem(which, eItemType), m_nValue(nTheValue) + DECLARE_ITEM_TYPE_FUNCTION(CntUInt16Item) + CntUInt16Item(sal_uInt16 which, sal_uInt16 nTheValue): + SfxPoolItem(which), m_nValue(nTheValue) {} virtual bool operator ==(const SfxPoolItem & rItem) const override; @@ -97,9 +97,9 @@ class SVL_DLLPUBLIC CntInt32Item: public SfxPoolItem sal_Int32 m_nValue; public: - - CntInt32Item(sal_uInt16 which, sal_Int32 nTheValue, SfxItemType eItemType = SfxItemType::CntInt32ItemType): - SfxPoolItem(which, eItemType), m_nValue(nTheValue) + DECLARE_ITEM_TYPE_FUNCTION(CntInt32Item) + CntInt32Item(sal_uInt16 which, sal_Int32 nTheValue): + SfxPoolItem(which), m_nValue(nTheValue) {} virtual bool operator ==(const SfxPoolItem & rItem) const override; @@ -132,9 +132,9 @@ class SVL_DLLPUBLIC CntUInt32Item: public SfxPoolItem sal_uInt32 m_nValue; public: - - CntUInt32Item(sal_uInt16 which, sal_uInt32 nTheValue, SfxItemType eItemType = SfxItemType::CntUInt32ItemType): - SfxPoolItem(which, eItemType), m_nValue(nTheValue) + DECLARE_ITEM_TYPE_FUNCTION(CntUInt32Item) + CntUInt32Item(sal_uInt16 which, sal_uInt32 nTheValue): + SfxPoolItem(which), m_nValue(nTheValue) {} virtual bool operator ==(const SfxPoolItem & rItem) const override; diff --git a/include/svl/eitem.hxx b/include/svl/eitem.hxx index fd398e8f0cbb..518ebe51db62 100644 --- a/include/svl/eitem.hxx +++ b/include/svl/eitem.hxx @@ -30,8 +30,8 @@ class SAL_DLLPUBLIC_RTTI SfxEnumItem : public SfxEnumItemInterface EnumT m_nValue; protected: - explicit SfxEnumItem(sal_uInt16 const nWhich, SfxItemType eItemType, EnumT const nValue) - : SfxEnumItemInterface(nWhich, eItemType) + explicit SfxEnumItem(sal_uInt16 const nWhich, EnumT const nValue) + : SfxEnumItemInterface(nWhich) , m_nValue(nValue) { } @@ -84,10 +84,9 @@ protected: public: static SfxPoolItem* CreateDefault(); - - explicit SfxBoolItem(sal_uInt16 const nWhich = 0, bool const bValue = false, - SfxItemType eItemType = SfxItemType::SfxBoolItemType) - : SfxPoolItem(nWhich, eItemType) + DECLARE_ITEM_TYPE_FUNCTION(SfxBoolItem) + explicit SfxBoolItem(sal_uInt16 const nWhich = 0, bool const bValue = false) + : SfxPoolItem(nWhich) , m_bValue(bValue) { } diff --git a/include/svl/flagitem.hxx b/include/svl/flagitem.hxx index f269e65582a8..8a8f70b869b4 100644 --- a/include/svl/flagitem.hxx +++ b/include/svl/flagitem.hxx @@ -28,9 +28,8 @@ class SVL_DLLPUBLIC SfxFlagItem: public SfxPoolItem sal_uInt16 nVal; public: - - explicit SfxFlagItem( sal_uInt16 nWhich = 0, sal_uInt16 nValue = 0, - SfxItemType eItemType = SfxItemType::SfxFlagItemType ); + DECLARE_ITEM_TYPE_FUNCTION(SfxFlagItem) + explicit SfxFlagItem( sal_uInt16 nWhich = 0, sal_uInt16 nValue = 0 ); virtual sal_uInt8 GetFlagCount() const; diff --git a/include/svl/globalnameitem.hxx b/include/svl/globalnameitem.hxx index edbb56273232..198330020697 100644 --- a/include/svl/globalnameitem.hxx +++ b/include/svl/globalnameitem.hxx @@ -30,6 +30,7 @@ class SVL_DLLPUBLIC SfxGlobalNameItem final : public SfxPoolItem public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SfxGlobalNameItem) SfxGlobalNameItem(); SfxGlobalNameItem( sal_uInt16 nWhich, const SvGlobalName& ); virtual ~SfxGlobalNameItem() override; diff --git a/include/svl/grabbagitem.hxx b/include/svl/grabbagitem.hxx index a50a5af9dc82..ea1dbef3f22d 100644 --- a/include/svl/grabbagitem.hxx +++ b/include/svl/grabbagitem.hxx @@ -22,6 +22,7 @@ private: std::map<OUString, css::uno::Any> m_aMap; public: + DECLARE_ITEM_TYPE_FUNCTION(SfxGrabBagItem) SfxGrabBagItem(); SfxGrabBagItem(sal_uInt16 nWhich); SfxGrabBagItem(sal_uInt16 nWhich, std::map<OUString, css::uno::Any> aMap); diff --git a/include/svl/ilstitem.hxx b/include/svl/ilstitem.hxx index bb49d18c9dbb..19fa21406c4d 100644 --- a/include/svl/ilstitem.hxx +++ b/include/svl/ilstitem.hxx @@ -32,6 +32,7 @@ class SVL_DLLPUBLIC SfxIntegerListItem final : public SfxPoolItem public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SfxIntegerListItem) SfxIntegerListItem(); SfxIntegerListItem( sal_uInt16 nWhich, std::vector < sal_Int32 >&& rList ); SfxIntegerListItem( sal_uInt16 nWhich, const css::uno::Sequence < sal_Int32 >& rList ); diff --git a/include/svl/imageitm.hxx b/include/svl/imageitm.hxx index 4ef7e4d47f1e..321931bd9bf3 100644 --- a/include/svl/imageitm.hxx +++ b/include/svl/imageitm.hxx @@ -28,6 +28,7 @@ class SVL_DLLPUBLIC SfxImageItem final : public SfxInt16Item { public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SfxImageItem) SfxImageItem( sal_uInt16 nWhich = 0 ); SfxImageItem( const SfxImageItem& ); virtual ~SfxImageItem() override; diff --git a/include/svl/int64item.hxx b/include/svl/int64item.hxx index 70a502c645a8..774d986f62b6 100644 --- a/include/svl/int64item.hxx +++ b/include/svl/int64item.hxx @@ -18,6 +18,7 @@ class SVL_DLLPUBLIC SfxInt64Item final : public SfxPoolItem sal_Int64 mnValue; public: + DECLARE_ITEM_TYPE_FUNCTION(SfxInt64Item) SfxInt64Item( sal_uInt16 nWhich, sal_Int64 nVal ); virtual ~SfxInt64Item() override; diff --git a/include/svl/intitem.hxx b/include/svl/intitem.hxx index 1197ed5de085..d8452fef6c2f 100644 --- a/include/svl/intitem.hxx +++ b/include/svl/intitem.hxx @@ -29,10 +29,9 @@ class SVL_DLLPUBLIC SfxByteItem: public CntByteItem { public: static SfxPoolItem* CreateDefault(); - - explicit SfxByteItem(sal_uInt16 which = 0, sal_uInt8 nValue = 0, - SfxItemType eItemType = SfxItemType::SfxByteItemType): - CntByteItem(which, nValue, eItemType) {} + DECLARE_ITEM_TYPE_FUNCTION(SfxByteItem) + explicit SfxByteItem(sal_uInt16 which = 0, sal_uInt8 nValue = 0): + CntByteItem(which, nValue) {} virtual SfxByteItem* Clone(SfxItemPool * = nullptr) const override { return new SfxByteItem(*this); } @@ -44,10 +43,9 @@ class SVL_DLLPUBLIC SfxInt16Item: public SfxPoolItem public: static SfxPoolItem* CreateDefault(); - - explicit SfxInt16Item(sal_uInt16 which = 0, sal_Int16 nTheValue = 0, - SfxItemType eItemType = SfxItemType::SfxInt16ItemType): - SfxPoolItem(which, eItemType), m_nValue(nTheValue) + DECLARE_ITEM_TYPE_FUNCTION(SfxInt16Item) + explicit SfxInt16Item(sal_uInt16 which = 0, sal_Int16 nTheValue = 0): + SfxPoolItem(which), m_nValue(nTheValue) {} virtual bool operator ==(const SfxPoolItem & rItem) const override; @@ -80,10 +78,9 @@ class SVL_DLLPUBLIC SfxUInt16Item: public CntUInt16Item { public: static SfxPoolItem* CreateDefault(); - - explicit SfxUInt16Item(sal_uInt16 which = 0, sal_uInt16 nValue = 0, - SfxItemType eItemType = SfxItemType::SfxUInt16ItemType): - CntUInt16Item(which, nValue, eItemType) {} + DECLARE_ITEM_TYPE_FUNCTION(SfxUInt16Item) + explicit SfxUInt16Item(sal_uInt16 which = 0, sal_uInt16 nValue = 0): + CntUInt16Item(which, nValue) {} virtual SfxUInt16Item* Clone(SfxItemPool * = nullptr) const override { return new SfxUInt16Item(*this); } @@ -98,9 +95,9 @@ class SVL_DLLPUBLIC SfxInt32Item: public CntInt32Item public: static SfxPoolItem* CreateDefault(); - explicit SfxInt32Item(sal_uInt16 which = 0, sal_Int32 nValue = 0, - SfxItemType eItemType = SfxItemType::SfxInt32ItemType): - CntInt32Item(which, nValue, eItemType) {} + DECLARE_ITEM_TYPE_FUNCTION(SfxInt32Item) + explicit SfxInt32Item(sal_uInt16 which = 0, sal_Int32 nValue = 0): + CntInt32Item(which, nValue) {} virtual SfxInt32Item* Clone(SfxItemPool * = nullptr) const override { return new SfxInt32Item(*this); } @@ -114,9 +111,9 @@ class SVL_DLLPUBLIC SfxUInt32Item: public CntUInt32Item { public: static SfxPoolItem* CreateDefault(); - - explicit SfxUInt32Item(sal_uInt16 which = 0, sal_uInt32 nValue = 0, SfxItemType eItemType = SfxItemType::SfxUInt32ItemType): - CntUInt32Item(which, nValue, eItemType) {} + DECLARE_ITEM_TYPE_FUNCTION(SfxUInt32Item) + explicit SfxUInt32Item(sal_uInt16 which = 0, sal_uInt32 nValue = 0): + CntUInt32Item(which, nValue) {} virtual SfxUInt32Item* Clone(SfxItemPool * = nullptr) const override { return new SfxUInt32Item(*this); } diff --git a/include/svl/lckbitem.hxx b/include/svl/lckbitem.hxx index af19872d05eb..9a61bb55e643 100644 --- a/include/svl/lckbitem.hxx +++ b/include/svl/lckbitem.hxx @@ -33,6 +33,7 @@ public: SfxLockBytesItem(); virtual ~SfxLockBytesItem() override; + DECLARE_ITEM_TYPE_FUNCTION(SfxLockBytesItem) SfxLockBytesItem(SfxLockBytesItem const &) = default; SfxLockBytesItem(SfxLockBytesItem &&) = default; SfxLockBytesItem & operator =(SfxLockBytesItem const &) = delete; // due to SfxPoolItem diff --git a/include/svl/macitem.hxx b/include/svl/macitem.hxx index 999acb8a9f02..0445396f4f22 100644 --- a/include/svl/macitem.hxx +++ b/include/svl/macitem.hxx @@ -110,6 +110,7 @@ This item describes a Macro table. class SVL_DLLPUBLIC SvxMacroItem final : public SfxPoolItem { public: + DECLARE_ITEM_TYPE_FUNCTION(SvxMacroItem) explicit inline SvxMacroItem ( const sal_uInt16 nId ); // "pure virtual methods" of SfxPoolItem @@ -135,7 +136,7 @@ private: }; inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId ) - : SfxPoolItem( nId, SfxItemType::SvxMacroItemType ) + : SfxPoolItem( nId ) {} inline bool SvxMacroItem::HasMacro( SvMacroItemId nEvent ) const diff --git a/include/svl/metitem.hxx b/include/svl/metitem.hxx index 125ee7c3dc1d..30cf75b7f864 100644 --- a/include/svl/metitem.hxx +++ b/include/svl/metitem.hxx @@ -25,8 +25,7 @@ class SVL_DLLPUBLIC SfxMetricItem: public SfxInt32Item { public: - explicit SfxMetricItem( sal_uInt16 nWhich, sal_Int32 nValue, - SfxItemType eItemType = SfxItemType::SfxMetricItemType ); + explicit SfxMetricItem( sal_uInt16 nWhich, sal_Int32 nValue ); virtual void ScaleMetrics( tools::Long lMult, tools::Long lDiv ) override; virtual bool HasMetrics() const override; diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 43dc82143339..3475aea6c039 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -105,7 +105,16 @@ enum class SfxItemState { SET = 0x0040 }; -enum class SfxItemType : sal_uInt16 { +/** + * These defines SfxItemType. Each derivation from SfxPoolItem needs one + * unique value that is returned in the call to ItemType(). This is done + * using DECLARE_ITEM_TYPE_FUNCTION in the public section of each definition + * of a derivation of SfxItemType, also for types derived deeper than one + * step. It overloads virtual SfxItemType ItemType() with the secified + * type, see that macro. +*/ +enum class SfxItemType : sal_uInt16 +{ AffineMatrixItemType, CntByteItemType, CntInt32ItemType, @@ -117,11 +126,11 @@ enum class SfxItemType : sal_uInt16 { InvalidOrDisabledItemType, MediaItemType, NameOrIndexType, - OStringListItemType, OfaPtrItemType, OfaXColorListItemType, OptionalBoolItemType, - RectangleAlignmentType, + OStringListItemType, + SampleItemType, SbxItemType, ScCondFormatItemType, ScConsolidateItemType, @@ -130,6 +139,7 @@ enum class SfxItemType : sal_uInt16 { ScInputStatusItemType, ScLineBreakCellType, ScMergeAttrType, + ScMergeFlagAttrType, ScPageHFItemType, ScPageScaleToItemType, ScPivotItemType, @@ -149,6 +159,7 @@ enum class SfxItemType : sal_uInt16 { ScUserListItemType, ScVerticalStackCellType, ScViewObjectModeItemType, + SdOptionsGridItemType, SdOptionsMiscItemType, SdOptionsPrintItemType, SdrAllPositionXItemType, @@ -157,12 +168,12 @@ enum class SfxItemType : sal_uInt16 { SdrAllSizeWidthItemType, SdrAngleItemType, SdrCaptionAngleItemType, - SdrCaptionGapItemType, SdrCaptionEscAbsItemType, SdrCaptionEscDirItemType, - SdrCaptionEscRelItemType, SdrCaptionEscIsRelItemType, + SdrCaptionEscRelItemType, SdrCaptionFitLineLenItemType, + SdrCaptionGapItemType, SdrCaptionLineLenItemType, SdrCaptionTypeItemType, SdrCircKindItemType, @@ -178,21 +189,23 @@ enum class SfxItemType : sal_uInt16 { SdrFractionItemType, SdrGrafBlueItemType, SdrGrafContrastItemType, - SdrGrafCropType, + SdrGrafCropItemType, SdrGrafGamma100ItemType, SdrGrafGreenItemType, + SdrGrafInvertItemType, SdrGrafLuminanceItemType, + SdrGrafModeItemType, + SdrGrafModeItem_BaseType, SdrGrafRedItemType, - SdrGrafInvertItemType, - SdrGrafModeItem_Base, SdrGrafTransparenceItemType, + SdrHorzShearAllItemType, + SdrHorzShearOneItemType, SdrLayerIdItemType, SdrLayerNameItemType, SdrLogicSizeHeightItemType, SdrLogicSizeWidthItemType, SdrMeasureBelowRefEdgeItemType, SdrMeasureDecimalPlacesItemType, - SdrMeasureFormatStringItemType, SdrMeasureKindItemType, SdrMeasureOverhangItemType, SdrMeasureScaleItemType, @@ -229,30 +242,30 @@ enum class SfxItemType : sal_uInt16 { SdrTextAniCountItemType, SdrTextAniDelayItemType, SdrTextAniDirectionItemType, + SdrTextAniKindItemType, SdrTextAniStartInsideItemType, SdrTextAniStopInsideItemType, - SdrTextAniKindItemType, SdrTextFitToSizeTypeItemType, SdrTextFixedCellHeightItemType, - SdrTextHorzAdjustType, - SdrTextVertAdjustType, + SdrTextHorzAdjustItemType, + SdrTextVertAdjustItemType, SdrTransformRef1XItemType, SdrTransformRef1YItemType, SdrTransformRef2XItemType, SdrTransformRef2YItemType, - SdrHorzShearAllItemType, SdrVertShearAllItemType, - SdrHorzShearOneItemType, SdrVertShearOneItemType, SdrYesNoItemType, SfxBoolItemType, SfxByteItemType, SfxDocumentInfoItemType, + SfxEnumItemInterfaceType, SfxEventNamesItemType, SfxFlagItemType, SfxFrameItemType, SfxGlobalNameItemType, SfxGrabBagItemType, + SfxHyphenRegionItemType, SfxImageItemType, SfxInt16ItemType, SfxInt32ItemType, @@ -261,13 +274,11 @@ enum class SfxItemType : sal_uInt16 { SfxLinkItemType, SfxLockBytesItemType, SfxMacroInfoItemType, - SfxMetricItemType, SfxObjectItemType, SfxObjectShellItemType, SfxPointItemType, SfxRangeItemType, SfxRectangleItemType, - SfxRegionItemType, SfxScriptOrganizerItemType, SfxSetItemType, SfxStringItemType, @@ -282,7 +293,6 @@ enum class SfxItemType : sal_uInt16 { SfxVisibilityItemType, SfxVoidItemType, SfxWatermarkItemType, - SfxZoomItemType, Svx3DCharacterModeItemType, Svx3DCloseBackItemType, Svx3DCloseFrontItemType, @@ -296,7 +306,6 @@ enum class SfxItemType : sal_uInt16 { Svx3DTextureModeItemType, Svx3DTextureProjectionXItemType, Svx3DTextureProjectionYItemType, - SvXMLAttrContainerItemType, SvxAdjustItemType, SvxAutoKernItemType, SvxB3DVectorItemType, @@ -333,6 +342,8 @@ enum class SfxItemType : sal_uInt16 { SvxFontListItemType, SvxForbiddenRuleItemType, SvxFormatBreakItemType, + SvxFormatKeepItemType, + SvxFormatSplitItemType, SvxFrameDirectionItemType, SvxGalleryItemType, SvxGradientListItemType, @@ -348,42 +359,50 @@ enum class SfxItemType : sal_uInt16 { SvxHyphenZoneItemType, SvxJustifyMethodItemType, SvxKerningItemType, - SvxLRSpaceItemType, SvxLanguageItemType, + SvxLanguageItem_BaseType, SvxLeftMarginItemType, SvxLineEndListItemType, SvxLineItemType, SvxLineSpacingItemType, SvxLongLRSpaceItemType, SvxLongULSpaceItemType, + SvxLRSpaceItemType, SvxMacroItemType, SvxMarginItemType, + SvXMLAttrContainerItemType, SvxNoHyphenItemType, - SvxNumBulletItemType, SvxNumberInfoItemType, + SvxNumBulletItemType, SvxObjectItemType, SvxOpaqueItemType, SvxOrientationItemType, SvxOrphansItemType, SvxOverlineItemType, SvxPageItemType, + SvxPageModelItemType, SvxPagePosSizeItemType, SvxPaperBinItemType, SvxParaGridItemType, SvxParaVertAlignItemType, SvxPatternListItemType, + SvxPostItAuthorItemType, SvxPostItDateItemType, + SvxPostItIdItemType, + SvxPostItTextItemType, SvxPostureItemType, SvxPrintItemType, SvxProtectItemType, + SvxRectangleAlignmentItemType, SvxRightMarginItemType, SvxRotateModeItemType, SvxRsidItemType, SvxScriptSetItemType, SvxScriptSpaceItemType, SvxSearchItemType, - SvxShadowItemType, + SvxSetItemType, SvxShadowedItemType, + SvxShadowItemType, SvxSizeItemType, SvxSmartTagItemType, SvxStatusItemType, @@ -392,22 +411,26 @@ enum class SfxItemType : sal_uInt16 { SvxTextLineItemType, SvxTextRotateItemType, SvxTwoLinesItemType, - SvxUnderlineItemType, SvxULSpaceItemType, + SvxUnderlineItemType, SvxVerJustifyItemType, SvxViewLayoutItemType, SvxWeightItemType, SvxWidowsItemType, - SvxWordLineItemType, + SvxWordLineModeItemType, SvxWritingModeItemType, + SvxZoomItemType, SvxZoomSliderItemType, SwAddPrinterItemType, - SwChannelGrfType, + SwAttrSetChgType, + SwChannelBGrfType, + SwChannelGGrfType, + SwChannelRGrfType, SwCondCollItemType, SwContrastGrfType, SwCropGrfType, SwDocDisplayItemType, - SwDrawModeGrf_BaseType, + SwDrawModeGrfType, SwElemItemType, SwEnvItemType, SwFltAnchorType, @@ -421,25 +444,26 @@ enum class SfxItemType : sal_uInt16 { SwFormatChainType, SwFormatCharFormatType, SwFormatColType, - SwFormatContentControlType, SwFormatContentType, + SwFormatContentControlType, SwFormatDropType, - SwFormatEditInReadonly, + SwFormatEditInReadonlyType, + SwFormatEndAtTextEndType, SwFormatFieldType, - SwFormatFrameSizeType, SwFormatFillOrderType, SwFormatFlyCntType, SwFormatFlySplitType, SwFormatFollowTextFlowType, SwFormatFooterType, - SwFormatFootnoteEndAtTextEndType, SwFormatFootnoteType, + SwFormatFootnoteAtTextEndType, + SwFormatFrameSizeType, SwFormatHeaderType, SwFormatHoriOrientType, SwFormatINetFormatType, SwFormatLayoutSplitType, + SwFormatLineBreakType, SwFormatLineNumberType, - SwFormatLinebreakType, SwFormatMetaType, SwFormatNoBalancedColumnsType, SwFormatPageDescType, @@ -449,7 +473,7 @@ enum class SfxItemType : sal_uInt16 { SwFormatSurroundType, SwFormatURLType, SwFormatVertOrientType, - SwFormatWrapInfluenceOnOjPosType, + SwFormatWrapInfluenceOnObjPosType, SwFormatWrapTextAtFlyStartType, SwGammaGrfType, SwHeaderAndFooterEatSpacingItemType, @@ -459,18 +483,22 @@ enum class SfxItemType : sal_uInt16 { SwMirrorGrfType, SwMsgPoolItemType, SwNumRuleItemType, - SwPaMItemType, SwPageFootnoteInfoItemType, + SwPaMItemType, + SwParaConnectBorderItemType, SwPtrItemType, + SwPtrMsgPoolItemType, + SwRegisterItemType, SwRotationGrfType, SwShadowCursorItemType, - SwTOXMarkType, + SwTableBoxFormulaType, SwTableBoxNumFormatType, SwTableBoxValueType, - SwTableFormulaType, SwTextGridItemType, + SwTOXMarkType, SwTransparencyGrfType, SwUINumRuleItemType, + SwUpdateAttrType, SwWrtShellItemType, XColorItemType, XFillAttrSetItemType, @@ -514,7 +542,7 @@ enum class SfxItemType : sal_uInt16 { XLineEndItemType, XLineEndWidthItemType, XLineJointItemType, - XLineStartCenterItem, + XLineStartCenterItemType, XLineStartItemType, XLineStartWidthItemType, XLineStyleItemType, @@ -537,6 +565,9 @@ class SfxItemPool; typedef struct _xmlTextWriter* xmlTextWriterPtr; class ItemInstanceManager; +#define DECLARE_ITEM_TYPE_FUNCTION(T) \ + virtual SfxItemType ItemType() const override { return SfxItemType::T##Type; } + class SVL_DLLPUBLIC SfxPoolItem { friend class SfxItemPool; @@ -551,7 +582,6 @@ class SVL_DLLPUBLIC SfxPoolItem mutable sal_uInt32 m_nRefCount; sal_uInt16 m_nWhich; - SfxItemType m_eItemType; #ifdef DBG_UTIL // for debugging add a serial number, will be set in the constructor @@ -640,10 +670,11 @@ private: } protected: - - explicit SfxPoolItem( sal_uInt16 nWhich, SfxItemType ); - SfxPoolItem( const SfxPoolItem& rCopy) - : SfxPoolItem(rCopy.m_nWhich, rCopy.m_eItemType) {} + // costructors 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(); @@ -654,8 +685,8 @@ public: assert(m_nRefCount==0); m_nWhich = nId; } - sal_uInt16 Which() const { return m_nWhich; } - SfxItemType ItemType() const { return m_eItemType;} + sal_uInt16 Which() const { return m_nWhich; } + 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. @@ -757,7 +788,7 @@ private: // 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 'poooled' +// 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) diff --git a/include/svl/ptitem.hxx b/include/svl/ptitem.hxx index 763d2d859663..f78d0f9a0851 100644 --- a/include/svl/ptitem.hxx +++ b/include/svl/ptitem.hxx @@ -30,6 +30,7 @@ class SVL_DLLPUBLIC SfxPointItem final : public SfxPoolItem public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SfxPointItem) SfxPointItem(); SfxPointItem( sal_uInt16 nWhich, const Point& rVal ); diff --git a/include/svl/rectitem.hxx b/include/svl/rectitem.hxx index 0b7dadb88a33..24d4e59e1eb3 100644 --- a/include/svl/rectitem.hxx +++ b/include/svl/rectitem.hxx @@ -29,6 +29,7 @@ class SVL_DLLPUBLIC SfxRectangleItem final : public SfxPoolItem public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SfxRectangleItem) SfxRectangleItem(); SfxRectangleItem( sal_uInt16 nWhich, const tools::Rectangle& rVal ); diff --git a/include/svl/rngitem.hxx b/include/svl/rngitem.hxx index 6276863a47de..452fc71ab18d 100644 --- a/include/svl/rngitem.hxx +++ b/include/svl/rngitem.hxx @@ -31,6 +31,7 @@ private: sal_uInt16 nFrom; sal_uInt16 nTo; public: + DECLARE_ITEM_TYPE_FUNCTION(SfxRangeItem) SfxRangeItem( sal_uInt16 nWID, sal_uInt16 nFrom, sal_uInt16 nTo ); virtual bool operator==( const SfxPoolItem& ) const override; virtual bool GetPresentation( SfxItemPresentation ePres, diff --git a/include/svl/setitem.hxx b/include/svl/setitem.hxx index 6468037870be..219906f97f62 100644 --- a/include/svl/setitem.hxx +++ b/include/svl/setitem.hxx @@ -31,10 +31,9 @@ class SVL_DLLPUBLIC SfxSetItem : public SfxPoolItem SfxSetItem& operator=(const SfxSetItem&) = delete; public: - SfxSetItem(sal_uInt16 nWhich, SfxItemSet&& pSet, - SfxItemType eItemType = SfxItemType::SfxSetItemType); - SfxSetItem(sal_uInt16 nWhich, const SfxItemSet& rSet, - SfxItemType eItemType = SfxItemType::SfxSetItemType); + DECLARE_ITEM_TYPE_FUNCTION(SfxSetItem) + SfxSetItem(sal_uInt16 nWhich, SfxItemSet&& pSet); + SfxSetItem(sal_uInt16 nWhich, const SfxItemSet& rSet); SfxSetItem(const SfxSetItem&, SfxItemPool* pPool = nullptr); virtual bool operator==(const SfxPoolItem&) const override; diff --git a/include/svl/slstitm.hxx b/include/svl/slstitm.hxx index 48e558149881..53406cc4382d 100644 --- a/include/svl/slstitm.hxx +++ b/include/svl/slstitm.hxx @@ -34,6 +34,7 @@ class SVL_DLLPUBLIC SfxStringListItem final : public SfxPoolItem public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SfxStringListItem) SfxStringListItem(); SfxStringListItem( sal_uInt16 nWhich, const std::vector<OUString> *pList=nullptr ); virtual ~SfxStringListItem() override; diff --git a/include/svl/srchitem.hxx b/include/svl/srchitem.hxx index c51d2d752e02..f9c71d4e767b 100644 --- a/include/svl/srchitem.hxx +++ b/include/svl/srchitem.hxx @@ -92,6 +92,7 @@ class SVL_DLLPUBLIC SvxSearchItem final : public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SvxSearchItem) explicit SvxSearchItem( const sal_uInt16 nId ); SvxSearchItem( const SvxSearchItem& rItem ); virtual ~SvxSearchItem() override; diff --git a/include/svl/stritem.hxx b/include/svl/stritem.hxx index 977f4bddc7b0..5708de213224 100644 --- a/include/svl/stritem.hxx +++ b/include/svl/stritem.hxx @@ -28,12 +28,12 @@ class SVL_DLLPUBLIC SfxStringItem: public SfxPoolItem { public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SfxStringItem) + SfxStringItem(sal_uInt16 which = 0) + : SfxPoolItem(which) {} - SfxStringItem(sal_uInt16 which = 0, SfxItemType eItemType = SfxItemType::SfxStringItemType) - : SfxPoolItem(which, eItemType) {} - - SfxStringItem(sal_uInt16 which, const OUString & rValue, SfxItemType eItemType = SfxItemType::SfxStringItemType): - SfxPoolItem(which, eItemType), m_aValue(rValue) {} + SfxStringItem(sal_uInt16 which, const OUString & rValue): + SfxPoolItem(which), m_aValue(rValue) {} virtual bool operator ==(const SfxPoolItem & rItem) const override; // Note that all the subclasses are currently marked as false since we haven't check them to diff --git a/include/svl/visitem.hxx b/include/svl/visitem.hxx index 8a458bbf2f6c..225f602ccb23 100644 --- a/include/svl/visitem.hxx +++ b/include/svl/visitem.hxx @@ -30,8 +30,9 @@ class SVL_DLLPUBLIC SfxVisibilityItem final : public SfxPoolItem public: + DECLARE_ITEM_TYPE_FUNCTION(SfxVisibilityItem) explicit SfxVisibilityItem(sal_uInt16 which, bool bVisible): - SfxPoolItem(which, SfxItemType::SfxVisibilityItemType) + SfxPoolItem(which) { m_nValue.bVisible = bVisible; } diff --git a/include/svl/voiditem.hxx b/include/svl/voiditem.hxx index 911c691470fb..07f37326e888 100644 --- a/include/svl/voiditem.hxx +++ b/include/svl/voiditem.hxx @@ -27,6 +27,7 @@ class SVL_DLLPUBLIC SfxVoidItem final : public SfxPoolItem public: static SfxPoolItem* CreateDefault(); + DECLARE_ITEM_TYPE_FUNCTION(SfxVoidItem) explicit SfxVoidItem(sal_uInt16 nWhich); SfxVoidItem(const SfxVoidItem& rCopy); SfxVoidItem(SfxVoidItem&& rOrig); |