CMXFilter Class Reference

Import filter for CMX format. More...

#include <cmxfiltr.h>

Inheritance diagram for CMXFilter:

VectorFilter Filter ListItem CCObject SimpleCCObject CMXFilter16 CMXFilter32 List of all members.

Public Member Functions

 CMXFilter ()
 Constructor for class CMXFilter.
INT32 HowCompatible (PathName &Filename, ADDR HeaderStart, UINT32 HeaderSize, UINT32 FileSize)
 Looks at the start of the file to see if we recognise it as one of ours.
BOOL DoImport (SelOperation *, CCLexFile *, Document *, BOOL AutoChosen=FALSE, ImportPosition *Pos=NULL, KernelBitmap **ppImportedBitmap=NULL, DocCoord *pPosTranslate=NULL, String_256 *=NULL)
 Read an CMX format file and convert it into Camelot tree data structures. When the file is loaded we force a redraw for the area affected by the new data At the moment the data is just put on the first layer of the first spread of the first chapter in the document, and this is a bodge. The operation is terminated (i.e. its End() function is called) if the operation completed successfully.
BOOL DoExport (Operation *, CCLexFile *, PathName *, Document *, BOOL)
 does the exportness
virtual BOOL PrepareToExport (CCLexFile *, Spread *pSpread)
 get everything ready for the old exporting business -- basically set up one of our nice render regions, write a little header and get everything under way.
virtual void CleanUpAfterExport ()
 Sorts everything out when something went wrong, or we finished normally.
virtual CMXExportDCCreateExportDC ()
 Get a device context up and running.
virtual BOOL FinishExport (void)
 Finish off the export operation -- finishes header and all that.
void SetIsDoingClipboardExport (BOOL dopb)
BOOL GetIsDoingClipboardExport (void)

Protected Member Functions

virtual CMXRenderRegionCreateRenderRegion (Matrix *pM)
 create a 32 bit render region for CMX export.
virtual Matrix GetExportTransform (Spread *pSpread)=0

Protected Attributes

BOOL DisplaySquishyWarning
BOOL IsDoingClipboardExport

Private Member Functions

 CC_DECLARE_DYNAMIC (CMXFilter)

Private Attributes

CMXExportDCExportDC
CMXRenderRegionExportRegion

Detailed Description

Import filter for CMX format.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/96

Definition at line 121 of file cmxfiltr.h.


Constructor & Destructor Documentation

CMXFilter::CMXFilter  ) 
 

Constructor for class CMXFilter.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/96
Parameters:
None [INPUTS]
Returns:
None
See also:
class VectorFilter

Definition at line 137 of file cmxfiltr.cpp.

00138 {
00139     // Set up filter descriptions.
00140     FilterName.Load(_R(IDT_CMXFILTER_FILTERNAME));
00141     FilterInfo.Load(_R(IDT_CMXFILTER_FILTERINFO));
00142     FilterID = FILTERID_NONE;
00143 
00144     Flags.CanImport = FALSE;
00145     Flags.CanExport = FALSE;
00146 
00147 #ifdef DO_EXPORT
00148     //WEBSTER-Martin-27/01/97
00149 #ifndef WEBSTER
00150     Flags.CanExport = TRUE;
00151 #endif //WEBSTER
00152 #endif
00153     
00154     ImportMsgID = _R(IDT_IMPORTMSG_CMX);
00155 
00156     ExportDC = NULL;
00157     ExportRegion = NULL;
00158     ExportMsgID = _R(IDT_EXPORTMSG_CMX);
00159 
00160     IsDoingClipboardExport = FALSE;
00161 }


Member Function Documentation

CMXFilter::CC_DECLARE_DYNAMIC CMXFilter   )  [private]
 

void CMXFilter::CleanUpAfterExport  )  [virtual]
 

Sorts everything out when something went wrong, or we finished normally.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/6/96
Parameters:
nothin' [INPUTS]
Returns:
nothin'
See also:

Definition at line 600 of file cmxfiltr.cpp.

00601 {
00602 #ifdef DO_EXPORT
00603     ExportDC->CleanUp();
00604 
00605     // get rid of that render region
00606     delete ExportRegion;
00607 #endif
00608 }

CMXExportDC * CMXFilter::CreateExportDC  )  [virtual]
 

Get a device context up and running.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/6/96
Parameters:
nothin' [INPUTS]
Returns:
the device context to use when exporting CMX files
See also:

Definition at line 624 of file cmxfiltr.cpp.

00625 {
00626 #ifdef DO_EXPORT
00627     // Create and return a DC
00628     return new CMXExportDC(this);
00629 #else
00630     return NULL;
00631 #endif
00632 }

CMXRenderRegion * CMXFilter::CreateRenderRegion Matrix pM  )  [protected, virtual]
 

create a 32 bit render region for CMX export.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/6/96
Parameters:
nothin' [INPUTS]
Returns:
render region or 0
See also:

Definition at line 648 of file cmxfiltr.cpp.

