[Libreoffice-commits] core.git: chart2/source cui/source include/sfx2 include/svl include/svx sc/source sd/source sfx2/source solenv/gdb svl/source svx/qa svx/source sw/inc sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 15 12:41:51 UTC 2021


 chart2/source/controller/itemsetwrapper/ItemConverter.cxx |   12 
 chart2/source/controller/main/ShapeController.cxx         |    2 
 cui/source/dialogs/iconcdlg.cxx                           |   11 
 cui/source/dialogs/postdlg.cxx                            |   10 
 cui/source/dialogs/srchxtra.cxx                           |    2 
 cui/source/factory/dlgfact.cxx                            |   10 
 cui/source/factory/dlgfact.hxx                            |   10 
 cui/source/inc/TextColumnsPage.hxx                        |    4 
 cui/source/inc/align.hxx                                  |    4 
 cui/source/inc/backgrnd.hxx                               |    4 
 cui/source/inc/border.hxx                                 |    4 
 cui/source/inc/chardlg.hxx                                |   16 
 cui/source/inc/connect.hxx                                |    4 
 cui/source/inc/cuihyperdlg.hxx                            |    4 
 cui/source/inc/cuitabarea.hxx                             |   12 
 cui/source/inc/cuitabline.hxx                             |    4 
 cui/source/inc/labdlg.hxx                                 |    4 
 cui/source/inc/macropg.hxx                                |    2 
 cui/source/inc/measure.hxx                                |    4 
 cui/source/inc/numfmt.hxx                                 |    4 
 cui/source/inc/optasian.hxx                               |    2 
 cui/source/inc/page.hxx                                   |    4 
 cui/source/inc/paragrph.hxx                               |   14 
 cui/source/inc/postdlg.hxx                                |    2 
 cui/source/inc/srchxtra.hxx                               |    2 
 cui/source/inc/swpossizetabpage.hxx                       |    2 
 cui/source/inc/tabstpge.hxx                               |    4 
 cui/source/inc/textanim.hxx                               |    4 
 cui/source/inc/textattr.hxx                               |    4 
 cui/source/inc/transfrm.hxx                               |   12 
 cui/source/options/optasian.cxx                           |    5 
 cui/source/tabpages/TextColumnsPage.cxx                   |    4 
 cui/source/tabpages/align.cxx                             |   24 
 cui/source/tabpages/backgrnd.cxx                          |    8 
 cui/source/tabpages/border.cxx                            |   16 
 cui/source/tabpages/chardlg.cxx                           |   90 --
 cui/source/tabpages/connect.cxx                           |    8 
 cui/source/tabpages/labdlg.cxx                            |   21 
 cui/source/tabpages/measure.cxx                           |    8 
 cui/source/tabpages/numfmt.cxx                            |   18 
 cui/source/tabpages/page.cxx                              |   19 
 cui/source/tabpages/paragrph.cxx                          |   45 -
 cui/source/tabpages/swpossizetabpage.cxx                  |   40 -
 cui/source/tabpages/tabstpge.cxx                          |    8 
 cui/source/tabpages/textanim.cxx                          |    8 
 cui/source/tabpages/textattr.cxx                          |   13 
 cui/source/tabpages/tparea.cxx                            |   12 
 cui/source/tabpages/tpline.cxx                            |   12 
 cui/source/tabpages/tpshadow.cxx                          |   18 
 cui/source/tabpages/tptrans.cxx                           |   15 
 cui/source/tabpages/transfrm.cxx                          |   58 -
 include/sfx2/basedlgs.hxx                                 |    3 
 include/sfx2/sfxdlg.hxx                                   |    2 
 include/sfx2/tabdlg.hxx                                   |    6 
 include/svl/itempool.hxx                                  |    5 
 include/svl/itemset.hxx                                   |   52 -
 include/svl/whichranges.hxx                               |   74 +
 include/svl/whiter.hxx                                    |    7 
 include/svx/hdft.hxx                                      |    6 
 include/svx/svdetc.hxx                                    |    3 
 include/svx/svxdlg.hxx                                    |    4 
 sc/source/ui/attrdlg/scdlgfact.cxx                        |    2 
 sc/source/ui/attrdlg/scdlgfact.hxx                        |    2 
 sc/source/ui/attrdlg/tabpages.cxx                         |    8 
 sc/source/ui/drawfunc/drawsh.cxx                          |    2 
 sc/source/ui/inc/tabpages.hxx                             |    4 
 sc/source/ui/inc/tphf.hxx                                 |    4 
 sc/source/ui/inc/tptable.hxx                              |    4 
 sc/source/ui/pagedlg/tphf.cxx                             |    4 
 sc/source/ui/pagedlg/tptable.cxx                          |    7 
 sd/source/ui/dlg/paragr.cxx                               |   12 
 sd/source/ui/dlg/prltempl.cxx                             |   15 
 sd/source/ui/dlg/sddlgfact.cxx                            |    6 
 sd/source/ui/dlg/sddlgfact.hxx                            |    6 
 sd/source/ui/func/fupage.cxx                              |   28 
 sd/source/ui/func/futransf.cxx                            |    2 
 sfx2/source/appl/appcfg.cxx                               |    7 
 sfx2/source/appl/appserv.cxx                              |   10 
 sfx2/source/appl/appuno.cxx                               |    7 
 sfx2/source/control/bindings.cxx                          |    5 
 sfx2/source/dialog/tabdlg.cxx                             |   45 -
 sfx2/source/view/viewfrm.cxx                              |   20 
 sfx2/source/view/viewfrm2.cxx                             |    9 
 solenv/gdb/libreoffice/svl.py                             |    9 
 svl/source/inc/items_helper.hxx                           |   90 --
 svl/source/inc/poolio.hxx                                 |    2 
 svl/source/items/itempool.cxx                             |   13 
 svl/source/items/itemset.cxx                              |  529 ++++++++------
 svl/source/items/whiter.cxx                               |   25 
 svx/qa/unit/removewhichrange.cxx                          |  107 +-
 svx/source/dialog/hdft.cxx                                |    8 
 svx/source/dialog/srchdlg.cxx                             |   25 
 svx/source/svdraw/svdedxv.cxx                             |   61 -
 svx/source/svdraw/svdetc.cxx                              |   30 
 sw/inc/swatrset.hxx                                       |    1 
 sw/source/core/attr/swatrset.cxx                          |    7 
 sw/source/core/txtnode/thints.cxx                         |   10 
 sw/source/core/undo/unattr.cxx                            |    6 
 sw/source/filter/ww8/writerhelper.cxx                     |    2 
 sw/source/ui/chrdlg/drpcps.cxx                            |    7 
 sw/source/ui/chrdlg/numpara.cxx                           |    5 
 sw/source/ui/chrdlg/swuiccoll.cxx                         |    5 
 sw/source/ui/dialog/swdlgfact.cxx                         |    6 
 sw/source/ui/dialog/swdlgfact.hxx                         |    6 
 sw/source/ui/envelp/envfmt.cxx                            |   82 --
 sw/source/ui/frmdlg/column.cxx                            |    5 
 sw/source/ui/frmdlg/frmpage.cxx                           |   14 
 sw/source/ui/frmdlg/wrap.cxx                              |    7 
 sw/source/ui/misc/pgfnote.cxx                             |    5 
 sw/source/ui/misc/pggrid.cxx                              |    7 
 sw/source/uibase/inc/column.hxx                           |    4 
 sw/source/uibase/inc/drpcps.hxx                           |    4 
 sw/source/uibase/inc/frmpage.hxx                          |    8 
 sw/source/uibase/inc/numpara.hxx                          |    4 
 sw/source/uibase/inc/pgfnote.hxx                          |    4 
 sw/source/uibase/inc/pggrid.hxx                           |    2 
 sw/source/uibase/inc/swuiccoll.hxx                        |    4 
 sw/source/uibase/inc/wrap.hxx                             |    4 
 sw/source/uibase/shells/drwbassh.cxx                      |    2 
 sw/source/uibase/uiview/formatclipboard.cxx               |    7 
 sw/source/uibase/utlui/uitool.cxx                         |   29 
 121 files changed, 994 insertions(+), 1150 deletions(-)

New commits:
commit 5d0a231b29dfd4d587c7a4d1bbda6a511f94ec77
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Jul 10 10:19:28 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 15 14:41:13 2021 +0200

    WhichRangesContainer, reduce malloc in SfxItemSet
    
    SfxItemSet shows up in perf profiles frequently,
    and the hottest part is the malloc of the two arrays we need.
    But most of the time, one of those arrays is a compile-time
    constant.
    
    So this change introduces
    (*) WhichRangesContainer, which manages whether the SfxItemSet
    owns the array it points at or not.
    (*) a static const member in svl::Items (idea from mkaganski)
    to store the data.
    
    Change-Id: Icb8cdbc4d54fd76739565c575e16a744515e5355
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118703
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
index a99d848d0c8c..e90fad016cfd 100644
--- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
@@ -75,20 +75,18 @@ void ItemConverter::_disposing( const lang::EventObject& )
 
 void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
 {
-    const sal_uInt16 * pRanges = rOutItemSet.GetRanges();
+    const WhichRangesContainer& pRanges = rOutItemSet.GetRanges();
     tPropertyNameWithMemberId aProperty;
     SfxItemPool & rPool = GetItemPool();
 
-    assert(pRanges != nullptr);
+    assert(!pRanges.empty());
     OSL_ASSERT( m_xPropertySetInfo.is());
     OSL_ASSERT( m_xPropertySet.is());
 
-    while( (*pRanges) != 0)
+    for(const auto& rPair : pRanges)
     {
-        sal_uInt16 nBeg = *pRanges;
-        ++pRanges;
-        sal_uInt16 nEnd = *pRanges;
-        ++pRanges;
+        sal_uInt16 nBeg = rPair.first;
+        sal_uInt16 nEnd = rPair.second;
 
         OSL_ASSERT( nBeg <= nEnd );
         for( sal_uInt16 nWhich = nBeg; nWhich <= nEnd; ++nWhich )
diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx
index 8161717fe339..360c2513df18 100644
--- a/chart2/source/controller/main/ShapeController.cxx
+++ b/chart2/source/controller/main/ShapeController.cxx
@@ -361,7 +361,7 @@ void ShapeController::executeDispatch_TransformDialog()
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         ScopedVclPtr< SfxAbstractTabDialog > pDlg(
             pFact->CreateCaptionDialog(pChartWindow, pDrawViewWrapper));
-        const sal_uInt16* pRange = pDlg->GetInputRanges( *aAttr.GetPool() );
+        const WhichRangesContainer& pRange = pDlg->GetInputRanges( *aAttr.GetPool() );
         SfxItemSet aCombAttr( *aAttr.GetPool(), pRange );
         aCombAttr.Put( aAttr );
         aCombAttr.Put( aGeoAttr );
diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx
index 8eeed40dc181..6e6ffaf5c53a 100644
--- a/cui/source/dialogs/iconcdlg.cxx
+++ b/cui/source/dialogs/iconcdlg.cxx
@@ -226,7 +226,7 @@ void SvxHpLinkDlg::ResetPageImpl ()
 |
 \**********************************************************************/
 
-const sal_uInt16* SvxHpLinkDlg::GetInputRanges( const SfxItemPool& )
+WhichRangesContainer SvxHpLinkDlg::GetInputRanges( const SfxItemPool& )
 {
     if ( pSet )
     {
@@ -234,13 +234,10 @@ const sal_uInt16* SvxHpLinkDlg::GetInputRanges( const SfxItemPool& )
         return pSet->GetRanges();
     }
 
-    if ( pRanges )
-        return pRanges.get();
+    if ( !pRanges.empty() )
+        return pRanges;
 
-    pRanges.reset(new sal_uInt16[1]);
-    pRanges[0] = 0;
-
-    return pRanges.get();
+    return WhichRangesContainer();
 }
 
 
diff --git a/cui/source/dialogs/postdlg.cxx b/cui/source/dialogs/postdlg.cxx
index fe9f2e065bf3..7e8541c5c615 100644
--- a/cui/source/dialogs/postdlg.cxx
+++ b/cui/source/dialogs/postdlg.cxx
@@ -116,15 +116,9 @@ void SvxPostItDialog::ShowLastAuthor(std::u16string_view rAuthor, std::u16string
     m_xLastEditFT->set_label( sTxt );
 }
 
-const sal_uInt16* SvxPostItDialog::GetRanges()
+WhichRangesContainer SvxPostItDialog::GetRanges()
 {
-    static const sal_uInt16 pRanges[] =
-    {
-        SID_ATTR_POSTIT_AUTHOR,
-        SID_ATTR_POSTIT_TEXT,
-        0
-    };
-    return pRanges;
+    return WhichRangesContainer(svl::Items<SID_ATTR_POSTIT_AUTHOR, SID_ATTR_POSTIT_TEXT>::value);
 }
 
 void SvxPostItDialog::EnableTravel(bool bNext, bool bPrev)
diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx
index 513501700970..384acbc1d566 100644
--- a/cui/source/dialogs/srchxtra.cxx
+++ b/cui/source/dialogs/srchxtra.cxx
@@ -105,7 +105,7 @@ void SvxSearchFormatDialog::PageCreated(const OString& rId, SfxTabPage& rPage)
 }
 
 SvxSearchAttributeDialog::SvxSearchAttributeDialog(weld::Window* pParent,
-    SearchAttrItemList& rLst, const sal_uInt16* pWhRanges)
+    SearchAttrItemList& rLst, const WhichRangesContainer& pWhRanges)
     : GenericDialogController(pParent, "cui/ui/searchattrdialog.ui", "SearchAttrDialog")
     , rList(rLst)
     , m_xAttrLB(m_xBuilder->weld_tree_view("treeview"))
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index f49e3228134f..5085a2dc4bce 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -364,7 +364,7 @@ const SfxItemSet* CuiAbstractTabController_Impl::GetOutputItemSet() const
     return m_xDlg->GetOutputItemSet();
 }
 
-const sal_uInt16* CuiAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer CuiAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
 {
     return m_xDlg->GetInputRanges( pItem );
 }
@@ -665,7 +665,7 @@ const SfxItemSet* AbstractSvxTransformTabDialog_Impl::GetOutputItemSet() const
     return m_xDlg->GetOutputItemSet();
 }
 
-const sal_uInt16* AbstractSvxTransformTabDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer AbstractSvxTransformTabDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
 {
     return m_xDlg->GetInputRanges( pItem );
 }
@@ -697,7 +697,7 @@ const SfxItemSet* AbstractSvxCaptionDialog_Impl::GetOutputItemSet() const
     return m_xDlg->GetOutputItemSet();
 }
 
