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     // property index that this build doesn't know about.
01773     while (n--)
01774     {
01775         short nType;
01776         if (!pRec->ReadINT16(&nType))
01777         {
01778             ok = FALSE;
01779             break;
01780         }
01781         if (nType >= SGNameProp::nPropertyCount)
01782             break;
01783         if (!pProp->GetProperty(nType)->Read(pRec))
01784         {
01785             ok = FALSE;
01786             break;
01787         }
01788     }
01789 
01790     // the data in this property node is not correct
01791     // the default data for a property node is used instead
01792     // which the user shouldn't notice much of a change
01793     if (!ok)
01794     {
01795         delete pProp;
01796         pProp = NULL;
01797         // Create a new set property with a full complement of default properties.
01798         pProp = new NodeSetProperty(strName);
01799         ERRORIF(pProp == 0 || !pProp->CreateDefaults(), _R(IDE_NOMORE_MEMORY), FALSE );
01800     }
01801 
01802     pProp->m_Imported = TRUE;
01803 
01804     // Insert the property into the tree.
01805     if (!InsertNode(pProp))
01806         return FALSE;
01807 
01808     // If importing into a document, rather than loading, then try to create undo
01809     // actions for the new attachments.  In an extremely bodgy way we also create
01810     // undo records for the TemplateAttributes we've imported.
01811     if (IsImporting())
01812     {
01813         SelOperation* pSelOp = GetBaseCamelotFilter()->GetImportSelOp();
01814         if (pSelOp != 0)
01815         {
01816             HideNodeAction* pHideAct;
01817             if (AC_FAIL == HideNodeAction::Init(pSelOp, pSelOp->GetUndoActions(),
01818                                                 pProp, TRUE, (Action**) &pHideAct) )
01819                     return FALSE;
01820 
01821             TemplateAttribute* pAttr = GetDocument()->GetSetSentinel()->GetNameAttr(strName);
01822             //ERROR3IF(pAttr == 0, "DocumentRecordHandler::HandleSetPropertyRecord: no name");
01823 
01824             if (pAttr && AC_FAIL == HideNodeAction::Init(pSelOp, pSelOp->GetUndoActions(),
01825                                                 pAttr, TRUE, (Action**) &pHideAct) )
01826                     return FALSE;
01827 
01828         }
01829     }
01830 
01831     // Success.
01832     return TRUE;
01833 }

BOOL DocumentRecordHandler::HandleSetSentinelRecord CXaraFileRecord pRec  )  [private]
 

Handles insertion for a NodeSetSentinel record.

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

Definition at line 1712 of file rechdoc.cpp.

01713 {
01714     ERROR2IF(pRec == 0, FALSE,
01715                 "DocumentRecordHandler::HandleSetSentinelRecord: no record");
01716     ERROR2IF_PF(pRec->GetTag() != TAG_SETSENTINEL, FALSE,
01717                 ("SetSentinel: I don't handle records with the tag (%d)", pRec->GetTag()));
01718 
01719     // If this is not the first SetSentinel handled then ignore the rest of the file.
01720     IncSetSentinelInsertedCount();
01721     if (GetSetSentinelInsertedCount() > 1) EndOfFile();
01722 
01723     // Tell the handler to insert the following records as children of the sentinel.
01724     SetInsertContextNode(GetDocument()->GetSetSentinel());
01725     InsertNextNodeAsChild();
01726 
01727     // Success.
01728     return TRUE;
01729 }

BOOL DocumentRecordHandler::HandleSpreadAnimPropertiesRecord CXaraFileRecord pRec  )  [private]
 

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.

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

Definition at line 1578 of file rechdoc.cpp.

