#include <cutop.h>
Inheritance diagram for OpCopy:
Public Member Functions | |
OpCopy () | |
OpCopy constructor. | |
void | Do (OpDescriptor *) |
Performs the Copy operation. | |
virtual BOOL | MayChangeNodeBounds () const |
Static Public Member Functions | |
static BOOL | Init () |
OpCopy initialiser method. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
For finding OpCopy's state. |
Definition at line 154 of file cutop.h.
|
OpCopy constructor.
Definition at line 514 of file cutop.cpp. 00514 : SelOperation() 00515 { 00516 }
|
|
Performs the Copy operation.
Reimplemented from Operation. Definition at line 617 of file cutop.cpp. 00618 { 00619 BeginSlowJob(-1, FALSE); // Make sure we have a simple hourglass, without a delay 00620 00621 // Check with the clipboard if it is OK to go ahead 00622 InternalClipboard *Clipboard = InternalClipboard::Instance(); 00623 if (Clipboard == NULL || !Clipboard->PrepareForCopy()) 00624 { 00625 FailAndExecute(); 00626 00627 EndSlowJob(); 00628 End(); 00629 return; 00630 } 00631 00632 // Obtain the current selections 00633 Range Sel(*(GetApplication()->FindSelection())); 00634 00635 // DMc change to range control 00636 00637 RangeControl rg = Sel.GetRangeControlFlags(); 00638 rg.PromoteToParent = TRUE; 00639 Sel.Range::SetRangeControl(rg); 00640 00641 // Prepare an ObjChangeParam so we can mark which nodes will allow this op to happen to them 00642 ObjChangeFlags cFlags; 00643 cFlags.CopyNode=TRUE; 00644 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this); 00645 00646 // Find the first node which is selected 00647 Node* FirstSelectedNode = Sel.FindFirst(); 00648 00649 ENSURE(FirstSelectedNode != NULL, "Called copy operation with no nodes selected"); 00650 00651 // In the retail build it is best to do nothing if we find there are no selected nodes 00652 if (FirstSelectedNode != NULL) // No nodes selected so End 00653 { 00654 if (!DoStartSelOp(TRUE,TRUE)) // Try to record the selection state 00655 { 00656 goto EndOperation; 00657 } 00658 00659 // Mark nodes that will allow this to happen, and error if no nodes will let it happen 00660 if (!Sel.AllowOp(&ObjChange)) 00661 { 00662 ERROR3("AllowOp() returned FALSE, i.e. op should have been greyed out"); 00663 goto EndOperation; 00664 } 00665 00666 // Copy the selection to the internal clipboard 00667 if (!DoCopyNodesToClipboard(Sel)) 00668 { 00669 goto EndOperation; 00670 } 00671 } 00672 00673 00674 EndOperation: 00675 // Update all the changed nodes, i.e. tell all the parents of the children that have been effected 00676 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this); 00677 if (!UpdateChangedNodes(&ObjChange)) 00678 FailAndExecute(); 00679 00680 // Copy the doc's file-path etc, so that the clipboard doc knows if it is possible to 00681 // OLE link to the doc. 00682 Document* pSourceDoc = Document::GetSelected(); 00683 if (pSourceDoc && !pSourceDoc->GetOilDoc()->GetKernelPathName().IsEmpty()) 00684 { 00685 // Don't add to the MRU list! 00686 String_256 str = pSourceDoc->GetOilDoc()->GetKernelPathName(); 00687 InternalClipboard::Instance()->GetOilDoc()->SetPathName(str, FALSE); 00688 TRACEUSER( "JustinF", _T("Copied file-path %s to clipboard document\n"), 00689 (LPCTSTR) InternalClipboard::Instance()->GetOilDoc()->GetKernelPathName()); 00690 } 00691 else 00692 { 00693 // Set the path-name to be empty (what a delicious potential bug!) 00694 InternalClipboard::Instance()->GetOilDoc()->SetPathNameEmpty(); 00695 TRACEUSER( "JustinF", _T("Setting clipboard file-path to nothing\n")); 00696 } 00697 00698 // And finally, tell the clipboard we've finished copying to it 00699 // (This is the point where it is made available to other applications, etc) 00700 if (!Clipboard->CopyCompleted()) 00701 FailAndExecute(); 00702 00703 EndSlowJob(); 00704 End(); 00705 }
|
|
For finding OpCopy's state.
Definition at line 571 of file cutop.cpp. 00572 { 00573 OpState OpSt; 00574 00575 // BODGE Temporarily disable copying TextStory sub-selections 00576 Range Sel(*(GetApplication()->FindSelection())); 00577 /*Node* Current =*/ Sel.FindFirst(); 00578 00579 // Set up the ObjChangeParam so we can ask the selected nodes if they minds being copied 00580 ObjChangeFlags cFlags; 00581 cFlags.CopyNode=TRUE; 00582 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,NULL); 00583 00584 // Will one or more selected nodes allow this op? 00585 if (!Sel.AllowOp(&ObjChange,FALSE)) 00586 { 00587 // None of the nodes can be deleted 00588 OpSt.Greyed = TRUE; 00589 00590 // Load reason why operation is disabled 00591 UINT32 IDS = ObjChange.GetReasonForDenial(); 00592 if (IDS == 0) IDS = _R(IDS_NO_OBJECTS_SELECTED); // if 0 (i.e. not been set), then assume there's no selection 00593 *UIDescription = String_256(IDS); // Resolve the string ID 00594 } 00595 else 00596 SetCutOpText(UIDescription, _R(IDS_CLIPBOARD_PRECOPY)); 00597 00598 return(OpSt); 00599 }
|
|
OpCopy initialiser method.
Reimplemented from SimpleCCObject. Definition at line 536 of file cutop.cpp. 00537 { 00538 return (RegisterOpDescriptor(0, 00539 _R(IDS_COPYOP), 00540 CC_RUNTIME_CLASS(OpCopy), 00541 OPTOKEN_COPY, 00542 OpCopy::GetState, 00543 0, // help ID 00544 _R(IDBBL_COPY), 00545 0, // bitmap ID 00546 0, 00547 SYSTEMBAR_ILLEGAL, // For now ! 00548 TRUE, // Receive messages 00549 FALSE, 00550 FALSE, 00551 0, 00552 (DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION) 00553 )); 00554 }
|
|
Reimplemented from SelOperation. Definition at line 166 of file cutop.h. 00166 { return FALSE; }
|