Fixed to construct when text doesn't have link text
authorYunji Park <yunji19.park@samsung.com>
Wed, 26 Jun 2013 03:06:44 +0000 (12:06 +0900)
committerYunji Park <yunji19.park@samsung.com>
Wed, 26 Jun 2013 04:40:54 +0000 (13:40 +0900)
Change-Id: I708fcf4bbb01b3d173c38a68d6de5084a180e00e

src/graphics/FGrp_TextElementImpl.cpp

index d1bd72a..e1dee5a 100644 (file)
@@ -302,7 +302,7 @@ _TextElementImpl::Construct(const Tizen::Base::String& text, unsigned long autoL
        r = CreateAutoLink(__strText, autoLink);
        SysTryCatch(NID_GRP
                        , r == E_SUCCESS
-                       , , r, "[%s] Fails to create native text element.", GetErrorMessage(r));
+                       , , r, "[%s] Fails to construct native text element.", GetErrorMessage(r));
 
        __foregroundColor = GetTextColor();
        __backgroundColor = GetBackgroundColor();
@@ -505,16 +505,17 @@ _TextElementImpl::SetText(const Tizen::Base::String& text)
                if (__isAuto == true)
                {
                        r = CreateAutoLink(__strText, __autoLink);
-
                        if (r == E_SUCCESS)
                        {
                                _CutLinkType type = GetCutLinkType();
-                               __linkType = ConvertObjectLinkType(type);
+                               if (type != TEXT_CUTLINK_TYPE_INVALID)
+                               {
+                                       __linkType = ConvertObjectLinkType(type);
 
-                               int len = GetLength();
-                               Tizen::Base::String link;
-                               __strText.SubString(GetAutolinkSrcOffset(), len, link);
-                               __linkText = link;
+                                       Tizen::Base::String link;
+                                       __strText.SubString(GetAutolinkSrcOffset(), GetLength(), link);
+                                       __linkText = link;
+                               }
 
                                SetTextColor(__foregroundColor);
                                if (__bgColorEnable == true)
@@ -900,44 +901,44 @@ _TextElementImpl::CreateAutoLink(const Tizen::Base::String& text, unsigned long
                pTextLinkInfo = pParser->Parse(pText, len, 0);
                if (!pTextLinkInfo)
                {
-                       delete pParser;
-                       pParser = null;
-
-                       return E_INVALID_ARG;
+                       SysLog(NID_GRP, "[] This instance isn't the link type of TextElement");
+                       r = Create(text, len, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
                }
-
-               __linkOffset = pTextLinkInfo->srcOffset;
-
-               if ((ConvertLinkType(pTextLinkInfo->linkType) & autoLink) != 0)
+               else
                {
-                       TextCutLink* pTextElement = null;
+                       __linkOffset = pTextLinkInfo->srcOffset;
 
-                       pTextElement = new (std::nothrow) TextCutLink(false, pTextLinkInfo->linkType, pText + pTextLinkInfo->srcOffset
-                                                                                                                                       , pTextLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
-
-                       if (pTextElement == null)
+                       if ((ConvertLinkType(pTextLinkInfo->linkType) & autoLink) != 0)
                        {
-                               if (pParser)
+                               TextCutLink* pTextElement = null;
+
+                               pTextElement = new (std::nothrow) TextCutLink(false, pTextLinkInfo->linkType, pText + pTextLinkInfo->srcOffset
+                                                                                                                                               , pTextLinkInfo->length, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
+
+                               if (pTextElement == null)
                                {
-                                       delete pParser;
-                                       pParser = null;
+                                       if (pParser)
+                                       {
+                                               delete pParser;
+                                               pParser = null;
+                                       }
+                                       return E_OUT_OF_MEMORY;
                                }
-                               return E_OUT_OF_MEMORY;
-                       }
 
-                       __pTextComponent = pTextElement;
-                       r = E_SUCCESS;
-               }
-               else
-               {
-                       r = Create(text, len, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
-               }
+                               __pTextComponent = pTextElement;
+                               r = E_SUCCESS;
+                       }
+                       else
+                       {
+                               r = Create(text, len, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
+                       }
 
-               while (pTextLinkInfo)
-               {
-                       TextLinkInfo* pCurrent = pTextLinkInfo;
-                       pTextLinkInfo = pTextLinkInfo->pNextLinkInfo;
-                       delete pCurrent;
+                       while (pTextLinkInfo)
+                       {
+                               TextLinkInfo* pCurrent = pTextLinkInfo;
+                               pTextLinkInfo = pTextLinkInfo->pNextLinkInfo;
+                               delete pCurrent;
+                       }
                }
 
                if (pParser)