X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fmarkup-processor-strikethrough.cpp;h=10e104cde6ee16ae02dcd2456abb20d928e325f8;hb=16561908a5e0e9bbef2aa11c9cdc3a27aeb1bd54;hp=9282121e3533d6b6b3a5115cbbc15e0cf1e64521;hpb=04194fd795542d80b5cf7c1b954ca14593e536d4;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/markup-processor-strikethrough.cpp b/dali-toolkit/internal/text/markup-processor-strikethrough.cpp index 9282121..10e104c 100644 --- a/dali-toolkit/internal/text/markup-processor-strikethrough.cpp +++ b/dali-toolkit/internal/text/markup-processor-strikethrough.cpp @@ -22,7 +22,9 @@ #include // INTERNAL INCLUDES +#include #include +#include #include namespace Dali @@ -31,9 +33,17 @@ namespace Toolkit { namespace Text { -namespace +void ProcessColorAttribute(const Attribute& attribute, StrikethroughCharacterRun& strikethroughRun) + { -const std::string XHTML_COLOR_ATTRIBUTE("color"); + ColorStringToVector4(attribute.valueBuffer, attribute.valueLength, strikethroughRun.properties.color); + strikethroughRun.properties.colorDefined = true; +} + +void ProcessHeightAttribute(const Attribute& attribute, StrikethroughCharacterRun& strikethroughRun) +{ + strikethroughRun.properties.height = ProcessFloatAttribute(attribute); + strikethroughRun.properties.heightDefined = true; } void ProcessStrikethroughTag(const Tag& tag, StrikethroughCharacterRun& strikethroughRun) @@ -44,10 +54,52 @@ void ProcessStrikethroughTag(const Tag& tag, StrikethroughCharacterRun& striketh ++it) { const Attribute& attribute(*it); - if(TokenComparison(XHTML_COLOR_ATTRIBUTE, attribute.nameBuffer, attribute.nameLength)) + + if(TokenComparison(MARKUP::STRIKETHROUGH_ATTRIBUTES::COLOR, attribute.nameBuffer, attribute.nameLength)) + { + ProcessColorAttribute(attribute, strikethroughRun); + } + else if(TokenComparison(MARKUP::STRIKETHROUGH_ATTRIBUTES::HEIGHT, attribute.nameBuffer, attribute.nameLength)) + { + ProcessHeightAttribute(attribute, strikethroughRun); + } + } +} + +void OverrideNestedStrikethroughCharacterRuns(Vector& strikethroughCharacterRuns) +{ + // Handle nested tags + // The inner tag inherit the attributes of the outer tag and override them when defined in the inner tag. + // Example: + // outer tag before inner tag outer tag after + // "outer tag before" and "outer tag after" have height = 5.0f and color = 'blue' + // "inner tag" has height = 5.0f and color = 'green' + + if(strikethroughCharacterRuns.Count() > 0u) + { + Vector::ConstIterator preIt = strikethroughCharacterRuns.Begin(); + + Vector::Iterator it = strikethroughCharacterRuns.Begin() + 1; + Vector::ConstIterator endIt = strikethroughCharacterRuns.End(); + + while(it != endIt) { - strikethroughRun.isColorSet = true; - ColorStringToVector4(attribute.valueBuffer, attribute.valueLength, strikethroughRun.color); + const StrikethroughCharacterRun& run = *it; + const CharacterIndex& characterIndex = run.characterRun.characterIndex; + const Length& numberOfCharacters = run.characterRun.numberOfCharacters; + + const StrikethroughCharacterRun& preRun = *preIt; + const CharacterIndex& preCharacterIndex = preRun.characterRun.characterIndex; + const Length& preNumberOfCharacters = preRun.characterRun.numberOfCharacters; + + if((preCharacterIndex <= characterIndex) && + ((characterIndex + numberOfCharacters) <= (preCharacterIndex + preNumberOfCharacters))) + { + it->properties.CopyIfNotDefined(preIt->properties); + } + + it++; + preIt++; } } }