-const sal_uInt16* AbstractSvxCaptionDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer AbstractSvxCaptionDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
 {
     return m_xDlg->GetInputRanges( pItem );
 }
@@ -890,7 +890,7 @@ const SfxItemSet* AbstractSvxAreaTabDialog_Impl::GetOutputItemSet() const
     return m_xDlg->GetOutputItemSet();
 }
 
-const sal_uInt16* AbstractSvxAreaTabDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer AbstractSvxAreaTabDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
 {
     return m_xDlg->GetInputRanges( pItem );
 }
@@ -1189,7 +1189,7 @@ VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateTabItemDialog(wel
 
 VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxSearchAttributeDialog(weld::Window* pParent,
                                             SearchAttrItemList& rLst,
-                                            const sal_uInt16* pWhRanges )
+                                            const WhichRangesContainer& pWhRanges )
 {
     return VclPtr<CuiAbstractController_Impl>::Create(std::make_unique<SvxSearchAttributeDialog>(pParent, rLst, pWhRanges));
 }
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index 39e540c46352..c0b1f7714418 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -162,7 +162,7 @@ public:
     virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
     virtual void                SetCurPageId( const OString &rName ) override;
     virtual const SfxItemSet*   GetOutputItemSet() const override;
-    virtual const sal_uInt16*   GetInputRanges( const SfxItemPool& pItem ) override;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
     virtual void                SetInputSet( const SfxItemSet* pInSet ) override;
     virtual void        SetText( const OUString& rStr ) override;
 
@@ -383,7 +383,7 @@ public:
     virtual void SetValidateFramePosLink( const Link<SvxSwFrameValidation&,void>& rLink ) override;
     virtual void                SetCurPageId( const OString& rName ) override;
     virtual const SfxItemSet*   GetOutputItemSet() const override;
-    virtual const sal_uInt16*       GetInputRanges( const SfxItemPool& pItem ) override;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
     virtual void                SetInputSet( const SfxItemSet* pInSet ) override;
     virtual void        SetText( const OUString& rStr ) override;
 };
@@ -401,7 +401,7 @@ public:
     virtual void SetValidateFramePosLink( const Link<SvxSwFrameValidation&,void>& rLink ) override;
     virtual void                SetCurPageId( const OString& rName ) override;
     virtual const SfxItemSet*   GetOutputItemSet() const override;
-    virtual const sal_uInt16*       GetInputRanges( const SfxItemPool& pItem ) override;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
     virtual void                SetInputSet( const SfxItemSet* pInSet ) override;
     virtual void        SetText( const OUString& rStr ) override;
 };
@@ -576,7 +576,7 @@ public:
     virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
     virtual void SetCurPageId(const OString& rName) override;
     virtual const SfxItemSet* GetOutputItemSet() const override;
-    virtual const sal_uInt16* GetInputRanges(const SfxItemPool& pItem) override;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
     virtual void SetInputSet(const SfxItemSet* pInSet) override;
     virtual void SetText(const OUString& rStr) override;
 };
