MetaFileClipMap Class Reference

A class which describes and implements an available mapping between internal and external data formats. More...

#include <metafilt.h>

Inheritance diagram for MetaFileClipMap:

ClipboardMapping ListItem CCObject SimpleCCObject List of all members.

Static Public Member Functions

static void CreateAndRegister (ClipboardMappingType TheType, Filter *TheFilter, InternalClipboardFormat &InternalDataType, UINT32 ExternalDataType, UINT32 Priority)
 Constructs and registers a clipboard mapping with the ExternalClipboard manager. This mapping info describes a filter which is able to import data from or export data to a windows clipboard in some way.

Protected Member Functions

 MetaFileClipMap ()
 MetaFileClipMap (ClipboardMappingType TheType, Filter *TheFilter, InternalClipboardFormat &InternalDataType, UINT32 ExternalDataType, UINT32 Priority)
 Constructs a clipboard mapping with the ExternalClipboard manager. This mapping info describes a filter which is able to import data from or export data to a windows clipboard in some way.
virtual BOOL HandleImport (SelOperation *Caller, HANDLE ClipboardData, InternalClipboard *Dest)
 Calls the parent filter as appropriate to import the given data from the external clipboard.
virtual HANDLE HandleExport (Operation *Caller, InternalClipboard *Source)
 Invokes this mapping for exporting This takes the document tree of Source, and exports it to the external (windows) clipboard. Usually this just involves calling Filter::DoExport for the parent filter, and then returning the handle to the global memory block to be placed onto the external clipboard.

Friends

class ExternalClipboard
class OpClipboardExport
class OpClipboardImport

Detailed Description

A class which describes and implements an available mapping between internal and external data formats.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/4/95
This class implements clipboard import/export functionality for Windows MetaFiles, using the MetaFile Filter.

See also:
ExternalClipboard; Filter; MetaFileFilter

Definition at line 162 of file metafilt.h.


Constructor & Destructor Documentation

MetaFileClipMap::MetaFileClipMap  )  [inline, protected]
 

Definition at line 171 of file metafilt.h.

00171 {}

MetaFileClipMap::MetaFileClipMap ClipboardMappingType  TheType,
Filter TheFilter,
InternalClipboardFormat TheInternalDataType,
UINT32  TheExternalDataType,
UINT32  ThePriority
[protected]
 

Constructs a clipboard mapping with the ExternalClipboard manager. This mapping info describes a filter which is able to import data from or export data to a windows clipboard in some way.

Parameters:
TheType - 1 (import), 2 (export), or 3 (import and export) [INPUTS]
TheFilter - The filter which can apply this conversion

TheInternalDatatType - An object defining the internal data type (see cliptype.h)

TheExternalDataType - A Windows CF_ constant defining the external clipboard data type which will be imported/exported.

ThePriority - An integer indicating the priority of this mapping. The highest available priority mapping will be used in order to retain as much information in the data as possible. See docs.doc for details of the existing mappings.

Notes: DON'T call the constructor - call CreateAndRegister

See also:
MetaFileClipMap::CreateAndRegister

Definition at line 773 of file metafilt.cpp.

00777                 : ClipboardMapping(TheType, TheFilter, TheInternalDataType,
00778                                     TheExternalDataType, ThePriority)
00779 {
00780 }


Member Function Documentation

void MetaFileClipMap::CreateAndRegister ClipboardMappingType  TheType,
Filter TheFilter,
InternalClipboardFormat TheInternalDataType,
UINT32  TheExternalDataType,
UINT32  ThePriority
[static]
 

Constructs and registers a clipboard mapping with the ExternalClipboard manager. This mapping info describes a filter which is able to import data from or export data to a windows clipboard in some way.

Parameters:
ImportOrExport - TRUE == Import, FALSE == Export [INPUTS]
TheFilter - The filter which can apply this conversion

TheInternalDatatType - An object defining the internal data type (see cliptype.h)

TheExternalDataType - A Windows CF_ constant defining the external clipboard data type which will be imported/exported.

ThePriority - An integer indicating the priority of this mapping. The highest available priority mapping will be used in order to retain as much information in the data as possible. See docs.doc for details of the existing mappings.

Reimplemented from ClipboardMapping.

Definition at line 813 of file metafilt.cpp.

00817 {
00818     MetaFileClipMap *Mapping = new MetaFileClipMap(TheType, TheFilter,
00819                                                     TheInternalDataType,
00820                                                     TheExternalDataType,
00821                                                     ThePriority);
00822     if (Mapping == NULL)
00823         InformError();
00824     else
00825         ExternalClipboard::RegisterDataType(Mapping);
00826 }

HANDLE MetaFileClipMap::HandleExport Operation Caller,
InternalClipboard Source
[protected, virtual]
 

