CDRFilter Class Reference

Corel Draw file importing class. More...

#include <cdrfiltr.h>

Inheritance diagram for CDRFilter:

VectorFilter Filter ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 CDRFilter ()
 Constructor.
BOOL Init ()
 Initialisation.
INT32 HowCompatible (PathName &Filename, ADDR HeaderStart, UINT32 HeaderSize, UINT32 FileSize)
 Examines a file to see how compatable it is with this filter.
BOOL DoImport (SelOperation *, CCLexFile *, Document *, BOOL AutoChosen=FALSE, ImportPosition *Pos=NULL, KernelBitmap **ppImportedBitmap=NULL, DocCoord *pPosTranslate=NULL, String_256 *=NULL)
BOOL DoExport (Operation *, CCLexFile *, PathName *, Document *, BOOL)
 Refuses to export a Corel Palette file.

Static Public Member Functions

static void DeleteNodeList (Node *)
 Deletes a linked list of nodes (forward direction only).
static BOOL GetCorelBBox (NodeRenderableBounded *pNode, DocRect *BBox)
 gets the Corel simple union bbox of an object
static ADDR FindDataInObject (cdrfOffsetHeader *Header, WORD Type)
 returns the address of data of the given type in an objects with a standard offset header
static BOOL AddElementsToPath (Path *pPath, INT32 NCoords, cdrfCoord *Coords, BYTE *Types, BOOL *IsClosed)
 Adds elements to a path from a CDR path data.
static BOOL AddStandardColourSet (Document *pDocument)
 Adds the standard set of colours to a Corel file.
static BOOL HasCDRFileGotCMXFile (PathName *FileName, CCLexFile *pFile=NULL)
 to find out whether a CDR file has got a CMX file in it, and therefore whether the CMX filter should grab it instead of this one

Static Public Attributes

static INT32 BitmapNumber = 0
static INT32 PatternNumber = 0

Private Member Functions

 CC_DECLARE_DYNAMIC (CDRFilter)
BOOL ClearUp (void)
 Clears up after an CDR file import.
BOOL UpdateProgress (BOOL Now=FALSE)
 Updating the progress everysooften - called at every significant place to get a nice smooth update on that progress bar thingy.
BOOL ProcessDoc (void)
 Processes the root level doc chunk of a CDR file.
BOOL ProcessPage (void)
 Processes a page list of a CDR file.
BOOL ProcessLayer (void)
 Processes a layer list of a CDR file. This is the function which actually grabs objects to convert.
BOOL ProcessObjectTree (UINT32 Level)
 process objects from the CDR file - they end up linked to pLevelNodeList.
BOOL ProcessObject (void)
 Converts an object. If there's a problem with the object, then it's skipped rather than reporting an error, and the count of problem objects incremented.
BOOL ProcessGroup (UINT32 Level, BOOL FromLink=FALSE)
 Sets up a group end action and alters the level node list to be a new list.
BOOL ProcessLink (void)
 Sets up a group end action and a post transform action and alters the level node list to be a new list.
BOOL ProcessVectorList (ADDR Block, INT32 Size)
 processes the vector list at the beginning of CDR files. This contains a list of objects which are used for things such as full colour fills, texture fills, mould shapes, that sort of thing.
BOOL ProcessVectorListEntry ()
 processes an entry in the vector list
BOOL ProcessTextList4 ()
 Processes the list of text objects for a version 4 CDR file creating text lines and textchars with partially applied attributes.
BOOL ProcessTextListItem4 ()
 Processes a item from the list of text objects for a version 4 CDR file creating text lines and textchars with partially applied attributes.
BOOL ConvertRectangle (cdrfOffsetHeader *)
BOOL ConvertEllipse (cdrfOffsetHeader *)
 generates an ellipse object
BOOL ConvertPath (cdrfOffsetHeader *)
 actually converts a path object to a node. If the object has an unexpected format, then FormatError is set and it return *TRUE* - the return value only indicated environmental errors such as lack of memory
BOOL ConvertText (cdrfOffsetHeader *)
 converts a text object to a node. If the object has an unexpected format, then FormatError is set and it return *TRUE* - the return value only indicated environmental errors such as lack of memory
BOOL ConvertText4Art (cdrfOffsetHeader *)
 converts a version 4 artisitic text object
BOOL ConvertText4Para (cdrfOffsetHeader *)
 converts a version 4 paragraph text object
BOOL ConvertText3 (cdrfOffsetHeader *)
 converts a version 3 text object to a node. If the object has an unexpected format, then FormatError is set and it return *TRUE* - the return value only indicated environmental errors such as lack of memory
BOOL ConvertBitmap (cdrfOffsetHeader *)
BOOL SetLineAttr (cdrfOffsetHeader *Object)
BOOL SetFillAttr (cdrfOffsetHeader *Object)
 sets the fill attributes
BOOL SetLineAttr3 (cdrfOffsetHeader *Object)
BOOL SetFillAttr3 (cdrfOffsetHeader *Object)
 sets the fill attributes for version 3
BOOL SetFillAttrFlat (cdrfFillHeader *Fill, INT32 Size)
 sets flat fill attributes
BOOL SetFillAttrGrad (cdrfFillHeader *Fill, INT32 Size)
 sets graduated fill attributes
BOOL SetUKFill (void)
 sets a fill attribute for unknown fills
