|
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: |
|
15 * Utility class for phone number formatting. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __CPhoneNumberFormat_H__ |
|
21 #define __CPhoneNumberFormat_H__ |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <AknUtils.h> |
|
26 #include <NumberGrouping.h> |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // MACROS |
|
31 |
|
32 // DATA TYPES |
|
33 enum TFormatResult |
|
34 { |
|
35 EResultOK, // No loss of precision on formatting. |
|
36 EResultTruncated, // result descriptor truncated from the start. |
|
37 EResultClipped, // result descriptor truncated and extra dots added to start |
|
38 }; |
|
39 |
|
40 // FUNCTION PROTOTYPES |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 class CFont; |
|
44 class CEikFormattedCellListBox; |
|
45 class CEikColumnListBox; |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * Class for phone number formatting |
|
51 */ |
|
52 class CPhoneNumberFormat :public CBase |
|
53 { |
|
54 public: // Constructors and destructor |
|
55 |
|
56 /** |
|
57 * Symbian OS constructor |
|
58 * @return new object |
|
59 */ |
|
60 static CPhoneNumberFormat* NewL(); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 virtual ~CPhoneNumberFormat(); |
|
66 |
|
67 public: |
|
68 /** |
|
69 * Strip DTMF post and prefix from phone number |
|
70 * @param aNumberToFormat, input buffer |
|
71 * @param aFormattedString, output buffer |
|
72 * @return KErrNone if number stripped ok or nothing to strip |
|
73 * @return KErrParameter if invalid number given for formatter. |
|
74 * In this error situation output buffer = input buffer. |
|
75 */ |
|
76 static TInt DTMFStrip( TPtrC aNumberToFormat, TDes& aFormattedString ); |
|
77 |
|
78 /** |
|
79 * Identify DTMF character(w,W,p,P). |
|
80 */ |
|
81 static TInt IsDtmf( TChar aChar ); |
|
82 |
|
83 /** |
|
84 * Identify SS character(*,#). |
|
85 */ |
|
86 static TInt IsSS( TChar aChar ); |
|
87 |
|
88 |
|
89 /** |
|
90 * Phone number formatting |
|
91 * @param aNumberToFormat phone number in string to format |
|
92 * @param aFormattedString formatted number |
|
93 * @return EResultOK |
|
94 * EResultTruncated |
|
95 * EResultClipped |
|
96 */ |
|
97 TFormatResult PhoneNumberFormat |
|
98 ( TPtrC aNumberToFormat |
|
99 , TDes& aFormattedString |
|
100 ); |
|
101 |
|
102 /** |
|
103 * Phone number formatting |
|
104 * @param aNumberToFormat phone number in string to format |
|
105 * @param aFormattedString formatted number |
|
106 * @param aFont |
|
107 * @param aPixelWidth width in pixels, long numbers are clipped from the beginging |
|
108 * of descriptor. |
|
109 * @return EResultOK |
|
110 * EResultTruncated |
|
111 * EResultClipped |
|
112 */ |
|
113 TFormatResult PhoneNumberFormat |
|
114 ( TPtrC aNumberToFormat |
|
115 , TDes& aFormattedString |
|
116 , const CFont* aFont |
|
117 , TInt aPixelWidth |
|
118 ); |
|
119 |
|
120 TFormatResult PhoneNumberFormat |
|
121 ( TPtrC aNumberToFormat |
|
122 , TDes& aFormattedString |
|
123 , AknTextUtils::TClipDirection aClipDirection |
|
124 , CEikFormattedCellListBox *aListBox |
|
125 , TInt aItemIndex |
|
126 , TInt aSubCellNumber |
|
127 ); |
|
128 |
|
129 TFormatResult PhoneNumberFormat |
|
130 ( TPtrC aNumberToFormat |
|
131 , TDes& aFormattedString |
|
132 , AknTextUtils::TClipDirection aClipDirection |
|
133 , CEikColumnListBox *aListBox |
|
134 , TInt aItemIndex |
|
135 , TInt aColumnNumber |
|
136 ); |
|
137 |
|
138 private: |
|
139 |
|
140 //Constructors are private by default |
|
141 CPhoneNumberFormat(); |
|
142 void ConstructL(); |
|
143 |
|
144 TFormatResult DescriptorCopy( const TDesC& aSource, TDes& aDestination ); |
|
145 |
|
146 private: // Data |
|
147 /// Own: grouping number grouping |
|
148 CPNGNumberGrouping* iNumberGrouping; |
|
149 }; |
|
150 |
|
151 #endif // __CPhoneNumberFormat_H__ |
|
152 |
|
153 // End of File |