summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-01-18 21:09:53 +0000
committerAndras Timar <andras.timar@collabora.com>2018-03-06 14:48:49 +0100
commit49b75728ec6f998d0695fe7a68470082c9ab1a0a (patch)
tree19313f80e2ab986ece1ff9182dc71ee5872aded6
parentResolves: rhbz#1535541 fdo#88004 mimetypes are .macroEnabled not .macroenabled (diff)
downloadcore-49b75728ec6f998d0695fe7a68470082c9ab1a0a.tar.gz
core-49b75728ec6f998d0695fe7a68470082c9ab1a0a.zip
ofz#5477 if the para is already oversize, nums would go negative
Change-Id: I183e1377747f662da1204e90a24fb4f8f2268699 Reviewed-on: https://gerrit.libreoffice.org/48158 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 4c73f977bc21e2f2c8304c6a331dac6b03339197)
-rw-r--r--editeng/source/editeng/impedit2.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 76009022f7f4..850aa9200784 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2673,12 +2673,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));