BitmapRecordHandler Class Reference

Provide a bitmap record handler for the new native and web file formats. This asks the bitmap document component to import the bitmap definitions for us. More...

#include <rechbmp.h>

Inheritance diagram for BitmapRecordHandler:

CamelotRecordHandler CXaraFileRecordHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 BitmapRecordHandler ()
 ~BitmapRecordHandler ()
virtual BOOL BeginImport ()
 Initialises the bitmap record handler.
virtual UINT32GetTagList ()
 Provides the record handler system with a list of records handled by this handler.
virtual BOOL IsStreamed (UINT32 Tag)
 Function to find out if the record is streamed or not.
virtual BOOL HandleRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles the given record.
virtual BOOL HandleStreamedRecord (CXaraFile *pCXFile, UINT32 Tag, UINT32 Size, UINT32 RecordNumber)
 This is the bitmap streamed record handler. It handles the loading of bitmap definitions.
virtual BOOL HandleNodeBitmap (CXaraFileRecord *pCXaraFileRecord, INT32 Tag)
 This handles the loading and creation of node bitmaps on receiving the correct records from the main record handler.
virtual BOOL HandleXPEBitmapPlaceHolder (CXaraFileRecord *pCXaraFileRecord, INT32 Tag)
 This handles the loading and creation of kernel bitmaps to be filled in subsequently by XPE bitmap properties.

Protected Attributes

BitmapListComponentpBmpComponent

Private Member Functions

 CC_DECLARE_DYNAMIC (BitmapRecordHandler)

Detailed Description

Provide a bitmap record handler for the new native and web file formats. This asks the bitmap document component to import the bitmap definitions for us.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
See also:
bitmapDocComponent;

Definition at line 124 of file rechbmp.h.


Constructor & Destructor Documentation

BitmapRecordHandler::BitmapRecordHandler  )  [inline]
 

Definition at line 130 of file rechbmp.h.

00130 : CamelotRecordHandler() {}

BitmapRecordHandler::~BitmapRecordHandler  )  [inline]
 

Definition at line 131 of file rechbmp.h.

00131 {}


Member Function Documentation

BOOL BitmapRecordHandler::BeginImport  )  [virtual]
 

Initialises the bitmap record handler.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Parameters:
- [INPUTS]
Returns:
TRUE if ok FALSE otherwise

Errors: -

See also:
-

Reimplemented from CXaraFileRecordHandler.

Definition at line 140 of file rechbmp.cpp.

00141 {
00142     pBmpComponent = GetBitmapDocComponent();
00143 
00144     return (pBmpComponent != NULL);
00145 }

BitmapRecordHandler::CC_DECLARE_DYNAMIC BitmapRecordHandler   )  [private]
 

UINT32 * BitmapRecordHandler::GetTagList  )  [virtual]
 

Provides the record handler system with a list of records handled by this handler.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Parameters:
- [INPUTS]
Returns:
Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END
See also:
-

Implements CXaraFileRecordHandler.

Definition at line 161 of file rechbmp.cpp.

BOOL BitmapRecordHandler::HandleNodeBitmap CXaraFileRecord pCXaraFileRecord,
INT32  Tag
[virtual]
 

This handles the loading and creation of node bitmaps on receiving the correct records from the main record handler.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/6/96
Parameters:
pCXaraFileRecord = baseclass record handler [INPUTS] Tag = record tag
Returns:
-

Errors: -

See also:
-

Definition at line 371 of file rechbmp.cpp.