01579 {
01580     // Ignore this record if we are importing into an existing file
01581     if (IsImporting())
01582         return TRUE;
01583 
01584     UINT32 Tag = pRec->GetTag();
01585     ERROR2IF(pRec == NULL,FALSE,"pCXaraFileRecord is NULL");
01586     ERROR2IF(Tag != TAG_SPREAD_ANIMPROPS,FALSE,"I do not handle this tag type!");
01587 
01588     // Get a ptr to the last spread and test for NULL.
01589     Spread* pLastSpread = GetLastSpreadInserted();
01590     if (pLastSpread == NULL)
01591     {
01592         ERROR3("I don't have a 'last spread' ptr");
01593         return TRUE;
01594     }
01595 
01596     BOOL ok = TRUE;
01597 
01598     // Read the Animation information.
01599     UINT32  Loop                =0;             
01600     UINT32  GlobalDelay         =0;     
01601     UINT32  Dither              =0;         
01602     UINT32  WebPalette          =0;     
01603     UINT32  ColoursPalette      =0; 
01604     UINT32  NumColsInPalette    =0; 
01605     UINT32  FlagsWord           =0;
01606 
01607     if (ok)
01608         ok = pRec->ReadUINT32(&Loop);   
01609     if (ok)
01610         ok = pRec->ReadUINT32(&GlobalDelay);
01611     if (ok)
01612         ok = pRec->ReadUINT32(&Dither);
01613     if (ok)
01614         ok = pRec->ReadUINT32(&WebPalette);
01615     if (ok)
01616         ok = pRec->ReadUINT32(&ColoursPalette);
01617     if (ok)
01618         ok = pRec->ReadUINT32(&NumColsInPalette);
01619     if (ok)
01620         ok = pRec->ReadUINT32(&FlagsWord);
01621 
01622     // Decode the flags word into its component parts 
01623     BOOL UseSystemColours   = FALSE;
01624     BOOL BgTransparent      = FALSE;
01625 
01626     // <SpreadAnimationFlags : WORD>    Flags for the current animation properties.
01627     // SpreadAnimationFlags ::= UseSystemColours
01628     // UseSystemColours flag to say whether we add system colours to the exported palettes
01629     UseSystemColours    = ((FlagsWord & 1) ? TRUE : FALSE);
01630 
01631     // BgTransparent flag says whether or not we're creating a transparent GIF or not.
01632     // To be compatible with CX2, BgTransparent is set if (FlagsWord & 2) is zero,
01633     // as CX2 always does background transparent GIFs and didn't have this new bit.
01634     BgTransparent       = ((FlagsWord & 2) ? FALSE : TRUE);
01635 
01636     // Apply these details to the spread.
01637     if (ok && pLastSpread)
01638     {
01639         // Set the details in the layer.
01640         /*BOOL Worked =*/ pLastSpread->SetSpreadAnimPropertiesParam(Loop, GlobalDelay,(DITHER)Dither,(WEB_PALETTE)WebPalette,
01641                                                                 (PALETTE_COLOURS)ColoursPalette, NumColsInPalette,
01642                                                                 UseSystemColours, BgTransparent);
01643     }
01644     return ok;
01645 };

BOOL DocumentRecordHandler::HandleSpreadInformationRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the spread information 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:
-

Definition at line 578 of file rechdoc.cpp.

00579 {
00580     // Ignore this record if we are importing into ac existing file
00581     if (IsImporting())
00582         return TRUE;
00583 
00584     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00585 
00586     Spread* pLastSpread = GetLastSpreadInserted();
00587 
00588     // If there isn't a spread to apply the info to, just ignore it
00589     if (pLastSpread == NULL)
00590     {
00591         ERROR3("I don't have a 'last spread' ptr");
00592         return TRUE;
00593     }
00594 
00595     BOOL ok = TRUE;
00596 
00597     // Width, Height of page
00598     MILLIPOINT Width = 0;
00599     MILLIPOINT Height = 0;
00600     if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
00601     if (ok) ok = pCXaraFileRecord->ReadINT32(&Height);
00602     
00603     // <Margin : MILLIPOINT>    The margin to add around all four sides of the pages in the spread to make up the pasteboard. 
00604     // <Bleed : MILLIPOINT> Bleed margin to add around all pages in this spread. (0 means none)
00605     MILLIPOINT Margin = 0;
00606     MILLIPOINT Bleed = 0;
00607     if (ok) ok = pCXaraFileRecord->ReadINT32(&Margin);
00608     if (ok) ok = pCXaraFileRecord->ReadINT32(&Bleed);
00609 
00610     // <SpreadFlags : BYTE> Flags for the current spread.
00611     // SpreadFlags ::= DoublePageSpread | ShowDropShadow 
00612     // ShowDropShadow flag to say whether we apply a page shadow behind the page
00613     // DoublePageSpread flag to say whether one or two pages are present 
00614     BOOL Dps = TRUE;
00615     BOOL ShowDropShadow = TRUE;
00616     BYTE FlagsWord = 0; 
00617     if (ok) ok = pCXaraFileRecord->ReadBYTE(&FlagsWord);
00618     if (FlagsWord & 1)
00619         Dps = TRUE;
00620     else
00621         Dps = FALSE; 
00622     if (FlagsWord & 2)
00623         ShowDropShadow = TRUE;
00624     else
00625         ShowDropShadow = FALSE; 
00626 
00627     // If everything has been read in ok then go and apply those settings to the current
00628     // spread
00629 //  Document* pDoc = GetDocument();
00630     if (ok && pLastSpread && Width > 0 && Height > 0)
00631     {
00632         // This function also sets the fold linea automatically
00633         /*BOOL Worked =*/ pLastSpread->SetPageSize(Width, Height, Margin, Bleed, Dps, ShowDropShadow);
00634 
00635         if (!IsImporting())
00636         {
00637             // Only change the the import coord origin if are not importing into another document
00638             // When importing into an existing document, the import origin would have already been set
00639             // (e.g. to the drag & drop point)
00640 
00641             // We have altered the coordinates origin by this so we must update it
00642             DocRect PagesRect;
00643             if (pLastSpread->GetPagesRect(&PagesRect))
00644                 SetCoordOrigin(PagesRect.lo);
00645         }
00646     }   
00647 
00648     return ok;
00649 }

