DocumentRecordHandler Class Reference

Handles the reading of all document records in the v2 file format. More...

#include <rechdoc.h>

Inheritance diagram for DocumentRecordHandler:

CamelotRecordHandler CXaraFileRecordHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 DocumentRecordHandler ()
 Default constructor.
 ~DocumentRecordHandler ()
virtual BOOL BeginImport ()
 Default constructor.
virtual UINT32GetTagList ()
 Provides the record handler system with a list of records handled by this handler.
virtual BOOL HandleRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles the given record.

Private Member Functions

 CC_DECLARE_DYNAMIC (DocumentRecordHandler)
void InitVars ()
 Inits all the member vars to their default settings.
BOOL HandleSpreadRecord (CXaraFileRecord *)
 Handles the given record. The record has to be a spread record.
BOOL HandleSpreadInformationRecord (CXaraFileRecord *)
 Handles the spread information record. Decodes the information and then applies it.
BOOL HandleDocumentRecord (CXaraFileRecord *)
 Handles the given record. The record has to be a document record.
BOOL HandleChapterRecord (CXaraFileRecord *)
 Handles the given record. The record has to be a chapter record.
BOOL HandleLayerRecord (CXaraFileRecord *)
 Handles the given record. The record has to be a layer record.
BOOL HandleLayerDetailsRecord (CXaraFileRecord *)
 Handles the given record. The record has to be a layer and guide layer details record.
BOOL HandleGuidelineRecord (CXaraFileRecord *)
 Handles the given record. The record has to be a guideline record.
BOOL HandleSetSentinelRecord (CXaraFileRecord *)
 Handles insertion for a NodeSetSentinel record.
BOOL HandleSetPropertyRecord (CXaraFileRecord *)
 Handles insertion for a NodeSetProperty record.
BOOL HandleBarPropertyRecord (CXaraFileRecord *)
 Handles insertion for a NodeBarProperty record.
BOOL HandleCurrentAttrsRecord (CXaraFileRecord *)
 Handles the given record. The record has to be a document record.
BOOL HandleDuplicationOffsetRecord (CXaraFileRecord *)
 Handles the given record. The record has to be a TAG_DUPLICATIONOFFSET record.
LayerFindThisLayer (UINT32 n)
 This hunts for the nth layer in the sibling list of the context node.
BOOL HandleGridAndRulerSettingsRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles grid and ruler settings record. Decodes the information and then applies it.
BOOL HandleGridAndRulerOriginRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles the grid and ruler origin record. Decodes the information and then applies it.
BOOL HandleSpreadScalingRecord (CXaraFileRecord *pCXaraFileRecord, INT32 Tag)
 Handles the spread scaling records. Decodes the information and then applies it.
BOOL HandleSpreadAnimPropertiesRecord (CXaraFileRecord *pRec)
 This provides descriptions for the document records. Handles the spread information record. Decodes the information and then applies it. Notes: Karim 07/12/2000 - modified to read in transparent GIF information.
BOOL HandleFramePropertiesRecord (CXaraFileRecord *pRec)
 Handles the Frame Layer Delay record. Decodes the information and then applies it.

Detailed Description

Handles the reading of all document records in the v2 file format.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/6/96
See also:
-

Definition at line 122 of file rechdoc.h.


Constructor & Destructor Documentation

DocumentRecordHandler::DocumentRecordHandler  ) 
 

Default constructor.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/7/96
Parameters:
- [INPUTS]
Returns:
-
See also:
-

Definition at line 155 of file rechdoc.cpp.

00156 {
00157     InitVars();
00158 }

DocumentRecordHandler::~DocumentRecordHandler  )  [inline]
 

Definition at line 129 of file rechdoc.h.

00129 {}


Member Function Documentation

BOOL DocumentRecordHandler::BeginImport  )  [virtual]
 

Default constructor.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/7/96
Parameters:
- [INPUTS]
Returns:
TRUE if ok, FALSE otherwise
See also:
-

Reimplemented from CXaraFileRecordHandler.

Definition at line 190 of file rechdoc.cpp.

00191 {
00192     // Init vars before import
00193     InitVars();
00194 
00195     return TRUE;
00196 }

DocumentRecordHandler::CC_DECLARE_DYNAMIC DocumentRecordHandler   )  [private]
 

Layer * DocumentRecordHandler::FindThisLayer UINT32  n  )  [private]
 

This hunts for the nth layer in the sibling list of the context node.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/8/96
Parameters:
n = number of the layer to find (the first layer is layer 1) [INPUTS]
Returns:
ptr to layer, or NULL if it couldn't find the nth layer
It is used when loading in a file (as opposed to importing). If a layer is read in, and there already exists a layer in the tree that corresponds to this layer, this func with find it so it can be used, instead of creating a new one
See also:
-

Definition at line 668 of file rechdoc.cpp.

