CMXClipMap Class Reference

Describes and handles import mapping for some "QuarkXPress Picture Data"Describes and handles import/export mappings for CMX files. More...

#include <clipmap.h>

Inheritance diagram for CMXClipMap:

ClipboardMapping ListItem CCObject SimpleCCObject CMX16ClipMap CMX32ClipMap List of all members.

Protected Member Functions

 CMXClipMap ()
 CMXClipMap (ClipboardMappingType TheType, UINT32 ClaimType, UINT32 nPriority)
 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.
virtual CMXFilterCreateExportFilter (void)=0

Friends

class ExternalClipboard
class OpClipboardExport
class OpClipboardImport

Detailed Description

Describes and handles import mapping for some "QuarkXPress Picture Data"Describes and handles import/export mappings for CMX files.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/09/96
Notes: This is the base class for 16 and 32 bit varients of CMX files

See also:
ClipboardMapping; ExternalClipboard; Filter

Definition at line 585 of file clipmap.h.


Constructor & Destructor Documentation

CMXClipMap::CMXClipMap  )  [inline, protected]
 

Definition at line 594 of file clipmap.h.

00594 {};

CMXClipMap::CMXClipMap ClipboardMappingType  TheType,
UINT32  ClaimType,
UINT32  nPriority
[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 - indicates import / export / import & export [INPUTS]
ClaimType - specifies the text type that this mapping will claim from the windows clipboard - that is, create 3 of these mappings, specifying CF_TEXT, CF_UNICODETEXT, and CF_OEMTEXT, and they will all ask the clipboard for UNICODE text when they actually go to import. This allows us to detect the 3 implicitly-converted clipboard formats, and map them all to UNICODE, i.e. use the UNICODE mapping for all 3 available formats. If ClaimType == 0, UNICODE is assumed

Notes: DON'T call the constructor - call CreateAndRegister

See also:
BodgeTextClipMap::CreateAndRegister

Definition at line 2875 of file clipmap.cpp.

02876                 : ClipboardMapping(TheType, NULL, InternalClipboardFormat(CLIPTYPE_VECTOR),
02877                     ClaimType, nPriority)
02878 {
02879     if (ClaimType != 0)
02880         ExternalDataType = ClaimType;
02881 }


Member Function Documentation

virtual CMXFilter* CMXClipMap::CreateExportFilter void   )  [protected, pure virtual]
 

Implemented in CMX16ClipMap, and CMX32ClipMap.

HANDLE CMXClipMap::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:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/09/96
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 3083 of file clipmap.cpp.

03084 {
03085     char *tempname = GetTempFileName(); //_ttempnam("C:\temp", "XS");
03086     if (tempname == NULL)
03087     {
03088         ERROR3("Couldn't get a temp filename");
03089         return(FALSE);
03090     }
03091 
03092 
03093     // make a new disk file of this name
03094     CCDiskFile File;
03095     PathName pathname(tempname);
03096     if(!File.open(pathname, (ios::in | ios::out | ios::binary)))
03097         return 0;       // error!
03098     
03099     // get a filter to export the thingy to
03100     CMXFilter* pFilter = CreateExportFilter();
03101     BOOL ok = (pFilter != NULL);
03102 
03103     if(ok)
03104     {
03105         // tell the filter not to do non clipboardy thing
03106         pFilter->SetIsDoingClipboardExport(TRUE);
03107 
03109         //
03110         // JustinF says: this is a ultra-late bodge so that we can render OLE presentation
03111         // data in CMX format.  The only app that requires this is CorelDRAW.  We are
03112         // tricking the CMX exporter to work with any kernel Document rather than only
03113         // the internal clipboard document.
03114         //
03115 
03116 // WEBSTER - markn 12/2/97
03117 #if (_OLE_VER >= 0x200)
03118         ok = pFilter->DoExport(Caller, &File, &pathname, m_pDoc, TRUE);
03119 #else
03120         // export to the file
03121         ok = pFilter->DoExport(Caller, &File, &pathname, InternalClipboard::Instance());
03122 #endif
03123 
03124         // reset clipboardy flag
03125         pFilter->SetIsDoingClipboardExport(FALSE);
03126     }
03127 
03128     delete pFilter;
03129 
03130     void* pMem;
03131     INT32 FileSize;
03132     HANDLE hGlobalMem;
03133 
03134     if (ok)
03135     {
03136         // find out how big the file is
03137         FileSize = File.Size();
03138 
03139     #if (_OLE_VER >= 0x200)
03140     
03141         // Is memory already allocated?
03142         if ((hGlobalMem = m_hMem) != 0)
03143         {
03144             // Is the file too big?
03145             if (UINT32(FileSize) > m_cbMemSize) return 0;
03146         }
03147         else
03148         {
03149             // No.  Allocate some.
03150             hGlobalMem = m_hMem = GlobalAlloc(GHND, FileSize);
03151         }
03152 
03153     #else
03154         
03155         // copy the file into the global block
03156         pMem = GlobalLock(hGlobalMem);
03157     
03158     #endif
03159 
03160         // Lock the block.
03161         pMem = GlobalLock(hGlobalMem);
03162         ok = (pMem != 0);
03163     }
03164 
03165     
03166     if (ok)
03167     {
03168         // seek to beginning of file
03169         File.seekIn(0);
03170 
03171         // load data..
03172         File.read(pMem, FileSize);
03173     }
03174 
03175     // close the file
03176     if(File.isOpen())
03177         File.close();
03178 
03179     // get rid of the temp file
03180     RemoveTempFile();
03181 
03182     // We must unlock the block before giving it to the clipboard
03183     GlobalUnlock(hGlobalMem);
03184 
03185     return hGlobalMem;
03186 }

