OpBrowserPreview Class Reference

Performs an operation to preview the animation in a browser. More...

#include <frameops.h>

Inheritance diagram for OpBrowserPreview:

OpSaveAnimatedGIF OpGrabAllFrames OpGrabFrame Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Static Public Member Functions

static BOOL RemoveTempFile ()
 For finding the OpBrowserPreview's state. For cleaning up any temp file useage that we may have made. This should be called in the DeInit during program shut down.

Protected Member Functions

virtual BOOL GetFileNameFromUser ()
 Gives the operation chance to get the filename from the user. In this version we need to override the OpSaveAnimation's version so that we do nothing.
virtual BOOL SaveOrShowTheAnimation (PreviewDialog *pPreviewDialog, BitmapExportParam *pExportParam)
 Tries to actually do the preview operation required. In this case we just save the animation out to a temporary file and then fire up the browser with an html wrapper which references that file.

Private Member Functions

 CC_DECLARE_DYNCREATE (OpBrowserPreview)

Static Private Attributes

static PathName m_TempPath

Detailed Description

Performs an operation to preview the animation in a browser.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/97
See also:
-

Definition at line 680 of file frameops.h.


Member Function Documentation

OpBrowserPreview::CC_DECLARE_DYNCREATE OpBrowserPreview   )  [private]
 

BOOL OpBrowserPreview::GetFileNameFromUser  )  [protected, virtual]
 

Gives the operation chance to get the filename from the user. In this version we need to override the OpSaveAnimation's version so that we do nothing.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/7/97
Returns:
True if worked ok, False otherwise

Reimplemented from OpSaveAnimatedGIF.

Definition at line 4785 of file frameops.cpp.

04786 {
04787     // This version, do nothing
04788     return TRUE;
04789 }

BOOL OpBrowserPreview::RemoveTempFile  )  [static]
 

For finding the OpBrowserPreview's state. For cleaning up any temp file useage that we may have made. This should be called in the DeInit during program shut down.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/7/97
Returns:
True if worked correctly, False otherwise.

Definition at line 5021 of file frameops.cpp.

05022 {
05023     // If we have used the m_TempPath during this session then ensure that we have cleaned up
05024     // any temp files
05025     String_256 Filename;
05026     Filename = m_TempPath.GetPath();
05027     if (!Filename.IsEmpty() && m_TempPath.IsValid())
05028     {   
05029         FileUtil::DeleteFile(&m_TempPath);
05030     }
05031 
05032     return TRUE;
05033 }

BOOL OpBrowserPreview::SaveOrShowTheAnimation PreviewDialog pPreviewDialog,
BitmapExportParam pExportParam
[protected, virtual]
 

Tries to actually do the preview operation required. In this case we just save the animation out to a temporary file and then fire up the browser with an html wrapper which references that file.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/8/97
Parameters:
pPreviewDialog the preview dialog box, if open [INPUTS] pExportParam the export param which we will use
Returns:
True if worked ok, False otherwise
------------------------------------

Reimplemented from OpSaveAnimatedGIF.

Definition at line 4806 of file frameops.cpp.

