OpCut Class Reference

This class represents the Cut operation. When executed this operation hides all selected objects and places a copy of them on the Internal clipboard. More...

#include <cutop.h>

Inheritance diagram for OpCut:

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

Public Member Functions

 OpCut ()
 OpCut constructor.
void Do (OpDescriptor *)
 Performs the Cut operation.

Static Public Member Functions

static BOOL Init ()
 OpCut initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding OpCut's state.

Detailed Description

This class represents the Cut operation. When executed this operation hides all selected objects and places a copy of them on the Internal clipboard.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/7/93

Definition at line 130 of file cutop.h.


Constructor & Destructor Documentation

OpCut::OpCut  ) 
 

OpCut constructor.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 225 of file cutop.cpp.

00225             : SelOperation()                                
00226 {                              
00227 }


Member Function Documentation

void OpCut::Do OpDescriptor  )  [virtual]
 

Performs the Cut operation.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/8/93
Parameters:
OpDescriptor (unused) [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 343 of file cutop.cpp.

00344 {  
00345     ObjectSet CompoundSet;
00346 
00347     BeginSlowJob(-1, FALSE);        // Make sure we have a simple hourglass, without a delay
00348 
00349     // Check with the clipboard if it is OK to go ahead
00350     InternalClipboard *Clipboard = InternalClipboard::Instance();
00351     if (Clipboard == NULL || !Clipboard->PrepareForCopy())
00352     {
00353         FailAndExecute();
00354 
00355         EndSlowJob();
00356         End();
00357         return;
00358     }
00359 
00360     // Obtain the current selection
00361     Range Sel(*(GetApplication()->FindSelection()));
00362     
00363     // DMc change to range control
00364     RangeControl rg = Sel.GetRangeControlFlags();
00365     rg.PromoteToParent = TRUE;
00366     Sel.Range::SetRangeControl(rg);
00367 
00368 
00369     // Prepare an ObjChangeParam so we can mark which nodes will allow this op to happen to them
00370     ObjChangeFlags cFlags(TRUE);
00371     ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
00372 
00373     if (!DoStartSelOp(TRUE,FALSE))  // Try to record the selection state
00374         goto EndOperation;  
00375     
00376     // Mark nodes that will allow this to happen, and error if no nodes will let it happen
00377     if (!Sel.AllowOp(&ObjChange))
00378     {
00379         ERROR3("AllowOp() returned FALSE, i.e. op should have been greyed out");
00380         goto EndOperation;
00381     }
00382 
00383     
00384     // We need to invalidate the region
00385     if (!DoInvalidateNodesRegions(Sel, TRUE))
00386         goto EndOperation; 
00387 
00388     // Prior to hiding anything lets get ourselves a set of compound nodes which 
00389     // we will need to factor out attributes on. We cannot use the SelRange because
00390     // this will be empty after the deletion has taken place. 
00391 
00392     if (!(Sel.GetCompoundObjectSet(&CompoundSet, 
00393                                     TRUE )))
00394     {
00395         goto EndOperation; 
00396     }
00397     
00398     // Removed 24/07/95 (We now leave it up to the text story deletion code to handle its own attributes)
00399 
00400     // Because of complex deletion we must also add the TextStory objects 
00401     // of selected chars. This code will hopefuly be removed in future. It is
00402     // inefficient cos we will need to factor out more than once for each line !.
00403     
00404     //if (!(Sel.AddTextStoryCompoundsForDel(&CompoundSet)))
00405     //{
00406     //  goto EndOperation;
00407     //} 
00408 
00409     // We now must localise the attributes on every item marked for deletion
00410     if (!DoLocaliseForAttrChange(&Sel, (AttrTypeSet*)NULL, TRUE ))
00411     {
00412         goto EndOperation;
00413     }
00414 
00415 
00416     // Copy the selection to the internal clipboard
00417     if (!DoCopyNodesToClipboard(Sel))
00418         goto EndOperation; 
00419 
00420     // Go through one pass, asking nodes to hide themselves
00421     if (!DoHideComplexRange(Sel))
00422         goto EndOperation;
00423     {
00424         SelRange* pRange = GetApplication()->FindSelection();
00425         if (pRange)
00426         {
00427             // freshen the selection range by counting the currently selected objects
00428             pRange->Update(FALSE,NULL);
00429 //          INT32 num = pRange->Count();
00430             pRange->Count();    // side-effect?
00431         
00432             // Obtain the current selection (should be up-to-date now!)
00433             Range NewSel(*pRange);
00434 
00435             // Now go through a second pass snip the remainder out of the tree
00436             if (!DoHideNodes(NewSel,TRUE))   // Hide the nodes (IncludeSubtreeSize)
00437                 goto EndOperation;
00438         }
00439     }
00440 
00441     // Finally try to factor out the attributes on all compounds. Note that if a particular compound
00442     // is hidden then it will  be it's parent that has its attributes factored out !
00443     if (!DoFactorOutAfterAttrChange(&CompoundSet,(AttrTypeSet*)NULL))
00444     {
00445         goto EndOperation; 
00446     }
00447     
00448     // We need to inform the DocComponents of the clipboard that the copy is complete
00449 
00450 EndOperation:
00451 
00452     CompoundSet.DeleteAll();    // Delete all items in the CompoundSet
00453         
00454     // Update all the changed nodes, i.e. tell all the parents of the children that have been effected
00455     ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
00456     if (!UpdateChangedNodes(&ObjChange))
00457         FailAndExecute();
00458 
00459     // Invalidate sel range as it may have been cached in the middle of the op while the tree is
00460     // in an invalid state (i.e. some selected nodes may have had the PERMISSION_DENIED state set during caching).
00461     {
00462         SelRange* pRange = GetApplication()->FindSelection();
00463         if (pRange)
00464             pRange->Update(FALSE,NULL);
00465     }
00466 
00467     // Copy the doc's file-path etc, so that the clipboard doc knows if it is possible to
00468     // OLE link to the doc.
00469     Document* pSourceDoc = Document::GetSelected();
00470     if (pSourceDoc && !pSourceDoc->GetOilDoc()->GetKernelPathName().IsEmpty())
00471     {
00472         // Don't add to the MRU list!
00473         String_256 str = pSourceDoc->GetOilDoc()->GetKernelPathName();
00474         InternalClipboard::Instance()->GetOilDoc()->SetPathName(str, FALSE);
00475         TRACEUSER( "JustinF", _T("Copied file-path %s to clipboard document\n"),
00476                     (LPCTSTR) InternalClipboard::Instance()->GetOilDoc()->GetKernelPathName());
00477     }
00478     else
00479     {
00480         // Set the path-name to be empty (what a delicious potential bug!)
00481         InternalClipboard::Instance()->GetOilDoc()->SetPathNameEmpty();
00482         TRACEUSER( "JustinF", _T("Setting clipboard file-path to nothing\n"));
00483     }
00484 
00485     // And finally, tell the clipboard we've finished copying to it
00486     // (This is the point where it is made available to other applications, etc)
00487     if (!Clipboard->CopyCompleted())
00488         FailAndExecute();
00489 
00490     EndSlowJob();
00491     End();
00492 }           

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

For finding OpCut's state.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/9/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the OpCut

Errors: -

See also:
-

Definition at line 282 of file cutop.cpp.

00283 {
00284     OpState OpSt;
00285 
00286     // BODGE Temporarily disable copying TextStory sub-selections
00287 /*
00288     Range Sel(*(GetApplication()->FindSelection()));
00289     Node* Current = Sel.FindFirst();
00290     while(Current != NULL)
00291     {
00292         if (Current->IS_KIND_OF(BaseTextClass))
00293         {
00294             if (!(IS_A(Current, TextStory)))
00295             {
00296                 OpSt.Greyed = TRUE;
00297                 return(OpSt);
00298             }
00299         }
00300         Current = Sel.FindNext(Current, TRUE); 
00301     }
00302 */
00303 
00304     SelRange* pSelRange = GetApplication()->FindSelection();    // get the selected range
00305 
00306     // Set up the ObjChangeParam so we can ask the selected nodes if they minds being cut
00307     ObjChangeFlags cFlags(TRUE);
00308     ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,NULL);
00309 
00310     // Will one or more selected nodes allow this op?
00311     if (!pSelRange->AllowOp(&ObjChange,FALSE))
00312     {
00313         // None of the nodes can be deleted
00314         OpSt.Greyed = TRUE;
00315 
00316         // Load reason why operation is disabled
00317         UINT32 IDS = ObjChange.GetReasonForDenial();
00318         if (IDS == 0) IDS = _R(IDS_NO_OBJECTS_SELECTED);    // if 0 (i.e. not been set), then assume there's no selection
00319         *UIDescription = String_256(IDS);               // Resolve the string ID
00320     }
00321     else
00322         SetCutOpText(UIDescription, _R(IDS_CLIPBOARD_PRECUT));
00323 
00324     return(OpSt);
00325 }

BOOL OpCut::Init void   )  [static]
 

OpCut initialiser method.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/9/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Errors: ERROR will be called if there was insufficient memory to allocate the operation.

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 247 of file cutop.cpp.

00248 {
00249     return (RegisterOpDescriptor(0,
00250                             _R(IDS_CUTOP),
00251                             CC_RUNTIME_CLASS(OpCut),
00252                             OPTOKEN_CUT,
00253                             OpCut::GetState,
00254                             0,                          // help ID 
00255                             _R(IDBBL_CUT),
00256                             0,
00257                             0,
00258                             SYSTEMBAR_ILLEGAL,          // For now !
00259                             TRUE,                       // Receive messages
00260                             FALSE,
00261                             FALSE,
00262                             0,
00263                             0 //(GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION)
00264     ));
00265 }               


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