WizOpStyleRecordHandler Class Reference

Allows WizOpStyleComponent's to be read from the .xar/.web file formats. More...

#include <styles.h>

Inheritance diagram for WizOpStyleRecordHandler:

CamelotRecordHandler CXaraFileRecordHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 WizOpStyleRecordHandler ()
 Makes sure data members are initialized to safe values.
virtual ~WizOpStyleRecordHandler ()
 Makes sure data members are unheaped properly.
virtual UINT32GetTagList ()
 Provides the record handler system with a list of records handled by this handler.
virtual BOOL Init (BaseCamelotFilter *pFilter)
 Initialises the WizOpStyleRecordHandler.
virtual BOOL HandleRecord (CXaraFileRecord *pCXaraFileRecord)
 Handles the given record.
virtual BOOL EndImport ()
 Informs the record handler that importing is over Reverses all the stuff done in Init(). Should it be done in BeginImport?
WizOpStyleFindStyleFromRecordReference (XFileRef RecordRef) const
 Finds an imported style, given the record number.

Protected Member Functions

 WizOpStyleRecordHandler (const WizOpStyleRecordHandler &Other)
 Warns us that we've done a destructor but we haven't done either of these.
WizOpStyleRecordHandleroperator= (const WizOpStyleRecordHandler &Other)
WizOpStyleAddStyle (const StringBase &Name, const StringBase &Question, const StringBase &WizOpName, const StringBase &Param)
 Adds a WizOpStyle to the importing document's WizOpStyles component.
BOOL AddRecordReference (XFileRef RecordRef, const WizOpStyle &ImportedStyle)
 We need to remember the record numbers of the styles so that Style References can find the style they want. This function associates a record number with the newly imported style to that end.
WizOpStylesGetTentativeStyles ()
 This provides descriptions for the define units records.Data Access.

Private Member Functions

 CC_DECLARE_DYNAMIC (WizOpStyleRecordHandler)

Private Attributes

WizOpStylesm_pTentativeStyles
List m_ImportedItems

Detailed Description

Allows WizOpStyleComponent's to be read from the .xar/.web file formats.

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

Definition at line 422 of file styles.h.


Constructor & Destructor Documentation

WizOpStyleRecordHandler::WizOpStyleRecordHandler  ) 
 

Makes sure data members are initialized to safe values.

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

Definition at line 1363 of file styles.cpp.

01363                                                  : 
01364     m_pTentativeStyles(NULL)
01365 {
01366 }

WizOpStyleRecordHandler::~WizOpStyleRecordHandler  )  [virtual]
 

Makes sure data members are unheaped properly.

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

Definition at line 1379 of file styles.cpp.

01380 {
01381     if (!m_ImportedItems.IsEmpty())
01382     {
01383         TRACE( _T("WizOpStyleRecordHandler - Imported items left over\n"));
01384     }
01385 }

WizOpStyleRecordHandler::WizOpStyleRecordHandler const WizOpStyleRecordHandler Other  )  [protected]
 

Warns us that we've done a destructor but we haven't done either of these.

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

Definition at line 1399 of file styles.cpp.

01400 {
01401     TRACE( _T("WizOpStyleRecordHandler - Copy constructor not implemented"));
01402 }


Member Function Documentation

BOOL WizOpStyleRecordHandler::AddRecordReference XFileRef  RecordRef,
const WizOpStyle ImportedStyle
[protected]
 

We need to remember the record numbers of the styles so that Style References can find the style they want. This function associates a record number with the newly imported style to that end.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/07/97
Parameters:
RecordRef,: The record number of the newly imported style [INPUTS] ImportedStyle: The newly imported style
Returns:
TRUE if it managed to add the reference FALSE if not
See Also: WizOpStyleRefRecordHandler::HandleRecord

Definition at line 1624 of file styles.cpp.

01625 {
01626     BOOL Ok = TRUE;
01627 
01628     StyleRecordReference* pNewRecRef = new StyleRecordReference(ImportedStyle, RecordRef);
01629 
01630     Ok = (pNewRecRef != NULL);
01631 
01632     if (Ok)
01633     {
01634         m_ImportedItems.AddHead(pNewRecRef);
01635     }
01636 
01637     return Ok;
01638 }

