summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-06-11 12:07:44 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-06-14 19:32:07 +0200
commitd8bb5bb58ef62bc0e32d17f00f5fe695c81b5606 (patch)
treebfdaa5de9ce71a4cfb8a1b91881236a8ae4fc6bb /svx
parentf1f0c101109bcf9b54a47bf1010376fd8736e56c (diff)
Assert on valid order of which ids in ranges on SfxItemSet creation
This allows to make sure we actually use sorted which ranges, and then it's safe to call SfxItemSet::MergeRange when needed. Also this change relaxes the previous requirement that ranges must be separated by at least one; this allows to have adjacent ranges, like in RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_GRFATR_BEGIN, RES_GRFATR_END-1, where RES_FRMATR_END is equal to RES_GRFATR_BEGIN. Allowing this makes possible to (1) self-document the ranges, so it's clear which ranges are included; and (2) be safe in case when these constants would change, so that the one merged range would not unexpectedly contain everything inserted between RES_FRMATR_END and RES_GRFATR_BEGIN. Change-Id: Iaad0f099b85059b3aa318a347aa7fbd3f6d455c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116909 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117106 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/dialog/hdft.cxx57
-rw-r--r--svx/source/svdraw/svdedxv.cxx34
2 files changed, 42 insertions, 49 deletions
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx
index 06605ce2efcf..de65ff6c5d01 100644
--- a/svx/source/dialog/hdft.cxx
+++ b/svx/source/dialog/hdft.cxx
@@ -202,30 +202,25 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet )
const sal_uInt16 nWBoxInfo = GetWhich(SID_ATTR_BORDER_INNER);
const sal_uInt16 nWShadow = GetWhich(SID_ATTR_BORDER_SHADOW);
- const sal_uInt16 aWhichTab[] = {
- nWSize, nWSize,
- nWLRSpace, nWLRSpace,
- nWULSpace, nWULSpace,
- nWOn, nWOn,
- nWDynamic, nWDynamic,
- nWShared, nWShared,
- nWSharedFirst, nWSharedFirst,
- nWBrush, nWBrush,
- nWBoxInfo, nWBoxInfo,
- nWBox, nWBox,
- nWShadow, nWShadow,
- nWDynSpacing, nWDynSpacing,
-
- // take over DrawingLayer FillStyles
- XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014
-
- 0, 0};
-
const SfxItemSet& rOldSet = GetItemSet();
SfxItemPool* pPool = rOldSet.GetPool();
DBG_ASSERT(pPool,"no pool :-(");
MapUnit eUnit = pPool->GetMetric(nWSize);
- SfxItemSet aSet(*pPool,aWhichTab);
+ // take over DrawingLayer FillStyles
+ SfxItemSet aSet(*pPool, svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{});
+ // Keep it valid
+ aSet.MergeRange(nWSize, nWSize);
+ aSet.MergeRange(nWLRSpace, nWLRSpace);
+ aSet.MergeRange(nWULSpace, nWULSpace);
+ aSet.MergeRange(nWOn, nWOn);
+ aSet.MergeRange(nWDynamic, nWDynamic);
+ aSet.MergeRange(nWShared, nWShared);
+ aSet.MergeRange(nWSharedFirst, nWSharedFirst);
+ aSet.MergeRange(nWBrush, nWBrush);
+ aSet.MergeRange(nWBoxInfo, nWBoxInfo);
+ aSet.MergeRange(nWBox, nWBox);
+ aSet.MergeRange(nWShadow, nWShadow);
+ aSet.MergeRange(nWDynSpacing, nWDynSpacing);
if(mbEnableDrawingLayerFillStyles)
{
@@ -540,11 +535,12 @@ IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, weld::Button&, void)
{
pBBSet.reset(new SfxItemSet(
*GetItemSet().GetPool(),
- {{XATTR_FILL_FIRST, XATTR_FILL_LAST}, // DrawingLayer FillStyle definitions
- {SID_COLOR_TABLE, SID_PATTERN_LIST}, // XPropertyLists for Color, Gradient, Hatch and Graphic fills
- {nOuter, nOuter},
- {nInner, nInner},
- {nShadow, nShadow}}));
+ svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST, // DrawingLayer FillStyle definitions
+ SID_COLOR_TABLE, SID_PATTERN_LIST>{})); // XPropertyLists for Color, Gradient, Hatch and Graphic fills
+ // Keep it valid
+ pBBSet->MergeRange(nOuter, nOuter);
+ pBBSet->MergeRange(nInner, nInner);
+ pBBSet->MergeRange(nShadow, nShadow);
// copy items for XPropertyList entries from the DrawModel so that
// the Area TabPage can access them
@@ -577,11 +573,12 @@ IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, weld::Button&, void)
pBBSet.reset( new SfxItemSet(
*GetItemSet().GetPool(),
- {{XATTR_FILL_FIRST, XATTR_FILL_LAST},
- {nBrush, nBrush},
- {nOuter, nOuter},
- {nInner, nInner},
- {nShadow, nShadow}}) );
+ svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}) );
+ // Keep it valid
+ pBBSet->MergeRange(nBrush, nBrush);
+ pBBSet->MergeRange(nOuter, nOuter);
+ pBBSet->MergeRange(nInner, nInner);
+ pBBSet->MergeRange(nShadow, nShadow);
}
const SfxPoolItem* pItem;
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 58d8437b9513..1bf140367ac1 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2629,25 +2629,21 @@ bool SdrObjEditView::SupportsFormatPaintbrush(SdrInventor nObjectInventor,
static const sal_uInt16* GetFormatRangeImpl(bool bTextOnly)
{
- static const sal_uInt16 gRanges[] = { SDRATTR_SHADOW_FIRST,
- SDRATTR_SHADOW_LAST,
- SDRATTR_GRAF_FIRST,
- SDRATTR_GRAF_LAST,
- SDRATTR_TABLE_FIRST,
- SDRATTR_TABLE_LAST,
- XATTR_LINE_FIRST,
- XATTR_LINE_LAST,
- XATTR_FILL_FIRST,
- XATTRSET_FILL,
- EE_PARA_START,
- EE_PARA_END, // text-only from here on
- EE_CHAR_START,
- EE_CHAR_END,
- SDRATTR_MISC_FIRST,
- SDRATTR_MISC_LAST, // table cell formats
- 0,
- 0 };
- return &gRanges[bTextOnly ? 10 : 0];
+ static constexpr auto gFull
+ = svl::ItemsArray({ { 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 } });
+
+ static constexpr auto gTextOnly = svl::ItemsArray({ { SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST },
+ { EE_PARA_START, EE_PARA_END },
+ { EE_CHAR_START, EE_CHAR_END } });
+
+ return bTextOnly ? gTextOnly.data() : gFull.data();
}
void SdrObjEditView::TakeFormatPaintBrush(std::shared_ptr<SfxItemSet>& rFormatSet)