BitmapClipMap Class Reference

Describes and handles import/export mappings for bitmaps. More...

#include <clipmap.h>

Inheritance diagram for BitmapClipMap:

ClipboardMapping ListItem CCObject SimpleCCObject List of all members.

Static Public Member Functions

static void CreateAndRegister (ClipboardMappingType TheType, UINT32 ClaimType=0)
 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

 BitmapClipMap ()
 BitmapClipMap (ClipboardMappingType TheType, UINT32 ClaimType)
 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.

Friends

class ExternalClipboard
class OpClipboardExport
class OpClipboardImport

Detailed Description

Describes and handles import/export mappings for bitmaps.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/95
This mapping does not attach to a filter - it simply scans the tree for bitmap objects, and exports the DIB data, or imports DIB data and creates a new bitmap object in the document. (i.e. the data is not converted, just inserted/extracted from the document tree)

Notes: Due to the unbelieveable crapness of windows, it seems to be impossible to export a bitmap with a decent palette. So we do like Corel and don't export in bitmap format - DIBs are the way of the future anyway.

See also:
ClipboardMapping; ExternalClipboard; Filter

Definition at line 380 of file clipmap.h.


Constructor & Destructor Documentation

BitmapClipMap::BitmapClipMap  )  [protected]
 

Definition at line 1575 of file clipmap.cpp.

01576 {
01577     ERROR3("Please don't press that button again");
01578 }