BOOL SetLinearGrad (CDRFillInfo *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour)
 sets a linear graduated fill from fill definition in the file Copied from coreleps.cpp and modified
BOOL SetRadialGrad (CDRFillInfo *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour)
 sets a radial graduated fill from fill definition in the file
BOOL SetConicalGrad (CDRFillInfo *GFill, DocRect &BBox, DocColour *StartColour, DocColour *EndColour)
 sets a conical graduated fill from fill definition in the file Copied from coreleps.cpp and modified
BOOL SetFillAttrPattern (CDRTiledFillInfo *Info, DocColour *Colour1, DocColour *Colour2)
 set pattern fill attributes
BOOL SetFillAttrTexture (cdrfFillHeader *Fill, INT32 Size)
 sets texture fill attributes
BOOL SetFillAttrVector (CDRTiledFillInfo *Info)
 set vector fill attributes
BOOL NoFill (void)
 makes an object not filled
BOOL AddAttributesToArrowheadNode (NodeRenderableBounded *N, DocColour *Col, INT32 LineWidth, LineCapType Cap, JointType Join)
 apply attributes to a arrow head node
BOOL AddAttributesToArrowheadPath (NodePath *P, DocColour *Col, INT32 LineWidth, LineCapType Cap, JointType Join)
 apply attributes to a arrow head path
BOOL DoesPathNeedArrowheads (NodePath *P)
 To find out whether a path need attributes.
BOOL TransformArrowhead (NodeRenderableBounded *N, DocCoord *Point, DocCoord *Other, BOOL Start, INT32 LineWidth, INT32 Distance)
 transform an arrowhead path to be the correct size and orientation
BOOL AddArrowheadsToPath (DWORD StartArrow, DWORD EndArrow, DocColour *Col, INT32 LineWidth, LineCapType Cap, JointType Join)
 adds arrowheads to a path. Changes pMadeNode from a path to a group
BOOL ConvertColour (cdrfColour *Col, DocColour *Out)
 converts a colour from the CDR definition taking into account the version
BOOL IsTransformJustMatrices (ADDR Trans, INT32 Size)
 scans a transform chunk. Returns TRUE if the transform was just composed of matrices and unknown transforms.
BOOL TransformConvertedObject (NodeRenderable **N, ADDR Trans, INT32 Size, BOOL TranslateForPage=TRUE, BOOL IsAGroupTransform=FALSE, BOOL WorkAtOrigin=FALSE)
 transforms an object we converted, given a trfd chunk. If TranslateForPage is true (defaults to TRUE) then the object will also be translated to get the origin in the right place. The pointer may be modified to be a pointer to a different object. WorkAtOrigin causes the object to be translated back to the origin before being hacked apon, except if it's in a CDR3 file when it's ignored as the file is mass-translated at the end of the conversion..
BOOL TransformConvertedObjectDoMatrix (NodeRenderable **N, cdrMatrix *Ma, BOOL TranslateForPage)
 transforms an object given a CDR matrix
BOOL TransformConvertedObjectDoPerspective (NodeRenderable **N, cdrPerspective *P, BOOL TranslateShapeForPage=FALSE)
BOOL TransformConvertedObjectDoEnvelope (NodeRenderable **N, Path *P, DocRect *OriginalBBox, INT32 *Corners, BOOL TranslateShapeForPage=FALSE)
 transforms an object given a path to envelope into
BOOL TransformConvertedObjectDoExtrude (NodeRenderable **N, cdrExtrudeInfo *Info, BOOL TranslateShapeForPage=FALSE)
 performs a extrude transform
BOOL TransformConvertedObjectDoExtrudeTransPath (NodePath *pPath, cdrExtrudeInfo *Info)
 does the extrude transform on a path
BOOL GetMatrixFromTransform (Matrix *M, ADDR Trans, INT32 Size, BOOL TranslateForPage=TRUE)
 given some transform data, works out a matrix. This ignores any 3D transforms, TransformConvertedObject should be used in preference.
BOOL GetObjCorelBBox (NodeRenderableBounded *pNode, DocRect *BBox)
 gets the corel bbox of a converted object, looking up the bbox of text objects
KernelBitmapBitmapFromNodeList (Node *List)
 given a list of nodes, if it only contains one bitmap then return a pointer to that bitmap
BOOL MakeTextOnPathLinkList ()
 creates the list of paths which should be linked to text stories to get text on paths.
BOOL AttachTextToPaths ()
 attachs paths to text stories from the list of links.
BOOL CheckTextForLinks (TextStory *pTextStory, cdrfOffsetHeader *Header)
 checks to see if this text story is in the link table
BOOL GetTextStyleFromCDRStyle (CDRTextStyle *TS, WORD StyleRef, BOOL SearchForParent=TRUE)
 gets a text style from a CDR style. If it can't be found, you get the default text style. If SearchForParent is TRUE, the parent style of this style will be located
BOOL GetTextStyleFromDefn (CDRTextStyle *TS, cdrfTextInfoFontDefn *FontDefn, const CDRTextStyle *BasedOn)
 gets a font style from a font definition stored in a txsm chunk. Anything not defined comes from the BasedOn style.
BOOL ApplyTextAttr (Node *ContextNode, const CDRTextStyle *TS, const CDRTextStyle *BasedOn)
 Applies text attributes to a node from a CDRTextStyle. If BasedOn != 0 then the attributes will only be applied if they are different from those in *BasedOn.