00669 {
00670     if (n < 1) n = 1;
00671 
00672     Node* pNode = GetInsertContextNode();
00673     if (pNode != NULL)
00674         pNode = pNode->FindParent();
00675     if (pNode != NULL)
00676         pNode = pNode->FindFirstChild();
00677 
00678     while (pNode != NULL)
00679     {
00680         if (pNode->IsLayer())
00681         {
00682             n--;
00683             if (n == 0)
00684                 return (Layer*)pNode;
00685         }
00686 
00687         pNode = pNode->FindNext();
00688     }
00689 
00690     return NULL;
00691 }

UINT32 * DocumentRecordHandler::GetTagList  )  [virtual]
 

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

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/6/96
Returns:
Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END

Implements CXaraFileRecordHandler.

Definition at line 210 of file rechdoc.cpp.

BOOL DocumentRecordHandler::HandleBarPropertyRecord CXaraFileRecord pRec  )  [private]
 

Handles insertion for a NodeBarProperty record.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/9/99
Parameters:
pRec --- the (TAG_BARPROPERTY) record to process [INPUTS]
Returns:
TRUE if handled successfully.
See also:
DocumentRecordHandler::HandleRecord; DocumentRecordHandler::GetTagList; NodeSetProperty

Definition at line 1849 of file rechdoc.cpp.

01850 {
01851 PORTNOTE("dialog","DocumentRecordHandler::HandleBarPropertyRecord - do nothing")
01852 #ifndef EXCLUDE_FROM_XARALX
01853     ERROR2IF(pRec == 0, FALSE,
01854                 "DocumentRecordHandler::HandleBarPropertyRecord: no record");
01855     ERROR2IF_PF(pRec->GetTag() != TAG_BARPROPERTY, FALSE,
01856                 ("BarProperty: I don't handle records with the tag (%d)", pRec->GetTag()));
01857 
01858     // Find the existing NodeBarProperty (there is always one).
01859     NodeSetSentinel* pSentry = Document::GetCurrent()->GetSetSentinel();
01860     ERROR3IF(pSentry == 0, "DocumentRecordHandler::HandleBarPropertyRecord: no sentry");
01861     NodeBarProperty* pBarProp = pSentry->FindBarProperty();
01862     ERROR3IF(pBarProp == 0, "DocumentRecordHandler::HandleBarPropertyRecord: no properties");
01863 
01864     g_NoOfBarsBeforeImport = pBarProp->HowMany();
01865 
01866     // Read in the how many array entries were previously written out, if any.
01867     INT32 nBars;
01868     if (!pRec->ReadINT32(&nBars)) return FALSE;
01869     if (nBars == 0) return TRUE;
01870 
01871     // If importing then duplicate and hide the old NodeBarProperty, otherwise 
01872     // clear out all existing entries.
01873     if (IsImporting())
01874     {
01875         SelOperation* pSelOp = GetBaseCamelotFilter()->GetImportSelOp();
01876         if (pSelOp != 0)
01877         {
01878             // Try to duplicate the old bar properties.
01879             NodeBarProperty* pCopy;
01880             ALLOC_WITH_FAIL(pCopy, ((NodeBarProperty*) pBarProp->SimpleCopy()), pSelOp);
01881             if (pCopy == 0) return FALSE;
01882 
01883             // Try to attach the duplicate bar properties in the right place.
01884             pCopy->AttachNode(pSentry, LASTCHILD);
01885             HideNodeAction* pHideAct;
01886             if (AC_FAIL == HideNodeAction::Init(pSelOp, pSelOp->GetUndoActions(),
01887                                                 pCopy, TRUE, (Action**) &pHideAct))
01888                 return FALSE;
01889 
01890             // Try to hide the old bar properties, and substitute the new for the old.
01891             if (!pSelOp->DoHideNode(pBarProp, TRUE, 0, TRUE)) return FALSE;
01892             pBarProp = pCopy;
01893         }
01894     }
01895     else
01896         pBarProp->Clear();
01897 
01898     // Read in each property in ascending index order.
01899     for (INT32 i = 0; i < nBars; i++)
01900     {
01901         BarDataType bdt;
01902         BYTE nCode; 
01903         if (!pRec->ReadINT32(&bdt.Spacing) || !pRec->ReadBYTE(&nCode) || !pRec->ReadBYTE(&bdt.SameSize))
01904             return FALSE;
01905 
01906         bdt.IsLive = nCode & 1;     
01907         bdt.IsHorizontal = (nCode >> 1) & 1;
01908         bdt.RequiresShuffle = (nCode >> 2) & 1;
01909         bdt.ButtonsExtend = (nCode >> 3) & 1;
01910         bdt.ButtonsScale = (nCode >> 4) & 1;
01911         bdt.GroupsStretch = (nCode >> 5) & 1;
01912 
01913         if (pBarProp->HowMany() < MAX_BAR_PROPERTIES) pBarProp->Add(bdt);
01914     } 
01915 #endif  
01916     // Success.
01917     return TRUE;
01918 }

