diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-08-22 14:38:50 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-08-22 15:05:48 +0100 |
commit | 4f177fbbab1619b9a2f9afa04d882c5fd415fcc0 (patch) | |
tree | 03227278ce7f2cb7dcfb2b08ccc2411445bf87e0 /editeng | |
parent | 45b03c888042052a47cb79bc5a2837d04e115c5e (diff) |
Resolves: rhbz#841092 don't crash on empty portions (a11y?)
Change-Id: Ibd08fa09370580bff12f19f867219098f0d4980e
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index a0aedb12f051..027302f1f653 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -2477,22 +2477,26 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nSt pTP->GetLen() = pTP->GetLen() + nNewChars; } - // No HYPHENATOR portion is allowed to get stuck right at the end... - DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "RecalcTextPortions: Nothing left! "); - sal_uInt16 nLastPortion = pParaPortion->GetTextPortions().Count() - 1; - pTP = pParaPortion->GetTextPortions()[nLastPortion]; - if ( pTP->GetKind() == PORTIONKIND_HYPHENATOR ) + sal_uInt16 nPortionCount = pParaPortion->GetTextPortions().Count(); + assert( nPortionCount ); + if (nPortionCount) { - // Discard portion; if possible, correct the ones before, - // if the Hyphenator portion has swallowed one character... - if ( nLastPortion && pTP->GetLen() ) + // No HYPHENATOR portion is allowed to get stuck right at the end... + sal_uInt16 nLastPortion = nPortionCount - 1; + pTP = pParaPortion->GetTextPortions()[nLastPortion]; + if ( pTP->GetKind() == PORTIONKIND_HYPHENATOR ) { - TextPortion* pPrev = pParaPortion->GetTextPortions()[nLastPortion - 1]; - DBG_ASSERT( pPrev->GetKind() == PORTIONKIND_TEXT, "Portion?!" ); - pPrev->SetLen( pPrev->GetLen() + pTP->GetLen() ); - pPrev->GetSize().Width() = (-1); + // Discard portion; if possible, correct the ones before, + // if the Hyphenator portion has swallowed one character... + if ( nLastPortion && pTP->GetLen() ) + { + TextPortion* pPrev = pParaPortion->GetTextPortions()[nLastPortion - 1]; + DBG_ASSERT( pPrev->GetKind() == PORTIONKIND_TEXT, "Portion?!" ); + pPrev->SetLen( pPrev->GetLen() + pTP->GetLen() ); + pPrev->GetSize().Width() = (-1); + } + pParaPortion->GetTextPortions().Remove( nLastPortion ); } - pParaPortion->GetTextPortions().Remove( nLastPortion ); } } #if OSL_DEBUG_LEVEL > 2 |