AttrUser Class Reference

User Attribute Node. More...

#include <userattr.h>

Inheritance diagram for AttrUser:

NodeAttribute NodeRenderable Node CCObject SimpleCCObject TemplateAttribute StyleReferenceAttribute List of all members.

Public Member Functions

 AttrUser ()
 Default constructor for User Attribute class.
 AttrUser (Node *ContextNode, AttachNodeDirection Direction, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE)
 Creates a User Attribute.
 AttrUser (const StringBase &NewKey, const StringBase &NewSubKey, const StringBase &NewValue)
 Constructs a User Attribute node given a Key, SubKey and Value.
 AttrUser (const StringBase &NewLongKey, const StringBase &NewValue)
 Constructs an AttrUser (User attribute node) from a long key.
virtual void Render (RenderRegion *pRender)
 We don't need to render a user attribute. So simply do nothing.
virtual NodeSimpleCopy ()
 This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.
virtual INT32 operator== (const NodeAttribute &NodeAttrib)
 A virtual comparison operator. See NodeAttribute::operator== for a description of why it's required.
virtual UINT32 GetAttrNameID (void)
 Returns back a string resource ID describing the attribute.
virtual BOOL IsUserAttribute () const
void ShowDebugTreeDetails () const
void GetDebugDetails (StringBase *Str)
 For obtaining debug information about the Node.
virtual UINT32 GetNodeSize () const
 For finding the size of the node.
virtual void Transform (TransformBase &)
 We don't need to transform a User Attribute - so this function does nothing.
virtual BOOL CanBeMultiplyApplied ()
virtual BOOL ShouldBeOptimized ()
 When applying multiple template args / WizOp user attributes we want them to remain associated with the object they were applied to rather than migrating to groups, otherwise where there was once two questions for two objects in a group there would instead be one. The default AttrUser should always be optimized out.
virtual BOOL EffectsParentBounds ()
 Virtual function for determining if the node will effect it's parent bounds. eg. ArrowHeads.
virtual BOOL Blend (BlendAttrParam *pBlendParam)
 Blends one User attribute with another.
virtual AttributeValueGetAttributeValue ()
virtual CCRuntimeClassGetAttributeType ()
virtual AttributeIdentifier GetAttributeClassID () const
 Generates an AttributeIdentifier for this Attribute. Since the RuntimeClass is inadequate for dynamically generated Atrributes (read Nodes), we need to provide an ID that can be created dynamically too. This is what an AttributeIdentifier is supposed to be. In the case of an AttrUser it returns a pointer to a template handler.
virtual AttrIndex GetAttributeIndex ()
virtual VisibleAttributeCreateVisibleAttribute () const
 Creates a VisibleAttribute representing this AttrUser that the user can edit. (this is all horribly wrong).
virtual BOOL WritePreChildrenWeb (BaseCamelotFilter *pFilter)
 Writes the line width record to the filter.
virtual BOOL WritePreChildrenNative (BaseCamelotFilter *pFilter)
BOOL ShouldBecomeCurrent ()
 The attribute manager calls this function before making an attribute current.
StringBaseGetWebAddress ()
 This is only used for Web Address User Attributes.
virtual void PolyCopyNodeContents (NodeRenderable *pNodeCopy)
 Polymorphically copies the contents of this node to another.

Public Attributes

UserAttribute Value

Protected Member Functions

void CopyNodeContents (AttrUser *NodeCopy)
 This method copies the node's contents to the node pointed to by NodeCopy.

Static Protected Attributes

static const TCHAR s_KeyDelimiter = TEXT('\\')

Detailed Description

User Attribute Node.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/93

Definition at line 164 of file userattr.h.


Constructor & Destructor Documentation

AttrUser::AttrUser  ) 
 

Default constructor for User Attribute class.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/8/96

Definition at line 445 of file userattr.cpp.

00446 {
00447 }

AttrUser::AttrUser Node ContextNode,
AttachNodeDirection  Direction,
BOOL  Locked = FALSE,
BOOL  Mangled = FALSE,
BOOL  Marked = FALSE,
BOOL  Selected = FALSE
 

