Support Wordwrap Japanese
authorYunji Park <yunji19.park@samsung.com>
Sat, 11 May 2013 09:34:18 +0000 (18:34 +0900)
committerYunji Park <yunji19.park@samsung.com>
Sat, 11 May 2013 09:34:18 +0000 (18:34 +0900)
Change-Id: Icb4e54c6551972e0b921c1f4fcad97706a7738c3

src/graphics/inc/FGrp_TextCommon.h
src/graphics/text/FGrp_TextTextComposite.cpp
src/graphics/text/FGrp_TextTextCutLinkParser.cpp
src/graphics/text/FGrp_TextTextObject.cpp
src/graphics/text/FGrp_TextTextSimple.cpp

index 2f5137a..3501512 100644 (file)
@@ -212,6 +212,7 @@ static const unsigned short TEXT_PARAGRAPH_SEPARATOR = 0x2029;
 static const unsigned short TEXT_TAB_CHARACTER = 0x09;
 static const unsigned short TEXT_JAPANESE_DOT = 0x3001;
 static const unsigned short TEXT_JAPANESE_COMMA = 0x3002;
+static const unsigned short TEXT_JAPANESE_SPACE = 0x3000;
 
 }}} // Tizen::Graphics::_Text
 
index d83bbeb..d872047 100644 (file)
@@ -600,7 +600,7 @@ TextComposite::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int st
                        SysTryReturn(NID_GRP, length >= 0 && length < pSimpleText->GetTextLength()
                                , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",length, pSimpleText->GetTextLength());
 
-                       if (pText[length] == (wchar_t)L' ')
+                       if (pText[length] == (wchar_t)L' ' || pText[length] == TEXT_JAPANESE_SPACE)
                        {
                                GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
@@ -623,7 +623,7 @@ TextComposite::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int st
                        SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
                                , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",index, pSimpleText->GetTextLength());
 
-                       if (pText[index] == (wchar_t)L' ')
+                       if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
                        {
                                GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
@@ -834,7 +834,7 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                        SysTryReturn(NID_GRP, length >= 0 && length < pSimpleText->GetTextLength()
                                , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",length, pSimpleText->GetTextLength());
 
-                       if (pText[length] == (wchar_t)L' ')
+                       if (pText[length] == (wchar_t)L' ' || pText[length] == TEXT_JAPANESE_SPACE)
                        {
                                GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
@@ -857,7 +857,7 @@ TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& display
                        SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
                                , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",index, pSimpleText->GetTextLength());
 
-                       if (pText[index] == (wchar_t)L' ')
+                       if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
                        {
                                GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
@@ -1173,7 +1173,7 @@ TextComposite::DrawWithBaseline(_CanvasImpl& canvasImpl, FloatRectangle& display
                        SysTryReturn(NID_GRP, length >= 0 && length < pSimpleText->GetTextLength()
                                , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",length, pSimpleText->GetTextLength());
 
-                       if (pText[length] == (wchar_t)L' ')
+                       if (pText[length] == (wchar_t)L' ' || pText[length] == TEXT_JAPANESE_SPACE)
                        {
                                GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
@@ -1196,7 +1196,7 @@ TextComposite::DrawWithBaseline(_CanvasImpl& canvasImpl, FloatRectangle& display
                        SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
                                , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",index, pSimpleText->GetTextLength());
 
-                       if (pText[index] == (wchar_t)L' ')
+                       if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
                        {
                                GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
@@ -1390,7 +1390,7 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        SysTryReturn(NID_GRP, length >= 0 && length < pSimpleText->GetTextLength()
                                , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",length, pSimpleText->GetTextLength());
 
-                       if (pText[length] == (wchar_t)L' ')
+                       if (pText[length] == (wchar_t)L' ' || pText[length] == TEXT_JAPANESE_SPACE)
                        {
                                GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
@@ -1413,7 +1413,7 @@ TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectan
                        SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
                                , E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",index, pSimpleText->GetTextLength());
 
-                       if (pText[index] == (wchar_t)L' ')
+                       if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
                        {
                                GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
                                textLength--;
@@ -5758,7 +5758,7 @@ TextComposite::GetDisplayableText(FloatRectangle displayRect, TextObjectActionTy
                                        , String(L""), E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)"
                                        ,index, pSimpleText->GetTextLength());
 
-                               if (pText[index] == (wchar_t)L' ')
+                               if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
                                {
                                        remainingLength--;
                                        lineOffset++;
index 01ea1f9..3c3792a 100644 (file)
@@ -23,6 +23,7 @@
 #include <new>
 #include <FBaseCharacter.h>
 #include <FBaseSysLog.h>
+#include "FGrp_TextCommon.h"
 #include "FGrp_TextTextCutLinkParser.h"
 
 using namespace Tizen::Base;
@@ -241,9 +242,9 @@ GetUrlLink(const String& text, int index, int lastLinkEndIndex, int domainLength
                        index++;
                }
        }
-       else if (text[index] != null && text[index] != L' ' && text[index] != L')' &&
-                        text[index] != L']' && text[index] != 0xFFFC &&
-                        text[index] != 0x000A && text[index] != 0x000D)
+       else if (text[index] != null && text[index] != L' ' && text[index] != TEXT_JAPANESE_SPACE &&
+                       text[index] != L')' && text[index] != L']' && text[index] != 0xFFFC &&
+                       text[index] != 0x000A && text[index] != 0x000D)
        {
                return false;
        }
@@ -418,7 +419,7 @@ IsPhoneNumber(const String& text, int index, int& linkLength)
                {
                        oneDot = true;
                }
-               else if (text[index + j] == L' ' || text[index + j] == L'(' || text[index + j] == L')')
+               else if (text[index + j] == L' ' || text[index + j] == TEXT_JAPANESE_SPACE || text[index + j] == L'(' || text[index + j] == L')')
                {
                        // empty statement
                }
@@ -438,17 +439,17 @@ IsPhoneNumber(const String& text, int index, int& linkLength)
                while (index < totalLength &&
                           (Character::IsDigit(text[index]) || (text[index] == L'*') ||
                                (text[index] == L'#') || (text[index] == L'-') ||
-                               (text[index] == L' ') || (text[index] == L'+') ||
+                               (text[index] == L' ') || (text[index] == TEXT_JAPANESE_SPACE) || (text[index] == L'+') ||
                                (text[index] == L'.') || (text[index] == L'(') ||
                                (text[index] == L')') || (index == linkOffset && (text[linkOffset] == L'+'))))
                {
                        index++;
 
-                       if (blankCount == 0 && text[index] == L' ')
+                       if (blankCount == 0 && (text[index] == L' ' || text[index] == TEXT_JAPANESE_SPACE))
                        {
                                blankCount++;
                        }
-                       else if (blankCount == 1 && text[index] == L' ')
+                       else if (blankCount == 1 && (text[index] == L' ' || text[index] == TEXT_JAPANESE_SPACE))
                        {
                                blankCount++;
                                break;
@@ -476,10 +477,10 @@ IsPhoneNumber(const String& text, int index, int& linkLength)
                        }
                }
 
-               if (text[index - 1] == L' ')
+               if (text[index - 1] == L' ' || text[index - 1] == TEXT_JAPANESE_SPACE)
                {
                        index -= 1;
-                       while (text[index] == L' ')
+                       while (text[index] == L' ' || text[index] == TEXT_JAPANESE_SPACE)
                        {
                                index--;
                        }
index f0495f4..39ecbc0 100644 (file)
@@ -1932,7 +1932,7 @@ TextObject::GetTextIndexFromPositionAtLine(int lineIndex, float x, bool cursorMo
                                SysTryReturn(NID_GRP, i >= 0 && i < pSimpleText->GetTextLength(), -1, E_OUT_OF_RANGE
                                                , "[E_OUT_OF_RANGE] text index(%d) must greater than 0 and must be less than total string length(%d)",i, pSimpleText->GetTextLength());
 
-                               if (pText[i] == L' ')
+                               if (pText[i] == L' ' || pText[i] == TEXT_JAPANESE_SPACE)
                                {
                                        index--;
                                }
index 70816e3..5c92052 100644 (file)
@@ -1044,7 +1044,8 @@ TextSimple::GetWordWrapLengthEx(const wchar_t* pText, int textLength, int& actua
        {
                return TEXT_RETBY_LINEFEED;
        }
-       else if (*pLastCharacter == (wchar_t)L' ' || *pLastCharacter == TEXT_OBJ_CHARACTER)
+       else if (*pLastCharacter == (wchar_t)L' ' || *pLastCharacter == TEXT_JAPANESE_SPACE ||
+               *pLastCharacter == TEXT_OBJ_CHARACTER || *pLastCharacter == TEXT_JAPANESE_DOT|| *pLastCharacter ==  TEXT_JAPANESE_COMMA)
        {
                return TEXT_RETBY_NORMAL;
        }
@@ -1059,7 +1060,7 @@ TextSimple::GetWordWrapLengthEx(const wchar_t* pText, int textLength, int& actua
        {
                return TEXT_RETBY_NORMAL;
        }
-       else if (*pText == (wchar_t)L' ')
+       else if (*pText == (wchar_t)L' ' || *pText == TEXT_JAPANESE_SPACE)
        {
                actualLength--;
                length--;
@@ -1084,9 +1085,14 @@ TextSimple::GetWordWrapLengthEx(const wchar_t* pText, int textLength, int& actua
                return TEXT_RETBY_NORMAL;
        }
 
+       actualLength--;
+       length--;
+       pText--;
+
        while ((length >= 0) && (*pText != 0))
        {
-               if (*pText == (wchar_t)L' ' || *pText == TEXT_OBJ_CHARACTER)
+               if (*pText == (wchar_t)L' ' || *pText == TEXT_JAPANESE_SPACE || *pText == TEXT_OBJ_CHARACTER ||
+                       *pText == TEXT_JAPANESE_DOT || *pText == TEXT_JAPANESE_COMMA)
                {
                        actualLength++;
                        length++;