Invokes this mapping for exporting This takes the document tree of Source, and exports it to the external (windows) clipboard. Usually this just involves calling Filter::DoExport for the parent filter, and then returning the handle to the global memory block to be placed onto the external clipboard.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/4/95
Parameters:
Caller - the operation within which this method is being called [INPUTS] Source - the internal clipboard (document) to be exported
Returns:
NULL (if it failed), or a windows handle of the data to be placed on the clipboard.
Notes: The returned handle should be the thing you'd pass to SetClipboardData if you were dealing with it directly. You must adhere to all the Windows rules for this - i.e. a global data block, unlocked, etc etc.

Reimplemented from ClipboardMapping.

Definition at line 914 of file metafilt.cpp.

00915 {
00916 #if (_OLE_VER >= 0x200)
00917     
00918     // Check if we need to allocate some memory.
00919     HANDLE hGlobalMem;
00920     if ((hGlobalMem = m_hMem) != 0)
00921     {
00922         // We have some already.  Is it big enough?
00923         if (m_cbMemSize < sizeof(METAFILEPICT)) return 0;
00924     }
00925     else
00926     {
00927         // We must allocate some.
00928         hGlobalMem = m_hMem = GlobalAlloc(GHND, sizeof(METAFILEPICT));
00929         if (!hGlobalMem) return 0;
00930     }
00931 
00932 #else
00933 
00934     HANDLE hGlobalMem = GlobalAlloc(GHND, sizeof(METAFILEPICT));
00935     if (!hGlobalMem) return 0;
00936 
00937 #endif
00938 
00939     METAFILEPICT* Info = (METAFILEPICT*) GlobalLock(hGlobalMem);
00940 
00941     // Initialise to suitable defaults, just in case
00942     Info->mm    = MM_ANISOTROPIC;
00943     Info->xExt  = 0;
00944     Info->yExt  = 0;
00945     Info->hMF   = NULL; 
00946 
00947     // --- Now, export the source clipboard to a memory metafile
00948     // Create a dummy MemFile to keep the exporter happy
00949     char *temp[1024];
00950     CCMemFile DummyFile(temp, 1000);
00951 
00952     ((MetaFileFilter *)pFilter)->DoExport(Caller, &DummyFile, (Document *)Source, Info);
00953 
00954     if (DummyFile.isOpen()) DummyFile.close();
00955 
00956     // -- Finally, lob the metafile on the clipboard (we can forget about it now, as
00957     // it is now owned (and will be deleted) by the OS)
00958     // We must unlock the block before giving it to the clipboard
00959     GlobalUnlock(hGlobalMem);
00960     return(hGlobalMem);
00961 }

BOOL MetaFileClipMap::HandleImport SelOperation Caller,
HANDLE  ClipboardData,
InternalClipboard Dest
[protected, virtual]
 

Calls the parent filter as appropriate to import the given data from the external clipboard.

Parameters:
Caller - The operation within which this method is being called [INPUTS] ClipboardData - The result of calling GetClipboardData for your datatype Dest - The InternalClipboard (document) to import the data into.
Returns:
TRUE for success

Reimplemented from ClipboardMapping.

Definition at line 848 of file metafilt.cpp.

00850 {
00851     BOOL ok = FALSE;
00852 
00853     // Get a scratch file - if TMP isn't set, this will try for c:\temp.
00854     // The filename will have XS as a prefix
00855     char *tempname = GetTempFileName(); //_ttempnam("C:\temp", "XS");
00856     if (tempname == NULL)
00857     {
00858         ERROR3("Couldn't get a temp filename");
00859         return(FALSE);
00860     }
00861 
00862     // ---
00863     // Get the header data out of the clipboard, and copy the referenced metafile to disc
00864     METAFILEPICT *Info = (METAFILEPICT *) GlobalLock(ClipboardData);
00865 
00866     if (Info == NULL)
00867     {
00868         RemoveTempFile();
00869         return(FALSE);
00870     }
00871 
00872     HMETAFILE hCopy = CopyMetaFile(Info->hMF, tempname);
00873 
00874     GlobalUnlock(ClipboardData);
00875 
00876     if (hCopy != NULL)
00877     {
00878         ok = ImportFromTempFile(tempname, Caller, Dest);
00879         DeleteMetaFile(hCopy);
00880     }
00881 
00882     RemoveTempFile();
00883 
00884     return(ok);
00885 }


Friends And Related Function Documentation

friend class ExternalClipboard [friend]
 

Reimplemented from ClipboardMapping.

Definition at line 166 of file metafilt.h.

friend class OpClipboardExport [friend]
 

Reimplemented from ClipboardMapping.

Definition at line 167 of file metafilt.h.

friend class OpClipboardImport [friend]
 

Reimplemented from ClipboardMapping.

Definition at line 168 of file metafilt.h.


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