00372 {
00373     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"BitmapRecordHandler::HandleNodeBitmap pCXaraFileRecord is NULL");
00374 
00375     BOOL ok = TRUE;
00376 
00377     // Create a NodeBitmap ready for our use
00378     NodeBitmap * pNodeBmp = NULL;
00379     pNodeBmp = new NodeBitmap;
00380     if ((pNodeBmp == NULL) || (!pNodeBmp->SetUpPath(12,12)))
00381         return FALSE;
00382 
00383     // --------------------------------
00384     // Get details for that node bitmap 
00385     // Sort out reading the coordinates for the 4 corners of the rectangle
00386     // And apply them to the NodeBitmap
00387     DocCoord Parallel[4];       // 4 coords to represent the parallelogram that the shape fits in
00388     INT32 i;
00389     for (i = 0; i < 4; i++)
00390     {
00391         if (ok) ok = pCXaraFileRecord->ReadCoord(&Parallel[i]);
00392         pNodeBmp->Parallel[i] = Parallel[i];
00393     }
00394 
00395     // Put them into the path.
00396     pNodeBmp->InkPath.InsertMoveTo(Parallel[0]);
00397 
00398     for (i = 1; i <= 3; i++)
00399         pNodeBmp->InkPath.InsertLineTo(Parallel[i]);
00400 
00401     pNodeBmp->InkPath.InsertLineTo(Parallel[0]);
00402     pNodeBmp->InkPath.CloseSubPath();
00403 
00404     // ---------------------------------
00405     // Read in the details on the bitmap
00406     INT32 BitmapRecordRef = 0;
00407     if (ok) ok = pCXaraFileRecord->ReadINT32(&BitmapRecordRef);
00408     if (BitmapRecordRef == 0)
00409         return FALSE;
00410 
00411     KernelBitmap * pBitmap = NULL;
00412     pBitmap = GetReadBitmapReference(BitmapRecordRef);
00413     if (pBitmap == NULL)
00414         return FALSE;
00415 
00416     // Attach the bitmap to the NodeBitmap
00417     pNodeBmp->GetBitmapRef()->Attach(pBitmap, NULL); //GetDocument());
00418 
00419     pNodeBmp->InvalidateBoundingRect();
00420     if (ok) ok = InsertNode(pNodeBmp);
00421 
00422     // ---------------------------------------------
00423     // Sort out the contoning to be either on or off
00424     INT32 StartColourRecordRef = 0;
00425     INT32 EndColourRecordRef = 0;
00426     switch (Tag)
00427     {
00428         case TAG_NODE_CONTONEDBITMAP:
00429         {
00430             // Get the colour details for that contoned node bitmap 
00431             if (ok) ok = pCXaraFileRecord->ReadINT32(&StartColourRecordRef);
00432             if (ok) ok = pCXaraFileRecord->ReadINT32(&EndColourRecordRef);
00433             
00434             DocColour * pStartColour = new DocColour;
00435             if (pStartColour && ok)
00436                 ok = GetDocColour(StartColourRecordRef, pStartColour);
00437             pNodeBmp->SetStartColour(pStartColour);
00438             delete pStartColour;
00439 
00440             DocColour * pEndColour = new DocColour;
00441             if (pEndColour && ok)
00442                 ok = GetDocColour(EndColourRecordRef, pEndColour);
00443             pNodeBmp->SetEndColour(pEndColour);
00444             delete pEndColour;
00445             break;
00446         }
00447 
00448         case TAG_NODE_BITMAP:
00449         {
00450             // Plain old node bitmap so just set up the plain colours
00451             pNodeBmp->SetStartColour(NULL);
00452             pNodeBmp->SetEndColour(NULL);
00453             break;
00454         }
00455 
00456         default:
00457             ok = FALSE;
00458             ERROR3_PF(("BitmapRecordHandler::HandleNodeBitmap I don't handle records with the tag (%d)\n", Tag));
00459             break;
00460     }
00461 
00462     return ok;
00463 }

BOOL BitmapRecordHandler::HandleRecord CXaraFileRecord pCXaraFileRecord  )  [virtual]
 

Handles the given record.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/6/96
Parameters:
pCXaraFileRecord = ptr to record to handle [INPUTS]
Returns:
TRUE if handled successfuly FALSE otherwise
See also:
-

Implements CXaraFileRecordHandler.

Definition at line 240 of file rechbmp.cpp.

