[Tizen] Code clean up
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller.cpp
index f96c976..f7b28f9 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
+#include <dali/public-api/adaptor-framework/tts-player.h>
 #include <memory.h>
 #include <cmath>
 #include <limits>
@@ -2315,6 +2316,34 @@ void Controller::InsertText(const std::string& text, Controller::InsertType type
 
     DALI_ASSERT_DEBUG(text.size() >= utf32Characters.Count() && "Invalid UTF32 conversion length");
     DALI_LOG_INFO(gLogFilter, Debug::Verbose, "UTF8 size %d, UTF32 size %d\n", text.size(), utf32Characters.Count());
+
+    // Play the input text with the TTS player.
+    Dali::TtsPlayer player = Dali::TtsPlayer::Get(Dali::TtsPlayer::SCREEN_READER);
+    if(player)
+    {
+      if(type == COMMIT && mImpl->mEventData->mPreEditToCommitFlag)
+      {
+        if(characterCount > 1u)
+        {
+          std::string ttsText = text;
+          if(text.length() > mImpl->mEventData->mPreEditTextLength)
+          {
+            ttsText = text.substr(mImpl->mEventData->mPreEditTextLength);
+          }
+          player.Play(ttsText);
+        }
+      }
+      else
+      {
+        player.Play(text);
+      }
+    }
+  }
+
+  // PRE_EDIT type empty text is inserted before the preedit input is converted to commit.
+  if(text.empty() && type == PRE_EDIT)
+  {
+    mImpl->mEventData->mPreEditToCommitFlag = true;
   }
 
   if(0u != utf32Characters.Count()) // Check if Utf8ToUtf32 conversion succeeded
@@ -2326,6 +2355,7 @@ void Controller::InsertText(const std::string& text, Controller::InsertType type
     }
 
     mImpl->ChangeState(EventData::EDITING);
+    mImpl->mEventData->mPreEditToCommitFlag = false;
 
     // Handle the InputMethodContext (predicitive text) state changes
     if(COMMIT == type)
@@ -2343,8 +2373,9 @@ void Controller::InsertText(const std::string& text, Controller::InsertType type
         mImpl->mEventData->mPreEditStartPosition = mImpl->mEventData->mPrimaryCursorPosition;
       }
 
-      mImpl->mEventData->mPreEditLength = utf32Characters.Count();
-      mImpl->mEventData->mPreEditFlag   = true;
+      mImpl->mEventData->mPreEditLength     = utf32Characters.Count();
+      mImpl->mEventData->mPreEditTextLength = text.length();
+      mImpl->mEventData->mPreEditFlag       = true;
 
       DALI_LOG_INFO(gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", mImpl->mEventData->mPreEditStartPosition, mImpl->mEventData->mPreEditLength);
     }