PrePostTextAction Class Reference

This action will be generated at the start and end of an OpTextUndoable operation. It will perform the following tasks. More...

#include <textops.h>

Inheritance diagram for PrePostTextAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 PrePostTextAction ()
 Constructor for the text reformat action.
 ~PrePostTextAction ()
 Destructor for the text reformat action.
virtual ActionCode Execute ()
 If this action is active then it calls the text story to reformat itself. In both cases (active and idle) the opposite action created has the opposite state.
BOOL DoIReformat ()

Static Public Member Functions

static ActionCode Init (Operation *pOp, ActionList *pActionList, TextStory *pStory, BOOL ThisActionReformats, BOOL ToTail=FALSE)
 This is the function which creates an instance of this action. There should be two actions in the ActionList for each operation, one at the start lying idle, and the one at the end of the action list causing a reformat. The execute function should toggle the idle state of the action. When inserting actions into the list in the Do function of your operation the first one should be active and the second one idle.
static BOOL DoFormatStory (UndoableOperation *pUndoOp, TextStory *pStory, BOOL ToTail=FALSE)
 Calls FormatAndChildren() then inserts a dormant action to reformat the story.

Protected Attributes

BOOL HasEffect
VisibleTextNodeCaretContextNode
AttachNodeDirection CaretAttachDir
TextStorypTextStoryToReformat
BOOL m_bToTail

Detailed Description

This action will be generated at the start and end of an OpTextUndoable operation. It will perform the following tasks.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/03/95
Restores the Caret position

Calls FormatAndChild on the Text story on which it operates so that text stories get formated when we undo/redo.

The action toggles between being active and not active so that it only gets executed when it is a last executed action.

Definition at line 530 of file textops.h.


Constructor & Destructor Documentation

PrePostTextAction::PrePostTextAction  ) 
 

Constructor for the text reformat action.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/94

Definition at line 2312 of file textops.cpp.

02313 {
02314     HasEffect            = TRUE;
02315     pTextStoryToReformat = NULL;
02316     CaretContextNode     = NULL;
02317     CaretAttachDir       = PREV;
02318 }

PrePostTextAction::~PrePostTextAction  ) 
 

Destructor for the text reformat action.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/7/94

Definition at line 2329 of file textops.cpp.

02330 {
02331 }


Member Function Documentation

BOOL PrePostTextAction::DoFormatStory UndoableOperation pUndoOp,
TextStory pStory,
BOOL  ToTail = FALSE
[static]
 

Calls FormatAndChildren() then inserts a dormant action to reformat the story.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/4/95
Parameters:
pUndoOp - pointer to an undoable operation [INPUTS] pStory - points to the story to reform
Returns:
FALSE if fails

Definition at line 2416 of file textops.cpp.

02418 {
02419     ERROR2IF(pUndoOp==NULL,FALSE,"PrePostTextAction::DoFormatStory() - NULL operation pointer");
02420     ERROR2IF( pStory==NULL,FALSE,"PrePostTextAction::DoFormatStory() - NULL story pointer");
02421     
02422     // Format the story
02423     BOOL ok = pStory->FormatAndChildren(pUndoOp,!ToTail);
02424 
02425     // Insert dormant reformat action
02426     ActionList* pActionList = pUndoOp->GetUndoActionList();
02427     ERROR2IF(pActionList==NULL,FALSE,"PrePostTextAction::DoFormatStory() - pActionList==NULL");
02428     if (ok) ok = (Init(pUndoOp, pActionList, pStory, FALSE, ToTail) != AC_FAIL);
02429 
02430     return ok;
02431 }

BOOL PrePostTextAction::DoIReformat  )  [inline]
 

Definition at line 548 of file textops.h.

00548 { return HasEffect; }

ActionCode PrePostTextAction::Execute  )  [virtual]
 

If this action is active then it calls the text story to reformat itself. In both cases (active and idle) the opposite action created has the opposite state.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/3/95
Returns:
ActionCode, either AC_OK, AC_NORECORD or AC_FAIL

Errors: ERROR3 if the text story pointer is NULL

Reimplemented from Action.

Definition at line 2445 of file textops.cpp.