BOOL DocumentRecordHandler::HandleChapterRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the given record. The record has to be a chapter record.

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

Definition at line 389 of file rechdoc.cpp.

00390 {
00391     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00392     ERROR2IF(pCXaraFileRecord->GetTag() != TAG_CHAPTER,FALSE,"I don't handle this tag type");
00393 
00394     IncChapterInsertedCount();
00395 
00396     // If this is not the first chapter in the file, ignore the rest of the file
00397     if (GetChapterInsertedCount() > 1)
00398     {
00399         EndOfFile();
00400         return TRUE;
00401     }
00402 
00403     // Ignore this record if we are importing into an existing file
00404     if (IsImporting()) return TRUE;
00405 
00406     Node* pContextNode = GetInsertContextNode();
00407     ERROR2IF(pContextNode == NULL,FALSE, "What? No context node?");
00408     Node* pChapter = pContextNode->FindParent(CC_RUNTIME_CLASS(Chapter));
00409     ERROR2IF(pChapter == NULL,FALSE, "Couldn't find the chapter node");
00410 
00411     return TRUE;
00412 /*
00413     Node* pContextNode = GetInsertContextNode();
00414     ERROR2IF(pContextNode == NULL,FALSE,"What? No context node?");
00415 
00416     Node* pChapter = pContextNode->FindParent(CC_RUNTIME_CLASS(Chapter));
00417     if (pChapter!= NULL)
00418     {
00419         SetInsertContextNode(pChapter);
00420         InsertNextNodeAsSibling();
00421     }
00422 
00423     BOOL ok = FALSE;
00424 
00425     {
00426         Chapter* pNewChapter = new Chapter;
00427         if (pNewChapter != NULL)
00428             ok = InsertNode(pNewChapter);
00429 
00430         SetLastChapterInserted(pNewChapter);
00431         InsertNextNodeAsChild();
00432     }
00433 
00434     if (ok && pChapter != NULL)
00435     {
00436         pChapter->CascadeDelete();
00437         delete pChapter;
00438         pChapter = NULL;
00439     }
00440     return ok;
00441   */
00442 }

BOOL DocumentRecordHandler::HandleCurrentAttrsRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the given record. The record has to be a document record.

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

Definition at line 1935 of file rechdoc.cpp.

01936 {
01937     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
01938     ERROR2IF(!(pCXaraFileRecord->GetTag() == TAG_CURRENTATTRIBUTES || pCXaraFileRecord->GetTag() == TAG_CURRENTATTRIBUTEBOUNDS), FALSE, "I don't handle this tag type");
01939 
01940     BOOL bOK = TRUE;
01941 
01942     if (pCXaraFileRecord->GetTag() == TAG_CURRENTATTRIBUTES)
01943     {
01944         // Something clever needs to be done here to allow the child attribute TAGs
01945         // of this TAG to behave differently, and make themselves current rather than
01946         // adding themselves to the document tree.
01947         //
01948         // Set the special flag that makes InsertNode behave differently!
01949         // Keep on going until we get a TAG_UP
01950         // Then set the flag back again...
01951         // (Bodgy but quicker and simpler than deriving a special filter class to behave that way)
01952         CCRuntimeClass* pGroupType = NULL;
01953 
01954         BYTE groupid = 0;
01955         bOK = pCXaraFileRecord->ReadBYTE(&groupid);
01956 
01957         if (groupid == ATTRIBUTEGROUP_INK)
01958             pGroupType = CC_RUNTIME_CLASS(NodeRenderableInk);
01959 
01960         else if (groupid == ATTRIBUTEGROUP_TEXT)
01961             pGroupType = CC_RUNTIME_CLASS(BaseTextClass);
01962 
01963         else
01964         {
01965             ERROR3("Unknown Attribute Group ID");
01966 //          bOK = FALSE;
01967             pGroupType = NULL;  // Skip this current attr group
01968         }
01969 
01970         if (bOK && pGroupType!=NULL)
01971         {
01972             pBaseCamelotFilter->SetInsertMode(INSERTMODE_SETCURRENTATTRIBUTE, pGroupType);
01973             bOK = pBaseCamelotFilter->ReadFileUntil(TAG_UP);
01974             pBaseCamelotFilter->SetInsertMode(INSERTMODE_ATTACHTOTREE);
01975         }
01976     }
01977     else if (pCXaraFileRecord->GetTag() == TAG_CURRENTATTRIBUTEBOUNDS)
01978     {
01979         NodeAttribute* pLastCurrentAttr = pBaseCamelotFilter->GetLastCurrentAttrInserted();
01980         if (pLastCurrentAttr && pLastCurrentAttr->IsKindOf(CC_RUNTIME_CLASS(AttrFillGeometry)))
01981         {
01982             DocRect newBounds;
01983             if (bOK) bOK = pCXaraFileRecord->ReadCoord(&newBounds.lo);
01984             if (bOK) bOK = pCXaraFileRecord->ReadCoord(&newBounds.hi);
01985             ((AttrFillGeometry*)pLastCurrentAttr)->SetBoundingRect(newBounds);
01986         }
01987     }
01988 
01989     return bOK;
01990 }

