photosgallery/gallery/src/glxdocument.cpp
changeset 0 4e91876724a2
child 1 9ba538e329bd
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     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 != NULL)
       
    77         {
       
    78         iViewUtility->Close();
       
    79         }
       
    80     if ( NULL != iImageViewerInstance)
       
    81         {
       
    82         iImageViewerInstance->DeleteInstance();
       
    83         }
       
    84 	}
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CGlxDocument::OpenFileL()
       
    88 // Open document.
       
    89 // -----------------------------------------------------------------------------
       
    90 void CGlxDocument::OpenFileL( CFileStore*& /*aFileStore*/, RFile& aFile )
       
    91 	{	
       
    92 	TRACER("CGlxDocument::OpenFileL()");
       
    93 	// Make sure that aFile is closed in leave situation
       
    94 	CleanupClosePushL( aFile );
       
    95 	
       
    96 	// Reset old data
       
    97 	ResetDocument();    
       
    98 	iImageViewerInstance->SetImageFileHandleL(aFile);	
       
    99 	CleanupStack::PopAndDestroy(); // Close aFile
       
   100 	}
       
   101 
       
   102 // ----------------------------------------------------------------------------
       
   103 // CGlxDocument::ResetDocument
       
   104 // Reset the document
       
   105 // ----------------------------------------------------------------------------
       
   106 //
       
   107 void CGlxDocument::ResetDocument()
       
   108     {	
       
   109     TRACER("CGlxDocument::ResetDocument()");
       
   110     // Set document to NULL
       
   111     iImageViewerInstance->Reset();    
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CreateAppUiL
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 CEikAppUi* CGlxDocument::CreateAppUiL()
       
   119     {
       
   120     TRACER("CGlxDocument::CreateAppUiL()");
       
   121     // Create the application user interface, and return a pointer to it,
       
   122     // the framework takes ownership of this object
       
   123     CEikAppUi* appUi = new (ELeave) CGlxAppUi();
       
   124     return appUi;
       
   125     }
       
   126