/******************************************************************************************** > BitmapExportOptions *MakeBitmapExportOptions::MakeCopy() Author: Neville_Humphrys (Xara Group Ltd) <*****@*****.**> from Stefan code Created: 2/7/97 Purpose: Makes a copy object of this object See Also: BitmapExportOptions::CopyFrom(); BitmapExportOptions::MakeCopy(); ********************************************************************************************/ BitmapExportOptions *MakeBitmapExportOptions::MakeCopy() { // Get the runtime class info on this object CCRuntimeClass *pCCRuntimeClass = GetRuntimeClass(); // Create another object of the same type MakeBitmapExportOptions *temp = (MakeBitmapExportOptions *) pCCRuntimeClass->CreateObject(); if (temp != NULL) temp->CopyFrom(this); // copy the contents accross return temp; }
void CachedFractal::SetCachedFractal(FillGeometryAttribute* NewFrac) { CCRuntimeClass* ObjectType = NewFrac->GetRuntimeClass(); FillGeometryAttribute* FracClone = (FillGeometryAttribute*)ObjectType->CreateObject(); NewFrac->CacheFractalData(FracClone); KernelBitmap* Bmp = new KernelBitmap(NewFrac->GetBitmap()->ActualBitmap, TRUE); FracClone->GetBitmapRef()->SetBitmap(Bmp); // Bmp->IncUsageCount(); Fractal = FracClone; }
BOOL FreeHandEPSFilter::SaveCurrentFill() { // get rid of any stored fill if(OldFill != 0) delete OldFill; // create a copy of the current fill attribute CCRuntimeClass* ObjectType = CurrentAttrs[ATTR_FILLGEOMETRY].pAttr->GetRuntimeClass(); AttributeValue* AttrClone = (AttributeValue*)ObjectType->CreateObject(); if(AttrClone == 0) return FALSE; AttrClone->SimpleCopy(CurrentAttrs[ATTR_FILLGEOMETRY].pAttr); // set the old fill pointer to the nice clone we've made OldFill = AttrClone; return TRUE; }
BOOL RenderStack::Copy(const RenderStack *Other, RenderRegion *pRegion) { ERROR3IF(Other == NULL || pRegion == NULL, "Illegal NULL params"); // WEBSTER - markn 15/8/97 // This has bee taken out of Webster builds as it can cause fatal access violations with Paper render regions. // It is new path processor code that not's totally bug-free, and as path processors are not used in Webster, // it can be safely taken out. #ifndef WEBSTER // Make sure all attributes are properly popped && deinitialised, so that any used // PathProcessors are correctly removed, etc // (Note: This doesn't deinit the DEFAULT attributes, which we hope will never use // PathProcessors - this should be OK, because the places where this is called from // (at present) always make sure all PathProcessors are properly cleaned up too) CleanUpBeforeDestruct(pRegion); #endif // WEBSTER // Make sure we have an empty stack to work with if (TheStack!=NULL) { // Empty the current stack before copying the new one onto it // For every item in the stack, check to see if it is 'temporary'. If it is, // we can't use it in our stack - we must take a copy. for (UINT32 i=0; i<Top; i++) { // Get rid of all the temp attrs in the stack if (TheStack[i].Temporary) { // Delete this tempory attr. CC_ASSERT_VALID(TheStack[i].pAttrValue); delete TheStack[i].pAttrValue; } } // then get rid of the stack itself CCFree(TheStack); TheStack=NULL; ContextLevel = 0; StackLimit = 0; Top = 0; } // Sanity check ENSURE(TheStack == NULL,"RenderStack::Copy called on a non-empty stack"); #if FALSE // Jason (7/3/97) // Copying the stack like this is rampant. We must render all the attributes across onto // the new stack, so that they are properly stacked and initialised /* // Copy stack variables ContextLevel = Other->ContextLevel; StackLimit = Other->StackLimit; Top = Other->Top; // The other stack may be empty, which will often be the case when merging as it may // not have started rendering yet. if (Other->TheStack == NULL) { // Just to be on the safe side TheStack = NULL; // We're done. return TRUE; } // Allocate the same amount of memory for the stack TheStack = (AttributeRec *) CCMalloc(StackLimit * ITEM_SIZE); if (TheStack == NULL) return FALSE; // Copy the other render region's stack data into this new stack memcpy(TheStack, Other->TheStack, StackLimit * ITEM_SIZE); // For every item in the stack, check to see if it is 'temporary'. If it is, // we can't use it in our stack - we must take a copy. for (UINT32 i = 0; i < Top; i++) { if (TheStack[i].Temporary) { // Get the runtime class info on this object CCRuntimeClass *pCCRuntimeClass = TheStack[i].pAttrValue->GetRuntimeClass(); // Create another object of the same type AttributeValue *pNewAttr = (AttributeValue *) pCCRuntimeClass->CreateObject(); if (pNewAttr == NULL) { // Failed to create object - quit with error, but first ensure that this // stack is limited to the items copied so far. Otherwise the destructor // will attempt to delete objects that belong to the other stack. Top = i; return FALSE; } // Object created ok - get the object to copy its contents across. pNewAttr->SimpleCopy(TheStack[i].pAttrValue); // Put it in the stack TheStack[i].pAttrValue = pNewAttr; } } */ #else if (Other->TheStack == NULL) return(TRUE); UINT32 LastContextLevel = 0; // Copy all attributes across to the new stack by rendering them into the provided render region. // If we aren't "pRegion->TheStack" then we've just lost our paddle, and we're being sucked up the creek... for (UINT32 i = 0; i < Other->Top; i++) { // Make sure we copy context level information across too - if the context level changed, we must // save the context level now. if (LastContextLevel != Other->TheStack[i].ContextLevel) pRegion->SaveContext(); // Get each attribute to render into our render region AttributeValue *pAttrVal = Other->TheStack[i].pAttrValue; // If it's temporary, then replace it with a unique copy for this render region if (Other->TheStack[i].Temporary) { // Get the runtime class info on this object CCRuntimeClass *pCCRuntimeClass = Other->TheStack[i].pAttrValue->GetRuntimeClass(); // Create another object of the same type pAttrVal = (AttributeValue *) pCCRuntimeClass->CreateObject(); if (pAttrVal == NULL) return FALSE; // Object created ok - get the object to copy its contents across. pAttrVal->SimpleCopy(Other->TheStack[i].pAttrValue); } // and render the attribute into this render region pAttrVal->Render(pRegion, Other->TheStack[i].Temporary); } #endif // It worked return TRUE; }