chart2/source/controller/dialogs/dlg_ObjectProperties.cxx                |    
2 
 chart2/source/controller/dialogs/res_DataLabel.cxx                       |    
2 
 chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx            |   
22 ++++----
 chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx       |    
2 
 chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx        |    
8 +--
 chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx |   
10 ++--
 chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx   |    
2 
 chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx      |   
18 +++----
 chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx       |    
2 
 chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx           |    
2 
 cui/source/dialogs/hltpbase.cxx                                          |   
20 ++++----
 cui/source/tabpages/align.cxx                                            |   
12 ++--
 dbaccess/source/ui/dlg/dlgattr.cxx                                       |    
4 -
 include/sfx2/sfxsids.hrc                                                 |    
5 +-
 include/svl/typedwhich.hxx                                               |   
13 ++++-
 include/svx/SmartTagItem.hxx                                             |    
2 
 include/svx/algitem.hxx                                                  |    
8 +--
 include/svx/chrtitem.hxx                                                 |   
10 ++--
 include/svx/clipfmtitem.hxx                                              |    
2 
 include/svx/drawitem.hxx                                                 |   
14 ++---
 include/svx/e3ditem.hxx                                                  |    
2 
 include/svx/grfcrop.hxx                                                  |    
4 -
 include/svx/hlnkitem.hxx                                                 |    
4 -
 include/svx/numinf.hxx                                                   |   
10 ++--
 include/svx/optgrid.hxx                                                  |    
2 
 include/svx/pageitem.hxx                                                 |    
6 +-
 include/svx/postattr.hxx                                                 |   
14 ++---
 include/svx/rotmodit.hxx                                                 |    
2 
 include/svx/rulritem.hxx                                                 |    
4 -
 include/svx/sdangitm.hxx                                                 |    
2 
 include/svx/sdmetitm.hxx                                                 |    
2 
 include/svx/sdooitm.hxx                                                  |    
2 
 include/svx/sdprcitm.hxx                                                 |    
2 
 include/svx/sdtaitm.hxx                                                  |    
2 
 include/svx/sdynitm.hxx                                                  |    
2 
 include/svx/svxids.hrc                                                   |   
24 +++++----
 include/svx/viewlayoutitem.hxx                                           |    
2 
 include/svx/xcolit.hxx                                                   |   
10 +---
 include/svx/xflgrit.hxx                                                  |    
2 
 include/svx/xit.hxx                                                      |    
4 -
 include/svx/zoomslideritem.hxx                                           |    
2 
 reportdesign/source/ui/misc/UITools.cxx                                  |    
2 
 reportdesign/source/ui/report/ReportController.cxx                       |    
2 
 sc/inc/sc.hrc                                                            |    
4 +
 sc/source/filter/qpro/qprostyle.cxx                                      |    
2 
 sc/source/ui/unoobj/afmtuno.cxx                                          |    
2 
 sc/source/ui/unoobj/cellsuno.cxx                                         |    
2 
 sc/source/ui/unoobj/styleuno.cxx                                         |    
2 
 sc/source/ui/view/tabvwsh5.cxx                                           |    
2 
 sd/inc/sdattr.hrc                                                        |    
8 ++-
 sd/source/ui/dlg/paragr.cxx                                              |    
1 
 sd/source/ui/view/drviews3.cxx                                           |    
8 +--
 sd/source/ui/view/drviewsf.cxx                                           |    
1 
 svx/source/dialog/hdft.cxx                                               |    
2 
 svx/source/dialog/rulritem.cxx                                           |    
4 -
 svx/source/items/SmartTagItem.cxx                                        |    
2 
 svx/source/items/algitem.cxx                                             |   
10 ++--
 svx/source/items/autoformathelper.cxx                                    |    
4 -
 svx/source/items/chrtitem.cxx                                            |   
12 ++--
 svx/source/items/clipfmtitem.cxx                                         |    
4 -
 svx/source/items/drawitem.cxx                                            |   
14 ++---
 svx/source/items/e3ditem.cxx                                             |    
2 
 svx/source/items/grfitem.cxx                                             |    
4 -
 svx/source/items/hlnkitem.cxx                                            |    
4 -
 svx/source/items/numinf.cxx                                              |   
10 ++--
 svx/source/items/pageitem.cxx                                            |    
8 +--
 svx/source/items/postattr.cxx                                            |   
25 ++++------
 svx/source/items/rotmodit.cxx                                            |    
4 -
 svx/source/items/viewlayoutitem.cxx                                      |    
2 
 svx/source/items/zoomslideritem.cxx                                      |    
2 
 svx/source/mnuctrls/smarttagmenu.cxx                                     |    
2 
 svx/source/svdraw/svdattr.cxx                                            |   
10 ++--
 svx/source/unodraw/UnoNameItemTable.cxx                                  |    
2 
 svx/source/xoutdev/xattr.cxx                                             |   
14 ++---
 sw/inc/cmdid.h                                                           |   
10 ++--
 sw/qa/core/uwriter.cxx                                                   |    
4 -
 sw/source/core/doc/tblafmt.cxx                                           |    
4 -
 sw/source/filter/ww8/ww8graf.cxx                                         |    
3 -
 sw/source/ui/fldui/flddinf.cxx                                           |    
3 -
 sw/source/ui/fldui/fldedt.cxx                                            |    
4 -
 sw/source/ui/fldui/fldtdlg.cxx                                           |    
4 -
 sw/source/uibase/dochdl/swdtflvr.cxx                                     |    
2 
 sw/source/uibase/shells/basesh.cxx                                       |    
2 
 sw/source/uibase/shells/textsh1.cxx                                      |    
2 
 sw/source/uibase/uiview/viewsrch.cxx                                     |    
2 
 sw/source/uibase/uiview/viewtab.cxx                                      |   
14 ++---
 86 files changed, 257 insertions(+), 238 deletions(-)

New commits:
commit c3d5c9a08df77f9c0d0fd2493cf299dbad1a9dff
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Jan 28 15:17:04 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Jan 29 18:59:53 2022 +0100

    used TypedWhichId in the constructor of various svx *Item classes
    
    to act as an extra check that we have the association of Item and
    TypedWhichId annotations correct.
    
    (*) requires that I add an upcasting constructor to TypedWhichId
    
    (*) Make the field dialog stuff in writer use a new item id
    FN_FIELD_DIALOG_DOC_PROPS instead of abusing the
    existing SID_DOCINFO
    
    Change-Id: Ica4aea930c80124609a063768c9af5a189df1c27
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129098
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx 
b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
index 3acad5007365..d7d1c5514633 100644
--- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
+++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx
@@ -570,7 +570,7 @@ void SchAttribTabDlg::PageCreated(const OString& rId, 
SfxTabPage &rPage)
     }
     else if (rId == "numberformat")
     {
-        aSet.Put (SvxNumberInfoItem( m_pNumberFormatter, 
static_cast<sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO)));
+        aSet.Put (SvxNumberInfoItem( m_pNumberFormatter, 
SID_ATTR_NUMBERFORMAT_INFO));
         rPage.PageCreated(aSet);
     }
     else if (rId == "xerrorbar")
diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx 
b/chart2/source/controller/dialogs/res_DataLabel.cxx
index 6bba918d6937..a51e9d79a860 100644
--- a/chart2/source/controller/dialogs/res_DataLabel.cxx
+++ b/chart2/source/controller/dialogs/res_DataLabel.cxx
@@ -187,7 +187,7 @@ IMPL_LINK(DataLabelResources, NumberFormatDialogHdl, 
weld::Button&, rButton, voi
         m_xCBPercent->set_active(true);
 
     SfxItemSet aNumberSet = 
NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( *m_pPool );
-    aNumberSet.Put (SvxNumberInfoItem( m_pNumberFormatter, 
static_cast<sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO)));
+    aNumberSet.Put (SvxNumberInfoItem( m_pNumberFormatter, 
SID_ATTR_NUMBERFORMAT_INFO));
 
     bool bPercent = (&rButton == m_xPB_NumberFormatForPercent.get());
 
diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
index e4a1df261ff2..62e35cede66f 100644
--- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx
@@ -181,12 +181,12 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 
nWhichId, SfxItemSet & rOutI
             {
                 double fMax = 10.0;
                 if( rScale.Maximum >>= fMax )
-                    rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) );
+                    rOutItemSet.Put( SvxDoubleItem( fMax, SCHATTR_AXIS_MAX ) );
                 else
                 {
                     if( m_pExplicitScale )
                         fMax = m_pExplicitScale->Maximum;
-                    rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) );
+                    rOutItemSet.Put( SvxDoubleItem( fMax, SCHATTR_AXIS_MAX ) );
                 }
             }
             break;
@@ -199,9 +199,9 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 
nWhichId, SfxItemSet & rOutI
             {
                 double fMin = 0.0;
                 if( rScale.Minimum >>= fMin )
-                    rOutItemSet.Put( SvxDoubleItem( fMin, nWhichId ) );
+                    rOutItemSet.Put( SvxDoubleItem( fMin, SCHATTR_AXIS_MIN ) );
                 else if( m_pExplicitScale )
-                    rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, 
nWhichId ));
+                    rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, 
SCHATTR_AXIS_MIN ));
             }
             break;
 
@@ -239,17 +239,17 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 
nWhichId, SfxItemSet & rOutI
             {
                 TimeInterval aTimeInterval;
                 if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval )
-                    rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, 
nWhichId ));
+                    rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, 
SCHATTR_AXIS_STEP_MAIN ));
                 else if( m_pExplicitIncrement )
-                    rOutItemSet.Put( SvxDoubleItem( 
m_pExplicitIncrement->MajorTimeInterval.Number, nWhichId ));
+                    rOutItemSet.Put( SvxDoubleItem( 
m_pExplicitIncrement->MajorTimeInterval.Number, SCHATTR_AXIS_STEP_MAIN ));
             }
             else
             {
                 double fDistance = 1.0;
                 if( rIncrement.Distance >>= fDistance )
-                    rOutItemSet.Put( SvxDoubleItem(fDistance, nWhichId ));
+                    rOutItemSet.Put( SvxDoubleItem(fDistance, 
SCHATTR_AXIS_STEP_MAIN ));
                 else if( m_pExplicitIncrement )
-                    rOutItemSet.Put( SvxDoubleItem( 
m_pExplicitIncrement->Distance, nWhichId ));
+                    rOutItemSet.Put( SvxDoubleItem( 
m_pExplicitIncrement->Distance, SCHATTR_AXIS_STEP_MAIN ));
             }
             break;
 
@@ -330,7 +330,7 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 
nWhichId, SfxItemSet & rOutI
                 if( m_pExplicitScale )
                     fOrigin = m_pExplicitScale->Origin;
             }
-            rOutItemSet.Put( SvxDoubleItem( fOrigin, nWhichId ));
+            rOutItemSet.Put( SvxDoubleItem( fOrigin, SCHATTR_AXIS_ORIGIN ));
         }
         break;
 
@@ -346,7 +346,7 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 
nWhichId, SfxItemSet & rOutI
         {
             double fValue = 0.0;
             if( GetPropertySet()->getPropertyValue( "CrossoverValue" ) >>= 
fValue )
-                rOutItemSet.Put( SvxDoubleItem( fValue, nWhichId ) );
+                rOutItemSet.Put( SvxDoubleItem( fValue, 
SCHATTR_AXIS_POSITION_VALUE ) );
         }
         break;
 
@@ -394,7 +394,7 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 
nWhichId, SfxItemSet & rOutI
 
             if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fVal )
             {
-                rOutItemSet.Put( SdrAngleItem( nWhichId, 
Degree100(static_cast< sal_Int32 >(
+                rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, 
Degree100(static_cast< sal_Int32 >(
                                                    ::rtl::math::round( fVal * 
100.0 )) ) ));
             }
         }
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index a4d336ce8216..e06cc392ac86 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -806,7 +806,7 @@ void DataPointItemConverter::FillSpecialItem(
 
             if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= 
fValue )
             {
-                rOutItemSet.Put( SdrAngleItem( nWhichId, 
Degree100(static_cast< sal_Int32 >(
+                rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, 
Degree100(static_cast< sal_Int32 >(
                                                    ::rtl::math::round( fValue 
* 100.0 ) ) )));
             }
         }
diff --git a/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx
index 89c4e8cc212a..8e23902f6423 100644
--- a/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx
@@ -356,7 +356,7 @@ void ErrorBarItemConverter::FillSpecialItem(
         {
             double fPos(0.0), fNeg(0.0);
             lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
-            rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
+            rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, 
SCHATTR_STAT_PERCENT ));
         }
         break;
 
@@ -364,7 +364,7 @@ void ErrorBarItemConverter::FillSpecialItem(
         {
             double fPos(0.0), fNeg(0.0);
             lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
-            rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
+            rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, 
SCHATTR_STAT_BIGERROR ));
         }
         break;
 
@@ -372,7 +372,7 @@ void ErrorBarItemConverter::FillSpecialItem(
         {
             double fPos(0.0), fNeg(0.0);
             lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
-            rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId ));
+            rOutItemSet.Put( SvxDoubleItem( fPos, SCHATTR_STAT_CONSTPLUS ));
         }
         break;
 
@@ -380,7 +380,7 @@ void ErrorBarItemConverter::FillSpecialItem(
         {
             double fPos(0.0), fNeg(0.0);
             lcl_getErrorValues( GetPropertySet(), fPos, fNeg );
-            rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId ));
+            rOutItemSet.Put( SvxDoubleItem( fNeg, SCHATTR_STAT_CONSTMINUS ));
         }
         break;
 
diff --git 
a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
index f98ec6375f3b..a999d30b6414 100644
--- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx
@@ -65,12 +65,12 @@ void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 
nWhichId, const uno::R
     }
 }
 
-void lclConvertToItemSetDouble(SfxItemSet& rItemSet, sal_uInt16 nWhichId, 
const uno::Reference<beans::XPropertySet>& xProperties, const OUString& 
aPropertyID)
+void lclConvertToItemSetDouble(SfxItemSet& rItemSet, 
TypedWhichId<SvxDoubleItem> nWhichId, const 
uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID)
 {
     OSL_ASSERT(xProperties.is());
     if( xProperties.is() )
     {
-        double aValue = static_cast<const SvxDoubleItem&>(rItemSet.Get( 
nWhichId )).GetValue();
+        double aValue = rItemSet.Get( nWhichId ).GetValue();
         if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
         {
             rItemSet.Put(SvxDoubleItem( aValue, nWhichId ));
@@ -283,13 +283,13 @@ void 
RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemS
 
         case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
         {
-            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, 
"ExtrapolateForward");
+            lclConvertToItemSetDouble(rOutItemSet, 
SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, xProperties, "ExtrapolateForward");
         }
         break;
 
         case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
         {
-            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, 
"ExtrapolateBackward");
+            lclConvertToItemSetDouble(rOutItemSet, 
SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, xProperties, "ExtrapolateBackward");
         }
         break;
 
@@ -301,7 +301,7 @@ void 
RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemS
 
         case SCHATTR_REGRESSION_INTERCEPT_VALUE:
         {
-            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, 
"InterceptValue");
+            lclConvertToItemSetDouble(rOutItemSet, 
SCHATTR_REGRESSION_INTERCEPT_VALUE, xProperties, "InterceptValue");
         }
         break;
 