02446 {
02447     ERROR3IF(pTextStoryToReformat == NULL, "The TextStory pointer is NULL");
02448     
02449     // Create a redo action for this action, which is also a PrePostTextAction
02450     ActionCode Act;
02451     Act = PrePostTextAction::Init(pOperation, 
02452                                   pOppositeActLst, 
02453                                   pTextStoryToReformat,
02454                                   !HasEffect,
02455                                   m_bToTail);         // Toggle
02456     
02457     if (Act == AC_FAIL)
02458         return AC_FAIL;
02459 
02460     if (pTextStoryToReformat == NULL)
02461         return Act;
02462 
02463     if (pTextStoryToReformat->FindParent() == NULL) // The TextStory is not in the tree, 
02464                                                   // it's probably hidden
02465         return Act;
02466 
02467     // Cause the reformat if required.
02468     if (HasEffect && pTextStoryToReformat!=NULL)
02469     {
02470         // Restore the caret first
02471         pTextStoryToReformat->MoveCaretToCharacter(CaretContextNode, CaretAttachDir);
02472 
02473         if (!pTextStoryToReformat->FormatAndChildren(NULL,FALSE,FALSE))
02474             return AC_FAIL;
02475     }
02476     return Act;
02477 }

ActionCode PrePostTextAction::Init Operation pOp,
ActionList pActionList,
TextStory pStory,
BOOL  ThisActionReformats,
BOOL  ToTail = FALSE
[static]
 

This is the function which creates an instance of this action. There should be two actions in the ActionList for each operation, one at the start lying idle, and the one at the end of the action list causing a reformat. The execute function should toggle the idle state of the action. When inserting actions into the list in the Do function of your operation the first one should be active and the second one idle.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/3/95
Parameters:
pOp is the pointer to the operation to which this action belongs [INPUTS] pActionList is the action list to which this action should be added pStory - pointer to the text story to reformat ThisActionReformats - TRUE if this action will cause a reformat FALSE if it is dormant
Returns:
ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL
See also:
Action::Init(), PrePostTextAction::Execute()

Definition at line 2358 of file textops.cpp.

02363 {
02364     UINT32 ActSize = sizeof(PrePostTextAction);
02365     PrePostTextAction* pNewAction;
02366     ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(PrePostTextAction), (Action**)&pNewAction);
02367 
02368     if (Ac==AC_OK && pNewAction!=NULL)
02369     {
02370         pNewAction->m_bToTail = ToTail;
02371         
02372         pNewAction->HasEffect            = ThisActionReformats;
02373         pNewAction->pTextStoryToReformat = pStory;
02374 
02375         // Now store a Context node and direction so the caret's position can be restored
02376         // must be on the same line, otherwise losts of grief!
02377         CaretNode* pCaret = pStory->GetCaret();
02378         ERROR2IF(pCaret==NULL,AC_FAIL,"PrePostTextAction::Init() - story has no caret");
02379         pNewAction->CaretAttachDir   = PREV;
02380         pNewAction->CaretContextNode = pCaret->FindNextVTNInLine();
02381         if (pNewAction->CaretContextNode==NULL)
02382         {
02383             pNewAction->CaretAttachDir   = NEXT;
02384             pNewAction->CaretContextNode = pCaret->FindPrevVTNInLine();
02385             ERROR2IF(pNewAction->CaretContextNode==NULL,AC_FAIL,"PrePostTextAction::Init() - could find no context node for caret!");
02386         }
02387 
02388         // reformat the text (if the tail flag is set)
02389         if (ToTail)
02390         {
02391             pStory->FlagNodeAndDescendantsModifiedByOpAndParentsHaveDescendantModifiedByOp();
02392             pStory->FormatAndChildren(NULL,FALSE);
02393 
02394             // remove the new action from the list, and add it to the head of
02395             // the action list
02396             pActionList->RemoveItem(pNewAction);
02397             pActionList->AddHead(pNewAction);
02398         }
02399     }
02400 
02401     return Ac;
02402 }


Member Data Documentation

AttachNodeDirection PrePostTextAction::CaretAttachDir [protected]
 

Definition at line 553 of file textops.h.

VisibleTextNode* PrePostTextAction::CaretContextNode [protected]
 

Definition at line 552 of file textops.h.

BOOL PrePostTextAction::HasEffect [protected]
 

Definition at line 551 of file textops.h.

BOOL PrePostTextAction::m_bToTail [protected]
 

Definition at line 555 of file textops.h.

TextStory* PrePostTextAction::pTextStoryToReformat [protected]
 

Definition at line 554 of file textops.h.


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