|
1 /* |
|
2 * Copyright (c) 2006 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: Text style manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <avkon.hrh> // @todo: include proper header file |
|
20 #include <AknUtils.h> |
|
21 #include <aknappui.h> |
|
22 #include <AknLayoutFont.h> |
|
23 #include <gdi.h> |
|
24 #include <aknlayoutscalable_avkon.cdl.h> |
|
25 |
|
26 #include "alf/alftextstylemanager.h" |
|
27 #include "uiacceltk/HuiFont.h" |
|
28 #include "alf/alfbitmapprovider.h" |
|
29 #include "alf/alfconstants.h" |
|
30 #include "alf/alftextstyle.h" |
|
31 #include "alf/alfgencomponent.h" |
|
32 #include "alf/alftextvisual.h" |
|
33 |
|
34 #include <uiacceltk/HuiUtil.h> |
|
35 #ifdef ALF_RASTER_TEXT |
|
36 |
|
37 NONSHARABLE_CLASS(CAlfS60TextStyle): public CAlfTextStyle |
|
38 { |
|
39 public: |
|
40 /* Constructors and destructor. */ |
|
41 |
|
42 /** @beginAPI */ |
|
43 |
|
44 /** |
|
45 * Default constructor. Create a new S60 specific text style. |
|
46 * |
|
47 * @param aParent A handle id set into the THuiFont by the Texture manager or skin |
|
48 * @param aFontSpec Symbian OS Font Specification to store |
|
49 */ |
|
50 static CAlfS60TextStyle* NewL(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams) |
|
51 { |
|
52 CAlfS60TextStyle* me = new (ELeave) CAlfS60TextStyle(); |
|
53 CleanupStack::PushL(me); |
|
54 me->ConstructL(aEnv, aId, aImplementationId, aConstructionParams); |
|
55 CleanupStack::Pop(); |
|
56 me->Init(); |
|
57 return me; |
|
58 } |
|
59 |
|
60 void Init() |
|
61 { |
|
62 if (!CCoeEnv::Static()) |
|
63 { |
|
64 return; |
|
65 } |
|
66 |
|
67 const CAknLayoutFont* font = AknLayoutUtils::LayoutFontFromId(FontStyleId(), NULL); |
|
68 THuiFont huiFont(FontStyleId(), font->FontSpecInTwips()); |
|
69 |
|
70 // transfer the text pane height between the different font specs |
|
71 TAknFontSpecification aknFs = font->FontSpecification(); |
|
72 huiFont.SetTextPaneHeight(aknFs.TextPaneHeight()); |
|
73 SetUnderline(EFalse); |
|
74 SetStrikeThrough(EFalse); |
|
75 SetTextColor(KRgbBlack); |
|
76 SetFont(&huiFont); |
|
77 } |
|
78 }; |
|
79 |
|
80 NONSHARABLE_CLASS(CAlfTextStyleHolder):public CActive |
|
81 { |
|
82 public: |
|
83 CAlfTextStyleHolder(CAlfTextStyle* aTextStyle) |
|
84 :CActive(EPriorityNormal), iTextStyle(aTextStyle) |
|
85 { |
|
86 CActiveScheduler::Add(this); |
|
87 } |
|
88 |
|
89 ~CAlfTextStyleHolder() |
|
90 { |
|
91 Cancel(); |
|
92 delete iTextStyle; |
|
93 iVisuals.Reset(); |
|
94 } |
|
95 |
|
96 void RemoveReference(CAlfTextVisual* aUser) |
|
97 { |
|
98 for (TInt i = iVisuals.Count() -1; i >= 0; i--) |
|
99 { |
|
100 if (aUser == iVisuals[i]) |
|
101 { |
|
102 iVisuals.Remove(i); |
|
103 } |
|
104 } |
|
105 } |
|
106 |
|
107 void RefreshMesh() |
|
108 { |
|
109 if (!IsActive()) |
|
110 { |
|
111 SetActive(); |
|
112 TRequestStatus* sptr = &iStatus; |
|
113 User::RequestComplete(sptr, KErrNone); |
|
114 } |
|
115 } |
|
116 |
|
117 void DoRefreshMesh() |
|
118 { |
|
119 for (TInt p = iVisuals.Count()-1; p >= 0; p--) |
|
120 { |
|
121 iVisuals[p]->PrepareForUpdateMesh(); |
|
122 } |
|
123 |
|
124 for (TInt i = iVisuals.Count()-1; i >= 0; i--) |
|
125 { |
|
126 iVisuals[i]->UpdateMesh(ETrue); |
|
127 } |
|
128 } |
|
129 |
|
130 void ReleaseMesh() |
|
131 { |
|
132 for (TInt i = iVisuals.Count()-1; i >= 0; i--) |
|
133 { |
|
134 iVisuals[i]->ReleaseMesh(); |
|
135 } |
|
136 |
|
137 } |
|
138 |
|
139 void RunL() |
|
140 { |
|
141 if( iStatus.Int() != KErrCancel ) |
|
142 { |
|
143 DoRefreshMesh(); |
|
144 } |
|
145 } |
|
146 |
|
147 void DoCancel() |
|
148 { |
|
149 } |
|
150 |
|
151 TInt AddReference(CAlfTextVisual* aUser) |
|
152 { |
|
153 return iVisuals.InsertInAddressOrder(aUser); |
|
154 } |
|
155 |
|
156 CAlfTextStyle* iTextStyle; |
|
157 RPointerArray<CAlfTextVisual> iVisuals; |
|
158 }; |
|
159 |
|
160 #else |
|
161 const TUint KPreconfiguredTextStyleCount = 10; |
|
162 #endif |
|
163 |
|
164 // Private structure |
|
165 struct CAlfTextStyleManager::TPrivateData |
|
166 { |
|
167 /** Current Alf environment. */ |
|
168 CAlfEnv* iEnv; // Not owned. |
|
169 /** Array of alf text style objects. */ |
|
170 #ifdef ALF_RASTER_TEXT |
|
171 RPointerArray<CAlfTextStyleHolder> iTextStyles; // Owned. |
|
172 #else |
|
173 RPointerArray<CAlfTextStyle> iTextStyles; // Owned. |
|
174 #endif |
|
175 }; |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // Constructor |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 CAlfTextStyleManager::CAlfTextStyleManager() |
|
182 { |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // Destructor |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 CAlfTextStyleManager::~CAlfTextStyleManager() |
|
190 { |
|
191 // Free the alf text styles array. |
|
192 if(iData) |
|
193 { |
|
194 iData->iTextStyles.ResetAndDestroy(); |
|
195 } |
|
196 |
|
197 // Delete the private data. |
|
198 delete iData; |
|
199 iData = NULL; |
|
200 } |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // 2-phased constructor. |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 CAlfTextStyleManager* CAlfTextStyleManager::NewL(CAlfEnv& aEnv) |
|
207 { |
|
208 CAlfTextStyleManager* self = CAlfTextStyleManager::NewLC(aEnv); |
|
209 CleanupStack::Pop( self ); |
|
210 return self; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // 2-phased constructor. Object stays on the stack. |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 CAlfTextStyleManager* CAlfTextStyleManager::NewLC(CAlfEnv& aEnv) |
|
218 { |
|
219 CAlfTextStyleManager* self = new( ELeave ) CAlfTextStyleManager; |
|
220 CleanupStack::PushL( self ); |
|
221 self->ConstructL(aEnv); |
|
222 return self; |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // Creates new platform style |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 EXPORT_C TInt CAlfTextStyleManager::CreatePlatformTextStyleL( |
|
230 TInt aFontStyleId, TInt aParentId) |
|
231 { |
|
232 return DoCreatePlatformTextStyleL(aFontStyleId, aParentId, EAlfPlatformTextStyleCreate); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // Creates new platform style |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 EXPORT_C TInt CAlfTextStyleManager::CreatePlatformTextStyleL( |
|
240 TInt aParentId) |
|
241 { |
|
242 CAlfTextStyle* parentStyle = TextStyle(aParentId); |
|
243 TInt parentStyleFontId = parentStyle->FontStyleId(); |
|
244 return DoCreatePlatformTextStyleL(parentStyleFontId, aParentId, EAlfPlatformTextStyleCreate); |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // Return text style for given ID |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 EXPORT_C CAlfTextStyle* CAlfTextStyleManager::TextStyle(TInt aId) |
|
252 { |
|
253 #ifdef ALF_RASTER_TEXT |
|
254 if(aId >= 0 && aId < iData->iTextStyles.Count()) |
|
255 { |
|
256 __ASSERT_DEBUG( iData->iTextStyles[aId]->iTextStyle, USER_INVARIANT() ); |
|
257 return iData->iTextStyles[aId]->iTextStyle; |
|
258 } |
|
259 |
|
260 return iData->iTextStyles[EAlfTextStyleNormal]->iTextStyle; |
|
261 |
|
262 #else |
|
263 if(aId >= 0 && aId < iData->iTextStyles.Count()) |
|
264 { |
|
265 __ASSERT_DEBUG( iData->iTextStyles[aId], USER_INVARIANT() ); |
|
266 return iData->iTextStyles[aId]; |
|
267 } |
|
268 |
|
269 return iData->iTextStyles[EAlfTextStyleNormal]; |
|
270 #endif |
|
271 } |
|
272 |
|
273 CAlfTextStyle* CAlfTextStyleManager::SwitchTextStyle(TInt aStyle, CAlfTextVisual* aVisual) |
|
274 { |
|
275 #ifdef ALF_RASTER_TEXT |
|
276 CAlfTextStyle* newStyle = iData->iTextStyles[EAlfTextStyleNormal]->iTextStyle; |
|
277 |
|
278 if(aStyle >= 0 && aStyle < iData->iTextStyles.Count()) |
|
279 { |
|
280 newStyle = iData->iTextStyles[aStyle]->iTextStyle; |
|
281 } |
|
282 if (iData->iTextStyles[aStyle]->AddReference(aVisual) == KErrNone) |
|
283 { |
|
284 if(newStyle != iData->iTextStyles[aVisual->TextStyle()]->iTextStyle ) |
|
285 { |
|
286 iData->iTextStyles[aVisual->TextStyle()]->RemoveReference(aVisual); |
|
287 } |
|
288 } |
|
289 return newStyle; |
|
290 #else |
|
291 return 0; |
|
292 #endif |
|
293 } |
|
294 |
|
295 void CAlfTextStyleManager::Unregister(CAlfTextVisual* aVisual) |
|
296 { |
|
297 #ifdef ALF_RASTER_TEXT |
|
298 TInt style = aVisual->TextStyle(); |
|
299 if(style >= 0 && style < iData->iTextStyles.Count()) |
|
300 { |
|
301 iData->iTextStyles[style]->RemoveReference(aVisual); |
|
302 } |
|
303 |
|
304 #else |
|
305 return; |
|
306 #endif |
|
307 } |
|
308 |
|
309 void CAlfTextStyleManager::RefreshVisuals(TInt aStyle) |
|
310 { // called by text style it self so queue request as such |
|
311 #ifdef ALF_RASTER_TEXT |
|
312 if (aStyle >= iData->iTextStyles.Count()) |
|
313 return; |
|
314 iData->iTextStyles[aStyle]->RefreshMesh(); |
|
315 #else |
|
316 return; |
|
317 #endif |
|
318 } |
|
319 |
|
320 |
|
321 void CAlfTextStyleManager::ReleaseAllVisuals() |
|
322 { // called by CAlfEnv::Release to get all the text visuals to destroy their textures |
|
323 // Those textures can not recreate themselves because missing bitmapprovider but need |
|
324 // to be rebuild by AlfTextVisual when client calls CAlfEnv::RestoreL |
|
325 #ifdef ALF_RASTER_TEXT |
|
326 for(TInt i = 0 ; i < iData->iTextStyles.Count() ; i++ ) |
|
327 { |
|
328 iData->iTextStyles[i]->ReleaseMesh(); |
|
329 } |
|
330 #else |
|
331 return; |
|
332 #endif |
|
333 } |
|
334 |
|
335 void CAlfTextStyleManager::RefreshAllVisuals() |
|
336 { // called by CAlfEnv::RestoreL to get all the text visuals to rebuild themselves |
|
337 #ifdef ALF_RASTER_TEXT |
|
338 for(TInt i = 0 ; i < iData->iTextStyles.Count() ; i++ ) |
|
339 { |
|
340 iData->iTextStyles[i]->RefreshMesh(); |
|
341 } |
|
342 #else |
|
343 return; |
|
344 #endif |
|
345 } |
|
346 |
|
347 |
|
348 |
|
349 // --------------------------------------------------------------------------- |
|
350 // Creates a new text style object that is identical with the given source |
|
351 // text style. |
|
352 // --------------------------------------------------------------------------- |
|
353 // |
|
354 EXPORT_C TInt CAlfTextStyleManager::CopyTextStyleL(TInt aSourceId) |
|
355 { |
|
356 #ifdef ALF_RASTER_TEXT |
|
357 CAlfTextStyle* sourceStyle = TextStyle(aSourceId); |
|
358 const TInt freeSlot = FindFreeSlotIndex(); |
|
359 |
|
360 // Create alf text style object. |
|
361 CAlfTextStyle* textStyle = |
|
362 CAlfTextStyle::NewL( |
|
363 *iData->iEnv, |
|
364 (freeSlot != KErrNotFound ) ? freeSlot : iData->iTextStyles.Count(), |
|
365 sourceStyle->FontStyleId(), |
|
366 KNullDesC8); |
|
367 |
|
368 // Set the parent id of the text style. |
|
369 textStyle->SetParentId(sourceStyle->ParentId()); |
|
370 |
|
371 // Store the font style id of the text style |
|
372 textStyle->SetFontStyleId(sourceStyle->FontStyleId()); |
|
373 |
|
374 CleanupStack::PushL(textStyle); |
|
375 CAlfTextStyleHolder* holder = new (ELeave) CAlfTextStyleHolder(textStyle); |
|
376 CleanupStack::PushL(holder); |
|
377 |
|
378 if ( freeSlot != KErrNotFound ) |
|
379 { |
|
380 iData->iTextStyles[freeSlot] = holder; |
|
381 } |
|
382 else |
|
383 { |
|
384 // Append the specified text style into the array of styles. |
|
385 iData->iTextStyles.AppendL(holder); |
|
386 } |
|
387 |
|
388 CleanupStack::Pop(2); |
|
389 |
|
390 #else |
|
391 CAlfTextStyle* sourceStyle = TextStyle(aSourceId); |
|
392 TInt parentId = sourceStyle->ParentId(); |
|
393 |
|
394 // Create construction parameters for alf text style object. |
|
395 TInt params(sourceStyle->Comms()->Identifier()); |
|
396 TPckgC<TInt> paramBuf(params); |
|
397 |
|
398 const TInt freeSlot = FindFreeSlotIndex(); |
|
399 |
|
400 // Create alf text style object. |
|
401 CAlfTextStyle* textStyle = |
|
402 CAlfTextStyle::NewL( |
|
403 *iData->iEnv, |
|
404 (freeSlot != KErrNotFound ) ? freeSlot : iData->iTextStyles.Count(), |
|
405 EAlfPlatformTextStyleCopy, |
|
406 paramBuf); |
|
407 |
|
408 // Set the parent id of the text style. |
|
409 textStyle->SetParentId(parentId); |
|
410 |
|
411 if ( freeSlot != KErrNotFound ) |
|
412 { |
|
413 iData->iTextStyles[freeSlot] = textStyle; |
|
414 } |
|
415 else |
|
416 { |
|
417 // Append the specified text style into the array of styles. |
|
418 iData->iTextStyles.AppendL(textStyle); |
|
419 } |
|
420 |
|
421 #endif |
|
422 // Return the id of the created text style. |
|
423 return textStyle->Id(); |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // Constructor. |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 EXPORT_C TInt CAlfTextStyleManager::DeleteTextStyle(TInt aId) |
|
431 { |
|
432 if ( aId >= iData->iTextStyles.Count() ) |
|
433 { |
|
434 return KErrArgument; |
|
435 } |
|
436 |
|
437 // Cannot delete platform styles from an application. |
|
438 #ifdef ALF_RASTER_TEXT |
|
439 CAlfTextStyle* deletedStyle = iData->iTextStyles[aId]->iTextStyle; |
|
440 |
|
441 if (dynamic_cast<CAlfS60TextStyle*>(deletedStyle)) // is platform style |
|
442 #else |
|
443 |
|
444 CAlfTextStyle* deletedStyle = iData->iTextStyles[aId]; |
|
445 |
|
446 if ( aId >= 0 && aId < KPreconfiguredTextStyleCount ) |
|
447 #endif |
|
448 { |
|
449 return KErrAccessDenied; |
|
450 } |
|
451 |
|
452 if ( deletedStyle ) |
|
453 { |
|
454 delete deletedStyle; |
|
455 iData->iTextStyles[aId] = NULL; // NULL the slot for later usage. |
|
456 } |
|
457 else |
|
458 { |
|
459 return KErrArgument; |
|
460 } |
|
461 return KErrNone; |
|
462 } |
|
463 |
|
464 // --------------------------------------------------------------------------- |
|
465 // Constructor. |
|
466 // --------------------------------------------------------------------------- |
|
467 // |
|
468 void CAlfTextStyleManager::ConstructL(CAlfEnv& aEnv) |
|
469 { |
|
470 iData = new (ELeave) TPrivateData; |
|
471 |
|
472 // Fill data |
|
473 iData->iEnv = &aEnv; |
|
474 |
|
475 // Construct CAlfTextStyle representations from preconfigured text styles |
|
476 ConstructPreconfiguredStylesL(); |
|
477 } |
|
478 |
|
479 // --------------------------------------------------------------------------- |
|
480 // Constructs CAlfTextStyle representations from build in preconfigured |
|
481 // text styles |
|
482 // --------------------------------------------------------------------------- |
|
483 // |
|
484 void CAlfTextStyleManager::ConstructPreconfiguredStylesL() |
|
485 { |
|
486 #ifdef ALF_RASTER_TEXT |
|
487 // create default parent for all styles for all |
|
488 CreatePlatformTextStyleL( EAknLogicalFontPrimaryFont, -1 ); |
|
489 |
|
490 // initialize platform styles |
|
491 CAlfTextStyle* style = 0; |
|
492 |
|
493 // ENormalItalicFont / no EAlfTextStyleXxx def |
|
494 TInt normalItalicStyleId = CreatePlatformTextStyleL( EAknLogicalFontPrimaryFont, EAlfTextStyleNormal ); |
|
495 style = TextStyle(normalItalicStyleId); |
|
496 style->SetItalic(ETrue); |
|
497 |
|
498 // EAlfTextStyleMenuItem |
|
499 CreatePlatformTextStyleL( EAknLogicalFontPrimaryFont, EAlfTextStyleNormal ); |
|
500 |
|
501 // ESmallFont / EHuiTextStyleSmall |
|
502 TInt smallStyleId = CreatePlatformTextStyleL( EAknLogicalFontSecondaryFont, EAlfTextStyleNormal ); |
|
503 |
|
504 // ESmallFont EHuiTextStyleMenuSmall |
|
505 CreatePlatformTextStyleL( EAknLogicalFontSecondaryFont, smallStyleId ); |
|
506 |
|
507 // ENormalBoldFont / EAlfTextStyleMenuTitle |
|
508 TInt normalBoldStyleId = CreatePlatformTextStyleL( EAknLogicalFontPrimaryFont, EAlfTextStyleNormal ); |
|
509 style = TextStyle(normalBoldStyleId); |
|
510 style->SetBold(ETrue); |
|
511 |
|
512 // ELargeFont / EAlfTextStyleLarge |
|
513 CreatePlatformTextStyleL( EAknLogicalFontTitleFont, EAlfTextStyleNormal ); |
|
514 |
|
515 // ESoftkeyFont / EAlfTextStyleSoftkey |
|
516 /*TInt softkeyStyleId =*/ CreatePlatformTextStyleL( EAknLogicalFontTitleFont, EAlfTextStyleNormal ); |
|
517 |
|
518 // EAlfTextStyleSupplement |
|
519 CreatePlatformTextStyleL( EAknLogicalFontPrimaryFont, EAlfTextStyleNormal ); |
|
520 |
|
521 // EAlfTextStyleTitle |
|
522 /*iLastBuiltInStyleId =*/ CreatePlatformTextStyleL( EAknLogicalFontTitleFont, EAlfTextStyleNormal ); |
|
523 |
|
524 #else |
|
525 for(TUint i = 0; i < KPreconfiguredTextStyleCount; ++i) |
|
526 { |
|
527 // Create construction parameters for alf text style object. |
|
528 TPckgC<TInt> paramBuf(iData->iTextStyles.Count()); |
|
529 |
|
530 // Create the new text style. |
|
531 CAlfTextStyle* textStyle = |
|
532 CAlfTextStyle::NewL( |
|
533 *iData->iEnv, |
|
534 iData->iTextStyles.Count(), |
|
535 EAlfPreconfiguredTextStyleCreate, |
|
536 paramBuf); |
|
537 |
|
538 // Append the specified text style into the array of styles. |
|
539 iData->iTextStyles.AppendL(textStyle); |
|
540 } |
|
541 #endif |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 // Finds a free slot |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 TInt CAlfTextStyleManager::FindFreeSlotIndex() const |
|
549 { |
|
550 TInt index = KErrNotFound; |
|
551 for ( TInt i = iData->iTextStyles.Count() -1 ; i >= 0; i-- ) |
|
552 { |
|
553 if ( !iData->iTextStyles[i] ) |
|
554 { |
|
555 index = i; |
|
556 break; |
|
557 } |
|
558 } |
|
559 return index; |
|
560 } |
|
561 |
|
562 |
|
563 // --------------------------------------------------------------------------- |
|
564 // Internal implementation to create a platform style. |
|
565 // --------------------------------------------------------------------------- |
|
566 // |
|
567 TInt CAlfTextStyleManager::DoCreatePlatformTextStyleL(TInt aFontStyleId, TInt aParentId, TInt aImplementationId) |
|
568 { |
|
569 #ifdef ALF_RASTER_TEXT |
|
570 // Create construction parameters for alf text style object. |
|
571 CAlfTextStyle* parentStyle = 0; |
|
572 if (iData->iTextStyles.Count()) |
|
573 { |
|
574 parentStyle = TextStyle(aParentId); |
|
575 } |
|
576 |
|
577 const TInt freeSlot = FindFreeSlotIndex(); |
|
578 |
|
579 // Create alf text style object. |
|
580 CAlfS60TextStyle* textStyle = |
|
581 CAlfS60TextStyle::NewL( |
|
582 *iData->iEnv, |
|
583 (freeSlot != KErrNotFound ) ? freeSlot : iData->iTextStyles.Count(), |
|
584 aFontStyleId, |
|
585 KNullDesC8); |
|
586 |
|
587 if ( parentStyle ) |
|
588 {// Set the parent id of the text style. |
|
589 textStyle->SetParentId(parentStyle->Id()); |
|
590 } |
|
591 |
|
592 CleanupStack::PushL(textStyle); |
|
593 CAlfTextStyleHolder* holder = new (ELeave) CAlfTextStyleHolder(textStyle); |
|
594 CleanupStack::PushL(holder); |
|
595 |
|
596 if ( freeSlot != KErrNotFound ) |
|
597 { |
|
598 iData->iTextStyles[freeSlot] = holder; |
|
599 } |
|
600 else |
|
601 { |
|
602 // Append the specified text style into the array of styles. |
|
603 iData->iTextStyles.AppendL(holder); |
|
604 } |
|
605 |
|
606 CleanupStack::Pop(2); |
|
607 |
|
608 textStyle->SetManager(this); |
|
609 |
|
610 #else |
|
611 // Create construction parameters for alf text style object. |
|
612 CAlfTextStyle* parentStyle = TextStyle(aParentId); |
|
613 TInt2 params(aFontStyleId, parentStyle->Comms()->Identifier()); |
|
614 TPckgC<TInt2> paramBuf(params); |
|
615 |
|
616 const TInt freeSlot = FindFreeSlotIndex(); |
|
617 |
|
618 // Create alf text style object. |
|
619 CAlfTextStyle* textStyle = |
|
620 CAlfTextStyle::NewL( |
|
621 *iData->iEnv, |
|
622 (freeSlot != KErrNotFound ) ? freeSlot : iData->iTextStyles.Count(), |
|
623 aImplementationId, |
|
624 paramBuf); |
|
625 |
|
626 // Set the parent id of the text style. |
|
627 textStyle->SetParentId(parentStyle->Id()); |
|
628 |
|
629 // Store the font style id of the text style |
|
630 textStyle->SetFontStyleId(aFontStyleId); |
|
631 |
|
632 if ( freeSlot != KErrNotFound ) |
|
633 { |
|
634 iData->iTextStyles[freeSlot] = textStyle; |
|
635 } |
|
636 else |
|
637 { |
|
638 // Append the specified text style into the array of styles. |
|
639 iData->iTextStyles.AppendL(textStyle); |
|
640 } |
|
641 |
|
642 #endif |
|
643 // Return the id of the created text style. |
|
644 return textStyle->Id(); |
|
645 } |