diff --git 
a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index 5080b4d8be01..1615c72d5549 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -394,7 +394,7 @@ void SeriesOptionsItemConverter::FillSpecialItem(
         case SCHATTR_STARTING_ANGLE:
         {
             if( m_bSupportingStartingAngle )
-                rOutItemSet.Put( SdrAngleItem(nWhichId, 
Degree100(m_nStartingAngle*100)) );
+                rOutItemSet.Put( SdrAngleItem(SCHATTR_STARTING_ANGLE, 
Degree100(m_nStartingAngle*100)) );
             break;
         }
         case SCHATTR_CLOCKWISE:
diff --git 
a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
index a900466b85b8..681dd81ef56c 100644
--- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx
@@ -192,12 +192,12 @@ void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 
nWhichId, const uno::R
     }
 }
 
-void lclConvertToItemSetDouble(SfxItemSet& rItemSet, sal_uInt16 nWhichId, 
const uno::Reference<beans::XPropertySet>& xProperties, const OUString& 
aPropertyID)
+void lclConvertToItemSetDouble(SfxItemSet& rItemSet, 
TypedWhichId<SvxDoubleItem> nWhichId, const 
uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID)
 {
     OSL_ASSERT(xProperties.is());
     if( xProperties.is() )
     {
-        double aValue = static_cast<const SvxDoubleItem&>(rItemSet.Get( 
nWhichId )).GetValue();
+        double aValue = rItemSet.Get( nWhichId ).GetValue();
         if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
         {
             rItemSet.Put(SvxDoubleItem( aValue, nWhichId ));
@@ -663,7 +663,7 @@ void StatisticsItemConverter::FillSpecialItem(
             {
                 double fPos(0.0), fNeg(0.0);
                 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
-                rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, 
nWhichId ));
+                rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, 
SCHATTR_STAT_PERCENT ));
             }
         }
         break;
@@ -677,7 +677,7 @@ void StatisticsItemConverter::FillSpecialItem(
             {
                 double fPos(0.0), fNeg(0.0);
                 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
-                rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, 
nWhichId ));
+                rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, 
SCHATTR_STAT_BIGERROR ));
             }
         }
         break;
@@ -691,7 +691,7 @@ void StatisticsItemConverter::FillSpecialItem(
             {
                 double fPos(0.0), fNeg(0.0);
                 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
-                rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId ));
+                rOutItemSet.Put( SvxDoubleItem( fPos, SCHATTR_STAT_CONSTPLUS 
));
             }
         }
         break;
@@ -705,7 +705,7 @@ void StatisticsItemConverter::FillSpecialItem(
             {
                 double fPos(0.0), fNeg(0.0);
                 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
-                rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId ));
+                rOutItemSet.Put( SvxDoubleItem( fNeg, SCHATTR_STAT_CONSTMINUS 
));
             }
         }
         break;
@@ -745,14 +745,14 @@ void StatisticsItemConverter::FillSpecialItem(
         case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD:
         {
             uno::Reference< beans::XPropertySet > xProperties( 
lcl_getCurveProperties( GetPropertySet(), nullptr ));
-            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, 
"ExtrapolateForward");
+            lclConvertToItemSetDouble(rOutItemSet, 
SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, xProperties, "ExtrapolateForward");
         }
         break;
 
         case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD:
         {
             uno::Reference< beans::XPropertySet > xProperties( 
lcl_getCurveProperties( GetPropertySet(), nullptr ));
-            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, 
"ExtrapolateBackward");
+            lclConvertToItemSetDouble(rOutItemSet, 
SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, xProperties, "ExtrapolateBackward");
         }
         break;
 
@@ -766,7 +766,7 @@ void StatisticsItemConverter::FillSpecialItem(
         case SCHATTR_REGRESSION_INTERCEPT_VALUE:
         {
             uno::Reference< beans::XPropertySet > xProperties( 
lcl_getCurveProperties( GetPropertySet(), nullptr ));
-            lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, 
"InterceptValue");
+            lclConvertToItemSetDouble(rOutItemSet, 
SCHATTR_REGRESSION_INTERCEPT_VALUE, xProperties, "InterceptValue");
         }
         break;
 
diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
index cc21bd3604da..b73a1770c767 100644
--- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx
@@ -713,7 +713,7 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 
nWhichId, SfxItemSet& r
             if (GetPropertySet()->getPropertyValue("TextRotation") >>= fValue)
             {
                 rOutItemSet.Put(
-                    SdrAngleItem(nWhichId, 
Degree100(static_cast<sal_Int32>(rtl::math::round(fValue * 100.0)))));
+                    SdrAngleItem(SCHATTR_TEXT_DEGREES, 
Degree100(static_cast<sal_Int32>(rtl::math::round(fValue * 100.0)))));
             }
         }
         break;
diff --git a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx
index 605eb07b4692..7a3f57af5703 100644
--- a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx
@@ -197,7 +197,7 @@ void TitleItemConverter::FillSpecialItem(
 
             if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fVal )
             {
-                rOutItemSet.Put( SdrAngleItem( nWhichId, 
Degree100(static_cast< sal_Int32 >(
+                rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, 
Degree100(static_cast< sal_Int32 >(
                                                    ::rtl::math::round( fVal * 
100.0 ) ) )));
             }
         }
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index fb64eecdfd97..77d335f109c2 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -322,8 +322,8 @@ void SvxHyperlinkTabPageBase::DisableClose(bool _bDisable)
 // Click on imagebutton : Script
 IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, weld::Button&, 
void)
 {
-    SvxHyperlinkItem *pHyperlinkItem = 
const_cast<SvxHyperlinkItem*>(static_cast<const SvxHyperlinkItem *>(
-                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK)));
+    SvxHyperlinkItem *pHyperlinkItem = const_cast<SvxHyperlinkItem*>(
+                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK));
 
     if (!pHyperlinkItem || pHyperlinkItem->GetMacroEvents() == 
HyperDialogEvent::NONE)
         return;
@@ -371,16 +371,16 @@ IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, 
ClickScriptHdl_Impl, weld::Button&, voi
 // Get Macro-Infos
 HyperDialogEvent SvxHyperlinkTabPageBase::GetMacroEvents() const
 {
-    const SvxHyperlinkItem *pHyperlinkItem = static_cast<const 
SvxHyperlinkItem *>(
-                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK));
+    const SvxHyperlinkItem *pHyperlinkItem =
+                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK);
 
     return pHyperlinkItem ? pHyperlinkItem->GetMacroEvents() : 
HyperDialogEvent();
 }
 
 SvxMacroTableDtor* SvxHyperlinkTabPageBase::GetMacroTable()
 {
-    const SvxHyperlinkItem *pHyperlinkItem = static_cast<const 
SvxHyperlinkItem *>(
-                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK));
+    const SvxHyperlinkItem *pHyperlinkItem =
+                                       GetItemSet().GetItem 
(SID_HYPERLINK_GETLINK);
 
     return const_cast<SvxMacroTableDtor*>(pHyperlinkItem->GetMacroTable());
 }
@@ -445,8 +445,8 @@ void SvxHyperlinkTabPageBase::Reset( const SfxItemSet& 
rItemSet)
     // Set dialog-fields from create-itemset
     maStrInitURL.clear();
 
-    const SvxHyperlinkItem *pHyperlinkItem = static_cast<const 
SvxHyperlinkItem *>(
-                                       rItemSet.GetItem 
(SID_HYPERLINK_GETLINK));
+    const SvxHyperlinkItem *pHyperlinkItem =
+                                       rItemSet.GetItem 
(SID_HYPERLINK_GETLINK);
 
     if ( pHyperlinkItem )
     {
@@ -486,8 +486,8 @@ void SvxHyperlinkTabPageBase::ActivatePage( const 
SfxItemSet& rItemSet )
 {
 
     // Set dialog-fields from input-itemset
-    const SvxHyperlinkItem *pHyperlinkItem = static_cast<const 
SvxHyperlinkItem *>(
-                                       rItemSet.GetItem 
(SID_HYPERLINK_GETLINK));
+    const SvxHyperlinkItem *pHyperlinkItem =
+                                       rItemSet.GetItem 
(SID_HYPERLINK_GETLINK);
 
     if ( pHyperlinkItem )
     {
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index 3db4e5c20ca5..837566e29d22 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -273,19 +273,19 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet )
     else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
         rSet->InvalidateItem(nWhich);
 
-    nWhich = GetWhich(SID_ATTR_ALIGN_LOCKPOS);
+    TypedWhichId<SvxRotateModeItem> 
nWhichLockPos(GetWhich(SID_ATTR_ALIGN_LOCKPOS));
     if (m_aVsRefEdge.IsValueChangedFromSaved())
     {
         switch (m_aVsRefEdge.GetSelectedItemId())
         {
             case IID_CELLLOCK:
-                
rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, nWhich));
+                
rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_STANDARD, 
nWhichLockPos));
                 break;
             case IID_TOPLOCK:
-                
rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhich));
+                
rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_TOP, nWhichLockPos));
                 break;
             case IID_BOTTOMLOCK:
-                
rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, nWhich));
+                
rSet->Put(SvxRotateModeItem(SvxRotateMode::SVX_ROTATE_MODE_BOTTOM, 
nWhichLockPos));
                 break;
             default:
                 m_aVsRefEdge.SetNoSelection();
@@ -293,8 +293,8 @@ bool AlignmentTabPage::FillItemSet( SfxItemSet* rSet )
         }
         bChanged = true;
     }
-    else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhich, false))
-        rSet->InvalidateItem(nWhich);
+    else if (SfxItemState::DEFAULT == rOldSet.GetItemState(nWhichLockPos, 
false))
+        rSet->InvalidateItem(nWhichLockPos);
 
     nWhich = GetWhich(SID_ATTR_ALIGN_STACKED);
     if (m_xCbStacked->get_state_changed_from_saved())
diff --git a/dbaccess/source/ui/dlg/dlgattr.cxx 
b/dbaccess/source/ui/dlg/dlgattr.cxx
index 47457be595ca..1df2acc20a77 100644
--- a/dbaccess/source/ui/dlg/dlgattr.cxx
+++ b/dbaccess/source/ui/dlg/dlgattr.cxx
@@ -34,7 +34,7 @@ SbaSbAttrDlg::SbaSbAttrDlg(weld::Widget* pParent, const 
SfxItemSet* pCellAttrs,
     SvNumberFormatter* pFormatter, bool bHasFormat)
     : SfxTabDialogController(pParent, "dbaccess/ui/fielddialog.ui", 
"FieldDialog", pCellAttrs)
 {
-    pNumberInfoItem.reset( new SvxNumberInfoItem( pFormatter, 0 ) );
+    pNumberInfoItem.reset( new SvxNumberInfoItem( pFormatter, 
SID_ATTR_NUMBERFORMAT_INFO ) );
 
     if (bHasFormat)
         AddTabPage("format", RID_SVXPAGE_NUMBERFORMAT);
@@ -52,7 +52,7 @@ void SbaSbAttrDlg::PageCreated(const OString& rPageId, 
SfxTabPage& rTabPage)
     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
     if (rPageId == "format")
     {
-        aSet.Put (SvxNumberInfoItem( pNumberInfoItem->GetNumberFormatter(), 
static_cast<sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO)));
+        aSet.Put (SvxNumberInfoItem( pNumberInfoItem->GetNumberFormatter(), 
SID_ATTR_NUMBERFORMAT_INFO));
         rTabPage.PageCreated(aSet);
     }
 }
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index b586f16fade0..90197dbcddf3 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -35,6 +35,7 @@ class SfxStringListItem;
 class SfxUInt16Item;
 class SfxUnoAnyItem;
 class SfxUnoFrameItem;
+class SvxClipboardFormatItem;
 class SvxHyperlinkItem;
 class SvxLanguageItem;
 class SvxSearchItem;
@@ -67,7 +68,7 @@ class SvxZoomItem;
 #define SID_CONTEXT                         (SID_SFX_START + 310)
 
 #define SID_PASTE_SPECIAL                   (SID_SFX_START + 311)
-#define SID_CLIPBOARD_FORMAT_ITEMS          (SID_SFX_START + 312)
+#define SID_CLIPBOARD_FORMAT_ITEMS          
TypedWhichId<SvxClipboardFormatItem>(SID_SFX_START + 312)
 
 #define SID_PASTE_UNFORMATTED               (SID_SFX_START + 314)
 #define SID_PRINTER_NOTFOUND_WARN           
TypedWhichId<SfxBoolItem>(SID_SFX_START + 320)
@@ -578,7 +579,7 @@ class SvxZoomItem;
 #define SID_SIDEBAR                         (SID_SVX_START + 336)
 #define SID_NOTEBOOKBAR                     (SID_SVX_START + 338)
 #define SID_MENUBAR                         (SID_SVX_START + 339)
-#define SID_HYPERLINK_GETLINK               (SID_SVX_START + 361)
+#define SID_HYPERLINK_GETLINK               
TypedWhichId<SvxHyperlinkItem>(SID_SVX_START + 361)
 #define SID_HYPERLINK_SETLINK               
TypedWhichId<SvxHyperlinkItem>(SID_SVX_START + 362)
 #define SID_INFOBAR                         (SID_SVX_START + 365)
 #define SID_NAVIGATOR                       (SID_SVX_START + 366)
diff --git a/include/svl/typedwhich.hxx b/include/svl/typedwhich.hxx
index d3f2bedec671..cb9efabd59fc 100644
--- a/include/svl/typedwhich.hxx
+++ b/include/svl/typedwhich.hxx
@@ -11,6 +11,7 @@
 
 #include <sal/config.h>
 #include <sal/types.h>
+#include <type_traits>
 
 /**
  * A very thin wrapper around the sal_uInt16 WhichId whose purpose is mostly 
to carry type information,
@@ -23,10 +24,20 @@ public:
         : mnWhich(nWhich)
     {
     }
+
+    /** Up-casting conversion constructor
+    */
+    template <class derived_type>
+    constexpr TypedWhichId(TypedWhichId<derived_type> other,
+                           std::enable_if_t<std::is_base_of_v<T, 
derived_type>, int> = 0)
+        : mnWhich(sal_uInt16(other))
+    {
+    }
+
     constexpr operator sal_uInt16() const { return mnWhich; }
 
 private:
-    sal_uInt16 const mnWhich;
+    sal_uInt16 mnWhich;
 };
 
 template <class T> constexpr bool operator==(sal_uInt16 lhs, TypedWhichId<T> 
const& rhs)
diff --git a/include/svx/SmartTagItem.hxx b/include/svx/SmartTagItem.hxx
index 9b8b11049539..caf0c4551567 100644
--- a/include/svx/SmartTagItem.hxx
+++ b/include/svx/SmartTagItem.hxx
@@ -50,7 +50,7 @@ class SVX_DLLPUBLIC SvxSmartTagItem final : public SfxPoolItem
 public:
     static SfxPoolItem* CreateDefault();
 