Creates a User Attribute.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> (from Will)
Date:
14/8/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 423 of file userattr.cpp.

00429   : NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected)  
00430 {
00431     // Empty.
00432 } 

AttrUser::AttrUser const StringBase NewKey,
const StringBase NewSubKey,
const StringBase NewValue
 

Constructs a User Attribute node given a Key, SubKey and Value.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/8/96
Parameters:
[INPUTS] 

Definition at line 461 of file userattr.cpp.

00463 {
00464     if (!Value.Key.Alloc(NewKey.Length())) return;
00465     Value.Key = NewKey;
00466 
00467     INT32 n = NewKey.Length();
00468     if (!NewSubKey.IsEmpty())  n += 1 + NewSubKey.Length();
00469     
00470     if (!Value.LongKey.Alloc(n)) return;
00471     Value.LongKey = NewKey;
00472     if (!NewSubKey.IsEmpty())
00473     {
00474         Value.LongKey += s_KeyDelimiter;
00475         Value.LongKey += NewSubKey;
00476     }
00477 
00478     if (!Value.Value.Alloc(NewValue.Length())) return;
00479     Value.Value = NewValue;
00480 }

AttrUser::AttrUser const StringBase NewLongKey,
const StringBase NewValue
 

Constructs an AttrUser (User attribute node) from a long key.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/07/97

Definition at line 493 of file userattr.cpp.

00494 {
00495     // Find the first bit of the long key
00496     INT32 DelimiterPosition = NewLongKey.FindNextChar(s_KeyDelimiter);
00497     if (DelimiterPosition < 0)
00498     {
00499         // couldn't find the end so the delimiter is beyond the end of the string
00500         DelimiterPosition = NewLongKey.Length();
00501     }
00502 
00503     INT32 ShortKeyLength = DelimiterPosition;
00504     if (ShortKeyLength > 0)
00505     {
00506         // Added by Craig Hamilton 2/8/00.
00507         // This section of code deals with the situation where the length of Value.Key.Length is
00508         // less than ShortKeyLength. This was causing problems with the call to StringBase::Left
00509         // which would fail in this eventuality. To prevent this we just allocate Value.Key more
00510         // space. We did try another method involving the use of a String_256 being passed to 
00511         // StringBase::Left and then asigning Value.Key to the String_256, but this caused a
00512         // Damage: after normal block error in the VC++ debug library.
00513         if(Value.Key.Length() < ShortKeyLength)
00514         {
00515             Value.Key.Alloc(ShortKeyLength);
00516         }
00517         // End Added.
00518 
00519         NewLongKey.Left(&Value.Key, ShortKeyLength);
00520     }
00521     else
00522     {
00523         TRACE( _T("AttrUser::AttrUser - no key\n"));
00524     }
00525 
00526     if (!Value.LongKey.Alloc(NewLongKey.Length())) return;
00527     Value.LongKey   = NewLongKey;
00528 
00529     if (!Value.Value.Alloc(NewValue.Length())) return;
00530     Value.Value     = NewValue;
00531 }


Member Function Documentation

BOOL AttrUser::Blend BlendAttrParam pBlendParam  )  [virtual]
 

Blends one User attribute with another.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from MarkN
Date:
14/8/96
Parameters:
pBlendParam = ptr to blend attribute param object holding all info needed [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise
See also:
-

Reimplemented from NodeAttribute.

Definition at line 795 of file userattr.cpp.

00796 {
00797     // Get the User member to blend to the User member of the other NodeAttribute.
00798     // If it succeeds, ask the blended Value to make a NodeAttribute out of itself.
00799     ERROR3IF(pBlendParam == NULL,"NULL entry param");
00800     if (Value.Blend(pBlendParam))
00801     {
00802         // Get the blended attr val. After this call, the ptr is our reponsibility
00803         // so we have to delete it if it's no longer needed
00804         AttributeValue* pBlendedAttrVal = pBlendParam->GetBlendedAttrVal();
00805         if (pBlendedAttrVal != NULL)
00806         {
00807             // We have a blended attr val, so ask it to make a NodeAttribute out of itself
00808             // and set the pBlendParam's blended NodeAttribute ptr to it
00809             NodeAttribute* pBlendedAttr = pBlendedAttrVal->MakeNode();
00810             pBlendParam->SetBlendedAttr(pBlendedAttr);
00811 
00812             if (pBlendedAttr != NULL)
00813             {
00814                 // We were able to make a blended NodeAttribute
00815                 // so delete the blended attr val, and return TRUE
00816                 delete pBlendedAttrVal;
00817                 return TRUE;
00818             }
00819             else
00820             {
00821                 // Couldn't make a blended NodeAttribute, so give the blended attr val back
00822                 // and return FALSE
00823                 pBlendParam->SetBlendedAttrVal(pBlendedAttrVal);
00824             }
00825         }
00826     }
00827     
00828     return FALSE;
00829 }

virtual BOOL AttrUser::CanBeMultiplyApplied  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 195 of file userattr.h.

00195 { return TRUE; }

void AttrUser::CopyNodeContents AttrUser NodeCopy  )  [protected]
 

This method copies the node's contents to the node pointed to by NodeCopy.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Simon
Date:
28/4/93
Parameters:
[INPUTS] 
A copy of this node [OUTPUTS]
Returns:
-

Errors: An assertion failure will occur if NodeCopy is NULL

Scope: protected

Definition at line 666 of file userattr.cpp.

00667 {
00668     NodeAttribute::CopyNodeContents(NodeCopy);
00669     NodeCopy->Value = Value;
00670 } 

VisibleAttribute * AttrUser::CreateVisibleAttribute  )  const [virtual]
 

Creates a VisibleAttribute representing this AttrUser that the user can edit. (this is all horribly wrong).

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
A new VIsibleAttribute

Reimplemented from NodeAttribute.

Reimplemented in TemplateAttribute, and StyleReferenceAttribute.

Definition at line 961 of file userattr.cpp.

00962 {
00963     VisibleAttribute* pVisibleAttribute = NULL; // return this
00964 
00965     PORTNOTETRACE("other","AttrUser::CreateVisibleAttribute - do nothing");
00966 #ifndef EXCLUDE_FROM_XARALX
00967     pVisibleAttribute = new VisibleUserAttribute(Value.LongKey, Value.Value);
00968 #endif
00969     return pVisibleAttribute;
00970 }

virtual BOOL AttrUser::EffectsParentBounds  )  [inline, virtual]
 

Virtual function for determining if the node will effect it's parent bounds. eg. ArrowHeads.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the node will effect the bounds of it's parent.
See also:
NodeAttribute::GetAttrBoundingRect

Reimplemented from NodeAttribute.

Definition at line 197 of file userattr.h.

00197 { return TRUE; }

AttributeIdentifier AttrUser::GetAttributeClassID  )  const [virtual]
 

Generates an AttributeIdentifier for this Attribute. Since the RuntimeClass is inadequate for dynamically generated Atrributes (read Nodes), we need to provide an ID that can be created dynamically too. This is what an AttributeIdentifier is supposed to be. In the case of an AttrUser it returns a pointer to a template handler.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97

Reimplemented from NodeAttribute.

Reimplemented in TemplateAttribute.

Definition at line 942 of file userattr.cpp.

00943 {
00944     return Value.LongKey;
00945 }

virtual AttrIndex AttrUser::GetAttributeIndex  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 204 of file userattr.h.

00204 { return ATTR_USERATTRIBUTE; }

virtual CCRuntimeClass* AttrUser::GetAttributeType  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 202 of file userattr.h.

00202 { return CC_RUNTIME_CLASS(AttrUser); }

virtual AttributeValue* AttrUser::GetAttributeValue  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 201 of file userattr.h.

00201 { return &Value; }

UINT32 AttrUser::GetAttrNameID void   )  [virtual]
 

Returns back a string resource ID describing the attribute.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Simon
Date:
22/2/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Attribute description ID

Errors: -

See also:
-

Reimplemented from NodeAttribute.

Reimplemented in TemplateAttribute, and StyleReferenceAttribute.

Definition at line 642 of file userattr.cpp.

00643 {
00644     return (_R(IDS_USERATTRIBUTE_ID)); 
00645 }               

