summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-06-19 12:14:52 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-06-19 12:17:19 +0100
commit18eba6a69f49c9e8e2902f84e96cb6906ee337f1 (patch)
tree2836b496fb1069cb9f2b0c856f0d652232ce1cb7 /sw
parent967b623031cd115722e2708f1281282ca8dccbe0 (diff)
bounds can be -1 for not-found
Change-Id: I941ef1dae00167460f2f0de39e472ed047539f27
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/txtnode/txtedt.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 1716010a78f4..691da301329c 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -595,6 +595,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()
*
@@ -640,6 +649,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);
}