BOOL ApplyTextAttrDoApply (Node *ContextNode, TxtBaseClassAttribute *Attr, BOOL CheckExisting)
 Given a text attribute, apply it to a node. If CheckExising is TRUE, the existing attributes will be checked, and this attribute will not be applied if one of it's type already exists.
TCHARGetFontName (WORD FontRef)
 finds a font name
BOOL GetTextStyle3 (CDRTextStyle *TS, WORD Style, CDRTextStyle *BasedOn=0)
 gets a style for version 3 text from the global text styles table
BOOL GetTextStyleFromChar4 (CDRTextStyle *TS, cdrfTextCharStyledV4 *Char, CDRTextStyle *BasedOn)
 gets a text style from a styled version 4 text character

Private Attributes

friend CDRActionTransform
friend CDRActionGroupEnd
friend CDRBitmapStore
friend CDRBitmap
DocumentpDocument
SpreadpSpread
PagepPage
CDRVersion Version
BOOL Success
RIFFFileRIFF
UndoableOperationThisOp
BOOL SlowJobStarted
UINT32 ProgressCount
BOOL InMasterPage
BOOL DoneMasterPage
BOOL DoneDoc
BOOL UseLayers
CDRAttributeStore Fills
CDRAttributeStore Outlines
CDRAttributeStore Styles
CDRFontnameStore Fonts
CDRArrowheadStore Arrowheads
CDRBitmapStore Patterns
CDRBitmapStore Bitmaps
CDRVectorStore Vectors
CDRVectorStore TextV4
CDRPageList Pages
CDRPageListItemThisPage
CDRLayerListItemThisLayer
CDRActionList Actions
CDRBBoxList TextBBoxes
INT32 PageX
INT32 PageY
BOOL Landscape
DocCoord Origin
INT32 TranslateByX
INT32 TranslateByY
INT32 ObjectsConverted
INT32 ObjectsFormatWrong
INT32 ObjectsUnknown
INT32 EnvelopesApproximated
BOOL FormatError
NodeRenderablepLevelNodeList
NodeRenderablepMadeNode
INT32 SerialNumber
BOOL ObjFilled
BOOL ObjStroked
BOOL IsText
BOOL IsTextStory
BOOL AttrsAlreadyApplied
ADDR ObjDataBlock
INT32 ObjDataBlockSize
ColourListColList
ADDR TransformChunk
INT32 TransformChunkSize
ADDR FontTableV3
INT32 FontTableEntriesV3
ADDR FontStylesV3
ADDR LinkTable
BOOL LinkTransformsExist
List TextOnPathLinks
BOOL IsTextOnAPath

Detailed Description

Corel Draw file importing class.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
21 03 95

Definition at line 764 of file cdrfiltr.h.


Constructor & Destructor Documentation

CDRFilter::CDRFilter void   ) 
 

Constructor.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
21 03 95
Parameters:
As for the Filter class [INPUTS]
Returns:
As for the Filter class
See also:
Filter

Definition at line 234 of file cdrfiltr.cpp.

00235 {
00236     // Set up filter descriptions.
00237     FilterName.Load(_R(IDT_CDRFILTER_FILTERNAME));
00238     FilterInfo.Load(_R(IDT_CDRFILTER_FILTERINFO));
00239     FilterID = FILTERID_CDR;
00240 
00241     Flags.CanImport = TRUE;
00242     Flags.CanExport = FALSE;
00243 
00244     Version = CDRVERSION_NULL;
00245 }


Member Function Documentation

BOOL CDRFilter::AddArrowheadsToPath DWORD  StartArrow,
DWORD  EndArrow,
DocColour Col,
INT32  LineWidth,
LineCapType  Cap,
JointType  Join
[private]
 

adds arrowheads to a path. Changes pMadeNode from a path to a group

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
29 03 95
Parameters:
[INPUTS] 
Returns:
error flag
See also:
Filter

Definition at line 632 of file cdroutl.cpp.