BOOL DocumentRecordHandler::HandleDocumentRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the given record. The record has to be a document record.

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

Definition at line 360 of file rechdoc.cpp.

00361 {
00362     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00363     ERROR2IF(pCXaraFileRecord->GetTag() != TAG_DOCUMENT,FALSE,"I don't handle this tag type");
00364 
00365     IncDocumentInsertedCount();
00366 
00367     // If this is not the first doc in the file, ignore the rest of the file
00368     if (GetDocumentInsertedCount() > 1)
00369         EndOfFile();
00370 
00371     return TRUE;
00372 }

BOOL DocumentRecordHandler::HandleDuplicationOffsetRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the given record. The record has to be a TAG_DUPLICATIONOFFSET record.

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

Definition at line 2010 of file rechdoc.cpp.

02011 {
02012     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
02013     ERROR2IF(pCXaraFileRecord->GetTag() != TAG_DUPLICATIONOFFSET,FALSE,"I don't handle this tag type");
02014 
02015     BOOL bOK = TRUE;
02016     Document* pDoc = Document::GetCurrent();
02017     if (pDoc)
02018     {
02019         DocCoord newOffset;
02020         if (bOK) bOK = pCXaraFileRecord->ReadINT32(&(newOffset.x));
02021         if (bOK) bOK = pCXaraFileRecord->ReadINT32(&(newOffset.y));
02022         if (bOK) pDoc->SetDuplicationOffset(newOffset);
02023     }
02024 
02025     return bOK;
02026 }

BOOL DocumentRecordHandler::HandleFramePropertiesRecord CXaraFileRecord pRec  )  [private]
 

Handles the Frame Layer Delay record. Decodes the information and then applies it.

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

Definition at line 1663 of file rechdoc.cpp.

01664 {
01665     ERROR2IF(pRec == NULL,FALSE,"pCXaraFileRecord is NULL");
01666     UINT32 Tag = pRec->GetTag();
01667     ERROR2IF(Tag != TAG_LAYER_FRAMEPROPS,FALSE,"I do not handle this tag type");
01668 
01669     // Get a ptr to the last inserted layer and check for NULL.
01670     Layer* pLastLayer = GetLastLayerInserted();
01671     if (pLastLayer == NULL)
01672     {
01673         ERROR3("I don't have a 'last layer' ptr!");
01674         return TRUE;
01675     }
01676 
01677     UINT32 Delay=0;
01678     BYTE Flags = 0;
01679     BOOL ok =TRUE;
01680 
01681     // Read the record and pass the details onto the layer.
01682     if (ok) ok = pRec->ReadUINT32(&Delay);
01683     if (ok) ok = pRec->ReadBYTE(&Flags);
01684 
01685     if (ok) pLastLayer->SetFrameDelay(Delay);
01686 
01687     pLastLayer->SetSolid((Flags & TAG_LAYER_FLAG_SOLID)   != 0);
01688     pLastLayer->SetOverlay((Flags & TAG_LAYER_FLAG_OVERLAY) != 0);
01689     pLastLayer->SetHiddenFrame((Flags & TAG_LAYER_FLAG_HIDDEN) != 0);
01690 
01691     pLastLayer->SetFrame(TRUE); 
01692     // Frame layers must always be foreground layers!
01693     pLastLayer->SetBackground(FALSE); 
01694     
01695     return ok;
01696 };

BOOL DocumentRecordHandler::HandleGridAndRulerOriginRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the grid and ruler origin record. Decodes the information and then applies it.

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

Definition at line 1094 of file rechdoc.cpp.

01095 {
01096 #if !defined(EXCLUDE_FROM_RALPH)
01097     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
01098 
01099     // If we are just importing data from this document into an existing one,
01100     // then don't import this data.
01101     if (IsImporting())
01102         return TRUE;
01103     
01104     BOOL ok = TRUE;
01105 
01106     DocCoord Origin(0,0);
01107     if (ok) ok = pCXaraFileRecord->ReadCoord(&Origin);
01108 
01109     Spread* pSpread = GetSpread();
01110     ERROR2IF(pSpread == NULL,FALSE,"HandleGridAndRulerOriginRecord No spread");
01111 
01112     NodeGrid* pDefaultGrid = pSpread->FindFirstDefaultGridInSpread();
01113     ERROR2IF(pDefaultGrid == NULL,FALSE,"HandleGridAndRulerOriginRecord No default grid");
01114 
01115     pDefaultGrid->SetOrigin(Origin.x, Origin.y);    
01116 
01117     return ok;
01118 #else
01119     return TRUE;
01120 #endif
01121 }

