std::string input;
std::size_t wordIndex;
std::size_t characterIndex;
+ std::size_t characterParagraphIndex;
float lineHeightOffset;
std::string firstResult;
std::string lastResult;
{
std::cout << "[" << textActor.GetText() << "]";
}
- else
- {
- std::cout << "{" << character.mStyledText.mText.GetText() << "}";
- }
}
void Print( const TextViewProcessor::WordLayoutInfo& word )
std::cout << "||" << std::endl;
}
-std::string GetText( const TextViewProcessor::CharacterLayoutInfo& character )
-{
- return character.mStyledText.mText.GetText();
-}
-
-std::string GetText( const TextViewProcessor::WordLayoutInfo& word )
+std::string GetText( const TextViewProcessor::WordLayoutInfo& word, const Text& paragraphText )
{
- std::string text;
+ Text text;
- for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it = word.mCharactersLayoutInfo.begin(), endIt = word.mCharactersLayoutInfo.end(); it != endIt; ++it )
- {
- text += GetText( *it );
- }
+ paragraphText.GetSubText( word.mFirstCharacter, word.mFirstCharacter + word.mCharactersLayoutInfo.size() - 1u, text );
- return text;
+ return text.GetText();
}
std::string GetText( const TextViewProcessor::ParagraphLayoutInfo& paragraph )
for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it )
{
- text += GetText( *it );
+ text += GetText( *it, paragraph.mText );
}
return text;
return false;
}
- text1 = character1.mStyledText.mText.GetText();
- style1 = character1.mStyledText.mStyle;
-
- text2 = character2.mStyledText.mText.GetText();
- style2 = character2.mStyledText.mStyle;
-
- if( text1 != text2 )
- {
- return false;
- }
-
- if( style1 != style2 )
- {
- std::cout << " style1 : " << std::endl;
- TextViewProcessor::dbgPrint( style1 );
-
- std::cout << " style2 : " << std::endl;
- TextViewProcessor::dbgPrint( style2 );
- return false;
- }
-
return true;
}
* @param input The input word.
* @param wordIndex Index to the word within the paragraph where to split it.
* @param characterIndex Where to split the word.
+ * @param characterIndex Character index within the paragraph.
* @param lineHeightOffset Offset between lines.
* @param firstResult First part of the split paragraph.
* @param lastResult Last part of the split paragraph.
const std::string& input,
size_t wordIndex,
size_t characterIndex,
+ size_t characterParagraphIndex,
float lineHeightOffset,
const std::string& firstResult,
const std::string& lastResult,
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
relayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
firstRelayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..."),
true ),
lastRelayoutData );
TextViewProcessor::ParagraphLayoutInfo lastParagraphLayoutInfo;
TextViewProcessor::TextInfoIndices indices( 0, wordIndex, characterIndex );
+ indices.mCharacterParagraphIndex = characterParagraphIndex;
SplitParagraph( indices,
PointSize( lineHeightOffset ),
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
firstRelayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
lastRelayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
resultRelayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
relayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
resultRelayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
relayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true ),
resultRelayoutData );
static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
Toolkit::TextView::Center,
PointSize( lineHeightOffset ),
- std::string( "..." ),
true );
switch( operation )
layoutInfo12.mBearing = BEARING_12;
layoutInfo12.mAscender = ASCENDER_12;
- TextStyle style10;
- style10.SetFontName( "" );
- style10.SetFontPointSize( PointSize( 10.f ) );
- TextStyle style12;
- style12.SetFontName( "" );
-
- layoutInfo12.mStyledText.mStyle = style12;
- layoutInfo10.mStyledText.mStyle = style10;
-
// Words
TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
wordLayout1.mAscender = ASCENDER_12;
wordLayout1.mType = TextViewProcessor::NoSeparator;
- layoutInfo12.mStyledText.mText = Text( "H" );
wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H
- layoutInfo12.mStyledText.mText = Text( "e" );
wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e
- layoutInfo12.mStyledText.mText = Text( "l" );
wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
- layoutInfo10.mStyledText.mText = Text( "l" );
wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l
- layoutInfo10.mStyledText.mText = Text( "o" );
wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
// (white space)
wordLayout2.mSize = Size( ADVANCE_10, HEIGHT_10 );
wordLayout2.mAscender = ASCENDER_10;
wordLayout2.mType = TextViewProcessor::WordSeparator;
- layoutInfo10.mStyledText.mText = Text( " " );
wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
// world!
wordLayout3.mSize = Size( 2.f * ADVANCE_10 + 4.f * ADVANCE_12, HEIGHT_12 );
wordLayout3.mAscender = ASCENDER_12;
wordLayout3.mType = TextViewProcessor::NoSeparator;
- layoutInfo10.mStyledText.mText = Text( "w" );
wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w
- layoutInfo10.mStyledText.mText = Text( "o" );
wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
- layoutInfo12.mStyledText.mText = Text( "r" );
wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r
- layoutInfo12.mStyledText.mText = Text( "l" );
wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
- layoutInfo12.mStyledText.mText = Text( "d" );
wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d
- layoutInfo12.mStyledText.mText = Text( "!" );
wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // !
// (new paragraph character)
wordLayout4.mSize = Size( 0.f, HEIGHT_12 );
wordLayout4.mAscender = ASCENDER_12;
wordLayout4.mType = TextViewProcessor::ParagraphSeparator;
- layoutInfo12.mStyledText.mText = Text( "\n" );
layoutInfo12.mSize.width = 0.f;
wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new paragraph char)
std::string( "Hello <font size='30'>w</font>orl<font size='10'>dhello</font> world" )
},
// * Remove RTL text within LTR
- /* TODO check this when RTL text is working
{
std::string( "Remove within the same paragraph, RTL text within LTR." ),
Remove,
0.f,
std::string( "Hello worlello world" )
},
- */
// * Remove whole paragraph
{
std::string( "Remove whole paragraph" ),
std::string( "Touch <b>me\nhello\n</b>world" )
},
};
- const std::size_t numberOfTests( 21u );
+ const std::size_t numberOfTests( 22u );
for( std::size_t index = 0u; index < numberOfTests; ++index )
{
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
0,
0,
+ 0,
3.f,
std::string( "" ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
10,
4,
+ 36,
0.f,
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
std::string( "" ),
std::string("<font size='10'>Hello </font>wor<font size='12'>ld, hello wo</font>rld"),
2,
4,
+ 10,
0.f,
std::string("<font size='10'>Hello </font>wor<font size='12'>l</font>"),
std::string("<font size='12'>d, hello wo</font>rld")
- }
- /* TODO RTL
+ },
{
std::string( "Split paragraph, wordPosition 6, position 0." ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
6,
0,
+ 21,
0.f,
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום " ),
std::string( "עולם text text" ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
4,
0,
+ 17,
0.f,
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> " ),
std::string( "שלום עולם text text" ),
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
8,
0,
+ 27,
6.f,
std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם " ),
std::string( "text text" ),
},
- */
};
- const std::size_t numberOfTests( 3u );
+ const std::size_t numberOfTests( 6u );
for( std::size_t index = 0u; index < numberOfTests; ++index )
{
test.input,
test.wordIndex,
test.characterIndex,
+ test.characterParagraphIndex,
test.lineHeightOffset,
test.firstResult,
test.lastResult,
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert1 = true;
}
try
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert2 = true;
}
try
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert3 = true;
}
try
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert4 = true;
}
try
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert5 = true;
}
try
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
assert6 = true;
}
0.f,
std::string( "Hello world, this is a whole paragraph" )
},
- /* TODO RTL
{
std::string( "Merge paragraphs: last starting with RTL text and first ending with RTL" ),
std::string( "Hello world, שלום" ),
3.f,
std::string( "Hello world, שלום עולם, hello world." )
},
- */
{
std::string( "Merge paragraphs. Don't merge words" ),
std::string( "Hello world," ),
std::string( "Hello world, this is a whole paragraph" )
},
};
- const std::size_t numberOfTests( 4u );
+ const std::size_t numberOfTests( 6u );
for( std::size_t index = 0u; index < numberOfTests; ++index )
{
}
catch( Dali::DaliException& e )
{
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character.\"", TEST_LOCATION );
+ DALI_TEST_PRINT_ASSERT( e );
+ DALI_TEST_EQUALS( e.condition, "!\"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character.\"", TEST_LOCATION );
assert1 = true;
}