OpDeleteTextStory Class Reference

This operation should be used to hide a particular TextStory. More...

#include <textops.h>

Inheritance diagram for OpDeleteTextStory:

SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpDeleteTextStory ()
virtual void DoWithParam (OpDescriptor *, OpParam *pParam)
 For finding OpDeleteTextStory's state. Always available.
void PerformMergeProcessing ()
 This function gets called from the Operation::EndOp method after the operation has ended successfuly and been added to the operation history. If the operation could potentially merge itself with the previous operation then perform this merging here.

Static Public Member Functions

static BOOL Init ()
 Initialalises the DeleteATextStory operation.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding OpDeleteTextStory's state. Always available.
static BOOL DoActions (UndoableOperation *, TextStory *)
 Hides an empty text story, inserting the required undo actions into the operation.
static BOOL RemoveEmptyFocusStory (UndoableOperation *pOp=NULL)
 If the focus story has no characters in it and the caret in it is not selected then the story is hidden and the focus story is cleared.

Detailed Description

This operation should be used to hide a particular TextStory.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/04/95

Definition at line 383 of file textops.h.


Constructor & Destructor Documentation

OpDeleteTextStory::OpDeleteTextStory  )  [inline]
 

Definition at line 388 of file textops.h.

00388 {};                             


Member Function Documentation

BOOL OpDeleteTextStory::DoActions UndoableOperation pOp,
TextStory pEmptyStory
[static]
 

Hides an empty text story, inserting the required undo actions into the operation.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/05/95
Parameters:
pOp - points to the current operation [INPUTS] pEmptyStory - points to the text story to delete
Returns:
TRUE/FALSE for success/failure

Errors: Checks on the arguments

Definition at line 4266 of file textops.cpp.

04267 {
04268     ERROR2IF(pEmptyStory == NULL, FALSE, "Story pointer was NULL");
04269 
04270     BOOL ok = TRUE;
04271 
04272     ObjChangeParam ObjDeleteChange(OBJCHANGE_STARTING, ObjChangeFlags(TRUE), pEmptyStory, pOp);
04273     if (ok && pEmptyStory->AllowOp(&ObjDeleteChange))
04274     {
04275         if (pEmptyStory->GetCaret() != NULL)
04276             pEmptyStory->GetCaret()->DeSelect(TRUE);
04277 
04278         if (ok)
04279             ok = pOp->DoInvalidateNodeRegion(pEmptyStory, TRUE, FALSE);
04280 
04281         // If the story is on a path then we want the path to remain
04282         if (ok && (pEmptyStory->GetTextPath() != NULL))
04283         {
04284             NodePath* pTextPath = pEmptyStory->GetTextPath();
04285 
04286             //Localise attributes of the story
04287             if (ok) ok = pOp->DoLocaliseCommonAttributes(pEmptyStory); 
04288             if (ok) ok = pOp->DoMoveNode(pTextPath,pEmptyStory,NEXT);
04289             if (ok) pTextPath->DeSelect(FALSE);
04290 
04291             // Factor back out the common attributes
04292             if (ok)
04293                 ok = pOp->DoFactorOutCommonChildAttributes(pEmptyStory);
04294         }
04295 
04296         // Hide the story
04297         if (ok)
04298             ok = pOp->DoHideNode(pEmptyStory, TRUE);
04299 
04300         if (ok && (TextStory::GetFocusStory() == pEmptyStory))
04301             TextStory::SetFocusStory(NULL);
04302 
04303         GetApplication()->UpdateSelection();
04304     }
04305 
04306     return ok;
04307 }

void OpDeleteTextStory::DoWithParam OpDescriptor pOpDesc,
OpParam pParam
[virtual]
 

For finding OpDeleteTextStory's state. Always available.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/04/95
Parameters:
pOpDesc - points to the OpDescriptor (unused) [INPUTS] pParam - Param1 points to the TextStory to delete

Reimplemented from Operation.

Definition at line 4223 of file textops.cpp.

04224 {
04225     TextStory* pStory = (TextStory*) (void *) pParam->Param1;
04226     if (pStory == NULL)
04227     {
04228         ERROR3("Story pointer was NULL");
04229         return;
04230     }
04231     ERROR3IF(!IS_A(pStory,TextStory),"Story pointer didn't point to a TextStory!");
04232 
04233     BOOL ok = DoStartSelOp(TRUE, TRUE);
04234 
04235     if (ok)
04236         ok = DoActions(this, pStory);
04237 
04238     if (ok)
04239     {
04240         ObjChangeParam ObjChange(OBJCHANGE_FINISHED,ObjChangeFlags(TRUE), pStory, this);
04241         ok = UpdateChangedNodes(&ObjChange);
04242     }
04243         
04244     if (!ok)
04245     {
04246         FailAndExecute();
04247         InformError();
04248     }
04249 
04250     End();
04251 }