-    SvxSmartTagItem( const sal_uInt16 nId,
+    SvxSmartTagItem( const TypedWhichId<SvxSmartTagItem> nId,
                      const css::uno::Sequence < css::uno::Sequence< 
css::uno::Reference< css::smarttags::XSmartTagAction > > >& 
rActionComponentsSequence,
                      const css::uno::Sequence < css::uno::Sequence< sal_Int32 
> >& rActionIndicesSequence,
                      const css::uno::Sequence< css::uno::Reference< 
css::container::XStringKeyMap > >& rStringKeyMaps,
diff --git a/include/svx/algitem.hxx b/include/svx/algitem.hxx
index c778735436ee..d0245403360d 100644
--- a/include/svx/algitem.hxx
+++ b/include/svx/algitem.hxx
@@ -35,11 +35,11 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxOrientationItem 
final : public SfxEnumIte
 public:
     SvxOrientationItem(
         const SvxCellOrientation eOrientation,
-        const sal_uInt16 nId );
+        const TypedWhichId<SvxOrientationItem> nId );
 
     SvxOrientationItem(
         Degree100 nRotation, bool bStacked,
-        const sal_uInt16 nId );
+        const TypedWhichId<SvxOrientationItem> nId );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
                                   MapUnit eCoreMetric,
@@ -67,10 +67,10 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxMarginItem final : 
public SfxPoolItem
     sal_Int16       nBottomMargin;
 public:
     static SfxPoolItem* CreateDefault();
-    SvxMarginItem( const sal_uInt16 nId  );
+    SvxMarginItem( const TypedWhichId<SvxMarginItem> nId  );
     SvxMarginItem( sal_Int16 nLeft, sal_Int16 nTop /*= 0*/,
                    sal_Int16 nRight /*= 0*/, sal_Int16 nBottom /*= 0*/,
-                   const sal_uInt16 nId  );
+                   const TypedWhichId<SvxMarginItem> nId  );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
                                   MapUnit eCoreMetric,
diff --git a/include/svx/chrtitem.hxx b/include/svx/chrtitem.hxx
index cb18efa0ad33..a8910845d4a9 100644
--- a/include/svx/chrtitem.hxx
+++ b/include/svx/chrtitem.hxx
@@ -81,7 +81,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC SvxChartRegressItem 
final : public SfxEn
 {
 public:
     SvxChartRegressItem(SvxChartRegress eRegress /*= SvxChartRegress::Linear*/,
-                        sal_uInt16 nId );
+                        TypedWhichId<SvxChartRegressItem> nId );
 
     virtual SvxChartRegressItem* Clone(SfxItemPool* pPool = nullptr) const 
override;
 
@@ -92,7 +92,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC SvxChartTextOrderItem 
final : public Sfx
 {
 public:
     SvxChartTextOrderItem(SvxChartTextOrder eOrder /*= 
SvxChartTextOrder::SideBySide*/,
-                          sal_uInt16 nId );
+                          TypedWhichId<SvxChartTextOrderItem> nId );
 
     virtual SvxChartTextOrderItem* Clone(SfxItemPool* pPool = nullptr) const 
override;
 
@@ -106,7 +106,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC 
SvxChartKindErrorItem final : public Sfx
 {
 public:
     SvxChartKindErrorItem(SvxChartKindError /*eOrient = 
SvxChartKindError::NONE*/,
-                           sal_uInt16 nId );
+                           TypedWhichId<SvxChartKindErrorItem> nId );
 
     virtual SvxChartKindErrorItem* Clone(SfxItemPool* pPool = nullptr) const 
override;
 
@@ -117,7 +117,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC 
SvxChartIndicateItem final : public SfxE
 {
 public:
     SvxChartIndicateItem(SvxChartIndicate eOrient /*= SvxChartIndicate::NONE*/,
-                           sal_uInt16 nId );
+                           TypedWhichId<SvxChartIndicateItem> nId );
 
     virtual SvxChartIndicateItem* Clone(SfxItemPool* pPool = nullptr) const 
override;
 
@@ -130,7 +130,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC SvxDoubleItem final 
: public SfxPoolItem
 
 public:
     static SfxPoolItem* CreateDefault();
-    SvxDoubleItem(double fValue /*= 0.0*/, sal_uInt16 nId );
+    SvxDoubleItem(double fValue /*= 0.0*/, TypedWhichId<SvxDoubleItem> nId );
     SvxDoubleItem(const SvxDoubleItem& rItem);
 
     virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) 
const override;
diff --git a/include/svx/clipfmtitem.hxx b/include/svx/clipfmtitem.hxx
index f2fe10aceb59..eb87aecbbb60 100644
--- a/include/svx/clipfmtitem.hxx
+++ b/include/svx/clipfmtitem.hxx
@@ -38,7 +38,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC 
SvxClipboardFormatItem final : public Sf
 
 public:
     static SfxPoolItem* CreateDefault();
-    SvxClipboardFormatItem(sal_uInt16 nId);
+    SvxClipboardFormatItem(TypedWhichId<SvxClipboardFormatItem> nId);
     SvxClipboardFormatItem(const SvxClipboardFormatItem&);
     virtual ~SvxClipboardFormatItem() override;
 
diff --git a/include/svx/drawitem.hxx b/include/svx/drawitem.hxx
index 21a7d334fc66..d40848c53c36 100644
--- a/include/svx/drawitem.hxx
+++ b/include/svx/drawitem.hxx
@@ -32,7 +32,7 @@ public:
 
                             SvxColorListItem();
                             SvxColorListItem( XColorListRef const & pTable,
-                                    sal_uInt16 nWhich  );
+                                    TypedWhichId<SvxColorListItem> nWhich  );
                             SvxColorListItem( const SvxColorListItem& );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
@@ -57,7 +57,7 @@ public:
 
                             SvxGradientListItem();
                             SvxGradientListItem( XGradientListRef const & 
pList,
-                                    sal_uInt16 nWhich  );
+                                    TypedWhichId<SvxGradientListItem> nWhich  
);
                             SvxGradientListItem( const SvxGradientListItem& );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
@@ -81,7 +81,7 @@ public:
                             static SfxPoolItem* CreateDefault();
                             SvxHatchListItem();
                             SvxHatchListItem( XHatchListRef const & pList,
-                                    sal_uInt16 nWhich  );
+                                    TypedWhichId<SvxHatchListItem> nWhich  );
                             SvxHatchListItem( const SvxHatchListItem& );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
@@ -106,7 +106,7 @@ public:
 
                             SvxBitmapListItem();
                             SvxBitmapListItem( XBitmapListRef const & pBL,
-                                    sal_uInt16 nWhich  );
+                                    TypedWhichId<SvxBitmapListItem> nWhich  );
                             SvxBitmapListItem( const SvxBitmapListItem& );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
@@ -131,7 +131,7 @@ public:
 
                             SvxPatternListItem();
                             SvxPatternListItem( XPatternListRef const & pBL,
-                                   sal_uInt16 nWhich   );
+                                   TypedWhichId<SvxPatternListItem> nWhich   );
                             SvxPatternListItem( const SvxPatternListItem& );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
@@ -155,7 +155,7 @@ public:
 
                             SvxDashListItem();
                             SvxDashListItem( XDashListRef const & pList,
-                                    sal_uInt16 nWhich  );
+                                    TypedWhichId<SvxDashListItem> nWhich  );
                             SvxDashListItem( const SvxDashListItem& );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
@@ -180,7 +180,7 @@ public:
 
                             SvxLineEndListItem();
                             SvxLineEndListItem( XLineEndListRef const & pList,
-                                    sal_uInt16 nWhich  );
+                                    TypedWhichId<SvxLineEndListItem> nWhich  );
                             SvxLineEndListItem( const SvxLineEndListItem& );
 
     virtual bool GetPresentation( SfxItemPresentation ePres,
diff --git a/include/svx/e3ditem.hxx b/include/svx/e3ditem.hxx
index 29e7636e64da..3a8ad16902fd 100644
--- a/include/svx/e3ditem.hxx
+++ b/include/svx/e3ditem.hxx
@@ -29,7 +29,7 @@ class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC SvxB3DVectorItem 
final : public SfxPoolI
     basegfx::B3DVector  aVal;
 
 public:
-                            SvxB3DVectorItem( sal_uInt16 nWhich, const 
basegfx::B3DVector& rVal );
+                            SvxB3DVectorItem( TypedWhichId<SvxB3DVectorItem> 
nWhich, const basegfx::B3DVector& rVal );
                             SvxB3DVectorItem( const SvxB3DVectorItem& );
                             virtual ~SvxB3DVectorItem() override;
 
diff --git a/include/svx/grfcrop.hxx b/include/svx/grfcrop.hxx
index b24aa9c0a19b..de0cfef5b976 100644
--- a/include/svx/grfcrop.hxx
+++ b/include/svx/grfcrop.hxx
@@ -30,10 +30,10 @@ class SVXCORE_DLLPUBLIC SvxGrfCrop : public SfxPoolItem
 {
     sal_Int32   nLeft, nRight, nTop, nBottom;
 public:
-    SvxGrfCrop( sal_uInt16  );
+    SvxGrfCrop( TypedWhichId<SvxGrfCrop>  );
     SvxGrfCrop( sal_Int32 nLeft,    sal_Int32 nRight,
                 sal_Int32 nTop,     sal_Int32 nBottom,
-                sal_uInt16  );
+                TypedWhichId<SvxGrfCrop>  );
     virtual ~SvxGrfCrop() override;
 
     SvxGrfCrop(SvxGrfCrop const &) = default;
diff --git a/include/svx/hlnkitem.hxx b/include/svx/hlnkitem.hxx
index 5d6ac5689401..a129cc720ed1 100644
--- a/include/svx/hlnkitem.hxx
+++ b/include/svx/hlnkitem.hxx
@@ -60,10 +60,10 @@ class SVX_DLLPUBLIC SvxHyperlinkItem final : public 
SfxPoolItem
 public:
     static SfxPoolItem* CreateDefault();
 
-    SvxHyperlinkItem( sal_uInt16 _nWhich = SID_HYPERLINK_GETLINK ):
+    SvxHyperlinkItem( TypedWhichId<SvxHyperlinkItem> _nWhich = 
SID_HYPERLINK_GETLINK ):
                 SfxPoolItem(_nWhich) { eType = HLINK_DEFAULT; 
nMacroEvents=HyperDialogEvent::NONE; };
     SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem );
-    SvxHyperlinkItem( sal_uInt16 nWhich, const OUString& rName, const 
OUString& rURL,
+    SvxHyperlinkItem( TypedWhichId<SvxHyperlinkItem> nWhich, const OUString& 
rName, const OUString& rURL,
                                     const OUString& rTarget, const OUString& 
rIntName,
                                     SvxLinkInsertMode eTyp,
                                     HyperDialogEvent nEvents,
diff --git a/include/svx/numinf.hxx b/include/svx/numinf.hxx
index ef1219988e04..4d4b07478a41 100644
--- a/include/svx/numinf.hxx
+++ b/include/svx/numinf.hxx
@@ -30,16 +30,16 @@ class SVX_DLLPUBLIC SvxNumberInfoItem final : public 
SfxPoolItem
 {
 public:
 
-    SvxNumberInfoItem( const sal_uInt16 nId  );
+    SvxNumberInfoItem( const TypedWhichId<SvxNumberInfoItem> nId  );
     SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
-                       const sal_uInt16 nId  );
+                       const TypedWhichId<SvxNumberInfoItem> nId  );
     SvxNumberInfoItem( SvNumberFormatter* pNumFormatter, const OUString& rVal,
-                       const sal_uInt16 nId  );
+                       const TypedWhichId<SvxNumberInfoItem> nId  );
     SvxNumberInfoItem( SvNumberFormatter* pNumFormatter, const double& rVal,
-                       const sal_uInt16 nId  );
+                       const TypedWhichId<SvxNumberInfoItem> nId  );
     // if both double and String are supplied, String is used for text formats
     SvxNumberInfoItem( SvNumberFormatter* pNumFormatter, const double& rVal,
-                       const OUString& rValueStr, const sal_uInt16 nId );
+                       const OUString& rValueStr, const 
TypedWhichId<SvxNumberInfoItem> nId );
     SvxNumberInfoItem( const SvxNumberInfoItem& );
     virtual ~SvxNumberInfoItem() override;
 
diff --git a/include/svx/optgrid.hxx b/include/svx/optgrid.hxx
index 1b86834ee8c8..97ec7a228e54 100644
--- a/include/svx/optgrid.hxx
+++ b/include/svx/optgrid.hxx
@@ -74,7 +74,7 @@ class SVX_DLLPUBLIC SvxGridItem : public SvxOptionsGrid, 
public SfxPoolItem
     friend class SvxGridTabPage;
 
 public:
-    SvxGridItem( sal_uInt16 _nWhich) : SfxPoolItem(_nWhich){};
+    SvxGridItem( TypedWhichId<SvxGridItem> _nWhich) : SfxPoolItem(_nWhich){};
 
     virtual SvxGridItem*    Clone( SfxItemPool *pPool = nullptr ) const 
override;
     virtual bool            operator==( const SfxPoolItem& ) const override;
diff --git a/include/svx/pageitem.hxx b/include/svx/pageitem.hxx
index 9b3fadc6146c..32702fe8089f 100644
--- a/include/svx/pageitem.hxx
+++ b/include/svx/pageitem.hxx
@@ -58,7 +58,7 @@ private:
 public:
 
     static SfxPoolItem* CreateDefault();
-    SvxPageItem( const sal_uInt16 nId );
+    SvxPageItem( const TypedWhichId<SvxPageItem> nId );
     SvxPageItem( const SvxPageItem& rItem );
 
     virtual ~SvxPageItem() override;