00649 {
00650 #ifdef DO_EXPORT
00651     // Don't care about clip regions when exporting - create a null region.
00652     DocRect NullClipRect;
00653     NullClipRect.MakeEmpty();
00654 
00655     // Don't use view scale; set to 1
00656     FIXED16 Scale(1);
00657 
00658     // Create the region
00659     return new CMXRenderRegion(NullClipRect, *pM, Scale);
00660 #else
00661     // Ne yuk yuk... No cmx export for you pesky ralphs...
00662     return NULL;
00663 #endif
00664 }

BOOL CMXFilter::DoExport Operation pOp,
CCLexFile pFile,
PathName pPath,
Document pDoc,
BOOL  ShowOptions
[virtual]
 

does the exportness

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/96
Parameters:
[INPUTS] 
Returns:
See also:

Reimplemented from Filter.

Definition at line 317 of file cmxfiltr.cpp.

00319 {
00320 #ifdef DO_EXPORT
00321     // Used to open the file up before starting DoExport. But this meant a cancel on the export
00322     // options dialog had filled the file, if it was already present. So now up up here if
00323     // not open already.
00324     BOOL ok;
00325     if (!pFile->isOpen())
00326     {
00327         if (pFile->IsKindOf(CC_RUNTIME_CLASS(CCDiskFile)))
00328         {
00329             ok = OpenExportFile((CCDiskFile*) pFile, pPath);
00330             if (!ok) return FALSE;
00331         }
00332         else
00333         {
00334             TRACEUSER( "JustinF", _T("Tried to open non-CCDiskFile in CMXFilter::DoExport\n"));
00335             return FALSE;
00336         }
00337     }
00338 
00339     // Set up document pointer
00340     TheDocument = pDoc;
00341 
00342     // set a nice flag
00343     DisplaySquishyWarning = FALSE;
00344 
00345     // Get pointer to the spread to export.
00346     Spread *pSpread = GetFirstSpread(pDoc);
00347 
00348     // Set up device context and render region for this export.
00349     if (!PrepareToExport(pFile, pSpread))
00350     {
00351         CleanUpAfterExport();
00352         return FALSE;
00353     }
00354 
00355     // Graeme (15-2-00) - Ben's original code used the spread's bounding box, which appears
00356     // to line in the range +/- 10,000,000. This was giving the wrong results, so I've
00357     // now modified the code to create the PageBBox from the page's bounding box.
00358     Page *pPage = ( Page * ) pSpread->FindFirstPageInSpread ();
00359     DocRect PageBBox = pPage->GetPageRect ();
00360 
00361     ExportDC->SetInfo(pOp, pPath, pDoc);
00362 
00363     // write the header
00364     if(!ExportDC->CreateHeader(&PageBBox))
00365         return FALSE;
00366 
00367     // preview bitmap...
00368     if(!IsDoingClipboardExport)
00369     {
00370         if(!ExportDC->WritePreviewBitmap())
00371             return FALSE;
00372     }
00373 
00374     // start the page
00375     if(!ExportDC->StartPage(&PageBBox))
00376         return FALSE;
00377 
00378     // Export the data to the file
00379     if (!ExportRender(ExportRegion))
00380     {
00381         CleanUpAfterExport();
00382         return FALSE;
00383     }
00384 
00385     // end the page
00386     if(!ExportDC->EndPage())
00387         return FALSE;
00388 
00389     // write the reference list
00390     if(!ExportDC->WriteReferenceList())
00391         return FALSE;
00392 
00393     // write the description sections
00394     if(!ExportDC->WriteDescriptionSections())
00395         return FALSE;
00396 
00397     // write any other sections
00398     if(!ExportDC->WriteReferSections())
00399         return FALSE;
00400 
00401     // write the index
00402     if(!ExportDC->WriteIndex())
00403         return FALSE;
00404 
00405     if(!FinishExport())
00406         return FALSE;
00407 
00408     // All done - deallocate dynamic objects and return success.
00409     CleanUpAfterExport();
00410 
00411     // Detach document
00412     TheDocument = NULL;
00413 
00414     if(DisplaySquishyWarning)
00415     {
00416         Error::SetError(_R(IDT_CMXFILTER_SQUISHWARNING), 0);
00417         InformWarning();
00418         Error::ClearError();
00419     }
00420 
00421     return TRUE;
00422 #else
00423     return FALSE;
00424 #endif
00425 }

BOOL CMXFilter::DoImport SelOperation Op,
CCLexFile pDiskFile,
Document DestDoc,
BOOL  AutoChoosen = FALSE,
ImportPosition Pos = NULL,
KernelBitmap **  ppImportedBitmap = NULL,
DocCoord pPosTranslate = NULL,
String_256 URL = NULL
[virtual]
 

