[Libreoffice-commits] core.git: editeng/source

Caolán McNamara caolanm at redhat.com
Fri Jan 19 20:51:27 UTC 2018


 editeng/source/editeng/impedit2.cxx |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 25d159dd764d917a04e46819bb8efcc2a6067cd6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jan 18 21:09:53 2018 +0000

    ofz#5477 if the para is already oversize, nums would go negative
    
    Change-Id: I183e1377747f662da1204e90a24fb4f8f2268699
    Reviewed-on: https://gerrit.libreoffice.org/48156
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index c5d8c2ad4830..a7e5ef0c9ceb 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2723,12 +2723,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));


More information about the Libreoffice-commits mailing list