princomp.cpp

Go to the documentation of this file.
00001 // $Id: princomp.cpp 1328 2006-06-15 19:23:45Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 //
00099 // Implementation of the print document component classes
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 #include "princomp.h"
00107 
00108 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 #include "colourix.h"
00111 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "cxfrech.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 #include "cxftags.h"
00114 //#include "epsfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
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 // Declare smart memory handling in Debug builds
00125 #define new CAM_DEBUG_NEW
00126 
00127 
00128 //---------------------------------------------------------------------------------------
00129 
00130 /********************************************************************************************
00131 
00132 >   BOOL PrintComponentClass::Init()
00133 
00134     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00135     Created:    31/3/95
00136     Returns:    TRUE if all went well;
00137                 FALSE if not.
00138     Purpose:    Register the print document component with the main application.
00139     Errors:     Out of memory.
00140     SeeAlso:    DocComponent
00141 
00142 ********************************************************************************************/
00143 
00144 BOOL PrintComponentClass::Init()
00145 {
00146     // Instantiate a component class to register with the application.
00147     PrintComponentClass *pClass = new PrintComponentClass;
00148     if (pClass == NULL)
00149         return FALSE;
00150 
00151     // Register it
00152     GetApplication()->RegisterDocComponent(pClass);
00153 
00154     if (Camelot.DeclareSection(_T("Printing"),1))
00155         Camelot.DeclarePref(_T("Printing"), _T("AppPrintMethod"),   (INT32*)(&PrintControl::AppPrintMethod));
00156 
00157     // All ok
00158     return TRUE;
00159 }
00160 
00161 
00162 /********************************************************************************************
00163 
00164 >   BOOL PrintComponentClass::AddComponent(BaseDocument *pDocument)
00165 
00166     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00167     Created:    31/3/95
00168     Inputs:     pDocument - the document to add the print to.
00169     Returns:    TRUE if the print was added ok;
00170                 FALSE if not.
00171     Purpose:    Add a print component to the specified document.
00172     Errors:     Out of memory
00173     SeeAlso:    PrintComponentClass
00174 
00175 ********************************************************************************************/
00176 
00177 BOOL PrintComponentClass::AddComponent(BaseDocument *pDocument)
00178 {
00179     // Check to see if this document already has a print component; if so, leave it alone.
00180     if (pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent)) != NULL)
00181         return TRUE;
00182 
00183     // No print component- try to create a new one for this document.
00184 
00185     // Firstly, create a new PrintControl object for the print component
00186     PrintControl *pPrCtrl = new PrintControl();
00187     if(pPrCtrl == NULL)
00188         return FALSE;
00189 
00190     // Ok - create the print component using this print control object.
00191     PrintComponent *pComponent = new PrintComponent(pPrCtrl);
00192     if (pComponent == NULL)
00193     {
00194         // Out of memory...
00195         delete pPrCtrl;
00196         return FALSE;
00197     }
00198 
00199     // All ok - add the component to the document.
00200     pDocument->AddDocComponent(pComponent);
00201 
00202     return TRUE;
00203 }
00204 
00205 
00206 //---------------------------------------------------------------------------------------
00207 //---------------------------------------------------------------------------------------
00208 //---------------------------------------------------------------------------------------
00209 
00210 //----------------------------
00211 
00212 /********************************************************************************************
00213 
00214 >   PrintComponent::PrintComponent()
00215 
00216     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00217     Created:    31/3/95
00218     Purpose:    Construct a print component. DO NOT use this constructor. It gives
00219                 and ERROR3 (and sets up this in a semi-safe default state)
00220     SeeAlso:    PrintComponent
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 >   PrintComponent::PrintComponent(PrintControl *pThisPrCtrl)
00236 
00237     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00238     Created:    31/3/95
00239     Inputs:     pThisPrCtrl - the print control to use for this print componet.
00240     Purpose:    Construct a print component using the given print control object
00241     Errors:     ENSURE if pPrCtrl is NULL.
00242     SeeAlso:    PrintComponent
00243 
00244 ********************************************************************************************/
00245 
00246 PrintComponent::PrintComponent(PrintControl *pThisPrCtrl)
00247 {
00248     ERROR3IF(pThisPrCtrl == NULL, "NULL print control object in print component constructor!");
00249 
00250     // Install this Bitmap list.
00251     pPrCtrl     = pThisPrCtrl;
00252     pExportDC   = NULL;
00253 }
00254 
00255 /********************************************************************************************
00256 
00257 >   PrintComponent::~PrintComponent()
00258 
00259     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00260     Created:    31/3/95
00261     Purpose:    Clean up a print component's data structures - deletes the print control object
00262     Errors:     -
00263     SeeAlso:    PrintComponent
00264 
00265 ********************************************************************************************/
00266 
00267 PrintComponent::~PrintComponent()
00268 {
00269     // Delete our print control object
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 >   PCToken PrintComponent::GetToken(const char* pComment)
00314 
00315     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00316     Created:    5/4/95
00317     Input:      pComment = ptr to an EPS comment
00318     Returns:    The print component token value 
00319     Purpose:    Outputs a print component token with the given value
00320     SeeAlso:    PrintComponent
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 >   void PrintComponent::ExtractTokenValStr(const char* pComment)
00348 
00349     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00350     Created:    5/4/95
00351     Input:      pComment = ptr to an EPS comment
00352     Returns:    -
00353     Purpose:    The string representation of the token value is stored in Buffer.
00354                 If no value is found, or the buffer overflows, Buffer will contain an empty string
00355     SeeAlso:    PrintComponent
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         // Skip past token str, up to first space char or string terminating char
00368         while (!camIsspace(pComment[i]) && !camIscntrl(pComment[i]))
00369             i++;
00370 
00371         // Find next non-space char
00372         while (camIsspace(pComment[i]))
00373             i++;
00374 
00375         // Extract all the remaining printable characters
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 >   INT32 PrintComponent::GetTokenValINT32(const char* pComment)
00390 
00391     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00392     Created:    5/4/95
00393     Input:      pComment = ptr to an EPS comment
00394     Returns:    -
00395     Purpose:    This gets the value after the token part of the comment and returns it as a INT32
00396     SeeAlso:    PrintComponent
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 >   FIXED16 PrintComponent::GetTokenValFIXED16(const char* pComment)
00414 
00415     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00416     Created:    5/4/95
00417     Input:      pComment = ptr to an EPS comment
00418     Returns:    -
00419     Purpose:    This gets the value after the token part of the comment and returns it as a FIXED16
00420     SeeAlso:    PrintComponent
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 >   BOOL PrintComponent::OutputValue(UINT32 Token,UINT32 Value)
00444 
00445     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00446     Created:    31/3/95
00447     Input:      Token = the print component token to output
00448                 Value = the value to output after the token
00449     Returns:    TRUE if successful, FALSE if failed
00450     Purpose:    Outputs a print component token with the given value
00451     SeeAlso:    PrintComponent
00452 
00453 ********************************************************************************************/
00454 
00455 // Signed INT32 version
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 // FIXED16 version
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 >   BOOL PrintComponent::WriteEPSComments(EPSFilter *pFilter)
00487 
00488     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00489     Created:    31/3/95
00490     Inputs:     pFilter - the filter being used to import the EPS file.
00491     Returns:    TRUE if the print control object was written successfully;
00492                 FALSE if not.
00493     Purpose:    Writes out the print control object in the form of EPS comments in the 'header'
00494                 comments of the EPS file.
00495     Errors:     Out of disk space, and similar disk errors.
00496     SeeAlso:    DocComponent::WriteEPSComments;
00497                 DocComponent
00498 
00499 ********************************************************************************************/
00500 
00501 BOOL PrintComponent::WriteEPSComments(EPSFilter *pFilter)
00502 {
00503     // Graeme (23-5-00) - Neither AI nor ArtWorks files need the print control entries, so
00504     // just return TRUE to avoid problems.
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     // Set up the export DC ptr
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     // We only need to output the bitmap DPI if the user has selected 'manual' bitmap DPI
00539     // Auto DPI will calculated the DPI automatically ( surprise, surprise - Cilla 'ere!)
00540     // This also means that the printer's DPI is not needed before saving, hence avoiding any unnecessary
00541     // delays.
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 //  if (ok) ok = OutputValue(PCTOKEN_PRINTMETHOD,       pPrCtrl->GetPrintMethod());
00557 
00558     // reset the DC ptr to NULL (ready for next time)
00559     pExportDC = NULL;
00560 
00561     return ok;
00562 }
00563 
00564 
00565 /********************************************************************************************
00566 
00567 >   ProcessEPSResult PrintComponent::ProcessEPSComment(EPSFilter *pFilter, 
00568                                                             const char *pComment)
00569 
00570     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00571     Created:    31/3/95
00572     Inputs:     pFilter - the EPS filter that is being used to import a file.
00573                 pComment - pointer to the comment to process.
00574     Returns:    EPSCommentUnknown       - This EPS comment is not recognised by the document
00575                                           component.
00576                 EPSCommentSyntaxError   - This EPS comment was recognised by this document
00577                                           component, but it contained an error.
00578                 EPSCommentSystemError   - This EPS comment was recognised by this document
00579                                           component, but an error occured that was not caused
00580                                           directly by the comment, e.g. out of memory.
00581                 EPSCommentOK            - This EPS comment was recognised as a legal comment by 
00582                                           this document component, and was processed
00583                                           successfully.
00584     Purpose:    Process an EPS comment - if this is a print component comment, this component
00585                 will claim it and try to decode it.
00586     Errors:     Badly formed EPS comment.
00587     SeeAlso:    DocComponent::ProcessEPSComment
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         // Let the print control object know we are importing the data rather than changing it via UI
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                 // 'n' is the version number for this comment block
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 // Dirty bodge to ensure that PSLevel is always 2
00631 // Job 10463: remove PS Level bits - default to Level 2
00632 //          case PCTOKEN_PSLEVEL:           pPrCtrl->SetPSLevel(PSLevel(n));                    break;
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 //          case PCTOKEN_PRINTMETHOD:       pPrCtrl->SetPrintMethod(PrintMethodType(n));        break;
00643             default:
00644                 break;
00645         }
00646 
00647         // Let the print control object know we have finished importing (for the moment at least)
00648         pPrCtrl->EndImport();
00649     }
00650     return Result;
00651 }
00652 
00653 
00654 
00655 
00656 
00657 
00658 /********************************************************************************************
00659 
00660 >   BOOL PrintComponent::EndExport(BaseCamelotFilter *pFilter)
00661 
00662     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00663     Created:    14/8/96
00664     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to export a file.
00665                 Success - True if everything went swimmingly, False if just a clean up is required.
00666     Purpose:    Inform the colour list document component that a Web or Native export has
00667                 just finished.
00668     Returns:    TRUE if the component was able to end the importing;
00669                 FALSE if not (e.g. out of memory)
00670     SeeAlso:    DocComponent
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 // WEBSTER - markn 14/2/97
00680 // No print records needed in Webster
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     // If we're not exporting native data, or if export has failed, we do nothing here
00690     if (pFilter->IsWebFilter() || !Success)
00691         return(ok);
00692 
00693     // Export our 3 record types (1 print info, 1 imagesetting info, 'n' colour plates)
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 >   BOOL PrintComponent::ExportPrintSettings(BaseCamelotFilter *pFilter)
00718 
00719     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00720     Created:    14/8/96
00721 
00722     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to export a file.
00723     Returns:    TRUE for success
00724 
00725     Purpose:    Export a TAG_PRINTERSETTINGS native file record
00726 
00727     SeeAlso:    PrintingRecordHandler
00728 
00729 ********************************************************************************************/
00730 
00731 BOOL PrintComponent::ExportPrintSettings(BaseCamelotFilter *pFilter)
00732 {
00733     BOOL ok = TRUE;
00734 
00735 #if !defined(EXCLUDE_FROM_RALPH)
00736 
00737     // --- Write the record
00738     CXaraFileRecord Rec(TAG_PRINTERSETTINGS, TAG_PRINTERSETTINGS_SIZE);
00739     if (ok) ok = Rec.Init();
00740 
00741     INT32 Value;        // Temp variable used by macros etc
00742 
00743     // --- Macros. These are undefined immediately at the end of this function
00744     // --- Helper macro for safely exporting an enum as a BYTE value: 1, 2. Unknown enums are output as a 1.
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     // --- Helper macro for safely exporting an enum as a BYTE value: 1, 2, 3. Unknown enums are output as a 1.
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     // --- Helper macro for safely exporting an enum as a BYTE value: 1, 2, 3. Unknown enums are output as a 1.
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     // --- Helper macro to output any 32-bit UNsigned value
00787     #define OutputValueU(FuncName)              \
00788         if (ok)  ok = Rec.WriteUINT32((UINT32)pPrCtrl->Get##FuncName());
00789 
00790     // --- Helper macro to output any 32-bit Signed value
00791     #define OutputValueS(FuncName)              \
00792         if (ok)  ok = Rec.WriteINT32((INT32)pPrCtrl->Get##FuncName());
00793 
00794     // --- Helper macro to output any 16-bit UNsigned value
00795     #define OutputValue16(FuncName)             \
00796         if (ok)  ok = Rec.WriteUINT16((UINT16)pPrCtrl->Get##FuncName());
00797 
00798 
00799                                                                                                     // Size Total
00800     OutputValueU(NumCopies);                                                                        // 4    4
00801     if (ok) ok = Rec.WriteFIXED16(pPrCtrl->GetScale());                                             // 4    8
00802     OutputValueS(TopMargin);                                                                        // 4    12
00803     OutputValueS(LeftMargin);                                                                       // 4    16
00804     OutputValueS(Width);                                                                            // 4    20
00805     OutputValueS(Height);                                                                           // 4    24
00806     OutputValue16(Rows);                                                                            // 2    26
00807     OutputValue16(Columns);                                                                         // 2    28
00808     OutputValueS(Gutter);                                                                           // 4    32
00809     OutputEnum3(PrintMethod,        PRINTMETHOD_NORMAL, PRINTMETHOD_BITMAP, PRINTMETHOD_AABITMAP);  // 1    33
00810     OutputEnum2(ObjPrintRange,      PRINTRANGEOBJ_ALL, PRINTRANGEOBJ_SELECTED);                     // 1    34
00811     OutputEnum3(DPSPrintRange,      PRINTRANGEDPS_BOTH, PRINTRANGEDPS_LEFTPAGES, PRINTRANGEDPS_RIGHTPAGES);
00812                                                                                                     // 1    35
00813     OutputEnum2(PrintOrient,        PRINTORIENTATION_UPRIGHT, PRINTORIENTATION_SIDEWAYS);           // 1    36
00814     OutputEnum4(FitType,            PRINTFIT_BEST, PRINTFIT_CUSTOM, PRINTFIT_MULTIPLE, PRINTFIT_BESTPAPER); // 1    37
00815     OutputEnum2(PrintLayers,        PRINTLAYERS_ALLFOREGROUND, PRINTLAYERS_VISIBLEFOREGROUND);      // 1    38
00816     OutputEnum3(PSLevel,            PSLEVEL_AUTO, PSLEVEL_1, PSLEVEL_2);                            // 1    39
00817     OutputEnum2(BitmapResMethod,    BITMAPRES_AUTO, BITMAPRES_MANUAL);                              // 1    40
00818                                                                                                     //
00819     if (ok)                                                                                         //
00820     {                                                                                               //
00821         // If bitmap resolution is automatic, then just output a default of 150dpi for DotsPerInch  //
00822         if (pPrCtrl->GetBitmapResMethod() == BITMAPRES_MANUAL)                                      //
00823             Value = pPrCtrl->GetDotsPerInch();                                                      //
00824         else                                                                                        //
00825             Value = 150;                                                                            //
00826                                                                                                     //
00827         ok = Rec.WriteUINT32((UINT32) Value);                                                           // 4    44
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);                                                            // 1    45 TOTAL
00840     }
00841 
00842     // --- Finally, output the record
00843     if (ok)
00844         pFilter->Write(&Rec);
00845 
00846 
00847     // Undefine the macros we were using
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 >   BOOL PrintComponent::ExportImagesetting(BaseCamelotFilter *pFilter)
00863 
00864     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00865     Created:    14/8/96
00866 
00867     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to export a file.
00868     Returns:    TRUE for success
00869 
00870     Purpose:    Export a TAG_IMAGESETTING native file record
00871 
00872     SeeAlso:    PrintingRecordHandler
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);       // If we can't find imagesetting info, don't sweat it
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 >   BOOL PrintComponent::ExportColourPlate(BaseCamelotFilter *pFilter, ColourPlate *pPlate)
00937 
00938     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00939     Created:    14/8/96
00940 
00941     Inputs:     pFilter - the BaseCamelotFilter filter that is being used to export a file.
00942                 pPlate  - the plate to be exported
00943 
00944     Returns:    TRUE for success
00945 
00946     Purpose:    Export a TAG_COLOURPLATE native file record
00947 
00948     SeeAlso:    PrintingRecordHandler
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     // --- Save any referenced spot colour
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     // -- Now save the ColourPlate
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                                                                     //  Size    Total
00986     if (ok)  ok = Rec.WriteBYTE(Type);                              //  1       1
00987     if (ok)  ok = Rec.WriteReference(SpotRecordNumber);             //  4       5
00988 
00989     double temp = pPlate->GetScreenAngle();
00990     if (ok)  ok = Rec.WriteDOUBLE(temp);                            //  8       13
00991     temp = pPlate->GetScreenFrequency();
00992     if (ok)  ok = Rec.WriteDOUBLE(temp);                            //  8       21
00993                                                                     //
00994     BYTE Flags = 0x00;                                              //  1       22
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 >   void PrintComponent::ImportPrintSettings(CXaraFileRecord* Rec)
01011 
01012     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
01013     Created:    14/8/96
01014     Inputs:     pCXaraFileRecord - the record to be imported
01015 
01016     Purpose:    Load a TAG_PRINTERSETTINGS native file record
01017 
01018     SeeAlso:    PrintingRecordHandler
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     // Let the print control object know we are importing the data rather than changing it via UI
01029     // This makes sure that setting some values does not auto-update other values!
01030     pPrCtrl->StartImport();
01031 
01032     // --- Macros. These are undefined immediately at the end of this function
01033     // --- Helper macro for safely importing an enum stored as a BYTE value: 1, 2.
01034     //     Unknown enums are ignored - i.e. they retain the default program setting
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     // --- Helper macro for safely exporting an enum as a BYTE value: 1, 2, 3. Unknown enums are Input as a 1.
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     // --- Helper macro for safely exporting an enum as a BYTE value: 1, 2, 3. Unknown enums are Input as a 1.
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     // --- Helper macro to Input any 32-bit UNsigned value
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     // --- Helper macro to Input any 32-bit Signed value
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     // --- Helper macro to Input any 16-bit UNsigned value (NOTE: Casts the result to a INT32)
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     // --- Read the record
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 // Dirty bodge to ensure that all loaded XAR files use PSLEVEL_2
01138 // Job 10463: remove PS Level bits - default to Level 2
01139 //  InputEnum3(PSLevel,         PSLEVEL_AUTO, PSLEVEL_1, PSLEVEL_2);
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);   // Bit 1 indicates collated
01158             pPrCtrl->SetWholeSpread((Value & 0x02) != 0);   // Bit 2 indicates whole spread
01159             pPrCtrl->SetPrintToFile((Value & 0x04) != 0);   // Bit 3 indicates print-to-file
01160 
01161             pPrCtrl->SetTextOptions(((Value & 0x08) != 0) ? PRINTTEXTOPTIONS_ALLTEXTASSHAPES : PRINTTEXTOPTIONS_NORMAL);
01162                                                             // Bit 4 indicates print-text-as-shapes
01163         }
01164     }
01165 
01166     // Let the print control object know we have finished importing (for the moment at least)
01167     pPrCtrl->EndImport();
01168 
01169     // Undefine the macros we were using
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 >   void PrintComponent::ImportImagesetting(CXaraFileRecord* Rec)
01184 
01185     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
01186     Created:    14/8/96
01187     Inputs:     Rec - the record to be imported
01188 
01189     Purpose:    Load a TAG_IMAGESETTING native file record
01190 
01191     SeeAlso:    PrintingRecordHandler
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     // Vape any colour plates already resident in the typeset info
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());  // Slave Printers Marks off the Seps flag
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 >   void PrintComponent::ImportColourPlate(CXaraFileRecord* Rec, CamelotRecordHandler *pHandler)
01268 
01269     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
01270     Created:    14/8/96
01271     Inputs:     Rec - the record to be imported
01272                 pHandler - The 'andler wot's callin' me, so's I can find me spot culler.
01273 
01274     Purpose:    Load a TAG_COLOURPLATE native file record
01275 
01276     Notes:      To correctly set up all plates, the TypesetInfo should have been
01277                 correctly set up (by loading a TAG_IMAGESETTING record). This is
01278                 because some ColourPlate settings are regenerated from entries
01279                 saved in the TAG_IMAGESETTING record.
01280 
01281     SeeAlso:    PrintingRecordHandler
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     // If this is a spot plate, it must reference a valid spot colour
01330     if (PlateType == COLOURPLATE_SPOT &&
01331         (pCol == NULL || pCol->GetType() != COLOURTYPE_SPOT || pCol->IsDeleted()) )
01332     {
01333         // Poohs. No point in keeping this plate around
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);        // NOTE Flag is ENabled state!
01356         NewPlate->SetOverprint((Flags & 0x02) != 0);
01357     }
01358 
01359 
01360     if (ok)
01361     {
01362         // Now, it'll be quite handy if we add the new plate to the plate list!
01363         TInfo->AddPlate(NewPlate);
01364     }
01365 #endif
01366 }

Generated on Sat Nov 10 03:46:35 2007 for Camelot by  doxygen 1.4.4