WizOpStyle * WizOpStyleRecordHandler::AddStyle const StringBase Name,
const StringBase Question,
const StringBase WizOpName,
const StringBase Param
[protected]
 

Adds a WizOpStyle to the importing document's WizOpStyles component.

Parameters:
Name,Question,Param,: Passed on to the WizOpStyle [INPUTS] WizOpName: The name of the WizOp that the style refers to
Returns:
A pointer to the WizOpStyle to use in any reference NULL if it failed

Definition at line 1586 of file styles.cpp.

01588 {
01589     WizOpStyle* pStyleToUse = NULL;
01590 
01591     WizOp* const pWizOp = GetWizOps().FindWizOpFromInternalName(WizOpName);
01592 
01593     if (pWizOp != NULL)
01594     {
01595         WizOpStyle NewStyle(Name, Question, *pWizOp, Param);
01596         pStyleToUse = (WizOpStyle*)GetTentativeStyles().CopyComponentData(NewStyle);
01597     }
01598 
01599     return pStyleToUse;
01600 }

WizOpStyleRecordHandler::CC_DECLARE_DYNAMIC WizOpStyleRecordHandler   )  [private]
 

BOOL WizOpStyleRecordHandler::EndImport  )  [virtual]
 

Informs the record handler that importing is over Reverses all the stuff done in Init(). Should it be done in BeginImport?

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/07/97
Returns:
TRUE if ok FALSE otherwise
Notes: If you override this func, be sure to call the base class varient

Reimplemented from CXaraFileRecordHandler.

Definition at line 1488 of file styles.cpp.

01489 {
01490     BOOL Ok = TRUE;
01491 
01492     m_ImportedItems.DeleteAll();
01493 
01494     Ok = CXaraFileRecordHandler::EndImport();
01495 
01496     return Ok;
01497 }

WizOpStyle * WizOpStyleRecordHandler::FindStyleFromRecordReference XFileRef  RecordRef  )  const
 

Finds an imported style, given the record number.

Parameters:
RecordRef,: The number of the record in which the style was. [INPUTS]

Definition at line 1653 of file styles.cpp.

01654 {
01655     WizOpStyle* pFoundStyle = NULL;
01656 
01657     StyleRecordReference* pCurrentSRR = (StyleRecordReference*)m_ImportedItems.GetHead();
01658 
01659     while (pCurrentSRR != NULL)
01660     {
01661         if (pCurrentSRR->GetRecordRef() == RecordRef)
01662         {
01663             pFoundStyle = (WizOpStyle*)&(pCurrentSRR->GetStyle());
01664             break;
01665         }
01666         else
01667         {
01668             pCurrentSRR = (StyleRecordReference*)m_ImportedItems.GetNext(pCurrentSRR);
01669         }
01670     }
01671 
01672     return pFoundStyle;
01673 }

UINT32 * WizOpStyleRecordHandler::GetTagList  )  [virtual]
 

Provides the record handler system with a list of records handled by this handler.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/07/97
Returns:
Ptr to a list of tag values, terminated by CXFRH_TAG_LIST_END

Implements CXaraFileRecordHandler.

Definition at line 1424 of file styles.cpp.

01425 {
01426     static UINT32 TagList[] = {TAG_WIZOP_STYLE,
01427                               CXFRH_TAG_LIST_END};
01428 
01429     return (UINT32*)&TagList;
01430 }

WizOpStyles & WizOpStyleRecordHandler::GetTentativeStyles  )  [protected]
 

This provides descriptions for the define units records.Data Access.

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

Definition at line 1776 of file styles.cpp.

01777 {
01778     // This static dummy object is used for returning in the ERROR2 case
01779     // The original used to return a ptr to a local variable, which is a tad dangerous.
01780     // This solution is not ideal, because there's a permanent instance of an object
01781     // that will probably never be used.
01782     static WizOpStyles Dummy;
01783 
01784     ERROR2IF(m_pTentativeStyles == NULL, Dummy, "NULL Member");
01785 
01786     return *m_pTentativeStyles;
01787 }