BOOL DocumentRecordHandler::HandleGridAndRulerSettingsRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles grid and ruler settings record. Decodes the information and then applies it.

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

Definition at line 1007 of file rechdoc.cpp.

01008 {
01009 #if !defined(EXCLUDE_FROM_RALPH)
01010     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
01011 
01012     // If we are just importing data from this document into an existing one,
01013     // then don't import this data.
01014     if (IsImporting())
01015         return TRUE;
01016     
01017     BOOL ok = TRUE;
01018 
01019     double   Divisions    = 0.0;
01020     UnitType Type         = NOTYPE;
01021     UINT32    SubDivisions = 0;
01022     GridType TypeOfGrid   = RECTANGULAR;
01023     INT32    UnitsRef     = 0L;
01024     BYTE     TypeOfGridB  = (BYTE)RECTANGULAR;
01025 
01026     if (ok) ok = pCXaraFileRecord->ReadINT32(&UnitsRef);
01027     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Divisions);
01028     if (ok) ok = pCXaraFileRecord->ReadUINT32(&SubDivisions);
01029     if (ok) ok = pCXaraFileRecord->ReadBYTE(&TypeOfGridB);
01030     TypeOfGrid = (GridType)TypeOfGridB;
01031 
01032     // Convert the reference into unittype
01033     UnitListComponent * pUnitsComponent = GetUnitDocComponent();
01034     ERROR2IF(pUnitsComponent == NULL,FALSE,"HandleGridAndRulerSettingsRecord No units doc component present");
01035 
01036     Unit* pUnit = pUnitsComponent->GetReadUnitReference(UnitsRef);
01037     if (pUnit)
01038         Type = pUnit->GetUnitType();
01039     else
01040         return FALSE;
01041 
01042     Spread* pSpread = GetSpread();
01043     ERROR2IF(pSpread == NULL,FALSE,"HandleGridAndRulerSettingsRecord No spread");
01044 
01045     NodeGrid* pDefaultGrid = pSpread->FindFirstDefaultGridInSpread();
01046     ERROR2IF(pDefaultGrid == NULL,FALSE,"HandleGridAndRulerSettingsRecord No default grid");
01047     
01048     // remove it as its bound to be wrong
01049     pDefaultGrid->CascadeDelete();
01050     delete pDefaultGrid;                
01051 
01052     // Set all the global variables - What a load of B********
01053     NodeGrid::SetDefaultDivisions(Divisions);
01054     NodeGrid::SetDefaultSubdivisions(SubDivisions);
01055     NodeGrid::SetDefaultUnits(Type);
01056     NodeGrid::SetDefaultGridType(TypeOfGrid);
01057 
01058     // Make a grid
01059     // BODGE - old builds (hence docs) save the grid spacing in divisions and units but don't
01060     // account for unit scaling, so as not to change doc format new docs do the same so we must
01061     // set the grid with scaling turned off - yuk!
01062     // But surely it is best saved unscaled!
01063     BOOL Scale=FALSE;
01064     NodeGrid::MakeDefaultGrid(pSpread, Scale);
01065 
01066     /* DocRect PageRect;
01067     pDefaultGrid = pSpread->FindFirstDefaultGridInSpread();
01068     if (pSpread->GetPagesRect(&PageRect) && pDefaultGrid)
01069     {
01070         pDefaultGrid->SetOrigin(PageRect.lo.x, PageRect.lo.y);
01071     } */
01072 
01073     return ok;
01074 #else
01075     return TRUE;
01076 #endif
01077 }

BOOL DocumentRecordHandler::HandleGuidelineRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the given record. The record has to be a guideline record.

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

Definition at line 958 of file rechdoc.cpp.

00959 {
00960 #if !defined(EXCLUDE_FROM_RALPH)
00961     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00962     ERROR3IF(pCXaraFileRecord->GetTag() != TAG_GUIDELINE,"I don't handle this tag type");
00963 
00964     BYTE Type;
00965     MILLIPOINT Ordinate;
00966 
00967     BOOL ok = pCXaraFileRecord->ReadBYTE(&Type);
00968 
00969     if (ok && Type == GUIDELINE_HORZ)
00970         ok = pCXaraFileRecord->ReadYOrd(&Ordinate);
00971     else
00972         ok = pCXaraFileRecord->ReadXOrd(&Ordinate);
00973 
00974     if (ok)
00975     {
00976         NodeGuideline* pGuide = new NodeGuideline;
00977 
00978         if (pGuide != NULL)
00979         {
00980             pGuide->SetType(GuidelineType(Type));
00981             pGuide->SetOrdinate(Ordinate);
00982             ok = InsertNode(pGuide);
00983         }
00984     }
00985 
00986     return ok;
00987 #else
00988     return TRUE;
00989 #endif
00990 }

BOOL DocumentRecordHandler::HandleLayerDetailsRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the given record. The record has to be a layer and guide layer details record.

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

