summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore/unocrsrhelper.cxx
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-13 19:23:28 +0200
commit8aaa28ed43978a9a4a20d62368410a57ec05c23f (patch)
tree16706bd93e2af74db7220a099a1391bf7cdd1bd4 /sw/source/core/unocore/unocrsrhelper.cxx
parentf7c7e4c63f5479de66d2fbed9db34972a5bd05aa (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>
Diffstat (limited to 'sw/source/core/unocore/unocrsrhelper.cxx')
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx14
1 files changed, 6 insertions, 8 deletions
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 58d5dbf6b11e..1c9f9d4b28db 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1292,7 +1292,7 @@ void makeRedline( SwPaM const & rPaM,
SwDoc& rDoc = rPaM.GetDoc();
// Build set of attributes we want to fetch
- std::vector<sal_uInt16> aWhichPairs;
+ std::vector<std::pair<sal_uInt16, sal_uInt16>> aWhichPairs;
std::vector<SfxItemPropertyMapEntry const*> aEntries;
std::vector<uno::Any> aValues;
aEntries.reserve(aRevertProperties.getLength());
@@ -1314,15 +1314,12 @@ void makeRedline( SwPaM const & rPaM,
}
else if (rPropertyName == "NumberingRules")
{
- aWhichPairs.push_back(RES_PARATR_NUMRULE);
- aWhichPairs.push_back(RES_PARATR_NUMRULE);
+ aWhichPairs.emplace_back(RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
nNumId = aEntries.size();
}
else
{
- // FIXME: we should have some nice way of merging ranges surely ?
- aWhichPairs.push_back(pEntry->nWID);
- aWhichPairs.push_back(pEntry->nWID);
+ aWhichPairs.emplace_back(pEntry->nWID, pEntry->nWID);
if (rPropertyName == "ParaStyleName")
nStyleId = aEntries.size();
}
@@ -1334,8 +1331,9 @@ void makeRedline( SwPaM const & rPaM,
{
sal_uInt16 nStylePoolId = USHRT_MAX;
OUString sParaStyleName;
- aWhichPairs.push_back(0); // terminate
- SfxItemSet aItemSet(rDoc.GetAttrPool(), aWhichPairs.data());
+ SfxItemSet aItemSet(rDoc.GetAttrPool(), nullptr);
+ for (const auto& [nWhich1, nWhich2] : aWhichPairs)
+ aItemSet.MergeRange(nWhich1, nWhich2);
for (size_t i = 0; i < aEntries.size(); ++i)
{