Exemplo n.º 1
0
BOOL CDRFilter::SetLineAttr(cdrfOffsetHeader *Object)
{
	if(Version == CDRVERSION_3)
	{
		return SetLineAttr3(Object);
	}
		
	// find the reference...
	DWORD *pReference = (DWORD *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_LINE);

	// if the pointer to the reference is zero, then the reference is probably
	// within some random style definition
	if(pReference == 0)
	{
		// OK, try and find a style number within the style reference
		WORD *pStyleReference = (WORD *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_STYLE);

		if(pStyleReference != 0)
		{
			// OK, see if we can find a the style...
			cdrfStyle *pStyle;
			INT32 StyleSize;

			if((pStyle = (cdrfStyle *)Styles.Find(*pStyleReference, &StyleSize)) != 0)
			{
				// OK, got a style... now find a fill reference within it
				pReference = (DWORD *)FindDataInObject(&pStyle->Header, cdrfSTYLEOFFSETTYPE_OUTLINE);
			}
		}
	}
	
	cdrfOutline *Out;
	INT32 OutSize;
	
	if(pReference == 0 || (Out = (cdrfOutline *)Outlines.Find(*pReference, &OutSize)) == 0
			|| OutSize < sizeof(cdrfOutline))
	{
		// if no outline data, or outline definitions couldn't be found, or outline
		// definition is too small, set up the default line attributes
		if(!SetLineWidth(cdrfOUTLINE_DEFAULT_WIDTH))
			return FALSE;

	PColourCMYK cmyk;
	cmyk.Cyan = cmyk.Magenta = cmyk.Yellow = 0;
	cmyk.Key = 255;

	DocColour Col;
	Col.SetCMYKValue(&cmyk);
	
		if(!SetLineColour(Col))
			return FALSE;

		return TRUE;
	}

	// check that this thingy should have an outline
	if((CDRDATA_WORD(Out->Flags) & cdrfOUTLINEFLAGS_NOOUTLINE) != 0)
	{
		if (!SetLineColour(DocColour(COLOUR_TRANS)))
			return FALSE;

		return TRUE;
	}

	// convert the line colour
	DocColour Col;
	ConvertColour(&Out->Colour, &Col);

	// find the line width
	INT32 LineWidth = CDRDATA_WORD(Out->LineThickness) * CDRCOORDS_TO_MILLIPOINTS;

	if(LineWidth > MAX_LINE_WIDTH)
		LineWidth = MAX_LINE_WIDTH;
	
	// find the join type
	JointType JType;
	switch(CDRDATA_WORD(Out->JoinStyle))
	{
		case cdrfJOINSTYLE_SQUARE:	JType = MitreJoin;		break;
		case cdrfJOINSTYLE_ROUNDED:	JType = RoundJoin;		break;
		default:
		case cdrfJOINSTYLE_BEVEL:	JType = BevelledJoin;	break;
	}
	
	// set the cap style
	LineCapType CType;
	switch(CDRDATA_WORD(Out->EndStyle))
	{
		case cdrfENDSTYLE_BUTT:		CType = LineCapButt;	break;
		case cdrfENDSTYLE_ROUNDED:	CType = LineCapRound;	break;
		default:
		case cdrfENDSTYLE_SQUARE:	CType = LineCapSquare;	break;

	}

	// set the dash pattern
	DashRec Dash;
	DashElement DashArray[cdrfMAX_DASH_ELEMENTS];
	if(CDRDATA_WORD(Out->NDashSegments) > 0 && (CDRDATA_WORD(Out->Flags) & cdrfOUTLINEFLAGS_NODASH) == 0)
	{
		// set a dash pattern
		INT32 NSeg = CDRDATA_WORD(Out->NDashSegments);
		if(NSeg > cdrfMAX_DASH_ELEMENTS)
			NSeg = cdrfMAX_DASH_ELEMENTS;

		INT32 l;
		for(l = 0; l < NSeg; l++)
		{
			DashArray[l] = CDRDATA_WORD(Out->DashSegments[l]) * LineWidth;
		}

		Dash.Elements = NSeg;
		Dash.DashStart = 0;
		Dash.ElementData = DashArray;

		Dash.LineWidth = LineWidth;
		Dash.ScaleWithLineWidth = TRUE;
		Dash.DashID = -1;
	}
	else
	{
		// no dash pattern
		Dash = SD_SOLID;
	}

	// set the attributes
	if(!SetLineWidth(LineWidth) || !SetLineColour(Col) || !SetJoinType(JType)
			|| !SetLineCap(CType) || !SetDashPattern(Dash))
		return FALSE;

	// check for arrowheads
	if(CDRDATA_DWORD(Out->StartArrowReference) != 0 || CDRDATA_DWORD(Out->EndArrowReference) != 0)
	{
		// apply the attributes to the object
		// If not filled, then set the ignore bit on the fill attribute.
		if (ObjFilled == FALSE)
			CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE;

		// Add attributes to the path, if they are different from the default...
		AttributeManager::ApplyBasedOnDefaults(pMadeNode, CurrentAttrs);

	//	DeleteCurrentAttrs();
 	//	SetUpCurrentAttrs();

		// Enable the fill attribute again
		CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE;

		// ensure that the attributes won't be applied again
		AttrsAlreadyApplied = TRUE;

		// apply arrow heads to the path
		AddArrowheadsToPath(CDRDATA_DWORD(Out->StartArrowReference), CDRDATA_DWORD(Out->EndArrowReference),
				&Col, LineWidth, CType, JType);
	}

	return TRUE;
}
Exemplo n.º 2
0
BOOL CDRFilter::SetLineAttr3(cdrfOffsetHeader *Object)
{
	cdrfOutlineV3 *Out = (cdrfOutlineV3 *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_LINE);
	
	if(Out == 0)
	{
		// if no outline data, or outline definitions couldn't be found, or outline
		// definition is too small, set up the default line attributes
		if(!SetLineWidth(cdrfOUTLINE_DEFAULT_WIDTH))
			return FALSE;

		PColourCMYK cmyk;
		cmyk.Cyan = cmyk.Magenta = cmyk.Yellow = 0;
		cmyk.Key = 255;

		DocColour Col;
		Col.SetCMYKValue(&cmyk);
	
		if(!SetLineColour(Col))
			return FALSE;

		return TRUE;
	}

	// check that this thingy should have an outline
	if((Out->Flags & cdrfOUTLINEFLAGSV3_STROKED) == 0)
	{
		if (!SetLineColour(DocColour(COLOUR_TRANS)))
			return FALSE;

		return TRUE;
	}

	// convert the line colour
	DocColour Col;
	ConvertColour((cdrfColour *)&Out->Colour, &Col);

	// find the line width
	INT32 LineWidth = CDRDATA_WORD(Out->LineThickness) * CDRCOORDS_TO_MILLIPOINTS;

	if(LineWidth > MAX_LINE_WIDTH)
		LineWidth = MAX_LINE_WIDTH;
	
	// find the join type
	JointType JType;
	switch(CDRDATA_WORD(Out->JoinStyle))
	{
		case cdrfJOINSTYLE_SQUARE:	JType = MitreJoin;		break;
		case cdrfJOINSTYLE_ROUNDED:	JType = RoundJoin;		break;
		default:
		case cdrfJOINSTYLE_BEVEL:	JType = BevelledJoin;	break;
	}
	
	// set the cap style
	LineCapType CType;
	switch(Out->EndStyle)  // byte
	{
		case cdrfENDSTYLE_BUTT:		CType = LineCapButt;	break;
		case cdrfENDSTYLE_ROUNDED:	CType = LineCapRound;	break;
		default:
		case cdrfENDSTYLE_SQUARE:	CType = LineCapSquare;	break;

	}

	// set the dash pattern
/*	DashRec Dash;
	DashElement DashArray[cdrfMAX_DASH_ELEMENTS];
	if((ObjectFlagsV3 & cdrfOBJFLAGSV3_NODASH) == 0 && Out->NDashSegments > 0)		// byte
	{
		// set a dash pattern
		INT32 NSeg = CDRDATA_WORD(Out->NDashSegments);
		if(NSeg > cdrfMAX_DASH_ELEMENTS)
			NSeg = cdrfMAX_DASH_ELEMENTS;

		INT32 l;
		for(l = 0; l < NSeg; l++)
		{
			DashArray[l] = Out->DashSegments[l] * LineWidth;  // byte
		}

		Dash.Elements = NSeg;
		Dash.DashStart = 0;
		Dash.ElementData = DashArray;

		Dash.LineWidth = LineWidth;
		Dash.ScaleWithLineWidth = TRUE;
		Dash.DashID = -1;
	}
	else
	{
		// no dash pattern
		Dash = SD_SOLID;
	}
*/
	// set the attributes
	if(!SetLineWidth(LineWidth) || !SetLineColour(Col) || !SetJoinType(JType)
			|| !SetLineCap(CType)/* || !SetDashPattern(Dash)*/)
		return FALSE;

	// check for arrowheads
	if(CDRDATA_DWORD(Out->StartArrowReference) != 0 || CDRDATA_DWORD(Out->EndArrowReference) != 0)
	{
		// apply the attributes to the object
		// If not filled, then set the ignore bit on the fill attribute.
		if (ObjFilled == FALSE)
			CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE;

		// Add attributes to the path, if they are different from the default...
		AttributeManager::ApplyBasedOnDefaults(pMadeNode, CurrentAttrs);

		// Enable the fill attribute again
		CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE;

		// ensure that the attributes won't be applied again
		AttrsAlreadyApplied = TRUE;

		// apply arrow heads to the path
		AddArrowheadsToPath(CDRDATA_DWORD(Out->StartArrowReference), CDRDATA_DWORD(Out->EndArrowReference),
				&Col, LineWidth, CType, JType);
	}

	return TRUE;
}