BOOL DocumentRecordHandler::HandleSpreadRecord CXaraFileRecord pCXaraFileRecord  )  [private]
 

Handles the given record. The record has to be a spread 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:
-

Definition at line 459 of file rechdoc.cpp.

00460 {
00461     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
00462     ERROR2IF(pCXaraFileRecord->GetTag() != TAG_SPREAD,FALSE,"I don't handle this tag type");
00463 
00464     IncSpreadInsertedCount();
00465 
00466     // If this is not the first spread in the file, ignore the rest of the file
00467     if (GetSpreadInsertedCount() <= 1)
00468     {
00469         // Mainstream code used between 1994 and 2006
00470         //
00471         // Ignore this record if we are importing into an existing file
00472         if (IsImporting())
00473             return TRUE;
00474 
00475         Node* pContextNode = GetInsertContextNode();
00476         ERROR2IF(pContextNode == NULL, FALSE, "What? No context node?");
00477 
00478         // JCF: bodge insertion context.
00479         if (IS_A(pContextNode, NodeSetSentinel))
00480         {
00481             SetInsertContextNode(0);
00482             pContextNode = GetInsertContextNode();
00483         }
00484 
00485         Spread* pSpread = (Spread*) pContextNode->FindParent(CC_RUNTIME_CLASS(Spread));
00486         ERROR2IF(pSpread == NULL, FALSE, "Can't find the spread");
00487 
00488         SetLastSpreadInserted(pSpread);
00489         SetInsertContextNode(pSpread);
00490         InsertNextNodeAsChild();
00491 
00492         Layer* pLayer = pSpread->FindFirstLayer();
00493         if (pLayer != NULL)
00494         {
00495             SetInsertContextNode(pLayer);
00496             InsertNextNodeAsChild();
00497         }
00498 
00499         return TRUE;
00500     }
00501     else
00502     {
00503         // Multi-spread code written before 1994, resurrected in 2006 by Phil
00504         //
00505         // For some reason the above code assumes that a spread already
00506         // exists and simply "overloads" it.
00507         // Some of the logic below creates grid and page nodes in a similar
00508         // vein. Not sure why...
00509         //
00510         Node* pContextNode = GetInsertContextNode();
00511         ERROR2IF(pContextNode == NULL,FALSE,"What? No context node?");
00512 
00513         // JCF: bodge insertion context.
00514         if (IS_A(pContextNode, NodeSetSentinel))
00515         {
00516             SetInsertContextNode(0);
00517             pContextNode = GetInsertContextNode();
00518         }
00519 
00520         Node* pSpread = pContextNode->FindParent(CC_RUNTIME_CLASS(Spread));
00521         if (pSpread != NULL)
00522         {
00523             SetInsertContextNode(pSpread);
00524             InsertNextNodeAsSibling();
00525         }
00526 
00527         BOOL ok = FALSE;
00528 
00529         {
00530             Spread* pNewSpread = new Spread;
00531             if (pNewSpread != NULL)
00532                 ok = InsertNode(pNewSpread);
00533 
00534             if (ok)
00535             {
00536                 SetLastSpreadInserted(pNewSpread);
00537                 InsertNextNodeAsChild();
00538 
00539                 NodeGrid::MakeDefaultGrid(pNewSpread);
00540 
00541                 Page* pPage = new Page;
00542                 ok = (pPage != NULL);
00543 
00544                 if (ok)
00545                     pPage->AttachNode(pNewSpread,LASTCHILD);
00546 
00547                 SetInsertContextNode(pNewSpread);
00548                 InsertNextNodeAsChild();
00549             }
00550         }
00551 
00552         if (!ok && pSpread != NULL)
00553         {
00554             pSpread->CascadeDelete();
00555             delete pSpread;
00556             pSpread = NULL;
00557         }
00558         return ok;
00559     }
00560 }

BOOL DocumentRecordHandler::HandleSpreadScalingRecord CXaraFileRecord pCXaraFileRecord,
INT32  Tag
[private]
 

Handles the spread scaling records. 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] Tag = tag for this record
Returns:
TRUE if handled successfuly FALSE otherwise
See also:
Document::ImportViewInfo;

Definition at line 1140 of file rechdoc.cpp.