Definition at line 769 of file rechdoc.cpp.

00770 {
00771     UINT32 Tag = pCXaraFileRecord->GetTag();
00772 
00773     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00774     ERROR2IF(Tag != TAG_LAYERDETAILS && Tag != TAG_GUIDELAYERDETAILS,FALSE,"I don't handle this tag type");
00775 
00776     Layer* pLastLayer = GetLastLayerInserted();
00777 
00778     // If there isn't a layer to apply the info to, just ignore it
00779     if (pLastLayer == NULL)
00780     {
00781         ERROR3("I don't have a 'last layer' ptr");
00782         return TRUE;
00783     }
00784 
00785     BYTE Flags = 0;
00786     String_256 Name;
00787     INT32 ColRef = 0;
00788     DocColour Col;
00789 
00790     BOOL ok = TRUE;
00791 
00792     if (ok) ok = pCXaraFileRecord->ReadBYTE(&Flags);
00793     if (ok) ok = pCXaraFileRecord->ReadUnicode(&Name);//Name, Name.MaxLength());
00794 
00795     if (ok && Tag == TAG_GUIDELAYERDETAILS)
00796         ok = pCXaraFileRecord->ReadINT32(&ColRef);
00797 
00798 #ifdef WEBSTER
00799     if (ok)
00800     {
00801         // WEBSTER - markn 14/1/97
00802         // If it's a guide layer, make it invisible
00803         // otherwise if the layer is visible, make sure it's editable
00804 
00805         if (Tag == TAG_GUIDELAYERDETAILS)
00806             Flags &= ~TAG_LAYER_FLAG_VISIBLE;   // clear visible flag
00807         else
00808         {
00809             if (Flags & TAG_LAYER_FLAG_VISIBLE)
00810                 Flags &= ~TAG_LAYER_FLAG_LOCKED;    // visible, so clear locked flag
00811 
00812             // Markn 18/7/97
00813             // Fixed a bug whereby Webster would load in locked page background layers and
00814             // unlock them because of the two lines above.
00815             if (Flags & TAG_LAYER_FLAG_PAGEBACKGROUND)
00816                 Flags |= TAG_LAYER_FLAG_LOCKED;     // page background, so make sure it's locked
00817         }
00818     }
00819 #endif  // WEBSTER
00820 
00821     pLastLayer->SetVisible(  (Flags & TAG_LAYER_FLAG_VISIBLE)   != 0);
00822     pLastLayer->SetLocked(   (Flags & TAG_LAYER_FLAG_LOCKED)    != 0);
00823     pLastLayer->SetPrintable((Flags & TAG_LAYER_FLAG_PRINTABLE) != 0);
00824     pLastLayer->SetActive(   (Flags & TAG_LAYER_FLAG_ACTIVE)    != 0);
00825     // new 4/4/97
00826     pLastLayer->SetPageBackground((Flags & TAG_LAYER_FLAG_PAGEBACKGROUND) != 0);
00827 
00828     pLastLayer->SetBackground((Flags & TAG_LAYER_FLAG_BACKGROUND) != 0);
00829 
00830     // handle Guide Layers a little differently:
00831     if(Tag == TAG_GUIDELAYERDETAILS)
00832     {
00833         pLastLayer->SetGuide(TRUE);
00834     }
00835     else
00836     {
00837         pLastLayer->SetGuide(FALSE);
00838     }
00839 
00840     pLastLayer->SetLayerID(Name);
00841 
00842 #if !defined(EXCLUDE_FROM_RALPH)
00843     if (ok && ColRef != 0)
00844     {
00845         ok = GetDocColour(ColRef,&Col);
00846         if (ok)
00847         {
00848             IndexedColour* pIndexedColour = Col.FindParentIndexedColour();
00849             pLastLayer->SetGuideColour(pIndexedColour);
00850             pLastLayer->SetGuide(TRUE);
00851         }
00852     }
00853 #endif
00854 
00855     if (ok)
00856     {
00857         // Do some extra work on the layer, such as ensuring the layer name is unique
00858         // Ensure that if we are importing that the layers are placed in as foreground visible
00859         // and editable layers as otherwise confusion may reign.
00860         
00861         // NOTE: If not importing then Webster must not play with the PageBackground layer and
00862         // its visible and editable status
00863         
00864         if (IsImporting())
00865         {
00866             // Firstly, make sure all imported layers are printable visible editable foreground layers
00867             // but only if they are not guide layers
00868             if (!pLastLayer->IsGuide())
00869             {
00870                 // Disable the blatent lets make all layers visible code. This would mean
00871                 // that hidden layers actually appear. In cases like pills.xar, this is bad!
00872                 //pLastLayer->SetVisible(TRUE);
00873                 pLastLayer->SetLocked(FALSE);
00874                 pLastLayer->SetPrintable(TRUE);
00875             }
00876 
00877             // Ensure that all imported layers are NOT background as otherwise we will have a mixture
00878             //pLastLayer->SetBackground(FALSE);
00879 
00880             // no imported layer is going to be the active layer!
00881             pLastLayer->SetActive(FALSE);
00882 
00883             // If we have improted a page background layer then we need to do some extra work
00884             if (pLastLayer->IsPageBackground())
00885             {
00886                 // If we dont unset this then things may get confusing!
00887                 // Unlocked visible page background layers = trouble
00888                 pLastLayer->SetPageBackground(FALSE);
00889                 // If we set it as a frame layer then it wont get merged with the active layer
00890                 pLastLayer->SetFrame(TRUE);
00891                 // Mark it as hidden and solid so that it is almost as it was as a page background layer
00892                 pLastLayer->SetHiddenFrame(TRUE);
00893                 pLastLayer->SetSolid(TRUE);
00894             }
00895 
00896             // If importing do something a little more intelligent with the name matching
00897             // SJK - as a test try to keep the names the same then merge similar names at 
00898             // the last minute when importing
00899             INT32 ImportWithLayers = 1;
00900             Camelot.GetPrefValue(TEXT("Filters"), TEXT("ImportWithLayers"), &ImportWithLayers);
00901 
00902             if (ImportWithLayers == 0) // ask for unique layer names, all on new layers
00903                 pLastLayer->EnsureUniqueLayerID();
00904             else if (ImportWithLayers == 1) // stick it on the active layer
00905             {
00906                 Spread* pSpread = GetSpread();
00907 
00908                 if (pSpread)
00909                 {
00910                     // name it the same as the active layer
00911                     // and the layers will be meshed together later
00912                     Layer * pActiveLayer = pSpread->FindActiveLayer();
00913                     pLastLayer->SetLayerID(pActiveLayer->GetLayerID());
00914                 }               
00915             }
00916 
00917             String_256 CurName = pLastLayer->GetLayerID();
00918 
00919             // Has the name changed as a result of the above call?
00920             if (ImportWithLayers == 0 && CurName != Name)
00921             {
00922                 // Get a suitable prefix string (in this case "Imported ")
00923                 String_256 Prefix( _("Imported ") );
00924 
00925                 // Does the name already have the prefix string embedded in it?
00926 //              if (cc_lstristr(Name,Prefix) == NULL)
00927                 if (Name.Sub(Prefix) == 0)
00928                 {
00929                     // If not, append the prefix to the original name, and try again
00930                     Prefix += Name;
00931                     pLastLayer->SetLayerID(Prefix);
00932                     pLastLayer->EnsureUniqueLayerID();
00933                 }
00934             }
00935         }
00936         else
00937             pLastLayer->EnsureUniqueLayerID();
00938     }
00939 
00940     return ok;
00941 }

