2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_TextTextComposite.cpp
20 * @brief This is the implementation file for TextComposite class.
26 #include <FBaseSysLog.h>
27 #include <FApp_AppInfo.h>
28 #include "FGrp_TextCommon.h"
29 #include "FGrp_TextTextElement.h"
30 #include "FGrp_TextTextSimple.h"
31 #include "FGrp_TextTextImage.h"
32 #include "FGrp_TextTextCutLink.h"
33 #include "FGrp_TextTextLine.h"
34 #include "FGrp_TextTextColumn.h"
35 #include "FGrp_TextTextCutLinkListInfo.h"
36 #include "FGrp_TextTextComposite.h"
37 #include "FGrp_TextTextUtility.h"
38 #include "FGrp_CanvasImpl.h"
39 #include "FGrp_CoordinateSystemUtils.h"
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Base::Collection;
54 const float LINE_FEED_WIDTH = 8.0f;
57 namespace Tizen { namespace Graphics
63 struct NoneWrapComposeInfo
72 TextComposite::TextComposite(TextElement* pTextElement)
74 __pTextElementList = new (std::nothrow) LinkedList;
75 SysTryReturn(NID_GRP, __pTextElementList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
77 __wrap = TEXT_OBJECT_WRAP_TYPE_WORD;
82 __displayBlock = false;
83 __defaultBlockColor = Color(183, 212, 247);
86 __ignoreRearBlank = true;
87 __ignoreFrontBlank = false;
89 __rearSpaceHideMode = TEXT_OBJECT_SPACE_HIDE_TYPE_ONE;
90 __frontSpaceHideMode = TEXT_OBJECT_SPACE_HIDE_TYPE_ONE;
93 __elementVertialAlignment = TEXT_OBJECT_ALIGNMENT_BOTTOM;
94 __pCurrentTextColumn = null;
95 __pCutLinkListInfo = new (std::nothrow)TextCutLinkListInfo;
98 wchar_t abbrevText[2];
99 abbrevText[0] = TEXT_ABBREV_CHARACTER;
102 __pAbbrevTextElement = new (std::nothrow)TextSimple(abbrevText, 1, TEXT_ELEMENT_SOURCE_TYPE_INTERNAL, null,
103 Color::GetColor(COLOR_ID_BLACK), Color::GetColor(COLOR_ID_WHITE), Color::GetColor(COLOR_ID_WHITE));
106 if (pTextElement != null)
108 AppendElement(*pTextElement);
110 __drawAbbrevText = false;
111 __drawTextEllipsis = false;
112 __TextObjectEllipsisType = TEXT_OBJECT_ELLIPSIS_TYPE_TAIL;
114 __partialComposingModeEnabled = false;
115 __lineIndexCompositeDone = 0;
116 __totalComposedHeight = 0;
117 __composePartialLimitHeight = 0;
119 __headEllipsisTextLength = 0;
120 __headEllipsisWidth = 0;
121 __middleEllipsisHeadWidth = 0;
122 __middleEllipsisTextLengthInHead = 0;
123 __middleEllipsisTextLengthInTail = 0;
124 __middleEllipsisWidth = 0;
130 TextComposite::~TextComposite(void)
132 Release(__pCutLinkListInfo);
133 Release(__pAbbrevTextElement);
135 if (__pTextElementList)
137 RemoveAllElements(true);
138 delete __pTextElementList;
139 __pTextElementList = null;
144 TextComposite::ForwardAnalyze(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, int& actualLength,
145 int& width, int& height)
147 float maxWidthF = _CoordinateSystemUtils::ConvertToFloat(maxWidth);
148 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
149 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
151 int r = ForwardAnalyze(startTextIndex, textLength, maxWidthF, wrap, actualLength, widthF, heightF);
153 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
154 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
160 TextComposite::ForwardAnalyze(int startTextIndex, int textLength, float maxWidth, TextObjectWrapType wrap, int& actualLength,
161 float& width, float& height)
163 SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length, -1, E_INVALID_ARG
164 , "[E_INVALID_ARG] The argument is invalid. startTextIndex(%d)", startTextIndex);
165 SysTryReturn(NID_GRP, textLength <= __length, -1, E_INVALID_ARG
166 , "[E_INVALID_ARG] The argument is invalid. textLength(%d)", textLength);
168 result r = E_SUCCESS;
169 FloatDimension textSize;
170 int elementTextOffset = 0;
171 int elementIndex = 0;
172 int textIndexFromElementOffset = 0;
173 float remainingWidth = 0;
174 int remainingLength = 0;
176 int currentLength = 0;
177 int ret = TEXT_RETBY_NORMAL;
179 IEnumerator* pEnum = null;
180 TextElement* pTextElement = null;
182 bool isFirstWord = true;
183 FloatDimension tempTextSize;
184 int tempTextCount = 0;
189 pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength,textIndexFromElementOffset);
190 SysTryReturn(NID_GRP, pTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
193 remainingWidth = maxWidth;
194 remainingLength = textLength;
195 currentLength = Math::Min(remainingLength, currentLength);
197 pEnum = __pTextElementList->GetEnumeratorN();
198 for (int i = 0; i <= elementIndex; i++)
200 r = pEnum->MoveNext();
201 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
204 while ((remainingWidth != 0) && (remainingLength != 0))
206 ret = pTextElement->ForwardAnalyze(textIndexFromElementOffset, currentLength, remainingWidth,
207 wrap, textCount, textSize.width, textSize.height);
209 if (textSize.width == 0 && textCount == 0)
214 textSize.height += __lineSpacing;
215 remainingWidth -= textSize.width;
216 remainingLength -= textCount;
217 currentLength -= textCount;
219 actualLength += textCount;
220 width += textSize.width;
221 height = (textSize.height > height) ? textSize.height : height;
223 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret != TEXT_RETBY_LIMITWIDTH)
225 tempTextCount = actualLength;
226 tempTextSize.width = width;
227 tempTextSize.height = height;
230 if (ret == TEXT_RETBY_OVERWIDTH || ret == TEXT_RETBY_LINEFEED)
235 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD)
237 if (ret == TEXT_RETBY_LIMITWIDTH)
239 if (isFirstWord == false)
241 actualLength = tempTextCount;
242 width = tempTextSize.width;
243 height = tempTextSize.height;
245 ret = TEXT_RETBY_NORMAL;
252 if (0 < currentLength)
254 textIndexFromElementOffset += textCount;
260 if (ret == TEXT_RETBY_LIMITWIDTH)
266 if (pEnum->MoveNext() != E_SUCCESS)
271 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
272 if (pTextElement == null)
278 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
279 currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength);
282 if (ret == TEXT_RETBY_LIMITLENGTH)
284 ret = TEXT_RETBY_NORMAL;
287 SetLastResult(E_SUCCESS);
297 TextComposite::ForwardAnalyzeWithBaseline(int startTextIndex, int textLength, int maxWidth, TextObjectWrapType wrap, int& actualLength,
298 int& width, int& height, int& baseline)
300 float maxWidthF = _CoordinateSystemUtils::ConvertToFloat(maxWidth);
301 float widthF = _CoordinateSystemUtils::ConvertToFloat(width);
302 float heightF = _CoordinateSystemUtils::ConvertToFloat(height);
303 float baselineF = _CoordinateSystemUtils::ConvertToFloat(baseline);
305 int r = ForwardAnalyzeWithBaseline(startTextIndex, textLength, maxWidthF, wrap, actualLength, widthF, heightF, baselineF);
307 width = _CoordinateSystemUtils::ConvertToInteger(widthF);
308 height = _CoordinateSystemUtils::ConvertToInteger(heightF);
309 baseline = _CoordinateSystemUtils::ConvertToInteger(baselineF);
315 TextComposite::ForwardAnalyzeWithBaseline(int startTextIndex, int textLength, float maxWidth, TextObjectWrapType wrap, int& actualLength,
316 float& width, float& height, float& baseline)
318 SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length
319 , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. startTextIndex(%d)", startTextIndex);
321 SysTryReturn(NID_GRP, startTextIndex + textLength <= __length
322 , -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. textLength(%d)", textLength);
324 result r = E_SUCCESS;
326 FloatDimension textSize;
327 int elementTextOffset = 0;
328 int elementIndex = 0;
329 int textIndexFromElementOffset = 0;
330 float remainingWidth = 0;
331 int remainingLength = 0;
333 int currentLength = 0;
334 int ret = TEXT_RETBY_NORMAL;
335 bool isMaxHeightImage = false;
337 IEnumerator* pEnum = null;
338 TextElement* pTextElement = null;
340 bool isFirstWord = true;
341 FloatDimension tempTextSize;
342 int tempTextCount = 0;
347 pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength,
348 textIndexFromElementOffset);
349 SysTryReturn(NID_GRP, pTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
352 remainingWidth = maxWidth;
353 remainingLength = textLength;
354 currentLength = Math::Min(remainingLength, currentLength);
355 baseline = pTextElement->GetBaselineF();
357 pEnum = __pTextElementList->GetEnumeratorN();
358 for (int i = 0; i <= elementIndex; i++)
360 r = pEnum->MoveNext();
361 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
364 while (remainingLength != 0)
366 ret = pTextElement->ForwardAnalyze(textIndexFromElementOffset, currentLength, remainingWidth,
367 wrap, textCount, textSize.width, textSize.height);
369 textSize.height += __lineSpacing;
370 remainingWidth -= textSize.width;
371 remainingLength -= textCount;
372 currentLength -= textCount;
374 actualLength += textCount;
375 width += textSize.width;
376 baseline = (pTextElement->GetBaselineF() > baseline) ? pTextElement->GetBaselineF() : baseline;
378 if (height < textSize.height)
380 height = textSize.height;
382 (pTextElement->GetType() == TEXT_ELEMENT_TYPE_IMAGE) ? isMaxHeightImage = true : isMaxHeightImage = false;
385 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret != TEXT_RETBY_LIMITWIDTH)
387 tempTextCount = actualLength;
388 tempTextSize.width = width;
389 tempTextSize.height = height;
392 if (ret == TEXT_RETBY_OVERWIDTH || ret == TEXT_RETBY_LINEFEED)
397 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD)
399 if (ret == TEXT_RETBY_LIMITWIDTH)
401 if (isFirstWord == false)
403 actualLength = tempTextCount;
404 width = tempTextSize.width;
405 height = tempTextSize.height;
407 ret = TEXT_RETBY_NORMAL;
414 if (0 < currentLength)
416 textIndexFromElementOffset += textCount;
422 if (ret == TEXT_RETBY_LIMITWIDTH)
428 if (pEnum->MoveNext() != E_SUCCESS)
433 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
434 if (pTextElement == null)
440 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
441 currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength);
444 if (ret == TEXT_RETBY_LIMITLENGTH)
446 ret = TEXT_RETBY_NORMAL;
449 if (isMaxHeightImage)
454 SetLastResult(E_SUCCESS);
464 TextComposite::GetRegion(int textIndex, int textLength, float& width, float& height) const
474 SysTryReturn(NID_GRP, 0 <= textIndex && textIndex < __length, E_INVALID_ARG, E_INVALID_ARG
475 , "[E_INVALID_ARG] The argument is invalid. textIndex(%d) __length(%d)", textIndex, __length);
476 SysTryReturn(NID_GRP, textLength <= __length, E_INVALID_ARG, E_INVALID_ARG
477 , "[E_INVALID_ARG] The argument is invalid. textIndex(%d) __length(%d)", textIndex, __length);
479 result r = E_SUCCESS;
480 IEnumerator* pEnum = null;
481 TextElement* pTextElement = null;
482 FloatDimension textSize;
483 int currentLength = 0;
484 int elementTextOffset = 0;
485 int elementIndex = 0;
486 int textIndexFromElementOffset = 0;
491 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
492 SysTryReturn(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
494 pEnum = __pTextElementList->GetEnumeratorN();
495 for (int i = 0; i <= elementIndex; i++)
497 r = pEnum->MoveNext();
498 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
501 currentLength = Math::Min(currentLength, textLength);
503 while (textLength != 0)
505 pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
507 width += textSize.width;
508 height = (height > textSize.height) ? height : textSize.height;
509 textLength -= currentLength;
511 if (pEnum->MoveNext() != E_SUCCESS)
516 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
517 if (pTextElement == null)
522 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
523 currentLength = Math::Min(textLength, pTextElement->GetTextLength());
538 TextComposite::GetHeightF(int textIndex) const
545 SysTryReturn(NID_GRP, 0 <= textIndex && textIndex < __length, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
547 TextElement* pTextElement = null;
548 int currentLength = 0;
549 int elementTextOffset = 0;
550 int elementIndex = 0;
551 int textIndexFromElementOffset = 0;
553 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
554 SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
556 return pTextElement->GetHeightF();
563 TextComposite::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
564 const TextObjectActionType action)
571 SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
572 SysTryReturn(NID_GRP, textLength <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
574 result r = E_SUCCESS;
575 IEnumerator* pEnum = null;
576 TextElement* pTextElement = null;
577 FloatDimension textSize;
578 FloatDimension spaceCharDim;
579 FloatDimension abbrevTextDim;
580 FloatRectangle adjustedRect = displayRect;
581 FloatRectangle blockRect;
582 int currentLength = 0;
583 int elementTextOffset = 0;
584 int elementIndex = 0;
585 int textIndexFromElementOffset = 0;
586 bool drawAbbrevText = false;
588 if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
590 pTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
591 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
593 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
594 if (pSimpleText != null)
596 int length = startTextIndex + textLength - elementTextOffset - 1;
597 const wchar_t* pText = pSimpleText->GetText();
598 SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
600 SysTryReturn(NID_GRP, length >= 0 && length < pSimpleText->GetTextLength()
601 , 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());
603 if (pText[length] == (wchar_t)L' ' || pText[length] == TEXT_JAPANESE_SPACE)
605 GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
611 pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
612 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
614 if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE && textLength > 0)
616 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
617 if (pSimpleText != null)
619 int index = startTextIndex - elementTextOffset;
620 const wchar_t* pText = pSimpleText->GetText();
621 SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
623 SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
624 , 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());
626 if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
628 GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
632 textIndexFromElementOffset++;
637 GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
638 if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
640 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
642 ForwardAnalyze(startTextIndex, textLength - startTextIndex, adjustedRect.width
643 , TEXT_OBJECT_WRAP_TYPE_NONE, textLength, textSize.width, textSize.height);
646 TextElement* pLastTextElement = (textLength == 0) ? GetElementAtTextIndex(startTextIndex) : GetElementAtTextIndex(startTextIndex + textLength - 1);
647 SysTryCatch(NID_GRP, pLastTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
649 if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
651 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
652 SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
654 SetAbbrevObjectFontInfo(pSimpleText);
656 __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
658 ForwardAnalyze(startTextIndex, __length - startTextIndex, adjustedRect.width - abbrevTextDim.width
659 , TEXT_OBJECT_WRAP_TYPE_CHARACTER, textLength, textSize.width, textSize.height);
661 textSize.width += abbrevTextDim.width;
662 currentLength = Math::Min(currentLength, textLength);
663 drawAbbrevText = true;
666 switch (alignment & TEXT_ALIGNMASK_HORIZ)
668 case TEXT_OBJECT_ALIGNMENT_CENTER:
669 if (textSize.width < adjustedRect.width)
671 adjustedRect.x += (adjustedRect.width - textSize.width) / 2;
675 case TEXT_OBJECT_ALIGNMENT_RIGHT:
676 if (textSize.width < adjustedRect.width)
678 adjustedRect.x += adjustedRect.width - textSize.width;
682 case TEXT_OBJECT_ALIGNMENT_LEFT:
688 pEnum = __pTextElementList->GetEnumeratorN();
689 for (int i = 0; i <= elementIndex; i++)
691 r = pEnum->MoveNext();
692 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
695 if (drawAbbrevText && IsRTL(startTextIndex, textLength))
697 if (pTextElement->IsBackGroundDrawingModeEnable())
699 r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
700 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
703 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
705 adjustedRect.x += abbrevTextDim.width;
706 adjustedRect.width -= abbrevTextDim.width;
708 drawAbbrevText = false;
711 blockRect = adjustedRect;
712 blockRect.y = displayRect.y;
713 currentLength = Math::Min(textLength, currentLength);
715 while (textLength > 0)
717 textLength -= currentLength;
719 pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
721 switch (alignment & TEXT_ALIGNMASK_VERT)
723 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
724 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2;
727 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
728 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height);
731 case TEXT_OBJECT_ALIGNMENT_TOP:
734 adjustedRect.y = displayRect.y;
738 if (pTextElement->IsBackGroundDrawingModeEnable())
740 DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
743 bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
744 if (__displayBlock && isAlternateLookEnabled == false)
746 DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
749 pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
751 adjustedRect.x += textSize.width;
752 adjustedRect.width -= textSize.width;
759 startTextIndex += currentLength;
761 if (pEnum->MoveNext() != E_SUCCESS)
766 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
767 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
769 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
770 currentLength = Math::Min(textLength, pTextElement->GetTextLength());
772 if (currentLength == 0)
780 if (pTextElement->IsBackGroundDrawingModeEnable())
782 r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
783 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
786 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
788 adjustedRect.x += abbrevTextDim.width;
789 adjustedRect.width -= abbrevTextDim.width;
801 TextComposite::DrawWithEliipsis(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
802 const TextObjectActionType action)
809 SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
810 SysTryReturn(NID_GRP, textLength <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
812 result r = E_SUCCESS;
813 IEnumerator* pEnum = null;
814 TextElement* pTextElement = null;
815 TextElement* pLastDisplayTextElement = null;
816 FloatDimension textSize;
817 FloatDimension spaceCharDim;
818 FloatDimension abbrevTextDim;
819 FloatRectangle adjustedRect = displayRect;
820 FloatRectangle blockRect;
821 int currentLength = 0;
822 int elementTextOffset = 0;
823 int elementIndex = 0;
824 int textIndexFromElementOffset = 0;
825 int LTRTextLength = 0;
826 int RTLTextLength = 0;
827 bool drawAbbrevText = false;
829 if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
831 pTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
832 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
834 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
835 if (pSimpleText != null)
837 int length = startTextIndex + textLength - elementTextOffset - 1;
838 const wchar_t* pText = pSimpleText->GetText();
839 SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
841 SysTryReturn(NID_GRP, length >= 0 && length < pSimpleText->GetTextLength()
842 , 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());
844 if (pText[length] == (wchar_t)L' ' || pText[length] == TEXT_JAPANESE_SPACE)
846 GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
852 pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
853 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
855 if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE && textLength > 0)
857 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
858 if (pSimpleText != null)
860 int index = startTextIndex - elementTextOffset;
861 const wchar_t* pText = pSimpleText->GetText();
862 SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
864 SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
865 , 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());
867 if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
869 GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
873 textIndexFromElementOffset++;
878 GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
879 if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
881 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
883 ForwardAnalyze(startTextIndex, textLength - startTextIndex, adjustedRect.width
884 , TEXT_OBJECT_WRAP_TYPE_NONE, textLength, textSize.width, textSize.height);
887 pLastDisplayTextElement = (textLength == 0) ? GetElementAtTextIndex(startTextIndex) : GetElementAtTextIndex(startTextIndex + textLength - 1);
888 SysTryCatch(NID_GRP, pLastDisplayTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
890 if (pLastDisplayTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastDisplayTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
892 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastDisplayTextElement);
893 SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
895 SetAbbrevObjectFontInfo(pSimpleText);
897 __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
899 ForwardAnalyze(startTextIndex, __length - startTextIndex, adjustedRect.width - abbrevTextDim.width
900 , TEXT_OBJECT_WRAP_TYPE_CHARACTER, textLength, textSize.width, textSize.height);
902 textSize.width += abbrevTextDim.width;
903 currentLength = Math::Min(currentLength, textLength);
904 drawAbbrevText = true;
907 switch (alignment & TEXT_ALIGNMASK_HORIZ)
909 case TEXT_OBJECT_ALIGNMENT_CENTER:
910 if (textSize.width < adjustedRect.width)
912 adjustedRect.x += (adjustedRect.width - textSize.width) / 2;
916 case TEXT_OBJECT_ALIGNMENT_RIGHT:
917 if (textSize.width < adjustedRect.width)
919 adjustedRect.x += adjustedRect.width - textSize.width;
923 case TEXT_OBJECT_ALIGNMENT_LEFT:
929 pEnum = __pTextElementList->GetEnumeratorN();
930 for (int i = 0; i <= elementIndex; i++)
932 r = pEnum->MoveNext();
933 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
936 blockRect = adjustedRect;
937 blockRect.y = displayRect.y;
938 currentLength = Math::Min(textLength, currentLength);
942 if (IsRTLCharacter(startTextIndex + currentLength))
944 LTRTextLength = SearchLTRTextIndex(startTextIndex, startTextIndex + currentLength) - startTextIndex;
945 RTLTextLength = textLength - LTRTextLength;
947 if (LTRTextLength <= 0)
949 if (pLastDisplayTextElement->IsBackGroundDrawingModeEnable())
951 r = canvasImpl.FillRectangle(pLastDisplayTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
952 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
955 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
957 adjustedRect.x += abbrevTextDim.width;
958 adjustedRect.width -= abbrevTextDim.width;
960 drawAbbrevText = false;
965 LTRTextLength = textLength;
970 if (LTRTextLength > 0)
972 currentLength = Math::Min(LTRTextLength, currentLength);
974 while (LTRTextLength > 0)
976 LTRTextLength -= currentLength;
978 pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
980 switch (alignment & TEXT_ALIGNMASK_VERT)
982 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
983 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2;
986 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
987 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height);
990 case TEXT_OBJECT_ALIGNMENT_TOP:
993 adjustedRect.y = displayRect.y;
997 if (pTextElement->IsBackGroundDrawingModeEnable())
999 DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
1002 bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
1003 if (__displayBlock && isAlternateLookEnabled == false)
1005 DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
1008 pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
1010 adjustedRect.x += textSize.width;
1011 adjustedRect.width -= textSize.width;
1013 if (!LTRTextLength || adjustedRect.width <= 0)
1018 startTextIndex += currentLength;
1020 if (pEnum->MoveNext() != E_SUCCESS)
1025 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
1026 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1028 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
1029 currentLength = Math::Min(LTRTextLength, pTextElement->GetTextLength());
1031 if (currentLength == 0)
1037 textIndexFromElementOffset += LTRTextLength;
1038 textLength -= LTRTextLength;
1041 if (drawAbbrevText && (RTLTextLength > 0))
1043 if (pTextElement->IsBackGroundDrawingModeEnable())
1045 r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
1046 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1049 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
1051 adjustedRect.x += abbrevTextDim.width;
1052 adjustedRect.width -= abbrevTextDim.width;
1054 drawAbbrevText = false;
1057 if (RTLTextLength > 0)
1059 currentLength = Math::Min(RTLTextLength, currentLength);
1061 while (RTLTextLength > 0)
1063 RTLTextLength -= currentLength;
1065 pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
1067 switch (alignment & TEXT_ALIGNMASK_VERT)
1069 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
1070 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2;
1073 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
1074 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height);
1077 case TEXT_OBJECT_ALIGNMENT_TOP:
1080 adjustedRect.y = displayRect.y;
1084 if (pTextElement->IsBackGroundDrawingModeEnable())
1086 DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
1089 bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
1090 if (__displayBlock && isAlternateLookEnabled == false)
1092 DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
1095 pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
1097 adjustedRect.x += textSize.width;
1098 adjustedRect.width -= textSize.width;
1105 startTextIndex += currentLength;
1107 if (pEnum->MoveNext() != E_SUCCESS)
1112 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
1113 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1115 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
1116 currentLength = Math::Min(RTLTextLength, pTextElement->GetTextLength());
1118 if (currentLength == 0)
1124 textLength -= RTLTextLength;
1129 if (pTextElement->IsBackGroundDrawingModeEnable())
1131 r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
1132 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1135 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
1137 adjustedRect.x += abbrevTextDim.width;
1138 adjustedRect.width -= abbrevTextDim.width;
1150 TextComposite::DrawWithBaseline(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
1151 const TextObjectActionType action, float baseline)
1153 if (textLength == 0)
1158 SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1159 SysTryReturn(NID_GRP, textLength <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1161 result r = E_SUCCESS;
1162 IEnumerator* pEnum = null;
1163 TextElement* pTextElement = null;
1165 FloatDimension textSize;
1166 FloatDimension spaceCharDim;
1167 FloatDimension abbrevTextDim;
1168 FloatRectangle adjustedRect = displayRect;
1169 FloatRectangle blockRect;
1170 int currentLength = 0;
1171 int elementTextOffset = 0;
1172 int elementIndex = 0;
1173 int textIndexFromElementOffset = 0;
1174 bool drawAbbrevText = false;
1176 if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
1178 pTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
1179 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1180 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
1181 if (pSimpleText != null)
1183 int length = startTextIndex + textLength - elementTextOffset - 1;
1184 const wchar_t* pText = pSimpleText->GetText();
1185 SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
1187 SysTryReturn(NID_GRP, length >= 0 && length < pSimpleText->GetTextLength()
1188 , 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());
1190 if (pText[length] == (wchar_t)L' ' || pText[length] == TEXT_JAPANESE_SPACE)
1192 GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
1198 pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
1199 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1201 if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE && textLength > 0)
1203 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
1204 if (pSimpleText != null)
1206 int index = startTextIndex - elementTextOffset;
1207 const wchar_t* pText = pSimpleText->GetText();
1208 SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
1210 SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
1211 , 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());
1213 if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
1215 GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
1218 textIndexFromElementOffset++;
1223 GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
1224 if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
1226 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1228 ForwardAnalyze(startTextIndex, textLength - startTextIndex, adjustedRect.width
1229 , TEXT_OBJECT_WRAP_TYPE_NONE, textLength, textSize.width, textSize.height);
1232 TextElement* pLastTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1);
1233 SysTryCatch(NID_GRP, pLastTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1235 if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
1237 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
1238 SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
1240 SetAbbrevObjectFontInfo(pSimpleText);
1242 __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
1244 ForwardAnalyze(startTextIndex, __length - startTextIndex, adjustedRect.width - abbrevTextDim.width
1245 , TEXT_OBJECT_WRAP_TYPE_CHARACTER, textLength, textSize.width, textSize.height);
1247 textSize.width += abbrevTextDim.width;
1248 currentLength = textLength;
1249 drawAbbrevText = true;
1252 switch (alignment & TEXT_ALIGNMASK_HORIZ)
1254 case TEXT_OBJECT_ALIGNMENT_CENTER:
1255 if (textSize.width < adjustedRect.width)
1257 adjustedRect.x += (adjustedRect.width - textSize.width) / 2;
1261 case TEXT_OBJECT_ALIGNMENT_RIGHT:
1262 if (textSize.width < adjustedRect.width)
1264 adjustedRect.x += adjustedRect.width - textSize.width;
1268 case TEXT_OBJECT_ALIGNMENT_LEFT:
1274 pEnum = __pTextElementList->GetEnumeratorN();
1275 for (int i = 0; i <= elementIndex; i++)
1277 r = pEnum->MoveNext();
1278 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
1281 blockRect = adjustedRect;
1282 blockRect.y = displayRect.y;
1283 adjustedRect.y = displayRect.y + displayRect.height - baseline;
1284 canvasImpl.SetTextOrigin(TEXT_ORIGIN_BASELINE);
1286 currentLength = Math::Min(textLength, currentLength);
1288 while (textLength > 0)
1290 textLength -= currentLength;
1292 pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
1294 if (pTextElement->IsBackGroundDrawingModeEnable())
1296 DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
1299 bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
1300 if (__displayBlock && isAlternateLookEnabled == false)
1302 DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
1305 TextElementType objectType = pTextElement->GetType();
1306 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
1308 pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
1312 FloatRectangle imageRect = adjustedRect;
1313 imageRect.y -= textSize.height;
1315 pTextElement->Draw(canvasImpl, imageRect, textIndexFromElementOffset, currentLength, alignment, action);
1318 adjustedRect.x += textSize.width;
1319 adjustedRect.width -= textSize.width;
1326 startTextIndex += currentLength;
1328 if (pEnum->MoveNext() != E_SUCCESS)
1333 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
1334 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1336 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
1337 currentLength = Math::Min(textLength, pTextElement->GetTextLength());
1339 if (currentLength == 0)
1347 if (pTextElement->IsBackGroundDrawingModeEnable())
1349 r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
1350 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1353 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
1355 adjustedRect.x += abbrevTextDim.width;
1356 adjustedRect.width -= abbrevTextDim.width;
1359 canvasImpl.SetTextOrigin(TEXT_ORIGIN_LEFT_TOP);
1365 canvasImpl.SetTextOrigin(TEXT_ORIGIN_LEFT_TOP);
1372 TextComposite::DrawWithBaselineWithEllipsis(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength, const TextObjectAlignment alignment,
1373 const TextObjectActionType action, int baseline)
1375 if (textLength == 0)
1380 SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1381 SysTryReturn(NID_GRP, textLength <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1383 result r = E_SUCCESS;
1384 IEnumerator* pEnum = null;
1385 TextElement* pTextElement = null;
1386 TextElement* pLastDisplayTextElement = null;
1387 FloatDimension textSize;
1388 FloatDimension spaceCharDim;
1389 FloatDimension abbrevTextDim;
1390 FloatRectangle adjustedRect = displayRect;
1391 FloatRectangle blockRect;
1392 int currentLength = 0;
1393 int elementTextOffset = 0;
1394 int elementIndex = 0;
1395 int textIndexFromElementOffset = 0;
1396 int LTRTextLength = 0;
1397 int RTLTextLength = 0;
1398 bool drawAbbrevText = false;
1400 if (__ignoreRearBlank && __rearSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
1402 pLastDisplayTextElement = GetElementAtTextIndex(startTextIndex + textLength - 1, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
1403 SysTryCatch(NID_GRP, pLastDisplayTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1404 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pLastDisplayTextElement);
1405 if (pSimpleText != null)
1407 int length = startTextIndex + textLength - elementTextOffset - 1;
1408 const wchar_t* pText = pSimpleText->GetText();
1409 SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
1411 SysTryReturn(NID_GRP, length >= 0 && length < pSimpleText->GetTextLength()
1412 , 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());
1414 if (pText[length] == (wchar_t)L' ' || pText[length] == TEXT_JAPANESE_SPACE)
1416 GetRegion(length + elementTextOffset, 1, spaceCharDim.width, spaceCharDim.height);
1422 pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
1423 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1425 if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE && textLength > 0)
1427 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
1428 if (pSimpleText != null)
1430 int index = startTextIndex - elementTextOffset;
1431 const wchar_t* pText = pSimpleText->GetText();
1432 SysTryReturn(NID_GRP, pText, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text.");
1434 SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
1435 , 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());
1437 if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
1439 GetRegion(textIndexFromElementOffset, 1, spaceCharDim.width, spaceCharDim.height);
1443 textIndexFromElementOffset++;
1448 GetRegion(startTextIndex, textLength, textSize.width, textSize.height);
1449 if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
1451 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
1453 ForwardAnalyze(startTextIndex, textLength - startTextIndex, adjustedRect.width
1454 , TEXT_OBJECT_WRAP_TYPE_NONE, textLength, textSize.width, textSize.height);
1457 TextElement* pLastTextElement = (textLength == 0) ? GetElementAtTextIndex(startTextIndex) : GetElementAtTextIndex(startTextIndex + textLength - 1);
1458 SysTryCatch(NID_GRP, pLastTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1460 if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
1462 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
1463 SysTryCatch(NID_GRP, pSimpleText, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
1465 SetAbbrevObjectFontInfo(pSimpleText);
1467 __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
1469 ForwardAnalyze(startTextIndex, __length - startTextIndex, adjustedRect.width - abbrevTextDim.width
1470 , TEXT_OBJECT_WRAP_TYPE_CHARACTER, textLength, textSize.width, textSize.height);
1472 textSize.width += abbrevTextDim.width;
1473 currentLength = Math::Min(currentLength, textLength);
1474 drawAbbrevText = true;
1477 switch (alignment & TEXT_ALIGNMASK_HORIZ)
1479 case TEXT_OBJECT_ALIGNMENT_CENTER:
1480 if (textSize.width < adjustedRect.width)
1482 adjustedRect.x += (adjustedRect.width - textSize.width) / 2;
1486 case TEXT_OBJECT_ALIGNMENT_RIGHT:
1487 if (textSize.width < adjustedRect.width)
1489 adjustedRect.x += adjustedRect.width - textSize.width;
1493 case TEXT_OBJECT_ALIGNMENT_LEFT:
1499 pEnum = __pTextElementList->GetEnumeratorN();
1500 for (int i = 0; i <= elementIndex; i++)
1502 r = pEnum->MoveNext();
1503 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
1506 currentLength = Math::Min(textLength, currentLength);
1507 blockRect = adjustedRect;
1508 blockRect.y = displayRect.y;
1509 adjustedRect.y = displayRect.y + displayRect.height - baseline;
1510 canvasImpl.SetTextOrigin(TEXT_ORIGIN_BASELINE);
1514 if (IsRTLCharacter(startTextIndex + currentLength))
1516 LTRTextLength = SearchLTRTextIndex(startTextIndex, startTextIndex + currentLength) - startTextIndex;
1517 RTLTextLength = textLength - LTRTextLength;
1519 if (LTRTextLength <= 0)
1521 if (pLastDisplayTextElement && pLastDisplayTextElement->IsBackGroundDrawingModeEnable())
1523 r = canvasImpl.FillRectangle(pLastDisplayTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
1524 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1527 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
1529 adjustedRect.x += abbrevTextDim.width;
1530 adjustedRect.width -= abbrevTextDim.width;
1532 drawAbbrevText = false;
1537 LTRTextLength = textLength;
1542 if (LTRTextLength > 0)
1544 currentLength = Math::Min(LTRTextLength, currentLength);
1546 while (LTRTextLength > 0)
1548 LTRTextLength -= currentLength;
1550 pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
1552 if (pTextElement->IsBackGroundDrawingModeEnable())
1554 DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
1557 bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
1558 if (__displayBlock && isAlternateLookEnabled == false)
1560 DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
1563 TextElementType objectType = pTextElement->GetType();
1564 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
1566 pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
1570 FloatRectangle imageRect = adjustedRect;
1571 imageRect.y -= textSize.height;
1573 pTextElement->Draw(canvasImpl, imageRect, textIndexFromElementOffset, currentLength, alignment, action);
1576 adjustedRect.x += textSize.width;
1577 adjustedRect.width -= textSize.width;
1579 if (!LTRTextLength || adjustedRect.width <= 0)
1584 startTextIndex += currentLength;
1586 if (pEnum->MoveNext() != E_SUCCESS)
1591 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
1592 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1594 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
1595 currentLength = Math::Min(LTRTextLength, pTextElement->GetTextLength());
1597 if (currentLength == 0)
1603 textIndexFromElementOffset += LTRTextLength;
1604 textLength -= LTRTextLength;
1607 if (drawAbbrevText && (RTLTextLength > 0))
1609 if (pTextElement->IsBackGroundDrawingModeEnable())
1611 r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
1612 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1615 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
1617 adjustedRect.x += abbrevTextDim.width;
1618 adjustedRect.width -= abbrevTextDim.width;
1620 drawAbbrevText = false;
1623 if (RTLTextLength > 0)
1625 currentLength = Math::Min(RTLTextLength, currentLength);
1627 while (RTLTextLength > 0)
1629 RTLTextLength -= currentLength;
1631 pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
1633 if (pTextElement->IsBackGroundDrawingModeEnable())
1635 DrawBackgroundBlock(canvasImpl, FloatRectangle(adjustedRect.x, displayRect.y, adjustedRect.width, adjustedRect.height), startTextIndex, currentLength, alignment, action);
1638 bool isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
1639 if (__displayBlock && isAlternateLookEnabled == false)
1641 DrawBlock(canvasImpl, blockRect, startTextIndex, currentLength, alignment, action);
1644 TextElementType objectType = pTextElement->GetType();
1646 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
1648 pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, alignment, action);
1652 FloatRectangle imageRect = adjustedRect;
1653 imageRect.y -= textSize.height;
1655 pTextElement->Draw(canvasImpl, imageRect, textIndexFromElementOffset, currentLength, alignment, action);
1658 adjustedRect.x += textSize.width;
1659 adjustedRect.width -= textSize.width;
1666 startTextIndex += currentLength;
1668 if (pEnum->MoveNext() != E_SUCCESS)
1673 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
1674 SysTryCatch(NID_GRP, pTextElement, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
1676 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
1677 currentLength = Math::Min(RTLTextLength, pTextElement->GetTextLength());
1679 if (currentLength == 0)
1685 textLength -= RTLTextLength;
1690 if (pTextElement->IsBackGroundDrawingModeEnable())
1692 r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, abbrevTextDim.width, displayRect.height));
1693 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1696 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), action);
1698 adjustedRect.x += abbrevTextDim.width;
1699 adjustedRect.width -= abbrevTextDim.width;
1702 canvasImpl.SetTextOrigin(TEXT_ORIGIN_LEFT_TOP);
1708 canvasImpl.SetTextOrigin(TEXT_ORIGIN_LEFT_TOP);
1715 TextComposite::DrawBlock(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect, int startTextIndex, int textLength,
1716 const TextObjectAlignment align, const TextObjectActionType action)
1718 int lineIndex = __pCurrentTextColumn->GetLineIndexAtTextIndex(startTextIndex);
1719 TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(lineIndex);
1720 SysTryReturn(NID_GRP, pTextLine, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1722 int lineOffset = pTextLine->GetTextOffset();
1723 int blockStartTextIndex = Math::Max(__workStart, startTextIndex);
1724 int blockEndTextIndex = Math::Min(__workStart + __workLength, startTextIndex + textLength);
1725 int blockTextLength = blockEndTextIndex - blockStartTextIndex;
1732 if (blockStartTextIndex >= blockEndTextIndex)
1737 FloatRectangle lineBounds = pTextLine->GetBoundsF();
1738 blockStartTextIndex -= lineOffset;
1739 blockEndTextIndex -= lineOffset;
1740 FloatRectangle blockRect = displayRect;
1741 blockRect.y = lineBounds.y;
1743 Collection::ArrayListT<_FloatPair>* pGapList = pTextLine->GetTextExtentList();
1745 _FloatPair currentGap;
1746 IEnumeratorT<_FloatPair >* pGapEnum = pGapList->GetEnumeratorN();
1748 for (int i = 0; i <= blockStartTextIndex; i++)
1750 pGapEnum->MoveNext();
1753 pGapEnum->GetCurrent(currentGap);
1754 float blockStart = currentGap.first;
1755 float blockEnd = currentGap.second;
1756 bool prevRtL = TextUtility::IsRTLCharacter(GetCharacter(blockStartTextIndex + lineOffset));
1757 TextBidiHint bidiHint = _GetTextBidiHint();
1758 bool isBidiEnabled = (bidiHint == TEXT_BIDI_HINT_RTL) ? true : false;
1760 for (int count = 0; count < blockTextLength; count++)
1762 pGapEnum->GetCurrent(currentGap);
1764 ch = GetCharacter(blockStartTextIndex + lineOffset + count);
1765 isRtL = TextUtility::IsRTLCharacter(ch);
1766 isLtR = TextUtility::IsLTRCharacter(ch);
1767 isRtL = (!isRtL && !isLtR) ? isBidiEnabled : isRtL;
1769 if (prevRtL == isRtL)
1771 blockStart = (currentGap.first < blockStart) ? currentGap.first : blockStart;
1772 blockEnd = (currentGap.second > blockEnd) ? currentGap.second : blockEnd;
1776 if (blockStart != blockEnd)
1778 canvasImpl.FillRectangle(__defaultBlockColor, FloatRectangle(blockRect.x + blockStart, displayRect.y, blockEnd - blockStart, displayRect.height));
1781 blockStart = currentGap.first;
1782 blockEnd = currentGap.second;
1785 left = currentGap.first;
1786 right = currentGap.second;
1789 pGapEnum->MoveNext();
1792 if (blockStart != blockEnd)
1794 canvasImpl.FillRectangle(__defaultBlockColor, FloatRectangle(blockRect.x + blockStart, displayRect.y, blockEnd - blockStart, displayRect.height));
1797 if ((pTextLine->GetEndType() == TEXT_RETBY_LINEFEED) && (pTextLine->GetTextLength() == blockEndTextIndex))
1799 canvasImpl.FillRectangle(__defaultBlockColor, FloatRectangle(blockRect.x + blockEnd, displayRect.y, LINE_FEED_WIDTH, displayRect.height));
1808 TextComposite::DrawBackgroundBlock(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect, int startTextIndex, int textLength,
1809 const TextObjectAlignment align, const TextObjectActionType action)
1811 if (textLength == 0)
1816 TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(__pCurrentTextColumn->GetLineIndexAtTextIndex(startTextIndex));
1817 SysTryReturn(NID_GRP, pTextLine, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1819 int blockEndTextIndex = startTextIndex + textLength;
1821 float prevRight = 0;
1822 int currentLength = 0;
1823 int elementTextOffset = 0;
1824 int elementIndex = 0;
1825 int textIndexFromElementOffset = 0;
1826 int textIndex = startTextIndex;
1831 FloatRectangle lineBounds = pTextLine->GetBoundsF();
1832 FloatRectangle blockRect = displayRect;
1833 blockRect.y = lineBounds.y;
1835 TextElement* pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
1836 SysTryReturn(NID_GRP, pTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
1838 TextElementType objectType = pTextElement->GetType();
1839 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
1841 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
1842 if (pSimpleText != null)
1844 Color backgroundColor = pSimpleText->GetBackgroundColor();
1845 const wchar_t* pText = pSimpleText->GetTextSource();
1847 _FontImpl* pFontImpl = (_FontImpl::GetInstance(*const_cast < Font* >(pSimpleText->GetFont())));
1848 SysTryReturn(NID_GRP, pFontImpl, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
1850 Collection::ArrayListT<_FloatPair> elemenGapListF;
1851 pFontImpl->GetTextExtentList(pText, textIndexFromElementOffset, textLength, elemenGapListF);
1853 _FloatPair currentGap;
1854 IEnumeratorT<_FloatPair >* pEnum = elemenGapListF.GetEnumeratorN();
1857 pEnum->GetCurrent(currentGap);
1858 float blockStart = currentGap.first;
1859 float blockEnd = currentGap.second;
1860 bool prevRtL = TextUtility::IsRTLCharacter(GetCharacter(textIndex));
1861 TextBidiHint bidiHint = _GetTextBidiHint();
1862 bool isBidiEnabled = (bidiHint == TEXT_BIDI_HINT_RTL) ? true : false;
1864 while (textIndex < blockEndTextIndex)
1866 pEnum->GetCurrent(currentGap);
1868 ch = GetCharacter(textIndex++);
1869 isRtL = TextUtility::IsRTLCharacter(ch);
1870 isLtR = TextUtility::IsLTRCharacter(ch);
1871 isRtL = (!isRtL && !isLtR) ? isBidiEnabled : isRtL;
1873 if (prevRtL == isRtL)
1875 blockStart = (currentGap.first < blockStart) ? currentGap.first : blockStart;
1876 blockEnd = (currentGap.second > blockEnd) ? currentGap.second : blockEnd;
1880 if (blockStart != blockEnd)
1882 canvasImpl.FillRectangle(backgroundColor, FloatRectangle(blockRect.x + blockStart, displayRect.y, blockEnd - blockStart, displayRect.height));
1885 blockStart = currentGap.first;
1886 blockEnd = currentGap.second;
1889 prevLeft = currentGap.first;
1890 prevRight = currentGap.second;
1896 if (blockStart != blockEnd)
1898 canvasImpl.FillRectangle(backgroundColor, FloatRectangle(blockRect.x + blockStart, displayRect.y, blockEnd - blockStart, displayRect.height));
1901 if ((pTextLine->GetEndType() == TEXT_RETBY_LINEFEED) && (pTextLine->GetTextOffset() + pTextLine->GetTextLength() == blockEndTextIndex))
1903 canvasImpl.FillRectangle(backgroundColor, FloatRectangle(blockRect.x + blockEnd, displayRect.y, LINE_FEED_WIDTH, displayRect.height));
1914 TextComposite::DrawLine(_CanvasImpl& canvasImpl, TextLine* pTextLine, const FloatRectangle& displayRect,
1915 const TextObjectAlignment align, const TextObjectActionType action)
1917 SysTryReturn(NID_GRP, pTextLine, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1922 FloatRectangle adjustedRect = displayRect;
1924 lineLength = pTextLine->GetTextLength();
1925 lineOffset = pTextLine->GetTextOffset();
1927 adjustedRect.height = pTextLine->GetBoundsF().height;
1929 if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
1931 if (__elementVertialAlignment & TEXT_OBJECT_ALIGNMENT_BASELINE)
1933 return DrawWithBaselineWithEllipsis(canvasImpl, adjustedRect, lineOffset, lineLength,
1934 (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | TEXT_OBJECT_ALIGNMENT_BASELINE), action, pTextLine->GetBaselineF());
1938 return DrawWithEliipsis(canvasImpl, adjustedRect, lineOffset, lineLength,
1939 (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | __elementVertialAlignment), action);
1944 if (__elementVertialAlignment & TEXT_OBJECT_ALIGNMENT_BASELINE)
1946 return DrawWithBaseline(canvasImpl, adjustedRect, lineOffset, lineLength,
1947 (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | TEXT_OBJECT_ALIGNMENT_BASELINE), action, pTextLine->GetBaselineF());
1951 return Draw(canvasImpl, adjustedRect, lineOffset, lineLength,
1952 (TextObjectAlignment)((TEXT_ALIGNMASK_HORIZ & align) | __elementVertialAlignment), action);
1958 TextComposite::GetValue(TextElement* pTextElement, TextComponentInfoValueType type, unsigned int* value) const
1960 SysTryReturn(NID_GRP, pTextElement, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1962 TextElementType objectType = TextUtility::GetObjectTypeFromValueType(type);
1964 SysTryReturn(NID_GRP, pTextElement->GetType() == objectType, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get type.");
1966 *value = pTextElement->GetValue(type);
1972 TextComposite::InsertElementAt(TextElement& textElement, int textIndex)
1974 SysTryReturn(NID_GRP, 0 <= textIndex && textIndex <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
1976 result r = E_SUCCESS;
1978 TextElement* pCurrentTextElement = null;
1979 TextElement* pNewTextElement = null;
1981 int currentLength = 0;
1982 int elementTextOffset = 0;
1983 int elementIndex = 0;
1984 int textIndexFromElementOffset = 0;
1986 pCurrentTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex,
1987 currentLength, textIndexFromElementOffset);
1989 if (pCurrentTextElement != null)
1991 if (textIndex == elementTextOffset)
1993 r = __pTextElementList->InsertAt(textElement, elementIndex);
1994 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to insert element.", GetErrorMessage(r));
1998 pCurrentTextElement->SetTextLength(pCurrentTextElement->GetTextLength() - currentLength);
2000 r = __pTextElementList->InsertAt(textElement, ++elementIndex);
2001 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to insert element.", GetErrorMessage(r));
2003 pNewTextElement = pCurrentTextElement->CloneN(SET_ALLVALUE_CLONE, 0);
2004 SysTryReturn(NID_GRP, pNewTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element.");
2006 pNewTextElement->SetTextLength(currentLength);
2008 if (textIndexFromElementOffset != 0)
2010 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset);
2013 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
2014 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to insert element.", GetErrorMessage(r));
2019 if (textIndex == __length)
2021 r = __pTextElementList->Add(textElement);
2022 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to add element.", GetErrorMessage(r));
2030 int elementTextLength = textElement.GetTextLength();
2032 __workStart = textIndex;
2033 __workLength = elementTextLength;
2034 __length += elementTextLength;
2037 TextElementType objectType = textElement.GetType();
2038 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK)
2040 TextCutLink* pLinkElement = dynamic_cast < TextCutLink* >(&textElement);
2041 __pCutLinkListInfo->InsertCutLinkElementInfo(textIndex, *pLinkElement, elementTextLength);
2045 __pCutLinkListInfo->InsertText(textIndex, elementTextLength);
2048 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
2050 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(&textElement);
2051 if (pSimpleText != null)
2053 pSimpleText->SetUserWrap(__wrap);
2061 TextComposite::AppendElement(TextElement& textElement)
2063 result r = E_SUCCESS;
2064 int elementTextLength = textElement.GetTextLength();
2066 r = __pTextElementList->Add(textElement);
2067 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to add element.", GetErrorMessage(r));
2069 __workStart = __length;
2070 __workLength = elementTextLength;
2071 __length += elementTextLength;
2074 TextElementType objectType = textElement.GetType();
2075 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK)
2077 TextCutLink* pLinkElement = dynamic_cast < TextCutLink* >(&textElement);
2078 __pCutLinkListInfo->InsertCutLinkElementInfo(__workStart, *pLinkElement, elementTextLength);
2082 __pCutLinkListInfo->InsertText(__workStart, elementTextLength);
2085 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
2087 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(&textElement);
2088 if (pSimpleText != null)
2090 pSimpleText->SetUserWrap(__wrap);
2098 TextComposite::Remove(int startTextIndex, int textLength)
2100 if (textLength == 0)
2105 result r = E_SUCCESS;
2106 TextElement* pNewTextElement = null;
2107 int startElementIndex = -1;
2108 int endElementIndex = -1;
2109 int elementTextOffset = 0;
2110 int elementIndex = 0;
2111 int currentLength = 0;
2112 int textIndexFromElementOffset = 0;
2113 int textIndex = startTextIndex;
2114 int remainingLength = textLength;
2116 TextElement* pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
2117 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
2118 SysTryReturn(NID_GRP, currentLength > 0, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] _Text::TextElement is invalid.");
2120 startElementIndex = elementIndex;
2122 if (elementTextOffset == textIndex && remainingLength == currentLength)
2124 __pTextElementList->RemoveAt(elementIndex, true);
2128 else if (elementTextOffset < textIndex && remainingLength < currentLength)
2130 pTextElement->SetTextLength(pTextElement->GetTextLength() - currentLength);
2132 pNewTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE, 0);
2133 SysTryReturn(NID_GRP, pNewTextElement, r, r, "[E_SYSTEM] Fail to clone text element.");
2135 pNewTextElement->SetTextLength(currentLength - remainingLength);
2136 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset + remainingLength);
2138 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
2139 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
2141 endElementIndex = elementIndex;
2145 else if (elementTextOffset < textIndex)
2147 pTextElement->SetTextLength(pTextElement->GetTextLength() - currentLength);
2149 textIndex += currentLength;
2150 remainingLength -= currentLength;
2154 while (remainingLength > 0)
2156 pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(elementIndex));
2159 endElementIndex = elementIndex;
2163 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
2164 currentLength = pTextElement->GetTextLength();
2166 if (remainingLength < currentLength)
2168 pTextElement->SetTextLength(currentLength - remainingLength);
2169 pTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset + remainingLength);
2171 endElementIndex = elementIndex;
2176 __pTextElementList->RemoveAt(elementIndex, true);
2179 endElementIndex = elementIndex;
2180 remainingLength -= currentLength;
2184 __length -= textLength;
2185 Optimize(startElementIndex, endElementIndex);
2189 Release(pNewTextElement);
2194 TextComposite::RemoveElementAt(int elementIndex, bool deallocate)
2196 SysTryReturn(NID_GRP, elementIndex >= 0 && elementIndex < __pTextElementList->GetCount()
2197 , E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2199 result r = E_SUCCESS;
2200 TextElement* pTextElement = null;
2202 pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(elementIndex));
2203 if (pTextElement != null)
2205 int elementTextLength = pTextElement->GetTextLength();
2206 int elementTextOffset = GetFirstTextIndexAt(elementIndex);
2208 r = __pTextElementList->RemoveAt(elementIndex);
2209 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to remove element.", GetErrorMessage(r));
2211 if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
2213 __pCutLinkListInfo->RemoveCutLinkElementInfo(dynamic_cast < TextCutLink* >(pTextElement));
2217 __pCutLinkListInfo->RemoveText(elementTextOffset, elementTextLength);
2220 __length -= elementTextLength;
2224 Release(pTextElement);
2232 TextComposite::RemoveAllElements(bool deallocate)
2234 result r = E_SUCCESS;
2236 if (__pCutLinkListInfo)
2238 __pCutLinkListInfo->RemoveAllCutLinkElementInfos();
2241 __pTextElementList->RemoveAll(deallocate);
2243 SysTryCatch(NID_GRP, __pTextElementList->GetCount() == 0, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to remove all elements.");
2248 __displayBlock = false;
2263 TextComposite::SearchTextElement(TextElementType type, int textIndex, int& elementTextOffset) const
2265 SysTryReturn(NID_GRP, 0 <= textIndex && textIndex < __length, null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2267 result r = E_SUCCESS;
2268 IEnumerator* pEnum = null;
2269 TextElement* pTextElement = null;
2271 int elementIndex = 0;
2272 int currentLength = 0;
2273 int textIndexFromElementOffset = 0;
2275 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
2276 SysTryReturn(NID_GRP, pTextElement, null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
2278 if (pTextElement->GetType() == type)
2280 return pTextElement;
2283 elementTextOffset += pTextElement->GetTextLength();
2285 pEnum = __pTextElementList->GetEnumeratorN();
2286 for (int i = 0; i < elementIndex; i++)
2288 r = pEnum->MoveNext();
2289 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
2292 while (pEnum->MoveNext() == E_SUCCESS)
2294 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
2295 if (pTextElement == null)
2300 if (pTextElement->GetType() == type)
2303 SetLastResult(E_SUCCESS);
2304 return pTextElement;
2307 elementTextOffset += pTextElement->GetTextLength();
2311 SetLastResult(E_SUCCESS);
2320 TextComposite::GetTextN(int startTextIndex, int textLength) const
2322 SysTryReturn(NID_GRP, 0 <= startTextIndex && textLength <= __length, null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2324 result r = E_SUCCESS;
2325 IEnumerator* pEnum = null;
2327 int currentLength = 0;
2328 int elementTextOffset = 0;
2329 int elementIndex = 0;
2330 int textIndexFromElementOffset = 0;
2332 wchar_t* pText = new (std::nothrow) wchar_t[textLength+1];
2333 SysTryReturn(NID_GRP, pText, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2335 wchar_t* pTextPointer = pText;
2337 TextElement* pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
2338 SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get element.");
2340 textIndexFromElementOffset = startTextIndex - elementTextOffset;
2342 pEnum = __pTextElementList->GetEnumeratorN();
2343 for (int i = 0; i < elementIndex; i++)
2345 r = pEnum->MoveNext();
2348 while (pEnum->MoveNext() == E_SUCCESS)
2350 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
2353 currentLength = Math::Min(pTextElement->GetTextLength() - textIndexFromElementOffset, textLength);
2355 TextElementType objectType = pTextElement->GetType();
2357 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
2359 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
2362 const wchar_t* pSrcText = pSimpleText->GetText();
2363 TextUtility::CopyText(pTextPointer, &pSrcText[textIndexFromElementOffset], currentLength);
2366 textLength -= currentLength;
2367 pTextPointer += currentLength;
2371 if (textLength <= 0)
2376 textIndexFromElementOffset = 0;
2394 TextComposite::GetCharacter(int textIndex) const
2398 SysTryReturn(NID_GRP, 0 <= textIndex && textIndex <= __length, ch, E_INVALID_ARG
2399 , "[E_INVALID_ARG] The argument is invalid. textIndex(%d), __length(%d)", textIndex, __length);
2401 result r = E_SUCCESS;
2402 IEnumerator* pEnum = null;
2403 int currentLength = 0;
2404 int elementTextOffset = 0;
2405 int elementIndex = 0;
2406 int textIndexFromElementOffset = 0;
2408 TextElement* pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
2409 SysTryReturn(NID_GRP, pTextElement, ch, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
2411 textIndexFromElementOffset = textIndex - elementTextOffset;
2413 pEnum = __pTextElementList->GetEnumeratorN();
2414 for (int i = 0; i < elementIndex + 1; i++)
2416 r = pEnum->MoveNext();
2419 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
2423 TextElementType objectType = pTextElement->GetType();
2425 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
2427 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
2430 const wchar_t* pText = pSimpleText->GetText();
2431 ch = pText[textIndexFromElementOffset];
2441 TextComposite::GetText(TextComposite* pTargetCompsiteText, int textIndex, int textLength)
2443 SysTryReturn(NID_GRP, pTargetCompsiteText, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2444 SysTryReturn(NID_GRP, 0 < textLength, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2446 result r = E_SUCCESS;
2447 IEnumerator* pEnum = null;
2448 TextElement* pTextElement = null;
2449 TextElement* pNewTextElement = null;
2451 int currentLength = 0;
2452 int elementTextOffset = 0;
2453 int elementIndex = 0;
2454 int textIndexFromElementOffset = 0;
2456 if (textIndex == -1 || textIndex < 0)
2461 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
2462 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
2464 textIndexFromElementOffset = textIndex - elementTextOffset;
2466 pEnum = __pTextElementList->GetEnumeratorN();
2467 for (int i = 0; i < elementIndex; i++)
2469 r = pEnum->MoveNext();
2470 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
2473 while (pEnum->MoveNext() == E_SUCCESS)
2475 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
2476 if (pTextElement == null)
2481 textIndexFromElementOffset = 0;
2482 currentLength = Math::Min(pTextElement->GetTextLength(), textLength);
2484 pNewTextElement = pTextElement->CopyN(textIndexFromElementOffset, currentLength);
2485 if (pNewTextElement != null)
2487 pTargetCompsiteText->AppendElement(*pNewTextElement);
2490 textLength -= currentLength;
2502 TextComposite::Compose(FloatRectangle& rect, TextColumn* pTextColumn)
2504 SysTryReturn(NID_GRP, pTextColumn, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2506 __pCurrentTextColumn = pTextColumn;
2510 if (__pTextElementList->GetCount() == 0 || __length == 0)
2512 pTextColumn->RemoveAllLines();
2519 case TEXT_OBJECT_WRAP_TYPE_NONE:
2521 if (__drawAbbrevText)
2523 __pCurrentTextColumn->PrepareCompose();
2524 __drawTextEllipsis = false;
2526 if (__TextObjectEllipsisType == TEXT_OBJECT_ELLIPSIS_TYPE_TAIL)
2528 lineCount = ComposeInNoneWrap(rect);
2530 else if (__TextObjectEllipsisType == TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE)
2532 lineCount = ComposeInNoneWrapMiddleEllipsis(rect);
2536 lineCount = ComposeInNoneWrapHeadEllipsis(rect);
2541 bool setNoneWrapComposeInfo = false;
2542 NoneWrapComposeInfo noneWrapComposeInfo;
2544 TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(0);
2545 if (pTextLine != null)
2548 noneWrapComposeInfo.prevTextOffset = pTextLine->GetTextOffset();
2549 noneWrapComposeInfo.prevTextLength = pTextLine->GetTextLength();
2550 pTextLine->GetRegion(0, noneWrapComposeInfo.prevTextLength, noneWrapComposeInfo.prevWidth, noneWrapComposeInfo.prevHeight);
2551 noneWrapComposeInfo.prevEndType = pTextLine->GetEndType();
2552 setNoneWrapComposeInfo = true;
2555 __pCurrentTextColumn->PrepareCompose();
2556 __drawTextEllipsis = false;
2557 if (setNoneWrapComposeInfo)
2559 lineCount = ComposeInNoneWrap(rect, &noneWrapComposeInfo);
2563 lineCount = ComposeInNoneWrap(rect);
2567 __pCurrentTextColumn->FinishCompose();
2571 case TEXT_OBJECT_WRAP_TYPE_CHARACTER:
2573 __pCurrentTextColumn->PrepareCompose();
2574 lineCount = ComposeInWrap(rect);
2575 __pCurrentTextColumn->FinishCompose();
2579 case TEXT_OBJECT_WRAP_TYPE_WORD:
2581 if (IsPartialComposingModeEnabled())
2583 if (__pCurrentTextColumn->GetTotalLineCount() == 0)
2585 __pCurrentTextColumn->PrepareCompose();
2587 lineCount = ComposeInPartialMode(rect);
2591 __pCurrentTextColumn->PrepareCompose();
2592 //lineCount = ComposeInWrap(rect);
2593 lineCount = ComposeInWrapInSweepMode(rect);
2594 __pCurrentTextColumn->CompareDeletedLine();
2595 __pCurrentTextColumn->FinishCompose();
2606 TextComposite::SetRange(int textStartIndex, int textLength)
2608 SysTryReturn(NID_GRP, 0 <= textStartIndex && textStartIndex <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2610 __workStart = textStartIndex;
2611 __workLength = textLength;
2617 TextComposite::GetRange(int& startTextIndex, int& textLength) const
2619 startTextIndex = __workStart;
2620 textLength = __workLength;
2624 TextComposite::SetDisplayBitmap(const Bitmap* pBitmap)
2626 if (__workLength == 0)
2631 result r = E_SUCCESS;
2632 IEnumerator* pEnum = null;
2633 TextElement* pTextElement = null;
2634 TextElement* pNewTextElement = null;
2635 int startElementIndex = -1;
2636 int endElementIndex = -1;
2637 int textIndex = __workStart;
2638 int textLength = __workLength;
2639 int elementTextOffset = 0;
2640 int elementIndex = 0;
2641 int currentLength = 0;
2642 int textIndexFromElementOffset = 0;
2644 TextComponentInfoValueType type = SET_ALTERNATE_DISPLAY_BITMAP;
2646 BitmapDisplayProperty displayProperty;
2647 displayProperty.displayEnable = true;
2648 displayProperty.pBitmap = pBitmap;
2650 while (textLength > 0)
2652 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
2653 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
2654 SysTryReturn(NID_GRP, 0 < currentLength, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] _Text::TextElement is invalid.");
2656 if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT)
2659 startElementIndex = elementIndex;
2663 textIndex += currentLength;
2664 textLength -= currentLength;
2672 if (elementTextOffset == textIndex && textLength == currentLength)
2674 pTextElement->SetValue(SET_ALTERNATE_DISPLAY_BITMAP, (unsigned int)&displayProperty);
2675 displayProperty.displayEnable = false;
2678 else if (elementTextOffset < textIndex && textLength < currentLength)
2680 pTextElement->SetTextLength(pTextElement->GetTextLength() - currentLength);
2682 pNewTextElement = pTextElement->CloneN(SET_ALTERNATE_DISPLAY_BITMAP, (unsigned int)&displayProperty);
2683 SysTryReturn(NID_GRP, pNewTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element.");
2685 pNewTextElement->SetTextLength(textLength);
2686 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset);
2687 displayProperty.displayEnable = false;
2689 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
2690 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
2692 pNewTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE, 0);
2693 SysTryReturn(NID_GRP, pNewTextElement, r, r, "[E_SYSTEM] Fail to clone text element.");
2695 pNewTextElement->SetTextLength(currentLength - textLength);
2696 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset + textLength);
2698 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
2699 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
2701 endElementIndex = elementIndex;
2704 else if (elementTextOffset < textIndex)
2706 pTextElement->SetTextLength(pTextElement->GetTextLength() - currentLength);
2708 pNewTextElement = pTextElement->CloneN(SET_ALTERNATE_DISPLAY_BITMAP, (unsigned int)&displayProperty);
2709 SysTryReturn(NID_GRP, pNewTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element.");
2711 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset);
2712 pNewTextElement->SetTextLength(currentLength);
2713 displayProperty.displayEnable = false;
2715 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
2716 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
2718 textIndex += currentLength;
2719 textLength -= currentLength;
2723 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
2724 if (pTextElement == null)
2731 endElementIndex = elementIndex;
2736 pEnum = __pTextElementList->GetEnumeratorN();
2737 for (int i = 0; i <= elementIndex; i++)
2739 r = pEnum->MoveNext();
2740 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
2743 while (textLength > 0)
2745 TextElementType objectType = pTextElement->GetType();
2746 TextElementType objectTypeFromValueType = TextUtility::GetObjectTypeFromValueType(type);
2747 unsigned int elementValue = pTextElement->GetValue(SET_ALTERNATE_DISPLAY_BITMAP);
2749 if (objectType == objectTypeFromValueType && (unsigned int)&displayProperty != elementValue)
2751 if (textLength < currentLength)
2753 pNewTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE, 0);
2754 SysTryReturn(NID_GRP, pNewTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element.");
2756 pNewTextElement->SetTextLength(currentLength - textLength);
2757 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset + textLength);
2759 pTextElement->SetValue(SET_ALTERNATE_DISPLAY_BITMAP, (unsigned int)&displayProperty);
2760 pTextElement->SetTextLength(textLength);
2762 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
2763 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
2769 pTextElement->SetValue(SET_ALTERNATE_DISPLAY_BITMAP, (unsigned int)&displayProperty);
2772 displayProperty.displayEnable = false;
2773 endElementIndex = elementIndex;
2776 elementTextOffset += currentLength;
2777 textLength -= currentLength;
2780 if (pEnum->MoveNext() != E_SUCCESS)
2785 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
2786 if (pTextElement == null)
2791 currentLength = pTextElement->GetTextLength();
2792 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
2796 Optimize(startElementIndex, endElementIndex);
2801 Release(pNewTextElement);
2807 TextComposite::GetDisplayBitmap(int textIndex) const
2809 result r = E_SUCCESS;
2810 unsigned int value = 0;
2812 r = GetValue(textIndex, SET_ALTERNATE_DISPLAY_BITMAP, &value);
2813 SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
2815 return (Bitmap*)value;
2819 TextComposite::SetFont(Font* pFont)
2821 return SetValueToAllTextElements(SET_FONT, (unsigned int)pFont);
2825 TextComposite::GetFont(int textIndex) const
2827 unsigned int value = 0;
2829 GetValue(textIndex, SET_FONT, &value);
2830 Font* pFont = static_cast < Font* >((void*)value);
2832 SetLastResult(E_SUCCESS);
2838 TextComposite::SetFontSize(int size)
2840 return SetValueToAllTextElements(SET_FONT_SIZE, (unsigned int)size);
2844 TextComposite::SetFontSize(float size)
2846 return SetFontSize(_CoordinateSystemUtils::ConvertToInteger(size));
2850 TextComposite::GetFontSize(int textIndex) const
2852 return _CoordinateSystemUtils::ConvertToInteger(GetFontSizeF(textIndex));
2856 TextComposite::GetFontSizeF(int textIndex) const
2858 unsigned int value = 0;
2860 result r = GetValue(textIndex, SET_FONT_SIZE, &value);
2861 SysTryReturn(NID_GRP, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
2863 return (float)value;
2867 TextComposite::SetFontStyle(int style)
2869 return SetValueToAllTextElements(SET_FONT_STYLE, (unsigned int)style);
2873 TextComposite::GetFontStyle(int textIndex) const
2875 unsigned int value = 0;
2877 result r = GetValue(textIndex, SET_FONT_STYLE, &value);
2878 SysTryReturn(NID_GRP
2880 , -1, r, "[%s] Propagating.", GetErrorMessage(r));
2886 TextComposite::SetForegroundColor(const Color& color)
2888 return SetValueToAllTextElements(SET_FONT_FGCOLOR, (unsigned int)color.GetRGB32());
2892 TextComposite::GetForegroundColor(int textIndex) const
2894 result r = E_SUCCESS;
2895 unsigned int value = 0;
2897 r = GetValue(textIndex, SET_FONT_FGCOLOR, &value);
2898 SysTryReturn(NID_GRP, r == E_SUCCESS, Color::GetColor(COLOR_ID_BLACK), r, "[%s] Propagating.", GetErrorMessage(r));
2900 return Color(value);
2904 TextComposite::SetBackgroundColor(const Color& color)
2906 return SetValueToAllTextElements(SET_FONT_BGCOLOR, (unsigned int)color.GetRGB32());
2910 TextComposite::GetBackgroundColor(int textIndex) const
2912 result r = E_SUCCESS;
2913 unsigned int value = 0;
2915 r = GetValue(textIndex, SET_FONT_BGCOLOR, &value);
2916 SysTryReturn(NID_GRP, r == E_SUCCESS, Color::GetColor(COLOR_ID_BLACK), r, "[%s] Propagating.", GetErrorMessage(r));
2918 return Color(value);
2922 TextComposite::SetOutlineColor(const Color& color)
2924 return SetValueToAllTextElements(SET_FONT_OUTLINECOLOR, (unsigned int)color.GetRGB32());
2928 TextComposite::GetOutlineColor(int textIndex) const
2930 result r = E_SUCCESS;
2931 unsigned int value = 0;
2933 r = GetValue(textIndex, SET_FONT_OUTLINECOLOR, &value);
2934 SysTryReturn(NID_GRP, r == E_SUCCESS, Color::GetColor(COLOR_ID_BLACK), r, "[%s] Propagating.", GetErrorMessage(r));
2936 return Color(value);
2940 TextComposite::GetAlternativeForegroundColor(int textIndex) const
2942 SysTryReturn(NID_GRP, 0 <= textIndex && textIndex < __length
2943 , Color::GetColor(COLOR_ID_BLACK), E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
2945 result r = E_SUCCESS;
2946 unsigned int value = 0;
2948 r = GetValue(textIndex, SET_ALTERNATIVE_FGCOLOR, &value);
2949 SysTryReturn(NID_GRP, r == E_SUCCESS, Color::GetColor(COLOR_ID_BLACK), r, "[%s] Propagating.", GetErrorMessage(r));
2951 return Color(value);
2955 TextComposite::SetAlternateLookEnabled(bool enable)
2957 return SetValueToAllTextElements(SET_ALTERNATE_LOOK, (unsigned int)enable);
2961 TextComposite::GetMaxLineHeight(void) const
2963 IEnumerator* pEnum = null;
2964 TextElement* pTextElement = null;
2968 pEnum = __pTextElementList->GetEnumeratorN();
2969 while (pEnum->MoveNext() == E_SUCCESS)
2971 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
2972 if (pTextElement == null)
2977 height = pTextElement->GetHeight();
2978 maxHeight = Math::Max(maxHeight, height);
2986 TextComposite::GetMaxLineHeightF(void) const
2988 return _CoordinateSystemUtils::ConvertToFloat(GetMaxLineHeight());
2992 TextComposite::GetElementAtTextIndex(int textIndex, int& elementTextOffset, int& elementIndex, int& elementTextLength,
2993 int& textIndexFromElementOffset) const
2995 result r = E_SUCCESS;
2996 IEnumerator* pEnum = null;
2997 TextElement* pTextElement = null;
2999 int currentElementLength = 0;
3001 elementTextOffset = 0;
3003 elementTextLength = 0;
3004 textIndexFromElementOffset = 0;
3006 if (__pTextElementList->GetCount() == 0)
3011 pEnum = __pTextElementList->GetEnumeratorN();
3012 r = pEnum->MoveNext();
3013 SysTryReturn(NID_GRP, r == E_SUCCESS, null, r
3014 , "[%s] Fail to move next element. Now Elements count is (%d)", GetErrorMessage(r), __pTextElementList->GetCount());
3016 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3017 SysTryReturn(NID_GRP, pTextElement, null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
3021 currentElementLength = pTextElement->GetTextLength();
3022 if (textIndex < elementTextOffset + currentElementLength)
3024 offset = pTextElement->GetValue(SET_TEXT_OFFSET);
3025 textIndexFromElementOffset = offset + (textIndex - elementTextOffset);
3030 if (currentElementLength == 0 && textIndex == elementTextOffset)
3032 offset = pTextElement->GetValue(SET_TEXT_OFFSET);
3033 textIndexFromElementOffset = offset + (textIndex - elementTextOffset);
3038 pTextElement = null;
3039 if (pEnum->MoveNext() != E_SUCCESS)
3044 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3045 if (pTextElement == null)
3050 elementTextOffset += currentElementLength;
3054 if (pTextElement != null)
3056 elementTextLength = elementTextOffset + currentElementLength - textIndex;
3060 return pTextElement;
3064 TextComposite::GetElementAtTextIndex(int textIndex) const
3066 result r = E_SUCCESS;
3067 IEnumerator* pEnum = null;
3068 TextElement* pTextElement = null;
3069 int currentElementLength = 0;
3070 int elementTextOffset = 0;
3072 if (__pTextElementList->GetCount() == 0 || textIndex < 0)
3077 pEnum = __pTextElementList->GetEnumeratorN();
3078 r = pEnum->MoveNext();
3079 SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Fail to move next element. Now Elements count is (%d)"
3080 , GetErrorMessage(r), __pTextElementList->GetCount());
3082 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3083 SysTryReturn(NID_GRP, pTextElement, null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
3087 currentElementLength = pTextElement->GetTextLength();
3088 if (textIndex < elementTextOffset + currentElementLength)
3094 if (currentElementLength == 0 && textIndex == elementTextOffset)
3100 pTextElement = null;
3101 if (pEnum->MoveNext() != E_SUCCESS)
3106 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3107 if (pTextElement == null)
3112 elementTextOffset += currentElementLength;
3116 return pTextElement;
3120 TextComposite::SetWrap(TextObjectWrapType wrap)
3129 IEnumerator* pEnum = null;
3130 TextElement* pTextElement = null;
3132 pEnum = __pTextElementList->GetEnumeratorN();
3133 while (pEnum->MoveNext() == E_SUCCESS)
3135 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3136 if (pTextElement == null)
3141 TextElementType objectType = pTextElement->GetType();
3142 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
3144 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
3145 if (pSimpleText != null)
3147 pSimpleText->SetUserWrap(__wrap);
3157 TextComposite::Optimize(int startElementIndex, int endElementIndex)
3159 TextElement* pStartTextElement = null;
3160 TextElement* pEndTextElement = null;
3161 TextElement* pCurrentTextElement = null;
3162 TextElement* pNextTextElement = null;
3163 int elementIndex = 0;
3164 int elementCount = __pTextElementList->GetCount();
3166 if (elementCount == 0)
3171 startElementIndex = (startElementIndex == -1 || startElementIndex < 0) ? 0 : startElementIndex;
3172 endElementIndex = (endElementIndex == -1 || endElementIndex < 0 || endElementIndex > elementCount - 1) ? elementCount - 1 : endElementIndex;
3173 startElementIndex = (0 < startElementIndex) ? startElementIndex - 1 : startElementIndex;
3174 endElementIndex = (endElementIndex < elementCount - 1) ? endElementIndex + 1 : endElementIndex;
3176 if (endElementIndex - startElementIndex < 1)
3181 pStartTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(startElementIndex));
3182 SysTryReturn(NID_GRP, pStartTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
3184 pEndTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(endElementIndex));
3185 SysTryReturn(NID_GRP, pEndTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
3189 pCurrentTextElement = pStartTextElement;
3191 elementIndex = startElementIndex + 1;
3192 pNextTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(elementIndex));
3193 if (pNextTextElement == null)
3198 if (TextUtility::CanMerge(pCurrentTextElement, pNextTextElement))
3200 pCurrentTextElement->SetTextLength(pCurrentTextElement->GetTextLength() + pNextTextElement->GetTextLength());
3201 __pTextElementList->RemoveAt(elementIndex, true);
3205 pStartTextElement = pNextTextElement;
3206 startElementIndex++;
3209 pStartTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(startElementIndex));
3210 if (pStartTextElement == null)
3215 while (startElementIndex != endElementIndex);
3221 TextComposite::ChangeTextOffset(wchar_t* pText, int elementIndex, int gap)
3223 SysTryReturn(NID_GRP, 0 <= elementIndex, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
3224 SysTryReturn(NID_GRP, gap != 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
3226 result r = E_SUCCESS;
3227 IEnumerator* pEnum = null;
3228 TextElement* pTextElement = null;
3230 pEnum = __pTextElementList->GetEnumeratorN();
3231 for (int i = 0; i < elementIndex; i++)
3233 r = pEnum->MoveNext();
3234 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
3237 while (pEnum->MoveNext() == E_SUCCESS)
3239 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3240 if (pTextElement == null)
3245 TextElementType objectType = pTextElement->GetType();
3246 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
3248 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
3249 if (pSimpleText != null)
3251 pSimpleText->ChangeTextOffset(pText, gap);
3265 TextComposite::NotifyTextChanged(wchar_t* pText, int startTextIndex, int textLength, int gap, Font* pFont,
3266 const Color& fgColor, const Color& bgColor, const Color& outlineColor)
3273 result r = E_SUCCESS;
3274 TextElement* pTextElement = null;
3275 TextElement* pNextTextElement = null;
3277 int currentLength = 0;
3278 int elementTextOffset = 0;
3279 int elementIndex = 0;
3280 int textIndexFromElementOffset = 0;
3281 bool isOptimized = false;
3283 //SetWorkWidth(pFont, pText, __workStart, gap);
3287 bool checkNextElement = false;
3289 if (__workStart == startTextIndex)
3291 pTextElement = GetElementAtTextIndex(__workStart, elementTextOffset, elementIndex, currentLength,
3292 textIndexFromElementOffset);
3296 pTextElement = GetElementAtTextIndex(__workStart - 1, elementTextOffset, elementIndex, currentLength,
3297 textIndexFromElementOffset);
3298 checkNextElement = true;
3301 if (pTextElement == null)
3303 TextSimple* pSimpleText = null;
3304 pSimpleText = new (std::nothrow)TextSimple(pText, gap, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, pFont, fgColor, bgColor, outlineColor);
3305 SysTryReturn(NID_GRP, pSimpleText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3307 pSimpleText->SetTextOffset(__workStart - startTextIndex);
3308 InsertElementAt(*pSimpleText, __workStart);
3314 TextSimple* pSimpleText = null;
3315 bool canMerge = false;
3317 TextElementType objectType = pTextElement->GetType();
3318 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
3320 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
3321 if (pSimpleText != null)
3323 if (pSimpleText->IsSame(pText, pFont, fgColor, bgColor, outlineColor, false))
3329 pTextElement = null;
3335 pTextElement = null;
3338 if (!canMerge && checkNextElement)
3340 pTextElement = null;
3342 if (currentLength == 1)
3344 pNextTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(elementIndex+1));
3345 if (pNextTextElement != null)
3347 objectType = pNextTextElement->GetType();
3348 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
3350 pSimpleText = dynamic_cast < TextSimple* >(pNextTextElement);
3351 if (pSimpleText != null)
3353 if (pSimpleText->IsSame(pText, pFont, fgColor, bgColor, outlineColor, false))
3356 pTextElement = pNextTextElement;
3360 pTextElement = null;
3366 pTextElement = null;
3371 pTextElement = null;
3376 if (pTextElement == null)
3378 TextSimple* pSimpleText = null;
3379 pSimpleText = new (std::nothrow)TextSimple(pText, gap, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL, pFont, fgColor, bgColor,
3381 SysTryReturn(NID_GRP, pSimpleText, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
3383 pSimpleText->SetTextOffset(__workStart - startTextIndex);
3384 InsertElementAt(*pSimpleText, __workStart);
3387 r = __pTextElementList->IndexOf(*pSimpleText, elementIndex);
3388 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Fail to get element index.", GetErrorMessage(r));
3392 __pCutLinkListInfo->InsertText(startTextIndex, gap);
3394 pTextElement->SetTextLength(pTextElement->GetTextLength() + gap);
3400 int remainingGap = -gap;
3403 int currentelementIndex = 0;
3405 textIndex = __workStart + remainingGap;
3406 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength,textIndexFromElementOffset);
3407 if (pTextElement == null || elementTextOffset == textIndex)
3409 pTextElement = GetElementAtTextIndex(textIndex - 1, elementTextOffset, elementIndex, currentLength,textIndexFromElementOffset);
3412 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
3414 currentelementIndex = elementIndex;
3415 currentGap = Math::Min(remainingGap, textIndex - elementTextOffset);
3416 if (currentGap == pTextElement->GetTextLength())
3418 RemoveElementAt(currentelementIndex);
3424 pTextElement->SetTextLength(pTextElement->GetTextLength() - currentGap);
3425 __length -= currentGap;
3426 if (currentGap < remainingGap)
3428 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
3429 if (pSimpleText != null)
3431 int offset = pSimpleText->GetTextOffset();
3432 offset -= (remainingGap - currentGap);
3433 pSimpleText->SetTextOffset(offset);
3438 remainingGap -= currentGap;
3439 while (remainingGap > 0)
3441 pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(--currentelementIndex));
3442 SysTryReturn(NID_GRP, pTextElement, r, r, "[%s] Fail to get element.", GetErrorMessage(r));
3444 int elementTextLength = pTextElement->GetTextLength();
3445 currentGap = Math::Min(elementTextLength, remainingGap);
3447 if (currentGap == elementTextLength)
3449 RemoveElementAt(currentelementIndex);
3455 __pCutLinkListInfo->RemoveText(__workStart, currentGap);
3456 pTextElement->SetTextLength(elementTextLength - currentGap);
3457 __length -= currentGap;
3460 remainingGap -= currentGap;
3464 ChangeTextOffset(pText, elementIndex + 1, gap);
3468 Optimize(elementIndex, elementIndex);
3475 TextComposite::ForwardAnalyzeWithFocusedObjectType(int textIndex, int textLength, int maxWidth,
3476 int& cursorIndex, TextElementType& type)
3478 return ForwardAnalyzeWithFocusedObjectType(textIndex, textLength
3479 , _CoordinateSystemUtils::ConvertToFloat(maxWidth), cursorIndex, type);
3483 TextComposite::ForwardAnalyzeWithFocusedObjectType(int textIndex, int textLength, float maxWidth,
3484 int& cursorIndex, TextElementType& type)
3486 result r = E_SUCCESS;
3487 FloatDimension textSize;
3488 int currentLength = 0;
3489 int elementTextOffset = 0;
3490 int elementIndex = 0;
3491 int textIndexFromElementOffset = 0;
3493 float remainingWidth = 0;
3494 int remainingLength = 0;
3495 int ret = TEXT_RETBY_NORMAL;
3496 bool isFirstWord = true;
3499 IEnumerator* pEnum = null;
3500 TextElement* pTextElement = null;
3503 type = TEXT_ELEMENT_TYPE_MAX;
3505 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
3506 SysTryReturn(NID_GRP, pTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
3508 remainingWidth = maxWidth;
3509 remainingLength = textLength;
3511 pEnum = __pTextElementList->GetEnumeratorN();
3512 for (int i = 0; i <= elementIndex; i++)
3514 r = pEnum->MoveNext();
3515 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
3518 currentLength = Math::Min(remainingLength, currentLength);
3520 while (remainingWidth > 0 || remainingLength > 0)
3522 ret = pTextElement->ForwardAnalyze(textIndexFromElementOffset, currentLength, remainingWidth, __wrap, textCount , textSize.width, textSize.height);
3523 TextElementType objectType = pTextElement->GetType();
3525 if ((objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) && (ret == TEXT_RETBY_LIMITWIDTH))
3527 FloatDimension tempTextSize;
3528 r = pTextElement->GetRegion(textIndexFromElementOffset, textCount + 1, tempTextSize.width, tempTextSize.height);
3529 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3531 if ((remainingWidth - textSize.width) > (tempTextSize.width - remainingWidth))
3533 textSize.width = tempTextSize.width;
3538 remainingWidth -= textSize.width;
3539 remainingWidth = (remainingWidth < 0) ? 0 : remainingWidth;
3541 remainingLength -= textCount;
3542 currentLength -= textCount ;
3543 cursorIndex += textCount ;
3545 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret != TEXT_RETBY_LIMITWIDTH)
3547 index = cursorIndex;
3550 if (remainingLength <= currentLength)
3555 if (ret == TEXT_RETBY_OVERWIDTH || ret == TEXT_RETBY_LINEFEED)
3560 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD)
3562 if (ret == TEXT_RETBY_LIMITWIDTH)
3564 if (isFirstWord == false)
3566 cursorIndex = index;
3567 ret = TEXT_RETBY_NORMAL;
3572 isFirstWord = false;
3574 if (currentLength > 0)
3576 textIndexFromElementOffset += textCount ;
3582 if (ret == TEXT_RETBY_LIMITWIDTH)
3588 if (pEnum->MoveNext() != E_SUCCESS)
3593 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3594 if (pTextElement == null)
3599 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
3600 currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength);
3603 if (ret == TEXT_RETBY_LIMITLENGTH)
3605 ret = TEXT_RETBY_NORMAL;
3608 SetLastResult(E_SUCCESS);
3618 TextComposite::HideFrontSpace(TextObjectSpaceHideType mode)
3620 __ignoreFrontBlank = true;
3621 __frontSpaceHideMode = mode;
3625 TextComposite::HideRearSpace(TextObjectSpaceHideType mode)
3627 __ignoreRearBlank = true;
3628 __rearSpaceHideMode = mode;
3632 TextComposite::ForwardAnalyzeInNoneCursorMode(int startTextIndex, int textLength, int maxWidth, int& textIndex)
3634 return ForwardAnalyzeInNoneCursorMode(startTextIndex, textLength
3635 , _CoordinateSystemUtils::ConvertToFloat(maxWidth), textIndex);
3639 TextComposite::ForwardAnalyzeInNoneCursorMode(int startTextIndex, int textLength, float maxWidth, int& textIndex)
3641 result r = E_SUCCESS;
3642 FloatDimension textSize;
3643 int currentLength = 0;
3644 int elementTextOffset = 0;
3645 int elementIndex = 0;
3646 int textIndexFromElementOffset = 0;
3648 float remainingWidth = 0;
3649 int remainingLength = 0;
3650 int ret = TEXT_RETBY_NORMAL;
3651 bool isFirstWord = true;
3655 IEnumerator* pEnum = null;
3656 TextElement* pTextElement = null;
3658 pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
3659 SysTryReturn(NID_GRP, pTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
3662 remainingWidth = maxWidth;
3663 remainingLength = textLength;
3665 pEnum = __pTextElementList->GetEnumeratorN();
3666 for (int i = 0; i <= elementIndex; i++)
3668 r = pEnum->MoveNext();
3669 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
3672 currentLength = Math::Min(remainingLength, currentLength);
3674 while (remainingWidth > 0 || remainingLength > 0)
3676 ret = pTextElement->ForwardAnalyze(textIndexFromElementOffset, currentLength, remainingWidth,
3677 __wrap, textCount, textSize.width, textSize.width);
3679 TextElementType objectType = pTextElement->GetType();
3681 if ((objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK) && (ret == TEXT_RETBY_LIMITWIDTH))
3683 FloatDimension tempTextSize;
3684 r = pTextElement->GetRegion(textIndexFromElementOffset, textCount + 1, tempTextSize.width, tempTextSize.height);
3685 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3687 textSize.width = tempTextSize.width;
3691 remainingWidth -= textSize.width;
3692 remainingWidth = (remainingWidth < 0) ? 0 : remainingWidth;
3694 remainingLength -= textCount;
3695 currentLength -= textCount;
3696 textIndex += textCount;
3698 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret != TEXT_RETBY_LIMITWIDTH)
3703 if (remainingLength <= currentLength)
3708 if (ret == TEXT_RETBY_OVERWIDTH || ret == TEXT_RETBY_LINEFEED)
3713 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD)
3715 if (ret == TEXT_RETBY_LIMITWIDTH)
3717 if (isFirstWord == false)
3720 ret = TEXT_RETBY_NORMAL;
3725 isFirstWord = false;
3727 if (currentLength > 0)
3729 textIndexFromElementOffset += textCount;
3735 if (ret == TEXT_RETBY_LIMITWIDTH)
3741 if (pEnum->MoveNext() != E_SUCCESS)
3746 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3747 if (pTextElement == null)
3752 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
3753 currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength);
3756 if (ret == TEXT_RETBY_LIMITLENGTH)
3758 ret = TEXT_RETBY_NORMAL;
3761 SetLastResult(E_SUCCESS);
3771 TextComposite::GetCutLinkElementCount(void) const
3773 return __pCutLinkListInfo->GetCutLinkElementCount();
3777 TextComposite::GetCutLinkElementIndexAt(int textIndex) const
3779 return __pCutLinkListInfo->GetCutLinkElementIndexAt(textIndex);
3783 TextComposite::GetCutLinkElementAtCutLinkElementIndex(int index) const
3785 return __pCutLinkListInfo->GetCutLinkElementAtCutLinkElementIndex(index);
3789 TextComposite::ResetAllCutLinkElementsState(void)
3791 return __pCutLinkListInfo->ResetAllCutLinkElementsState();
3795 TextComposite::ChangeCutLinkState(int linkIndex, bool select)
3797 return __pCutLinkListInfo->ChangeCutLinkState(linkIndex, select);
3801 TextComposite::SetValueToAllTextElements(TextComponentInfoValueType type, unsigned int value)
3803 if (__workLength == 0)
3808 result r = E_SUCCESS;
3809 IEnumerator* pEnum = null;
3810 TextElement* pTextElement = null;
3811 TextElement* pNewTextElement = null;
3812 int startElementIndex = -1;
3813 int endElementIndex = -1;
3816 int elementTextOffset = 0;
3817 int elementIndex = 0;
3818 int currentLength = 0;
3819 int textIndexFromElementOffset = 0;
3822 textIndex = __workStart;
3823 textLength = __workLength;
3825 while (textLength > 0)
3827 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
3828 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element. textIndex(%d)", textIndex);
3829 SysTryReturn(NID_GRP, 0 < currentLength, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] _Text::TextElement is invalid.");
3831 TextElementType objectType = pTextElement->GetType();
3832 unsigned int elementValue = pTextElement->GetValue(type);
3833 TextElementType objectTypeFromValueType = TextUtility::GetObjectTypeFromValueType(type);
3835 if (objectType == objectTypeFromValueType && value != elementValue)
3838 startElementIndex = elementIndex;
3841 else if ((COMMONOBJECT_VALUE_START <= type && type < MAX_COMMONOBJECT_VALUE) && (value != elementValue))
3844 startElementIndex = elementIndex;
3848 textIndex += currentLength;
3849 textLength -= currentLength;
3857 if (elementTextOffset == textIndex && textLength == currentLength)
3859 pTextElement->SetValue(type, value);
3862 else if (elementTextOffset < textIndex && textLength < currentLength)
3864 pTextElement->SetTextLength(pTextElement->GetTextLength() - currentLength);
3866 pNewTextElement = pTextElement->CloneN(type, value);
3867 SysTryReturn(NID_GRP, pNewTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element.");
3869 pNewTextElement->SetTextLength(textLength);
3870 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset);
3872 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
3873 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
3875 pNewTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE, 0);
3876 SysTryReturn(NID_GRP, pNewTextElement, r, r, "[E_SYSTEM] Fail to clone text element.");
3878 pNewTextElement->SetTextLength(currentLength - textLength);
3879 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset + textLength);
3881 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
3882 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
3884 endElementIndex = elementIndex;
3887 else if (elementTextOffset < textIndex)
3889 pTextElement->SetTextLength(pTextElement->GetTextLength() - currentLength);
3891 pNewTextElement = pTextElement->CloneN(type, value);
3892 SysTryReturn(NID_GRP, pNewTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element.");
3894 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset);
3895 pNewTextElement->SetTextLength(currentLength);
3897 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
3898 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
3900 textIndex += currentLength;
3901 textLength -= currentLength;
3905 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
3906 if (pTextElement == null)
3913 endElementIndex = elementIndex;
3918 pEnum = __pTextElementList->GetEnumeratorN();
3919 for (int i = 0; i <= elementIndex; i++)
3921 r = pEnum->MoveNext();
3922 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to move next element.", GetErrorMessage(r));
3925 while (textLength > 0)
3927 TextElementType objectType = pTextElement->GetType();
3928 TextElementType objectTypeFromValueType = TextUtility::GetObjectTypeFromValueType(type);
3929 unsigned int elementValue = pTextElement->GetValue(type);
3931 if (objectType == objectTypeFromValueType && value != elementValue)
3933 if (textLength < currentLength)
3935 pNewTextElement = pTextElement->CloneN(SET_ALLVALUE_CLONE, 0);
3936 SysTryReturn(NID_GRP, pNewTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to clone text element.");
3938 pNewTextElement->SetTextLength(currentLength - textLength);
3939 pNewTextElement->SetValue(SET_TEXT_OFFSET, textIndexFromElementOffset + textLength);
3941 pTextElement->SetValue(type, value);
3942 pTextElement->SetTextLength(textLength);
3944 r = __pTextElementList->InsertAt(*pNewTextElement, ++elementIndex);
3945 SysTryCatch(NID_GRP, r == E_SUCCESS, , r, "[%s] Fail to insert element.", GetErrorMessage(r));
3951 pTextElement->SetValue(type, value);
3954 endElementIndex = elementIndex;
3957 elementTextOffset += currentLength;
3958 textLength -= currentLength;
3961 if (pEnum->MoveNext() != E_SUCCESS)
3966 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
3967 if (pTextElement == null)
3972 currentLength = pTextElement->GetTextLength();
3973 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
3977 Optimize(startElementIndex, endElementIndex);
3982 Release(pNewTextElement);
3988 TextComposite::SetAbbrevObjectFontInfo(TextSimple* pSimpleText)
3990 SysTryReturn(NID_GRP, __pAbbrevTextElement, false, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
3992 __pAbbrevTextElement->SetFont(pSimpleText->GetFont());
3993 __pAbbrevTextElement->SetForegroundColor(pSimpleText->GetForegroundColor());
3994 __pAbbrevTextElement->SetBackgroundColor(pSimpleText->GetBackgroundColor());
3995 __pAbbrevTextElement->SetOutlineColor(pSimpleText->GetOutlineColor());
3996 __pAbbrevTextElement->SetOutlineEnabled(pSimpleText->IsOutlineEnable());
3997 __pAbbrevTextElement->SetAlternativeForegroundColor(pSimpleText->GetAlternativeForegroundColor());
3998 __pAbbrevTextElement->SetAlternateLookEnabled(pSimpleText->IsAlternateLookEnabled());
4000 if (pSimpleText->IsTextShadowEnable() == true)
4002 __pAbbrevTextElement->SetTextShadowEnabled(true);
4003 __pAbbrevTextElement->SetTextShadowOffset(pSimpleText->GetTextShadowOffset());
4010 TextComposite::ComposeInNoneWrap(FloatRectangle& rect, NoneWrapComposeInfo* pNoneWrapComposeInfo)
4012 SysTryReturn(NID_GRP, __pCurrentTextColumn, -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
4014 TextLine* pTextLine = new (std::nothrow)TextLine(this);
4015 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4017 FloatRectangle lineBounds;
4018 FloatDimension lineTextSize;
4019 int lineLength = __length;
4020 float baseline = 0.0f;
4021 float elementBaseline = 0.0f;
4023 GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
4024 lineBounds.width = (rect.width < lineTextSize.width) ? lineTextSize.width :rect.width;
4025 lineBounds.height = lineTextSize.height;
4027 for (int i = 0; i < GetElementCount(); i++)
4029 TextElement* pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0));
4032 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
4035 elementBaseline = pSimpleText->GetBaselineF();
4036 if (baseline < elementBaseline)
4038 baseline = elementBaseline;
4044 pTextLine->SetBounds(lineBounds);
4045 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
4046 pTextLine->SetTextOffset(0);
4047 pTextLine->SetTextLength(lineLength);
4048 pTextLine->SetEndType(TEXT_RETBY_NORMAL);
4049 pTextLine->SetBaseline(baseline);
4050 GetTextExtentList(pTextLine);
4052 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4058 TextComposite::GetTextExtentList(TextLine* pTextLine) const
4060 result r = E_SUCCESS;
4061 int lineOffset = pTextLine->GetTextOffset();
4062 int lineLength = pTextLine->GetTextLength();
4063 int elementTextOffset = 0;
4064 int elementIndex = 0;
4065 int currentLength = 0;
4066 int textIndexFromElementOffset = 0;
4067 int remainingLength = 0;
4071 if (lineLength == 0)
4076 TextElement* pTextElement = GetElementAtTextIndex(lineOffset, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
4077 SysTryReturn(NID_GRP, pTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element. (lineOffset = %d)", lineOffset);
4079 remainingLength = lineLength;
4080 currentLength = Math::Min(remainingLength, currentLength);
4082 IEnumerator* pEnum = __pTextElementList->GetEnumeratorN();
4083 for (int i = 0; i <= elementIndex; i++)
4085 r = pEnum->MoveNext();
4088 Collection::ArrayListT<_FloatPair>* pGapListF = new (std::nothrow) Collection::ArrayListT<_FloatPair>;
4089 _FloatPair currentGap;
4091 while (remainingLength != 0)
4093 TextElementType objectType = pTextElement->GetType();
4094 if (objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT)
4096 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
4097 if (pSimpleText != null)
4099 const Bitmap* pBitmap = pSimpleText->GetBitmap();
4102 currentGap.first = maxWidth;
4103 currentGap.second = currentGap.first + pBitmap->GetWidth();
4105 pGapListF->Add(currentGap);
4106 right = (right < currentGap.second) ? currentGap.second : right;
4110 _FontImpl* pFontImpl = _FontImpl::GetInstance(*const_cast < Font* >(pSimpleText->GetFont()));
4111 SysTryCatch(NID_GRP, pFontImpl, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get native font instance.");
4113 Collection::ArrayListT<_FloatPair> pCurrentElementGapListF;
4115 if (__wrap == TEXT_OBJECT_WRAP_TYPE_NONE)
4117 const wchar_t* pText = pSimpleText->GetText();
4118 int textLength = pSimpleText->GetTextLength();
4120 wchar_t* pModifiedText = new (std::nothrow) wchar_t[textLength + 1];
4121 SysTryCatch(NID_GRP, pModifiedText, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4123 int length = TextSimple::ConvertEnterToSpace(pModifiedText, pText, textLength);
4126 pModifiedText[textLength] = 0;
4127 pFontImpl->GetTextExtentList(pModifiedText, 0, currentLength, pCurrentElementGapListF);
4130 delete[] pModifiedText;
4131 pModifiedText = null;
4135 const wchar_t* pText = pSimpleText->GetTextSource();
4136 pFontImpl->GetTextExtentList(pText, textIndexFromElementOffset, currentLength, pCurrentElementGapListF);
4139 IEnumeratorT<_FloatPair >* pCurrentElementGapEnum = pCurrentElementGapListF.GetEnumeratorN();
4140 while (pCurrentElementGapEnum->MoveNext() == E_SUCCESS)
4142 pCurrentElementGapEnum->GetCurrent(currentGap);
4144 currentGap.first = maxWidth + currentGap.first;
4145 currentGap.second = maxWidth + currentGap.second;
4147 pGapListF->Add(currentGap);
4148 right = (right < currentGap.second) ? currentGap.second : right;
4151 Release(pCurrentElementGapEnum);
4155 else if (objectType == TEXT_ELEMENT_TYPE_IMAGE)
4157 TextImage* pImageText = dynamic_cast < TextImage* >(pTextElement);
4158 if (pImageText != null)
4160 FloatRectangle rect = pImageText->GetBoundsF();
4162 currentGap.first = maxWidth;
4163 currentGap.second = currentGap.first + rect.width;
4165 pGapListF->Add(currentGap);
4166 right = (right < currentGap.second) ? currentGap.second : right;
4170 remainingLength -= currentLength;
4172 if (pEnum->MoveNext() != E_SUCCESS)
4177 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
4178 if (pTextElement == null)
4183 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
4184 currentLength = Math::Min(pTextElement->GetTextLength(), remainingLength);
4189 pTextLine->SetTextExtentList(pGapListF);
4204 TextComposite::ComposeInWrap(FloatRectangle& rect)
4206 SysTryReturn(NID_GRP, __pCurrentTextColumn, -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
4211 int remainingLength = 0;
4212 float remainingWidth = 0;
4213 float remainingHeight = 0;
4215 bool hasPrevLine = false;
4216 FloatDimension textSize;
4217 TextLine* pTextLine = null;
4219 int endType = TEXT_RETBY_NORMAL;
4220 FloatRectangle lineBounds;
4221 FloatDimension lineTextSize;
4224 int displayLineCount = 0;
4225 float displayHeight = 0;
4227 float lineBaseline = 0;
4229 pTextLine = __pCurrentTextColumn->GetPrevLineChangedStartLine();
4230 if (pTextLine != null)
4232 endType = pTextLine->GetEndType();
4233 lineOffset = pTextLine->GetTextOffset();
4234 lineLength = pTextLine->GetTextLength();
4235 lineBounds = pTextLine->GetBoundsF();
4236 lineBaseline = pTextLine->GetBaselineF();
4237 pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineTextSize.width, lineTextSize.height);
4239 if (endType != TEXT_RETBY_LINEFEED)
4241 textIndex = lineOffset + lineLength;
4242 remainingLength = __length - textIndex;
4243 remainingWidth = lineBounds.width - lineTextSize.width;
4246 if (remainingLength == 0)
4253 textIndex = lineOffset + lineLength;
4254 remainingLength = __length - textIndex;
4255 remainingWidth = rect.width;
4256 offsetY = lineBounds.y + lineBounds.height;
4258 if (remainingLength == 0)
4260 float nextY = offsetY;
4261 lineTextSize.height = lineBounds.height;
4263 pTextLine = new (std::nothrow)TextLine(this);
4264 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4266 lineBounds.y = nextY;
4268 pTextLine->SetBounds(lineBounds);
4269 pTextLine->SetRegion(0.0f, lineTextSize.height);
4270 pTextLine->SetTextLength(0);
4271 pTextLine->SetTextOffset(textIndex);
4272 pTextLine->SetEndType(TEXT_RETBY_LINEFEED);
4273 pTextLine->SetBaseline(0);
4274 GetTextExtentList(pTextLine);
4276 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4278 if (lineBounds.y + lineBounds.height <= rect.height)
4280 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4281 displayHeight += lineBounds.height;
4282 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4292 remainingLength = __length;
4293 remainingWidth = rect.width;
4295 __pCurrentTextColumn->SetChangedStartLineIndex(0);
4300 pTextLine = new (std::nothrow)TextLine(this);
4301 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4303 lineBounds.x = rect.x;
4304 lineBounds.width = rect.width;
4305 lineBounds.y = offsetY;
4306 lineTextSize.height = 0;
4308 if (remainingLength == 0)
4310 lineTextSize.height = GetHeightF(0);
4311 lineBounds.height = lineTextSize.height;
4313 pTextLine->SetBounds(lineBounds);
4314 pTextLine->SetRegion(0.0f, lineTextSize.height);
4315 pTextLine->SetTextLength(0);
4316 pTextLine->SetTextOffset(textIndex);
4317 pTextLine->SetEndType(TEXT_RETBY_NORMAL);
4318 pTextLine->SetBaseline(0);
4319 GetTextExtentList(pTextLine);
4321 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4323 if (lineBounds.y + lineBounds.height <= rect.height)
4325 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4326 displayHeight += lineBounds.height;
4327 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4334 remainingHeight = rect.height;
4336 while (remainingLength != 0)
4338 ret = ForwardAnalyzeWithBaseline(textIndex, remainingLength, remainingWidth, __wrap, textCount, textSize.width, textSize.height, baseline);
4353 lineOffset = textIndex;
4354 lineLength = textCount;
4355 lineTextSize.width = textSize.width;
4356 lineTextSize.height = textSize.height;
4357 lineBounds.height = textSize.height;
4360 pTextLine->SetBounds(lineBounds);
4361 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
4362 pTextLine->SetTextLength(lineLength);
4363 pTextLine->SetTextOffset(lineOffset);
4364 pTextLine->SetEndType(ret);
4365 pTextLine->SetBaseline(baseline);
4366 GetTextExtentList(pTextLine);
4368 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4371 if (lineBounds.y + lineBounds.height <= rect.height)
4373 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4374 displayHeight += lineBounds.height;
4375 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4380 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD)
4382 if (ret != TEXT_RETBY_LIMITWIDTH)
4384 lineLength += textCount;
4385 lineTextSize.width += textSize.width;
4386 lineBounds.height = (lineBounds.height > textSize.height) ? lineBounds.height: textSize.height;
4387 lineTextSize.height = lineBounds.height;
4389 baseline = (lineBaseline > baseline) ? baseline : lineBaseline;
4391 pTextLine->SetBounds(lineBounds);
4392 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
4393 pTextLine->SetTextLength(lineLength);
4394 pTextLine->SetEndType(endType);
4395 pTextLine->SetBaseline(baseline);
4396 GetTextExtentList(pTextLine);
4398 __pCurrentTextColumn->CheckComposeDone(pTextLine);
4407 lineLength += textCount;
4408 lineTextSize.width += textSize.width;
4409 lineBounds.height = (lineBounds.height > textSize.height) ? lineBounds.height : textSize.height;
4410 lineTextSize.height = lineBounds.height;
4412 baseline = (lineBaseline > baseline) ? baseline : lineBaseline;
4414 pTextLine->SetBounds(lineBounds);
4415 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
4416 pTextLine->SetTextLength(lineLength);
4417 pTextLine->SetEndType(endType);
4418 pTextLine->SetBaseline(baseline);
4419 GetTextExtentList(pTextLine);
4421 __pCurrentTextColumn->CheckComposeDone(pTextLine);
4426 __pCurrentTextColumn->SetChangedStartLineIndex(pTextLine->GetIndex());
4429 hasPrevLine = false;
4432 if (__pCurrentTextColumn->IsComposeDone())
4437 textIndex += textCount;
4438 remainingLength -= textCount;
4440 remainingHeight -= lineTextSize.height;
4442 if (remainingLength > 0)
4444 float nextY = lineBounds.y + lineBounds.height;
4446 pTextLine = new (std::nothrow)TextLine(this);
4447 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4449 lineBounds.x = rect.x;
4450 lineBounds.y = nextY;
4451 lineBounds.width = rect.width;
4452 lineTextSize.height = 0;
4454 remainingWidth = rect.width;
4458 if (endType == TEXT_RETBY_LINEFEED)
4460 float nextY = lineBounds.y + lineBounds.height;
4461 lineTextSize.height = lineBounds.height;
4463 pTextLine = new (std::nothrow)TextLine(this);
4464 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4466 lineBounds.x = rect.x;
4467 lineBounds.y = nextY;
4468 lineBounds.width = rect.width;
4469 lineBounds.height = lineTextSize.height;
4471 pTextLine->SetBounds(lineBounds);
4472 pTextLine->SetRegion(0.0f, lineTextSize.height);
4473 pTextLine->SetTextLength(0);
4474 pTextLine->SetTextOffset(textIndex);
4475 pTextLine->SetEndType(TEXT_RETBY_LINEFEED);
4476 pTextLine->SetBaseline(0);
4477 GetTextExtentList(pTextLine);
4479 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4482 if (lineBounds.y + lineBounds.height <= rect.height)
4484 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4485 displayHeight += lineBounds.height;
4486 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4495 FloatDimension columnTextSize;
4496 __pCurrentTextColumn->GetRegion(0, __length, columnTextSize.width, columnTextSize.height);
4497 rect.height = columnTextSize.height;
4501 __pCurrentTextColumn->SetChangedLastLineIndex(pTextLine->GetIndex());
4504 if (Tizen::App::_AppInfo::IsOspCompat())
4506 __pCurrentTextColumn->SetDisplayLineCount(0);
4507 __pCurrentTextColumn->SetDisplayHeight(0);
4514 TextComposite::ComposeInWrapInSweepMode(FloatRectangle& rect)
4516 SysTryReturn(NID_GRP, __pCurrentTextColumn, -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
4521 int remainingLength = 0;
4522 float remainingWidth = 0;
4523 float remainingHeight = 0;
4525 bool hasPrevLine = false;
4526 FloatDimension textSize;
4527 TextLine* pTextLine = null;
4528 TextLine* pPrevTextLine = null;
4530 int endType = TEXT_RETBY_NORMAL;
4531 FloatRectangle lineBounds;
4532 FloatDimension lineTextSize;
4535 int displayLineCount = 0;
4536 float displayHeight = 0;
4538 float lineBaseline = 0;
4539 int prevLineIndex = 0;
4541 pPrevTextLine = __pCurrentTextColumn->GetPrevTextLine(prevLineIndex++);
4542 pTextLine = __pCurrentTextColumn->GetPrevLineChangedStartLine();
4544 if (pTextLine != null)
4546 endType = pTextLine->GetEndType();
4547 lineOffset = pTextLine->GetTextOffset();
4548 lineLength = pTextLine->GetTextLength();
4549 lineBounds = pTextLine->GetBoundsF();
4550 lineBaseline = pTextLine->GetBaselineF();
4551 pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineTextSize.width, lineTextSize.height);
4553 if (endType != TEXT_RETBY_LINEFEED)
4555 textIndex = lineOffset + lineLength;
4556 remainingLength = __length - textIndex;
4557 remainingWidth = lineBounds.width - lineTextSize.width;
4560 if (remainingLength == 0)
4567 textIndex = lineOffset + lineLength;
4568 remainingLength = __length - textIndex;
4569 remainingWidth = rect.width;
4570 offsetY = lineBounds.y + lineBounds.height;
4572 pPrevTextLine = __pCurrentTextColumn->GetPrevTextLine(prevLineIndex++);
4574 if (remainingLength == 0)
4576 float nextY = offsetY;
4577 lineTextSize.height = lineBounds.height;
4579 pTextLine = new (std::nothrow)TextLine(this);
4580 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4582 lineBounds.y = nextY;
4584 pTextLine->SetBounds(lineBounds);
4585 pTextLine->SetRegion(0.0f, lineTextSize.height);
4586 pTextLine->SetTextLength(0);
4587 pTextLine->SetTextOffset(textIndex);
4588 pTextLine->SetEndType(TEXT_RETBY_LINEFEED);
4589 pTextLine->SetBaseline(0);
4590 GetTextExtentList(pTextLine);
4592 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4594 if (lineBounds.y + lineBounds.height <= rect.height)
4596 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4597 displayHeight += lineBounds.height;
4598 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4608 remainingLength = __length;
4609 remainingWidth = rect.width;
4611 __pCurrentTextColumn->SetChangedStartLineIndex(0);
4616 pTextLine = new (std::nothrow)TextLine(this);
4617 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4619 lineBounds.x = rect.x;
4620 lineBounds.width = rect.width;
4621 lineBounds.y = offsetY;
4622 lineTextSize.height = 0;
4624 if (remainingLength == 0)
4626 lineTextSize.height = GetHeightF(0);
4627 lineBounds.height = lineTextSize.height;
4629 pTextLine->SetBounds(lineBounds);
4630 pTextLine->SetRegion(0.0f, lineTextSize.height);
4631 pTextLine->SetTextLength(0);
4632 pTextLine->SetTextOffset(textIndex);
4633 pTextLine->SetEndType(TEXT_RETBY_NORMAL);
4634 pTextLine->SetBaseline(0);
4635 GetTextExtentList(pTextLine);
4637 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4639 if (lineBounds.y + lineBounds.height <= rect.height)
4641 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4642 displayHeight += lineBounds.height;
4643 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4650 remainingHeight = rect.height;
4652 while (remainingLength != 0)
4654 ret = ForwardAnalyzeWithBaseline(textIndex, remainingLength, remainingWidth, __wrap, textCount, textSize.width, textSize.height, baseline);
4669 if ((__frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE) &&
4670 (GetCharacter(textIndex+textCount) == ' '))
4675 lineOffset = textIndex;
4676 lineLength = textCount;
4677 lineTextSize.width = textSize.width;
4678 lineTextSize.height = textSize.height;
4679 lineBounds.height = textSize.height;
4682 pTextLine->SetBounds(lineBounds);
4683 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
4684 pTextLine->SetTextLength(lineLength);
4685 pTextLine->SetTextOffset(lineOffset);
4686 pTextLine->SetEndType(ret);
4687 pTextLine->SetBaseline(baseline);
4688 GetTextExtentList(pTextLine);
4690 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4693 if (lineBounds.y + lineBounds.height <= rect.height)
4695 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4696 displayHeight += lineBounds.height;
4697 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4702 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD && ret == TEXT_RETBY_LIMITWIDTH)
4708 lineLength += textCount;
4709 lineTextSize.width += textSize.width;
4710 lineBounds.height = (lineBounds.height > textSize.height) ? lineBounds.height : textSize.height;
4711 lineTextSize.height = lineBounds.height;
4713 baseline = (lineBaseline > baseline) ? baseline : lineBaseline;
4715 pTextLine->SetBounds(lineBounds);
4716 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
4717 pTextLine->SetTextLength(lineLength);
4718 pTextLine->SetEndType(endType);
4719 pTextLine->SetBaseline(baseline);
4720 GetTextExtentList(pTextLine);
4722 __pCurrentTextColumn->CheckComposeDone(pTextLine);
4727 __pCurrentTextColumn->SetChangedStartLineIndex(pTextLine->GetIndex());
4730 hasPrevLine = false;
4733 if (__pSweepInfo->sweepEventType == TEXT_OBJECT_SWEEP_EVENT_INSERT)
4735 if (pPrevTextLine && pPrevTextLine->GetTextOffset() + __workLength == pTextLine->GetTextOffset())
4737 pPrevTextLine = __pCurrentTextColumn->GetPrevTextLine(prevLineIndex++);
4739 while(pPrevTextLine)
4741 TextLine* pNewTextLine = pPrevTextLine->CopyN();
4742 SysTryReturn(NID_GRP, pNewTextLine, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4743 pNewTextLine->SetTextOffset(pNewTextLine->GetTextOffset() + __workLength);
4744 GetTextExtentList(pNewTextLine);
4746 __pCurrentTextColumn->AddLineDuringCompose(pNewTextLine);
4748 pPrevTextLine = __pCurrentTextColumn->GetPrevTextLine(prevLineIndex++);
4754 else if (__pSweepInfo->sweepEventType == TEXT_OBJECT_SWEEP_EVENT_REMOVE)
4756 if (pPrevTextLine && pPrevTextLine->GetTextOffset() - __workLength == pTextLine->GetTextOffset())
4758 pPrevTextLine = __pCurrentTextColumn->GetPrevTextLine(prevLineIndex++);
4760 while(pPrevTextLine)
4762 TextLine* pNewTextLine = pPrevTextLine->CopyN();
4763 SysTryReturn(NID_GRP, pNewTextLine, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4764 pNewTextLine->SetTextOffset(pNewTextLine->GetTextOffset() - __workLength);
4765 GetTextExtentList(pNewTextLine);
4767 __pCurrentTextColumn->AddLineDuringCompose(pNewTextLine);
4769 pPrevTextLine = __pCurrentTextColumn->GetPrevTextLine(prevLineIndex++);
4776 if (__pCurrentTextColumn->IsComposeDone())
4781 pPrevTextLine = __pCurrentTextColumn->GetPrevTextLine(prevLineIndex++);
4783 textIndex += textCount;
4784 remainingLength -= textCount;
4785 remainingHeight -= lineTextSize.height;
4787 if (remainingLength > 0)
4789 float nextY = lineBounds.y + lineBounds.height;
4791 pTextLine = new (std::nothrow)TextLine(this);
4792 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4794 lineBounds.x = rect.x;
4795 lineBounds.y = nextY;
4796 lineBounds.width = rect.width;
4797 lineTextSize.height = 0;
4799 remainingWidth = rect.width;
4803 if (endType == TEXT_RETBY_LINEFEED)
4805 float nextY = lineBounds.y + lineBounds.height;
4806 lineTextSize.height = lineBounds.height;
4808 pTextLine = new (std::nothrow)TextLine(this);
4809 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4811 lineBounds.x = rect.x;
4812 lineBounds.y = nextY;
4813 lineBounds.width = rect.width;
4814 lineBounds.height = lineTextSize.height;
4816 pTextLine->SetBounds(lineBounds);
4817 pTextLine->SetRegion(0.0f, lineTextSize.height);
4818 pTextLine->SetTextLength(0);
4819 pTextLine->SetTextOffset(textIndex);
4820 pTextLine->SetEndType(TEXT_RETBY_LINEFEED);
4821 pTextLine->SetBaseline(0);
4822 GetTextExtentList(pTextLine);
4824 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4828 if (lineBounds.y + lineBounds.height <= rect.height)
4830 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4831 displayHeight += lineBounds.height;
4832 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4841 FloatDimension columnTextSize;
4842 __pCurrentTextColumn->GetRegion(0, __length, columnTextSize.width, columnTextSize.height);
4843 rect.height = columnTextSize.height;
4847 __pCurrentTextColumn->SetChangedLastLineIndex(pTextLine->GetIndex());
4850 if (Tizen::App::_AppInfo::IsOspCompat())
4852 __pCurrentTextColumn->SetDisplayLineCount(0);
4853 __pCurrentTextColumn->SetDisplayHeight(0);
4860 TextComposite::ComposeInPartialMode(FloatRectangle& rect)
4862 SysTryReturn(NID_GRP, __pCurrentTextColumn, -1, E_INVALID_STATE
4863 , "[E_INVALID_STATE] This instance is not constructed yet.");
4868 int remainingLength = 0;
4869 float remainingWidth = 0;
4870 float remainingHeight = 0;
4875 FloatDimension textSize;
4876 FloatDimension lineTextSize;
4877 FloatRectangle lineBounds;
4878 bool hasPrevLine = false;
4879 int displayLineCount = 0;
4880 float displayHeight = 0;
4882 float lineBaseline = 0;
4883 TextLine* pTextLine = null;
4884 int endType = TEXT_RETBY_NORMAL;
4886 if (__lineIndexCompositeDone != 0)
4888 pTextLine = __pCurrentTextColumn->GetTextLine(__lineIndexCompositeDone - 1);
4889 lineCount = __lineIndexCompositeDone;
4892 if (pTextLine != null)
4894 endType = pTextLine->GetEndType();
4895 lineOffset = pTextLine->GetTextOffset();
4896 lineLength = pTextLine->GetTextLength();
4897 lineBounds = pTextLine->GetBoundsF();
4898 lineBaseline = pTextLine->GetBaselineF();
4899 pTextLine->GetRegion(0, pTextLine->GetTextLength(), lineTextSize.width, lineTextSize.height);
4901 if (endType != TEXT_RETBY_LINEFEED)
4903 textIndex = lineOffset + lineLength;
4904 remainingLength = __length - textIndex;
4905 remainingWidth = lineBounds.width - lineTextSize.width;
4908 if (remainingLength == 0)
4915 textIndex = lineOffset + lineLength;
4916 remainingLength = __length - textIndex;
4917 remainingWidth = rect.width;
4918 offsetY = lineBounds.y + lineBounds.height;
4920 if (remainingLength == 0)
4922 float nextY = offsetY;
4923 lineTextSize.height = lineBounds.height;
4925 pTextLine = new (std::nothrow)TextLine(this);
4926 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4928 lineBounds.y = nextY;
4930 pTextLine->SetBounds(lineBounds);
4931 pTextLine->SetRegion(0.0f, lineTextSize.height);
4932 pTextLine->SetTextLength(0);
4933 pTextLine->SetTextOffset(textIndex);
4934 pTextLine->SetEndType(TEXT_RETBY_LINEFEED);
4935 pTextLine->SetBaseline(0);
4936 GetTextExtentList(pTextLine);
4938 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4940 if (lineBounds.y + lineBounds.height <= rect.height)
4942 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4943 displayHeight += lineBounds.height;
4944 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4954 remainingLength = __length;
4955 remainingWidth = rect.width;
4957 __pCurrentTextColumn->SetChangedStartLineIndex(0);
4962 pTextLine = new (std::nothrow)TextLine(this);
4963 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4965 lineBounds.x = rect.x;
4966 lineBounds.width = rect.width;
4967 lineBounds.y = offsetY;
4968 lineTextSize.height = 0;
4970 if (remainingLength == 0)
4972 lineTextSize.height = GetHeightF(0);
4973 lineBounds.height = lineTextSize.height;
4975 pTextLine->SetBounds(lineBounds);
4976 pTextLine->SetRegion(0.0f, lineTextSize.height);
4977 pTextLine->SetTextLength(0);
4978 pTextLine->SetTextOffset(textIndex);
4979 pTextLine->SetEndType(TEXT_RETBY_NORMAL);
4980 pTextLine->SetBaseline(0);
4981 GetTextExtentList(pTextLine);
4983 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
4985 if (lineBounds.y + lineBounds.height <= rect.height)
4987 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
4988 displayHeight += lineBounds.height;
4989 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
4996 remainingHeight = GetComposePartialLimitHeightF();
4997 if (remainingHeight == 0)
4999 remainingHeight = rect.height;
5001 if (remainingHeight < lineBounds.height && remainingLength > 0)
5003 remainingHeight = lineBounds.height;
5006 while (remainingLength != 0)
5008 ret = ForwardAnalyzeWithBaseline(textIndex, remainingLength, remainingWidth, __wrap, textCount, textSize.width, textSize.height, baseline);
5023 lineOffset = textIndex;
5024 lineLength = textCount;
5025 lineTextSize.width = textSize.width;
5026 lineTextSize.height = textSize.height;
5027 lineBounds.height = textSize.height;
5030 pTextLine->SetBounds(lineBounds);
5031 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
5032 pTextLine->SetTextLength(lineLength);
5033 pTextLine->SetTextOffset(lineOffset);
5034 pTextLine->SetEndType(endType);
5035 pTextLine->SetBaseline(baseline);
5036 GetTextExtentList(pTextLine);
5038 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
5040 if (lineBounds.y + lineBounds.height <= rect.height)
5042 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
5043 displayHeight += lineBounds.height;
5044 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
5048 __lineIndexCompositeDone++;
5049 __totalComposedHeight += lineTextSize.height;
5053 if (__wrap == TEXT_OBJECT_WRAP_TYPE_WORD)
5055 if (ret != TEXT_RETBY_LIMITWIDTH)
5057 lineLength += textCount;
5058 lineTextSize.width += textSize.width;
5059 lineBounds.height = (lineBounds.height > textSize.height) ? lineBounds.height: textSize.height;
5060 lineTextSize.height = lineBounds.height;
5062 baseline = (lineBaseline > baseline) ? baseline : lineBaseline;
5064 pTextLine->SetBounds(lineBounds);
5065 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
5066 pTextLine->SetTextLength(lineLength);
5067 pTextLine->SetEndType(endType);
5068 pTextLine->SetBaseline(baseline);
5069 GetTextExtentList(pTextLine);
5078 lineLength += textCount;
5079 lineTextSize.width += textSize.width;
5080 lineBounds.height = (lineBounds.height > textSize.height) ? lineBounds.height : textSize.height;
5081 lineTextSize.height = lineBounds.height;
5083 baseline = (lineBaseline > baseline) ? baseline : lineBaseline;
5085 pTextLine->SetBounds(lineBounds);
5086 pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
5087 pTextLine->SetTextLength(lineLength);
5088 pTextLine->SetEndType(endType);
5089 pTextLine->SetBaseline(baseline);
5090 GetTextExtentList(pTextLine);
5095 __pCurrentTextColumn->SetChangedStartLineIndex(pTextLine->GetIndex());
5098 hasPrevLine = false;
5101 if (__pCurrentTextColumn->IsComposeDone())
5106 textIndex += textCount;
5107 remainingLength -= textCount;
5108 remainingHeight -= lineTextSize.height;
5110 if (remainingHeight < 0)
5115 if (remainingLength > 0)
5117 float nextY = lineBounds.y + lineBounds.height;
5119 pTextLine = new (std::nothrow)TextLine(this);
5120 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5122 lineBounds.x = rect.x;
5123 lineBounds.y = nextY;
5124 lineBounds.width = rect.width;
5125 lineTextSize.height = 0;
5127 remainingWidth = rect.width;
5131 if (endType == TEXT_RETBY_LINEFEED)
5133 float nextY = lineBounds.y + lineBounds.height;
5134 lineTextSize.height = lineBounds.height;
5136 pTextLine = new (std::nothrow)TextLine(this);
5137 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5139 lineBounds.x = rect.x;
5140 lineBounds.y = nextY;
5141 lineBounds.width = rect.width;
5142 lineBounds.height = lineTextSize.height;
5144 pTextLine->SetBounds(lineBounds);
5145 pTextLine->SetRegion(0.0f, lineTextSize.height);
5146 pTextLine->SetTextLength(0);
5147 pTextLine->SetTextOffset(textIndex);
5148 pTextLine->SetEndType(TEXT_RETBY_LINEFEED);
5149 pTextLine->SetBaseline(0);
5150 GetTextExtentList(pTextLine);
5152 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
5156 if (lineBounds.y + lineBounds.height <= rect.height)
5158 __pCurrentTextColumn->SetDisplayLineCount(++displayLineCount);
5159 displayHeight += lineBounds.height;
5160 __pCurrentTextColumn->SetDisplayHeight(displayHeight);
5163 __lineIndexCompositeDone++;
5164 __totalComposedHeight += lineTextSize.height;
5165 __pCurrentTextColumn->FinishCompose();
5172 __pCurrentTextColumn->FinishCompose();
5177 rect.height = __totalComposedHeight;
5181 __pCurrentTextColumn->SetChangedLastLineIndex(pTextLine->GetIndex());
5184 if (Tizen::App::_AppInfo::IsOspCompat())
5186 __pCurrentTextColumn->SetDisplayLineCount(0);
5187 __pCurrentTextColumn->SetDisplayHeight(0);
5194 TextComposite::ComposeInNoneWrapMiddleEllipsis(FloatRectangle& rect)
5196 int endType = TEXT_RETBY_NORMAL;
5197 FloatRectangle lineBounds;
5198 FloatDimension abbrevTextDim;
5199 FloatDimension textSize;
5201 float maxHeight = 0;
5204 lineBounds.width = rect.width;
5207 lineBounds.height = rect.height;
5208 endType = ForwardAnalyzeWithBaseline(0, __length, lineBounds.width, __wrap, length, textSize.width, textSize.height, baseline);
5210 if (endType != TEXT_RETBY_LIMITWIDTH)
5212 __drawTextEllipsis = false;
5213 return ComposeInNoneWrap(rect);
5216 __drawTextEllipsis = true;
5218 TextElement* pTextElement = null;
5219 TextSimple* pSimpleText = null;
5221 pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0));
5222 SysTryReturn(NID_GRP, pTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
5224 TextElementType objectType = pTextElement->GetType();
5225 SysTryReturn(NID_GRP, objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
5227 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
5228 if (pSimpleText != null)
5230 SetAbbrevObjectFontInfo(pSimpleText);
5233 __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
5234 __middleEllipsisWidth = abbrevTextDim.width;
5236 ForwardAnalyze(0, __length, ((lineBounds.width - __middleEllipsisWidth + 10.0f) / 2.0f), __wrap, length, textSize.width, textSize.height);
5237 __middleEllipsisTextLengthInHead = length;
5238 __middleEllipsisHeadWidth = textSize.width;
5240 maxHeight = textSize.height;
5242 BackwardAnalyze(__length - 1, lineBounds.width - __middleEllipsisWidth - __middleEllipsisHeadWidth, length, textSize.width, textSize.height);
5244 __middleEllipsisTextLengthInTail = length;
5245 maxHeight = (maxHeight < textSize.height) ? textSize.height : maxHeight;
5247 TextLine* pTextLine = new (std::nothrow)TextLine(this);
5248 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5250 pTextLine->SetBounds(lineBounds);
5251 pTextLine->SetRegion(lineBounds.width, maxHeight);
5252 pTextLine->SetTextLength(__length);
5253 pTextLine->SetTextOffset(0);
5254 pTextLine->SetEndType(TEXT_RETBY_NORMAL);
5255 pTextLine->SetBaseline(baseline);
5256 GetTextExtentList(pTextLine);
5258 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
5260 lineBounds.height = maxHeight;
5266 TextComposite::ComposeInNoneWrapHeadEllipsis(FloatRectangle& rect)
5268 SysTryReturn(NID_GRP, __pCurrentTextColumn, -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
5270 int endType = TEXT_RETBY_NORMAL;
5271 FloatRectangle lineBounds;
5272 FloatDimension abbrevTextDim;
5273 FloatDimension textSize;
5275 float maxHeight = 0;
5278 lineBounds.width = rect.width;
5281 lineBounds.height = rect.height;
5282 endType = ForwardAnalyzeWithBaseline(0, __length, lineBounds.width, __wrap, length, textSize.width, textSize.height, baseline);
5284 if (endType != TEXT_RETBY_LIMITWIDTH)
5286 __drawTextEllipsis = false;
5287 return ComposeInNoneWrap(rect);
5290 __drawTextEllipsis = true;
5291 TextElement* pTextElement = null;
5292 TextSimple* pSimpleText = null;
5294 pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0));
5295 SysTryReturn(NID_GRP, pTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
5297 TextElementType objectType = pTextElement->GetType();
5298 SysTryReturn(NID_GRP, objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT
5299 , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
5301 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
5302 if (pSimpleText != null)
5304 SetAbbrevObjectFontInfo(pSimpleText);
5307 __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
5308 __headEllipsisWidth = abbrevTextDim.width;
5310 BackwardAnalyze(__length - 1, lineBounds.width - abbrevTextDim.width, __headEllipsisTextLength, textSize.width, textSize.height);
5312 maxHeight = textSize.height;
5314 TextLine* pTextLine = new (std::nothrow)TextLine(this);
5315 SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5317 pTextLine->SetBounds(lineBounds);
5318 pTextLine->SetRegion(lineBounds.width, maxHeight);
5319 pTextLine->SetTextLength(__length);
5320 pTextLine->SetTextOffset(0);
5321 pTextLine->SetEndType(TEXT_RETBY_NORMAL);
5322 pTextLine->SetBaseline(baseline);
5323 GetTextExtentList(pTextLine);
5325 __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
5327 lineBounds.height = maxHeight;
5333 TextComposite::DrawAbbrev(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect, const TextObjectAlignment align)
5335 if (__TextObjectEllipsisType == TEXT_OBJECT_ELLIPSIS_TYPE_MIDDLE)
5337 return DrawAbbrevInMiddleEllipsis(canvasImpl, displayRect, align);
5339 else if (__TextObjectEllipsisType == TEXT_OBJECT_ELLIPSIS_TYPE_HEAD)
5341 return DrawAbbrevInHeadEllipsis(canvasImpl, displayRect, align);
5348 TextComposite::GetValue(int textIndex, TextComponentInfoValueType type, unsigned int* value) const
5350 IEnumerator* pEnum = null;
5351 TextElement* pTextElement = null;
5353 int elementTextLength = 0;
5355 pEnum = __pTextElementList->GetEnumeratorN();
5356 while (pEnum->MoveNext() == E_SUCCESS)
5358 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
5359 if (pTextElement == null)
5364 elementTextLength = pTextElement->GetTextLength();
5366 if (textIndex < offset + elementTextLength)
5368 TextElementType objectType = pTextElement->GetType();
5370 if (objectType != TextUtility::GetObjectTypeFromValueType(type) && objectType != TEXT_ELEMENT_TYPE_CUTLINK)
5373 return E_INVALID_ARG;
5376 *value = pTextElement->GetValue(type);
5381 offset += elementTextLength;
5385 return E_INVALID_ARG;
5389 TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLength, float& width, float& height)
5391 float remainingWidth = 0;
5393 FloatDimension textSize;
5399 remainingWidth = maxWidth;
5402 while (startTextIndex >= 0 && textSize.width < remainingWidth)
5404 GetRegion(startTextIndex, length, textSize.width, textSize.height);
5406 if (textSize.width <= remainingWidth)
5408 actualLength = length;
5409 width = textSize.width;
5410 height = textSize.height;
5421 TextComposite::GetFirstTextIndexAt(int elementIndex) const
5423 SysTryReturn(NID_GRP, elementIndex >= 0 && elementIndex < __pTextElementList->GetCount(), -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
5425 IEnumerator* pEnum = null;
5426 TextElement* pTextElement = null;
5429 int elementTextOffset = 0;
5431 if (elementIndex == 0)
5436 pEnum = __pTextElementList->GetEnumeratorN();
5437 while (pEnum->MoveNext() == E_SUCCESS)
5439 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
5440 if (pTextElement == null)
5445 if (index == elementIndex)
5450 elementTextOffset += pTextElement->GetTextLength();
5452 pTextElement = null;
5458 if (pTextElement != null)
5460 return elementTextOffset;
5467 TextComposite::DrawAbbrevInMiddleEllipsis(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect, const TextObjectAlignment alignment)
5469 TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(0);
5470 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
5472 FloatDimension textSize;
5473 FloatRectangle adjustedRect;
5475 pTextLine->GetRegion(0, __length, textSize.width, textSize.height);
5476 adjustedRect.x = displayRect.x;
5477 adjustedRect.width = displayRect.width;
5479 switch (alignment & TEXT_ALIGNMASK_VERT)
5481 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
5482 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2;
5485 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
5486 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height);
5489 case TEXT_OBJECT_ALIGNMENT_TOP:
5492 adjustedRect.y = displayRect.y;
5495 adjustedRect.height = displayRect.height - (displayRect.y - adjustedRect.y);
5497 TextElement* pTextElement = null;
5498 TextSimple* pSimpleText = null;
5500 pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0));
5501 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
5503 TextElementType objectType = pTextElement->GetType();
5504 SysTryReturn(NID_GRP, objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT
5505 , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to draw to symbol object.");
5507 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
5508 if (pSimpleText != null)
5510 SetAbbrevObjectFontInfo(pSimpleText);
5513 DrawPartial(canvasImpl, adjustedRect, 0, __middleEllipsisTextLengthInHead);
5515 adjustedRect.x += __middleEllipsisHeadWidth;
5516 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), TEXT_OBJECT_ACTION_TYPE_NONE);
5518 adjustedRect.x += __middleEllipsisWidth;
5519 DrawPartial(canvasImpl, adjustedRect, __length - __middleEllipsisTextLengthInTail, __middleEllipsisTextLengthInTail);
5525 TextComposite::DrawAbbrevInHeadEllipsis(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect, const TextObjectAlignment alignment)
5527 TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(0);
5528 SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
5530 result r = E_SUCCESS;
5531 FloatDimension textSize;
5532 FloatRectangle adjustedRect;
5534 pTextLine->GetRegion(0, __length, textSize.width, textSize.height);
5535 adjustedRect.x = displayRect.x;
5536 adjustedRect.width = displayRect.width;
5538 switch (alignment & TEXT_ALIGNMASK_VERT)
5540 case TEXT_OBJECT_ALIGNMENT_MIDDLE:
5541 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height) / 2;
5544 case TEXT_OBJECT_ALIGNMENT_BOTTOM:
5545 adjustedRect.y = displayRect.y + (displayRect.height - textSize.height);
5548 case TEXT_OBJECT_ALIGNMENT_TOP:
5551 adjustedRect.y = displayRect.y;
5554 adjustedRect.height = displayRect.height - (displayRect.y - adjustedRect.y);
5556 TextElement* pTextElement = null;
5557 TextSimple* pSimpleText = null;
5559 pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(0));
5560 r = GetLastResult();
5561 SysTryReturn(NID_GRP, pTextElement, r, r, "[%s] Fail to get element.", GetErrorMessage(r));
5563 TextElementType objectType = pTextElement->GetType();
5564 SysTryReturn(NID_GRP, objectType == TEXT_ELEMENT_TYPE_CUTLINK || objectType == TEXT_ELEMENT_TYPE_TEXT
5565 , E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to draw to symbol object.");
5567 pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
5568 if (pSimpleText != null)
5570 SetAbbrevObjectFontInfo(pSimpleText);
5573 __pAbbrevTextElement->Draw(canvasImpl, adjustedRect, 0, 1, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT), TEXT_OBJECT_ACTION_TYPE_NONE);
5575 adjustedRect.x += __headEllipsisWidth;
5576 DrawPartial(canvasImpl, adjustedRect, __length - __headEllipsisTextLength, __headEllipsisTextLength);
5582 TextComposite::DrawPartial(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int startTextIndex, int textLength)
5584 SysTryReturn(NID_GRP, 0 <= startTextIndex && startTextIndex < __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
5585 SysTryReturn(NID_GRP, textLength <= __length, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
5587 result r = E_SUCCESS;
5588 IEnumerator* pEnum = null;
5589 TextElement* pTextElement = null;
5591 FloatDimension textSize;
5592 int currentLength = 0;
5593 int textIndexFromElementOffset = 0;
5595 int elementTextOffset = 0;
5596 FloatRectangle adjustedRect = displayRect;
5597 int blockStartTextIndex = 0;
5598 int blockEndTextIndex = 0;
5599 bool isAlternateLookEnabled = false;
5600 int textIndex = startTextIndex;
5602 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, nodeIndex, currentLength,
5603 textIndexFromElementOffset);
5604 SysTryReturn(NID_GRP, pTextElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
5606 currentLength = Math::Min(textLength, currentLength);
5608 pEnum = __pTextElementList->GetEnumeratorN();
5609 while (textLength > 0)
5611 textLength -= currentLength;
5613 pTextElement->GetRegion(textIndexFromElementOffset, currentLength, textSize.width, textSize.height);
5615 if (pTextElement->IsBackGroundDrawingModeEnable())
5617 r = canvasImpl.FillRectangle(pTextElement->GetBackgroundColor(), FloatRectangle(adjustedRect.x, displayRect.y, textSize.width, displayRect.height));
5618 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5621 isAlternateLookEnabled = (pTextElement->GetValue(SET_ALTERNATE_LOOK) > 0) ? true : false;
5622 if ((__displayBlock) && (isAlternateLookEnabled == false))
5624 FloatDimension tempTextSize;
5625 float adjustedX = 0;
5627 blockStartTextIndex = Math::Max(__workStart, textIndex);
5628 blockEndTextIndex = Math::Min(__workStart + __workLength, textIndex + currentLength);
5629 if (blockStartTextIndex < blockEndTextIndex)
5631 blockStartTextIndex = textIndexFromElementOffset + (blockStartTextIndex - textIndex);
5632 blockEndTextIndex = textIndexFromElementOffset + (blockEndTextIndex - textIndex);
5633 adjustedX = adjustedRect.x;
5635 if (textIndexFromElementOffset < blockStartTextIndex)
5637 pTextElement->GetRegion(textIndexFromElementOffset, blockStartTextIndex - textIndexFromElementOffset,
5638 tempTextSize.width, tempTextSize.height);
5639 adjustedX += tempTextSize.width;
5642 FloatRectangle blockRect = adjustedRect;
5643 blockRect.x = adjustedX;
5647 pTextElement->Draw(canvasImpl, adjustedRect, textIndexFromElementOffset, currentLength, (TextObjectAlignment)(TEXT_OBJECT_ALIGNMENT_TOP | TEXT_OBJECT_ALIGNMENT_LEFT),
5648 TEXT_OBJECT_ACTION_TYPE_NONE);
5650 adjustedRect.x += textSize.width;
5651 adjustedRect.width -= textSize.width;
5658 textIndex += currentLength;
5660 if (pEnum->MoveNext() != E_SUCCESS)
5665 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
5667 textIndexFromElementOffset = pTextElement->GetValue(SET_TEXT_OFFSET);
5668 currentLength = Math::Min(textLength, pTextElement->GetTextLength());
5670 if (currentLength == 0)
5681 TextComposite::SetPartialComposingModeEnabled(bool enable)
5683 __partialComposingModeEnabled = enable;
5687 TextComposite::IsPartialComposingModeEnabled(void) const
5689 return __partialComposingModeEnabled;
5693 TextComposite::InitPartialComposeMode(void)
5695 __lineIndexCompositeDone = 0;
5696 __totalComposedHeight = 0;
5697 __composePartialLimitHeight = 0;
5699 SysTryReturn(NID_GRP, __pCurrentTextColumn, false, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
5701 __pCurrentTextColumn->SetFirstDisplayLineIndex(0);
5702 __pCurrentTextColumn->SetFirstDisplayPositionY(0);
5703 __pCurrentTextColumn->PrepareCompose();
5709 TextComposite::IsComposeDone() const
5711 SysTryReturn(NID_GRP, __pCurrentTextColumn, false, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
5713 return __pCurrentTextColumn->IsComposeDone();
5717 TextComposite::GetCutLinkObjectInfo(int cutLinkIndex, int& textStartIndex, int& textLength) const
5719 return __pCutLinkListInfo->GetCutLinkObjectInfo(cutLinkIndex, textStartIndex, textLength);
5723 TextComposite::GetTotalComposedHeight(void) const
5725 return _CoordinateSystemUtils::ConvertToInteger(__totalComposedHeight);
5729 TextComposite::GetTotalComposedHeightF(void) const
5731 return __totalComposedHeight;
5735 TextComposite::GetAnalysedTotalHeight(void) const
5737 return _CoordinateSystemUtils::ConvertToInteger(GetAnalysedTotalHeightF());
5741 TextComposite::GetAnalysedTotalHeightF(void) const
5743 TextLine* pTextLine = null;
5744 pTextLine = __pCurrentTextColumn->GetTextLine(__lineIndexCompositeDone - 1);
5751 int lineOffset = pTextLine->GetTextOffset();
5752 int lineLength = pTextLine->GetTextLength();
5754 int composedLength = lineOffset + lineLength;
5755 if (composedLength == 0)
5760 return (float)(GetTotalComposedHeightF() * __length / composedLength);
5764 TextComposite::SetComposePartialLimitHeight(int limitHeight)
5766 __composePartialLimitHeight = _CoordinateSystemUtils::ConvertToFloat(limitHeight);
5770 TextComposite::SetComposePartialLimitHeight(float limitHeight)
5772 __composePartialLimitHeight = limitHeight;
5776 TextComposite::GetComposePartialLimitHeight(void) const
5778 return _CoordinateSystemUtils::ConvertToInteger(__composePartialLimitHeight);
5782 TextComposite::GetComposePartialLimitHeightF(void) const
5784 return __composePartialLimitHeight;
5788 TextComposite::GetObjectType(int textIndex) const
5790 TextElement* pTextElement = null;
5792 int currentLength = 0;
5793 int elementIndex = 0;
5794 int textIndexFromElementOffset = 0;
5795 int elementTextOffset = 0;
5797 pTextElement = GetElementAtTextIndex(textIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
5798 if (pTextElement == null)
5800 return TEXT_ELEMENT_TYPE_NONE;
5804 return pTextElement->GetType();
5809 TextComposite::GetElementIndexOf(TextElement& textElement) const
5813 result r = E_SUCCESS;
5815 r = __pTextElementList->IndexOf(textElement, index);
5816 SysTryReturn(NID_GRP, r == E_SUCCESS, false, r, "[%s] Fail to add element.", GetErrorMessage(r));
5822 TextComposite::GetElementAtElementIndex(int elementIndex) const
5824 result r = E_SUCCESS;
5826 TextElement* pTextElement = null;
5827 pTextElement = static_cast < TextElement* >(__pTextElementList->GetAt(elementIndex));
5828 SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Fail to add element.", GetErrorMessage(r));
5830 return pTextElement;
5834 TextComposite::GetTextLength(void) const
5840 TextComposite::GetElementCount(void) const
5842 return __pTextElementList->GetCount();
5846 TextComposite::SetBlock(bool enable)
5848 __displayBlock = enable;
5852 TextComposite::SetImageAlign(TextObjectAlignment align)
5854 return SetValueToAllTextElements(SET_IMAGE_ALIGN, (unsigned int)align);
5858 TextComposite::GetWrap(void) const
5864 TextComposite::SetLineSpace(int gap)
5866 SetLineSpace(_CoordinateSystemUtils::ConvertToFloat(gap));
5870 TextComposite::SetLineSpace(float gap)
5872 __lineSpacing = gap;
5876 TextComposite::GetLineSpace(void) const
5878 return _CoordinateSystemUtils::ConvertToInteger(__lineSpacing);
5882 TextComposite::GetLineSpaceF(void) const
5884 return __lineSpacing;
5888 TextComposite::SetElementVerticalAlignment(TextObjectAlignment alignment)
5890 __elementVertialAlignment = alignment;
5894 TextComposite::GetElementVerticalAlignment(void) const
5896 return __elementVertialAlignment;
5900 TextComposite::SetCursorIndex(int cursorIndex)
5902 __cursorIndex = cursorIndex;
5906 TextComposite::GetCursorIndex(void) const
5908 return __cursorIndex;
5912 TextComposite::SetTextObjectEllipsisType(TextObjectEllipsisType type)
5914 __TextObjectEllipsisType = type;
5917 TextObjectEllipsisType
5918 TextComposite::GetTextObjectEllipsisType(void) const
5920 return __TextObjectEllipsisType;
5924 TextComposite::SetTextAbbreviationEnabled(bool enable)
5926 __drawAbbrevText = enable;
5930 TextComposite::IsTextAbbreviationEnabled(void) const
5932 if (__drawAbbrevText && __drawTextEllipsis)
5941 TextComposite::GetBlock(void) const
5943 return __displayBlock;
5947 TextComposite::GetWorkStart(void) const
5953 TextComposite::GetWorkLength(void) const
5955 return __workLength;
5959 TextComposite::GetImageAlign(int textIndex) const
5961 result r = E_SUCCESS;
5962 unsigned int value = 0;
5964 r = GetValue(textIndex, SET_IMAGE_ALIGN, &value);
5965 SysTryReturn(NID_GRP, r == E_SUCCESS, TEXT_OBJECT_ALIGNMENT_INVALID, r, "[%s] Propagating.", GetErrorMessage(r));
5967 return (TextObjectAlignment)value;
5971 TextComposite::IsChanged(void) const
5977 TextComposite::SetBlockColor(const Color& color)
5979 __defaultBlockColor = color;
5983 TextComposite::GetBlockColor(void) const
5985 return __defaultBlockColor;
5989 TextComposite::GetDisplayableText(FloatRectangle displayRect, TextObjectActionType action)
5991 int firstDisplayLineIndex = __pCurrentTextColumn->GetFirstDisplayLineIndex();
5992 TextLine* pTextLine = __pCurrentTextColumn->GetTextLine(firstDisplayLineIndex);
5993 SysTryReturn(NID_GRP, pTextLine, L"", E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (firstDisplayLineIndex = %d)", firstDisplayLineIndex);
5995 int firstDisplayTextIndex = pTextLine->GetTextOffset();
5996 int displayableTextLength = 0;
5997 int displayableLineCount = __pCurrentTextColumn->CalculateDisplayableLineCount(displayRect, action);
5998 int lastDisplayLineIndex = firstDisplayLineIndex + displayableLineCount - 1;
6000 for (int i = firstDisplayLineIndex; i < lastDisplayLineIndex; i++)
6002 pTextLine = __pCurrentTextColumn->GetTextLine(i);
6003 SysTryReturn(NID_GRP, pTextLine, L"", E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (line index = %d)", i);
6005 displayableTextLength += pTextLine->GetTextLength();
6008 pTextLine = __pCurrentTextColumn->GetTextLine(lastDisplayLineIndex);
6009 SysTryReturn(NID_GRP, pTextLine, L"", E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid. (lastDisplayLineIndex = %d)", lastDisplayLineIndex);
6011 int lineOffset = pTextLine->GetTextOffset();
6012 int lineLength = pTextLine->GetTextLength();
6013 int elementTextOffset = 0;
6014 int elementIndex = 0;
6015 int currentLength = 0;
6016 int textIndexFromElementOffset = 0;
6017 int remainingLength = lineLength;
6019 if (lineOffset + remainingLength < __length) // abbreviation mode
6021 TextElement* pTextElement = GetElementAtTextIndex(lineOffset, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
6022 SysTryReturn(NID_GRP, pTextElement, String(L""), E_SYSTEM, "[E_SYSTEM] Fail to get element.");
6024 if (__ignoreFrontBlank && __frontSpaceHideMode == TEXT_OBJECT_SPACE_HIDE_TYPE_ONE)
6026 const TextSimple* pSimpleText = dynamic_cast <const TextSimple*>(pTextElement);
6027 if (pSimpleText != null)
6029 int index = lineOffset - elementTextOffset;
6030 const wchar_t* pText = pSimpleText->GetText();
6031 SysTryReturn(NID_GRP, pText, String(L""), E_SYSTEM, "[E_SYSTEM] Fail to get text.");
6033 SysTryReturn(NID_GRP, index >= 0 && index < pSimpleText->GetTextLength()
6034 , 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)"
6035 ,index, pSimpleText->GetTextLength());
6037 if (pText[index] == (wchar_t)L' ' || pText[index] == TEXT_JAPANESE_SPACE)
6045 if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
6047 FloatDimension textSize;
6048 FloatDimension abbrevTextSize;
6049 FloatRectangle lineBounds = pTextLine->GetBoundsF();
6051 GetRegion(lineOffset, remainingLength, textSize.width, textSize.height);
6053 TextElement* pLastTextElement = GetElementAtTextIndex(lineOffset + lineLength - 1);
6054 SysTryReturn(NID_GRP, pLastTextElement, -1, E_SYSTEM, "[E_SYSTEM] Fail to get element.");
6056 if (pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_TEXT || pLastTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
6058 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pLastTextElement);
6059 SysTryReturn(NID_GRP, pSimpleText, String(L""), E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
6061 SetAbbrevObjectFontInfo(pSimpleText);
6063 __pAbbrevTextElement->GetRegion(0, 1, abbrevTextSize.width, abbrevTextSize.height);
6065 ForwardAnalyze(lineOffset, __length - lineOffset, lineBounds.width - abbrevTextSize.width
6066 , TEXT_OBJECT_WRAP_TYPE_CHARACTER, lineLength, textSize.width, textSize.height);
6070 displayableTextLength += lineLength;
6072 wchar_t* pText = GetTextN(firstDisplayTextIndex, displayableTextLength);
6073 SysTryReturn(NID_GRP, pText, String(L""), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
6082 TextComposite::SetWorkWidth(Font* pFont, wchar_t* pText, int workStart, int textLength)
6084 result r = E_SUCCESS;
6088 const wchar_t* pSrc = &pText[workStart];
6090 workLength = Math::Abs(textLength);
6092 r = TextUtility::GetTextExtent(pFont, pSrc, workLength, false, width, height);
6093 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
6097 __workWidth = -width;
6101 __workWidth = width;
6108 TextComposite::GetWorkWidth(void)
6114 TextComposite::SetTextSweepInfo(TextObjectSweepInfo* pTextSweepInfo)
6116 __pSweepInfo = pTextSweepInfo;
6120 TextComposite::GetTextSweepInfo(TextObjectSweepInfo& textSweepInfo)
6122 textSweepInfo.isValid = __pSweepInfo->isValid;
6123 textSweepInfo.sweepType = __pSweepInfo->sweepType;
6124 textSweepInfo.sweepEventType = __pSweepInfo->sweepEventType;
6125 textSweepInfo.anchorTextIndex = __pSweepInfo->anchorTextIndex;
6126 textSweepInfo.anchorLineIndex = __pSweepInfo->anchorLineIndex;
6127 textSweepInfo.sweepRegionStartLineIndex = __pSweepInfo->sweepRegionStartLineIndex;
6128 textSweepInfo.sweepRegionLineCount = __pSweepInfo->sweepRegionLineCount;
6129 textSweepInfo.insertedLineCount = __pSweepInfo->insertedLineCount;
6130 textSweepInfo.deletedLineCount = __pSweepInfo->deletedLineCount;
6131 textSweepInfo.widthChanged = __pSweepInfo->widthChanged;
6135 TextComposite::UpdateTextSweepInfo(TextObjectSweepInfo* pTextSweepInfo)
6137 __pSweepInfo->isValid = pTextSweepInfo->isValid;
6138 __pSweepInfo->sweepType = pTextSweepInfo->sweepType;
6139 __pSweepInfo->sweepEventType = pTextSweepInfo->sweepEventType;
6140 __pSweepInfo->anchorTextIndex = pTextSweepInfo->anchorTextIndex;
6141 __pSweepInfo->anchorLineIndex = pTextSweepInfo->anchorLineIndex;
6142 __pSweepInfo->sweepRegionStartLineIndex = pTextSweepInfo->sweepRegionStartLineIndex;
6143 __pSweepInfo->sweepRegionLineCount = pTextSweepInfo->sweepRegionLineCount;
6144 __pSweepInfo->insertedLineCount = pTextSweepInfo->insertedLineCount;
6145 __pSweepInfo->deletedLineCount = pTextSweepInfo->deletedLineCount;
6146 __pSweepInfo->widthChanged = pTextSweepInfo->widthChanged;
6150 TextComposite::IsRTL(int startTextIndex, int textLength) const
6152 SysTryReturn(NID_GRP, 0 <= startTextIndex && textLength <= __length, false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
6154 result r = E_SUCCESS;
6155 IEnumerator* pEnum = null;
6157 int currentLength = 0;
6158 int elementTextOffset = 0;
6159 int elementIndex = 0;
6160 int textIndexFromElementOffset = 0;
6167 TextElement* pTextElement = GetElementAtTextIndex(startTextIndex, elementTextOffset, elementIndex, currentLength, textIndexFromElementOffset);
6168 SysTryCatch(NID_GRP, pTextElement, , E_SYSTEM, "[E_SYSTEM] Fail to get element.");
6170 textIndexFromElementOffset = startTextIndex - elementTextOffset;
6172 pEnum = __pTextElementList->GetEnumeratorN();
6173 for (int i = 0; i < elementIndex; i++)
6175 r = pEnum->MoveNext();
6178 while (pEnum->MoveNext() == E_SUCCESS)
6180 pTextElement = static_cast < TextElement* >(pEnum->GetCurrent());
6183 currentLength = Math::Min(pTextElement->GetTextLength() - textIndexFromElementOffset, textLength);
6185 TextElementType objectType = pTextElement->GetType();
6187 if (objectType == TEXT_ELEMENT_TYPE_TEXT || objectType == TEXT_ELEMENT_TYPE_CUTLINK)
6189 TextSimple* pSimpleText = dynamic_cast < TextSimple* >(pTextElement);
6192 const wchar_t* pSrcText = pSimpleText->GetText();
6193 SysTryCatch(NID_GRP, pSrcText, , E_SYSTEM, "[E_SYSTEM] Fail to get text.");
6195 const wchar_t* pPointer = &pSrcText[textIndexFromElementOffset];
6196 SysTryCatch(NID_GRP, pPointer, , E_SYSTEM, "[E_SYSTEM] Fail to get text.");
6198 for (int i = 0; i< currentLength; i++)
6200 if(*pPointer == null)
6204 FriBidiChar bidiText[1] = { *pPointer };
6205 FriBidiCharType type[1] = { 0 };
6206 fribidi_get_bidi_types(bidiText, 1, type);
6208 if ((type[0] & FRIBIDI_MASK_RTL) != 0)
6213 else if (((type[0] & FRIBIDI_MASK_STRONG) != 0) && ((type[0] & FRIBIDI_MASK_LETTER) != 0))
6224 textLength -= currentLength;
6228 if (textLength <= 0)
6233 textIndexFromElementOffset = 0;
6246 TextComposite::IsRTLCharacter(int textIndex) const
6248 SysTryReturn(NID_GRP, 0 <= textIndex, false, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
6251 for (int i = textIndex; i >= 0; i--)
6253 wchar_t ch = GetCharacter(i);
6254 if (TextUtility::IsStrongCharacter(ch))
6256 if (TextUtility::IsRTLCharacter(GetCharacter(i)))
6272 TextComposite::SearchLTRTextIndex(int startTextIndex,int fromTextIndex) const
6274 SysTryReturn(NID_GRP, 0 <= fromTextIndex, -1, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
6277 int LTRTextIndex = -1;
6280 for (int i = fromTextIndex; i >= startTextIndex; i--)
6282 ch = GetCharacter(i);
6284 if (TextUtility::IsLTRCharacter(ch))
6291 LTRTextIndex = i + 1;
6295 ch = GetCharacter(LTRTextIndex);
6296 if (TextUtility::IsStrongCharacter(ch))
6308 LTRTextIndex = (startTextIndex <= LTRTextIndex && LTRTextIndex <= fromTextIndex) ? LTRTextIndex : startTextIndex;
6310 return LTRTextIndex;
6313 }}} // Tizen::Graphics::_Text