How to cut, copy and paste inside a document

To cut, copy and paste inside a document, you must use the CopyLabel class from the TDFpackage.

In fact, you must define a Label which contains the temporary value a cut or copy operation (say, in Lab_Clipboard). You must also define two other labels:

One containing the data (let's call it Lab_source)

One for the destination of the copy (say, in Lab_ Target )

Copy = copy (Lab_Source => Lab_Clipboard)

Cut = copy + Lab_Source.ForgetAll() // this last command clear the contents of LabelSource.

Paste = copy (Lab_Clipboard => Lab_target)

So we need a tool to copy all (or a part) of the content of a label and its sub-label, to another place defined by a label.

For example:

TDF_CopyLabel aCopy;

TDF_IDFilter aFilter (Standard_False);

//Don't copy TDataStd_TreeNode attribute

 aFilter.Ignore(TDataStd_TreeNode::GetDefaultTreeID());

 aCopy.Load(aSource, aTarget); aCopy.UseFilter(aFilter); aCopy.Perform();

// copy the data structure to clipboard

return aCopy.IsDone(); }

Note the use of a filter to forbid copying a specified type of attribute. You can also have a look to TDF_Closure* which can be useful to determine the dependencies of the part you want to cut from the document.