BOOL DocumentRecordHandler::HandleLayerRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the given record. The record has to be a layer record.

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

Definition at line 709 of file rechdoc.cpp.

00710 {
00711     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00712     ERROR2IF(pCXaraFileRecord->GetTag() != TAG_LAYER,FALSE,"I don't handle this tag type");
00713 
00714     IncLayerInsertedCount();
00715 
00716     BOOL ok = TRUE;
00717 
00718     Layer* pLayer = NULL;
00719     
00720     if (!IsImporting())
00721         pLayer = FindThisLayer(GetLayerInsertedCount());
00722 
00723     if (pLayer == NULL)
00724     {
00725         pLayer = new Layer;
00726 
00727         ok = FALSE;
00728         if (pLayer != NULL)
00729         {
00730             ok = InsertNode(pLayer);
00731 
00732             if (ok)
00733             {
00734                 // Set the layer name to a default
00735                 String_256 LayerName( _("Imported ") );
00736                 String_256 Suffix( _("layer") );
00737                 LayerName += Suffix;
00738                 pLayer->SetLayerID(LayerName);
00739                 pLayer->EnsureUniqueLayerID();
00740             }
00741         }
00742     }
00743 
00744     SetLastLayerInserted(pLayer);
00745     
00746     // If we haven't set it already, then set this as the first imported layer
00747     Layer * pFirstImportedLayer = GetFirstImportedLayer();
00748     if (pFirstImportedLayer == NULL)
00749         SetFirstImportedLayer(pLayer);
00750 
00751     return ok;
00752 }

BOOL DocumentRecordHandler::HandleRecord CXaraFileRecord pCXaraFileRecord  )  [virtual]
 

Handles the given record.

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

Implements CXaraFileRecordHandler.

Definition at line 253 of file rechdoc.cpp.

