summaryrefslogtreecommitdiff
path: root/sc/source/core/tool
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2015-04-02 22:22:09 +0200
committerEike Rathke <erack@redhat.com>2015-04-02 21:57:23 +0000
commitdd5e8ff4314a87cf86d473e21902df48668d1dd3 (patch)
treebd372006b857cdba27d6706ecd22262857d49ea4 /sc/source/core/tool
parent16d157efc2aec07758448c95cc41731912675db2 (diff)
we need a more intelligent increment for the iterator, tdf#90391
Change-Id: I5a980f0b1ca47b18ce2e479e46971d7c6690c437 Reviewed-on: https://gerrit.libreoffice.org/15125 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com> Reviewed-on: https://gerrit.libreoffice.org/15126
Diffstat (limited to 'sc/source/core/tool')
-rw-r--r--sc/source/core/tool/scmatrix.cxx32
1 files changed, 26 insertions, 6 deletions
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 998f56203be7..4398308bf90e 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -1999,6 +1999,31 @@ public:
}
};
+namespace {
+
+MatrixImplType::position_type increment_position(const MatrixImplType::position_type& pos, size_t n)
+{
+ MatrixImplType::position_type ret = pos;
+ do
+ {
+ if (ret.second + n < ret.first->size)
+ {
+ ret.second += n;
+ break;
+ }
+ else
+ {
+ n -= (ret.first->size - ret.second);
+ ++ret.first;
+ ret.second = 0;
+ }
+ }
+ while (n > 0);
+ return ret;
+}
+
+}
+
template<typename T>
struct MatrixOpWrapper
{
@@ -2027,7 +2052,6 @@ public:
block_type::const_iterator itEnd = block_type::end(*node.data);
MatrixIteratorWrapper<block_type, T> aFunc(it, itEnd, maOp);
pos = mrMat.set(pos,aFunc.begin(), aFunc.end());
- ++pos.first;
}
break;
case mdds::mtm::element_boolean:
@@ -2039,7 +2063,6 @@ public:
MatrixIteratorWrapper<block_type, T> aFunc(it, itEnd, maOp);
pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
- ++pos.first;
}
break;
case mdds::mtm::element_string:
@@ -2051,7 +2074,6 @@ public:
MatrixIteratorWrapper<block_type, T> aFunc(it, itEnd, maOp);
pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
- ++pos.first;
}
break;
case mdds::mtm::element_empty:
@@ -2061,15 +2083,13 @@ public:
std::vector<char> aVec(node.size);
MatrixIteratorWrapper<std::vector<char>, T> aFunc(aVec.begin(), aVec.end(), maOp);
pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
- ++pos.first;
}
- else
- pos.second += node.size;
}
break;
default:
;
}
+ pos = increment_position(pos, node.size);
}
};