cbmpdata.cpp

Go to the documentation of this file.
00001 // $Id: cbmpdata.cpp 1482 2006-07-20 10:23:23Z luke $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // A simple Dialog That does some Gavin Rendering into itself
00099 
00100 
00101 #include "camtypes.h"
00102 #include "bmpexprw.h"
00103 #include "prvwmenu.h" // the context menu for the dialog
00104 //#include "exprwres.h"
00105 #include "giffiltr.h"   // for TI_GIFFilter
00106 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "app.h"      // for Document - in camtypes.h [AUTOMATICALLY REMOVED]
00108 
00109 //#include "webprvw.h"  // the resource strings for the web preview
00110 #include "product.h"    // the product name
00111 #include "backgrnd.h"
00112 #include "bmpexdoc.h"
00113 #include "prvwflt.h"
00114 #include "fileutil.h"
00115 #include "bitmpinf.h"
00116 #include "sgliboil.h"
00117 #include "makebmp.h"
00118 
00119 #include "filtimag.h"   //The imagemap filter class
00120 #include "filtimop.h"   //The ImagemapFilterOptions class
00121 #include "filtrmgr.h"   //The Filter Manager - used to find the imagemap filter
00122 //#include "resimmap.h" //Imagemap resources
00123 #include "menucmds.h"   // InvokeWeblink
00124 
00125 //#include "bmpsdlgr.h" // _R(IDS_JPEG)
00126 
00127 // This is not compulsory, but you may as well put it in so that the correct version
00128 // of your file can be registered in the .exe
00129 DECLARE_SOURCE("$Revision: 1482 $");
00130 
00131 // An implement to match the Declare in the .h file.
00132 // If you have many classes, it is recommended to place them all together, 
00133 // here at the start of the file
00134 CC_IMPLEMENT_MEMDUMP(BrowserPreviewOptions, CCObject)
00135 CC_IMPLEMENT_DYNAMIC(BitmapPreviewData, CCObject)
00136 
00137 // This will get Camelot to display the filename and linenumber of any memory allocations
00138 // that are not released at program exit
00139 #define new CAM_DEBUG_NEW
00140 
00141 // this is a pointer to the path where the bitmap page background was exported 
00142 // to be displayed in the web stub
00143 PathName * BitmapPreviewData::pPagePath = NULL;
00144 
00146 // BrowserPreviewOptions section
00147 
00148 /*******************************************************************************************
00149 >   BrowserPreviewOptions::BrowserPreviewOptions()
00150 
00151   Author:   Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00152   Created:  1/7/97
00153   Purpose:  Default Constructor
00154   
00155 *******************************************************************************************/
00156 
00157 BrowserPreviewOptions::BrowserPreviewOptions()
00158 {   
00159     m_Background    = BROWSER_BGR_NONE; 
00160     m_bInfo         = TRUE; 
00161     m_bImagemap     = TRUE; 
00162     m_pSpread       = NULL;
00163 }
00164 
00165 
00166 /*******************************************************************************************
00167 >   BrowserPreviewOptions::BrowserPreviewOptions(BrowserBackground Bgr, BOOL bInfo, 
00168 BOOL bImagemap, ImagemapFilterOptions ifoToUse)
00169 
00170   Author:   Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00171   Created:  1/7/97
00172   Purpose:  Constructor - set the default values
00173   
00174 *******************************************************************************************/
00175 
00176 BrowserPreviewOptions::BrowserPreviewOptions(BrowserBackground Bgr, BOOL bInfo, BOOL bImagemap
00177                                              , ImagemapFilterOptions ifoOptions)
00178 {   
00179     m_Background    = Bgr; 
00180     m_bInfo         = bInfo; 
00181     m_bImagemap     = bImagemap; 
00182     m_pSpread       = NULL;
00183     m_ifoImagemapOptions = ifoOptions;
00184 }
00185 
00186 
00187 /*******************************************************************************************
00188 >   void BrowserPreviewOptions::Get(BrowserBackground *pBgr, BOOL *pbInfo, BOOL *pbImagemap)
00189 
00190   Author:   Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00191   Created:  1/7/97
00192   Purpose:  Gets the values of the member variables
00193   
00194 *******************************************************************************************/
00195 
00196 void BrowserPreviewOptions::Get(BrowserBackground *pBgr, BOOL *pbInfo, BOOL *pbImagemap,
00197                                 ImagemapFilterOptions* pifoOptions)
00198 {   
00199     *pBgr = m_Background; 
00200     *pbInfo = m_bInfo; 
00201     *pbImagemap = m_bImagemap; 
00202     if (pifoOptions)
00203         *pifoOptions=m_ifoImagemapOptions;
00204 }
00205 
00206 
00207 /*******************************************************************************************
00208 >   void BrowserPreviewOptions::Set(BrowserBackground Bgr, BOOL bInfo, BOOL bImagemap,
00209 ImagemapFilterOPtions ifoToSet)
00210 
00211   Author:   Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00212   Created:  1/7/97
00213   Purpose:  Sets values for the member variables
00214   
00215 *******************************************************************************************/
00216 
00217 void BrowserPreviewOptions::Set(BrowserBackground Bgr, BOOL bInfo, BOOL bImagemap,
00218                                 ImagemapFilterOptions ifoToSet)
00219 {   
00220     m_Background = Bgr; 
00221     m_bInfo = bInfo; 
00222     m_bImagemap = bImagemap; 
00223     m_ifoImagemapOptions=ifoToSet;
00224 }
00225 
00226 /********************************************************************************************
00227 
00228   > BrowserPreviewOptions::BrowserPreviewOptions(const BrowserPreviewOptions& obj)
00229   
00230     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
00231     Created:    29/07/97
00232     Scope:      public
00233     
00234 ********************************************************************************************/
00235 
00236 BrowserPreviewOptions::BrowserPreviewOptions(const BrowserPreviewOptions& obj)
00237 {
00238     m_Background            =   obj.m_Background;
00239     m_bInfo                 =   obj.m_bInfo;
00240     m_bImagemap             =   obj.m_bImagemap;
00241     m_pSpread               =   obj.m_pSpread;
00242     m_ifoImagemapOptions    =   obj.m_ifoImagemapOptions;
00243 }
00244 
00245 
00247 // BitmapPreviewData section
00248 
00249 /*******************************************************************************************
00250 >   BitmapPreviewData::BitmapPreviewData()
00251 
00252   Author:   Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00253   Created:  11/4/97
00254   Purpose:  Constructor
00255   
00256 *******************************************************************************************/
00257 
00258 BitmapPreviewData::BitmapPreviewData()
00259 {
00260     m_pBitmap = NULL;
00261     m_FileSize = 0;
00262     m_pOptions = NULL;
00263     m_pTempHTMLPath = NULL;
00264     
00265     m_bIsSameBitmap = TRUE;
00266 }
00267 
00268 /*******************************************************************************************
00269 >   BitmapPreviewData::~BitmapPreviewData()
00270 
00271   Author:   Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00272   Created:  11/4/97
00273   Purpose:  Destructor
00274   
00275 *******************************************************************************************/
00276 
00277 BitmapPreviewData::~BitmapPreviewData()
00278 {
00279     DeleteBitmapData();
00280 }
00281 
00282 
00283 /*******************************************************************************************
00284 
00285   > void BitmapPreviewData::DeleteBitmapData()
00286   
00287     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00288     Created:    11/4/97
00289     Purpose:    Removes all the data of the object, but only if its not shared with other 
00290                 objects of the same type
00291                 
00292 *******************************************************************************************/
00293 
00294 void BitmapPreviewData::DeleteBitmapData()
00295 {
00296     if (!m_bIsSameBitmap)
00297     {
00298         // delete the bitmap
00299         if (m_pBitmap != NULL)
00300             delete m_pBitmap;
00301         m_pBitmap = NULL;
00302         
00303         // delete the options   
00304         // SMFIX - Please dont delete my options these are only place holders, this class is NOT responsible for these objects
00305         //if (m_pOptions != NULL)
00306         //  delete m_pOptions;
00307         //m_pOptions = NULL;
00308     }
00309     
00310     // delete the html stub file
00311     if (m_pTempHTMLPath != NULL)
00312     {
00313         // delete the temp file 
00314         FileUtil::DeleteFile(m_pTempHTMLPath);
00315         
00316         // delete the path name
00317         delete m_pTempHTMLPath;
00318     }
00319     m_pTempHTMLPath = NULL;
00320 }
00321 
00322 
00323 /*******************************************************************************************
00324 
00325   > static BOOL BitmapPreviewData::ComposeHTMLColour(DocColour *pColour, String_32 &OutColour)
00326   
00327     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00328     Created:    11/4/97
00329     Inputs:     pColour -   pointer to a DocColour
00330     Outputs:    OutColour   - string, where the converted colour is stored.
00331     Purpose:    Converts from a DocColour to a colour string in html format:
00332                 "#rrggbb", where rr - the red component, gg - the green, and rr - the blue.
00333                 All the components specify a hexadecimal value in the 00 - ff range.
00334                 
00335 *******************************************************************************************/
00336 
00337 BOOL BitmapPreviewData::ComposeHTMLColour(DocColour *pColour, String_32 &OutColour)
00338 {
00339     if (pColour == NULL)
00340         return FALSE;
00341     
00342     // get the RGB values from the colour
00343     INT32 R, G, B;
00344     pColour->GetRGBValue(&R, &G, &B);
00345     
00346     // convert this into a html colour string
00347     OutColour = String_32( _T("#") );
00348     String_32 c;
00349     
00350     // add the red component
00351     if (R < 16) // is a leading 0 required
00352         OutColour += _T("0");
00353     c._MakeMsg( _T("#1%X"), R % 256);
00354     OutColour += c;
00355     
00356     // the green component
00357     if (G < 16)
00358         OutColour += _T("0");
00359     c._MakeMsg( _T("#1%X"), G % 256);
00360     OutColour += c;
00361     
00362     // the blue component
00363     if (B < 16)
00364         OutColour += _T("0");
00365     c._MakeMsg( _T("#1%X"), B % 256);
00366     OutColour += c;
00367     
00368     return TRUE;
00369 }
00370 
00371 
00372 
00373 /*******************************************************************************************
00374 
00375   > static BOOL BitmapPreviewData::ExportBrowserTypeBitmap(KernelBitmap *pBmp,PathName *pOutFile)
00376   
00377     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00378     Created:    11/4/97
00379     Inputs:     pKernelBitmap   -   pointer to a Bitmap to be exported
00380                 pOutPath - the path to export the bitmap to
00381                 Purpose:    Exports a kernel bitmap to a gif file, the gif preview filter is used, so 
00382                 that no export options dialog box is displayed.
00383                 
00384 *******************************************************************************************/
00385 
00386 BOOL BitmapPreviewData::ExportBrowserTypeBitmap(KernelBitmap *pBmp,PathName *pOutFile)
00387 {
00388     ERROR3IF(pBmp == NULL, "NULL param passed in ExportPreviewBitmap");
00389     ERROR3IF(pOutFile == NULL, "NULL param passed in ExportPreviewBitmap");
00390     if ((pBmp == NULL) || (pOutFile == NULL))
00391         return FALSE;
00392     
00393     // create a disk file
00394     CCDiskFile TempDiskFile(1024, FALSE, TRUE);
00395     
00396     // Find the gif preview filter for export (so we don't get an options dialog box)
00397     Filter *pFilter = Filter::GetFirst();
00398     while (pFilter != NULL)
00399     {
00400         if (IS_A(pFilter,PreviewFilterGIF))
00401             // This is the filter!
00402             break;
00403         
00404         // Try the next filter
00405         pFilter = Filter::GetNext(pFilter);
00406     }
00407     
00408     if (pFilter == NULL)
00409         return FALSE;  // filter not found
00410     
00411     // get the preview bitmap filter, so no dialog box is displayed
00412     PreviewFilterGIF *pGIFFilter = (PreviewFilterGIF *)pFilter;
00413     
00414     BOOL ok = TRUE;
00415     
00416     // create an operation for the export
00417     SelOperation *pOp = new SelOperation;
00418     if (pOp != NULL)
00419     {
00420         ok = pGIFFilter->DoExportBitmap(pOp, &TempDiskFile, pOutFile, pBmp);
00421         
00422         // delete the created operation
00423         delete pOp;
00424     }
00425     else
00426         return FALSE;
00427     
00428     // close the file 
00429     if (TempDiskFile.isOpen())
00430         TempDiskFile.close();
00431     
00432     return ok;
00433 }
00434 
00435 
00436 
00437 /*******************************************************************************************
00438 
00439   > static BOOL BitmapPreviewData::SetBackgroundFromPage(CCDiskFile &DiskFile, Spread * pSpread = NULL)
00440   
00441     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00442     Created:    11/4/97
00443     Inputs:     DiskFile - the file to write to 
00444                 pSpread  - the spread to pull the page background from
00445                 Purpose:    Gets the current page background from the current document and generates an
00446                 HTML string which displays the same background on the HTML page. If a spread
00447                 has been specified then use that instead of the current document.
00448                 See Also:   BitmapPreviewData::ComposeHTMLColour, BitmapPreviewData::ExportBrowserTypeBitmap
00449                 
00450 *******************************************************************************************/
00451 
00452 BOOL BitmapPreviewData::SetBackgroundFromPage(CCDiskFile &DiskFile, Spread * pSpread)
00453 {
00454     String_256 s; // to contain the generated html strings
00455     
00456     // If the user has not specified a spead then assume the selected spread in the current doc
00457     if (pSpread == NULL)
00458     {
00459         // get the current doc
00460         Document *pDoc = Document::GetCurrent();
00461         ERROR3IF(pDoc == NULL, "No Current Document");
00462         if (pDoc == NULL)
00463             return FALSE;
00464         pSpread = pDoc->GetSelectedSpread();
00465     }
00466     
00467     // get the page colour, or bitmap fill
00468     KernelBitmap *pPageBmp = NULL;
00469     DocColour *pPageColour = NULL;
00470     OpBackground::GetPageColour(pSpread, &pPageBmp, &pPageColour);
00471     
00472     BOOL Ok = TRUE;
00473     // check for a bitmap page background first
00474     if (pPageBmp != NULL) // the page background was a bitmap
00475     {
00476         // check if we haven't exported that bitmap before
00477         if (pPagePath == NULL)
00478         {
00479             // alocate the path name
00480             pPagePath = new PathName;
00481             
00482             if (pPagePath)
00483             {
00484                 // create a new temporary file
00485                 Ok = FileUtil::GetTemporaryPathName( _T("gif"), pPagePath);
00486             }
00487             else
00488                 Ok = FALSE;
00489             
00490         }
00491         
00492         // check if we have a valid path
00493         if (Ok) Ok = pPagePath->IsValid();
00494         
00495         // export the background bitmap into the a file
00496         if (Ok && ExportBrowserTypeBitmap(pPageBmp, pPagePath))
00497         {
00498             // everything went ok, so add the link in the html file
00499             s.MakeMsg(_R(IDS_HTML_BGIMAGE), (const TCHAR *)pPagePath->GetFileName());
00500             DiskFile.write(s);
00501         }
00502         
00503         return Ok;
00504     }
00505     
00506     // If we recovered a page background colour then use that
00507     // otherwise Page is by default white so set this as a background
00508     BOOL AllocatedColour = FALSE;
00509     if (pPageColour == NULL)
00510     {
00511         // Neither colour nor bitmap.
00512         AllocatedColour = TRUE;
00513         pPageColour = new DocColour(COLOUR_WHITE);  // default colour of a page (white)
00514     }
00515     
00516     // convert to a browser colour
00517     String_32 col;
00518     if (ComposeHTMLColour(pPageColour,col))
00519     {
00520         // output the background colour
00521         s.MakeMsg(_R(IDS_HTML_BGCOLOUR), (TCHAR *)col);
00522         DiskFile.write(s);
00523     }
00524     else
00525         Ok = FALSE;
00526     
00527     if (AllocatedColour && pPageColour != NULL)
00528         delete pPageColour;
00529     
00530     return Ok;
00531 }
00532 
00533 
00534 /*******************************************************************************************
00535 
00536   > static BOOL BitmapPreviewData::ExportImagemap(CCDiskFile &DiskFile, PathName *pPath,
00537         ImagemapFilterOptions ifoOptionsToUse)
00538         
00539           Author:   Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00540           Created:  24/6/97
00541           Inputs:   -
00542           Purpose:  Generate a imagemap for our bitmap, and writes it out to our html page
00543           
00544 *******************************************************************************************/
00545 
00546 BOOL BitmapPreviewData::ExportImagemap(CCDiskFile &DiskFile, PathName *pPath, SelectionType Sel, DPI dpi,
00547                                        ImagemapFilterOptions ifoOptionsToUse)
00548 {
00549     // sanity checks
00550     ERROR3IF(pPath == NULL, "BitmapPreviewData::ExportImagemap - no file path to use");
00551     if (dpi <= 0.0)
00552         return FALSE;
00553     
00554     //Rewritten by Graham 23/7/97
00555     
00556     //First find the imagemap filter
00557     ImagemapFilter* pImagemapFilter = (ImagemapFilter*) Filter::FindFilterFromID(FILTERID_IMAGEMAP);
00558     
00559     if (pImagemapFilter == NULL)  // no imagemap filter found
00560         return FALSE;
00561     
00562     //Now, we're going to set some imagemap filter options into the filter
00563     //But before we do so, let's remember the old set of imagemap filter options
00564     //so that the user doesn't get her defaults overridden
00565     ImagemapFilterOptions ifoOld=pImagemapFilter->GetFilterOptions();
00566     
00567     //Now, base our new set of options on the set we have been given
00568     ImagemapFilterOptions ifoToSet=ifoOptionsToUse;
00569     
00570     //But make the following changes
00571     ifoToSet.m_strName="PreviewBitmapImagemap";
00572     ifoToSet.m_stExportArea=Sel;
00573     ifoToSet.m_dDPI=dpi;
00574     ifoToSet.m_fClipboard=FALSE;
00575     ifoToSet.m_fFile=TRUE;
00576     ifoToSet.m_pthFile=*pPath;
00577     ifoToSet.m_fInsert=TRUE;
00578     ifoToSet.m_pfileFile=&DiskFile;
00579     ifoToSet.m_fReportErrors=FALSE;
00580     
00581     //Then set our new options back into the imagemap filter
00582     pImagemapFilter->SetFilterOptions(ifoToSet);
00583     
00584     //And tell the filter to export the file
00585     BOOL ok= pImagemapFilter->PrepareAndWriteData(Document::GetCurrent());
00586     
00587     //Finally, set the previous set of options back into the filter
00588     pImagemapFilter->SetFilterOptions(ifoOld);
00589     
00590     return ok; // return the result of the export
00591 }
00592 
00593 
00594 /*******************************************************************************************
00595 
00596   > BOOL BitmapPreviewData::GenerateHTMLStub(BrowserPreviewOptions BrowserOptions)
00597   
00598     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> 
00599     Created:    24/6/97
00600     Inputs:     BrowserOptions - the options for generating the html page
00601     Purpose:    Generate a html file which includes our bitmap, together with some other optional 
00602                 stuff. Used for browser preview.
00603                 
00604 *******************************************************************************************/
00605 BOOL BitmapPreviewData::GenerateHTMLStub(BrowserPreviewOptions BrowserOptions)
00606 {
00607 PORTNOTE("other","Removed _R(IDD_TIMAPOPTIONS) - isn't wanted yet")
00608 #ifndef EXCLUDE_FROM_XARALX
00609     // sanity checks
00610     
00611     // check for export options
00612     
00613     ERROR3IF(m_pOptions == NULL, "BitmapPreviewData::GenerateHTMLStub - need export options");
00614     if (m_pOptions == NULL) // we need export options
00615         return FALSE;
00616     
00617     // get the path for the exported bitmap from the options
00618     PathName TempPath = m_pOptions->GetPathName();
00619     
00620     // check for exported bitmap
00621     ERROR3IF((m_pOptions->HasTempFile() == FALSE) || (TempPath.IsValid() == FALSE), 
00622         "BitmapPreviewData::GenerateHTMLStub - need exported bitmap");
00623     if ((m_pOptions->HasTempFile() == FALSE) || (TempPath.IsValid() == FALSE)) 
00624         return FALSE;
00625     
00626     // delete the previous temp file, if any
00627     if (m_pTempHTMLPath != NULL)
00628         FileUtil::DeleteFile(m_pTempHTMLPath);
00629     else
00630         m_pTempHTMLPath = new PathName;
00631     
00632     // safety check
00633     if (m_pTempHTMLPath == NULL)
00634         return FALSE;
00635     
00636     // create a new temp file 
00637     if (FileUtil::GetTemporaryPathName( _T("htm"),m_pTempHTMLPath) == FALSE)
00638     {
00639         delete m_pTempHTMLPath;
00640         m_pTempHTMLPath = NULL;
00641         
00642         return FALSE;
00643     }
00644     
00645     // start creating the html page
00646     
00647     // create a disk file
00648     CCDiskFile TempDiskFile(1024, FALSE, TRUE);
00649     
00650     // get path name to server, so we can find the logo bitmaps
00651     CString str;
00652     AfxGetModuleShortFileName(AfxGetInstanceHandle(), str);
00653     String_256 strPathName(str.GetBuffer(0));
00654     
00655     // create a path name object from the program name
00656     PathName ProgramPath(strPathName);
00657     
00658     try
00659     {
00660         // open it for reading
00661         if (!TempDiskFile.open(*m_pTempHTMLPath, ios::out))
00662             return FALSE;
00663         
00664         // output header
00665         String_256 s(_R(IDS_HTML_HEAD));
00666         TempDiskFile.write(s);
00667         
00668         // set the background attributes
00669         switch (BrowserOptions.m_Background)
00670         {
00671         case BROWSER_BGR_DOC:
00672             {
00673                 // set the background from the document page
00674                 if (!SetBackgroundFromPage(TempDiskFile, BrowserOptions.m_pSpread))
00675                     ERROR3("Setting the html background from the document page failed\n");
00676             }
00677             break;
00678             
00679         case BROWSER_BGR_CHECKER:
00680             {
00681                 // display the checkered bitmap as background
00682                 
00683                 // get the checkered bitmap name
00684                 String_256 Checker(_R(IDS_HTML_CHECKER));
00685                 
00686                 // set it in the path
00687                 ProgramPath.SetFileNameAndType(Checker);
00688                 
00689                 // set the checkered bitmap as background image
00690                 s.MakeMsg(_R(IDS_CHECK_BACK), (TCHAR *)ProgramPath.GetWebAddress());
00691                 TempDiskFile.write(s);
00692             }
00693             break;
00694             
00695         case BROWSER_BGR_BITMAP:
00696             {
00697                 // set our bitmap as background image
00698                 s.MakeMsg(_R(IDS_BITMAPED_BACKGROUND), (TCHAR *)TempPath.GetWebAddress());
00699                 TempDiskFile.write(s);
00700                 
00701                 
00702             }
00703             break;
00704             
00705         case BROWSER_BGR_NONE:
00706             {
00707                 String_256 background(_R(IDS_PLAIN_BACKGROUND));
00708                 TempDiskFile.write(background);
00709             }
00710             
00711             break;
00712             
00713         default:
00714             ERROR3("Unknown type of BrowserOptions.m_Background");
00715             break;
00716         } // end of switch(BrowserOptions.m_Background) block
00717         
00718         // Get a pointer to the actual bitmap so that we can get some details from it.
00719         //      OILBitmap *pOilBitmap = m_pBitmap->ActualBitmap;
00720         //      ERROR3IF(pOilBitmap == NULL,"BitmapPreviewData::GenerateBitmapInfoStrings NULL oil bitmap pointer");
00721         
00722         // Get the details from the specified bitmap
00723         //      BitmapInfo BmInfo;
00724         //      pOilBitmap->GetInfo(&BmInfo);
00725         
00726         // output our bitmap, but only if it wasn't already set as background
00727         String_256 s2(_R(IDS_PAGE_TITLE));
00728         TempDiskFile.write(s2);
00729         
00730         if (BrowserOptions.m_Background != BROWSER_BGR_BITMAP)
00731         {
00732             // output the bitmap
00733             
00734             if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER)
00735             {
00736                 // GIF animation
00737                 s.MakeMsg(_R(IDS_DISPLAY_PIC), (const TCHAR *)TempPath.GetFileName());
00738             }
00739             else
00740             {
00741                 if( m_pOptions->GetFilterNameStrID() == _R(IDN_FILTERNAME_GIF) ||
00742                     m_pOptions->GetFilterNameStrID() == _R(IDS_JPG_EXP_FILTERNAME) ||
00743                     m_pOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP) )
00744                 {
00745                     s.MakeMsg(_R(IDS_DISPLAY_BMP), (const TCHAR *)TempPath.GetFileName());
00746                 }
00747                 else
00748                 if( m_pOptions->GetFilterNameStrID() == _R(IDS_FILTERNAME_PNG) )
00749                     s.MakeMsg(_R(IDS_DISPLAY_PNG), (const TCHAR *)TempPath.GetFileName());
00750             }   
00751             
00752             TempDiskFile.write(s);
00753         }
00754         else
00755         {
00756             s.MakeMsg(_R(IDS_EMPTY_BOX));
00757             TempDiskFile.write(s);
00758             
00759         }
00760         
00761         switch (m_pOptions->GetFilterNameStrID())
00762         {
00763         case _R(IDT_FILTERNAME_BMP):
00764             s2.MakeMsg(_R(IDS_BMP_MESSAGE));
00765             s.MakeMsg(_R(IDS_WARNING_BOX), (TCHAR *)s2);
00766             TempDiskFile.write(s);
00767             break;
00768         case _R(IDS_FILTERNAME_PNG):
00769             s2.MakeMsg(_R(IDS_PNG_MESSAGE));
00770             s.MakeMsg(_R(IDS_WARNING_BOX), (TCHAR *)s2);
00771             TempDiskFile.write(s);
00772             break;
00773         } // end of switch(m_pOptions->GetFilterNameStrID())
00774         
00775         s.MakeMsg(_R(IDS_DETAILS_BUILD));
00776         TempDiskFile.write(s);
00777         
00778         // output the bitmap info, if requested
00779         if (BrowserOptions.m_bInfo != FALSE)
00780         {
00781             String_64 ImageSize;
00782             String_64 FileSize;
00783             BOOL m_bTransparent = FALSE;
00784             INT32 count;
00785             count=0;
00786             // generate the info strings
00787             
00788             if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER)
00789             {
00790                 // This is actually the export animated GIF using the frame gallery system
00791                 MakeBitmapExportOptions* pMkBOptions = (MakeBitmapExportOptions*)m_pOptions;
00792                 ERROR3IF(!pMkBOptions->IS_KIND_OF(MakeBitmapExportOptions), "pMkBOptions isn't");
00793                 
00794                 PALETTE Palette = PAL_OPTIMISED;
00795                 DITHER DitherType;
00796                 UINT32 colDepth;
00797                 String_64 sPalette;
00798                 String_64 Dither;
00799                 UINT32 NoOfColours;
00800                 
00801                 NoOfColours=m_pOptions->GetNumColsInPalette();
00802                 //                      Palette = pMkBOptions->GetPalette();
00803                 DitherType = pMkBOptions->GetDither();
00804                 colDepth = pMkBOptions->GetDepth();
00805                 
00806                 s2.MakeMsg(_R(IDS_ANIMATED_GIF));
00807                 
00808                 if (pMkBOptions->WantTransparent())
00809                 {
00810                     s2.MakeMsg(_R(IDS_TRANSPARENT),"animated GIF");
00811                 }
00812                 
00813                 s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
00814                 TempDiskFile.write(s);
00815                 
00816                 switch (Palette)
00817                 {
00818                 case PAL_OPTIMISED:
00819                     sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL));
00820                     break;
00821                 case PAL_BROWSER:
00822                 case PAL_STANDARD:
00823                     sPalette.MakeMsg(_R(IDS_BROWSER_PAL));
00824                     break;
00825                 case PAL_GLOBALOPTIMISED:
00826                     sPalette.MakeMsg(_R(IDS_GLOBAL_OPT));
00827                     break;
00828                     
00829                 }
00830                 
00831                 if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) )
00832                 {
00833                     NoOfColours = 216;
00834                 }
00835                 
00836                 switch (colDepth)
00837                 {
00838                 case 32:
00839                 case 24:
00840                     s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth);
00841                     break;
00842                 case 8:
00843                     {
00844                         // Include the transparent colour in the colour depth check
00845                         UINT32 RealNumberOfColours = NoOfColours;
00846                         if (colDepth <= 8 && pMkBOptions->WantTransparent())
00847                         {
00848                             UINT32 MaxColours = UINT32(pow(2,colDepth));
00849                             RealNumberOfColours++;
00850                             if (RealNumberOfColours > MaxColours)
00851                                 RealNumberOfColours = MaxColours;
00852                         }
00853                         // We say 8 but we really mean the number of colours deep
00854                         // We cannot say 2 colours = 2bpp as we save it as 10 colours due
00855                         // to having 1 transparent colour and the usual lets pick 10 as the
00856                         // transparent colour. Cannot allow the user to choose 1 as the code
00857                         // then outputs 8bpp as GRenderOptPalette::GetOptimisedPalette has the
00858                         // test if (ReservedColours < NumColours), which fails.
00859                         /* if (RealNumberOfColours <= 2)
00860                         s2.MakeMsg(_R(IDS_PALETTEINFO),2,NoOfColours,(const TCHAR*)sPalette);
00861                         else */
00862                         if (RealNumberOfColours <= 16)
00863                             s2.MakeMsg(_R(IDS_PALETTEINFO),4,NoOfColours,(const TCHAR*)sPalette);
00864                         else
00865                             s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);
00866                         break;
00867                     }
00868                 case 1:
00869                     s2.MakeMsg(_R(IDS_MONO),colDepth);
00870                     break;
00871                 case 4:
00872                 default:
00873                     s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);                    
00874                     break;
00875                 }
00876                 
00877                 TempDiskFile.write(s2);                 
00878                 
00879                 s.MakeMsg(_R(IDS_NODITHER));
00880                 switch (DitherType)
00881                 {
00882                 case XARADITHER_ORDERED:
00883                 case XARADITHER_ORDERED_GREY:
00884                     Dither.MakeMsg(_R(IDS_DITH_ORDER));
00885                     s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
00886                     break;
00887                 case XARADITHER_ERROR_DIFFUSION:
00888                 case XARADITHER_SIMPLE:
00889                     Dither.MakeMsg(_R(IDS_DITH_ERROR));
00890                     s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
00891                     break;
00892                 case XARADITHER_NONE:
00893                     s.MakeMsg(_R(IDS_NODITHER));
00894                     break;
00895                 }
00896                 
00897                 TempDiskFile.write(s);
00898             } // if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER) block ends
00899             else
00900             {
00901                 switch (m_pOptions->GetFilterNameStrID())
00902                 {
00903                 case _R(IDN_FILTERNAME_GIF):
00904                     {
00905                         GIFExportOptions* pGIFOptions = (GIFExportOptions*)m_pOptions;
00906                         ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
00907                         PALETTE Palette = PAL_OPTIMISED;
00908                         DITHER DitherType;
00909                         UINT32 colDepth;
00910                         String_64 sPalette;
00911                         String_64 Dither;
00912                         UINT32 NoOfColours;
00913                         
00914                         NoOfColours=m_pOptions->GetNumColsInPalette();
00915                         //                      Palette = pGIFOptions->GetPalette();
00916                         DitherType = pGIFOptions->GetDither();
00917                         colDepth = pGIFOptions->GetDepth();
00918                         
00919                         
00920                         if (pGIFOptions->WantTransparent())
00921                             count=count+1;
00922                         
00923                         if (pGIFOptions->WantInterlaced())
00924                             count=count+2;
00925                         
00926                         s.MakeMsg(_R(IDS_GIF));
00927                         s2.MakeMsg(_R(IDS_A), (const TCHAR*)s);
00928                         
00929                         switch (count)
00930                         {
00931                         case 1:
00932                             s2.MakeMsg(_R(IDS_TRANSPARENT),"GIF");
00933                             break;
00934                         case 2:
00935                             s2.MakeMsg(_R(IDS_INTERLACED),"GIF");
00936                             break;
00937                         case 3:
00938                             s2.MakeMsg(_R(IDS_INTER_TRANS),"GIF");
00939                             break;
00940                         case 0:
00941                             break;
00942                         }
00943                         
00944                         s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
00945                         TempDiskFile.write(s);
00946                         
00947                         switch (Palette)
00948                         {
00949                         case PAL_OPTIMISED:
00950                             sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL));
00951                             break;
00952                         case PAL_BROWSER:
00953                         case PAL_STANDARD:
00954                             sPalette.MakeMsg(_R(IDS_BROWSER_PAL));
00955                             break;
00956                         case PAL_GLOBALOPTIMISED:
00957                             sPalette.MakeMsg(_R(IDS_GLOBAL_OPT));
00958                             break;
00959                             
00960                         }
00961                         
00962                         if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) )
00963                         {
00964                             NoOfColours = 216;
00965                         }
00966                         
00967                         s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);                    
00968                         
00969                         if (colDepth == 8)
00970                             s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);
00971                         
00972                         if (colDepth == 1)
00973                             s2.MakeMsg(_R(IDS_MONO),colDepth);
00974                         
00975                         if (colDepth > 8)
00976                             s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth);
00977                         
00978                         TempDiskFile.write(s2);                 
00979                         
00980                         s.MakeMsg(_R(IDS_NODITHER));
00981                         switch (DitherType)
00982                         {
00983                         case XARADITHER_ORDERED:
00984                         case XARADITHER_ORDERED_GREY:
00985                             Dither.MakeMsg(_R(IDS_DITH_ORDER));
00986                             s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
00987                             break;
00988                         case XARADITHER_ERROR_DIFFUSION:
00989                         case XARADITHER_SIMPLE:
00990                             Dither.MakeMsg(_R(IDS_DITH_ERROR));
00991                             s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
00992                             break;
00993                         case XARADITHER_NONE:
00994                             s.MakeMsg(_R(IDS_NODITHER));
00995                             break;
00996                         }
00997                         
00998                         TempDiskFile.write(s);
00999                         
01000                         
01001                     } // end case _R(IDN_FILTERNAME_GIF)
01002                     break;
01003                 case _R(IDS_JPG_EXP_FILTERNAME): 
01004                     {
01005                         JPEGExportOptions* pJPEGOptions = (JPEGExportOptions *)m_pOptions;
01006                         ERROR3IF(!pJPEGOptions->IS_KIND_OF(JPEGExportOptions), "pJPEGOptions isn't");
01007                         INT32 Quality = pJPEGOptions->GetQuality(); // Default Quality
01008                         BOOL Progressive = pJPEGOptions->DoAsProgressive();
01009                         if (Quality > 100)
01010                             Quality = 100;
01011                         
01012                         
01013                         s.MakeMsg(_R(IDS_JPEG));
01014                         s2.MakeMsg(_R(IDS_A), (const TCHAR*)s);
01015                         
01016                         if (Progressive)
01017                             s2.MakeMsg(_R(IDS_PROGRESSIVE));
01018                         
01019                         s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
01020                         TempDiskFile.write(s);
01021                         
01022                         
01023                         s.MakeMsg(_R(IDS_JCOMPRESSION),Quality);
01024                         TempDiskFile.write(s);                  
01025                     } // end case _R(IDS_JPG_EXP_FILTERNAME)
01026                     break;
01027                     
01028                 case _R(IDT_FILTERNAME_BMP):
01029                     {
01030                         BMPExportOptions* pBMPOptions = (BMPExportOptions*)m_pOptions;
01031                         ERROR3IF(!pBMPOptions->IS_KIND_OF(BMPExportOptions), "pBMPOptions isn't");
01032                         PALETTE Palette;
01033                         DITHER DitherType;
01034                         UINT32 colDepth;
01035                         String_64 sPalette;
01036                         String_64 Dither;
01037                         UINT32 NoOfColours;
01038                         
01039                         NoOfColours=m_pOptions->GetNumColsInPalette();
01040                         Palette = pBMPOptions->GetPalette();
01041                         DitherType = pBMPOptions->GetDither();
01042                         colDepth = pBMPOptions->GetDepth();
01043                         
01044                         s.MakeMsg(_R(IDS_BMP));
01045                         s2.MakeMsg(_R(IDS_A), (const TCHAR*)s);
01046                         
01047                         s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
01048                         TempDiskFile.write(s);
01049                         
01050                         switch (Palette)
01051                         {
01052                         case PAL_OPTIMISED:
01053                             sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL));
01054                             break;
01055                         case PAL_BROWSER:
01056                         case PAL_STANDARD:
01057                             sPalette.MakeMsg(_R(IDS_BROWSER_PAL));
01058                             break;
01059                         case PAL_GLOBALOPTIMISED:
01060                             sPalette.MakeMsg(_R(IDS_GLOBAL_OPT));
01061                             break;
01062                         }
01063                         
01064                         if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) )
01065                         {
01066                             NoOfColours = 216;
01067                         }
01068                         
01069                         if (colDepth == 8 && NoOfColours > 256)
01070                             NoOfColours = 256;
01071                         
01072                         s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);                    
01073                         
01074                         if (colDepth == 8)
01075                             s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);
01076                         
01077                         if (colDepth == 1)
01078                             s2.MakeMsg(_R(IDS_MONO),colDepth);
01079                         
01080                         if (colDepth > 8)
01081                             s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth);
01082                         
01083                         TempDiskFile.write(s2);                 
01084                         
01085                         s.MakeMsg(_R(IDS_NODITHER));
01086                         switch (DitherType)
01087                         {
01088                         case XARADITHER_ORDERED:
01089                         case XARADITHER_ORDERED_GREY:
01090                             Dither.MakeMsg(_R(IDS_DITH_ORDER));
01091                             s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
01092                             break;
01093                         case XARADITHER_ERROR_DIFFUSION:
01094                         case XARADITHER_SIMPLE:
01095                             Dither.MakeMsg(_R(IDS_DITH_ERROR));
01096                             s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
01097                             break;
01098                         case XARADITHER_NONE:
01099                             s.MakeMsg(_R(IDS_NODITHER));
01100                             break;
01101                         }
01102                         
01103                         TempDiskFile.write(s);
01104                     } // end case _R(IDT_FILTERNAME_BMP)
01105                     break;
01106                     
01107                 case _R(IDS_FILTERNAME_PNG):
01108                     {
01109                         PNGExportOptions* pPNGOptions = (PNGExportOptions*)m_pOptions;
01110                         ERROR3IF(!pPNGOptions->IS_KIND_OF(PNGExportOptions), "pPNGOptions isn't");
01111                         PALETTE Palette = PAL_OPTIMISED;
01112                         DITHER DitherType;
01113                         UINT32 colDepth;
01114                         String_64 sPalette;
01115                         String_64 Dither;
01116                         UINT32 NoOfColours;
01117                         
01118                         NoOfColours=m_pOptions->GetNumColsInPalette();
01119                         
01120                         //                      Palette = pPNGOptions->GetPalette();
01121                         DitherType = pPNGOptions->GetDither();
01122                         colDepth = pPNGOptions->GetDepth();
01123                         
01124                         
01125                         if (pPNGOptions->WantTransparent())
01126                             count=count+1;
01127                         
01128                         if (pPNGOptions->WantInterlaced())
01129                             count=count+2;
01130                         
01131                         s.MakeMsg(_R(IDS_PNG));
01132                         s2.MakeMsg(_R(IDS_A), (const TCHAR*)s);
01133                         
01134                         switch (count)
01135                         {
01136                         case 1:
01137                             s2.MakeMsg(_R(IDS_TRANSPARENT),"PNG");
01138                             break;
01139                         case 2:
01140                             s2.MakeMsg(_R(IDS_INTERLACED),"PNG");
01141                             break;
01142                         case 3:
01143                             s2.MakeMsg(_R(IDS_INTER_TRANS),"PNG");
01144                             break;
01145                         case 0:
01146                             break;
01147                         }
01148                         
01149                         s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
01150                         TempDiskFile.write(s);
01151                         
01152                         switch (Palette)
01153                         {
01154                         case PAL_OPTIMISED:
01155                             sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL));
01156                             break;
01157                         case PAL_BROWSER:
01158                         case PAL_STANDARD:
01159                             sPalette.MakeMsg(_R(IDS_BROWSER_PAL));
01160                             break;
01161                         case PAL_GLOBALOPTIMISED:
01162                             sPalette.MakeMsg(_R(IDS_GLOBAL_OPT));
01163                             break;
01164                         }
01165                         
01166                         if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) )
01167                         {
01168                             NoOfColours = 216;
01169                         }
01170                         
01171                         s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);                    
01172                         
01173                         if (colDepth == 8)
01174                             s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);
01175                         
01176                         if (colDepth == 1)
01177                             s2.MakeMsg(_R(IDS_MONO),colDepth);
01178                         
01179                         if (colDepth > 8)
01180                             s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth);
01181                         
01182                         TempDiskFile.write(s2);                 
01183                         
01184                         s.MakeMsg(_R(IDS_NODITHER));
01185                         switch (DitherType)
01186                         {
01187                         case XARADITHER_ORDERED:
01188                         case XARADITHER_ORDERED_GREY:
01189                             Dither.MakeMsg(_R(IDS_DITH_ORDER));
01190                             s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
01191                             break;
01192                         case XARADITHER_ERROR_DIFFUSION:
01193                         case XARADITHER_SIMPLE:
01194                             Dither.MakeMsg(_R(IDS_DITH_ERROR));
01195                             s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
01196                             break;
01197                         case XARADITHER_NONE:
01198                             s.MakeMsg(_R(IDS_NODITHER));
01199                             break;
01200                         }
01201                         
01202                         TempDiskFile.write(s);
01203                     } // end case _R(IDS_FILTERNAME_PNG)
01204                     
01205                     break;
01206                 } // end switch (m_pOptions->GetFilterNameStrID())
01207             } // end else block
01208             
01209             GenerateBitmapInfoStrings(ImageSize, FileSize);
01210             
01211             // output the bitmap info
01212             s.MakeMsg(_R(IDS_HTML_INFO1), (TCHAR *)ImageSize);
01213             TempDiskFile.write(s);
01214             
01215             // output the bitmap file size info
01216             s.MakeMsg(_R(IDS_HTML_INFO2), (TCHAR *)FileSize);
01217             TempDiskFile.write(s);
01218             
01219             s.MakeMsg(_R(IDS_CLOSE_CENTER));
01220             TempDiskFile.write(s);
01221             
01222             s.MakeMsg(_R(IDS_TDTR_CLOSE));
01223             TempDiskFile.write(s);
01224             
01225             s.MakeMsg(_R(IDS_BANNER_BOX));
01226             TempDiskFile.write(s);
01227             
01228             s.MakeMsg(_R(IDS_SPEED_BUILD));
01229             TempDiskFile.write(s);
01230             //          s.MakeMsg(_R(IDS_SPEED_BUILD2));
01231             //          TempDiskFile.write(s);
01232             
01233             s.MakeMsg(_R(IDS_ES_TR));
01234             TempDiskFile.write(s);
01235             
01236             String_64 times;
01237             
01238             s.MakeMsg(_R(IDS_TIME_ENTRY),"14.4k");
01239             TempDiskFile.write(s);
01240             CalculateTime(times,14400.0);
01241             TempDiskFile.write(times);
01242             s.MakeMsg(_R(IDS_ES_TR));
01243             TempDiskFile.write(s);
01244             
01245             s.MakeMsg(_R(IDS_TIME_ENTRY),"28.8k");
01246             TempDiskFile.write(s);
01247             CalculateTime(times,28800.0);
01248             TempDiskFile.write(times);
01249             s.MakeMsg(_R(IDS_ES_TR));
01250             TempDiskFile.write(s);
01251             
01252             s.MakeMsg(_R(IDS_TIME_ENTRY),"33.6k");
01253             TempDiskFile.write(s);
01254             CalculateTime(times,33600.0);
01255             TempDiskFile.write(times);
01256             s.MakeMsg(_R(IDS_ES_TR));
01257             TempDiskFile.write(s);
01258             
01259             s.MakeMsg(_R(IDS_TIME_ENTRY),"57.6k");
01260             TempDiskFile.write(s);
01261             CalculateTime(times,57600.0);
01262             TempDiskFile.write(times);
01263             s.MakeMsg(_R(IDS_ES_TR));
01264             TempDiskFile.write(s);
01265             
01266             s.MakeMsg(_R(IDS_TIME_ENTRY),"64k");
01267             TempDiskFile.write(s);
01268             CalculateTime(times,65536.0);
01269             TempDiskFile.write(times);
01270             s.MakeMsg(_R(IDS_ES_TR));
01271             TempDiskFile.write(s);
01272             
01273             s.MakeMsg(_R(IDS_TIME_ENTRY),"128k");
01274             TempDiskFile.write(s);
01275             CalculateTime(times,131072.0);
01276             TempDiskFile.write(times);
01277             
01278             //          s.MakeMsg(_R(IDS_ES_TR));
01279             //          TempDiskFile.write(s);
01280             
01281             s.MakeMsg(_R(IDS_SPEED_END));
01282             TempDiskFile.write(s);
01283             
01284             TRACE( _T("m_FileSize = %d"), m_FileSize);
01285         } // end of if (BrowserOptions.m_bInfo != FALSE)
01286         
01287         String_64 webaddy(_R(IDS_HTML_URL_PROGRAM));
01288         //Mark Howitt, 29/10/97. Setup the _R(IDS_HTML_URL_VISITMSG) To be a TCHAR* Also. It likes it that way!
01289         String_64 webvmess(_R(IDS_HTML_URL_VISITMSG));
01290         
01291         s.MakeMsg(_R(IDS_LINK_BOX),(TCHAR *)webaddy,(TCHAR *)webvmess);
01292         TempDiskFile.write(s);
01293         
01294         //end of my stuff
01295         
01296         s.MakeMsg(_R(IDS_END_TABLE));
01297         TempDiskFile.write(s);
01298         
01299         s.MakeMsg(_R(IDS_CLOSE_CENTER));
01300         TempDiskFile.write(s);
01301         
01302         // output the "Exported from" string
01303         
01304         // get the xara logo file name
01305         String_256 Logo(_R(IDS_HTML_XARALOGO));
01306         
01307         // set it in the path
01308         ProgramPath.SetFileNameAndType(Logo);
01309         
01310         // get the xara link
01311         String_256 URL(_R(IDS_HTML_URL_XARA));
01312         
01313         // output the xara link and the xara logo
01314         s.MakeMsg(_R(IDS_HTML_XARA), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress());
01315         TempDiskFile.write(s);
01316         
01317         // Do not display the Xara X logo bottom right...
01318         /*
01319         // get the program logo file name
01320         Logo.Load(_R(IDS_HTML_PROGRAMLOGO));
01321         
01322         // set it in the path
01323         ProgramPath.SetFileNameAndType(Logo);
01324         
01325         // output the program link
01326         URL.Load(_R(IDS_HTML_URL_PROGRAM));
01327         s.MakeMsg(_R(IDS_HTML_PROGRAM), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress());
01328         TempDiskFile.write(s);
01329         */
01330         
01331         // output the end of the file
01332         s.Load(_R(IDS_HTML_END));
01333         TempDiskFile.write(s);
01334         
01335         // close the file
01336         TempDiskFile.close();
01337         
01338         // now export the image map, if the option for that is set
01339         if (BrowserOptions.m_bImagemap != FALSE)
01340         {
01341             // export the image map
01342             ExportImagemap( TempDiskFile, 
01343                 m_pTempHTMLPath, 
01344                 m_pOptions->GetSelectionType(), 
01345                 m_pOptions->GetDPI(),
01346                 BrowserOptions.m_ifoImagemapOptions);
01347         }
01348         
01349         TCHAR *FileWebAddress =  m_pTempHTMLPath->GetWebAddress();
01350         
01351         //Graham 17/9/97
01352         ProgramPath.SetFileNameAndType(PRODUCT_WEBLINKEXENAME);
01353         
01354         const TCHAR *PathToWebLink = (const TCHAR *)ProgramPath.GetPath();
01355         
01356         String_256 CmdLine = PathToWebLink + String_256(" -f ") + FileWebAddress;
01357         //TCHAR *CommandLine = (TCHAR *)CmdLine;
01358         
01359         if (!InvokeWeblink(CmdLine))
01360             return FALSE;
01361         
01362     } // end of TRY block
01363     
01364     catch( CFileException )
01365     {
01366         // any disk problems - come here
01367         
01368         // not much we can do really - just close the file and return FALSE
01369         if (TempDiskFile.isOpen())
01370             TempDiskFile.close();
01371         
01372         return FALSE;
01373     }
01374 #endif
01375         
01376     return TRUE;
01377 }
01378 
01379 
01380 
01381 /*******************************************************************************************
01382 
01383   > BOOL BitmapPreviewData::DeleteTempFile(PathName *FileToRemove)
01384   
01385     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com> (based on code by Neville Humphrys)
01386     Created:    11/4/97
01387     Inputs:     FileToRemove - the path name of the file to be removed.
01388     Returns:    TRUE if succesful, FALSE otherwise
01389     Purpose:    Removes a file
01390     
01391  *******************************************************************************************/
01392 #if FALSE
01393  BOOL BitmapPreviewData::DeleteTempFile(PathName *FileToRemove)
01394  {
01395      if (FileToRemove == NULL)
01396          return FALSE;
01397      
01398      BOOL Exists = TRUE;
01399      BOOL status = TRUE;
01400      
01401      // check if the file exists
01402      Exists = SGLibOil::FileExists(FileToRemove);
01403      
01404      // remove it
01405      if (Exists)
01406          status = _tremove((const TCHAR *)FileToRemove->GetPath());
01407      
01408      return !status;
01409  }
01410 #endif
01411  
01412  
01413  /********************************************************************************************
01414  
01415    >    void BitmapPreviewData::GenerateBitmapInfoStrings(String_64 &ImageSize, String_64 &FileSize,
01416    BOOL bIncludeBpp = FALSE)
01417    
01418      Author:    Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
01419      Created:   10/5/97
01420      Inputs:    -
01421      Outputs:   ImageSize - a string receiving the image size info for the current bitmap
01422      FileSize - a string receiving the file size info for the current bitmap
01423      Returns:   -
01424      Purpose:   Generates image size and file size info strings
01425  ********************************************************************************************/
01426  
01427  void BitmapPreviewData::GenerateBitmapInfoStrings(String_64 &ImageSize, String_64 &FileSize,
01428      BOOL bIncludeBpp)
01429  {
01430      // sanity check
01431      ERROR3IF(m_pBitmap == NULL, "BitmapPreviewData::GenerateBitmapInfoStrings no bitmap to work with");
01432      ERROR3IF(m_pOptions == NULL, "BitmapPreviewData::GenerateBitmapInfoStrings no export options");
01433      if ((m_pBitmap == NULL) || (m_pOptions == NULL))
01434          return;
01435      
01436      // Get a pointer to the actual bitmap so that we can get some details from it.
01437      OILBitmap *pOilBitmap = m_pBitmap->ActualBitmap;
01438      ERROR3IF(pOilBitmap == NULL,"BitmapPreviewData::GenerateBitmapInfoStrings NULL oil bitmap pointer");
01439      
01440      // Get the details from the specified bitmap
01441      BitmapInfo BmInfo;
01442      pOilBitmap->GetInfo(&BmInfo);
01443      
01444      // make the image size string
01445      
01446      // the width and the height
01447      ImageSize.MakeMsg(_R(IDS_IMAGE_SIZE), BmInfo.PixelWidth, BmInfo.PixelHeight);
01448      
01449      // the image depth
01450      if (bIncludeBpp)
01451      {
01452          UINT32 Depth = m_pOptions->GetDepth();
01453          if (Depth == 1)
01454          {
01455              // monochrome image
01456              ImageSize += String_32(_R(IDS_IMAGE_DEPTH1));
01457          }
01458          else
01459          {
01460              String_16 s;
01461              s.MakeMsg(_R(IDS_IMAGE_DEPTH2), Depth);
01462              ImageSize += s;
01463          }
01464      }
01465      
01466      // make the file size message
01467      FileSize.MakeMsg(_R(IDS_FILE_SIZE), m_FileSize);
01468  }
01469  
01470  
01471  
01472  /********************************************************************************************
01473  
01474    >    void BitmapPreviewData::SetNewBitmap(KernelBitmap *pKernelBitmap, PathName *TempPath, 
01475    UINT32 FileSize, BitmapExportOptions *pOptions)
01476    
01477      Author:    Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
01478      Created:   10/5/97
01479      Inputs:    pKernelBitmap - pointer to a kernel bitmap
01480      TempPath - The disk file of the bitmap
01481      FileSize - the size of the temp disk file
01482      pOptions - the export options for the bitmap
01483      Outputs:   -
01484      Returns:   -
01485      Purpose:   Receives a new bitmap (and its file). Deletes the previous bitmap and file 
01486      (if any) set for that object.
01487  ********************************************************************************************/
01488  
01489  void BitmapPreviewData::SetNewBitmap(KernelBitmap *pKernelBitmap, UINT32 FileSize, 
01490      BitmapExportOptions *pOptions)
01491  {
01492      // delete any previous data
01493      DeleteBitmapData();
01494      
01495      // now remember the data
01496      m_pBitmap = pKernelBitmap;
01497      m_FileSize = FileSize;
01498      m_pOptions = pOptions;
01499  }
01500  
01501  /********************************************************************************************
01502  
01503    >    void BitmapPreviewData::CalculateTime(String_64 &timestring,double speed)
01504    
01505      Author:    Martin_Bell (Xara Group Ltd) <camelotdev@xara.com> Donnelly
01506      Created:   12/7/97
01507      Inputs:    speed - the download speed
01508      
01509        Outputs: -
01510        Returns: timestring - The timeing to be returned as a string
01511        Purpose: Calculates the time to download the bitmap
01512  ********************************************************************************************/
01513  
01514  
01515  void BitmapPreviewData::CalculateTime(String_64 &timestring,double speed)
01516  {
01517      // sanity check
01518      
01519      double dtime;
01520      String_64 tempstring;
01521      char buffer[16];
01522      INT32 j;
01523      String_16 times;
01524      
01525      dtime =(m_FileSize * 8.0)/speed;
01526      
01527      if (fabs(dtime) == fabs(1.000)) 
01528      {
01529          tempstring.MakeMsg(_R(IDS_1SEC));
01530          timestring.MakeMsg(_R(IDS_TIME_ENTRY),(TCHAR *)tempstring);
01531      }
01532      else if (fabs(dtime) < fabs(1.000))
01533      {
01534          //Added by Graham 14/9/97
01535          
01536          tempstring.MakeMsg(_R(IDS_LESSTHANONESECOND));
01537          timestring.MakeMsg(_R(IDS_TIME_ENTRY),(TCHAR *)tempstring);
01538          
01539      }
01540      else
01541      { 
01542          /* Format and print various data: */
01543          j  = sprintf( buffer,"%.2f",dtime);
01544          
01545          times.MakeMsg(_R(IDS_SECS_MOD), buffer);
01546          timestring.MakeMsg(_R(IDS_TIME_ENTRY),(const TCHAR *)times);
01547      }
01548      
01549      
01550  }

Generated on Sat Nov 10 03:48:13 2007 for Camelot by  doxygen 1.4.4