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
00102
00103 #include "camtypes.h"
00104
00105 #include "nativeps.h"
00106
00107
00108
00109
00110 #include "cversion.h"
00111 #include "progress.h"
00112
00113 #include "bmpcomp.h"
00114
00115
00116 #include "opgrad.h"
00117 #include "nodetext.h"
00118
00119 #include "zstream.h"
00120 #include <sstream>
00121 #include "fontman.h"
00122 #include "expbmp.h"
00123
00124
00125
00126
00127 CC_IMPLEMENT_DYNAMIC(CamelotNativeEPSFilter, CamelotEPSFilter);
00128 #if !defined(EXCLUDE_FROM_RALPH)
00129 CC_IMPLEMENT_DYNAMIC(NativeRenderRegion, CamelotEPSRenderRegion);
00130 #endif
00131
00132
00133
00134 #define new CAM_DEBUG_NEW
00135
00136 typedef enum
00137 {
00138 TRANSPFILL_NONE,
00139 TRANSPFILL_FLAT,
00140 TRANSPFILL_LINEAR,
00141 TRANSPFILL_CIRCULAR,
00142 TRANSPFILL_ELLIPTICAL,
00143 TRANSPFILL_CONICAL,
00144 TRANSPFILL_TEXTURE,
00145 TRANSPFILL_FRACTAL,
00146 TRANSPFILL_NEWLINEAR,
00147 TRANSPFILL_NEWTEXTURE,
00148 TRANSPFILL_NEWFRACTAL
00149 } TranspFillGeometryType;
00150
00151
00152
00153 CommandMap CamelotNativeEPSFilter::NativeCommands[] =
00154 {
00155
00156 { EPSC_cbmp, _T("cbmp") },
00157
00158
00159 { EPSC_Invalid, _T("Invalid") }
00160 };
00161
00162
00163
00164
00165
00166 typedef enum
00167 {
00168
00169
00170
00171
00172
00173 FIRSTVERSION = 100
00174
00175 } NativeFileVersion;
00176
00177
00178 const NativeFileVersion ReadNativeVersion100 = FIRSTVERSION;
00179 const NativeFileVersion WriteNativeVersion100 = FIRSTVERSION;
00180 const double ReadNativeVersion = (ReadNativeVersion100/100);
00181 const double WriteNativeVersion = (WriteNativeVersion100/100);
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 BOOL CamelotNativeEPSFilter::CompressNative = TRUE;
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 CamelotNativeEPSFilter::CamelotNativeEPSFilter()
00209 {
00210
00211 FilterNameID = _R(IDS_NATIVE_EPS_FILTERNAME);
00212 FilterInfoID = _R(IDS_NATIVE_EPS_FILTERINFO);
00213 ImportMsgID = _R(IDS_IMPORTMSG_NATIVE_EPS);
00214 ExportMsgID = _R(IDS_EXPORTMSG_NATIVE_EPS);
00215
00216 FilterID = FILTERID_NATIVE_EPS;
00217
00218 #ifndef STANDALONE
00219 Flags.CanImport = TRUE;
00220
00221 #ifdef WEBSTER
00222 Flags.CanExport = FALSE;
00223 #else
00224 Flags.CanExport = FALSE;
00225 #endif //WEBSTER
00226 #else
00227 Flags.CanImport = TRUE;
00228 Flags.CanExport = FALSE;
00229 #endif
00230
00231
00232
00233 AdjustOrigin = FALSE;
00234
00235
00236 IsSavingBitmapPool = FALSE;
00237 BitmapCount = 0;
00238 BitmapPoolRefs = NULL;
00239 PendingBitmapNum = 0;
00240
00241
00242 OldImportWithLayers = TRUE;
00243 OldOpenWithLayers = TRUE;
00244
00245
00246 CompressionType = 0;
00247 CompressionOn = FALSE;
00248
00249 FileVersionNumber = 0.0;
00250 BuildVersionNumber = 0.0;
00251 }
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 CamelotNativeEPSFilter::~CamelotNativeEPSFilter()
00268 {
00269
00270 if (BitmapPoolRefs != NULL)
00271 delete [] BitmapPoolRefs;
00272 }
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 BOOL CamelotNativeEPSFilter::Init()
00290 {
00291
00292 pOILFilter = new NativeEPSOILFilter(this);
00293 if (pOILFilter == NULL)
00294 return FALSE;
00295
00296
00297 FilterName.Load(FilterNameID);
00298 FilterInfo.Load(FilterInfoID);
00299
00300
00301 if (Camelot.DeclareSection(_T("Filters"), 10))
00302 {
00303 Camelot.DeclarePref( NULL, _T("CompressNative"), &CompressNative, 0, 1 );
00304 }
00305
00306
00307 return TRUE;
00308 }
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322 BOOL CamelotNativeEPSFilter::SetNativeCompression(BOOL NewState)
00323 {
00324
00325 CompressNative = NewState;
00326 return CompressNative;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 BOOL CamelotNativeEPSFilter::GetNativeCompression()
00343 {
00344 return CompressNative;
00345 }
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 BOOL CamelotNativeEPSFilter::SetFileCompressionState(BOOL NewState)
00360 {
00361 TRACEUSER( "Neville", _T("CamelotNativeEPSFilter::SetFileCompressionState new state= %d\n"),NewState);
00362
00363 CompressionOn = NewState;
00364
00365 return TRUE;
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379 BOOL CamelotNativeEPSFilter::GetFileCompressionState()
00380 {
00381 return CompressionOn;
00382 }
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395 void CamelotNativeEPSFilter::LookUpToken()
00396 {
00397
00398 if (Token == EPSC_Comment)
00399 return;
00400
00401
00402
00403 INT32 i = 0;
00404 while (NativeCommands[i].Cmd != EPSC_Invalid)
00405 {
00406 if (camStrcmp(TokenBuf, NativeCommands[i].CmdStr) == 0)
00407 {
00408
00409 Token = NativeCommands[i].Cmd;
00410 return;
00411 }
00412
00413
00414 i++;
00415 }
00416
00417
00418 CamelotEPSFilter::LookUpToken();
00419 }
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 BOOL CamelotNativeEPSFilter::ProcessToken()
00435 {
00436 ArrowRec Arrow;
00437 double ArrowWidth;
00438 double ArrowHeight;
00439 INT32 ArrowID;
00440
00441 DashRec Dash;
00442 INT32 DashID;
00443 DashPatternAttribute* pDash;
00444
00445
00446 switch (Token)
00447 {
00448
00449 case EPSC_cbmp:
00450 {
00451 INT32 PoolType;
00452
00453
00454 if ((!Stack.Pop(&PoolType)) || (PoolType!=0))
00455 goto EPSError;
00456
00457
00458 if (!Stack.Pop(&PendingBitmapNum))
00459 goto EPSError;
00460
00461
00462 TRACEUSER( "Rik", _T("Got a Bitmap pool item....\n"));
00463 m_PendingBitmap = PENDING_BITMAP_POOLITEM;
00464 break;
00465 }
00466
00467
00468 case EPSC_cst:
00469 INT32 TranspType, Transp;
00470
00471
00472 if (!Stack.Pop(&TranspType))
00473 goto EPSError;
00474
00475
00476 if (!Stack.Pop(&Transp))
00477 goto EPSError;
00478
00479 TRACEUSER( "Will", _T("Importing Line transp, Val=%d, Type=%d\n"),Transp, TranspType);
00480
00481 if (!SetLineTransp((UINT32)TranspType, (UINT32)Transp))
00482 goto NoMemory;
00483 break;
00484
00485
00486 case EPSC_csah:
00487 if (!Stack.Pop(&ArrowHeight))
00488 goto EPSError;
00489
00490 if (!Stack.Pop(&ArrowWidth))
00491 goto EPSError;
00492
00493 if (!Stack.Pop(&ArrowID))
00494 goto EPSError;
00495
00496 TRACEUSER( "Will", _T("Importing StartArrow, ID=%d\n"),ArrowID);
00497
00498 if (!Arrow.CreateStockArrow((StockArrow)ArrowID))
00499 goto NoMemory;
00500
00501 Arrow.SetArrowSize(FIXED16(ArrowWidth), FIXED16(ArrowHeight));
00502
00503 if (!SetStartArrow(Arrow))
00504 goto NoMemory;
00505 break;
00506
00507
00508 case EPSC_ceah:
00509 if (!Stack.Pop(&ArrowHeight))
00510 goto EPSError;
00511
00512 if (!Stack.Pop(&ArrowWidth))
00513 goto EPSError;
00514
00515 if (!Stack.Pop(&ArrowID))
00516 goto EPSError;
00517
00518 TRACEUSER( "Will", _T("Importing EndArrow, ID=%d\n"),ArrowID);
00519
00520 if (!Arrow.CreateStockArrow((StockArrow)ArrowID))
00521 goto NoMemory;
00522
00523 Arrow.SetArrowSize(FIXED16(ArrowWidth), FIXED16(ArrowHeight));
00524
00525 if (!SetEndArrow(Arrow))
00526 goto NoMemory;
00527 break;
00528
00529
00530 case EPSC_cdp:
00531 if (!Stack.Pop(&DashID))
00532 goto EPSError;
00533
00534 TRACEUSER( "Will", _T("Importing Dash Pattern, ID=%d\n"),DashID);
00535
00536 pDash = new DashPatternAttribute;
00537 if (pDash == NULL)
00538 goto NoMemory;
00539
00540 if (!pDash->SetStockDashPattern((StockDash)DashID))
00541 goto NoMemory;
00542
00543 Dash = pDash->DashPattern;
00544 delete pDash;
00545
00546 if (!SetDashPattern(Dash))
00547 goto NoMemory;
00548 break;
00549
00550
00551 case EPSC_cxt:
00552 {
00553 DocCoord StartPoint, EndPoint, EndPoint2;
00554 INT32 StartTransp, EndTransp, TranspType;
00555 INT32 FillType;
00556 INT32 Tileable;
00557
00558
00559 INT32 Seed;
00560 double Graininess, Gravity, Squash;
00561 UINT32 DPI;
00562
00563
00564 if (!Stack.Pop(&FillType))
00565 goto EPSError;
00566
00567 TRACEUSER( "Will", _T("Importing Transp Fill, Type=%d\n"),FillType);
00568
00569
00570 if (FillType != TRANSPFILL_NONE)
00571 {
00572
00573 if (!Stack.Pop(&TranspType))
00574 goto EPSError;
00575
00576 if ((FillType != TRANSPFILL_TEXTURE) && (FillType != TRANSPFILL_FRACTAL))
00577 {
00578
00579 switch (FillType)
00580 {
00581 case TRANSPFILL_LINEAR:
00582 case TRANSPFILL_ELLIPTICAL:
00583 case TRANSPFILL_CIRCULAR:
00584 case TRANSPFILL_CONICAL:
00585 case TRANSPFILL_NEWLINEAR:
00586 case TRANSPFILL_NEWTEXTURE:
00587 case TRANSPFILL_NEWFRACTAL:
00588 if (!Stack.Pop(&EndTransp))
00589 goto EPSError;
00590 break;
00591
00592 default:
00593
00594 break;
00595 }
00596
00597
00598 if (!Stack.Pop(&StartTransp))
00599 goto EPSError;
00600 }
00601
00602 }
00603
00604
00605 if (FillType == TRANSPFILL_FRACTAL || FillType == TRANSPFILL_NEWFRACTAL)
00606 {
00607
00608
00609 INT32 SubType;
00610
00611 if (!Stack.Pop(&SubType))
00612 goto EPSError;
00613
00614
00615 Tileable = FALSE;
00616
00617
00618
00619 if (SubType != 0)
00620 {
00621 if (SubType == 1)
00622 {
00623
00624 if (!Stack.Pop(&Tileable))
00625 goto EPSError;
00626 }
00627 else
00628 {
00629 ERROR2RAW("Bad fractal fill sub-type");
00630 goto EPSError;
00631 }
00632 }
00633
00634
00635 if (!Stack.Pop(&DPI) ||
00636 !Stack.Pop(&Squash) ||
00637 !Stack.Pop(&Gravity) ||
00638 !Stack.Pop(&Graininess) ||
00639 !Stack.Pop(&Seed))
00640 {
00641
00642 goto EPSError;
00643 }
00644 }
00645
00646
00647 if ((FillType == TRANSPFILL_ELLIPTICAL) ||
00648 (FillType == TRANSPFILL_TEXTURE) ||
00649 (FillType == TRANSPFILL_FRACTAL) ||
00650 (FillType == TRANSPFILL_NEWTEXTURE) ||
00651 (FillType == TRANSPFILL_NEWFRACTAL) ||
00652 (FillType == TRANSPFILL_NEWLINEAR))
00653 {
00654 if (!Stack.PopCoordPair(&EndPoint2))
00655 goto EPSError;
00656 }
00657
00658
00659 if ((FillType == TRANSPFILL_ELLIPTICAL) ||
00660 (FillType == TRANSPFILL_CIRCULAR) ||
00661 (FillType == TRANSPFILL_LINEAR) ||
00662 (FillType == TRANSPFILL_CONICAL) ||
00663 (FillType == TRANSPFILL_TEXTURE) ||
00664 (FillType == TRANSPFILL_FRACTAL) ||
00665 (FillType == TRANSPFILL_NEWLINEAR) ||
00666 (FillType == TRANSPFILL_NEWFRACTAL) ||
00667 (FillType == TRANSPFILL_NEWTEXTURE))
00668 {
00669 if (!Stack.PopCoordPair(&EndPoint) || !Stack.PopCoordPair(&StartPoint))
00670 goto EPSError;
00671 }
00672
00673 switch (FillType)
00674 {
00675
00676 case TRANSPFILL_NONE:
00677 if (!SetNoTranspFill())
00678 goto NoMemory;
00679 break;
00680
00681 case TRANSPFILL_FLAT:
00682 if (!SetFlatTranspFill(TranspType, StartTransp))
00683 goto NoMemory;
00684 break;
00685
00686 case TRANSPFILL_LINEAR:
00687 if (!SetLinearTranspFill(TranspType, StartTransp, EndTransp,
00688 StartPoint, EndPoint))
00689 goto NoMemory;
00690 break;
00691
00692 case TRANSPFILL_NEWLINEAR:
00693 if (!SetLinearTranspFill(TranspType, StartTransp, EndTransp,
00694 StartPoint, EndPoint, &EndPoint2))
00695 goto NoMemory;
00696 break;
00697
00698 case TRANSPFILL_ELLIPTICAL:
00699 if (!SetRadialTranspFill(TranspType, StartTransp, EndTransp,
00700 StartPoint, EndPoint, EndPoint2))
00701 goto NoMemory;
00702 break;
00703
00704 case TRANSPFILL_CIRCULAR:
00705 if (!SetRadialTranspFill(TranspType, StartTransp, EndTransp,
00706 StartPoint, EndPoint))
00707 goto NoMemory;
00708 break;
00709
00710 case TRANSPFILL_CONICAL:
00711 if (!SetConicalTranspFill(TranspType, StartTransp, EndTransp,
00712 StartPoint, EndPoint))
00713 goto NoMemory;
00714 break;
00715
00716 case TRANSPFILL_TEXTURE:
00717 m_PendingBitmap = PENDING_BITMAP_TRANSPFILL;
00718 BitmapAttrs.Coords[0] = StartPoint;
00719 BitmapAttrs.Coords[1] = EndPoint;
00720 BitmapAttrs.Coords[2] = EndPoint2;
00721 BitmapAttrs.TranspType = TranspType;
00722 BitmapAttrs.Transp = 0;
00723 BitmapAttrs.EndTransp = 255;
00724 break;
00725
00726 case TRANSPFILL_NEWTEXTURE:
00727 m_PendingBitmap = PENDING_BITMAP_TRANSPFILL;
00728 BitmapAttrs.Coords[0] = StartPoint;
00729 BitmapAttrs.Coords[1] = EndPoint;
00730 BitmapAttrs.Coords[2] = EndPoint2;
00731 BitmapAttrs.TranspType = TranspType;
00732 BitmapAttrs.Transp = StartTransp;
00733 BitmapAttrs.EndTransp = EndTransp;
00734 break;
00735
00736 case TRANSPFILL_FRACTAL:
00737 if (!SetFractalTranspFill(TranspType, StartPoint, EndPoint, EndPoint2,
00738 Seed, Graininess, Gravity, Squash, DPI,
00739 Tileable))
00740 goto NoMemory;
00741 break;
00742
00743 case TRANSPFILL_NEWFRACTAL:
00744 if (!SetFractalTranspFill(TranspType, StartPoint, EndPoint, EndPoint2,
00745 Seed, Graininess, Gravity, Squash, DPI,
00746 Tileable, StartTransp, EndTransp))
00747 goto NoMemory;
00748 break;
00749
00750 default:
00751 ENSURE(FALSE, "Unknown fill type found!");
00752 break;
00753 }
00754
00755 break;
00756 }
00757
00758 case EPSC_cxmt:
00759 {
00760 INT32 MappingType;
00761 INT32 Repeat;
00762
00763
00764 if (!Stack.Pop(&MappingType))
00765 goto EPSError;
00766
00767 if (MappingType != 0)
00768 {
00769 ERROR2RAW("Bad mapping type in EPS");
00770 goto EPSError;
00771 }
00772
00773
00774 if (!Stack.Pop(&Repeat))
00775 goto EPSError;
00776
00777 if ((Repeat < 1) || (Repeat > 3))
00778 {
00779 ERROR2RAW("Bad mapping type in EPS");
00780 goto EPSError;
00781 }
00782
00783
00784 if (Token == EPSC_cxm)
00785 {
00786 if (!SetLinearFillMapping(Repeat))
00787 goto NoMemory;
00788 }
00789 else
00790 {
00791 if (!SetLinearTranspFillMapping(Repeat))
00792 goto NoMemory;
00793 }
00794
00795 break;
00796 }
00797
00798 case EPSC_ctf:
00799 {
00800
00801 String_64 FName;
00802
00803 if (!Stack.Pop(&FName))
00804 goto EPSError;
00805 FName.SwapChar('-',' ');
00806
00807 if ((FONTMANAGER->CacheNamedFont(&FName, EPSFilter::ClassOfFont) == ILLEGALFHANDLE))
00808 goto EPSError;
00809
00810 if (!SetTextTypeFace(&FName, EPSFilter::ClassOfFont))
00811 goto EPSError;
00812
00813
00814 EPSFilter::ClassOfFont = FC_TRUETYPE;
00815
00816 break;
00817 }
00818
00819 case EPSC_ctb:
00820 {
00821
00822 INT32 Bold;
00823 if (!Stack.Pop(&Bold))
00824 goto EPSError;
00825
00826 BOOL Boldon = (Bold==1);
00827
00828 if (FontFlags.Bold)
00829 {
00830 if (!SetTextBoldFont(Boldon))
00831 goto EPSError;
00832 }
00833 else
00834 {
00835 if (!SetTextBold(Boldon))
00836 goto EPSError;
00837 }
00838
00839 FontFlags.Bold = FALSE;
00840 break;
00841 }
00842
00843 case EPSC_cti:
00844 {
00845
00846 INT32 Italic;
00847 if (!Stack.Pop(&Italic))
00848 goto EPSError;
00849
00850 BOOL ItalicOn = (Italic==1);
00851
00852 if (FontFlags.Italic)
00853 {
00854 if (!SetTextItalicFont(ItalicOn))
00855 goto EPSError;
00856 }
00857 else
00858 {
00859 if (!SetTextItalic(ItalicOn))
00860 goto EPSError;
00861 }
00862 FontFlags.Italic = FALSE;
00863 break;
00864 }
00865
00866 case EPSC_cts:
00867 {
00868
00869 INT32 rise,ptsize;
00870
00871 if (!Stack.Pop(&ptsize))
00872 goto EPSError;
00873
00874 if (!Stack.Pop(&rise))
00875 goto EPSError;
00876
00877 if (!SetTextScript(rise,ptsize))
00878 goto EPSError;
00879
00880 break;
00881 }
00882
00883
00884 case EPSC_ctp:
00885 {
00886
00887 INT32 ptsize;
00888
00889 if (!Stack.Pop(&ptsize))
00890 goto EPSError;
00891
00892 if (!SetTextSize(ptsize))
00893 goto EPSError;
00894
00895 break;
00896 }
00897
00898 case EPSC_ctls:
00899 {
00900 INT32 type;
00901 if (!Stack.Pop(&type))
00902 goto EPSError;
00903
00904 switch (type)
00905 {
00906 case 0:
00907 {
00908 MILLIPOINT linespace;
00909 if (!Stack.Pop(&linespace))
00910 goto EPSError;
00911
00912 if (!SetTextLineSpacing(1,0,linespace,0))
00913 goto EPSError;
00914 break;
00915 }
00916
00917 case 1:
00918 {
00919 double proportional;
00920 if (!Stack.Pop(&proportional))
00921 goto EPSError;
00922
00923 if (!SetTextLineSpacing(2,0,0,proportional))
00924 goto EPSError;
00925 break;
00926 }
00927 }
00928 break;
00929 }
00930
00931 default:
00932
00933 return CamelotEPSFilter::ProcessToken();
00934 }
00935
00936
00937 return TRUE;
00938
00939
00940 EPSError:
00941 HandleEPSError();
00942 return FALSE;
00943
00944 NoMemory:
00945 HandleNoMemory();
00946 return FALSE;
00947 }
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963 INT32 CamelotNativeEPSFilter::EPSHeaderIsOk(ADDR pFileHeader, UINT32 HeaderSize)
00964 {
00965
00966
00967
00968 if (strncmp((char *) pFileHeader, "%!PS-Adobe-2.0 EPSF-1.2", 23) != 0)
00969 {
00970
00971 return 0;
00972 }
00973
00974
00975 std::istringstream HeaderFile((char *) pFileHeader, ios_base::in );
00976 char Buffer[200];
00977
00978 UINT32 Lines = 0;
00979 while ((Lines < 20) && !HeaderFile.eof())
00980 {
00981 HeaderFile.getline(Buffer, 200);
00982 Lines++;
00983
00984
00985 if (strncmp(Buffer, "%%Creator: Xara Studio (Native)", 31) == 0)
00986 return 10;
00987
00988
00989
00990 if (strncmp(Buffer, "%%Compression:", 14)==0)
00991 break;
00992 }
00993
00994
00995
00996
00997 return 0;
00998 }
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014 BOOL CamelotNativeEPSFilter::PrepareToImport()
01015 {
01016
01017 OldImportWithLayers = Filter::ImportWithLayers;
01018 OldOpenWithLayers = Filter::OpenWithLayers;
01019
01020
01021 #ifndef WEBSTER
01022
01023
01024
01025 if (TheDocument->IsTemplateLoading())
01026 {
01027 ImportWithLayers = TRUE;
01028 OpenWithLayers = TRUE;
01029 }
01030 else
01031 {
01032
01033
01034
01035 if (TheDocument->IsImporting())
01036 {
01037 ERROR2IF(ImportInfo.pSpread == NULL,FALSE,"CamelotNativeEPSFilter::PrepareToImport No spread");
01038 Layer * pFrame = ImportInfo.pSpread->FindFirstFrameLayer();
01039 if (pFrame == NULL)
01040 ImportWithLayers = TRUE;
01041 else
01042 ImportWithLayers = FALSE;
01043 }
01044 else
01045 ImportWithLayers = TRUE;
01046 OpenWithLayers = TRUE;
01047 }
01048 #else
01049
01050 if (TheDocument->IsTemplateLoading())
01051 {
01052 ImportWithLayers = TRUE;
01053 OpenWithLayers = TRUE;
01054 }
01055 else
01056 {
01057 ImportWithLayers = FALSE;
01058 OpenWithLayers = FALSE;
01059 }
01060 #endif // WEBSTER */
01061
01062
01063 FileVersionNumber = 0.0;
01064 BuildVersionNumber = 0.0;
01065
01066
01067 if (!CamelotEPSFilter::PrepareToImport())
01068 return FALSE;
01069
01070
01071 OldMinLineWidth = MinLineWidth;
01072 MinLineWidth = 0;
01073
01074 return TRUE;
01075 }
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091 void CamelotNativeEPSFilter::CleanUpAfterImport(BOOL Successful)
01092 {
01093
01094 CamelotEPSFilter::CleanUpAfterImport(Successful);
01095
01096
01097 MinLineWidth = OldMinLineWidth;
01098
01099
01100
01101 if (BitmapPoolRefs != NULL)
01102 delete [] BitmapPoolRefs;
01103
01104
01105 BitmapPoolRefs = NULL;
01106
01107
01108 ImportWithLayers = OldImportWithLayers;
01109 OpenWithLayers = OldOpenWithLayers;
01110
01111
01112 if (TheDocument && Successful)
01113 {
01114
01115 if (!TheDocument->IsImporting())
01116 TheDocument->SetLoadedAsVersion1File(TRUE);
01117 }
01118 }
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134 void CamelotNativeEPSFilter::BitmapPoolAttach(KernelBitmap* pBitmap)
01135 {
01136
01137 if ((BitmapPoolRefs!=NULL) && (PendingBitmapNum < BitmapCount))
01138 {
01139
01140 BitmapPoolRefs[PendingBitmapNum].Attach(pBitmap, GetDocument());
01141
01142 if (BitmapPoolRefs[PendingBitmapNum].GetBitmap() != pBitmap)
01143 {
01144
01145 delete pBitmap;
01146 }
01147
01148 }
01149 }
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166 BOOL CamelotNativeEPSFilter::ReadBitmap()
01167 {
01168 TRACEUSER( "Rik", _T("ReadBitmap...\n"));
01169
01170 INT32 BitmapType;
01171 if (!Stack.Pop(&BitmapType))
01172 {
01173
01174 HandleEPSError();
01175 return FALSE;
01176 }
01177
01178
01179 if (BitmapType == 0)
01180 {
01181
01182 TRACEUSER( "Rik", _T("Bitmap with data (in the pool I hope)\n"));
01183 Stack.Push(BitmapType);
01184 return CamelotEPSFilter::ReadBitmap();
01185 }
01186
01187
01188 if (BitmapType != 1)
01189 {
01190
01191 HandleEPSError();
01192 return FALSE;
01193 }
01194
01195
01196 INT32 BitmapIndex = 0;
01197
01198
01199 if ((!Stack.Pop(&BitmapIndex)) )
01200 {
01201
01202 HandleEPSError();
01203 return FALSE;
01204 }
01205
01206
01207
01208 if (BitmapIndex >= BitmapCount)
01209 BitmapIndex = (BitmapCount-1);
01210
01211 TRACEUSER( "Rik", _T("Bitmap reference found - refers to bitmap %d\n"), BitmapIndex);
01212
01213
01214 pBitmap = BitmapPoolRefs[BitmapIndex].GetBitmap();
01215 return TRUE;
01216 }
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240 INT32 CamelotNativeEPSFilter::ImportBinary(ADDR pData, INT32 Length)
01241 {
01242
01243 INT32 CountDown = 50;
01244 TCHAR Ch;
01245 do {
01246
01247 if (EPSFile->read(&Ch, 1).fail())
01248 {
01249 HandleEPSError();
01250 return FALSE;
01251 }
01252
01253
01254 CountDown--;
01255 } while ((CountDown>0) && (Ch!='>'));
01256
01257
01258 if (CountDown==0)
01259 {
01260 HandleEPSError();
01261 return FALSE;
01262 }
01263
01264
01265 if (EPSFile->read(pData, Length).fail())
01266 {
01267 HandleEPSError();
01268 return FALSE;
01269 }
01270
01271
01272 if (EPSFile->read(&Ch, 1).fail())
01273 {
01274 HandleEPSError();
01275 return FALSE;
01276 }
01277
01278 if (Ch!='<')
01279 {
01280 HandleEPSError();
01281 return FALSE;
01282 }
01283
01284
01285 INT32 CharsRead = EPSFile->GetCharsRead();
01286 if (CharsRead > (LastProgressUpdate + 2048))
01287 {
01288 if (!ContinueSlowJob(CharsRead))
01289 {
01290
01291 ERROR(_R(IDT_IMPORT_USERABORT), FALSE);
01292 }
01293 else
01294 {
01295 LastProgressUpdate = CharsRead;
01296 }
01297 }
01298
01299
01300 EPSFile->GetLine();
01301 EPSFile->GetCh();
01302
01303
01304 return TRUE;
01305 }
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 BOOL CamelotNativeEPSFilter::ProcessFilterComment()
01320 {
01321
01322 if (camStrncmp(TokenBuf, _T("%%Creator: Xara Studio (Native)"), 31) == 0)
01323 {
01324 return TRUE;
01325 }
01326
01327
01328
01329 if (camStrncmp(TokenBuf, _T("%%File version:"), 15)==0)
01330 {
01331 TCHAR* pVersion = &(((TCHAR*)TokenBuf)[15]);
01332 double Version=0.0;
01333 camSscanf(pVersion, _T("%lf"), &Version);
01334 TRACEUSER( "Neville", _T("Native file version = %f\n"), Version);
01335 FileVersionNumber = Version;
01336
01337 if (Version > ReadNativeVersion)
01338 {
01339 InformWarning(_R(IDW_FILEISWRONGVERSION));
01340
01341 EPSFlags.EPSErrorEncountered = TRUE;
01342
01343 Error::SetError(_R(IDN_USER_CANCELLED), 0);
01344
01345
01346 return TRUE;
01347 }
01348 }
01349
01350
01351
01352 if (camStrncmp(TokenBuf, _T("%%Compression:"), 14)==0)
01353 {
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368 TCHAR* pType = &(((TCHAR*)TokenBuf)[14]);
01369 camSscanf(pType, _T("%d"), &CompressionType);
01370 TRACEUSER( "Neville", _T("CamelotNativeEPSFilter::ProcessFilterComment compression type %d\n"), CompressionType);
01371
01372
01373 BOOL ok = EPSFile->SetCompression(TRUE);
01374 if (!ok)
01375 {
01376
01377
01378 EPSFlags.EPSErrorEncountered = TRUE;
01379
01380
01381 Error::SetError(_R(IDT_EPS_NOMEMORY), 0);
01382
01383 return TRUE;
01384 }
01385
01386 return TRUE;
01387 }
01388 if (camStrncmp(TokenBuf, _T("%%Compression info:"), 19)==0)
01389 {
01390 TCHAR* pVersion = &(((TCHAR*)TokenBuf)[19]);
01391 double CompVersion=0.0;
01392 camSscanf(pVersion, _T("%lf"), &CompVersion);
01393 TRACEUSER( "Neville", _T("Compression version = %f\n"), CompVersion);
01394 double StreamVersion = GZipFile::GetStreamVersionNo();
01395
01396
01397 if (CompVersion > StreamVersion)
01398 {
01399 InformWarning(_R(IDW_FILEISCOMPRESSED));
01400
01401 EPSFlags.EPSErrorEncountered = TRUE;
01402
01403 Error::SetError(_R(IDN_USER_CANCELLED), 0);
01404
01405 return TRUE;
01406 }
01407
01408 return TRUE;
01409 }
01410 if (camStrncmp(TokenBuf, _T("%%EndCompression:"), 17)==0)
01411 {
01412
01413 BOOL ok = EPSFile->SetCompression(FALSE);
01414 if (!ok)
01415 {
01416
01417
01418 EPSFlags.EPSErrorEncountered = TRUE;
01419
01420
01421
01422 return TRUE;
01423 }
01424
01425 return TRUE;
01426 }
01427 if (camStrncmp(TokenBuf, _T("%%EndCompressionInfo:"), 21)==0)
01428 {
01429 return TRUE;
01430 }
01431
01432
01433 if (camStrncmp(TokenBuf, _T("%%BitmapPoolCount"), 17)==0)
01434 {
01435 TCHAR* pCount = &(((TCHAR*)TokenBuf)[17]);
01436 camSscanf(pCount, _T("%d"), &BitmapCount);
01437 TRACEUSER( "Rik", _T("%d\n"), BitmapCount);
01438
01439
01440 if (BitmapCount==0)
01441 return TRUE;
01442
01443
01444 if (BitmapPoolRefs!=NULL)
01445 ERROR3("Bitmap Pool already in use!");
01446
01447
01448 BitmapPoolRefs = new KernelBitmapRef[BitmapCount];
01449 return TRUE;
01450 }
01451
01452
01453 if (camStrncmp(TokenBuf, _T("%%XSScript"), 10)==0)
01454 {
01455 TextComment[0]=2;
01456 return TRUE;
01457 }
01458
01459 return FALSE;
01460 }
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474 EPSExportDC* CamelotNativeEPSFilter::CreateExportDC()
01475 {
01476 #if !defined(EXCLUDE_FROM_RALPH)
01477 return new NativeExportDC(this);
01478 #else
01479 return NULL;
01480 #endif
01481 }
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498 BOOL CamelotNativeEPSFilter::GetExportOptions( )
01499 {
01500
01501 return TRUE;
01502 }
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519 BOOL CamelotNativeEPSFilter::PrepareToExport(CCLexFile* pFile, Spread* pSpread)
01520 {
01521 #if !defined(EXCLUDE_FROM_RALPH)
01522
01523 if (!CamelotEPSFilter::PrepareToExport(pFile, pSpread)) return FALSE;
01524
01525
01526
01527 if (IS_A(this, CamelotNativeEPSFilter))
01528 {
01529
01530 DocRect NullClipRect;
01531 NullClipRect.MakeEmpty();
01532
01533
01534 Matrix Identity;
01535
01536
01537 FIXED16 Scale(1);
01538
01539
01540 ExportRegion = new NativeRenderRegion(NullClipRect, Identity, Scale);
01541 if (ExportRegion == NULL) return FALSE;
01542
01543
01544 DocView * pDocView = TheDocument->GetFirstDocView();
01545
01546 if ((!pDocView) || (!pDocView->IsKindOf(CC_RUNTIME_CLASS(DocView))))
01547 pDocView = DocView::GetSelected();
01548
01549
01550 ExportRegion->AttachDevice(pDocView, ExportDCPtr->GetDC(), pSpread);
01551 }
01552 #endif
01553
01554 return TRUE;
01555 }
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577 BOOL CamelotNativeEPSFilter::ExportBitmap(KernelBitmap& TheBitmap)
01578 {
01579 #if !defined(EXCLUDE_FROM_RALPH)
01580
01581 if (IsSavingBitmapPool)
01582 {
01583 TRACEUSER( "Rik", _T("In the bitmap pool, so saving out real data\n"));
01584 return CamelotEPSFilter::ExportBitmap(TheBitmap);
01585 }
01586
01587
01588 TRACEUSER( "Rik", _T("Trying to save a reference to a bitmap\n"));
01589
01590
01591
01592 Document* pDoc = GetDocument();
01593 if (pDoc==NULL)
01594 return FALSE;
01595
01596
01597 DocComponent* DocBitmapList = pDoc->GetDocComponent(CC_RUNTIME_CLASS(BitmapListComponent));
01598 if (DocBitmapList==NULL)
01599 return FALSE;
01600
01601 ExportedBitmaps* pBitmapExportPool = ((BitmapListComponent*)DocBitmapList)->GetBitmapExportPool();
01602 ERROR3IF(pBitmapExportPool == NULL, "No BitmapExportPool in CamelotNativeEPSFilter::ExportBitmap");
01603 if (pBitmapExportPool==NULL)
01604 return FALSE;
01605
01606 INT32 BitmapPoolNum = -1;
01607
01608
01609 class ExportBitmap* pExportBitmap = pBitmapExportPool->GetBitmap(&TheBitmap);
01610
01611
01612 ERROR3IF(pExportBitmap == NULL, "Couldn't find the bitmap in the pool in CamelotNativeEPSFilter::ExportBitmap");
01613
01614 if (pExportBitmap)
01615 {
01616 BitmapPoolNum = pExportBitmap->RecordNumber;
01617 }
01618
01619
01620 if (BitmapPoolNum >= 0)
01621 {
01622
01623 ExportDCPtr->OutputValue((UINT32) BitmapPoolNum);
01624
01625
01626 ExportDCPtr->OutputToken(_T("1"));
01627
01628
01629 ExportDCPtr->OutputToken(_T("csbm"));
01630 ExportDCPtr->OutputNewLine();
01631
01632
01633 ExportDCPtr->OutputToken(_T("cebm"));
01634 ExportDCPtr->OutputNewLine();
01635
01636
01637 return TRUE;
01638 }
01639 #endif
01640
01641 return FALSE;
01642 }
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658 BitmapFilterSupport CamelotNativeEPSFilter::GetBitmapSupportLevel()
01659 {
01660 return IndirectedBitmapSupport;
01661 }
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677 double CamelotNativeEPSFilter::SmartGetBuildNumber()
01678 {
01679 double BuildNumber = GetBuildNumber();
01680 if (BuildNumber==1.00)
01681 BuildNumber = 0.586;
01682 return BuildNumber;
01683 }
01684
01685 #if !defined(EXCLUDE_FROM_RALPH)
01686
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704 NativeRenderRegion::NativeRenderRegion(DocRect ClipRect, Matrix ConvertMatrix, FIXED16 ViewScale) :
01705 CamelotEPSRenderRegion(ClipRect, ConvertMatrix, ViewScale)
01706 {
01707 CreatorString = _T("Xara Studio (Native) ") CAMELOT_VERSION_STRING;
01708
01709
01710 CompressionInitedOk = FALSE;
01711 }
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726 void NativeRenderRegion::ConditionalSuicide ( void )
01727 {
01728
01729 delete this;
01730 }
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746 void NativeRenderRegion::GetRenderRegionCaps(RRCaps* pCaps)
01747 {
01748
01749 pCaps->CanDoAll();
01750 }
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769 BOOL NativeRenderRegion::WriteProlog(KernelDC *pDC)
01770 {
01771
01772 return TRUE;
01773 }
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791 BOOL NativeRenderRegion::WriteSetup(KernelDC *pDC)
01792 {
01793
01794 return TRUE;
01795 }
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810 void NativeRenderRegion::GetValidPathAttributes()
01811 {
01812 KernelDC *pDC = (KernelDC*)CCDC::ConvertFromNativeDC(RenderDC);
01813
01814
01815 RRCaps Caps;
01816 GetRenderRegionCaps(&Caps);
01817
01818 if (SetLastOutputAttribute(ATTR_STARTARROW))
01819 {
01820
01821 StartArrowAttribute *pArrow =
01822 (StartArrowAttribute *) CurrentAttrs[ATTR_STARTARROW].pAttr;
01823
01824 TRACEUSER( "Will", _T("Outputing Start Arrow, ID=%d\n"),pArrow->StartArrow.GetArrowID());
01825
01826 if (pArrow->StartArrow.GetArrowID() >= 0)
01827 {
01828 pDC->OutputValue((INT32)pArrow->StartArrow.GetArrowID());
01829 pDC->OutputReal((pArrow->StartArrow.GetArrowWidth()).MakeDouble());
01830 pDC->OutputReal((pArrow->StartArrow.GetArrowHeight()).MakeDouble());
01831
01832 pDC->OutputToken(_T("csah"));
01833 pDC->OutputNewLine();
01834 }
01835 }
01836
01837 if (SetLastOutputAttribute(ATTR_ENDARROW))
01838 {
01839
01840 EndArrowAttribute *pArrow =
01841 (EndArrowAttribute *) CurrentAttrs[ATTR_ENDARROW].pAttr;
01842
01843 TRACEUSER( "Will", _T("Outputing End Arrow, ID=%d\n"),pArrow->EndArrow.GetArrowID());
01844
01845 if (pArrow->EndArrow.GetArrowID() >= 0)
01846 {
01847 pDC->OutputValue((INT32)pArrow->EndArrow.GetArrowID());
01848 pDC->OutputReal((pArrow->EndArrow.GetArrowWidth()).MakeDouble());
01849 pDC->OutputReal((pArrow->EndArrow.GetArrowHeight()).MakeDouble());
01850
01851 pDC->OutputToken(_T("ceah"));
01852 pDC->OutputNewLine();
01853 }
01854 }
01855
01856 if (SetLastOutputAttribute(ATTR_DASHPATTERN))
01857 {
01858
01859 DashPatternAttribute *pDash =
01860 (DashPatternAttribute *) CurrentAttrs[ATTR_DASHPATTERN].pAttr;
01861
01862 TRACEUSER( "Will", _T("Outputing Dash Pattern, ID=%d\n"),pDash->DashPattern.GetDashID());
01863
01864 pDC->OutputValue((INT32)pDash->DashPattern.GetDashID());
01865 pDC->OutputToken(_T("cdp"));
01866 pDC->OutputNewLine();
01867 }
01868
01869
01870 GetValidTransparencyAttributes();
01871
01872
01873 CamelotEPSRenderRegion::GetValidPathAttributes();
01874 }
01875
01876
01877 void NativeRenderRegion::GetValidTransparencyAttributes()
01878 {
01879
01880 RRCaps Caps;
01881 GetRenderRegionCaps(&Caps);
01882
01883
01884 if (!Caps.Transparency)
01885
01886 return;
01887
01888 KernelDC *pDC = (KernelDC*)CCDC::ConvertFromNativeDC(RenderDC);
01889
01890 if (SetLastOutputAttribute(ATTR_STROKETRANSP))
01891 {
01892
01893 StrokeTranspAttribute *pAttr =
01894 (StrokeTranspAttribute *) CurrentAttrs[ATTR_STROKETRANSP].pAttr;
01895
01896 UINT32 Transp = *pAttr->GetStartTransp();
01897 UINT32 TranspType = pAttr->GetTranspType();
01898
01899 TRACEUSER( "Will", _T("Outputing Line transp, Val=%d, Type=%d\n"),Transp, TranspType);
01900
01901
01902 pDC->OutputValue((UINT32) Transp);
01903
01904 pDC->OutputValue((UINT32) TranspType);
01905
01906 pDC->OutputToken(_T("cst"));
01907 pDC->OutputNewLine();
01908 }
01909
01910 if (SetLastOutputAttribute(ATTR_TRANSPFILLGEOMETRY))
01911 {
01912
01913 TranspFillAttribute *pFillAttr =
01914 (TranspFillAttribute *) CurrentAttrs[ATTR_TRANSPFILLGEOMETRY].pAttr;
01915
01916
01917 UINT32 *StartTransp,
01918 *EndTransp,
01919 TranspType,
01920 FillType = TRANSPFILL_NONE;
01921
01922 TranspType = pFillAttr->GetTranspType();
01923 ENSURE((TranspType >= 1) && (TranspType <= 3), "Bad transparency type!");
01924
01925 StartTransp = pFillAttr->GetStartTransp();
01926 ENSURE((StartTransp == NULL) || ((*StartTransp >= 0) && (*StartTransp <= 255)),
01927 "Bad start transparency level!");
01928
01929
01930 if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(FlatTranspFillAttribute)))
01931 {
01932
01933 if (((*StartTransp) != 0) || (TranspType != TT_Mix))
01934 FillType = TRANSPFILL_FLAT;
01935 }
01936 else if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(GradTranspFillAttribute)) &&
01937 !pFillAttr->IsKindOf(CC_RUNTIME_CLASS(BitmapTranspFillAttribute)) )
01938 {
01939
01940 DocCoord *Point;
01941 Point = pFillAttr->GetStartPoint();
01942 pDC->OutputCoord(*Point);
01943 Point = pFillAttr->GetEndPoint();
01944 pDC->OutputCoord(*Point);
01945
01946
01947 if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(LinearTranspFillAttribute)))
01948 {
01949 DocCoord* Start = pFillAttr->GetStartPoint();
01950 DocCoord* End = pFillAttr->GetEndPoint();
01951 DocCoord* End2 = pFillAttr->GetEndPoint2();
01952
01953 if (AreLinesPerpendicular(Start, End, End2))
01954 {
01955 TRACEUSER( "Will", _T("Exporting Simple Transp Linear Fill\n"));
01956 FillType = TRANSPFILL_LINEAR;
01957 }
01958 else
01959 {
01960 TRACEUSER( "Will", _T("Exporting New Style Transp Linear Fill\n"));
01961 pDC->OutputCoord(*pFillAttr->GetEndPoint2());
01962 FillType = TRANSPFILL_NEWLINEAR;
01963 }
01964 }
01965 else if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(RadialTranspFillAttribute)))
01966 {
01967
01968 RadialTranspFillAttribute *pRadialFillAttr =
01969 (RadialTranspFillAttribute *) pFillAttr;
01970
01971 if (pRadialFillAttr->IsElliptical())
01972 {
01973
01974 Point = pRadialFillAttr->GetEndPoint2();
01975 pDC->OutputCoord(*Point);
01976 FillType = TRANSPFILL_ELLIPTICAL;
01977 }
01978 else
01979 {
01980
01981 FillType = TRANSPFILL_CIRCULAR;
01982 }
01983 }
01984 else if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(ConicalTranspFillAttribute)))
01985 {
01986 FillType = TRANSPFILL_CONICAL;
01987 }
01988 else
01989 {
01990
01991 ERROR3("Unsupported grad fill encountered while exporting");
01992 EPSRenderRegion::GetValidPathAttributes();
01993 return;
01994 }
01995
01996 }
01997 else if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(FractalTranspFillAttribute)) &&
01998 Caps.BitmapFills)
01999 {
02000
02001 FractalTranspFillAttribute *pFractalFill = (FractalTranspFillAttribute *) pFillAttr;
02002
02003
02004 pDC->OutputCoord(pFractalFill->StartPoint);
02005 pDC->OutputCoord(pFractalFill->EndPoint);
02006 pDC->OutputCoord(pFractalFill->EndPoint2);
02007
02008
02009 pDC->OutputValue(pFractalFill->Seed);
02010 pDC->OutputReal(pFractalFill->Graininess.MakeDouble());
02011 pDC->OutputReal(pFractalFill->Gravity.MakeDouble());
02012 pDC->OutputReal(pFractalFill->Squash.MakeDouble());
02013
02014
02015 UINT32 DPI = pFractalFill->GetFractalDPI();
02016 pDC->OutputValue(DPI);
02017
02018
02019 pDC->OutputValue((INT32) (pFractalFill->GetTileable()));
02020
02021
02022 pDC->OutputToken(_T("1"));
02023
02024 TRACEUSER( "Will", _T("Exporting new fractal transp\n"));
02025
02026
02027 FillType = TRANSPFILL_NEWFRACTAL;
02028 }
02029 else if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(NoiseTranspFillAttribute)))
02030 {
02031 FillType = TRANSPFILL_NONE;
02032 }
02033 else if (pFillAttr->IsKindOf(CC_RUNTIME_CLASS(BitmapTranspFillAttribute)) &&
02034 Caps.BitmapFills)
02035 {
02036
02037
02038
02039
02040 DocCoord *Point;
02041 Point = pFillAttr->GetStartPoint();
02042 pDC->OutputCoord(*Point);
02043 Point = pFillAttr->GetEndPoint();
02044 pDC->OutputCoord(*Point);
02045 Point = pFillAttr->GetEndPoint2();
02046 pDC->OutputCoord(*Point);
02047
02048 TRACEUSER( "Will", _T("Exporting new bitmap transp\n"));
02049
02050
02051 FillType = TRANSPFILL_NEWTEXTURE;
02052 }
02053 else
02054 {
02055 ERROR3("Illegal transparency fill type!");
02056 }
02057
02058
02059 if (FillType != TRANSPFILL_NONE)
02060 {
02061 if ((FillType != TRANSPFILL_TEXTURE) && (FillType != TRANSPFILL_FRACTAL))
02062 {
02063
02064 pDC->OutputValue((UINT32) (*StartTransp));
02065
02066
02067 switch (FillType)
02068 {
02069 case TRANSPFILL_LINEAR:
02070 case TRANSPFILL_ELLIPTICAL:
02071 case TRANSPFILL_CIRCULAR:
02072 case TRANSPFILL_CONICAL:
02073 case TRANSPFILL_NEWLINEAR:
02074 case TRANSPFILL_NEWTEXTURE:
02075 case TRANSPFILL_NEWFRACTAL:
02076 EndTransp = pFillAttr->GetEndTransp();
02077 ENSURE((*EndTransp >= 0) && (*EndTransp <= 255),
02078 "Bad end transparency level!");
02079 pDC->OutputValue((UINT32) (*EndTransp));
02080 break;
02081
02082 default:
02083
02084 break;
02085 }
02086 }
02087
02088
02089 pDC->OutputValue((UINT32) TranspType);
02090
02091 }
02092
02093
02094 pDC->OutputValue((UINT32) FillType);
02095
02096
02097 pDC->OutputToken(_T("cxt"));
02098 pDC->OutputNewLine();
02099
02100
02101 if ((FillType == TRANSPFILL_TEXTURE || FillType == TRANSPFILL_NEWTEXTURE) &&
02102 Caps.BitmapFills)
02103 {
02104 BitmapTranspFillAttribute *pBitmapFill = (BitmapTranspFillAttribute *) pFillAttr;
02105 ExportDC *pExportDC = (ExportDC *) pDC;
02106
02107 if (pBitmapFill->GetBitmap())
02108 pExportDC->GetParentFilter()->ExportBitmap(*pBitmapFill->GetBitmap());
02109 }
02110 }
02111
02112 if (SetLastOutputAttribute(ATTR_TRANSPFILLMAPPING))
02113 {
02114
02115 TranspFillMappingAttribute *pFillAttr =
02116 (TranspFillMappingAttribute *) CurrentAttrs[ATTR_TRANSPFILLMAPPING].pAttr;
02117
02118
02119 INT32 MappingType = pFillAttr->Repeat;
02120 ERROR3IF((MappingType < 1) || (MappingType > 3), "Illegal fill mapping value!");
02121
02122
02123 pDC->OutputValue((UINT32) MappingType);
02124
02125
02126 pDC->OutputToken(_T("0"));
02127
02128
02129 pDC->OutputToken(_T("cxmt"));
02130 pDC->OutputNewLine();
02131 }
02132 }
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148 void NativeRenderRegion::GetValidTextAttributes()
02149 {
02150 KernelDC *pDC = (KernelDC*)CCDC::ConvertFromNativeDC(RenderDC);
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164 if (SetLastOutputAttribute(ATTR_TXTFONTTYPEFACE))
02165 {
02166 TxtFontTypefaceAttribute* pFontAttr = (TxtFontTypefaceAttribute*)CurrentAttrs[ATTR_TXTFONTTYPEFACE].pAttr;
02167 if (pFontAttr)
02168 {
02169 String_64 OutputFont;
02170 FontClass Class;
02171
02172 CachedFontItem* pItem = FONTMANAGER->GetCachedFont(pFontAttr->HTypeface);
02173 ERROR3IF(pItem==NULL,"Cannot find the cached font in GetValidTextAttributes");
02174 OutputFont = *(pItem->GetFontName());
02175 Class = pItem->GetFontClass();
02176
02177
02178
02179
02180
02181 if (Class!=FC_TRUETYPE)
02182 {
02183 pDC->OutputValue((INT32)EOTAG_FONTTYPE);
02184 pDC->OutputToken(_T("cso"));
02185 pDC->OutputValue((INT32)Class);
02186 pDC->OutputToken(_T("cftf"));
02187 pDC->OutputToken(_T("ceo"));
02188 pDC->OutputNewLine();
02189 }
02190
02191 FONTMANAGER->GetFontName(pFontAttr->HTypeface, OutputFont);
02192 OutputFont.SwapChar(' ','-');
02193
02194 pDC->OutputToken((TCHAR *)OutputFont);
02195 pDC->OutputToken(_T("ctf"));
02196 pDC->OutputNewLine();
02197
02198 if ((pFontAttr->IsBold) || (pFontAttr->IsItalic))
02199 {
02200
02201
02202 pDC->OutputValue((INT32)EOTAG_FONTFLAGS);
02203 pDC->OutputToken(_T("cso"));
02204 pDC->OutputNewLine();
02205 pDC->OutputToken(_T("cfft"));
02206 pDC->OutputNewLine();
02207 pDC->OutputToken(_T("ceo"));
02208 pDC->OutputNewLine();
02209
02210 pDC->OutputValue((INT32) pFontAttr->IsBold);
02211 pDC->OutputToken(_T("ctb"));
02212 pDC->OutputNewLine();
02213
02214 pDC->OutputValue((INT32) pFontAttr->IsItalic);
02215 pDC->OutputToken(_T("cti"));
02216 pDC->OutputNewLine();
02217 }
02218 }
02219 }
02220
02221 if (SetLastOutputAttribute(ATTR_TXTFONTSIZE))
02222 {
02223
02224 pDC->OutputValue(RR_TXTFONTSIZE());
02225 pDC->OutputToken(_T("ctp"));
02226 pDC->OutputNewLine();
02227 }
02228
02229 if (SetLastOutputAttribute(ATTR_TXTBOLD))
02230 {
02231
02232 BOOL Bold = ( (TxtBoldAttribute*)(CurrentAttrs[ATTR_TXTBOLD].pAttr) )->BoldOn;
02233 pDC->OutputValue((INT32)Bold);
02234 pDC->OutputToken(_T("ctb"));
02235 pDC->OutputNewLine();
02236 }
02237
02238 if (SetLastOutputAttribute(ATTR_TXTITALIC))
02239 {
02240
02241 BOOL Italic = ( (TxtItalicAttribute*)(CurrentAttrs[ATTR_TXTITALIC].pAttr) )->ItalicOn;
02242 pDC->OutputValue((INT32)Italic);
02243 pDC->OutputToken(_T("cti"));
02244 pDC->OutputNewLine();
02245 }
02246
02247 if (SetLastOutputAttribute(ATTR_TXTSCRIPT))
02248 {
02249 TxtScriptAttribute* pScript = RR_TXTSCRIPT();
02250
02251 double FontSize = (double)RR_TXTFONTSIZE();
02252 double offset = (pScript->Offset).MakeDouble();
02253 double size = (pScript->Size).MakeDouble();
02254
02255 MILLIPOINT rise = (MILLIPOINT)(FontSize*offset);
02256 MILLIPOINT ptsize = (MILLIPOINT)(FontSize*size);
02257 pDC->OutputValue(rise);
02258 pDC->OutputValue(ptsize);
02259 pDC->OutputToken(_T("cts"));
02260 pDC->OutputNewLine();
02261 }
02262
02263
02264 if (SetLastOutputAttribute(ATTR_TXTLINESPACE))
02265 {
02266 TxtLineSpaceAttribute* pLineSpace = (TxtLineSpaceAttribute*)(CurrentAttrs[ATTR_TXTLINESPACE].pAttr);
02267
02268
02269
02270
02271
02272
02273
02274
02275 if (!pLineSpace->IsARatio())
02276 {
02277 INT32 LineSpace = pLineSpace->Value;
02278 ERROR3IF(LineSpace==0, "Absolute line spacing is zero yet IsARatio() is FALSE, in GetValidTextAttributes()");
02279 pDC->OutputValue(LineSpace);
02280 pDC->OutputValue((INT32)0);
02281 }
02282 else
02283 {
02284 double Ratio = (pLineSpace->Ratio).MakeDouble();
02285 pDC->OutputFloat(Ratio,4);
02286 pDC->OutputValue((INT32)1);
02287 }
02288
02289 pDC->OutputToken(_T("ctls"));
02290 pDC->OutputNewLine();
02291 }
02292
02293
02294
02295 EPSRenderRegion::GetValidTextAttributes();
02296 }
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312 BOOL NativeRenderRegion::RenderChar(WCHAR ch, Matrix* pMatrix)
02313 {
02314
02315 if ((!RenderComplexShapes) && (TestForComplexShape(&Caps)))
02316 return TRUE;
02317
02318 ERROR2IF( this==NULL,FALSE,"RenderRegion::RenderChar() - this==NULL");
02319 ERROR2IF(pMatrix==NULL,FALSE,"RenderRegion::RenderChar() - pMatrix==NULL");
02320
02321 #if EXPORT_TEXT
02322
02323 GetValidPathAttributes();
02324 GetValidTextAttributes();
02325
02326 KernelDC *pDC = (KernelDC*)CCDC::ConvertFromNativeDC(RenderDC);
02327
02328 INT32 CharOut = (INT32)ch;
02329 INT32 NumCodes = 1;
02330 pDC->OutputValue(CharOut);
02331 pDC->OutputValue(NumCodes);
02332 pDC->OutputToken(_T("ctx"));
02333 pDC->OutputNewLine();
02334
02335 #else
02336
02337
02338
02339 Path* pCharPath=CreateCharPath(ch,pMatrix);
02340 if (pCharPath==NULL)
02341 return FALSE;
02342
02343
02344 if (pCharPath->GetNumCoords()!=0)
02345 DrawPath(pCharPath);
02346
02347
02348 delete pCharPath;
02349 #endif
02350
02351 return TRUE;
02352 }
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371 BOOL NativeRenderRegion::WriteFileVersion(KernelDC *pDC)
02372 {
02373
02374 TCHAR buf[50];
02375
02376
02377 camSprintf(buf, _T("%%%%File version: %.2f"), WriteNativeVersion);
02378 pDC->OutputToken(buf);
02379 pDC->OutputNewLine();
02380
02381 return TRUE;
02382 }
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399
02400
02401 BOOL NativeRenderRegion::WriteCompressionState(KernelDC *pDC)
02402 {
02403 TRACEUSER( "Neville", _T("WriteCompressionState\n"));
02404
02405
02406 if (CamelotNativeEPSFilter::GetNativeCompression())
02407 {
02408
02409 EPSExportDC *pEPSDC = (EPSExportDC *) pDC;
02410 if (pEPSDC == NULL || ExportFile == NULL)
02411 return FALSE;
02412
02413
02414 BOOL Ok = pEPSDC->ExportFile->InitCompression();
02415
02416 if (!Ok)
02417 {
02418
02419
02420 CompressionInitedOk = FALSE;
02421
02422 return FALSE;
02423 }
02424
02425
02426
02427 CompressionInitedOk = TRUE;
02428
02429
02430 pDC->OutputToken(_T("%%Compression: "));
02431
02432 pDC->OutputToken(_T("0 "));
02433 pDC->OutputNewLine();
02434
02435 pDC->OutputToken(_T("%%Compression info:"));
02436
02437
02438
02439
02440
02441 double StreamVersion = GZipFile::GetStreamVersionNo();
02442 TCHAR buf[300];
02443 camSprintf(buf, _T(" %.2fD"), StreamVersion);
02444 pDC->OutputToken(buf);
02445 TRACEUSER( "Neville", _T("WriteCompressionState wrote version %.2f\n"),StreamVersion);
02446 pDC->OutputNewLine();
02447
02448
02449
02450
02451 pEPSDC->ExportFile->SetCompression(TRUE);
02452 }
02453
02454 return TRUE;
02455 }
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475 BOOL NativeRenderRegion::WriteEndCompressionState(KernelDC* pDC)
02476 {
02477 TRACEUSER( "Neville", _T("WriteEndCompressionState\n"));
02478
02479
02480
02481 if (CamelotNativeEPSFilter::GetNativeCompression() && CompressionInitedOk)
02482 {
02483
02484 pDC->OutputToken(_T("%%EndCompression: "));
02485 pDC->OutputNewLine();
02486
02487 pDC->OutputToken(_T("%%EndCompressionInfo: "));
02488 pDC->OutputNewLine();
02489
02490
02491
02492
02493
02494 EPSExportDC *pEPSDC = (EPSExportDC *) pDC;
02495 if (pEPSDC && ExportFile)
02496 pEPSDC->ExportFile->SetCompression(FALSE);
02497 }
02498
02499 return TRUE;
02500 }
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521 BOOL NativeRenderRegion::WantsGrids()
02522 {
02523 return TRUE;
02524 }
02525
02526
02527
02528
02529
02530
02531
02532
02533
02534
02535
02536
02537
02538
02539 void NativeRenderRegion::OutputFillColour ()
02540 {
02541 OutputFillCMYKColour ();
02542 }
02543
02544
02545
02546
02547
02548
02549
02550
02551
02552
02553
02554
02555
02556
02557 void NativeRenderRegion::OutputStrokeColour ()
02558 {
02559 OutputStrokeCMYKColour ();
02560 }
02561
02562
02563
02564
02565
02566
02567
02568
02569
02570
02571
02572
02573
02574
02575
02576 BOOL NativeRenderRegion::OutputGradFillColours(DocColour* StartCol, DocColour* EndCol, ColourContext* pContext)
02577 {
02578 KernelDC *pDC = (KernelDC*)CCDC::ConvertFromNativeDC(RenderDC);
02579 bool outputNames = FALSE;
02580
02581 if ((StartCol->FindParentIndexedColour() == NULL) &&
02582 (EndCol->FindParentIndexedColour() == NULL))
02583 {
02584
02585 outputNames = FALSE;
02586 }
02587 else
02588 {
02589
02590 outputNames = TRUE;
02591 }
02592
02593
02594 PColourCMYK CMYK;
02595
02596
02597 StartCol->GetCMYKValue (pContext, &CMYK);
02598 pDC->OutputColour (&CMYK);
02599
02600 if (outputNames)
02601 {
02602
02603 pDC->OutputColourName (StartCol);
02604
02605
02606
02607 pDC->OutputValue ((INT32)0);
02608 }
02609
02610
02611 EndCol->GetCMYKValue (pContext, &CMYK);
02612 pDC->OutputColour (&CMYK);
02613
02614 if (outputNames)
02615 {
02616
02617 pDC->OutputColourName (EndCol);
02618
02619
02620
02621 pDC->OutputValue ((INT32)0);
02622 }
02623
02624
02625 return (!outputNames);
02626 }
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636
02637
02638
02639
02640
02641
02642
02643 NativeExportDC::NativeExportDC(Filter* pFilter) : EPSExportDC(pFilter)
02644 {
02645 }
02646
02647
02648
02649
02650
02651
02652
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662
02663
02664
02665
02666
02667
02668 INT32 NativeExportDC::OutputRawBinary(BYTE* Data, UINT32 Length, UINT32 Alignment)
02669 {
02670
02671 INT32 nBytes = 0;
02672
02673
02674 if (!OutputNewLine())
02675
02676 return -1;
02677
02678
02679
02680
02681
02682 static TCHAR Begin = _T('>');
02683 if (!OutputTCHARAsChar(&Begin, 1))
02684
02685 return -1;
02686
02687
02688 if (!OutputDirect(Data, Length))
02689 {
02690
02691 return -1;
02692 }
02693
02694
02695 nBytes += Length;
02696
02697
02698 ENSURE(Alignment != 0, "Bad alignment in OutputRawBinary!");
02699 UINT32 Padding = Alignment - (Length % Alignment);
02700 if (Padding == Alignment)
02701 Padding = 0;
02702
02703 if (Padding > 0)
02704 {
02705
02706 TCHAR Buffer[2];
02707 Buffer[0] = 0;
02708 Buffer[1] = 0;
02709
02710
02711 while (Padding > 0)
02712 {
02713 if (OutputTCHARAsChar(Buffer, 1))
02714
02715 return -1;
02716
02717 nBytes++;
02718 Padding--;
02719 }
02720 }
02721
02722
02723 static TCHAR End = _T('<');
02724 if (!OutputTCHARAsChar(&End, 1))
02725
02726 return -1;
02727
02728
02729
02730
02731
02732 return nBytes;
02733 }
02734
02735 #endif // EXCLUDE_FROM_RALPH