sw/source/core/txtnode/txtedt.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+)
New commits: commit d1252e284460998d36409d4462e953cc0e813809 Author: Caolán McNamara <caol...@redhat.com> Date: Wed Jun 19 12:14:52 2013 +0100 bounds can be -1 for not-found Change-Id: I941ef1dae00167460f2f0de39e472ed047539f27 (cherry picked from commit 18eba6a69f49c9e8e2902f84e96cb6906ee337f1) Reviewed-on: https://gerrit.libreoffice.org/4359 Reviewed-by: Noel Power <noel.po...@suse.com> Tested-by: Noel Power <noel.po...@suse.com> diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index e1c2824..d498eb7 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -593,6 +593,15 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, sal_uInt16 nWhich, } } +sal_Int32 clipIndexBounds(const OUString &rStr, sal_Int32 nPos) +{ + if (nPos < 0) + return 0; + if (nPos > rStr.getLength()) + return rStr.getLength(); + return nPos; +} + /************************************************************************* * SwTxtNode::GetCurWord() * @@ -638,6 +647,10 @@ XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const if (aBndry.endPos != aBndry.startPos && IsSymbol( (xub_StrLen)aBndry.startPos )) aBndry.endPos = aBndry.startPos; + // can have -1 as start/end of bounds not found + aBndry.startPos = clipIndexBounds(m_Text, aBndry.startPos); + aBndry.endPos = clipIndexBounds(m_Text, aBndry.endPos); + return m_Text.copy(aBndry.startPos, aBndry.endPos - aBndry.startPos); }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits