StyleReferenceAttribute Class Reference

This represents a TemplateOp/Argument/user-changable from the template file attribute. It will probably be superceded, but for now it's derived from AttrUser with a value of the form <InternalName>[/][;<Question>] Bring on the plug-in attributes I say. More...

#include <tmpltatr.h>

Inheritance diagram for StyleReferenceAttribute:

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

Public Member Functions

 StyleReferenceAttribute (const WizOpStyle &Style)
 Constructor ensures this attribute actually references a style.
virtual NodeSimpleCopy ()
 Creates a new copy of this StyleReferenceAttribute.
virtual UINT32 GetAttrNameID (void)
 Provides an attribute name for undo, etc.
virtual BOOL WritePreChildrenWeb (BaseCamelotFilter *pFilter)
 Writes this StyleReferenceAttribute via the given filter.
virtual BOOL CopyComponentData (BaseDocument *SrcDoc, BaseDocument *NodesDoc)
 Ensures that the style to which this refers is in the target document.
virtual VisibleAttributeCreateVisibleAttribute () const
 Creates the user with something to look at in the Wizard Properties dialog.
const StringBaseGetStyleName () const
 Support function to get the name of the referred style.

Protected Member Functions

BOOL SetStyle (const Style &StyleToReference)
 When the component copy does it's stuff it sometimes needs to change the reference. This member is for that purpose.
WizOpStylesGetStylesForFilter (BaseCamelotFilter &Filter) const
 Support function to get the styles for the exporting document.
WizOpStylesGetStylesForDoc (BaseDocument &Doc) const
 Support function to get the styles for the given document.

Detailed Description

This represents a TemplateOp/Argument/user-changable from the template file attribute. It will probably be superceded, but for now it's derived from AttrUser with a value of the form <InternalName>[/][;<Question>] Bring on the plug-in attributes I say.

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

Definition at line 209 of file tmpltatr.h.


Constructor & Destructor Documentation

StyleReferenceAttribute::StyleReferenceAttribute const WizOpStyle Style  ) 
 

Constructor ensures this attribute actually references a style.

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

Definition at line 1027 of file tmpltatr.cpp.

01028 {
01029     SetWizOpNameAndParam( Style.GetWizOp().GetInternalName(), Style.GetParam() );
01030     SetStyle( Style );
01031 }


Member Function Documentation

BOOL StyleReferenceAttribute::CopyComponentData BaseDocument pSourceDoc,
BaseDocument pTargetDoc
[virtual]
 

Ensures that the style to which this refers is in the target document.

Parameters:
pSrcDoc,: The document from where this node was copied [INPUTS] pTargetDoc: The document where this node lives
Returns:
FALSE if unable to copy data
See also:
NodeAttribute::CopyComponentData

Reimplemented from NodeAttribute.

Definition at line 1097 of file tmpltatr.cpp.

01099 {
01100     ENSURE_NOT_NULL(Value.m_pStyle);
01101 
01102     ENSURE_NOT_NULL(pSourceDoc);
01103     ENSURE_NOT_NULL(pTargetDoc);
01104 
01105     // Ask the base class to copy its data
01106     BOOL Ok = TemplateAttribute::CopyComponentData(pSourceDoc, pTargetDoc);
01107 
01108     // Get the style in our document
01109     WizOpStyles* pTargetStyles          = NULL;
01110 
01111     if (Ok)
01112     {
01113         pTargetStyles = GetStylesForDoc(*pTargetDoc);
01114 
01115         Ok = (pTargetStyles != NULL);
01116     }
01117 
01118     if (Ok)
01119     {
01120         // Attempt to add the style that was in the old (source) document and to which this 
01121         // StyleReferenceAttribute currently refers, to the new (target) document
01122 
01123         // If the new document already has a style of the same name, but different 
01124         // characteristics it will return a style with a different name, which we will need
01125         // to use as our reference.
01126         ENSURE_KIND(Value.m_pStyle, WizOpStyle);
01127         const WizOpStyle& SourceStyle = (WizOpStyle&)*Value.m_pStyle;
01128 
01129         WizOpStyle* const pTargetStyle = (WizOpStyle*)pTargetStyles->CopyComponentData(SourceStyle);
01130         if (pTargetStyle != NULL)
01131         {
01132             SetStyle(*pTargetStyle);
01133         }
01134         else
01135         {
01136             Ok = FALSE;
01137         }
01138     }
01139 
01140     return Ok;
01141 }

VisibleAttribute * StyleReferenceAttribute::CreateVisibleAttribute  )  const [virtual]
 

Creates the user with something to look at in the Wizard Properties dialog.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
A pointer to a new VisibleStyleReference (or NULL if not)

Reimplemented from TemplateAttribute.

Definition at line 1222 of file tmpltatr.cpp.

01223 {
01224     ENSURE_NOT_NULL(Value.m_pStyle);
01225     ENSURE_KIND(Value.m_pStyle, WizOpStyle);
01226     const WizOpStyle& ActualStyle = (WizOpStyle&)*Value.m_pStyle;
01227 
01228     return new VisibleStyleReference(ActualStyle);
01229 }

UINT32 StyleReferenceAttribute::GetAttrNameID void   )  [virtual]
 