01141 {
01142 #if !defined(EXCLUDE_FROM_RALPH)
01143     ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
01144 
01145     // If we are just importing data from this document into an existing one,
01146     // then don't import this data.
01147     if (IsImporting())
01148         return TRUE;
01149     
01150     BOOL ok = TRUE;
01151 
01152     BOOL Active = FALSE;
01153     if (Tag == TAG_SPREADSCALING_ACTIVE)
01154         Active= TRUE;
01155     
01156     double      DrawingScaleValue   = 1.0;
01157     INT32       DrawingUnits        = 0L;
01158     double      RealScaleValue      = 1.0;
01159     INT32       RealUnits           = 0L;
01160 //  UnitType    DrawingType         = NOTYPE;
01161 //  UnitType    RealType            = NOTYPE;
01162     BOOL        DrawingPrefix       = FALSE;
01163     BOOL        RealPrefix          = FALSE;
01164     String_32   DrawingAbbr;
01165     String_32   RealAbbr;
01166 
01167     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&DrawingScaleValue);
01168     if (ok) ok = pCXaraFileRecord->ReadINT32(&DrawingUnits);
01169     if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&RealScaleValue);
01170     if (ok) ok = pCXaraFileRecord->ReadINT32(&RealUnits);
01171 
01172     // Any problems then return immediately
01173     if (!ok)
01174         return FALSE;
01175 
01176     // Convert the reference into unittype
01177     UnitListComponent * pUnitsComponent = GetUnitDocComponent();
01178     ERROR2IF(pUnitsComponent == NULL,FALSE,"HandleSpreadScalingRecord No units doc component present");
01179 
01180     Unit* pDrawingUnit = pUnitsComponent->GetReadUnitReference(DrawingUnits);
01181     if (pDrawingUnit)
01182     {
01183         DrawingAbbr = pDrawingUnit->GetSpecifier();
01184         DrawingPrefix = pDrawingUnit->IsPrefix();
01185     }
01186     else
01187         return FALSE;
01188 
01189     Unit* pRealUnit = pUnitsComponent->GetReadUnitReference(RealUnits);
01190     if (pRealUnit)
01191     {
01192         RealAbbr = pRealUnit->GetSpecifier();
01193         RealPrefix = pRealUnit->IsPrefix();
01194     }
01195     else
01196         return FALSE;
01197 
01198     //if (RealType == NOTYPE || DrawingType == NOTYPE)
01199     //  ERROR2(FALSE,"HandleSpreadScalingRecord bad real and/or drawing unit types");
01200 
01201     Spread* pSpread = GetSpread();
01202     ERROR2IF(pSpread == NULL,FALSE,"HandleSpreadScalingRecord No spread");
01203 
01204     DimScale* pDimScale = pSpread->GetPtrDimScale();
01205     ERROR2IF(pDimScale == NULL,FALSE,"HandleSpreadScalingRecord No pDimScale");
01206 
01207     // Set up the scale factor strings with this new info
01208     // Could do with functions to set the scale factor and units directly but if that's the
01209     // way DimScale wants it then thats the way it is going to get it!
01210     String_32 DrawingScale;
01211     String_32 RealScale;
01212     INT32 DecimalPlaces  = 6;
01213     if (DrawingPrefix)
01214     {
01215         DrawingScale += DrawingAbbr;
01216     }
01217     if (ok) ok = Convert::DoubleToString( DrawingScaleValue, &DrawingScale, DecimalPlaces);
01218     if (!DrawingPrefix)
01219     {
01220         DrawingScale += DrawingAbbr;
01221     }
01222 
01223     if (RealPrefix)
01224         RealScale += RealAbbr;
01225     if (ok) ok = Convert::DoubleToString( RealScaleValue, &RealScale, DecimalPlaces);
01226     if (!RealPrefix)
01227         RealScale += RealAbbr;
01228     
01229     if (ok)
01230     {
01231         // Set up a possibly new active state
01232         pDimScale->SetActiveState(Active);
01233         // Now set up all the other aspects
01234         ok = pDimScale->SetDrawingScaleStr(DrawingScale);
01235         if (ok) ok = pDimScale->SetRealScaleStr(RealScale);
01236         if (ok) ok = pDimScale->SetScaleFactor();
01237     }
01238 
01239 #ifdef __WXMAC__
01240 PORTNOTE("MacPort", "Horrendous bodge - One of the above functions returns ok = FALSE. Another ReadDOUBLE problem?")
01241 return TRUE;
01242 #endif
01243 
01244     return ok;
01245 #else
01246     return TRUE;
01247 #endif
01248 }

void DocumentRecordHandler::InitVars  )  [private]
 

Inits all the member vars to their default settings.

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

Definition at line 173 of file rechdoc.cpp.

00174 {
00175 }


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