|
1 /* |
|
2 * Copyright (c) 2005 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 * CUniSmilModel, Storage for Smil presentation data. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // ========== INCLUDE FILES ================================ |
|
22 |
|
23 |
|
24 #include <e32def.h> |
|
25 #include <eikenv.h> |
|
26 #include <eikfutil.h> // CopyFile |
|
27 |
|
28 #include <mtclbase.h> // for CBaseMtm |
|
29 #include <msvstd.h> // for TMsvId |
|
30 #include <msvids.h> // for KMsvTempIndexEntryId |
|
31 #include <msvstore.h> |
|
32 #include <mmsvattachmentmanager.h> |
|
33 #include <mmsvattachmentmanagersync.h> |
|
34 #include <cmsvattachment.h> |
|
35 |
|
36 #include <bautils.h> // NearestLanguageFile |
|
37 |
|
38 #include <coemain.h> |
|
39 |
|
40 // LAF |
|
41 /* |
|
42 #include <AknUtils.h> |
|
43 #include <AknLayoutScalable_Avkon.cdl.h> |
|
44 #include <AknLayoutScalable_Apps.cdl.h> |
|
45 #include <LayoutMetadata.cdl.h> |
|
46 */ |
|
47 |
|
48 // DOM |
|
49 #include <gmxmldocument.h> |
|
50 #include <gmxmlnode.h> |
|
51 #include <gmxmlelement.h> |
|
52 |
|
53 // MsgMedia |
|
54 #include <MsgMedia.hrh> |
|
55 #include <MsgMediaInfo.h> |
|
56 #include <MmsConformance.h> |
|
57 #include <mmsversion.h> |
|
58 #include <MsgTextInfo.h> |
|
59 |
|
60 |
|
61 // MsgDataUTILS |
|
62 #include <UniDataModel.rsg> // Viewer/Editor Mimetype strings |
|
63 #include "UniModelConst.h" // Definitions and enums |
|
64 #include "UniDataUtils.h" |
|
65 #include "UniSmilSlide.h" |
|
66 #include "UniSmilModel.h" |
|
67 #include "UniObjectList.h" |
|
68 #include "UniObject.h" |
|
69 #include "UniTextObject.h" |
|
70 #include "UniMimeInfo.h" |
|
71 #include "UniSmilUtils.h" |
|
72 #include "UniSmilParams.h" |
|
73 |
|
74 #include "fileprotectionresolver.h" // EFileProtDrm2 |
|
75 #include "MsgMimeTypes.h" |
|
76 |
|
77 // Logging |
|
78 //#include "//MsgDataUTILSLOGGing.h" |
|
79 |
|
80 |
|
81 // ========== EXTERNAL DATA STRUCTURES ===================== |
|
82 |
|
83 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
|
84 |
|
85 // ========== CONSTANTS ==================================== |
|
86 |
|
87 // ========== MACROS ======================================= |
|
88 |
|
89 // ========== LOCAL CONSTANTS AND MACROS =================== |
|
90 |
|
91 _LIT( KSmilIntFormat, "%d" ); |
|
92 _LIT( KSmilMsecFormat, "%dms" ); |
|
93 const TUint KSlideArrayGranularity( 16 ); |
|
94 |
|
95 // SMIL size estimates |
|
96 const TInt KSizeMandatorySmilTags = 148; |
|
97 const TInt KSizeHeadOneRegion = 85; |
|
98 const TInt KSizeHeadTwoRegions = 170; |
|
99 const TInt KSizeEmptyPar = 27; |
|
100 const TInt KSizeNonEmptyPar = 41; |
|
101 const TInt KSizeAudioTag = 38; |
|
102 const TInt KSizeImageTag = 52; |
|
103 const TInt KSizeTextTag = 51; |
|
104 const TInt KSizeVideoTag = 53; |
|
105 |
|
106 const TInt KSizeLowResHeight = 208; |
|
107 const TInt KSizeLowResWidth = 176; |
|
108 |
|
109 // ========== MODULE DATA STRUCTURES ======================= |
|
110 |
|
111 // ========== LOCAL FUNCTION PROTOTYPES ==================== |
|
112 |
|
113 // ========== LOCAL FUNCTIONS ============================== |
|
114 |
|
115 // ========== MEMBER FUNCTIONS ============================= |
|
116 |
|
117 |
|
118 // --------------------------------------------------------- |
|
119 // CUniSmilModel::NewL |
|
120 // |
|
121 // Factory method. |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 EXPORT_C CUniSmilModel* CUniSmilModel::NewLC( RFs& aFs, |
|
125 CBaseMtm& aMtm, |
|
126 CUniDataUtils& aData, |
|
127 CUniObjectList& aObjectList ) |
|
128 { |
|
129 CUniSmilModel* self = new ( ELeave ) |
|
130 CUniSmilModel( aFs, aMtm, aData, aObjectList ); |
|
131 |
|
132 CleanupStack::PushL(self); |
|
133 self->ConstructL(); |
|
134 return self; |
|
135 } |
|
136 |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // CUniSmilModel::NewL |
|
140 // |
|
141 // Factory method. |
|
142 // --------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C CUniSmilModel* CUniSmilModel::NewL( RFs& aFs, |
|
145 CBaseMtm& aMtm, |
|
146 CUniDataUtils& aData, |
|
147 CUniObjectList& aObjectList ) |
|
148 { |
|
149 CUniSmilModel* self = NewLC( aFs, aMtm, aData, aObjectList ); |
|
150 CleanupStack::Pop( self ); |
|
151 return self; |
|
152 } |
|
153 |
|
154 |
|
155 // --------------------------------------------------------- |
|
156 // CUniSmilModel::CUniSmilModel |
|
157 // |
|
158 // Constructor. |
|
159 // --------------------------------------------------------- |
|
160 // |
|
161 CUniSmilModel::CUniSmilModel( RFs& aFs, |
|
162 CBaseMtm& aMtm, |
|
163 CUniDataUtils& aData, |
|
164 CUniObjectList& aObjectList ) : |
|
165 iFs( aFs ), |
|
166 iMtm( aMtm ), |
|
167 iData( aData ), |
|
168 iObjectList( aObjectList ), |
|
169 iSlideLayout( EUniUndefinedLayout ), |
|
170 iSmilParams( 0 ), |
|
171 iScreenSize( 0, 0 ), |
|
172 iSizeEstimateUpToDate( EFalse ), |
|
173 iSizeEstimate( 0 ) |
|
174 { |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CUniSmilModel::~CUniSmilModel |
|
179 // |
|
180 // Destructor. |
|
181 // --------------------------------------------------------- |
|
182 // |
|
183 CUniSmilModel::~CUniSmilModel() |
|
184 { |
|
185 if (iSlideArray) |
|
186 { |
|
187 iSlideArray->ResetAndDestroy(); |
|
188 } |
|
189 delete iSlideArray; |
|
190 delete iSmilParams; |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------- |
|
194 // CUniSmilModel::ParseL |
|
195 // |
|
196 // --------------------------------------------------------- |
|
197 // |
|
198 EXPORT_C TInt CUniSmilModel::ParseL( CMDXMLDocument* aDom ) |
|
199 { |
|
200 //MsgDataUTILSLOGGER_ENTERFN( "CUniSmilModel::ParseL()" ); |
|
201 |
|
202 Reset(); |
|
203 |
|
204 if ( aDom ) |
|
205 { |
|
206 TRAPD( error, DoPresentationFromDomL( aDom ) ); |
|
207 if ( error ) |
|
208 { |
|
209 Reset(); |
|
210 User::Leave( error ); |
|
211 } |
|
212 else |
|
213 { |
|
214 iParseResult |= EParsedFromSmil; |
|
215 } |
|
216 } |
|
217 else |
|
218 { |
|
219 // No SMIL -> Do presentation from object list |
|
220 if ( IsMessageSlide() ) |
|
221 { |
|
222 // Determine layout. Make slide. |
|
223 DoNoSmilOneSlideL(); |
|
224 } |
|
225 else |
|
226 { |
|
227 // Do slide for each media object |
|
228 DoNoSmilManySlideL(); |
|
229 } |
|
230 iParseResult |= EParsedFromList; |
|
231 } |
|
232 |
|
233 return iParseResult; |
|
234 } |
|
235 |
|
236 |
|
237 //********************************************************** |
|
238 //* |
|
239 //* SMIL COMPOSING FUNCTIONS |
|
240 //* |
|
241 //********************************************************** |
|
242 |
|
243 |
|
244 // --------------------------------------------------------- |
|
245 // CUniSmilModel::¨ComposeL |
|
246 // |
|
247 // --------------------------------------------------------- |
|
248 // |
|
249 EXPORT_C CMDXMLDocument* CUniSmilModel::ComposeL() |
|
250 { |
|
251 //MsgDataUTILSLOGGER_ENTERFN( "CUniSmilModel::ComposeL()" ); |
|
252 |
|
253 // Reset region id's |
|
254 iTextRegionId.Set( KNullDesC ); |
|
255 iImageRegionId.Set( KNullDesC ); |
|
256 |
|
257 // Read default smil parameters |
|
258 if( !iSmilParams ) |
|
259 { |
|
260 //MsgDataUTILSLOGGER_WRITE( "CUniSmilModel: Creating smil parameter structures." ); |
|
261 iSmilParams = CUniSmilParams::NewL( iFs ); |
|
262 } |
|
263 |
|
264 //MsgDataUTILSLOGGER_WRITE( "CUniSmilModel: Creating new DOM." ); |
|
265 //delete iDom; |
|
266 //iDom = 0; |
|
267 CMDXMLDocument* dom = CMDXMLDocument::NewLC(); |
|
268 |
|
269 // Create smil node |
|
270 TPtrC name( KSMILWREleSmil ); |
|
271 CMDXMLElement* root = CMDXMLElement::NewLC( ETrue, dom, name ); |
|
272 // Append |
|
273 dom->DocumentElement()->AppendChild( root ); // Ownership to dom |
|
274 CleanupStack::Pop( root ); |
|
275 |
|
276 // Create Head |
|
277 CreateHeadL( dom, root ); |
|
278 |
|
279 // Create Body |
|
280 CreateBodyL( dom, root ); |
|
281 |
|
282 // TODO: Move to Document and to use smil list |
|
283 //iObjectList.CreateSmilAttachmentL( smilAttaId, iDom, iFs ); |
|
284 CleanupStack::Pop( dom ); |
|
285 return dom; |
|
286 } |
|
287 |
|
288 |
|
289 |
|
290 // --------------------------------------------------------- |
|
291 // CUniSmilModel::RemoveEmptySlides |
|
292 // |
|
293 // |
|
294 // --------------------------------------------------------- |
|
295 // |
|
296 EXPORT_C void CUniSmilModel::RemoveEmptySlides() |
|
297 { |
|
298 TInt count = iSlideArray->Count(); |
|
299 // Must be done from end to beginning because |
|
300 // slides might be removed. |
|
301 while ( count-- ) |
|
302 { |
|
303 if ( !iSlideArray->At( count )->ObjectCount() ) |
|
304 { |
|
305 RemoveSlide( count ); |
|
306 } |
|
307 } |
|
308 } |
|
309 |
|
310 |
|
311 // --------------------------------------------------------- |
|
312 // CUniSmilModel::AddSlideL |
|
313 // |
|
314 // |
|
315 // --------------------------------------------------------- |
|
316 // |
|
317 EXPORT_C void CUniSmilModel::AddSlideL( TInt aSlideNum ) |
|
318 { |
|
319 DoAddSlideL( aSlideNum ); |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------- |
|
323 // CUniSmilModel::RemoveSlide |
|
324 // |
|
325 // |
|
326 // --------------------------------------------------------- |
|
327 // |
|
328 EXPORT_C void CUniSmilModel::RemoveSlide( TInt aSlideNum ) |
|
329 { |
|
330 if ( !IsSlide( aSlideNum ) ) |
|
331 { |
|
332 //__ASSERT_DEBUG( EFalse, DataUtilsPanic( EMmsNotASlide ) ); |
|
333 return; |
|
334 } |
|
335 CUniSmilSlide* slide = iSlideArray->At( aSlideNum ); |
|
336 if ( slide->ObjectCount() ) |
|
337 { |
|
338 //__ASSERT_DEBUG( EFalse, DataUtilsPanic( EMmsSlideNotEmpty ) ); |
|
339 return; |
|
340 } |
|
341 |
|
342 iSlideArray->Delete( aSlideNum ); |
|
343 delete slide; |
|
344 //MsgDataUTILSLOGGER_WRITE( "CUniSmilModel: Empty slide removed." ); |
|
345 iSizeEstimateUpToDate = EFalse; |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------- |
|
349 // CUniSmilModel::MoveSlideL |
|
350 // |
|
351 // |
|
352 // --------------------------------------------------------- |
|
353 // |
|
354 EXPORT_C void CUniSmilModel::MoveSlideL( TInt aSlideToMove, TInt aPlaceToMove ) |
|
355 { |
|
356 TInt slideCount = iSlideArray->Count(); |
|
357 if ( !slideCount |
|
358 || aSlideToMove < 0 |
|
359 || aSlideToMove >= slideCount |
|
360 || aSlideToMove == aPlaceToMove ) |
|
361 { |
|
362 return; |
|
363 } |
|
364 TInt place = Min( Max( 0, aPlaceToMove ), slideCount - 1 ); |
|
365 CUniSmilSlide* slide = iSlideArray->At( aSlideToMove ); |
|
366 |
|
367 iSlideArray->Delete( aSlideToMove ); |
|
368 iSlideArray->InsertL( place, slide ); |
|
369 iSizeEstimateUpToDate = EFalse; |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------- |
|
373 // SortSlidesL |
|
374 // |
|
375 // Sorts slides accoring to a separate comparison function |
|
376 // called SortSlidesCompare(). |
|
377 // |
|
378 // Insertion sort algorithm. |
|
379 // |
|
380 // Notice! Intended to be used with SendAs when there |
|
381 // are multiple slides - each slide containing only |
|
382 // one object |
|
383 // --------------------------------------------------------- |
|
384 EXPORT_C void CUniSmilModel::SortSlidesL() |
|
385 { |
|
386 TInt i = 1; // index 1, i.e. second slide |
|
387 TInt count = SlideCount(); |
|
388 while ( i < count ) |
|
389 { |
|
390 CUniSmilSlide* slide1 = iSlideArray->At( i ); |
|
391 TInt j = i - 1; |
|
392 while ( j >= 0 ) |
|
393 { |
|
394 CUniSmilSlide* slide2 = iSlideArray->At( j ); |
|
395 if ( SortSlidesCompare( slide1, slide2 ) > 0 ) |
|
396 { |
|
397 break; |
|
398 } |
|
399 j--; |
|
400 } |
|
401 j++; |
|
402 if ( j < i ) |
|
403 { |
|
404 // slide1 was not in the right place |
|
405 iSlideArray->Delete( i ); |
|
406 iSlideArray->InsertL( j, slide1 ); |
|
407 } |
|
408 i++; |
|
409 } |
|
410 iSizeEstimateUpToDate = EFalse; |
|
411 } |
|
412 |
|
413 |
|
414 // --------------------------------------------------------- |
|
415 // SortSlidesCompare |
|
416 // |
|
417 // Compares slides according to time. Most recent is greatest. |
|
418 // |
|
419 // Empty slides are greater than non-empty slides. |
|
420 // If aSlide1 "is greater than" aSlide2 returns positive value. |
|
421 // If aSlide1 "is smaller than" aSlide2 returns negative value. |
|
422 // If aSlide1 and aSlide2 "are equal" returns zero. |
|
423 // --------------------------------------------------------- |
|
424 // |
|
425 TInt CUniSmilModel::SortSlidesCompare( CUniSmilSlide* aSlide1, |
|
426 CUniSmilSlide* aSlide2 ) |
|
427 { |
|
428 if ( !aSlide1->ObjectCount() ) |
|
429 { |
|
430 //if both are empty returns 0 |
|
431 //if slide2 is non-empty -> slide1 "is greater" |
|
432 return aSlide2->ObjectCount(); |
|
433 } |
|
434 else if ( !aSlide2->ObjectCount() ) |
|
435 { |
|
436 //empty slide is always "greatest" |
|
437 return -1; |
|
438 } |
|
439 else |
|
440 { |
|
441 TTime time1; |
|
442 TTime time2; |
|
443 aSlide1->GetObjectByIndex( 0 )->MediaInfo()->ModificationTime( time1 ); |
|
444 aSlide2->GetObjectByIndex( 0 )->MediaInfo()->ModificationTime( time2 ); |
|
445 if ( time1 < time2 ) |
|
446 { |
|
447 return -1; |
|
448 } |
|
449 else if ( time1 == time2 ) |
|
450 { |
|
451 return 0; |
|
452 } |
|
453 else |
|
454 { |
|
455 return 1; |
|
456 } |
|
457 } |
|
458 } |
|
459 |
|
460 // --------------------------------------------------------- |
|
461 // CUniSmilModel::IsSlide |
|
462 // |
|
463 // |
|
464 // --------------------------------------------------------- |
|
465 // |
|
466 EXPORT_C TBool CUniSmilModel::IsSlide( TInt aSlideNum ) const |
|
467 { |
|
468 if( aSlideNum >= 0 && |
|
469 aSlideNum < iSlideArray->Count() ) |
|
470 { |
|
471 return ETrue; |
|
472 } |
|
473 return EFalse; |
|
474 } |
|
475 |
|
476 // --------------------------------------------------------- |
|
477 // CUniSmilModel::AddTextObjectL |
|
478 // |
|
479 // --------------------------------------------------------- |
|
480 // |
|
481 EXPORT_C CUniTextObject* CUniSmilModel::AddTextObjectL( |
|
482 TInt aSlideNum, |
|
483 CEikRichTextEditor* aText ) |
|
484 { |
|
485 CUniTextObject* obj = CUniTextObject::NewLC( iFs, iMtm, iData, aText ); |
|
486 iObjectList.AddObjectL( obj ); |
|
487 CleanupStack::Pop( obj ); |
|
488 iSlideArray->At(aSlideNum)->AddObjectL( obj ); |
|
489 iSizeEstimateUpToDate = EFalse; |
|
490 return obj; |
|
491 } |
|
492 |
|
493 // --------------------------------------------------------- |
|
494 // CUniSmilModel::AddTempObjectL |
|
495 // |
|
496 // --------------------------------------------------------- |
|
497 // |
|
498 /* |
|
499 EXPORT_C CUniObject* CUniSmilModel::AddTempObjectL( TInt aSlideNum, |
|
500 CMsgMediaInfo* aMedia ) |
|
501 { |
|
502 if ( !IsSlide( aSlideNum ) ) |
|
503 { |
|
504 User::Leave( KErrArgument ); |
|
505 } |
|
506 |
|
507 CUniObject* obj = CUniObject::NewLC( iFs, iMtm, iData, aMedia ); |
|
508 |
|
509 // Update model |
|
510 iObjectList.AddObjectL( obj ); |
|
511 CleanupStack::Pop( obj ); |
|
512 iSlideArray->At( aSlideNum )->AddObjectL( obj ); |
|
513 SetLayoutFromObjectTypeL( obj->MediaType() ); |
|
514 iSizeEstimateUpToDate = EFalse; |
|
515 return obj; |
|
516 } |
|
517 */ |
|
518 |
|
519 // --------------------------------------------------------- |
|
520 // CUniSmilModel::AddObjectL |
|
521 // |
|
522 // --------------------------------------------------------- |
|
523 // |
|
524 EXPORT_C CUniObject* CUniSmilModel::AddObjectL( MUniObjectSaveObserver& aObserver, |
|
525 TInt aSlideNum, |
|
526 CMsgMediaInfo* aMedia ) |
|
527 { |
|
528 if ( !IsSlide( aSlideNum ) ) |
|
529 { |
|
530 User::Leave( KErrArgument ); |
|
531 } |
|
532 |
|
533 CUniObject* obj = CUniObject::NewLC( iFs, iMtm, iData, aMedia ); |
|
534 |
|
535 // Update model |
|
536 iObjectList.AddObjectL( obj ); |
|
537 CleanupStack::Pop( obj ); |
|
538 obj->Save( aObserver, CMsvAttachment::EMsvLinkedFile ); |
|
539 iSlideArray->At(aSlideNum)->AddObjectL( obj ); |
|
540 iSizeEstimateUpToDate = EFalse; |
|
541 return obj; |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------- |
|
545 // CUniSmilModel::AddStoredObjectL |
|
546 // |
|
547 // --------------------------------------------------------- |
|
548 // |
|
549 EXPORT_C CUniObject* CUniSmilModel::AddStoredObjectL( TInt aSlideNum, |
|
550 TMsvAttachmentId aAttachmentId, |
|
551 CMsgMediaInfo* aMedia ) |
|
552 { |
|
553 if ( !IsSlide( aSlideNum ) ) |
|
554 { |
|
555 User::Leave( KErrArgument ); |
|
556 } |
|
557 |
|
558 CMsvStore* store = iMtm.Entry().EditStoreL(); |
|
559 CleanupStack::PushL( store ); |
|
560 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
561 MMsvAttachmentManagerSync& managerSync = store->AttachmentManagerExtensionsL(); |
|
562 CMsvAttachment* attachment = manager.GetAttachmentInfoL( aAttachmentId ); |
|
563 CleanupStack::PushL( attachment ); |
|
564 |
|
565 CUniObject* obj = NULL; |
|
566 |
|
567 if ( aMedia && |
|
568 aMedia->MediaType() == EMsgMediaText ) |
|
569 { |
|
570 CMsgTextInfo* textInfo = static_cast<CMsgTextInfo*>( aMedia ); |
|
571 obj = CUniTextObject::NewLC( iFs, iMtm, iData, textInfo, manager, *attachment ); |
|
572 } |
|
573 else |
|
574 { |
|
575 obj = CUniObject::NewLC( iFs, iMtm, iData, aMedia, manager, *attachment ); |
|
576 } |
|
577 managerSync.ModifyAttachmentInfoL( attachment ); |
|
578 CleanupStack::Pop( 2, attachment ); //obj, attachment |
|
579 CleanupStack::PushL( obj ); |
|
580 store->CommitL(); |
|
581 |
|
582 // Update model |
|
583 iObjectList.AddObjectL( obj ); |
|
584 CleanupStack::Pop( obj ); |
|
585 CleanupStack::PopAndDestroy( store ); |
|
586 iSlideArray->At(aSlideNum)->AddObjectL( obj ); |
|
587 iSizeEstimateUpToDate = EFalse; |
|
588 return obj; |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------- |
|
592 // CUniSmilModel::RemoveObjectL |
|
593 // |
|
594 // |
|
595 // --------------------------------------------------------- |
|
596 // |
|
597 EXPORT_C void CUniSmilModel::RemoveObjectL( TInt aSlideNum, |
|
598 CUniObject* aObject, |
|
599 TBool aLeaveToStore/* = EFalse*/ ) |
|
600 { |
|
601 if ( !IsSlide( aSlideNum ) || |
|
602 !iSlideArray->At( aSlideNum )->IsObject( aObject ) ) |
|
603 { |
|
604 return; |
|
605 } |
|
606 // TODO: Check that object exists on the slide. |
|
607 |
|
608 //if ( !IsObject( aSlideNum, aObjectType ) ) |
|
609 // { |
|
610 // return; |
|
611 // } |
|
612 DoRemoveObjectL( aSlideNum, aObject, aLeaveToStore ); |
|
613 } |
|
614 |
|
615 // --------------------------------------------------------- |
|
616 // CUniSmilModel::RemoveObjectByIndexL |
|
617 // |
|
618 // |
|
619 // --------------------------------------------------------- |
|
620 // |
|
621 EXPORT_C void CUniSmilModel::RemoveObjectByIndexL( TInt aSlideNum, TInt aObjectNum ) |
|
622 { |
|
623 if ( !IsSlide( aSlideNum ) ) |
|
624 { |
|
625 return; |
|
626 } |
|
627 CUniObject* obj = iSlideArray->At( aSlideNum )->GetObjectByIndex( aObjectNum ); |
|
628 DoRemoveObjectL( aSlideNum, obj ); |
|
629 } |
|
630 |
|
631 // --------------------------------------------------------- |
|
632 // CUniSmilModel::DoRemoveObjectL |
|
633 // |
|
634 // |
|
635 // --------------------------------------------------------- |
|
636 // |
|
637 void CUniSmilModel::DoRemoveObjectL( TInt aSlideNum, CUniObject* aObject, TBool aLeaveToStore/* = EFalse*/ ) |
|
638 { |
|
639 //MsgDataUTILSLOGGER_ENTERFN( "CUniSmilModel : DoRemoveObjectL()" ); |
|
640 |
|
641 TBool removeObj = ( aObject->ReferenceCount() - 1 <= 0 ); |
|
642 //if last reference was (will be) removed, remove from |
|
643 //attachment list (and msg store) |
|
644 if ( removeObj ) |
|
645 { |
|
646 //MsgDataUTILSLOGGER_WRITE( "CUniSmilModel: Removing from atta list and store." ); |
|
647 iObjectList.RemoveObjectL( aObject, !aLeaveToStore ); |
|
648 } |
|
649 |
|
650 CUniSmilSlide* slide = iSlideArray->At( aSlideNum ); |
|
651 slide->RemoveObject( aObject ); |
|
652 iSizeEstimateUpToDate = EFalse; |
|
653 |
|
654 if ( removeObj ) |
|
655 { |
|
656 delete aObject; |
|
657 } |
|
658 |
|
659 //MsgDataUTILSLOGGER_LEAVEFN( "CUniSmilModel : DoRemoveObjectL()" ); |
|
660 } |
|
661 |
|
662 // --------------------------------------------------------- |
|
663 // CUniSmilModel::GetObject |
|
664 // |
|
665 // |
|
666 // --------------------------------------------------------- |
|
667 // |
|
668 EXPORT_C CUniObject* CUniSmilModel::GetObjectByIndex( TInt aSlideNum, |
|
669 TInt aObjectNum ) const |
|
670 { |
|
671 if( !IsSlide( aSlideNum ) ) |
|
672 { |
|
673 return NULL; |
|
674 } |
|
675 return iSlideArray->At( aSlideNum )->GetObjectByIndex( aObjectNum ); |
|
676 } |
|
677 |
|
678 // --------------------------------------------------------- |
|
679 // CUniSmilModel::GetObject |
|
680 // |
|
681 // |
|
682 // --------------------------------------------------------- |
|
683 // |
|
684 EXPORT_C CUniObject* CUniSmilModel::GetObject( TInt aSlideNum, |
|
685 TUniRegion aRegion ) const |
|
686 { |
|
687 if( !IsSlide( aSlideNum ) ) |
|
688 { |
|
689 return NULL; |
|
690 } |
|
691 return iSlideArray->At( aSlideNum )->GetObject( aRegion ); |
|
692 } |
|
693 |
|
694 // --------------------------------------------------------- |
|
695 // CUniSmilModel::SetLayoutL |
|
696 // |
|
697 // Mutator. |
|
698 // --------------------------------------------------------- |
|
699 // |
|
700 EXPORT_C void CUniSmilModel::SetLayoutL( TUniLayout aNewLayout ) |
|
701 { |
|
702 iSlideLayout = aNewLayout; |
|
703 TUint slideCnt = iSlideArray->Count(); |
|
704 for (TUint i = 0; i < slideCnt; i++ ) |
|
705 { |
|
706 iSlideArray->At(i)->UpdateLayoutL( iSlideLayout ); |
|
707 } |
|
708 iSizeEstimateUpToDate = EFalse; |
|
709 } |
|
710 |
|
711 // --------------------------------------------------------- |
|
712 // CUniSmilModel::SmilComposeSize() |
|
713 // |
|
714 // Total size |
|
715 // --------------------------------------------------------- |
|
716 // |
|
717 EXPORT_C TInt CUniSmilModel::SmilComposeSize() |
|
718 { |
|
719 TInt slideCount = iSlideArray->Count(); |
|
720 if ( !slideCount ) |
|
721 { |
|
722 return 0; |
|
723 } |
|
724 if ( !iSizeEstimateUpToDate ) |
|
725 { |
|
726 iSizeEstimate = SmilComposeSize( |
|
727 slideCount, |
|
728 iSlideArray->At( slideCount - 1 )->ObjectCount() ); |
|
729 iSizeEstimateUpToDate = ETrue; |
|
730 } |
|
731 return iSizeEstimate; |
|
732 } |
|
733 |
|
734 |
|
735 // --------------------------------------------------------- |
|
736 // CUniSmilModel::SmilComposeSize() |
|
737 // |
|
738 // Size from beginning |
|
739 // --------------------------------------------------------- |
|
740 // |
|
741 EXPORT_C TInt CUniSmilModel::SmilComposeSize( TInt aToSlideNum, TInt aToObjectNum ) |
|
742 { |
|
743 //__ASSERT_DEBUG( |
|
744 // ( aToSlideNum > 0 && aToSlideNum <= iSlideArray->Count() ), |
|
745 // DataUtilsPanic( EMmsIllegalSlide ) ); |
|
746 //__ASSERT_DEBUG( |
|
747 // ( aToObjectNum <= iSlideArray->At( aToSlideNum - 1 )->ObjectCount() ), |
|
748 // DataUtilsPanic( EMmsIllegalObject ) ); |
|
749 |
|
750 TInt size( KSizeMandatorySmilTags ); |
|
751 TBool imageRegion = EFalse; |
|
752 TBool textRegion = EFalse; |
|
753 |
|
754 for ( TInt i = 0; i < aToSlideNum; ++i ) |
|
755 { |
|
756 CUniSmilSlide* slide = iSlideArray->At( i ); |
|
757 TInt toObj = slide->ObjectCount(); |
|
758 if ( i == aToSlideNum - 1 ) |
|
759 { |
|
760 toObj = aToObjectNum; |
|
761 } |
|
762 if ( !toObj ) |
|
763 { |
|
764 //No objects on the slide |
|
765 size += KSizeEmptyPar; |
|
766 } |
|
767 else |
|
768 { |
|
769 //One or more objects |
|
770 size += KSizeNonEmptyPar; |
|
771 } |
|
772 for ( TInt ii = 0; ii < toObj; ++ii ) |
|
773 { |
|
774 CUniObject* obj = slide->GetObjectByIndex( ii ); |
|
775 switch ( obj->MediaType() ) |
|
776 { |
|
777 case EMsgMediaAudio: |
|
778 size += KSizeAudioTag; |
|
779 break; |
|
780 case EMsgMediaImage: |
|
781 case EMsgMediaSvg: |
|
782 size += KSizeImageTag; |
|
783 imageRegion = ETrue; |
|
784 break; |
|
785 case EMsgMediaText: |
|
786 case EMsgMediaXhtml: |
|
787 size += KSizeTextTag; |
|
788 textRegion = ETrue; |
|
789 break; |
|
790 case EMsgMediaVideo: |
|
791 size += KSizeVideoTag; |
|
792 imageRegion = ETrue; |
|
793 break; |
|
794 default: |
|
795 //Should never come here |
|
796 //Don't increase size |
|
797 break; |
|
798 } |
|
799 } |
|
800 } |
|
801 |
|
802 TInt regions = 0; |
|
803 if ( imageRegion ) |
|
804 { |
|
805 regions++; |
|
806 } |
|
807 if ( textRegion ) |
|
808 { |
|
809 regions++; |
|
810 } |
|
811 switch ( regions ) |
|
812 { |
|
813 case 1: |
|
814 size += KSizeHeadOneRegion; |
|
815 break; |
|
816 case 2: |
|
817 size += KSizeHeadTwoRegions; |
|
818 break; |
|
819 default: |
|
820 //Should be zero |
|
821 //Don't increase size |
|
822 break; |
|
823 } |
|
824 return size; |
|
825 } |
|
826 |
|
827 |
|
828 // --------------------------------------------------------- |
|
829 // CUniSmilModel::ObjectCount |
|
830 // |
|
831 // Accessor |
|
832 // --------------------------------------------------------- |
|
833 // |
|
834 EXPORT_C TInt CUniSmilModel::ObjectCount() const |
|
835 { |
|
836 TInt objCnt(0); |
|
837 |
|
838 for ( TInt i = iSlideArray->Count(); --i >= 0 ;) |
|
839 { |
|
840 objCnt += iSlideArray->At(i)->ObjectCount(); |
|
841 } |
|
842 |
|
843 return objCnt; |
|
844 } |
|
845 |
|
846 |
|
847 // --------------------------------------------------------- |
|
848 // CUniSmilModel::SlideObjectCount |
|
849 // |
|
850 // Accessor |
|
851 // --------------------------------------------------------- |
|
852 // |
|
853 EXPORT_C TInt CUniSmilModel::SlideObjectCount(TInt aSlideNum) const |
|
854 { |
|
855 if ( !IsSlide(aSlideNum) ) |
|
856 { |
|
857 return 0; |
|
858 } |
|
859 |
|
860 return iSlideArray->At( aSlideNum )->ObjectCount(); |
|
861 } |
|
862 |
|
863 //********************************************************** |
|
864 //* |
|
865 //* CONTRUCTION FUNCTIONS |
|
866 //* |
|
867 //********************************************************** |
|
868 |
|
869 |
|
870 // --------------------------------------------------------- |
|
871 // CUniSmilModel::ConstructL |
|
872 // |
|
873 // 2nd phase constructor. |
|
874 // --------------------------------------------------------- |
|
875 // |
|
876 void CUniSmilModel::ConstructL() |
|
877 { |
|
878 iSlideArray = new ( ELeave ) CSmilSlideArray( KSlideArrayGranularity ); |
|
879 iTextRegionId.Set( KNullDesC ); |
|
880 iImageRegionId.Set( KNullDesC ); |
|
881 |
|
882 // Set default layout to "Text first" |
|
883 iSlideLayout = EUniTextFirst; |
|
884 |
|
885 // Fix for NSIA-6CKFJA. Sets same screen size that SMIL Player is using. MH |
|
886 /* |
|
887 TRect appWindowRect; |
|
888 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, appWindowRect ); |
|
889 |
|
890 TAknLayoutRect mainPane; |
|
891 mainPane.LayoutRect( appWindowRect, AknLayoutScalable_Avkon::main_pane( 0 ) ); |
|
892 |
|
893 TAknLayoutRect mainSmilPane; |
|
894 mainSmilPane.LayoutRect( mainPane.Rect(), AknLayoutScalable_Apps::main_smil_pane() ); |
|
895 |
|
896 iScreenSize = mainSmilPane.Rect().Size(); |
|
897 */ |
|
898 } |
|
899 |
|
900 // --------------------------------------------------------- |
|
901 // CUniSmilModel::Reset |
|
902 // |
|
903 // |
|
904 // --------------------------------------------------------- |
|
905 // |
|
906 void CUniSmilModel::Reset() |
|
907 { |
|
908 iParseResult = 0; |
|
909 iSlideLayout = EUniTextFirst; |
|
910 iTextRegionId.Set( KNullDesC ); |
|
911 iImageRegionId.Set( KNullDesC ); |
|
912 if ( iSlideArray ) |
|
913 { |
|
914 // Reset slide array |
|
915 iSlideArray->ResetAndDestroy(); |
|
916 } |
|
917 TInt objCount = iObjectList.Count(); |
|
918 while ( objCount-- ) |
|
919 { |
|
920 iObjectList.GetByIndex( objCount )->SetReferenceCount( 0 ); |
|
921 } |
|
922 } |
|
923 |
|
924 // --------------------------------------------------------- |
|
925 // CUniSmilModel::DoPresentationFromDomL |
|
926 // |
|
927 // When this functios is called DOM should be validated as MMS SMIL. |
|
928 // --------------------------------------------------------- |
|
929 // |
|
930 void CUniSmilModel::DoPresentationFromDomL( CMDXMLDocument* aDom ) |
|
931 { |
|
932 RemoveMetaTagsAndComments( aDom ); |
|
933 // Resolve layout of the slide |
|
934 iSlideLayout = GetMmsSmilLayout( aDom ); |
|
935 |
|
936 CMDXMLNode* node = GetNode( aDom, KSMILWREleBody ); |
|
937 |
|
938 if ( node && node->FirstChild() ) |
|
939 { |
|
940 // Only one slide in the message since no <par> tag found |
|
941 if ( node->FirstChild()->NodeName().Compare( KSMILWRElePar ) != 0 ) |
|
942 { |
|
943 // Add slide - the one and only |
|
944 AddSlideFromDomL( node ); |
|
945 } |
|
946 |
|
947 // Other node types than <par> not possible as this is MMS SMIL. |
|
948 else |
|
949 { |
|
950 // Traverse through every page |
|
951 CMDXMLNode* page = node->FirstChild(); |
|
952 while ( page ) |
|
953 { |
|
954 AddSlideFromDomL( page ); |
|
955 // Go to next page. |
|
956 page = page->NextSibling(); |
|
957 } |
|
958 } |
|
959 } |
|
960 } |
|
961 |
|
962 // --------------------------------------------------------- |
|
963 // CUniSmilModel::AddSlideFromDomL |
|
964 // |
|
965 // --------------------------------------------------------- |
|
966 // |
|
967 void CUniSmilModel::AddSlideFromDomL( CMDXMLNode* aPage ) |
|
968 { |
|
969 CUniObject* obj = NULL; |
|
970 CUniSmilSlide* slide = DoAddSlideL(); |
|
971 CMDXMLNode* node = aPage->FirstChild(); |
|
972 |
|
973 // Traverse through every object in page. |
|
974 while ( node ) |
|
975 { |
|
976 if ( UniSmilUtils::IsMediaElem( node ) ) |
|
977 { |
|
978 obj = iObjectList.GetByNodeL( node ); |
|
979 if ( obj ) |
|
980 { |
|
981 if ( slide ) |
|
982 { |
|
983 obj->SetMediaTypeBySmilTag( UniSmilUtils::MediaElemType( node ) ); |
|
984 AddObjectFromDomL( |
|
985 slide, |
|
986 obj, |
|
987 GetRegionType( node ) ); |
|
988 } |
|
989 else |
|
990 { |
|
991 iObjectList.RemoveObjectL( obj, ETrue ); |
|
992 delete obj; |
|
993 iParseResult |= EObjectRemoved; |
|
994 } |
|
995 } |
|
996 } |
|
997 node = node->NextSibling(); |
|
998 } |
|
999 } |
|
1000 |
|
1001 |
|
1002 // --------------------------------------------------------- |
|
1003 // CUniSmilModel::AddObjectFromDomL |
|
1004 // |
|
1005 // --------------------------------------------------------- |
|
1006 // |
|
1007 void CUniSmilModel::AddObjectFromDomL( CUniSmilSlide* aSlide, |
|
1008 CUniObject* aObj, |
|
1009 TUniRegion aRegion ) |
|
1010 { |
|
1011 if ( !aObj ) |
|
1012 { |
|
1013 // Smil presentation refers to attachment that's not in the message |
|
1014 iParseResult |= EMissingObjects; |
|
1015 // Not actually error that should prevent message viewing. |
|
1016 return; |
|
1017 } |
|
1018 |
|
1019 TMsgMediaType mediaBySmilTag = aObj->MediaTypeBySmilTag(); |
|
1020 TMsgMediaType media = aObj->MediaType(); |
|
1021 |
|
1022 if ( media == EMsgMediaSvg ) |
|
1023 { |
|
1024 // SVG considered an image. |
|
1025 // (...because "image" tag is used for SVG while composing SMIL.) |
|
1026 media = EMsgMediaImage; |
|
1027 } |
|
1028 |
|
1029 if ( media == EMsgMediaXhtml ) |
|
1030 { |
|
1031 // XHTML is considered as a text. |
|
1032 // (...because "text" tag is used for xhtml while composing SMIL.) |
|
1033 media = EMsgMediaText; |
|
1034 } |
|
1035 |
|
1036 if ( !( media == EMsgMediaText || |
|
1037 media == EMsgMediaImage || |
|
1038 media == EMsgMediaAudio || |
|
1039 media == EMsgMediaVideo ) ) |
|
1040 { |
|
1041 // Unsupported format |
|
1042 //MsgDataUTILSLOGGER_WRITE( "CUniSmilModel: Parsing: Message has unsupported objects." ); |
|
1043 iParseResult |= EUnsupportedObjects; |
|
1044 // Not actually error that should prevent message viewing. |
|
1045 } |
|
1046 |
|
1047 // NOTE: Smil standard allows <img src="aa.txt"> references, but conformance |
|
1048 // Data forbids these. |
|
1049 if ( media != EMsgMediaUnknown && //Unknown matches anything |
|
1050 mediaBySmilTag != EMsgMediaRef && //<ref> matches anything |
|
1051 media != mediaBySmilTag ) |
|
1052 { |
|
1053 // SMIL does not describe content as it should |
|
1054 //MsgDataUTILSLOGGER_WRITE( "CUniSmilModel: Parsing: Smil object type differs from message object type." ); |
|
1055 iParseResult |= EBadlyReferencedObjects; |
|
1056 } |
|
1057 |
|
1058 TUniRegion regionBySmilTag = EUniRegionUnresolved; |
|
1059 switch ( mediaBySmilTag ) |
|
1060 { |
|
1061 case EMsgMediaAudio: |
|
1062 { |
|
1063 regionBySmilTag = EUniRegionAudio; |
|
1064 break; |
|
1065 } |
|
1066 case EMsgMediaImage: |
|
1067 case EMsgMediaVideo: |
|
1068 { |
|
1069 regionBySmilTag = EUniRegionImage; |
|
1070 break; |
|
1071 } |
|
1072 case EMsgMediaText: |
|
1073 { |
|
1074 regionBySmilTag = EUniRegionText; |
|
1075 break; |
|
1076 } |
|
1077 default: |
|
1078 break; |
|
1079 } |
|
1080 |
|
1081 TUniRegion regionByMediaType = EUniRegionUnresolved; |
|
1082 switch ( media ) |
|
1083 { |
|
1084 case EMsgMediaAudio: |
|
1085 { |
|
1086 regionByMediaType = EUniRegionAudio; |
|
1087 break; |
|
1088 } |
|
1089 case EMsgMediaImage: |
|
1090 case EMsgMediaVideo: |
|
1091 { |
|
1092 regionByMediaType = EUniRegionImage; |
|
1093 break; |
|
1094 } |
|
1095 case EMsgMediaText: |
|
1096 { |
|
1097 regionByMediaType = EUniRegionText; |
|
1098 break; |
|
1099 } |
|
1100 default: |
|
1101 break; |
|
1102 } |
|
1103 |
|
1104 // Check that region type matches object media type |
|
1105 if ( aRegion != EUniRegionUnresolved && |
|
1106 regionByMediaType != EUniRegionUnresolved && |
|
1107 aRegion != regionByMediaType ) |
|
1108 { |
|
1109 iParseResult |= ERegionMediaTypeMismatch; |
|
1110 aRegion = regionByMediaType; |
|
1111 } |
|
1112 else if ( regionByMediaType == EUniRegionUnresolved && |
|
1113 aRegion == EUniRegionText ) |
|
1114 { |
|
1115 // do not put every possible content into text reqion |
|
1116 iParseResult |= ERegionMediaTypeMismatch; |
|
1117 aRegion = EUniRegionUnresolved; |
|
1118 } |
|
1119 else if ( aRegion == EUniRegionUnresolved ) |
|
1120 { |
|
1121 // If region couldn't be resolved from the region tag |
|
1122 // follow the media type. If that's not possible follow |
|
1123 // the smil media tag name. If everything fails |
|
1124 // "aRegion" will remain "unresolved". |
|
1125 aRegion = ( regionByMediaType != EUniRegionUnresolved ) |
|
1126 ? regionByMediaType |
|
1127 : regionBySmilTag; |
|
1128 } |
|
1129 |
|
1130 CMsgMediaInfo* mediaInfo = aObj->MediaInfo(); |
|
1131 // DRM2 must be put into object view in the viewer |
|
1132 if ( mediaInfo && |
|
1133 ( /*mediaInfo->HandlerApplicationUid().iUid == 0 ||*/ |
|
1134 aObj->MediaInfo()->Protection() & EFileProtDrm2 ) ) |
|
1135 { |
|
1136 aRegion = EUniRegionUnresolved; |
|
1137 } |
|
1138 // else - should not occur |
|
1139 |
|
1140 if ( aRegion != EUniRegionUnresolved ) |
|
1141 { |
|
1142 aSlide->AddObjectL( aObj, aRegion ); |
|
1143 iSizeEstimateUpToDate = EFalse; |
|
1144 } |
|
1145 else |
|
1146 { |
|
1147 iParseResult |= EBadlyReferencedObjects; |
|
1148 // -> Something unknown in the SMIL. |
|
1149 // -> Don't add. Will be handled as an attachment. |
|
1150 } |
|
1151 } |
|
1152 |
|
1153 // --------------------------------------------------------- |
|
1154 // CUniSmilModel::IsMessageSlide |
|
1155 // |
|
1156 // --------------------------------------------------------- |
|
1157 // |
|
1158 TBool CUniSmilModel::IsMessageSlide() |
|
1159 { |
|
1160 TInt imageCnt( 0 ); |
|
1161 TInt audioCnt( 0 ); |
|
1162 TInt textCnt( 0 ); |
|
1163 |
|
1164 for ( TInt i = iObjectList.Count(); --i >= 0 ; ) |
|
1165 { |
|
1166 switch( iObjectList.GetByIndex(i)->MediaType() ) |
|
1167 { |
|
1168 case EMsgMediaSvg: |
|
1169 case EMsgMediaImage: |
|
1170 imageCnt++; |
|
1171 break; |
|
1172 |
|
1173 case EMsgMediaAudio: |
|
1174 audioCnt++; |
|
1175 break; |
|
1176 |
|
1177 case EMsgMediaText: |
|
1178 case EMsgMediaXhtml: |
|
1179 textCnt++; |
|
1180 break; |
|
1181 |
|
1182 case EMsgMediaVideo: |
|
1183 //always consider video as image + audio |
|
1184 imageCnt++; |
|
1185 audioCnt++; |
|
1186 break; |
|
1187 |
|
1188 case EMsgMediaUnknown: |
|
1189 default: |
|
1190 // Unsupported objects will be put into attachment list |
|
1191 // in FindAttachmentsL() |
|
1192 break; |
|
1193 } // switch |
|
1194 } // for |
|
1195 |
|
1196 if ( imageCnt > 1 || audioCnt > 1 || textCnt > 1 ) |
|
1197 { |
|
1198 return EFalse; |
|
1199 } |
|
1200 |
|
1201 return ETrue; |
|
1202 } |
|
1203 |
|
1204 // --------------------------------------------------------- |
|
1205 // DoNoSmilOneSlideL |
|
1206 // |
|
1207 // NOTE: Message should be a valid slide at this point. |
|
1208 // --------------------------------------------------------- |
|
1209 // |
|
1210 void CUniSmilModel::DoNoSmilOneSlideL() |
|
1211 { |
|
1212 CUniSmilSlide* slide = NULL; |
|
1213 |
|
1214 for ( TInt i = 0; i < iObjectList.Count(); ++i ) |
|
1215 { |
|
1216 CUniObject* obj = iObjectList.GetByIndex(i); |
|
1217 TMsgMediaType media = obj->MediaType(); |
|
1218 CMsgMediaInfo* mediaInfo = obj->MediaInfo(); |
|
1219 |
|
1220 // DRM2 must be put into objects view in the viewer |
|
1221 if ( ( media == EMsgMediaText || |
|
1222 media == EMsgMediaXhtml || |
|
1223 media == EMsgMediaImage || |
|
1224 media == EMsgMediaSvg || |
|
1225 media == EMsgMediaAudio || |
|
1226 media == EMsgMediaVideo ) && |
|
1227 mediaInfo && |
|
1228 /*mediaInfo->HandlerApplicationUid().iUid &&*/ |
|
1229 !( obj->MediaInfo()->Protection() & EFileProtDrm2 ) ) |
|
1230 { |
|
1231 if ( !slide ) |
|
1232 { |
|
1233 // Add slide |
|
1234 slide = DoAddSlideL(); |
|
1235 } |
|
1236 slide->AddObjectL( obj ); |
|
1237 } |
|
1238 } |
|
1239 } |
|
1240 |
|
1241 // --------------------------------------------------------- |
|
1242 // DoNoSmilManySlideL |
|
1243 // |
|
1244 // |
|
1245 // --------------------------------------------------------- |
|
1246 // |
|
1247 void CUniSmilModel::DoNoSmilManySlideL() |
|
1248 { |
|
1249 for ( TInt i = 0; i < iObjectList.Count(); ++i ) |
|
1250 { |
|
1251 CUniObject* obj = iObjectList.GetByIndex(i); |
|
1252 if (obj == NULL) |
|
1253 return; |
|
1254 |
|
1255 TMsgMediaType media = obj->MediaType(); |
|
1256 CMsgMediaInfo* mediaInfo = obj->MediaInfo(); |
|
1257 |
|
1258 // DRM2 must be put into objects view in the viewer |
|
1259 if ( ( media == EMsgMediaText || |
|
1260 media == EMsgMediaXhtml || |
|
1261 media == EMsgMediaImage || |
|
1262 media == EMsgMediaSvg || |
|
1263 media == EMsgMediaAudio || |
|
1264 media == EMsgMediaVideo ) && |
|
1265 mediaInfo && |
|
1266 /*mediaInfo->HandlerApplicationUid().iUid &&*/ |
|
1267 !( obj->MediaInfo()->Protection() & EFileProtDrm2 ) ) |
|
1268 { |
|
1269 CUniSmilSlide* slide = DoAddSlideL(); |
|
1270 if ( slide ) |
|
1271 { |
|
1272 slide->AddObjectL( obj ); |
|
1273 } |
|
1274 else |
|
1275 { |
|
1276 iObjectList.RemoveObjectL( obj, ETrue ); |
|
1277 delete obj; |
|
1278 iParseResult |= EObjectRemoved; |
|
1279 i--; |
|
1280 } |
|
1281 } |
|
1282 } |
|
1283 } |
|
1284 |
|
1285 // --------------------------------------------------------- |
|
1286 // DoAddSlideL |
|
1287 // |
|
1288 // --------------------------------------------------------- |
|
1289 // |
|
1290 CUniSmilSlide* CUniSmilModel::DoAddSlideL( TInt aSlideNum /*= -1*/ ) |
|
1291 { |
|
1292 CUniSmilSlide* newSlide = NULL; |
|
1293 if ( iMaxSlideCount == 0 || |
|
1294 iSlideArray->Count() < iMaxSlideCount ) |
|
1295 { |
|
1296 newSlide = CUniSmilSlide::NewLC( iSlideLayout ); |
|
1297 if ( aSlideNum == -1 || aSlideNum >= iSlideArray->Count() ) |
|
1298 { |
|
1299 // Add to end of array |
|
1300 iSlideArray->AppendL( newSlide ); |
|
1301 } |
|
1302 else |
|
1303 { |
|
1304 iSlideArray->InsertL( aSlideNum, newSlide ); |
|
1305 } |
|
1306 CleanupStack::Pop( newSlide ); // newSlide |
|
1307 iSizeEstimateUpToDate = EFalse; |
|
1308 } |
|
1309 return newSlide; |
|
1310 } |
|
1311 |
|
1312 // --------------------------------------------------------- |
|
1313 // CUniSmilModel::CreateHeadL |
|
1314 // |
|
1315 // --------------------------------------------------------- |
|
1316 void CUniSmilModel::CreateHeadL( CMDXMLDocument* aDom, CMDXMLElement* aRoot ) |
|
1317 { |
|
1318 |
|
1319 TPtrC name( KSMILWREleHead ); |
|
1320 // Create Head node |
|
1321 CMDXMLElement* ele = CMDXMLElement::NewLC( ETrue, aDom, name ); |
|
1322 // Append Head in Root node |
|
1323 aRoot->AppendChild( ele ); |
|
1324 |
|
1325 // Create Layout |
|
1326 CreateLayoutL( aDom, ele ); |
|
1327 CleanupStack::Pop( ele ); |
|
1328 } |
|
1329 |
|
1330 // --------------------------------------------------------- |
|
1331 // CUniSmilModel::ChangeLayoutL |
|
1332 // |
|
1333 // --------------------------------------------------------- |
|
1334 EXPORT_C TBool CUniSmilModel::ChangeLayoutL( CMDXMLDocument* aDom ) |
|
1335 { |
|
1336 TBool retVal = EFalse; |
|
1337 if ( aDom ) |
|
1338 { |
|
1339 CMDXMLElement* layout = (CMDXMLElement*) GetNode( aDom, KSMILWREleLayout ); |
|
1340 if ( !layout ) |
|
1341 { |
|
1342 // No layout. Nothing to do without composing |
|
1343 // SMIL from scratch. |
|
1344 return EFalse; |
|
1345 } |
|
1346 CMDXMLElement* head = (CMDXMLElement*) layout->ParentNode(); |
|
1347 |
|
1348 // Read default smil parameters |
|
1349 if( !iSmilParams ) |
|
1350 { |
|
1351 iSmilParams = CUniSmilParams::NewL( iFs ); |
|
1352 } |
|
1353 CMDXMLElement* rootLayout = NULL; |
|
1354 CMDXMLElement* textRegion = NULL; |
|
1355 CMDXMLElement* imageRegion = NULL; |
|
1356 |
|
1357 GetLayoutElements( |
|
1358 layout, |
|
1359 rootLayout, |
|
1360 textRegion, |
|
1361 imageRegion ); |
|
1362 |
|
1363 if ( rootLayout ) |
|
1364 { |
|
1365 rootLayout->RemoveAttribute( KSMILWRParaWidth ); |
|
1366 rootLayout->RemoveAttribute( KSMILWRParaHeight ); |
|
1367 } |
|
1368 |
|
1369 if ( textRegion ) |
|
1370 { |
|
1371 textRegion->RemoveAttribute( KSMILWRParaFit ); |
|
1372 textRegion->RemoveAttribute( KSMILWRParaTop ); |
|
1373 textRegion->RemoveAttribute( KSMILWRParaLeft ); |
|
1374 textRegion->RemoveAttribute( KSMILWRParaBottom ); |
|
1375 textRegion->RemoveAttribute( KSMILWRParaRight ); |
|
1376 textRegion->RemoveAttribute( KSMILWRParaHeight ); |
|
1377 textRegion->RemoveAttribute( KSMILWRParaWidth ); |
|
1378 } |
|
1379 if ( imageRegion ) |
|
1380 { |
|
1381 imageRegion->RemoveAttribute( KSMILWRParaFit ); |
|
1382 imageRegion->RemoveAttribute( KSMILWRParaTop ); |
|
1383 imageRegion->RemoveAttribute( KSMILWRParaLeft ); |
|
1384 imageRegion->RemoveAttribute( KSMILWRParaBottom ); |
|
1385 imageRegion->RemoveAttribute( KSMILWRParaRight ); |
|
1386 imageRegion->RemoveAttribute( KSMILWRParaHeight ); |
|
1387 imageRegion->RemoveAttribute( KSMILWRParaWidth ); |
|
1388 } |
|
1389 |
|
1390 CreateLayoutL( aDom, head, rootLayout, layout, textRegion, imageRegion ); |
|
1391 retVal = ETrue; |
|
1392 } |
|
1393 return retVal; |
|
1394 } |
|
1395 |
|
1396 // --------------------------------------------------------- |
|
1397 // CUniSmilModel::CorrectTimingL |
|
1398 // |
|
1399 // --------------------------------------------------------- |
|
1400 EXPORT_C TBool CUniSmilModel::CorrectTimingL( CMDXMLDocument* aDom ) |
|
1401 { |
|
1402 if ( aDom ) |
|
1403 { |
|
1404 CMDXMLElement* body = static_cast<CMDXMLElement*>( GetNode( aDom, KSMILWREleBody ) ); |
|
1405 if ( !body ) |
|
1406 { |
|
1407 // No body. Nothing to do without composing |
|
1408 // SMIL from scratch. |
|
1409 return EFalse; |
|
1410 } |
|
1411 |
|
1412 if ( body && body->FirstChild() ) |
|
1413 { |
|
1414 // Only one slide in the message since no <par> tag found |
|
1415 if ( body->FirstChild()->NodeName().Compare( KSMILWRElePar ) != 0 && |
|
1416 !body->FirstChild()->NextSibling() ) |
|
1417 { |
|
1418 // Correct slide timing to the one and only slide |
|
1419 CorrectSlideTimingL( body ); |
|
1420 } |
|
1421 // Other node types than <par> not possible as this is MMS SMIL. |
|
1422 else |
|
1423 { |
|
1424 // Traverse through every page |
|
1425 CMDXMLNode* page = body->FirstChild(); |
|
1426 |
|
1427 while ( page != NULL ) |
|
1428 { |
|
1429 if ( page->NodeName().Compare( KSMILWRElePar ) == 0 && |
|
1430 page->NodeType() == CMDXMLNode::EElementNode ) |
|
1431 { |
|
1432 CMDXMLElement* pageElement = static_cast<CMDXMLElement*>( page ); |
|
1433 if ( !TimingSpecified( pageElement ) ) |
|
1434 { |
|
1435 CorrectSlideTimingL( pageElement ); |
|
1436 } |
|
1437 } |
|
1438 // Go to next page. |
|
1439 page = page->NextSibling(); |
|
1440 } |
|
1441 } |
|
1442 } |
|
1443 } |
|
1444 |
|
1445 return ETrue; |
|
1446 } |
|
1447 |
|
1448 // --------------------------------------------------------- |
|
1449 // CUniSmilModel::IsSupportedMediaType |
|
1450 // |
|
1451 // --------------------------------------------------------- |
|
1452 EXPORT_C TBool CUniSmilModel::IsSupportedMediaType( TMsgMediaType aMediaType ) const |
|
1453 { |
|
1454 if ( aMediaType == EMsgMediaAudio || |
|
1455 aMediaType == EMsgMediaImage || |
|
1456 aMediaType == EMsgMediaSvg || |
|
1457 aMediaType == EMsgMediaXhtml || |
|
1458 aMediaType == EMsgMediaVideo || |
|
1459 aMediaType == EMsgMediaText ) |
|
1460 { |
|
1461 return ETrue; |
|
1462 } |
|
1463 else |
|
1464 { |
|
1465 return EFalse; |
|
1466 } |
|
1467 } |
|
1468 |
|
1469 |
|
1470 // --------------------------------------------------------- |
|
1471 // CUniSmilModel::CreateLayoutL |
|
1472 // |
|
1473 // --------------------------------------------------------- |
|
1474 void CUniSmilModel::CreateLayoutL( CMDXMLDocument* aDom, |
|
1475 CMDXMLElement* aRoot, |
|
1476 CMDXMLElement* aRootLayout, |
|
1477 CMDXMLElement* aLayout, |
|
1478 CMDXMLElement* aTextRegion, |
|
1479 CMDXMLElement* aImageRegion ) |
|
1480 { |
|
1481 |
|
1482 TPtrC name( KSMILWREleLayout ); |
|
1483 // Create Layout node |
|
1484 if ( !aLayout ) |
|
1485 { |
|
1486 aLayout = CMDXMLElement::NewLC( ETrue, aDom, name ); |
|
1487 // Append Layout in Head |
|
1488 aRoot->InsertBefore( NULL, aLayout ); |
|
1489 CleanupStack::Pop(); // layout |
|
1490 } |
|
1491 |
|
1492 // Do we have images and text-objects on a slide with other media objects and |
|
1493 // do we have any video |
|
1494 TInt hasVideo( 0 ); |
|
1495 TInt hasImage( 0 ); |
|
1496 TInt hasText( 0 ); |
|
1497 |
|
1498 // Do we have media, which is alone on a slide? Also calculate how medias are alone on a slide. |
|
1499 // Video overrides any image region, it is not needed |
|
1500 TInt hasImageOneAndOnly( 0 ); |
|
1501 TInt hasTextOneAndOnly( 0 ); |
|
1502 |
|
1503 for( TInt i = 0; i < iSlideArray->Count(); ++i ) |
|
1504 { |
|
1505 CUniSmilSlide* s = iSlideArray->At( i ); |
|
1506 TBool hasVideoOnThisSlide = EFalse; |
|
1507 TBool hasImageOnThisSlide = EFalse; |
|
1508 TBool hasTextOnThisSlide = EFalse; |
|
1509 |
|
1510 CUniObject* imageRegionObj = s->GetObject( EUniRegionImage ); |
|
1511 if ( imageRegionObj ) |
|
1512 { |
|
1513 if ( imageRegionObj->MediaType() == EMsgMediaVideo ) |
|
1514 { |
|
1515 hasVideoOnThisSlide = ETrue; |
|
1516 hasVideo++; |
|
1517 } |
|
1518 else |
|
1519 { |
|
1520 hasImageOnThisSlide = ETrue; |
|
1521 hasImage++; |
|
1522 } |
|
1523 } |
|
1524 if ( s->GetObject( EUniRegionText ) ) |
|
1525 { |
|
1526 hasTextOnThisSlide = ETrue; |
|
1527 hasText++; |
|
1528 } |
|
1529 |
|
1530 if ( !hasVideoOnThisSlide |
|
1531 && hasImageOnThisSlide |
|
1532 && !hasTextOnThisSlide ) |
|
1533 { |
|
1534 hasImageOneAndOnly++; |
|
1535 } |
|
1536 if ( !hasVideoOnThisSlide |
|
1537 && !hasImageOnThisSlide |
|
1538 && hasTextOnThisSlide ) |
|
1539 { |
|
1540 hasTextOneAndOnly++; |
|
1541 } |
|
1542 } |
|
1543 |
|
1544 // we know: |
|
1545 // how many media objects of each type there are totally in the message and |
|
1546 // whether some regions have alone on a slide |
|
1547 // we conclude: |
|
1548 // if a media object has been alone on the slide and there is |
|
1549 // only one media object in the whole message |
|
1550 // or if there are several images without other content or several texts on several slides |
|
1551 // without other content then the media object is alone on a slide |
|
1552 // and is only one of its type in the message |
|
1553 // but: video is exception. It handling is ignored here. Following big if() statement handles it |
|
1554 // by handling video before exception case resolved |
|
1555 if ( hasImageOneAndOnly == hasImage ) |
|
1556 { |
|
1557 // image does not occur with some other region |
|
1558 hasImage = 0; |
|
1559 } |
|
1560 else |
|
1561 { |
|
1562 // image occurs with some other region on some slide |
|
1563 hasImageOneAndOnly = 0; |
|
1564 } |
|
1565 |
|
1566 if ( hasTextOneAndOnly == hasText ) |
|
1567 { |
|
1568 // text does not occur with some other region |
|
1569 hasText = 0; |
|
1570 } |
|
1571 else |
|
1572 { |
|
1573 // text occurs with some other region on some slide |
|
1574 hasTextOneAndOnly = 0; |
|
1575 } |
|
1576 |
|
1577 /* |
|
1578 TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
1579 TBool useSubQCIF( EFalse); |
|
1580 |
|
1581 TRect appWin; |
|
1582 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, appWin ); |
|
1583 TAknLayoutRect mainPane; |
|
1584 |
|
1585 if ( isLandscape ) |
|
1586 { |
|
1587 mainPane.LayoutRect( |
|
1588 appWin, |
|
1589 AknLayoutScalable_Apps::main_pane( 4 ).LayoutLine() ); |
|
1590 } |
|
1591 else |
|
1592 { |
|
1593 mainPane.LayoutRect( |
|
1594 appWin, |
|
1595 AknLayoutScalable_Apps::main_pane( 6 ).LayoutLine() ); |
|
1596 } |
|
1597 |
|
1598 if ( isLandscape && |
|
1599 appWin.Height() == KSizeLowResWidth && |
|
1600 appWin.Width() == KSizeLowResHeight ) |
|
1601 { |
|
1602 useSubQCIF = ETrue; |
|
1603 } |
|
1604 |
|
1605 TAknLayoutRect smilLayout; |
|
1606 smilLayout.LayoutRect( |
|
1607 mainPane.Rect(), |
|
1608 AknLayoutScalable_Apps::main_smil2_pane().LayoutLine() ); |
|
1609 |
|
1610 TAknLayoutRect rootLayout; |
|
1611 TAknLayoutRect textLayout; |
|
1612 TAknLayoutRect imageLayout; |
|
1613 TAknLayoutRect videoLayout; |
|
1614 |
|
1615 // For reader about notation: |
|
1616 // x + y == x and y are on the different slide |
|
1617 // x,y == x and y are on the same slide |
|
1618 // { <item> } item can occur 0 or more times |
|
1619 if ( hasText && hasImage && !hasVideo ) // text, image - no video |
|
1620 { |
|
1621 if ( isLandscape ) // landscape text & image |
|
1622 { |
|
1623 if ( iSlideLayout == EUniTextFirst ) |
|
1624 { |
|
1625 rootLayout.LayoutRect( |
|
1626 smilLayout.Rect(), |
|
1627 AknLayoutScalable_Apps::smil2_root_pane( 4 ).LayoutLine() ); |
|
1628 textLayout.LayoutRect( |
|
1629 smilLayout.Rect(), |
|
1630 AknLayoutScalable_Apps::smil2_text_pane( 4 ).LayoutLine() ); |
|
1631 imageLayout.LayoutRect( |
|
1632 smilLayout.Rect(), |
|
1633 AknLayoutScalable_Apps::smil2_image_pane( 3 ).LayoutLine() ); |
|
1634 } |
|
1635 else |
|
1636 { |
|
1637 rootLayout.LayoutRect( |
|
1638 smilLayout.Rect(), |
|
1639 AknLayoutScalable_Apps::smil2_root_pane( 2 ).LayoutLine() ); |
|
1640 textLayout.LayoutRect( |
|
1641 smilLayout.Rect(), |
|
1642 AknLayoutScalable_Apps::smil2_text_pane( 2 ).LayoutLine() ); |
|
1643 imageLayout.LayoutRect( |
|
1644 smilLayout.Rect(), |
|
1645 AknLayoutScalable_Apps::smil2_image_pane( 1 ).LayoutLine() ); |
|
1646 } |
|
1647 } |
|
1648 else // portrait text & image |
|
1649 { |
|
1650 if ( iSlideLayout == EUniTextFirst ) |
|
1651 { |
|
1652 // Option 3 in the layout spec |
|
1653 rootLayout.LayoutRect( |
|
1654 smilLayout.Rect(), |
|
1655 AknLayoutScalable_Apps::smil2_root_pane( 3 ).LayoutLine() ); |
|
1656 textLayout.LayoutRect( |
|
1657 smilLayout.Rect(), |
|
1658 AknLayoutScalable_Apps::smil2_text_pane( 3 ).LayoutLine() ); |
|
1659 imageLayout.LayoutRect( |
|
1660 smilLayout.Rect(), |
|
1661 AknLayoutScalable_Apps::smil2_image_pane( 2 ).LayoutLine() ); |
|
1662 } |
|
1663 else |
|
1664 { |
|
1665 // Option 1 |
|
1666 rootLayout.LayoutRect( |
|
1667 smilLayout.Rect(), |
|
1668 AknLayoutScalable_Apps::smil2_root_pane( 1 ).LayoutLine() ); |
|
1669 textLayout.LayoutRect( |
|
1670 smilLayout.Rect(), |
|
1671 AknLayoutScalable_Apps::smil2_text_pane( 1 ).LayoutLine() ); |
|
1672 imageLayout.LayoutRect( |
|
1673 smilLayout.Rect(), |
|
1674 AknLayoutScalable_Apps::smil2_image_pane( 0 ).LayoutLine() ); |
|
1675 } |
|
1676 } |
|
1677 } |
|
1678 else if ( hasText && hasVideo ) // text, video or text, image + video |
|
1679 { |
|
1680 if ( isLandscape && useSubQCIF ) // landscape subQCIF text & video |
|
1681 { |
|
1682 if ( iSlideLayout == EUniTextFirst ) |
|
1683 { |
|
1684 rootLayout.LayoutRect( |
|
1685 smilLayout.Rect(), |
|
1686 AknLayoutScalable_Apps::smil2_root_pane( 13 ).LayoutLine() ); |
|
1687 textLayout.LayoutRect( |
|
1688 smilLayout.Rect(), |
|
1689 AknLayoutScalable_Apps::smil2_text_pane( 10 ).LayoutLine() ); |
|
1690 videoLayout.LayoutRect( |
|
1691 smilLayout.Rect(), |
|
1692 AknLayoutScalable_Apps::smil2_video_pane( 7 ).LayoutLine() ); |
|
1693 } |
|
1694 else |
|
1695 { |
|
1696 rootLayout.LayoutRect( |
|
1697 smilLayout.Rect(), |
|
1698 AknLayoutScalable_Apps::smil2_root_pane( 12 ).LayoutLine() ); |
|
1699 textLayout.LayoutRect( |
|
1700 smilLayout.Rect(), |
|
1701 AknLayoutScalable_Apps::smil2_text_pane( 9 ).LayoutLine() ); |
|
1702 videoLayout.LayoutRect( |
|
1703 smilLayout.Rect(), |
|
1704 AknLayoutScalable_Apps::smil2_video_pane( 6 ).LayoutLine() ); |
|
1705 } |
|
1706 } |
|
1707 else if ( isLandscape && !useSubQCIF ) // landscape QCIF text & video |
|
1708 { |
|
1709 if ( iSlideLayout == EUniTextFirst ) |
|
1710 { |
|
1711 rootLayout.LayoutRect( |
|
1712 smilLayout.Rect(), |
|
1713 AknLayoutScalable_Apps::smil2_root_pane( 10 ).LayoutLine() ); |
|
1714 textLayout.LayoutRect( |
|
1715 smilLayout.Rect(), |
|
1716 AknLayoutScalable_Apps::smil2_text_pane( 8 ).LayoutLine() ); |
|
1717 videoLayout.LayoutRect( |
|
1718 smilLayout.Rect(), |
|
1719 AknLayoutScalable_Apps::smil2_video_pane( 4 ).LayoutLine() ); |
|
1720 } |
|
1721 else |
|
1722 { |
|
1723 rootLayout.LayoutRect( |
|
1724 smilLayout.Rect(), |
|
1725 AknLayoutScalable_Apps::smil2_root_pane( 9 ).LayoutLine() ); |
|
1726 textLayout.LayoutRect( |
|
1727 smilLayout.Rect(), |
|
1728 AknLayoutScalable_Apps::smil2_text_pane( 7 ).LayoutLine() ); |
|
1729 videoLayout.LayoutRect( |
|
1730 smilLayout.Rect(), |
|
1731 AknLayoutScalable_Apps::smil2_video_pane( 3 ).LayoutLine() ); |
|
1732 } |
|
1733 } |
|
1734 else // portrait QCIF text & video |
|
1735 { |
|
1736 if ( iSlideLayout == EUniTextFirst ) |
|
1737 { |
|
1738 // Option 8 |
|
1739 rootLayout.LayoutRect( |
|
1740 smilLayout.Rect(), |
|
1741 AknLayoutScalable_Apps::smil2_root_pane( 8 ).LayoutLine() ); |
|
1742 textLayout.LayoutRect( |
|
1743 smilLayout.Rect(), |
|
1744 AknLayoutScalable_Apps::smil2_text_pane( 6 ).LayoutLine() ); |
|
1745 videoLayout.LayoutRect( |
|
1746 smilLayout.Rect(), |
|
1747 AknLayoutScalable_Apps::smil2_video_pane( 2 ).LayoutLine() ); |
|
1748 } |
|
1749 else |
|
1750 { |
|
1751 // Option 6 |
|
1752 rootLayout.LayoutRect( |
|
1753 smilLayout.Rect(), |
|
1754 AknLayoutScalable_Apps::smil2_root_pane( 6 ).LayoutLine() ); |
|
1755 textLayout.LayoutRect( |
|
1756 smilLayout.Rect(), |
|
1757 AknLayoutScalable_Apps::smil2_text_pane( 5 ).LayoutLine() ); |
|
1758 videoLayout.LayoutRect( |
|
1759 smilLayout.Rect(), |
|
1760 AknLayoutScalable_Apps::smil2_video_pane( 0 ).LayoutLine() ); |
|
1761 } |
|
1762 } |
|
1763 } |
|
1764 // cases left: |
|
1765 // - 1) text {+ text} |
|
1766 // - 2) text {+ text} + video |
|
1767 // - 3) text {+ text} + image { + image } |
|
1768 // - 4) image {+ image} + video, no text |
|
1769 // - 5) image {+ image} |
|
1770 // - 6) video |
|
1771 // - no visual media content |
|
1772 else if ( hasVideo ) |
|
1773 { |
|
1774 // 2) 'text {+ text} + video', 4) 'image {+ image} + video, no text' or 6) 'video' |
|
1775 if ( isLandscape ) |
|
1776 { |
|
1777 rootLayout.LayoutRect( |
|
1778 smilLayout.Rect(), |
|
1779 AknLayoutScalable_Apps::smil2_root_pane( 11 ).LayoutLine() ); |
|
1780 videoLayout.LayoutRect( |
|
1781 smilLayout.Rect(), |
|
1782 AknLayoutScalable_Apps::smil2_video_pane( 5 ).LayoutLine() ); |
|
1783 } |
|
1784 else |
|
1785 { |
|
1786 // Option 7 |
|
1787 rootLayout.LayoutRect( |
|
1788 smilLayout.Rect(), |
|
1789 AknLayoutScalable_Apps::smil2_root_pane( 7 ).LayoutLine() ); |
|
1790 videoLayout.LayoutRect( |
|
1791 smilLayout.Rect(), |
|
1792 AknLayoutScalable_Apps::smil2_video_pane( 1 ).LayoutLine() ); |
|
1793 } |
|
1794 |
|
1795 if ( hasTextOneAndOnly ) // + text |
|
1796 { |
|
1797 // Option 0 |
|
1798 rootLayout.LayoutRect( |
|
1799 smilLayout.Rect(), |
|
1800 AknLayoutScalable_Apps::smil2_root_pane( 0 ).LayoutLine() ); |
|
1801 textLayout.LayoutRect( |
|
1802 smilLayout.Rect(), |
|
1803 AknLayoutScalable_Apps::smil2_text_pane( 0 ).LayoutLine() ); |
|
1804 } |
|
1805 |
|
1806 } |
|
1807 else if ( hasTextOneAndOnly |
|
1808 || hasImageOneAndOnly ) |
|
1809 { |
|
1810 // 1) text {+ text}, 3) text {+ text} + image { + image ), 5) image {+ image} |
|
1811 if ( hasTextOneAndOnly ) // text |
|
1812 { |
|
1813 // Option 0 |
|
1814 rootLayout.LayoutRect( |
|
1815 smilLayout.Rect(), |
|
1816 AknLayoutScalable_Apps::smil2_root_pane( 0 ).LayoutLine() ); |
|
1817 textLayout.LayoutRect( |
|
1818 smilLayout.Rect(), |
|
1819 AknLayoutScalable_Apps::smil2_text_pane( 0 ).LayoutLine() ); |
|
1820 } |
|
1821 |
|
1822 // no else - rootLayouts are same |
|
1823 if ( hasImageOneAndOnly ) // image |
|
1824 { |
|
1825 // Option 5 |
|
1826 rootLayout.LayoutRect( |
|
1827 smilLayout.Rect(), |
|
1828 AknLayoutScalable_Apps::smil2_root_pane( 5 ).LayoutLine() ); |
|
1829 imageLayout.LayoutRect( |
|
1830 smilLayout.Rect(), |
|
1831 AknLayoutScalable_Apps::smil2_image_pane( 4 ).LayoutLine() ); |
|
1832 } |
|
1833 } |
|
1834 else // empty |
|
1835 { |
|
1836 rootLayout.LayoutRect( |
|
1837 smilLayout.Rect(), |
|
1838 AknLayoutScalable_Apps::smil2_root_pane( 0 ).LayoutLine() ); |
|
1839 textLayout.LayoutRect( |
|
1840 smilLayout.Rect(), |
|
1841 AknLayoutScalable_Apps::smil2_text_pane( 0 ).LayoutLine() ); |
|
1842 } |
|
1843 |
|
1844 iSmilParams->iComposeParams->iDisplayHeight = rootLayout.Rect().Height(); |
|
1845 iSmilParams->iComposeParams->iDisplayWidth = rootLayout.Rect().Width(); |
|
1846 |
|
1847 // it does not matter anymore whether object is alone on the slide. |
|
1848 // Use one variable only in the if() statements |
|
1849 if ( hasImage || hasImageOneAndOnly ) |
|
1850 { |
|
1851 hasImage = 1; |
|
1852 } |
|
1853 if ( hasText || hasTextOneAndOnly ) |
|
1854 { |
|
1855 hasText = 1; |
|
1856 } |
|
1857 |
|
1858 if ( hasText ) |
|
1859 { |
|
1860 iSmilParams->iTextRegionParams->iSize = textLayout.Rect().Size(); |
|
1861 iSmilParams->iTextRegionParams->iTopLeft = |
|
1862 textLayout.Rect().iTl - rootLayout.Rect().iTl; |
|
1863 } |
|
1864 if ( hasImage || hasVideo ) |
|
1865 { |
|
1866 if ( hasVideo ) |
|
1867 { |
|
1868 iSmilParams->iImageRegionParams->iSize = videoLayout.Rect().Size(); |
|
1869 iSmilParams->iImageRegionParams->iTopLeft = |
|
1870 videoLayout.Rect().iTl - rootLayout.Rect().iTl; |
|
1871 } |
|
1872 else |
|
1873 { |
|
1874 iSmilParams->iImageRegionParams->iSize = imageLayout.Rect().Size(); |
|
1875 iSmilParams->iImageRegionParams->iTopLeft = |
|
1876 imageLayout.Rect().iTl - rootLayout.Rect().iTl; |
|
1877 } |
|
1878 } |
|
1879 |
|
1880 */ |
|
1881 |
|
1882 // Set Region IDs to defaults |
|
1883 if ( !iImageRegionId.Length() ) |
|
1884 { |
|
1885 iImageRegionId.Set( KSMILWRRegIDImage ); |
|
1886 } |
|
1887 if ( !iTextRegionId.Length() ) |
|
1888 { |
|
1889 iTextRegionId.Set( KSMILWRRegIDText ); |
|
1890 } |
|
1891 |
|
1892 // Create root layout |
|
1893 name.Set( KSMILWREleRoot_layout ); |
|
1894 TBool rlPop = EFalse; |
|
1895 if ( !aRootLayout ) |
|
1896 { |
|
1897 aRootLayout = CMDXMLElement::NewLC( EFalse, aDom, name ); |
|
1898 rlPop = ETrue; |
|
1899 } |
|
1900 // Set root layout parameters (attributes) |
|
1901 TBuf16<20> val; |
|
1902 val.Zero(); |
|
1903 val.Format( KSmilIntFormat, iSmilParams->iComposeParams->iDisplayWidth ); |
|
1904 aRootLayout->SetAttributeL( KSMILWRParaWidth,val ); |
|
1905 val.Zero(); |
|
1906 val.Format( KSmilIntFormat, iSmilParams->iComposeParams->iDisplayHeight ); |
|
1907 aRootLayout->SetAttributeL( KSMILWRParaHeight, val ); |
|
1908 if ( rlPop ) |
|
1909 { |
|
1910 // Append root layout in Layout |
|
1911 aLayout->AppendChild( aRootLayout ); |
|
1912 CleanupStack::Pop( aRootLayout ); |
|
1913 } |
|
1914 |
|
1915 // Create Image region (if needed) |
|
1916 name.Set( KSMILWREleRegion ); |
|
1917 if ( hasImage || hasVideo ) |
|
1918 { |
|
1919 TBool imgPop = EFalse; |
|
1920 if ( !aImageRegion ) |
|
1921 { |
|
1922 aImageRegion = CMDXMLElement::NewLC( EFalse, aDom, name ); |
|
1923 imgPop = ETrue; |
|
1924 } |
|
1925 // Set Image region attributes |
|
1926 aImageRegion->SetAttributeL( KSMILWRParaId, iImageRegionId ); |
|
1927 val.Zero(); |
|
1928 val.Format( KSmilIntFormat, iSmilParams->iImageRegionParams->Width() ); |
|
1929 aImageRegion->SetAttributeL( KSMILWRParaWidth, val ); |
|
1930 val.Zero(); |
|
1931 val.Format( KSmilIntFormat, iSmilParams->iImageRegionParams->Height() ); |
|
1932 aImageRegion->SetAttributeL( KSMILWRParaHeight, val ); |
|
1933 val.Zero(); |
|
1934 val.Format( KSmilIntFormat, iSmilParams->iImageRegionParams->Top() ); |
|
1935 aImageRegion->SetAttributeL( KSMILWRParaTop, val ); |
|
1936 val.Zero(); |
|
1937 val.Format( KSmilIntFormat, iSmilParams->iImageRegionParams->Left() ); |
|
1938 aImageRegion->SetAttributeL( KSMILWRParaLeft, val ); |
|
1939 aImageRegion->SetAttributeL( KSMILWRParaFit, iSmilParams->iImageRegionParams->iFit->Des() ); |
|
1940 if ( imgPop ) |
|
1941 { |
|
1942 // Append region in Layout |
|
1943 aLayout->AppendChild( aImageRegion ); // Ownership to dom |
|
1944 CleanupStack::Pop( aImageRegion ); |
|
1945 } |
|
1946 } |
|
1947 |
|
1948 // Create Text region (if needed) |
|
1949 if ( hasText ) |
|
1950 { |
|
1951 TBool txtPop = EFalse; |
|
1952 if ( !aTextRegion ) |
|
1953 { |
|
1954 aTextRegion = CMDXMLElement::NewLC( EFalse, aDom, name ); |
|
1955 txtPop = ETrue; |
|
1956 } |
|
1957 // Set Text region attributes |
|
1958 aTextRegion->SetAttributeL( KSMILWRParaId, iTextRegionId ); |
|
1959 val.Zero(); |
|
1960 val.Format( KSmilIntFormat, iSmilParams->iTextRegionParams->Width() ); |
|
1961 aTextRegion->SetAttributeL( KSMILWRParaWidth, val ); |
|
1962 val.Zero(); |
|
1963 val.Format( KSmilIntFormat, iSmilParams->iTextRegionParams->Height() ); |
|
1964 aTextRegion->SetAttributeL( KSMILWRParaHeight, val ); |
|
1965 val.Zero(); |
|
1966 val.Format( KSmilIntFormat, iSmilParams->iTextRegionParams->Top() ); |
|
1967 aTextRegion->SetAttributeL( KSMILWRParaTop, val ); |
|
1968 val.Zero(); |
|
1969 val.Format( KSmilIntFormat, iSmilParams->iTextRegionParams->Left() ); |
|
1970 aTextRegion->SetAttributeL( KSMILWRParaLeft, val ); |
|
1971 aTextRegion->SetAttributeL( KSMILWRParaFit, iSmilParams->iTextRegionParams->iFit->Des() ); |
|
1972 if ( txtPop ) |
|
1973 { |
|
1974 // Append region in Layout |
|
1975 aLayout->AppendChild( aTextRegion ); // Ownership to dom |
|
1976 CleanupStack::Pop( aTextRegion ); |
|
1977 } |
|
1978 } |
|
1979 } |
|
1980 |
|
1981 // --------------------------------------------------------- |
|
1982 // CUniSmilModel::CreateBodyL |
|
1983 // |
|
1984 // --------------------------------------------------------- |
|
1985 void CUniSmilModel::CreateBodyL( CMDXMLDocument* aDom, CMDXMLElement* aRoot ) |
|
1986 { |
|
1987 TPtrC name( KSMILWREleBody ); |
|
1988 // Create Body node |
|
1989 CMDXMLElement* body = CMDXMLElement::NewLC( ETrue, aDom, name ); |
|
1990 // Append |
|
1991 aRoot->AppendChild( body ); |
|
1992 CleanupStack::Pop( body ); |
|
1993 |
|
1994 // For each slide |
|
1995 for( TInt slide = 0; slide < iSlideArray->Count(); ++slide ) |
|
1996 { |
|
1997 // Create par |
|
1998 CreateParL( aDom, body, slide ); |
|
1999 } |
|
2000 |
|
2001 } |
|
2002 |
|
2003 // --------------------------------------------------------- |
|
2004 // CUniSmilModel::CreateParL |
|
2005 // |
|
2006 // --------------------------------------------------------- |
|
2007 void CUniSmilModel::CreateParL( CMDXMLDocument* aDom, CMDXMLElement* aRoot, TInt aSlide ) |
|
2008 { |
|
2009 TPtrC name( KSMILWRElePar ); |
|
2010 // Create par node |
|
2011 CMDXMLElement* ele = CMDXMLElement::NewLC( ETrue, aDom, name ); |
|
2012 // Append |
|
2013 |
|
2014 // Get default page duration. |
|
2015 TInt slideDur = iSmilParams->iComposeParams->iSlideDuration; |
|
2016 TInt objDur = 0; |
|
2017 TBool unresolvedDur = EFalse; |
|
2018 |
|
2019 CUniSmilSlide* s = iSlideArray->At( aSlide ); |
|
2020 |
|
2021 // For each object in slide |
|
2022 for ( TInt i = s->ObjectCount(); --i >= 0; ) |
|
2023 { |
|
2024 // Create Item |
|
2025 CUniObject* obj = s->GetObjectByIndex( i ); |
|
2026 objDur = CreateItemL( aDom, ele, obj ); |
|
2027 if ( !obj->MediaInfo()->Parsed() && |
|
2028 ( obj->MediaType() == EMsgMediaAudio || |
|
2029 obj->MediaType() == EMsgMediaVideo ) ) |
|
2030 { |
|
2031 unresolvedDur = ETrue; |
|
2032 } |
|
2033 else |
|
2034 { |
|
2035 slideDur = Max( slideDur, objDur ); |
|
2036 } |
|
2037 } |
|
2038 |
|
2039 if ( !unresolvedDur ) |
|
2040 { |
|
2041 TBuf16<20> val; |
|
2042 val.Zero(); |
|
2043 val.Format( KSmilMsecFormat, slideDur ); |
|
2044 |
|
2045 // Set par attributes |
|
2046 ele->SetAttributeL( KSMILWRParaDur, val ); |
|
2047 } |
|
2048 aRoot->AppendChild( ele ); // Ownership to dom |
|
2049 CleanupStack::Pop( ele ); |
|
2050 } |
|
2051 |
|
2052 // --------------------------------------------------------- |
|
2053 // CUniSmilModel::CreateItemL |
|
2054 // |
|
2055 // --------------------------------------------------------- |
|
2056 TInt CUniSmilModel::CreateItemL( CMDXMLDocument* aDom, CMDXMLElement* aRoot, CUniObject* aObj ) |
|
2057 { |
|
2058 CMDXMLElement* ele = NULL; |
|
2059 TPtrC name( KNullDesC ); |
|
2060 |
|
2061 // Create mediaobject node |
|
2062 switch ( aObj->Region() ) |
|
2063 { |
|
2064 case EUniRegionImage: |
|
2065 { |
|
2066 if ( aObj->MediaType() == EMsgMediaVideo ) |
|
2067 { |
|
2068 name.Set( KSMILWREleVideo ); |
|
2069 ele = CMDXMLElement::NewLC( EFalse, aDom, name ); |
|
2070 ele->SetAttributeL( KSMILWRParaRegion, KSMILWRRegIDImage ); |
|
2071 } |
|
2072 else |
|
2073 { |
|
2074 // Considered an image - includes also SVG |
|
2075 name.Set( KSMILWREleImg ); |
|
2076 ele = CMDXMLElement::NewLC( EFalse, aDom, name ); |
|
2077 ele->SetAttributeL( KSMILWRParaRegion, KSMILWRRegIDImage ); |
|
2078 } |
|
2079 } |
|
2080 break; |
|
2081 case EUniRegionText: |
|
2082 { |
|
2083 name.Set( KSMILWREleText ); |
|
2084 ele = CMDXMLElement::NewLC( EFalse, aDom, name ); |
|
2085 ele->SetAttributeL( KSMILWRParaRegion, KSMILWRRegIDText ); |
|
2086 } |
|
2087 break; |
|
2088 case EUniRegionAudio: |
|
2089 { |
|
2090 name.Set( KSMILWREleAudio ); |
|
2091 ele = CMDXMLElement::NewLC( EFalse, aDom, name ); |
|
2092 } |
|
2093 break; |
|
2094 default: |
|
2095 { |
|
2096 User::Leave( KErrNotSupported ); |
|
2097 } |
|
2098 } |
|
2099 |
|
2100 // Set MediaObject node attributes |
|
2101 ele->SetAttributeL( KSMILWRParaSrc, aObj->MimeInfo()->ContentLocation() ); |
|
2102 |
|
2103 // Append |
|
2104 aRoot->AppendChild( ele ); // Ownership to dom |
|
2105 CleanupStack::Pop( ele ); |
|
2106 |
|
2107 return aObj->MediaInfo()->Duration(); |
|
2108 } |
|
2109 |
|
2110 // --------------------------------------------------------- |
|
2111 // CUniSmilModel::GetMediaElemRegionIDs |
|
2112 // |
|
2113 // --------------------------------------------------------- |
|
2114 void CUniSmilModel::GetMediaElemRegionIDs( CMDXMLNode* aPage ) |
|
2115 { |
|
2116 CMDXMLNode* txtEle = NULL; |
|
2117 CMDXMLNode* imgEle = NULL; |
|
2118 CMDXMLNode* obj = aPage->FirstChild(); |
|
2119 |
|
2120 // Traverse through every object in page. |
|
2121 while ( obj ) |
|
2122 { |
|
2123 if( UniSmilUtils::IsMediaElem( obj ) ) |
|
2124 { |
|
2125 TMsgMediaType type = UniSmilUtils::MediaElemType( obj ); |
|
2126 switch ( type ) |
|
2127 { |
|
2128 case EMsgMediaImage: |
|
2129 case EMsgMediaVideo: |
|
2130 imgEle = obj; |
|
2131 break; |
|
2132 |
|
2133 case EMsgMediaText: |
|
2134 case EMsgMediaXhtml: |
|
2135 txtEle = obj; |
|
2136 break; |
|
2137 |
|
2138 // TODO: REF |
|
2139 default: |
|
2140 break; |
|
2141 } |
|
2142 } |
|
2143 obj = obj->NextSibling(); |
|
2144 } |
|
2145 |
|
2146 // Resolve ID:s |
|
2147 if ( !iTextRegionId.Length() && txtEle ) |
|
2148 { |
|
2149 UniSmilUtils::GetRegionId( txtEle, iTextRegionId ); |
|
2150 } |
|
2151 if ( !iImageRegionId.Length() && imgEle ) |
|
2152 { |
|
2153 UniSmilUtils::GetRegionId( imgEle, iImageRegionId ); |
|
2154 } |
|
2155 } |
|
2156 |
|
2157 // --------------------------------------------------------- |
|
2158 // CUniSmilModel::GetLayoutElements |
|
2159 // |
|
2160 // --------------------------------------------------------- |
|
2161 void CUniSmilModel::GetLayoutElements( CMDXMLNode* aLayout, |
|
2162 CMDXMLElement*& aRlEle, |
|
2163 CMDXMLElement*& aTxtEle, |
|
2164 CMDXMLElement*& aImgEle ) |
|
2165 { |
|
2166 if ( !aLayout ) |
|
2167 { |
|
2168 return; |
|
2169 } |
|
2170 |
|
2171 TPtrC value( KNullDesC ); |
|
2172 CMDXMLNode* node = aLayout->FirstChild(); |
|
2173 |
|
2174 // Search REGIONS & RootLayout |
|
2175 while ( node ) |
|
2176 { |
|
2177 // REGION PARAMETERS |
|
2178 if ( node->NodeName().CompareF( KSMILWREleRegion ) == 0 ) |
|
2179 { |
|
2180 |
|
2181 //UniSmilUtils::GetRegionId( node, value ); |
|
2182 if( ((CMDXMLElement*) node)->IsAttributeSpecified( KSMILWRParaId ) ) |
|
2183 { |
|
2184 ((CMDXMLElement*) node)->GetAttribute( KSMILWRParaId, value ); |
|
2185 } |
|
2186 else |
|
2187 { |
|
2188 value.Set( KNullDesC ); |
|
2189 } |
|
2190 |
|
2191 // IMAGE REGION |
|
2192 if ( value.CompareF( iImageRegionId ) == 0 ) |
|
2193 { |
|
2194 aImgEle = (CMDXMLElement*) node; |
|
2195 } |
|
2196 |
|
2197 // TEXT REGION |
|
2198 else if ( value.CompareF( iTextRegionId ) == 0 ) |
|
2199 { |
|
2200 aTxtEle = (CMDXMLElement*) node; |
|
2201 } |
|
2202 |
|
2203 } |
|
2204 else if ( node->NodeName().CompareF( KSMILWREleRoot_layout ) == 0 ) |
|
2205 { |
|
2206 aRlEle = (CMDXMLElement*) node; |
|
2207 } |
|
2208 |
|
2209 node = node->NextSibling(); |
|
2210 |
|
2211 } |
|
2212 } |
|
2213 |
|
2214 // --------------------------------------------------------- |
|
2215 // CUniSmilModel::GetMmsSmilLayout |
|
2216 // |
|
2217 // --------------------------------------------------------- |
|
2218 TUniLayout CUniSmilModel::GetMmsSmilLayout( CMDXMLDocument* aDom ) |
|
2219 { |
|
2220 TUniLayout rval = EUniUndefinedLayout; |
|
2221 |
|
2222 iTextRegionId.Set( KNullDesC ); |
|
2223 iImageRegionId.Set( KNullDesC ); |
|
2224 |
|
2225 // -------------------------------------------- |
|
2226 // Resolve region IDs used in media elements |
|
2227 // -------------------------------------------- |
|
2228 CMDXMLNode* node = GetNode( aDom, KSMILWREleBody ); |
|
2229 if ( !node ) |
|
2230 { |
|
2231 return rval; |
|
2232 } |
|
2233 |
|
2234 // Only one slide in the message since no <par> tag found |
|
2235 // Other node types than <par> not possible as this is MMS SMIL. |
|
2236 if ( node->FirstChild() ) |
|
2237 { |
|
2238 if ( node->FirstChild()->NodeName().CompareF( KSMILWRElePar ) != 0 ) |
|
2239 { |
|
2240 GetMediaElemRegionIDs( node ); |
|
2241 } |
|
2242 else |
|
2243 { |
|
2244 CMDXMLNode* page = node->FirstChild(); |
|
2245 while ( page ) |
|
2246 { |
|
2247 GetMediaElemRegionIDs( page ); |
|
2248 |
|
2249 // Go to next page. |
|
2250 page = page->NextSibling(); |
|
2251 } |
|
2252 } |
|
2253 } |
|
2254 |
|
2255 // ------------------------------------- |
|
2256 // Search layout elements |
|
2257 // ------------------------------------- |
|
2258 node = GetNode( aDom, KSMILWREleLayout ); |
|
2259 CMDXMLElement* rootLayout = NULL; |
|
2260 CMDXMLElement* textRegion = NULL; |
|
2261 CMDXMLElement* imageRegion = NULL; |
|
2262 GetLayoutElements( node, rootLayout, textRegion, imageRegion ); |
|
2263 |
|
2264 // ------------------------------ |
|
2265 // Resolve Root Layout |
|
2266 // ------------------------------ |
|
2267 TSize rootSize( 0, 0 ); |
|
2268 GetRootLayoutSize( rootLayout, rootSize ); |
|
2269 |
|
2270 // ------------------------------------ |
|
2271 // Resolve region parameters |
|
2272 // ------------------------------------ |
|
2273 TRect imgRect( 0, 0, 0, 0 ); |
|
2274 TRect txtRect( 0, 0, 0, 0 ); |
|
2275 GetRegionRect( imageRegion, rootSize, imgRect ); |
|
2276 GetRegionRect( textRegion, rootSize, txtRect ); |
|
2277 |
|
2278 // ------------------------------------ |
|
2279 // Layout decision |
|
2280 // ------------------------------------ |
|
2281 if ( textRegion && imageRegion ) |
|
2282 { |
|
2283 if( imgRect.iTl.iY < txtRect.iTl.iY ) |
|
2284 { |
|
2285 rval = EUniImageFirst; |
|
2286 } |
|
2287 else if ( imgRect.iTl.iY > txtRect.iTl.iY ) |
|
2288 { |
|
2289 rval = EUniTextFirst; |
|
2290 } |
|
2291 else |
|
2292 { |
|
2293 if ( imgRect.iTl.iX <= txtRect.iTl.iX ) |
|
2294 { |
|
2295 rval = EUniImageFirst; |
|
2296 } |
|
2297 else |
|
2298 { |
|
2299 rval = EUniTextFirst; |
|
2300 } |
|
2301 } |
|
2302 } |
|
2303 else if ( textRegion ) |
|
2304 { |
|
2305 rval = EUniTextFirst; |
|
2306 } |
|
2307 else // if ( iImgEle ) or none |
|
2308 { |
|
2309 rval = EUniImageFirst; |
|
2310 } |
|
2311 |
|
2312 return rval; |
|
2313 |
|
2314 } |
|
2315 |
|
2316 // --------------------------------------------------------- |
|
2317 // CUniSmilModel::GetRootLayoutSize |
|
2318 // |
|
2319 // --------------------------------------------------------- |
|
2320 |
|
2321 void CUniSmilModel::GetRootLayoutSize( CMDXMLElement* aRl, TSize& aSize ) |
|
2322 { |
|
2323 TPtrC value( KNullDesC ); |
|
2324 |
|
2325 if ( aRl ) |
|
2326 { |
|
2327 if( aRl->IsAttributeSpecified( KSMILWRParaWidth ) ) |
|
2328 { |
|
2329 aRl->GetAttribute( KSMILWRParaWidth, value ); |
|
2330 aSize.iWidth = UniSmilUtils::StringToIntValue( value, 0 ); |
|
2331 } |
|
2332 else |
|
2333 { |
|
2334 aSize.iWidth = iScreenSize.iWidth; |
|
2335 } |
|
2336 |
|
2337 if( aRl->IsAttributeSpecified( KSMILWRParaHeight ) ) |
|
2338 { |
|
2339 aRl->GetAttribute( KSMILWRParaHeight, value ); |
|
2340 aSize.iHeight = UniSmilUtils::StringToIntValue( value, 0 ); |
|
2341 } |
|
2342 else |
|
2343 { |
|
2344 aSize.iHeight = iScreenSize.iHeight; |
|
2345 } |
|
2346 } |
|
2347 else |
|
2348 { |
|
2349 aSize = iScreenSize; |
|
2350 } |
|
2351 } |
|
2352 |
|
2353 // --------------------------------------------------------- |
|
2354 // CUniSmilModel::GetRegionRect |
|
2355 // |
|
2356 // --------------------------------------------------------- |
|
2357 |
|
2358 void CUniSmilModel::GetRegionRect( CMDXMLElement* aRegion, TSize aRoot, TRect& aRect ) |
|
2359 { |
|
2360 TPtrC value; |
|
2361 |
|
2362 TInt width = 0; |
|
2363 TInt height = 0; |
|
2364 |
|
2365 if ( aRegion ) |
|
2366 { |
|
2367 if( aRegion->IsAttributeSpecified( KSMILWRParaWidth ) ) |
|
2368 { |
|
2369 aRegion->GetAttribute( KSMILWRParaWidth, value ); |
|
2370 width = UniSmilUtils::StringToIntValue( value, 0 ) ; |
|
2371 if ( value.Locate( '%' ) != KErrNotFound ) |
|
2372 { |
|
2373 width = width * aRoot.iWidth / 100; |
|
2374 } |
|
2375 } |
|
2376 |
|
2377 if( aRegion->IsAttributeSpecified( KSMILWRParaHeight ) ) |
|
2378 { |
|
2379 aRegion->GetAttribute( KSMILWRParaHeight, value ); |
|
2380 height = UniSmilUtils::StringToIntValue( value, 0 ) ; |
|
2381 if ( value.Locate( '%' ) != KErrNotFound ) |
|
2382 { |
|
2383 height = height * aRoot.iHeight / 100; |
|
2384 } |
|
2385 } |
|
2386 |
|
2387 if( aRegion->IsAttributeSpecified( KSMILWRParaTop ) ) |
|
2388 { |
|
2389 aRegion->GetAttribute( KSMILWRParaTop, value ); |
|
2390 aRect.iTl.iY = UniSmilUtils::StringToIntValue( value, 0 ); |
|
2391 if ( value.Locate( '%' ) != KErrNotFound ) |
|
2392 { |
|
2393 aRect.iTl.iY = aRect.iTl.iY * aRoot.iHeight / 100; |
|
2394 } |
|
2395 } |
|
2396 else |
|
2397 { |
|
2398 aRect.iTl.iY = 0; |
|
2399 } |
|
2400 |
|
2401 if( aRegion->IsAttributeSpecified( KSMILWRParaLeft ) ) |
|
2402 { |
|
2403 aRegion->GetAttribute( KSMILWRParaLeft, value ); |
|
2404 aRect.iTl.iX = UniSmilUtils::StringToIntValue( value, 0 ); |
|
2405 if ( value.Locate( '%' ) != KErrNotFound ) |
|
2406 { |
|
2407 aRect.iTl.iX = aRect.iTl.iX * aRoot.iWidth / 100; |
|
2408 } |
|
2409 } |
|
2410 else |
|
2411 { |
|
2412 aRect.iTl.iX = 0; |
|
2413 } |
|
2414 |
|
2415 aRect.iBr.iY = aRect.iTl.iY + height; |
|
2416 aRect.iBr.iX = aRect.iTl.iX + width; |
|
2417 |
|
2418 } |
|
2419 else |
|
2420 { |
|
2421 aRect = TRect( 0, 0, 0, 0 ); |
|
2422 } |
|
2423 } |
|
2424 |
|
2425 // --------------------------------------------------------- |
|
2426 // CUniSmilModel::GetRegionType |
|
2427 // --------------------------------------------------------- |
|
2428 // |
|
2429 TUniRegion CUniSmilModel::GetRegionType( CMDXMLNode* aNodePtr ) |
|
2430 { |
|
2431 if ( iImageRegionId.CompareF( iTextRegionId ) == 0 ) |
|
2432 { |
|
2433 // Image and text regions are the same! |
|
2434 // Literally taken this is agains MMS SMIL, but |
|
2435 // we should still tolerate it. |
|
2436 iParseResult |= ETextAndImageRegionsSame; |
|
2437 return EUniRegionUnresolved; |
|
2438 } |
|
2439 TPtrC regId; |
|
2440 TInt err = UniSmilUtils::GetRegionId( aNodePtr, regId ); |
|
2441 if ( !err ) |
|
2442 { |
|
2443 if ( regId.CompareF( iImageRegionId ) == 0 ) |
|
2444 { |
|
2445 return EUniRegionImage; |
|
2446 } |
|
2447 else if ( regId.CompareF( iTextRegionId ) == 0 ) |
|
2448 { |
|
2449 return EUniRegionText; |
|
2450 } |
|
2451 else |
|
2452 { |
|
2453 return EUniRegionUnresolved; |
|
2454 } |
|
2455 } |
|
2456 else |
|
2457 { |
|
2458 return EUniRegionUnresolved; |
|
2459 } |
|
2460 } |
|
2461 |
|
2462 |
|
2463 // --------------------------------------------------------- |
|
2464 // CUniSmilModel::GetNode |
|
2465 // |
|
2466 // --------------------------------------------------------- |
|
2467 CMDXMLNode* CUniSmilModel::GetNode( CMDXMLDocument* aDom, const TDesC& aName ) |
|
2468 { |
|
2469 CMDXMLNode* node = aDom->DocumentElement()->FirstChild(); |
|
2470 while ( node ) |
|
2471 { |
|
2472 if ( node->NodeName().CompareF( aName ) == 0 ) |
|
2473 { |
|
2474 break; |
|
2475 } |
|
2476 else |
|
2477 { |
|
2478 node = UniSmilUtils::NextNode( node ); |
|
2479 } |
|
2480 } |
|
2481 return node; |
|
2482 } |
|
2483 |
|
2484 // --------------------------------------------------------- |
|
2485 // CUniSmilModel::RemoveMetaTagsAndComments |
|
2486 // |
|
2487 // --------------------------------------------------------- |
|
2488 void CUniSmilModel::RemoveMetaTagsAndComments( CMDXMLDocument* aDom ) |
|
2489 { |
|
2490 CMDXMLNode* node = aDom->DocumentElement()->FirstChild(); |
|
2491 while ( node ) |
|
2492 { |
|
2493 if ( node->NodeType() == CMDXMLNode::ECommentNode || |
|
2494 node->NodeName().CompareF( KSMILWREleMeta ) == 0 ) |
|
2495 { |
|
2496 CMDXMLNode* removeNode = node; |
|
2497 node = removeNode->ParentNode(); |
|
2498 /*TInt ignore =*/ node->RemoveChild( removeNode ); |
|
2499 delete removeNode; |
|
2500 } |
|
2501 node = UniSmilUtils::NextNode( node ); |
|
2502 } |
|
2503 } |
|
2504 |
|
2505 // --------------------------------------------------------- |
|
2506 // CUniSmilModel::CorrectSlideTimingL |
|
2507 // |
|
2508 // --------------------------------------------------------- |
|
2509 void CUniSmilModel::CorrectSlideTimingL( CMDXMLElement* aPage ) |
|
2510 { |
|
2511 CMDXMLNode* node = aPage->FirstChild(); |
|
2512 |
|
2513 // Traverse through every object in page. |
|
2514 while ( node != NULL ) |
|
2515 { |
|
2516 if ( UniSmilUtils::IsMediaElem( node ) ) |
|
2517 { |
|
2518 CMDXMLElement* nodeElement = static_cast<CMDXMLElement*>( node ); |
|
2519 |
|
2520 CUniObject* obj = iObjectList.GetByNodeL( node ); |
|
2521 |
|
2522 if( !obj || |
|
2523 !obj->MediaInfo() || |
|
2524 obj->MediaInfo()->Duration() != 0 || |
|
2525 TimingSpecified( nodeElement ) ) |
|
2526 { |
|
2527 // Return as non-static media was found from the page. |
|
2528 return; |
|
2529 } |
|
2530 else if ( nodeElement->IsAttributeSpecified( KSMILWRParaBegin ) ) |
|
2531 { |
|
2532 // Remove invalid Begin element since no End or Dur attributes is specified. |
|
2533 nodeElement->RemoveAttribute( KSMILWRParaBegin ); |
|
2534 } |
|
2535 else if ( nodeElement->IsAttributeSpecified( KSMILWRParaEnd ) ) |
|
2536 { |
|
2537 // Remove invalid End element since no Begin or Dur attributes is specified. |
|
2538 nodeElement->RemoveAttribute( KSMILWRParaEnd ); |
|
2539 } |
|
2540 } |
|
2541 |
|
2542 node = node->NextSibling(); |
|
2543 } |
|
2544 |
|
2545 // Read default smil parameters |
|
2546 if ( !iSmilParams ) |
|
2547 { |
|
2548 iSmilParams = CUniSmilParams::NewL( iFs ); |
|
2549 } |
|
2550 |
|
2551 TBuf16<20> defaultVal; |
|
2552 defaultVal.Zero(); |
|
2553 defaultVal.Format( KSmilMsecFormat, iSmilParams->iComposeParams->iSlideDuration ); |
|
2554 |
|
2555 aPage->SetAttributeL( KSMILWRParaDur, defaultVal ); |
|
2556 } |
|
2557 |
|
2558 // --------------------------------------------------------- |
|
2559 // CUniSmilModel::TimingSpecified |
|
2560 // |
|
2561 // --------------------------------------------------------- |
|
2562 TBool CUniSmilModel::TimingSpecified( CMDXMLElement* aNodePrt ) |
|
2563 { |
|
2564 TBool result( EFalse ); |
|
2565 |
|
2566 // Timing is set if dur or begin & end parameters are found |
|
2567 if ( aNodePrt && |
|
2568 ( aNodePrt->IsAttributeSpecified( KSMILWRParaDur ) || |
|
2569 ( aNodePrt->IsAttributeSpecified( KSMILWRParaBegin ) && |
|
2570 aNodePrt->IsAttributeSpecified( KSMILWRParaEnd ) ) ) ) |
|
2571 { |
|
2572 result = ETrue; |
|
2573 } |
|
2574 |
|
2575 return result; |
|
2576 } |
|
2577 |
|
2578 // End of file |