00254 {
00255     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00256 
00257     BOOL ok = TRUE;
00258 
00259     INT32 Tag = pCXaraFileRecord->GetTag();
00260     switch (Tag)
00261     {
00262         case TAG_DOCUMENT:
00263             ok = HandleDocumentRecord(pCXaraFileRecord);
00264             break;
00265 
00266         case TAG_CHAPTER:
00267             ok = HandleChapterRecord(pCXaraFileRecord);
00268             break;
00269 
00270         case TAG_SPREAD:
00271             ok = HandleSpreadRecord(pCXaraFileRecord);
00272             break;
00273 
00274         case TAG_SPREADINFORMATION:
00275             ok = HandleSpreadInformationRecord(pCXaraFileRecord);
00276             break;
00277         
00278         case TAG_GRIDRULERSETTINGS:
00279             ok = HandleGridAndRulerSettingsRecord(pCXaraFileRecord);
00280             break;
00281         case TAG_GRIDRULERORIGIN:
00282             ok = HandleGridAndRulerOriginRecord(pCXaraFileRecord);
00283             break;
00284 
00285         case TAG_SPREADSCALING_ACTIVE:
00286         case TAG_SPREADSCALING_INACTIVE:
00287             ok = HandleSpreadScalingRecord(pCXaraFileRecord, Tag);
00288             break;
00289 
00290         case TAG_LAYER:
00291             ok = HandleLayerRecord(pCXaraFileRecord);
00292             break;
00293 
00294         case TAG_LAYERDETAILS:
00295         case TAG_GUIDELAYERDETAILS:
00296                 ok = HandleLayerDetailsRecord(pCXaraFileRecord);
00297             break;
00298 
00299         case TAG_GUIDELINE:
00300             ok = HandleGuidelineRecord(pCXaraFileRecord);
00301             break;
00302 
00303         case TAG_SPREAD_ANIMPROPS:
00304             ok = HandleSpreadAnimPropertiesRecord(pCXaraFileRecord);
00305             break;
00306             
00307         case TAG_LAYER_FRAMEPROPS:
00308             ok = HandleFramePropertiesRecord(pCXaraFileRecord);
00309             break;
00310 
00311         case TAG_SETSENTINEL:
00312             ok = HandleSetSentinelRecord(pCXaraFileRecord);
00313             break;
00314 
00315         case TAG_SETPROPERTY:
00316             ok = HandleSetPropertyRecord(pCXaraFileRecord);
00317             break;
00318 
00319         case TAG_BARPROPERTY:
00320             ok = HandleBarPropertyRecord(pCXaraFileRecord);
00321             break;
00322 
00323         case TAG_CURRENTATTRIBUTES:
00324             ok = HandleCurrentAttrsRecord(pCXaraFileRecord);
00325             break;
00326 
00327         case TAG_CURRENTATTRIBUTEBOUNDS:
00328             ok = HandleCurrentAttrsRecord(pCXaraFileRecord);
00329             break;
00330 
00331         case TAG_DUPLICATIONOFFSET:
00332             ok = HandleDuplicationOffsetRecord(pCXaraFileRecord);
00333             break;
00334 
00335         default:
00336             ok = FALSE;
00337             ERROR3_PF(("I don't handle records with the tag (%d)\n",pCXaraFileRecord->GetTag()));
00338             break;
00339     }
00340 
00341     return ok;
00342 }

BOOL DocumentRecordHandler::HandleSetPropertyRecord CXaraFileRecord pRec  )  [private]
 

Handles insertion for a NodeSetProperty record.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/9/99
Parameters:
pRec --- the (TAG_SETPROPERTY) record to process [INPUTS]
Returns:
TRUE if handled successfully.
See also:
DocumentRecordHandler::HandleRecord; DocumentRecordHandler::GetTagList; NodeSetProperty

Definition at line 1745 of file rechdoc.cpp.

01746 {
01747     ERROR2IF(pRec == 0, FALSE,
01748                 "DocumentRecordHandler::HandleSetPropertyRecord: no record");
01749     ERROR2IF_PF(pRec->GetTag() != TAG_SETPROPERTY, FALSE,
01750                 ("SetProperty: I don't handle records with the tag (%d)", pRec->GetTag()));
01751 
01752     // Read in the property's set name and number of associated properties.
01753     String_256 strName;
01754     short n;
01755     if (!pRec->ReadUnicode(&strName) ||
01756         !pRec->ReadINT16(&n))
01757             return FALSE;
01758 
01759     // If the set already has a property then don't input.  This will reject
01760     // duplicate properties on imports. (justin)
01761 // no longer reject duplicate nodes. We need this data! Instead duplicates are removed later (sjk 21/9/00)
01762 //  if (GetDocument()->GetSetSentinel()->FindPropertyNode(strName) != 0)
01763 //      return TRUE;
01764 
01765     // Create a new set property with a full complement of default properties.
01766     NodeSetProperty* pProp = new NodeSetProperty(strName);
01767     ERRORIF( pProp == 0 || !pProp->CreateDefaults(), _R(IDE_NOMORE_MEMORY), FALSE );
01768 
01769     BOOL ok = TRUE;
01770 
01771     // Read in each property in ascending index order.  Stop reading if we reach a
01772