BitmapClipMap::BitmapClipMap ClipboardMappingType  TheType,
UINT32  ClaimType
[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.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/95
Parameters:
TheType - indicates import / export / import & export [INPUTS]
ClaimType - CF_DIB for straight import, CF_BITMAP for an alias

Notes: DON'T call the constructor - call CreateAndRegister

See also:
BitmapClipMap::CreateAndRegister

Definition at line 1602 of file clipmap.cpp.

01603                 : ClipboardMapping(TheType, NULL, InternalClipboardFormat(CLIPTYPE_BITMAP),
01604                                     CF_BITMAP, 75)
01605 {
01606     if (ClaimType != 0)
01607         ExternalDataType = ClaimType;
01608 }


Member Function Documentation

void BitmapClipMap::CreateAndRegister ClipboardMappingType  TheType,
UINT32  ClaimType = 0
[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.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/95
Parameters:
TheType - indicates import / export / import & export [INPUTS]
ClaimType - CF_DIB for straight import, CF_BITMAP for an alias

Definition at line 1629 of file clipmap.cpp.

01630 {
01631     BitmapClipMap *Mapping = new BitmapClipMap(TheType, ClaimType);
01632     if (Mapping == NULL)
01633         InformError();
01634     else
01635         ExternalClipboard::RegisterDataType(Mapping);
01636 }

HANDLE BitmapClipMap::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.

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.
This bodge mapping for text scans the docuemnt tree for text chars and strips them out by hand. Styles and suchlike are lost. It's a bodge.

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.

Note that when a bitmap is available on the clipabord, a palette will also be available - see the SeeAlso

See also:
PaletteClipMap::HandleExport; DIBClipMap::HandleExport

Reimplemented from ClipboardMapping.

Definition at line 2029 of file clipmap.cpp.

02030 {
02031     ERROR3("Bitmap export is unsupported on the grounds that it won't work thanks to Windows");
02032     return(NULL);
02033 
02034 /*
02035     // Scan the entire document tree, looking for a bitmap to export
02036     KernelBitmap *KernelBmp = FindBitmapToExport(Source);
02037     if (KernelBmp == NULL)      // Didn't find a bitmap
02038         return(NULL);
02039 
02040     OILBitmap *pOilBitmap = KernelBmp->ActualBitmap;
02041     ERROR3IF(pOilBitmap == NULL, "Unattached kernel bitmap found!");
02042     WinBitmap* pWBitmap = (WinBitmap*)pOilBitmap;
02043     LPBITMAPINFO Info = pWBitmap->BMInfo;
02044     LPBYTE Bytes = pWBitmap->BMBytes;
02045     
02046     // Convert the DIB into GDI BITMAP format
02047     HDC hDCScreen = GetDC(NULL);
02048     HBITMAP hBitmap = NULL;
02049     if (hDCScreen != NULL)
02050     {
02051 //      HGDIOBJ OldPal = ::SelectObject(hDCScreen, CMainFrame::MainPalette.GetSafeHandle());
02052 //      RealizePalette(hDCScreen);
02053 
02054         HPALETTE hPal = CreateBMPPalette(&Info->bmiHeader);
02055         HPALETTE hOldPal = NULL;
02056         
02057 #if _DEBUG
02058         if (IsUserName("Jason"))
02059             ERROR3IF(hPal == NULL, "Couldn't create a palette for that image");
02060 #endif
02061 
02062         if (hPal != NULL)
02063         {
02064             hOldPal = SelectPalette(hDCScreen, hPal, FALSE);
02065             RealizePalette(hDCScreen);
02066         }
02067 
02068         hBitmap = CreateDIBitmap(hDCScreen, &Info->bmiHeader, CBM_INIT, Bytes, Info, DIB_RGB_COLORS);
02069         SetClipboardData(CF_PALETTE, hPal);
02070 
02071 //      if (OldPal != NULL)
02072 //          ::SelectObject(hDCScreen, OldPal);
02073         
02074 
02075         if (hPal != NULL)
02076         {
02077             SelectPalette(hDCScreen, hOldPal, FALSE);
02078             RealizePalette(hDCScreen);
02079         }
02080 
02081         ReleaseDC(NULL, hDCScreen);
02082     }
02083 
02084     // And return the bitmap handle, which is put on the clipboard for the CF_BITMAP data
02085     return((HANDLE) hBitmap);
02086  */
02087 /*
02088     // Scan the entire document tree, looking for a bitmap to export
02089     KernelBitmap *KernelBmp = FindBitmapToExport(Source);
02090     if (KernelBmp == NULL)      // Didn't find a bitmap
02091         return(NULL);
02092 
02093     OILBitmap *pOilBitmap = KernelBmp->ActualBitmap;
02094     ERROR3IF(pOilBitmap == NULL, "Unattached kernel bitmap found!");
02095     WinBitmap* pWBitmap = (WinBitmap*)pOilBitmap;
02096     LPBITMAPINFO Info = pWBitmap->BMInfo;
02097     LPBYTE Bytes = pWBitmap->BMBytes;
02098     
02099     // Convert the DIB into GDI BITMAP format
02100 //  HDC hDCScreen = GetDC(NULL);
02101     HBITMAP hBitmap = NULL;
02102 //  if (hDCScreen != NULL)
02103     {
02104 //      hBitmap = CreateDIBitmap(hDCScreen, &Info->bmiHeader, CBM_INIT, Bytes, Info, DIB_RGB_COLORS);
02105         hBitmap = CreateBitmap(Info->bmiHeader.biWidth, Info->bmiHeader.biHeight,
02106                                 1, Info->bmiHeader.biBitCount, NULL);//Bytes);
02107 
02108         // Copy the DIB bits into the bitmap
02109         SetDIBits(NULL, hBitmap, 0, Info->bmiHeader.biHeight, Bytes, Info, NULL);//DIB_RGB_COLORS);
02110 
02111         HPALETTE hPal = CreateBMPPalette(&Info->bmiHeader);
02112         SetClipboardData(CF_PALETTE, hPal);
02113 
02114 //      ReleaseDC(NULL, hDCScreen);
02115     }
02116 
02117     // And return the bitmap handle, which is put on the clipboard for the CF_BITMAP data
02118     return((HANDLE) hBitmap);
02119 */
02120 }

BOOL BitmapClipMap::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
This bodge mapping for text scans the docuemnt tree for text chars and strips them out by hand. Styles and suchlike are lost. It's a bodge.

See also:
DIBClipMap::HandleImport

Reimplemented from ClipboardMapping.

Definition at line 1793 of file clipmap.cpp.

01795 {
01796     LPBYTE Bits = NULL;
01797     LPBITMAPINFO BmpInfo = NULL;
01798     WinBitmap *WinBmp = NULL;
01799     KernelBitmap *KernelBmp = NULL;
01800 //  NodeBitmap *pNode = NULL;
01801 
01802     // Try to retrieve the palette from the clipboard - if there is not one there,
01803     // we'll get a NULL, which ConvertBMPToDIB is quite happy with.
01804     HPALETTE hPalette = (HPALETTE) GetClipboardData(CF_PALETTE);
01805     if (!ConvertBMPToDIB((HBITMAP)ClipboardData, hPalette, /* TO */ &BmpInfo, &Bits))
01806         goto Abort;
01807 
01808     WinBmp = new WinBitmap(BmpInfo, Bits);
01809     if (WinBmp == NULL)
01810         goto Abort;
01811 
01812     KernelBmp = new KernelBitmap(WinBmp);
01813     if (KernelBmp == NULL)
01814         goto Abort;
01815 
01816 #if FALSE
01817 /*
01818     // And now, lob a bitmap node for it into the clipboard
01819     pNode = new NodeBitmap();
01820     if (pNode == NULL || pNode->GetBitmapRef() == NULL || !(pNode->SetUpPath(12,12)))
01821         goto Abort;
01822 
01823     // Attach this bitmap reference to the new bitmap, and put in the clipboard document
01824     pNode->GetBitmapRef()->Attach(KernelBmp, Dest);
01825 
01826     // And set up the node's bounds appropriately
01827     BitmapInfo Info;
01828     pNode->GetBitmap()->ActualBitmap->GetInfo(&Info);
01829 
01830     {
01831         DocRect BoundsRect;
01832         BoundsRect.lo.x = 0;
01833         BoundsRect.lo.y = 0;
01834         BoundsRect.hi.x = Info.RecommendedWidth/2;
01835         BoundsRect.hi.y = Info.RecommendedHeight/2;
01836 
01837         pNode->CreateShape(BoundsRect);
01838     }
01839 
01840     pNode->AttachNode(Dest->GetInsertionLayer(), LASTCHILD, FALSE);
01841 */
01842 #else
01843     {
01844         // Compile information on where to put the imported NodeBitmap
01845         PageDropInfo DropInfo;
01846 
01847         DropInfo.pDoc       = InternalClipboard::Instance();
01848         DropInfo.pDocView   = DocView::GetCurrent();
01849         DropInfo.pSpread    = InternalClipboard::Instance()->FindFirstSpread(); //GetInsertionLayer()->FindParent();
01850         DropInfo.DropPos    = DocCoord(100,100);        // Position is unimportant as it is centered when pasted
01851         DropInfo.TargetHit  = NO_TARGET;
01852         DropInfo.pObjectHit = NULL;
01853 
01854         // Invoke an Op to create a NodeBitmap for us
01855         OpDescriptor* OpCreateNodeBmp = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpCreateNodeBitmap));
01856         OpCreateNodeBmp->Invoke(&OpParam((INT32)KernelBmp,(INT32)&DropInfo));
01857     }
01858 #endif
01859 
01860     return(TRUE);
01861 
01862 Abort:
01863 //  ERROR2RAW("Bitmap import failed, probably due to lack of memory");
01864     InformError();
01865 
01866     if (KernelBmp != NULL)
01867         delete KernelBmp;
01868 
01869     if (WinBmp != NULL)
01870         delete WinBmp;
01871     else if (BmpInfo != NULL || Bits != NULL)
01872         FreeDIB(BmpInfo, Bits);
01873 
01874     InternalClipboard::Clear(); // We failed, so ensure the doc is wiped
01875 
01876     return(FALSE);
01877 }


Friends And Related Function Documentation

friend class ExternalClipboard [friend]
 

Reimplemented from ClipboardMapping.

Definition at line 384 of file clipmap.h.

friend class OpClipboardExport [friend]
 

Reimplemented from ClipboardMapping.

Definition at line 385 of file clipmap.h.

friend class OpClipboardImport [friend]
 

Reimplemented from ClipboardMapping.

Definition at line 386 of file clipmap.h.


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