|
1 /* |
|
2 * Copyright (c) 2007-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: This component converts CRichText style's to HuiTextStyle |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_FSALFTEXTSTYLEMANAGER_H |
|
20 #define C_FSALFTEXTSTYLEMANAGER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <txtfrmat.h> |
|
24 |
|
25 class CAlfTextStyleManager; |
|
26 class TFsTextStyleData; |
|
27 |
|
28 |
|
29 /** |
|
30 * CFsAlfTextStyleManager |
|
31 * |
|
32 * This class is designed to convert CRichText style definitions to |
|
33 * TAlfTextStyles. To avoid overlapping style definitions, all previously |
|
34 * created styles are stored in a list. |
|
35 * |
|
36 * Example: |
|
37 * @code |
|
38 * |
|
39 * manager = CFsTextStyleManager::NewL( Env().TextStyleManager() ); |
|
40 * rText.GetChars( someText, charFormat, position ); //CRichText |
|
41 * TInt styleID = manager->GetStyleIDL( charFormat ); |
|
42 * visual = CAlfTextVisual::AddNewL( *iControl, iCurveLayout ); |
|
43 * visual->SetTextStyle( styleID ); |
|
44 * |
|
45 * @endcode |
|
46 * |
|
47 * @since S60 v3.2 |
|
48 */ |
|
49 class CFsAlfTextStyleManager : CBase |
|
50 { |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 * @param aAlfTextStyleManager Reference to the CAlfTextStyleManager |
|
56 */ |
|
57 static CFsAlfTextStyleManager* NewL( CAlfTextStyleManager& aAlfTextStyleManager ); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 ~CFsAlfTextStyleManager(); |
|
63 |
|
64 /** |
|
65 * GetStyleIDL |
|
66 * |
|
67 * This is the only public method in CFsAlfTextStyleManager. If there |
|
68 * already a style that matches the given TCharFormat, the ID of this |
|
69 * style is returned. If not, a new style is created. |
|
70 * |
|
71 * @since S60 3.2 |
|
72 * @param aCharFormat Style format from CRichText |
|
73 * @return ID for TAlfTextStyle |
|
74 */ |
|
75 TInt GetStyleIDL( const TCharFormat& aCharFormat ); |
|
76 |
|
77 /** |
|
78 * FindId |
|
79 * |
|
80 * The array of previously created styles is searched for matching |
|
81 * TCharFormat. If not found KErrNotFound is returned. |
|
82 * |
|
83 * @since S60 3.2 |
|
84 * @param aCharFormat Style format from CRichText |
|
85 * @return ID for TAlfTextStyle or KErrNotFound |
|
86 */ |
|
87 TInt GetStyleIDWithOpositeUnderlineL( TInt aId ); |
|
88 |
|
89 private: |
|
90 |
|
91 CFsAlfTextStyleManager( CAlfTextStyleManager& aAlfTextStyleManager ); |
|
92 |
|
93 // void ConstructL(); This wasn't needed at the time |
|
94 |
|
95 /** |
|
96 * FindId |
|
97 * |
|
98 * The array of previously created styles is searched for matching |
|
99 * TCharFormat. If not found KErrNotFound is returned. |
|
100 * |
|
101 * @since S60 3.2 |
|
102 * @param aCharFormat Style format from CRichText |
|
103 * @return ID for TAlfTextStyle or KErrNotFound |
|
104 */ |
|
105 TInt FindId( const TCharFormat& aCharFormat ); |
|
106 |
|
107 |
|
108 /** |
|
109 * FindPositionOfId |
|
110 * |
|
111 * The array of previously created styles is searched for matching |
|
112 * ID. If not found KErrNotFound is returned. |
|
113 * |
|
114 * @since S60 3.2 |
|
115 * @param ID Style format from CRichText |
|
116 * @return position in table for TAlfTextStyle or KErrNotFound |
|
117 */ |
|
118 TInt FindPositionOfId(TInt aId); |
|
119 |
|
120 /** |
|
121 * CreateNewTextStyleL |
|
122 * |
|
123 * Creates a new text style using TCharFormat. |
|
124 * |
|
125 * @since S60 3.2 |
|
126 * @param aCharFormat Style format from CRichText |
|
127 * @return ID for TAlfTextStyle |
|
128 */ |
|
129 TInt CreateNewTextStyleL( const TCharFormat& aCharFormat ); |
|
130 |
|
131 private: // data |
|
132 |
|
133 /** |
|
134 * Reference to the CAlfTextStyleManager |
|
135 */ |
|
136 CAlfTextStyleManager& iAlfTextStyleManager; |
|
137 |
|
138 /** |
|
139 * Array of previously created styles |
|
140 */ |
|
141 RArray<TFsTextStyleData> iStyles; |
|
142 |
|
143 }; |
|
144 |
|
145 #endif // C_FSALFTEXTSTYLEMANAGER_H |