summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-07-10 10:19:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-07-15 14:41:13 +0200
commit5d0a231b29dfd4d587c7a4d1bbda6a511f94ec77 (patch)
treeebc1d470fd891fe0f9e68a002055c4d3a8dd4884
parentdf9ca514d4e9ea87bbf0a96d99181ed8965cd45a (diff)
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@collabora.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--chart2/source/controller/itemsetwrapper/ItemConverter.cxx12
-rw-r--r--chart2/source/controller/main/ShapeController.cxx2
-rw-r--r--cui/source/dialogs/iconcdlg.cxx11
-rw-r--r--cui/source/dialogs/postdlg.cxx10
-rw-r--r--cui/source/dialogs/srchxtra.cxx2
-rw-r--r--cui/source/factory/dlgfact.cxx10
-rw-r--r--cui/source/factory/dlgfact.hxx10
-rw-r--r--cui/source/inc/TextColumnsPage.hxx4
-rw-r--r--cui/source/inc/align.hxx4
-rw-r--r--cui/source/inc/backgrnd.hxx4
-rw-r--r--cui/source/inc/border.hxx4
-rw-r--r--cui/source/inc/chardlg.hxx16
-rw-r--r--cui/source/inc/connect.hxx4
-rw-r--r--cui/source/inc/cuihyperdlg.hxx4
-rw-r--r--cui/source/inc/cuitabarea.hxx12
-rw-r--r--cui/source/inc/cuitabline.hxx4
-rw-r--r--cui/source/inc/labdlg.hxx4
-rw-r--r--cui/source/inc/macropg.hxx2
-rw-r--r--cui/source/inc/measure.hxx4
-rw-r--r--cui/source/inc/numfmt.hxx4
-rw-r--r--cui/source/inc/optasian.hxx2
-rw-r--r--cui/source/inc/page.hxx4
-rw-r--r--cui/source/inc/paragrph.hxx14
-rw-r--r--cui/source/inc/postdlg.hxx2
-rw-r--r--cui/source/inc/srchxtra.hxx2
-rw-r--r--cui/source/inc/swpossizetabpage.hxx2
-rw-r--r--cui/source/inc/tabstpge.hxx4
-rw-r--r--cui/source/inc/textanim.hxx4
-rw-r--r--cui/source/inc/textattr.hxx4
-rw-r--r--cui/source/inc/transfrm.hxx12
-rw-r--r--cui/source/options/optasian.cxx5
-rw-r--r--cui/source/tabpages/TextColumnsPage.cxx4
-rw-r--r--cui/source/tabpages/align.cxx24
-rw-r--r--cui/source/tabpages/backgrnd.cxx8
-rw-r--r--cui/source/tabpages/border.cxx16
-rw-r--r--cui/source/tabpages/chardlg.cxx90
-rw-r--r--cui/source/tabpages/connect.cxx8
-rw-r--r--cui/source/tabpages/labdlg.cxx21
-rw-r--r--cui/source/tabpages/measure.cxx8
-rw-r--r--cui/source/tabpages/numfmt.cxx18
-rw-r--r--cui/source/tabpages/page.cxx19
-rw-r--r--cui/source/tabpages/paragrph.cxx45
-rw-r--r--cui/source/tabpages/swpossizetabpage.cxx40
-rw-r--r--cui/source/tabpages/tabstpge.cxx8
-rw-r--r--cui/source/tabpages/textanim.cxx8
-rw-r--r--cui/source/tabpages/textattr.cxx13
-rw-r--r--cui/source/tabpages/tparea.cxx12
-rw-r--r--cui/source/tabpages/tpline.cxx12
-rw-r--r--cui/source/tabpages/tpshadow.cxx18
-rw-r--r--cui/source/tabpages/tptrans.cxx15
-rw-r--r--cui/source/tabpages/transfrm.cxx58
-rw-r--r--include/sfx2/basedlgs.hxx3
-rw-r--r--include/sfx2/sfxdlg.hxx2
-rw-r--r--include/sfx2/tabdlg.hxx6
-rw-r--r--include/svl/itempool.hxx5
-rw-r--r--include/svl/itemset.hxx52
-rw-r--r--include/svl/whichranges.hxx74
-rw-r--r--include/svl/whiter.hxx7
-rw-r--r--include/svx/hdft.hxx6
-rw-r--r--include/svx/svdetc.hxx3
-rw-r--r--include/svx/svxdlg.hxx4
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx2
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx2
-rw-r--r--sc/source/ui/attrdlg/tabpages.cxx8
-rw-r--r--sc/source/ui/drawfunc/drawsh.cxx2
-rw-r--r--sc/source/ui/inc/tabpages.hxx4
-rw-r--r--sc/source/ui/inc/tphf.hxx4
-rw-r--r--sc/source/ui/inc/tptable.hxx4
-rw-r--r--sc/source/ui/pagedlg/tphf.cxx4
-rw-r--r--sc/source/ui/pagedlg/tptable.cxx7
-rw-r--r--sd/source/ui/dlg/paragr.cxx12
-rw-r--r--sd/source/ui/dlg/prltempl.cxx15
-rw-r--r--sd/source/ui/dlg/sddlgfact.cxx6
-rw-r--r--sd/source/ui/dlg/sddlgfact.hxx6
-rw-r--r--sd/source/ui/func/fupage.cxx28
-rw-r--r--sd/source/ui/func/futransf.cxx2
-rw-r--r--sfx2/source/appl/appcfg.cxx7
-rw-r--r--sfx2/source/appl/appserv.cxx10
-rw-r--r--sfx2/source/appl/appuno.cxx7
-rw-r--r--sfx2/source/control/bindings.cxx5
-rw-r--r--sfx2/source/dialog/tabdlg.cxx45
-rw-r--r--sfx2/source/view/viewfrm.cxx20
-rw-r--r--sfx2/source/view/viewfrm2.cxx9
-rw-r--r--solenv/gdb/libreoffice/svl.py9
-rw-r--r--svl/source/inc/items_helper.hxx90
-rw-r--r--svl/source/inc/poolio.hxx2
-rw-r--r--svl/source/items/itempool.cxx13
-rw-r--r--svl/source/items/itemset.cxx529
-rw-r--r--svl/source/items/whiter.cxx25
-rw-r--r--svx/qa/unit/removewhichrange.cxx107
-rw-r--r--svx/source/dialog/hdft.cxx8
-rw-r--r--svx/source/dialog/srchdlg.cxx25
-rw-r--r--svx/source/svdraw/svdedxv.cxx61
-rw-r--r--svx/source/svdraw/svdetc.cxx30
-rw-r--r--sw/inc/swatrset.hxx1
-rw-r--r--sw/source/core/attr/swatrset.cxx7
-rw-r--r--sw/source/core/txtnode/thints.cxx10
-rw-r--r--sw/source/core/undo/unattr.cxx6
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx2
-rw-r--r--sw/source/ui/chrdlg/drpcps.cxx7
-rw-r--r--sw/source/ui/chrdlg/numpara.cxx5
-rw-r--r--sw/source/ui/chrdlg/swuiccoll.cxx5
-rw-r--r--sw/source/ui/dialog/swdlgfact.cxx6
-rw-r--r--sw/source/ui/dialog/swdlgfact.hxx6
-rw-r--r--sw/source/ui/envelp/envfmt.cxx82
-rw-r--r--sw/source/ui/frmdlg/column.cxx5
-rw-r--r--sw/source/ui/frmdlg/frmpage.cxx14
-rw-r--r--sw/source/ui/frmdlg/wrap.cxx7
-rw-r--r--sw/source/ui/misc/pgfnote.cxx5
-rw-r--r--sw/source/ui/misc/pggrid.cxx7
-rw-r--r--sw/source/uibase/inc/column.hxx4
-rw-r--r--sw/source/uibase/inc/drpcps.hxx4
-rw-r--r--sw/source/uibase/inc/frmpage.hxx8
-rw-r--r--sw/source/uibase/inc/numpara.hxx4
-rw-r--r--sw/source/uibase/inc/pgfnote.hxx4
-rw-r--r--sw/source/uibase/inc/pggrid.hxx2
-rw-r--r--sw/source/uibase/inc/swuiccoll.hxx4
-rw-r--r--sw/source/uibase/inc/wrap.hxx4
-rw-r--r--sw/source/uibase/shells/drwbassh.cxx2
-rw-r--r--sw/source/uibase/uiview/formatclipboard.cxx7
-rw-r--r--sw/source/uibase/utlui/uitool.cxx29
121 files changed, 994 insertions, 1150 deletions
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");
@@ -659,7 +651,7 @@ bool SfxTabDialogController::PrepareLeaveCurrentPage()
return bEnd;
}
-const sal_uInt16* SfxTabDialogController::GetInputRanges(const SfxItemPool& rPool)
+const WhichRangesContainer & SfxTabDialogController::GetInputRanges(const SfxItemPool& rPool)
/* [Description]
@@ -686,8 +678,8 @@ const sal_uInt16* SfxTabDialogController::GetInputRanges(const SfxItemPool& rPoo
return m_pSet->GetRanges();
}
- if ( m_pRanges )
- return m_pRanges.get();
+ if ( !m_pRanges.empty() )
+ return m_pRanges;
SfxItemSet aUS(const_cast<SfxItemPool&>(rPool));
for (auto const& elem : m_pImpl->aData)
@@ -695,26 +687,19 @@ const sal_uInt16* SfxTabDialogController::GetInputRanges(const SfxItemPool& rPoo
if ( elem->fnGetRanges )
{
- const sal_uInt16* pTmpRanges = (elem->fnGetRanges)();
+ const WhichRangesContainer& pTmpRanges = (elem->fnGetRanges)();
- for (const sal_uInt16* pIter = pTmpRanges; *pIter;)
+ for (const auto & rPair : pTmpRanges)
{
- sal_uInt16 nWidFrom = rPool.GetWhich(*pIter++);
- assert(*pIter);
- sal_uInt16 nWidTo = rPool.GetWhich(*pIter++);
+ sal_uInt16 nWidFrom = rPool.GetWhich(rPair.first);
+ sal_uInt16 nWidTo = rPool.GetWhich(rPair.second);
aUS.MergeRange(nWidFrom, nWidTo); // Keep it valid
}
}
}
- int nSize = 0;
- for (const sal_uInt16* pIter = aUS.GetRanges(); pIter && *pIter; pIter++)
- ++nSize;
-
- m_pRanges.reset(new sal_uInt16[nSize + 1]);
- std::copy(aUS.GetRanges(), aUS.GetRanges() + nSize, m_pRanges.get());
- m_pRanges[nSize] = 0;
- return m_pRanges.get();
+ m_pRanges = aUS.GetRanges();
+ return m_pRanges;
}
SfxTabDialogController::~SfxTabDialogController()
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 95d1d5d1dfeb..1809c9c136cc 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -2538,12 +2538,12 @@ void SfxViewFrame::StateView_Impl
// I'm just on reload and am yielding myself ...
return;
- const sal_uInt16 *pRanges = rSet.GetRanges();
- assert(pRanges && "Set with no Range");
- while ( *pRanges )
+ const WhichRangesContainer & pRanges = rSet.GetRanges();
+ assert(!pRanges.empty() && "Set with no Range");
+ for ( auto const & pRange : pRanges )
{
- sal_uInt16 nStartWhich = *pRanges++;
- sal_uInt16 nEndWhich = *pRanges++;
+ sal_uInt16 nStartWhich = pRange.first;
+ sal_uInt16 nEndWhich = pRange.second;
for ( sal_uInt16 nWhich = nStartWhich; nWhich <= nEndWhich; ++nWhich )
{
switch(nWhich)
@@ -3064,11 +3064,11 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
void SfxViewFrame::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)
{
@@ -3166,8 +3166,6 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
break;
}
}
-
- ++pRanges;
}
}
diff --git a/sfx2/source/view/viewfrm2.cxx b/sfx2/source/view/viewfrm2.cxx
index 370459a3ec0f..744a8fe1bcb1 100644
--- a/sfx2/source/view/viewfrm2.cxx
+++ b/sfx2/source/view/viewfrm2.cxx
@@ -267,11 +267,11 @@ void SfxViewFrame::GetState_Impl( SfxItemSet &rSet )
if ( !pDocSh )
return;
- const sal_uInt16 *pRanges = rSet.GetRanges();
- DBG_ASSERT(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)
{
@@ -314,7 +314,6 @@ void SfxViewFrame::GetState_Impl( SfxItemSet &rSet )
OSL_FAIL( "invalid message-id" );
}
}
- ++pRanges;
}
}
diff --git a/solenv/gdb/libreoffice/svl.py b/solenv/gdb/libreoffice/svl.py
index 99a0fad70092..28ca2997e5d7 100644
--- a/solenv/gdb/libreoffice/svl.py
+++ b/solenv/gdb/libreoffice/svl.py
@@ -25,12 +25,11 @@ class ItemSetPrinter(object):
% (self.value['m_pPool'], self.value['m_pParent'], whichranges)
def which_ranges(self):
- whichranges = self.value['m_pWhichRanges']
- index = 0
+ whichranges = self.value['m_pWhichRanges']['m_pairs']
+ whichranges_cnt = self.value['m_pWhichRanges']['m_size']
whiches = []
- while (whichranges[index]):
- whiches.append((int(whichranges[index]), int(whichranges[index+1])))
- index = index + 2
+ for index in range(whichranges_cnt):
+ whiches.append((int(whichranges[index]['first']), int(whichranges[index]['second'])))
return whiches
def children(self):
diff --git a/svl/source/inc/items_helper.hxx b/svl/source/inc/items_helper.hxx
index 75582d9f8741..da81ecf334da 100644
--- a/svl/source/inc/items_helper.hxx
+++ b/svl/source/inc/items_helper.hxx
@@ -30,12 +30,7 @@
namespace svl::detail
{
-/**
- * Determines the number of sal_uInt16s in a 0-terminated array of pairs of
- * sal_uInt16s, each representing a range of sal_uInt16s, and total capacity of the ranges.
- * The terminating 0 is included in the count.
- */
-inline std::pair<sal_uInt16, sal_uInt16> CountRanges(const sal_uInt16* pRanges)
+inline std::pair<sal_uInt16, sal_uInt16> CountRangesOld(const sal_uInt16* pRanges)
{
sal_uInt16 nCount = 0;
sal_uInt16 nCapacity = 0;
@@ -51,75 +46,32 @@ inline std::pair<sal_uInt16, sal_uInt16> CountRanges(const sal_uInt16* pRanges)
}
return { nCount, nCapacity };
}
-
-// Adds a range to which ranges, keeping the ranges in valid state (sorted, non-overlapping)
-inline std::unique_ptr<sal_uInt16[]> MergeRange(const sal_uInt16* pWhichRanges, sal_uInt16 nFrom,
- sal_uInt16 nTo)
+/**
+ * Determines the number of sal_uInt16s in a container of pairs of
+ * sal_uInt16s, each representing a range of sal_uInt16s, and total capacity of the ranges.
+ */
+inline sal_uInt16 CountRanges(const WhichRangesContainer& pRanges)
{
- assert(validRange(nFrom, nTo));
-
- if (!pWhichRanges)
- {
- auto pNewRanges = std::make_unique<sal_uInt16[]>(3);
- pNewRanges[0] = nFrom;
- pNewRanges[1] = nTo;
- pNewRanges[2] = 0;
- return pNewRanges;
- }
-
- assert(validRanges(pWhichRanges));
-
- // create vector of ranges (sal_uInt16 pairs of lower and upper bound)
- const size_t nOldCount = CountRanges(pWhichRanges).first;
- std::vector<std::pair<sal_uInt16, sal_uInt16>> aRangesTable;
- aRangesTable.reserve(nOldCount / 2 + 1);
- bool bAdded = false;
- for (size_t i = 0; i + 1 < nOldCount; i += 2)
+ sal_uInt16 nCapacity = 0;
+ for (const auto& rPair : pRanges)
{
- if (!bAdded && pWhichRanges[i] >= nFrom)
- { // insert new range, keep ranges sorted
- aRangesTable.emplace_back(std::pair<sal_uInt16, sal_uInt16>(nFrom, nTo));
- bAdded = true;
- }
- // insert current range
- aRangesTable.emplace_back(
- std::pair<sal_uInt16, sal_uInt16>(pWhichRanges[i], pWhichRanges[i + 1]));
+ nCapacity += rangeSize(rPair.first, rPair.second);
}
- if (!bAdded)
- aRangesTable.emplace_back(std::pair<sal_uInt16, sal_uInt16>(nFrom, nTo));
-
- // true if ranges overlap or adjoin, false if ranges are separate
- auto needMerge
- = [](std::pair<sal_uInt16, sal_uInt16> lhs, std::pair<sal_uInt16, sal_uInt16> rhs) {
- return (lhs.first - 1) <= rhs.second && (rhs.first - 1) <= lhs.second;
- };
+ return nCapacity;
+}
- auto it = aRangesTable.begin();
- // we got at least one range
- for (;;)
+inline bool validRanges2(const WhichRangesContainer& pRanges)
+{
+ for (sal_Int32 i = 0; i < pRanges.size(); ++i)
{
- auto itNext = std::next(it);
- if (itNext == aRangesTable.end())
- break;
- // check neighbouring ranges, find first range which overlaps or adjoins a previous range
- if (needMerge(*it, *itNext))
- {
- // lower bounds are sorted, implies: it->first = min(it[0].first, it[1].first)
- it->second = std::max(it->second, itNext->second);
- aRangesTable.erase(itNext);
- }
- else
- ++it;
+ auto p = pRanges[i];
+ if (!validRange(p.first, p.second))
+ return false;
+ // ranges must be sorted
+ if (i < pRanges.size() - 1 && !validGap(p.second, pRanges[i + 1].first))
+ return false;
}
-
- // construct range array
- const size_t nNewSize = 2 * aRangesTable.size() + 1;
- auto pNewRanges = std::make_unique<sal_uInt16[]>(nNewSize);
- for (size_t i = 0; i < (nNewSize - 1); i += 2)
- std::tie(pNewRanges[i], pNewRanges[i + 1]) = aRangesTable[i / 2];
-
- pNewRanges[nNewSize - 1] = 0;
- return pNewRanges;
+ return true;
}
}
diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx
index 3ec1be562a01..b2819cc46bd5 100644
--- a/svl/source/inc/poolio.hxx
+++ b/svl/source/inc/poolio.hxx
@@ -157,7 +157,7 @@ struct SfxItemPool_Impl
std::vector<SfxPoolItem*>* mpStaticDefaults;
SfxItemPool* mpMaster;
rtl::Reference<SfxItemPool> mpSecondary;
- std::unique_ptr<sal_uInt16[]> mpPoolRanges;
+ WhichRangesContainer mpPoolRanges;
sal_uInt16 mnStart;
sal_uInt16 mnEnd;
MapUnit eDefMetric;
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index f4976b1b7767..fe13cfb96a32 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -765,26 +765,25 @@ SfxItemPool* SfxItemPool::GetMasterPool() const
*/
void SfxItemPool::FreezeIdRanges()
{
- assert(!pImpl->mpPoolRanges && "pool already frozen, cannot freeze twice");
+ assert(pImpl->mpPoolRanges.empty() && "pool already frozen, cannot freeze twice");
FillItemIdRanges_Impl( pImpl->mpPoolRanges );
}
-void SfxItemPool::FillItemIdRanges_Impl( std::unique_ptr<sal_uInt16[]>& pWhichRanges ) const
+void SfxItemPool::FillItemIdRanges_Impl( WhichRangesContainer& pWhichRanges ) const
{
- DBG_ASSERT( !pImpl->mpPoolRanges, "GetFrozenRanges() would be faster!" );
+ DBG_ASSERT( pImpl->mpPoolRanges.empty(), "GetFrozenRanges() would be faster!" );
pWhichRanges.reset();
// Merge all ranges, keeping them sorted
for (const SfxItemPool* pPool = this; pPool; pPool = pPool->pImpl->mpSecondary.get())
- pWhichRanges = svl::detail::MergeRange(pWhichRanges.get(), pPool->pImpl->mnStart,
- pPool->pImpl->mnEnd);
+ pWhichRanges = pWhichRanges.MergeRange(pPool->pImpl->mnStart, pPool->pImpl->mnEnd);
}
-const sal_uInt16* SfxItemPool::GetFrozenIdRanges() const
+const WhichRangesContainer& SfxItemPool::GetFrozenIdRanges() const
{
- return pImpl->mpPoolRanges.get();
+ return pImpl->mpPoolRanges;
}
const SfxPoolItem *SfxItemPool::GetItem2Default(sal_uInt16 nWhich) const
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 5b986167686f..66673ad69968 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -47,36 +47,54 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool)
, m_pParent(nullptr)
, m_nCount(0)
{
- m_pWhichRanges = const_cast<sal_uInt16*>(m_pPool->GetFrozenIdRanges());
- assert( m_pWhichRanges && "don't create ItemSets with full range before FreezeIdRanges()" );
- if (!m_pWhichRanges)
- {
- std::unique_ptr<sal_uInt16[]> tmp;
- m_pPool->FillItemIdRanges_Impl(tmp);
- m_pWhichRanges = tmp.release();
- }
- assert(svl::detail::validRanges(m_pWhichRanges));
+ m_pWhichRanges = m_pPool->GetFrozenIdRanges();
+ assert( !m_pWhichRanges.empty() && "don't create ItemSets with full range before FreezeIdRanges()" );
+ assert(svl::detail::validRanges2(m_pWhichRanges));
const sal_uInt16 nSize = TotalCount();
m_pItems.reset(new const SfxPoolItem*[nSize]{});
}
-sal_uInt16 SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable)
+SfxItemSet::SfxItemSet(
+ SfxItemPool & pool, std::initializer_list<sal_uInt16> wids,
+ std::size_t items):
+ m_pPool(&pool), m_pParent(nullptr),
+ m_pItems(new SfxPoolItem const *[items]{}),
+ // cannot overflow, assuming std::size_t is no smaller than sal_uInt16,
+ // as wids.size() must be substantially smaller than
+ // std::numeric_limits<sal_uInt16>::max() by construction in
+ // SfxItemSet::create
+ m_nCount(0)
+{
+ assert(wids.size() != 0);
+ assert(wids.size() % 2 == 0);
+ std::unique_ptr<WhichPair[]> xPairs = std::make_unique<WhichPair[]>(wids.size()/2);
+ std::size_t i = 0;
+ for (auto it = wids.begin(); it != wids.end(); ) {
+ sal_uInt16 nStart = *it;
+ ++it;
+ sal_uInt16 nEnd = *it;
+ ++it;
+ xPairs[i++] = { nStart, nEnd };
+ }
+ m_pWhichRanges = WhichRangesContainer(std::move(xPairs), wids.size()/2);
+ assert(svl::detail::validRanges2(m_pWhichRanges));
+}
+
+SfxItemSet::SfxItemSet( SfxItemPool& rPool, SfxAllItemSetFlag )
+ : m_pPool(&rPool)
+ , m_pParent(nullptr)
+ , m_nCount(0)
{
- const auto& [nCnt, nCap] = svl::detail::CountRanges(pWhichPairTable);
- m_pItems.reset(new const SfxPoolItem* [nCap] {});
- m_pWhichRanges = new sal_uInt16[nCnt];
- memcpy(m_pWhichRanges, pWhichPairTable, sizeof(sal_uInt16) * nCnt);
- assert(svl::detail::validRanges(m_pWhichRanges));
- return nCap;
}
SfxItemSet::SfxItemSet(
- SfxItemPool & pool, std::initializer_list<sal_uInt16> wids,
+ SfxItemPool & pool,
+ const WhichRangesContainer& wids,
std::size_t items):
m_pPool(&pool), m_pParent(nullptr),
m_pItems(new SfxPoolItem const *[items]{}),
- m_pWhichRanges(new sal_uInt16[wids.size() + 1]),
+ m_pWhichRanges(wids),
// cannot overflow, assuming std::size_t is no smaller than sal_uInt16,
// as wids.size() must be substantially smaller than
// std::numeric_limits<sal_uInt16>::max() by construction in
@@ -84,56 +102,90 @@ SfxItemSet::SfxItemSet(
m_nCount(0)
{
assert(wids.size() != 0);
- assert(wids.size() % 2 == 0);
- std::copy(wids.begin(), wids.end(), m_pWhichRanges);
- m_pWhichRanges[wids.size()] = 0;
- assert(svl::detail::validRanges(m_pWhichRanges));
+ assert(svl::detail::validRanges2(m_pWhichRanges));
+}
+
+SfxItemSet::SfxItemSet(
+ SfxItemPool & pool,
+ WhichRangesContainer&& wids,
+ std::size_t items):
+ m_pPool(&pool), m_pParent(nullptr),
+ m_pItems(new SfxPoolItem const *[items]{}),
+ m_pWhichRanges(std::move(wids)),
+ // cannot overflow, assuming std::size_t is no smaller than sal_uInt16,
+ // as wids.size() must be substantially smaller than
+ // std::numeric_limits<sal_uInt16>::max() by construction in
+ // SfxItemSet::create
+ m_nCount(0)
+{
+ assert(m_pWhichRanges.size() != 0);
+ assert(svl::detail::validRanges2(m_pWhichRanges));
+}
+
+SfxItemSet::SfxItemSet(
+ SfxItemPool & pool, const WhichRangesContainer& wids):
+ m_pPool(&pool), m_pParent(nullptr),
+ m_pWhichRanges(wids),
+ m_nCount(0)
+{
+ assert(wids.size() != 0);
+ assert(svl::detail::validRanges2(m_pWhichRanges));
+ std::size_t size = svl::detail::CountRanges(wids);
+ m_pItems.reset( new SfxPoolItem const *[size]{} );
+}
+
+SfxItemSet::SfxItemSet(
+ SfxItemPool & pool, WhichRangesContainer&& wids):
+ m_pPool(&pool), m_pParent(nullptr),
+ m_pWhichRanges(std::move(wids)),
+ m_nCount(0)
+{
+ assert(svl::detail::validRanges2(m_pWhichRanges));
+ std::size_t size = svl::detail::CountRanges(m_pWhichRanges);
+ m_pItems.reset( new SfxPoolItem const *[size]{} );
}
SfxItemSet::SfxItemSet(
SfxItemPool & pool, std::initializer_list<Pair> wids):
m_pPool(&pool), m_pParent(nullptr),
- m_pWhichRanges(new sal_uInt16[2 * wids.size() + 1]), //TODO: overflow
m_nCount(0)
{
assert(wids.size() != 0);
+ std::unique_ptr<WhichPair[]> xPairs = std::make_unique<WhichPair[]>(wids.size());
std::size_t i = 0;
std::size_t size = 0;
for (auto const & p: wids) {
- m_pWhichRanges[i++] = p.wid1;
- m_pWhichRanges[i++] = p.wid2;
+ xPairs[i++] = { p.wid1, p.wid2 };
size += svl::detail::rangeSize(p.wid1, p.wid2);
// cannot overflow, assuming std::size_t is no smaller than
// sal_uInt16
}
- m_pWhichRanges[i] = 0;
- assert(svl::detail::validRanges(m_pWhichRanges));
+ m_pWhichRanges = WhichRangesContainer(std::move(xPairs), wids.size());
+ assert(svl::detail::validRanges2(m_pWhichRanges));
m_pItems.reset( new SfxPoolItem const *[size]{} );
}
SfxItemSet::SfxItemSet( SfxItemPool& rPool, const sal_uInt16* pWhichPairTable )
: m_pPool(&rPool)
, m_pParent(nullptr)
- , m_pWhichRanges(nullptr)
, m_nCount(0)
{
- // pWhichPairTable == 0 is for the SfxAllEnumItemSet
- if ( pWhichPairTable )
- InitRanges_Impl(pWhichPairTable);
+ const auto& [nCnt, nCap] = svl::detail::CountRangesOld(pWhichPairTable);
+ m_pItems.reset(new const SfxPoolItem* [nCap] {});
+ m_pWhichRanges = WhichRangesContainer(reinterpret_cast<const WhichPair*>(pWhichPairTable), (nCnt-1)/2);
}
SfxItemSet::SfxItemSet( const SfxItemSet& rASet )
: m_pPool( rASet.m_pPool )
, m_pParent( rASet.m_pParent )
+ , m_pWhichRanges( rASet.m_pWhichRanges )
, m_nCount( rASet.m_nCount )
{
- if (!rASet.m_pWhichRanges)
- {
- m_pWhichRanges = nullptr;
+ if (rASet.m_pWhichRanges.empty())
return;
- }
- sal_uInt16 nCnt = InitRanges_Impl(rASet.m_pWhichRanges);
+ auto nCnt = svl::detail::CountRanges(m_pWhichRanges);
+ m_pItems.reset(new const SfxPoolItem* [nCnt] {});
// Copy attributes
SfxPoolItem const** ppDst = m_pItems.get();
@@ -156,26 +208,25 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet )
// !IsPoolable() => assign via Pool
*ppDst = &m_pPool->Put( **ppSrc );
- assert(svl::detail::validRanges(m_pWhichRanges));
+ assert(svl::detail::validRanges2(m_pWhichRanges));
}
SfxItemSet::SfxItemSet(SfxItemSet&& rASet) noexcept
: m_pPool( rASet.m_pPool )
, m_pParent( rASet.m_pParent )
, m_pItems( std::move(rASet.m_pItems) )
- , m_pWhichRanges( rASet.m_pWhichRanges )
+ , m_pWhichRanges( std::move(rASet.m_pWhichRanges) )
, m_nCount( rASet.m_nCount )
{
rASet.m_pPool = nullptr;
rASet.m_pParent = nullptr;
- rASet.m_pWhichRanges = nullptr;
rASet.m_nCount = 0;
- assert(svl::detail::validRanges(m_pWhichRanges));
+ assert(svl::detail::validRanges2(m_pWhichRanges));
}
SfxItemSet::~SfxItemSet()
{
- if (m_pWhichRanges) // might be nullptr if we have been moved-from
+ if (!m_pWhichRanges.empty()) // might be nullptr if we have been moved-from
{
sal_uInt16 nCount = TotalCount();
if( Count() )
@@ -200,9 +251,7 @@ SfxItemSet::~SfxItemSet()
}
m_pItems.reset();
- if (m_pPool && m_pWhichRanges != m_pPool->GetFrozenIdRanges())
- delete[] m_pWhichRanges;
- m_pWhichRanges = nullptr; // for invariant-testing
+ m_pWhichRanges.reset(); // for invariant-testing
}
/**
@@ -218,14 +267,13 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich )
if( nWhich )
{
- const sal_uInt16* pPtr = m_pWhichRanges;
- while( *pPtr )
+ for (const WhichPair& rPair : m_pWhichRanges)
{
// Within this range?
- if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ if( rPair.first <= nWhich && nWhich <= rPair.second )
{
// Actually set?
- ppFnd += nWhich - *pPtr;
+ ppFnd += nWhich - rPair.first;
if( *ppFnd )
{
// Due to the assertions in the sub calls, we need to do the following
@@ -252,18 +300,16 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich )
// found => break
break;
}
- ppFnd += *(pPtr+1) - *pPtr + 1;
- pPtr += 2;
+ ppFnd += rPair.second - rPair.first + 1;
}
}
else
{
nDel = m_nCount;
- sal_uInt16* pPtr = m_pWhichRanges;
- while( *pPtr )
+ for (const WhichPair& rPair : m_pWhichRanges)
{
- for( nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ for( nWhich = rPair.first; nWhich <= rPair.second; ++nWhich, ++ppFnd )
if( *ppFnd )
{
// Due to the assertions in the sub calls, we need to do this
@@ -296,7 +342,6 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich )
}
}
}
- pPtr += 2;
}
}
return nDel;
@@ -304,17 +349,15 @@ sal_uInt16 SfxItemSet::ClearItem( sal_uInt16 nWhich )
void SfxItemSet::ClearInvalidItems()
{
- sal_uInt16* pPtr = m_pWhichRanges;
SfxPoolItem const** ppFnd = m_pItems.get();
- while( *pPtr )
+ for (const WhichPair& rPair : m_pWhichRanges)
{
- for( sal_uInt16 nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ for( sal_uInt16 nWhich = rPair.first; nWhich <= rPair.second; ++nWhich, ++ppFnd )
if( IsInvalidItem(*ppFnd) )
{
*ppFnd = nullptr;
--m_nCount;
}
- pPtr += 2;
}
}
@@ -335,39 +378,34 @@ SfxItemState SfxItemSet::GetItemState( sal_uInt16 nWhich,
do
{
SfxPoolItem const** ppFnd = pCurrentSet->m_pItems.get();
- const sal_uInt16* pPtr = pCurrentSet->m_pWhichRanges;
- if (pPtr)
+ for (const WhichPair& rPair : pCurrentSet->m_pWhichRanges)
{
- while ( *pPtr )
+ if ( rPair.first <= nWhich && nWhich <= rPair.second )
{
- if ( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ // Within this range
+ ppFnd += nWhich - rPair.first;
+ if ( !*ppFnd )
{
- // Within this range
- ppFnd += nWhich - *pPtr;
- if ( !*ppFnd )
- {
- eRet = SfxItemState::DEFAULT;
- if( !bSrchInParent )
- return eRet; // Not present
- break; // Keep searching in the parents!
- }
+ eRet = SfxItemState::DEFAULT;
+ if( !bSrchInParent )
+ return eRet; // Not present
+ break; // Keep searching in the parents!
+ }
- if ( IsInvalidItem(*ppFnd) )
- // Different ones are present
- return SfxItemState::DONTCARE;
+ if ( IsInvalidItem(*ppFnd) )
+ // Different ones are present
+ return SfxItemState::DONTCARE;
- if ( (*ppFnd)->IsVoidItem() )
- return SfxItemState::DISABLED;
+ if ( (*ppFnd)->IsVoidItem() )
+ return SfxItemState::DISABLED;
- if (ppItem)
- {
- *ppItem = *ppFnd;
- }
- return SfxItemState::SET;
+ if (ppItem)
+ {
+ *ppItem = *ppFnd;
}
- ppFnd += *(pPtr+1) - *pPtr + 1;
- pPtr += 2;
+ return SfxItemState::SET;
}
+ ppFnd += rPair.second - rPair.first + 1;
}
if (!bSrchInParent)
break;
@@ -393,13 +431,12 @@ const SfxPoolItem* SfxItemSet::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nWh
}
SfxPoolItem const** ppFnd = m_pItems.get();
- const sal_uInt16* pPtr = m_pWhichRanges;
- while( *pPtr )
+ for (const WhichPair& rPair : m_pWhichRanges)
{
- if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ if( rPair.first <= nWhich && nWhich <= rPair.second )
{
// Within this range
- ppFnd += nWhich - *pPtr;
+ ppFnd += nWhich - rPair.first;
if( *ppFnd ) // Already one present
{
// Same Item already present?
@@ -478,8 +515,7 @@ const SfxPoolItem* SfxItemSet::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nWh
"svl.items", "putted Item unequal, with ID/pos " << nWhich );
return *ppFnd;
}
- ppFnd += *(pPtr+1) - *pPtr + 1;
- pPtr += 2;
+ ppFnd += rPair.second - rPair.first + 1;
}
if (bPassingOwnership)
delete &rItem;
@@ -492,10 +528,9 @@ bool SfxItemSet::Put( const SfxItemSet& rSet, bool bInvalidAsDefault )
if( rSet.Count() )
{
SfxPoolItem const** ppFnd = rSet.m_pItems.get();
- const sal_uInt16* pPtr = rSet.m_pWhichRanges;
- while ( *pPtr )
+ for (const WhichPair& rPair : rSet.m_pWhichRanges)
{
- for ( sal_uInt16 nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ for ( sal_uInt16 nWhich = rPair.first; nWhich <= rPair.second; ++nWhich, ++ppFnd )
if( *ppFnd )
{
if ( IsInvalidItem( *ppFnd ) )
@@ -510,7 +545,6 @@ bool SfxItemSet::Put( const SfxItemSet& rSet, bool bInvalidAsDefault )
else
bRet |= nullptr != Put( **ppFnd, nWhich );
}
- pPtr += 2;
}
}
return bRet;
@@ -540,10 +574,9 @@ void SfxItemSet::PutExtended
{
// don't "optimize" with "if( rSet.Count()" because of dont-care + defaults
SfxPoolItem const** ppFnd = rSet.m_pItems.get();
- const sal_uInt16* pPtr = rSet.m_pWhichRanges;
- while ( *pPtr )
+ for (const WhichPair& rPair : rSet.m_pWhichRanges)
{
- for ( sal_uInt16 nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+ for ( sal_uInt16 nWhich = rPair.first; nWhich <= rPair.second; ++nWhich, ++ppFnd )
if( *ppFnd )
{
if ( IsInvalidItem( *ppFnd ) )
@@ -592,7 +625,6 @@ void SfxItemSet::PutExtended
assert(!"invalid Argument for eDefaultAs");
}
}
- pPtr += 2;
}
}
@@ -608,34 +640,39 @@ void SfxItemSet::MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo )
eItemState == SfxItemState::DEFAULT || eItemState == SfxItemState::SET)
return;
- auto pNewRanges = svl::detail::MergeRange(m_pWhichRanges, nFrom, nTo);
- SetRanges(pNewRanges.get());
+ auto pNewRanges = m_pWhichRanges.MergeRange(nFrom, nTo);
+ RecreateRanges_Impl(pNewRanges);
+ m_pWhichRanges = std::move(pNewRanges);
}
/**
* Modifies the ranges of settable items. Keeps state of items which
* are new ranges too.
*/
-void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges )
+void SfxItemSet::SetRanges( const WhichRangesContainer& pNewRanges )
{
// Identical Ranges?
if (m_pWhichRanges == pNewRanges)
return;
- if (m_pWhichRanges)
- {
- const sal_uInt16* pOld = m_pWhichRanges;
- const sal_uInt16* pNew = pNewRanges;
- while (*pOld == *pNew)
- {
- if (!*pOld && !*pNew)
- return;
- ++pOld;
- ++pNew;
- }
- }
+ assert(svl::detail::validRanges2(pNewRanges));
+ RecreateRanges_Impl(pNewRanges);
+ m_pWhichRanges = pNewRanges;
+}
+void SfxItemSet::SetRanges( WhichRangesContainer&& pNewRanges )
+{
+ // Identical Ranges?
+ if (m_pWhichRanges == pNewRanges)
+ return;
+ assert(svl::detail::validRanges2(pNewRanges));
+ RecreateRanges_Impl(pNewRanges);
+ m_pWhichRanges = std::move(pNewRanges);
+}
+
+void SfxItemSet::RecreateRanges_Impl(const WhichRangesContainer& pNewRanges)
+{
// create new item-array (by iterating through all new ranges)
- const auto& [nCount, nSize] = svl::detail::CountRanges(pNewRanges);
+ const auto nSize = svl::detail::CountRanges(pNewRanges);
SfxPoolItem const** aNewItems = new const SfxPoolItem* [ nSize ];
sal_uInt16 nNewCount = 0;
if (m_nCount == 0)
@@ -643,10 +680,10 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges )
else
{
sal_uInt16 n = 0;
- for ( const sal_uInt16 *pRange = pNewRanges; *pRange; pRange += 2 )
+ for ( auto const & pRange : pNewRanges )
{
// iterate through all ids in the range
- for ( sal_uInt16 nWID = *pRange; nWID <= pRange[1]; ++nWID, ++n )
+ for ( sal_uInt16 nWID = pRange.first; nWID <= pRange.second; ++nWID, ++n )
{
// direct move of pointer (not via pool)
SfxItemState eState = GetItemState( nWID, false, aNewItems+n );
@@ -687,20 +724,6 @@ void SfxItemSet::SetRanges( const sal_uInt16 *pNewRanges )
// replace old items-array and ranges
m_pItems.reset( aNewItems );
m_nCount = nNewCount;
-
- if( pNewRanges == GetPool()->GetFrozenIdRanges() )
- {
- delete[] m_pWhichRanges;
- m_pWhichRanges = const_cast<sal_uInt16*>(pNewRanges);
- }
- else
- {
- if (m_pWhichRanges != m_pPool->GetFrozenIdRanges())
- delete[] m_pWhichRanges;
- m_pWhichRanges = new sal_uInt16[ nCount ];
- memcpy( m_pWhichRanges, pNewRanges, sizeof( sal_uInt16 ) * nCount );
- }
- assert(svl::detail::validRanges(m_pWhichRanges));
}
/**
@@ -784,13 +807,12 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const
if( pCurrentSet->Count() )
{
SfxPoolItem const** ppFnd = pCurrentSet->m_pItems.get();
- const sal_uInt16* pPtr = pCurrentSet->m_pWhichRanges;
- while( *pPtr )
+ for (auto const & pPtr : pCurrentSet->m_pWhichRanges)
{
- if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ if( pPtr.first <= nWhich && nWhich <= pPtr.second )
{
// In this Range
- ppFnd += nWhich - *pPtr;
+ ppFnd += nWhich - pPtr.first;
if( *ppFnd )
{
if( IsInvalidItem(*ppFnd) ) {
@@ -809,8 +831,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const
}
break; // Continue with Parent
}
- ppFnd += *(pPtr+1) - *pPtr + 1;
- pPtr += 2;
+ ppFnd += pPtr.second - pPtr.first + 1;
}
}
//TODO: Search until end of Range: What are we supposed to do now? To the Parent or Default??
@@ -836,11 +857,9 @@ void SfxItemSet::Changed( const SfxPoolItem&, const SfxPoolItem& )
sal_uInt16 SfxItemSet::TotalCount() const
{
sal_uInt16 nRet = 0;
- sal_uInt16* pPtr = m_pWhichRanges;
- while( *pPtr )
+ for (auto const & pPtr : m_pWhichRanges)
{
- nRet += ( *(pPtr+1) - *pPtr ) + 1;
- pPtr += 2;
+ nRet += ( pPtr.second - pPtr.first ) + 1;
}
return nRet;
}
@@ -862,25 +881,10 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet )
return;
}
- // Test whether the Which Ranges are different
- sal_uInt16* pWh1 = m_pWhichRanges;
- sal_uInt16* pWh2 = rSet.m_pWhichRanges;
- sal_uInt16 nSize = 0;
-
- for( sal_uInt16 n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n )
- {
- if( *pWh1 != *pWh2 )
- {
- break;
- }
- if( n & 1 )
- nSize += ( *pWh1 - *(pWh1-1) ) + 1;
- }
- bool bEqual = *pWh1 == *pWh2; // Also check for 0
-
// If the Ranges are identical, we can easily process it
- if( bEqual )
+ if( m_pWhichRanges == rSet.m_pWhichRanges )
{
+ sal_uInt16 nSize = TotalCount();
SfxPoolItem const** ppFnd1 = m_pItems.get();
SfxPoolItem const** ppFnd2 = rSet.m_pItems.get();
@@ -926,25 +930,10 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet )
if( !Count() || !rSet.Count() )// None set?
return;
- // Test whether the Which Ranges are different
- sal_uInt16* pWh1 = m_pWhichRanges;
- sal_uInt16* pWh2 = rSet.m_pWhichRanges;
- sal_uInt16 nSize = 0;
-
- for( sal_uInt16 n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n )
- {
- if( *pWh1 != *pWh2 )
- {
- break;
- }
- if( n & 1 )
- nSize += ( *pWh1 - *(pWh1-1) ) + 1;
- }
- bool bEqual = *pWh1 == *pWh2; // Also test for 0
-
// If the Ranges are identical, we can easily process it
- if( bEqual )
+ if( m_pWhichRanges == rSet.m_pWhichRanges )
{
+ sal_uInt16 nSize = TotalCount();
SfxPoolItem const** ppFnd1 = m_pItems.get();
SfxPoolItem const** ppFnd2 = rSet.m_pItems.get();
@@ -1134,25 +1123,10 @@ void SfxItemSet::MergeValues( const SfxItemSet& rSet )
// WARNING! When making changes/fixing bugs, always update the table above!!
assert( GetPool() == rSet.GetPool() && "MergeValues with different Pools" );
- // Test if the which Ranges are different
- sal_uInt16* pWh1 = m_pWhichRanges;
- sal_uInt16* pWh2 = rSet.m_pWhichRanges;
- sal_uInt16 nSize = 0;
-
- for( sal_uInt16 n = 0; *pWh1 && *pWh2; ++pWh1, ++pWh2, ++n )
- {
- if( *pWh1 != *pWh2 )
- {
- break;
- }
- if( n & 1 )
- nSize += ( *pWh1 - *(pWh1-1) ) + 1;
- }
- bool bEqual = *pWh1 == *pWh2; // Also check for 0
-
// If the Ranges match, they are easier to process!
- if( bEqual )
+ if( m_pWhichRanges == rSet.m_pWhichRanges )
{
+ sal_uInt16 nSize = TotalCount();
SfxPoolItem const** ppFnd1 = m_pItems.get();
SfxPoolItem const** ppFnd2 = rSet.m_pItems.get();
@@ -1184,32 +1158,29 @@ void SfxItemSet::MergeValues( const SfxItemSet& rSet )
void SfxItemSet::MergeValue( const SfxPoolItem& rAttr, bool bIgnoreDefaults )
{
SfxPoolItem const** ppFnd = m_pItems.get();
- const sal_uInt16* pPtr = m_pWhichRanges;
const sal_uInt16 nWhich = rAttr.Which();
- while( *pPtr )
+ for( auto const & pPtr : m_pWhichRanges )
{
// In this Range??
- if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ if( pPtr.first <= nWhich && nWhich <= pPtr.second )
{
- ppFnd += nWhich - *pPtr;
+ ppFnd += nWhich - pPtr.first;
MergeItem_Impl(m_pPool, m_nCount, ppFnd, &rAttr, bIgnoreDefaults);
break;
}
- ppFnd += *(pPtr+1) - *pPtr + 1;
- pPtr += 2;
+ ppFnd += pPtr.second - pPtr.first + 1;
}
}
void SfxItemSet::InvalidateItem( sal_uInt16 nWhich )
{
SfxPoolItem const** ppFnd = m_pItems.get();
- const sal_uInt16* pPtr = m_pWhichRanges;
- while( *pPtr )
+ for( auto const & pPtr : m_pWhichRanges )
{
- if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ if( pPtr.first <= nWhich && nWhich <= pPtr.second )
{
// In this Range?
- ppFnd += nWhich - *pPtr;
+ ppFnd += nWhich - pPtr.first;
if( *ppFnd ) // Set for me
{
@@ -1226,22 +1197,19 @@ void SfxItemSet::InvalidateItem( sal_uInt16 nWhich )
}
break;
}
- ppFnd += *(pPtr+1) - *pPtr + 1;
- pPtr += 2;
+ ppFnd += pPtr.second - pPtr.first + 1;
}
}
sal_uInt16 SfxItemSet::GetWhichByPos( sal_uInt16 nPos ) const
{
sal_uInt16 n = 0;
- sal_uInt16* pPtr = m_pWhichRanges;
- while( *pPtr )
+ for( auto const & pPtr : m_pWhichRanges )
{
- n = ( *(pPtr+1) - *pPtr ) + 1;
+ n = ( pPtr.second - pPtr.first ) + 1;
if( nPos < n )
- return *pPtr + nPos;
+ return pPtr.first + nPos;
nPos = nPos - n;
- pPtr += 2;
}
assert(false);
return 0;
@@ -1270,10 +1238,9 @@ bool SfxItemSet::Equals(const SfxItemSet &rCmp, bool bComparePool) const
return false;
// Are the Ranges themselves unequal?
- for (sal_uInt16 nRange = 0; m_pWhichRanges[nRange]; nRange += 2)
+ for (sal_Int32 i = 0; i < m_pWhichRanges.size(); ++i)
{
- if (m_pWhichRanges[nRange] != rCmp.m_pWhichRanges[nRange] ||
- m_pWhichRanges[nRange+1] != rCmp.m_pWhichRanges[nRange+1])
+ if (m_pWhichRanges[i] != rCmp.m_pWhichRanges[i])
{
// We must use the slow method then
SfxWhichIter aIter( *this );
@@ -1374,18 +1341,17 @@ SfxItemSet SfxItemSet::CloneAsValue(bool bItems, SfxItemPool *pToPool ) const
void SfxItemSet::PutDirect(const SfxPoolItem &rItem)
{
SfxPoolItem const** ppFnd = m_pItems.get();
- const sal_uInt16* pPtr = m_pWhichRanges;
const sal_uInt16 nWhich = rItem.Which();
#ifdef DBG_UTIL
IsPoolDefaultItem(&rItem) || m_pPool->CheckItemInPool(&rItem);
// Only cause assertion in the callees
#endif
- while( *pPtr )
+ for( auto const & pPtr : m_pWhichRanges)
{
- if( *pPtr <= nWhich && nWhich <= *(pPtr+1) )
+ if( pPtr.first <= nWhich && nWhich <= pPtr.second )
{
// In this Range?
- ppFnd += nWhich - *pPtr;
+ ppFnd += nWhich - pPtr.first;
const SfxPoolItem* pOld = *ppFnd;
if( pOld ) // One already present
{
@@ -1408,8 +1374,7 @@ void SfxItemSet::PutDirect(const SfxPoolItem &rItem)
return;
}
- ppFnd += *(pPtr+1) - *pPtr + 1;
- pPtr += 2;
+ ppFnd += pPtr.second - pPtr.first + 1;
}
}
@@ -1436,7 +1401,7 @@ void SfxItemSet::dumpAsXml(xmlTextWriterPtr pWriter) const
// ----------------------------------------------- class SfxAllItemSet
SfxAllItemSet::SfxAllItemSet( SfxItemPool &rPool )
-: SfxItemSet(rPool, nullptr)
+: SfxItemSet(rPool, SfxAllItemSetFlag::Flag)
{
}
@@ -1492,4 +1457,134 @@ SfxItemSet SfxAllItemSet::CloneAsValue(bool , SfxItemPool * ) const
throw std::logic_error("cannot do this");
}
+
+
+
+WhichRangesContainer::WhichRangesContainer( const WhichPair* wids, sal_Int32 nSize )
+{
+ auto p = new WhichPair[nSize];
+ memcpy(p, wids, nSize * sizeof(WhichPair));
+ m_pairs = p;
+ m_size = nSize;
+ m_bOwnRanges = true;
+}
+
+WhichRangesContainer::WhichRangesContainer(sal_uInt16 nWhichStart, sal_uInt16 nWhichEnd)
+ : m_size(1), m_bOwnRanges(true)
+{
+ auto p = new WhichPair[1];
+ p[0] = { nWhichStart, nWhichEnd };
+ m_pairs = p;
+}
+
+WhichRangesContainer::WhichRangesContainer(WhichRangesContainer && other)
+{
+ std::swap(m_pairs, other.m_pairs);
+ std::swap(m_size, other.m_size);
+ std::swap(m_bOwnRanges, other.m_bOwnRanges);
+}
+
+WhichRangesContainer& WhichRangesContainer::operator=(WhichRangesContainer && other)
+{
+ std::swap(m_pairs, other.m_pairs);
+ std::swap(m_size, other.m_size);
+ std::swap(m_bOwnRanges, other.m_bOwnRanges);
+ return *this;
+}
+
+WhichRangesContainer& WhichRangesContainer::operator=(WhichRangesContainer const & other)
+{
+ reset();
+ m_size = other.m_size;
+ m_bOwnRanges = other.m_bOwnRanges;
+ if (m_bOwnRanges)
+ {
+ auto p = new WhichPair[m_size];
+ memcpy(p, other.m_pairs, m_size * sizeof(WhichPair));
+ m_pairs = p;
+ }
+ else
+ m_pairs = other.m_pairs;
+ return *this;
+}
+
+WhichRangesContainer::~WhichRangesContainer()
+{
+ reset();
+}
+
+bool WhichRangesContainer::operator==(WhichRangesContainer const & other) const
+{
+ if (m_size != other.m_size)
+ return false;
+ if (m_pairs == other.m_pairs)
+ return true;
+ return std::equal(m_pairs, m_pairs + m_size, other.m_pairs, other.m_pairs + m_size);
+}
+
+
+void WhichRangesContainer::reset()
+{
+ if (m_bOwnRanges)
+ {
+ delete [] m_pairs;
+ m_bOwnRanges = false;
+ }
+ m_pairs = nullptr;
+ m_size = 0;
+}
+
+// Adds a range to which ranges, keeping the ranges in valid state (sorted, non-overlapping)
+WhichRangesContainer WhichRangesContainer::MergeRange(sal_uInt16 nFrom,
+ sal_uInt16 nTo) const
+{
+ assert(svl::detail::validRange(nFrom, nTo));
+
+ if (empty())
+ return WhichRangesContainer(nFrom, nTo);
+
+ // create vector of ranges (sal_uInt16 pairs of lower and upper bound)
+ const size_t nOldCount = size();
+ std::vector<WhichPair> aRangesTable;
+ aRangesTable.reserve(nOldCount);
+ bool bAdded = false;
+ for (const auto& rPair : *this)
+ {
+ if (!bAdded && rPair.first >= nFrom)
+ { // insert new range, keep ranges sorted
+ aRangesTable.push_back({ nFrom, nTo });
+ bAdded = true;
+ }
+ // insert current range
+ aRangesTable.emplace_back(rPair);
+ }
+ if (!bAdded)
+ aRangesTable.push_back({ nFrom, nTo });
+
+ // true if ranges overlap or adjoin, false if ranges are separate
+ auto needMerge = [](WhichPair lhs, WhichPair rhs) {
+ return (lhs.first - 1) <= rhs.second && (rhs.first - 1) <= lhs.second;
+ };
+
+ auto it = aRangesTable.begin();
+ // we got at least one range
+ for (;;)
+ {
+ auto itNext = std::next(it);
+ if (itNext == aRangesTable.end())
+ break;
+ // check neighbouring ranges, find first range which overlaps or adjoins a previous range
+ if (needMerge(*it, *itNext))
+ {
+ // lower bounds are sorted, implies: it->first = min(it[0].first, it[1].first)
+ it->second = std::max(it->second, itNext->second);
+ aRangesTable.erase(itNext);
+ }
+ else
+ ++it;
+ }
+
+ return WhichRangesContainer(aRangesTable.data(), aRangesTable.size());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/whiter.cxx b/svl/source/items/whiter.cxx
index 88b487b02d30..59f2790a530c 100644
--- a/svl/source/items/whiter.cxx
+++ b/svl/source/items/whiter.cxx
@@ -23,31 +23,40 @@
SfxWhichIter::SfxWhichIter( const SfxItemSet& rSet ):
pStart(rSet.GetRanges()),
- pRanges(pStart),
+ pRanges(pStart.begin()),
nOffset(0)
{
}
+sal_uInt16 SfxWhichIter::GetCurWhich() const
+{
+ if ( pRanges >= (pStart.begin() + pStart.size()) )
+ return 0;
+ return pRanges->first + nOffset;
+}
+
sal_uInt16 SfxWhichIter::NextWhich()
{
- if ( 0 == pRanges[0] )
+ if ( pRanges >= (pStart.begin() + pStart.size()) )
return 0;
- const sal_uInt16 nLastWhich = pRanges[0] + nOffset;
+ const sal_uInt16 nLastWhich = pRanges->first + nOffset;
++nOffset;
- if (pRanges[1] == nLastWhich)
+ if (pRanges->second == nLastWhich)
{
- pRanges += 2;
+ ++pRanges;
nOffset = 0;
}
- return pRanges[0] + nOffset;
+ if ( pRanges >= (pStart.begin() + pStart.size()) )
+ return 0;
+ return pRanges->first + nOffset;
}
sal_uInt16 SfxWhichIter::FirstWhich()
{
- pRanges = pStart;
+ pRanges = pStart.begin();
nOffset = 0;
- return pRanges[0];
+ return pRanges->first;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/removewhichrange.cxx b/svx/qa/unit/removewhichrange.cxx
index fc2b0a038931..1c45e2d7874e 100644
--- a/svx/qa/unit/removewhichrange.cxx
+++ b/svx/qa/unit/removewhichrange.cxx
@@ -16,6 +16,7 @@
#include <sal/types.h>
#include <svx/svdetc.hxx>
+#include <svl/itemset.hxx>
namespace
{
@@ -28,98 +29,88 @@ class TestRemoveWhichRange : public CppUnit::TestFixture
void testRemoveWhichRange()
{
{
- sal_uInt16 const in[] = { 0 };
+ WhichRangesContainer in;
auto const out = RemoveWhichRange(in, 10, 20);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[0]);
+ CPPUNIT_ASSERT(out.empty());
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 0, 20);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[2]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[0].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 10, 20);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[2]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[0].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 15, 20);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[2]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[3]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[0].second);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[1].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 30, 40);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[2]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 30, 50);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[2]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 30, 35);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[2]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[3]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[1].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 15, 35);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[2]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[3]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(14), out[0].second);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(36), out[1].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 12, 15);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(11), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(16), out[2]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[3]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[4]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[5]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[6]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(11), out[0].second);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(16), out[1].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1].second);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), out[2].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[2].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 30, 40, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 30, 40>::value);
auto const out = RemoveWhichRange(in, 0, 100);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[0]);
+ CPPUNIT_ASSERT(out.empty());
}
{
- sal_uInt16 const in[] = { 10, 20, 40, 50, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 40, 50>::value);
auto const out = RemoveWhichRange(in, 25, 35);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[2]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(50), out[3]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(50), out[1].second);
}
{
- sal_uInt16 const in[] = { 10, 20, 40, 50, 0 };
+ WhichRangesContainer in(svl::Items<10, 20, 40, 50>::value);
auto const out = RemoveWhichRange(in, 50, 100);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[1]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[2]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(49), out[3]);
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), out[4]);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(10), out[0].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), out[0].second);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(40), out[1].first);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(49), out[1].second);
}
}
};
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx
index 0cd7e9102abd..0fa7b35a4a3f 100644
--- a/svx/source/dialog/hdft.cxx
+++ b/svx/source/dialog/hdft.cxx
@@ -54,8 +54,7 @@ const tools::Long MINBODY = 56; // 1mm in twips rounded
const tools::Long DEF_DIST_WRITER = 500; // 5mm (Writer)
const tools::Long DEF_DIST_CALC = 250; // 2.5mm (Calc)
-const sal_uInt16 SvxHFPage::pRanges[] =
-{
+const WhichRangesContainer SvxHFPage::pRanges(svl::Items<
SID_ATTR_BRUSH, SID_ATTR_BRUSH,
// Support DrawingLayer FillStyles (no real call to below GetRanges()
@@ -74,9 +73,8 @@ const sal_uInt16 SvxHFPage::pRanges[] =
SID_ATTR_PAGE_DYNAMIC, SID_ATTR_PAGE_DYNAMIC,
SID_ATTR_PAGE_SHARED, SID_ATTR_PAGE_SHARED,
SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST,
- SID_ATTR_HDFT_DYNAMIC_SPACING, SID_ATTR_HDFT_DYNAMIC_SPACING,
- 0
-};
+ SID_ATTR_HDFT_DYNAMIC_SPACING, SID_ATTR_HDFT_DYNAMIC_SPACING
+>::value);
namespace svx {
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index 76ccbd333599..28fa49e0ba8a 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -127,7 +127,7 @@ struct SearchDlg_Impl
{
bool bSaveToModule : 1,
bFocusOnSearch : 1;
- std::unique_ptr<sal_uInt16[]> pRanges;
+ WhichRangesContainer pRanges;
Timer aSelectionTimer;
uno::Reference< frame::XDispatch > xCommand1Dispatch;
@@ -1053,19 +1053,8 @@ void SvxSearchDialog::InitAttrList_Impl( const SfxItemSet* pSSet,
if ( !pSSet && !pRSet )
return;
- if ( !pImpl->pRanges && pSSet )
- {
- const sal_uInt16* pPtr = pSSet->GetRanges();
- const sal_uInt16* pTmp = pPtr;
-
- while( *pPtr )
- {
- pPtr += 2;
- }
- sal_sSize nCnt = pPtr - pTmp + 1;
- pImpl->pRanges.reset( new sal_uInt16[nCnt] );
- memcpy( pImpl->pRanges.get(), pTmp, sizeof(sal_uInt16) * nCnt );
- }
+ if ( pImpl->pRanges.empty() && pSSet )
+ pImpl->pRanges = pSSet->GetRanges();
bool bSetOptimalLayoutSize = false;
@@ -1945,11 +1934,11 @@ IMPL_LINK_NOARG(SvxSearchDialog, FormatHdl_Impl, weld::Button&, void)
DBG_ASSERT( pSh, "no DocShell" );
- if ( !pSh || !pImpl->pRanges )
+ if ( !pSh || pImpl->pRanges.empty() )
return;
SfxItemPool& rPool = pSh->GetPool();
- SfxItemSet aSet(rPool, pImpl->pRanges.get());
+ SfxItemSet aSet(rPool, pImpl->pRanges);
aSet.MergeRange(SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL);
@@ -2066,11 +2055,11 @@ IMPL_LINK_NOARG(SvxSearchDialog, NoFormatHdl_Impl, weld::Button&, void)
IMPL_LINK_NOARG(SvxSearchDialog, AttributeHdl_Impl, weld::Button&, void)
{
- if ( !pSearchList || !pImpl->pRanges )
+ if ( !pSearchList || pImpl->pRanges.empty() )
return;
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSvxSearchAttributeDialog(m_xDialog.get(), *pSearchList, pImpl->pRanges.get()));
+ ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSvxSearchAttributeDialog(m_xDialog.get(), *pSearchList, pImpl->pRanges));
executeSubDialog(pDlg.get());
PaintAttrText_Impl();
}
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index be08b46b1f2e..5f4c4529bef0 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2218,10 +2218,9 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
// Otherwise split Set, if necessary.
// Now we build an ItemSet aSet that doesn't contain EE_Items from
// *pSet (otherwise it would be a copy).
- std::unique_ptr<sal_uInt16[]> pNewWhichTable
+ WhichRangesContainer pNewWhichTable
= RemoveWhichRange(pSet->GetRanges(), EE_ITEMS_START, EE_ITEMS_END);
- SfxItemSet aSet(mpModel->GetItemPool(), pNewWhichTable.get());
- pNewWhichTable.reset();
+ SfxItemSet aSet(mpModel->GetItemPool(), std::move(pNewWhichTable));
SfxWhichIter aIter(aSet);
sal_uInt16 nWhich = aIter.FirstWhich();
while (nWhich != 0)
@@ -2626,35 +2625,18 @@ bool SdrObjEditView::SupportsFormatPaintbrush(SdrInventor nObjectInventor,
}
}
-static const sal_uInt16* GetFormatRangeImpl(bool bTextOnly)
-{
- static const sal_uInt16 gFull[] = { XATTR_LINE_FIRST,
- XATTR_LINE_LAST,
- XATTR_FILL_FIRST,
- XATTRSET_FILL,
- SDRATTR_SHADOW_FIRST,
- SDRATTR_SHADOW_LAST,
- SDRATTR_MISC_FIRST,
- SDRATTR_MISC_LAST, // table cell formats
- SDRATTR_GRAF_FIRST,
- SDRATTR_GRAF_LAST,
- SDRATTR_TABLE_FIRST,
- SDRATTR_TABLE_LAST,
- EE_PARA_START,
- EE_PARA_END,
- EE_CHAR_START,
- EE_CHAR_END,
- 0,
- 0 };
-
- static const sal_uInt16 gTextOnly[] = { SDRATTR_MISC_FIRST,
- SDRATTR_MISC_LAST,
- EE_PARA_START,
- EE_PARA_END,
- EE_CHAR_START,
- EE_CHAR_END,
- 0,
- 0 };
+static WhichRangesContainer GetFormatRangeImpl(bool bTextOnly)
+{
+ static const WhichRangesContainer gFull(
+ svl::Items<XATTR_LINE_FIRST, XATTR_LINE_LAST, XATTR_FILL_FIRST, XATTRSET_FILL,
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, SDRATTR_MISC_FIRST,
+ SDRATTR_MISC_LAST, // table cell formats
+ SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
+ EE_PARA_START, EE_PARA_END, EE_CHAR_START, EE_CHAR_END>::value);
+
+ static const WhichRangesContainer gTextOnly(
+ svl::Items<SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, EE_PARA_START, EE_PARA_END, EE_CHAR_START,
+ EE_CHAR_END>::value);
return bTextOnly ? gTextOnly : gFull;
}
@@ -2692,16 +2674,16 @@ void SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr<SfxItemSet>& rFormatSe
}
}
-static SfxItemSet CreatePaintSet(const sal_uInt16* pRanges, SfxItemPool& rPool,
+static SfxItemSet CreatePaintSet(const WhichRangesContainer& pRanges, SfxItemPool& rPool,
const SfxItemSet& rSourceSet, const SfxItemSet& rTargetSet,
bool bNoCharacterFormats, bool bNoParagraphFormats)
{
SfxItemSet aPaintSet(rPool, pRanges);
- while (*pRanges)
+ for (const auto& pRange : pRanges)
{
- sal_uInt16 nWhich = *pRanges++;
- const sal_uInt16 nLastWhich = *pRanges++;
+ sal_uInt16 nWhich = pRange.first;
+ const sal_uInt16 nLastWhich = pRange.second;
if (bNoCharacterFormats && (nWhich == EE_CHAR_START))
continue;
@@ -2779,17 +2761,16 @@ void SdrObjEditView::ApplyFormatPaintBrush(SfxItemSet& rFormatSet, bool bNoChara
// All formatting items (see ranges above) that are unequal in selected shape and
// the format paintbrush are hard set on the selected shape.
- const sal_uInt16* pRanges = rFormatSet.GetRanges();
+ const WhichRangesContainer& pRanges = rFormatSet.GetRanges();
bool bTextOnly = true;
- while (*pRanges)
+ for (const auto& pRange : pRanges)
{
- if ((*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START))
+ if ((pRange.first != EE_PARA_START) && (pRange.first != EE_CHAR_START))
{
bTextOnly = false;
break;
}
- pRanges += 2;
}
if (!bTextOnly)
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 9967376bf078..aa8ef44ee845 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -367,39 +367,33 @@ bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnl
return bHas;
}
-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)
{
// Six possible cases (per range):
// [Beg..End] [nRangeBeg, nRangeEnd], to delete
// [b..e] [b..e] [b..e] Cases 1,3,2: doesn't matter, delete, doesn't matter + Ranges
// [b........e] [b........e] Cases 4,5 : shrink range | in
// [b......................e] Case 6 : splitting + pOldWhichTable
- std::vector<sal_uInt16> buf;
- for (auto p = pOldWhichTable; *p != 0; p += 2) {
- auto const begin = p[0];
- auto const end = p[1];
+ std::vector<WhichPair> buf;
+ for (const auto & rPair : pOldWhichTable) {
+ auto const begin = rPair.first;
+ auto const end = rPair.second;
if (end < nRangeBeg || begin > nRangeEnd) { // cases 1, 2
- buf.push_back(begin);
- buf.push_back(end);
+ buf.push_back({begin, end});
} else if (begin >= nRangeBeg && end <= nRangeEnd) { // case 3
// drop
} else if (end <= nRangeEnd) { // case 4
- buf.push_back(begin);
- buf.push_back(nRangeBeg - 1);
+ buf.push_back({begin, nRangeBeg - 1});
} else if (begin >= nRangeBeg) { // case 5
- buf.push_back(nRangeEnd + 1);
- buf.push_back(end);
+ buf.push_back({nRangeEnd + 1, end});
} else { // case 6
- buf.push_back(begin);
- buf.push_back(nRangeBeg - 1);
- buf.push_back(nRangeEnd + 1);
- buf.push_back(end);
+ buf.push_back({begin, nRangeBeg - 1});
+ buf.push_back({nRangeEnd + 1, end});
}
}
- std::unique_ptr<sal_uInt16[]> pNewWhichTable(new sal_uInt16[buf.size() + 1]);
+ std::unique_ptr<WhichPair[]> pNewWhichTable(new WhichPair[buf.size()]);
std::copy(buf.begin(), buf.end(), pNewWhichTable.get());
- pNewWhichTable[buf.size()] = 0;
- return pNewWhichTable;
+ return WhichRangesContainer(std::move(pNewWhichTable), buf.size());
}
diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx
index 02e82d5fa085..6edd8fba4165 100644
--- a/sw/inc/swatrset.hxx
+++ b/sw/inc/swatrset.hxx
@@ -163,6 +163,7 @@ class SW_DLLPUBLIC SwAttrSet final : public SfxItemSet
public:
SwAttrSet( SwAttrPool&, sal_uInt16 nWhich1, sal_uInt16 nWhich2 );
SwAttrSet( SwAttrPool&, const sal_uInt16* nWhichPairTable );
+ SwAttrSet( SwAttrPool&, const WhichRangesContainer& nWhichPairTable );
SwAttrSet( const SwAttrSet& );
virtual std::unique_ptr<SfxItemSet> Clone(bool bItems = true, SfxItemPool *pToPool = nullptr) const override;
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index b72e65222a31..b49043c029ce 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -73,7 +73,7 @@ SwAttrPool::SwAttrPool( SwDoc* pD )
pSdrPool->SetSecondaryPool(pEEgPool.get());
- if(!GetFrozenIdRanges())
+ if(GetFrozenIdRanges().empty())
{
FreezeIdRanges();
}
@@ -102,6 +102,11 @@ SwAttrSet::SwAttrSet( SwAttrPool& rPool, const sal_uInt16* nWhichPairTable )
{
}
+SwAttrSet::SwAttrSet( SwAttrPool& rPool, const WhichRangesContainer& nWhichPairTable )
+ : SfxItemSet( rPool, nWhichPairTable ), m_pOldSet( nullptr ), m_pNewSet( nullptr )
+{
+}
+
SwAttrSet::SwAttrSet( const SwAttrSet& rSet )
: SfxItemSet( rSet ), m_pOldSet( nullptr ), m_pNewSet( nullptr )
{
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index a3659ebbdd3d..052b56813823 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -2973,13 +2973,11 @@ bool SwpHints::TryInsertHint(
rNode.SetCalcHiddenCharFlags();
// fdo#71556: populate aWhichFormatAttr member of SwMsgPoolItem
- const sal_uInt16 *pRanges = pSet->GetRanges();
- while( (*pRanges) != 0 )
+ const WhichRangesContainer& pRanges = pSet->GetRanges();
+ for(auto const & rPair : pRanges)
{
- const sal_uInt16 nBeg = *pRanges;
- ++pRanges;
- const sal_uInt16 nEnd = *pRanges;
- ++pRanges;
+ const sal_uInt16 nBeg = rPair.first;
+ const sal_uInt16 nEnd = rPair.second;
for( sal_uInt16 nSubElem = nBeg; nSubElem <= nEnd; ++nSubElem )
if( pSet->HasItem( nSubElem ) )
aWhichSublist.push_back( nSubElem );
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 208f54cc7eb2..cbd9fe52cd99 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -649,7 +649,7 @@ void SwUndoResetAttr::SetAttrs( const o3tl::sorted_vector<sal_uInt16> &rAttrs )
SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr,
const SetAttrMode nFlags )
: SwUndo( SwUndoId::INSATTR, &rRange.GetDoc() ), SwUndRng( rRange )
- , m_AttrSet( rRange.GetDoc().GetAttrPool(), {{rAttr.Which(), rAttr.Which()}} )
+ , m_AttrSet( rRange.GetDoc().GetAttrPool(), rAttr.Which(), rAttr.Which() )
, m_pHistory( new SwHistory )
, m_nNodeIndex( ULONG_MAX )
, m_nInsertFlags( nFlags )
@@ -735,8 +735,8 @@ void SwUndoAttr::UndoImpl(::sw::UndoRedoContext & rContext)
}
const bool bToLast = (1 == m_AttrSet.Count())
- && (RES_TXTATR_FIELD <= *m_AttrSet.GetRanges())
- && (*m_AttrSet.GetRanges() <= RES_TXTATR_ANNOTATION);
+ && (RES_TXTATR_FIELD <= m_AttrSet.GetRanges()[0].first)
+ && (m_AttrSet.GetRanges()[0].first <= RES_TXTATR_ANNOTATION);
// restore old values
m_pHistory->TmpRollback( pDoc, 0, !bToLast );
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index f4394f76c4e4..6d978c26f30f 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -279,7 +279,7 @@ namespace sw
sal_uInt16 GetSetWhichFromSwDocWhich(const SfxItemSet &rSet,
const SwDoc &rDoc, sal_uInt16 nWhich)
{
- if (RES_WHICHHINT_END < *(rSet.GetRanges()))
+ if (RES_WHICHHINT_END < rSet.GetRanges()[0].first)
{
nWhich = TransformWhichBetweenPools(*rSet.GetPool(),
rDoc.GetAttrPool(), nWhich);
diff --git a/sw/source/ui/chrdlg/drpcps.cxx b/sw/source/ui/chrdlg/drpcps.cxx
index c1ef7c489846..f3ca8162ee15 100644
--- a/sw/source/ui/chrdlg/drpcps.cxx
+++ b/sw/source/ui/chrdlg/drpcps.cxx
@@ -55,10 +55,7 @@ using namespace css;
using namespace css::uno;
using namespace css::lang;
-const sal_uInt16 SwDropCapsPage::aPageRg[] = {
- RES_PARATR_DROP, RES_PARATR_DROP,
- 0
-};
+const WhichRangesContainer SwDropCapsPage::aPageRg(svl::Items<RES_PARATR_DROP, RES_PARATR_DROP>::value);
void SwDropCapsPict::SetText( const OUString& rT )
{
@@ -174,7 +171,7 @@ bool SwDropCapsPict::GetNextScriptSegment(size_t &nIdx, sal_Int32 &start, sal_In
void SwDropCapsPict::GetFontSettings( const SwDropCapsPage& _rPage, vcl::Font& _rFont, sal_uInt16 _nWhich )
{
- SfxItemSet aSet( _rPage.rSh.GetAttrPool(), {{_nWhich, _nWhich}});
+ SfxItemSet aSet( _rPage.rSh.GetAttrPool(), _nWhich, _nWhich);
_rPage.rSh.GetCurAttr(aSet);
SvxFontItem aFormatFont(static_cast<const SvxFontItem &>( aSet.Get(_nWhich)));
diff --git a/sw/source/ui/chrdlg/numpara.cxx b/sw/source/ui/chrdlg/numpara.cxx
index c4d1de17a62a..a40521c817bc 100644
--- a/sw/source/ui/chrdlg/numpara.cxx
+++ b/sw/source/ui/chrdlg/numpara.cxx
@@ -32,10 +32,7 @@
#include <sfx2/dispatch.hxx>
#include <sfx2/viewsh.hxx>
-const sal_uInt16 SwParagraphNumTabPage::aPageRg[] = {
- FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART_AT,
- 0
-};
+const WhichRangesContainer SwParagraphNumTabPage::aPageRg(svl::Items<FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART_AT>::value);
SwParagraphNumTabPage::SwParagraphNumTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rAttr)
: SfxTabPage(pPage, pController, "modules/swriter/ui/numparapage.ui", "NumParaPage", &rAttr)
diff --git a/sw/source/ui/chrdlg/swuiccoll.cxx b/sw/source/ui/chrdlg/swuiccoll.cxx
index 6b35b6a309e5..8f831b24b84f 100644
--- a/sw/source/ui/chrdlg/swuiccoll.cxx
+++ b/sw/source/ui/chrdlg/swuiccoll.cxx
@@ -32,10 +32,7 @@
#include <swuiccoll.hxx>
-const sal_uInt16 SwCondCollPage::m_aPageRg[] = {
- FN_COND_COLL, FN_COND_COLL,
- 0
-};
+const WhichRangesContainer SwCondCollPage::m_aPageRg(svl::Items<FN_COND_COLL, FN_COND_COLL>::value);
SwCondCollPage::SwCondCollPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet)
: SfxTabPage(pPage, pController, "modules/swriter/ui/conditionpage.ui", "ConditionPage", &rSet)
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 9fcc14e8a587..b3038f5b9a5b 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -291,7 +291,7 @@ const SfxItemSet* AbstractTabController_Impl::GetOutputItemSet() const
return m_xDlg->GetOutputItemSet();
}
-const sal_uInt16* AbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer AbstractTabController_Impl::GetInputRanges(const SfxItemPool& pItem )
{
return m_xDlg->GetInputRanges( pItem );
}
@@ -425,7 +425,7 @@ const SfxItemSet* AbstractSwLabDlg_Impl::GetOutputItemSet() const
return m_xDlg->GetOutputItemSet();
}
-const sal_uInt16* AbstractSwLabDlg_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer AbstractSwLabDlg_Impl::GetInputRanges(const SfxItemPool& pItem )
{
return m_xDlg->GetInputRanges( pItem );
}
@@ -480,7 +480,7 @@ const SfxItemSet* AbstractSwFieldDlg_Impl::GetOutputItemSet() const
return m_xDlg->GetOutputItemSet();
}
-const sal_uInt16* AbstractSwFieldDlg_Impl::GetInputRanges(const SfxItemPool& pItem )
+WhichRangesContainer AbstractSwFieldDlg_Impl::GetInputRanges(const SfxItemPool& pItem )
{
return m_xDlg->GetInputRanges( pItem );
}
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 3561adbb77d5..bfaf2c0745c4 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -243,7 +243,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;
//From class Window.
virtual void SetText( const OUString& rStr ) override;
@@ -336,7 +336,7 @@ public:
virtual short Execute() 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;
//From class Window.
virtual void SetText( const OUString& rStr ) override;
@@ -382,7 +382,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;
//From class Window.
virtual void SetText( const OUString& rStr ) override;
diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index f29d4f49ab99..62c98cc54a3a 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -44,68 +44,6 @@
#include <swabstdlg.hxx>
#include <swuiexp.hxx>
-namespace {
- /// Converts a ranges array to a list containing one entry for each
- /// element covered by the ranges.
- /// @param aRanges An array containing zero or more range specifications and
- /// terminated by one or more zero entries. A range
- /// specification is two consecutive entries that specify
- /// the start and end points of the range.
- /// @returns A vector containing one element for each item covered by the
- /// ranges. This is not guaranteed to be sorted and may contain
- /// duplicates if the original ranges contained overlaps.
- std::vector<sal_uInt16> lcl_convertRangesToList(const sal_uInt16 aRanges[]) {
- std::vector<sal_uInt16> aVec;
- int i = 0;
- while (aRanges[i])
- {
- for (sal_uInt16 n = aRanges[i]; n <= aRanges[i+1]; ++n)
- {
- aVec.push_back(n);
- }
- i += 2;
- }
- return aVec;
- }
-
- /// Converts a list of elements to a ranges array.
- /// @param rElements Vector of the initial elements, this need not be sorted,
- /// and may contain duplicate items. The vector is sorted
- /// on exit from this function but may still contain duplicates.
- /// @returns An array containing zero or more range specifications and
- /// terminated by one or more zero entries. A range specification
- /// is two consecutive entries that specify the start and end
- /// points of the range. This list will be sorted and will not
- /// contain any overlapping ranges.
- sal_uInt16* lcl_convertListToRanges(std::vector<sal_uInt16> &rElements) {
- std::sort(rElements.begin(), rElements.end());
- std::vector<sal_uInt16> aRanges;
- size_t i;
- for (i = 0; i < rElements.size(); ++i)
- {
- //Push the start of the this range.
- aRanges.push_back(rElements[i]);
- //Seek to the end of this range.
- while (i + 1 < rElements.size() && rElements[i+1] - rElements[i] <= 1)
- {
- ++i;
- }
- //Push the end of this range (may be the same as the start).
- aRanges.push_back( rElements[i] );
- }
-
- // Convert the vector to an array with terminating zero
- sal_uInt16 *pNewRanges = new sal_uInt16[aRanges.size() + 1];
- for (i = 0; i < aRanges.size(); ++i)
- {
- pNewRanges[i] = aRanges[i];
- }
- pNewRanges[i] = 0;
- return pNewRanges;
- }
-
-}
-
static tools::Long lUserW = 5669; // 10 cm
static tools::Long lUserH = 5669; // 10 cm
@@ -316,10 +254,9 @@ SfxItemSet *SwEnvFormatPage::GetCollItemSet(SwTextFormatColl const * pColl, bool
if (!pAddrSet)
{
// determine range (merge both Itemsets' ranges)
- const sal_uInt16 *pRanges = pColl->GetAttrSet().GetRanges();
+ const WhichRangesContainer& pRanges = pColl->GetAttrSet().GetRanges();
- static sal_uInt16 const aRanges[] =
- {
+ static WhichRangesContainer const aRanges(svl::Items<
RES_PARATR_BEGIN, RES_PARATR_ADJUST,
RES_PARATR_TABSTOP, RES_PARATR_END-1,
RES_LR_SPACE, RES_UL_SPACE,
@@ -327,18 +264,13 @@ SfxItemSet *SwEnvFormatPage::GetCollItemSet(SwTextFormatColl const * pColl, bool
SID_ATTR_TABSTOP_POS, SID_ATTR_TABSTOP_POS,
SID_ATTR_TABSTOP_DEFAULTS, SID_ATTR_TABSTOP_DEFAULTS,
SID_ATTR_TABSTOP_OFFSET, SID_ATTR_TABSTOP_OFFSET,
- SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
- 0, 0
- };
-
- // BruteForce merge because MergeRange in SvTools is buggy:
- std::vector<sal_uInt16> aVec2 = ::lcl_convertRangesToList(pRanges);
- std::vector<sal_uInt16> aVec = ::lcl_convertRangesToList(aRanges);
- aVec2.insert(aVec2.end(), aVec.begin(), aVec.end());
- std::unique_ptr<sal_uInt16[]> pNewRanges(::lcl_convertListToRanges(aVec2));
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER
+ >::value);
pAddrSet.reset(new SfxItemSet(GetParentSwEnvDlg()->pSh->GetView().GetCurShell()->GetPool(),
- pNewRanges.get()));
+ pRanges));
+ for (const auto& rPair : aRanges)
+ pAddrSet->MergeRange(rPair.first, rPair.second);
pAddrSet->Put(pColl->GetAttrSet());
}
diff --git a/sw/source/ui/frmdlg/column.cxx b/sw/source/ui/frmdlg/column.cxx
index d3d849eb10c0..bce89696efce 100644
--- a/sw/source/ui/frmdlg/column.cxx
+++ b/sw/source/ui/frmdlg/column.cxx
@@ -351,10 +351,7 @@ sal_uInt16 GetMaxWidth( SwColMgr const * pColMgr, sal_uInt16 nCols )
return nMax;
}
-const sal_uInt16 SwColumnPage::aPageRg[] = {
- RES_COL, RES_COL,
- 0
-};
+const WhichRangesContainer SwColumnPage::aPageRg(svl::Items<RES_COL, RES_COL>::value);
void SwColumnPage::ResetColWidth()
{
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 09d732efce5a..987fd665e0d5 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -387,21 +387,19 @@ FrameMap const aVAsCharHtmlMap[] =
{SwFPos::CENTER_VERT, SwFPos::CENTER_VERT, text::VertOrientation::LINE_CENTER, LB::RelRow}
};
-const sal_uInt16 SwFramePage::aPageRg[] = {
+const WhichRangesContainer SwFramePage::aPageRg(svl::Items<
RES_FRM_SIZE, RES_FRM_SIZE,
RES_VERT_ORIENT, RES_ANCHOR,
RES_COL, RES_COL,
- RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW,
- 0
-};
-const sal_uInt16 SwFrameAddPage::aAddPgRg[] = {
+ RES_FOLLOW_TEXT_FLOW, RES_FOLLOW_TEXT_FLOW
+>::value);
+const WhichRangesContainer SwFrameAddPage::aAddPgRg(svl::Items<
RES_PROTECT, RES_PROTECT,
RES_PRINT, RES_PRINT,
FN_SET_FRM_NAME, FN_SET_FRM_NAME,
FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME,
- FN_UNO_DESCRIPTION, FN_UNO_DESCRIPTION,
- 0
-};
+ FN_UNO_DESCRIPTION, FN_UNO_DESCRIPTION
+>::value);
static size_t lcl_GetFrameMapCount( const FrameMap* pMap)
{
diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx
index ad9e0aad185e..61cb43dd23ae 100644
--- a/sw/source/ui/frmdlg/wrap.cxx
+++ b/sw/source/ui/frmdlg/wrap.cxx
@@ -44,12 +44,11 @@
using namespace ::com::sun::star;
-const sal_uInt16 SwWrapTabPage::m_aWrapPageRg[] = {
+const WhichRangesContainer SwWrapTabPage::m_aWrapPageRg(svl::Items<
RES_LR_SPACE, RES_UL_SPACE,
RES_PROTECT, RES_SURROUND,
- RES_PRINT, RES_PRINT,
- 0
-};
+ RES_PRINT, RES_PRINT
+>::value);
SwWrapDlg::SwWrapDlg(weld::Window* pParent, SfxItemSet& rSet, SwWrtShell* pWrtShell, bool bDrawMode)
: SfxSingleTabDialogController(pParent, &rSet, "modules/swriter/ui/wrapdialog.ui", "WrapDialog")
diff --git a/sw/source/ui/misc/pgfnote.cxx b/sw/source/ui/misc/pgfnote.cxx
index 8292d1b35c7b..e644feffd109 100644
--- a/sw/source/ui/misc/pgfnote.cxx
+++ b/sw/source/ui/misc/pgfnote.cxx
@@ -38,10 +38,7 @@
using namespace ::com::sun::star;
-const sal_uInt16 SwFootNotePage::aPageRg[] = {
- FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO,
- 0
-};
+const WhichRangesContainer SwFootNotePage::aPageRg(svl::Items<FN_PARAM_FTN_INFO, FN_PARAM_FTN_INFO>::value);
// handler to switch between the different possibilities how the footnote
// region's height can be set.
diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx
index 20a964eceaf7..34771ba1313f 100644
--- a/sw/source/ui/misc/pggrid.cxx
+++ b/sw/source/ui/misc/pggrid.cxx
@@ -323,12 +323,9 @@ void SwTextGridPage::SetLinesOrCharsRanges(weld::Label& rField, const sal_Int32
rField.set_label(aFieldStr);
}
-const sal_uInt16* SwTextGridPage::GetRanges()
+WhichRangesContainer SwTextGridPage::GetRanges()
{
- static const sal_uInt16 aPageRg[] = {
- RES_TEXTGRID, RES_TEXTGRID,
- 0};
- return aPageRg;
+ return WhichRangesContainer(svl::Items<RES_TEXTGRID, RES_TEXTGRID>::value);
}
IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, weld::SpinButton&, rField, void)
diff --git a/sw/source/uibase/inc/column.hxx b/sw/source/uibase/inc/column.hxx
index 133757a77d52..98b335a8a78f 100644
--- a/sw/source/uibase/inc/column.hxx
+++ b/sw/source/uibase/inc/column.hxx
@@ -164,14 +164,14 @@ class SwColumnPage final : public SfxTabPage
bool isLineNotNone() const;
- static const sal_uInt16 aPageRg[];
+ static const WhichRangesContainer aPageRg;
public:
SwColumnPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
virtual ~SwColumnPage() override;
static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet);
- static const sal_uInt16* GetRanges() { return aPageRg; }
+ static WhichRangesContainer GetRanges() { return aPageRg; }
virtual bool FillItemSet(SfxItemSet *rSet) override;
virtual void Reset(const SfxItemSet *rSet) override;
diff --git a/sw/source/uibase/inc/drpcps.hxx b/sw/source/uibase/inc/drpcps.hxx
index d07746a0386a..4c2274cf25aa 100644
--- a/sw/source/uibase/inc/drpcps.hxx
+++ b/sw/source/uibase/inc/drpcps.hxx
@@ -144,14 +144,14 @@ friend class SwDropCapsPict;
DECL_LINK(SelectHdl, weld::ComboBox&, void);
DECL_LINK(WholeWordHdl, weld::Toggleable&, void);
- static const sal_uInt16 aPageRg[];
+ static const WhichRangesContainer aPageRg;
public:
SwDropCapsPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
virtual ~SwDropCapsPage() override;
static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet);
- static const sal_uInt16* GetRanges() { return aPageRg; }
+ static WhichRangesContainer GetRanges() { return aPageRg; }
virtual bool FillItemSet( SfxItemSet *rSet) override;
diff --git a/sw/source/uibase/inc/frmpage.hxx b/sw/source/uibase/inc/frmpage.hxx
index a555440622ad..8211dc7b350b 100644
--- a/sw/source/uibase/inc/frmpage.hxx
+++ b/sw/source/uibase/inc/frmpage.hxx
@@ -173,14 +173,14 @@ class SwFramePage final : public SfxTabPage
SwWrtShell *getFrameDlgParentShell();
- static const sal_uInt16 aPageRg[];
+ static const WhichRangesContainer aPageRg;
public:
SwFramePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
virtual ~SwFramePage() override;
static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet);
- static const sal_uInt16* GetRanges() { return aPageRg; }
+ static WhichRangesContainer GetRanges() { return aPageRg; }
virtual bool FillItemSet(SfxItemSet *rSet) override;
virtual void Reset(const SfxItemSet *rSet) override;
@@ -302,14 +302,14 @@ class SwFrameAddPage final : public SfxTabPage
DECL_LINK(EditModifyHdl, weld::Entry&, void);
DECL_LINK(ChainModifyHdl, weld::ComboBox&, void);
- static const sal_uInt16 aAddPgRg[];
+ static const WhichRangesContainer aAddPgRg;
public:
SwFrameAddPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
virtual ~SwFrameAddPage() override;
static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet);
- static const sal_uInt16* GetRanges() { return aAddPgRg; }
+ static WhichRangesContainer GetRanges() { return aAddPgRg; }
virtual bool FillItemSet(SfxItemSet *rSet) override;
virtual void Reset(const SfxItemSet *rSet) override;
diff --git a/sw/source/uibase/inc/numpara.hxx b/sw/source/uibase/inc/numpara.hxx
index db67c1358ab2..f6398cb96146 100644
--- a/sw/source/uibase/inc/numpara.hxx
+++ b/sw/source/uibase/inc/numpara.hxx
@@ -56,7 +56,7 @@ class SwParagraphNumTabPage final : public SfxTabPage
DECL_LINK(EditNumStyleHdl_Impl, weld::Button&, void);
DECL_LINK(EditNumStyleSelectHdl_Impl, weld::ComboBox&, void);
- static const sal_uInt16 aPageRg[];
+ static const WhichRangesContainer aPageRg;
static bool ExecuteEditNumStyle_Impl( sal_uInt16 nId, const OUString& rStr,
SfxStyleFamily nFamily );
@@ -67,7 +67,7 @@ public:
static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController,
const SfxItemSet* rSet );
- static const sal_uInt16* GetRanges() { return aPageRg; }
+ static WhichRangesContainer GetRanges() { return aPageRg; }
virtual bool FillItemSet( SfxItemSet* rSet ) override;
virtual void Reset( const SfxItemSet* rSet ) override;
diff --git a/sw/source/uibase/inc/pgfnote.hxx b/sw/source/uibase/inc/pgfnote.hxx
index 6fc8196161b1..c55a9f9c723d 100644
--- a/sw/source/uibase/inc/pgfnote.hxx
+++ b/sw/source/uibase/inc/pgfnote.hxx
@@ -26,13 +26,13 @@
// footnote settings TabPage
class SwFootNotePage final : public SfxTabPage
{
- static const sal_uInt16 aPageRg[];
+ static const WhichRangesContainer aPageRg;
public:
SwFootNotePage(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 ~SwFootNotePage() override;
- static const sal_uInt16* GetRanges() { return aPageRg; }
+ static WhichRangesContainer GetRanges() { return aPageRg; }
virtual bool FillItemSet(SfxItemSet *rSet) override;
virtual void Reset(const SfxItemSet *rSet) override;
diff --git a/sw/source/uibase/inc/pggrid.hxx b/sw/source/uibase/inc/pggrid.hxx
index be53c1a6721a..12d6a8bae13d 100644
--- a/sw/source/uibase/inc/pggrid.hxx
+++ b/sw/source/uibase/inc/pggrid.hxx
@@ -77,7 +77,7 @@ public:
virtual ~SwTextGridPage() override;
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;
diff --git a/sw/source/uibase/inc/swuiccoll.hxx b/sw/source/uibase/inc/swuiccoll.hxx
index 80adad95fe73..4695bfe51691 100644
--- a/sw/source/uibase/inc/swuiccoll.hxx
+++ b/sw/source/uibase/inc/swuiccoll.hxx
@@ -49,14 +49,14 @@ class SwCondCollPage final : public SfxTabPage
void AssignRemove(const weld::Widget*);
void SelectHdl(const weld::Widget*);
- static const sal_uInt16 m_aPageRg[];
+ static const WhichRangesContainer m_aPageRg;
public:
SwCondCollPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
virtual ~SwCondCollPage() override;
static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet *rSet);
- static const sal_uInt16* GetRanges() { return m_aPageRg; }
+ static WhichRangesContainer GetRanges() { return m_aPageRg; }
virtual bool FillItemSet( SfxItemSet *rSet) override;
virtual void Reset (const SfxItemSet *rSet) override;
diff --git a/sw/source/uibase/inc/wrap.hxx b/sw/source/uibase/inc/wrap.hxx
index 7ce99b1696d3..f28757be5a48 100644
--- a/sw/source/uibase/inc/wrap.hxx
+++ b/sw/source/uibase/inc/wrap.hxx
@@ -82,7 +82,7 @@ class SwWrapTabPage final : public SfxTabPage
DECL_LINK(WrapTypeHdl, weld::Toggleable&, void);
DECL_LINK(ContourHdl, weld::Toggleable&, void);
- static const sal_uInt16 m_aWrapPageRg[];
+ static const WhichRangesContainer m_aWrapPageRg;
public:
SwWrapTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
@@ -92,7 +92,7 @@ public:
virtual bool FillItemSet(SfxItemSet *rSet) override;
virtual void Reset(const SfxItemSet *rSet) override;
- static const sal_uInt16* GetRanges() { return m_aWrapPageRg; }
+ static WhichRangesContainer GetRanges() { return m_aWrapPageRg; }
void SetNewFrame(bool bNewFrame) { m_bNew = bNewFrame; }
void SetFormatUsed(bool bFormat, bool bDrawMode) { m_bFormat = bFormat; m_bDrawMode = bDrawMode; }
void SetShell(SwWrtShell* pSh) { m_pWrtSh = pSh; }
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx
index 4dad1d221060..8ccf0d10af2e 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -198,7 +198,7 @@ void SwDrawBaseShell::Execute(SfxRequest const &rReq)
}
SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
- const sal_uInt16* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
+ const WhichRangesContainer& pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
SfxItemSet aSet( *aNewAttr.GetPool(), pRange );
FieldUnit eMetric = ::GetDfltMetric( dynamic_cast<SwWebView*>(&GetView()) != nullptr );
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
diff --git a/sw/source/uibase/uiview/formatclipboard.cxx b/sw/source/uibase/uiview/formatclipboard.cxx
index e9268bffa23f..f9eb7abf09e7 100644
--- a/sw/source/uibase/uiview/formatclipboard.cxx
+++ b/sw/source/uibase/uiview/formatclipboard.cxx
@@ -420,10 +420,10 @@ typedef std::vector< std::unique_ptr< SfxPoolItem > > ItemVector;
// collect all PoolItems from the applied styles
static void lcl_AppendSetItems( ItemVector& rItemVector, const SfxItemSet& rStyleAttrSet )
{
- const sal_uInt16* pRanges = rStyleAttrSet.GetRanges();
- while( *pRanges )
+ const WhichRangesContainer& pRanges = rStyleAttrSet.GetRanges();
+ for(const auto & rPair : pRanges)
{
- for ( sal_uInt16 nWhich = *pRanges; nWhich <= *(pRanges+1); ++nWhich )
+ for ( sal_uInt16 nWhich = rPair.first; nWhich <= rPair.second; ++nWhich )
{
const SfxPoolItem* pItem;
if( SfxItemState::SET == rStyleAttrSet.GetItemState( nWhich, false, &pItem ) )
@@ -431,7 +431,6 @@ static void lcl_AppendSetItems( ItemVector& rItemVector, const SfxItemSet& rStyl
rItemVector.emplace_back( pItem->Clone() );
}
}
- pRanges += 2;
}
}
// remove all items that are inherited from the styles
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index 7f6432dbbf1d..82d00c830f8d 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -130,11 +130,14 @@ void ConvertAttrCharToGen(SfxItemSet& rSet, bool bIsPara)
SfxGrabBagItem aGrabBag(RES_PARATR_GRABBAG);
aGrabBag.GetGrabBag()["DialogUseCharAttr"] <<= true;
// Store initial ranges to allow restoring later
- const sal_uInt16* pRanges = rSet.GetRanges();
- const sal_uInt16* pEnd = pRanges;
- while (*pEnd)
- ++pEnd;
- const uno::Sequence<sal_uInt16> aOrigRanges(pRanges, pEnd - pRanges + 1);
+ uno::Sequence<sal_uInt16> aOrigRanges(rSet.GetRanges().size() * 2 + 1);
+ int i = 0;
+ for (const auto& rPair : rSet.GetRanges())
+ {
+ aOrigRanges.getArray()[i++] = rPair.first;
+ aOrigRanges.getArray()[i++] = rPair.second;
+ }
+ aOrigRanges.getArray()[i++] = 0;
aGrabBag.GetGrabBag()["OrigItemSetRanges"] <<= aOrigRanges;
rSet.MergeRange(RES_PARATR_GRABBAG, RES_PARATR_GRABBAG);
rSet.Put(aGrabBag);
@@ -176,10 +179,18 @@ void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet, bool bIs
auto aIterator = rMap.find("OrigItemSetRanges");
if (aIterator != rMap.end())
{
- if (uno::Sequence<sal_uInt16> aOrigRanges; (aIterator->second >>= aOrigRanges)
- && aOrigRanges.getLength() % 2 == 1
- && *(std::cend(aOrigRanges) - 1) == 0)
- rSet.SetRanges(aOrigRanges.getConstArray());
+ uno::Sequence<sal_uInt16> aOrigRanges;
+ if ( aIterator->second >>= aOrigRanges )
+ {
+ assert(aOrigRanges.getLength() % 2 == 1);
+ int numPairs = (aOrigRanges.getLength()-1)/2;
+ std::unique_ptr<WhichPair[]> xPairs(new WhichPair[numPairs]);
+ for(int i=0; i<aOrigRanges.getLength()-1; i += 2)
+ {
+ xPairs[i/2] = { aOrigRanges[i], aOrigRanges[i+1] };
+ }
+ rSet.SetRanges(WhichRangesContainer(std::move(xPairs), numPairs));
+ }
}
}
assert(SfxItemState::SET != rSet.GetItemState(RES_PARATR_GRABBAG, false));