@@ -851,7 +851,7 @@ public:
 
     virtual VclPtr<VclAbstractDialog>      CreateSvxSearchAttributeDialog(weld::Window* pParent,
                                             SearchAttrItemList& rLst,
-                                            const sal_uInt16* pWhRanges) override;
+                                            const WhichRangesContainer& pWhRanges) override;
     virtual VclPtr<AbstractSvxSearchSimilarityDialog> CreateSvxSearchSimilarityDialog( weld::Window* pParent,
                                                             bool bRelax,
                                                             sal_uInt16 nOther,
diff --git a/cui/source/inc/TextColumnsPage.hxx b/cui/source/inc/TextColumnsPage.hxx
index 6153cd27a520..af45c23c93ca 100644
--- a/cui/source/inc/TextColumnsPage.hxx
+++ b/cui/source/inc/TextColumnsPage.hxx
@@ -19,7 +19,7 @@
 class SvxTextColumnsPage : public SfxTabPage
 {
 private:
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
 
     std::unique_ptr<weld::SpinButton> m_xColumnsNumber;
     std::unique_ptr<weld::MetricSpinButton> m_xColumnsSpacing;
@@ -31,7 +31,7 @@ public:
 
     static std::unique_ptr<SfxTabPage>
     Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet*);
-    static const sal_uInt16* GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool FillItemSet(SfxItemSet*) override;
     virtual void Reset(const SfxItemSet*) override;
diff --git a/cui/source/inc/align.hxx b/cui/source/inc/align.hxx
index 61d31cd00a65..2be30aec6c71 100644
--- a/cui/source/inc/align.hxx
+++ b/cui/source/inc/align.hxx
@@ -45,14 +45,14 @@ namespace svx {
 
 class AlignmentTabPage : public SfxTabPage
 {
-    static const sal_uInt16 s_pRanges[];
+    static const WhichRangesContainer s_pRanges;
 
 public:
     virtual             ~AlignmentTabPage() override;
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet );
     explicit            AlignmentTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet);
 
-    static const sal_uInt16*  GetRanges() { return s_pRanges; }
+    static WhichRangesContainer GetRanges() { return s_pRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
     virtual void        Reset( const SfxItemSet* rSet ) override;
diff --git a/cui/source/inc/backgrnd.hxx b/cui/source/inc/backgrnd.hxx
index 5673b2f6067b..450fbdaaa27f 100644
--- a/cui/source/inc/backgrnd.hxx
+++ b/cui/source/inc/backgrnd.hxx
@@ -37,7 +37,7 @@ class SvxBrushItem;
 
 class SvxBkgTabPage : public SvxAreaTabPage
 {
-    static const sal_uInt16 pPageRanges[];
+    static const WhichRangesContainer pPageRanges;
 
     std::unique_ptr<weld::ComboBox> m_xTblLBox;
     bool        bHighlighting       : 1;
@@ -53,7 +53,7 @@ public:
     virtual ~SvxBkgTabPage() override;
 
     // returns the area of the which-values
-    static const sal_uInt16* GetRanges() { return pPageRanges; }
+    static WhichRangesContainer GetRanges() { return pPageRanges; }
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
     virtual bool FillItemSet( SfxItemSet* ) override;
diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx
index 1bac9a24bfbf..708f79083380 100644
--- a/cui/source/inc/border.hxx
+++ b/cui/source/inc/border.hxx
@@ -75,14 +75,14 @@ private:
 
 class SvxBorderTabPage : public SfxTabPage
 {
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
 
 public:
     SvxBorderTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
     virtual ~SvxBorderTabPage() override;
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController,
                                 const SfxItemSet* rAttrSet);
-    static const sal_uInt16*      GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* rCoreAttrs ) override;
     virtual void        Reset( const SfxItemSet* ) override;
diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx
index 31bf955b13ae..281a86b4d826 100644
--- a/cui/source/inc/chardlg.hxx
+++ b/cui/source/inc/chardlg.hxx
@@ -61,7 +61,7 @@ struct SvxCharNamePage_Impl;
 class SvxCharNamePage : public SvxCharBasePage
 {
 private:
-    static const sal_uInt16 pNameRanges[];
+    static const WhichRangesContainer pNameRanges;
 
     std::unique_ptr<SvxCharNamePage_Impl>   m_pImpl;
 
@@ -140,7 +140,7 @@ public:
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
     virtual ~SvxCharNamePage() override;
 
-    static const sal_uInt16* GetRanges() { return pNameRanges; }
+    static WhichRangesContainer GetRanges() { return pNameRanges; }
 
     virtual void        Reset( const SfxItemSet* rSet ) override;
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
@@ -159,7 +159,7 @@ public:
 class SvxCharEffectsPage : public SvxCharBasePage
 {
 private:
-    static const sal_uInt16 pEffectsRanges[];
+    static const WhichRangesContainer pEffectsRanges;
     bool                       m_bOrigFontColor;
     bool                       m_bNewFontColor;
     bool                       m_bEnableNoneFontColor;
@@ -220,7 +220,7 @@ public:
     virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
 
 public:
-    static const sal_uInt16* GetRanges() { return pEffectsRanges; }
+    static WhichRangesContainer GetRanges() { return pEffectsRanges; }
 
     virtual void        Reset( const SfxItemSet* rSet ) override;
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
@@ -233,7 +233,7 @@ public:
 // class SvxCharPositionPage ---------------------------------------------
 class SvxCharPositionPage : public SvxCharBasePage
 {
-    static const sal_uInt16 pPositionRanges[];
+    static const WhichRangesContainer pPositionRanges;
 
 private:
     short               m_nSuperEsc;
@@ -289,7 +289,7 @@ public:
     virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
 
 public:
-    static const sal_uInt16*      GetRanges() { return pPositionRanges; }
+    static WhichRangesContainer GetRanges() { return pPositionRanges; }
 
     virtual void        Reset( const SfxItemSet* rSet ) override;
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
@@ -303,7 +303,7 @@ public:
 class SvxCharTwoLinesPage : public SvxCharBasePage
 {
 private:
-    static const sal_uInt16 pTwoLinesRanges[];
+    static const WhichRangesContainer pTwoLinesRanges;
     sal_uInt16              m_nStartBracketPosition;
     sal_uInt16              m_nEndBracketPosition;
 
@@ -328,7 +328,7 @@ public:
     virtual void        ActivatePage( const SfxItemSet& rSet ) override;
     virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
 
-    static const sal_uInt16*  GetRanges() { return pTwoLinesRanges; }
+    static WhichRangesContainer GetRanges() { return pTwoLinesRanges; }
 
     virtual void        Reset( const SfxItemSet* rSet ) override;
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
diff --git a/cui/source/inc/connect.hxx b/cui/source/inc/connect.hxx
index ea97a266c882..8b7119f0dcaf 100644
--- a/cui/source/inc/connect.hxx
+++ b/cui/source/inc/connect.hxx
@@ -30,7 +30,7 @@ class SdrView;
 class SvxConnectionPage : public SfxTabPage
 {
 private:
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
     const SfxItemSet&   rOutAttrs;
     SfxItemSet          aAttrSet;
     const SdrView*      pView;
@@ -61,7 +61,7 @@ public:
     virtual ~SvxConnectionPage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16* GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* ) override;
     virtual void        Reset( const SfxItemSet * ) override;
diff --git a/cui/source/inc/cuihyperdlg.hxx b/cui/source/inc/cuihyperdlg.hxx
index 9d6e1ee358d1..b43361edfea1 100644
--- a/cui/source/inc/cuihyperdlg.hxx
+++ b/cui/source/inc/cuihyperdlg.hxx
@@ -72,7 +72,7 @@ private:
     const SfxItemSet*       pSet;
     std::unique_ptr<SfxItemSet>     pOutSet;
     std::unique_ptr<SfxItemSet>     pExampleSet;
-    std::unique_ptr<sal_uInt16[]>   pRanges;
+    WhichRangesContainer   pRanges;
 
     SvxHlinkCtrl        maCtrl;         ///< Controller
     std::unique_ptr<SfxItemSet> mpItemSet;
@@ -120,7 +120,7 @@ public:
     void                ShowPage( const OString& rId );
 
     /// gives via map converted local slots if applicable
-    const sal_uInt16*   GetInputRanges( const SfxItemPool& );
+    WhichRangesContainer GetInputRanges( const SfxItemPool& );
     void                SetInputSet( const SfxItemSet* pInSet );
 
     void                Start();
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 651604bb3c37..3f18d069f6e4 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -126,7 +126,7 @@ public:
 
 class SvxTransparenceTabPage : public SfxTabPage
 {
-    static const sal_uInt16 pTransparenceRanges[];
+    static const WhichRangesContainer pTransparenceRanges;
 
     const SfxItemSet&   rOutAttrs;
 
@@ -188,7 +188,7 @@ public:
     virtual ~SvxTransparenceTabPage() override;
 
     static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet*);
-    static const sal_uInt16* GetRanges() { return pTransparenceRanges; }
+    static WhichRangesContainer GetRanges() { return pTransparenceRanges; }
 
     virtual bool FillItemSet(SfxItemSet*) override;
     virtual void Reset(const SfxItemSet*) override;
@@ -205,7 +205,7 @@ public:
 
 class SvxAreaTabPage : public SfxTabPage
 {
-    static const sal_uInt16 pAreaRanges[];
+    static const WhichRangesContainer pAreaRanges;
 private:
     std::unique_ptr<SfxTabPage> m_xFillTabPage;
     ButtonBox                  maBox;
@@ -264,7 +264,7 @@ public:
     virtual ~SvxAreaTabPage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16* GetRanges() { return pAreaRanges; }
+    static WhichRangesContainer GetRanges() { return pAreaRanges; }
 
     virtual bool FillItemSet( SfxItemSet* ) override;
     virtual void Reset( const SfxItemSet * ) override;
@@ -290,7 +290,7 @@ public:
 
 class SvxShadowTabPage : public SvxTabPage
 {
-    static const sal_uInt16 pShadowRanges[];
+    static const WhichRangesContainer pShadowRanges;
 
 private:
     const SfxItemSet&   m_rOutAttrs;
@@ -324,7 +324,7 @@ public:
     virtual ~SvxShadowTabPage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16* GetRanges() { return pShadowRanges; }
+    static WhichRangesContainer GetRanges() { return pShadowRanges; }
 
     virtual bool FillItemSet( SfxItemSet* ) override;
     virtual void Reset( const SfxItemSet * ) override;
diff --git a/cui/source/inc/cuitabline.hxx b/cui/source/inc/cuitabline.hxx
index db74b0f65970..704852b187fe 100644
--- a/cui/source/inc/cuitabline.hxx
+++ b/cui/source/inc/cuitabline.hxx
@@ -87,7 +87,7 @@ struct SvxBmpItemInfo
 
 class SvxLineTabPage : public SfxTabPage
 {
-    static const sal_uInt16 pLineRanges[];
+    static const WhichRangesContainer pLineRanges;
 private:
     //#58425# symbols on a line (e. g. StarChart) ->
     /** a list of symbols to be shown in menu. Symbol at position SID_ATTR_SYMBOLTYPE is to be shown in preview.
@@ -206,7 +206,7 @@ public:
     void    Construct();
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16* GetRanges() { return pLineRanges; }
+    static WhichRangesContainer GetRanges() { return pLineRanges; }
 
     virtual bool FillItemSet( SfxItemSet* ) override;
     virtual void Reset( const SfxItemSet* ) override;
diff --git a/cui/source/inc/labdlg.hxx b/cui/source/inc/labdlg.hxx
index 1a5d58a8357f..8146ec388f53 100644
--- a/cui/source/inc/labdlg.hxx
+++ b/cui/source/inc/labdlg.hxx
@@ -34,7 +34,7 @@ const sal_uInt16 CAPTYPE_BITMAPS_COUNT = 3;
 class SvxCaptionTabPage : public SfxTabPage
 {
 private:
-    static const sal_uInt16 pCaptionRanges[];
+    static const WhichRangesContainer pCaptionRanges;
 
     Image           m_aBmpCapTypes[CAPTYPE_BITMAPS_COUNT];
 
@@ -81,7 +81,7 @@ public:
     virtual ~SvxCaptionTabPage() override;
 
     static std::unique_ptr<SfxTabPage>  Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16*  GetRanges() { return pCaptionRanges; }
+    static WhichRangesContainer GetRanges() { return pCaptionRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* ) override;
     virtual void        Reset( const SfxItemSet * ) override;
diff --git a/cui/source/inc/macropg.hxx b/cui/source/inc/macropg.hxx
index 2c1bd1a1259a..f6a6e8a17ae2 100644
--- a/cui/source/inc/macropg.hxx
+++ b/cui/source/inc/macropg.hxx
@@ -101,7 +101,7 @@ public:
 
 // class SvxMacroAssignDlg --------------------------------------------------
 
-typedef const sal_uInt16* (*GetTabPageRanges)(); // gives international Which-values
+typedef WhichRangesContainer (*GetTabPageRanges)(); // gives international Which-values
 
 class SvxMacroAssignSingleTabDialog : public SfxSingleTabDialogController
 {
diff --git a/cui/source/inc/measure.hxx b/cui/source/inc/measure.hxx
index 6a41fb122854..7e18c6485556 100644
--- a/cui/source/inc/measure.hxx
+++ b/cui/source/inc/measure.hxx
@@ -28,7 +28,7 @@ class SdrView;
 class SvxMeasurePage : public SvxTabPage
 {
 private:
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
 
     const SfxItemSet&   rOutAttrs;
     SfxItemSet          aAttrSet;
@@ -70,7 +70,7 @@ public:
     virtual ~SvxMeasurePage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16* GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* ) override;
     virtual void        Reset( const SfxItemSet * ) override;
diff --git a/cui/source/inc/numfmt.hxx b/cui/source/inc/numfmt.hxx
index 7a4fd4605c6b..b4bddde39aaa 100644
--- a/cui/source/inc/numfmt.hxx
+++ b/cui/source/inc/numfmt.hxx
@@ -56,7 +56,7 @@ public:
 
 class SvxNumberFormatTabPage : public SfxTabPage
 {
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
 
 public:
     SvxNumberFormatTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
@@ -64,7 +64,7 @@ public:
                                     const SfxItemSet* rAttrSet );
     virtual ~SvxNumberFormatTabPage() override;
     // Returns area information.
-    static const sal_uInt16* GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool            FillItemSet( SfxItemSet* rSet ) override;
     virtual void            Reset( const SfxItemSet* rSet ) override;
diff --git a/cui/source/inc/optasian.hxx b/cui/source/inc/optasian.hxx
index 6da4646ecc17..9d9815ea49f0 100644
--- a/cui/source/inc/optasian.hxx
+++ b/cui/source/inc/optasian.hxx
@@ -52,7 +52,7 @@ public:
 
     static std::unique_ptr<SfxTabPage>
     Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet);
-    static const sal_uInt16* GetRanges();
+    static WhichRangesContainer GetRanges();
     virtual bool FillItemSet(SfxItemSet* rSet) override;
     virtual void Reset(const SfxItemSet* rSet) override;
 };
diff --git a/cui/source/inc/page.hxx b/cui/source/inc/page.hxx
index f38283c1c61d..02af8079a88c 100644
--- a/cui/source/inc/page.hxx
+++ b/cui/source/inc/page.hxx
@@ -64,7 +64,7 @@ typedef sal_uInt16 MarginPosition;
 
 class SvxPageDescPage : public SfxTabPage
 {
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
 private:
     OUString            sStandardRegister;
     tools::Long                nFirstLeftMargin;
@@ -174,7 +174,7 @@ public:
     virtual ~SvxPageDescPage() override;
 
     // returns the range of the Which values
-    static const sal_uInt16* GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* rOutSet ) override;
     virtual void        Reset( const SfxItemSet* rSet ) override;
diff --git a/cui/source/inc/paragrph.hxx b/cui/source/inc/paragrph.hxx
index a187bba92787..73cc5faf32cd 100644
--- a/cui/source/inc/paragrph.hxx
+++ b/cui/source/inc/paragrph.hxx
@@ -40,7 +40,7 @@ class SvxLineSpacingItem;
 
 class SvxStdParagraphTabPage: public SfxTabPage
 {
-    static const sal_uInt16 pStdRanges[];
+    static const WhichRangesContainer pStdRanges;
 
 private:
     tools::Long                    nWidth;
@@ -102,7 +102,7 @@ public:
 
     DECL_LINK(ELRLoseFocusHdl, weld::MetricSpinButton&, void);
 
-    static const sal_uInt16* GetRanges() { return pStdRanges; }
+    static WhichRangesContainer GetRanges() { return pStdRanges; }
 
     virtual bool            FillItemSet( SfxItemSet* rSet ) override;
     virtual void            Reset( const SfxItemSet* rSet ) override;
@@ -121,7 +121,7 @@ public:
 
 class SvxParaAlignTabPage : public SfxTabPage
 {
-    static const sal_uInt16 pAlignRanges[];
+    static const WhichRangesContainer pAlignRanges;
 
     SvxParaPrevWindow m_aExampleWin;
 
@@ -163,7 +163,7 @@ public:
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
     virtual ~SvxParaAlignTabPage() override;
 
-    static const sal_uInt16* GetRanges() { return pAlignRanges; }
+    static WhichRangesContainer GetRanges() { return pAlignRanges; }
 
     virtual bool            FillItemSet( SfxItemSet* rSet ) override;
     virtual void            Reset( const SfxItemSet* rSet ) override;
@@ -189,7 +189,7 @@ public:
 
 class SvxExtParagraphTabPage: public SfxTabPage
 {
-    static const sal_uInt16 pExtRanges[];
+    static const WhichRangesContainer pExtRanges;
 
 public:
     SvxExtParagraphTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
@@ -197,7 +197,7 @@ public:
                                 const SfxItemSet* rSet );
     virtual ~SvxExtParagraphTabPage() override;
 
-    static const sal_uInt16* GetRanges() { return pExtRanges; }
+    static WhichRangesContainer GetRanges() { return pExtRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
     virtual void        Reset( const SfxItemSet* rSet ) override;
@@ -289,7 +289,7 @@ public:
     static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet);
     virtual ~SvxAsianTabPage() override;
 
-    static const sal_uInt16*      GetRanges();
+    static WhichRangesContainer GetRanges();
 
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
     virtual void        Reset( const SfxItemSet* rSet ) override;
diff --git a/cui/source/inc/postdlg.hxx b/cui/source/inc/postdlg.hxx
index b294fbcc77df..66fd07af6255 100644
--- a/cui/source/inc/postdlg.hxx
+++ b/cui/source/inc/postdlg.hxx
@@ -44,7 +44,7 @@ public:
                     bool bPrevNext);
     virtual ~SvxPostItDialog() override;
 
-    static const sal_uInt16*      GetRanges();
+    static WhichRangesContainer GetRanges();
     const SfxItemSet*   GetOutputItemSet() const { return m_xOutSet.get(); }
 
     void                SetPrevHdl( const Link<SvxPostItDialog&,void>& rLink )
diff --git a/cui/source/inc/srchxtra.hxx b/cui/source/inc/srchxtra.hxx
index 4da71f3c9601..e95fccd413fd 100644
--- a/cui/source/inc/srchxtra.hxx
+++ b/cui/source/inc/srchxtra.hxx
@@ -42,7 +42,7 @@ class SvxSearchAttributeDialog : public weld::GenericDialogController
 {
 public:
     SvxSearchAttributeDialog(weld::Window* pParent, SearchAttrItemList& rLst,
-                             const sal_uInt16* pWhRanges);
+                             const WhichRangesContainer& pWhRanges);
     virtual ~SvxSearchAttributeDialog() override;
 
 private:
diff --git a/cui/source/inc/swpossizetabpage.hxx b/cui/source/inc/swpossizetabpage.hxx
index 18e48481a3ce..eb73196986bf 100644
--- a/cui/source/inc/swpossizetabpage.hxx
+++ b/cui/source/inc/swpossizetabpage.hxx
@@ -112,7 +112,7 @@ public:
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
     virtual ~SvxSwPosSizeTabPage() override;
 
-    static const sal_uInt16*     GetRanges();
+    static WhichRangesContainer GetRanges();
 
     virtual bool FillItemSet( SfxItemSet* ) override;
     virtual void Reset( const SfxItemSet * ) override;
diff --git a/cui/source/inc/tabstpge.hxx b/cui/source/inc/tabstpge.hxx
index ddd7775b24da..207b8b70503d 100644
--- a/cui/source/inc/tabstpge.hxx
+++ b/cui/source/inc/tabstpge.hxx
@@ -58,14 +58,14 @@ public:
 
 class SvxTabulatorTabPage : public SfxTabPage
 {
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
 
 public:
     SvxTabulatorTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
     virtual ~SvxTabulatorTabPage() override;
 
-    static const sal_uInt16* GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
     virtual void        Reset( const SfxItemSet* rSet ) override;
diff --git a/cui/source/inc/textanim.hxx b/cui/source/inc/textanim.hxx
index 4f7785887a6c..8f4767e22fe8 100644
--- a/cui/source/inc/textanim.hxx
+++ b/cui/source/inc/textanim.hxx
@@ -34,7 +34,7 @@ class SdrView;
 class SvxTextAnimationPage : public SfxTabPage
 {
 private:
-    static const sal_uInt16     pRanges[];
+    static const WhichRangesContainer     pRanges;
 
     SdrTextAniKind      eAniKind;
     FieldUnit           eFUnit;
@@ -80,7 +80,7 @@ public:
     virtual ~SvxTextAnimationPage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16* GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* ) override;
     virtual void        Reset( const SfxItemSet * ) override;
diff --git a/cui/source/inc/textattr.hxx b/cui/source/inc/textattr.hxx
index fe00b6302c3f..d48e87b7d759 100644
--- a/cui/source/inc/textattr.hxx
+++ b/cui/source/inc/textattr.hxx
@@ -32,7 +32,7 @@ class SdrView;
 class SvxTextAttrPage : public SvxTabPage
 {
 private:
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
 
     const SfxItemSet&   rOutAttrs;
     SdrObjKind    m_eObjKind;
@@ -77,7 +77,7 @@ public:
     virtual ~SvxTextAttrPage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16*  GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
 
     virtual bool        FillItemSet( SfxItemSet* ) override;
     virtual void        Reset( const SfxItemSet * ) override;
diff --git a/cui/source/inc/transfrm.hxx b/cui/source/inc/transfrm.hxx
index f3a6ba0a0e21..30b789dc73c4 100644
--- a/cui/source/inc/transfrm.hxx
+++ b/cui/source/inc/transfrm.hxx
@@ -60,7 +60,7 @@ public:
 
 class SvxPositionSizeTabPage : public SvxTabPage
 {
-    static const sal_uInt16 pPosSizeRanges[];
+    static const WhichRangesContainer pPosSizeRanges;
 
 private:
     const SfxItemSet&   mrOutAttrs;
@@ -132,7 +132,7 @@ public:
     virtual ~SvxPositionSizeTabPage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16* GetRanges() {  return pPosSizeRanges; }
+    static WhichRangesContainer GetRanges() {  return pPosSizeRanges; }
 
     virtual bool FillItemSet( SfxItemSet* ) override;
     virtual void Reset( const SfxItemSet * ) override;
@@ -160,7 +160,7 @@ public:
 \************************************************************************/
 class SvxAngleTabPage : public SvxTabPage
 {
-    static const sal_uInt16 pAngleRanges[];
+    static const WhichRangesContainer pAngleRanges;
 
 private:
     const SdrView*      pView;
@@ -188,7 +188,7 @@ public:
     virtual ~SvxAngleTabPage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16*  GetRanges() { return pAngleRanges; }
+    static WhichRangesContainer GetRanges() { return pAngleRanges; }
 
     virtual bool FillItemSet( SfxItemSet* ) override;
     virtual void Reset( const SfxItemSet * ) override;
@@ -209,7 +209,7 @@ public:
 \************************************************************************/
 class SvxSlantTabPage : public SfxTabPage
 {
-    static const sal_uInt16 pSlantRanges[];
+    static const WhichRangesContainer pSlantRanges;
 
 private:
     const SdrView*      pView;
@@ -232,7 +232,7 @@ public:
     virtual ~SvxSlantTabPage() override;
 
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* );
-    static const sal_uInt16* GetRanges() {  return pSlantRanges; }
+    static WhichRangesContainer GetRanges() {  return pSlantRanges; }
 
     virtual bool FillItemSet( SfxItemSet* ) override;
     virtual void Reset( const SfxItemSet * ) override;
diff --git a/cui/source/options/optasian.cxx b/cui/source/options/optasian.cxx
index a5294c0b4b70..94a192cfddc7 100644
--- a/cui/source/options/optasian.cxx
+++ b/cui/source/options/optasian.cxx
@@ -375,11 +375,10 @@ IMPL_LINK(SvxAsianLayoutPage, ModifyHdl, weld::Entry&, rEdit, void)
     pImpl->aConfig.SetStartEndChars( aLocale, bEnable ? &sStart : nullptr, bEnable ? &sEnd : nullptr);
 }
 
-const sal_uInt16* SvxAsianLayoutPage::GetRanges()
+WhichRangesContainer SvxAsianLayoutPage::GetRanges()
 {
     //no items are used
-    static const sal_uInt16 pAsianLayoutRanges[] = { 0 };
-    return pAsianLayoutRanges;
+    return WhichRangesContainer();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/tabpages/TextColumnsPage.cxx b/cui/source/tabpages/TextColumnsPage.cxx
index db83722e6be1..9c5c27404f3d 100644
--- a/cui/source/tabpages/TextColumnsPage.cxx
+++ b/cui/source/tabpages/TextColumnsPage.cxx
@@ -16,8 +16,8 @@
 
 #include <TextColumnsPage.hxx>
 
-const sal_uInt16 SvxTextColumnsPage::pRanges[]
-    = { SDRATTR_TEXTCOLUMNS_FIRST, SDRATTR_TEXTCOLUMNS_LAST, 0 };
+const WhichRangesContainer SvxTextColumnsPage::pRanges(
+    svl::Items<SDRATTR_TEXTCOLUMNS_FIRST, SDRATTR_TEXTCOLUMNS_LAST>::value);
 
 SvxTextColumnsPage::SvxTextColumnsPage(weld::Container* pPage, weld::DialogController* pController,
                                        const SfxItemSet& rInAttrs)
diff --git a/cui/source/tabpages/align.cxx b/cui/source/tabpages/align.cxx
index 5937a2b28995..b178630ab61e 100644
--- a/cui/source/tabpages/align.cxx
+++ b/cui/source/tabpages/align.cxx
@@ -39,19 +39,17 @@
 
 namespace svx {
 
-const sal_uInt16 AlignmentTabPage::s_pRanges[] =
-{
-    SID_ATTR_ALIGN_HOR_JUSTIFY,SID_ATTR_ALIGN_VER_JUSTIFY,
-    SID_ATTR_ALIGN_STACKED,SID_ATTR_ALIGN_LINEBREAK,
-    SID_ATTR_ALIGN_INDENT,SID_ATTR_ALIGN_INDENT,
-    SID_ATTR_ALIGN_DEGREES,SID_ATTR_ALIGN_DEGREES,
-    SID_ATTR_ALIGN_LOCKPOS,SID_ATTR_ALIGN_LOCKPOS,
-    SID_ATTR_ALIGN_HYPHENATION,SID_ATTR_ALIGN_HYPHENATION,
-    SID_ATTR_ALIGN_ASIANVERTICAL,SID_ATTR_ALIGN_ASIANVERTICAL,
-    SID_ATTR_FRAMEDIRECTION,SID_ATTR_FRAMEDIRECTION,
-    SID_ATTR_ALIGN_SHRINKTOFIT,SID_ATTR_ALIGN_SHRINKTOFIT,
-    0
-};
+const WhichRangesContainer AlignmentTabPage::s_pRanges(
+    svl::Items<
+    SID_ATTR_ALIGN_HOR_JUSTIFY, SID_ATTR_ALIGN_VER_JUSTIFY,
+    SID_ATTR_ALIGN_STACKED, SID_ATTR_ALIGN_LINEBREAK,
+    SID_ATTR_ALIGN_INDENT, SID_ATTR_ALIGN_INDENT,
+    SID_ATTR_ALIGN_DEGREES, SID_ATTR_ALIGN_DEGREES,
+    SID_ATTR_ALIGN_LOCKPOS, SID_ATTR_ALIGN_LOCKPOS,
+    SID_ATTR_ALIGN_HYPHENATION, SID_ATTR_ALIGN_HYPHENATION,
+    SID_ATTR_ALIGN_ASIANVERTICAL, SID_ATTR_ALIGN_ASIANVERTICAL,
+    SID_ATTR_FRAMEDIRECTION, SID_ATTR_FRAMEDIRECTION,
+    SID_ATTR_ALIGN_SHRINKTOFIT, SID_ATTR_ALIGN_SHRINKTOFIT>::value);
 
 
 namespace {
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 3aac1fae51a7..229891a082fc 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -36,12 +36,10 @@ using namespace css;
 #define TBL_DEST_ROW    1
 #define TBL_DEST_TBL    2
 
-const sal_uInt16 SvxBkgTabPage::pPageRanges[] =
-{
+const WhichRangesContainer SvxBkgTabPage::pPageRanges(svl::Items<
     SID_ATTR_BRUSH, SID_ATTR_BRUSH,
-    SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR,
-    0
-};
+    SID_ATTR_BRUSH_CHAR, SID_ATTR_BRUSH_CHAR
+>::value);
 
 static sal_uInt16 lcl_GetTableDestSlot(sal_Int32 nTblDest)
 {
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index cad792327f74..430cc4e55295 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -69,15 +69,13 @@ using ::com::sun::star::uno::UNO_QUERY;
 
 // static ----------------------------------------------------------------
 
-const sal_uInt16 SvxBorderTabPage::pRanges[] =
-{
-    SID_ATTR_BORDER_INNER,      SID_ATTR_BORDER_SHADOW,
-    SID_ATTR_ALIGN_MARGIN,      SID_ATTR_ALIGN_MARGIN,
-    SID_ATTR_BORDER_CONNECT,    SID_ATTR_BORDER_CONNECT,
-    SID_SW_COLLAPSING_BORDERS,  SID_SW_COLLAPSING_BORDERS,
-    SID_ATTR_BORDER_DIAG_TLBR,  SID_ATTR_BORDER_DIAG_BLTR,
-    0
-};
+const WhichRangesContainer SvxBorderTabPage::pRanges(
+    svl::Items<
+        SID_ATTR_BORDER_INNER,      SID_ATTR_BORDER_SHADOW,
+        SID_ATTR_ALIGN_MARGIN,      SID_ATTR_ALIGN_MARGIN,
+        SID_ATTR_BORDER_CONNECT,    SID_ATTR_BORDER_CONNECT,
+        SID_SW_COLLAPSING_BORDERS,  SID_SW_COLLAPSING_BORDERS,
+        SID_ATTR_BORDER_DIAG_TLBR,  SID_ATTR_BORDER_DIAG_BLTR>::value);
 
 static void lcl_SetDecimalDigitsTo1(weld::MetricSpinButton& rField)
 {
diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx
index a4cc33265a18..0bb9460745dd 100644
--- a/cui/source/tabpages/chardlg.cxx
+++ b/cui/source/tabpages/chardlg.cxx
@@ -65,65 +65,37 @@ using namespace ::com::sun::star;
 
 // static ----------------------------------------------------------------
 
-const sal_uInt16 SvxCharNamePage::pNameRanges[] =
-{
-    SID_ATTR_CHAR_FONT,
-    SID_ATTR_CHAR_WEIGHT,
-    SID_ATTR_CHAR_FONTHEIGHT,
-    SID_ATTR_CHAR_FONTHEIGHT,
-    SID_ATTR_CHAR_COLOR,
-    SID_ATTR_CHAR_COLOR,
-    SID_ATTR_CHAR_LANGUAGE,
-    SID_ATTR_CHAR_LANGUAGE,
-    SID_ATTR_CHAR_CJK_FONT,
-    SID_ATTR_CHAR_CJK_WEIGHT,
-    SID_ATTR_CHAR_CTL_FONT,
-    SID_ATTR_CHAR_CTL_WEIGHT,
-    0
-};
-
-const sal_uInt16 SvxCharEffectsPage::pEffectsRanges[] =
-{
-    SID_ATTR_CHAR_SHADOWED,
-    SID_ATTR_CHAR_UNDERLINE,
-    SID_ATTR_CHAR_COLOR,
-    SID_ATTR_CHAR_COLOR,
-    SID_ATTR_CHAR_CASEMAP,
-    SID_ATTR_CHAR_CASEMAP,
-    SID_ATTR_FLASH,
-    SID_ATTR_FLASH,
-    SID_ATTR_CHAR_EMPHASISMARK,
-    SID_ATTR_CHAR_EMPHASISMARK,
-    SID_ATTR_CHAR_RELIEF,
-    SID_ATTR_CHAR_RELIEF,
-    SID_ATTR_CHAR_HIDDEN,
-    SID_ATTR_CHAR_HIDDEN,
-    SID_ATTR_CHAR_OVERLINE,
-    SID_ATTR_CHAR_OVERLINE,
-    0
-};
-
-const sal_uInt16 SvxCharPositionPage::pPositionRanges[] =
-{
-    SID_ATTR_CHAR_KERNING,
-    SID_ATTR_CHAR_KERNING,
-    SID_ATTR_CHAR_ESCAPEMENT,
-    SID_ATTR_CHAR_ESCAPEMENT,
-    SID_ATTR_CHAR_AUTOKERN,
-    SID_ATTR_CHAR_AUTOKERN,
-    SID_ATTR_CHAR_ROTATED,
-    SID_ATTR_CHAR_SCALEWIDTH,
-    SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
-    SID_ATTR_CHAR_WIDTH_FIT_TO_LINE,
-    0
-};
-
-const sal_uInt16 SvxCharTwoLinesPage::pTwoLinesRanges[] =
-{
-    SID_ATTR_CHAR_TWO_LINES,
-    SID_ATTR_CHAR_TWO_LINES,
-    0
-};
+const WhichRangesContainer SvxCharNamePage::pNameRanges(svl::Items<
+    SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_WEIGHT,
+    SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_FONTHEIGHT,
+    SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_COLOR,
+    SID_ATTR_CHAR_LANGUAGE, SID_ATTR_CHAR_LANGUAGE,
+    SID_ATTR_CHAR_CJK_FONT, SID_ATTR_CHAR_CJK_WEIGHT,
+    SID_ATTR_CHAR_CTL_FONT, SID_ATTR_CHAR_CTL_WEIGHT
+>::value);
+
+const WhichRangesContainer SvxCharEffectsPage::pEffectsRanges(svl::Items<
+    SID_ATTR_CHAR_SHADOWED, SID_ATTR_CHAR_UNDERLINE,
+    SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_COLOR,
+    SID_ATTR_CHAR_CASEMAP, SID_ATTR_CHAR_CASEMAP,
+    SID_ATTR_FLASH, SID_ATTR_FLASH,
+    SID_ATTR_CHAR_EMPHASISMARK, SID_ATTR_CHAR_EMPHASISMARK,
+    SID_ATTR_CHAR_RELIEF, SID_ATTR_CHAR_RELIEF,
+    SID_ATTR_CHAR_HIDDEN, SID_ATTR_CHAR_HIDDEN,
+    SID_ATTR_CHAR_OVERLINE, SID_ATTR_CHAR_OVERLINE
+>::value);
+
+const WhichRangesContainer SvxCharPositionPage::pPositionRanges(svl::Items<
+    SID_ATTR_CHAR_KERNING, SID_ATTR_CHAR_KERNING,
+    SID_ATTR_CHAR_ESCAPEMENT, SID_ATTR_CHAR_ESCAPEMENT,
+    SID_ATTR_CHAR_AUTOKERN, SID_ATTR_CHAR_AUTOKERN,
+    SID_ATTR_CHAR_ROTATED, SID_ATTR_CHAR_SCALEWIDTH,
+    SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
+>::value);
+
+const WhichRangesContainer SvxCharTwoLinesPage::pTwoLinesRanges(svl::Items<
+    SID_ATTR_CHAR_TWO_LINES, SID_ATTR_CHAR_TWO_LINES
+>::value);
 
 // C-Function ------------------------------------------------------------
 
diff --git a/cui/source/tabpages/connect.cxx b/cui/source/tabpages/connect.cxx
index 70b38bbc95af..ffe14bea9754 100644
--- a/cui/source/tabpages/connect.cxx
+++ b/cui/source/tabpages/connect.cxx
@@ -33,12 +33,8 @@
 
 #include <connect.hxx>
 
-const sal_uInt16 SvxConnectionPage::pRanges[] =
-{
-    SDRATTR_EDGE_FIRST,
-    SDRATTR_EDGE_LAST,
-    0
-};
+const WhichRangesContainer SvxConnectionPage::pRanges(
+    svl::Items<SDRATTR_EDGE_FIRST, SDRATTR_EDGE_LAST>::value);
 
 /*************************************************************************
 |*
diff --git a/cui/source/tabpages/labdlg.cxx b/cui/source/tabpages/labdlg.cxx
index c230797d9c4a..a9af513ba3f5 100644
--- a/cui/source/tabpages/labdlg.cxx
+++ b/cui/source/tabpages/labdlg.cxx
@@ -49,20 +49,13 @@
 
 // static ----------------------------------------------------------------
 
-const sal_uInt16 SvxCaptionTabPage::pCaptionRanges[] =
-{
-    SDRATTR_CAPTIONTYPE,
-    SDRATTR_CAPTIONFIXEDANGLE,
-    SDRATTR_CAPTIONANGLE,
-    SDRATTR_CAPTIONGAP,
-    SDRATTR_CAPTIONESCDIR,
-    SDRATTR_CAPTIONESCISREL,
-    SDRATTR_CAPTIONESCREL,
-    SDRATTR_CAPTIONESCABS,
-    SDRATTR_CAPTIONLINELEN,
-    SDRATTR_CAPTIONFITLINELEN,
-    0
-};
+const WhichRangesContainer SvxCaptionTabPage::pCaptionRanges(
+    svl::Items<
+    SDRATTR_CAPTIONTYPE, SDRATTR_CAPTIONFIXEDANGLE,
+    SDRATTR_CAPTIONANGLE, SDRATTR_CAPTIONGAP,
+    SDRATTR_CAPTIONESCDIR, SDRATTR_CAPTIONESCISREL,
+    SDRATTR_CAPTIONESCREL, SDRATTR_CAPTIONESCABS,
+    SDRATTR_CAPTIONLINELEN, SDRATTR_CAPTIONFITLINELEN>::value);
 
 SvxCaptionTabPage::SvxCaptionTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs)
     : SfxTabPage(pPage, pController, "cui/ui/calloutpage.ui", "CalloutPage", &rInAttrs)
diff --git a/cui/source/tabpages/measure.cxx b/cui/source/tabpages/measure.cxx
index a543ebc07b01..c27f904ef970 100644
--- a/cui/source/tabpages/measure.cxx
+++ b/cui/source/tabpages/measure.cxx
@@ -36,12 +36,8 @@
 
 #include <measure.hxx>
 
-const sal_uInt16 SvxMeasurePage::pRanges[] =
-{
-    SDRATTR_MEASURE_FIRST,
-    SDRATTR_MEASURE_LAST,
-    0
-};
+const WhichRangesContainer SvxMeasurePage::pRanges(
+    svl::Items<SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST>::value);
 
 /*************************************************************************
 |*
diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index de987adb754d..6f889f747517 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -54,18 +54,12 @@ using ::com::sun::star::uno::UNO_QUERY;
 
 // static ----------------------------------------------------------------
 
-const sal_uInt16 SvxNumberFormatTabPage::pRanges[] =
-{
-    SID_ATTR_NUMBERFORMAT_VALUE,
-    SID_ATTR_NUMBERFORMAT_INFO,
-    SID_ATTR_NUMBERFORMAT_NOLANGUAGE,
-    SID_ATTR_NUMBERFORMAT_NOLANGUAGE,
-    SID_ATTR_NUMBERFORMAT_ONE_AREA,
-    SID_ATTR_NUMBERFORMAT_ONE_AREA,
-    SID_ATTR_NUMBERFORMAT_SOURCE,
-    SID_ATTR_NUMBERFORMAT_SOURCE,
-    0
-};
+const WhichRangesContainer SvxNumberFormatTabPage::pRanges(
+    svl::Items<
+    SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO,
+    SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE,
+    SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA,
+    SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE>::value);
 
 /*************************************************************************
 #*  Method:        SvxNumberPreview
diff --git a/cui/source/tabpages/page.cxx b/cui/source/tabpages/page.cxx
index d7bc0cc6a9d7..84e3b38af282 100644
--- a/cui/source/tabpages/page.cxx
+++ b/cui/source/tabpages/page.cxx
@@ -60,16 +60,11 @@
 // #i19922# - tdf#126051 see svx/source/dialog/hdft.cxx and sw/source/uibase/sidebar/PageMarginControl.hxx
 const tools::Long MINBODY = 56;  // 1mm in twips rounded
 
-const sal_uInt16 SvxPageDescPage::pRanges[] =
-{
-    SID_ATTR_BORDER_OUTER,
-    SID_ATTR_BORDER_SHADOW,
-    SID_ATTR_LRSPACE,
-    SID_ATTR_PAGE_SHARED,
-    SID_SWREGISTER_COLLECTION,
-    SID_SWREGISTER_MODE,
-    0
-};
+const WhichRangesContainer SvxPageDescPage::pRanges(
+    svl::Items<
+    SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_SHADOW,
+    SID_ATTR_LRSPACE, SID_ATTR_PAGE_SHARED,
+    SID_SWREGISTER_COLLECTION, SID_SWREGISTER_MODE>::value);
 // ------- Mapping page layout ------------------------------------------
 
 const SvxPageUsage aArr[] =
@@ -1287,7 +1282,7 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet )
             {
                 // aBspWin.SetHdColor(rItem.GetColor());
                 const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(rHeaderSet.Get(nWhich));
-                SfxItemSet aTempSet(*rHeaderSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
+                SfxItemSet aTempSet(*rHeaderSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>::value);
 
                 setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
                 aHeaderFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(aTempSet);
@@ -1342,7 +1337,7 @@ void SvxPageDescPage::InitHeadFoot_Impl( const SfxItemSet& rSet )
         {
             // aBspWin.SetFtColor(rItem.GetColor());
             const SvxBrushItem& rItem = static_cast<const SvxBrushItem&>(rFooterSet.Get(nWhich));
-            SfxItemSet aTempSet(*rFooterSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
+            SfxItemSet aTempSet(*rFooterSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>::value);
 
             setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet);
             aFooterFillAttributes = std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>(aTempSet);
diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx
index 83613a78938a..8b3a14f0d38f 100644
--- a/cui/source/tabpages/paragrph.cxx
+++ b/cui/source/tabpages/paragrph.cxx
@@ -51,32 +51,20 @@
 #include <svl/eitem.hxx>
 #include <svl/intitem.hxx>
 
-const sal_uInt16 SvxStdParagraphTabPage::pStdRanges[] =
-{
-    SID_ATTR_PARA_LINESPACE,        // 10033
-    SID_ATTR_PARA_LINESPACE,
-    SID_ATTR_LRSPACE,               // 10048 -
-    SID_ATTR_ULSPACE,               // 10049
-    SID_ATTR_PARA_REGISTER,         // 10413
-    SID_ATTR_PARA_REGISTER,
-    0
-};
+const WhichRangesContainer SvxStdParagraphTabPage::pStdRanges(
+    svl::Items<
+    SID_ATTR_PARA_LINESPACE, SID_ATTR_PARA_LINESPACE, // 10033
+    SID_ATTR_LRSPACE, SID_ATTR_ULSPACE,              // 10048 - 10049
+    SID_ATTR_PARA_REGISTER, SID_ATTR_PARA_REGISTER  // 10413
+    >::value);
 
-const sal_uInt16 SvxParaAlignTabPage::pAlignRanges[] =
-{
-    SID_ATTR_PARA_ADJUST,           // 10027
-    SID_ATTR_PARA_ADJUST,
-    0
-};
+const WhichRangesContainer SvxParaAlignTabPage::pAlignRanges(
+    svl::Items<SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_ADJUST>::value);  // 10027
 
-const sal_uInt16 SvxExtParagraphTabPage::pExtRanges[] =
-{
-    SID_ATTR_PARA_PAGEBREAK,        // 10037 -
-    SID_ATTR_PARA_WIDOWS,           // 10041
-    SID_ATTR_PARA_MODEL,            // 10065 -
-    SID_ATTR_PARA_KEEP,             // 10066
-    0
-};
+const WhichRangesContainer SvxExtParagraphTabPage::pExtRanges(svl::Items<
+    SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS, // 10037 - 10041
+    SID_ATTR_PARA_MODEL, SID_ATTR_PARA_KEEP        // 10065 - 10066
+>::value);
 
 #define MAX_DURCH 5670      // 10 cm makes sense as maximum interline lead
                             // according to BP
@@ -2229,14 +2217,9 @@ std::unique_ptr<SfxTabPage> SvxAsianTabPage::Create(weld::Container* pPage, weld
     return std::make_unique<SvxAsianTabPage>(pPage, pController, *rSet);
 }
 
-const sal_uInt16*     SvxAsianTabPage::GetRanges()
+WhichRangesContainer SvxAsianTabPage::GetRanges()
 {
-    static const sal_uInt16 pRanges[] =
-    {
-        SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES,
-        0
-    };
-    return pRanges;
+    return WhichRangesContainer(svl::Items<SID_ATTR_PARA_SCRIPTSPACE, SID_ATTR_PARA_FORBIDDEN_RULES>::value);
 }
 
 bool SvxAsianTabPage::FillItemSet( SfxItemSet* rSet )
diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx
index 564976c7fb8b..ac9a0da25866 100644
--- a/cui/source/tabpages/swpossizetabpage.cxx
+++ b/cui/source/tabpages/swpossizetabpage.cxx
@@ -719,33 +719,21 @@ std::unique_ptr<SfxTabPage> SvxSwPosSizeTabPage::Create(weld::Container* pPage,
     return std::make_unique<SvxSwPosSizeTabPage>(pPage, pController, *rSet);
 }
 
-const sal_uInt16* SvxSwPosSizeTabPage::GetRanges()
+WhichRangesContainer SvxSwPosSizeTabPage::GetRanges()
 {
-    static const sal_uInt16 pSwPosRanges[] =
-    {
-        SID_ATTR_TRANSFORM_POS_X,
-        SID_ATTR_TRANSFORM_POS_Y,
-        SID_ATTR_TRANSFORM_PROTECT_POS,
-        SID_ATTR_TRANSFORM_PROTECT_POS,
-        SID_ATTR_TRANSFORM_INTERN,
-        SID_ATTR_TRANSFORM_INTERN,
-        SID_ATTR_TRANSFORM_ANCHOR,
-        SID_ATTR_TRANSFORM_VERT_ORIENT,
-        SID_ATTR_TRANSFORM_WIDTH,
-        SID_ATTR_TRANSFORM_SIZE_POINT,
-        SID_ATTR_TRANSFORM_PROTECT_POS,
-        SID_ATTR_TRANSFORM_INTERN,
-        SID_ATTR_TRANSFORM_AUTOWIDTH,
-        SID_ATTR_TRANSFORM_VERT_ORIENT,
-        SID_HTML_MODE,
-        SID_HTML_MODE,
-        SID_SW_FOLLOW_TEXT_FLOW,
-        SID_SW_FOLLOW_TEXT_FLOW,
-        SID_ATTR_TRANSFORM_HORI_POSITION,
-        SID_ATTR_TRANSFORM_VERT_POSITION,
-        0
-    };
-    return pSwPosRanges;
+    static const WhichRangesContainer ranges(svl::Items<
+        SID_ATTR_TRANSFORM_POS_X, SID_ATTR_TRANSFORM_POS_Y,
+        SID_ATTR_TRANSFORM_PROTECT_POS, SID_ATTR_TRANSFORM_PROTECT_POS,
+        SID_ATTR_TRANSFORM_INTERN, SID_ATTR_TRANSFORM_INTERN,
+        SID_ATTR_TRANSFORM_ANCHOR, SID_ATTR_TRANSFORM_VERT_ORIENT,
+        SID_ATTR_TRANSFORM_WIDTH, SID_ATTR_TRANSFORM_SIZE_POINT,
+        SID_ATTR_TRANSFORM_PROTECT_POS, SID_ATTR_TRANSFORM_INTERN,
+        SID_ATTR_TRANSFORM_AUTOWIDTH, SID_ATTR_TRANSFORM_VERT_ORIENT,
+        SID_HTML_MODE, SID_HTML_MODE,
+        SID_SW_FOLLOW_TEXT_FLOW, SID_SW_FOLLOW_TEXT_FLOW,
+        SID_ATTR_TRANSFORM_HORI_POSITION, SID_ATTR_TRANSFORM_VERT_POSITION
+    >::value);
+    return ranges;
 }
 
 bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet)
diff --git a/cui/source/tabpages/tabstpge.cxx b/cui/source/tabpages/tabstpge.cxx
index 712a88e86a7e..bfc1feb108f6 100644
--- a/cui/source/tabpages/tabstpge.cxx
+++ b/cui/source/tabpages/tabstpge.cxx
@@ -32,12 +32,8 @@
 
 constexpr FieldUnit eDefUnit = FieldUnit::MM_100TH;
 
-const sal_uInt16 SvxTabulatorTabPage::pRanges[] =
-{
-    SID_ATTR_TABSTOP,
-    SID_ATTR_TABSTOP_OFFSET,
-    0
-};
+const WhichRangesContainer SvxTabulatorTabPage::pRanges(
+    svl::Items<SID_ATTR_TABSTOP, SID_ATTR_TABSTOP_OFFSET>::value);
 
 static void FillUpWithDefTabs_Impl( tools::Long nDefDist, SvxTabStopItem& rTabs )
 {
diff --git a/cui/source/tabpages/textanim.cxx b/cui/source/tabpages/textanim.cxx
index 43b69d77afd6..4adce8ed9d4a 100644
--- a/cui/source/tabpages/textanim.cxx
+++ b/cui/source/tabpages/textanim.cxx
@@ -29,12 +29,8 @@
 #include <svx/sdtayitm.hxx>
 #include <svtools/unitconv.hxx>
 
-const sal_uInt16 SvxTextAnimationPage::pRanges[] =
-{
-    SDRATTR_TEXT_ANIKIND,
-    SDRATTR_TEXT_ANIAMOUNT,
-    0
-};
+const WhichRangesContainer SvxTextAnimationPage::pRanges(
+    svl::Items<SDRATTR_TEXT_ANIKIND, SDRATTR_TEXT_ANIAMOUNT>::value);
 
 /*************************************************************************
 |*
diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx
index 2e2c42bfa540..3abf4fe0d65c 100644
--- a/cui/source/tabpages/textattr.cxx
+++ b/cui/source/tabpages/textattr.cxx
@@ -35,14 +35,11 @@
 
 using namespace ::com::sun::star;
 
-const sal_uInt16 SvxTextAttrPage::pRanges[] =
-{
-      SDRATTR_MISC_FIRST
-    , SDRATTR_TEXT_HORZADJUST
-    , SDRATTR_TEXT_WORDWRAP
-    , SDRATTR_TEXT_WORDWRAP
-    , 0
-};
+const WhichRangesContainer SvxTextAttrPage::pRanges(
+    svl::Items<
+      SDRATTR_MISC_FIRST ,SDRATTR_TEXT_HORZADJUST,
+      SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_WORDWRAP
+>::value);
 
 /*************************************************************************
 |*
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index fe751bc37436..bcc77512ebd7 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -46,14 +46,10 @@ enum FillType
 
 }
 
-const sal_uInt16 SvxAreaTabPage::pAreaRanges[] =
-{
-    XATTR_GRADIENTSTEPCOUNT,
-    XATTR_GRADIENTSTEPCOUNT,
-    SID_ATTR_FILL_STYLE,
-    SID_ATTR_FILL_BITMAP,
-    0
-};
+const WhichRangesContainer SvxAreaTabPage::pAreaRanges(
+    svl::Items<
+    XATTR_GRADIENTSTEPCOUNT, XATTR_GRADIENTSTEPCOUNT,
+    SID_ATTR_FILL_STYLE, SID_ATTR_FILL_BITMAP>::value);
 
 namespace
 {
diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx
index 609946a0287d..e996c65a8580 100644
--- a/cui/source/tabpages/tpline.cxx
+++ b/cui/source/tabpages/tpline.cxx
@@ -71,14 +71,10 @@ using namespace com::sun::star;
 
 // static ----------------------------------------------------------------
 
-const sal_uInt16 SvxLineTabPage::pLineRanges[] =
-{
-    XATTR_LINETRANSPARENCE,
-    XATTR_LINETRANSPARENCE,
-    SID_ATTR_LINE_STYLE,
-    SID_ATTR_LINE_ENDCENTER,
-    0
-};
+const WhichRangesContainer SvxLineTabPage::pLineRanges(svl::Items<
+    XATTR_LINETRANSPARENCE, XATTR_LINETRANSPARENCE,
+    SID_ATTR_LINE_STYLE, SID_ATTR_LINE_ENDCENTER
+>::value);
 
 SvxLineTabPage::SvxLineTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs)
     : SfxTabPage(pPage, pController, "cui/ui/linetabpage.ui", "LineTabPage", &rInAttrs)
diff --git a/cui/source/tabpages/tpshadow.cxx b/cui/source/tabpages/tpshadow.cxx
index cca27ae0edb1..8e0c86eaea59 100644
--- a/cui/source/tabpages/tpshadow.cxx
+++ b/cui/source/tabpages/tpshadow.cxx
@@ -41,18 +41,12 @@
 
 using namespace com::sun::star;
 
-const sal_uInt16 SvxShadowTabPage::pShadowRanges[] =
-{
-    SDRATTR_SHADOWCOLOR,
-    SDRATTR_SHADOWTRANSPARENCE,
-    SDRATTR_SHADOWBLUR,
-    SID_ATTR_FILL_SHADOW,
-    SID_ATTR_FILL_SHADOW,
-    SID_ATTR_SHADOW_TRANSPARENCE,
-    SID_ATTR_SHADOW_BLUR,
-    SID_ATTR_SHADOW_YDISTANCE,
-    0
-};
+const WhichRangesContainer SvxShadowTabPage::pShadowRanges(svl::Items<
+    SDRATTR_SHADOWCOLOR, SDRATTR_SHADOWTRANSPARENCE,
+    SDRATTR_SHADOWBLUR, SID_ATTR_FILL_SHADOW,
+    SID_ATTR_FILL_SHADOW, SID_ATTR_SHADOW_TRANSPARENCE,
+    SID_ATTR_SHADOW_BLUR, SID_ATTR_SHADOW_YDISTANCE
+>::value);
 
 SvxShadowTabPage::SvxShadowTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs)
     : SvxTabPage(pPage, pController, "cui/ui/shadowtabpage.ui", "ShadowTabPage", rInAttrs)
diff --git a/cui/source/tabpages/tptrans.cxx b/cui/source/tabpages/tptrans.cxx
index 3f7d9f6a76bd..594a41ecf704 100644
--- a/cui/source/tabpages/tptrans.cxx
+++ b/cui/source/tabpages/tptrans.cxx
@@ -33,16 +33,11 @@
 
 using namespace com::sun::star;
 
-const sal_uInt16 SvxTransparenceTabPage::pTransparenceRanges[] =
-{
-    XATTR_FILLTRANSPARENCE,
-    XATTR_FILLTRANSPARENCE,
-    SDRATTR_SHADOWTRANSPARENCE,
-    SDRATTR_SHADOWTRANSPARENCE,
-    XATTR_FILLFLOATTRANSPARENCE,
-    XATTR_FILLFLOATTRANSPARENCE,
-    0
-};
+const WhichRangesContainer SvxTransparenceTabPage::pTransparenceRanges(svl::Items<
+    XATTR_FILLTRANSPARENCE, XATTR_FILLTRANSPARENCE,
+    SDRATTR_SHADOWTRANSPARENCE, SDRATTR_SHADOWTRANSPARENCE,
+    XATTR_FILLFLOATTRANSPARENCE, XATTR_FILLFLOATTRANSPARENCE
+>::value);
 
 /*************************************************************************
 |*
diff --git a/cui/source/tabpages/transfrm.cxx b/cui/source/tabpages/transfrm.cxx
index 94ff0ef49d20..6737aba40f67 100644
--- a/cui/source/tabpages/transfrm.cxx
+++ b/cui/source/tabpages/transfrm.cxx
@@ -43,44 +43,26 @@
 
 // static ----------------------------------------------------------------
 
-const sal_uInt16 SvxPositionSizeTabPage::pPosSizeRanges[] =
-{
-    SID_ATTR_TRANSFORM_POS_X,
-    SID_ATTR_TRANSFORM_POS_Y,
-    SID_ATTR_TRANSFORM_PROTECT_POS,
-    SID_ATTR_TRANSFORM_PROTECT_POS,
-    SID_ATTR_TRANSFORM_INTERN,
-    SID_ATTR_TRANSFORM_INTERN,
-    SID_ATTR_TRANSFORM_ANCHOR,
-    SID_ATTR_TRANSFORM_VERT_ORIENT,
-    SID_ATTR_TRANSFORM_WIDTH,
-    SID_ATTR_TRANSFORM_SIZE_POINT,
-    SID_ATTR_TRANSFORM_PROTECT_POS,
-    SID_ATTR_TRANSFORM_INTERN,
-    SID_ATTR_TRANSFORM_AUTOWIDTH,
-    SID_ATTR_TRANSFORM_AUTOHEIGHT,
-    0
-};
-
-const sal_uInt16 SvxAngleTabPage::pAngleRanges[] =
-{
-    SID_ATTR_TRANSFORM_ROT_X,
-    SID_ATTR_TRANSFORM_ANGLE,
-    SID_ATTR_TRANSFORM_INTERN,
-    SID_ATTR_TRANSFORM_INTERN,
-    0
-};
-
-const sal_uInt16 SvxSlantTabPage::pSlantRanges[] =
-{
-    SDRATTR_CORNER_RADIUS,
-    SDRATTR_CORNER_RADIUS,
-    SID_ATTR_TRANSFORM_SHEAR,
-    SID_ATTR_TRANSFORM_SHEAR_VERTICAL,
-    SID_ATTR_TRANSFORM_INTERN,
-    SID_ATTR_TRANSFORM_INTERN,
-    0
-};
+const WhichRangesContainer SvxPositionSizeTabPage::pPosSizeRanges(svl::Items<
+    SID_ATTR_TRANSFORM_POS_X, SID_ATTR_TRANSFORM_POS_Y,
+    SID_ATTR_TRANSFORM_PROTECT_POS, SID_ATTR_TRANSFORM_PROTECT_POS,
+    SID_ATTR_TRANSFORM_INTERN, SID_ATTR_TRANSFORM_INTERN,
+    SID_ATTR_TRANSFORM_ANCHOR, SID_ATTR_TRANSFORM_VERT_ORIENT,
+    SID_ATTR_TRANSFORM_WIDTH, SID_ATTR_TRANSFORM_SIZE_POINT,
+    SID_ATTR_TRANSFORM_PROTECT_POS, SID_ATTR_TRANSFORM_INTERN,
+    SID_ATTR_TRANSFORM_AUTOWIDTH, SID_ATTR_TRANSFORM_AUTOHEIGHT
+>::value);
+
+const WhichRangesContainer SvxAngleTabPage::pAngleRanges(svl::Items<
+    SID_ATTR_TRANSFORM_ROT_X, SID_ATTR_TRANSFORM_ANGLE,
+    SID_ATTR_TRANSFORM_INTERN, SID_ATTR_TRANSFORM_INTERN
+>::value);
+
+const WhichRangesContainer SvxSlantTabPage::pSlantRanges(svl::Items<
+    SDRATTR_CORNER_RADIUS, SDRATTR_CORNER_RADIUS,
+    SID_ATTR_TRANSFORM_SHEAR, SID_ATTR_TRANSFORM_SHEAR_VERTICAL,
+    SID_ATTR_TRANSFORM_INTERN, SID_ATTR_TRANSFORM_INTERN
+>::value);
 
 /*************************************************************************
 |*
diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index 2d32406e4de9..c8c1bdad8a40 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -31,6 +31,7 @@ class SfxChildWindow;
 struct SfxChildWinInfo;
 class SfxItemSet;
 class Timer;
+struct WhichRangesContainer;
 
 class SFX2_DLLPUBLIC SfxDialogController : public weld::GenericDialogController
 {
@@ -82,7 +83,7 @@ public:
     SfxBindings&            GetBindings() const { return *m_pBindings; }
 };
 
-typedef const sal_uInt16* (*GetTabPageRanges)(); // provides international Which values
+typedef WhichRangesContainer (*GetTabPageRanges)(); // provides international Which values
 
 class SFX2_DLLPUBLIC SfxOkDialogController : public SfxDialogController
 {
diff --git a/include/sfx2/sfxdlg.hxx b/include/sfx2/sfxdlg.hxx
index 1c4b25f335fd..8313693e1c70 100644
--- a/include/sfx2/sfxdlg.hxx
+++ b/include/sfx2/sfxdlg.hxx
@@ -63,7 +63,7 @@ protected:
     virtual ~SfxAbstractTabDialog() override = default;
 public:
     virtual void                SetCurPageId( const OString &rName ) = 0;
-    virtual const sal_uInt16*   GetInputRanges( const SfxItemPool& ) = 0;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& ) = 0;
     virtual void                SetInputSet( const SfxItemSet* pInSet ) = 0;
 };
 
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index 7d338e40c342..22130c2a22fb 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -36,7 +36,7 @@
 class SfxTabPage;
 
 typedef std::unique_ptr<SfxTabPage> (*CreateTabPage)(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rAttrSet);
-typedef const sal_uInt16*     (*GetTabPageRanges)(); // provides international Which-value
+typedef WhichRangesContainer (*GetTabPageRanges)(); // provides international Which-value
 struct TabPageImpl;
 
 struct TabDlg_Impl;
@@ -76,7 +76,7 @@ private:
     std::unique_ptr<SfxItemSet>           m_pSet;
     std::unique_ptr<SfxItemSet>           m_pOutSet;
     std::unique_ptr<TabDlg_Impl>          m_pImpl;
-    std::unique_ptr<sal_uInt16[]>         m_pRanges;
+    WhichRangesContainer                  m_pRanges;
     OString             m_sAppPageId;
     bool                m_bStandardPushed;
     std::unique_ptr<SfxAllItemSet>       m_xItemSet;
@@ -134,7 +134,7 @@ public:
     SfxTabPage*         GetCurTabPage() const { return GetTabPage(GetCurPageId()); }
 
     // may provide local slots converted by Map
-    const sal_uInt16*   GetInputRanges( const SfxItemPool& );
+    const WhichRangesContainer& GetInputRanges( const SfxItemPool& );
     void                SetInputSet( const SfxItemSet* pInSet );
     const SfxItemSet*   GetOutputItemSet() const { return m_pOutSet.get(); }
 
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index 0ff1c8d4b27a..8d1f2324363b 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -23,6 +23,7 @@
 #include <svl/poolitem.hxx>
 #include <svl/svldllapi.h>
 #include <svl/typedwhich.hxx>
+#include <svl/whichranges.hxx>
 #include <memory>
 #include <vector>
 #include <o3tl/sorted_vector.hxx>
@@ -63,8 +64,8 @@ private:
 
 public:
     // for default SfxItemSet::CTOR, set default WhichRanges
-    void                            FillItemIdRanges_Impl( std::unique_ptr<sal_uInt16[]>& pWhichRanges ) const;
-    const sal_uInt16*               GetFrozenIdRanges() const;
+    void                            FillItemIdRanges_Impl( WhichRangesContainer& pWhichRanges ) const;
+    const WhichRangesContainer &    GetFrozenIdRanges() const;
 
 protected:
     static inline void              ClearRefCount(SfxPoolItem& rItem);
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 7c85e7534f59..efae21b3be61 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -32,6 +32,7 @@
 #include <svl/svldllapi.h>
 #include <svl/poolitem.hxx>
 #include <svl/typedwhich.hxx>
+#include <svl/whichranges.hxx>
 
 class SfxItemPool;
 
@@ -84,7 +85,12 @@ constexpr std::size_t rangesSize()
 
 }
 
-template<sal_uInt16... WIDs> struct Items {};
+template<sal_uInt16... WIDs> struct Items
+{
+    // This is passed to WhichRangesContainer so we can avoid needing to malloc()
+    // for compile-time data.
+    static constexpr std::array<sal_uInt16, sizeof...(WIDs)> value = { { WIDs... } };
+};
 
 }
 
@@ -96,18 +102,18 @@ class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet
     const SfxItemSet* m_pParent;       ///< derivation
     std::unique_ptr<SfxPoolItem const*[]>
                       m_pItems;        ///< array of items
-    sal_uInt16*       m_pWhichRanges;  ///< array of Which Ranges
+    WhichRangesContainer m_pWhichRanges;  ///< array of Which Ranges
     sal_uInt16        m_nCount;        ///< number of items
 
 friend class SfxItemPoolCache;
 friend class SfxAllItemSet;
 
 private:
-    SVL_DLLPRIVATE sal_uInt16 InitRanges_Impl(const sal_uInt16 *nWhichPairTable);
+    SVL_DLLPRIVATE void       RecreateRanges_Impl(const WhichRangesContainer& pNewRanges);
 
-    SfxItemSet(
-        SfxItemPool & pool, std::initializer_list<sal_uInt16> wids,
-        std::size_t items);
+    SfxItemSet( SfxItemPool & pool, const WhichRangesContainer& wids, std::size_t items );
+    SfxItemSet( SfxItemPool & pool, WhichRangesContainer&& wids, std::size_t items );
+    SfxItemSet( SfxItemPool & pool, std::initializer_list<sal_uInt16> wids, std::size_t items );
 
 public:
     SfxPoolItem const**         GetItems_Impl() const { return m_pItems.get(); }
@@ -123,21 +129,32 @@ protected:
 
     virtual const SfxPoolItem*  PutImpl( const SfxPoolItem&, sal_uInt16 nWhich, bool bPassingOwnership );
 
+    /** special constructor for SfxAllItemSet */
+    enum class SfxAllItemSetFlag { Flag };
+    SfxItemSet( SfxItemPool&, SfxAllItemSetFlag );
+
 public:
     struct Pair { sal_uInt16 wid1, wid2; };
+    SfxItemSet( const SfxItemSet& );
+    SfxItemSet( SfxItemSet&& ) noexcept;
+    SfxItemSet( SfxItemPool& );
+    SfxItemSet( SfxItemPool&, const WhichRangesContainer& ranges );
+    SfxItemSet( SfxItemPool&, WhichRangesContainer&& ranges );
 
-                                SfxItemSet( const SfxItemSet& );
-                                SfxItemSet( SfxItemSet&& ) noexcept;
+    SfxItemSet( SfxItemPool& rPool, sal_uInt16 nWhichStart, sal_uInt16 nWhichEnd )
+        : SfxItemSet(rPool, WhichRangesContainer(nWhichStart, nWhichEnd)) {}
 
-                                SfxItemSet( SfxItemPool&);
-    template<sal_uInt16... WIDs> SfxItemSet(
+    template<sal_uInt16... WIDs>
+    SfxItemSet(
         typename std::enable_if<
             svl::detail::validRanges<WIDs...>(), SfxItemPool &>::type pool,
-        svl::Items<WIDs...>):
-        SfxItemSet(pool, {WIDs...}, svl::detail::rangesSize<WIDs...>()) {}
-                                SfxItemSet( SfxItemPool&, std::initializer_list<Pair> wids );
-                                SfxItemSet( SfxItemPool&, const sal_uInt16* nWhichPairTable );
-    virtual                     ~SfxItemSet();
+        svl::Items<WIDs...>)
+        : SfxItemSet(pool, WhichRangesContainer(svl::Items<WIDs...>::value), svl::detail::rangesSize<WIDs...>()) {}
+
+    SfxItemSet( SfxItemPool&, std::initializer_list<Pair> wids );
+    SfxItemSet( SfxItemPool&, const sal_uInt16* nWhichPairTable );
+
+    virtual ~SfxItemSet();
 
     virtual std::unique_ptr<SfxItemSet> Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const;
     virtual SfxItemSet CloneAsValue(bool bItems = true, SfxItemPool *pToPool = nullptr) const;
@@ -231,8 +248,9 @@ public:
     void                        MergeValue( const SfxPoolItem& rItem, bool bOverwriteDefaults = false  );
 
     SfxItemPool*                GetPool() const { return m_pPool; }
-    const sal_uInt16*           GetRanges() const { return m_pWhichRanges; }
-    void                        SetRanges( const sal_uInt16 *pRanges );
+    const WhichRangesContainer & GetRanges() const { return m_pWhichRanges; }
+    void                        SetRanges( const WhichRangesContainer& );
+    void                        SetRanges( WhichRangesContainer&& );
     void                        MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo );
     const SfxItemSet*           GetParent() const { return m_pParent; }
 
diff --git a/include/svl/whichranges.hxx b/include/svl/whichranges.hxx
new file mode 100644
index 000000000000..b1e87bba38b4
--- /dev/null
+++ b/include/svl/whichranges.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+#pragma once
+
+#include <sal/config.h>
+#include <sal/types.h>
+#include <svl/svldllapi.h>
+#include <array>
+#include <memory>
+#include <cassert>
+
+typedef std::pair<sal_uInt16, sal_uInt16> WhichPair;
+
+/**
+ * Most of the time, the which ranges we point at are a compile-time literal.
+ * So we take advantage of that, and avoid the cost of allocating our own array and copying into it.
+ */
+struct SVL_DLLPUBLIC WhichRangesContainer
+{
+    using const_iterator = WhichPair const*;
+
+    WhichPair const* m_pairs = nullptr;
+    sal_Int32 m_size = 0;
+    /** if true, we allocated and need to delete the pairs, if not, we are pointing
+      * at a global const literal */
+    bool m_bOwnRanges = false;
+
+    WhichRangesContainer() {}
+
+    WhichRangesContainer(std::unique_ptr<WhichPair[]> wids, sal_Int32 nSize)
+        : m_pairs(wids.release())
+        , m_size(nSize)
+        , m_bOwnRanges(true)
+    {
+    }
+    template <std::size_t N>
+    WhichRangesContainer(const std::array<sal_uInt16, N>& ranges)
+        : m_pairs(reinterpret_cast<const WhichPair*>(ranges.data()))
+        , m_size(static_cast<sal_Int32>(N / 2))
+        , m_bOwnRanges(false)
+    {
+    }
+    WhichRangesContainer(const WhichPair* wids, sal_Int32 nSize);
+    WhichRangesContainer(sal_uInt16 nWhichStart, sal_uInt16 nWhichEnd);
+    WhichRangesContainer(WhichRangesContainer const& other) { operator=(other); }
+    WhichRangesContainer(WhichRangesContainer&& other);
+    ~WhichRangesContainer();
+
+    WhichRangesContainer& operator=(WhichRangesContainer&& other);
+    WhichRangesContainer& operator=(WhichRangesContainer const& other);
+
+    bool operator==(WhichRangesContainer const& other) const;
+    const_iterator begin() const noexcept { return m_pairs; }
+    const_iterator end() const noexcept { return begin() + size(); }
+    bool empty() const noexcept { return m_size == 0; }
+    sal_Int32 size() const noexcept { return m_size; }
+    WhichPair const& operator[](sal_Int32 idx) const noexcept
+    {
+        assert(idx >= 0 && idx < size() && "index out of range");
+        return m_pairs[idx];
+    }
+    void reset();
+
+    // Adds a range to which ranges, keeping the ranges in valid state (sorted, non-overlapping)
+    WhichRangesContainer MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo) const;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/svl/whiter.hxx b/include/svl/whiter.hxx
index be584fc23911..c4a49a06b622 100644
--- a/include/svl/whiter.hxx
+++ b/include/svl/whiter.hxx
@@ -20,19 +20,20 @@
 #define INCLUDED_SVL_WHITER_HXX
 
 #include <svl/svldllapi.h>
+#include <svl/whichranges.hxx>
 
 class SfxItemSet;
 
 class SVL_DLLPUBLIC SfxWhichIter
 {
-    const sal_uInt16* const pStart;
-    const sal_uInt16* pRanges;
+    const WhichRangesContainer& pStart;
+    const WhichPair* pRanges;
     sal_uInt16 nOffset;
 
 public:
     SfxWhichIter(const SfxItemSet& rSet);
 
-    sal_uInt16 GetCurWhich() const { return pRanges[0] + nOffset; }
+    sal_uInt16 GetCurWhich() const;
     sal_uInt16 NextWhich();
     sal_uInt16 FirstWhich();
 };
diff --git a/include/svx/hdft.hxx b/include/svx/hdft.hxx
index c7d929f8ed66..8590516c1544 100644
--- a/include/svx/hdft.hxx
+++ b/include/svx/hdft.hxx
@@ -50,7 +50,7 @@ public:
     void            EnableDynamicSpacing();
 
 protected:
-    static const sal_uInt16 pRanges[];
+    static const WhichRangesContainer pRanges;
 
     virtual void    ActivatePage( const SfxItemSet& rSet ) override;
     virtual DeactivateRC   DeactivatePage( SfxItemSet* pSet ) override;
@@ -97,7 +97,7 @@ class SVX_DLLPUBLIC SvxHeaderPage final : public SvxHFPage
 public:
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
     // returns the Which values to the range
-    static const sal_uInt16*  GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
     SVX_DLLPRIVATE SvxHeaderPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
 };
 
@@ -105,7 +105,7 @@ class SVX_DLLPUBLIC SvxFooterPage final : public SvxHFPage
 {
 public:
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
-    static const sal_uInt16*  GetRanges() { return pRanges; }
+    static WhichRangesContainer GetRanges() { return pRanges; }
     SVX_DLLPRIVATE SvxFooterPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
 };
 
diff --git a/include/svx/svdetc.hxx b/include/svx/svdetc.hxx
index a6e26bbbdaf4..f594550a5aa2 100644
--- a/include/svx/svdetc.hxx
+++ b/include/svx/svdetc.hxx
@@ -25,6 +25,7 @@
 #include <tools/link.hxx>
 #include <tools/fract.hxx>
 #include <svx/svdobj.hxx>
+#include <svl/whichranges.hxx>
 #include <memory>
 
 
@@ -101,7 +102,7 @@ bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnl
 /**
  * @returns a new WhichTable, which we need to squash at some point with a delete
  */
-std::unique_ptr<sal_uInt16[]> RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd);
+WhichRangesContainer RemoveWhichRange(const WhichRangesContainer& pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd);
 
 /**
  * Helper class for the communication between the dialog
diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx
index 927705943453..71f167f12dbe 100644
--- a/include/svx/svxdlg.hxx
+++ b/include/svx/svxdlg.hxx
@@ -55,7 +55,7 @@ class SdrObject;
 class SvxSpellWrapper;
 struct FmSearchContext;
 
-typedef const sal_uInt16*  (*DialogGetRanges)();
+typedef WhichRangesContainer (*DialogGetRanges)();
 
 typedef ::std::vector< OUString > TargetList;
 
@@ -350,7 +350,7 @@ public:
     virtual VclPtr<SfxAbstractTabDialog> CreateTabItemDialog(weld::Window* pParent, const SfxItemSet& rSet) = 0;
     virtual VclPtr<VclAbstractDialog>      CreateSvxSearchAttributeDialog(weld::Window* pParent,
                                             SearchAttrItemList& rLst,
-                                            const sal_uInt16* pWhRanges)=0;
+                                            const WhichRangesContainer& pWhRanges)=0;
     virtual VclPtr<AbstractSvxSearchSimilarityDialog> CreateSvxSearchSimilarityDialog( weld::Window* pParent,
                                                             bool bRelax,
                                                             sal_uInt16 nOther,
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 5a82f4e7371a..14e4f6920e2f 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -932,7 +932,7 @@ const SfxItemSet* ScAbstractTabController_Impl::GetOutputItemSet() const
     return m_xDlg->GetOutputItemSet();
 }
 
-const sal_uInt16* ScAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer ScAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
 {
     return m_xDlg->GetInputRanges( pItem );
 }
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index c2a376428074..fef206002dea 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -648,7 +648,7 @@ public:
     virtual bool  StartExecuteAsync(AsyncContext &rCtx) override;
     virtual void                SetCurPageId( const OString &rName ) override;
     virtual const SfxItemSet*   GetOutputItemSet() const override;
-    virtual const sal_uInt16*   GetInputRanges( const SfxItemPool& pItem ) override;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
     virtual void                SetInputSet( const SfxItemSet* pInSet ) override;
     virtual void        SetText( const OUString& rStr ) override;
 
diff --git a/sc/source/ui/attrdlg/tabpages.cxx b/sc/source/ui/attrdlg/tabpages.cxx
index 5957de8d1c2d..633db59f7688 100644
--- a/sc/source/ui/attrdlg/tabpages.cxx
+++ b/sc/source/ui/attrdlg/tabpages.cxx
@@ -25,12 +25,8 @@
 #include <tabpages.hxx>
 #include <osl/diagnose.h>
 
-const sal_uInt16 ScTabPageProtection::pProtectionRanges[] =
-{
-    SID_SCATTR_PROTECTION,
-    SID_SCATTR_PROTECTION,
-    0
-};
+const WhichRangesContainer ScTabPageProtection::pProtectionRanges(
+    svl::Items<SID_SCATTR_PROTECTION, SID_SCATTR_PROTECTION>::value);
 
 // Zellschutz-Tabpage:
 
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index 2be55f8100ab..d843ae6984a3 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -365,7 +365,7 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq )
                                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                                 VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateCaptionDialog(pWin ? pWin->GetFrameWeld() : nullptr, pView));
 
-                                const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
+                                const WhichRangesContainer& pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
                                 SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
                                 aCombSet.Put( aNewAttr );
                                 aCombSet.Put( aNewGeoAttr );
diff --git a/sc/source/ui/inc/tabpages.hxx b/sc/source/ui/inc/tabpages.hxx
index cd7c9f10bb7e..8880f738f3f2 100644
--- a/sc/source/ui/inc/tabpages.hxx
+++ b/sc/source/ui/inc/tabpages.hxx
@@ -23,14 +23,14 @@
 
 class ScTabPageProtection : public SfxTabPage
 {
-    static const sal_uInt16 pProtectionRanges[];
+    static const WhichRangesContainer pProtectionRanges;
 public:
     ScTabPageProtection(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreAttrs);
     static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController,
                                               const SfxItemSet* rAttrSet);
     virtual ~ScTabPageProtection() override;
 
-    static  const sal_uInt16* GetRanges () { return pProtectionRanges; }
+    static WhichRangesContainer GetRanges () { return pProtectionRanges; }
     virtual bool        FillItemSet     ( SfxItemSet* rCoreAttrs ) override;
     virtual void        Reset           ( const SfxItemSet* ) override;
 
diff --git a/sc/source/ui/inc/tphf.hxx b/sc/source/ui/inc/tphf.hxx
index 911d8bccd1ce..9af97f6d7080 100644
--- a/sc/source/ui/inc/tphf.hxx
+++ b/sc/source/ui/inc/tphf.hxx
@@ -56,7 +56,7 @@ class ScHeaderPage : public ScHFPage
 public:
     static std::unique_ptr<SfxTabPage>  Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
     ScHeaderPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
-    static const sal_uInt16*      GetRanges();
+    static WhichRangesContainer GetRanges();
 };
 
 class ScFooterPage : public ScHFPage
@@ -64,7 +64,7 @@ class ScFooterPage : public ScHFPage
 public:
     static std::unique_ptr<SfxTabPage>  Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
     ScFooterPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
-    static const sal_uInt16*      GetRanges();
+    static WhichRangesContainer GetRanges();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tptable.hxx b/sc/source/ui/inc/tptable.hxx
index 6cc5888a4d9b..e843f769cb42 100644
--- a/sc/source/ui/inc/tptable.hxx
+++ b/sc/source/ui/inc/tptable.hxx
@@ -23,13 +23,13 @@
 
 class ScTablePage : public SfxTabPage
 {
-    static const sal_uInt16 pPageTableRanges[];
+    static const WhichRangesContainer pPageTableRanges;
 public:
     ScTablePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet);
     static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rCoreSet);
     virtual         ~ScTablePage() override;
 
-    static  const sal_uInt16* GetRanges () { return pPageTableRanges; }
+    static WhichRangesContainer GetRanges () { return pPageTableRanges; }
     virtual bool        FillItemSet     ( SfxItemSet* rCoreSet ) override;
     virtual void        Reset           ( const SfxItemSet* rCoreSet ) override;
     virtual DeactivateRC   DeactivatePage  ( SfxItemSet* pSet ) override;
diff --git a/sc/source/ui/pagedlg/tphf.cxx b/sc/source/ui/pagedlg/tphf.cxx
index 406e23ed24bc..b62fca5feeaa 100644
--- a/sc/source/ui/pagedlg/tphf.cxx
+++ b/sc/source/ui/pagedlg/tphf.cxx
@@ -218,7 +218,7 @@ std::unique_ptr<SfxTabPage> ScHeaderPage::Create(weld::Container* pPage, weld::D
     return std::make_unique<ScHeaderPage>(pPage, pController, *rCoreSet);
 }
 
-const sal_uInt16* ScHeaderPage::GetRanges()
+WhichRangesContainer ScHeaderPage::GetRanges()
 {
     return SvxHeaderPage::GetRanges();
 }
@@ -234,7 +234,7 @@ std::unique_ptr<SfxTabPage> ScFooterPage::Create(weld::Container* pPage, weld::D
     return std::make_unique<ScFooterPage>(pPage, pController, *rCoreSet);
 }
 
-const sal_uInt16* ScFooterPage::GetRanges()
+WhichRangesContainer ScFooterPage::GetRanges()
 {
     return SvxHeaderPage::GetRanges();
 }
diff --git a/sc/source/ui/pagedlg/tptable.cxx b/sc/source/ui/pagedlg/tptable.cxx
index 3b987debda35..cb4c19c4d549 100644
--- a/sc/source/ui/pagedlg/tptable.cxx
+++ b/sc/source/ui/pagedlg/tptable.cxx
@@ -30,11 +30,8 @@
 
 // Static Data
 
-const sal_uInt16 ScTablePage::pPageTableRanges[] =
-{
-    ATTR_PAGE_NOTES, ATTR_PAGE_FIRSTPAGENO,
-    0
-};
+const WhichRangesContainer ScTablePage::pPageTableRanges(
+    svl::Items<ATTR_PAGE_NOTES, ATTR_PAGE_FIRSTPAGENO>::value);
 
 static bool lcl_PutVObjModeItem(sal_uInt16  nWhich,
                           SfxItemSet&       rCoreSet,
diff --git a/sd/source/ui/dlg/paragr.cxx b/sd/source/ui/dlg/paragr.cxx
index 1dd236a50e47..e7eec89fe998 100644
--- a/sd/source/ui/dlg/paragr.cxx
+++ b/sd/source/ui/dlg/paragr.cxx
@@ -36,7 +36,7 @@ public:
     SdParagraphNumTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet);
     static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet );
 
-    static const sal_uInt16*  GetRanges();
+    static WhichRangesContainer GetRanges();
 
     virtual bool        FillItemSet( SfxItemSet* rSet ) override;
     virtual void        Reset( const SfxItemSet* rSet ) override;
@@ -68,15 +68,9 @@ std::unique_ptr<SfxTabPage> SdParagraphNumTabPage::Create(weld::Container* pPage
     return std::make_unique<SdParagraphNumTabPage>(pPage, pController, *rAttrSet);
 }
 
-const sal_uInt16* SdParagraphNumTabPage::GetRanges()
+WhichRangesContainer SdParagraphNumTabPage::GetRanges()
 {
-    static const sal_uInt16 aRange[] =
-    {
-        ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END,
-        0
-    };
-
-    return aRange;
+    return WhichRangesContainer(svl::Items<ATTR_PARANUMBERING_START, ATTR_PARANUMBERING_END>::value);
 }
 
 bool SdParagraphNumTabPage::FillItemSet( SfxItemSet* rSet )
diff --git a/sd/source/ui/dlg/prltempl.cxx b/sd/source/ui/dlg/prltempl.cxx
index a741d9ba39c4..a4ef27fed216 100644
--- a/sd/source/ui/dlg/prltempl.cxx
+++ b/sd/source/ui/dlg/prltempl.cxx
@@ -58,21 +58,20 @@ SdPresLayoutTemplateDlg::SdPresLayoutTemplateDlg(SfxObjectShell const * pDocSh,
     if( IS_OUTLINE(ePO))
     {
         // Unfortunately, the Itemsets of our style sheets are not discrete...
-        const sal_uInt16* pPtr = pOrgSet->GetRanges();
+        const WhichRangesContainer& pPtr = pOrgSet->GetRanges();
         sal_uInt16 p1, p2;
-        while( *pPtr )
+        for( sal_Int32 i = 0; i < pPtr.size(); ++i )
         {
-            p1 = pPtr[0];
-            p2 = pPtr[1];
+            p1 = pPtr[i].first;
+            p2 = pPtr[i].second;
 
             // first, we make it discrete
-            while(pPtr[2] && (pPtr[2] - p2 == 1))
+            while(i < pPtr.size() - 1 && (pPtr[i+1].first - p2 == 1))
             {
-                p2 = pPtr[3];
-                pPtr += 2;
+                p2 = pPtr[i+1].second;
+                ++i;
             }
             aInputSet.MergeRange( p1, p2 );
-            pPtr += 2;
         }
 
         aInputSet.Put( rStyleBase.GetItemSet() );
diff --git a/sd/source/ui/dlg/sddlgfact.cxx b/sd/source/ui/dlg/sddlgfact.cxx
index 0335c68fa8be..506b741e677d 100644
--- a/sd/source/ui/dlg/sddlgfact.cxx
+++ b/sd/source/ui/dlg/sddlgfact.cxx
@@ -271,7 +271,7 @@ const SfxItemSet* SdAbstractTabController_Impl::GetOutputItemSet() const
     return m_xDlg->GetOutputItemSet();
 }
 
-const sal_uInt16* SdAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer SdAbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
 {
     return m_xDlg->GetInputRanges( pItem );
 }
@@ -313,7 +313,7 @@ const SfxItemSet* AbstractBulletDialog_Impl::GetOutputItemSet() const
     return static_cast< ::sd::OutlineBulletDlg*>(m_xDlg.get())->GetBulletOutputItemSet();
 }
 
-const sal_uInt16* AbstractBulletDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer AbstractBulletDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
 {
     return m_xDlg->GetInputRanges(pItem);
 }
@@ -349,7 +349,7 @@ const SfxItemSet* SdPresLayoutTemplateDlg_Impl::GetOutputItemSet() const
     return m_xDlg->GetOutputItemSet();
 }
 
-const sal_uInt16* SdPresLayoutTemplateDlg_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer SdPresLayoutTemplateDlg_Impl::GetInputRanges(const SfxItemPool& pItem )
 {
     return m_xDlg->GetInputRanges( pItem );
 }
diff --git a/sd/source/ui/dlg/sddlgfact.hxx b/sd/source/ui/dlg/sddlgfact.hxx
index 6570c2b93b5d..5a8637586b8e 100644
--- a/sd/source/ui/dlg/sddlgfact.hxx
+++ b/sd/source/ui/dlg/sddlgfact.hxx
@@ -152,7 +152,7 @@ public:
     virtual bool  StartExecuteAsync(AsyncContext &rCtx) override;
     virtual void                SetCurPageId( const OString &rName ) override;
     virtual const SfxItemSet*   GetOutputItemSet() const override;
-    virtual const sal_uInt16*   GetInputRanges( const SfxItemPool& pItem ) override;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
     virtual void                SetInputSet( const SfxItemSet* pInSet ) override;
     virtual void        SetText( const OUString& rStr ) override;
 
@@ -173,7 +173,7 @@ public:
     virtual bool  StartExecuteAsync(AsyncContext &rCtx) override;
     virtual void                SetCurPageId( const OString& rName ) override;
     virtual const SfxItemSet*   GetOutputItemSet() const override;
-    virtual const sal_uInt16*       GetInputRanges( const SfxItemPool& pItem ) override;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
     virtual void                SetInputSet( const SfxItemSet* pInSet ) override;
     virtual void        SetText( const OUString& rStr ) override;
 
@@ -194,7 +194,7 @@ public:
     virtual bool  StartExecuteAsync(AsyncContext &rCtx) override;
     virtual void                SetCurPageId( const OString& rName ) override;
     virtual const SfxItemSet*   GetOutputItemSet() const override;
-    virtual const sal_uInt16*       GetInputRanges( const SfxItemPool& pItem ) override;
+    virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override;
     virtual void                SetInputSet( const SfxItemSet* pInSet ) override;
     virtual void        SetText( const OUString& rStr ) override;
 
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index 32b98a08bf58..982fab729734 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -77,21 +77,20 @@ namespace sd {
 
 static void mergeItemSetsImpl( SfxItemSet& rTarget, const SfxItemSet& rSource )
 {
-    const sal_uInt16* pPtr = rSource.GetRanges();
+    const WhichRangesContainer& rRanges = rSource.GetRanges();
     sal_uInt16 p1, p2;
-    while( *pPtr )
+    for (sal_Int32 i = 0; i < rRanges.size(); ++i)
     {
-        p1 = pPtr[0];
-        p2 = pPtr[1];
+        p1 = rRanges[i].first;
+        p2 = rRanges[i].second;
 
         // make ranges discrete
-        while(pPtr[2] && (pPtr[2] - p2 == 1))
+        while(i < rRanges.size()-1 && (rRanges[i+1].first - p2 == 1))
         {
-            p2 = pPtr[3];
-            pPtr += 2;
+            p2 = rRanges[i+1].second;
+            ++i;
         }
         rTarget.MergeRange( p1, p2 );
-        pPtr += 2;
     }
 
     rTarget.Put(rSource);
@@ -266,14 +265,15 @@ const SfxItemSet* FuPage::ExecuteDialog(weld::Window* pParent, const SfxRequest&
 
     // Merge ItemSet for dialog
 
-    const sal_uInt16* pPtr = aNewAttr.GetRanges();
-    sal_uInt16 p1 = pPtr[0], p2 = pPtr[1];
-    while(pPtr[2] && (pPtr[2] - p2 == 1))
+    const WhichRangesContainer& rRanges = aNewAttr.GetRanges();
+    sal_uInt16 p1 = rRanges[0].first, p2 = rRanges[0].second;
+    sal_Int32 idx = 1;
+    while(idx < rRanges.size() && (rRanges[idx].first - p2 == 1))
     {
-        p2 = pPtr[3];
-        pPtr += 2;
+        p2 = rRanges[idx].second;
+        ++idx;
     }
-    SfxItemSet aMergedAttr( *aNewAttr.GetPool(), {{p1, p2}} );
+    SfxItemSet aMergedAttr( *aNewAttr.GetPool(), p1, p2 );
 
     mergeItemSetsImpl( aMergedAttr, aNewAttr );
 
diff --git a/sd/source/ui/func/futransf.cxx b/sd/source/ui/func/futransf.cxx
index 6c07e0e70be6..80441e57dea4 100644
--- a/sd/source/ui/func/futransf.cxx
+++ b/sd/source/ui/func/futransf.cxx
@@ -95,7 +95,7 @@ void FuTransform::DoExecute( SfxRequest& rReq )
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         pDlg.reset(pFact->CreateCaptionDialog(mpViewShell->GetFrameWeld(), mpView));
 
-        const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
+        const WhichRangesContainer& pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
         SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
         aCombSet.Put( aNewAttr );
         aCombSet.Put( aSet );
diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx
index bac9a650966f..4595f6508ca0 100644
--- a/sfx2/source/appl/appcfg.cxx
+++ b/sfx2/source/appl/appcfg.cxx
@@ -114,15 +114,15 @@ void SfxApplication::GetOptions( SfxItemSet& rSet )
     bool bRet = false;
     SfxItemPool &rPool = GetPool();
 
-    const sal_uInt16 *pRanges = rSet.GetRanges();
+    const WhichRangesContainer& pRanges = rSet.GetRanges();
     SvtSaveOptions aSaveOptions;
     SvtHelpOptions aHelpOptions;
     SvtSecurityOptions  aSecurityOptions;
     SvtMiscOptions aMiscOptions;
 
-    while ( *pRanges )
+    for (auto const & pRange : pRanges)
     {
-        for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
+        for(sal_uInt16 nWhich = pRange.first; nWhich <= pRange.second; ++nWhich)
         {
             switch(nWhich)
             {
@@ -390,7 +390,6 @@ void SfxApplication::GetOptions( SfxItemSet& rSet )
             }
             SAL_WARN_IF(!bRet, "sfx.appl", "Putting options failed!");
         }
-        pRanges++;
     }
 }
 
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index fe23dd1935f6..4e4e5f90c3a2 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -1080,11 +1080,11 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
 
 void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
 {
-    const sal_uInt16 *pRanges = rSet.GetRanges();
-    DBG_ASSERT(pRanges && *pRanges, "Set without range");
-    while ( *pRanges )
+    const WhichRangesContainer & pRanges = rSet.GetRanges();
+    DBG_ASSERT(!pRanges.empty(), "Set without range");
+    for ( auto const & pRange : pRanges )
     {
-        for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
+        for(sal_uInt16 nWhich = pRange.first; nWhich <= pRange.second; ++nWhich)
         {
             switch(nWhich)
             {
@@ -1278,8 +1278,6 @@ void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
                     break;
             }
         }
-
-        ++pRanges;
     }
 }
 
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index cc4917eebb11..17c2304ed10a 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -1118,11 +1118,10 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b
     if ( rSet.Count() != nItems )
     {
         // detect unknown item and present error message
-        const sal_uInt16 *pRanges = rSet.GetRanges();
-        while ( *pRanges )
+        for ( auto const & rPair : rSet.GetRanges() )
         {
-            sal_uInt16 nStartWhich = *pRanges++;
-            sal_uInt16 nEndWhich = *pRanges++;
+            sal_uInt16 nStartWhich = rPair.first;
+            sal_uInt16 nEndWhich = rPair.second;
             for(sal_uInt16 nId = nStartWhich; nId <= nEndWhich; ++nId)
             {
                 if ( rSet.GetItemState(nId) < SfxItemState::SET ) //???
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index ca8366f26539..042684647114 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1166,8 +1166,8 @@ std::optional<SfxItemSet> SfxBindings::CreateSet_Impl
     }
 
     // Create a Set from the ranges
+    WhichRangesContainer ranges;
     size_t i = 0;
-    SfxItemSet aSet(rPool, nullptr);
     while ( i < rFound.size() )
     {
         const sal_uInt16 nWhich1 = rFound[i].nWhichId;
@@ -1176,8 +1176,9 @@ std::optional<SfxItemSet> SfxBindings::CreateSet_Impl
             if ( rFound[i].nWhichId+1 != rFound[i+1].nWhichId )
                 break;
         const sal_uInt16 nWhich2 = rFound[i++].nWhichId;
-        aSet.MergeRange(nWhich1, nWhich2);
+        ranges = ranges.MergeRange(nWhich1, nWhich2);
     }
+    SfxItemSet aSet(rPool, std::move(ranges));
     return aSet;
 }
 
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index fa276f8b7400..18bfd7bd18f1 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -421,14 +421,12 @@ IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void)
         m_xExampleSet.reset(new SfxItemSet(*m_pSet));
 
     const SfxItemPool* pPool = m_pSet->GetPool();
-    const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)();
+    const WhichRangesContainer& pTmpRanges = (pDataObject->fnGetRanges)();
 
-    while (*pTmpRanges)
+    for (const auto & rPair : pTmpRanges)
     {
-        const sal_uInt16* pU = pTmpRanges + 1;
-
         // Correct Range with multiple values
-        sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU;
+        sal_uInt16 nTmp = rPair.first, nTmpEnd = rPair.second;
         DBG_ASSERT(nTmp <= nTmpEnd, "Range is sorted the wrong way");
 
         if (nTmp > nTmpEnd)
@@ -454,8 +452,6 @@ IMPL_LINK_NOARG(SfxTabDialogController, ResetHdl, weld::Button&, void)
             }
             nTmp++;
         }
-        // Go to the next pair
-        pTmpRanges += 2;
     }
 }
 
@@ -479,15 +475,13 @@ IMPL_LINK_NOARG(SfxTabDialogController, BaseFmtHdl, weld::Button&, void)
         m_xExampleSet.reset(new SfxItemSet(*m_pSet));
 
     const SfxItemPool* pPool = m_pSet->GetPool();
-    const sal_uInt16* pTmpRanges = (pDataObject->fnGetRanges)();
+    const WhichRangesContainer& pTmpRanges = (pDataObject->fnGetRanges)();
     SfxItemSet aTmpSet(*m_xExampleSet);
 
-    while (*pTmpRanges)
+    for (const auto& rPair : pTmpRanges)
     {
-        const sal_uInt16* pU = pTmpRanges + 1;
-
         // Correct Range with multiple values
-        sal_uInt16 nTmp = *pTmpRanges, nTmpEnd = *pU;
+        sal_uInt16 nTmp = rPair.first, nTmpEnd = rPair.second;
         DBG_ASSERT( nTmp <= nTmpEnd, "Range is sorted the wrong way" );
 
         if ( nTmp > nTmpEnd )
@@ -507,8 +501,6 @@ IMPL_LINK_NOARG(SfxTabDialogController, BaseFmtHdl, weld::Button&, void)
             m_pOutSet->InvalidateItem(nWh);
             nTmp++;
         }
-        // Go to the next pair
-        pTmpRanges += 2;
     }
     // Set all Items as new  -> the call the current Page Reset()
     assert(pDataObject->xTabPage && "the Page is gone");

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list