00634 {
00635     if(!IS_A(pMadeNode, NodePath))
00636         return TRUE;            // don't apply arrowheads to non path things
00637 
00638     NodePath *pPath = (NodePath *)pMadeNode;
00639 
00640     // check that the path actaully needs some arrow heads
00641     if(!DoesPathNeedArrowheads(pPath) || (StartArrow == 0 && EndArrow == 0))
00642         return TRUE;
00643     
00644     // get pointers to nodes of the arrow heads to copy
00645     NodeRenderableBounded *StartA = 0;
00646     NodeRenderableBounded *EndA = 0;
00647     INT32 StartDistance;
00648     INT32 EndDistance;
00649     if(StartArrow != 0)
00650     {
00651         BOOL NotPresent;
00652         StartA = Arrowheads.GetConvertedNode(StartArrow, &StartDistance, &NotPresent);
00653 
00654         if(StartA == 0 && NotPresent == FALSE)
00655             return FALSE;   // error occurred
00656     }
00657     if(EndArrow != 0)
00658     {
00659         BOOL NotPresent;
00660         EndA = Arrowheads.GetConvertedNode(EndArrow, &EndDistance, &NotPresent);
00661 
00662         if(EndA == 0 && NotPresent == FALSE)
00663             return FALSE;   // error occurred
00664     }
00665 
00666     // check that enough arrowheads were found to do something with
00667     if(StartA == 0 && EndA == 0)
00668         return TRUE;
00669 
00670     // get rid of any dash patterns
00671     DashRec NoDash;
00672     NoDash = SD_SOLID;
00673     SetDashPattern(NoDash);
00674 
00675     // get some info about the path
00676     DocCoord *Coords = pPath->InkPath.GetCoordArray();
00677     PathVerb *Verbs = pPath->InkPath.GetVerbArray();
00678     INT32 NCoords = pPath->InkPath.GetNumCoords();
00679     INT32 SubPathStart = -1;        // the number of the coord the sub path starts on
00680     INT32 SubPathEnd = -1;          // the number of the coord the sub path ends on
00681 
00682     // set up a pointers for the nodes we're about to create - it points to the made
00683     // at first, but shuffles on as nodes are copied. You see, we have to copy nodes which
00684     // are attached to something
00685     NodeRenderableBounded *ThisNode = pPath;
00686 
00687     // work out the trim distances
00688     double StartTrimDistance;
00689     double EndTrimDistance;
00690     if(StartA != 0)
00691         StartTrimDistance = ((double)LineWidth / (double)cdrfARROWHEAD_LINEWIDTH) * (double)StartDistance;
00692     if(EndA != 0)
00693         EndTrimDistance = ((double)LineWidth / (double)cdrfARROWHEAD_LINEWIDTH) * (double)EndDistance;
00694 
00695     // run through all the coords
00696     INT32 c;
00697     for(c = 0; c < NCoords; c++)
00698     {
00699         UINT32 Verb = Verbs[c] & ~PT_CLOSEFIGURE;
00700         BOOL CloseHere = ((Verbs[c] & PT_CLOSEFIGURE) != 0)?TRUE:FALSE;
00701         
00702         // if the verb is a close figure, this sub path is close, so we can't add arrowheads
00703         // to it. Invalidate the path start to avoid getting any arrowheads
00704         if(CloseHere)
00705             SubPathStart = -1;
00706         
00707         // if we get a new moveto and the sub path start is valid then we have a applying arrowheads
00708         // situation
00709         if((Verb == PT_MOVETO || ((c == (NCoords - 1)) && !CloseHere)) && c != 0)
00710         {
00711             // set the sub path end
00712             if(Verb == PT_MOVETO)
00713             {
00714                 // if it's a moveto, then the sub path end was at the previous coord
00715                 SubPathEnd = c - 1;
00716             } else {
00717                 // if it wasn't, then it's this one (end of path)
00718                 SubPathEnd = c;
00719             }
00720         }
00721 
00722         // have we got a valid start path marker?
00723 
00724         if(SubPathStart != -1 && SubPathEnd != -1)
00725         {
00726             // OK, now we need to trim the sub path
00727             if(StartA != 0)
00728             {
00729                 // trim the start of the path if the next element is a line
00730                 if((Verbs[SubPathStart + 1] & ~PT_CLOSEFIGURE) == PT_LINETO)
00731                 {
00732                     double dx, dy;
00733                     dx = Coords[SubPathStart + 1].x - Coords[SubPathStart].x;
00734                     dy = Coords[SubPathStart + 1].y - Coords[SubPathStart].y;
00735                     double len = sqrt((dx * dx) + (dy * dy));
00736                     // if the resulting path line leaves enough room, trim it
00737                     if((len - StartTrimDistance) >= 32.0)
00738                     {
00739                         double factor = StartTrimDistance / len;
00740                         dx *= factor;
00741                         Coords[SubPathStart].x += (INT32)dx;
00742                         dy *= factor;
00743                         Coords[SubPathStart].y += (INT32)dy;
00744                     }
00745                 }
00746                 
00747                 // now pop an arrowhead on the resulting point
00748 
00749                 // first, make a copy of our node
00750                 if(!StartA->CopyNode(ThisNode, NEXT))
00751                     return FALSE;   // error!
00752 
00753                 ThisNode = (NodeRenderableBounded *)ThisNode->FindNext();
00754                 ERROR3IF(ThisNode == 0, "CopyNode returned a zero path but didn't complain");
00755                 ERROR3IF(ThisNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded)) == FALSE, "copied thing isn't a renderable bounded node");
00756 
00757                 // transform it
00758                 if(!TransformArrowhead(ThisNode, &Coords[SubPathStart], &Coords[SubPathStart + 1],
00759                         TRUE, LineWidth, StartDistance))
00760                     return FALSE;
00761 
00762                 // and apply attributes to it
00763                 if(!AddAttributesToArrowheadNode(ThisNode, Col, LineWidth, Cap, Join))
00764                     return FALSE;       
00765             }
00766 
00767             // and the same for the end path
00768             if(EndA != 0)
00769             {
00770                 if((Verbs[SubPathEnd] & ~PT_CLOSEFIGURE) == PT_LINETO)
00771                 {
00772                     double dx, dy;
00773                     dx = Coords[SubPathEnd].x - Coords[SubPathEnd - 1].x;
00774                     dy = Coords[SubPathEnd].y - Coords[SubPathEnd - 1].y;
00775                     double len = sqrt((dx * dx) + (dy * dy));
00776                     // if the resulting path line leaves enough room, trim it
00777                     if((len - EndTrimDistance) >= 32.0)
00778                     {
00779                         double factor = EndTrimDistance / len;
00780                         dx *= factor;
00781                         Coords[SubPathEnd].x += (INT32)dx;
00782                         dy *= factor;
00783                         Coords[SubPathEnd].y += (INT32)dy;
00784                     }
00785                 }
00786                 
00787                 // now pop an arrowhead on the resulting point
00788 
00789                 // first, make a copy of our node
00790                 if(!EndA->CopyNode(ThisNode, NEXT))
00791                     return FALSE;   // error!
00792 
00793                 ThisNode = (NodeRenderableBounded *)ThisNode->FindNext();
00794                 ERROR3IF(ThisNode == 0, "CopyNode returned a zero path but didn't complain");
00795                 ERROR3IF(ThisNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded)) == FALSE, "copied thing isn't a renderable bounded node");
00796 
00797                 // transform it
00798                 if(!TransformArrowhead(ThisNode, &Coords[SubPathEnd], &Coords[SubPathEnd - 1],
00799                         FALSE, LineWidth, EndDistance))
00800                     return FALSE;
00801 
00802                 // and apply attributes to it
00803                 if(!AddAttributesToArrowheadNode(ThisNode, Col, LineWidth, Cap, Join))
00804                     return FALSE;               
00805             }
00806         
00807         }
00808             
00809         // set the new sub path start marker and invalidate the end point marker
00810         if(Verb == PT_MOVETO)
00811         {
00812             SubPathStart = c;
00813             SubPathEnd = -1;
00814         }
00815     }
00816 
00817 
00818     // ensure that the bounding rectangle is updated
00819     pPath->InvalidateBoundingRect();
00820 
00821     // get a new group node
00822     NodeGroup *pGroup = new NodeGroup;
00823     if(pGroup == 0)
00824         return FALSE;
00825     
00826     // attach everything to it
00827     pMadeNode->InsertChainSimple(pGroup, FIRSTCHILD);
00828 
00829     // and make the made node the group
00830     pMadeNode = pGroup;
00831     
00832     return TRUE;
00833 }

