X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Fpublic-api%2Fmarkup-processor%2Fmarkup-processor.cpp;h=ed4cc57cc3c825534acde5e1c7e6b23505fd23f4;hb=refs%2Fchanges%2F50%2F19450%2F1;hp=41a070e9d5149a6a920aad74e088b43dfbba31d9;hpb=cf2dd988cd7f7154208f1ffe9257f81df698cee6;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/public-api/markup-processor/markup-processor.cpp b/dali-toolkit/public-api/markup-processor/markup-processor.cpp index 41a070e..ed4cc57 100644 --- a/dali-toolkit/public-api/markup-processor/markup-processor.cpp +++ b/dali-toolkit/public-api/markup-processor/markup-processor.cpp @@ -542,10 +542,52 @@ bool IsTag( std::string::const_iterator& it, const std::string::const_iterator& } // namespace -void GetStyledTextArray( const std::string& markupString, StyledTextArray& styledTextArray ) +static inline bool HasMarkup( const std::string& markupString ) +{ + // Reset counters + unsigned int lessThanCount = 0; + unsigned int greaterThanCount = 0; + + // Check to see if any markup command surrounds are of equal number and not zero + for ( std::string::const_iterator it = markupString.begin(); it != markupString.end(); ++it ) + { + if ( *it == LESS_THAN ) + { + lessThanCount++; + } + else + { + if ( *it == GREATER_THAN ) + { + greaterThanCount++; + } + else + { + if ( *it == BACK_SLASH ) + { + return true; + } + } + } + } + if ( !lessThanCount || !greaterThanCount || lessThanCount != greaterThanCount ) + { + return false; + } + return true; +} + +void GetStyledTextArray( const std::string& markupString, StyledTextArray& styledTextArray, bool scanForMarkup ) { styledTextArray.clear(); + // Scan markup ( if necessary ) to see if the string contains any change in style from default? + if ( !scanForMarkup || !HasMarkup( markupString ) ) + { + styledTextArray.push_back( StyledText( Text( markupString ), TextStyle() ) ); + return; + } + TextStyle defaultStyle; std::stack styleStack;