rollback about nonewrap
authorYunji Park <yunji19.park@samsung.com>
Thu, 30 May 2013 14:50:56 +0000 (23:50 +0900)
committerYunji Park <yunji19.park@samsung.com>
Thu, 30 May 2013 14:50:56 +0000 (23:50 +0900)
Change-Id: If27ec355fdc40b1e5394c69796cfdf42dfcaa499

src/graphics/inc/FGrp_TextTextObject.h
src/graphics/text/FGrp_TextTextColumn.cpp
src/graphics/text/FGrp_TextTextColumn.h
src/graphics/text/FGrp_TextTextComposite.cpp
src/graphics/text/FGrp_TextTextComposite.h
src/graphics/text/FGrp_TextTextObject.cpp

index dfba180..b5ac97d 100644 (file)
@@ -357,14 +357,6 @@ public:
 
        TextBidiHint GetTextBidiHint(void) const;
 
-       result SetFirstDisplayPositionX(int x);
-
-       result SetFirstDisplayPositionX(float x);
-
-       int GetFirstDisplayPositionX(void) const;
-
-       float GetFirstDisplayPositionXF(void) const;
-
 private:
        result DrawByLine(_CanvasImpl& canvasImpl, const Rectangle& displayRect);
 
index dfb7948..c2e2991 100644 (file)
@@ -51,7 +51,6 @@ TextColumn::TextColumn(TextComposite* pCompositeText)
        __displayLineCount = 0;
        __firstDisplayLineIndex = 0;
        __firstDisplayPositionY = -1;
-       __firstDisplayPositionX = -1;
        __displayHeight = -1;
        __slidingPosition = 0;
        __pCompositeText = pCompositeText;
@@ -199,11 +198,6 @@ TextColumn::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int start
                __displayHeight -= __firstDisplayPositionY - lineBounds.y;
        }
 
