[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - svx/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Fri Nov 15 11:25:32 UTC 2019
svx/source/svdraw/svdpage.cxx | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
New commits:
commit 761672398d44e4d708ddd2d2257026bdb47c4869
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Nov 14 18:44:33 2019 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Nov 15 12:24:33 2019 +0100
tdf#128737 svx: fix off-by-one in SdrObjList::sort()
Increment if the previous one was a text-box, not the current one.
Also add some consistency checks while at it.
(regression from a8b1699ca9c7e8c43eff79467451fd1fcb4fde9b or its
follow-ups)
Change-Id: Iab79e884f4f9cfa358630681495848f4f894506b
Reviewed-on: https://gerrit.libreoffice.org/82758
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index d9dd6cc35e42..6fe5f085b25a 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -627,6 +627,11 @@ void SdrObjList::sort( std::vector<sal_Int32>& sortOrder)
// example aShapesWithTextbox [0 2]
}
+ if (aShapesWithTextbox.size() != maList.size() - sortOrder.size())
+ {
+ throw lang::IllegalArgumentException("mismatch of no. of shapes", nullptr, 0);
+ }
+
for (size_t i = 0; i< sortOrder.size(); ++i)
{
@@ -637,17 +642,19 @@ void SdrObjList::sort( std::vector<sal_Int32>& sortOrder)
// example aDuplicates [2 2 0 0 1]
}
+ assert(aDuplicates.size() == maList.size());
aIncrements.push_back(0);
for (size_t i = 1; i< sortOrder.size(); ++i)
{
- if (aShapesWithTextbox.count(i))
+ if (aShapesWithTextbox.count(i - 1))
aIncrements.push_back(aIncrements[i-1] + 1 );
else
aIncrements.push_back(aIncrements[i-1]);
// example aIncrements [0 1 1]
}
+ assert(aIncrements.size() == sortOrder.size());
std::vector<sal_Int32> aNewSortOrder(maList.size());
sal_Int32 nPrev = -1;
@@ -662,9 +669,18 @@ void SdrObjList::sort( std::vector<sal_Int32>& sortOrder)
// example aNewSortOrder [3 4 0 1 2]
}
+ assert(aNewSortOrder.size() == maList.size());
- if ( aNewSortOrder.size() != maList.size())
- throw css::lang::IllegalArgumentException("mismatch of no. of shapes", nullptr, 0);
+#ifndef NDEBUG
+ {
+ std::vector<sal_Int32> tmp(aNewSortOrder);
+ std::sort(tmp.begin(), tmp.end());
+ for (size_t i = 0; i < tmp.size(); ++i)
+ {
+ assert(size_t(tmp[i]) == i);
+ }
+ }
+#endif
for (size_t i = 0; i < aNewSortOrder.size(); ++i)
{
More information about the Libreoffice-commits
mailing list