summaryrefslogtreecommitdiff
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 20:52:17 +0000
commitf9e38cbd3afdf0c8b2ebef0c4995e2443eac4d9a (patch)
treea89fe72cd2d973a84ed39ff2dca549478f35c617
parent6d089a4c7dbc38277e54998020cdb6ff3fac9371 (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>
-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 47554d12d797..905413c57e66 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -2000,6 +2000,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
{
@@ -2028,7 +2053,6 @@ public:
block_type::const_iterator itEnd = block_type::end(*node.data);
MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp);
pos = mrMat.set(pos,aFunc.begin(), aFunc.end());
- ++pos.first;
}
break;
case mdds::mtm::element_boolean:
@@ -2040,7 +2064,6 @@ public:
MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp);
pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
- ++pos.first;
}
break;
case mdds::mtm::element_string:
@@ -2052,7 +2075,6 @@ public:
MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp);
pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
- ++pos.first;
}
break;
case mdds::mtm::element_empty:
@@ -2062,15 +2084,13 @@ public:
std::vector<char> aVec(node.size);
MatrixIteratorWrapper<std::vector<char>, T, typename T::empty_value_type> 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);
}
};