photosgallery/gallery/src/glxdocument.cpp
branchRCL_3
changeset 60 5b3385a43d68
equal deleted inserted replaced
59:8e5f6eea9c9f 60:5b3385a43d68
       
     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 "glxappui.h"
       
    21 #include "glxdocument.h"
       
    22 #include <glximageviewermanager.h>
       
    23 #include <glxtracer.h>
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // NewL
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 CGlxDocument* CGlxDocument::NewL(CEikApplication& aApp)
       
    30     {
       
    31     TRACER("CGlxDocument::NewL");
       
    32     CGlxDocument* self = NewLC(aApp);
       
    33     CleanupStack::Pop(self);
       
    34     return self;
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // NewLC
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CGlxDocument* CGlxDocument::NewLC(CEikApplication& aApp)
       
    42     {
       
    43     TRACER("CGlxDocument::NewLC");
       
    44     CGlxDocument* self = new (ELeave) CGlxDocument(aApp);
       
    45     CleanupStack::PushL(self);
       
    46     self->ConstructL();
       
    47     return self;
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // ConstructL
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CGlxDocument::ConstructL()
       
    55     {
       
    56     TRACER("CGlxDocument::ConstructL");
       
    57     iViewUtility = MMPXViewUtility::UtilityL();
       
    58     iImageViewerInstance = CGlxImageViewerManager::InstanceL();
       
    59     }    
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // Constructor
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CGlxDocument::CGlxDocument(CEikApplication& aApp) : CAknDocument(aApp) 
       
    66     {
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // Destructor
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 CGlxDocument::~CGlxDocument()
       
    74     {
       
    75     TRACER("CGlxDocument::~CGlxDocument()");
       
    76     if ( iViewUtility )
       
    77         {
       
    78         iViewUtility->Close();
       
    79         }
       
    80     if ( iImageViewerInstance )
       
    81         {
       
    82         iImageViewerInstance->DeleteInstance();
       
    83         }
       
    84 	}
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // OpenFileL()
       
    88 // Open document.
       
    89 // -----------------------------------------------------------------------------
       
    90 CFileStore* CGlxDocument::OpenFileL( TBool /*aDoOpen*/,
       
    91                                     const TDesC& aFilename, RFs& /*aFs*/ )
       
    92     {
       
    93     TRACER("CFileStore* CGlxDocument::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 CGlxDocument::OpenFileL( CFileStore*& /*aFileStore*/, RFile& aFile )
       
   105 	{	
       
   106 	TRACER("CGlxDocument::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( &aFile );
       
   114 	}
       
   115 
       
   116 // ----------------------------------------------------------------------------
       
   117 // CGlxDocument::ResetDocument
       
   118 // Reset the document
       
   119 // ----------------------------------------------------------------------------
       
   120 //
       
   121 void CGlxDocument::ResetDocument()
       
   122     {	
       
   123     TRACER("CGlxDocument::ResetDocument()");
       
   124     // Set document to NULL
       
   125     iImageViewerInstance->Reset();    
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CreateAppUiL
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 CEikAppUi* CGlxDocument::CreateAppUiL()
       
   133     {
       
   134     TRACER("CGlxDocument::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) CGlxAppUi();
       
   138     return appUi;
       
   139     }
       
   140