summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-09-22 18:32:13 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-10-05 09:52:58 +0200
commit1ea5633c8ca31fad574ea9fd98ddb20425054b48 (patch)
tree2dc08d41349459ebab2f7d95c159ddb068b46746
parentmake sure SharedString::EMPTY_STRING is interned in pools (tdf#150647) (diff)
downloadcore-1ea5633c8ca31fad574ea9fd98ddb20425054b48.tar.gz
core-1ea5633c8ca31fad574ea9fd98ddb20425054b48.zip
Fix string length assertion and handle parentheses in multi-line formula
soffice.bin: include/rtl/ustring.hxx:842: sal_Unicode rtl::OUString::operator[](sal_Int32) const: Assert ion `index >= 0 && static_cast<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength())' failed. when editing a paragraph (line) longer than the first, because the string was always obtained from the first paragraph but the position from the current selection. Also match parentheses in the current paragraph, not somewhere else in the first paragraph.. still we're matching only within one paragraph. Change-Id: I955fd371c1e248ce58735a5b61603bbce6c997db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140446 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 1df910dac84b4690371f2fc84299e3a918529484) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140387 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/ui/app/inputhdl.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index b837cb2d089b..dd1f9f61958a 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2171,10 +2171,11 @@ void ScInputHandler::UpdateParenthesis()
{
// Examine character left to the cursor
sal_Int32 nPos = aSel.nStartPos - 1;
- OUString aFormula = mpEditEngine->GetText(0);
+ OUString aFormula = mpEditEngine->GetText(aSel.nStartPara);
sal_Unicode c = aFormula[nPos];
if ( c == '(' || c == ')' )
{
+ // Note this matches only within one paragraph.
sal_Int32 nOther = lcl_MatchParenthesis( aFormula, nPos );
if ( nOther != -1 )
{
@@ -2190,9 +2191,9 @@ void ScInputHandler::UpdateParenthesis()
mpEditEngine->RemoveCharAttribs( i, EE_CHAR_WEIGHT );
}
- ESelection aSelThis( 0,nPos, 0,nPos+1 );
+ ESelection aSelThis( aSel.nStartPara, nPos, aSel.nStartPara, nPos+1);
mpEditEngine->QuickSetAttribs( aSet, aSelThis );
- ESelection aSelOther( 0,nOther, 0,nOther+1 );
+ ESelection aSelOther( aSel.nStartPara, nOther, aSel.nStartPara, nOther+1);
mpEditEngine->QuickSetAttribs( aSet, aSelOther );
// Dummy InsertText for Update and Paint (selection is empty)