@@ -97,9 +97,9 @@ public:
 class SVX_DLLPUBLIC SvxSetItem final : public SfxSetItem
 {
 public:
-    SvxSetItem( const sal_uInt16 nId, const SfxItemSet& rSet );
+    SvxSetItem( const TypedWhichId<SvxSetItem> nId, const SfxItemSet& rSet );
     SvxSetItem( const SvxSetItem& rItem );
-    SvxSetItem( const sal_uInt16 nId, SfxItemSet&& pSet );
+    SvxSetItem( const TypedWhichId<SvxSetItem> nId, SfxItemSet&& pSet );
 
     virtual SvxSetItem* Clone( SfxItemPool *pPool = nullptr ) const override;
 
diff --git a/include/svx/postattr.hxx b/include/svx/postattr.hxx
index 2ff44c84b344..af980a3e5b9e 100644
--- a/include/svx/postattr.hxx
+++ b/include/svx/postattr.hxx
@@ -30,9 +30,9 @@ class SVX_DLLPUBLIC SvxPostItAuthorItem final : public 
SfxStringItem
 public:
     static SfxPoolItem* CreateDefault();
 
-    SvxPostItAuthorItem( sal_uInt16 nWhich  );
+    SvxPostItAuthorItem( TypedWhichId<SvxPostItAuthorItem> nWhich  );
 
-    SvxPostItAuthorItem( const OUString& rAuthor, sal_uInt16 nWhich  );
+    SvxPostItAuthorItem( const OUString& rAuthor, 
TypedWhichId<SvxPostItAuthorItem> nWhich  );
     virtual bool GetPresentation( SfxItemPresentation ePres,
                                   MapUnit eCoreMetric,
                                   MapUnit ePresMetric,
@@ -50,9 +50,9 @@ class SVX_DLLPUBLIC SvxPostItDateItem final : public 
SfxStringItem
 public:
     static SfxPoolItem* CreateDefault();
 
-    SvxPostItDateItem( sal_uInt16 nWhich  );
+    SvxPostItDateItem( TypedWhichId<SvxPostItDateItem> nWhich  );
 
-    SvxPostItDateItem( const OUString& rDate, sal_uInt16 nWhich  );
+    SvxPostItDateItem( const OUString& rDate, TypedWhichId<SvxPostItDateItem> 
nWhich  );
     virtual bool GetPresentation( SfxItemPresentation ePres,
                                   MapUnit eCoreMetric,
                                   MapUnit ePresMetric,
@@ -69,9 +69,9 @@ class SVX_DLLPUBLIC SvxPostItTextItem final : public 
SfxStringItem
 public:
     static SfxPoolItem* CreateDefault();
 
-    SvxPostItTextItem( sal_uInt16 nWhich  );
+    SvxPostItTextItem( TypedWhichId<SvxPostItTextItem> nWhich  );
 
-    SvxPostItTextItem( const OUString& rText, sal_uInt16 nWhich  );
+    SvxPostItTextItem( const OUString& rText, TypedWhichId<SvxPostItTextItem> 
nWhich  );
     // "pure virtual methods" from SfxPoolItem
     virtual bool GetPresentation( SfxItemPresentation ePres,
                                   MapUnit eCoreMetric,
@@ -90,7 +90,7 @@ class SVX_DLLPUBLIC SvxPostItIdItem final : public 
SfxStringItem
 public:
     static SfxPoolItem* CreateDefault();
 
-    SvxPostItIdItem( sal_uInt16 nWhich );
+    SvxPostItIdItem( TypedWhichId<SvxPostItIdItem>  nWhich );
 
     virtual SvxPostItIdItem* Clone( SfxItemPool *pPool = nullptr ) const 
override;
 };
diff --git a/include/svx/rotmodit.hxx b/include/svx/rotmodit.hxx
index 0c2e6bfb50aa..fa8510e5079f 100644
--- a/include/svx/rotmodit.hxx
+++ b/include/svx/rotmodit.hxx
@@ -39,7 +39,7 @@ class SVX_DLLPUBLIC SvxRotateModeItem final : public 
SfxEnumItem<SvxRotateMode>
 public:
                 static SfxPoolItem* CreateDefault();
 
-                SvxRotateModeItem( SvxRotateMode eMode, sal_uInt16 nWhich);
+                SvxRotateModeItem( SvxRotateMode eMode, 
TypedWhichId<SvxRotateModeItem> nWhich);
                 SvxRotateModeItem( const SvxRotateModeItem& rItem );
                 virtual ~SvxRotateModeItem() override;
 
diff --git a/include/svx/rulritem.hxx b/include/svx/rulritem.hxx
index 9d24ecd6088d..a5600a6588c4 100644
--- a/include/svx/rulritem.hxx
+++ b/include/svx/rulritem.hxx
@@ -44,7 +44,7 @@ class SVX_DLLPUBLIC SvxLongLRSpaceItem final : public 
SfxPoolItem
 
 public:
     static SfxPoolItem* CreateDefault();
-    SvxLongLRSpaceItem(tools::Long lLeft, tools::Long lRight, sal_uInt16 nId);
+    SvxLongLRSpaceItem(tools::Long lLeft, tools::Long lRight, 
TypedWhichId<SvxLongLRSpaceItem> nId);
     SvxLongLRSpaceItem();
     SvxLongLRSpaceItem(SvxLongLRSpaceItem const &) = default;
 
@@ -74,7 +74,7 @@ class SVX_DLLPUBLIC SvxLongULSpaceItem final : public 
SfxPoolItem
 
 public:
     static SfxPoolItem* CreateDefault();
-    SvxLongULSpaceItem(tools::Long lUpper, tools::Long lLower, sal_uInt16 nId);
+    SvxLongULSpaceItem(tools::Long lUpper, tools::Long lLower, 
TypedWhichId<SvxLongULSpaceItem> nId);
     SvxLongULSpaceItem();
     SvxLongULSpaceItem(SvxLongULSpaceItem const &) = default;
 
diff --git a/include/svx/sdangitm.hxx b/include/svx/sdangitm.hxx
index 61770899b951..ee4af385a171 100644
--- a/include/svx/sdangitm.hxx
+++ b/include/svx/sdangitm.hxx
@@ -27,7 +27,7 @@
 
 class SVXCORE_DLLPUBLIC SdrAngleItem: public SfxInt32Item {
 public:
-    SdrAngleItem(sal_uInt16 nId, Degree100 nAngle): 
SfxInt32Item(nId,nAngle.get()) {}
+    SdrAngleItem(TypedWhichId<SdrAngleItem> nId, Degree100 nAngle): 
SfxInt32Item(nId,nAngle.get()) {}
     virtual SdrAngleItem* Clone(SfxItemPool* pPool=nullptr) const override;
 
     virtual bool GetPresentation(SfxItemPresentation ePres,
diff --git a/include/svx/sdmetitm.hxx b/include/svx/sdmetitm.hxx
index 8819c5e2a2b4..934c24034d94 100644
--- a/include/svx/sdmetitm.hxx
+++ b/include/svx/sdmetitm.hxx
@@ -29,7 +29,7 @@
 
 class SVXCORE_DLLPUBLIC SdrMetricItem: public SfxInt32Item {
 public:
-    SdrMetricItem(sal_uInt16 nId, sal_Int32 nVal):  SfxInt32Item(nId,nVal) {}
+    SdrMetricItem(TypedWhichId<SdrMetricItem> nId, sal_Int32 nVal):  
SfxInt32Item(nId,nVal) {}
     virtual SdrMetricItem* Clone(SfxItemPool* pPool=nullptr) const override;
     virtual bool HasMetrics() const override;
     virtual void ScaleMetrics(tools::Long nMul, tools::Long nDiv) override;
diff --git a/include/svx/sdooitm.hxx b/include/svx/sdooitm.hxx
index 2cc2fce42738..befd67f749e0 100644
--- a/include/svx/sdooitm.hxx
+++ b/include/svx/sdooitm.hxx
@@ -29,7 +29,7 @@
 
 class SVXCORE_DLLPUBLIC SdrOnOffItem: public SfxBoolItem {
 public:
-    SdrOnOffItem(sal_uInt16 nId, bool bOn): SfxBoolItem(nId,bOn) {}
+    SdrOnOffItem(TypedWhichId<SdrOnOffItem> nId, bool bOn): 
SfxBoolItem(nId,bOn) {}
     virtual SdrOnOffItem* Clone(SfxItemPool* pPool=nullptr) const override;
 
     virtual OUString GetValueTextByVal(bool bVal) const override;
diff --git a/include/svx/sdprcitm.hxx b/include/svx/sdprcitm.hxx
index 0316c4d0e452..f00c8d514edb 100644
--- a/include/svx/sdprcitm.hxx
+++ b/include/svx/sdprcitm.hxx
@@ -31,7 +31,7 @@
 class SVXCORE_DLLPUBLIC SdrPercentItem : public SfxUInt16Item
 {
 public:
-    SdrPercentItem(sal_uInt16 nId, sal_uInt16 nVal): SfxUInt16Item(nId,nVal) {}
+    SdrPercentItem(TypedWhichId<SdrPercentItem> nId, sal_uInt16 nVal): 
SfxUInt16Item(nId,nVal) {}
     virtual SdrPercentItem* Clone(SfxItemPool* pPool=nullptr) const override;
 
     virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit 
eCoreMetric, MapUnit ePresMetric, OUString& rText, const IntlWrapper&) const 
override;
diff --git a/include/svx/sdtaitm.hxx b/include/svx/sdtaitm.hxx
index 69b909da5bd3..716f703ec4eb 100644
--- a/include/svx/sdtaitm.hxx
+++ b/include/svx/sdtaitm.hxx
@@ -35,7 +35,7 @@ enum SdrTextVertAdjust {SDRTEXTVERTADJUST_TOP,      // 
aligned to top (normally
 class SVXCORE_DLLPUBLIC SdrTextVertAdjustItem final : public 
SfxEnumItem<SdrTextVertAdjust> {
 public:
     SdrTextVertAdjustItem(SdrTextVertAdjust eAdj=SDRTEXTVERTADJUST_TOP): 
SfxEnumItem(SDRATTR_TEXT_VERTADJUST, eAdj) {}
-    SdrTextVertAdjustItem(SdrTextVertAdjust eAdj, sal_uInt16 nWhich): 
SfxEnumItem(nWhich, eAdj) {}
+    SdrTextVertAdjustItem(SdrTextVertAdjust eAdj, 
TypedWhichId<SdrTextVertAdjustItem> nWhich): SfxEnumItem(nWhich, eAdj) {}
     virtual SdrTextVertAdjustItem* Clone(SfxItemPool* pPool=nullptr) const 
override;
     virtual sal_uInt16        GetValueCount() const override; // { return 5; }
 
diff --git a/include/svx/sdynitm.hxx b/include/svx/sdynitm.hxx
index a67f3f41fd7e..970956a42cee 100644
--- a/include/svx/sdynitm.hxx
+++ b/include/svx/sdynitm.hxx
@@ -29,7 +29,7 @@
 //-------------------------------------------------- ----------
 class SVXCORE_DLLPUBLIC SdrYesNoItem: public SfxBoolItem {
 public:
-    SdrYesNoItem(sal_uInt16 nId, bool bOn): SfxBoolItem(nId,bOn) {}
+    SdrYesNoItem(TypedWhichId<SdrYesNoItem> nId, bool bOn): 
SfxBoolItem(nId,bOn) {}
     virtual SdrYesNoItem* Clone(SfxItemPool* pPool=nullptr) const override;
     virtual OUString GetValueTextByVal(bool bVal) const override;
     virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit 
eCoreMetric, MapUnit ePresMetric, OUString& rText, const IntlWrapper&) const 
override;
diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index f4623b6e0e77..a88beea11421 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -24,6 +24,7 @@
 #include <editeng/editids.hrc>
 #include <svl/typedwhich.hxx>
 
+class OfaPtrItem;
 class SdrAngleItem;
 class SfxBoolItem;
 class SfxInt32Item;
@@ -41,6 +42,7 @@ class SvxColorItem;
 class SvxColorListItem;
 class SvxColumnItem;
 class SvxDashListItem;
+class SvxDoubleItem;
 class SvxGradientListItem;
 class SvxGridItem;
 class SvxHatchListItem;
@@ -60,8 +62,10 @@ class SvxPostItTextItem;
 class SvxRulerItem;
 class SvxSetItem;
 class SvxSizeItem;
+class SvxSmartTagItem;
 class SvxViewLayoutItem;
-
+class SvxZoomSliderItem;
+class XFillGradientItem;
 
 // member IDs
 
@@ -393,12 +397,12 @@ class SvxViewLayoutItem;
 #define SID_GALLERY_FORMATS                             ( SID_SVX_START + 280 )
 #define SID_OBJECT_HELL                                 ( SID_SVX_START + 282 )
 #define SID_OBJECT_HEAVEN                               ( SID_SVX_START + 283 )
-#define SID_ATTR_LONG_ULSPACE                           ( SID_SVX_START + 284 )
-#define SID_ATTR_LONG_LRSPACE                           ( SID_SVX_START + 285 )
+#define SID_ATTR_LONG_ULSPACE                           
TypedWhichId<SvxLongULSpaceItem>( SID_SVX_START + 284 )
+#define SID_ATTR_LONG_LRSPACE                           
TypedWhichId<SvxLongLRSpaceItem>( SID_SVX_START + 285 )
 #define SID_FRAME_TO_TOP                                ( SID_SVX_START + 286 )
 #define SID_FRAME_TO_BOTTOM                             ( SID_SVX_START + 287 )
-#define SID_SEARCH_SEARCHSET                            ( SID_SVX_START + 292 )
-#define SID_SEARCH_REPLACESET                           ( SID_SVX_START + 293 )
+#define SID_SEARCH_SEARCHSET                            
TypedWhichId<SvxSetItem>( SID_SVX_START + 292 )
+#define SID_SEARCH_REPLACESET                           
TypedWhichId<SvxSetItem>( SID_SVX_START + 293 )
 #define SID_SET_SUPER_SCRIPT                            ( SID_SVX_START + 294 )
 #define SID_SET_SUB_SCRIPT                              ( SID_SVX_START + 295 )
 #define SID_CHAR_DLG                                    ( SID_SVX_START + 296 )
@@ -792,7 +796,7 @@ class SvxViewLayoutItem;
 #define SID_EXTRUSION_LIGHTING_FLOATER                  ( SID_SVX_START + 967 )
 #define SID_EXTRUSION_SURFACE_FLOATER                   ( SID_SVX_START + 968 )
 #define SID_EXTRUSION_3D_COLOR                          ( SID_SVX_START + 969 )
-#define SID_EXTRUSION_DEPTH                             ( SID_SVX_START + 970 )
+#define SID_EXTRUSION_DEPTH                             
TypedWhichId<SvxDoubleItem>( SID_SVX_START + 970 )
 #define SID_EXTRUSION_DIRECTION                         ( SID_SVX_START + 971 )
 #define SID_EXTRUSION_PROJECTION                        ( SID_SVX_START + 972 )
 #define SID_EXTRUSION_LIGHTING_DIRECTION                ( SID_SVX_START + 973 )
@@ -843,7 +847,7 @@ class SvxViewLayoutItem;
 #define SID_DLG_TYPE                                    ( SID_SVX_START + 1018 
)
 #define SID_TABPAGE_POS                                 ( SID_SVX_START + 1019 
)
 #define SID_GRAPHIC                                     ( SID_SVX_START + 1020 
)
-#define SID_OBJECT_LIST                                 ( SID_SVX_START + 1021 
)
+#define SID_OBJECT_LIST                                 
TypedWhichId<OfaPtrItem>( SID_SVX_START + 1021 )
 #define SID_ATTR_SET                                    ( SID_SVX_START + 1022 
)
 #define SID_CHAR_FMT_LIST_BOX                           ( SID_SVX_START + 1023 
)
 #define SID_METRIC_ITEM                                 
TypedWhichId<SfxUInt16Item>( SID_SVX_START + 1024 )
@@ -884,7 +888,7 @@ class SvxViewLayoutItem;
 #define SID_INSERT_ZWSP                                 ( SID_SVX_START + 1058 
)   /* insert ZWJ - invisible space, keep words together*/
 #define SID_INSERT_WJ                                   ( SID_SVX_START + 1059 
)   /* insert WJ  - Word Joiner */
 #define SID_OPTIONS_DATABASES                           ( SID_SVX_START + 1060 
)
-#define SID_OPEN_SMARTTAGMENU                           ( SID_SVX_START + 1061 
)
+#define SID_OPEN_SMARTTAGMENU                           
TypedWhichId<SvxSmartTagItem>( SID_SVX_START + 1061 )
 
 // CAUTION! Range <1062 .. 1069> used by include/sfx2/sfxsids.hrc
 