BOOL WizOpStyleRecordHandler::HandleRecord CXaraFileRecord pRecord  )  [virtual]
 

Handles the given record.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/07/97
Parameters:
pCXaraFileRecord = ptr to record to handle [INPUTS]
Returns:
TRUE if handled successfuly FALSE otherwise

Implements CXaraFileRecordHandler.

Definition at line 1512 of file styles.cpp.

01513 {
01514     ENSURE_NOT_NULL(pRecord);
01515     ERROR2IF(pRecord->GetTag() != TAG_WIZOP_STYLE, FALSE, "I don't handle this tag type");
01516 
01517     String_64 OpName;
01518     String_256 Question;
01519     String_256 Param;
01520     String_256 StyleName;
01521 
01522     BOOL ok = pRecord->ReadUnicode(OpName, 64);
01523 
01524     if (ok)
01525     {
01526         ok = pRecord->ReadUnicode(Question, 256);
01527     }
01528 
01529     if (ok)
01530     {
01531         ok = pRecord->ReadUnicode(Param, 256);
01532     }
01533 
01534     if (ok)
01535     {
01536         ok = pRecord->ReadUnicode(StyleName, 256);
01537     }
01538 
01539     if (ok)
01540     {
01541         // We managed to read it all OK so add a new Style to the styles we've imported
01542         // and remember its record number for reference purposes
01543         WizOpStyle* pStyleToUse = AddStyle(StyleName, Question, OpName, Param);
01544         if (pStyleToUse == NULL)
01545         {
01546             BaseCamelotFilter* const pFilter = GetBaseCamelotFilter();
01547             ENSURE_NOT_NULL(pFilter);
01548             pFilter->AppendWarning(_R(IDS_STYLE_OF_UNKNOWN_WIZOP));
01549         }
01550         else
01551         {
01552             ok = AddRecordReference(pRecord->GetRecordNumber(), *pStyleToUse);
01553         }
01554 
01555     }
01556 
01557     if (!ok)
01558     {
01559         BaseCamelotFilter* const pFilter = GetBaseCamelotFilter();
01560         ENSURE_NOT_NULL(pFilter);
01561         pFilter->GotError(_R(IDE_FILE_READ_ERROR));
01562     }
01563 
01564     return ok;
01565 }

BOOL WizOpStyleRecordHandler::Init BaseCamelotFilter pFilter  )  [virtual]
 

Initialises the WizOpStyleRecordHandler.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/07/97
Returns:
TRUE if ok FALSE otherwise

Reimplemented from CamelotRecordHandler.

Definition at line 1446 of file styles.cpp.

01447 {
01448     BOOL Ok = TRUE;
01449 
01450     Ok = CamelotRecordHandler::Init(pFilter);
01451 
01452     Document* const pDoc = GetDocument();
01453     Ok = (pDoc != NULL);
01454 
01455     if (Ok)
01456     {
01457         m_pTentativeStyles = (WizOpStyles*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(WizOpStyles));
01458         Ok = (m_pTentativeStyles != NULL);
01459     }
01460 
01461     // give this WizOpStyleRecordHandler to the style component so it can call us back
01462     if (Ok)
01463     {
01464         Ok = m_pTentativeStyles->SetRecordHandler(*this);
01465     }
01466 
01467     return Ok;
01468 }

WizOpStyleRecordHandler & WizOpStyleRecordHandler::operator= const WizOpStyleRecordHandler Other  )  [protected]
 

Definition at line 1404 of file styles.cpp.

01405 {
01406     TRACE( _T("WizOpStyleRecordHandler - Assignment operator not implemented"));
01407     return *this;
01408 }


Member Data Documentation

List WizOpStyleRecordHandler::m_ImportedItems [private]
 

Definition at line 460 of file styles.h.

WizOpStyles* WizOpStyleRecordHandler::m_pTentativeStyles [private]
 

Definition at line 459 of file styles.h.


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