-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2014 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 HEADER
+#include <dali-toolkit/internal/controls/text-view/text-view-processor-helper-functions.h>
// INTERNAL INCLUDES
-#include "text-view-processor-helper-functions.h"
-#include "text-view-processor-dbg.h"
+#include <dali-toolkit/internal/controls/text-view/text-view-processor-dbg.h>
namespace Dali
{
const TextLayoutInfo& textLayoutInfo,
TextInfoIndices& indices )
{
- // TODO : Check for mixed LTR and RTL.
-
// clear all indices
indices = TextInfoIndices();
return;
}
- std::size_t currentIndex = 0; // stores how many characters have been traversed.
+ std::size_t currentIndex = 0u; // stores how many characters have been traversed (within the whole text).
- // Traverse all lines, groups of words and words until global index is found.
+ // Traverse all lines and words until global index is found.
bool found = false;
for( LineLayoutInfoContainer::const_iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(),
lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
if( currentIndex + lineLayoutInfo.mNumberOfCharacters > index )
{
// The character is in this line
- for( WordGroupLayoutInfoContainer::const_iterator groupIt = lineLayoutInfo.mWordGroupsLayoutInfo.begin(),
- groupEndIt = lineLayoutInfo.mWordGroupsLayoutInfo.end();
- ( !found ) && ( groupIt != groupEndIt );
- ++groupIt, ++indices.mGroupIndex )
+ for( WordLayoutInfoContainer::const_iterator wordIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
+ wordEndIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ ( !found ) && ( wordIt != wordEndIt );
+ ++wordIt, ++indices.mWordIndex )
{
- const WordGroupLayoutInfo& wordGroupLayoutInfo( *groupIt );
+ const WordLayoutInfo& wordLayoutInfo( *wordIt );
- if( currentIndex + wordGroupLayoutInfo.mNumberOfCharacters > index )
+ if( currentIndex + wordLayoutInfo.mCharactersLayoutInfo.size() > index )
{
- // The character is in this group of words.
- for( WordLayoutInfoContainer::const_iterator wordIt = wordGroupLayoutInfo.mWordsLayoutInfo.begin(),
- wordEndIt = wordGroupLayoutInfo.mWordsLayoutInfo.end();
- ( !found ) && ( wordIt != wordEndIt );
- ++wordIt, ++indices.mWordIndex )
- {
- const WordLayoutInfo& wordLayoutInfo( *wordIt );
-
- if( currentIndex + wordLayoutInfo.mCharactersLayoutInfo.size() > index )
- {
- // The character is in this word
- indices.mCharacterIndex = index - currentIndex;
- found = true;
- }
- else
- {
- // check in the next word.
- currentIndex += wordLayoutInfo.mCharactersLayoutInfo.size();
- }
- } // end words.
- if( !wordGroupLayoutInfo.mWordsLayoutInfo.empty() )
- {
- --indices.mWordIndex;
- }
+ // The character is in this word
+ indices.mCharacterIndex = index - currentIndex;
+ found = true;
}
else
{
- // check in the next group of words
- currentIndex += wordGroupLayoutInfo.mNumberOfCharacters;
+ // check in the next word.
+ currentIndex += wordLayoutInfo.mCharactersLayoutInfo.size();
}
- } // end groups of words.
- if( !lineLayoutInfo.mWordGroupsLayoutInfo.empty() )
+ } // end words.
+ if( !lineLayoutInfo.mWordsLayoutInfo.empty() )
{
- --indices.mGroupIndex;
+ --indices.mWordIndex;
}
}
else