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
00104 #include "camtypes.h"
00105
00106 #include "princomp.h"
00107
00108
00109
00110 #include "colourix.h"
00111
00112
00113 #include "cxftags.h"
00114
00115 #include "printctl.h"
00116 #include "saveeps.h"
00117
00118 DECLARE_SOURCE("$Revision: 1328 $");
00119
00120
00121 CC_IMPLEMENT_DYNAMIC(PrintComponentClass, DocComponentClass)
00122 CC_IMPLEMENT_DYNAMIC(PrintComponent, DocComponent)
00123
00124
00125 #define new CAM_DEBUG_NEW
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 BOOL PrintComponentClass::Init()
00145 {
00146
00147 PrintComponentClass *pClass = new PrintComponentClass;
00148 if (pClass == NULL)
00149 return FALSE;
00150
00151
00152 GetApplication()->RegisterDocComponent(pClass);
00153
00154 if (Camelot.DeclareSection(_T("Printing"),1))
00155 Camelot.DeclarePref(_T("Printing"), _T("AppPrintMethod"), (INT32*)(&PrintControl::AppPrintMethod));
00156
00157
00158 return TRUE;
00159 }
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 BOOL PrintComponentClass::AddComponent(BaseDocument *pDocument)
00178 {
00179
00180 if (pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent)) != NULL)
00181 return TRUE;
00182
00183
00184
00185
00186 PrintControl *pPrCtrl = new PrintControl();
00187 if(pPrCtrl == NULL)
00188 return FALSE;
00189
00190
00191 PrintComponent *pComponent = new PrintComponent(pPrCtrl);
00192 if (pComponent == NULL)
00193 {
00194
00195 delete pPrCtrl;
00196 return FALSE;
00197 }
00198
00199
00200 pDocument->AddDocComponent(pComponent);
00201
00202 return TRUE;
00203 }
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 PrintComponent::PrintComponent()
00225 {
00226 ERROR3("PrintComponent constructed with default constructor!?\n");
00227 pPrCtrl = NULL;
00228 pExportDC = NULL;
00229 }
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 PrintComponent::PrintComponent(PrintControl *pThisPrCtrl)
00247 {
00248 ERROR3IF(pThisPrCtrl == NULL, "NULL print control object in print component constructor!");
00249
00250
00251 pPrCtrl = pThisPrCtrl;
00252 pExportDC = NULL;
00253 }
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 PrintComponent::~PrintComponent()
00268 {
00269
00270 if (pPrCtrl != NULL)
00271 {
00272 delete pPrCtrl;
00273 pPrCtrl = NULL;
00274 }
00275 }
00276
00277
00278
00279
00280
00281
00282 #define PC_SECTION_VERSION 1
00283
00284 static TCHAR *PCTokenStr[] =
00285 {
00286 _T("%%PrintControl"),
00287 _T("%%+WholeSpread"),
00288 _T("%%+Scale"),
00289 _T("%%+Orientation"),
00290 _T("%%+FitType"),
00291 _T("%%+TopMargin"),
00292 _T("%%+LeftMargin"),
00293 _T("%%+Width"),
00294 _T("%%+Height"),
00295 _T("%%+Rows"),
00296 _T("%%+Columns"),
00297 _T("%%+Gutter"),
00298 _T("%%+Layers"),
00299 _T("%%+PSLevel"),
00300 _T("%%+PrintMethod"),
00301 _T("%%+BitmapResMethod"),
00302 _T("%%+DotsPerInch"),
00303 _T("%%+Collated"),
00304 _T("%%+NumCopies"),
00305 _T("%%+PrintToFile"),
00306 _T("%%+ObjPrintRange"),
00307 _T("%%+DPSPrintRange"),
00308 _T("%%+AllTextAsShapes")
00309 };
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324 PCToken PrintComponent::GetToken(const char* pComment)
00325 {
00326 UINT32 i;
00327
00328 for (i=0;!camIsspace(pComment[i]) && i < PC_BUFFERSIZE;i++)
00329 Buffer[i] = pComment[i];
00330
00331 if (i >= PC_BUFFERSIZE)
00332 i=0;
00333
00334 Buffer[i] = '\0';
00335
00336 for (i=0;i < PCTOKEN_UNKNOWN;i++)
00337 {
00338 if (camStrcmp(PCTokenStr[i],Buffer) == 0)
00339 return (PCToken)i;
00340 }
00341
00342 return PCTOKEN_UNKNOWN;
00343 }
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359 void PrintComponent::ExtractTokenValStr(const char* pComment)
00360 {
00361 Buffer[0] = '\0';
00362
00363 if (pComment != NULL)
00364 {
00365 UINT32 i=0;
00366
00367
00368 while (!camIsspace(pComment[i]) && !camIscntrl(pComment[i]))
00369 i++;
00370
00371
00372 while (camIsspace(pComment[i]))
00373 i++;
00374
00375
00376 UINT32 j=0;
00377 while (camIsprint(pComment[i]) && j < PC_BUFFERSIZE)
00378 Buffer[j++] = pComment[i++];
00379
00380 if (j >= PC_BUFFERSIZE)
00381 j=0;
00382
00383 Buffer[j] = '\0';
00384 }
00385 }
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400 INT32 PrintComponent::GetTokenValINT32(const char* pComment)
00401 {
00402 ExtractTokenValStr(pComment);
00403
00404 INT32 n = 0;
00405 camSscanf( Buffer, _T("%ld"), &n );
00406
00407 return n;
00408 }
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424 FIXED16 PrintComponent::GetTokenValFIXED16(const char* pComment)
00425 {
00426 ExtractTokenValStr(pComment);
00427
00428 double n = 0.0;
00429 camSscanf( Buffer, _T("%le"), &n );
00430
00431 if (n > double(0x7fff))
00432 n = double(0x7fff);
00433
00434 if (n < double(-0x8000))
00435 n = double(-0x8000);
00436
00437 return FIXED16(n);
00438 }
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456 BOOL PrintComponent::OutputValue(UINT32 Token,INT32 Value)
00457 {
00458 ERROR2IF(pExportDC == NULL,FALSE,"NULL export DC in PrintComponent::OutputValue()");
00459 ERROR2IF(Token >= PCTOKEN_UNKNOWN,FALSE,"Token out of range");
00460
00461 BOOL ok = TRUE;
00462
00463 if (ok) ok = pExportDC->OutputToken(PCTokenStr[Token]);
00464 if (ok) ok = pExportDC->OutputValue(Value);
00465 if (ok) ok = pExportDC->OutputNewLine();
00466
00467 return ok;
00468 }
00469
00470
00471 BOOL PrintComponent::OutputValue(UINT32 Token,FIXED16 Value)
00472 {
00473 ERROR2IF(pExportDC == NULL,FALSE,"NULL export DC in PrintComponent::OutputValue()");
00474 ERROR2IF(Token >= PCTOKEN_UNKNOWN,FALSE,"Token out of range");
00475
00476 BOOL ok = TRUE;
00477
00478 if (ok) ok = pExportDC->OutputToken(PCTokenStr[Token]);
00479 if (ok) ok = pExportDC->OutputReal(Value.MakeDouble());
00480 if (ok) ok = pExportDC->OutputNewLine();
00481 return ok;
00482 }
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501 BOOL PrintComponent::WriteEPSComments(EPSFilter *pFilter)
00502 {
00503
00504
00505 if ( !pFilter->NeedsPrintComponents () )
00506 {
00507 return TRUE;
00508 }
00509
00510 ERROR2IF ( pPrCtrl == NULL, FALSE,
00511 "No print control to output in PrintComponent::WriteEPSComments()" );
00512
00513
00514
00515 pExportDC = pFilter->GetExportDC();
00516
00517 ERROR2IF(pExportDC == NULL,FALSE,"Export DC is NULL in PrintComponent::WriteEPSComments()");
00518
00519 BOOL ok = TRUE;
00520
00521 if (ok) ok = OutputValue(PCTOKEN_SECTIONNAME, PC_SECTION_VERSION);
00522
00523 if (ok) ok = OutputValue(PCTOKEN_WHOLESPREAD, pPrCtrl->IsWholeSpread());
00524 if (ok) ok = OutputValue(PCTOKEN_SCALE, pPrCtrl->GetScale());
00525 if (ok) ok = OutputValue(PCTOKEN_ORIENTATION, pPrCtrl->GetPrintOrient());
00526 if (ok) ok = OutputValue(PCTOKEN_FITTYPE, pPrCtrl->GetFitType());
00527 if (ok) ok = OutputValue(PCTOKEN_TOPMARGIN, pPrCtrl->GetTopMargin());
00528 if (ok) ok = OutputValue(PCTOKEN_LEFTMARGIN, pPrCtrl->GetLeftMargin());
00529 if (ok) ok = OutputValue(PCTOKEN_WIDTH, pPrCtrl->GetWidth());
00530 if (ok) ok = OutputValue(PCTOKEN_HEIGHT, pPrCtrl->GetHeight());
00531 if (ok) ok = OutputValue(PCTOKEN_ROWS, pPrCtrl->GetRows());
00532 if (ok) ok = OutputValue(PCTOKEN_COLUMNS, pPrCtrl->GetColumns());
00533 if (ok) ok = OutputValue(PCTOKEN_GUTTER, pPrCtrl->GetGutter());
00534 if (ok) ok = OutputValue(PCTOKEN_LAYERS, pPrCtrl->GetPrintLayers());
00535 if (ok) ok = OutputValue(PCTOKEN_PSLEVEL, pPrCtrl->GetPSLevel());
00536 if (ok) ok = OutputValue(PCTOKEN_BITMAPRESMETHOD, pPrCtrl->GetBitmapResMethod());
00537
00538
00539
00540
00541
00542 if (ok)
00543 {
00544 if (pPrCtrl->GetBitmapResMethod() == BITMAPRES_MANUAL)
00545 ok = OutputValue(PCTOKEN_DOTSPERINCH, pPrCtrl->GetDotsPerInch());
00546 else
00547 ok = OutputValue(PCTOKEN_DOTSPERINCH, 150);
00548 }
00549
00550 if (ok) ok = OutputValue(PCTOKEN_COLLATED, pPrCtrl->IsCollated());
00551 if (ok) ok = OutputValue(PCTOKEN_NUMCOPIES, pPrCtrl->GetNumCopies());
00552 if (ok) ok = OutputValue(PCTOKEN_PRINTTOFILE, pPrCtrl->GetPrintToFile());
00553 if (ok) ok = OutputValue(PCTOKEN_OBJPRINTRANGE, pPrCtrl->GetObjPrintRange());
00554 if (ok) ok = OutputValue(PCTOKEN_DPSPRINTRANGE, pPrCtrl->GetDPSPrintRange());
00555 if (ok) ok = OutputValue(PCTOKEN_ALLTEXTASSHAPES, pPrCtrl->GetTextOptions());
00556
00557
00558
00559 pExportDC = NULL;
00560
00561 return ok;
00562 }
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 ProcessEPSResult PrintComponent::ProcessEPSComment(EPSFilter *pFilter,
00592 const char *pComment)
00593 {
00594 ERROR2IF(pPrCtrl == NULL,EPSCommentUnknown,"No print control to output in PrintComponent::ProcessEPSComment()");
00595
00596 ProcessEPSResult Result = EPSCommentUnknown;
00597
00598 PCToken Token = GetToken(pComment);
00599
00600 if (Token != PCTOKEN_UNKNOWN)
00601 {
00602
00603 pPrCtrl->StartImport();
00604
00605 Result = EPSCommentOK;
00606
00607 INT32 n = GetTokenValINT32(pComment);
00608 FIXED16 Scale = GetTokenValFIXED16(pComment);
00609
00610 switch (Token)
00611 {
00612 case PCTOKEN_SECTIONNAME:
00613
00614 if (n != PC_SECTION_VERSION)
00615 Result = EPSCommentSyntaxError;
00616 break;
00617
00618 case PCTOKEN_WHOLESPREAD: pPrCtrl->SetWholeSpread(n); break;
00619 case PCTOKEN_SCALE: pPrCtrl->SetScale(Scale); break;
00620 case PCTOKEN_ORIENTATION: pPrCtrl->SetPrintOrient(PrintOrient(n)); break;
00621 case PCTOKEN_FITTYPE: pPrCtrl->SetFitType(PrintFitType(n)); break;
00622 case PCTOKEN_TOPMARGIN: pPrCtrl->SetTopMargin(n); break;
00623 case PCTOKEN_LEFTMARGIN: pPrCtrl->SetLeftMargin(n); break;
00624 case PCTOKEN_WIDTH: pPrCtrl->SetWidth(n); break;
00625 case PCTOKEN_HEIGHT: pPrCtrl->SetHeight(n); break;
00626 case PCTOKEN_ROWS: pPrCtrl->SetRows(n); break;
00627 case PCTOKEN_COLUMNS: pPrCtrl->SetColumns(n); break;
00628 case PCTOKEN_GUTTER: pPrCtrl->SetGutter(n); break;
00629 case PCTOKEN_LAYERS: pPrCtrl->SetPrintLayers(PrintLayers(n)); break;
00630
00631
00632
00633 case PCTOKEN_PSLEVEL: pPrCtrl->SetPSLevel(PSLEVEL_2); break;
00634 case PCTOKEN_BITMAPRESMETHOD: pPrCtrl->SetBitmapResMethod(BitmapResMethod(n)); break;
00635 case PCTOKEN_DOTSPERINCH: pPrCtrl->SetDotsPerInch(n); break;
00636 case PCTOKEN_COLLATED: pPrCtrl->SetCollated(n); break;
00637 case PCTOKEN_NUMCOPIES: pPrCtrl->SetNumCopies(n); break;
00638 case PCTOKEN_PRINTTOFILE: pPrCtrl->SetPrintToFile(n); break;
00639 case PCTOKEN_OBJPRINTRANGE: pPrCtrl->SetObjPrintRange(PrintRangeObj(n)); break;
00640 case PCTOKEN_DPSPRINTRANGE: pPrCtrl->SetDPSPrintRange(PrintRangeDPS(n)); break;
00641 case PCTOKEN_ALLTEXTASSHAPES: pPrCtrl->SetTextOptions((PrintTextOptions) n); break;
00642
00643 default:
00644 break;
00645 }
00646
00647
00648 pPrCtrl->EndImport();
00649 }
00650 return Result;
00651 }
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674 BOOL PrintComponent::EndExport(BaseCamelotFilter *pFilter, BOOL Success)
00675 {
00676 BOOL ok = TRUE;
00677
00678 PORTNOTETRACE("print","PrintComponent::EndExport - do nothing");
00679
00680
00681 #ifndef WEBSTER
00682 #if !defined(EXCLUDE_FROM_RALPH)
00683 if (pFilter == NULL)
00684 {
00685 ERROR3("PrintComponent::EndExport filter is null!");
00686 return(ok);
00687 }
00688
00689
00690 if (pFilter->IsWebFilter() || !Success)
00691 return(ok);
00692
00693
00694 ExportPrintSettings(pFilter);
00695 ExportImagesetting(pFilter);
00696
00697 TypesetInfo *TInfo = TypesetInfo::FindTypesetInfoForDoc(pFilter->GetDocument());
00698 if (TInfo != NULL && TInfo->GetNumPlates() > 0)
00699 {
00700 ColourPlate *pPlate = TInfo->GetFirstPlate();
00701 while (pPlate != NULL)
00702 {
00703 ExportColourPlate(pFilter, pPlate);
00704 pPlate = TInfo->GetNextPlate(pPlate);
00705 }
00706 }
00707
00708 #endif // WEBSTER
00709 #endif
00710 return(ok);
00711 }
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731 BOOL PrintComponent::ExportPrintSettings(BaseCamelotFilter *pFilter)
00732 {
00733 BOOL ok = TRUE;
00734
00735 #if !defined(EXCLUDE_FROM_RALPH)
00736
00737
00738 CXaraFileRecord Rec(TAG_PRINTERSETTINGS, TAG_PRINTERSETTINGS_SIZE);
00739 if (ok) ok = Rec.Init();
00740
00741 INT32 Value;
00742
00743
00744
00745 #define OutputEnum2(FuncName,A,B) \
00746 if (ok) \
00747 { \
00748 switch(pPrCtrl->Get##FuncName()) \
00749 { \
00750 case A: Value=1; break; \
00751 case B: Value=2; break; \
00752 default: Value=1; ERROR3("Bad enum"); break; \
00753 } \
00754 ok = Rec.WriteBYTE((BYTE)Value); \
00755 }
00756
00757
00758 #define OutputEnum3(FuncName,A,B,C) \
00759 if (ok) \
00760 { \
00761 switch(pPrCtrl->Get##FuncName()) \
00762 { \
00763 case A: Value=1; break; \
00764 case B: Value=2; break; \
00765 case C: Value=3; break; \
00766 default: Value=1; ERROR3("Bad enum"); break; \
00767 } \
00768 ok = Rec.WriteBYTE((BYTE)Value); \
00769 }
00770
00771
00772 #define OutputEnum4(FuncName,A,B,C,D) \
00773 if (ok) \
00774 { \
00775 switch(pPrCtrl->Get##FuncName()) \
00776 { \
00777 case A: Value=1; break; \
00778 case B: Value=2; break; \
00779 case C: Value=3; break; \
00780 case D: Value=4; break; \
00781 default: Value=1; ERROR3("Bad enum"); break; \
00782 } \
00783 ok = Rec.WriteBYTE((BYTE)Value); \
00784 }
00785
00786
00787 #define OutputValueU(FuncName) \
00788 if (ok) ok = Rec.WriteUINT32((UINT32)pPrCtrl->Get##FuncName());
00789
00790
00791 #define OutputValueS(FuncName) \
00792 if (ok) ok = Rec.WriteINT32((INT32)pPrCtrl->Get##FuncName());
00793
00794
00795 #define OutputValue16(FuncName) \
00796 if (ok) ok = Rec.WriteUINT16((UINT16)pPrCtrl->Get##FuncName());
00797
00798
00799
00800 OutputValueU(NumCopies);
00801 if (ok) ok = Rec.WriteFIXED16(pPrCtrl->GetScale());
00802 OutputValueS(TopMargin);
00803 OutputValueS(LeftMargin);
00804 OutputValueS(Width);
00805 OutputValueS(Height);
00806 OutputValue16(Rows);
00807 OutputValue16(Columns);
00808 OutputValueS(Gutter);
00809 OutputEnum3(PrintMethod, PRINTMETHOD_NORMAL, PRINTMETHOD_BITMAP, PRINTMETHOD_AABITMAP);
00810 OutputEnum2(ObjPrintRange, PRINTRANGEOBJ_ALL, PRINTRANGEOBJ_SELECTED);
00811 OutputEnum3(DPSPrintRange, PRINTRANGEDPS_BOTH, PRINTRANGEDPS_LEFTPAGES, PRINTRANGEDPS_RIGHTPAGES);
00812
00813 OutputEnum2(PrintOrient, PRINTORIENTATION_UPRIGHT, PRINTORIENTATION_SIDEWAYS);
00814 OutputEnum4(FitType, PRINTFIT_BEST, PRINTFIT_CUSTOM, PRINTFIT_MULTIPLE, PRINTFIT_BESTPAPER);
00815 OutputEnum2(PrintLayers, PRINTLAYERS_ALLFOREGROUND, PRINTLAYERS_VISIBLEFOREGROUND);
00816 OutputEnum3(PSLevel, PSLEVEL_AUTO, PSLEVEL_1, PSLEVEL_2);
00817 OutputEnum2(BitmapResMethod, BITMAPRES_AUTO, BITMAPRES_MANUAL);
00818
00819 if (ok)
00820 {
00821
00822 if (pPrCtrl->GetBitmapResMethod() == BITMAPRES_MANUAL)
00823 Value = pPrCtrl->GetDotsPerInch();
00824 else
00825 Value = 150;
00826
00827 ok = Rec.WriteUINT32((UINT32) Value);
00828 }
00829
00830 if (ok)
00831 {
00832 Value = 0x00;
00833 if (pPrCtrl->IsCollated()) Value |= 0x01;
00834 if (pPrCtrl->IsWholeSpread()) Value |= 0x02;
00835 if (pPrCtrl->GetPrintToFile()) Value |= 0x04;
00836 if (pPrCtrl->GetTextOptions() == PRINTTEXTOPTIONS_ALLTEXTASSHAPES)
00837 Value |= 0x08;
00838
00839 ok = Rec.WriteBYTE((BYTE)Value);
00840 }
00841
00842
00843 if (ok)
00844 pFilter->Write(&Rec);
00845
00846
00847
00848 #undef OutputEnum2
00849 #undef OutputEnum3
00850 #undef OutputValueU
00851 #undef OutputValueS
00852 #undef OutputValue16
00853 #endif // EXCLUDE_FROM_RALPH
00854
00855 return(ok);
00856 }
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876 BOOL PrintComponent::ExportImagesetting(BaseCamelotFilter *pFilter)
00877 {
00878 BOOL ok = TRUE;
00879
00880 #if !defined(EXCLUDE_FROM_RALPH)
00881
00882 TypesetInfo *TInfo = GetPrintControl()->GetTypesetInfo();
00883 if (TInfo == NULL)
00884 return(TRUE);
00885
00886 CXaraFileRecord Rec(TAG_IMAGESETTING, TAG_IMAGESETTING_SIZE);
00887 if (ok) ok = Rec.Init();
00888
00889 if (ok) ok = Rec.WriteINT32(TInfo->GetPrintResolution());
00890 if (ok) ok = Rec.WriteDOUBLE(TInfo->GetDefaultScreenFrequency());
00891
00892 if (ok)
00893 {
00894 UINT16 Func = 0;
00895 switch(TInfo->GetScreenFunction())
00896 {
00897 case SCRTYPE_SPOT1: Func = 1; break;
00898 case SCRTYPE_SPOT2: Func = 2; break;
00899 case SCRTYPE_TRIPLESPOT1: Func = 3; break;
00900 case SCRTYPE_TRIPLESPOT2: Func = 4; break;
00901 case SCRTYPE_ELLIPTICAL: Func = 5; break;
00902 case SCRTYPE_LINE: Func = 6; break;
00903 case SCRTYPE_CROSSHATCH: Func = 7; break;
00904 case SCRTYPE_MEZZOTINT: Func = 8; break;
00905 case SCRTYPE_SQUARE: Func = 9; break;
00906 case SCRTYPE_DITHER: Func = 10; break;
00907 default:
00908 break;
00909 }
00910 ok = Rec.WriteUINT16(Func);
00911 }
00912
00913 if (ok)
00914 {
00915 BYTE Flags = 0x00;
00916 if (TInfo->AreSeparating()) Flags |= 0x01;
00917 if (TInfo->AreScreening()) Flags |= 0x02;
00918 if (TInfo->PrintEmulsionDown()) Flags |= 0x04;
00919 if (TInfo->PrintPhotoNegative()) Flags |= 0x08;
00920 if (TInfo->AlwaysOverprintBlack()) Flags |= 0x10;
00921
00922 ok = Rec.WriteBYTE(Flags);
00923 }
00924
00925 if (ok)
00926 pFilter->Write(&Rec);
00927
00928 #endif // EXCLUDE_FROM_RALPH
00929 return(ok);
00930 }
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952 BOOL PrintComponent::ExportColourPlate(BaseCamelotFilter *pFilter, ColourPlate *pPlate)
00953 {
00954 ERROR3IF(pPlate == NULL, "Illegal NULL params");
00955
00956 BOOL ok = TRUE;
00957 #if !defined(EXCLUDE_FROM_RALPH)
00958
00959
00960 IndexedColour *pCol = pPlate->GetSpotColour();
00961 INT32 SpotRecordNumber = 0;
00962 if (pCol != NULL)
00963 {
00964 DocColour Fred;
00965 Fred.MakeRefToIndexedColour(pCol);
00966 SpotRecordNumber = pFilter->WriteRecord(&Fred);
00967 ok = (SpotRecordNumber > 0);
00968 }
00969
00970
00971 CXaraFileRecord Rec(TAG_COLOURPLATE, TAG_COLOURPLATE_SIZE);
00972 if (ok) ok = Rec.Init();
00973
00974 BYTE Type = 0;
00975 switch(pPlate->GetType())
00976 {
00977 case COLOURPLATE_CYAN: Type = 1; break;
00978 case COLOURPLATE_MAGENTA: Type = 2; break;
00979 case COLOURPLATE_YELLOW: Type = 3; break;
00980 case COLOURPLATE_KEY: Type = 4; break;
00981 case COLOURPLATE_SPOT: Type = 5; break;
00982 default:
00983 break;
00984 }
00985
00986 if (ok) ok = Rec.WriteBYTE(Type);
00987 if (ok) ok = Rec.WriteReference(SpotRecordNumber);
00988
00989 double temp = pPlate->GetScreenAngle();
00990 if (ok) ok = Rec.WriteDOUBLE(temp);
00991 temp = pPlate->GetScreenFrequency();
00992 if (ok) ok = Rec.WriteDOUBLE(temp);
00993
00994 BYTE Flags = 0x00;
00995 if (!pPlate->IsDisabled()) Flags |= 0x01;
00996 if (pPlate->Overprints()) Flags |= 0x02;
00997 if (ok) ok = Rec.WriteBYTE(Flags);
00998
00999 if (ok)
01000 pFilter->Write(&Rec);
01001
01002 #endif // EXCLUDE_FROM_RALPH
01003 return(ok);
01004 }
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022 void PrintComponent::ImportPrintSettings(CXaraFileRecord* Rec)
01023 {
01024 #if !defined(EXCLUDE_FROM_RALPH)
01025 BOOL ok = TRUE;
01026
01027 PORTNOTETRACE("print","PrintComponent::ImportPrintSettings - do nothing");
01028
01029
01030 pPrCtrl->StartImport();
01031
01032
01033
01034
01035 #define InputEnum2(FuncName,A,B) \
01036 if (ok) \
01037 { \
01038 BYTE Value; \
01039 ok = Rec->ReadBYTE(&Value); \
01040 if (ok) \
01041 { \
01042 switch(Value) \
01043 { \
01044 case 1: pPrCtrl->Set##FuncName(A); break; \
01045 case 2: pPrCtrl->Set##FuncName(B); break; \
01046 default: ERROR3("Bad enum"); break; \
01047 } \
01048 } \
01049 }
01050
01051
01052 #define InputEnum3(FuncName,A,B,C) \
01053 if (ok) \
01054 { \
01055 BYTE Value; \
01056 ok = Rec->ReadBYTE(&Value); \
01057 if (ok) \
01058 { \
01059 switch(Value) \
01060 { \
01061 case 1: pPrCtrl->Set##FuncName(A); break; \
01062 case 2: pPrCtrl->Set##FuncName(B); break; \
01063 case 3: pPrCtrl->Set##FuncName(C); break; \
01064 default: ERROR3("Bad enum"); break; \
01065 } \
01066 } \
01067 }
01068
01069
01070 #define InputEnum4(FuncName,A,B,C,D) \
01071 if (ok) \
01072 { \
01073 BYTE Value; \
01074 ok = Rec->ReadBYTE(&Value); \
01075 if (ok) \
01076 { \
01077 switch(Value) \
01078 { \
01079 case 1: pPrCtrl->Set##FuncName(A); break; \
01080 case 2: pPrCtrl->Set##FuncName(B); break; \
01081 case 3: pPrCtrl->Set##FuncName(C); break; \
01082 case 4: pPrCtrl->Set##FuncName(D); break; \
01083 default: ERROR3("Bad enum"); break; \
01084 } \
01085 } \
01086 }
01087
01088
01089 #define InputValueU(FuncName) \
01090 if (ok) \
01091 { \
01092 UINT32 Value; \
01093 ok = Rec->ReadUINT32(&Value); \
01094 if (ok) pPrCtrl->Set##FuncName(Value); \
01095 } \
01096
01097
01098 #define InputValueS(FuncName) \
01099 if (ok) \
01100 { \
01101 INT32 Value; \
01102 ok = Rec->ReadINT32(&Value); \
01103 if (ok) pPrCtrl->Set##FuncName(Value); \
01104 } \
01105
01106
01107 #define InputValue16(FuncName) \
01108 if (ok) \
01109 { \
01110 UINT16 Value; \
01111 ok = Rec->ReadUINT16(&Value); \
01112 if (ok) pPrCtrl->Set##FuncName((INT32)Value); \
01113 } \
01114
01115
01116
01117 InputValueU(NumCopies);
01118 if (ok)
01119 {
01120 FIXED16 Value;
01121 ok = Rec->ReadFIXED16(&Value);
01122 if (ok) pPrCtrl->SetScale(Value);
01123 }
01124 InputValueS(TopMargin);
01125 InputValueS(LeftMargin);
01126 InputValueS(Width);
01127 InputValueS(Height);
01128 InputValue16(Rows);
01129 InputValue16(Columns);
01130 InputValueS(Gutter);
01131 InputEnum3(PrintMethod, PRINTMETHOD_NORMAL, PRINTMETHOD_BITMAP, PRINTMETHOD_AABITMAP);
01132 InputEnum2(ObjPrintRange, PRINTRANGEOBJ_ALL, PRINTRANGEOBJ_SELECTED);
01133 InputEnum3(DPSPrintRange, PRINTRANGEDPS_BOTH, PRINTRANGEDPS_LEFTPAGES, PRINTRANGEDPS_RIGHTPAGES);
01134 InputEnum2(PrintOrient, PRINTORIENTATION_UPRIGHT, PRINTORIENTATION_SIDEWAYS);
01135 InputEnum4(FitType, PRINTFIT_BEST, PRINTFIT_CUSTOM, PRINTFIT_MULTIPLE, PRINTFIT_BESTPAPER);
01136 InputEnum2(PrintLayers, PRINTLAYERS_ALLFOREGROUND, PRINTLAYERS_VISIBLEFOREGROUND);
01137
01138
01139
01140 InputEnum3(PSLevel, PSLEVEL_2, PSLEVEL_2, PSLEVEL_2);
01141 InputEnum2(BitmapResMethod, BITMAPRES_AUTO, BITMAPRES_MANUAL);
01142
01143 if (ok)
01144 {
01145 UINT32 Value;
01146 ok = Rec->ReadUINT32(&Value);
01147 if (ok) pPrCtrl->SetDotsPerInch(Value);
01148 }
01149
01150 if (ok)
01151 {
01152 BYTE Value;
01153 ok = Rec->ReadBYTE(&Value);
01154
01155 if (ok)
01156 {
01157 pPrCtrl->SetCollated( (Value & 0x01) != 0);
01158 pPrCtrl->SetWholeSpread((Value & 0x02) != 0);
01159 pPrCtrl->SetPrintToFile((Value & 0x04) != 0);
01160
01161 pPrCtrl->SetTextOptions(((Value & 0x08) != 0) ? PRINTTEXTOPTIONS_ALLTEXTASSHAPES : PRINTTEXTOPTIONS_NORMAL);
01162
01163 }
01164 }
01165
01166
01167 pPrCtrl->EndImport();
01168
01169
01170 #undef InputEnum2
01171 #undef InputEnum3
01172 #undef InputValueU
01173 #undef InputValueS
01174 #undef InputValue16
01175
01176 #endif
01177 }
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195 void PrintComponent::ImportImagesetting(CXaraFileRecord* Rec)
01196 {
01197 #if !defined(EXCLUDE_FROM_RALPH)
01198 PORTNOTETRACE("print","PrintComponent::ImportImagesetting - do nothing");
01199 TypesetInfo *TInfo = GetPrintControl()->GetTypesetInfo();
01200 if (TInfo == NULL)
01201 return;
01202
01203
01204 TInfo->DestroyPlateList();
01205
01206 BOOL ok = TRUE;
01207
01208 if (ok)
01209 {
01210 INT32 Res;
01211 ok = Rec->ReadINT32(&Res);
01212 if (ok) TInfo->SetPrintResolution(Res);
01213 }
01214
01215 if (ok)
01216 {
01217 double Freq;
01218 ok = Rec->ReadDOUBLE(&Freq);
01219 if (ok) TInfo->SetDefaultScreenFrequency(Freq);
01220 }
01221
01222 if (ok)
01223 {
01224 UINT16 Func;
01225 ok = Rec->ReadUINT16(&Func);
01226
01227 if (ok)
01228 {
01229 ScreenType Screen = SCRTYPE_NONE;
01230 switch(Func)
01231 {
01232 case 1: Screen = SCRTYPE_SPOT1; break;
01233 case 2: Screen = SCRTYPE_SPOT2; break;
01234 case 3: Screen = SCRTYPE_TRIPLESPOT1; break;
01235 case 4: Screen = SCRTYPE_TRIPLESPOT2; break;
01236 case 5: Screen = SCRTYPE_ELLIPTICAL; break;
01237 case 6: Screen = SCRTYPE_LINE; break;
01238 case 7: Screen = SCRTYPE_CROSSHATCH; break;
01239 case 8: Screen = SCRTYPE_MEZZOTINT; break;
01240 case 9: Screen = SCRTYPE_SQUARE; break;
01241 case 0: Screen = SCRTYPE_DITHER; break;
01242 }
01243 TInfo->SetScreenFunction(Screen, TRUE);
01244 }
01245 }
01246
01247 if (ok)
01248 {
01249 BYTE Flags;
01250 ok = Rec->ReadBYTE(&Flags);
01251
01252 TInfo->SetSeparations( (Flags & 0x01) != 0);
01253 TInfo->SetOutputPrintersMarks(TInfo->AreSeparating());
01254
01255 TInfo->SetScreening( (Flags & 0x02) != 0);
01256 TInfo->SetEmulsionDown( (Flags & 0x04) != 0);
01257 TInfo->SetPhotoNegative((Flags & 0x08) != 0);
01258 TInfo->SetOverprintBlack((Flags & 0x10) != 0);
01259 }
01260 #endif
01261 }
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285 void PrintComponent::ImportColourPlate(CXaraFileRecord* Rec, CamelotRecordHandler *pHandler)
01286 {
01287 #if !defined(EXCLUDE_FROM_RALPH)
01288 BOOL ok = TRUE;
01289
01290 PORTNOTETRACE("print","PrintComponent::ImportColourPlate - do nothing");
01291 TypesetInfo *TInfo = GetPrintControl()->GetTypesetInfo();
01292 if (TInfo == NULL)
01293 return;
01294
01295 ColourPlate *NewPlate = TInfo->CreateColourPlate();
01296 if (NewPlate == NULL)
01297 return;
01298
01299 BYTE Type;
01300 if (ok) ok = Rec->ReadBYTE(&Type);
01301
01302 ColourPlateType PlateType = COLOURPLATE_NONE;
01303 if (ok)
01304 {
01305 switch(Type)
01306 {
01307 case 1: PlateType = COLOURPLATE_CYAN; break;
01308 case 2: PlateType = COLOURPLATE_MAGENTA; break;
01309 case 3: PlateType = COLOURPLATE_YELLOW; break;
01310 case 4: PlateType = COLOURPLATE_KEY; break;
01311 case 5: PlateType = COLOURPLATE_SPOT; break;
01312 }
01313 }
01314
01315 IndexedColour *pCol = NULL;
01316 if (ok)
01317 {
01318 INT32 ColRecordNum;
01319 ok = Rec->ReadINT32(&ColRecordNum);
01320 if (ok && PlateType == COLOURPLATE_SPOT)
01321 {
01322 DocColour SpotCol;
01323 ok = pHandler->GetDocColour(ColRecordNum, &SpotCol);
01324 if (ok)
01325 pCol = SpotCol.FindParentIndexedColour();
01326 }
01327 }
01328
01329
01330 if (PlateType == COLOURPLATE_SPOT &&
01331 (pCol == NULL || pCol->GetType() != COLOURTYPE_SPOT || pCol->IsDeleted()) )
01332 {
01333
01334 delete NewPlate;
01335 return;
01336 }
01337
01338 NewPlate->SetType(NULL, PlateType, pCol);
01339
01340 if (ok)
01341 {
01342 double Angle = 0.0;
01343 double Frequency = 60.0;
01344
01345 ok = Rec->ReadDOUBLE(&Angle);
01346 if (ok) ok = Rec->ReadDOUBLE(&Frequency);
01347 if (ok) NewPlate->SetScreenInfo(Angle, Frequency);
01348 }
01349
01350 BYTE Flags;
01351 if (ok) ok = Rec->ReadBYTE(&Flags);
01352
01353 if (ok)
01354 {
01355 NewPlate->SetDisabled( (Flags & 0x01) == 0);
01356 NewPlate->SetOverprint((Flags & 0x02) != 0);
01357 }
01358
01359
01360 if (ok)
01361 {
01362
01363 TInfo->AddPlate(NewPlate);
01364 }
01365 #endif
01366 }