@@ -981,7 +985,7 @@ class SvxViewLayoutItem;
 
 #define SID_ATTR_PAGE_COLOR                             ( SID_SVX_START + 1152 
)
 // 1153 is used by editeng (SID_ATTR_CHAR_BACK_COLOR)
-#define SID_ATTR_PAGE_GRADIENT                          ( SID_SVX_START + 1154 
)
+#define SID_ATTR_PAGE_GRADIENT                          
TypedWhichId<XFillGradientItem>( SID_SVX_START + 1154 )
 #define SID_ATTR_PAGE_HATCH                             ( SID_SVX_START + 1155 
)
 #define SID_ATTR_PAGE_BITMAP                            ( SID_SVX_START + 1156 
)
 #define SID_ATTR_PAGE_FILLSTYLE                         ( SID_SVX_START + 1157 
)
@@ -1041,7 +1045,7 @@ class SvxViewLayoutItem;
 
 #define SID_INSERT_TREECONTROL                          ( SID_SVX_START + 1206 
)
 #define SID_ATTR_VIEWLAYOUT                             
TypedWhichId<SvxViewLayoutItem>( SID_SVX_START + 1207 )
-#define SID_ATTR_ZOOMSLIDER                             ( SID_SVX_START + 1208 
)
+#define SID_ATTR_ZOOMSLIDER                             
TypedWhichId<SvxZoomSliderItem>( SID_SVX_START + 1208 )
 #define SID_LANGUAGE_STATUS                             ( SID_SVX_START + 1209 
)
 #define SID_CHAR_DLG_FOR_PARAGRAPH                      ( SID_SVX_START + 1210 
)
 #define SID_SET_DOCUMENT_LANGUAGE                       
TypedWhichId<SfxBoolItem>( SID_SVX_START + 1211 )
diff --git a/include/svx/viewlayoutitem.hxx b/include/svx/viewlayoutitem.hxx
index 0a5b3ee434b5..495443c85c10 100644
--- a/include/svx/viewlayoutitem.hxx
+++ b/include/svx/viewlayoutitem.hxx
@@ -31,7 +31,7 @@ class SVX_DLLPUBLIC SvxViewLayoutItem final : public 
SfxUInt16Item
 public:
     static SfxPoolItem* CreateDefault();
 
-    SvxViewLayoutItem( sal_uInt16 nColumns = 0, bool bBookMode = false, 
sal_uInt16 nWhich = SID_ATTR_VIEWLAYOUT );
+    SvxViewLayoutItem( sal_uInt16 nColumns = 0, bool bBookMode = false, 
TypedWhichId<SvxViewLayoutItem> nWhich = SID_ATTR_VIEWLAYOUT );
     SvxViewLayoutItem( const SvxViewLayoutItem& );
     virtual ~SvxViewLayoutItem() override;
 
diff --git a/include/svx/xcolit.hxx b/include/svx/xcolit.hxx
index 9f35416b56ae..8760ba88208e 100644
--- a/include/svx/xcolit.hxx
+++ b/include/svx/xcolit.hxx
@@ -36,15 +36,13 @@ class SVXCORE_DLLPUBLIC XColorItem : public NameOrIndex
 public:
             static SfxPoolItem* CreateDefault();
             XColorItem() {}
-            XColorItem(sal_uInt16 nWhich, sal_Int32 nIndex, const Color& 
rTheColor);
+            XColorItem(TypedWhichId<XColorItem> nWhich, sal_Int32 nIndex, 
const Color& rTheColor);
+            XColorItem(TypedWhichId<XColorItem> nWhich, const Color& 
rTheColor);
+            XColorItem(TypedWhichId<XColorItem> nWhich, const OUString& rName, 
const Color& rTheColor);
+            XColorItem(const XColorItem& rItem);
 
     virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) 
const override;
     virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) 
override;
-
-            XColorItem(sal_uInt16 nWhich, const Color& rTheColor);
-            XColorItem(sal_uInt16 nWhich, const OUString& rName, const Color& 
rTheColor);
-            XColorItem(const XColorItem& rItem);
-
     virtual bool            operator==(const SfxPoolItem& rItem) const 
override;
     virtual XColorItem* Clone(SfxItemPool* pPool = nullptr) const override;
 
diff --git a/include/svx/xflgrit.hxx b/include/svx/xflgrit.hxx
index 01268edd04f8..0c02e44a8d09 100644
--- a/include/svx/xflgrit.hxx
+++ b/include/svx/xflgrit.hxx
@@ -37,7 +37,7 @@ public:
             static SfxPoolItem* CreateDefault();
             XFillGradientItem() : NameOrIndex(XATTR_FILLGRADIENT, -1) {}
             XFillGradientItem(sal_Int32 nIndex, const XGradient& rTheGradient);
-            XFillGradientItem(const OUString& rName, const XGradient& 
rTheGradient, sal_uInt16 nWhich = XATTR_FILLGRADIENT);
+            XFillGradientItem(const OUString& rName, const XGradient& 
rTheGradient, TypedWhichId<XFillGradientItem> nWhich = XATTR_FILLGRADIENT);
             XFillGradientItem(const XGradient& rTheGradient);
             XFillGradientItem(const XFillGradientItem& rItem);
 
diff --git a/include/svx/xit.hxx b/include/svx/xit.hxx
index db8f666197c5..f6b19595a9f8 100644
--- a/include/svx/xit.hxx
+++ b/include/svx/xit.hxx
@@ -43,8 +43,8 @@ protected:
 
 public:
             NameOrIndex() { nPalIndex = -1; }
-            NameOrIndex(sal_uInt16 nWhich, sal_Int32 nIndex);
-            NameOrIndex(sal_uInt16 nWhich, const OUString& rName);
+            NameOrIndex(TypedWhichId<NameOrIndex> nWhich, sal_Int32 nIndex);
+            NameOrIndex(TypedWhichId<NameOrIndex> nWhich, const OUString& 
rName);
             NameOrIndex(const NameOrIndex& rNameOrIndex);
 
     virtual bool         operator==(const SfxPoolItem& rItem) const override;
diff --git a/include/svx/zoomslideritem.hxx b/include/svx/zoomslideritem.hxx
index f257f19997a9..919d7c026260 100644
--- a/include/svx/zoomslideritem.hxx
+++ b/include/svx/zoomslideritem.hxx
@@ -34,7 +34,7 @@ class SVX_DLLPUBLIC SvxZoomSliderItem final : public 
SfxUInt16Item
 public:
     static SfxPoolItem* CreateDefault();
 
-    SvxZoomSliderItem( sal_uInt16 nCurrentZoom = 100, sal_uInt16 nMinZoom = 
20, sal_uInt16 nMaxZoom = 600, sal_uInt16 nWhich = SID_ATTR_ZOOMSLIDER );
+    SvxZoomSliderItem( sal_uInt16 nCurrentZoom = 100, sal_uInt16 nMinZoom = 
20, sal_uInt16 nMaxZoom = 600, TypedWhichId<SvxZoomSliderItem> nWhich = 
SID_ATTR_ZOOMSLIDER );
 
     void AddSnappingPoint( sal_Int32 nNew );
     const css::uno::Sequence < sal_Int32 >& GetSnappingPoints() const { return 
maValues;}
diff --git a/reportdesign/source/ui/misc/UITools.cxx 
b/reportdesign/source/ui/misc/UITools.cxx
index 243474ac39de..6440b37878ce 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -139,7 +139,7 @@
 #define ITEMID_ESCAPEMENT               XATTR_FILL_LAST + 14
 #define ITEMID_FONTLIST                 XATTR_FILL_LAST + 15
 #define ITEMID_AUTOKERN                 XATTR_FILL_LAST + 16
-#define ITEMID_COLOR_TABLE              XATTR_FILL_LAST + 17
+#define ITEMID_COLOR_TABLE              
TypedWhichId<SvxColorListItem>(XATTR_FILL_LAST + 17)
 #define ITEMID_BLINK                    XATTR_FILL_LAST + 18
 #define ITEMID_EMPHASISMARK             XATTR_FILL_LAST + 19
 #define ITEMID_TWOLINES                 XATTR_FILL_LAST + 20
diff --git a/reportdesign/source/ui/report/ReportController.cxx 
b/reportdesign/source/ui/report/ReportController.cxx
index 9e1df7251c9d..b845623ed0fa 100644
--- a/reportdesign/source/ui/report/ReportController.cxx
+++ b/reportdesign/source/ui/report/ReportController.cxx
@@ -144,7 +144,7 @@
 
 #define RPTUI_ID_LRSPACE    XATTR_FILL_FIRST - 8
 #define RPTUI_ID_ULSPACE    XATTR_FILL_FIRST - 7
-#define RPTUI_ID_PAGE       XATTR_FILL_FIRST - 6
+#define RPTUI_ID_PAGE       TypedWhichId<SvxPageItem>(XATTR_FILL_FIRST - 6)
 #define RPTUI_ID_SIZE       XATTR_FILL_FIRST - 5
 #define RPTUI_ID_PAGE_MODE  XATTR_FILL_FIRST - 4
 #define RPTUI_ID_START      XATTR_FILL_FIRST - 3
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index e958d421c18e..3275f866ee13 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -22,6 +22,8 @@
 
 #include <svx/svxids.hrc>
 
+class SvxZoomSliderItem;
+
 // areas
 
 #ifndef SC_VIEW_START // duplicated in sfx2/sfxsids.hrc
@@ -453,7 +455,7 @@
 #define SID_PREVIEW_LAST        (SID_PREVIEW_START+3)
 #define SID_PREVIEW_CLOSE       (SID_PREVIEW_START+7)
 #define SID_PREVIEW_MARGIN      (SID_PREVIEW_START+8)
-#define SID_PREVIEW_SCALINGFACTOR   (SID_PREVIEW_START+9)
+#define SID_PREVIEW_SCALINGFACTOR   
TypedWhichId<SvxZoomSliderItem>(SID_PREVIEW_START+9)
 #define SID_PREVIEW_END         (SID_PREVIEW_START+20)
 
 //from sfx: #define SID_KEYFUNC_START       (SID_PREVIEW_END+5)
diff --git a/sc/source/filter/qpro/qprostyle.cxx 
b/sc/source/filter/qpro/qprostyle.cxx
index 899d7ff498b5..2303d29e53ba 100644
--- a/sc/source/filter/qpro/qprostyle.cxx
+++ b/sc/source/filter/qpro/qprostyle.cxx
@@ -103,7 +103,7 @@ void ScQProStyle::SetFormat( ScDocument *pDoc, sal_uInt8 
nCol, sal_uInt16 nRow,
             break;
 
     }
-    rItemSet.Put( SvxOrientationItem( eOrient, 0) );
+    rItemSet.Put( SvxOrientationItem( eOrient, 
TypedWhichId<SvxOrientationItem>(0)) );
 
     // Wrap cell contents
     if( nTmp & 0x80 )
diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx
index c3b52eafc4b7..15a8bcbafe1b 100644
--- a/sc/source/ui/unoobj/afmtuno.cxx
+++ b/sc/source/ui/unoobj/afmtuno.cxx
@@ -686,7 +686,7 @@ uno::Any SAL_CALL ScAutoFormatFieldObj::getPropertyValue( 
const OUString& aPrope
                         const ScRotateValueItem* pRotItem = pData->GetItem( 
nFieldIndex, ATTR_ROTATE_VALUE );
                         Degree100 nRot = pRotItem ? pRotItem->GetValue() : 
0_deg100;
                         bool bStacked = static_cast<const 
ScVerticalStackCell*>(pItem)->GetValue();
-                        SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( 
aVal );
+                        SvxOrientationItem( nRot, bStacked, 
TypedWhichId<SvxOrientationItem>(0) ).QueryValue( aVal );
                     }
                     break;
                     default:
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index d8a5dc5fe43a..91483f02476e 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -2384,7 +2384,7 @@ void ScCellRangesBase::GetOnePropertyValue( const 
SfxItemPropertyMapEntry* pEntr
                     {
                         Degree100 nRot = 
pDataSet->Get(ATTR_ROTATE_VALUE).GetValue();
                         bool bStacked = static_cast<const 
ScVerticalStackCell&>(pDataSet->Get(pEntry->nWID)).GetValue();
-                        SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( 
rAny );
+                        SvxOrientationItem( nRot, bStacked, 
TypedWhichId<SvxOrientationItem>(0) ).QueryValue( rAny );
                     }
                     break;
                 default:
diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx
index 4baa85a35476..b03f8dc0788b 100644
--- a/sc/source/ui/unoobj/styleuno.cxx
+++ b/sc/source/ui/unoobj/styleuno.cxx
@@ -1818,7 +1818,7 @@ uno::Any ScStyleObj::getPropertyValue_Impl( 
std::u16string_view aPropertyName )
                         {
                             Degree100 nRot = 
pItemSet->Get(ATTR_ROTATE_VALUE).GetValue();
                             bool bStacked = static_cast<const 
ScVerticalStackCell&>(pItemSet->Get(nWhich)).GetValue();
-                            SvxOrientationItem( nRot, bStacked, 0 
).QueryValue( aAny );
+                            SvxOrientationItem( nRot, bStacked, 
TypedWhichId<SvxOrientationItem>(0) ).QueryValue( aAny );
                         }
                         break;
                     case ATTR_PAGE_SCALE:
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 62949eaaa472..0758a9fe3724 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -378,7 +378,7 @@ std::unique_ptr<SvxNumberInfoItem> 
ScTabViewShell::MakeNumberInfoItem( ScDocumen
     }
 
     return std::make_unique<SvxNumberInfoItem>(
-        rDoc.GetFormatTable(), 
static_cast<sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO));
+        rDoc.GetFormatTable(), SID_ATTR_NUMBERFORMAT_INFO);
 }
 
 void ScTabViewShell::UpdateNumberFormatter(
diff --git a/sd/inc/sdattr.hrc b/sd/inc/sdattr.hrc
index 90dc0964322b..f6230634e07e 100644
--- a/sd/inc/sdattr.hrc
+++ b/sd/inc/sdattr.hrc
@@ -21,6 +21,8 @@
 
 #include <svl/solar.hrc>
 
+class XColorItem;
+
 // Layer attributes
 #define ATTR_LAYER_START        SID_SD_START + 1234
 #define ATTR_LAYER_NAME         ATTR_LAYER_START
@@ -78,11 +80,11 @@
 #define ATTR_COPY_NUMBER                ATTR_COPY_START
 #define ATTR_COPY_MOVE_X                ATTR_COPY_START + 1
 #define ATTR_COPY_MOVE_Y                ATTR_COPY_START + 2
-#define ATTR_COPY_ANGLE                 ATTR_COPY_START + 3
+#define ATTR_COPY_ANGLE                 
TypedWhichId<SdrAngleItem>(ATTR_COPY_START + 3)
 #define ATTR_COPY_WIDTH                 ATTR_COPY_START + 4
 #define ATTR_COPY_HEIGHT                ATTR_COPY_START + 5
-#define ATTR_COPY_START_COLOR           ATTR_COPY_START + 6
-#define ATTR_COPY_END_COLOR             ATTR_COPY_START + 7
+#define ATTR_COPY_START_COLOR           
TypedWhichId<XColorItem>(ATTR_COPY_START + 6)
+#define ATTR_COPY_END_COLOR             
TypedWhichId<XColorItem>(ATTR_COPY_START + 7)
 #define ATTR_COPY_END                   ATTR_COPY_END_COLOR
 
 #define ATTR_SNAPLINE_START             ATTR_COPY_END + 1
diff --git a/sd/source/ui/dlg/paragr.cxx b/sd/source/ui/dlg/paragr.cxx
index 2918fbb22c77..cead5dfc4634 100644
--- a/sd/source/ui/dlg/paragr.cxx
+++ b/sd/source/ui/dlg/paragr.cxx
@@ -24,6 +24,7 @@
 #include <svx/dialogs.hrc>
 #include <svx/svxids.hrc>
 #include <svx/flagsdef.hxx>
+#include <svx/xcolit.hxx>
 
 #include <paragr.hxx>
 #include <sdattr.hrc>
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
index bddb47947e88..19eea777637e 100644
--- a/sd/source/ui/view/drviews3.cxx
+++ b/sd/source/ui/view/drviews3.cxx
@@ -556,8 +556,8 @@ void  DrawViewShell::ExecRuler(SfxRequest& rReq)
                 std::unique_ptr<SdUndoGroup> pUndoGroup(new 
SdUndoGroup(GetDoc()));
                 pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER));
 
