mobilemessaging/unieditor/application/src/UniEditorObjectsModelObserver.cpp
changeset 0 72b543305e3a
child 2 0bf1d54f37d9
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006,2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Provides UniEditor Object Model Observer methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // Symbian OS
       
    21 #include <e32std.h>
       
    22 
       
    23 // Symbian OS Messaging
       
    24 #include <msvapi.h>                 // MTM server API
       
    25 
       
    26 // Base editor
       
    27 #include <MsgAttachmentUtils.h>
       
    28 
       
    29 // Uni Engine
       
    30 #include "UniClientMtm.h"              // Client Mtm API
       
    31 
       
    32 // UniModel
       
    33 #include <unismilmodel.h>           // SMIL api
       
    34 #include <uniobject.h>
       
    35 // UniUtils
       
    36 #include <uniobjectsmodel.h>        // Objects view model part
       
    37 #include <uniobjectsinfo.h>         // Objects view attachment info class
       
    38 
       
    39 // Uni Editor
       
    40 #include "UniEditorAppUi.h"         // UniEditorAppUi class
       
    41 #include "UniEditorObjectsModelObserver.h" // CUniEditorObjectsModelObserver
       
    42 #include "UniEditorDocument.h"      // UniEditorDocument class
       
    43 
       
    44 // ----------------------------------------------------
       
    45 // CUniEditorObjectsModelObserver::CUniEditorObjectsModelObserver
       
    46 // ----------------------------------------------------
       
    47 //
       
    48 CUniEditorObjectsModelObserver::CUniEditorObjectsModelObserver( CUniEditorDocument& aDocument,
       
    49                                                                 CUniEditorAppUi& aAppUi ) :
       
    50     iDocument( aDocument ),
       
    51     iAppUi( aAppUi )
       
    52     {
       
    53     }
       
    54 
       
    55 // ----------------------------------------------------
       
    56 // CUniEditorObjectsModelObserver::~CUniEditorObjectsModelObserver
       
    57 // ----------------------------------------------------
       
    58 //
       
    59 CUniEditorObjectsModelObserver::~CUniEditorObjectsModelObserver()
       
    60     {
       
    61     }
       
    62 
       
    63 // ----------------------------------------------------
       
    64 // CUniEditorObjectsModelObserver::NotifyChanges
       
    65 // ----------------------------------------------------
       
    66 //
       
    67 void CUniEditorObjectsModelObserver::NotifyChanges ( TMsgAttachmentCommand /* aCommand */, 
       
    68                                                      CMsgAttachmentInfo* /* aAttachmentInfo*/ )
       
    69     {
       
    70     // this shouldn't be called in unieditor but just in case.
       
    71     }
       
    72 
       
    73 // ----------------------------------------------------
       
    74 // CUniEditorObjectsModelObserver::NotifyChangesL
       
    75 // ----------------------------------------------------
       
    76 //
       
    77 void CUniEditorObjectsModelObserver::NotifyChangesL ( TMsgAttachmentCommand aCommand, 
       
    78                                                       CMsgAttachmentInfo* aAttachmentInfo )
       
    79     {
       
    80     CUniEditorDocument* editorDoc = static_cast<CUniEditorDocument*>( &iDocument );
       
    81     CUniSmilModel& smilModel = editorDoc->DataModel()->SmilModel();
       
    82 
       
    83     CUniObjectsInfo* objInfo = static_cast<CUniObjectsInfo*>( aAttachmentInfo );
       
    84 
       
    85     switch (aCommand)
       
    86         {
       
    87         case EMsgAttachmentRemoved:
       
    88             {
       
    89             CUniObject* obj = static_cast<CUniObject*>( objInfo->Object() );
       
    90             
       
    91             if ( objInfo->AttachmentObject() )
       
    92                 {
       
    93                 editorDoc->DeleteAttachmentL( objInfo->SlideNumber(), obj, ETrue );
       
    94                 editorDoc->SetHeaderModified( ETrue );
       
    95                 }
       
    96             else
       
    97                 {
       
    98                 TUniLayout layout = smilModel.Layout();
       
    99 
       
   100                 // Store the region type
       
   101                 TUniRegion region = obj->Region();
       
   102 
       
   103                 if ( obj &&
       
   104                      obj->MediaType() == EMsgMediaImage )
       
   105                     {
       
   106                     iAppUi.ReleaseImage( ETrue );
       
   107                     }
       
   108                 
       
   109                 editorDoc->DeleteAttachmentL( objInfo->SlideNumber(), obj, EFalse );
       
   110                 
       
   111                 // Only call AppUI to remove object if it is located on the
       
   112                 // current slide.
       
   113                 if ( editorDoc->CurrentSlide() == objInfo->SlideNumber() )
       
   114                     {
       
   115                     iAppUi.RemoveObjectL( region, layout );
       
   116                     }
       
   117                     
       
   118                 editorDoc->SetBodyModified( ETrue );
       
   119                 }
       
   120             }
       
   121             break;
       
   122 
       
   123         default:
       
   124             // Enum out of bounds
       
   125             User::Leave( KErrArgument );
       
   126             break;
       
   127         }
       
   128     }
       
   129 
       
   130 // ----------------------------------------------------
       
   131 // CUniEditorObjectsModelObserver::GetAttachmentFileL
       
   132 // ----------------------------------------------------
       
   133 //
       
   134 RFile CUniEditorObjectsModelObserver::GetAttachmentFileL( TMsvAttachmentId aId )
       
   135     {
       
   136     return iDocument.GetAttachmentFileL( aId );
       
   137     }
       
   138 
       
   139 // ----------------------------------------------------
       
   140 // CUniEditorObjectsModelObserver::NotifyOrderChangeL
       
   141 // ----------------------------------------------------
       
   142 //
       
   143 void CUniEditorObjectsModelObserver::NotifyOrderChangeL ( TUniLayout aLayout )
       
   144     {
       
   145     CUniEditorDocument* editorDoc = static_cast<CUniEditorDocument*>(&iDocument );
       
   146     CUniSmilModel& smilModel = editorDoc->DataModel()->SmilModel();
       
   147 
       
   148     // Item was moved first -> Layout changes
       
   149     iAppUi.ChangeOrderL( aLayout );
       
   150     
       
   151     smilModel.SetLayoutL( aLayout );
       
   152     editorDoc->SetBodyModified( ETrue );
       
   153     }
       
   154     
       
   155 // End of File
       
   156