void AttrUser::GetDebugDetails StringBase Str  )  [virtual]
 

For obtaining debug information about the Node.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/9/93
Parameters:
Str,: String giving debug info about the node [OUTPUTS]

Reimplemented from NodeRenderable.

Definition at line 717 of file userattr.cpp.

00718 {
00719 #ifdef _DEBUG
00720     NodeAttribute::GetDebugDetails( Str );
00721 
00722     *Str += TEXT("\r\nKey = ");
00723     *Str += Value.Key;
00724     *Str += TEXT("\r\nLongKey = ");
00725     *Str += Value.LongKey;
00726     *Str += TEXT("\r\nData= ");
00727     *Str += Value.Value;
00728 #endif
00729 }

UINT32 AttrUser::GetNodeSize  )  const [virtual]
 

For finding the size of the node.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com> from Simon
Date:
6/10/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The size of the node in bytes
See also:
Node::GetSubtreeSize

Reimplemented from Node.

Definition at line 747 of file userattr.cpp.

00748 {     
00749     return sizeof(*this); 
00750 }  

StringBase & AttrUser::GetWebAddress  ) 
 

This is only used for Web Address User Attributes.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/96
Returns:
The URL of the Hot Link

Definition at line 921 of file userattr.cpp.

00922 { 
00923     return Value.Value;
00924 }

virtual BOOL AttrUser::IsUserAttribute  )  const [inline, virtual]
 

Reimplemented from Node.

Definition at line 184 of file userattr.h.

00184 { return TRUE; }

INT32 AttrUser::operator== const NodeAttribute Attrib  )  [virtual]
 

A virtual comparison operator. See NodeAttribute::operator== for a description of why it's required.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>, from Simon
Date:
9/2/94
Parameters:
Atrib,: The attribute to compare, which must be an AttrUser [INPUTS]
- [OUTPUTS]
Returns:
-
Graham says: with this class you actually need to compare two values (the Value and and the Key) not just one.

Returns:
Errors: An ENSURE failure will occur if Attrib does not have a AttrUser runtime class.
See also:
NodeAttribute::operator==

Reimplemented from NodeAttribute.

Definition at line 616 of file userattr.cpp.

00617 {
00618     ENSURE(Attrib.IsKindOf(CC_RUNTIME_CLASS(AttrUser)), 
00619         "Trying to compare two objects with different types"); 
00620 
00621     AttrUser& OtherUserNode = (AttrUser&) Attrib;
00622     return !(Value.IsDifferent(&OtherUserNode.Value));
00623 } 

void AttrUser::PolyCopyNodeContents NodeRenderable pNodeCopy  )  [virtual]
 

Polymorphically copies the contents of this node to another.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/2003
Parameters:
- [OUTPUTS]
Returns:
Errors: An assertion failure will occur if NodeCopy is NULL Scope: protected

Reimplemented from NodeRenderable.

Reimplemented in TemplateAttribute.

Definition at line 686 of file userattr.cpp.

00687 {
00688     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
00689     ENSURE(IS_A(pNodeCopy, AttrUser), "PolyCopyNodeContents given wrong dest node type");
00690 
00691     if (IS_A(pNodeCopy, AttrUser))
00692         CopyNodeContents((AttrUser*)pNodeCopy);
00693 }

void AttrUser::Render RenderRegion pRender  )  [virtual]
 

We don't need to render a user attribute. So simply do nothing.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/96

Reimplemented from NodeAttribute.

Definition at line 545 of file userattr.cpp.

00546 {
00547     //Don't need to do anything to render a User Attribute.
00548 }

BOOL AttrUser::ShouldBecomeCurrent  )  [virtual]
 

The attribute manager calls this function before making an attribute current.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/96
Returns:
TRUE if this attribute should become current.
FALSE if the user must deliberately apply this attribute to an object every time he wants to use it.

There are some attributes - like this URL Hot Link attribute I'm about to put in - that the user probably won't want to become current. For example, if a user puts a HotLink on an object and happens to have the Give Other Objects Most Recent Attributes option on, all his new objects are going to have HotLinks. That's not good.