00241 {
00242     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"BitmapRecordHandler::HandleRecord pCXaraFileRecord is NULL");
00243 
00244     BOOL ok = TRUE;
00245 
00246     INT32 Tag = pCXaraFileRecord->GetTag();
00247     switch (Tag)
00248     {
00249         case TAG_NODE_BITMAP:
00250         {
00251             // Load in that node bitmap 
00252             ok = HandleNodeBitmap(pCXaraFileRecord, Tag);
00253             break;
00254         }
00255         case TAG_NODE_CONTONEDBITMAP:
00256         {
00257             // Load in that node contone bitmap 
00258             ok = HandleNodeBitmap(pCXaraFileRecord, Tag);
00259             break;
00260         }
00261         case TAG_DEFINEBITMAP_XPE:
00262         {
00263             // Load in the empty place marker for a XPE processed bitmap
00264             ok = HandleXPEBitmapPlaceHolder(pCXaraFileRecord, Tag);
00265             break;
00266         }
00267         
00268         default:
00269             ok = FALSE;
00270             ERROR3_PF(("BitmapRecordHandler::HandleRecord I don't handle records with the tag (%d)\n", Tag));
00271             break;
00272     }
00273 
00274     return ok;
00275 }

BOOL BitmapRecordHandler::HandleStreamedRecord CXaraFile pCXFile,
UINT32  Tag,
UINT32  Size,
UINT32  RecordNumber
[virtual]
 

This is the bitmap streamed record handler. It handles the loading of bitmap definitions.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/6/96
Parameters:
pCXFile = access to the CXaraFile class [INPUTS] Tag = the tag value Size = size of record RecordNumber = the record number in the file
Returns:
TRUE if handled ok FALSE otherwise

Errors: -

See also:
-

Reimplemented from CXaraFileRecordHandler.

Definition at line 296 of file rechbmp.cpp.

00297 {
00298     ERROR2IF(pCXFile == NULL,FALSE,"BitmapRecordHandler::HandleStreamedRecord pCXFile is NULL");
00299 
00300     BOOL ok = TRUE;
00301 
00302     switch (Tag)
00303     {
00304         case TAG_PREVIEWBITMAP_BMP:
00305         case TAG_PREVIEWBITMAP_GIF:
00306         case TAG_PREVIEWBITMAP_JPEG:
00307         case TAG_PREVIEWBITMAP_PNG:
00308         case TAG_PREVIEWBITMAP_TIFFLZW:
00309         {
00310             // We don't require it so just throw it away.
00311             TRACEUSER( "Neville", _T("BitmapRecordHandler::HandleStreamedRecord PREVIEWBITMAP\n"));
00312             // Note the current position in the file
00313             // Get the underlying file stream class, CCFile, that we are using to load the file
00314             CCLexFile* pFile = pCXFile->GetCCFile();
00315             if (pFile)
00316             {
00317                 // Move on by the size of the data in this record
00318                 FilePos pos = pFile->tellIn(); 
00319                 pFile->seekIn(pos + Size);
00320             }
00321             break;
00322         }
00323         case TAG_DEFINEBITMAP_BMP:
00324         case TAG_DEFINEBITMAP_GIF:
00325         case TAG_DEFINEBITMAP_JPEG:
00326         case TAG_DEFINEBITMAP_PNG:
00327         case TAG_DEFINEBITMAP_BMPZIP:
00328         case TAG_DEFINEBITMAP_JPEG8BPP:
00329             // Ask the bitmap document component class to import that bitmap for us
00330             if (pBmpComponent)
00331             {
00332                 TRACEUSER( "Neville", _T("BitmapRecordHandler::HandleStreamedRecord DEFINEBITMAP\n"));
00333                 ok = pBmpComponent->LoadBitmapDefinition(this, pCXFile, Tag, Size, RecordNumber);
00334             }
00335             else
00336                 ERROR3("BitmapRecordHandler::HandleStreamedRecord no pBmpComponent");
00337             break;
00338 
00339         case TAG_DEFINESOUND_WAV:
00340 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00341             TRACEUSER( "Neville", _T("BitmapRecordHandler::HandleStreamedRecord DEFINESOUND\n"));
00342             ok = SGLibOil::LoadSoundDefinition(this, pCXFile, Tag, Size, RecordNumber);
00343 #endif
00344             break;
00345 
00346         default:
00347             ok = FALSE;
00348             ERROR3_PF(("BitmapRecordHandler::HandleStreamedRecord I don't handle records with the tag (%d)\n", Tag));
00349             break;
00350     }
00351 
00352     return ok;
00353 }

