diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-01-18 21:09:53 +0000 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-01-19 14:20:49 +0100 |
commit | aba61f7b4a89db67c475f59101258d6054196545 (patch) | |
tree | 904e3664abd95d892635a7304408b81bea69f87b /editeng | |
parent | a91cd78c443cc2365f4fd6398ea054cb7ef37ca5 (diff) |
ofz#5477 if the para is already oversize, nums would go negative
Change-Id: I183e1377747f662da1204e90a24fb4f8f2268699
Reviewed-on: https://gerrit.libreoffice.org/48157
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 0ba0a04e53af..41fec1bf80b3 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -2722,12 +2722,13 @@ EditPaM ImpEditEngine::ImpInsertText(const EditSelection& aCurSel, const OUStrin if ( nEnd > nStart ) { OUString aLine = aText.copy( nStart, nEnd-nStart ); - sal_Int32 nChars = aPaM.GetNode()->Len() + aLine.getLength(); - if ( nChars > MAXCHARSINPARA ) + sal_Int32 nExistingChars = aPaM.GetNode()->Len(); + sal_Int32 nChars = nExistingChars + aLine.getLength(); + if (nChars > MAXCHARSINPARA) { - sal_Int32 nMaxNewChars = MAXCHARSINPARA-aPaM.GetNode()->Len(); + sal_Int32 nMaxNewChars = std::max<sal_Int32>(0, MAXCHARSINPARA - nExistingChars); nEnd -= ( aLine.getLength() - nMaxNewChars ); // Then the characters end up in the next paragraph. - aLine = aLine.copy( 0, nMaxNewChars ); // Delete the Rest... + aLine = aLine.copy( 0, nMaxNewChars ); // Delete the Rest... } if ( IsUndoEnabled() && !IsInUndo() ) InsertUndo(new EditUndoInsertChars(pEditEngine, CreateEPaM(aPaM), aLine)); |