photosgallery/imgvwr/src/glxivwrdocument.cpp
changeset 1 9ba538e329bd
child 4 57d388cc48c1
equal deleted inserted replaced
0:4e91876724a2 1:9ba538e329bd
       
     1 /*
       
     2  * Copyright (c) 2008-2009 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:    Document class 
       
    15  *
       
    16  */
       
    17 
       
    18 #include <mpxviewutility.h>
       
    19 
       
    20 #include "glxivwrappui.h"
       
    21 #include "glxivwrdocument.h"
       
    22 #include <glximageviewermanager.h>
       
    23 #include <glxtracer.h>
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // NewL
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CGlxIVwrDocument* CGlxIVwrDocument::NewL(CEikApplication& aApp)
       
    30     {
       
    31     TRACER("CGlxIVwrDocument::NewL");
       
    32     CGlxIVwrDocument* self = NewLC(aApp);
       
    33     CleanupStack::Pop(self);
       
    34     return self;
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // NewLC
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CGlxIVwrDocument* CGlxIVwrDocument::NewLC(CEikApplication& aApp)
       
    42     {
       
    43     TRACER("CGlxIVwrDocument::NewLC");
       
    44     CGlxIVwrDocument* self = new (ELeave) CGlxIVwrDocument(aApp);
       
    45     CleanupStack::PushL(self);
       
    46     self->ConstructL();
       
    47     return self;
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // ConstructL
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CGlxIVwrDocument::ConstructL()
       
    55     {
       
    56     TRACER("CGlxIVwrDocument::ConstructL");
       
    57     iViewUtility = MMPXViewUtility::UtilityL();
       
    58     iImageViewerInstance = CGlxImageViewerManager::InstanceL();
       
    59     }    
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // Constructor
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CGlxIVwrDocument::CGlxIVwrDocument(CEikApplication& aApp) : CAknDocument(aApp) 
       
    66             {
       
    67             }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // Destructor
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 CGlxIVwrDocument::~CGlxIVwrDocument()
       
    74     {
       
    75     TRACER("CGlxIVwrDocument::~CGlxDocument()");
       
    76     if (iViewUtility != NULL)
       
    77         {
       
    78         iViewUtility->Close();
       
    79         }
       
    80     if ( NULL != iImageViewerInstance)
       
    81         {
       
    82         iImageViewerInstance->DeleteInstance();
       
    83         }
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // OpenFileL()
       
    88 // Open document.
       
    89 // -----------------------------------------------------------------------------
       
    90 CFileStore* CGlxIVwrDocument::OpenFileL( TBool /*aDoOpen*/,
       
    91         const TDesC& aFilename, RFs& /*aFs*/ )
       
    92     {
       
    93     TRACER("CFileStore* CGlxIVwrDocument::OpenFileL");
       
    94     // Reset old data
       
    95     ResetDocument();
       
    96     iImageViewerInstance->SetImageUriL(aFilename);
       
    97     return NULL;
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CGlxDocument::OpenFileL()
       
   102 // Open document.
       
   103 // -----------------------------------------------------------------------------
       
   104 void CGlxIVwrDocument::OpenFileL( CFileStore*& /*aFileStore*/, RFile& aFile )
       
   105     {	
       
   106     TRACER("CGlxIVwrDocument::OpenFileL()");
       
   107     // Make sure that aFile is closed in leave situation
       
   108     CleanupClosePushL( aFile );
       
   109 
       
   110     // Reset old data
       
   111     ResetDocument();    
       
   112     iImageViewerInstance->SetImageFileHandleL(aFile);	
       
   113     CleanupStack::PopAndDestroy(); // Close aFile
       
   114     }
       
   115 
       
   116 // ----------------------------------------------------------------------------
       
   117 // CGlxDocument::ResetDocument
       
   118 // Reset the document
       
   119 // ----------------------------------------------------------------------------
       
   120 //
       
   121 void CGlxIVwrDocument::ResetDocument()
       
   122     {	
       
   123     TRACER("CGlxIVwrDocument::ResetDocument()");
       
   124     // Set document to NULL
       
   125     iImageViewerInstance->Reset();    
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CreateAppUiL
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 CEikAppUi* CGlxIVwrDocument::CreateAppUiL()
       
   133     {
       
   134     TRACER("CGlxIVwrDocument::CreateAppUiL()");
       
   135     // Create the application user interface, and return a pointer to it,
       
   136     // the framework takes ownership of this object
       
   137     CEikAppUi* appUi = new (ELeave) CGlxIVwrAppUi();
       
   138     return appUi;
       
   139     }
       
   140