BOOL CMXClipMap::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
Notes: This base-class default treats the clipboard data as a file, and makes the associated filter import it directly. (Note: It is currently implemented by slaving a temp file to disc, in order to avoid CCMemFiles which are not currently good enough for us to use)

Reimplemented from ClipboardMapping.

Definition at line 2946 of file clipmap.cpp.

02947 {
02948     BOOL ok = FALSE;
02949 
02950     // Get a scratch file - if TMP isn't set, this will try for c:\temp.
02951     // The filename will have XS as a prefix
02952     char *tempname = GetTempFileName();
02953     if (tempname == NULL)
02954     {
02955         ERROR3("Couldn't get a temp filename");
02956         return(FALSE);
02957     }
02958 
02959     void *pMem = GlobalLock(ClipboardData);
02960     ok = (pMem != NULL);
02961 
02962     BOOL Layers = Filter::ImportWithLayers;
02963     Filter::ImportWithLayers = FALSE;
02964     pFilter = new CMXImportFilter;
02965     ok = (pFilter != NULL);
02966 
02967     CCDiskFile File;
02968     if(ok)
02969     {
02970         // get a file and write to it
02971         PathName pathname(tempname);
02972         if(!File.open(pathname, (ios::out | ios::binary)))
02973             ok = FALSE;     // error!
02974     }
02975 
02976     if(ok)
02977     {
02978         File.write(pMem, GlobalSize(ClipboardData));
02979 
02980         File.close();
02981     }
02982 
02983     GlobalUnlock(ClipboardData);
02984 
02985     if(ok)
02986     {
02987         ok = ImportFromTempFile(tempname, Caller, InternalClipboard::Instance());
02988     }
02989 
02990     RemoveTempFile();
02991 
02992     if(pFilter != NULL)
02993     {
02994         delete pFilter;
02995         pFilter = NULL;
02996     }
02997 
02998     Filter::ImportWithLayers = Layers;
02999 
03000     return(ok);
03001 
03002 
03003 /*  char *buff=(char*)GlobalLock(ClipboardData);
03004     if (buff != NULL && buff[0] != 0)
03005     {
03006         // get a filter to play with
03007         CMXImportFilter *pFilter = new CMXImportFilter;
03008         BOOL ok = (pFilter != NULL);
03009 
03010         // Provide a current view for the filter to chomp on; We stack the current
03011         // view so that we do not corrupt it.
03012         View *OldCurrentView = View::GetCurrent();
03013         ClipboardView ImportView;
03014         if(!ImportView.Init())
03015         {
03016             ok = FALSE;
03017         }
03018         else
03019         {
03020             ImportView.SetCurrent();
03021         }
03022 
03023         // position arbitarily on clipboard - when pasted the clip contents are centered anyway
03024         if(ok)
03025         {
03026             // make a memfile based on this thingy
03027             CCMemFile File(buff, GlobalSize(ClipboardData), CCMemRead, TRUE, TRUE);
03028 
03029             // run it through the filter
03030             ok = pFilter->DoImport(Caller, &File, Dest);
03031 
03032             if(File.isOpen())
03033                 File.close();
03034 
03035             if (OldCurrentView != NULL)
03036                 OldCurrentView->SetCurrent();
03037         }
03038 
03039         // Unlock the clipboard data, as we won't need it again
03040         GlobalUnlock(ClipboardData);
03041 
03042         if(ok)
03043             return TRUE;
03044 
03045         // We failed (no text story), so report and ensure the clipboard is 'clean'
03046         InformError();
03047         Dest->ClearClipboard();
03048     }
03049 
03050     // We failed
03051     return FALSE;*/
03052 }


Friends And Related Function Documentation

friend class ExternalClipboard [friend]
 

Reimplemented from ClipboardMapping.

Reimplemented in CMX16ClipMap, and CMX32ClipMap.

Definition at line 589 of file clipmap.h.

friend class OpClipboardExport [friend]
 

Reimplemented from ClipboardMapping.

Reimplemented in CMX16ClipMap, and CMX32ClipMap.

Definition at line 590 of file clipmap.h.

friend class OpClipboardImport [friend]
 

Reimplemented from ClipboardMapping.

Reimplemented in CMX16ClipMap, and CMX32ClipMap.

Definition at line 591 of file clipmap.h.


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