-       if (__firstDisplayPositionX > 0)
-       {
-               displayRect.x -= __firstDisplayPositionX;
-       }
-
        while (pTextLineNode != null && 0 <= displayRect.height)
        {
                if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
@@ -224,11 +218,6 @@ TextColumn::Draw(_CanvasImpl& canvasImpl, FloatRectangle& displayRect, int start
                                {
                                        lineAction = TEXT_OBJECT_ACTION_TYPE_ABBREV;
                                }
-
-                               if (displayRect.width < lineBounds.width)
-                               {
-                                       lineAction = TEXT_OBJECT_ACTION_TYPE_ABBREV;
-                               }
                        }
                        else
                        {
@@ -1680,18 +1669,6 @@ TextColumn::GetFirstDisplayPositionYF(void) const
 }
 
 void
-TextColumn::SetFirstDisplayPositionX(float x)
-{
-       __firstDisplayPositionX = x;
-}
-
-float
-TextColumn::GetFirstDisplayPositionX(void) const
-{
-       return __firstDisplayPositionX;
-}
-
-void
 TextColumn::SetDisplayHeight(int height)
 {
        __displayHeight = _CoordinateSystemUtils::ConvertToFloat(height);
index 1b08256..2606bb3 100644 (file)
@@ -143,10 +143,6 @@ public:
 
        float GetFirstDisplayPositionYF(void) const;
 
-       void SetFirstDisplayPositionX(float x);
-
-       float GetFirstDisplayPositionX(void) const;
-
        int GetTextLengthAt(int lineIndex) const;
 
        int GetFirstTextIndexAt(int lineIndex) const;
@@ -246,7 +242,6 @@ private:
        int __totalLineCount;
        int __firstDisplayLineIndex;
        float __firstDisplayPositionY;
-       float __firstDisplayPositionX;
        int __displayLineCount;
        float __displayHeight;
        Tizen::Graphics::FloatDimension __slidingDimension;
index 7ddb9d4..d872047 100644 (file)
@@ -1872,6 +1872,7 @@ TextComposite::DrawLine(_CanvasImpl& canvasImpl, TextLine* pTextLine, const Floa
        pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
 
        adjustedRect = displayRect;
+       adjustedRect.width = lineBounds.width;
        adjustedRect.height = lineBounds.height;
 
        if (action == TEXT_OBJECT_ACTION_TYPE_ABBREV)
@@ -3951,30 +3952,201 @@ TextComposite::ComposeInNoneWrap(FloatRectangle& rect, NoneWrapComposeInfo* pNon
 {
        SysTryReturn(NID_GRP, __pCurrentTextColumn, -1, E_INVALID_STATE, "[E_INVALID_STATE] This instance is not constructed yet.");
 
-       TextLine* pTextLine = new (std::nothrow)TextLine(this);
-       SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
-
+       TextLine* pTextLine = null;
        FloatRectangle lineBounds;
-       FloatDimension lineTextSize;
-       int lineLength = __length;
+       FloatDimension textSize;
+       int lineOffset = 0;
+       int lineLength = 0;
+       int endType = TEXT_RETBY_NORMAL;
+       bool isChanged = false;
        float baseline = 0;
+       int textIndex = 0;
+
+       textIndex = (__workStart < 0) ? 0 : __workStart;
+       textIndex = (textIndex > __length) ? __length : textIndex;
+       bool forwardSearch = (textIndex == __length) ? false : true;
+
+       if (__pCurrentTextColumn->GetTotalLineCount() > 0)
+       {
+               pTextLine = __pCurrentTextColumn->GetTextLine(0);
+               SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
+
+               lineBounds = pTextLine->GetBoundsF();
+               endType = pTextLine->GetEndType();
+
+               if (lineBounds.width != rect.width)
+               {
+                       isChanged = true;
+               }
+
+               lineOffset = pTextLine->GetTextOffset();
+               lineLength = pTextLine->GetTextLength();
+
+               if (lineOffset <= textIndex && textIndex < lineOffset + lineLength)
+               {
+                       isChanged = true;
+               }
+       }
+       else
+       {
+               pTextLine = new (std::nothrow)TextLine(this);
+               SysTryReturn(NID_GRP, pTextLine, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
+
+               if (forwardSearch)
+               {
+                       if (pNoneWrapComposeInfo != null)
+                       {
+                               lineOffset = pNoneWrapComposeInfo->prevTextOffset;
+                       }
+                       else
+                       {
+                               lineOffset = 0;
+                       }
+               }
+               else
+               {
+                       lineOffset = __length - 1;
+               }
+
+               lineLength = 0;
+               lineBounds.width = rect.width;
+               lineBounds.x = 0;
+               lineBounds.y = 0;
+               lineBounds.height = 0;
+
+               __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
+
+               isChanged = true;
+       }
+
+       if (isChanged)
+       {
+               lineBounds.width = rect.width;
+               lineBounds.x = 0;
+               lineBounds.y = 0;
+
+               if (forwardSearch)
+               {
+                       endType = ForwardAnalyzeWithBaseline(lineOffset, __length - lineOffset, lineBounds.width, __wrap,
+                                                                         lineLength, textSize.width, textSize.height, baseline);
+
+                       lineBounds.height = textSize.height;
+                       pTextLine->SetBounds(lineBounds);
+                       pTextLine->SetTextOffset(lineOffset);
+                       pTextLine->SetTextLength(lineLength);
+                       pTextLine->SetRegion(textSize.width, textSize.height);
+                       pTextLine->SetEndType(endType);
+                       pTextLine->SetBaseline(baseline);
+                       GetTextExtentList(pTextLine);
+               }
+               else
+               {
+                       int textCount = 0;
 
-       GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
+                       BackwardAnalyze(lineOffset, lineBounds.width, &textCount, &textSize.width, &textSize.height);
 
-       lineBounds.width = (rect.width < lineTextSize.width) ? lineTextSize.width :rect.width;
-       lineBounds.height = lineTextSize.height;
-       baseline = lineBounds.height / 3.0f;
+                       lineBounds.height = textSize.height;
+                       lineOffset -= (textCount - 1);
+                       lineLength = textCount;
+                       endType = (lineOffset == 0) ? TEXT_RETBY_NORMAL : TEXT_RETBY_LIMITWIDTH;
+
+                       pTextLine->SetBounds(lineBounds);
+                       pTextLine->SetTextOffset(lineOffset);
+                       pTextLine->SetTextLength(lineLength);
+                       pTextLine->SetRegion(textSize.width, textSize.height);
+                       pTextLine->SetEndType(endType);
+                       pTextLine->SetBaseline(baseline);
+                       GetTextExtentList(pTextLine);
+               }
+       }
+
+       if (__length == 0)
+       {
+               pTextLine->SetEndType(TEXT_RETBY_NORMAL);
+               return 1;
+       }
+
+       rect.height = lineBounds.height;
+
+       if (textIndex < lineOffset)
+       {
+               lineOffset = textIndex;
+               endType = ForwardAnalyze(lineOffset, __length - lineOffset, lineBounds.width, __wrap,
+                                                                 lineLength, textSize.width, textSize.height);
+
+               lineBounds.height = textSize.height;
+       }
+       else if (forwardSearch && textIndex >= lineOffset + lineLength)
+       {
+               FloatDimension needDim;
+               GetRegion(lineOffset + lineLength, textIndex - (lineOffset + lineLength) + 1, needDim.width, needDim.height);
+
+               int index = 0;
+               float remainingWidth = needDim.width - (lineBounds.width - textSize.width);
+
+               FloatDimension charDim;
+               textSize.width += needDim.width;
+               lineLength += textIndex - (lineOffset + lineLength) + 1;
+
+               while (1)
+               {
+                       GetRegion(lineOffset, 1, charDim.width, charDim.height);
+                       lineOffset++;
+                       index++;
+                       remainingWidth -= charDim.width;
+                       textSize.width -= charDim.width;
+
+                       if (remainingWidth <= 0)
+                       {
+                               break;
+                       }
+               }
+
+               lineLength -= index;
+       }
+       else if (endType != TEXT_RETBY_LIMITWIDTH && lineLength != __length)
+       {
+               if (lineOffset > 0)
+               {
+                       FloatDimension lineTextSize;
+                       int textCount = 0;
+                       float remainingWidth = 0;
+
+                       pTextLine->GetRegion(0, lineLength, lineTextSize.width, lineTextSize.height);
+                       remainingWidth = lineBounds.width - lineTextSize.width;
+                       BackwardAnalyze(lineOffset - 1, remainingWidth, &textCount, &textSize.width, &textSize.height);
+
+                       if (textSize.width > 0)
+                       {
+                               lineOffset -= textCount;
+                               lineLength += textCount;
+                               textSize.width += lineTextSize.width;
+                               lineBounds.height = textSize.height;
+                               endType = TEXT_RETBY_LIMITLENGTH;
+                       }
+                       else
+                       {
+                               return 1;
+                       }
+               }
+               else
+               {
+                       return 1;
+               }
+       }
+       else
+       {
+               return 1;
+       }
 
        pTextLine->SetBounds(lineBounds);
-       pTextLine->SetRegion(lineTextSize.width, lineTextSize.height);
-       pTextLine->SetTextOffset(0);
+       pTextLine->SetRegion(textSize.width, textSize.height);
        pTextLine->SetTextLength(lineLength);
-       pTextLine->SetEndType(TEXT_RETBY_NORMAL);
+       pTextLine->SetTextOffset(lineOffset);
+       pTextLine->SetEndType(endType);
        pTextLine->SetBaseline(baseline);
        GetTextExtentList(pTextLine);
 
-       __pCurrentTextColumn->AddLineDuringCompose(pTextLine);
-
        return 1;
 }
 
@@ -4791,7 +4963,8 @@ TextComposite::ComposeInNoneWrapMiddleEllipsis(FloatRectangle& rect)
 
        maxHeight = textSize.height;
 
-       BackwardAnalyze(__length - 1, lineBounds.width - __middleEllipsisWidth - __middleEllipsisHeadWidth, length, textSize.width, textSize.height);
+       ForwardAnalyze(__middleEllipsisTextLengthInHead, __length - __middleEllipsisTextLengthInHead, lineBounds.width - __middleEllipsisWidth -
+                                  __middleEllipsisHeadWidth, __wrap, length, textSize.width, textSize.height);
 
        __middleEllipsisTextLengthInTail = length;
        maxHeight = (maxHeight < textSize.height) ? textSize.height : maxHeight;
@@ -4859,8 +5032,7 @@ TextComposite::ComposeInNoneWrapHeadEllipsis(FloatRectangle& rect)
        __pAbbrevTextElement->GetRegion(0, 1, abbrevTextDim.width, abbrevTextDim.height);
        __headEllipsisWidth = abbrevTextDim.width;
 
-       BackwardAnalyze(__length - 1, lineBounds.width - abbrevTextDim.width, __headEllipsisTextLength, textSize.width, textSize.height);
-
+       BackwardAnalyze(__length - 1, lineBounds.width - abbrevTextDim.width, &__headEllipsisTextLength, &textSize.width, &textSize.height);
        maxHeight = textSize.height;
 
        TextLine* pTextLine = new (std::nothrow)TextLine(this);
@@ -4938,15 +5110,15 @@ TextComposite::GetValue(int textIndex, TextComponentInfoValueType type, unsigned
 }
 
 bool
-TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLength, float& width, float& height)
+TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int* actualLength, float* width, float* height)
 {
        float remainingWidth = 0;
        int length = 0;
        FloatDimension textSize;
 
-       actualLength = 0;
-       width = 0;
-       height = 0;
+       *actualLength = 0;
+       *width = 0;
+       *height = 0;
 
        remainingWidth = maxWidth;
        length = 1;
@@ -4957,9 +5129,9 @@ TextComposite::BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLe
 
                if (textSize.width <= remainingWidth)
                {
-                       actualLength = length;
-                       width = textSize.width;
-                       height = textSize.height;
+                       *actualLength = length;
+                       *width = textSize.width;
+                       *height = textSize.height;
                }
 
                startTextIndex--;
index af6f58c..562f37f 100644 (file)
@@ -301,7 +301,7 @@ private:
 
        int ComposeInPartialMode(FloatRectangle& rect);
 
-       bool BackwardAnalyze(int startTextIndex, float maxWidth, int& actualLength, float& width, float& height);
+       bool BackwardAnalyze(int startTextIndex, float maxWidth, int* actualLength, float* width, float* height);
 
        result DrawAbbrevInMiddleEllipsis(_CanvasImpl& canvasImpl, const FloatRectangle& displayRect, const TextObjectAlignment alignment);
 
index c921346..c9bfe05 100644 (file)
@@ -730,7 +730,6 @@ TextObject::Compose(void)
                __pTextColumn->SetChangeAction(TextColumn::TEXT_CHANGE_UNKONWN, 0, 0);
                __pTextColumn->SetFirstDisplayLineIndex(0);
                __pTextColumn->SetFirstDisplayPositionY(0.0f);
-               __pTextColumn->SetFirstDisplayPositionX(0.0f);
        }
 
        ResetSweepInfo();
@@ -743,11 +742,10 @@ TextObject::Compose(void)
                TextLine* pTextLine = __pTextColumn->GetTextLine(0);
                if (pTextLine != null)
                {
-                       FloatRectangle lineBounds = pTextLine->GetBoundsF();
                        int lineLength = pTextLine->GetTextLength();
                        int totalLength = __pCompositeText->GetTextLength();
 
-                       if (lineLength < totalLength || __rect.width < lineBounds.width)
+                       if (lineLength < totalLength)
                        {
                                __isActionOn = true;
                                __pTextColumn->SetSlidingPosition(0.0f);
@@ -892,53 +890,6 @@ CATCH:
 }
 
 result
-TextObject::SetFirstDisplayPositionX(int x)
-{
-       return SetFirstDisplayPositionX(_CoordinateSystemUtils::ConvertToFloat(x));
-}
-
-result
-TextObject::SetFirstDisplayPositionX(float x)
-{
-       IF_NOT_CONSTRUCTED(return E_INVALID_STATE);
-       SysTryReturn(NID_GRP, __wrap == TEXT_OBJECT_WRAP_TYPE_NONE
-               , E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] The argument is invalid.");
-
-       TextLine* pTextLine = __pTextColumn->GetTextLine(0);
-       SysTryReturn(NID_GRP, pTextLine, -1, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
-
-       FloatRectangle lineBounds = pTextLine->GetBoundsF();
-
-       if (x < 0)
-       {
-               x = 0;
-       }
-
-       if (lineBounds.width - __rect.width < x)
-       {
-               x = lineBounds.width - __rect.width;
-       }
-
-       __pTextColumn->SetFirstDisplayPositionX(x);
-
-       return E_SUCCESS;
-}
-
-int
-TextObject::GetFirstDisplayPositionX(void) const
-{
-       return _CoordinateSystemUtils::ConvertToInteger(GetFirstDisplayPositionXF());
-}
-
-float
-TextObject::GetFirstDisplayPositionXF(void) const
-{
-       IF_NOT_CONSTRUCTED(return -1);
-
-       return __pTextColumn->GetFirstDisplayPositionX();
-}
-
-result
 TextObject::SetFirstDisplayPositionY(int y)
 {
        return SetFirstDisplayPositionY(_CoordinateSystemUtils::ConvertToFloat(y));
@@ -3421,7 +3372,6 @@ TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, float& width, float&
        SysTryReturn(NID_GRP, pTextLine, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Fail to get text line.");
 
        int lineLength = pTextLine->GetTextLength();
-       float firstDisplayPositionX = __pTextColumn->GetFirstDisplayPositionX();
        float posX = 0.0f;
        float posY = 0.0f;
 
@@ -3499,7 +3449,7 @@ TextObject::GetTextPositionInfoInNoneWrapAt(int textIndex, float& width, float&
                break;
        }
 
-       absX = posX + textExtent.x - firstDisplayPositionX;
+       absX = posX + textExtent.x;
        logicalX = (absX >= 0.0f) ? absX + __rect.x : absX;
        absY = posY;
        logicalY = absY + __rect.y;