#include <clipmap.h>
Inheritance diagram for DIBClipMap:
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 | |
DIBClipMap () | |
DIBClipMap (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 |
Definition at line 466 of file clipmap.h.
|
Definition at line 2249 of file clipmap.cpp. 02250 { 02251 ERROR3("Please don't press that button again"); 02252 }
|
|
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 2276 of file clipmap.cpp. 02277 : ClipboardMapping(TheType, NULL, InternalClipboardFormat(CLIPTYPE_BITMAP), 02278 CF_DIB, 80) 02279 { 02280 if (ClaimType != 0) 02281 ExternalDataType = ClaimType; 02282 }
|
|
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 2303 of file clipmap.cpp. 02304 { 02305 DIBClipMap *Mapping = new DIBClipMap(TheType, ClaimType); 02306 if (Mapping == NULL) 02307 InformError(); 02308 else 02309 ExternalClipboard::RegisterDataType(Mapping); 02310 }
|
|
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. Reimplemented from ClipboardMapping. Definition at line 2449 of file clipmap.cpp. 02450 { 02451 // Scan the entire document tree, looking for a bitmap to export 02452 KernelBitmap *KernelBmp = FindBitmapToExport(InternalClipboard::Instance()); 02453 if (KernelBmp == NULL) // Didn't find a bitmap 02454 return(NULL); 02455 02456 OILBitmap *pOilBitmap = KernelBmp->ActualBitmap; 02457 ERROR3IF(pOilBitmap == NULL, "Unattached kernel bitmap found!"); 02458 WinBitmap* pWBitmap = (WinBitmap*)pOilBitmap; 02459 LPBITMAPINFO Info = pWBitmap->BMInfo; 02460 LPBYTE Bytes = pWBitmap->BMBytes; 02461 02462 ERROR3IF(Info->bmiHeader.biSizeImage == 0, "Bitmap data size is zero - I'm about to screw up the export"); 02463 02464 // Neville 14/10/97 02465 // Don't just use the number of colours in the colour depth. If we have set biClrUsed to 02466 // something between 0 and max number of colours for that colour depth then that is 02467 // the size of the palette that is expected. We set biClrUsed when exporting an 02468 // optimised palette with a user specified number of colours. 02469 // If we don't make sure that this matches the the destination program will skew the 02470 // bitmap. 02471 UINT32 PalSize = DIBUtil::CalcPaletteSize(pWBitmap->GetBPP(), Info->bmiHeader.biCompression == BI_BITFIELDS, 02472 Info->bmiHeader.biClrUsed); 02473 DWORD HeaderSize = Info->bmiHeader.biSize + PalSize; 02474 DWORD BitmapSize = Info->bmiHeader.biSizeImage; 02475 02476 #if (_OLE_VER >= 0x200) 02477 02478 // Get the memory block's handle. 02479 BOOL fDidAlloc = FALSE; 02480 HANDLE hGlobalMem = m_hMem; 02481 if (!hGlobalMem) 02482 { 02483 // We don't have any memory, so try to allocate some and remember that we did so. 02484 fDidAlloc = TRUE; 02485 hGlobalMem = m_hMem = GlobalAlloc(GHND, HeaderSize + BitmapSize); 02486 if (hGlobalMem == NULL) 02487 { 02488 ERROR3("Couldn't get enough memory to export bitmap"); 02489 return(NULL); 02490 } 02491 } 02492 02493 #else 02494 02495 // Allocate a block of global memory to store the DIB 02496 HANDLE hGlobalMem = GlobalAlloc(GHND, HeaderSize + BitmapSize); 02497 02498 if (hGlobalMem == NULL) 02499 { 02500 ERROR3("Couldn't get enough memory to export bitmap"); 02501 return(NULL); 02502 } 02503 02504 #endif 02505 02506 char* buff = (char*) GlobalLock(hGlobalMem); 02507 if (buff == NULL) 02508 { 02509 ERROR3("Couldn't get clipboard memory"); 02510 #if (_OLE_VER >= 0x200) 02511 if (fDidAlloc) GlobalFree(hGlobalMem); 02512 #else 02513 GlobalFree(hGlobalMem); 02514 #endif 02515 return(NULL); 02516 } 02517 02518 // Copy the DIB onto the clipboard (copy the header and body separately as they 02519 // may not lie in contiguous memory) 02520 memcpy(buff, Info, HeaderSize); 02521 memcpy(buff + HeaderSize, Bytes, BitmapSize); 02522 02523 // We must unlock the block before giving it to the clipboard 02524 GlobalUnlock(hGlobalMem); 02525 return(hGlobalMem); 02526 }
|
|
Calls the parent filter as appropriate to import the given data from the external clipboard.
Reimplemented from ClipboardMapping. Definition at line 2336 of file clipmap.cpp. 02338 { 02339 LPBYTE Bits = NULL; 02340 LPBITMAPINFO BmpInfo = NULL; 02341 WinBitmap *WinBmp = NULL; 02342 KernelBitmap *KernelBmp = NULL; 02343 CCMemFile MemFile; 02344 02345 BITMAPINFO *buff = (BITMAPINFO *) GlobalLock(ClipboardData); 02346 if (buff != NULL) 02347 { 02348 String_64 ProgressMsg(_R(IDS_CLIPBOARD_IMPORTDIB)); 02349 MemFile.open(buff, GlobalSize(ClipboardData), CCMemRead); 02350 if (!DIBUtil::ReadFromFile(&MemFile, &BmpInfo, &Bits, FALSE, &ProgressMsg)) 02351 goto Abort; 02352 02353 MemFile.close(); 02354 GlobalUnlock(ClipboardData); 02355 02356 WinBmp = new WinBitmap(BmpInfo, Bits); 02357 if (WinBmp == NULL) 02358 goto Abort; 02359 02360 KernelBmp = new KernelBitmap(WinBmp); 02361 if (KernelBmp == NULL) 02362 goto Abort; 02363 02364 // And now, lob a bitmap node for it into the clipboard 02365 NodeBitmap *pNode = new NodeBitmap(); 02366 if (pNode == NULL || pNode->GetBitmapRef() == NULL || !(pNode->SetUpPath(12,12))) 02367 goto Abort; 02368 02369 // Attach this bitmap reference to the new bitmap, and put in the clipboard document 02370 pNode->GetBitmapRef()->Attach(KernelBmp, InternalClipboard::Instance()); 02371 if (pNode->GetBitmap() != KernelBmp) 02372 { 02373 // It didn't use the bitmap we gave it, so we can delete it 02374 delete KernelBmp; 02375 } 02376 02377 // And set up the node's bounds appropriately 02378 BitmapInfo Info; 02379 pNode->GetBitmap()->ActualBitmap->GetInfo(&Info); 02380 02381 DocRect BoundsRect; 02382 BoundsRect.lo.x = 0; 02383 BoundsRect.lo.y = 0; 02384 BoundsRect.hi.x = Info.RecommendedWidth/2; 02385 BoundsRect.hi.y = Info.RecommendedHeight/2; 02386 02387 pNode->CreateShape(BoundsRect); 02388 02389 // Apply the default bitmap attributes 02390 pNode->ApplyDefaultBitmapAttrs(NULL); 02391 02392 pNode->AttachNode(InternalClipboard::GetInsertionLayer(), LASTCHILD, FALSE); 02393 return(TRUE); 02394 } 02395 02396 return(FALSE); 02397 02398 Abort: 02399 // ERROR2RAW("Bitmap import failed, probably due to lack of memory"); 02400 // InformError(); 02401 02402 GlobalUnlock(ClipboardData); 02403 02404 if (MemFile.isOpen()) 02405 MemFile.close(); 02406 02407 if (KernelBmp != NULL) 02408 delete KernelBmp; 02409 02410 if (WinBmp != NULL) 02411 delete WinBmp; 02412 /* else if (BmpInfo != NULL || Bits != NULL) 02413 FreeDIB(BmpInfo, Bits); 02414 */ 02415 InternalClipboard::Clear(); // We failed, so ensure the doc is wiped 02416 InformError(); 02417 return(FALSE); 02418 }
|
|
Reimplemented from ClipboardMapping. |
|
Reimplemented from ClipboardMapping. |
|
Reimplemented from ClipboardMapping. |