summaryrefslogtreecommitdiff
authorCaolán McNamara <caolanm@redhat.com>2012-08-22 13:38:50 (GMT)
committer Caolán McNamara <caolanm@redhat.com>2012-08-22 14:05:48 (GMT)
commit4f177fbbab1619b9a2f9afa04d882c5fd415fcc0 (patch) (side-by-side diff)
tree03227278ce7f2cb7dcfb2b08ccc2411445bf87e0
parent45b03c888042052a47cb79bc5a2837d04e115c5e (diff)
downloadcore-4f177fbbab1619b9a2f9afa04d882c5fd415fcc0.zip
core-4f177fbbab1619b9a2f9afa04d882c5fd415fcc0.tar.gz
Resolves: rhbz#841092 don't crash on empty portions (a11y?)
Change-Id: Ibd08fa09370580bff12f19f867219098f0d4980e
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--editeng/source/editeng/impedit3.cxx30
1 files changed, 17 insertions, 13 deletions
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index a0aedb1..027302f 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