示例#1
0
WebCommonAttributeResult WebAddressDlg::FindCommonWebAttribute(WebAddressAttribute* pwaaReturn)
{	
	//First we need to get the current selection
	SelRange* pSelRange=GetApplication()->FindSelection();

	//If pSelRange doesn't exist, return No Selection
	if (!pSelRange)
		return WCA_NOSELECTION;	
	
	//Find the common Web Attribute on the selection
	Range::CommonAttribResult carResult;
	NodeAttribute* pnaApplied;
	
	carResult=pSelRange->FindCommonAttribute(CC_RUNTIME_CLASS(AttrWebAddress), &pnaApplied);
	
	//If this function has returned ATTR_NONE or ATTR_MANY, return our
	//analogous value
	if (carResult==SelRange::ATTR_NONE)
		return WCA_NOSELECTION;

	if (carResult==SelRange::ATTR_MANY)
		return WCA_MANY;

	//Otherwise, we know we have one Web Address attribute on the selection.

	//We must find out whether it is the default attribute

	//First extract the attribute value from the node we have found
	WebAddressAttribute* pWebAddressAttribute=
		(WebAddressAttribute*) pnaApplied->GetAttributeValue();

	WebAddressAttribute waaApplied=*pWebAddressAttribute;

	//And if the user wants this value returned, make a copy of it now
	if (pwaaReturn)
		*pwaaReturn=waaApplied;

	//And get the default Web Address attribute
	WebAddressAttribute waaDefault;
	if (AttributeManager::GetDefaultAttribute(ATTR_WEBADDRESS, &waaDefault))
	{
		//If they are the same, return WCA_DEFAULT. 
		//If they are different, return WCA_SINGLE
		if (!waaApplied.IsDifferent(&waaDefault))
			return WCA_DEFAULT;
	}
	
	return WCA_SINGLE;
	
}
示例#2
0
文件: backgrnd.cpp 项目: vata/xarino
BOOL OpBackground::GetPageColour(Spread *pSpread, KernelBitmap **ppOutBitmap, 
														DocColour **ppOutColour)
{
	ERROR2IF(pSpread == NULL,FALSE,"OpBackground::GetPageColour Bad params error!");
	ERROR2IF(ppOutBitmap == NULL || ppOutColour == NULL,FALSE,"OpBackground::GetPageColour Bad params error!");

	// Search for our special page background layer
	Layer* pFoundLayer = pSpread->FindFirstPageBackgroundLayer();
	if (pFoundLayer == NULL)
		return FALSE;

	// search for our page node
	NodeRegularShape *pNode = DoFindPageRectangle(pSpread, pFoundLayer);

	if (!pNode)
		return FALSE;

	// find the fill attribute applied to the page
	NodeAttribute *pAppliedAttr = NULL;
	pNode->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry),&pAppliedAttr);

	if (pAppliedAttr != NULL)
	{
		if (IS_A(pAppliedAttr, AttrFlatColourFill)) // flat colour fill?
		{
			// get the colour attribute
			ColourFillAttribute *pColAttr = (ColourFillAttribute *)(pAppliedAttr->GetAttributeValue());

			// set the colour pointer to the doc colour, and the bitmap pointer to NULL
			*ppOutBitmap = NULL;
			*ppOutColour = pColAttr->GetStartColour();

		}
		else if (IS_A(pAppliedAttr, AttrBitmapColourFill)) // bitmap fill
		{

			// set the colour pointer to NULL, and the bitmap pointer to the kernel bitmap
			*ppOutBitmap = ((AttrFillGeometry *)pAppliedAttr)->GetBitmap();
			*ppOutColour = NULL;
		}
		else
			return FALSE;
	}
	else
		return FALSE;

	return TRUE;
}