BOOL CDRFilter::AddAttributesToArrowheadNode NodeRenderableBounded N,
DocColour Col,
INT32  LineWidth,
LineCapType  Cap,
JointType  Join
[private]
 

apply attributes to a arrow head node

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
29 03 95
Parameters:
node,colour and line width [INPUTS]
Returns:
error flag
See also:
Filter

Definition at line 442 of file cdroutl.cpp.

00444 {
00445     if(IS_A(N, NodeGroup))
00446     {
00447         // go through all the members of the group setting their attributes
00448         Node *pNode;
00449 
00450         pNode = N->FindFirstChild();
00451 
00452         while(pNode != 0)
00453         {
00454             if(IS_A(pNode, NodePath))
00455                 AddAttributesToArrowheadPath((NodePath *)pNode, Col, LineWidth, Cap, Join);
00456             
00457             pNode = pNode->FindNext();
00458         }
00459     } else if(IS_A(N, NodePath))
00460     {
00461         // simply apply the attributes to this path
00462         AddAttributesToArrowheadPath((NodePath *)N, Col, LineWidth, Cap, Join);
00463     } else {
00464         ERROR3("Something unexpected passed to AddAttributesToArrowheadNode");
00465     }
00466 
00467     return TRUE;
00468 }

BOOL CDRFilter::AddAttributesToArrowheadPath NodePath P,
DocColour Col,
INT32  LineWidth,
LineCapType  Cap,
JointType  Join
[private]
 

apply attributes to a arrow head path

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
29 03 95
Parameters:
node,colour and line width [INPUTS]
Returns:
error flag
See also:
Filter

Definition at line 485 of file cdroutl.cpp.

00487 {
00488     if(P->InkPath.IsFilled)
00489     {
00490         // it's a filled path, so it need to be filled with the colour and have no line
00491         // colour
00492         SetPathFilled(TRUE);
00493         if(!SetLineColour(DocColour(COLOUR_TRANS)) || !SetFillColour(*Col))
00494             return FALSE;
00495     } else {
00496         // it's not a filled colour, so don't fill it and stroke it with the line width and colour
00497         if(!SetLineColour(*Col) || !SetLineWidth(LineWidth) || !SetLineCap(Cap) || !SetJoinType(Join))
00498             return FALSE;
00499     }
00500 
00501     // apply the attributes to the object
00502     // If not filled, then set the ignore bit on the fill attribute.
00503 //  if (P->InkPath.IsFilled == FALSE)
00504 //      CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE;
00505 //  else
00506         CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE;
00507 
00508     // Add attributes to the path, if they are different from the default...
00509     BOOL Result = AttributeManager::ApplyBasedOnDefaults(P, CurrentAttrs);
00510 
00511     //  DeleteCurrentAttrs();
00512     //  SetUpCurrentAttrs();
00513 
00514     // Enable the fill attribute again
00515     CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE;
00516 
00517     return Result;
00518 }

BOOL CDRFilter::AddElementsToPath Path pPath,
INT32  NCoords,
cdrfCoord Coords,
BYTE *  Types,
BOOL *  IsClosed
[static]
 

Adds elements to a path from a CDR path data.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
06/05/95
Parameters:
path to add too, number of coords, pointer to coord data, pointer to types [INPUTS]
Returns:
error flag
See also:

Definition at line 2476 of file cdrfiltr.cpp.