Read an CMX format file and convert it into Camelot tree data structures. When the file is loaded we force a redraw for the area affected by the new data At the moment the data is just put on the first layer of the first spread of the first chapter in the document, and this is a bodge. The operation is terminated (i.e. its End() function is called) if the operation completed successfully.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/96
Parameters:
Op - pointer to the operatioj that this input process is associated with, [INPUTS] pDiskFile - the CMX file to be loaded DestDoc - the document object whcih should hold the data read in from this file URL - original URL of the imported file
Returns:
TRUE is the input operation worked, FALSE if not

Errors: Fails (returns FALSE) if the document structure is incorrect, if the CMX file contains a syntax error, of the CMX file cannot be found/opened or if its not actually an CMX file.

See also:
CMXFilter::HowCompatible

Reimplemented from Filter.

Definition at line 297 of file cmxfiltr.cpp.

00300 {
00301     return FALSE;
00302 }

BOOL CMXFilter::FinishExport void   )  [virtual]
 

Finish off the export operation -- finishes header and all that.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/06/96
Parameters:
nothin' [INPUTS]
Returns:
success
See also:

Definition at line 575 of file cmxfiltr.cpp.

00576 {
00577 #ifdef DO_EXPORT
00578     if(!ExportDC->PolishOffThatFile())
00579         return FALSE;
00580     return TRUE;
00581 #else
00582     return FALSE;
00583 #endif
00584 }

virtual Matrix CMXFilter::GetExportTransform Spread pSpread  )  [protected, pure virtual]
 

Implemented in CMXFilter16, and CMXFilter32.

BOOL CMXFilter::GetIsDoingClipboardExport void   )  [inline]
 

Definition at line 147 of file cmxfiltr.h.

00147 {return IsDoingClipboardExport;};

INT32 CMXFilter::HowCompatible PathName FileName,
ADDR  HeaderStart,
UINT32  HeaderSize,
UINT32  FileSize
[virtual]
 

Looks at the start of the file to see if we recognise it as one of ours.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/6/96
Parameters:
Filename - filename of file to check [INPUTS] HeaderStart, HeaderSize, - infomation on header of file loaded into memory FileSize - length of file (bytes)
Returns:
0 to 10. 0 means I know nothing about this file, 10 means its definitly mine
See also:
class Filters, class CDRFilter

Reimplemented from Filter.

Definition at line 266 of file cmxfiltr.cpp.

00267 {
00268     return 0;
00269 }

BOOL CMXFilter::PrepareToExport CCLexFile pFile,
Spread pSpread
[virtual]
 

get everything ready for the old exporting business -- basically set up one of our nice render regions, write a little header and get everything under way.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/6/96
Parameters:
disk file to pop things out to, spread to do funky things to [INPUTS]
Returns:
whether it fell over or not, really.
See also:

Definition at line 517 of file cmxfiltr.cpp.

00518 {
00519 #ifdef DO_EXPORT
00520     // Get the position of the first page, and use this to set the origin.
00521     Page *pPage = pSpread->FindFirstPageInSpread(); 
00522     ENSURE(pPage != NULL, "Spread has no pages");
00523     ERRORIF(pPage == NULL, _R(IDT_DOC_BADSTRUCTURE), FALSE);
00524 
00525     // Create a new render region to export to:
00526     Matrix Mat = GetExportTransform(pSpread);
00527     ExportRegion = CreateRenderRegion(&Mat);
00528 
00529     if (ExportRegion == NULL)
00530         return FALSE;
00531 
00532     // Created the 'file' DC for rendering and try to open the specified file.
00533     ExportDC = CreateExportDC();
00534 
00535     if (ExportDC == NULL)
00536         return FALSE;
00537 
00538     TRY
00539     {
00540         ExportDC->Init(pFile, ExportRegion, IS_A(this, CMXFilter16)?FALSE:TRUE, IsDoingClipboardExport);
00541     }
00542     CATCH(CFileException, e)
00543     {
00544         // Could not open the export file - return error
00545         return FALSE;
00546     }
00547     END_CATCH
00548 
00549     // Attach to the right device.
00550     View* pView = View::GetCurrent();
00551     ERROR2IF(!pView, FALSE, "No current View to attach in CMXFilter::PrepareForExport");
00552     ExportRegion->AttachDevice(pView, ExportDC, pSpread);
00553         
00554     // All ok
00555     return TRUE;
00556 #else
00557     return FALSE;
00558 #endif
00559 }

void CMXFilter::SetIsDoingClipboardExport BOOL  dopb  )  [inline]
 

Definition at line 146 of file cmxfiltr.h.

00146 {IsDoingClipboardExport = dopb;};


Member Data Documentation

BOOL CMXFilter::DisplaySquishyWarning [protected]
 

Definition at line 153 of file cmxfiltr.h.

CMXExportDC* CMXFilter::ExportDC [private]
 

Definition at line 159 of file cmxfiltr.h.

CMXRenderRegion* CMXFilter::ExportRegion [private]
 

Definition at line 160 of file cmxfiltr.h.

BOOL CMXFilter::IsDoingClipboardExport [protected]
 

Definition at line 155 of file cmxfiltr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:38 2007 for Camelot by  doxygen 1.4.4