Fixed to drawable text length
authorYunji Park <yunji19.park@samsung.com>
Sun, 14 Apr 2013 08:15:43 +0000 (17:15 +0900)
committerYunji Park <yunji19.park@samsung.com>
Sun, 14 Apr 2013 08:15:43 +0000 (17:15 +0900)
Change-Id: I4f9b05442a7f48ef4ed87c25f69b3edee84be55c

src/graphics/text/FGrp_TextTextComposite.cpp [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 9dcdf53..9423eae
@@ -815,8 +815,8 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
        int elementTextOffset = 0;
        int elementIndex = 0;
        int textIndexFromElementOffset = 0;
-       int headTextLength = 0;
-       int tailTextLength = 0;
+       int LTRTextLength = 0;
+       int RTLTextLength = 0;
        bool drawAbbrevText = false;
 
        if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
@@ -927,10 +927,10 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
        {
                if (IsRTLCharacter(startTextIndex + currentLength))
                {
-                       headTextLength = SearchLTRTextIndex(startTextIndex, startTextIndex + currentLength) - startTextIndex;
-                       tailTextLength = textLength - headTextLength;
+                       LTRTextLength = SearchLTRTextIndex(startTextIndex, startTextIndex + currentLength) - startTextIndex;
+                       RTLTextLength = textLength - LTRTextLength;
 
-                       if (headTextLength <= 0)
+                       if (LTRTextLength <= 0)
                        {
                                if (pLastDisplayTextElement->IsBackGroundDrawingModeEnable())
                                {
@@ -948,20 +948,18 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                }
                else
                {
-                       headTextLength = textLength;
-                       tailTextLength = 0;
+                       LTRTextLength = textLength;
+                       RTLTextLength = 0;
                }
        }
 
-       if (headTextLength > 0)
+       if (LTRTextLength > 0)
        {
-               currentLength = headTextLength;
+               currentLength = Math::Min(LTRTextLength, currentLength);
 
-               currentLength = Math::Min(textLength, currentLength);
-
-               while (textLength > 0)
+               while (LTRTextLength > 0)
                {
-                       textLength -= currentLength;
+                       LTRTextLength -= currentLength;
 
                        pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
 
@@ -998,7 +996,7 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                        adjustedRect.x += textSize.width;
                        adjustedRect.width -= textSize.width;
 
-                       if (!textLength || adjustedRect.width <= 0)
+                       if (!LTRTextLength || adjustedRect.width <= 0)
                        {
                                break;
                        }
@@ -1014,7 +1012,7 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                        SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
                        textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
-                       currentLength = Math::Min(textLength, pTextElement->GetTextLength());
+                       currentLength = Math::Min(LTRTextLength, pTextElement->GetTextLength());
 
                        if (currentLength == 0)
                        {
@@ -1022,10 +1020,11 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                        }
                }
 
-               textIndexFromElementOffset += headTextLength;
+               textIndexFromElementOffset += LTRTextLength;
+               textLength -= LTRTextLength;
        }
 
-       if (drawAbbrevText && (headTextLength > 0 && tailTextLength > 0))
+       if (drawAbbrevText && (RTLTextLength > 0))
        {
                if (pTextElement->IsBackGroundDrawingModeEnable())
                {
@@ -1041,14 +1040,13 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                drawAbbrevText = false;
        }
 
-       if (tailTextLength > 0)
+       if (RTLTextLength > 0)
        {
-               currentLength = tailTextLength;
-               currentLength = Math::Min(textLength, currentLength);
+               currentLength = Math::Min(RTLTextLength, currentLength);
 
-               while (textLength > 0)
+               while (RTLTextLength > 0)
                {
-                       textLength -= currentLength;
+                       RTLTextLength -= currentLength;
 
                        pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
 
@@ -1085,7 +1083,7 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                        adjustedRect.x += textSize.width;
                        adjustedRect.width -= textSize.width;
 
-                       if (!textLength || adjustedRect.width <= 0)
+                       if (!RTLTextLength || adjustedRect.width <= 0)
                        {
                                break;
                        }
@@ -1101,13 +1099,15 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                        SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
                        textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
-                       currentLength = Math::Min(textLength, pTextElement->GetTextLength());
+                       currentLength = Math::Min(RTLTextLength, pTextElement->GetTextLength());
 
                        if (currentLength == 0)
                        {
                                break;
                        }
                }
+
+               textLength -= RTLTextLength;
        }
 
        if (drawAbbrevText)
@@ -1372,8 +1372,8 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
        int elementTextOffset = 0;
        int elementIndex = 0;
        int textIndexFromElementOffset = 0;
-       int headTextLength = 0;
-       int tailTextLength = 0;
+       int LTRTextLength = 0;
+       int RTLTextLength = 0;
        bool drawAbbrevText = false;
 
        if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
@@ -1483,12 +1483,12 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
        {
                if (IsRTLCharacter(startTextIndex + currentLength))
                {
-                       headTextLength = SearchLTRTextIndex(startTextIndex, startTextIndex + currentLength) - startTextIndex;
-                       tailTextLength = textLength - headTextLength;
+                       LTRTextLength = SearchLTRTextIndex(startTextIndex, startTextIndex + currentLength) - startTextIndex;
+                       RTLTextLength = textLength - LTRTextLength;
 
-                       if (headTextLength <= 0)
+                       if (LTRTextLength <= 0)
                        {
-                               if (pLastDisplayTextElement && pLastDisplayTextElement->IsBackGroundDrawingModeEnable())
+                               if (pLastDisplayTextElement->IsBackGroundDrawingModeEnable())
                                {
                                        r = canvasImpl.FillRectangle(pLastDisplayTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
                                        SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
@@ -1504,19 +1504,18 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                }
                else
                {
-                       headTextLength = textLength;
-                       tailTextLength = 0;
+                       LTRTextLength = textLength;
+                       RTLTextLength = 0;
                }
        }
 
-       if (headTextLength > 0)
+       if (LTRTextLength > 0)
        {
-               currentLength = headTextLength;
-               currentLength = Math::Min(textLength, currentLength);
+               currentLength = Math::Min(LTRTextLength, currentLength);
 
-               while (textLength > 0)
+               while (LTRTextLength > 0)
                {
-                       textLength -= currentLength;
+                       LTRTextLength -= currentLength;
 
                        pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
 
@@ -1547,7 +1546,7 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        adjustedRect.x += textSize.width;
                        adjustedRect.width -= textSize.width;
 
-                       if (!textLength || adjustedRect.width <= 0)
+                       if (!LTRTextLength || adjustedRect.width <= 0)
                        {
                                break;
                        }
@@ -1563,7 +1562,7 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
                        textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
-                       currentLength = Math::Min(textLength, pTextElement->GetTextLength());
+                       currentLength = Math::Min(LTRTextLength, pTextElement->GetTextLength());
 
                        if (currentLength == 0)
                        {
@@ -1571,10 +1570,11 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        }
                }
 
-               textIndexFromElementOffset += headTextLength;
+               textIndexFromElementOffset += LTRTextLength;
+               textLength -= LTRTextLength;
        }
 
-       if (drawAbbrevText && (headTextLength > 0 && tailTextLength > 0))
+       if (drawAbbrevText && (RTLTextLength > 0))
        {
                if (pTextElement->IsBackGroundDrawingModeEnable())
                {
@@ -1590,14 +1590,13 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                drawAbbrevText = false;
        }
 
-       if (tailTextLength > 0)
+       if (RTLTextLength > 0)
        {
-               currentLength = tailTextLength;
-               currentLength = Math::Min(textLength, currentLength);
+               currentLength = Math::Min(RTLTextLength, currentLength);
 
-               while (textLength > 0)
+               while (RTLTextLength > 0)
                {
-                       textLength -= currentLength;
+                       RTLTextLength -= currentLength;
 
                        pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
 
@@ -1628,7 +1627,7 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        adjustedRect.x += textSize.width;
                        adjustedRect.width -= textSize.width;
 
-                       if (!textLength || adjustedRect.width <= 0)
+                       if (!RTLTextLength || adjustedRect.width <= 0)
                        {
                                break;
                        }
@@ -1644,13 +1643,15 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
                        textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
-                       currentLength = Math::Min(textLength, pTextElement->GetTextLength());
+                       currentLength = Math::Min(RTLTextLength, pTextElement->GetTextLength());
 
                        if (currentLength == 0)
                        {
                                break;
                        }
                }
+
+               textLength -= RTLTextLength;
        }
 
        if (drawAbbrevText)