02477 {
02478     // go through the coordinates in the CDR path adding them to the Camelot path
02479     INT32 c;                    // coord counter
02480     UINT32 CoordType;           // type of this coordinate
02481     UINT32 Control1 = 0;        // number of first control point
02482     UINT32 Control2 = 0;        // of second
02483     DocCoord co, cn1, cn2;  // coordinates
02484     PathFlags Flags;
02485     BOOL NeedMoveTo = TRUE;
02486 
02487     if(IsClosed != 0)
02488         (*IsClosed) = FALSE;
02489     
02490     // go though converting all the coords
02491     for(c = 0; c < NCoords; c++)
02492     {
02493         CoordType = Types[c] & cdrfPATHCOORDTYPE_MASK;
02494 
02495         co.x = CDRDATA_SWORD(Coords[c].X) * CDRCOORDS_TO_MILLIPOINTS;
02496         co.y = CDRDATA_SWORD(Coords[c].Y) * CDRCOORDS_TO_MILLIPOINTS;
02497 
02498         // add in a move to if necessary
02499         if(NeedMoveTo && CoordType != cdrfPATHCOORDTYPE_MOVE)
02500         {
02501             if(!pPath->InsertMoveTo(co))
02502                 return FALSE;
02503         }
02504 
02505         NeedMoveTo = FALSE;
02506         
02507         // process the coordinate       
02508         switch(CoordType)
02509         {
02510             case cdrfPATHCOORDTYPE_MOVE:
02511                 // add a move to this path
02512                 if(!pPath->InsertMoveTo(co))
02513                     return FALSE;
02514                 break;
02515             
02516             case cdrfPATHCOORDTYPE_LINETO:
02517                 // add a line to this coord to the path
02518                 if(!pPath->InsertLineTo(co))
02519                     return FALSE;
02520                 break;
02521             
02522             case cdrfPATHCOORDTYPE_CURVE:
02523                 // check we have some control points for this curve
02524                 // a control point cannot be the first coord, so it's OK to check against 0
02525                 if(Control1 == 0 || Control2 == 0)
02526                 {
02527 TRACEUSER( "Ben", _T("No control points for curve element\n"));
02528                     break;
02529                 }
02530 
02531                 // convert the control points
02532                 cn1.x = CDRDATA_SWORD(Coords[Control1].X) * CDRCOORDS_TO_MILLIPOINTS;
02533                 cn1.y = CDRDATA_SWORD(Coords[Control1].Y) * CDRCOORDS_TO_MILLIPOINTS;
02534                 cn2.x = CDRDATA_SWORD(Coords[Control2].X) * CDRCOORDS_TO_MILLIPOINTS;
02535                 cn2.y = CDRDATA_SWORD(Coords[Control2].Y) * CDRCOORDS_TO_MILLIPOINTS;
02536                 
02537                 // create the curve
02538                 Flags.IsSelected = FALSE;
02539                 Flags.IsSmooth = Flags.IsRotate = ((Types[c] & cdrfPATHCOORDATTR_SMOOTH) != 0)?TRUE:FALSE;
02540                 Flags.IsEndPoint;
02541                 
02542                 // insert it into the path
02543                 if(!pPath->InsertCurveTo(cn1, cn2, co, &Flags))
02544                     return FALSE;
02545                 break;
02546 
02547             case cdrfPATHCOORDTYPE_CONTROL:
02548                 // shuffle the control points we've already got and add the new one
02549                 Control1 = Control2;
02550                 Control2 = c;
02551                 break;
02552             
02553             default:
02554                 // can't get here as mask won't allow any other value than the ones above.
02555                 break;
02556         }
02557 
02558         // is this a close subpath situtation?
02559         if((Types[c] & cdrfPATHCOORDATTR_CLOSE) != 0)
02560         {
02561             if(IsClosed != 0)
02562                 (*IsClosed) = TRUE;     // path has at least one closed element and should be filled
02563             
02564             // close the sub path
02565             if(CoordType != cdrfPATHCOORDTYPE_MOVE)
02566             {
02567                 if(!pPath->CloseSubPath())
02568                     return FALSE;
02569 
02570                 // ensure that the next coord is a moveto
02571                 NeedMoveTo = TRUE;
02572             }
02573         }
02574     }
02575 
02576     return TRUE;
02577 }

BOOL CDRFilter::AddStandardColourSet Document pDocument  )  [static]
 

Adds the standard set of colours to a Corel file.

/

typedef struct { BYTE C, M, Y, K; TCHAR *Name; } StandardCDRColour;

