#include <clipmap.h>
Inheritance diagram for BitmapClipMap:
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 |
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.
Definition at line 380 of file clipmap.h.
|
Definition at line 1575 of file clipmap.cpp. 01576 { 01577 ERROR3("Please don't press that button again"); 01578 }
|
|
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.
Notes: DON'T call the constructor - call 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 }
|
|
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.
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 }
|
|
Invokes this mapping for exporting This takes the document tree of Source, and exports it to the external (windows) 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. Note that when a bitmap is available on the clipabord, a palette will also be available - see the SeeAlso
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 }
|
|
Calls the parent filter as appropriate to import the given data from the external clipboard.
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 }
|
|
Reimplemented from ClipboardMapping. |
|
Reimplemented from ClipboardMapping. |
|
Reimplemented from ClipboardMapping. |