04807 {
04808     // A bit of checking on parameters
04809     if (pExportParam != NULL)
04810     {
04811         ERROR3IF(!pExportParam->IS_KIND_OF(BitmapExportParam), "OpParam passed is not a BitmapExportParam");
04812 
04813         if (pExportParam->GetBitmapCount() == 0)
04814         {
04815             ERROR2RAW("OpSaveAnimatedGIF::DoWithParam no bitmaps to export");
04816             return FALSE;
04817         }               
04818     }
04819     else
04820     {
04821         ERROR2RAW("OpSaveAnimatedGIF::DoWithParam bad params!");
04822         return FALSE;
04823     }
04824 
04825     // Go and preview it in a browser.
04826     // Get our saving filter
04827     if (m_pBitmapFilter == NULL)
04828         m_pBitmapFilter = new GrabFrameFilter();
04829     if (m_pBitmapFilter == NULL)
04830     {
04831         InformError(_R(IDT_CANT_FIND_FILTER));
04832         return FALSE;
04833     }
04834     
04835     // create a disk file
04836     CCDiskFile TempDiskFile(1024, FALSE, TRUE);
04837 
04838     // Ensure that if we have been using a previous temp file then
04839     // it is cleaned up
04840     RemoveTempFile();
04841 
04842     // Create the required unique temporary of the correct filetype
04843     String_32 ExtStr(_R(IDN_FILTEREXT_GIF));
04844     ExtStr.toLower();
04845     if (!FileUtil::GetTemporaryPathName(ExtStr, &m_TempPath))
04846         return FALSE;
04847 
04848     // Ensure that we have the correct extension on the filename we have allocated
04849     EnsureFileType(&m_TempPath);
04850 
04851     // First off, we have to try and open the file
04852     CCDiskFile DiskFile(1024, FALSE, TRUE);
04853 
04854     BOOL ExportedOk = TRUE;
04855 
04856     try
04857     {
04858         // Export bitmaps supressing the filename so that the user does not see the temp filename
04859         ExportedOk = m_pBitmapFilter->DoExportBitmaps(this, &TempDiskFile, &m_TempPath, &m_ExportParams, TRUE);
04860 
04861         if (!ExportedOk)
04862         {
04863             // Something went a bit wrong - tell the user what it was.
04864             // Supress the error if it was the 'user has cancelled one'
04865             if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED))
04866             {
04867                 InformError();
04868                 m_pBitmapFilter->DeleteExportFile(&DiskFile);
04869             }
04870             else
04871             {
04872                 // otherwise remove the error so it won't get reported
04873                 Error::ClearError();
04874             }
04875         }
04876 
04877         // close the file
04878         if (DiskFile.isOpen())
04879             DiskFile.close();
04880     }
04881 
04882     // See if there was a file io error
04883     catch(CFileException)
04884     {
04885         // Report the error if no one else did
04886         if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED))
04887         {
04888             InformError();
04889         }
04890         else
04891             Error::ClearError();    // otherwise remove the error so it won't get reported
04892 
04893         // Make sure that the file is closed and deleted
04894         try
04895         {
04896             // First try and delete it (tries to close it first)
04897             if (m_pBitmapFilter)
04898                 m_pBitmapFilter->DeleteExportFile(&DiskFile);
04899 
04900             // Double check to make sure it is closed.
04901             if (DiskFile.isOpen())
04902                 DiskFile.close();
04903         }
04904         catch(CFileException)
04905         {
04906             // Failed to close the file - not much we can do about it really
04907         }
04908 
04909         // Fail
04910         ExportedOk = FALSE;
04911     }
04912 
04914     // Now we have the file, we can go and preview it in the browser
04915     
04916     // Allocate our preview class, must keep it around as destruction causes
04917     // it to clean up the temp files, which is bad if this is before it has
04918     // had a chance to fire up the browser!
04919     if (m_pBitmapData == NULL)
04920     {
04921         m_pBitmapData = new BitmapPreviewData;
04922         if (m_pBitmapData == NULL)
04923             return FALSE;
04924     } 
04925     // Now a static pointer as otherwise the temp file is deleted too quickly
04926     
04927     MakeBitmapExportOptions * pBmpOptions = NULL;
04928     // Recover the options from the filter that it saved during the preparation of the bitmaps
04929     // They are helpfully vaped by now! So, we took a copy during GetExportOptions
04930     // But if all the frame are already captured then we will not have any options
04931     pBmpOptions = m_pBitmapFilter->GetCurrentExportOptionsCopy();
04932     BOOL MadeBitmapOptions = FALSE;
04933     if (pBmpOptions == NULL)
04934     {
04935         // Get the filter to set up the bitmap options for us (Use out public version of CreateExportOptions)
04936         pBmpOptions = m_pBitmapFilter->MakeExportOptions();
04937         // Use our public interface onto the GetExportOptions protected function
04938         if (pBmpOptions != NULL)
04939         {
04940             MadeBitmapOptions = TRUE;
04941             m_pBitmapFilter->SetupExportOptions(pBmpOptions, m_pSpread);
04942         }
04943     }
04944     ERROR2IF(pBmpOptions == NULL,FALSE,"OpBrowserPreview::PreviewAnimation No current bitmap options");
04945 
04946     // Get the first bitmap in the list, this will give us the size of the animation
04947     KernelBitmap* pTheBitmap = pExportParam->GetBitmap(0);
04948     // Get the filesize that we have exported
04949     UINT32 FileSize = TempDiskFile.Size();
04950 
04951     // tell the options about the temp file that we are using
04952     pBmpOptions->SetPathName(&m_TempPath);
04953 
04954     // This is our copy of the BitmapExportParam
04955     m_pBitmapData->SetNewBitmap(pTheBitmap, FileSize, pBmpOptions);
04956 
04957     // Set up the options that we require
04958 /*  BrowserBackground Bgr   = BROWSER_BGR_DOC; //BROWSER_BGR_CHECKER;
04959     BOOL ShowInfo           = TRUE;
04960     BOOL GenerateImagemap   = FALSE;
04961 */
04962     // Get the values from our global variables.
04963     BrowserBackground Bgr   = PreviewInBrowserTab::g_Background;
04964     BOOL ShowInfo           = PreviewInBrowserTab::g_InfoInHtmlStub;
04965     BOOL GenerateImagemap   = FALSE;    
04966 
04967     BrowserPreviewOptions PreviewOptions(Bgr, ShowInfo, GenerateImagemap);
04968 
04969     //BrowserPreviewOptions PreviewOptions(PreviewInBrowserTab::GetBrowserOptions());
04970 
04971     // tell it what spread to use when getting the document background
04972     PreviewOptions.SetSpread(m_pSpread);
04973     
04974     // This should actually preview it in the browser
04975     m_pBitmapData->GenerateHTMLStub(PreviewOptions);
04976     
04977 
04978     // Clean out the filter we created
04979     delete m_pBitmapFilter;
04980     m_pBitmapFilter = NULL;
04981     
04982     if (MadeBitmapOptions && pBmpOptions != NULL)
04983         delete pBmpOptions;
04984 
04985     return ExportedOk;
04986 }


Member Data Documentation

PathName OpBrowserPreview::m_TempPath [static, private]
 

end of OpSaveAnimatedGIF

Definition at line 695 of file frameops.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:57:35 2007 for Camelot by  doxygen 1.4.4