static StandardCDRColour StandardCDRColours[] = { {0, 0, 0, 100, "Black"}, {0, 0, 0, 90, "90% Black"}, {0, 0, 0, 80, "80% Black"}, {0, 0, 0, 70, "70% Black"}, {0, 0, 0, 60, "60% Black"}, {0, 0, 0, 50, "50% Black"}, {0, 0, 0, 40, "40% Black"}, {0, 0, 0, 30, "30% Black"}, {0, 0, 0, 20, "20% Black"}, {0, 0, 0, 10, "10% Black"}, {0, 0, 0, 0, "White"}, {100, 100, 0, 0, "Blue"}, {100, 0, 0, 0, "Cyan"}, {100, 0, 100, 0, "Green"}, {0, 0, 100, 0, "Yellow"}, {0, 100, 100, 0, "Red"}, {0, 100, 0, 0, "Magenta"}, {20, 80, 0, 20, "Purple"}, {0, 60, 100, 0, "Orange"}, {0, 40, 20, 0, "Pink"}, {0, 20, 20, 60, "Dark Brown"}, {20, 20, 0, 0, "Powder Blue"}, {40, 40, 0, 0, "Pastel Blue"}, {60, 40, 0, 0, "Baby Blue"}, {60, 60, 0, 0, "Electric Blue"}, {40, 40, 0, 20, "Twilight Blue"}, {60, 40, 0, 40, "Navy Blue"}, {40, 40, 0, 60, "Deep Navy Blue"}, {40, 20, 0, 40, "Desert Blue"}, {100, 20, 0, 0, "Sky Blue"}, {40, 0, 0, 0, "Ice Blue"}, {20, 0, 0, 20, "Light BlueGreen"}, {20, 0, 0, 40, "Ocean Green"}, {20, 0, 0, 60, "Moss Green"}, {20, 0, 0, 80, "Dark Green"}, {40, 0, 20, 60, "Forest Green"}, {60, 0, 40, 40, "Grass Green"}, {40, 0, 20, 40, "Kentucky Green"}, {60, 0, 40, 20, "Light Green"}, {60, 0, 60, 20, "Spring Green"}, {60, 0, 20, 0, "Turquoise"}, {60, 0, 20, 20, "Sea Green"}, {20, 0, 20, 20, "Faded Green"}, {20, 0, 20, 0, "Ghost Green"}, {40, 0, 40, 0, "Mint Green"}, {20, 0, 20, 40, "Army Green"}, {20, 0, 40, 40, "Avocado Green"}, {20, 0, 60, 20, "Martian Green"}, {20, 0, 40, 20, "Dull Green"}, {40, 0, 100, 0, "Chartreuse"}, {20, 0, 60, 0, "Moon Green"}, {0, 0, 20, 80, "Murky Green"}, {0, 0, 20, 60, "Olive Drab"}, {0, 0, 20, 40, "Khaki"}, {0, 0, 40, 40, "Olive"}, {0, 0, 60, 20, "Banana Yellow"}, {0, 0, 60, 0, "Light Yellow"}, {0, 0, 40, 0, "Chalk"}, {0, 0, 20, 0, "Pale Yellow"}, {0, 20, 40, 40, "Brown"}, {0, 40, 60, 20, "Red Brown"}, {0, 20, 60, 20, "Gold"}, {0, 60, 80, 0, "Autumn Orange"}, {0, 40, 80, 0, "Light Orange"}, {0, 40, 60, 0, "Peach"}, {0, 20, 100, 0, "Deep Yellow"}, {0, 20, 40, 0, "Sand"}, {0, 20, 40, 60, "Walnut"}, {0, 60, 60, 40, "Ruby Red"}, {0, 60, 80, 20, "Brick Red"}, {0, 60, 60, 0, "Tropical Pink"}, {0, 40, 40, 0, "Soft Pink"}, {0, 20, 20, 0, "Faded Pink"}, {0, 40, 20, 40, "Crimson"}, {0, 60, 40, 20, "Regal Red"}, {0, 60, 20, 20, "Deep Rose"}, {0, 100, 60, 0, "Neon Red"}, {0, 60, 40, 0, "Deep Pink"}, {0, 80, 40, 0, "Hot Pink"}, {0, 40, 20, 20, "Dusty Rose"}, {0, 40, 0, 60, "Plum"}, {0, 60, 0, 40, "Deep Violet"}, {0, 40, 0, 0, "Light Violet"}, {0, 40, 0, 20, "Violet"}, {0, 20, 0, 40, "Dusty Plum"}, {0, 20, 0, 20, "Pale Purple"}, {20, 60, 0, 20, "Majestic Purple"}, {20, 80, 0, 0, "Neon Purple"}, {20, 60, 0, 0, "Light Purple"}, {20, 40, 0, 20, "Twilight Violet"}, {20, 40, 0, 0, "Easter Purple"}, {20, 40, 0, 60, "Deep Purple"}, {20, 40, 0, 40, "Grape"}, {40, 60, 0, 0, "Blue Violet"}, {40, 100, 0, 0, "Blue Purple"}, {40, 80, 0, 20, "Deep River"}, {60, 80, 0, 0, "Deep Azure"}, {40, 60, 0, 40, "Storm Blue"}, {60, 80, 0, 20, "Deep Blue"}, {100, 100, 100, 100, "100C100M100Y100K"} };