-                const SvxLongLRSpaceItem& rLRSpace = static_cast<const 
SvxLongLRSpaceItem&>(
-                        pArgs->Get(SID_ATTR_LONG_LRSPACE));
+                const SvxLongLRSpaceItem& rLRSpace =
+                        pArgs->Get(SID_ATTR_LONG_LRSPACE);
 
                 if( mpDrawView->IsTextEdit() )
                 {
@@ -621,8 +621,8 @@ void  DrawViewShell::ExecRuler(SfxRequest& rReq)
                 std::unique_ptr<SdUndoGroup> pUndoGroup(new 
SdUndoGroup(GetDoc()));
                 pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEBORDER));
 
-                const SvxLongULSpaceItem& rULSpace = static_cast<const 
SvxLongULSpaceItem&>(
-                        pArgs->Get(SID_ATTR_LONG_ULSPACE));
+                const SvxLongULSpaceItem& rULSpace =
+                        pArgs->Get(SID_ATTR_LONG_ULSPACE);
 
                 if( mpDrawView->IsTextEdit() )
                 {
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 4c1eae173391..d54b43fd908a 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <comphelper/string.hxx>
 #include <svx/svxids.hrc>
+#include <svx/sdmetitm.hxx>
 #include <svx/hlnkitem.hxx>
 #include <editeng/eeitem.hxx>
 #include <editeng/flditem.hxx>
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx
index b20d60aacc35..5921d3b53c56 100644
--- a/svx/source/dialog/hdft.cxx
+++ b/svx/source/dialog/hdft.cxx
@@ -311,7 +311,7 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet )
     }
 
     // Flush the SetItem
-    SvxSetItem aSetItem( GetWhich( nId ), aSet );
+    SvxSetItem aSetItem( TypedWhichId<SvxSetItem>(GetWhich( nId )), aSet );
     rSet->Put( aSetItem );
 
     return true;
diff --git a/svx/source/dialog/rulritem.cxx b/svx/source/dialog/rulritem.cxx
index 830475293402..2e1dac9848b8 100644
--- a/svx/source/dialog/rulritem.cxx
+++ b/svx/source/dialog/rulritem.cxx
@@ -134,7 +134,7 @@ SvxLongLRSpaceItem* SvxLongLRSpaceItem::Clone(SfxItemPool 
*) const
     return new SvxLongLRSpaceItem(*this);
 }
 
-SvxLongLRSpaceItem::SvxLongLRSpaceItem(tools::Long lLeft, tools::Long lRight, 
sal_uInt16 nId) :
+SvxLongLRSpaceItem::SvxLongLRSpaceItem(tools::Long lLeft, tools::Long lRight, 
TypedWhichId<SvxLongLRSpaceItem> nId) :
     SfxPoolItem (nId),
     mlLeft      (lLeft),
     mlRight     (lRight)
@@ -253,7 +253,7 @@ SvxLongULSpaceItem* SvxLongULSpaceItem::Clone(SfxItemPool 
*) const
     return new SvxLongULSpaceItem(*this);
 }
 
-SvxLongULSpaceItem::SvxLongULSpaceItem(tools::Long lLeft, tools::Long lRight, 
sal_uInt16 nId) :
+SvxLongULSpaceItem::SvxLongULSpaceItem(tools::Long lLeft, tools::Long lRight, 
TypedWhichId<SvxLongULSpaceItem> nId) :
     SfxPoolItem (nId),
     mlLeft       (lLeft),
     mlRight      (lRight)
diff --git a/svx/source/items/SmartTagItem.cxx 
b/svx/source/items/SmartTagItem.cxx
index eac32b743b24..2208ee297d0e 100644
--- a/svx/source/items/SmartTagItem.cxx
+++ b/svx/source/items/SmartTagItem.cxx
@@ -29,7 +29,7 @@ using namespace ::com::sun::star;
 
 SfxPoolItem* SvxSmartTagItem::CreateDefault() { SAL_WARN( "svx", "No 
SvxSmartTagItem factory available"); return nullptr; }
 
-SvxSmartTagItem::SvxSmartTagItem( const sal_uInt16 nId,
+SvxSmartTagItem::SvxSmartTagItem( const TypedWhichId<SvxSmartTagItem> nId,
                                   const css::uno::Sequence < 
css::uno::Sequence< css::uno::Reference< css::smarttags::XSmartTagAction > > >& 
rActionComponentsSequence,
                                   const css::uno::Sequence < 
css::uno::Sequence< sal_Int32 > >& rActionIndicesSequence,
                                   const css::uno::Sequence< 
css::uno::Reference< css::container::XStringKeyMap > >& rStringKeyMaps,
diff --git a/svx/source/items/algitem.cxx b/svx/source/items/algitem.cxx
index 96783e822ef5..917edb1f6203 100644
--- a/svx/source/items/algitem.cxx
+++ b/svx/source/items/algitem.cxx
@@ -34,15 +34,15 @@
 using namespace ::com::sun::star;
 
 
-SfxPoolItem* SvxMarginItem::CreateDefault() { return new  SvxMarginItem(0) ;}
+SfxPoolItem* SvxMarginItem::CreateDefault() { return new  
SvxMarginItem(TypedWhichId<SvxMarginItem>(0)) ;}
 
 SvxOrientationItem::SvxOrientationItem( const SvxCellOrientation eOrientation,
-                                        const sal_uInt16 nId):
+                                        const TypedWhichId<SvxOrientationItem> 
nId):
     SfxEnumItem( nId, eOrientation )
 {
 }
 
-SvxOrientationItem::SvxOrientationItem( Degree100 nRotation, bool bStacked, 
const sal_uInt16 nId ) :
+SvxOrientationItem::SvxOrientationItem( Degree100 nRotation, bool bStacked, 
const TypedWhichId<SvxOrientationItem> nId ) :
     SfxEnumItem( nId, SvxCellOrientation::Standard )
 {
     if( bStacked )
@@ -141,7 +141,7 @@ Degree100 SvxOrientationItem::GetRotation( Degree100 
nStdAngle ) const
     return nAngle;
 }
 
-SvxMarginItem::SvxMarginItem( const sal_uInt16 nId ) :
+SvxMarginItem::SvxMarginItem( const TypedWhichId<SvxMarginItem> nId ) :
 
     SfxPoolItem( nId ),
 
@@ -157,7 +157,7 @@ SvxMarginItem::SvxMarginItem( sal_Int16 nLeft,
                               sal_Int16 nTop,
                               sal_Int16 nRight,
                               sal_Int16 nBottom,
-                              const sal_uInt16 nId ) :
+                              const TypedWhichId<SvxMarginItem> nId ) :
     SfxPoolItem( nId ),
 
     nLeftMargin  ( nLeft ),
diff --git a/svx/source/items/autoformathelper.cxx 
b/svx/source/items/autoformathelper.cxx
index 2d3ee9270914..0ae522fbd7ac 100644
--- a/svx/source/items/autoformathelper.cxx
+++ b/svx/source/items/autoformathelper.cxx
@@ -319,7 +319,7 @@ bool AutoFormatBase::LoadBlockB( SvStream& rStream, const 
AutoFormatVersions& rV
 {
     legacy::SvxHorJustify::Create(*m_aHorJustify, rStream, 
rVersions.nHorJustifyVersion);
     legacy::SvxVerJustify::Create(*m_aVerJustify, rStream, 
rVersions.nVerJustifyVersion);
-    SvxOrientationItem aOrientation( SvxCellOrientation::Standard, 0);
+    SvxOrientationItem aOrientation( SvxCellOrientation::Standard, 
TypedWhichId<SvxOrientationItem>(0));
     legacy::SvxOrientation::Create(aOrientation, rStream, 
rVersions.nOrientationVersion);
     legacy::SvxMargin::Create(*m_aMargin, rStream, rVersions.nMarginVersion);
     legacy::SfxBool::Create(*m_aLinebreak, rStream, rVersions.nBoolVersion);
@@ -377,7 +377,7 @@ bool AutoFormatBase::SaveBlockB( SvStream& rStream, 
sal_uInt16 fileVersion ) con
 {
     legacy::SvxHorJustify::Store(*m_aHorJustify, rStream, 
legacy::SvxHorJustify::GetVersion(fileVersion));
     legacy::SvxVerJustify::Store(*m_aVerJustify, rStream, 
legacy::SvxVerJustify::GetVersion(fileVersion));
-    SvxOrientationItem aOrientation( Degree100(m_aRotateAngle->GetValue()), 
m_aStacked->GetValue(), 0 );
+    SvxOrientationItem aOrientation( Degree100(m_aRotateAngle->GetValue()), 
m_aStacked->GetValue(), TypedWhichId<SvxOrientationItem>(0) );
     legacy::SvxOrientation::Store(aOrientation, rStream, 
legacy::SvxOrientation::GetVersion(fileVersion));
     legacy::SvxMargin::Store(*m_aMargin, rStream, 
legacy::SvxMargin::GetVersion(fileVersion));
     legacy::SfxBool::Store(*m_aLinebreak, rStream, 
legacy::SfxBool::GetVersion(fileVersion));
diff --git a/svx/source/items/chrtitem.cxx b/svx/source/items/chrtitem.cxx
index 9ee289ea083b..6fb6e85236fc 100644
--- a/svx/source/items/chrtitem.cxx
+++ b/svx/source/items/chrtitem.cxx
@@ -27,10 +27,10 @@
 using namespace ::com::sun::star;
 
 
-SfxPoolItem* SvxDoubleItem::CreateDefault() { return new  SvxDoubleItem(0.0, 
0);}
+SfxPoolItem* SvxDoubleItem::CreateDefault() { return new  SvxDoubleItem(0.0, 
TypedWhichId<SvxDoubleItem>(0));}
 
 SvxChartTextOrderItem::SvxChartTextOrderItem(SvxChartTextOrder eOrder,
-                                             sal_uInt16 nId) :
+                                             
TypedWhichId<SvxChartTextOrderItem> nId) :
     SfxEnumItem(nId, eOrder)
 {
 }
@@ -98,7 +98,7 @@ bool SvxChartTextOrderItem::PutValue( const css::uno::Any& 
rVal, sal_uInt8 /*nMe
     return true;
 }
 
-SvxDoubleItem::SvxDoubleItem(double fValue, sal_uInt16 nId) :
+SvxDoubleItem::SvxDoubleItem(double fValue, TypedWhichId<SvxDoubleItem> nId) :
     SfxPoolItem(nId),
     fVal(fValue)
 {
@@ -143,7 +143,7 @@ bool SvxDoubleItem::PutValue( const uno::Any& rVal, 
sal_uInt8 /*nMemberId*/ )
 }
 
 SvxChartKindErrorItem::SvxChartKindErrorItem(SvxChartKindError eOrient,
-                                               sal_uInt16 nId) :
+                                               
TypedWhichId<SvxChartKindErrorItem> nId) :
     SfxEnumItem(nId, eOrient)
 {
 }
@@ -154,7 +154,7 @@ SvxChartKindErrorItem* 
SvxChartKindErrorItem::Clone(SfxItemPool* /*pPool*/) cons
 }
 
 SvxChartIndicateItem::SvxChartIndicateItem(SvxChartIndicate eOrient,
-                                               sal_uInt16 nId) :
+                                               
TypedWhichId<SvxChartIndicateItem> nId) :
     SfxEnumItem(nId, eOrient)
 {
 }
@@ -165,7 +165,7 @@ SvxChartIndicateItem* 
SvxChartIndicateItem::Clone(SfxItemPool* /*pPool*/) const
 }
 
 SvxChartRegressItem::SvxChartRegressItem(SvxChartRegress eOrient,
-                                               sal_uInt16 nId) :
+                                               
TypedWhichId<SvxChartRegressItem> nId) :
     SfxEnumItem(nId, eOrient)
 {
 }
diff --git a/svx/source/items/clipfmtitem.cxx b/svx/source/items/clipfmtitem.cxx
index 8ed567cdebcd..caae609f6204 100644
--- a/svx/source/items/clipfmtitem.cxx
+++ b/svx/source/items/clipfmtitem.cxx
@@ -32,9 +32,9 @@ struct SvxClipboardFormatItem_Impl
     SvxClipboardFormatItem_Impl() {}
 };
 
-SfxPoolItem* SvxClipboardFormatItem::CreateDefault() { return new  
SvxClipboardFormatItem(0); };
+SfxPoolItem* SvxClipboardFormatItem::CreateDefault() { return new  
SvxClipboardFormatItem(TypedWhichId<SvxClipboardFormatItem>(0)); };
 
-SvxClipboardFormatItem::SvxClipboardFormatItem( sal_uInt16 nId )
+SvxClipboardFormatItem::SvxClipboardFormatItem( 
TypedWhichId<SvxClipboardFormatItem> nId )
     : SfxPoolItem( nId ), pImpl( new SvxClipboardFormatItem_Impl )
 {
 }
diff --git a/svx/source/items/drawitem.cxx b/svx/source/items/drawitem.cxx
index 69482d56ff2d..24a6acb395df 100644
--- a/svx/source/items/drawitem.cxx
+++ b/svx/source/items/drawitem.cxx
@@ -36,7 +36,7 @@ SvxColorListItem::SvxColorListItem()
 }
 
 