Provides an attribute name for undo, etc.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/06/97
Returns:
A resource id for "Wizard Style Reference"

Reimplemented from TemplateAttribute.

Definition at line 1074 of file tmpltatr.cpp.

01075 {
01076     return _R(IDS_WIZOP_STYLEREF);
01077 }

const StringBase & StyleReferenceAttribute::GetStyleName  )  const
 

Support function to get the name of the referred style.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Returns:
A string for the referred style's name.

Definition at line 1265 of file tmpltatr.cpp.

01266 {
01267     STRING_ENSURE_NOT_NULL(Value.m_pStyle);
01268     return Value.m_pStyle->GetName();
01269 }

WizOpStyles * StyleReferenceAttribute::GetStylesForDoc BaseDocument Doc  )  const [protected]
 

Support function to get the styles for the given document.

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

Definition at line 1310 of file tmpltatr.cpp.

01311 {
01312     return (WizOpStyles*)Doc.GetDocComponent( CC_RUNTIME_CLASS(WizOpStyles) );
01313 }

WizOpStyles * StyleReferenceAttribute::GetStylesForFilter BaseCamelotFilter Filter  )  const [protected]
 

Support function to get the styles for the exporting document.

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

Definition at line 1284 of file tmpltatr.cpp.

01285 {
01286     WizOpStyles* pStyles = NULL;
01287 
01288     BaseDocument* const pDoc = Filter.GetDocument();
01289     if (pDoc != NULL)
01290     {
01291         pStyles = GetStylesForDoc(*pDoc);
01292     }
01293 
01294     return pStyles;
01295 }

BOOL StyleReferenceAttribute::SetStyle const Style StyleToReference  )  [protected]
 

When the component copy does it's stuff it sometimes needs to change the reference. This member is for that purpose.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Parameters:
StyleToReference The Style to which this StyleReferenceAttribute refers [INPUTS]
Returns:
TRUE

Definition at line 1246 of file tmpltatr.cpp.

01247 {
01248     Value.m_pStyle = &StyleToReference;
01249     return TRUE;
01250 }

Node * StyleReferenceAttribute::SimpleCopy void   )  [virtual]
 

Creates a new copy of this StyleReferenceAttribute.

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

Reimplemented from TemplateAttribute.

Definition at line 1046 of file tmpltatr.cpp.

01047 {
01048     ENSURE_NOT_NULL(Value.m_pStyle);
01049     ENSURE_KIND(Value.m_pStyle, WizOpStyle);
01050 
01051     WizOpStyle& TrueStyle = (WizOpStyle&)*Value.m_pStyle;
01052     StyleReferenceAttribute* pNodeCopy = new StyleReferenceAttribute(TrueStyle);
01053 
01054     ERRORIF(pNodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL);
01055 
01056     CopyNodeContents(pNodeCopy);
01057 
01058     return pNodeCopy;
01059 }

BOOL StyleReferenceAttribute::WritePreChildrenWeb BaseCamelotFilter pFilter  )  [virtual]
 

Writes this StyleReferenceAttribute via the given filter.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/06/97
Parameters:
pFilter,: The filter to use [INPUTS]
Returns:
FALSE if it failed
Notes: this StyleReferenceAttribute attempts to write the referenced style out first.

Reimplemented from TemplateAttribute.

Definition at line 1162 of file tmpltatr.cpp.

01163 {
01164 #ifdef DO_EXPORT
01165     ENSURE_NOT_NULL(Value.m_pStyle);
01166 
01167     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
01168 
01169     // Must write out the style first
01170     ENSURE_KIND(Value.m_pStyle, WizOpStyle);
01171     const WizOpStyle& ActualStyle = (WizOpStyle&)*Value.m_pStyle;
01172 
01173     WizOpStyles* const pStyles = GetStylesForFilter(*pFilter);
01174     BOOL Ok = (pStyles != NULL);
01175 
01176     XFileRef RecordRef = 0;
01177     if (Ok)
01178     {
01179         RecordRef = pStyles->GetRecordRefForStyle(ActualStyle);
01180 
01181         // Is the style reference ok?
01182         Ok = (RecordRef != 0);
01183     }
01184 
01185     if (Ok)
01186     {
01187         // Add a description of the TAG_WIZOP_STYLEREF record for older importers
01188         pFilter->AddTagDescription(TAG_WIZOP_STYLEREF, _R(IDS_TAG_WIZOP_STYLEREF));
01189     }
01190 
01191     if (Ok)
01192     {
01193         CamelotFileRecord Rec(pFilter, TAG_WIZOP_STYLEREF, TAG_WIZOP_STYLEREF_SIZE);
01194 
01195         if (Ok) Ok = Rec.Init();
01196         if (Ok) Ok = Rec.WriteReference(RecordRef);
01197         if (Ok) Ok = pFilter->Write(&Rec);
01198     }
01199 
01200     if (!Ok)
01201         pFilter->GotError(_R(IDE_FILE_WRITE_ERROR));
01202 
01203     return Ok;
01204 #else
01205     return FALSE;
01206 #endif
01207 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:35 2007 for Camelot by  doxygen 1.4.4