OpState OpDeleteTextStory::GetState String_256 UIDescription,
OpDescriptor
[static]
 

For finding OpDeleteTextStory's state. Always available.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/04/95
Returns:
The state of the OpDeleteTextStory

Definition at line 4204 of file textops.cpp.

04205 {
04206     OpState OpSt;
04207 
04208     return OpSt;
04209 }

BOOL OpDeleteTextStory::Init void   )  [static]
 

Initialalises the DeleteATextStory operation.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/04/95
Returns:
TRUE/FALSE for Success/Failure

Reimplemented from SimpleCCObject.

Definition at line 4185 of file textops.cpp.

04186 {
04187     return RegisterOpDescriptor(0,
04188                                 _R(IDS_DELETETEXTSTORY),
04189                                 CC_RUNTIME_CLASS(OpDeleteTextStory),
04190                                 OPTOKEN_DELETESTORY,
04191                                 OpDeleteTextStory::GetState);
04192 }               

void OpDeleteTextStory::PerformMergeProcessing void   )  [virtual]
 

This function gets called from the Operation::EndOp method after the operation has ended successfuly and been added to the operation history. If the operation could potentially merge itself with the previous operation then perform this merging here.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/11/94
Parameters:
[INPUTS] 
- [OUTPUTS]
Returns:
-
Note that this base class function does nothing.

Here are some rules:

1. Note that this function cannot fail - doing so would really be quite scarry. If however you find yourself running out of memory in this function then simply tidyup (leaving things how they were) and then return.

2. After this function has been invoked the operation history size must not be greater than it was prior to the function getting called. It would be quite unimpressive if this was the case anyway.

3. In many cases you will want to delete 'this' operation from this function. so just be careful huh!

The way that you merge the operation is basically up to you, however here are a few pointers.

The first thing you should do on entering this function is to check that the last Operation added to the operation history is this operation. Call OperationHistory::FindLastOp to verify this within an ERROR2 Macro.

Next you will probably want to check if the previous operation performed can be merged with this op. To obtain the previous op call OperationHistory::FindPrevToLastOp. Testing the runtime class of this op is probably enough for you to determine if a merge can take place or not.

Usually you will want to augment the previous operation in some way so that it includes the function which was performed by this operation. This could involve changing an action in the previous operation, adding new actions etc.

Returns:
Errors: -
See also:
OperationHistory::FindLastOp OperationHistory::FindPrevToLastOp OperationHistory::DeleteLastOp ActionList::

Reimplemented from UndoableOperation.

Definition at line 4363 of file textops.cpp.

04364 {
04365     MergeWithPrevious();
04366 }

BOOL OpDeleteTextStory::RemoveEmptyFocusStory UndoableOperation pOp = NULL  )  [static]
 

If the focus story has no characters in it and the caret in it is not selected then the story is hidden and the focus story is cleared.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/04/95
Parameters:
pOp - points to the current operation (if any) [INPUTS]
Returns:
TRUE/FALSE for success/failure

Definition at line 4321 of file textops.cpp.

04322 {
04323     BOOL ok = TRUE;
04324     TextStory* pTS = TextStory::GetFocusStory();
04325     CaretNode* pCaret = NULL;
04326     if (pTS != NULL)
04327         pCaret = pTS->GetCaret();
04328     if ((pTS != NULL) && (pCaret != NULL))
04329     {
04330         // Get a pointer to the first character in the story
04331         VisibleTextNode* pFirstChar = pTS->FindFirstVTN();
04332         if (pFirstChar == NULL)
04333             InformError();
04334         else
04335         {
04336             if (!IS_A(pFirstChar,TextChar))
04337                 pFirstChar = pFirstChar->FindNextTextCharInStory();
04338         }
04339 
04340         // Remove the story if it contains no text chars
04341         if (pFirstChar == NULL)
04342         {
04343             // If no op is running then invoke on to do the delete, otherwise append delete actions to running op 
04344             if (pOp == NULL)
04345             {
04346                 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpDeleteTextStory));
04347                 if (OpDesc != NULL)
04348                 {
04349                     OpParam p((void*)pTS,0);
04350                     OpDesc->Invoke(&p);
04351                 }
04352                 else
04353                     ok = FALSE;
04354             }
04355             else
04356                 ok = OpDeleteTextStory::DoActions(pOp, pTS);
04357         }
04358     }
04359 
04360     return ok;
04361 }


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