-SvxColorListItem::SvxColorListItem( XColorListRef const & pTable, sal_uInt16 
nW ) :
+SvxColorListItem::SvxColorListItem( XColorListRef const & pTable, 
TypedWhichId<SvxColorListItem> nW ) :
     SfxPoolItem( nW ),
     pColorList( pTable )
 {
@@ -96,7 +96,7 @@ SvxGradientListItem::SvxGradientListItem()
 {
 }
 
-SvxGradientListItem::SvxGradientListItem( XGradientListRef const & pList, 
sal_uInt16 nW ) :
+SvxGradientListItem::SvxGradientListItem( XGradientListRef const & pList, 
TypedWhichId<SvxGradientListItem> nW ) :
     SfxPoolItem( nW ),
     pGradientList( pList )
 {
@@ -141,7 +141,7 @@ SvxHatchListItem::SvxHatchListItem()
 }
 
 
-SvxHatchListItem::SvxHatchListItem( XHatchListRef const & pList, sal_uInt16 nW 
) :
+SvxHatchListItem::SvxHatchListItem( XHatchListRef const & pList, 
TypedWhichId<SvxHatchListItem> nW ) :
     SfxPoolItem( nW ),
     pHatchList( pList )
 {
@@ -185,7 +185,7 @@ SvxBitmapListItem::SvxBitmapListItem()
 {
 }
 
-SvxBitmapListItem::SvxBitmapListItem( XBitmapListRef const & pList, sal_uInt16 
nW ) :
+SvxBitmapListItem::SvxBitmapListItem( XBitmapListRef const & pList, 
TypedWhichId<SvxBitmapListItem> nW ) :
     SfxPoolItem( nW ),
     pBitmapList( pList )
 {
@@ -226,7 +226,7 @@ SvxPatternListItem::SvxPatternListItem()
 {
 }
 
-SvxPatternListItem::SvxPatternListItem( XPatternListRef const & pList, 
sal_uInt16 nW ) :
+SvxPatternListItem::SvxPatternListItem( XPatternListRef const & pList, 
TypedWhichId<SvxPatternListItem> nW ) :
     SfxPoolItem( nW ),
     pPatternList( pList )
 {
@@ -267,7 +267,7 @@ SvxDashListItem::SvxDashListItem()
 {
 }
 
-SvxDashListItem::SvxDashListItem( XDashListRef const & pList, sal_uInt16 nW ) :
+SvxDashListItem::SvxDashListItem( XDashListRef const & pList, 
TypedWhichId<SvxDashListItem> nW ) :
     SfxPoolItem( nW ),
     pDashList( pList )
 {
@@ -308,7 +308,7 @@ SvxLineEndListItem::SvxLineEndListItem()
 {
 }
 
-SvxLineEndListItem::SvxLineEndListItem( XLineEndListRef const & pList, 
sal_uInt16 nW ) :
+SvxLineEndListItem::SvxLineEndListItem( XLineEndListRef const & pList, 
TypedWhichId<SvxLineEndListItem>  nW ) :
     SfxPoolItem( nW ),
     pLineEndList( pList )
 {
diff --git a/svx/source/items/e3ditem.cxx b/svx/source/items/e3ditem.cxx
index cd61f9ac013a..135c7efaf370 100644
--- a/svx/source/items/e3ditem.cxx
+++ b/svx/source/items/e3ditem.cxx
@@ -30,7 +30,7 @@ SvxB3DVectorItem::~SvxB3DVectorItem()
 }
 
 
-SvxB3DVectorItem::SvxB3DVectorItem( sal_uInt16 _nWhich, const 
basegfx::B3DVector& rVal ) :
+SvxB3DVectorItem::SvxB3DVectorItem( TypedWhichId<SvxB3DVectorItem> _nWhich, 
const basegfx::B3DVector& rVal ) :
     SfxPoolItem( _nWhich ),
     aVal( rVal )
 {
diff --git a/svx/source/items/grfitem.cxx b/svx/source/items/grfitem.cxx
index b241738f313f..30c0977a034d 100644
--- a/svx/source/items/grfitem.cxx
+++ b/svx/source/items/grfitem.cxx
@@ -25,13 +25,13 @@
 
 using namespace ::com::sun::star;
 
-SvxGrfCrop::SvxGrfCrop( sal_uInt16 nItemId )
+SvxGrfCrop::SvxGrfCrop( TypedWhichId<SvxGrfCrop> nItemId )
     : SfxPoolItem( nItemId ),
     nLeft( 0 ), nRight( 0 ), nTop( 0 ), nBottom( 0 )
 {}
 
 SvxGrfCrop::SvxGrfCrop( sal_Int32 nL, sal_Int32 nR,
-                        sal_Int32 nT, sal_Int32 nB, sal_uInt16 nItemId )
+                        sal_Int32 nT, sal_Int32 nB, TypedWhichId<SvxGrfCrop> 
nItemId )
     : SfxPoolItem( nItemId ),
     nLeft( nL ), nRight( nR ), nTop( nT ), nBottom( nB )
 {}
diff --git a/svx/source/items/hlnkitem.cxx b/svx/source/items/hlnkitem.cxx
index 7a092b36fc5a..4a8bc3290762 100644
--- a/svx/source/items/hlnkitem.cxx
+++ b/svx/source/items/hlnkitem.cxx
@@ -22,7 +22,7 @@
 #include <svx/hlnkitem.hxx>
 
 
-SfxPoolItem* SvxHyperlinkItem::CreateDefault() { return new  
SvxHyperlinkItem(0);}
+SfxPoolItem* SvxHyperlinkItem::CreateDefault() { return new  
SvxHyperlinkItem(TypedWhichId<SvxHyperlinkItem>(0));}
 
 SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem ):
             SfxPoolItem(rHyperlinkItem)
@@ -39,7 +39,7 @@ SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& 
rHyperlinkItem ):
 
 };
 
-SvxHyperlinkItem::SvxHyperlinkItem( sal_uInt16 _nWhich, const OUString& rName, 
const OUString& rURL,
+SvxHyperlinkItem::SvxHyperlinkItem( TypedWhichId<SvxHyperlinkItem> _nWhich, 
const OUString& rName, const OUString& rURL,
                                     const OUString& rTarget, const OUString& 
rIntName, SvxLinkInsertMode eTyp,
                                     HyperDialogEvent nEvents, 
SvxMacroTableDtor const *pMacroTbl ):
     SfxPoolItem (_nWhich),
diff --git a/svx/source/items/numinf.cxx b/svx/source/items/numinf.cxx
index a59d00b42074..d4bb1e915e79 100644
--- a/svx/source/items/numinf.cxx
+++ b/svx/source/items/numinf.cxx
@@ -20,7 +20,7 @@
 #include <svx/numinf.hxx>
 
 
-SvxNumberInfoItem::SvxNumberInfoItem( const sal_uInt16 nId ) :
+SvxNumberInfoItem::SvxNumberInfoItem( const TypedWhichId<SvxNumberInfoItem> 
nId ) :
     SfxPoolItem     ( nId ),
     pFormatter      ( nullptr ),
     eValueType      ( SvxNumberValueType::Undefined ),
@@ -31,7 +31,7 @@ SvxNumberInfoItem::SvxNumberInfoItem( const sal_uInt16 nId ) :
 
 
 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
-                                      const sal_uInt16 nId ) :
+                                      const TypedWhichId<SvxNumberInfoItem> 
nId ) :
     SfxPoolItem     ( nId ),
     pFormatter      ( pNumFormatter ),
     eValueType      ( SvxNumberValueType::Undefined ),
@@ -42,7 +42,7 @@ SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* 
pNumFormatter,
 
 
 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
-                                      const OUString& rVal, const sal_uInt16 
nId ) :
+                                      const OUString& rVal, const 
TypedWhichId<SvxNumberInfoItem> nId ) :
     SfxPoolItem     ( nId ),
     pFormatter      ( pNumFormatter ),
     eValueType      ( SvxNumberValueType::String ),
@@ -53,7 +53,7 @@ SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* 
pNumFormatter,
 
 
 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
-                                      const double& rVal, const sal_uInt16 nId 
) :
+                                      const double& rVal, const 
TypedWhichId<SvxNumberInfoItem> nId ) :
     SfxPoolItem     ( nId ),
     pFormatter      ( pNumFormatter ),
     eValueType      ( SvxNumberValueType::Number ),
@@ -65,7 +65,7 @@ SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* 
pNumFormatter,
 
 SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
                                       const double& rVal, const OUString& 
rValueStr,
-                                      const sal_uInt16 nId ) :
+                                      const TypedWhichId<SvxNumberInfoItem> 
nId ) :
     SfxPoolItem     ( nId ),
     pFormatter      ( pNumFormatter ),
     eValueType      ( SvxNumberValueType::Number ),
diff --git a/svx/source/items/pageitem.cxx b/svx/source/items/pageitem.cxx
index ad600c68fc0e..93239ea3d5b1 100644
--- a/svx/source/items/pageitem.cxx
+++ b/svx/source/items/pageitem.cxx
@@ -38,9 +38,9 @@
 
 using namespace ::com::sun::star;
 
-SfxPoolItem* SvxPageItem::CreateDefault() { return new   SvxPageItem(0);}
+SfxPoolItem* SvxPageItem::CreateDefault() { return new 
SvxPageItem(TypedWhichId<SvxPageItem>(0));}
 
-SvxPageItem::SvxPageItem( const sal_uInt16 nId ) : SfxPoolItem( nId ),
+SvxPageItem::SvxPageItem( const TypedWhichId<SvxPageItem> nId ) : SfxPoolItem( 
nId ),
 
     eNumType    ( SVX_NUM_ARABIC ),
     bLandscape  ( false ),
@@ -250,7 +250,7 @@ bool SvxPageItem::PutValue( const uno::Any& rVal, sal_uInt8 
nMemberId )
 }
 
 // HeaderFooterSet
-SvxSetItem::SvxSetItem( const sal_uInt16 nId, const SfxItemSet& rSet ) :
+SvxSetItem::SvxSetItem( const TypedWhichId<SvxSetItem> nId, const SfxItemSet& 
rSet ) :
 
     SfxSetItem( nId, rSet )
 {
@@ -262,7 +262,7 @@ SvxSetItem::SvxSetItem( const SvxSetItem& rItem ) :
 {
 }
 
-SvxSetItem::SvxSetItem( const sal_uInt16 nId, SfxItemSet&& _pSet ) :
+SvxSetItem::SvxSetItem( const TypedWhichId<SvxSetItem> nId, SfxItemSet&& _pSet 
) :
 
     SfxSetItem( nId, std::move(_pSet) )
 {
diff --git a/svx/source/items/postattr.cxx b/svx/source/items/postattr.cxx
index aabeae28d775..267c2cd9ad18 100644
--- a/svx/source/items/postattr.cxx
+++ b/svx/source/items/postattr.cxx
@@ -21,19 +21,19 @@
 #include <svx/strings.hrc>
 #include <svx/dialmgr.hxx>
 
-SfxPoolItem* SvxPostItAuthorItem::CreateDefault() { return new 
SvxPostItAuthorItem(0); }
-SfxPoolItem* SvxPostItDateItem::CreateDefault() { return new 
SvxPostItDateItem(0); }
-SfxPoolItem* SvxPostItTextItem::CreateDefault() { return new 
SvxPostItTextItem(0); }
-SfxPoolItem* SvxPostItIdItem::CreateDefault() { return new SvxPostItIdItem(0); 
}
+SfxPoolItem* SvxPostItAuthorItem::CreateDefault() { return new 
SvxPostItAuthorItem(TypedWhichId<SvxPostItAuthorItem>(0)); }
+SfxPoolItem* SvxPostItDateItem::CreateDefault() { return new 
SvxPostItDateItem(TypedWhichId<SvxPostItDateItem>(0)); }
+SfxPoolItem* SvxPostItTextItem::CreateDefault() { return new 
SvxPostItTextItem(TypedWhichId<SvxPostItTextItem>(0)); }
+SfxPoolItem* SvxPostItIdItem::CreateDefault() { return new 
SvxPostItIdItem(TypedWhichId<SvxPostItIdItem>(0)); }
 
-SvxPostItAuthorItem::SvxPostItAuthorItem( sal_uInt16 _nWhich )
+SvxPostItAuthorItem::SvxPostItAuthorItem( TypedWhichId<SvxPostItAuthorItem> 
_nWhich )
 {
     SetWhich( _nWhich );
 }
 
 
 SvxPostItAuthorItem::SvxPostItAuthorItem( const OUString& rAuthor,
-                                          sal_uInt16 _nWhich ) :
+                                          TypedWhichId<SvxPostItAuthorItem> 
_nWhich ) :
     SfxStringItem( _nWhich, rAuthor )
 {
 }
@@ -65,14 +65,13 @@ SvxPostItAuthorItem* SvxPostItAuthorItem::Clone( 
SfxItemPool * ) const
     return new SvxPostItAuthorItem( *this );
 }
 
-SvxPostItDateItem::SvxPostItDateItem( sal_uInt16 _nWhich )
+SvxPostItDateItem::SvxPostItDateItem( TypedWhichId<SvxPostItDateItem> _nWhich )
+    : SfxStringItem(_nWhich)
 {
-    SetWhich( _nWhich );
 }
 
 
-SvxPostItDateItem::SvxPostItDateItem( const OUString& rDate, sal_uInt16 
_nWhich ) :
-
+SvxPostItDateItem::SvxPostItDateItem( const OUString& rDate, 
TypedWhichId<SvxPostItDateItem> _nWhich ) :
     SfxStringItem( _nWhich, rDate )
 {
 }
@@ -105,12 +104,12 @@ SvxPostItDateItem* SvxPostItDateItem::Clone( SfxItemPool 
* ) const
     return new SvxPostItDateItem( *this );
 }
 
-SvxPostItTextItem::SvxPostItTextItem( sal_uInt16 _nWhich )
+SvxPostItTextItem::SvxPostItTextItem( TypedWhichId<SvxPostItTextItem> _nWhich )
 {
     SetWhich( _nWhich );
 }
 
-SvxPostItTextItem::SvxPostItTextItem( const OUString& rText, sal_uInt16 
_nWhich ) :
+SvxPostItTextItem::SvxPostItTextItem( const OUString& rText, 
TypedWhichId<SvxPostItTextItem> _nWhich ) :
 
     SfxStringItem( _nWhich, rText )
 {
@@ -142,7 +141,7 @@ SvxPostItTextItem* SvxPostItTextItem::Clone( SfxItemPool * 
) const
     return new SvxPostItTextItem( *this );
 }
 
-SvxPostItIdItem::SvxPostItIdItem( sal_uInt16 _nWhich )
+SvxPostItIdItem::SvxPostItIdItem( TypedWhichId<SvxPostItIdItem> _nWhich )
 {
     SetWhich( _nWhich );
 }
diff --git a/svx/source/items/rotmodit.cxx b/svx/source/items/rotmodit.cxx
index abd29b2ca1a3..eb559fdaeb62 100644
--- a/svx/source/items/rotmodit.cxx
+++ b/svx/source/items/rotmodit.cxx
@@ -26,13 +26,13 @@
 using namespace ::com::sun::star;
 
 
-SfxPoolItem* SvxRotateModeItem::CreateDefault() { return new  
SvxRotateModeItem(SVX_ROTATE_MODE_STANDARD, 0);}
+SfxPoolItem* SvxRotateModeItem::CreateDefault() { return new  
SvxRotateModeItem(SVX_ROTATE_MODE_STANDARD, 
TypedWhichId<SvxRotateModeItem>(0));}
 
 
 //  SvxRotateModeItem - orientation with turned text
 
 
-SvxRotateModeItem::SvxRotateModeItem( SvxRotateMode eMode, sal_uInt16 _nWhich )
+SvxRotateModeItem::SvxRotateModeItem( SvxRotateMode eMode, 
TypedWhichId<SvxRotateModeItem> _nWhich )
     : SfxEnumItem( _nWhich, eMode )
 {
 }
