#include <textops.h>
Inheritance diagram for PrePostTextAction:
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 |
VisibleTextNode * | CaretContextNode |
AttachNodeDirection | CaretAttachDir |
TextStory * | pTextStoryToReformat |
BOOL | m_bToTail |
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 for the text reformat action.
Definition at line 2312 of file textops.cpp. 02313 { 02314 HasEffect = TRUE; 02315 pTextStoryToReformat = NULL; 02316 CaretContextNode = NULL; 02317 CaretAttachDir = PREV; 02318 }
|
|
Destructor for the text reformat action.
Definition at line 2329 of file textops.cpp.
|
|
Calls FormatAndChildren() then inserts a dormant action to reformat the story.
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 }
|
|
Definition at line 548 of file textops.h. 00548 { return HasEffect; }
|
|
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.
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 }
|
|
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.
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 }
|
|
|
|
|
|
|
|
|
|
|