|
1 /* |
|
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of the vkb data manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // system includes |
|
20 #include <peninputlayoutcontext.h> |
|
21 #include <aknfeppeninputenums.h> // ERangeHiraganaKanji, ... |
|
22 |
|
23 #include <PtiEngine.h> |
|
24 #include <PtiCompositionDataIF.h> |
|
25 #include <peninputcommonlayoutglobalenum.h> |
|
26 |
|
27 // user includes |
|
28 #include "peninputvkbdatamgr.h" |
|
29 |
|
30 // constant definition |
|
31 const TInt LengthSymbolFuncyional = 3; |
|
32 |
|
33 const TUint KSymbolsFuncyional[] = {0x309b, // dakuten(Full-width) |
|
34 0x309c, // handakuten(Full-width) |
|
35 0x5c0f}; // little |
|
36 const TUint16 KEWComma = 0x002C; |
|
37 const TUint16 KEWFullStop = 0x002E; |
|
38 const TUint16 KEWFullWidthComma = 0xFF0C; |
|
39 const TUint16 KEWFullWidthFullStop = 0xFF0E; |
|
40 const TUint16 KEWHalfWidthIdeographicComma = 0xFF64; // touten |
|
41 const TUint16 KEWHalfWidthIdeographicFullStop = 0xFF61; // kuten |
|
42 const TUint16 KEWIdeographicComma = 0x3001; // touten |
|
43 const TUint16 KEWIdeographicFullStop = 0x3002; // kuten |
|
44 const TUint KHalfDakuten = 0xff9e; |
|
45 const TUint KHalfHanDakuten = 0xff9f; |
|
46 const TUint KLittle = 0x5c0f; |
|
47 |
|
48 // ======== MEMBER FUNCTIONS ======== |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CPeninputVkbDataMgr::NewL |
|
52 // (other items were commented in a header). |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CPeninputVkbDataMgr* CPeninputVkbDataMgr::NewL(MPeninputLayoutContext* aContext) |
|
56 { |
|
57 CPeninputVkbDataMgr* self = NewLC(aContext); |
|
58 CleanupStack::Pop(self); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CPeninputVkbDataMgr::NewLC |
|
64 // (other items were commented in a header). |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CPeninputVkbDataMgr* CPeninputVkbDataMgr::NewLC(MPeninputLayoutContext* aContext) |
|
68 { |
|
69 CPeninputVkbDataMgr* self = new(ELeave) CPeninputVkbDataMgr(aContext); |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CPeninputVkbDataMgr::~CPeninputVkbDataMgr |
|
77 // (other items were commented in a header). |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CPeninputVkbDataMgr::~CPeninputVkbDataMgr() |
|
81 { |
|
82 delete iPtiEngine; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CPeninputGenericVkbDataMgr::InitMoreJpL |
|
87 // (other items were commented in a header) |
|
88 // --------------------------------------------------------------------------- |
|
89 // this method maybe Leave. this method is called by ConstructL() |
|
90 ///void CPeninputVkbDataMgr::InitMore() |
|
91 void CPeninputVkbDataMgr::InitMoreJpL() |
|
92 { |
|
93 // Create engine |
|
94 iPtiEngine = CPtiEngine::NewL(ETrue); |
|
95 iPtiEngine->ActivateLanguageL(ELangJapanese, EPtiEngineHiraganaKanjiPredictiveVkb); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CPeninputVkbDataMgr::PtiEngine |
|
100 // (other items were commented in a header). |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CPtiEngine* CPeninputVkbDataMgr::PtiEngine() |
|
104 { |
|
105 return iPtiEngine; |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CPeninputVkbDataMgr::Predictive |
|
110 // (other items were commented in a header). |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 TBool CPeninputVkbDataMgr::Predictive() const |
|
114 { |
|
115 return iPredictive; |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // CPeninputVkbDataMgr::FullHalf |
|
120 // (other items were commented in a header). |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 TInt CPeninputVkbDataMgr::FullHalf() const |
|
124 { |
|
125 return iFullHalf; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CPeninputVkbDataMgr::JapaneseFlags |
|
130 // (other items were commented in a header). |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 TInt CPeninputVkbDataMgr::JapaneseFlags() const |
|
134 { |
|
135 return iJapaneseFlags; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CPeninputVkbDataMgr::SetPermittedRange |
|
140 // (other items were commented in a header). |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CPeninputVkbDataMgr::SetPermittedRange(TInt aRange) |
|
144 { |
|
145 iPermittedRange = aRange; |
|
146 TPtr ptr((TUint16* ) &iPermittedRange,sizeof(iPermittedRange)/sizeof(TUint16)); |
|
147 iContext->SendEventToWindow(EPeninputLayoutEventSetPermittedRange,NULL,ptr); |
|
148 } |
|
149 |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CPeninputVkbDataMgr::SetEngineInputMode |
|
153 // (other items were commented in a header). |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CPeninputVkbDataMgr::SetEngineInputMode(TInt aRange) |
|
157 { |
|
158 if (iPermittedRange & aRange) |
|
159 { |
|
160 TInt clearDirection = iClear; // 1:delete 0:backspace |
|
161 TPtiEngineInputMode mode = EPtiEngineInputModeNone; |
|
162 switch (aRange) |
|
163 { |
|
164 case ERangeHiraganaKanji: |
|
165 mode = (Predictive())? EPtiEngineHiraganaKanjiPredictiveVkb |
|
166 : EPtiEngineHiraganaKanjiVkb; |
|
167 break; |
|
168 case ERangeKatakana: |
|
169 mode = EPtiEngineKatakanaVkb; |
|
170 break; |
|
171 case ERangeFullWidthKatakana: |
|
172 mode = EPtiEngineFullWidthKatakanaVkb; |
|
173 break; |
|
174 case ERangeHiraganaOnly: |
|
175 mode = EPtiEngineHiraganaVkb; |
|
176 break; |
|
177 default: |
|
178 break; |
|
179 } |
|
180 iPtiEngine->SetInputMode(mode); |
|
181 TRAP_IGNORE(iPtiEngine->HandleCommandL(EPtiCommandSetClearFunction, &clearDirection)); |
|
182 } |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CPeninputVkbDataMgr::SetPredictive |
|
187 // (other items were commented in a header). |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void CPeninputVkbDataMgr::SetPredictive(TBool aPredictive) |
|
191 { |
|
192 iPredictive = aPredictive; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // CPeninputVkbDataMgr::SetFullHalf |
|
197 // (other items were commented in a header). |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 void CPeninputVkbDataMgr::SetFullHalf(TInt aFullHalf) |
|
201 { |
|
202 iFullHalf = aFullHalf; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CPeninputVkbDataMgr::SetClear |
|
207 // (other items were commented in a header). |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CPeninputVkbDataMgr::SetClear(TInt aClear) |
|
211 { |
|
212 iClear = aClear; |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CPeninputVkbDataMgr::SetJapaneseFlags |
|
217 // (other items were commented in a header). |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 void CPeninputVkbDataMgr::SetJapaneseFlags(TInt aJapaneseFlags) |
|
221 { |
|
222 iJapaneseFlags = aJapaneseFlags; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CPeninputVkbDataMgr::HandleFunctionalVkbEventL |
|
227 // (other items were commented in a header). |
|
228 // return aStatus == False --->UiStateMgr()->CurrentUiState()->HandleControlEvent() by UiLayout |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 void CPeninputVkbDataMgr::HandleFunctionalVkbEventL(const TDesC& aEventData, TUint aPreChar |
|
232 , TBool& aStatus, TInt& aSendText) |
|
233 { |
|
234 aStatus = EFalse; |
|
235 TUint unicode = *((TUint16*) aEventData.Ptr()); // always aEventData length == 1 |
|
236 for (TInt ii=0; ii < LengthSymbolFuncyional; ii++) |
|
237 { |
|
238 if ( unicode == KSymbolsFuncyional[ii] ) |
|
239 { |
|
240 iPtiEngine->ClearCurrentWord(); |
|
241 iPtiEngine->HandleCommandL(EPtiCommandAppendCharacter, &aPreChar); |
|
242 iPtiEngine->HandleCommandL(EPtiCommandAppendCharacter, &unicode); |
|
243 const MPtiEngineCompositionDataInterface* data = iPtiEngine->CompositionData(); |
|
244 TPtrC convertingString = data->ConvertingString(); |
|
245 if (convertingString.Length() == 1 && aPreChar != convertingString[0]) |
|
246 { |
|
247 //replace |
|
248 // |
|
249 TInt replacedLen = 1; |
|
250 HBufC* p = HBufC::NewL(convertingString.Length() + 2); |
|
251 p->Des().Append((TUint16*)&replacedLen, 2); |
|
252 p->Des().Append(convertingString); |
|
253 iContext->Sendkey( ESignalReplaceTextJp, *p ); |
|
254 delete p; |
|
255 aSendText = 1; |
|
256 aStatus = ETrue; |
|
257 } |
|
258 else if (2 == ii) // ignore little |
|
259 { |
|
260 aStatus = ETrue; |
|
261 } |
|
262 iPtiEngine->ClearCurrentWord(); |
|
263 break; |
|
264 } |
|
265 } |
|
266 } |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CPeninputVkbDataMgr::HandleFunctionalVkbEventL |
|
269 // (other items were commented in a header). |
|
270 // return aStatus == False --->UiStateMgr()->CurrentUiState()->HandleControlEvent() by UiLayout |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 void CPeninputVkbDataMgr::HandleFunctionalVkbEventWithPrePreCharL(const TDesC& aEventData, TUint aPreChar |
|
274 , TUint aPrePreChar, TBool& aStatus, TInt& aSendText) |
|
275 { |
|
276 aStatus = EFalse; |
|
277 TUint unicode = *((TUint16*) aEventData.Ptr()); // always aEventData length == 1 |
|
278 if (KHalfDakuten == unicode || KHalfHanDakuten == unicode || KLittle == unicode) |
|
279 { |
|
280 TInt len = 2; |
|
281 iPtiEngine->ClearCurrentWord(); |
|
282 if (aPrePreChar != KNoChar) |
|
283 { |
|
284 iPtiEngine->HandleCommandL(EPtiCommandAppendCharacter, &aPrePreChar); |
|
285 ++ len; |
|
286 } |
|
287 iPtiEngine->HandleCommandL(EPtiCommandAppendCharacter, &aPreChar); |
|
288 iPtiEngine->HandleCommandL(EPtiCommandAppendCharacter, &unicode); |
|
289 const MPtiEngineCompositionDataInterface* data = iPtiEngine->CompositionData(); |
|
290 TPtrC convertingString = data->ConvertingString(); |
|
291 TInt backSpace = EKeyDelete; |
|
292 TPtrC ptr(reinterpret_cast<TText*>(&backSpace), 1); |
|
293 if (convertingString.Length() != len ) |
|
294 { |
|
295 if (convertingString.Length() == len-1 && len > 1 && aPreChar != convertingString[len-2]) |
|
296 { // pa + "-->ba |
|
297 TInt replacedLen = 1; |
|
298 HBufC* p = HBufC::NewL(convertingString.Right(1).Length() + 2); |
|
299 p->Des().Append((TUint16*)&replacedLen, 2); |
|
300 p->Des().Append(convertingString.Right(1)); |
|
301 iContext->Sendkey( ESignalReplaceTextJp, *p ); |
|
302 delete p; |
|
303 aSendText = 1; |
|
304 } |
|
305 else if (convertingString.Length() == len-2 && len > 2) |
|
306 { |
|
307 if (aPrePreChar != convertingString[0]) // zu + little ---> little tsu |
|
308 { |
|
309 TInt replacedLen = 1; |
|
310 HBufC* p = HBufC::NewL(convertingString.Length() + 2); |
|
311 p->Des().Append((TUint16*)&replacedLen, 2); |
|
312 p->Des().Append(convertingString); |
|
313 iContext->Sendkey(ESignalKeyEvent, ptr); // delete " |
|
314 iContext->Sendkey( ESignalReplaceTextJp, *p ); // tsu --->little tsu |
|
315 delete p; |
|
316 } |
|
317 else // ga + " ---> ka |
|
318 { |
|
319 iContext->Sendkey(ESignalKeyEvent, ptr); |
|
320 } |
|
321 aSendText = 1; |
|
322 } |
|
323 } |
|
324 else if (aPreChar != convertingString[len-2]) // little tsu + " ---> zu |
|
325 { |
|
326 TInt replacedLen = 1; |
|
327 HBufC* p = HBufC::NewL(convertingString.Mid(len-2,1).Length() + 2); |
|
328 p->Des().Append((TUint16*)&replacedLen, 2); |
|
329 p->Des().Append(convertingString.Mid(len-2,1)); |
|
330 iContext->Sendkey( ESignalReplaceTextJp, *p ); |
|
331 delete p; |
|
332 iContext->Sendkey(ESignalKeyEvent, convertingString.Right(1)); |
|
333 aSendText = 1; |
|
334 } |
|
335 else if (KLittle != unicode) // ignore little |
|
336 { |
|
337 iContext->Sendkey(ESignalKeyEvent, convertingString.Right(1)); |
|
338 aSendText = 1; |
|
339 } |
|
340 aStatus = ETrue; |
|
341 iPtiEngine->ClearCurrentWord(); |
|
342 } |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // CPeninputVkbDataMgr::ConvertCommaFullStop |
|
347 // (other items were commented in a header). |
|
348 // return aStatus == False : not changed |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 TBool CPeninputVkbDataMgr::ConvertCommaFullStop(TUint& aNewChar) const |
|
352 { |
|
353 TUint unicode = aNewChar; |
|
354 switch(unicode) |
|
355 { |
|
356 case KEWIdeographicComma: // touten |
|
357 if (iJapaneseFlags & EPenInputJapaneseSettingQwertyComma) // Japanese |
|
358 { |
|
359 aNewChar = (iFullHalf)? KEWIdeographicComma : KEWHalfWidthIdeographicComma; |
|
360 } |
|
361 else |
|
362 { // English |
|
363 aNewChar = (iFullHalf)? KEWFullWidthComma : KEWComma; |
|
364 } |
|
365 break; |
|
366 case KEWIdeographicFullStop: // kuten |
|
367 if (iJapaneseFlags & EPenInputJapaneseSettingQwertyPeriod) // Japanese |
|
368 { |
|
369 aNewChar = (iFullHalf)? KEWIdeographicFullStop : KEWHalfWidthIdeographicFullStop; |
|
370 } |
|
371 else |
|
372 { // English |
|
373 aNewChar = (iFullHalf)? KEWFullWidthFullStop : KEWFullStop; |
|
374 } |
|
375 break; |
|
376 case KEWHalfWidthIdeographicComma: // touten(halfwidth) |
|
377 if (!(iJapaneseFlags & EPenInputJapaneseSettingQwertyComma)) // English |
|
378 { |
|
379 aNewChar = KEWComma; |
|
380 } |
|
381 break; |
|
382 case KEWHalfWidthIdeographicFullStop: // kuten(halfwidth) |
|
383 if (!(iJapaneseFlags & EPenInputJapaneseSettingQwertyPeriod)) // English |
|
384 { |
|
385 aNewChar = KEWFullStop; |
|
386 } |
|
387 break; |
|
388 default: |
|
389 break; |
|
390 } |
|
391 return (aNewChar == unicode)? EFalse : ETrue; |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------- |
|
395 // Return the clear direction |
|
396 // --------------------------------------------------------- |
|
397 // |
|
398 TInt CPeninputVkbDataMgr::ClearDirection() const |
|
399 { |
|
400 return iClear; // 1:delete 0:backspace |
|
401 } |
|
402 |
|
403 // --------------------------------------------------------------------------- |
|
404 // CPeninputVkbDataMgr::CPeninputVkbDataMgr |
|
405 // (other items were commented in a header). |
|
406 // --------------------------------------------------------------------------- |
|
407 // |
|
408 CPeninputVkbDataMgr::CPeninputVkbDataMgr(MPeninputLayoutContext* aContext) |
|
409 : CPeninputDataMgr::CPeninputDataMgr(aContext), |
|
410 iPredictive(ETrue) |
|
411 { |
|
412 iInputLanguage = ELangJapanese; |
|
413 } |
|
414 |
|
415 // -------------------------------------------------------------------------- |
|
416 // CPeninputVkbDataMgr::ConstructL |
|
417 // (other items were commented in a header) |
|
418 // -------------------------------------------------------------------------- |
|
419 // |
|
420 void CPeninputVkbDataMgr::ConstructL() |
|
421 { |
|
422 CPeninputDataMgr::ConstructL(); |
|
423 InitMoreJpL(); |
|
424 } |
|
425 |
|
426 // End Of File |