diff --git a/svx/source/items/viewlayoutitem.cxx 
b/svx/source/items/viewlayoutitem.cxx
index 4ab6472c0774..d923133a19bc 100644
--- a/svx/source/items/viewlayoutitem.cxx
+++ b/svx/source/items/viewlayoutitem.cxx
@@ -38,7 +38,7 @@ SvxViewLayoutItem::SvxViewLayoutItem
 (
     sal_uInt16      nColumns,
     bool        bBookMode,
-    sal_uInt16  _nWhich
+    TypedWhichId<SvxViewLayoutItem>  _nWhich
 )
 :   SfxUInt16Item( _nWhich, nColumns ),
     mbBookMode( bBookMode )
diff --git a/svx/source/items/zoomslideritem.cxx 
b/svx/source/items/zoomslideritem.cxx
index 94bc8cce7bad..046a0359153c 100644
--- a/svx/source/items/zoomslideritem.cxx
+++ b/svx/source/items/zoomslideritem.cxx
@@ -35,7 +35,7 @@ constexpr OUStringLiteral ZOOMSLIDER_PARAM_MAXZOOM = 
u"MaxValue";
 #define ZOOMSLIDER_PARAMS           4
 
 
-SvxZoomSliderItem::SvxZoomSliderItem( sal_uInt16 nCurrentZoom, sal_uInt16 
nMinZoom, sal_uInt16 nMaxZoom, sal_uInt16 _nWhich )
+SvxZoomSliderItem::SvxZoomSliderItem( sal_uInt16 nCurrentZoom, sal_uInt16 
nMinZoom, sal_uInt16 nMaxZoom, TypedWhichId<SvxZoomSliderItem> _nWhich )
 :   SfxUInt16Item( _nWhich, nCurrentZoom ), mnMinZoom( nMinZoom ), mnMaxZoom( 
nMaxZoom )
 {
 }
diff --git a/svx/source/mnuctrls/smarttagmenu.cxx 
b/svx/source/mnuctrls/smarttagmenu.cxx
index 2bed24f1ff12..86f11e8d0cc4 100644
--- a/svx/source/mnuctrls/smarttagmenu.cxx
+++ b/svx/source/mnuctrls/smarttagmenu.cxx
@@ -101,7 +101,7 @@ void SmartTagMenuController::statusChanged( const 
css::frame::FeatureStateEvent&
         else if ( aProperty.Name == "RangeText" )
             aProperty.Value >>= aRangeText;
     }
-    m_pSmartTagItem.reset( new SvxSmartTagItem( 0, aActionComponents, 
aActionIndices, aStringKeyMaps, xTextRange, xController, aLocale, 
aApplicationName, aRangeText ) );
+    m_pSmartTagItem.reset( new SvxSmartTagItem( 
TypedWhichId<SvxSmartTagItem>(0), aActionComponents, aActionIndices, 
aStringKeyMaps, xTextRange, xController, aLocale, aApplicationName, aRangeText 
) );
     FillMenu();
 }
 
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index b0df93a13855..da041583f4c9 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -716,7 +716,7 @@ SdrScaleItem* SdrScaleItem::Clone(SfxItemPool * /*pPool*/) 
const
 
 SdrOnOffItem* SdrOnOffItem::Clone(SfxItemPool* /*pPool*/) const
 {
-    return new SdrOnOffItem(Which(),GetValue());
+    return new SdrOnOffItem(TypedWhichId<SdrOnOffItem>(Which()),GetValue());
 }
 
 OUString SdrOnOffItem::GetValueTextByVal(bool bVal) const
@@ -751,7 +751,7 @@ void SdrOnOffItem::dumpAsXml(xmlTextWriterPtr pWriter) const
 
 SdrYesNoItem* SdrYesNoItem::Clone(SfxItemPool* /*pPool*/) const
 {
-    return new SdrYesNoItem(Which(),GetValue());
+    return new SdrYesNoItem(TypedWhichId<SdrYesNoItem>(Which()),GetValue());
 }
 
 OUString SdrYesNoItem::GetValueTextByVal(bool bVal) const
@@ -773,7 +773,7 @@ bool SdrYesNoItem::GetPresentation(SfxItemPresentation 
ePres,
 
 SdrPercentItem* SdrPercentItem::Clone(SfxItemPool* /*pPool*/) const
 {
-    return new SdrPercentItem(Which(),GetValue());
+    return new 
SdrPercentItem(TypedWhichId<SdrPercentItem>(Which()),GetValue());
 }
 
 bool SdrPercentItem::GetPresentation(
@@ -807,7 +807,7 @@ void SdrPercentItem::dumpAsXml(xmlTextWriterPtr pWriter) 
const
 
 SdrAngleItem* SdrAngleItem::Clone(SfxItemPool* /*pPool*/) const
 {
-    return new SdrAngleItem(Which(),GetValue());
+    return new SdrAngleItem(TypedWhichId<SdrAngleItem>(Which()),GetValue());
 }
 
 bool SdrAngleItem::GetPresentation(
@@ -872,7 +872,7 @@ bool SdrAngleItem::GetPresentation(
 
 SdrMetricItem* SdrMetricItem::Clone(SfxItemPool* /*pPool*/) const
 {
-    return new SdrMetricItem(Which(),GetValue());
+    return new SdrMetricItem(TypedWhichId<SdrMetricItem>(Which()),GetValue());
 }
 
 bool SdrMetricItem::HasMetrics() const
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx 
b/svx/source/unodraw/UnoNameItemTable.cxx
index 17e952ea5d4c..71569ae7ab51 100644
--- a/svx/source/unodraw/UnoNameItemTable.cxx
+++ b/svx/source/unodraw/UnoNameItemTable.cxx
@@ -44,7 +44,7 @@ namespace
     class SampleItem : public NameOrIndex
     {
     public:
-        SampleItem(sal_uInt16 nWhich, const OUString& rName) : 
NameOrIndex(nWhich, rName) {}
+        SampleItem(sal_uInt16 nWhich, const OUString& rName) : 
NameOrIndex(TypedWhichId<NameOrIndex>(nWhich), rName) {}
 
         bool operator==(const SfxPoolItem& rCmp) const
         {
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 2fcb40379b65..0539e19664e7 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -93,13 +93,13 @@ using namespace ::com::sun::star;
 
 typedef std::map<OUString, OUString> StringMap;
 
-NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, sal_Int32 nIndex) :
+NameOrIndex::NameOrIndex(TypedWhichId<NameOrIndex> _nWhich, sal_Int32 nIndex) :
     SfxStringItem(_nWhich, OUString()),
     nPalIndex(nIndex)
 {
 }
 
-NameOrIndex::NameOrIndex(sal_uInt16 _nWhich, const OUString& rName) :
+NameOrIndex::NameOrIndex(TypedWhichId<NameOrIndex> _nWhich, const OUString& 
rName) :
     SfxStringItem(_nWhich, rName),
     nPalIndex(-1)
 {
@@ -259,19 +259,19 @@ void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter) 
const
 
 SfxPoolItem* XColorItem::CreateDefault() { return new XColorItem; }
 
-XColorItem::XColorItem(sal_uInt16 _nWhich, sal_Int32 nIndex, const Color& 
rTheColor) :
+XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, sal_Int32 nIndex, 
const Color& rTheColor) :
     NameOrIndex(_nWhich, nIndex),
     aColor(rTheColor)
 {
 }
 
-XColorItem::XColorItem(sal_uInt16 _nWhich, const OUString& rName, const Color& 
rTheColor) :
+XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, const OUString& 
rName, const Color& rTheColor) :
     NameOrIndex(_nWhich, rName),
     aColor(rTheColor)
 {
 }
 
-XColorItem::XColorItem(sal_uInt16 _nWhich, const Color& rTheColor)
+XColorItem::XColorItem(TypedWhichId<XColorItem> _nWhich, const Color& 
rTheColor)
     : NameOrIndex(_nWhich, OUString())
     , aColor(rTheColor)
 {
@@ -2128,7 +2128,7 @@ XFillGradientItem::XFillGradientItem(sal_Int32 nIndex,
 }
 
 XFillGradientItem::XFillGradientItem(const OUString& rName,
-                                   const XGradient& rTheGradient, sal_uInt16 
nWhich)
+                                   const XGradient& rTheGradient, 
TypedWhichId<XFillGradientItem> nWhich)
     : NameOrIndex(nWhich, rName)
     , aGradient(rTheGradient)
 {
@@ -2409,7 +2409,7 @@ std::unique_ptr<XFillGradientItem> 
XFillGradientItem::checkForUniqueItem( SdrMod
 
         // if the given name is not valid, replace it!
         if( aUniqueName != GetName() )
-            return std::make_unique<XFillGradientItem>( aUniqueName, 
aGradient, Which() );
+            return std::make_unique<XFillGradientItem>( aUniqueName, 
aGradient, TypedWhichId<XFillGradientItem>(Which()) );
     }
 
     return nullptr;
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 342f41cb949a..bdac82f3bc2c 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -625,7 +625,7 @@
 #define FN_UNO_FOOTER_FIRST                 (FN_EXTRA2 + 119)
 #define FN_UNO_TABLE_BORDER2                (FN_EXTRA2 + 120)
 
-// #define free                             (FN_EXTRA2 + 121)
+#define FN_FIELD_DIALOG_DOC_PROPS           
TypedWhichId<SfxUnoAnyItem>(FN_EXTRA2 + 121)
 #define FN_UNO_HIDDEN                       (FN_EXTRA2 + 122)
 #define FN_UNO_STYLE_INTEROP_GRAB_BAG       (FN_EXTRA2 + 123)
 #define FN_UNO_TABLE_TEMPLATE_NAME          (FN_EXTRA2 + 124)
@@ -861,12 +861,12 @@
 
 #define SID_ATTR_PAGE_COLUMN            (FN_SIDEBAR + 0)
 #define SID_ATTR_PAGE_HEADER            (FN_SIDEBAR + 3)
-#define SID_ATTR_PAGE_HEADER_LRMARGIN   (FN_SIDEBAR + 4)
-#define SID_ATTR_PAGE_HEADER_SPACING    (FN_SIDEBAR + 5)
+#define SID_ATTR_PAGE_HEADER_LRMARGIN   
TypedWhichId<SvxLongLRSpaceItem>(FN_SIDEBAR + 4)
+#define SID_ATTR_PAGE_HEADER_SPACING    
TypedWhichId<SvxLongULSpaceItem>(FN_SIDEBAR + 5)
 #define SID_ATTR_PAGE_HEADER_LAYOUT     (FN_SIDEBAR + 6)
 #define SID_ATTR_PAGE_FOOTER            (FN_SIDEBAR + 7)
-#define SID_ATTR_PAGE_FOOTER_LRMARGIN   (FN_SIDEBAR + 8)
-#define SID_ATTR_PAGE_FOOTER_SPACING    (FN_SIDEBAR + 9)
+#define SID_ATTR_PAGE_FOOTER_LRMARGIN   
TypedWhichId<SvxLongLRSpaceItem>(FN_SIDEBAR + 8)
+#define SID_ATTR_PAGE_FOOTER_SPACING    
TypedWhichId<SvxLongULSpaceItem>(FN_SIDEBAR + 9)
 #define SID_ATTR_PAGE_FOOTER_LAYOUT     (FN_SIDEBAR + 10)
 #define SID_ATTR_PAGE_MARGIN            (FN_SIDEBAR + 11)
 
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index c2175aea2f44..bc4b8b19bf1e 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1130,7 +1130,7 @@ void SwDocTest::testTableAutoFormats()
     SfxBoolItem aStacked(0, true);
     aBoxAF.SetStacked(aStacked);
     //Set m_aMargin
-    SvxMarginItem aSvxMarginItem(sal_Int16(4), sal_Int16(2), sal_Int16(3), 
sal_Int16(3), 0);
+    SvxMarginItem aSvxMarginItem(sal_Int16(4), sal_Int16(2), sal_Int16(3), 
sal_Int16(3), TypedWhichId<SvxMarginItem>(0));
     aBoxAF.SetMargin(aSvxMarginItem);
     //Set m_aLinebreak
     SfxBoolItem aLBreak(0, true);
@@ -1139,7 +1139,7 @@ void SwDocTest::testTableAutoFormats()
     SfxInt32Item aRAngle(sal_Int32(5));
     aBoxAF.SetRotateAngle(aRAngle);
     //Set m_aRotateMode
-    SvxRotateModeItem aSvxRotateModeItem(SVX_ROTATE_MODE_CENTER, 0);
+    SvxRotateModeItem aSvxRotateModeItem(SVX_ROTATE_MODE_CENTER, 
TypedWhichId<SvxRotateModeItem>(0));
     aBoxAF.SetRotateMode(aSvxRotateModeItem);
     //Set m_sNumFormatString
     OUString aNFString = "UnitTestFormat";
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index c92cadd49f50..d6807fb416dd 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -249,10 +249,10 @@ SwBoxAutoFormat::SwBoxAutoFormat()
     m_aHorJustify = 
std::make_unique<SvxHorJustifyItem>(SvxCellHorJustify::Standard, 0);
     m_aVerJustify = 
std::make_unique<SvxVerJustifyItem>(SvxCellVerJustify::Standard, 0);
     m_aStacked = std::make_unique<SfxBoolItem>(0 );
-    m_aMargin = std::make_unique<SvxMarginItem>(0 );
+    m_aMargin = std::make_unique<SvxMarginItem>( 
TypedWhichId<SvxMarginItem>(0) );
     m_aLinebreak = std::make_unique<SfxBoolItem>(0 );
     m_aRotateAngle = std::make_unique<SfxInt32Item>(0 );
-    m_aRotateMode = 
std::make_unique<SvxRotateModeItem>(SVX_ROTATE_MODE_STANDARD, 0 );
+    m_aRotateMode = 
std::make_unique<SvxRotateModeItem>(SVX_ROTATE_MODE_STANDARD, 
TypedWhichId<SvxRotateModeItem>(0) );
 
 // FIXME - add attribute IDs for the diagonal line items
 //    aTLBR( RES_... ),
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index c4f3bf269ce9..14f9109a5b3c 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -23,6 +23,7 @@
 #include <osl/endian.h>
 #include <sal/log.hxx>
 #include <editeng/lrspitem.hxx>
+#include <svx/xflbmtit.hxx>
 #include <svx/xfillit0.hxx>
 #include <svx/xlineit0.hxx>
 #include <svx/xlnclit.hxx>
@@ -1909,7 +1910,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject 
const * pSdrObj,
             case drawing::FillStyle_BITMAP:
                 {
                     GraphicObject 
aGrfObj(rOldSet.Get(XATTR_FILLBITMAP).GetGraphicObject());
-                    const bool bTile(WW8ITEMVALUE(rOldSet, XATTR_FILLBMP_TILE, 
SfxBoolItem));
+                    const bool bTile(WW8ITEMVALUE(rOldSet, XATTR_FILLBMP_TILE, 
XFillBmpTileItem));
 
                     if(bBrushItemOk) // has trans
                     {
diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index c9e07406ad5c..1729a68c148c 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx

... etc. - the rest is truncated

Reply via email to