|
1 /* |
|
2 * Copyright (c) 2003 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "AknRichTextPhoneNumberInlineTextSource.h" |
|
22 #include <finditemengine.h> |
|
23 |
|
24 // MODULE TEMPLATES |
|
25 |
|
26 // MODULE DATA STRUCTURES |
|
27 |
|
28 const TInt KInitialRichTextPhoneNumberGroupingSize(10); |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 //////////////////////////////////////////////////////////////////////////////// |
|
33 // |
|
34 // CAknRichTextPhoneNumberInlineTextSource |
|
35 // |
|
36 //////////////////////////////////////////////////////////////////////////////// |
|
37 |
|
38 CAknRichTextPhoneNumberInlineTextSource* CAknRichTextPhoneNumberInlineTextSource::NewL( |
|
39 const CRichText& aRichText ) |
|
40 { |
|
41 CAknRichTextPhoneNumberInlineTextSource* self = |
|
42 new (ELeave) CAknRichTextPhoneNumberInlineTextSource( aRichText ); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 void CAknRichTextPhoneNumberInlineTextSource::ConstructL() |
|
50 { |
|
51 iFindItemEngine = CFindItemEngine::NewL( KNullDesC, CFindItemEngine::EFindItemSearchPhoneNumberBin ); |
|
52 ConstructNumberGroupingEngineL( KInitialRichTextPhoneNumberGroupingSize ); |
|
53 CAknPhoneNumberInlineTextSource::ConstructL(); |
|
54 } |
|
55 |
|
56 CAknRichTextPhoneNumberInlineTextSource::~CAknRichTextPhoneNumberInlineTextSource() |
|
57 { |
|
58 delete iFindItemEngine; |
|
59 } |
|
60 |
|
61 void CAknRichTextPhoneNumberInlineTextSource::EditObserver( TInt /*aStart*/, TInt /*aExtent*/ ) |
|
62 { |
|
63 InlineTextStore()->Clear(); |
|
64 |
|
65 TInt nFound = 0; |
|
66 TRAP_IGNORE( nFound = iFindItemEngine->DoNewSearchL( |
|
67 Text().Read(0), |
|
68 CFindItemEngine::EFindItemSearchPhoneNumberBin ) ); |
|
69 |
|
70 if ( nFound > 0 ) |
|
71 { |
|
72 const CArrayFixFlat<CFindItemEngine::SFoundItem>* itemArray = iFindItemEngine->ItemArray(); |
|
73 |
|
74 for ( TInt index = 0; index < nFound; index++ ) |
|
75 { |
|
76 const CFindItemEngine::SFoundItem& findItem = itemArray->At(index); |
|
77 TPtrC ptr( Text().Read(findItem.iStartPos, findItem.iLength ) ); |
|
78 |
|
79 // Additional checks on the validity of the phone number: |
|
80 if ( FollowingCharIsValid(findItem.iStartPos + findItem.iLength) ) |
|
81 { |
|
82 TRAP_IGNORE( FormatPhoneNumberL( ptr, findItem.iStartPos ) ); |
|
83 } |
|
84 |
|
85 } |
|
86 } |
|
87 |
|
88 #ifdef INLINE_EDIT_DUMPING |
|
89 // Dumping code |
|
90 TBuf<80> buf; |
|
91 RDebug::Print(_L("\nDump of inline texts")); |
|
92 for ( TInt index = 0; index < iInlineTextStore->Count(); index++) |
|
93 { |
|
94 |
|
95 CAknPositionedInlineText* inlineText = iInlineTextStore->At( index ); |
|
96 TPtrC ptr = inlineText->InlineText(); |
|
97 buf.Format( _L("DocPos: %d Trailing/Leading: %d Text=<%S>"), |
|
98 inlineText->DocPos().iPos, |
|
99 inlineText->DocPos().iLeadingEdge, &ptr ); |
|
100 |
|
101 RDebug::Print( buf ); |
|
102 } |
|
103 #endif |
|
104 |
|
105 } |
|
106 |
|
107 CAknRichTextPhoneNumberInlineTextSource::CAknRichTextPhoneNumberInlineTextSource( |
|
108 const CRichText& aText ) |
|
109 : CAknPhoneNumberInlineTextSource(aText) |
|
110 {} |
|
111 |
|
112 TBool CAknRichTextPhoneNumberInlineTextSource::FollowingCharIsValid( TInt aNextPos ) const |
|
113 { |
|
114 // We must be just at the end. There is no next character |
|
115 if ( aNextPos >= Text().DocumentLength() ) |
|
116 return ETrue; |
|
117 |
|
118 TPtrC ptr( Text().Read( aNextPos, 1 ) ); |
|
119 if ( ptr[0] == '@' ) |
|
120 return EFalse; |
|
121 |
|
122 return ETrue; |
|
123 } |
|
124 |
|
125 // End of File |