to add code to prevent not to draw text over than element text length
authorYunji Park <yunji19.park@samsung.com>
Thu, 2 May 2013 07:29:27 +0000 (16:29 +0900)
committerYunji Park <yunji19.park@samsung.com>
Thu, 2 May 2013 08:12:32 +0000 (17:12 +0900)
Change-Id: Ib6ccdf2a636d501f3b9b2782f55c4949ede04270

src/graphics/inc/FGrp_TextTextCutLink.h
src/graphics/inc/FGrp_TextTextSimple.h
src/graphics/text/FGrp_TextTextComposite.cpp
src/graphics/text/FGrp_TextTextCutLink.cpp

index fe2c434..f753750 100644 (file)
@@ -64,6 +64,8 @@ public:
 
        virtual result SetTextOffset(int offset);
 
+       virtual const Font* GetFont(void) const;
+
        bool GetEditable(void) const;
 
        void SetEditModeEnable(bool enable);
index 979b863..ad96fbd 100644 (file)
@@ -95,7 +95,7 @@ public:
 
        result SetFont(const Font* pFont);
 
-       const Font* GetFont(void) const;
+       virtual const Font* GetFont(void) const;
 
        virtual void SetForegroundColor(const Color& color);
 
index a69a9bc..0ce0e53 100644 (file)
@@ -640,7 +640,7 @@ TextComposite::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int st
                TextElement* pLastTextElement = (textLength == 0) ? GetElementAtTextIndex(startTextIndex) : GetElementAtTextIndex(startTextIndex + textLength - 1);
                SysTryCatch(NID_GRP, pLastTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
-               if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT)
+               if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
                {
                        TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
                        SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
@@ -874,7 +874,7 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                pLastDisplayTextElement = (textLength == 0) ? GetElementAtTextIndex(startTextIndex) : GetElementAtTextIndex(startTextIndex + textLength - 1);
                SysTryCatch(NID_GRP, pLastDisplayTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
-               if (pLastDisplayTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT)
+               if (pLastDisplayTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastDisplayTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
                {
                        TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastDisplayTextElement);
                        SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
@@ -1212,7 +1212,7 @@ TextComposite::DrawWithBaseline(_CanvasImpl& canvasImpl, FloatRectangle& display
                TextElement* pLastTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1);
                SysTryCatch(NID_GRP, pLastTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
-               if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT)
+               if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
                {
                        TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
                        SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
@@ -1417,6 +1417,7 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        {
                                GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
+                               currentLength--;\r
                                startTextIndex++;
                                textIndexFromElementOffset++;
                        }
@@ -1426,10 +1427,10 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
        GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
        if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
        {
-               TextElement* pLastTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1);
+               TextElement* pLastTextElement = (textLength == 0) ? GetElementAtTextIndex(startTextIndex) : GetElementAtTextIndex(startTextIndex + textLength - 1);
                SysTryCatch(NID_GRP, pLastTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
-               if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT)
+               if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
                {
                        TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
                        SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
@@ -1442,7 +1443,7 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        , TEXT_OBJECT_WRAP_TYPE_CHARACTER, textLength, textSize.width, textSize.height);
 
                textSize.width += abbrevTextDim.width;
-               currentLength = textLength;
+               currentLength = Math::Min(currentLength, textLength);
                drawAbbrevText = true;
        }
 
@@ -1475,6 +1476,7 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
        }
 
+       currentLength = Math::Min(textLength, currentLength);
        blockRect = FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height);
        adjustedRect.y = displayRect.y + displayRect.height - baseline;
        canvasImpl.SetTextOrigin(TEXT_ORIGIN_BASELINE);
@@ -5775,7 +5777,7 @@ TextComposite::GetDisplayableText(FloatRectangle displayRect, TextObjectActionTy
                        TextElement* pLastTextElement = GetElementAtTextIndex(lineOffset + lineLength - 1);
                        SysTryReturn(NID_GRP, pLastTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
 
-                       if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT)
+                       if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
                        {
                                TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
                                SysTryReturn(NID_GRP, pSimpleText, String(L""), E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
index 64071a6..64b5cf3 100644 (file)
@@ -232,6 +232,17 @@ TextCutLink::ChangeTextOffset(wchar_t* pText, int gap)
        return TextSimple::ChangeTextOffset(pText, gap);
 }
 
+const Font*
+TextCutLink::GetFont(void) const
+{
+       if (__isEdited)
+       {
+               return TextSimple::GetCurrentFont();
+       }
+
+       return __pLinkFont;
+}
+
 Font*
 TextCutLink::GetCurrentFont(void) const
 {