So those attributes will override this function and return FALSE.

Reimplemented from NodeAttribute.

Definition at line 902 of file userattr.cpp.

00903 { 
00904     //No, don't pass this attribute on
00905     return FALSE; 
00906 }

BOOL AttrUser::ShouldBeOptimized  )  [virtual]
 

When applying multiple template args / WizOp user attributes we want them to remain associated with the object they were applied to rather than migrating to groups, otherwise where there was once two questions for two objects in a group there would instead be one. The default AttrUser should always be optimized out.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/06/97
Returns:
TRUE if the attribute should be optimized, normalized, etc. FALSE otherwise
See Also: NodeRenderableInk::NormaliseAttributes() NodeRenderableInk::FindCommonAttributesToFactorOut() NodeRenderableInk::MakeAttributeComplete()

Reimplemented from NodeAttribute.

Definition at line 774 of file userattr.cpp.

00775 {
00776     return Value.Key.IsEmpty() && Value.LongKey.IsEmpty() && Value.Value.IsEmpty();
00777 }  

void AttrUser::ShowDebugTreeDetails  )  const
 

Node * AttrUser::SimpleCopy void   )  [virtual]
 

This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/93
Parameters:
- [INPUTS]
[OUTPUTS] 
Returns:
A copy of the node, or NULL if memory runs out

Errors: If memory runs out when trying to copy, then ERROR is called with an out of memory error and the function returns NULL.

Scope: protected

Reimplemented from NodeAttribute.

Reimplemented in TemplateAttribute, and StyleReferenceAttribute.

Definition at line 586 of file userattr.cpp.

00587 {
00588     AttrUser* pNodeCopy = new AttrUser;
00589     ERRORIF(pNodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
00590     CopyNodeContents(pNodeCopy);
00591     return pNodeCopy;
00592 } 

void AttrUser::Transform TransformBase Trans  )  [virtual]
 

We don't need to transform a User Attribute - so this function does nothing.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/8/96
Parameters:
Trans - the transform object to apply to this attribute. [INPUTS]
See also:
NodeRenderable::Transform

Reimplemented from NodeRenderable.

Definition at line 562 of file userattr.cpp.

00563 {
00564     //Transforming a User Attribute does nothing.
00565 }

BOOL AttrUser::WritePreChildrenNative BaseCamelotFilter pFilter  )  [virtual]
 

Reimplemented from Node.

Definition at line 871 of file userattr.cpp.

00872 {
00873 #ifdef DO_EXPORT
00874     return WritePreChildrenWeb(pFilter);
00875 #else
00876     return FALSE;
00877 #endif
00878 }

BOOL AttrUser::WritePreChildrenWeb BaseCamelotFilter pFilter  )  [virtual]
 

Writes the line width record to the filter.

> virtual BOOL AttrUser::WritePreChildrenWeb(BaseCamelotFilter* pFilter)

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/5/96
Parameters:
pFilter = ptr to the filter [INPUTS]
Returns:
TRUE if record is written, FALSE if not
See also:
-

Reimplemented from Node.

Reimplemented in TemplateAttribute, and StyleReferenceAttribute.

Definition at line 846 of file userattr.cpp.

00847 {
00848 #ifdef DO_EXPORT
00849     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
00850 
00851     BOOL ok = TRUE;
00852 
00853     CamelotFileRecord Rec(pFilter,TAG_USERVALUE,TAG_USERVALUEATTRSIZE);
00854 
00855     ok = Rec.Init();
00856 
00857     if (ok) ok = Rec.WriteUnicode((TCHAR*)Value.LongKey);
00858     if (ok) ok = Rec.WriteUnicode((TCHAR*)Value.Value);
00859 
00860     if (ok) ok = pFilter->Write(&Rec);
00861 
00862     return ok;
00863 #else
00864     return FALSE;
00865 #endif
00866 }


Member Data Documentation

const TCHAR AttrUser::s_KeyDelimiter = TEXT('\\') [static, protected]
 

Definition at line 221 of file userattr.h.

UserAttribute AttrUser::Value
 

Definition at line 224 of file userattr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:50:44 2007 for Camelot by  doxygen 1.4.4