[Libreoffice-commits] .: editeng/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 22 07:07:13 PDT 2012


 editeng/source/editeng/impedit3.cxx |   30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

New commits:
commit 4f177fbbab1619b9a2f9afa04d882c5fd415fcc0
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Aug 22 14:38:50 2012 +0100

    Resolves: rhbz#841092 don't crash on empty portions (a11y?)
    
    Change-Id: Ibd08fa09370580bff12f19f867219098f0d4980e

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


More information about the Libreoffice-commits mailing list