Example #1
0
BOOL LoadBrushDirect::OnLoadDocument(Document* pDoc)
{
	ERROR3IF(pDoc==NULL,"No doc pointer during PrintMarksMan::ConvertAllDocColours!");

	Node *CurNode = Node::DocFindFirstDepthFirst(pDoc);
	Node *NextNode;

	while (CurNode !=NULL)
	{
		// We may be about to chop this node out of the tree, so get the next node now
		NextNode = CurNode->DocFindNextDepthFirst();

		// Use to scan the colour fields of the attribute.
		UINT32 Context = 0;
		DocColour *pColour;

		if (CurNode->IsAnAttribute())
		{
			NodeAttribute *pNodeAttr = (NodeAttribute *) CurNode;

			// Get the next colour field from the attribute
			pColour = pNodeAttr->EnumerateColourFields(Context++);

			while (pColour != NULL)
			{
				// For each colour field, make sure the colour is a local DocColour so that
				// the sub-tree is entirely stand-alone
				if (pColour->FindParentIndexedColour() != NULL)
				{
					ColourGeneric ColDef;
					ColourContext *cc = ColourManager::GetColourContext(pColour->GetColourModel());
					ERROR3IF(cc == NULL, "Can't find colour context?!");

					// Get the IndexedColour definition as a standalone colour definition
					cc->ConvertColour(pColour->FindParentIndexedColour(), &ColDef);

					// Make the DocColour into a simple standalone "lookalike" of the parent colour
					*pColour = DocColour(pColour->GetColourModel(), &ColDef);
				}

				pColour = pNodeAttr->EnumerateColourFields(Context++);
			}
		}
		CurNode = NextNode;
	}

	// All is well we hope.
	return TRUE;
}
Example #2
0
void GlobalFractalList::GetDocumentFractalData(Document* pDoc, EnumFractalData *pData)
{
	BitmapInfo Info;
	GlobalFractalList FoundList;

	if (pDoc != NULL)
	{
		// Now Scan this document's tree for any references to a bitmap
		Node* pNode = Node::DocFindFirstDepthFirst(pDoc);
		while (pNode != NULL)
		{
			// First of all is this a NodeHidden ?
			// If so we want to look at the actual hidden node it's pointing at,
			// and scan the subtree, for Hidden bitmap references.
			if (!pNode->IsNodeHidden())
			{
				if (pNode->IsAnAttribute())		// Is this an Attribute ?
				{
					// Is it a Fractal Fill ?
					if (((NodeAttribute*)pNode)->IsAFractalFill())
					{
						AttrFractalFill* pFrac = (AttrFractalFill*)pNode;
						FillGeometryAttribute* pVal = (FillGeometryAttribute*)pFrac->GetAttributeValue();
						BOOL NewFractal = FoundList.AddFractal(pVal);

						if (NewFractal)
						{
							pData->Count++;

							if (pVal->GetBitmap() &&
								pVal->GetBitmap()->ActualBitmap)
							{
								pVal->GetBitmap()->ActualBitmap->GetInfo(&Info);
								pData->Size += Info.MemoryUsed;
							}
						}
					}
				}
			}

			// Move onto the next node in the tree
			pNode = pNode->DocFindNextDepthFirst(); 
		}
	}

	FoundList.Destroy();
}