+++ /dev/null
-//
-// Open Service Platform
-// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/*
- * @file FGrp_TextTextWidthManager.cpp
- * @brief This is the implementation file for TextWidthManager class.
- */
-
-#include <FBaseSysLog.h>
-#include "FGrp_TextCommon.h"
-#include "FGrp_TextTextElement.h"
-#include "FGrp_TextTextSimple.h"
-#include "FGrp_TextTextCutLink.h"
-#include "FGrp_TextTextComposite.h"
-#include "FGrp_TextTextSimpleList.h"
-#include "FGrp_TextTextWidthManager.h"
-#include "FGrp_CoordinateSystemUtils.h"
-
-using namespace Tizen::Base::Utility;
-
-namespace
-{
- const int MAX_TEXT_WIDTH_INFO_MERGE_LENGTH = 10;
-}
-
-namespace Tizen { namespace Graphics
-{
-
-namespace _Text
-{
-
-enum TextWidthInfoType
-{
- TEXT_WIDTH_INFO_UNKNOWN = 0,
- TEXT_WIDTH_INFO_WORD,
- TEXT_WIDTH_INFO_SPACE,
- TEXT_WIDTH_INFO_ENTER,
- TEXT_WIDTH_INFO_SYMBOL
-};
-
-struct TextWidthCommonInfo
-{
- TextWidthInfoType type;
-};
-
-struct UnknownTextWidthInfo : public TextWidthCommonInfo
-{
- int length;
-};
-
-struct WordTextWidthInfo : public TextWidthCommonInfo
-{
- int length;
- int width;
- int maxHeight;
-};
-
-struct SpaceTextWidthInfo : public TextWidthCommonInfo
-{
- int width;
- int maxHeight;
-};
-
-struct EnterTextWidthInfo : public TextWidthCommonInfo
-{
- int length;
- int maxHeight;
-};
-
-struct SymbolTextWidthInfo : public TextWidthCommonInfo
-{
- int width;
- int maxHeight;
-};
-
-TextWidthManager::TextWidthManager(TextComposite* pCompositeText)
-{
- __isComposing = false;
- __isInitialized = false;
- __pCompositeText = pCompositeText;
- __pTextWidthInfoList = null;
- __pCurrentComposeTextElement = null;
- __pCurrentWordWidthInfoNode = null;
- __pCachedWordWidthInfoNode = null;
- __currentTextElementLength = 0;
- __currentTextElementType = TEXT_ELEMENT_TYPE_NONE;
- __textOffsetOfCachedWidthInfo = 0;
- __currentTextIndex = 0;
- __strCurrentRelIndex = 0;
- __textOffsetOfCurrentWidthInfo = 0;
- __length = 0;
- __currentComposeTextElementIndex = 0;
-}
-
-TextWidthManager::~TextWidthManager(void)
-{
- if (__isInitialized)
- {
- Finalize();
- }
-}
-
-bool
-TextWidthManager::Initialize(int textLength)
-{
- if (__isInitialized)
- {
- Finalize();
- }
-
- __pTextWidthInfoList = TextSimpleList::Create();
- SysTryReturn(NID_GRP
- , __pTextWidthInfoList
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- TextSimpleList::Init(__pTextWidthInfoList);
-
- __length = 0;
- __isComposing = false;
- __isInitialized = true;
- __pCurrentComposeTextElement = null;
- __pCachedWordWidthInfoNode = null;
- __currentComposeTextElementIndex = 0;
-
- if (textLength > 0)
- {
- InformTextInsert(0, textLength);
- }
-
- return true;
-}
-
-bool
-TextWidthManager::Finalize(void)
-{
- if (!__isInitialized)
- {
- return false;
- }
-
- if (__pTextWidthInfoList)
- {
- TextWidthCommonInfo* pTextWidthCommonInfo = null;
-
- pTextWidthCommonInfo = static_cast < TextWidthCommonInfo* >(TextSimpleList::DeleteNthObject(__pTextWidthInfoList, 0));
- while (pTextWidthCommonInfo)
- {
- delete pTextWidthCommonInfo;
- pTextWidthCommonInfo = static_cast < TextWidthCommonInfo* >(TextSimpleList::DeleteNthObject(__pTextWidthInfoList, 0));
- }
-
- if (__pTextWidthInfoList->nodeCount != 0)
- {
- TextSimpleList::Init(__pTextWidthInfoList);
- }
-
- TextSimpleList::Destory(__pTextWidthInfoList);
- __pTextWidthInfoList = null;
- }
-
- __isInitialized = false;
- __isComposing = false;
- __length = 0;
- __pCurrentComposeTextElement = null;
- __pCachedWordWidthInfoNode = null;
-
- return true;
-}
-
-bool
-TextWidthManager::StartCompose(int textIndex)
-{
- if (!__isInitialized)
- {
- return false;
- }
-
- if (__length <= textIndex)
- {
- return false;
- }
-
- SimpleNode* pCurrentTextWidthInfoNode = null;
- int currentWidthInfoTextOffset = 0;
- TextWidthCommonInfo* pCurrentTextWidthInfo = null;
-
- pCurrentTextWidthInfoNode = SearchTextWidthInfo(textIndex, currentWidthInfoTextOffset);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfoNode
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width node.");
-
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- __pCurrentWordWidthInfoNode = pCurrentTextWidthInfoNode;
- __textOffsetOfCurrentWidthInfo = textIndex - currentWidthInfoTextOffset;
-
- int elementIndex = 0;
- int elementTextOffset = 0;
- __currentTextIndex = textIndex;
- __pCurrentComposeTextElement = __pCompositeText->GetElementAtTextIndex(textIndex, elementTextOffset,
- elementIndex, __currentTextElementLength, __strCurrentRelIndex);
- SysTryReturn(NID_GRP
- , __pCurrentComposeTextElement
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- __currentComposeTextElementIndex = elementIndex;
- __currentTextElementType = __pCurrentComposeTextElement->GetType();
- __isComposing = true;
-
- return true;
-}
-
-bool
-TextWidthManager::GetCurrentLineInfo(int lineWidth, TextLineComposeInfo& textLineComposeInfo)
-{
- if (!__isComposing)
- {
- return false;
- }
-
- if (__length <= __currentTextIndex)
- {
- return false;
- }
-
- TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- if (__textOffsetOfCurrentWidthInfo != 0)
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = GetTextWidthInfoLength(pCurrentTextWidthInfo) - __textOffsetOfCurrentWidthInfo;
-
- __pCurrentWordWidthInfoNode = SplitWidthInfo(__pCurrentWordWidthInfoNode, __textOffsetOfCurrentWidthInfo,
- pUnknownTextWidthInfo);
-
- SysTryReturn(NID_GRP
- , __pCurrentWordWidthInfoNode
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width node.");
-
- __textOffsetOfCurrentWidthInfo = 0;
-
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
- }
-
- int maxHeight = 0;
- int remainingWidth = lineWidth;
- int type = 0;
- int textCount = 0;
- int endType = TEXT_RETBY_NORMAL;
- bool composeDone = false;
- bool wordMeet = false;
- bool enterMeet = false;
- bool spaceMeetAfterWord = false;
- bool cutLinkMeetAfterWord = false;
-
- while (!composeDone)
- {
- type = pCurrentTextWidthInfo->type;
-
- switch (type)
- {
- case TEXT_WIDTH_INFO_UNKNOWN:
- {
- AnalyzeCurrentUnKnownTextWidthInfo(remainingWidth);
- }
- break;
-
- case TEXT_WIDTH_INFO_WORD:
- {
- if (remainingWidth <= 0)
- {
- break;
- }
-
- WordTextWidthInfo* pWordTtextWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentTextWidthInfo);
- SysTryReturn(NID_GRP
- , pWordTtextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information.");
-
- if (pWordTtextWidthInfo->width <= remainingWidth)
- {
- bool iswordoverWidth = false;
- int widthAnalyzed = 0;
- int strLengthAnalyzed = 0;
- int heightAnalzyed = 0;
- bool nextKorean = false;
- bool includeCutLink = false;
-
- AnalyzeNextTextWidthInfo(remainingWidth - pWordTtextWidthInfo->width, iswordoverWidth,
- widthAnalyzed, strLengthAnalyzed, heightAnalzyed, nextKorean, includeCutLink);
-
- if (iswordoverWidth)
- {
- if ((nextKorean || !spaceMeetAfterWord) && !cutLinkMeetAfterWord)
- {
- remainingWidth -= (widthAnalyzed + pWordTtextWidthInfo->width);
- if (maxHeight < pWordTtextWidthInfo->maxHeight)
- {
- maxHeight = pWordTtextWidthInfo->maxHeight;
- }
-
- if (maxHeight < heightAnalzyed)
- {
- maxHeight = heightAnalzyed;
- }
-
- textCount += (pWordTtextWidthInfo->length + strLengthAnalyzed);
- Seek(pWordTtextWidthInfo->length + strLengthAnalyzed);
-
- }
- endType = TEXT_RETBY_LIMITWIDTH;
- composeDone = true;
- }
- else
- {
- remainingWidth -= (pWordTtextWidthInfo->width + widthAnalyzed);
- if (maxHeight < pWordTtextWidthInfo->maxHeight)
- {
- maxHeight = pWordTtextWidthInfo->maxHeight;
- }
- if (maxHeight < heightAnalzyed)
- {
- maxHeight = heightAnalzyed;
- }
-
- textCount += (pWordTtextWidthInfo->length + strLengthAnalyzed);
- Seek(pWordTtextWidthInfo->length + strLengthAnalyzed);
-
- wordMeet = true;
- cutLinkMeetAfterWord = includeCutLink;
- }
- }
- else
- {
- SysTryReturn(NID_GRP
- , __pCurrentWordWidthInfoNode
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width node.");
-
- bool nextKorean = false;
- int textLengthBeforeSplit = GetTextWidthInfoLength(static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject));
- pWordTtextWidthInfo = SplitCurrentWordWidthInfo(remainingWidth, nextKorean);
- SysTryReturn(NID_GRP
- , pWordTtextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- if (textLengthBeforeSplit != pWordTtextWidthInfo->length)
- {
- if ((nextKorean || !spaceMeetAfterWord) && !cutLinkMeetAfterWord)
- {
- remainingWidth -= pWordTtextWidthInfo->width;
- if (pWordTtextWidthInfo->maxHeight > maxHeight)
- {
- maxHeight = pWordTtextWidthInfo->maxHeight;
- }
- textCount += pWordTtextWidthInfo->length;
- Seek(pWordTtextWidthInfo->length);
- }
- }
-
- endType = TEXT_RETBY_LIMITWIDTH;
- composeDone = true;
- }
- }
- break;
-
- case TEXT_WIDTH_INFO_SPACE:
- {
- SpaceTextWidthInfo* pSpaceTextWidthInfo = static_cast < SpaceTextWidthInfo* >(pCurrentTextWidthInfo);
- SysTryReturn(NID_GRP
- , pSpaceTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information.");
-
- if (remainingWidth >= pSpaceTextWidthInfo->width)
- {
- remainingWidth -= pSpaceTextWidthInfo->width;
- if (maxHeight < pSpaceTextWidthInfo->maxHeight)
- {
- maxHeight = pSpaceTextWidthInfo->maxHeight;
- }
-
- textCount++;
-
- Seek(1);
-
- if (wordMeet)
- {
- spaceMeetAfterWord = true;
- }
-
- cutLinkMeetAfterWord = false;
- }
- else
- {
- endType = TEXT_RETBY_LIMITWIDTH;
- composeDone = true;
- }
- }
- break;
-
- case TEXT_WIDTH_INFO_ENTER:
- {
- endType = TEXT_RETBY_LINEFEED;
- composeDone = true;
- EnterTextWidthInfo* pEnterTextWidthInfo = static_cast < EnterTextWidthInfo* >(pCurrentTextWidthInfo);
- SysTryReturn(NID_GRP
- , pEnterTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information.");
-
- maxHeight = pEnterTextWidthInfo->maxHeight;
- textCount += pEnterTextWidthInfo->length;
- Seek(pEnterTextWidthInfo->length);
-
- enterMeet = true;
- }
- break;
-
- case TEXT_WIDTH_INFO_SYMBOL:
- {
- if (textCount == 0)
- {
- SymbolTextWidthInfo* pSymbolTextWidthInfo = static_cast < SymbolTextWidthInfo* >(pCurrentTextWidthInfo);
- SysTryReturn(NID_GRP
- , pSymbolTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information.");
-
- remainingWidth -= pSymbolTextWidthInfo->width;
- maxHeight = pSymbolTextWidthInfo->maxHeight;
- textCount++;
- Seek(1);
- }
- else
- {
- endType = TEXT_RETBY_NORMAL;
- composeDone = true;
- }
- }
- break;
- }
-
- if (remainingWidth <= 0)
- {
- break;
- }
-
- if (!enterMeet && (__length <= __currentTextIndex))
- {
- endType = TEXT_RETBY_NORMAL;
- composeDone = true;
- }
-
- if (!composeDone)
- {
- SysTryReturn(NID_GRP
- , __pCurrentWordWidthInfoNode
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width node.");
-
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
- }
- }
-
- textLineComposeInfo.length = textCount;
- textLineComposeInfo.width = lineWidth - remainingWidth;
- textLineComposeInfo.height = maxHeight;
- textLineComposeInfo.endType = endType;
-
- return true;
-}
-
-bool
-TextWidthManager::GetCurrentLineInfo(float lineWidth, TextLineComposeInfo& textLineComposeInfo)
-{
- return GetCurrentLineInfo(_CoordinateSystemUtils::ConvertToInteger(lineWidth), textLineComposeInfo);
-}
-
-bool
-TextWidthManager::EndCompose(void)
-{
- __isComposing = false;
- __pCurrentComposeTextElement = null;
- __pCurrentWordWidthInfoNode = null;
-
- return true;
-}
-
-bool
-TextWidthManager::InformTextInsert(int textIndex, int textLength)
-{
- SimpleNode* pCurrentTextWidthInfoNode = null;
- if (!__isInitialized)
- {
- return false;
- }
-
- if (__isComposing)
- {
- return false;
- }
-
- if (__length < textIndex)
- {
- return false;
- }
-
- if (textIndex == __length)
- {
- SimpleNode* pLastNode = TextSimpleList::GetLastNode(__pTextWidthInfoList);
- int strLastTextWidthInfo = 0;
- TextWidthCommonInfo* pLastTextWidthInfo = null;
-
- if (pLastNode != null)
- {
- pLastTextWidthInfo = static_cast < TextWidthCommonInfo* >(pLastNode->pObject);
- strLastTextWidthInfo = GetTextWidthInfoLength(pLastTextWidthInfo);
- SysTryReturn(NID_GRP
- , strLastTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element node.");
- }
-
- if ((pLastNode == null) || (strLastTextWidthInfo + textLength > MAX_TEXT_WIDTH_INFO_MERGE_LENGTH))
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = 0;
-
- pCurrentTextWidthInfoNode = TextSimpleList::AppendObject(__pTextWidthInfoList, pUnknownTextWidthInfo);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfoNode
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element node.");
-
- UpdateCachedTextWidhtInfo(__length, pCurrentTextWidthInfoNode);
- pUnknownTextWidthInfo->length = textLength;
- }
- else
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = strLastTextWidthInfo;
-
- delete static_cast < TextWidthCommonInfo* >(pLastNode->pObject);
- pLastNode->pObject = pUnknownTextWidthInfo;
-
- UpdateCachedTextWidhtInfo(__length - strLastTextWidthInfo, pLastNode);
- pUnknownTextWidthInfo->length += textLength;
- }
-
- __length += textLength;
-
- return true;
- }
-
- int currentWidthInfoTextOffset = 0;
- TextWidthCommonInfo* pCurrentTextWidthInfo = null;
-
- pCurrentTextWidthInfoNode = SearchTextWidthInfo(textIndex, currentWidthInfoTextOffset);
- if (pCurrentTextWidthInfoNode == null)
- {
- return false;
- }
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- int textIndexFromCurrentWidthInfoTextOffset = textIndex - currentWidthInfoTextOffset;
- int widthinfoType = pCurrentTextWidthInfo->type;
-
- switch (widthinfoType)
- {
- case TEXT_WIDTH_INFO_UNKNOWN:
- {
- UpdateCachedTextWidhtInfo(currentWidthInfoTextOffset, pCurrentTextWidthInfoNode);
-
- UnknownTextWidthInfo* pUnknownTextWidthInfo = static_cast < UnknownTextWidthInfo* >(pCurrentTextWidthInfo);
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
- pUnknownTextWidthInfo->length += textLength;
- __length += textLength;
- }
- break;
-
- case TEXT_WIDTH_INFO_WORD:
- {
- WordTextWidthInfo* pCurrentWordTextWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentTextWidthInfo);
- SysTryReturn(NID_GRP
- , pCurrentWordTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information.");
-
- if ((textIndexFromCurrentWidthInfoTextOffset == 0) &&
- (pCurrentWordTextWidthInfo->length + textLength > MAX_TEXT_WIDTH_INFO_MERGE_LENGTH))
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = 0;
-
- pCurrentTextWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentTextWidthInfoNode,
- pUnknownTextWidthInfo);
- UpdateCachedTextWidhtInfo(textIndex, pCurrentTextWidthInfoNode);
- pUnknownTextWidthInfo->length = textLength;
- }
- else
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = pCurrentWordTextWidthInfo->length;
- delete static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- pCurrentTextWidthInfoNode->pObject = pUnknownTextWidthInfo;
-
- UpdateCachedTextWidhtInfo(currentWidthInfoTextOffset, pCurrentTextWidthInfoNode);
- pUnknownTextWidthInfo->length += textLength;
- }
-
- __length += textLength;
- }
- break;
-
- case TEXT_WIDTH_INFO_SPACE:
- // fall through
- case TEXT_WIDTH_INFO_ENTER:
- // fall through
- case TEXT_WIDTH_INFO_SYMBOL:
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = GetTextWidthInfoLength(pCurrentTextWidthInfo);
- delete static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- pCurrentTextWidthInfoNode->pObject = pUnknownTextWidthInfo;
-
- UpdateCachedTextWidhtInfo(currentWidthInfoTextOffset, pCurrentTextWidthInfoNode);
- pUnknownTextWidthInfo->length += textLength;
- __length += textLength;
- }
- break;
- }
-
- return true;
-}
-
-bool
-TextWidthManager::InformTextRemove(int textIndex, int textLength)
-{
- if (!__isInitialized)
- {
- return false;
- }
-
- if (__isComposing)
- {
- return false;
- }
-
- if (__length <= textIndex)
- {
- return false;
- }
-
- if (__length < textIndex + textLength)
- {
- textLength = __length - textIndex;
- }
-
- int strLengthRemove = textLength;
- SimpleNode* pCurrentTextWidthInfoNode = null;
- int currentWidthInfoTextOffset = 0;
- TextWidthCommonInfo* pCurrentTextWidthInfo = null;
-
- pCurrentTextWidthInfoNode = SearchTextWidthInfo(textIndex, currentWidthInfoTextOffset);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfoNode
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text text width node.");
-
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- int textIndexFromCurrentWidthInfoTextOffset = textIndex - currentWidthInfoTextOffset;
- int currentWidthInfoTextLength = GetTextWidthInfoLength(pCurrentTextWidthInfo);
- bool cachedUpdated = false;
-
- if ((textIndexFromCurrentWidthInfoTextOffset != 0) || (currentWidthInfoTextLength > textLength))
- {
- int strCurrrentRemoveLength = 0;
- if (textIndexFromCurrentWidthInfoTextOffset == 0)
- {
- strCurrrentRemoveLength = textLength;
- }
- else
- {
- if (textLength + textIndexFromCurrentWidthInfoTextOffset >= currentWidthInfoTextLength)
- {
- strCurrrentRemoveLength = currentWidthInfoTextLength - textIndexFromCurrentWidthInfoTextOffset;
- }
- else
- {
- strCurrrentRemoveLength = textLength;
- }
- }
-
- UpdateCachedTextWidhtInfo(currentWidthInfoTextOffset, pCurrentTextWidthInfoNode);
- cachedUpdated = true;
-
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = currentWidthInfoTextLength - strCurrrentRemoveLength;
- delete static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- pCurrentTextWidthInfoNode->pObject = pUnknownTextWidthInfo;
-
- pCurrentTextWidthInfoNode = pCurrentTextWidthInfoNode->pNext;
-
- textLength -= strCurrrentRemoveLength;
- }
-
- while (textLength)
- {
- SimpleNode* pNextTextWidthInfoNode = null;
-
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfoNode
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element node.");
-
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- currentWidthInfoTextLength = GetTextWidthInfoLength(pCurrentTextWidthInfo);
-
- if (textLength < currentWidthInfoTextLength)
- {
- break;
- }
-
- pNextTextWidthInfoNode = pCurrentTextWidthInfoNode->pNext;
-
- TextSimpleList::DeleteNode(__pTextWidthInfoList, pCurrentTextWidthInfoNode);
-
- pCurrentTextWidthInfoNode = pNextTextWidthInfoNode;
-
- textLength -= currentWidthInfoTextLength;
- }
-
- if (textLength > 0)
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = currentWidthInfoTextLength - textLength;
- delete static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- pCurrentTextWidthInfoNode->pObject = pUnknownTextWidthInfo;
- }
-
- if (!cachedUpdated)
- {
- UpdateCachedTextWidhtInfo(textIndex, pCurrentTextWidthInfoNode);
- }
-
- __length -= strLengthRemove;
-
- return true;
-}
-
-int
-TextWidthManager::GetTextWidthInfoLength(TextWidthCommonInfo* pTextWidthCommonInfo)
-{
- int type = pTextWidthCommonInfo->type;
-
- switch (type)
- {
- case TEXT_WIDTH_INFO_UNKNOWN:
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = static_cast < UnknownTextWidthInfo* >(pTextWidthCommonInfo);
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , -1, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information.");
-
- return pUnknownTextWidthInfo->length;
- }
-
- case TEXT_WIDTH_INFO_WORD:
- {
- WordTextWidthInfo* pWordWidthInfo = static_cast < WordTextWidthInfo* >(pTextWidthCommonInfo);
- SysTryReturn(NID_GRP
- , pWordWidthInfo
- , -1, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- return pWordWidthInfo->length;
- }
-
- case TEXT_WIDTH_INFO_SPACE:
- return 1;
-
- case TEXT_WIDTH_INFO_ENTER:
- {
- EnterTextWidthInfo* pEnterWidthInfo = static_cast < EnterTextWidthInfo* >(pTextWidthCommonInfo);
- SysTryReturn(NID_GRP
- , pEnterWidthInfo
- , -1, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information.");
-
- return pEnterWidthInfo->length;
- }
-
- case TEXT_WIDTH_INFO_SYMBOL:
- return 1;
- }
-
- return -1;
-}
-
-SimpleNode*
-TextWidthManager::SplitWidthInfo(SimpleNode* pOrginalTextWidthInfoNode, int splitStartIndex,
- TextWidthCommonInfo* pTextWidthInfo)
-{
- TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pOrginalTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
-
- int type = pCurrentTextWidthInfo->type;
-
- if (type == TEXT_WIDTH_INFO_UNKNOWN)
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = static_cast < UnknownTextWidthInfo* >(pCurrentTextWidthInfo);
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text width information.");
-
- pUnknownTextWidthInfo->length = splitStartIndex;
- }
- else if (type == TEXT_WIDTH_INFO_WORD)
- {
- UnknownTextWidthInfo* pUnknownTextWidthInfo = new (std::nothrow) UnknownTextWidthInfo;
- SysTryReturn(NID_GRP
- , pUnknownTextWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pUnknownTextWidthInfo->type = TEXT_WIDTH_INFO_UNKNOWN;
- pUnknownTextWidthInfo->length = splitStartIndex;
- delete static_cast < TextWidthCommonInfo* >(pOrginalTextWidthInfoNode->pObject);
- pOrginalTextWidthInfoNode->pObject = pUnknownTextWidthInfo;
- }
-
- SimpleNode* pNode = TextSimpleList::InsertObjectAfterNode(__pTextWidthInfoList, pOrginalTextWidthInfoNode, pTextWidthInfo);
- return pNode;
-}
-
-WordTextWidthInfo*
-TextWidthManager::SplitCurrentWordWidthInfo(int limitWidth, bool& isNextKoreanStart)
-{
- TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- WordTextWidthInfo* pWordWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentTextWidthInfo);
- SysTryReturn(NID_GRP
- , pWordWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- int currentWordWidth = pWordWidthInfo->width;
- int currentWordLength = pWordWidthInfo->length;
-
- if ((currentWordWidth - limitWidth) >= (currentWordWidth >> 2))
- {
- TextElement* pTextElement = __pCurrentComposeTextElement;
- int textElementIndex = __currentComposeTextElementIndex;
- int strSrcRelIndex = __strCurrentRelIndex;
- int currentLength = Math::Min(__currentTextElementLength, currentWordLength);
- int stringLength = currentWordLength;
- int endType = TEXT_RETBY_NORMAL;
- int remainWidth = limitWidth;
- int charCount = 0;
- int width = 0;
- int height = 0;
- int maxHeight = 0;
- int textIndex = 0;
-
- while (stringLength != 0)
- {
- endType = pTextElement->ForwardAnalyze(strSrcRelIndex, currentLength, remainWidth,
- TEXT_OBJECT_WRAP_TYPE_NONE, charCount, width, height);
-
- if (endType == TEXT_RETBY_LIMITWIDTH)
- {
- textIndex += charCount;
- strSrcRelIndex += charCount;
- remainWidth -= width;
- if (height > maxHeight)
- {
- maxHeight = height;
- }
- break;
- }
- else if (endType != TEXT_RETBY_LIMITLENGTH)
- {
- ; //SysAssert(false);
- }
-
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- remainWidth -= width;
- if (height > maxHeight)
- {
- height = maxHeight;
- }
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- stringLength -= currentLength;
- textIndex += currentLength;
- currentLength = Math::Min(stringLength, pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex);
- }
-
- SysTryReturn(NID_GRP
- , pTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement);
- SysTryReturn(NID_GRP
- , pSimpleTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
-
- wchar_t* pText = (wchar_t*)pSimpleTextElement->GetText();
- isNextKoreanStart = IsKorean(pText[0]);
-
- if (textIndex > 0)
- {
- WordTextWidthInfo* pNewWordWidthInfo = new (std::nothrow) WordTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewWordWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewWordWidthInfo->type = TEXT_WIDTH_INFO_WORD;
- pNewWordWidthInfo->length = textIndex;
- pNewWordWidthInfo->maxHeight = height;
- pNewWordWidthInfo->width = limitWidth - remainWidth;
-
- bool isCacheChanged = false;
-
- if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode)
- {
- isCacheChanged = true;
- }
-
- __pCurrentWordWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, __pCurrentWordWidthInfoNode,
- pNewWordWidthInfo);
-
- if (isCacheChanged)
- {
- __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode;
- }
-
- pWordWidthInfo->length -= textIndex;
- pWordWidthInfo->width -= pNewWordWidthInfo->width;
- return pNewWordWidthInfo;
- }
- else
- {
- return pWordWidthInfo;
- }
- }
- else
- {
- int remainingWidth = currentWordWidth - limitWidth;
-
- TextElement* pTextElement = __pCurrentComposeTextElement;
- int textElementIndex = __currentComposeTextElementIndex;
- int strSrcRelIndex = __strCurrentRelIndex;
- int textLength = currentWordLength;
- int currentLength = __currentTextElementLength;
- TextElement* pTextElementStack[10];
- int textElementStackIndex = 0;
-
- pTextElementStack[0] = pTextElement;
-
- while (textLength > 0)
- {
- if (textLength <= currentLength)
- {
- strSrcRelIndex += (textLength - 1);
- break;
- }
-
- textLength -= currentLength;
-
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex;
-
- textElementStackIndex++;
- pTextElementStack[textElementStackIndex] = pTextElement;
- }
-
- SysTryReturn(NID_GRP
- , pTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- int width = 0;
- int height = 0;
- int strSrcStartRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- int widthBackward = 0;
- int stringLengthBackward = 0;
- int maxHeight = 0;
-
- while (0 < remainingWidth)
- {
- pTextElement->GetRegion(strSrcRelIndex, 1, width, height);
- if (remainingWidth <= width)
- {
- widthBackward += width;
- stringLengthBackward++;
- if (height > maxHeight)
- {
- maxHeight = height;
- }
- break;
- }
-
- widthBackward += width;
- stringLengthBackward++;
- remainingWidth -= width;
-
- if (height > maxHeight)
- {
- maxHeight = height;
- }
-
- if (strSrcStartRelIndex < strSrcRelIndex)
- {
- strSrcRelIndex--;
- }
- else
- {
- textElementStackIndex--;
- SysTryReturn(NID_GRP
- , textElementStackIndex >= 0
- , null, E_SYSTEM, "[E_SYSTEM] Index must be greater than or equal to 0.");
-
- pTextElement = pTextElementStack[textElementStackIndex];
- SysTryReturn(NID_GRP
- , pTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- strSrcStartRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - 1;
- }
- }
-
- TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement);
- SysTryReturn(NID_GRP
- , pSimpleTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
-
- wchar_t* pText = (wchar_t*)pSimpleTextElement->GetText();
- isNextKoreanStart = IsKorean(pText[0]);
-
- if ((stringLengthBackward > 0) && (stringLengthBackward < pWordWidthInfo->length))
- {
- WordTextWidthInfo* pNewWordWidthInfo = new (std::nothrow) WordTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewWordWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewWordWidthInfo->type = TEXT_WIDTH_INFO_WORD;
- pNewWordWidthInfo->length = stringLengthBackward;
- pNewWordWidthInfo->maxHeight = height;
- pNewWordWidthInfo->width = widthBackward;
-
- TextSimpleList::InsertObjectAfterNode(__pTextWidthInfoList, __pCurrentWordWidthInfoNode, pNewWordWidthInfo);
-
- pWordWidthInfo->length -= stringLengthBackward;
- pWordWidthInfo->width -= widthBackward;
- }
- else
- {
- return pWordWidthInfo;
- }
-
- return pWordWidthInfo;
- }
-
- return null;
-}
-
-WordTextWidthInfo*
-TextWidthManager::SplitWordWidthInfo(SimpleNode* pCurrentWordWidthInfoNode, TextElement* pCurrentTextElement,
- int strCurrentRelIndex, int strCurrentLength, int limitWidth, bool& isNextKoreanStart)
-{
- WordTextWidthInfo* pWordWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pWordWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- int currentWordWidth = pWordWidthInfo->width;
- int currentWordLength = pWordWidthInfo->length;
-
- if ((currentWordWidth - limitWidth) >= (currentWordWidth >> 2))
- {
- TextElement* pTextElement = pCurrentTextElement;
- int strSrcRelIndex = strCurrentRelIndex;
- int currentLength = Math::Min(__currentTextElementLength, currentWordLength);
- int stringLength = currentWordLength;
- int endType = TEXT_RETBY_NORMAL;
- int remainWidth = limitWidth;
- int charCount = 0;
- int width = 0;
- int height = 0;
- int maxHeight = 0;
- int stringIndex = 0;
- int textElementIndex = __pCompositeText->GetElementIndexOf(*pCurrentTextElement);
- SysTryReturn(NID_GRP
- , textElementIndex >= 0
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- while (stringLength != 0)
- {
- endType = pTextElement->ForwardAnalyze(strSrcRelIndex, currentLength, remainWidth,
- TEXT_OBJECT_WRAP_TYPE_NONE, charCount, width, height);
-
- if (endType == TEXT_RETBY_LIMITWIDTH)
- {
- stringIndex += charCount;
- strSrcRelIndex += charCount;
- remainWidth -= width;
- if (height > maxHeight)
- {
- maxHeight = height;
- }
- break;
- }
- else if (endType != TEXT_RETBY_LIMITLENGTH)
- {
- ; //SysAssert(false);
- }
-
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- remainWidth -= width;
-
- if (height > maxHeight)
- {
- height = maxHeight;
- }
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- stringLength -= currentLength;
- stringIndex += currentLength;
- currentLength = Math::Min(stringLength, pTextElement->GetValue(
- SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex);
- }
-
- SysTryReturn(NID_GRP
- , pTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement);
- SysTryReturn(NID_GRP
- , pSimpleTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
-
- wchar_t* pText = (wchar_t*)pSimpleTextElement->GetText();
- isNextKoreanStart = IsKorean(pText[0]);
-
- if (stringIndex > 0)
- {
- WordTextWidthInfo* pNewWordWidthInfo = new (std::nothrow) WordTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewWordWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewWordWidthInfo->type = TEXT_WIDTH_INFO_WORD;
- pNewWordWidthInfo->length = stringIndex;
- pNewWordWidthInfo->maxHeight = height;
- pNewWordWidthInfo->width = limitWidth - remainWidth;
-
- if (pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode)
- {
- __pCachedWordWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList,
- pCurrentWordWidthInfoNode, pNewWordWidthInfo);
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, pNewWordWidthInfo);
- }
-
- pWordWidthInfo->length -= stringIndex;
- pWordWidthInfo->width -= pNewWordWidthInfo->width;
- return pNewWordWidthInfo;
- }
- else
- {
- return pWordWidthInfo;
- }
- }
- else
- {
- int remainingWidth = currentWordWidth - limitWidth;
-
- TextElement* pTextElement = __pCurrentComposeTextElement;
- int textElementIndex = __currentComposeTextElementIndex;
- int strSrcRelIndex = strCurrentRelIndex;
- int textLength = currentWordLength;
- int currentLength = __currentTextElementLength;
- TextElement* pTextElementStack[10];
- int textElementStackIndex = 0;
-
- pTextElementStack[0] = pTextElement;
-
- while (textLength > 0)
- {
- if (currentLength >= textLength)
- {
- strSrcRelIndex += (textLength - 1);
- break;
- }
-
- textLength -= currentLength;
- textElementIndex++;
-
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex;
-
- textElementStackIndex++;
- pTextElementStack[textElementStackIndex] = pTextElement;
- }
-
- SysTryReturn(NID_GRP
- , pTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- int width = 0;
- int height = 0;
- int strSrcStartRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- int widthBackward = 0;
- int stringLengthBackward = 0;
- int maxHeight = 0;
- while (remainingWidth > 0)
- {
- pTextElement->GetRegion(strSrcRelIndex, 1, width, height);
- if (remainingWidth <= width)
- {
- widthBackward += width;
- stringLengthBackward++;
- if (height > maxHeight)
- {
- maxHeight = height;
- }
- break;
- }
-
- widthBackward += width;
- stringLengthBackward++;
- remainingWidth -= width;
-
- if (height > maxHeight)
- {
- maxHeight = height;
- }
-
- if (strSrcStartRelIndex < strSrcRelIndex)
- {
- strSrcRelIndex--;
- }
- else
- {
- textElementStackIndex--;
- SysTryReturn(NID_GRP
- , textElementStackIndex >= 0
- , null, E_SYSTEM, "[E_SYSTEM] Index must be greater than or equal to 0.");
-
- pTextElement = pTextElementStack[textElementStackIndex];
- SysTryReturn(NID_GRP
- , pTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- strSrcStartRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - 1;
- }
- }
-
- TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement);
- SysTryReturn(NID_GRP
- , pSimpleTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
-
- wchar_t* pText = (wchar_t*)pSimpleTextElement->GetText();
- isNextKoreanStart = IsKorean(pText[0]);
-
- if ((stringLengthBackward > 0) && (stringLengthBackward < pWordWidthInfo->length))
- {
- WordTextWidthInfo* pNewWordWidthInfo = new (std::nothrow) WordTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewWordWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewWordWidthInfo->type = TEXT_WIDTH_INFO_WORD;
- pNewWordWidthInfo->length = stringLengthBackward;
- pNewWordWidthInfo->maxHeight = height;
- pNewWordWidthInfo->width = widthBackward;
-
- TextSimpleList::InsertObjectAfterNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode, pNewWordWidthInfo);
-
- pWordWidthInfo->length -= stringLengthBackward;
- pWordWidthInfo->width -= widthBackward;
- }
- else
- {
- return pWordWidthInfo;
- }
-
- return pWordWidthInfo;
- }
-
- return null;
-}
-
-bool
-TextWidthManager::Seek(int textLength)
-{
- if (__currentTextIndex + textLength > __length)
- {
- return false;
- }
-
- if (__currentTextIndex + textLength == __length)
- {
- __pCurrentWordWidthInfoNode = null;
- __pCurrentComposeTextElement = null;
- __currentTextIndex += textLength;
- return true;
- }
-
- if (textLength == 0)
- {
- return false;
- }
-
- TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- int strCurrentTextWidthInfoLength = GetTextWidthInfoLength(pCurrentTextWidthInfo);
-
- if (__textOffsetOfCurrentWidthInfo != 0)
- {
- return false;
- }
-
- int length = textLength;
-
- while (length > 0)
- {
- length -= strCurrentTextWidthInfoLength;
-
- __pCurrentWordWidthInfoNode = __pCurrentWordWidthInfoNode->pNext;
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
- strCurrentTextWidthInfoLength = GetTextWidthInfoLength(pCurrentTextWidthInfo);
- }
-
- length = textLength;
- TextElement* pTextElement = __pCurrentComposeTextElement;
- int textElementIndex = __currentComposeTextElementIndex;
- int strSrcRelIndex = __strCurrentRelIndex;
- int currentLength = __currentTextElementLength;
-
- while (length > 0)
- {
- if (currentLength > length)
- {
- strSrcRelIndex += length;
- break;
- }
-
- length -= currentLength;
-
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex;
- }
-
- SysTryReturn(NID_GRP
- , pTextElement
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- __pCurrentComposeTextElement = pTextElement;
- __strCurrentRelIndex = strSrcRelIndex;
- __currentTextElementLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex;
- __currentTextIndex += textLength;
-
- return true;
-}
-
-bool
-TextWidthManager::AnalyzeCurrentUnKnownTextWidthInfo(int limitWidth)
-{
- SimpleNode* pCurrentWordWidthInfoNode = __pCurrentWordWidthInfoNode;
- UnknownTextWidthInfo* pCurrentUnknowTextWidthInfo = static_cast < UnknownTextWidthInfo* >(__pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentUnknowTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- int strCurrentTextWidthInfoLength = pCurrentUnknowTextWidthInfo->length;
-
- TextElement* pTextElement = __pCurrentComposeTextElement;
- int textElementIndex = __currentComposeTextElementIndex;
- int strSrcRelIndex = __strCurrentRelIndex;
- int currentLength = __currentTextElementLength;
- int textLength = strCurrentTextWidthInfoLength;
- int width = 0;
- int height = 0;
-
- TextElementType objectType;
-
- bool getDone = false;
-
- while (textLength > 0)
- {
- objectType = pTextElement->GetType();
-
- switch (objectType)
- {
- case TEXT_ELEMENT_TYPE_TEXT:
- // fall through
- case TEXT_ELEMENT_TYPE_CUTLINK:
- {
- TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement);
- SysTryReturn(NID_GRP
- , pSimpleTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
-
- int wordType = 0;
- int currentTextLength = 0;
-
- wordType = pSimpleTextElement->GetWordLength(strSrcRelIndex, currentTextLength);
- if (wordType == WORD_ENTER)
- {
- pCurrentUnknowTextWidthInfo->length -= currentTextLength;
-
- pTextElement->GetRegion(strSrcRelIndex, 1, width, height);
-
- EnterTextWidthInfo* pNewEnterTextWidthInfo = new (std::nothrow) EnterTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewEnterTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewEnterTextWidthInfo->type = TEXT_WIDTH_INFO_ENTER;
- pNewEnterTextWidthInfo->length = currentTextLength;
- pNewEnterTextWidthInfo->maxHeight = height;
-
- if (pCurrentWordWidthInfoNode == __pCurrentWordWidthInfoNode)
- {
- bool changecachedInfo = false;
-
- if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode)
- {
- changecachedInfo = true;
- }
-
- __pCurrentWordWidthInfoNode =
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewEnterTextWidthInfo);
-
- if (changecachedInfo)
- {
- __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode;
- }
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewEnterTextWidthInfo);
- }
-
- getDone = true;
- }
- else if (wordType == WORD_SPACE)
- {
- pCurrentUnknowTextWidthInfo->length--;
-
- pTextElement->GetRegion(strSrcRelIndex, 1, width, height);
-
- SpaceTextWidthInfo* pNewSpaceTextWidthInfo = new (std::nothrow) SpaceTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewSpaceTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewSpaceTextWidthInfo->type = TEXT_WIDTH_INFO_SPACE;
- pNewSpaceTextWidthInfo->width = width;
- pNewSpaceTextWidthInfo->maxHeight = height;
-
- if (pCurrentWordWidthInfoNode == __pCurrentWordWidthInfoNode)
- {
- bool changecachedInfo = false;
-
- if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode)
- {
- changecachedInfo = true;
- }
-
- __pCurrentWordWidthInfoNode =
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewSpaceTextWidthInfo);
-
- if (changecachedInfo)
- {
- __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode;
- }
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewSpaceTextWidthInfo);
- }
-
- currentLength--;
- strSrcRelIndex++;
- limitWidth -= width;
- textLength--;
- }
- else
- {
- if (currentTextLength > textLength)
- {
- currentTextLength = textLength;
- }
- pCurrentUnknowTextWidthInfo->length -= currentTextLength;
-
- pTextElement->GetRegion(strSrcRelIndex, currentTextLength, width, height);
-
- WordTextWidthInfo* pNewWordTextWidthInfo = new (std::nothrow) WordTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewWordTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewWordTextWidthInfo->type = TEXT_WIDTH_INFO_WORD;
- pNewWordTextWidthInfo->length = currentTextLength;
- pNewWordTextWidthInfo->width = width;
- pNewWordTextWidthInfo->maxHeight = height;
-
- if (pCurrentWordWidthInfoNode == __pCurrentWordWidthInfoNode)
- {
- bool changecachedInfo = false;
-
- if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode)
- {
- changecachedInfo = true;
- }
-
- __pCurrentWordWidthInfoNode =
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewWordTextWidthInfo);
-
- if (changecachedInfo)
- {
- __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode;
- }
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewWordTextWidthInfo);
- }
-
- currentLength -= currentTextLength;
- strSrcRelIndex += currentTextLength;
- limitWidth -= width;
- textLength -= currentTextLength;
- }
- }
- break;
-
- case TEXT_ELEMENT_TYPE_IMAGE:
- {
- pTextElement->GetRegion(0, 1, width, height);
-
- pCurrentUnknowTextWidthInfo->length--;
-
- SymbolTextWidthInfo* pNewSymbolTextWidthInfo = new (std::nothrow) SymbolTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewSymbolTextWidthInfo
- , false, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewSymbolTextWidthInfo->type = TEXT_WIDTH_INFO_SYMBOL;
- pNewSymbolTextWidthInfo->width = width;
- pNewSymbolTextWidthInfo->maxHeight = height;
-
- if (pCurrentWordWidthInfoNode == __pCurrentWordWidthInfoNode)
- {
- bool changecachedInfo = false;
-
- if (__pCurrentWordWidthInfoNode == __pCachedWordWidthInfoNode)
- {
- changecachedInfo = true;
- }
-
- __pCurrentWordWidthInfoNode =
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewSymbolTextWidthInfo);
-
- if (changecachedInfo)
- {
- __pCachedWordWidthInfoNode = __pCurrentWordWidthInfoNode;
- }
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewSymbolTextWidthInfo);
- }
-
- getDone = true;
- }
- break;
-
- default:
- return false;
- }
-
- if (limitWidth <= 0)
- {
- break;
- }
-
- if (getDone)
- {
- break;
- }
-
- if (currentLength <= 0)
- {
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex;
- }
- }
-
- if (pCurrentUnknowTextWidthInfo->length == 0)
- {
- TextSimpleList::DeleteNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode);
- }
-
- return true;
-}
-
-SimpleNode*
-TextWidthManager::AnalyzeUnKnownTextWidthInfo(SimpleNode* pCurrentWordWidthInfoNode, TextElement* pCurrentTextElement,
- int strCurrentRelIndex, int strCurrentLength, int limitWidth)
-{
- SimpleNode* pReturnWordWidthInfoNode = null;
- SimpleNode* p_current_word_width_info_node = pCurrentWordWidthInfoNode;
- int strCurrentTextWidthInfoLength = 0;
-
- UnknownTextWidthInfo* pCurrentUnknowTextWidthInfo = static_cast < UnknownTextWidthInfo* >(pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentUnknowTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
- strCurrentTextWidthInfoLength = pCurrentUnknowTextWidthInfo->length;
-
- TextElement* pTextElement = pCurrentTextElement;
- SysTryReturn(NID_GRP
- , pTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- int textElementIndex = __pCompositeText->GetElementIndexOf(*pCurrentTextElement);
- SysTryReturn(NID_GRP
- , textElementIndex >= 0
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- int strSrcRelIndex = strCurrentRelIndex;
- int currentLength = strCurrentLength;
- int textLength = strCurrentTextWidthInfoLength;
- TextElementType objectType;
- bool getDone = false;
- int width = 0;
- int height = 0;
-
- while (textLength > 0)
- {
- objectType = pTextElement->GetType();
-
- switch (objectType)
- {
- case TEXT_ELEMENT_TYPE_TEXT:
- // fall through
- case TEXT_ELEMENT_TYPE_CUTLINK:
- {
- TextSimple* pSimpleTextElement = dynamic_cast < TextSimple* >(pTextElement);
- SysTryReturn(NID_GRP
- , pSimpleTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to cast text element.");
-
- int wordType = 0;
- int currentTextLength = 0;
-
- wordType = pSimpleTextElement->GetWordLength(strSrcRelIndex, currentTextLength);
- if (wordType == WORD_ENTER)
- {
- pCurrentUnknowTextWidthInfo->length -= currentTextLength;
-
- pTextElement->GetRegion(strSrcRelIndex, 1, width, height);
-
- EnterTextWidthInfo* pNewEnterTextWidthInfo = new (std::nothrow) EnterTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewEnterTextWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewEnterTextWidthInfo->type = TEXT_WIDTH_INFO_ENTER;
- pNewEnterTextWidthInfo->length = currentTextLength;
- pNewEnterTextWidthInfo->maxHeight = height;
-
- if (pReturnWordWidthInfoNode == null)
- {
- bool changecachedInfo = false;
-
- if (p_current_word_width_info_node == __pCachedWordWidthInfoNode)
- {
- changecachedInfo = true;
- }
-
- pReturnWordWidthInfoNode =
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewEnterTextWidthInfo);
-
- if (changecachedInfo)
- {
- __pCachedWordWidthInfoNode = pReturnWordWidthInfoNode;
- }
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewEnterTextWidthInfo);
- }
-
- getDone = true;
- }
- else if (wordType == WORD_SPACE)
- {
- pCurrentUnknowTextWidthInfo->length--;
-
- pTextElement->GetRegion(strSrcRelIndex, 1, width, height);
-
- SpaceTextWidthInfo* pNewSpaceTextWidthInfo = new (std::nothrow) SpaceTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewSpaceTextWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewSpaceTextWidthInfo->type = TEXT_WIDTH_INFO_SPACE;
- pNewSpaceTextWidthInfo->width = width;
- pNewSpaceTextWidthInfo->maxHeight = height;
-
- if (pReturnWordWidthInfoNode == null)
- {
- bool changecachedInfo = false;
-
- if (p_current_word_width_info_node == __pCachedWordWidthInfoNode)
- {
- changecachedInfo = true;
- }
-
- pReturnWordWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewSpaceTextWidthInfo);
-
- if (changecachedInfo)
- {
- __pCachedWordWidthInfoNode = pReturnWordWidthInfoNode;
- }
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewSpaceTextWidthInfo);
- }
-
- currentLength--;
- strSrcRelIndex++;
- limitWidth -= width;
- textLength--;
- }
- else
- {
- if (textLength < currentTextLength)
- {
- currentTextLength = textLength;
- }
- pCurrentUnknowTextWidthInfo->length -= currentTextLength;
-
- pTextElement->GetRegion(strSrcRelIndex, currentTextLength, width, height);
-
- WordTextWidthInfo* pNewWordTextWidthInfo = new (std::nothrow) WordTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewWordTextWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewWordTextWidthInfo->type = TEXT_WIDTH_INFO_WORD;
- pNewWordTextWidthInfo->length = currentTextLength;
- pNewWordTextWidthInfo->width = width;
- pNewWordTextWidthInfo->maxHeight = height;
-
- if (pReturnWordWidthInfoNode == null)
- {
- bool changecachedInfo = false;
-
- if (p_current_word_width_info_node == __pCachedWordWidthInfoNode)
- {
- changecachedInfo = true;
- }
-
- pReturnWordWidthInfoNode =
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewWordTextWidthInfo);
-
- if (changecachedInfo)
- {
- __pCachedWordWidthInfoNode = pReturnWordWidthInfoNode;
- }
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewWordTextWidthInfo);
- }
-
- currentLength -= currentTextLength;
- strSrcRelIndex += currentTextLength;
- limitWidth -= width;
- textLength -= currentTextLength;
- }
- }
- break;
-
- case TEXT_ELEMENT_TYPE_IMAGE:
- {
- pTextElement->GetRegion(0, 1, width, height);
-
- pCurrentUnknowTextWidthInfo->length--;
-
- SymbolTextWidthInfo* pNewSymbolTextWidthInfo = new (std::nothrow) SymbolTextWidthInfo;
- SysTryReturn(NID_GRP
- , pNewSymbolTextWidthInfo
- , null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
- pNewSymbolTextWidthInfo->type = TEXT_WIDTH_INFO_SYMBOL;
- pNewSymbolTextWidthInfo->width = width;
- pNewSymbolTextWidthInfo->maxHeight = height;
-
- if (pReturnWordWidthInfoNode == null)
- {
- bool changecachedInfo = false;
-
- if (p_current_word_width_info_node == __pCachedWordWidthInfoNode)
- {
- changecachedInfo = true;
- }
-
- pReturnWordWidthInfoNode = TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewSymbolTextWidthInfo);
-
- if (changecachedInfo)
- {
- __pCachedWordWidthInfoNode = pReturnWordWidthInfoNode;
- }
- }
- else
- {
- TextSimpleList::InsertObjectBeforeNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode,
- pNewSymbolTextWidthInfo);
- }
-
- getDone = true;
- }
- break;
-
- default:
- return false;
- }
-
- if (limitWidth <= 0)
- {
- break;
- }
-
- if (getDone)
- {
- break;
- }
-
- if (currentLength <= 0)
- {
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- currentLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex;
- }
- }
-
- if (pCurrentUnknowTextWidthInfo->length == 0)
- {
- TextSimpleList::DeleteNode(__pTextWidthInfoList, pCurrentWordWidthInfoNode);
- }
-
- return pReturnWordWidthInfoNode;
-}
-
-bool
-TextWidthManager::AnalyzeNextTextWidthInfo(int limitWidth, bool& wordoverWidth, int& widthAnlyzed, int& strLengthAalyzed,
- int& heightAnalzyed, bool& isnextKorean, bool& meetCutlink)
-{
- widthAnlyzed = 0;
- strLengthAalyzed = 0;
- heightAnalzyed = 0;
- wordoverWidth = false;
- isnextKorean = false;
-
- TextWidthCommonInfo* pCurrentCommonTextWidthInfo = static_cast < TextWidthCommonInfo* >(__pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentCommonTextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- int strCurrentTextWidthInfoLength = GetTextWidthInfoLength(pCurrentCommonTextWidthInfo);
-
- SimpleNode* pCurrentWordWidthInfoNode = __pCurrentWordWidthInfoNode->pNext;
- if (pCurrentWordWidthInfoNode == null)
- {
- return false;
- }
-
- pCurrentCommonTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentCommonTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- TextElement* pTextElement = __pCurrentComposeTextElement;
- int textElementIndex = __currentComposeTextElementIndex;
- int strSrcRelIndex = __strCurrentRelIndex;
- int strTextElementLength = __currentTextElementLength;
-
- int seekLength = strCurrentTextWidthInfoLength;
-
- while (seekLength > 0)
- {
- if (seekLength < strTextElementLength)
- {
- strSrcRelIndex += seekLength;
- strTextElementLength -= seekLength;
- break;
- }
-
- seekLength -= strTextElementLength;
-
- if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
- {
- meetCutlink = true;
-
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- break;
- }
-
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- strTextElementLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex;
-
- if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
- {
- meetCutlink = true;
- break;
- }
- }
-
- int widthAnalyzed = 0;
- int maxHeight = 0;
- int stringAnalzyed = 0;
- int widthLeft = limitWidth;
-
- int type = pCurrentCommonTextWidthInfo->type;
-
- while (((type == TEXT_WIDTH_INFO_WORD) || (type == TEXT_WIDTH_INFO_UNKNOWN)) && !meetCutlink)
- {
- SysTryReturn(NID_GRP
- , pTextElement
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- int stringtoGo = 0;
- if (type == TEXT_WIDTH_INFO_WORD)
- {
- WordTextWidthInfo* pWordTtextWidthInfo = static_cast < WordTextWidthInfo* >(pCurrentCommonTextWidthInfo);
- SysTryReturn(NID_GRP
- , pWordTtextWidthInfo
- , false, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- if (widthLeft < pWordTtextWidthInfo->width)
- {
- if ((widthLeft <= 0) || (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK))
- {
- wordoverWidth = true;
- break;
- }
-
- int textLengthBeforeSplit = GetTextWidthInfoLength(static_cast < TextWidthCommonInfo* >(pCurrentWordWidthInfoNode->pObject));
- pWordTtextWidthInfo = SplitWordWidthInfo(pCurrentWordWidthInfoNode, pTextElement, strSrcRelIndex,
- strTextElementLength, widthLeft, isnextKorean);
-
- if (textLengthBeforeSplit != pWordTtextWidthInfo->length)
- {
- widthAnalyzed += pWordTtextWidthInfo->width;
- stringAnalzyed += pWordTtextWidthInfo->length;
- if (pWordTtextWidthInfo->maxHeight > maxHeight)
- {
- maxHeight = pWordTtextWidthInfo->maxHeight;
- }
- }
-
- wordoverWidth = true;
- break;
- }
- else
- {
- widthAnalyzed += pWordTtextWidthInfo->width;
- widthLeft -= pWordTtextWidthInfo->width;
- stringAnalzyed += pWordTtextWidthInfo->length;
- if (pWordTtextWidthInfo->maxHeight > maxHeight)
- {
- maxHeight = pWordTtextWidthInfo->maxHeight;
- }
-
- stringtoGo = pWordTtextWidthInfo->length;
- }
- }
- else
- {
- SimpleNode* pNewSimpleNode = AnalyzeUnKnownTextWidthInfo(pCurrentWordWidthInfoNode, pTextElement,
- strSrcRelIndex, strTextElementLength, widthLeft);
-
- SysTryReturn(NID_GRP
- , pNewSimpleNode
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element node.");
-
- pCurrentWordWidthInfoNode = pNewSimpleNode;
- pCurrentCommonTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentCommonTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- type = pCurrentCommonTextWidthInfo->type;
- }
-
- if (stringtoGo > 0)
- {
- pCurrentWordWidthInfoNode = pCurrentWordWidthInfoNode->pNext;
- if (pCurrentWordWidthInfoNode == null)
- {
- break;
- }
-
- pCurrentCommonTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentWordWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentCommonTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element node.");
-
- type = pCurrentCommonTextWidthInfo->type;
-
- seekLength = stringtoGo;
-
- while (seekLength > 0)
- {
- if (seekLength < strTextElementLength)
- {
- strSrcRelIndex += seekLength;
- strTextElementLength -= seekLength;
- break;
- }
-
- seekLength -= strTextElementLength;
-
- if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
- {
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- if (pTextElement == null)
- {
- break;
- }
-
- meetCutlink = true;
- break;
- }
-
- textElementIndex++;
- pTextElement = __pCompositeText->GetElementAtElementIndex(textElementIndex);
- SysTryReturn(NID_GRP
- , pTextElement
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text element.");
-
- strSrcRelIndex = pTextElement->GetValue(SET_TEXT_OFFSET);
- strTextElementLength = pTextElement->GetValue(SET_TEXT_OFFSET) + pTextElement->GetTextLength() - strSrcRelIndex;
-
- if (pTextElement->GetType() == TEXT_ELEMENT_TYPE_CUTLINK)
- {
- meetCutlink = true;
- break;
- }
- }
- }
- }
-
- widthAnlyzed = widthAnalyzed;
- strLengthAalyzed = stringAnalzyed;
- heightAnalzyed = maxHeight;
-
- return true;
-}
-
-bool
-TextWidthManager::UpdateCachedTextWidhtInfo(int textOffset, SimpleNode* pTextWidthInfoNode)
-{
- __pCachedWordWidthInfoNode = pTextWidthInfoNode;
- __textOffsetOfCachedWidthInfo = textOffset;
-
- return true;
-}
-
-SimpleNode*
-TextWidthManager::SearchTextWidthInfo(int textIndex, int& widthInfoTextOffset)
-{
- SimpleNode* pCurrentTextWidthInfoNode = __pCachedWordWidthInfoNode;
- int currentWidthInfoTextOffset = __textOffsetOfCachedWidthInfo;
-
- if (pCurrentTextWidthInfoNode == null)
- {
- pCurrentTextWidthInfoNode = TextSimpleList::GetNthNode(__pTextWidthInfoList, 0);
- currentWidthInfoTextOffset = 0;
- }
-
- if (pCurrentTextWidthInfoNode == null)
- {
- widthInfoTextOffset = 0;
- return null;
- }
-
- TextWidthCommonInfo* pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- if (currentWidthInfoTextOffset < textIndex)
- {
- int currentWidthInfoTextLength = GetTextWidthInfoLength(pCurrentTextWidthInfo);
-
- while (currentWidthInfoTextOffset + currentWidthInfoTextLength <= textIndex)
- {
- pCurrentTextWidthInfoNode = pCurrentTextWidthInfoNode->pNext;
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfoNode
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width.");
-
- currentWidthInfoTextOffset += currentWidthInfoTextLength;
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width information.");
-
- currentWidthInfoTextLength = GetTextWidthInfoLength(pCurrentTextWidthInfo);
- }
- }
- else if (textIndex < currentWidthInfoTextOffset)
- {
- pCurrentTextWidthInfoNode = pCurrentTextWidthInfoNode->pPrev;
-
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfoNode
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width.");
-
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width.");
-
- currentWidthInfoTextOffset -= GetTextWidthInfoLength(pCurrentTextWidthInfo);
-
- while (textIndex < currentWidthInfoTextOffset)
- {
- pCurrentTextWidthInfoNode = pCurrentTextWidthInfoNode->pPrev;
-
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfoNode
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width.");
-
- pCurrentTextWidthInfo = static_cast < TextWidthCommonInfo* >(pCurrentTextWidthInfoNode->pObject);
- SysTryReturn(NID_GRP
- , pCurrentTextWidthInfo
- , null, E_SYSTEM, "[E_SYSTEM] Fail to get text width.");
-
- currentWidthInfoTextOffset -= GetTextWidthInfoLength(pCurrentTextWidthInfo);
- }
- }
-
- widthInfoTextOffset = currentWidthInfoTextOffset;
-
- return pCurrentTextWidthInfoNode;
-}
-
-bool
-TextWidthManager::IsKorean(wchar_t ch)
-{
- bool r = false;
-
- if (0xAC00 <= ch && ch <= 0xD7A3)
- {
- r = true;
- }
- else if (0x3130 <= ch && ch <= 0x318F)
- {
- r = true;
- }
- else if (0x1100 <= ch && ch <= 0x11FF)
- {
- r = true;
- }
- else if (0X2E80 <= ch && ch <= 0x2FFF)
- {
- r = true;
- }
- else if (0x3220 <= ch && ch <= 0x3243)
- {
- r = true;
- }
- else if (0x3280 <= ch && ch <= 0x32CB)
- {
- r = true;
- }
- else if (0x3400 <= ch && ch <= 0x4DBF)
- {
- r = true;
- }
- else if (0x4E00 <= ch && ch <= 0x9FFF)
- {
- r = true;
- }
- else if (0xF900 <= ch && ch <= 0xFAFF)
- {
- r = true;
- }
-
- return r;
-}
-
-}}} // Tizen::Graphics::_Text