void CCAttrMap::TransformForBrush(TransformBase& Trans) { CCRuntimeClass *pType; void *pVal; for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { GetNextAssoc(Pos,pType,pVal); if (pVal != NULL) { NodeAttribute* pNodeAttr = (NodeAttribute *)pVal; // check that we are not about to set line width to zero if( pNodeAttr->IsALineWidthAttr() && Trans.TransLines != FALSE ) { double Test = Trans.GetScalar().MakeDouble() * (double)((AttrLineWidth*)pNodeAttr)->Value.LineWidth; // TRACEUSER( "Diccon", _T("Scale line width by %f\n"), Test); if (Test <= 1.0) { // TRACEUSER( "Diccon", _T("Setting line width scaling OFF\n")); Trans.TransLines = FALSE; } } if (pNodeAttr->NeedsToRenderAtEachBrushStroke()) pNodeAttr->Transform(Trans); } } }
void CCAttrMap::TransformBrushFills(TransformBase& Trans) { CCRuntimeClass *pType; void *pVal; for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { GetNextAssoc(Pos,pType,pVal); if (pVal != NULL) { NodeAttribute* pNodeAttr = (NodeAttribute *)pVal; // check that we are not about to set line width to zero if( pNodeAttr->IsALineWidthAttr() && Trans.TransLines != FALSE ) { INT32 Test = labs( INT32(Trans.GetScalar().MakeDouble() * ((AttrLineWidth*)pNodeAttr)->Value.LineWidth) ); if (Test <= 10) Trans.TransLines = FALSE; } if (!pNodeAttr->NeedsToRenderAtEachBrushStroke()) pNodeAttr->Transform(Trans); } } }
CCAttrMap* CCAttrMap::Copy() { CCAttrMap *pNewAttrMap = new CCAttrMap( GetCount() ); if( pNewAttrMap != NULL ) { // iterating all (key, value) pairs for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { CCRuntimeClass *pType; void *pVal; GetNextAssoc( Pos, pType, pVal ); // Get the attribute value of this attribute NodeAttribute* pAttr = (NodeAttribute*)pVal; // Copy the attribute NodeAttribute* pNewAttr = (NodeAttribute*) (pAttr->SimpleCopy()); // Stick the new attr into the new attr map if (pNewAttr != NULL) pNewAttrMap->SetAt(pNewAttr->GetAttributeType(),pNewAttr); } } pNewAttrMap->attrMapCreator = attrMapCreator; return pNewAttrMap; }
void ERModel::reBuildPrimaryKeyFromAttribute( int attributeID, int entityID ) { NodeAttribute* attributeNode = static_cast<NodeAttribute*>(searchComponent(attributeID)); NodeEntity* entityNode = static_cast<NodeEntity*>(searchComponent(entityID)); attributeNode->setIsPrimaryKey(true); entityNode->setPrimaryKey(attributeID); }
void NodeRenderableInk::DeleteFactoredOutAttribs(BOOL Global, AttrTypeSet* pAffectedAttrTypes) { Node* pGroupNode = FindFirstChild(); while(pGroupNode!=NULL) { // Karim 30/08/2000 // Non-optimisable attributes, like feathers and names, // must not be automatically deleted - only automatically delete optimisable ones. if (pGroupNode->IsAnAttribute() && ((NodeAttribute*)pGroupNode)->ShouldBeOptimized()) { NodeAttribute* pGroupAttr = (NodeAttribute*)pGroupNode; CCRuntimeClass* GrouptAttrType = pGroupAttr->GetAttributeType(); if (pAffectedAttrTypes==NULL || pAffectedAttrTypes->InSet(GrouptAttrType)) { // delete this group attr type from all child objects of this group // BUT if obj discards child attrs only delete attr if it also has same value for (Node* pNode=FindFirstChild(); pNode!=NULL; pNode=pNode->FindNext()) { if (pNode->IsAnObject()) { NodeRenderableInk* pObject = (NodeRenderableInk*)pNode; NodeAttribute* pDeadAttr = pObject->GetChildAttrOfType(GrouptAttrType); if (pDeadAttr!=NULL) { // This code used to only test the attribute for equality if pObject // returned TRUE from DiscardsAttributeChildren, otherwise it would // just assume that they are identical and delete it. // The DiscardAttributeChildren checks are now done elsewhere so // this code now just assumes it can delete any attributes that have // got this far. // This optimisation relies on the tree being in a "legal" state // at the start (i.e. correctly optimised) and also helps to correct // problems where attributes may have been incorrectly left on children // (though such "corrections" may change the appearance of the document). pDeadAttr->CascadeDelete(); delete pDeadAttr; } } } } } pGroupNode = pGroupNode->FindNext(); } // Do we need to delete any parent compound's attributes if (Global) { Node* pParent = FindParent(); if (pParent && (pParent->IsCompound())) { // We need to delete the parent's attributes first (Recursive bit) ((NodeRenderableInk*)pParent)->DeleteFactoredOutAttribs(Global, pAffectedAttrTypes); } } }
void NodeRenderableInk::NormaliseAttributes() { NodeAttribute* ChildAttribute; NodeAttribute* GlobalAttribute; Node* LocalScan; Node* NextLocal; // Scan the child attribute block LocalScan = FindFirstChild(); // Stop if we hit an object or if there are no more children // NOTE: Stopping scanning when we find the first RendereblInk node prevents // Effect attributes being Normalised. THIS IS DELIBERATE! while((LocalScan != NULL) && (!LocalScan->IsAnObject())) { // Hand over hand (LocalScan may get deleted) NextLocal = LocalScan->FindNext(); if(LocalScan->IsAnAttribute() && ((NodeAttribute*)LocalScan)->ShouldBeOptimized()) // cos it could be a NodeHidden { ChildAttribute = (NodeAttribute*)LocalScan; // We now need to search up the tree to see if ChildAttribute is redundant // Node* GlobalScan = FindPreviousEffectiveNode(); Node* GlobalScan = NodeAttribute::FindPrevAppliedAttr(this); // Search until we can go no higher while (GlobalScan != NULL) { if (GlobalScan->IsAnAttribute()) { GlobalAttribute = (NodeAttribute*)GlobalScan; // An attribute has been found, is it the same class as ChildAttribute ? if(GlobalAttribute->GetRuntimeClass() == ChildAttribute->GetRuntimeClass()) { // Yes it is, so let's check if they are equal if ((*GlobalAttribute)==(*ChildAttribute)) { // They are equal so we can nuke the child object because it's // redundant ChildAttribute->CascadeDelete(); delete ChildAttribute; } break; // don't search any further } } // GlobalScan = GlobalScan->FindPreviousEffectiveNode(); // climb higher GlobalScan = NodeAttribute::FindPrevAppliedAttr(GlobalScan); } } LocalScan = NextLocal; // Get the next child } }
void CCAttrMap::Transform(TransformBase& Trans) { CCRuntimeClass *pType; void *pVal; for( iterator Pos = GetStartPosition(); Pos != GetEndPosition(); ) { GetNextAssoc(Pos,pType,pVal); if (pVal != NULL) { NodeAttribute* pNodeAttr = (NodeAttribute *)pVal; pNodeAttr->Transform(Trans); } } }
vector<pair<int, bool>> ERModel::reBuildPrimaryKey( Component* oldAttributeNode, int newEntityNodeID, int newAttributeNodeID ) { vector<pair<int, bool>> reBuildPrimaryKeySet; vector<int> primaryKey; NodeAttribute* tempOldAttributeNode = static_cast<NodeAttribute*>(oldAttributeNode); if (tempOldAttributeNode->getIsPrimaryKey()) { primaryKey.push_back(newAttributeNodeID); setPrimaryKey(newEntityNodeID, primaryKey); reBuildPrimaryKeySet.push_back(make_pair(newAttributeNodeID, true)); return reBuildPrimaryKeySet; } return reBuildPrimaryKeySet; }
BOOL NodeRenderableInk::FactorOutCommonChildAttrHelper(BOOL Global, AttrTypeSet* pAffectedAttrTypes) { // This function should only ever get called on a compound object ENSURE(IsCompound(), "FactorOutCommonChildAttributes called on a non compound object"); CommonAttrSet CommonAttributeSet; // A list of CommonAttributeItems if (!FindCommonAttributesToFactorOut(&CommonAttributeSet)) // Ignores attr discard nodes { return FALSE; } NodeAttribute* pFactoredOutAttr; // Ok let's add the common attributes to the first child of the group CommonAttributeItem* pCommonAttr; for (pCommonAttr = (CommonAttributeItem*)CommonAttributeSet.GetHead(); pCommonAttr != NULL; pCommonAttr = (CommonAttributeItem*)CommonAttributeSet.GetNext(pCommonAttr)) { // Is the common attribute an attribute which should be factored out ? if (!pAffectedAttrTypes || (pAffectedAttrTypes->InSet(pCommonAttr->pAttr->GetAttributeType())) ) { //pCommonAttr->pAttr->MoveNode(this, FIRSTCHILD); // Take a copy of the node and insert it as a first child pFactoredOutAttr = (NodeAttribute*)(pCommonAttr->pAttr->SimpleCopy()); if (!pFactoredOutAttr) return FALSE; pFactoredOutAttr->AttachNode(this, FIRSTCHILD, TRUE, FALSE); } } // The CommonAttributeSet is no longer required CommonAttributeSet.DeleteAll(); // Do we need to factor out the parents attributes ? if (Global) { Node* pParent = FindParent(); if (pParent && (pParent->IsCompound())) { // We need to localise the parent's attributes first (Recursive bit) if (!(((NodeRenderableInk*)pParent)->FactorOutCommonChildAttrHelper(TRUE, pAffectedAttrTypes))) { return FALSE; // Failed } } } return TRUE; // Success }
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; }
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; }
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; }
/******************************************************************************************** > BOOL CCAttrMap::IsSeeThrough() Author: Karim_MacDonald (Xara Group Ltd) <*****@*****.**> Created: 19/02/2001 Returns: TRUE if at least one of our attrs IsSeeThrough(), FALSE otherwise. Purpose: Test each of the attributes in this map for see-through-ness. This is not the same as transparency - what it means is: if I draw something in white, then draw its outline as retrieved from PathBecomeA in black over the top, will I still be able to see white bits? IsSeeThrough() therefore depends partly on the implementation of PathBecomeA. Examples: Transparency is always see-through unless it is a zero transparency. Line width is not see through - PathBecomeA can cope with this attr. Fill colour is not see-through unless it is COLOUR_NONE. Brush attrs are normally see-through, as PathBecomeA ignores them. See Also: NodeRenderableInk::IsSeeThrough() ********************************************************************************************/ BOOL CCAttrMap::IsSeeThrough() { CCRuntimeClass *pKey; void *pVal; BOOL bIsSeeThrough = FALSE; for ( iterator pos = GetStartPosition(); pos != GetEndPosition() && !bIsSeeThrough; ) { GetNextAssoc(pos, pKey, pVal); NodeAttribute* pAttr = (NodeAttribute*)pVal; bIsSeeThrough = pAttr->IsSeeThrough(FALSE); } return bIsSeeThrough; }
/******************************************************************************************** > static CCAttrMap * CCAttrMap::MakeAttrMapFromRenderRegion(RenderRegion * pRegion) Author: David_McClarnon (Xara Group Ltd) <*****@*****.**> Created: 24/2/2000 Inputs: The render region to get the attribute map from Outputs: An attribute map (copied) from the render region Returns: - Purpose: Makes an attribute out of the render region's current attribute state Notes: You MUST call DeleteAttributes afterwards to release memory - delete is not sufficient SeeAlso: - ********************************************************************************************/ CCAttrMap * CCAttrMap::MakeAttrMapFromRenderRegion(RenderRegion * pRegion) { CCAttrMap * pMap = new CCAttrMap; ENSURE(pMap,"No mem for attrmap"); if(!pMap) return NULL; // let's get every attribute in the render region AttributeValue * pAttrVal = NULL; NodeAttribute * pNewAttr = NULL; for (UINT32 i = 0; i < ATTR_FIRST_FREE_ID; i++) { pAttrVal = pRegion->GetCurrentAttribute(i); // make a new node out of this attribute value pNewAttr = pAttrVal->MakeNode(); // Karim 12/04/2000 // AttributeValues _do_not_have_to_have_ a corresponding NodeAttribute, // so can we please *check* that MakeNode didn't just return NULL! if (pNewAttr != NULL) { if(!pNewAttr->IsLinkedToNodeGeometry()) pMap->SetAt(pNewAttr->GetAttributeType(),pNewAttr); else { delete pNewAttr; pNewAttr = AttributeManager::GetDefaultAttribute((AttrIndex) i); if(pNewAttr) { ENSURE(pNewAttr->IsLinkedToNodeGeometry(),"Incorrect NodeAttribute returned by GetDefaultAttribute"); pMap->SetAt(pNewAttr->GetAttributeType(), pNewAttr); } else return NULL; } } } pMap->attrMapCreator = NULL; return pMap; }
void CCAttrMap::ApplyAttributesToNode(NodeRenderableInk * pInk) { iterator pos = GetStartPosition(); while( pos != GetEndPosition() ) { CCRuntimeClass *pKey; void *pVal; GetNextAssoc(pos, pKey, pVal); NodeAttribute * pAttr = (NodeAttribute *)pVal; // copy the attribute if( pAttr->CanBeAppliedToObject() ) { NodeAttribute * pAttrCopy = NULL; pAttr->NodeCopy((Node **)(&pAttrCopy)); pAttrCopy->AttachNode(pInk, LASTCHILD); // nb now that GLAs have an independent flag to indicate when // they are copied from the default, it is safe to fix linkages // this ensures that GLA defaults get copied when BlendRefs are // made from complex nodes, and that they are found when MakeAppliedAttributes // calls FindAppliedAttributes on the unattached subtree // TODO?? // What about just copying compound node's Parent pointers to // pseudo attach the tree, rather than copying applied attrs to unattached tree // Just need to watch when deleting that it doesn't do anything to the // parents pointers - which it shouldn't surely? pAttrCopy->LinkToGeometry(pInk); } } }
/******************************************************************************************** > void CCAttrMap::Render(RenderRegion * pRegion, BOOL RenderOffscreenAttributes = TRUE) Author: David_McClarnon (Xara Group Ltd) <*****@*****.**> Created: 30/4/99 Inputs: pRegion render-region to render into. RenderOffscreenAttributes whether or not to render offscreen attributes, eg feathers. Outputs: - Returns: - Purpose: Renders the attribute map into the given render region Notes: Karim 15/11/2000 Modified so that I can render an attribute map *without* rendering any offscreen attributes contained therein. SeeAlso: - ********************************************************************************************/ void CCAttrMap::Render(RenderRegion * pRegion, BOOL RenderOffscreenAttributes) { // OK, we have found the full quota of attributes. Now render them all. iterator pos = GetStartPosition(); while( pos != GetEndPosition() ) { CCRuntimeClass *pKey; void *pVal; GetNextAssoc( pos, pKey, pVal ); NodeAttribute* pAttr = (NodeAttribute*)pVal; if ( pAttr->CanBeAppliedToObject() && pAttr->RenderSubtree(pRegion)==SUBTREE_ROOTONLY ) { // render all attributes, unless we've been specifically asked // not to render offscreen attributes. if (RenderOffscreenAttributes || !pAttr->IsAnOffscreenAttribute()) pAttr->Render(pRegion); } } }
// Required for all GLA's void CCAttrMap::PostBlendDeinit() { INT32 curr = 0; do { CCRuntimeClass *pType = (CCRuntimeClass *)GeometryLinkedAttributeClasses[curr]; void *pVal; if( Lookup( pType, pVal ) ) { if (pVal != NULL) { NodeAttribute * pAttr = (NodeAttribute *)pVal; pAttr->PostDynCreateDeInit(); } } curr++; } while(curr<NumGLAs); }
// Required for all GLA's // NB must only be called on attrmaps with copied attributes // DO NOT CALL on maps with 'live' attributes - ie pointers to attrs in the tree // (eg a mpa made by MakeAppliedAttrMap(pInk)) void CCAttrMap::PostBlendInit(Path* pPath, CCRuntimeClass* pCreatorClass) { INT32 curr = 0; // NB this function is called on a Blended attr map // The Blend() function should return false if it doesn't want to be in the blended attr map // ie default GLAs shouldn't be in here! do { CCRuntimeClass *pType = (CCRuntimeClass *)GeometryLinkedAttributeClasses[curr]; void *pVal; if( Lookup( pType, pVal ) ) { if (pVal != NULL) { NodeAttribute * pAttr = (NodeAttribute *)pVal; // call the attributes routine to initialise itself if(!pAttr->PostDynCreateInit(this, pPath, pCreatorClass)) { // make sure the node is not going to try and render itself TRACEUSER( "Ilan", wxT("Dynamically created attribute failed to post init itself. Removing attribute from map.\n") ); // NB map must contain copied attrs RemoveKey( pType ); // Must cast to NodeAttribute before deleting, otherwise wrong destructor gets called delete (NodeAttribute*)pVal; } } } curr++; } while(curr<NumGLAs); }
BOOL NodeAttribute::Blend(BlendAttrParam* pBlendParam) { // Check NULL entry param ERROR3IF(pBlendParam == NULL,"pBlendParam == NULL"); if (pBlendParam == NULL) return FALSE; // Make a copy of this node, and make this the blended attribute NodeAttribute* pBlendedAttr = NULL; NodeAttribute* pAttrToCopy = NULL; if (pBlendParam->GetBlendRatio() <= 0.5) pAttrToCopy = this; else pAttrToCopy = pBlendParam->GetOtherAttr(); if (pAttrToCopy != NULL) { pBlendedAttr = (NodeAttribute*) pAttrToCopy->SimpleCopy(); pBlendParam->SetBlendedAttr(pBlendedAttr); } // Return TRUE if we were able to make a copy of this node return (pBlendedAttr != NULL); }
INT32 AttrWebAddress::operator==(const NodeAttribute& naCompare) { //If naCompare is not an AttrWebAddress, return FALSE if (!naCompare.IsKindOf(CC_RUNTIME_CLASS(AttrWebAddress))) return FALSE; //Otherwise, cast naCompare into an AttrWebAddress pointer AttrWebAddress* pwaAttr = (AttrWebAddress*) &naCompare; //And check whether the member variables are the same BOOL fAreDifferent=Value.IsDifferent((AttributeValue*) &(pwaAttr->Value)); //And return accordingly return (!fAreDifferent); }
BOOL BitmapExportDocument::Init(KernelBitmap* pBitmap, const DocRect& RectToExport) { // Don't attach any CCamDoc. if (!Document::Init(0)) return(FALSE); Node *pSpread = FindFirstSpread(); ERROR3IF(pSpread == NULL, "No Spread in document!"); Node *pLayer = pSpread->FindFirstChild(); ERROR3IF(pLayer == NULL, "No Spread-child in document!"); // Store away the rectangle ExportRect = RectToExport; // Now scan the children of the first spread until we find a layer, or run out of nodes while (pLayer != NULL && !pLayer->IsLayer()) pLayer = pLayer->FindNext(); if (pLayer == NULL) // No Layer, so we'd better add one for ourselves { String_256 LayerID = String_256(_R(IDS_K_CLIPINT_LAYERNAME)); pLayer = new Layer(pSpread, LASTCHILD, LayerID); if (pLayer == NULL) return(InitFailed()); } // Create a new NodeRect NodeRect* pRectNode = new NodeRect(pLayer, FIRSTCHILD); // Failed so cleanup and exit if (pRectNode == NULL) return(InitFailed()); // Initilaise the node if (!pRectNode->SetUpPath(6,6)) return(InitFailed()); // Create the rectangle pRectNode->CreateShape(ExportRect); // Give the rectangle a line colour #if 0 // This memory leaks a StrokeColourAttribute StrokeColourAttribute* pAttrValue = new StrokeColourAttribute(DocColour(COLOUR_TRANS)); if (pAttrValue == NULL) return(InitFailed()); NodeAttribute* pAttr = pAttrValue->MakeNode(); if (pAttr == NULL) return(InitFailed()); // Attach the attribute to the rectangle pAttr->AttachNode(pRectNode, FIRSTCHILD); #else // Do what ApplyDefaultBitmapAttrs does Node* pLineColAttr = new AttrStrokeColour(); if (pLineColAttr == NULL) return(InitFailed()); DocColour none(COLOUR_NONE); ((AttrFillGeometry*)pLineColAttr)->SetStartColour(&none); pLineColAttr->AttachNode(pRectNode, FIRSTCHILD); #endif // Create a NodeBitmap (don't attach it to the tree straight away 'cos we // have to put the attributes on it first) pBitmapNode = new NodeBitmap(); if (pBitmapNode == NULL) return(InitFailed()); if (!pBitmapNode->SetUpPath(6,6)) return(InitFailed()); pBitmapNode->CreateShape(ExportRect); if (!SetBitmap(pBitmap)) return(InitFailed()); // Set the bitmap's attributes // This must be done before the NodeBitmap is inserted into the tree if (!pBitmapNode->ApplyDefaultBitmapAttrs(NULL)) return(InitFailed()); // Attach it to the tree as the next sibling of the rectangle pBitmapNode->AttachNode(pRectNode, NEXT); // Success... return(TRUE); }
/******************************************************************************************** > BOOL BlendHelpers::BlendAttributes(BlendNodeParam * pParam, CCAttrMap* pBlendedAttrMap) Author: David_McClarnon (Xara Group Ltd) <*****@*****.**> based on blender code Created: 21/2/2000 Inputs: pParam - the blend node param Outputs: - Returns: TRUE if successful, FALSE otherwise Purpose: Blends the attributes of the two BlendPath objects by the amount specified in BlendRatio SeeAlso: - ********************************************************************************************/ BOOL BlendHelpers::BlendAttributes(BlendNodeParam * pParam, CCAttrMap* pBlendedAttrMap) { // Check entry params double BlendRatio = pParam->GetAttrBlendRatio(); BOOL ok = (pParam != NULL && pBlendedAttrMap != NULL); ERROR3IF(!ok,"One or more NULL entry params"); if (!ok) return FALSE; // Find the attributes that are applied to the blend paths BlendPath * pBlendPathStart = pParam->GetStartBlendPath(); BlendPath * pBlendPathEnd = pParam->GetEndBlendPath(); ok = (pBlendPathStart != NULL && pBlendPathEnd != NULL); ERROR3IF(!ok, "Blend paths are NULL"); if (!ok) return FALSE; ok = (pBlendPathStart->GetCreatedByNode() != NULL && pBlendPathEnd->GetCreatedByNode() != NULL); ERROR3IF(!ok, "Blend path created by nodes are NULL"); if (!ok) return FALSE; BOOL startExludeGLAs = TRUE, endExcludeGLAs = TRUE; NodeAttribute * pAttr = NULL; if(pBlendPathStart->GetCreatedByNode()->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFeather),&pAttr)) { startExludeGLAs = FALSE; } if(pBlendPathEnd->GetCreatedByNode()->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFeather),&pAttr)) { endExcludeGLAs = FALSE; } CCAttrMap* pAttrMapStart = CCAttrMap::MakeAppliedAttrMap(pBlendPathStart->GetCreatedByNode(), startExludeGLAs); CCAttrMap* pAttrMapEnd = CCAttrMap::MakeAppliedAttrMap(pBlendPathEnd->GetCreatedByNode(), endExcludeGLAs); if (!pAttrMapStart || !pAttrMapEnd) return FALSE; // find the attributes on the nodes if (pParam->GetNodeBlendPath() != NULL) { Trans2DMatrix* pRotateStart = GetRotateMatrix(pParam->GetNodeStart(), 360.0 - pParam->GetAngleStart()); Trans2DMatrix* pRotateEnd = GetRotateMatrix(pParam->GetNodeEnd(), 360.0 - pParam->GetAngleEnd()); if (pRotateStart) pAttrMapStart->Transform(*pRotateStart); if (pRotateEnd) pAttrMapEnd ->Transform(*pRotateEnd); if (pRotateStart) delete pRotateStart; if (pRotateEnd) delete pRotateEnd; } // These vars are used as params to the CCAttrMap funcs CCRuntimeClass *pTypeStart; void *pValStart; void *pValEnd; double OldBlendRatio = pParam->GetBlendRatio(); // Process each attribute in turn CCAttrMap::iterator PosStart = pAttrMapStart->GetStartPosition(); CCAttrMap::iterator EndStart = pAttrMapStart->GetEndPosition(); for (;PosStart != EndStart;) { // Get a ptr to the attr at position PosStart in the start node's attr map pAttrMapStart->GetNextAssoc(PosStart,pTypeStart,pValStart); NodeAttribute* pNodeAttrStart = (NodeAttribute *)pValStart; BlendRatio = OldBlendRatio; // Diccon 10/99 When using non-linear profiles for the objects those attributes // that make use of control points were not being profiled, making the objects look strange. // to avoid this those attributes now share the same profiles as the objects. if (pNodeAttrStart->IsAGradFill()) { if (!((AttrFillGeometry*)pNodeAttrStart)->IsAColourFill()) { BlendRatio = pParam->GetObjectRatio(); } else { BlendRatio = pParam->GetInvertedAttributeRatio(); } } if (pNodeAttrStart->IsAFlatFill() || (pNodeAttrStart->GetRuntimeClass() == CC_RUNTIME_CLASS(AttrLineWidth))) { BlendRatio = pParam->GetInvertedAttributeRatio(); } // Get a blended attribute NodeAttribute* pBlendedNodeAttr = NULL; // Find an attr of the same type in the end object's attr list, // and blend the two attrs together pValEnd = NULL; if (pAttrMapEnd->Lookup(pTypeStart,pValEnd)) { // We've found a matching end attr, so try to blend it with the start attr // Set up the param object to pass to the start attr's blend method BlendAttrParam BlendParam; NodeAttribute * pEndAttr = (NodeAttribute *)pValEnd; // Initialise the BlendParam with the end attr and blend ratio if (BlendParam.Init(pParam->GetRenderRegion(), pEndAttr,BlendRatio, pParam->GetColourBlendType(), pAttrMapStart, pAttrMapEnd)) { // Successfully initialised, so now try blending the attributes if (pNodeAttrStart->Blend(&BlendParam)) { // Attrs successfully blended, now get a ptr to the new attr. // Once we get the blended attr ptr, it belongs to us, so we have // to delete it when it is not needed pBlendedNodeAttr = BlendParam.GetBlendedAttr(); } } } // If we have a blended attr, pBlendedNodeAttr != NULL if (pBlendedNodeAttr != NULL) { // Get the type of the blended attr CCRuntimeClass *pTypeBlend = pBlendedNodeAttr->GetAttributeType(); void* pValBlend; // If we already have an attr in the blended attr map of the same type, // remove it and delete it, before inserting a new attr of this type if (pBlendedAttrMap->Lookup(pTypeBlend,pValBlend)) { if (pValBlend != NULL) { pBlendedAttrMap->RemoveKey(pTypeBlend); delete (NodeAttribute*)pValBlend; } } // add it to the blend map pBlendedAttrMap->SetAt(pTypeBlend,pBlendedNodeAttr); } } if (pParam->GetNodeBlendPath() != NULL) { Trans2DMatrix* pRotateStart = GetRotateMatrix(pParam->GetNodeStart(), pParam->GetAngleStart()); Trans2DMatrix* pRotateEnd = GetRotateMatrix(pParam->GetNodeEnd(), pParam->GetAngleEnd() ); if (pRotateStart) pAttrMapStart->Transform(*pRotateStart); if (pRotateEnd) pAttrMapEnd ->Transform(*pRotateEnd); if (pRotateStart) delete pRotateStart; if (pRotateEnd) delete pRotateEnd; } delete pAttrMapStart; delete pAttrMapEnd; return TRUE; }
bool ERModel::getTargetAttributeIsPrimaryKey( int targetNodeID ) { NodeAttribute* targetAttribute = static_cast<NodeAttribute*>(searchComponent(targetNodeID)); return targetAttribute->getIsPrimaryKey(); }
BOOL NodeRenderableInk::MakeAttributeComplete(Node* Root, BOOL CheckForDuplicates, /* = TRUE */ AttrTypeSet* pAffectedAttrTypes, /* = NULL */ BOOL IncludeDefaults, /* = FALSE */ BOOL bIncludeEffectAttrs /* = FALSE */) { Node* Current = NULL; // Pointer to the current node in the tree NodeAttribute* CurAttr; CCRuntimeClass* AttrType; BOOL Exists; Node* PreFirstChild = FindFirstChild(); // Remember the FirstChild of the node before we add // any new attributes, this will come in handy if we // need to abort. // Loop until all attributes are copied, we are not interested in the defaults cos these are the // same for all docs !. if (bIncludeEffectAttrs) Current = NodeAttribute::FindFirstAppliedAttr(this, Root); else Current = NodeAttribute::FindPrevAppliedAttr(this, Root); while (Current && (IncludeDefaults || (!(IS_A(Current->FindParent(), NodeDocument)))) ) { // Find the next node, snaking up the tree if (Current->IsAnAttribute()) { CurAttr = (NodeAttribute*)Current; if (CurAttr->CanBeAppliedToObject() && CurAttr->ShouldBeOptimized()) { AttrType = CurAttr->GetAttributeType(); BOOL Required = RequiresAttrib(AttrType) || this->IsCompound(); // Is the attribute required ? if (Required && (!pAffectedAttrTypes || pAffectedAttrTypes->InSet(AttrType))) { Exists = FALSE; if (CheckForDuplicates) { // triggers can have duplicates if(!CurAttr->CanBeMultiplyApplied()) { // Does the node already have this child attribute Exists = (GetChildAttrOfType(AttrType) != NULL); } } #ifdef _DEBUG if (!CheckForDuplicates) { // If we feel there is no need to check for duplicates then there shouldn't be any ! if (!CurAttr->CanBeMultiplyApplied()) { NodeAttribute* pChildAttr = GetChildAttrOfType(AttrType); if ((pChildAttr != NULL)) { #if DEBUG_TREE DebugTreeDlg::DumpSubTree(this, 4); #endif TRACE(_T("Duplicate Attr found at %x %s\n"), pChildAttr, pChildAttr->GetRuntimeClass()->m_lpszClassName); } // ERROR3IF((pChildAttr != NULL), "MakeAttributeComplete: Duplicate attr found !"); } } #endif if (!Exists) { // Make a copy of the attribute NodeAttribute* NewAttr = (NodeAttribute*)CurAttr->SimpleCopy(); if (NewAttr == NULL) { goto OutOfMemory; } // Now add the attribute to this node NewAttr->AttachNode(this, FIRSTCHILD, TRUE, FALSE); } } } } Current = NodeAttribute::FindPrevAppliedAttr(Current, Root); // in order to copy brush ink nodes we need to break if the parent is NULL, else is violates if (Current!=NULL && Current->FindParent() == NULL) break; } return TRUE; OutOfMemory: // Delete any new attributes added to the node Current = FindFirstChild(); Node* Next; while (Current != PreFirstChild) { ENSURE(Current != NULL, "PreFirstChild could not be found"); ENSURE(Current->IsAnAttribute(), "Should be a NodeAttribute"); Next = Current->FindNext(); // Delete the attribute Current->CascadeDelete(); delete Current; Current = Next; } return FALSE; }
BOOL OpChangeLineAttribOpDesc::SetCurrentSelectedAttrib() { // Nothing to do if no current document. if (Document::GetCurrent() == NULL) { /* TRACEUSER( "JustinF", _T("No current document in OpChangeLineAttribOpDesc") "::SetCurrentSelectedAttrib\n"); */ // There is no document so blank all gadgets. SetGadgetText(String(_T(""))); return TRUE; } // Determine if there is a common attribute. NodeAttribute* pAttr; SelRange::CommonAttribResult eResult; eResult = GetApplication()-> FindSelection()-> FindCommonAttribute(GetAttribRuntimeClass(), &pAttr); // Work out what to put in the combo-box according to the returned result. UINT32 nTxtID; switch (eResult) { case SelRange::ATTR_COMMON: case SelRange::ATTR_NONE: { // If there isn't an attribute we just return (this logic is copied from the // line-width combo OpDescriptor code). if (pAttr == NULL) { /* TRACEUSER( "JustinF", _T("No attribute in OpChangeLineAttribOpDesc") "::SetCurrentSelectedAttrib\n"); */ return TRUE; } // Check for something screwy. ERROR3IF(pAttr->GetRuntimeClass() != GetAttribRuntimeClass(), "Wrong kind of attribute in OpChangeLineAttribOpDesc" "::SetCurrentSelectedAttrib"); // There is, so call the derived class to provide some text. nTxtID = ConvertAttribToStringID(pAttr); if (nTxtID == 0) { ERROR3("Unexpected attribute type in OpChangeLineAttribOpDesc" "::SetCurrentSelectedAttrib!"); return FALSE; } break; } case SelRange::ATTR_MANY: nTxtID = _R(IDS_MANY); break; default: ERROR3("Unexpected case in OpChangeLineAttribOpDesc::SetCurrentSelectedAttrib!"); return FALSE; } // Set the gadget's text. SetGadgetText(String(nTxtID)); return TRUE; }
BOOL NodeRenderableInk::FindCommonAttributesToFactorOut(CommonAttrSet* CommonAttributeSet) { CommonAttributeItem* CommonAttrItem; CommonAttributeItem* NextCommonAttrItem; // Place all attributes in the CommonAttributeSet if (!CommonAttributeSet->AddAllTypesToSet()) { return FALSE; // ERROR already called } // Scan all grouped objects for (Node* CurrentObject = FindFirstChild(); CurrentObject != NULL; CurrentObject = CurrentObject->FindNext()) { if (CurrentObject->IsAnObject()) { // Scan all attributes in the CommonAttributeSet in turn CommonAttrItem = (CommonAttributeItem*)CommonAttributeSet->GetHead(); while(CommonAttrItem != NULL) { // Hand over hand cos we may well delete the CommonAttrItem NextCommonAttrItem = (CommonAttributeItem*)(CommonAttributeSet->GetNext(CommonAttrItem)); // Does CurrentObject require the attribute to render if ( (((NodeRenderableInk*)CurrentObject)->RequiresAttrib(CommonAttrItem->AttrType)) || CurrentObject->IsCompound()) { BOOL DeleteCommonAttr = FALSE; // Until we know better // Ok the current object requires the attribute // Does the CurrentObject have a child attribute of this type ? NodeAttribute* pAttrNode = ((NodeRenderableInk*)CurrentObject)->GetChildAttrOfType(CommonAttrItem->AttrType); if (pAttrNode != NULL && pAttrNode->ShouldBeOptimized()) { // Ok it has an attribute of this type if (CommonAttrItem->pAttr == NULL) { // The attribute becomes a common attribute CommonAttrItem->pAttr = pAttrNode; CommonAttrItem->Status = Range::ATTR_COMMON; } else if(CommonAttrItem->pAttr->GetRuntimeClass() == pAttrNode->GetRuntimeClass()) { // Ok they are the same runtime class but are they equal if (!((*pAttrNode)==(*(CommonAttrItem->pAttr)))) { // They are not equal so remove CommonAttrItem from the // common attribute set. DeleteCommonAttr = TRUE; } // DY 12/5/2000 AttrBrushTypes cannot be factored because they // may contain caches of pressure or timestamp data which apply // to a specific node only. // They no longer contain this data so factor them like normal! //if (pAttrNode->IsKindOf(CC_RUNTIME_CLASS(AttrBrushType))) // DeleteCommonAttr = TRUE; } else { // They cannot be the same value cos they are different runtime types DeleteCommonAttr = TRUE; } } else { // The CurrentObject does not have an attribute of this type so it // cannot be common DeleteCommonAttr = TRUE; } if (DeleteCommonAttr) { delete(CommonAttributeSet->RemoveItem(CommonAttrItem)); } } CommonAttrItem = NextCommonAttrItem; } } // Removed because there are circumstances where certain attributes have // already been factored out eg. Corel filter //else //{ // ENSURE(CurrentObject->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeHidden), // "It's not an object, it's not a hidden node, so what is it ??"); //} } // Delete all NULL items in the CommonAttributeSet CommonAttrItem = (CommonAttributeItem*)CommonAttributeSet->GetHead(); while (CommonAttrItem != NULL) { CommonAttributeItem* Next = (CommonAttributeItem*)CommonAttributeSet->GetNext(CommonAttrItem); if (CommonAttrItem->pAttr == NULL) { // Item is a non required attribute so zap it delete (CommonAttributeSet->RemoveItem(CommonAttrItem)); } CommonAttrItem = Next; } return TRUE; // Job done }