// Includes
#include <new>
+#include <fribidi.h>
#include <FBaseSysLog.h>
#include <FApp_AppInfo.h>
#include "FGrp_TextCommon.h"
SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
}
+ if (drawAbbrevText && IsRTL(startTextIndex, textLength))
+ {
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
+ SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
+
+ adjustedRect.x += abbrevTextDim.width;
+ adjustedRect.width -= abbrevTextDim.width;
+
+ drawAbbrevText = false;
+ }
+
blockRect = FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height);
currentLength = Math::Min(textLength, currentLength);
DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
}
- pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
-
+ pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
+
+ adjustedRect.x += textSize.width;
+ adjustedRect.width -= textSize.width;
+
+ if (!textLength || adjustedRect.width <= 0)
+ {
+ break;
+ }
+
+ startTextIndex += currentLength;
+
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ break;
+ }
+
+ pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
+ 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());
+
+ if (currentLength == 0)
+ {
+ break;
+ }
+ }
+
+ if (drawAbbrevText)
+ {
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
+ SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
+
+ adjustedRect.x += abbrevTextDim.width;
+ adjustedRect.width -= abbrevTextDim.width;
+ }
+
+ Release(pEnum);
+ return E_SUCCESS;
+
+CATCH:
+ Release(pEnum);
+ return r;
+}
+
+result
+TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
+ const TextObjectActionType action)
+{
+ if (textLength == 0)
+ {
+ return E_SUCCESS;
+ }
+
+ SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+ SysTryReturn(NID_GRP, textLength <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+
+ result r = E_SUCCESS;
+ IEnumerator* pEnum = null;
+ TextElement* pTextElement = null;
+ TextElement* pLastDisplayTextElement = null;
+ FloatDimension textSize;
+ FloatDimension spaceCharDim;
+ FloatDimension abbrevTextDim;
+ FloatRectangle adjustedRect = displayRect;
+ FloatRectangle blockRect;
+ int currentLength = 0;
+ int elementTextOffset = 0;
+ int elementIndex = 0;
+ int textIndexFromElementOffset = 0;
+ int headTextLength = 0;
+ int tailTextLength = 0;
+ bool drawAbbrevText = false;
+
+ if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
+ {
+ pTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
+ SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
+
+ const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
+ if (pSimpleText != null)
+ {
+ int length = startTextIndex + textLength - elementTextOffset - 1;
+ const wchar_t* pText = pSimpleText->GetText();
+ SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
+
+ 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' ')
+ {
+ GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
+ textLength--;
+ }
+ }
+ }
+
+ pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
+ SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
+
+ if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
+ {
+ const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
+ if (pSimpleText != null)
+ {
+ int index = startTextIndex - elementTextOffset;
+ const wchar_t* pText = pSimpleText->GetText();
+ SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
+
+ 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' ')
+ {
+ GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
+ textLength--;
+ currentLength--;
+ startTextIndex++;
+ textIndexFromElementOffset++;
+ }
+ }
+ }
+
+ GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
+ if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
+ {
+ 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)
+ {
+ TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastDisplayTextElement);
+ SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
+
+ SetAbbrevObjectFontInfo(pSimpleText);
+ __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
+ }
+
+ ForwardAnalyze(startTextIndex, __length - startTextIndex, adjustedRect.width - abbrevTextDim.width
+ , TEXT_OBJECT_WRAP_TYPE_CHARACTER, textLength, textSize.width, textSize.height);
+
+ textSize.width += abbrevTextDim.width;
+ currentLength = Math::Min(currentLength, textLength);
+ drawAbbrevText = true;
+ }
+
+ switch (alignment & TEXT_ALIGNMASK_HORIZ)
+ {
+ case TEXT_OBJECT_ALIGNMENT_CENTER:
+ if (textSize.width < adjustedRect.width)
+ {
+ adjustedRect.x += (adjustedRect.width - textSize.width) / 2;
+ }
+ break;
+
+ case TEXT_OBJECT_ALIGNMENT_RIGHT:
+ if (textSize.width < adjustedRect.width)
+ {
+ adjustedRect.x += adjustedRect.width - textSize.width;
+ }
+ break;
+
+ case TEXT_OBJECT_ALIGNMENT_LEFT:
+ // fall through
+ default:
+ break;
+ }
+
+ pEnum = __pTextElementList->GetEnumeratorN();
+ for (int i = 0; i <= elementIndex; i++)
+ {
+ r = pEnum->MoveNext();
+ SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
+ }
+
+ blockRect = FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height);
+ currentLength = Math::Min(textLength, currentLength);
+
+ if (drawAbbrevText)
+ {
+ if (IsRTLCharacter(startTextIndex + currentLength))
+ {
+ headTextLength = SearchLTRTextIndex(startTextIndex, startTextIndex + currentLength) - startTextIndex;
+ tailTextLength = textLength - headTextLength;
+
+ if (headTextLength <= 0)
+ {
+ 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));
+ }
+
+ __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
+
+ adjustedRect.x += abbrevTextDim.width;
+ adjustedRect.width -= abbrevTextDim.width;
+
+ drawAbbrevText = false;
+ }
+ }
+ else
+ {
+ headTextLength = textLength;
+ tailTextLength = 0;
+ }
+ }
+
+ if (headTextLength > 0)
+ {
+ currentLength = headTextLength;
+
+ currentLength = Math::Min(textLength, currentLength);
+
+ while (textLength > 0)
+ {
+ textLength -= currentLength;
+
+ pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
+
+ switch (alignment & TEXT_ALIGNMASK_VERT)
+ {
+ case TEXT_OBJECT_ALIGNMENT_MIDDLE:
+ adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2;
+ break;
+
+ case TEXT_OBJECT_ALIGNMENT_BOTTOM:
+ adjustedRect.y = displayRect.y + (displayRect.height - textSize.height);
+ break;
+
+ case TEXT_OBJECT_ALIGNMENT_TOP:
+ // fall through
+ default:
+ adjustedRect.y = displayRect.y;
+ break;
+ }
+
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
+ }
+
+ bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
+ if (__displayBlock && isAlternateLookEnabled == false)
+ {
+ DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
+ }
+
+ pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
+
+ adjustedRect.x += textSize.width;
+ adjustedRect.width -= textSize.width;
+
+ if (!textLength || adjustedRect.width <= 0)
+ {
+ break;
+ }
+
+ startTextIndex += currentLength;
+
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ break;
+ }
+
+ pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
+ 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());
+
+ if (currentLength == 0)
+ {
+ break;
+ }
+ }
+
+ textIndexFromElementOffset += headTextLength;
+ }
+
+ if (drawAbbrevText && (headTextLength > 0 && tailTextLength > 0))
+ {
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
+ SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
+
+ adjustedRect.x += abbrevTextDim.width;
+ adjustedRect.width -= abbrevTextDim.width;
+
+ drawAbbrevText = false;
+ }
+
+ if (tailTextLength > 0)
+ {
+ currentLength = tailTextLength;
+ currentLength = Math::Min(textLength, currentLength);
+
+ while (textLength > 0)
+ {
+ textLength -= currentLength;
+
+ pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
+
+ switch (alignment & TEXT_ALIGNMASK_VERT)
+ {
+ case TEXT_OBJECT_ALIGNMENT_MIDDLE:
+ adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2;
+ break;
+
+ case TEXT_OBJECT_ALIGNMENT_BOTTOM:
+ adjustedRect.y = displayRect.y + (displayRect.height - textSize.height);
+ break;
+
+ case TEXT_OBJECT_ALIGNMENT_TOP:
+ // fall through
+ default:
+ adjustedRect.y = displayRect.y;
+ break;
+ }
+
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
+ }
+
+ bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
+ if (__displayBlock && isAlternateLookEnabled == false)
+ {
+ DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
+ }
+
+ pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
+
+ adjustedRect.x += textSize.width;
+ adjustedRect.width -= textSize.width;
+
+ if (!textLength || adjustedRect.width <= 0)
+ {
+ break;
+ }
+
+ startTextIndex += currentLength;
+
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ break;
+ }
+
+ pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
+ 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());
+
+ if (currentLength == 0)
+ {
+ break;
+ }
+ }
+ }
+
+ if (drawAbbrevText)
+ {
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
+ SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
+
+ adjustedRect.x += abbrevTextDim.width;
+ adjustedRect.width -= abbrevTextDim.width;
+ }
+
+ Release(pEnum);
+ return E_SUCCESS;
+
+CATCH:
+ Release(pEnum);
+ return r;
+}
+
+result
+TextComposite::DrawWithBaseline(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
+ const TextObjectActionType action, int baseline)
+{
+ if (textLength == 0)
+ {
+ return E_SUCCESS;
+ }
+
+ SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+ SysTryReturn(NID_GRP, textLength <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+
+ result r = E_SUCCESS;
+ IEnumerator* pEnum = null;
+ TextElement* pTextElement = null;
+
+ FloatDimension textSize;
+ FloatDimension spaceCharDim;
+ FloatDimension abbrevTextDim;
+ FloatRectangle adjustedRect = displayRect;
+ FloatRectangle blockRect;
+ int currentLength = 0;
+ int elementTextOffset = 0;
+ int elementIndex = 0;
+ int textIndexFromElementOffset = 0;
+ bool drawAbbrevText = false;
+
+ if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
+ {
+ pTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
+ SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
+ const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
+ if (pSimpleText != null)
+ {
+ int length = startTextIndex + textLength - elementTextOffset - 1;
+ const wchar_t* pText = pSimpleText->GetText();
+ SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
+
+ 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' ')
+ {
+ GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
+ textLength--;
+ }
+ }
+ }
+
+ pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
+ SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
+
+ if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
+ {
+ const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
+ if (pSimpleText != null)
+ {
+ int index = startTextIndex - elementTextOffset;
+ const wchar_t* pText = pSimpleText->GetText();
+ SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
+
+ 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' ')
+ {
+ GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
+ textLength--;
+ startTextIndex++;
+ textIndexFromElementOffset++;
+ }
+ }
+ }
+
+ GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
+ if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
+ {
+ 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)
+ {
+ TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
+ SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
+
+ SetAbbrevObjectFontInfo(pSimpleText);
+ __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
+ }
+
+ ForwardAnalyze(startTextIndex, __length - startTextIndex, adjustedRect.width - abbrevTextDim.width
+ , TEXT_OBJECT_WRAP_TYPE_CHARACTER, textLength, textSize.width, textSize.height);
+
+ textSize.width += abbrevTextDim.width;
+ currentLength = textLength;
+ drawAbbrevText = true;
+ }
+
+ switch (alignment & TEXT_ALIGNMASK_HORIZ)
+ {
+ case TEXT_OBJECT_ALIGNMENT_CENTER:
+ if (textSize.width < adjustedRect.width)
+ {
+ adjustedRect.x += (adjustedRect.width - textSize.width) / 2;
+ }
+ break;
+
+ case TEXT_OBJECT_ALIGNMENT_RIGHT:
+ if (textSize.width < adjustedRect.width)
+ {
+ adjustedRect.x += adjustedRect.width - textSize.width;
+ }
+ break;
+
+ case TEXT_OBJECT_ALIGNMENT_LEFT:
+ // fall through
+ default:
+ break;
+ }
+
+ pEnum = __pTextElementList->GetEnumeratorN();
+ for (int i = 0; i <= elementIndex; i++)
+ {
+ r = pEnum->MoveNext();
+ SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
+ }
+
+ blockRect = FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height);
+ adjustedRect.y = displayRect.y + displayRect.height - baseline;
+ canvasImpl.SetTextOrigin(TEXT_ORIGIN_BASELINE);
+
+ currentLength = Math::Min(textLength, currentLength);
+
+ while (textLength > 0)
+ {
+ textLength -= currentLength;
+
+ pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
+
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
+ }
+
+ bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
+ if (__displayBlock && isAlternateLookEnabled == false)
+ {
+ DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
+ }
+
+ FloatRectangle imageRect = adjustedRect;
+ imageRect.y -= textSize.height;
+ TextElementType objectType = pTextElement->GetType();
+
+ if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
+ {
+ pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
+ }
+ else
+ {
+ pTextElement->Draw(canvasImpl, imageRect, textIndexFromElementOffset, currentLength, alignment, action);
+ }
+
adjustedRect.x += textSize.width;
adjustedRect.width -= textSize.width;
adjustedRect.width -= abbrevTextDim.width;
}
+ canvasImpl.SetTextOrigin(TEXT_ORIGIN_LEFT_TOP);
+
Release(pEnum);
return E_SUCCESS;
CATCH:
+ canvasImpl.SetTextOrigin(TEXT_ORIGIN_LEFT_TOP);
+
Release(pEnum);
return r;
}
result
-TextComposite::DrawWithBaseline(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
+TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
const TextObjectActionType action, int baseline)
{
if (textLength == 0)
result r = E_SUCCESS;
IEnumerator* pEnum = null;
TextElement* pTextElement = null;
-
+ TextElement* pLastDisplayTextElement = null;
FloatDimension textSize;
FloatDimension spaceCharDim;
FloatDimension abbrevTextDim;
int elementTextOffset = 0;
int elementIndex = 0;
int textIndexFromElementOffset = 0;
+ int headTextLength = 0;
+ int tailTextLength = 0;
bool drawAbbrevText = false;
if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
{
- pTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
- SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
- const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
+ pLastDisplayTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
+ SysTryCatch(NID_GRP, pLastDisplayTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
+ const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pLastDisplayTextElement);
if (pSimpleText != null)
{
int length = startTextIndex + textLength - elementTextOffset - 1;
adjustedRect.y = displayRect.y + displayRect.height - baseline;
canvasImpl.SetTextOrigin(TEXT_ORIGIN_BASELINE);
- currentLength = Math::Min(textLength, currentLength);
-
- while (textLength > 0)
+ if (drawAbbrevText)
{
- textLength -= currentLength;
-
- pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
-
- if (pTextElement->IsBackGroundDrawingModeEnable())
+ if (IsRTLCharacter(startTextIndex + currentLength))
{
- DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
- }
+ headTextLength = SearchLTRTextIndex(startTextIndex, startTextIndex + currentLength) - startTextIndex;
+ tailTextLength = textLength - headTextLength;
- bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
- if (__displayBlock && isAlternateLookEnabled == false)
- {
- DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
- }
+ if (headTextLength <= 0)
+ {
+ 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));
+ }
- FloatRectangle imageRect = adjustedRect;
- imageRect.y -= textSize.height;
- TextElementType objectType = pTextElement->GetType();
+ __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
- if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
- {
- pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
+ adjustedRect.x += abbrevTextDim.width;
+ adjustedRect.width -= abbrevTextDim.width;
+
+ drawAbbrevText = false;
+ }
}
else
{
- pTextElement->Draw(canvasImpl, imageRect, textIndexFromElementOffset, currentLength, alignment, action);
+ headTextLength = textLength;
+ tailTextLength = 0;
}
+ }
- adjustedRect.x += textSize.width;
- adjustedRect.width -= textSize.width;
+ if (headTextLength > 0)
+ {
+ currentLength = headTextLength;
+ currentLength = Math::Min(textLength, currentLength);
- if (!textLength || adjustedRect.width <= 0)
+ while (textLength > 0)
{
- break;
+ textLength -= currentLength;
+
+ pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
+
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
+ }
+
+ bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
+ if (__displayBlock && isAlternateLookEnabled == false)
+ {
+ DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
+ }
+
+ FloatRectangle imageRect = adjustedRect;
+ imageRect.y -= textSize.height;
+ TextElementType objectType = pTextElement->GetType();
+
+ if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
+ {
+ pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
+ }
+ else
+ {
+ pTextElement->Draw(canvasImpl, imageRect, textIndexFromElementOffset, currentLength, alignment, action);
+ }
+
+ adjustedRect.x += textSize.width;
+ adjustedRect.width -= textSize.width;
+
+ if (!textLength || adjustedRect.width <= 0)
+ {
+ break;
+ }
+
+ startTextIndex += currentLength;
+
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ break;
+ }
+
+ pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
+ 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());
+
+ if (currentLength == 0)
+ {
+ break;
+ }
}
- startTextIndex += currentLength;
+ textIndexFromElementOffset += headTextLength;
+ }
- if (pEnum->MoveNext() != E_SUCCESS)
+ if (drawAbbrevText && (headTextLength > 0 && tailTextLength > 0))
+ {
+ if (pTextElement->IsBackGroundDrawingModeEnable())
{
- break;
+ r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
+ SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
}
- pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
- SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
+ __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
- textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
- currentLength = Math::Min(textLength, pTextElement->GetTextLength());
+ adjustedRect.x += abbrevTextDim.width;
+ adjustedRect.width -= abbrevTextDim.width;
- if (currentLength == 0)
+ drawAbbrevText = false;
+ }
+
+ if (tailTextLength > 0)
+ {
+ currentLength = tailTextLength;
+ currentLength = Math::Min(textLength, currentLength);
+
+ while (textLength > 0)
{
- break;
+ textLength -= currentLength;
+
+ pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
+
+ if (pTextElement->IsBackGroundDrawingModeEnable())
+ {
+ DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
+ }
+
+ bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
+ if (__displayBlock && isAlternateLookEnabled == false)
+ {
+ DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
+ }
+
+ FloatRectangle imageRect = adjustedRect;
+ imageRect.y -= textSize.height;
+ TextElementType objectType = pTextElement->GetType();
+
+ if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
+ {
+ pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
+ }
+ else
+ {
+ pTextElement->Draw(canvasImpl, imageRect, textIndexFromElementOffset, currentLength, alignment, action);
+ }
+
+ adjustedRect.x += textSize.width;
+ adjustedRect.width -= textSize.width;
+
+ if (!textLength || adjustedRect.width <= 0)
+ {
+ break;
+ }
+
+ startTextIndex += currentLength;
+
+ if (pEnum->MoveNext() != E_SUCCESS)
+ {
+ break;
+ }
+
+ pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
+ 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());
+
+ if (currentLength == 0)
+ {
+ break;
+ }
}
}
adjustedRect.width = lineBounds.width;
adjustedRect.height = lineBounds.height;
- if (__elementVertialAlignment & TEXT_OBJECT_ALIGNMENT_BASELINE)
+ if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
{
- return DrawWithBaseline(canvasImpl, adjustedRect, lineOffset, lineLength,
- (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | TEXT_OBJECT_ALIGNMENT_BASELINE), action, pTextLine->GetBaseline());
+ if (__elementVertialAlignment & TEXT_OBJECT_ALIGNMENT_BASELINE)
+ {
+ return DrawWithBaselineWithEllipsis(canvasImpl, adjustedRect, lineOffset, lineLength,
+ (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | TEXT_OBJECT_ALIGNMENT_BASELINE), action, pTextLine->GetBaseline());
+ }
+ else
+ {
+ return DrawWithEliipsis(canvasImpl, adjustedRect, lineOffset, lineLength,
+ (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | __elementVertialAlignment), action);
+ }
}
else
{
- return Draw(canvasImpl, adjustedRect, lineOffset, lineLength,
- (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | __elementVertialAlignment), action);
+ if (__elementVertialAlignment & TEXT_OBJECT_ALIGNMENT_BASELINE)
+ {
+ return DrawWithBaseline(canvasImpl, adjustedRect, lineOffset, lineLength,
+ (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | TEXT_OBJECT_ALIGNMENT_BASELINE), action, pTextLine->GetBaseline());
+ }
+ else
+ {
+ return Draw(canvasImpl, adjustedRect, lineOffset, lineLength,
+ (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | __elementVertialAlignment), action);
+ }
}
}
__pSweepInfo->widthChanged = pTextSweepInfo->widthChanged;
}
+bool
+TextComposite::IsRTL(int startTextIndex, int textLength) const
+{
+ SysTryReturn(NID_GRP, 0 <= startTextIndex && textLength <= __length, false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+
+ result r = E_SUCCESS;
+ IEnumerator* pEnum = null;
+
+ int currentLength = 0;
+ int elementTextOffset = 0;
+ int elementIndex = 0;
+ int textIndexFromElementOffset = 0;
+
+ if(textLength == 0)
+ {
+ return false;
+ }
+
+ TextElement* pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
+ SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get element.");
+
+ textIndexFromElementOffset = startTextIndex - elementTextOffset;
+
+ pEnum = __pTextElementList->GetEnumeratorN();
+ for (int i = 0; i < elementIndex; i++)
+ {
+ r = pEnum->MoveNext();
+ }
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
+ if (pTextElement)
+ {
+ currentLength = Math::Min(pTextElement->GetTextLength() - textIndexFromElementOffset, textLength);
+
+ TextElementType objectType = pTextElement->GetType();
+
+ if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
+ {
+ TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
+ if (pSimpleText)
+ {
+ const wchar_t* pSrcText = pSimpleText->GetText();
+ SysTryCatch(NID_GRP, pSrcText, , E_SYSTEM, "[E_SYSTEM] Fail to get text.");
+
+ const wchar_t* pPointer = &pSrcText[textIndexFromElementOffset];
+ SysTryCatch(NID_GRP, pPointer, , E_SYSTEM, "[E_SYSTEM] Fail to get text.");
+
+ for (int i = 0; i< currentLength; i++)
+ {
+ if(*pPointer == null)
+ {
+ break;
+ }
+ FriBidiChar bidiText[1] = { *pPointer };
+ FriBidiCharType type[1] = { 0 };
+ fribidi_get_bidi_types(bidiText, 1, type);
+
+ if ((type[0] & FRIBIDI_MASK_RTL) != 0)
+ {
+ Release(pEnum);
+ return true;
+ }
+ else if (((type[0] & FRIBIDI_MASK_STRONG) != 0) && ((type[0] & FRIBIDI_MASK_LETTER) != 0))
+ {
+ Release(pEnum);
+ return false;
+ }
+
+ pPointer++;
+ }
+
+ }
+
+ textLength -= currentLength;
+ }
+ }
+
+ if (textLength <= 0)
+ {
+ break;
+ }
+
+ textIndexFromElementOffset = 0;
+ }
+
+ Release(pEnum);
+ return false;
+
+CATCH:
+ Release(pEnum);
+
+ return false;
+}
+
+bool
+TextComposite::IsRTLCharacter(int textIndex) const
+{
+ SysTryReturn(NID_GRP, 0 <= textIndex, false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+ bool isRTL = false;
+
+ for (int i = textIndex; i >= 0; i--)
+ {
+ wchar_t ch = GetCharacter(i);
+ if (TextUtility::IsStrongCharacter(ch))
+ {
+ if (TextUtility::IsRTLCharacter(GetCharacter(i)))
+ {
+ isRTL = true;
+ }
+ else
+ {
+ isRTL = false;
+ }
+ break;
+ }
+ }
+
+ return isRTL;
+}
+
+int
+TextComposite::SearchLTRTextIndex(int startTextIndex,int fromTextIndex) const
+{
+ SysTryReturn(NID_GRP, 0 <= fromTextIndex, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+
+ bool isLTR = false;
+ int LTRTextIndex = -1;
+ wchar_t ch = 0;
+
+ for (int i = fromTextIndex; i >= startTextIndex; i--)
+ {
+ ch = GetCharacter(i);
+
+ if (TextUtility::IsLTRCharacter(ch))
+ {
+ isLTR = true;
+ }
+
+ if (isLTR == true)
+ {
+ LTRTextIndex = i + 1;
+
+ while(1)
+ {
+ ch = GetCharacter(LTRTextIndex);
+ if (TextUtility::IsStrongCharacter(ch))
+ {
+ break;
+ }
+
+ LTRTextIndex++;
+ }
+
+ break;
+ }
+ }
+
+ LTRTextIndex = (startTextIndex <= LTRTextIndex && LTRTextIndex <= fromTextIndex) ? LTRTextIndex : startTextIndex;
+
+ return LTRTextIndex;
+}
+
}}} // Tizen::Graphics::_Text