BOOL BitmapRecordHandler::HandleXPEBitmapPlaceHolder CXaraFileRecord pCXaraFileRecord,
INT32  Tag
[virtual]
 

This handles the loading and creation of kernel bitmaps to be filled in subsequently by XPE bitmap properties.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/02/2004
Parameters:
pCXaraFileRecord = baseclass record handler [INPUTS] Tag = record tag
Returns:
-

Errors: -

See also:
-

Definition at line 482 of file rechbmp.cpp.

00483 {
00484     ERROR2IF(pCXaraFileRecord == NULL, FALSE,
00485                 "BitmapRecordHandler::HandleXPEBitmapPlaceHolder pCXaraFileRecord is NULL");
00486 
00487     BOOL ok = TRUE;
00488 
00489     // First get the name of the bitmap and other details stored in the record
00490 //  String_256 BitmapName;
00491 //  if (ok) ok = pCXaraFileRecord->ReadUnicode(&BitmapName);
00492 
00493     // Check that the Filter existed
00494     KernelBitmap* pBitmap = NULL;
00495 
00496     // We have no filter present to load it. In the case of RALPH and even in Camelot,
00497     // the best course of action will be to use a default bitmap instead.
00498     // In the case of Camelot, warn the user that this has happened.
00499     pBitmap = KernelBitmap::MakeKernelBitmap(NULL, NULL, TRUE);
00500 
00501     // Set the bitmap name
00502 //  pBitmap->ActualBitmap->SetName(BitmapName);
00503 
00504     // If have a genuine bitmap then add it to the loaded list
00505     // If the bitmap is null then the reference will use the default instead.
00506     if (pBitmap != NULL)
00507     {
00508         PORTNOTETRACE("other","HandleXPEBitmapPlaceHolder - Removed ImportedBitmaps usage");
00509 #ifndef EXCLUDE_FROM_XARALX
00510         pBmpComponent->GetImportList()->AddBitmap(pBitmap, pCXaraFileRecord->GetRecordNumber());
00511 #endif
00512     }
00513 
00514     return ok;
00515 }

BOOL BitmapRecordHandler::IsStreamed UINT32  Tag  )  [virtual]
 

Function to find out if the record is streamed or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/6/96
Parameters:
The tag of the record [INPUTS]
Returns:
TRUE if this is a streamed record FALSE otherwise

Errors: -

See also:
-

Reimplemented from CamelotRecordHandler.

Definition at line 190 of file rechbmp.cpp.

00191 {
00192     // We handle both types so check what we need to do by the tag we have been given
00193     BOOL Streamed = FALSE;
00194     switch (Tag)
00195     {
00196         case TAG_NODE_BITMAP:
00197         case TAG_NODE_CONTONEDBITMAP:
00198         case TAG_DEFINEBITMAP_XPE:
00199             // These are not streamed records.
00200             Streamed = FALSE;
00201             break;
00202         case TAG_PREVIEWBITMAP_BMP:
00203         case TAG_PREVIEWBITMAP_GIF:
00204         case TAG_PREVIEWBITMAP_JPEG:
00205         case TAG_PREVIEWBITMAP_PNG:
00206         case TAG_PREVIEWBITMAP_TIFFLZW:
00207         case TAG_DEFINEBITMAP_BMP:
00208         case TAG_DEFINEBITMAP_GIF:
00209         case TAG_DEFINEBITMAP_JPEG:
00210         case TAG_DEFINEBITMAP_PNG:
00211         case TAG_DEFINEBITMAP_BMPZIP:
00212         case TAG_DEFINESOUND_WAV:
00213         case TAG_DEFINEBITMAP_JPEG8BPP:
00214             // These are streamed records.
00215             Streamed = TRUE;
00216             break;
00217         default:
00218             Streamed = FALSE;
00219             ERROR3_PF(("BitmapRecordHandler::IsStreamed I don't handle records with the tag (%d)\n", Tag));
00220             break;
00221     }
00222 
00223     return Streamed;
00224 }


Member Data Documentation

BitmapListComponent* BitmapRecordHandler::pBmpComponent [protected]
 

Definition at line 153 of file rechbmp.h.


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