00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #include "camtypes.h"
00102 #include "bmpexprw.h"
00103 #include "prvwmenu.h"
00104
00105 #include "giffiltr.h"
00106
00107
00108
00109
00110 #include "product.h"
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"
00120 #include "filtimop.h"
00121 #include "filtrmgr.h"
00122
00123 #include "menucmds.h"
00124
00125
00126
00127
00128
00129 DECLARE_SOURCE("$Revision: 1482 $");
00130
00131
00132
00133
00134 CC_IMPLEMENT_MEMDUMP(BrowserPreviewOptions, CCObject)
00135 CC_IMPLEMENT_DYNAMIC(BitmapPreviewData, CCObject)
00136
00137
00138
00139 #define new CAM_DEBUG_NEW
00140
00141
00142
00143 PathName * BitmapPreviewData::pPagePath = NULL;
00144
00146
00147
00148
00149
00150
00151
00152
00153
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
00168
00169
00170
00171
00172
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
00189
00190
00191
00192
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
00209
00210
00211
00212
00213
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
00229
00230
00231
00232
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
00248
00249
00250
00251
00252
00253
00254
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
00270
00271
00272
00273
00274
00275
00276
00277 BitmapPreviewData::~BitmapPreviewData()
00278 {
00279 DeleteBitmapData();
00280 }
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 void BitmapPreviewData::DeleteBitmapData()
00295 {
00296 if (!m_bIsSameBitmap)
00297 {
00298
00299 if (m_pBitmap != NULL)
00300 delete m_pBitmap;
00301 m_pBitmap = NULL;
00302
00303
00304
00305
00306
00307
00308 }
00309
00310
00311 if (m_pTempHTMLPath != NULL)
00312 {
00313
00314 FileUtil::DeleteFile(m_pTempHTMLPath);
00315
00316
00317 delete m_pTempHTMLPath;
00318 }
00319 m_pTempHTMLPath = NULL;
00320 }
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337 BOOL BitmapPreviewData::ComposeHTMLColour(DocColour *pColour, String_32 &OutColour)
00338 {
00339 if (pColour == NULL)
00340 return FALSE;
00341
00342
00343 INT32 R, G, B;
00344 pColour->GetRGBValue(&R, &G, &B);
00345
00346
00347 OutColour = String_32( _T("#") );
00348 String_32 c;
00349
00350
00351 if (R < 16)
00352 OutColour += _T("0");
00353 c._MakeMsg( _T("#1%X"), R % 256);
00354 OutColour += c;
00355
00356
00357 if (G < 16)
00358 OutColour += _T("0");
00359 c._MakeMsg( _T("#1%X"), G % 256);
00360 OutColour += c;
00361
00362
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
00376
00377
00378
00379
00380
00381
00382
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
00394 CCDiskFile TempDiskFile(1024, FALSE, TRUE);
00395
00396
00397 Filter *pFilter = Filter::GetFirst();
00398 while (pFilter != NULL)
00399 {
00400 if (IS_A(pFilter,PreviewFilterGIF))
00401
00402 break;
00403
00404
00405 pFilter = Filter::GetNext(pFilter);
00406 }
00407
00408 if (pFilter == NULL)
00409 return FALSE;
00410
00411
00412 PreviewFilterGIF *pGIFFilter = (PreviewFilterGIF *)pFilter;
00413
00414 BOOL ok = TRUE;
00415
00416
00417 SelOperation *pOp = new SelOperation;
00418 if (pOp != NULL)
00419 {
00420 ok = pGIFFilter->DoExportBitmap(pOp, &TempDiskFile, pOutFile, pBmp);
00421
00422
00423 delete pOp;
00424 }
00425 else
00426 return FALSE;
00427
00428
00429 if (TempDiskFile.isOpen())
00430 TempDiskFile.close();
00431
00432 return ok;
00433 }
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 BOOL BitmapPreviewData::SetBackgroundFromPage(CCDiskFile &DiskFile, Spread * pSpread)
00453 {
00454 String_256 s;
00455
00456
00457 if (pSpread == NULL)
00458 {
00459
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
00468 KernelBitmap *pPageBmp = NULL;
00469 DocColour *pPageColour = NULL;
00470 OpBackground::GetPageColour(pSpread, &pPageBmp, &pPageColour);
00471
00472 BOOL Ok = TRUE;
00473
00474 if (pPageBmp != NULL)
00475 {
00476
00477 if (pPagePath == NULL)
00478 {
00479
00480 pPagePath = new PathName;
00481
00482 if (pPagePath)
00483 {
00484
00485 Ok = FileUtil::GetTemporaryPathName( _T("gif"), pPagePath);
00486 }
00487 else
00488 Ok = FALSE;
00489
00490 }
00491
00492
00493 if (Ok) Ok = pPagePath->IsValid();
00494
00495
00496 if (Ok && ExportBrowserTypeBitmap(pPageBmp, pPagePath))
00497 {
00498
00499 s.MakeMsg(_R(IDS_HTML_BGIMAGE), (const TCHAR *)pPagePath->GetFileName());
00500 DiskFile.write(s);
00501 }
00502
00503 return Ok;
00504 }
00505
00506
00507
00508 BOOL AllocatedColour = FALSE;
00509 if (pPageColour == NULL)
00510 {
00511
00512 AllocatedColour = TRUE;
00513 pPageColour = new DocColour(COLOUR_WHITE);
00514 }
00515
00516
00517 String_32 col;
00518 if (ComposeHTMLColour(pPageColour,col))
00519 {
00520
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
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546 BOOL BitmapPreviewData::ExportImagemap(CCDiskFile &DiskFile, PathName *pPath, SelectionType Sel, DPI dpi,
00547 ImagemapFilterOptions ifoOptionsToUse)
00548 {
00549
00550 ERROR3IF(pPath == NULL, "BitmapPreviewData::ExportImagemap - no file path to use");
00551 if (dpi <= 0.0)
00552 return FALSE;
00553
00554
00555
00556
00557 ImagemapFilter* pImagemapFilter = (ImagemapFilter*) Filter::FindFilterFromID(FILTERID_IMAGEMAP);
00558
00559 if (pImagemapFilter == NULL)
00560 return FALSE;
00561
00562
00563
00564
00565 ImagemapFilterOptions ifoOld=pImagemapFilter->GetFilterOptions();
00566
00567
00568 ImagemapFilterOptions ifoToSet=ifoOptionsToUse;
00569
00570
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
00582 pImagemapFilter->SetFilterOptions(ifoToSet);
00583
00584
00585 BOOL ok= pImagemapFilter->PrepareAndWriteData(Document::GetCurrent());
00586
00587
00588 pImagemapFilter->SetFilterOptions(ifoOld);
00589
00590 return ok;
00591 }
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
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
00610
00611
00612
00613 ERROR3IF(m_pOptions == NULL, "BitmapPreviewData::GenerateHTMLStub - need export options");
00614 if (m_pOptions == NULL)
00615 return FALSE;
00616
00617
00618 PathName TempPath = m_pOptions->GetPathName();
00619
00620
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
00627 if (m_pTempHTMLPath != NULL)
00628 FileUtil::DeleteFile(m_pTempHTMLPath);
00629 else
00630 m_pTempHTMLPath = new PathName;
00631
00632
00633 if (m_pTempHTMLPath == NULL)
00634 return FALSE;
00635
00636
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
00646
00647
00648 CCDiskFile TempDiskFile(1024, FALSE, TRUE);
00649
00650
00651 CString str;
00652 AfxGetModuleShortFileName(AfxGetInstanceHandle(), str);
00653 String_256 strPathName(str.GetBuffer(0));
00654
00655
00656 PathName ProgramPath(strPathName);
00657
00658 try
00659 {
00660
00661 if (!TempDiskFile.open(*m_pTempHTMLPath, ios::out))
00662 return FALSE;
00663
00664
00665 String_256 s(_R(IDS_HTML_HEAD));
00666 TempDiskFile.write(s);
00667
00668
00669 switch (BrowserOptions.m_Background)
00670 {
00671 case BROWSER_BGR_DOC:
00672 {
00673
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
00682
00683
00684 String_256 Checker(_R(IDS_HTML_CHECKER));
00685
00686
00687 ProgramPath.SetFileNameAndType(Checker);
00688
00689
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
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 }
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727 String_256 s2(_R(IDS_PAGE_TITLE));
00728 TempDiskFile.write(s2);
00729
00730 if (BrowserOptions.m_Background != BROWSER_BGR_BITMAP)
00731 {
00732
00733
00734 if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER)
00735 {
00736
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 }
00774
00775 s.MakeMsg(_R(IDS_DETAILS_BUILD));
00776 TempDiskFile.write(s);
00777
00778
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
00787
00788 if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER)
00789 {
00790
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
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
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
00854
00855
00856
00857
00858
00859
00860
00861
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 }
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
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 }
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();
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 }
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 }
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
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 }
01204
01205 break;
01206 }
01207 }
01208
01209 GenerateBitmapInfoStrings(ImageSize, FileSize);
01210
01211
01212 s.MakeMsg(_R(IDS_HTML_INFO1), (TCHAR *)ImageSize);
01213 TempDiskFile.write(s);
01214
01215
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
01231
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
01279
01280
01281 s.MakeMsg(_R(IDS_SPEED_END));
01282 TempDiskFile.write(s);
01283
01284 TRACE( _T("m_FileSize = %d"), m_FileSize);
01285 }
01286
01287 String_64 webaddy(_R(IDS_HTML_URL_PROGRAM));
01288
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
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
01303
01304
01305 String_256 Logo(_R(IDS_HTML_XARALOGO));
01306
01307
01308 ProgramPath.SetFileNameAndType(Logo);
01309
01310
01311 String_256 URL(_R(IDS_HTML_URL_XARA));
01312
01313
01314 s.MakeMsg(_R(IDS_HTML_XARA), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress());
01315 TempDiskFile.write(s);
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332 s.Load(_R(IDS_HTML_END));
01333 TempDiskFile.write(s);
01334
01335
01336 TempDiskFile.close();
01337
01338
01339 if (BrowserOptions.m_bImagemap != FALSE)
01340 {
01341
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
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
01358
01359 if (!InvokeWeblink(CmdLine))
01360 return FALSE;
01361
01362 }
01363
01364 catch( CFileException )
01365 {
01366
01367
01368
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
01384
01385
01386
01387
01388
01389
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
01402 Exists = SGLibOil::FileExists(FileToRemove);
01403
01404
01405 if (Exists)
01406 status = _tremove((const TCHAR *)FileToRemove->GetPath());
01407
01408 return !status;
01409 }
01410 #endif
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427 void BitmapPreviewData::GenerateBitmapInfoStrings(String_64 &ImageSize, String_64 &FileSize,
01428 BOOL bIncludeBpp)
01429 {
01430
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
01437 OILBitmap *pOilBitmap = m_pBitmap->ActualBitmap;
01438 ERROR3IF(pOilBitmap == NULL,"BitmapPreviewData::GenerateBitmapInfoStrings NULL oil bitmap pointer");
01439
01440
01441 BitmapInfo BmInfo;
01442 pOilBitmap->GetInfo(&BmInfo);
01443
01444
01445
01446
01447 ImageSize.MakeMsg(_R(IDS_IMAGE_SIZE), BmInfo.PixelWidth, BmInfo.PixelHeight);
01448
01449
01450 if (bIncludeBpp)
01451 {
01452 UINT32 Depth = m_pOptions->GetDepth();
01453 if (Depth == 1)
01454 {
01455
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
01467 FileSize.MakeMsg(_R(IDS_FILE_SIZE), m_FileSize);
01468 }
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489 void BitmapPreviewData::SetNewBitmap(KernelBitmap *pKernelBitmap, UINT32 FileSize,
01490 BitmapExportOptions *pOptions)
01491 {
01492
01493 DeleteBitmapData();
01494
01495
01496 m_pBitmap = pKernelBitmap;
01497 m_FileSize = FileSize;
01498 m_pOptions = pOptions;
01499 }
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515 void BitmapPreviewData::CalculateTime(String_64 ×tring,double speed)
01516 {
01517
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
01535
01536 tempstring.MakeMsg(_R(IDS_LESSTHANONESECOND));
01537 timestring.MakeMsg(_R(IDS_TIME_ENTRY),(TCHAR *)tempstring);
01538
01539 }
01540 else
01541 {
01542
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 }