|
1 /* |
|
2 * Copyright (c) 2008 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 default phone number formatter. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include "CFscDefaultPhoneNumberFormatter.h" |
|
21 |
|
22 // System includes |
|
23 #include <AknUtils.h> |
|
24 |
|
25 // -------------------------------------------------------------------------- |
|
26 // CFscDefaultPhoneNumberFormatter::CFscDefaultPhoneNumberFormatter |
|
27 // -------------------------------------------------------------------------- |
|
28 // |
|
29 CFscDefaultPhoneNumberFormatter::CFscDefaultPhoneNumberFormatter() |
|
30 { |
|
31 FUNC_LOG; |
|
32 } |
|
33 |
|
34 // -------------------------------------------------------------------------- |
|
35 // CFscDefaultPhoneNumberFormatter::~CFscDefaultPhoneNumberFormatter |
|
36 // -------------------------------------------------------------------------- |
|
37 // |
|
38 CFscDefaultPhoneNumberFormatter::~CFscDefaultPhoneNumberFormatter() |
|
39 { |
|
40 FUNC_LOG; |
|
41 delete iFormatterNumberBuffer; |
|
42 } |
|
43 |
|
44 // -------------------------------------------------------------------------- |
|
45 // CFscDefaultPhoneNumberFormatter::ConstructL |
|
46 // -------------------------------------------------------------------------- |
|
47 // |
|
48 void CFscDefaultPhoneNumberFormatter::ConstructL |
|
49 ( TInt aMaxDisplayLength ) |
|
50 { |
|
51 FUNC_LOG; |
|
52 iFormatterNumberBuffer = HBufC::NewL( aMaxDisplayLength ); |
|
53 } |
|
54 |
|
55 // -------------------------------------------------------------------------- |
|
56 // CFscDefaultPhoneNumberFormatter::NewL |
|
57 // -------------------------------------------------------------------------- |
|
58 // |
|
59 CFscDefaultPhoneNumberFormatter* CFscDefaultPhoneNumberFormatter::NewL |
|
60 ( TInt aMaxDisplayLength ) |
|
61 { |
|
62 FUNC_LOG; |
|
63 CFscDefaultPhoneNumberFormatter* self = |
|
64 new( ELeave ) CFscDefaultPhoneNumberFormatter; |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL( aMaxDisplayLength ); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // -------------------------------------------------------------------------- |
|
72 // CFscDefaultPhoneNumberFormatter::SetMaxBufferLengthL |
|
73 // -------------------------------------------------------------------------- |
|
74 // |
|
75 void CFscDefaultPhoneNumberFormatter::SetMaxBufferLengthL( TInt aMaxLength ) |
|
76 { |
|
77 FUNC_LOG; |
|
78 if ( aMaxLength > iFormatterNumberBuffer->Des().MaxLength() ) |
|
79 { |
|
80 iFormatterNumberBuffer = |
|
81 iFormatterNumberBuffer->ReAllocL( aMaxLength ); |
|
82 } |
|
83 } |
|
84 |
|
85 // -------------------------------------------------------------------------- |
|
86 // CFscDefaultPhoneNumberFormatter::FormatPhoneNumberForDisplay |
|
87 // -------------------------------------------------------------------------- |
|
88 // |
|
89 TPtrC CFscDefaultPhoneNumberFormatter::FormatPhoneNumberForDisplay |
|
90 ( const TDesC& aOriginalPhoneNumber ) |
|
91 { |
|
92 FUNC_LOG; |
|
93 // Convert number according to active number setting |
|
94 if ( aOriginalPhoneNumber.Length() <= |
|
95 iFormatterNumberBuffer->Des().MaxLength() ) |
|
96 { |
|
97 TPtr formatterNumber = iFormatterNumberBuffer->Des(); |
|
98 formatterNumber.Copy( aOriginalPhoneNumber ); |
|
99 AknTextUtils::DisplayTextLanguageSpecificNumberConversion |
|
100 ( formatterNumber ); |
|
101 return formatterNumber; |
|
102 } |
|
103 else |
|
104 { |
|
105 return aOriginalPhoneNumber; |
|
106 } |
|
107 } |
|
108 |
|
109 // End of File |
|
110 |