60
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: MsgAddressControlEditor implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// ========== INCLUDE FILES ================================
|
|
21 |
|
|
22 |
#include <barsread.h> // for TResourceReader
|
|
23 |
#include <eikenv.h> // for CEikonEnv
|
|
24 |
#include <txtrich.h> // for CRichText
|
|
25 |
#include <AknUtils.h> // for AknUtils
|
|
26 |
#include <AknSettingCache.h> // for SettingCache().InputLanguage()
|
|
27 |
#include <AknsUtils.h> // for AknsUtils::GetCachedColor()
|
|
28 |
#include <AknsConstants.h> // for KAknsIIDQsnHighlightColors and EAknsCIQsnHighlightColorsCG1
|
|
29 |
|
|
30 |
#include <aknlayout.cdl.h> // LAF
|
|
31 |
#include <txtetext.h>
|
|
32 |
#include <fldinfo.h>
|
|
33 |
|
|
34 |
#ifdef RD_TACTILE_FEEDBACK
|
|
35 |
#include <touchfeedback.h>
|
|
36 |
#endif
|
|
37 |
|
|
38 |
|
|
39 |
#include "MsgEditorCommon.h" //
|
|
40 |
#include "MsgAddressControlEditor.h" // for CMsgAddressControlEditor
|
|
41 |
#include "MsgAddressControlEditorField.h" // for CMsgAddressControlEditorField and TMsgAddressControlEditorFieldFactory
|
|
42 |
#include "MsgBaseControl.h" // for TMsgEditPermissionFlags
|
|
43 |
#include "MsgBaseControlObserver.h" // for MMsgBaseControlObserver
|
|
44 |
#include "MsgAddressControl.h" // for permission flags
|
|
45 |
#include "MsgEditorPanic.h" // for MsgEditor panics
|
|
46 |
#include "MsgEditor.hrh" // for EditPermission flags
|
|
47 |
#include "MsgEditorKeyCatcher.h" // for CMsgEditorKeyCatcher
|
|
48 |
|
|
49 |
// ========== EXTERNAL DATA STRUCTURES =====================
|
|
50 |
|
|
51 |
// ========== EXTERNAL FUNCTION PROTOTYPES =================
|
|
52 |
|
|
53 |
// ========== CONSTANTS ====================================
|
|
54 |
|
|
55 |
// ========== MACROS =======================================
|
|
56 |
|
|
57 |
// ========== LOCAL CONSTANTS AND MACROS ===================
|
|
58 |
|
|
59 |
// Highlighted field does not exist.
|
|
60 |
const TInt KMsgHighlightedFieldPosNone = -1;
|
|
61 |
// Current entry not defined.
|
|
62 |
const TInt KMsgCurrentEntryNone = -1;
|
|
63 |
|
|
64 |
const TText KZeroWidthJoiner = 0x200D;
|
|
65 |
const TText KLRMarker = 0x200E;
|
|
66 |
const TText KRLMarker = 0x200F;
|
|
67 |
|
|
68 |
// ========== MODULE DATA STRUCTURES =======================
|
|
69 |
|
|
70 |
// ========== LOCAL FUNCTION PROTOTYPES ====================
|
|
71 |
|
|
72 |
// ========== LOCAL FUNCTIONS ==============================
|
|
73 |
|
|
74 |
// ========== MEMBER FUNCTIONS =============================
|
|
75 |
|
|
76 |
// ---------------------------------------------------------
|
|
77 |
// CMsgAddressControlEditor::CMsgAddressControlEditor
|
|
78 |
//
|
|
79 |
// Constructor.
|
|
80 |
// ---------------------------------------------------------
|
|
81 |
//
|
|
82 |
CMsgAddressControlEditor::CMsgAddressControlEditor(
|
|
83 |
const CCoeControl* aParent,
|
|
84 |
TUint32& aFlags,
|
|
85 |
MMsgBaseControlObserver* aBaseControlObserver )
|
|
86 |
: CMsgExpandableControlEditor( aParent, aFlags, aBaseControlObserver ),
|
|
87 |
iHighLightedFieldPos( KMsgHighlightedFieldPosNone ),
|
|
88 |
iCurrentEntry( KMsgCurrentEntryNone )
|
|
89 |
{
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------
|
|
93 |
// CMsgAddressControlEditor::~CMsgAddressControlEditor
|
|
94 |
//
|
|
95 |
// Destructor.
|
|
96 |
// ---------------------------------------------------------
|
|
97 |
//
|
|
98 |
CMsgAddressControlEditor::~CMsgAddressControlEditor()
|
|
99 |
{
|
|
100 |
delete iKeyCatcher;
|
|
101 |
delete iAddressControlEditorFieldFactory;
|
|
102 |
}
|
|
103 |
|
|
104 |
// ---------------------------------------------------------
|
|
105 |
// CMsgAddressControlEditor::ConstructL
|
|
106 |
//
|
|
107 |
// 2nd phase constructor.
|
|
108 |
// ---------------------------------------------------------
|
|
109 |
//
|
|
110 |
void CMsgAddressControlEditor::ConstructL()
|
|
111 |
{
|
|
112 |
CMsgExpandableControlEditor::ConstructL();
|
|
113 |
|
|
114 |
//To Dis-able Smiley support for address fields
|
|
115 |
RemoveFlagFromUserFlags(EAvkonEnableSmileySupport);
|
|
116 |
|
|
117 |
iFlags |= EMsgControlModeDoNotDrawFrameBgContext;
|
|
118 |
iKeyCatcher = new ( ELeave ) CMsgEditorKeyCatcher();
|
|
119 |
iKeyCatcher->ConstructL( this );
|
|
120 |
|
|
121 |
SetAllowUndo( EFalse );
|
|
122 |
// Variation is done inside edwin
|
|
123 |
SetPhoneNumberGrouping( ETrue );
|
|
124 |
iCusPos = 0;
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------
|
|
128 |
// CMsgAddressControlEditor::ExtractEntry
|
|
129 |
//
|
|
130 |
// Extracts an entry according to aEntryNumber and returns it in aEntryString.
|
|
131 |
// ---------------------------------------------------------
|
|
132 |
//
|
|
133 |
void CMsgAddressControlEditor::ExtractEntry(
|
|
134 |
TDes& aEntryString, TInt aEntryNumber )
|
|
135 |
{
|
|
136 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
137 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
138 |
Panic( EMsgInvalidEntryNumber ) );
|
|
139 |
|
|
140 |
TInt entryLength = 0;
|
|
141 |
TInt entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
142 |
iRichText->Extract( aEntryString, entryStart, entryLength - 1 );
|
|
143 |
}
|
|
144 |
|
|
145 |
// ---------------------------------------------------------
|
|
146 |
// CMsgAddressControlEditor::ReadEntry
|
|
147 |
//
|
|
148 |
// Reads an entry aEntryNumber and returns pointer to it.
|
|
149 |
// ---------------------------------------------------------
|
|
150 |
//
|
|
151 |
TPtrC CMsgAddressControlEditor::ReadEntry( TInt aEntryNumber ) const
|
|
152 |
{
|
|
153 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
154 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
155 |
Panic( EMsgInvalidEntryNumber ) );
|
|
156 |
|
|
157 |
TInt entryLength = 0;
|
|
158 |
TInt entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
159 |
return iRichText->Read( entryStart, entryLength - 1 );
|
|
160 |
}
|
|
161 |
|
|
162 |
// ---------------------------------------------------------
|
|
163 |
// CMsgAddressControlEditor::EntryCount
|
|
164 |
//
|
|
165 |
// Returns number of entries.
|
|
166 |
// ---------------------------------------------------------
|
|
167 |
//
|
|
168 |
TInt CMsgAddressControlEditor::EntryCount() const
|
|
169 |
{
|
|
170 |
return iRichText->ParagraphCount();
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------
|
|
174 |
// CMsgAddressControlEditor::DeleteEntryL
|
|
175 |
//
|
|
176 |
// Deletes an entry aEntryNumber.
|
|
177 |
// ---------------------------------------------------------
|
|
178 |
//
|
|
179 |
void CMsgAddressControlEditor::DeleteEntryL( TInt aEntryNumber )
|
|
180 |
{
|
|
181 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
182 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
183 |
Panic( EMsgInvalidEntryNumber ) );
|
|
184 |
|
|
185 |
CancelFepTransaction();
|
|
186 |
TBool setcursorpos(EFalse);
|
|
187 |
TInt numOfEntries = iRichText->ParagraphCount();
|
|
188 |
TInt entryLength = 0;
|
|
189 |
TInt entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
190 |
if ( numOfEntries == aEntryNumber + 1 ) //entry to be deleted is the lowest one
|
|
191 |
{
|
|
192 |
if ( aEntryNumber != 0 ) // but not the only one
|
|
193 |
{
|
|
194 |
entryStart--;
|
|
195 |
}
|
|
196 |
else
|
|
197 |
{
|
|
198 |
entryLength--;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
|
|
202 |
if ( TextView() )
|
|
203 |
{
|
|
204 |
// Cursor position must not go beyond text end. Otherwise
|
|
205 |
// panic will happen on text formatting.
|
|
206 |
TInt newTextLength = TextLength() - entryLength;
|
|
207 |
|
|
208 |
if ( CursorPos() > newTextLength )
|
|
209 |
{
|
|
210 |
SetCursorPosL( newTextLength, EFalse );
|
|
211 |
iCusPos = newTextLength;
|
|
212 |
setcursorpos = ETrue;
|
|
213 |
}
|
|
214 |
}
|
|
215 |
|
|
216 |
iRichText->CancelInsertCharFormat();
|
|
217 |
iRichText->DelSetInsertCharFormatL( entryStart, entryLength );
|
|
218 |
if ( iTextView )
|
|
219 |
{
|
|
220 |
iTextView->HandleInsertDeleteL(
|
|
221 |
TCursorSelection( entryStart, entryStart + entryLength ), entryLength, EFalse );
|
|
222 |
}
|
|
223 |
numOfEntries = iRichText->ParagraphCount();
|
|
224 |
if( numOfEntries > 0 && numOfEntries != aEntryNumber && !setcursorpos)
|
|
225 |
{
|
|
226 |
TInt txtlen = TextLength();
|
|
227 |
TInt curpos = CursorPos();
|
|
228 |
if ( aEntryNumber )
|
|
229 |
{
|
|
230 |
entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber - 1 );
|
|
231 |
curpos = entryStart + --entryLength ;
|
|
232 |
}
|
|
233 |
else
|
|
234 |
{
|
|
235 |
entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
236 |
curpos+= --entryLength;
|
|
237 |
}
|
|
238 |
|
|
239 |
if ( TextView() )
|
|
240 |
{
|
|
241 |
if(curpos < txtlen)
|
|
242 |
{
|
|
243 |
iCusPos = curpos;
|
|
244 |
SetCursorPosL( curpos, EFalse );
|
|
245 |
}
|
|
246 |
else
|
|
247 |
{
|
|
248 |
iCusPos =entryStart ;
|
|
249 |
SetCursorPosL( iCusPos, EFalse );
|
|
250 |
ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
|
|
251 |
}
|
|
252 |
}
|
|
253 |
}
|
|
254 |
}
|
|
255 |
// ---------------------------------------------------------
|
|
256 |
// CMsgAddressControlEditor::GetCursorpos
|
|
257 |
//
|
|
258 |
// returns the current cursor position.
|
|
259 |
// ---------------------------------------------------------
|
|
260 |
//
|
|
261 |
|
|
262 |
TInt CMsgAddressControlEditor::GetCursorpos() const
|
|
263 |
{
|
|
264 |
return iCusPos;
|
|
265 |
}
|
|
266 |
|
|
267 |
// ---------------------------------------------------------
|
|
268 |
// CMsgAddressControlEditor::ClearEntryL
|
|
269 |
//
|
|
270 |
// Clears all the text of an entry aEntryNumber but not the paragraph delimiter.
|
|
271 |
// ---------------------------------------------------------
|
|
272 |
//
|
|
273 |
void CMsgAddressControlEditor::ClearEntryL( TInt aEntryNumber, TBool aUpdate )
|
|
274 |
{
|
|
275 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
276 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
277 |
Panic( EMsgInvalidEntryNumber ) );
|
|
278 |
|
|
279 |
TInt entryLength = 0;
|
|
280 |
TInt entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
281 |
DeleteEntryCharsL( aEntryNumber, 0, entryLength );
|
|
282 |
if ( iTextView && aUpdate )
|
|
283 |
{
|
|
284 |
iTextView->HandleInsertDeleteL(
|
|
285 |
TCursorSelection( entryStart, entryStart ), --entryLength, EFalse );
|
|
286 |
SetCursorPosAndCancelSelectionL( entryStart );
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
// ---------------------------------------------------------
|
|
291 |
// CMsgAddressControlEditor::DeleteAllL
|
|
292 |
//
|
|
293 |
// Clears the content of the editor. Updates also the scroll bars.
|
|
294 |
// ---------------------------------------------------------
|
|
295 |
//
|
|
296 |
void CMsgAddressControlEditor::DeleteAllL()
|
|
297 |
{
|
|
298 |
CancelFepTransaction();
|
|
299 |
iRichText->CancelInsertCharFormat();
|
|
300 |
iRichText->Reset();
|
|
301 |
if (iTextView)
|
|
302 |
{
|
|
303 |
SetAmountToFormatL( ETrue );
|
|
304 |
SetCursorPosAndCancelSelectionL( 0 );
|
|
305 |
}
|
|
306 |
}
|
|
307 |
|
|
308 |
// ---------------------------------------------------------
|
|
309 |
// CMsgAddressControlEditor::DeleteEntryCharsL
|
|
310 |
//
|
|
311 |
// Deletes characters from aStartPos to aEndPos at entry aEntryNumber. Never
|
|
312 |
// removes the paragraph delimiter.
|
|
313 |
// ---------------------------------------------------------
|
|
314 |
//
|
|
315 |
void CMsgAddressControlEditor::DeleteEntryCharsL(
|
|
316 |
TInt aEntryNumber, TInt aStartPos, TInt aEndPos)
|
|
317 |
{
|
|
318 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
319 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
320 |
Panic( EMsgInvalidEntryNumber ) );
|
|
321 |
__ASSERT_DEBUG( ( aStartPos >= 0 ) && ( aStartPos <= aEndPos ),
|
|
322 |
Panic( EMsgInvalidStartPos ) );
|
|
323 |
|
|
324 |
CancelFepTransaction();
|
|
325 |
TInt entryLength = 0;
|
|
326 |
TInt entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
327 |
entryLength--;
|
|
328 |
entryLength = ( aEndPos < entryLength )
|
|
329 |
? aEndPos - aStartPos
|
|
330 |
: entryLength - aStartPos;
|
|
331 |
entryStart += aStartPos;
|
|
332 |
|
|
333 |
if ( TextView() )
|
|
334 |
{
|
|
335 |
// Cursor position must not go beyond text end. Otherwise
|
|
336 |
// panic will happen on text formatting.
|
|
337 |
TInt newTextLength = TextLength() - entryLength;
|
|
338 |
|
|
339 |
if ( CursorPos() > newTextLength )
|
|
340 |
{
|
|
341 |
SetCursorPosL( newTextLength, EFalse );
|
|
342 |
}
|
|
343 |
}
|
|
344 |
|
|
345 |
iRichText->CancelInsertCharFormat();
|
|
346 |
iRichText->DelSetInsertCharFormatL( entryStart, entryLength );
|
|
347 |
//clear the iTextView cache too
|
|
348 |
if ( iTextView )
|
|
349 |
{
|
|
350 |
iTextView->HandleInsertDeleteL(
|
|
351 |
TCursorSelection( entryStart, entryStart + entryLength ), entryLength, EFalse );
|
|
352 |
SetCursorPosAndCancelSelectionL( entryStart );
|
|
353 |
}
|
|
354 |
}
|
|
355 |
|
|
356 |
// ---------------------------------------------------------
|
|
357 |
// CMsgAddressControlEditor::SetCursorPosAndCancelSelectionL
|
|
358 |
//
|
|
359 |
// Sets cursor position to aPos and cancels selection.
|
|
360 |
// This is needed because Edwin/TextView does not do it as expected.
|
|
361 |
// ---------------------------------------------------------
|
|
362 |
//
|
|
363 |
void CMsgAddressControlEditor::SetCursorPosAndCancelSelectionL( TInt aPos )
|
|
364 |
{
|
|
365 |
if ( iTextView )
|
|
366 |
{
|
|
367 |
CancelFepTransaction();
|
|
368 |
|
|
369 |
iTextView->SetDocPosL( aPos, EFalse );
|
|
370 |
ForceScrollBarUpdateL();
|
|
371 |
}
|
|
372 |
}
|
|
373 |
|
|
374 |
// ---------------------------------------------------------
|
|
375 |
// CMsgAddressControlEditor::InsertEntryL
|
|
376 |
//
|
|
377 |
// Inserts an entry to the location aEntryNumber with strings a text aName
|
|
378 |
// and aAddress. Makes an entry as verified if aVerified = ETrue and validated
|
|
379 |
// if aValidated = ETrue.
|
|
380 |
// ---------------------------------------------------------
|
|
381 |
//
|
|
382 |
void CMsgAddressControlEditor::InsertEntryL(
|
|
383 |
TInt aEntryNumber,
|
|
384 |
const TDesC& aName,
|
|
385 |
const TDesC& aAddress,
|
|
386 |
TBool aVerified,
|
|
387 |
TBool aValidated,
|
|
388 |
const MVPbkContactLink* aContactLink )
|
|
389 |
{
|
|
390 |
__ASSERT_DEBUG( aEntryNumber >= 0 &&
|
|
391 |
aEntryNumber <= iRichText->ParagraphCount(),
|
|
392 |
Panic( EMsgInvalidEntryNumber ) );
|
|
393 |
|
|
394 |
TChar semicolon = KSemicolon;
|
|
395 |
TInt entryLength = 0;
|
|
396 |
TInt numOfEntries = iRichText->ParagraphCount();
|
|
397 |
|
|
398 |
TInt pos = TextLength();
|
|
399 |
TChar ch = CharAtPos( pos - 1 );
|
|
400 |
|
|
401 |
if ( ch == CEditableText::EParagraphDelimiter )
|
|
402 |
{
|
|
403 |
// last character is parag.delim. => decrease entry num.
|
|
404 |
aEntryNumber--;
|
|
405 |
}
|
|
406 |
|
|
407 |
/*
|
|
408 |
* Fix the split contact name issue::ECYU-7FPC93.
|
|
409 |
* Replace any enter-key characters with space characters.
|
|
410 |
*/
|
|
411 |
|
|
412 |
TBufC<KMaxContactLength> parsedName(aName.Left(KMaxContactLength));
|
|
413 |
|
|
414 |
TInt enterKeyPos;
|
|
415 |
TChar enterChar( CEditableText::EParagraphDelimiter );
|
|
416 |
TChar spaceChar( CEditableText::ESpace );
|
|
417 |
TPtr namePtr = parsedName.Des();
|
|
418 |
TInt nameLength = parsedName.Length();
|
|
419 |
|
|
420 |
enterKeyPos = namePtr.Locate(enterChar);
|
|
421 |
while( enterKeyPos != KErrNotFound && enterKeyPos < nameLength )
|
|
422 |
{
|
|
423 |
namePtr[enterKeyPos] = spaceChar;
|
|
424 |
enterKeyPos = namePtr.Locate(enterChar);
|
|
425 |
}
|
|
426 |
|
|
427 |
if ( aEntryNumber >= numOfEntries )
|
|
428 |
{
|
|
429 |
// entry appended to the end.
|
|
430 |
iRichText->CancelInsertCharFormat();
|
|
431 |
iRichText->InsertL( pos, CEditableText::EParagraphDelimiter );
|
|
432 |
}
|
|
433 |
else
|
|
434 |
{
|
|
435 |
// entry appended to the middle or beginning.
|
|
436 |
iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
437 |
|
|
438 |
if ( entryLength - 1 )
|
|
439 |
{
|
|
440 |
InsertEntryBreakL( aEntryNumber, 0 );
|
|
441 |
}
|
|
442 |
}
|
|
443 |
|
|
444 |
TInt entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
445 |
|
|
446 |
//ECYU-7FPC93:: Fix
|
|
447 |
HBufC* string = CreateEntryStringLC( parsedName, aAddress, aVerified );
|
|
448 |
//HBufC* string = CreateEntryStringLC( aName, aAddress, aVerified );
|
|
449 |
|
|
450 |
if ( aVerified || aValidated )
|
|
451 |
{
|
|
452 |
// Setting up the field factory.
|
|
453 |
iRichText->SetFieldFactory( iAddressControlEditorFieldFactory );
|
|
454 |
|
|
455 |
CMsgAddressControlEditorField* field =
|
|
456 |
static_cast<CMsgAddressControlEditorField*>(
|
|
457 |
iRichText->NewTextFieldL( KMsgAddressControlEditorFieldUid ) );
|
|
458 |
|
|
459 |
if ( field )
|
|
460 |
{
|
|
461 |
field->SetEntryStringL( *string );
|
|
462 |
|
|
463 |
//ECYU-7FPC93:: Fix
|
|
464 |
field->SetNameL( parsedName );
|
|
465 |
//field->SetNameL( aName );
|
|
466 |
|
|
467 |
field->SetAddressL( aAddress );
|
|
468 |
field->SetVerified( aVerified );
|
|
469 |
field->SetValidated( aValidated );
|
|
470 |
field->SetContactLink( aContactLink );
|
|
471 |
|
|
472 |
iRichText->InsertFieldL( entryStart,
|
|
473 |
field,
|
|
474 |
KMsgAddressControlEditorFieldUid );
|
|
475 |
|
|
476 |
iRichText->UpdateFieldL( entryStart );
|
|
477 |
}
|
|
478 |
}
|
|
479 |
else
|
|
480 |
{
|
|
481 |
if ( string->Length() > 0 )
|
|
482 |
{
|
|
483 |
iRichText->InsertL( entryStart, *string );
|
|
484 |
}
|
|
485 |
else
|
|
486 |
{
|
|
487 |
// This should not happen. Zero lenght contact name is being added.
|
|
488 |
// Insert semicolon only.
|
|
489 |
if ( iAvkonEnv->SettingCache().InputLanguage() == ELangArabic )
|
|
490 |
{
|
|
491 |
semicolon = KArabicSemicolon;
|
|
492 |
}
|
|
493 |
|
|
494 |
iRichText->InsertL( entryStart, semicolon );
|
|
495 |
}
|
|
496 |
}
|
|
497 |
|
|
498 |
if ( aEntryNumber >= numOfEntries )
|
|
499 |
{
|
|
500 |
if ( ch != semicolon &&
|
|
501 |
ch != CEditableText::EParagraphDelimiter &&
|
|
502 |
ch != KArabicSemicolon )
|
|
503 |
{
|
|
504 |
if ( iAvkonEnv->SettingCache().InputLanguage() == ELangArabic )
|
|
505 |
{
|
|
506 |
semicolon = KArabicSemicolon;
|
|
507 |
}
|
|
508 |
|
|
509 |
iRichText->InsertL( pos, semicolon );
|
|
510 |
}
|
|
511 |
}
|
|
512 |
|
|
513 |
CleanupStack::PopAndDestroy(); // string
|
|
514 |
}
|
|
515 |
|
|
516 |
// ---------------------------------------------------------
|
|
517 |
// CMsgAddressControlEditor::InsertEntryBreakL
|
|
518 |
//
|
|
519 |
// Inserts the paragraph delimiter at aPos on entry aEntryNumber.
|
|
520 |
// ---------------------------------------------------------
|
|
521 |
//
|
|
522 |
void CMsgAddressControlEditor::InsertEntryBreakL( TInt aEntryNumber, TInt aPos )
|
|
523 |
{
|
|
524 |
__ASSERT_DEBUG( aEntryNumber >= 0 &&
|
|
525 |
aEntryNumber < iRichText->ParagraphCount(),
|
|
526 |
Panic( EMsgInvalidEntryNumber ) );
|
|
527 |
|
|
528 |
TInt entryLength = 0;
|
|
529 |
TInt insertPos = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
530 |
insertPos += aPos;
|
|
531 |
iRichText->CancelInsertCharFormat();
|
|
532 |
iRichText->InsertL( insertPos, CEditableText::EParagraphDelimiter );
|
|
533 |
}
|
|
534 |
|
|
535 |
// ---------------------------------------------------------
|
|
536 |
// CMsgAddressControlEditor::EntryNumber
|
|
537 |
//
|
|
538 |
// Returs an entry number where aPos is on.
|
|
539 |
// ---------------------------------------------------------
|
|
540 |
//
|
|
541 |
TInt CMsgAddressControlEditor::EntryNumber( TInt aPos ) const
|
|
542 |
{
|
|
543 |
__ASSERT_DEBUG( ( aPos >= 0 ) && ( aPos <= TextLength() ),
|
|
544 |
Panic( EMsgDocPosOutOfRange ) );
|
|
545 |
|
|
546 |
// first paragraph==0
|
|
547 |
TInt paragraphNumber = iRichText->ParagraphNumberForPos( aPos );
|
|
548 |
return paragraphNumber;
|
|
549 |
}
|
|
550 |
|
|
551 |
// ---------------------------------------------------------
|
|
552 |
// CMsgAddressControlEditor::EntryLength
|
|
553 |
//
|
|
554 |
// Returns length of the entry aEntryNumber. Does not count paragraph delimiter.
|
|
555 |
// ---------------------------------------------------------
|
|
556 |
//
|
|
557 |
TInt CMsgAddressControlEditor::EntryLength( TInt aEntryNumber ) const
|
|
558 |
{
|
|
559 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
560 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
561 |
Panic( EMsgInvalidEntryNumber ) );
|
|
562 |
|
|
563 |
TInt entryLength = 0;
|
|
564 |
iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
565 |
return entryLength - 1;
|
|
566 |
}
|
|
567 |
|
|
568 |
// ---------------------------------------------------------
|
|
569 |
// CMsgAddressControlEditor::EntryStartPos
|
|
570 |
//
|
|
571 |
// Returns first character position on the entry aEntryNumber.
|
|
572 |
// ---------------------------------------------------------
|
|
573 |
//
|
|
574 |
TInt CMsgAddressControlEditor::EntryStartPos( TInt aEntryNumber ) const
|
|
575 |
{
|
|
576 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
577 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
578 |
Panic( EMsgInvalidEntryNumber ) );
|
|
579 |
|
|
580 |
TInt entryLength = 0;
|
|
581 |
return iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
582 |
}
|
|
583 |
|
|
584 |
// ---------------------------------------------------------
|
|
585 |
// CMsgAddressControlEditor::FirstFieldPos
|
|
586 |
//
|
|
587 |
//
|
|
588 |
// ---------------------------------------------------------
|
|
589 |
//
|
|
590 |
TInt CMsgAddressControlEditor::FirstFieldPos( TInt aCursorPos ) const
|
|
591 |
{
|
|
592 |
TFindFieldInfo fieldInfo;
|
|
593 |
|
|
594 |
/*TBool ret =*/ iRichText->FindFields( fieldInfo, aCursorPos, 0 );
|
|
595 |
|
|
596 |
return fieldInfo.iFirstFieldPos;
|
|
597 |
}
|
|
598 |
|
|
599 |
// ---------------------------------------------------------
|
|
600 |
// CMsgAddressControlEditor::MoveCursorToEntryPosL
|
|
601 |
//
|
|
602 |
// Moves the cursor on an entry aEntryNumber to a position aPos. 0 == entry start.
|
|
603 |
// ---------------------------------------------------------
|
|
604 |
//
|
|
605 |
void CMsgAddressControlEditor::MoveCursorToEntryPosL( TInt aEntryNumber, TInt aPos )
|
|
606 |
{
|
|
607 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
608 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
609 |
Panic( EMsgInvalidEntryNumber ) );
|
|
610 |
|
|
611 |
TInt entryLength = 0;
|
|
612 |
TInt entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
613 |
if ( entryLength - 1 < aPos )
|
|
614 |
{
|
|
615 |
aPos = entryLength - 1; // adjust the aPos if it happens to be too big
|
|
616 |
}
|
|
617 |
SetCursorPosAndCancelSelectionL( entryStart + aPos );
|
|
618 |
}
|
|
619 |
|
|
620 |
// ---------------------------------------------------------
|
|
621 |
// CMsgAddressControlEditor::IsPosAtEntryBeginning
|
|
622 |
//
|
|
623 |
// Checks whether the cursor is at the beginning of the entry and returns ETrue
|
|
624 |
// if it is, otherwise EFalse.
|
|
625 |
// ---------------------------------------------------------
|
|
626 |
//
|
|
627 |
TBool CMsgAddressControlEditor::IsPosAtEntryBeginning( TInt aPos ) const
|
|
628 |
{
|
|
629 |
__ASSERT_DEBUG( ( aPos >= 0 ) && ( aPos <= TextLength() ),
|
|
630 |
Panic( EMsgDocPosOutOfRange ) );
|
|
631 |
|
|
632 |
TInt entryLength = 0;
|
|
633 |
return ( iRichText->CharPosOfParagraph(
|
|
634 |
entryLength, EntryNumber( aPos ) ) == aPos );
|
|
635 |
}
|
|
636 |
|
|
637 |
// ---------------------------------------------------------
|
|
638 |
// CMsgAddressControlEditor::IsEntryVerified
|
|
639 |
//
|
|
640 |
// Check whether an entry aEntryNumber is verified or not and returns ETrue
|
|
641 |
// if it is, otherwise EFalse.
|
|
642 |
// ---------------------------------------------------------
|
|
643 |
//
|
|
644 |
TBool CMsgAddressControlEditor::IsEntryVerified( TInt aEntryNumber ) const
|
|
645 |
{
|
|
646 |
const CMsgAddressControlEditorField* field = Field( aEntryNumber );
|
|
647 |
|
|
648 |
return ( field ? field->IsVerified() : EFalse );
|
|
649 |
}
|
|
650 |
|
|
651 |
// ---------------------------------------------------------
|
|
652 |
// CMsgAddressControlEditor::IsPriorEntryVerified
|
|
653 |
//
|
|
654 |
// Checks whether an entry aEntryNumber-1 is verified and returns ETrue if
|
|
655 |
// it is, otherwise EFalse.
|
|
656 |
// ---------------------------------------------------------
|
|
657 |
//
|
|
658 |
TBool CMsgAddressControlEditor::IsPriorEntryVerified( TInt aEntryNumber ) const
|
|
659 |
{
|
|
660 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
661 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
662 |
Panic( EMsgInvalidEntryNumber ) );
|
|
663 |
|
|
664 |
if ( aEntryNumber > 0 )
|
|
665 |
{
|
|
666 |
return IsEntryVerified( aEntryNumber - 1 );
|
|
667 |
}
|
|
668 |
|
|
669 |
return EFalse;
|
|
670 |
}
|
|
671 |
|
|
672 |
// ---------------------------------------------------------
|
|
673 |
// CMsgAddressControlEditor::IsEntryValidated
|
|
674 |
//
|
|
675 |
// Check whether an entry aEntryNumber is validated or not and returns ETrue
|
|
676 |
// if it is, otherwise EFalse.
|
|
677 |
// ---------------------------------------------------------
|
|
678 |
//
|
|
679 |
TBool CMsgAddressControlEditor::IsEntryValidated( TInt aEntryNumber ) const
|
|
680 |
{
|
|
681 |
const CMsgAddressControlEditorField* field = Field( aEntryNumber );
|
|
682 |
|
|
683 |
return ( field ? field->IsValidated() : EFalse );
|
|
684 |
}
|
|
685 |
|
|
686 |
// ---------------------------------------------------------
|
|
687 |
// CMsgAddressControlEditor::IsFieldOnLeft
|
|
688 |
//
|
|
689 |
// Checks if there is a text field on the left hand side of the cursor at
|
|
690 |
// position aPos and returns ETrue if it is, otherwise EFalse.
|
|
691 |
// ---------------------------------------------------------
|
|
692 |
//
|
|
693 |
TBool CMsgAddressControlEditor::IsFieldOnLeft( TInt aPos ) const
|
|
694 |
{
|
|
695 |
if ( aPos > 0 && aPos <= TextLength() )
|
|
696 |
{
|
|
697 |
const CMsgAddressControlEditorField* field = FieldFromPos( aPos - 1 );
|
|
698 |
|
|
699 |
return ( field ? field->IsVerified() : EFalse );
|
|
700 |
}
|
|
701 |
return EFalse;
|
|
702 |
}
|
|
703 |
|
|
704 |
// ---------------------------------------------------------
|
|
705 |
// CMsgAddressControlEditor::IsFieldOnRight
|
|
706 |
//
|
|
707 |
// Checks if there is a text field on the right hand side of the cursor at position
|
|
708 |
// aPos and returns ETrue if it is, otherwise EFalse.
|
|
709 |
// ---------------------------------------------------------
|
|
710 |
//
|
|
711 |
TBool CMsgAddressControlEditor::IsFieldOnRight( TInt aPos ) const
|
|
712 |
{
|
|
713 |
if ( aPos >= 0 && aPos < TextLength() )
|
|
714 |
{
|
|
715 |
// Fixing Fixing "ESPI-63C45M - Messags: The contact named with one
|
|
716 |
// characteronly cannot be deleted from ‘To’ field by ‘Clear’ key."
|
|
717 |
|
|
718 |
const CMsgAddressControlEditorField* field = FieldFromPos( aPos );
|
|
719 |
|
|
720 |
return ( field ? field->IsVerified() : EFalse );
|
|
721 |
}
|
|
722 |
return EFalse;
|
|
723 |
}
|
|
724 |
|
|
725 |
// ---------------------------------------------------------
|
|
726 |
// CMsgAddressControlEditor::IsFieldOnPos
|
|
727 |
//
|
|
728 |
// Checks if there is a text field under the cursor at position
|
|
729 |
// aPos and returns ETrue if it is, otherwise EFalse.
|
|
730 |
// ---------------------------------------------------------
|
|
731 |
//
|
|
732 |
TBool CMsgAddressControlEditor::IsFieldOnPos( TInt aPos ) const
|
|
733 |
{
|
|
734 |
if ( aPos >= 0 && aPos < TextLength() )
|
|
735 |
{
|
|
736 |
const CMsgAddressControlEditorField* field = FieldFromPos( aPos );
|
|
737 |
|
|
738 |
return ( field ? field->IsVerified() : EFalse );
|
|
739 |
}
|
|
740 |
return EFalse;
|
|
741 |
}
|
|
742 |
|
|
743 |
// ---------------------------------------------------------
|
|
744 |
// CMsgAddressControlEditor::IsEntryEmpty
|
|
745 |
//
|
|
746 |
// Checks whether an entry aEntryNumber is empty.
|
|
747 |
// ---------------------------------------------------------
|
|
748 |
//
|
|
749 |
TBool CMsgAddressControlEditor::IsEntryEmpty( TInt aEntryNumber ) const
|
|
750 |
{
|
|
751 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
752 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
753 |
Panic( EMsgInvalidEntryNumber ) );
|
|
754 |
|
|
755 |
TInt entryLength = 0;
|
|
756 |
iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
757 |
|
|
758 |
return ( entryLength == 1 );
|
|
759 |
}
|
|
760 |
|
|
761 |
// ---------------------------------------------------------
|
|
762 |
// CMsgAddressControlEditor::IsEntryRightToLeft
|
|
763 |
//
|
|
764 |
// ---------------------------------------------------------
|
|
765 |
//
|
|
766 |
TBool CMsgAddressControlEditor::IsEntryRightToLeft( TInt aEntryNumber ) const
|
|
767 |
{
|
|
768 |
TBool isRightToLeft( EFalse );
|
|
769 |
|
|
770 |
const CMsgAddressControlEditorField* field = Field( aEntryNumber );
|
|
771 |
if ( field )
|
|
772 |
{
|
|
773 |
TPtrC entryText = ReadEntry( aEntryNumber );
|
|
774 |
if ( entryText.Length() > 0 )
|
|
775 |
{
|
|
776 |
if ( TBidiText::TextDirectionality( entryText ) ==
|
|
777 |
TBidiText::ERightToLeft )
|
|
778 |
{
|
|
779 |
isRightToLeft = ETrue;
|
|
780 |
}
|
|
781 |
}
|
|
782 |
}
|
|
783 |
return isRightToLeft;
|
|
784 |
}
|
|
785 |
|
|
786 |
// ---------------------------------------------------------
|
|
787 |
// CMsgAddressControlEditor::CheckHighlightingL
|
|
788 |
//
|
|
789 |
// Turns entry as highlighted if the cursor is on the top of the verified
|
|
790 |
// entry, otherwise turns highlighting off if there were any somewhere else.
|
|
791 |
// ---------------------------------------------------------
|
|
792 |
//
|
|
793 |
void CMsgAddressControlEditor::CheckHighlightingL( TBool aCancelFep /*= ETrue*/ )
|
|
794 |
{
|
|
795 |
if ( !iTextView )
|
|
796 |
{
|
|
797 |
return ;
|
|
798 |
}
|
|
799 |
|
|
800 |
if ( aCancelFep && IsFocused())
|
|
801 |
{
|
|
802 |
CancelFepTransaction();
|
|
803 |
}
|
|
804 |
|
|
805 |
TInt cursorPos = CursorPos();
|
|
806 |
|
|
807 |
if ( !IsReadOnly() && IsFieldOnPos( cursorPos ) )
|
|
808 |
{
|
|
809 |
TFindFieldInfo fieldInfo;
|
|
810 |
|
|
811 |
if ( iRichText->FindFields( fieldInfo, cursorPos, 0 ) )
|
|
812 |
{
|
|
813 |
TCharFormat charFormat;
|
|
814 |
TCharFormatMask applyMask;
|
|
815 |
|
|
816 |
if ( iHighLightedFieldPos != fieldInfo.iFirstFieldPos )
|
|
817 |
{
|
|
818 |
if ( !( iFlags & EMsgControlModeShiftPressed ) )
|
|
819 |
{
|
|
820 |
TRgb highlightColor;
|
|
821 |
|
|
822 |
AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
|
|
823 |
highlightColor,
|
|
824 |
KAknsIIDQsnHighlightColors,
|
|
825 |
EAknsCIQsnHighlightColorsCG1 );
|
|
826 |
|
|
827 |
charFormat.iFontPresentation.iHighlightColor = highlightColor;
|
|
828 |
applyMask.SetAttrib( EAttFontHighlightColor );
|
|
829 |
|
|
830 |
charFormat.iFontPresentation.iHighlightStyle =
|
|
831 |
TFontPresentation::EFontHighlightNormal;
|
|
832 |
applyMask.SetAttrib( EAttFontHighlightStyle );
|
|
833 |
|
|
834 |
// Sets only the attributes specified to be set on mask.
|
|
835 |
iRichText->ApplyCharFormatL(
|
|
836 |
charFormat,
|
|
837 |
applyMask,
|
|
838 |
fieldInfo.iFirstFieldPos,
|
|
839 |
fieldInfo.iFirstFieldLen );
|
|
840 |
}
|
|
841 |
|
|
842 |
if ( iTextView )
|
|
843 |
{
|
|
844 |
iTextView->HandleRangeFormatChangeL(
|
|
845 |
TCursorSelection(
|
|
846 |
fieldInfo.iFirstFieldPos,
|
|
847 |
fieldInfo.iFirstFieldPos + fieldInfo.iFirstFieldLen ),
|
|
848 |
EFalse );
|
|
849 |
}
|
|
850 |
|
|
851 |
if ( cursorPos != fieldInfo.iFirstFieldPos &&
|
|
852 |
!iHandlingPointerEvent )
|
|
853 |
{
|
|
854 |
MoveCursorToEntryPosL(EntryNumber( cursorPos ), 0 );
|
|
855 |
}
|
|
856 |
|
|
857 |
TurnHighlightingOffL( aCancelFep );
|
|
858 |
iHighLightedFieldPos = fieldInfo.iFirstFieldPos;
|
|
859 |
}
|
|
860 |
}
|
|
861 |
}
|
|
862 |
else
|
|
863 |
{
|
|
864 |
if ( IsReadOnly() && iValidHighlightable )
|
|
865 |
{
|
|
866 |
// Use "link highlight"
|
|
867 |
SetHighlightStyleL( EEikEdwinHighlightLink );
|
|
868 |
SelectAllL();
|
|
869 |
}
|
|
870 |
else
|
|
871 |
{
|
|
872 |
TurnHighlightingOffL( aCancelFep );
|
|
873 |
if ( IsReadOnly() )
|
|
874 |
{
|
|
875 |
iTextView->SetDocPosL( cursorPos, ETrue );
|
|
876 |
}
|
|
877 |
}
|
|
878 |
}
|
|
879 |
}
|
|
880 |
|
|
881 |
// ---------------------------------------------------------
|
|
882 |
// CMsgAddressControlEditor::TurnHighlightingOffL
|
|
883 |
//
|
|
884 |
// Turns highlighting off if it happens to be on aSelection.
|
|
885 |
// ---------------------------------------------------------
|
|
886 |
//
|
|
887 |
void CMsgAddressControlEditor::TurnHighlightingOffL( TCursorSelection aSelection )
|
|
888 |
{
|
|
889 |
if ( !Selection().Length() ||
|
|
890 |
( iHighLightedFieldPos == KMsgHighlightedFieldPosNone ) )
|
|
891 |
{
|
|
892 |
return;
|
|
893 |
}
|
|
894 |
|
|
895 |
if ( IsFieldOnPos( iHighLightedFieldPos ) )
|
|
896 |
{
|
|
897 |
CancelFepTransaction();
|
|
898 |
|
|
899 |
TInt selLowerPos = aSelection.LowerPos();
|
|
900 |
// The higherPos is more close to the end of the text
|
|
901 |
TInt selHigherPos = aSelection.HigherPos();
|
|
902 |
|
|
903 |
TFindFieldInfo fieldInfo;
|
|
904 |
iRichText->FindFields( fieldInfo, iHighLightedFieldPos, 0 );
|
|
905 |
|
|
906 |
if ( ( selLowerPos >= iHighLightedFieldPos ) &&
|
|
907 |
( iHighLightedFieldPos + fieldInfo.iFirstFieldLen <= selHigherPos ) )
|
|
908 |
{
|
|
909 |
TurnHighlightingOffL();
|
|
910 |
}
|
|
911 |
}
|
|
912 |
}
|
|
913 |
|
|
914 |
// ---------------------------------------------------------
|
|
915 |
// CMsgAddressControlEditor::TurnHighlightingOffL
|
|
916 |
//
|
|
917 |
// Turns highlighting off if such a highlighted text field is somewhere.
|
|
918 |
// ---------------------------------------------------------
|
|
919 |
//
|
|
920 |
void CMsgAddressControlEditor::TurnHighlightingOffL( TBool aCancelFep /*= ETrue*/ )
|
|
921 |
{
|
|
922 |
TInt textLength = TextLength();
|
|
923 |
|
|
924 |
if ( ( iHighLightedFieldPos == KMsgHighlightedFieldPosNone ) ||
|
|
925 |
( iHighLightedFieldPos > textLength ) )
|
|
926 |
{
|
|
927 |
return;
|
|
928 |
}
|
|
929 |
|
|
930 |
if ( aCancelFep )
|
|
931 |
{
|
|
932 |
CancelFepTransaction();
|
|
933 |
}
|
|
934 |
|
|
935 |
TInt cursorPos = CursorPos();
|
|
936 |
|
|
937 |
if ( cursorPos == textLength )
|
|
938 |
{
|
|
939 |
if ( IsFieldOnPos( cursorPos - 1 ) )
|
|
940 |
{
|
|
941 |
// Remove the highlight from last cursor position only if
|
|
942 |
// there is highlightable field.
|
|
943 |
TurnHighlightingOffFromPosL( cursorPos - 1 );
|
|
944 |
}
|
|
945 |
}
|
|
946 |
|
|
947 |
TurnHighlightingOffFromPosL( iHighLightedFieldPos );
|
|
948 |
}
|
|
949 |
|
|
950 |
// ---------------------------------------------------------
|
|
951 |
// CMsgAddressControlEditor::TurnHighlightingOffFromPosL
|
|
952 |
//
|
|
953 |
// Turns highlighting off from position aPos.
|
|
954 |
// ---------------------------------------------------------
|
|
955 |
//
|
|
956 |
void CMsgAddressControlEditor::TurnHighlightingOffFromPosL( TInt aPos )
|
|
957 |
{
|
|
958 |
TInt textLength = TextLength();
|
|
959 |
|
|
960 |
if ( iHighLightedFieldPos == KMsgHighlightedFieldPosNone ||
|
|
961 |
aPos < 0 ||
|
|
962 |
aPos > textLength )
|
|
963 |
{
|
|
964 |
return;
|
|
965 |
}
|
|
966 |
|
|
967 |
TFindFieldInfo fieldInfo;
|
|
968 |
|
|
969 |
if ( !iRichText->FindFields( fieldInfo, aPos, 0 ) )
|
|
970 |
{
|
|
971 |
// iHighLightedFieldPos is not updated correctly and hence, clear whole text
|
|
972 |
fieldInfo.iFirstFieldPos = 0;
|
|
973 |
fieldInfo.iFirstFieldLen = textLength;
|
|
974 |
__ASSERT_DEBUG( EFalse, Panic( EMsgInvalidStartPos ) );
|
|
975 |
}
|
|
976 |
|
|
977 |
TCharFormat charFormat;
|
|
978 |
TCharFormatMask applyMask;
|
|
979 |
|
|
980 |
// background color.
|
|
981 |
charFormat.iFontPresentation.iHighlightColor = AKN_LAF_COLOR( 0 );
|
|
982 |
applyMask.SetAttrib( EAttFontHighlightColor );
|
|
983 |
|
|
984 |
charFormat.iFontPresentation.iHighlightStyle = TFontPresentation::EFontHighlightNone;
|
|
985 |
applyMask.SetAttrib( EAttFontHighlightStyle );
|
|
986 |
|
|
987 |
// Sets only the attributes specified to be set on mask.
|
|
988 |
iRichText->ApplyCharFormatL( charFormat,
|
|
989 |
applyMask,
|
|
990 |
fieldInfo.iFirstFieldPos,
|
|
991 |
fieldInfo.iFirstFieldLen );
|
|
992 |
|
|
993 |
if ( iTextView )
|
|
994 |
{
|
|
995 |
TCursorSelection selection( fieldInfo.iFirstFieldPos,
|
|
996 |
fieldInfo.iFirstFieldPos + fieldInfo.iFirstFieldLen );
|
|
997 |
iTextView->HandleRangeFormatChangeL( selection, EFalse );
|
|
998 |
}
|
|
999 |
|
|
1000 |
if ( iHighLightedFieldPos == aPos )
|
|
1001 |
{
|
|
1002 |
// If highlight was removed from currently highlighted position
|
|
1003 |
// reset highlighted field position.
|
|
1004 |
iHighLightedFieldPos = KMsgHighlightedFieldPosNone;
|
|
1005 |
}
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
// ---------------------------------------------------------
|
|
1009 |
// CMsgAddressControlEditor::CreateEntryStringLC
|
|
1010 |
//
|
|
1011 |
// Creates a suitable text string for the text field using strings aName and
|
|
1012 |
// aAddress and return pointer to it. If aFormat == EFalse, this function does
|
|
1013 |
// not format the string but takes only aAddess. If text string does not fit to
|
|
1014 |
// view it clips it and adds ... to end of it. If text layout does not exist
|
|
1015 |
// this function does not attempt to clip text string.
|
|
1016 |
// ---------------------------------------------------------
|
|
1017 |
//
|
|
1018 |
|
|
1019 |
HBufC* CMsgAddressControlEditor::CreateEntryStringLC(
|
|
1020 |
const TDesC& aName,
|
|
1021 |
const TDesC& aAddress,
|
|
1022 |
TBool aVerified /*= ETrue*/ )
|
|
1023 |
{
|
|
1024 |
HBufC* addressCopy = aAddress.AllocLC();
|
|
1025 |
TPtr addrTPtr = addressCopy->Des();
|
|
1026 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( addrTPtr );
|
|
1027 |
|
|
1028 |
if ( aVerified || IsReadOnly() )
|
|
1029 |
{
|
|
1030 |
TInt len = aName.Length();
|
|
1031 |
if ( len == 0 )
|
|
1032 |
{
|
|
1033 |
len = addrTPtr.Length();
|
|
1034 |
}
|
|
1035 |
|
|
1036 |
// +2 for KZeroWidthJoiner and direction marker
|
|
1037 |
HBufC* string = HBufC::NewLC( len + 2 );
|
|
1038 |
TPtr strPtr = string->Des();
|
|
1039 |
|
|
1040 |
if ( aName.Length() == 0 )
|
|
1041 |
{
|
|
1042 |
strPtr.Append( addrTPtr );
|
|
1043 |
}
|
|
1044 |
else
|
|
1045 |
{
|
|
1046 |
strPtr.Append( aName );
|
|
1047 |
}
|
|
1048 |
|
|
1049 |
TInt maxWidth = 0;
|
|
1050 |
|
|
1051 |
if ( iTextView )
|
|
1052 |
{
|
|
1053 |
// We must have iTextView because LayoutWidth calls CursorPos.
|
|
1054 |
maxWidth = LayoutWidth();
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
if ( maxWidth > 0 )
|
|
1058 |
{
|
|
1059 |
const CFont* font = TextFont();
|
|
1060 |
|
|
1061 |
if ( strPtr.Length() )
|
|
1062 |
{
|
|
1063 |
// Clip a little bit more than maxWidth to prevent wrapping.
|
|
1064 |
TInt clipWidth = Max( 0, maxWidth - 4 );
|
|
1065 |
TInt ellipsisWidth = font->CharWidthInPixels( KEllipsis );
|
|
1066 |
|
|
1067 |
TInt fits = font->TextCount( strPtr, clipWidth );
|
|
1068 |
|
|
1069 |
if ( fits < strPtr.Length() )
|
|
1070 |
{
|
|
1071 |
fits = font->TextCount( strPtr, clipWidth - ellipsisWidth );
|
|
1072 |
|
|
1073 |
// Work out the text directionality before the truncation point.
|
|
1074 |
// First put the text in reverse order and then call
|
|
1075 |
// TBidiText::TextDirectionality. This effectively tells the
|
|
1076 |
// directionality of the last strongly directional character
|
|
1077 |
// in the text.
|
|
1078 |
HBufC* temp = strPtr.Left( fits ).AllocL();
|
|
1079 |
TPtr tempPtr = temp->Des();
|
|
1080 |
|
|
1081 |
TInt i = 0;
|
|
1082 |
TInt j = tempPtr.Length() - 1;
|
|
1083 |
while ( i < j )
|
|
1084 |
{
|
|
1085 |
TText t = tempPtr[i];
|
|
1086 |
tempPtr[i++] = tempPtr[j];
|
|
1087 |
tempPtr[j--] = t;
|
|
1088 |
}
|
|
1089 |
|
|
1090 |
TBidiText::TDirectionality dir =
|
|
1091 |
TBidiText::TextDirectionality( tempPtr );
|
|
1092 |
|
|
1093 |
delete temp;
|
|
1094 |
|
|
1095 |
TText dirMarker = ( dir == TBidiText::ERightToLeft )
|
|
1096 |
? KRLMarker
|
|
1097 |
: KLRMarker;
|
|
1098 |
|
|
1099 |
// Insert zero width joiner if necessary to get the correct glyph form
|
|
1100 |
// before truncation.
|
|
1101 |
|
|
1102 |
TText lastChar = strPtr[fits - 1];
|
|
1103 |
TText next = strPtr[fits];
|
|
1104 |
|
|
1105 |
TInt ellipsisPos = fits;
|
|
1106 |
|
|
1107 |
if ( CFont::CharactersJoin( lastChar, KZeroWidthJoiner ) &&
|
|
1108 |
CFont::CharactersJoin( lastChar, next ) )
|
|
1109 |
{
|
|
1110 |
strPtr[fits] = KZeroWidthJoiner;
|
|
1111 |
ellipsisPos++;
|
|
1112 |
}
|
|
1113 |
strPtr.SetMax();
|
|
1114 |
strPtr[ellipsisPos] = KEllipsis;
|
|
1115 |
// Inserting direction marker after the ellipsis ensures that
|
|
1116 |
// the ellipsis is shown on the correct side of the text
|
|
1117 |
// before it.
|
|
1118 |
strPtr[ellipsisPos + 1] = dirMarker;
|
|
1119 |
|
|
1120 |
strPtr.SetLength( ellipsisPos + 2 );
|
|
1121 |
}
|
|
1122 |
}
|
|
1123 |
}
|
|
1124 |
|
|
1125 |
HBufC* newString = strPtr.AllocL();
|
|
1126 |
CleanupStack::PopAndDestroy( 2 ); // string, addressCopy
|
|
1127 |
|
|
1128 |
CleanupStack::PushL(newString);
|
|
1129 |
return newString;
|
|
1130 |
}
|
|
1131 |
else
|
|
1132 |
{
|
|
1133 |
HBufC* string = addrTPtr.AllocL();
|
|
1134 |
CleanupStack::PopAndDestroy(); // addressCopy
|
|
1135 |
CleanupStack::PushL( string );
|
|
1136 |
return string;
|
|
1137 |
}
|
|
1138 |
}
|
|
1139 |
|
|
1140 |
// ---------------------------------------------------------
|
|
1141 |
// CMsgAddressControlEditor::ReBuildEntryStringsL
|
|
1142 |
//
|
|
1143 |
// Re-builds all the text strings. Goes through all the fields in the
|
|
1144 |
// text and assigns a new string into them. After this we call UpdateAllFieldsL
|
|
1145 |
// to update all the fields and after this restores to cursor position
|
|
1146 |
// to old position if it is valid or to the end of the text.
|
|
1147 |
// ---------------------------------------------------------
|
|
1148 |
//
|
|
1149 |
void CMsgAddressControlEditor::ReBuildEntryStringsL()
|
|
1150 |
{
|
|
1151 |
const TInt textLength = TextLength();
|
|
1152 |
TInt length = textLength;
|
|
1153 |
TInt docPos = 0;
|
|
1154 |
TFindFieldInfo fieldInfo;
|
|
1155 |
|
|
1156 |
iCurrentEntry = EntryNumber( CursorPos() );
|
|
1157 |
|
|
1158 |
while ( length > 0 &&
|
|
1159 |
docPos < textLength &&
|
|
1160 |
iRichText->FindFields( fieldInfo, docPos, length ) )
|
|
1161 |
{
|
|
1162 |
CMsgAddressControlEditorField* field =
|
|
1163 |
const_cast<CMsgAddressControlEditorField*>( FieldFromPos( fieldInfo.iFirstFieldPos ) );
|
|
1164 |
|
|
1165 |
HBufC* string = CreateEntryStringLC( *field->Name(),
|
|
1166 |
*field->Address(),
|
|
1167 |
field->IsVerified() );
|
|
1168 |
|
|
1169 |
field->SetEntryStringL( *string );
|
|
1170 |
|
|
1171 |
CleanupStack::PopAndDestroy( string );
|
|
1172 |
|
|
1173 |
if ( fieldInfo.iFieldCountInRange == 0 ) // no more fields left within a range
|
|
1174 |
{
|
|
1175 |
break;
|
|
1176 |
}
|
|
1177 |
|
|
1178 |
docPos = fieldInfo.iFirstFieldPos + fieldInfo.iFirstFieldLen;
|
|
1179 |
length = textLength - docPos;
|
|
1180 |
}
|
|
1181 |
|
|
1182 |
if ( IsFocused() )
|
|
1183 |
{
|
|
1184 |
CancelFepTransaction();
|
|
1185 |
}
|
|
1186 |
|
|
1187 |
TInt oldCursorPos( CursorPos() );
|
|
1188 |
|
|
1189 |
// Sets cursor pos always to beginning
|
|
1190 |
UpdateAllFieldsL();
|
|
1191 |
|
|
1192 |
oldCursorPos = Min( oldCursorPos, TextLength() );
|
|
1193 |
|
|
1194 |
// Restore the original cursor position if it was
|
|
1195 |
// not out of the limit.
|
|
1196 |
SetCursorPosL( oldCursorPos, EFalse );
|
|
1197 |
}
|
|
1198 |
|
|
1199 |
// ---------------------------------------------------------
|
|
1200 |
// CMsgAddressControlEditor::Field
|
|
1201 |
//
|
|
1202 |
// Returns a field of the entry aEntryNumber. If there is no field on that entry,
|
|
1203 |
// returns NULL.
|
|
1204 |
// ---------------------------------------------------------
|
|
1205 |
//
|
|
1206 |
const CMsgAddressControlEditorField* CMsgAddressControlEditor::Field(
|
|
1207 |
TInt aEntryNumber ) const
|
|
1208 |
{
|
|
1209 |
__ASSERT_DEBUG( ( aEntryNumber >= 0 ) &&
|
|
1210 |
( aEntryNumber < iRichText->ParagraphCount() ),
|
|
1211 |
Panic( EMsgInvalidEntryNumber ) );
|
|
1212 |
|
|
1213 |
TInt entryLength = 0;
|
|
1214 |
TInt entryStart = iRichText->CharPosOfParagraph( entryLength, aEntryNumber );
|
|
1215 |
|
|
1216 |
return FieldFromPos( entryStart );
|
|
1217 |
}
|
|
1218 |
|
|
1219 |
// ---------------------------------------------------------
|
|
1220 |
// CMsgAddressControlEditor::CharAtPos
|
|
1221 |
//
|
|
1222 |
//
|
|
1223 |
// ---------------------------------------------------------
|
|
1224 |
//
|
|
1225 |
TChar CMsgAddressControlEditor::CharAtPos( TInt aPos ) const
|
|
1226 |
{
|
|
1227 |
if ( aPos >= 0 && aPos < TextLength() )
|
|
1228 |
{
|
|
1229 |
TBuf<1> buf;
|
|
1230 |
iText->Extract( buf, aPos, 1 );
|
|
1231 |
return buf[0];
|
|
1232 |
}
|
|
1233 |
else
|
|
1234 |
{
|
|
1235 |
return 0;
|
|
1236 |
}
|
|
1237 |
}
|
|
1238 |
|
|
1239 |
// ---------------------------------------------------------
|
|
1240 |
// CMsgAddressControlEditor::PrepareForViewing
|
|
1241 |
//
|
|
1242 |
// Prepares control for viewing.
|
|
1243 |
// ---------------------------------------------------------
|
|
1244 |
//
|
|
1245 |
void CMsgAddressControlEditor::PrepareForViewing()
|
|
1246 |
{
|
|
1247 |
if ( iCurrentEntry >= 0 )
|
|
1248 |
{
|
|
1249 |
TRAP_IGNORE( MoveCursorToEntryPosL(
|
|
1250 |
iCurrentEntry, EntryLength( iCurrentEntry ) ) );
|
|
1251 |
|
|
1252 |
iCurrentEntry = KMsgCurrentEntryNone;
|
|
1253 |
}
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
// ---------------------------------------------------------
|
|
1257 |
// CMsgAddressControlEditor::PreInsertEditorFormattingL
|
|
1258 |
//
|
|
1259 |
//
|
|
1260 |
// ---------------------------------------------------------
|
|
1261 |
//
|
|
1262 |
void CMsgAddressControlEditor::PreInsertEditorFormattingL( const TKeyEvent& aKeyEvent )
|
|
1263 |
{
|
|
1264 |
if ( IsFocused() && !IsReadOnly() )
|
|
1265 |
{
|
|
1266 |
TBool modified = EFalse;
|
|
1267 |
TInt editPos = CursorPos();
|
|
1268 |
|
|
1269 |
// No preinserting is done in a case edit position is over
|
|
1270 |
// text length (should not be possible) or if delete key is pressed.
|
|
1271 |
if ( editPos > TextLength() ||
|
|
1272 |
aKeyEvent.iCode == EKeyDelete )
|
|
1273 |
{
|
|
1274 |
return;
|
|
1275 |
}
|
|
1276 |
|
|
1277 |
TInt entryNumber = EntryNumber( editPos );
|
|
1278 |
TInt startPos = FirstFieldPos( editPos );
|
|
1279 |
TInt endPos = startPos + EntryLength( entryNumber );
|
|
1280 |
|
|
1281 |
if ( startPos < editPos && editPos < endPos &&
|
|
1282 |
IsEntryVerified( entryNumber ) )
|
|
1283 |
{
|
|
1284 |
// Cursor is in the middle of verified entry, se inserting not possible.
|
|
1285 |
return;
|
|
1286 |
}
|
|
1287 |
|
|
1288 |
TChar currentChar = CharAtPos( editPos );
|
|
1289 |
TChar previousChar = CharAtPos( editPos - 1 );
|
|
1290 |
|
|
1291 |
if ( IsFieldOnLeft( editPos + 1 ) ) // looking on the right, but before the key is inserted
|
|
1292 |
{
|
|
1293 |
// user is trying to add character to left of field:
|
|
1294 |
// insert paragraph delimiter in front of the field,
|
|
1295 |
// and in front of that a semicolon.
|
|
1296 |
iTextView->SetDocPosL( editPos, EFalse );
|
|
1297 |
iRichText->CancelInsertCharFormat();
|
|
1298 |
InsertParagraphL( editPos );
|
|
1299 |
InsertSemicolonL( editPos );
|
|
1300 |
modified = ETrue;
|
|
1301 |
}
|
|
1302 |
else if ( IsFieldOnLeft( editPos ) )
|
|
1303 |
{
|
|
1304 |
// user is trying to add character to right of field:
|
|
1305 |
// insert semicolon after the field if there isn't one already,
|
|
1306 |
// and after that a paragraph delimiter.
|
|
1307 |
iTextView->SetDocPosL( editPos, EFalse );
|
|
1308 |
iRichText->CancelInsertCharFormat();
|
|
1309 |
if ( currentChar != KSemicolon && currentChar != KArabicSemicolon )
|
|
1310 |
{
|
|
1311 |
InsertSemicolonL( editPos );
|
|
1312 |
}
|
|
1313 |
InsertParagraphL( ++editPos );
|
|
1314 |
editPos++;
|
|
1315 |
modified = ETrue;
|
|
1316 |
}
|
|
1317 |
else if ( ( previousChar == KSemicolon ||
|
|
1318 |
previousChar == KArabicSemicolon ) &&
|
|
1319 |
IsFieldOnLeft( editPos - 1 ) )
|
|
1320 |
{
|
|
1321 |
// user is trying to add character to right of semicolon
|
|
1322 |
// and there is field right next to it:
|
|
1323 |
// insert a paragraph delimiter after semicolon.
|
|
1324 |
iTextView->SetDocPosL( editPos, EFalse );
|
|
1325 |
iRichText->CancelInsertCharFormat();
|
|
1326 |
InsertParagraphL( editPos );
|
|
1327 |
editPos++;
|
|
1328 |
modified = ETrue;
|
|
1329 |
}
|
|
1330 |
|
|
1331 |
if ( modified )
|
|
1332 |
{
|
|
1333 |
CheckHighlightingL( EFalse );
|
|
1334 |
|
|
1335 |
TInt len = TextLength();
|
|
1336 |
if ( editPos > len )
|
|
1337 |
{
|
|
1338 |
editPos = len;
|
|
1339 |
}
|
|
1340 |
|
|
1341 |
iTextView->SetDocPosL( editPos, EFalse );
|
|
1342 |
|
|
1343 |
TViewYPosQualifier yPosQualifier;
|
|
1344 |
yPosQualifier.SetFillScreen();
|
|
1345 |
yPosQualifier.SetMakeLineFullyVisible();
|
|
1346 |
iTextView->HandleGlobalChangeL( yPosQualifier );
|
|
1347 |
|
|
1348 |
iHighLightedFieldPos = KMsgHighlightedFieldPosNone;
|
|
1349 |
}
|
|
1350 |
}
|
|
1351 |
}
|
|
1352 |
|
|
1353 |
// ---------------------------------------------------------
|
|
1354 |
// CMsgAddressControlEditor::PostInsertEditorFormattingL
|
|
1355 |
//
|
|
1356 |
//
|
|
1357 |
// ---------------------------------------------------------
|
|
1358 |
//
|
|
1359 |
void CMsgAddressControlEditor::PostInsertEditorFormattingL( TBool aDuplicateEvent )
|
|
1360 |
{
|
|
1361 |
if ( IsFocused() && !IsReadOnly() )
|
|
1362 |
{
|
|
1363 |
TInt editPos = CursorPos();
|
|
1364 |
if ( editPos > TextLength() )
|
|
1365 |
{
|
|
1366 |
return;
|
|
1367 |
}
|
|
1368 |
TChar prevChar = CharAtPos( editPos - 1 );
|
|
1369 |
|
|
1370 |
if ( !aDuplicateEvent &&
|
|
1371 |
( prevChar == KSemicolon || prevChar == KArabicSemicolon ) )
|
|
1372 |
{
|
|
1373 |
// user is at the end of a line, after a semicolon:
|
|
1374 |
// paragraph delimiter after semicolon.
|
|
1375 |
iTextView->SetDocPosL( editPos, EFalse );
|
|
1376 |
iRichText->CancelInsertCharFormat();
|
|
1377 |
InsertParagraphL( editPos++ );
|
|
1378 |
|
|
1379 |
TInt len = TextLength();
|
|
1380 |
if ( editPos > len )
|
|
1381 |
{
|
|
1382 |
editPos = len;
|
|
1383 |
}
|
|
1384 |
|
|
1385 |
iTextView->SetDocPosL( editPos, EFalse );
|
|
1386 |
|
|
1387 |
TViewYPosQualifier yPosQualifier;
|
|
1388 |
yPosQualifier.SetFillScreen();
|
|
1389 |
yPosQualifier.SetMakeLineFullyVisible();
|
|
1390 |
iTextView->HandleGlobalChangeL( yPosQualifier );
|
|
1391 |
|
|
1392 |
iHighLightedFieldPos = KMsgHighlightedFieldPosNone;
|
|
1393 |
}
|
|
1394 |
}
|
|
1395 |
}
|
|
1396 |
|
|
1397 |
// ---------------------------------------------------------
|
|
1398 |
// CMsgAddressControlEditor::CheckEditPermission
|
|
1399 |
//
|
|
1400 |
// Does edit permission check and returns its result.
|
|
1401 |
// ---------------------------------------------------------
|
|
1402 |
//
|
|
1403 |
TUint32 CMsgAddressControlEditor::CheckEditPermission() const
|
|
1404 |
{
|
|
1405 |
TUint32 editPermission = CMsgBaseControl::EMsgEditNone;
|
|
1406 |
TInt textLength = TextLength();
|
|
1407 |
TCursorSelection selection = iTextView->Selection();
|
|
1408 |
|
|
1409 |
if ( selection.Length() )
|
|
1410 |
{
|
|
1411 |
TInt selLowerPos = selection.LowerPos();
|
|
1412 |
// The higherPos is more close to the end of the text
|
|
1413 |
TInt selHigherPos = selection.HigherPos();
|
|
1414 |
TFindFieldInfo fieldInfoLower;
|
|
1415 |
TFindFieldInfo fieldInfoHigher;
|
|
1416 |
TBool lowerPosOnField(
|
|
1417 |
iRichText->FindFields( fieldInfoLower, selLowerPos, 0 ) );
|
|
1418 |
TBool higherPosOnField(
|
|
1419 |
iRichText->FindFields( fieldInfoHigher, selHigherPos, 0 ) );
|
|
1420 |
|
|
1421 |
if ( lowerPosOnField && higherPosOnField )
|
|
1422 |
{
|
|
1423 |
// Both the lowerPos and the higherPos are on a field
|
|
1424 |
if ( IsPosAtEntryBeginning( selLowerPos ) &&
|
|
1425 |
IsPosAtEntryBeginning( selHigherPos ) )
|
|
1426 |
{
|
|
1427 |
// Both positions are at the beginning of the fields
|
|
1428 |
editPermission |= CMsgAddressControl::EMsgEditParagraphDelimiter
|
|
1429 |
| CMsgAddressControl::EMsgEditBackspace
|
|
1430 |
| CMsgAddressControl::EMsgEditDelete
|
|
1431 |
| CMsgBaseControl::EMsgEditCut;
|
|
1432 |
}
|
|
1433 |
}
|
|
1434 |
else if ( lowerPosOnField )
|
|
1435 |
{
|
|
1436 |
if ( IsPosAtEntryBeginning( selLowerPos ) )
|
|
1437 |
{
|
|
1438 |
editPermission |= CMsgAddressControl::EMsgEditParagraphDelimiter
|
|
1439 |
| CMsgAddressControl::EMsgEditBackspace
|
|
1440 |
| CMsgAddressControl::EMsgEditCharInsert
|
|
1441 |
| CMsgAddressControl::EMsgEditDelete
|
|
1442 |
| CMsgBaseControl::EMsgEditCut
|
|
1443 |
| CMsgBaseControl::EMsgEditPaste;
|
|
1444 |
}
|
|
1445 |
}
|
|
1446 |
else if ( higherPosOnField )
|
|
1447 |
{
|
|
1448 |
if ( IsPosAtEntryBeginning( selHigherPos ) )
|
|
1449 |
{
|
|
1450 |
editPermission |= CMsgAddressControl::EMsgEditParagraphDelimiter;
|
|
1451 |
}
|
|
1452 |
}
|
|
1453 |
else if ( IsFieldOnLeft( selLowerPos ) )
|
|
1454 |
{
|
|
1455 |
// Neither position are on a field but the lower pos is
|
|
1456 |
// just next to a field on the right side
|
|
1457 |
editPermission |= CMsgAddressControl::EMsgEditParagraphDelimiter;
|
|
1458 |
}
|
|
1459 |
else
|
|
1460 |
{
|
|
1461 |
// Neither position are on a field
|
|
1462 |
editPermission |= CMsgAddressControl::EMsgEditCharInsert
|
|
1463 |
| CMsgAddressControl::EMsgEditParagraphDelimiter
|
|
1464 |
| CMsgAddressControl::EMsgEditBackspace
|
|
1465 |
| CMsgAddressControl::EMsgEditDelete
|
|
1466 |
| CMsgBaseControl::EMsgEditCut
|
|
1467 |
| CMsgBaseControl::EMsgEditPaste;
|
|
1468 |
}
|
|
1469 |
|
|
1470 |
// Copy is always possible
|
|
1471 |
editPermission |= CMsgBaseControl::EMsgEditCopy;
|
|
1472 |
|
|
1473 |
// BackspaceMove and RemoveEntry are never possible when selection is on
|
|
1474 |
editPermission &= ~CMsgAddressControl::EMsgEditBackspaceMove;
|
|
1475 |
editPermission &= ~CMsgAddressControl::EMsgEditRemoveEntry;
|
|
1476 |
|
|
1477 |
editPermission |=
|
|
1478 |
(selHigherPos - selLowerPos) == textLength ?
|
|
1479 |
CMsgBaseControl::EMsgEditUnSelectAll : 0;
|
|
1480 |
}
|
|
1481 |
else
|
|
1482 |
{
|
|
1483 |
// Selection is off
|
|
1484 |
TInt cursorPos = CursorPos();
|
|
1485 |
TBool posAtEntryBeginning = IsPosAtEntryBeginning( cursorPos );
|
|
1486 |
TChar ch = CharAtPos( cursorPos - 1 );
|
|
1487 |
TChar nextCh = CharAtPos( cursorPos );
|
|
1488 |
|
|
1489 |
if ( ch == CEditableText::EParagraphDelimiter )
|
|
1490 |
{
|
|
1491 |
ch = CharAtPos( cursorPos - 2 );
|
|
1492 |
}
|
|
1493 |
|
|
1494 |
TInt entryAtPos = EntryNumber( cursorPos );
|
|
1495 |
|
|
1496 |
if ( IsFieldOnPos( cursorPos ) && !posAtEntryBeginning )
|
|
1497 |
{
|
|
1498 |
// The cursor is in a field. No edit actions are allowed.
|
|
1499 |
editPermission = (TUint32) CMsgBaseControl::EMsgEditNone;
|
|
1500 |
}
|
|
1501 |
else if ( IsFieldOnLeft( cursorPos ) && !posAtEntryBeginning )
|
|
1502 |
{
|
|
1503 |
// The cursor is not on a field but just next to it on the right
|
|
1504 |
// side. Only the paragraph delimiter can be inserted or the field
|
|
1505 |
// can be removed by the backspace.
|
|
1506 |
editPermission |= CMsgAddressControl::EMsgEditParagraphDelimiter;
|
|
1507 |
editPermission |= CMsgAddressControl::EMsgEditRemoveEntry;
|
|
1508 |
editPermission |= CMsgAddressControl::EMsgEditCharInsert;
|
|
1509 |
// This should check also a situation when next entry is empty
|
|
1510 |
// and when delete is also possible.
|
|
1511 |
}
|
|
1512 |
else if ( ( ch == KSemicolon || ch == KArabicSemicolon
|
|
1513 |
|| IsPriorEntryVerified( entryAtPos ) ) && posAtEntryBeginning )
|
|
1514 |
{
|
|
1515 |
// The cursor is not in a field but just below it at the
|
|
1516 |
// beginning of the line.
|
|
1517 |
if ( IsEntryEmpty( entryAtPos ) )
|
|
1518 |
{
|
|
1519 |
// Current entry is empty. RemoveEntry and BackspaceMove
|
|
1520 |
// the edit actions are not allowed.
|
|
1521 |
editPermission = (TUint32) CMsgBaseControl::EMsgEditAll;
|
|
1522 |
editPermission &= ~CMsgAddressControl::EMsgEditBackspaceMove;
|
|
1523 |
editPermission &= ~CMsgAddressControl::EMsgEditRemoveEntry;
|
|
1524 |
}
|
|
1525 |
else
|
|
1526 |
{
|
|
1527 |
// Pressing the backspace button is allowed but no char
|
|
1528 |
// removal i.e the BackspaceMove is allowed.
|
|
1529 |
editPermission = (TUint32) CMsgBaseControl::EMsgEditAll;
|
|
1530 |
editPermission &= ~CMsgAddressControl::EMsgEditBackspace;
|
|
1531 |
editPermission &= ~CMsgAddressControl::EMsgEditRemoveEntry;
|
|
1532 |
}
|
|
1533 |
}
|
|
1534 |
else
|
|
1535 |
{
|
|
1536 |
// The cursor is somewhere else but in a field or next to it on
|
|
1537 |
// the right side. All but the RemoveEntry and BackspaceMove the
|
|
1538 |
// edit actions are allowed.
|
|
1539 |
editPermission = (TUint32) CMsgBaseControl::EMsgEditAll;
|
|
1540 |
editPermission &= ~CMsgAddressControl::EMsgEditBackspaceMove;
|
|
1541 |
editPermission &= ~CMsgAddressControl::EMsgEditRemoveEntry;
|
|
1542 |
}
|
|
1543 |
|
|
1544 |
if ( IsFieldOnRight( cursorPos ) )
|
|
1545 |
{
|
|
1546 |
// Field immediatelly on right side of curser. Delete and RemoveEntry
|
|
1547 |
// are allowed.
|
|
1548 |
editPermission |= CMsgAddressControl::EMsgEditDelete;
|
|
1549 |
editPermission |= CMsgAddressControl::EMsgEditRemoveEntry;
|
|
1550 |
}
|
|
1551 |
else if ( IsFieldOnRight( cursorPos + 1) &&
|
|
1552 |
nextCh == CEditableText::EParagraphDelimiter )
|
|
1553 |
{
|
|
1554 |
// The cursor is not in a field but just above it at the
|
|
1555 |
// end of the line.
|
|
1556 |
if ( IsEntryEmpty( entryAtPos ) )
|
|
1557 |
{
|
|
1558 |
// Current entry is empty. RemoveEntry are not allowed.
|
|
1559 |
editPermission |= CMsgAddressControl::EMsgEditDelete;
|
|
1560 |
editPermission &= ~CMsgAddressControl::EMsgEditRemoveEntry;
|
|
1561 |
}
|
|
1562 |
else
|
|
1563 |
{
|
|
1564 |
// Current entry is not empty. Delete is not allowed.
|
|
1565 |
editPermission &= ~CMsgAddressControl::EMsgEditDelete;
|
|
1566 |
}
|
|
1567 |
}
|
|
1568 |
|
|
1569 |
// Copy is never allowed when selection is off.
|
|
1570 |
editPermission &= ~CMsgBaseControl::EMsgEditCopy;
|
|
1571 |
// Cut is never allowed when selection is off.
|
|
1572 |
editPermission &= ~CMsgBaseControl::EMsgEditCut;
|
|
1573 |
// UnSelectAll is never allowed when selection is off.
|
|
1574 |
editPermission &= ~CMsgBaseControl::EMsgEditUnSelectAll;
|
|
1575 |
}
|
|
1576 |
|
|
1577 |
editPermission &= ~CMsgBaseControl::EMsgEditUndo; // Undo is never allowed.
|
|
1578 |
|
|
1579 |
if ( textLength )
|
|
1580 |
{
|
|
1581 |
editPermission |= CMsgBaseControl::EMsgEditSelectAll;
|
|
1582 |
}
|
|
1583 |
else
|
|
1584 |
{
|
|
1585 |
editPermission &= ~CMsgBaseControl::EMsgEditSelectAll;
|
|
1586 |
}
|
|
1587 |
|
|
1588 |
if ( IsReadOnly() )
|
|
1589 |
{
|
|
1590 |
editPermission &= ~CMsgBaseControl::EMsgEditPaste;
|
|
1591 |
editPermission &= ~CMsgBaseControl::EMsgEditCut;
|
|
1592 |
editPermission &= ~CMsgAddressControl::EMsgEditRemoveEntry;
|
|
1593 |
editPermission &= ~CMsgAddressControl::EMsgEditParagraphDelimiter;
|
|
1594 |
editPermission &= ~CMsgAddressControl::EMsgEditCharInsert;
|
|
1595 |
}
|
|
1596 |
|
|
1597 |
return editPermission;
|
|
1598 |
}
|
|
1599 |
|
|
1600 |
// ---------------------------------------------------------
|
|
1601 |
// CMsgAddressControlEditor::ConstructFromResourceL
|
|
1602 |
//
|
|
1603 |
// Creates this control from resource.
|
|
1604 |
// ---------------------------------------------------------
|
|
1605 |
//
|
|
1606 |
void CMsgAddressControlEditor::ConstructFromResourceL( TResourceReader& aReader )
|
|
1607 |
{
|
|
1608 |
// This used to be font id. Not used anymore. Have to read it, though.
|
|
1609 |
/*TInt fontId =*/ aReader.ReadInt32();
|
|
1610 |
|
|
1611 |
ConstructL();
|
|
1612 |
|
|
1613 |
iAddressControlEditorFieldFactory =
|
|
1614 |
new ( ELeave ) TMsgAddressControlEditorFieldFactory();
|
|
1615 |
|
|
1616 |
if ( !IsReadOnly() )
|
|
1617 |
{
|
|
1618 |
ReadAknResourceL( aReader );
|
|
1619 |
}
|
|
1620 |
}
|
|
1621 |
|
|
1622 |
// ---------------------------------------------------------
|
|
1623 |
// CMsgAddressControlEditor::SetAndGetSizeL
|
|
1624 |
//
|
|
1625 |
// Calculates and sets the size of the control and returns new size as
|
|
1626 |
// reference aSize. Sets maximum height for editor to be maximum
|
|
1627 |
// body height. If our height has already been set then uses the current
|
|
1628 |
// one since edwin will decide internally what is the correct height and
|
|
1629 |
// report this through HandleEdwinSizeEventL observer interface.
|
|
1630 |
// After all this finally set the size to
|
|
1631 |
// edwin. This might cause reformatting so after this we need to check
|
|
1632 |
// whether we are band formatting and set the size to maximum body height
|
|
1633 |
// if we are since edwin will not report height change through HandleEdwinSizeEventL
|
|
1634 |
// when band formatting is enabled.
|
|
1635 |
// ---------------------------------------------------------
|
|
1636 |
//
|
|
1637 |
void CMsgAddressControlEditor::SetAndGetSizeL( TSize& aSize )
|
|
1638 |
{
|
|
1639 |
TSize controlSize( aSize );
|
|
1640 |
|
|
1641 |
if ( iSize.iHeight > 0 )
|
|
1642 |
{
|
|
1643 |
controlSize.iHeight = iSize.iHeight;
|
|
1644 |
}
|
|
1645 |
|
|
1646 |
CMsgExpandableControlEditor::SetAndGetSizeL( aSize );
|
|
1647 |
|
|
1648 |
// Make sure that if we are band formatting editor size is set
|
|
1649 |
// to maximum body height. Will not do any harm resetting this
|
|
1650 |
// even if we already are at maximum body height.
|
|
1651 |
if ( TextLayout() && TextLayout()->IsFormattingBand() )
|
|
1652 |
{
|
|
1653 |
controlSize.iHeight = MaximumHeight();
|
|
1654 |
SetSizeWithoutNotification( controlSize );
|
|
1655 |
}
|
|
1656 |
|
|
1657 |
aSize = iSize;
|
|
1658 |
}
|
|
1659 |
|
|
1660 |
// ---------------------------------------------------------
|
|
1661 |
// CMsgAddressControlEditor::OfferKeyEventL
|
|
1662 |
//
|
|
1663 |
// Handles key event.
|
|
1664 |
// ---------------------------------------------------------
|
|
1665 |
//
|
|
1666 |
TKeyResponse CMsgAddressControlEditor::OfferKeyEventL(
|
|
1667 |
const TKeyEvent& aKeyEvent, TEventCode aType )
|
|
1668 |
{
|
|
1669 |
if ( IsReadOnly() &&
|
|
1670 |
( aKeyEvent.iCode == EKeyUpArrow ||
|
|
1671 |
aKeyEvent.iCode == EKeyEnter ||
|
|
1672 |
aKeyEvent.iCode == EKeyDevice3 ) &&
|
|
1673 |
iValidHighlightable )
|
|
1674 |
{
|
|
1675 |
if ( aKeyEvent.iCode == EKeyDevice3
|
|
1676 |
&& iFindItemEventReceived )
|
|
1677 |
{
|
|
1678 |
// Find item was activated by touch,
|
|
1679 |
// no need to restore highlight
|
|
1680 |
iFindItemEventReceived = EFalse;
|
|
1681 |
return EKeyWasNotConsumed;
|
|
1682 |
}
|
|
1683 |
|
|
1684 |
if ( !SelectionLength() )
|
|
1685 |
{
|
|
1686 |
// Enable highlight if hw keys used
|
|
1687 |
CheckHighlightingL();
|
|
1688 |
}
|
|
1689 |
return EKeyWasConsumed;
|
|
1690 |
}
|
|
1691 |
return CMsgExpandableControlEditor::OfferKeyEventL( aKeyEvent, aType );
|
|
1692 |
}
|
|
1693 |
|
|
1694 |
// ---------------------------------------------------------
|
|
1695 |
// CMsgAddressControlEditor::HandlePointerEventL
|
|
1696 |
//
|
|
1697 |
// Handles pointer events. Sets handling pointer event flag on during
|
|
1698 |
// edwin pointer event handling so that callbacks from edwin can
|
|
1699 |
// use this information.
|
|
1700 |
// In readonly mode:
|
|
1701 |
// On button down event when automatic find is
|
|
1702 |
// activated stores the previously focused field if there is one.
|
|
1703 |
// On button up event checks whether same field is still focused.
|
|
1704 |
// If user has tapped already focused field again selection key menu
|
|
1705 |
// is launched by simulating key event into it.
|
|
1706 |
// In non-readonly mode:
|
|
1707 |
// If user taps in the middle of validated recipient field cursor
|
|
1708 |
// is moved to the beginning of that field if it is not already located
|
|
1709 |
// there. Also highlight is checked.
|
|
1710 |
// ---------------------------------------------------------
|
|
1711 |
//
|
|
1712 |
#ifdef RD_SCALABLE_UI_V2
|
|
1713 |
void CMsgAddressControlEditor::HandlePointerEventL( const TPointerEvent& aPointerEvent )
|
|
1714 |
{
|
|
1715 |
iHandlingPointerEvent = ETrue;
|
|
1716 |
|
|
1717 |
TBool forwardRequest( ETrue );
|
|
1718 |
|
|
1719 |
if ( IsReadOnly() )
|
|
1720 |
{
|
|
1721 |
if ( iValidHighlightable &&
|
|
1722 |
( aPointerEvent.iType == TPointerEvent::EButton1Down ||
|
|
1723 |
aPointerEvent.iType == TPointerEvent::EButton1Up ) )
|
|
1724 |
{
|
|
1725 |
TPoint tapPoint( aPointerEvent.iPosition );
|
|
1726 |
TInt docPos( TextView()->XyPosToDocPosL( tapPoint ) );
|
|
1727 |
|
|
1728 |
const CMsgAddressControlEditorField* currentField = FieldFromPos( docPos );
|
|
1729 |
|
|
1730 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
|
|
1731 |
{
|
|
1732 |
iPreviousField = currentField;
|
|
1733 |
|
|
1734 |
if ( iPreviousField &&
|
|
1735 |
!iPreviousField->IsVerified() )
|
|
1736 |
{
|
|
1737 |
iPreviousField = NULL;
|
|
1738 |
}
|
|
1739 |
else
|
|
1740 |
{
|
|
1741 |
forwardRequest = EFalse;
|
|
1742 |
|
|
1743 |
if ( docPos < TextLength() )
|
|
1744 |
{
|
|
1745 |
// Enable highlight on pointer down
|
|
1746 |
CheckHighlightingL();
|
|
1747 |
}
|
|
1748 |
}
|
|
1749 |
}
|
|
1750 |
else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
|
|
1751 |
{
|
|
1752 |
if ( currentField &&
|
|
1753 |
iPreviousField == currentField )
|
|
1754 |
{
|
|
1755 |
// Addressfield text was clicked, we will send simulated key event for
|
|
1756 |
// opening context sensitive menu in AppUI::HandleKeyEvent
|
|
1757 |
TKeyEvent event;
|
|
1758 |
event.iCode = EKeyDevice3;
|
|
1759 |
event.iScanCode = EKeyDevice3;
|
|
1760 |
event.iModifiers = 0;
|
|
1761 |
event.iRepeats = 0;
|
|
1762 |
|
|
1763 |
forwardRequest = EFalse;
|
|
1764 |
iFindItemEventReceived = ETrue;
|
|
1765 |
iCoeEnv->WsSession().SimulateKeyEvent( event );
|
|
1766 |
}
|
|
1767 |
|
|
1768 |
if ( SelectionLength() )
|
|
1769 |
{
|
|
1770 |
// Disable highlight on pointer up
|
|
1771 |
ClearSelectionL();
|
|
1772 |
}
|
|
1773 |
}
|
|
1774 |
}
|
|
1775 |
}
|
|
1776 |
else
|
|
1777 |
{
|
|
1778 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down ||
|
|
1779 |
aPointerEvent.iType == TPointerEvent::EButton1Up )
|
|
1780 |
{
|
|
1781 |
TPoint tapPoint( aPointerEvent.iPosition );
|
|
1782 |
TInt docPos( TextView()->XyPosToDocPosL( tapPoint ) );
|
|
1783 |
|
|
1784 |
const CMsgAddressControlEditorField* currentField = FieldFromPos( docPos );
|
|
1785 |
|
|
1786 |
if ( currentField &&
|
|
1787 |
currentField->IsVerified() )
|
|
1788 |
{
|
|
1789 |
// forwardRequest = EFalse;
|
|
1790 |
TInt entryStartPos = EntryStartPos( EntryNumber( docPos ) );
|
|
1791 |
if ( entryStartPos != CursorPos() )
|
|
1792 |
{
|
|
1793 |
SetCursorPosL( entryStartPos, EFalse );
|
|
1794 |
CheckHighlightingL();
|
|
1795 |
}
|
|
1796 |
}
|
|
1797 |
}
|
|
1798 |
}
|
|
1799 |
|
|
1800 |
if ( forwardRequest )
|
|
1801 |
{
|
|
1802 |
CMsgExpandableControlEditor::HandlePointerEventL( aPointerEvent );
|
|
1803 |
}
|
|
1804 |
#ifdef RD_TACTILE_FEEDBACK
|
|
1805 |
else if( aPointerEvent.iType == TPointerEvent::EButton1Down
|
|
1806 |
&& SelectionLength() )
|
|
1807 |
{
|
|
1808 |
MTouchFeedback* feedback = MTouchFeedback::Instance();
|
|
1809 |
if ( feedback )
|
|
1810 |
{
|
|
1811 |
feedback->InstantFeedback( this, ETouchFeedbackBasic );
|
|
1812 |
}
|
|
1813 |
}
|
|
1814 |
#endif
|
|
1815 |
|
|
1816 |
iHandlingPointerEvent = EFalse;
|
|
1817 |
}
|
|
1818 |
#else
|
|
1819 |
void CMsgAddressControlEditor::HandlePointerEventL( const TPointerEvent& /*aPointerEvent*/ )
|
|
1820 |
{
|
|
1821 |
}
|
|
1822 |
#endif // RD_SCALABLE_UI_V2
|
|
1823 |
|
|
1824 |
// ---------------------------------------------------------
|
|
1825 |
// CMsgAddressControlEditor::HandleResourceChange
|
|
1826 |
//
|
|
1827 |
// During layout switching if editor contains text highlight is
|
|
1828 |
// turned off and entry string are rebuild as width of the editor
|
|
1829 |
// might have changed. Also underlining is checked.
|
|
1830 |
// ---------------------------------------------------------
|
|
1831 |
//
|
|
1832 |
void CMsgAddressControlEditor::HandleResourceChange( TInt aType )
|
|
1833 |
{
|
|
1834 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
1835 |
{
|
|
1836 |
CMsgExpandableControlEditor::HandleResourceChange( aType );
|
|
1837 |
|
|
1838 |
//SKIM-7NKC4B
|
|
1839 |
/*if ( TextLength() > 0 )
|
|
1840 |
{
|
|
1841 |
TRAP_IGNORE(
|
|
1842 |
{
|
|
1843 |
TurnHighlightingOffL();
|
|
1844 |
ReBuildEntryStringsL();
|
|
1845 |
|
|
1846 |
CheckUnderliningL();
|
|
1847 |
|
|
1848 |
if ( IsFocused() )
|
|
1849 |
{
|
|
1850 |
CheckHighlightingL( EFalse );
|
|
1851 |
}
|
|
1852 |
} );
|
|
1853 |
}
|
|
1854 |
*/
|
|
1855 |
}
|
|
1856 |
else
|
|
1857 |
{
|
|
1858 |
CMsgExpandableControlEditor::HandleResourceChange( aType );
|
|
1859 |
}
|
|
1860 |
}
|
|
1861 |
|
|
1862 |
// ---------------------------------------------------------
|
|
1863 |
// CMsgAddressControlEditor::InsertParagraphL
|
|
1864 |
//
|
|
1865 |
//
|
|
1866 |
// ---------------------------------------------------------
|
|
1867 |
//
|
|
1868 |
void CMsgAddressControlEditor::InsertParagraphL( TInt aPos )
|
|
1869 |
{
|
|
1870 |
iRichText->InsertL( aPos, CEditableText::EParagraphDelimiter );
|
|
1871 |
iTextView->HandleCharEditL( CTextLayout::EFParagraphDelimiter );
|
|
1872 |
}
|
|
1873 |
|
|
1874 |
// ---------------------------------------------------------
|
|
1875 |
// CMsgAddressControlEditor::InsertSemicolonL
|
|
1876 |
//
|
|
1877 |
//
|
|
1878 |
// ---------------------------------------------------------
|
|
1879 |
//
|
|
1880 |
void CMsgAddressControlEditor::InsertSemicolonL( TInt aPos )
|
|
1881 |
{
|
|
1882 |
TInt langcode = CAknEnv::Static()->SettingCache().InputLanguage();
|
|
1883 |
TChar semicolon = ( langcode == ELangArabic )
|
|
1884 |
? KArabicSemicolon
|
|
1885 |
: KSemicolon;
|
|
1886 |
|
|
1887 |
iRichText->InsertL( aPos, semicolon );
|
|
1888 |
iTextView->HandleCharEditL( CTextLayout::EFCharacterInsert );
|
|
1889 |
}
|
|
1890 |
|
|
1891 |
// ---------------------------------------------------------
|
|
1892 |
// CMsgAddressControlEditor::CcpuPasteL
|
|
1893 |
//
|
|
1894 |
//
|
|
1895 |
// ---------------------------------------------------------
|
|
1896 |
//
|
|
1897 |
void CMsgAddressControlEditor::CcpuPasteL()
|
|
1898 |
{
|
|
1899 |
TInt cursorPos = CursorPos();
|
|
1900 |
TChar ch = CharAtPos ( cursorPos );
|
|
1901 |
|
|
1902 |
if ( ch == KSemicolon || ch == KArabicSemicolon )
|
|
1903 |
{
|
|
1904 |
iRichText->CancelInsertCharFormat();
|
|
1905 |
iRichText->InsertL(cursorPos, CEditableText::EParagraphDelimiter);
|
|
1906 |
iTextView->HandleCharEditL( CTextLayout::EFParagraphDelimiter );
|
|
1907 |
}
|
|
1908 |
|
|
1909 |
CMsgExpandableControlEditor::CcpuPasteL();
|
|
1910 |
}
|
|
1911 |
|
|
1912 |
// ---------------------------------------------------------
|
|
1913 |
// CMsgAddressControlEditor::SetAddressFieldAutoHighlight
|
|
1914 |
//
|
|
1915 |
//
|
|
1916 |
// ---------------------------------------------------------
|
|
1917 |
//
|
|
1918 |
void CMsgAddressControlEditor::SetAddressFieldAutoHighlight( TBool aValidHighlightable )
|
|
1919 |
{
|
|
1920 |
if ( iValidHighlightable != aValidHighlightable && !aValidHighlightable )
|
|
1921 |
{
|
|
1922 |
// Automatic find turned off -> cancel selection
|
|
1923 |
TRAP_IGNORE( ClearSelectionL() );
|
|
1924 |
}
|
|
1925 |
iValidHighlightable = aValidHighlightable;
|
|
1926 |
|
|
1927 |
TRAP_IGNORE( CheckUnderliningL() );
|
|
1928 |
}
|
|
1929 |
|
|
1930 |
// ---------------------------------------------------------
|
|
1931 |
// CMsgAddressControlEditor::CheckUnderliningL
|
|
1932 |
//
|
|
1933 |
//
|
|
1934 |
// ---------------------------------------------------------
|
|
1935 |
//
|
|
1936 |
void CMsgAddressControlEditor::CheckUnderliningL()
|
|
1937 |
{
|
|
1938 |
TInt textLength = TextLength();
|
|
1939 |
TInt length = textLength;
|
|
1940 |
TInt docPos = 0;
|
|
1941 |
TFindFieldInfo fieldInfo;
|
|
1942 |
|
|
1943 |
while ( length > 0 &&
|
|
1944 |
docPos < textLength &&
|
|
1945 |
iRichText->FindFields( fieldInfo, docPos, length ) )
|
|
1946 |
{
|
|
1947 |
TCharFormat currentCharFormat;
|
|
1948 |
TCharFormatMask currentCharMask;
|
|
1949 |
|
|
1950 |
TCharFormat newCharFormat;
|
|
1951 |
TCharFormatMask newCharMask;
|
|
1952 |
|
|
1953 |
iRichText->GetCharFormat( currentCharFormat,
|
|
1954 |
currentCharMask,
|
|
1955 |
fieldInfo.iFirstFieldPos,
|
|
1956 |
fieldInfo.iFirstFieldLen );
|
|
1957 |
|
|
1958 |
if ( iValidHighlightable )
|
|
1959 |
{
|
|
1960 |
if ( currentCharFormat.iFontPresentation.iUnderline != EUnderlineOn )
|
|
1961 |
{
|
|
1962 |
newCharFormat.iFontPresentation.iUnderline = EUnderlineOn;
|
|
1963 |
newCharMask.SetAttrib( EAttFontUnderline );
|
|
1964 |
}
|
|
1965 |
}
|
|
1966 |
else
|
|
1967 |
{
|
|
1968 |
if ( currentCharFormat.iFontPresentation.iUnderline != EUnderlineOff )
|
|
1969 |
{
|
|
1970 |
newCharFormat.iFontPresentation.iUnderline = EUnderlineOff;
|
|
1971 |
newCharMask.SetAttrib( EAttFontUnderline );
|
|
1972 |
}
|
|
1973 |
}
|
|
1974 |
|
|
1975 |
if ( newCharMask.AttribIsSet( EAttFontUnderline ) )
|
|
1976 |
{
|
|
1977 |
iRichText->ApplyCharFormatL( newCharFormat,
|
|
1978 |
newCharMask,
|
|
1979 |
fieldInfo.iFirstFieldPos,
|
|
1980 |
fieldInfo.iFirstFieldLen );
|
|
1981 |
}
|
|
1982 |
|
|
1983 |
if ( fieldInfo.iFieldCountInRange == 0 ) // no more fields left within a range
|
|
1984 |
{
|
|
1985 |
break;
|
|
1986 |
}
|
|
1987 |
|
|
1988 |
docPos = fieldInfo.iFirstFieldPos + fieldInfo.iFirstFieldLen;
|
|
1989 |
length = textLength - docPos;
|
|
1990 |
}
|
|
1991 |
}
|
|
1992 |
|
|
1993 |
// ---------------------------------------------------------
|
|
1994 |
// CMsgAddressControlEditor::PrepareForReadOnlyL
|
|
1995 |
// ---------------------------------------------------------
|
|
1996 |
//
|
|
1997 |
void CMsgAddressControlEditor::PrepareForReadOnlyL( TBool aReadOnly )
|
|
1998 |
{
|
|
1999 |
if ( IsReadOnly() == aReadOnly )
|
|
2000 |
{
|
|
2001 |
return;
|
|
2002 |
}
|
|
2003 |
|
|
2004 |
if ( aReadOnly )
|
|
2005 |
{
|
|
2006 |
#ifdef RD_SCALABLE_UI_V2
|
|
2007 |
SetHighlightStyleL( EEikEdwinHighlightLink );
|
|
2008 |
#endif
|
|
2009 |
|
|
2010 |
SetWordWrapL( EFalse );
|
|
2011 |
}
|
|
2012 |
|
|
2013 |
CMsgExpandableControlEditor::PrepareForReadOnlyL( aReadOnly );
|
|
2014 |
}
|
|
2015 |
|
|
2016 |
// End of File
|