MFC Grid manual

CCopyPaste Class Reference

Default implementation of ICopyPaste interface. More...

#include <Dapfor/GUI/CopyPaste.h>

Inheritance diagram for CCopyPaste:

ICopyPaste IObjectImporter IAutoDelete

List of all members.


Public Types

typedef std::vector
< IClipboardFormat * > 
Formats
 List of the clipboard formats.

Public Member Functions

 CCopyPaste (bool bAutoDelete=false)
 Constructor.
virtual ~CCopyPaste ()
 Virtual destructor.
virtual void RegisterFormat (IClipboardFormat *format)
 Registers a new clipboard format. The formats are applied in order of their registration.
virtual FormatsGetFormats () const
 Gets a list of all registered formats.
virtual bool Copy (const CGrid &grid)
 Copies content of CGrid to the clipboard.
virtual bool Cut (const CGrid &grid)
 Cuts content of CGrid to the clipboard.
virtual bool Paste (CPasteTarget &pasteTarget)
 Pastes the data, placed in the clipboard to CGrid.
virtual bool CustomCutCopy (CCutCopySource &source)
 Performs a copy/cut operation. The source has serializable content that can be modified.
virtual bool CustomPaste (CPasteTarget &pasteTarget, IClipboardFormat::RestoredInfo &restoredInfo, OperationType type)
 Performs a paste operation. The restoredInfo contains deserialized content which can be modified before being put to the grid.
virtual Common::CDataObjectImportObject (const TString &className) const
 Tries to create a new data object of the class specified in the className parameter.
virtual void GetImportedObjects (ImportedObjects &container) const
 Gets all imported objects.
virtual void RemoveImportedObjects (bool bDestroy)
 Removes all imported objects from the local cache.
virtual bool AutoDelete () const
 IAutoDelete implementation. Returns the value, passed in the constructor.

Detailed Description

Default implementation of ICopyPaste interface.

Provides basic functionality to copy/cut/paste objects from one grid to another via the clipboard mechanism. An object of this class can import data objects from other applications. These objects are deserialized from a binary presentation with the help of Common::CTypeFactory and are stocked in the internal container. Restored objects can be obtained by GetImportedObjects() call. When the application is stopped, all non retrieved data objects will be destroyed in the destructor of this class. If you want to prevent them from destruction, after each paste operation it should call RemoveImportedObjects(false).

Version:
1.0.0.0 Initial version

Constructor & Destructor Documentation

CCopyPaste ( bool  bAutoDelete = false  ) 

Constructor.

Parameters:
[in] bAutoDelete Indicates that this object can be destroyed in the destructor of CGrid


Member Function Documentation

void RegisterFormat ( IClipboardFormat format  )  [virtual]

Registers a new clipboard format. The formats are applied in order of their registration.

Parameters:
[in] format A new clipboard format.

CCopyPaste::Formats & GetFormats (  )  const [virtual]

Gets a list of all registered formats.

Returns:
List of all formats.

bool Copy ( const CGrid grid  )  [virtual]

Copies content of CGrid to the clipboard.

Parameters:
[in] grid Reference to the grid

Implements ICopyPaste.

bool Cut ( const CGrid grid  )  [virtual]

Cuts content of CGrid to the clipboard.

Parameters:
[in] grid Reference to the grid

Implements ICopyPaste.

bool Paste ( CPasteTarget pasteTarget  )  [virtual]

Pastes the data, placed in the clipboard to CGrid.

Parameters:
[in] pasteTarget Indicates the position in CGrid where the clipboard content should be inserted.

Implements ICopyPaste.

bool CustomCutCopy ( CCutCopySource source  )  [virtual]

Performs a copy/cut operation. The source has serializable content that can be modified.

Copies or cuts content of the grid into the clipboard with the specified formats

Parameters:
[in] source Source related information to copy into the clipboard.
Returns:
true if the items have been copied into the clipboard. Otherwise false.

bool CustomPaste ( CPasteTarget pasteTarget,
IClipboardFormat::RestoredInfo restoredInfo,
OperationType  type 
) [virtual]

Performs a paste operation. The restoredInfo contains deserialized content which can be modified before being put to the grid.

Pastes data from the clipboard to the grid.

Parameters:
[in] pasteTarget target - related information (grid, position, etc...).
[in] restoredInfo Clipboard content to be pasted.
[in] type Indicates the way, how the items were inserted into the clipboard.
Returns:
True if the clipboard content has been pasted. Otherwise false.

Common::CDataObject * ImportObject ( const TString &  className  )  const [virtual]

Tries to create a new data object of the class specified in the className parameter.

Parameters:
[in] className Name of the class, an instance of which should be created. Usually the class can be registered with the macro DF_DECLARE_SERIALIZABLE_TYPE().
Returns:
An instance of the class that has been registered in Common::CTypeFactory. If the appropriate class can't be found, the function returns a new instance Common::CDynamicObject.

Implements IObjectImporter.

void GetImportedObjects ( ImportedObjects container  )  const [virtual]

Gets all imported objects.

Parameters:
[in,out] container Container where all imported objects are copied to.

void RemoveImportedObjects ( bool  bDestroy  )  [virtual]

Removes all imported objects from the local cache.

Parameters:
[in] bDestroy Indicates whether it should destroy data objects. If the flag is set, data objects will be physically destroyed and all the handles associated with will be automatically removed from all grids.

Implements IObjectImporter.

bool AutoDelete (  )  const [virtual]

IAutoDelete implementation. Returns the value, passed in the constructor.

Returns:
Value, passed in the constructor.

Implements IAutoDelete.