/*!

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/06/95
Parameters:
[INPUTS] 
Returns:

Definition at line 1322 of file cdroutl.cpp.

01323 {
01324     ColourListComponent *pColours = 0;
01325 
01326     DocComponent *pComponent = pDocument->EnumerateDocComponents(NULL);
01327 
01328     while (pComponent != NULL)
01329     {
01330         // If this is the colour component, remember it
01331         if (pComponent->GetRuntimeClass() == CC_RUNTIME_CLASS(ColourListComponent))
01332         {
01333             pColours = (ColourListComponent *) pComponent;
01334             break;
01335         }
01336 
01337         // Look for next doc component
01338         pComponent = pDocument->EnumerateDocComponents(pComponent);
01339     }
01340 
01341     if(pColours == 0)
01342         return TRUE;            // can't be bothered to complain nicely about this very unlikely error
01343 
01344     // get an importedcolours object
01345     ImportedColours *pNewColours = new ImportedColours(pColours, FALSE);
01346     if(pNewColours == 0 || !pNewColours->Init())
01347         return FALSE;
01348 
01349     BOOL ok = TRUE;
01350 
01351     // add colours to it...
01352     ColourCMYK NewColour;
01353     for(INT32 l = 0; l < (sizeof(StandardCDRColours) / sizeof(StandardCDRColour)); l++)
01354     {
01355         NewColour.Cyan = ((double)StandardCDRColours[l].C) / 100;
01356         NewColour.Magenta = ((double)StandardCDRColours[l].M) / 100;
01357         NewColour.Yellow = ((double)StandardCDRColours[l].Y) / 100;
01358         NewColour.Key = ((double)StandardCDRColours[l].K) / 100;
01359         
01360         String_64 ColNameS(StandardCDRColours[l].Name);
01361         if(!pNewColours->AddColour(&ColNameS, &NewColour))
01362         {
01363             ok = FALSE;
01364             break;
01365         }
01366     }
01367 
01368     // add the colours to the document
01369     if(ok)
01370     {
01371         pNewColours->AddColoursToDocument();
01372     }
01373     else
01374     {
01375         pNewColours->DestroyColours();
01376     }
01377 
01378     // delete the imported colours object
01379     delete pNewColours;
01380 
01381     return ok;
01382 }

BOOL CDRFilter::ApplyTextAttr Node ContextNode,
const CDRTextStyle TS,
const CDRTextStyle BasedOn
[private]
 

Applies text attributes to a node from a CDRTextStyle. If BasedOn != 0 then the attributes will only be applied if they are different from those in *BasedOn.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/04/95
Parameters:
[INPUTS] 
Returns:
error flag
See also:

Definition at line 1623 of file cdrtext.cpp.

01624 {
01625     BOOL CheckExisting = FALSE;
01626 
01627     // if the node has children, then we want to check existing attributes
01628     if(ContextNode->FindFirstChild() != 0)
01629         CheckExisting = TRUE;
01630 
01631     // apply italicness
01632     if(BasedOn == 0 || TS->Italic != BasedOn->Italic)
01633     {
01634         // make a font size attribute
01635         TxtItalicAttribute Attr(TS->Italic);
01636     
01637         // attach
01638         if(!ApplyTextAttrDoApply(ContextNode, &Attr, CheckExisting))
01639             return FALSE;
01640     }
01641 
01642     // apply boldness
01643     if(BasedOn == 0 || TS->Bold != BasedOn->Bold)
01644     {
01645         // make a font size attribute
01646         TxtBoldAttribute Attr(TS->Bold);
01647     
01648         // attach
01649         if(!ApplyTextAttrDoApply(ContextNode, &Attr, CheckExisting))
01650             return FALSE;
01651     }
01652 
01653     // apply underline
01654     if(BasedOn == 0 || TS->Underline != BasedOn->Underline)
01655     {
01656         // make a font size attribute
01657         TxtUnderlineAttribute Attr(TS->Underline);
01658     
01659         // attach
01660         if(!ApplyTextAttrDoApply(ContextNode, &Attr, CheckExisting))
01661             return FALSE;
01662     }
01663 
01664     // apply the scriptness
01665     if(BasedOn == 0 || TS->Script != BasedOn->Script)
01666     {
01667         if(TS->Script != CDRSCRIPT_NONE)
01668         {
01669             TxtScriptAttribute Attr((TS->Script == CDRSCRIPT_SUB)?-0.1:0.33, 0.5);
01670 
01671             // attach
01672             if(!ApplyTextAttrDoApply(ContextNode, &Attr, CheckExisting))
01673                 return FALSE;
01674         }
01675     }
01676 
01677     // apply font size
01678     if(BasedOn == 0 || TS->FontSize != BasedOn->FontSize)
01679     {
01680         // make a font size attribute
01681         TxtFontSizeAttribute Attr(TS->FontSize);
01682     
01683         // attach
01684         if(!ApplyTextAttrDoApply(ContextNode, &Attr, CheckExisting))
01685             return FALSE;
01686     }
01687 
01688     // apply font name
01689 //  if(BasedOn == 0 || TS->FontName != BasedOn->FontName)
01690     if(BasedOn == 0 || TS->FontReference != BasedOn->FontReference)
01691     {
01692         // get a font handle
01693         WORD hTypeface = Fonts.GetHandleForReference(TS->FontReference);
01694         //WORD hTypeface = FONTMANAGER->GetFontHandle(&String_64(TS->FontName)); 
01695 
01696         // make a typeface attribute
01697         TxtFontTypefaceAttribute Attr(hTypeface);
01698     
01699         // attach
01700         if(!ApplyTextAttrDoApply(ContextNode, &Attr, CheckExisting))
01701             return FALSE;
01702     }
01703 
01704     // apply the justification stuff
01705     if((BasedOn == 0 || TS->Just != BasedOn->Just) && TS->Just != JLEFT)
01706     {
01707         // make a justification attribute
01708         TxtJustificationAttribute Attr(TS->Just);
01709     
01710         // attach
01711         if(!ApplyTextAttrDoApply(ContextNode, &Attr, CheckExisting))
01712             return FALSE;
01713     }
01714 
01715     // slap on a aspect ratio thingy so it gets transformed OK
01716     TxtAspectRatioAttribute Attr(1);
01717 
01718     if(!ApplyTextAttrDoApply(ContextNode, &Attr, CheckExisting))
01719         return FALSE;
01720 
01721     return TRUE;
01722 }

BOOL CDRFilter::ApplyTextAttrDoApply Node ContextNode,
TxtBaseClassAttribute Attr,
BOOL  CheckExisting