#include <clipmap.h>
Inheritance diagram for BodgeUnicodeClipMap:
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 | |
BodgeUnicodeClipMap () | |
BodgeUnicodeClipMap (ClipboardMappingType TheType, UINT32 ClaimType=0) | |
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 328 of file clipmap.h.
|
Definition at line 1206 of file clipmap.cpp. 01207 { 01208 ERROR3("Please don't press that button again"); 01209 }
|
|
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 1238 of file clipmap.cpp. 01239 : ClipboardMapping(TheType, NULL, InternalClipboardFormat(CLIPTYPE_TEXT), 01240 CF_UNICODETEXT, 55) 01241 { 01242 if (ClaimType != 0) 01243 ExternalDataType = ClaimType; 01244 }
|
|
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 1271 of file clipmap.cpp. 01272 { 01273 BodgeUnicodeClipMap *Mapping = new BodgeUnicodeClipMap(TheType, ClaimType); 01274 if (Mapping == NULL) 01275 InformError(); 01276 else 01277 ExternalClipboard::RegisterDataType(Mapping); 01278 }
|
|
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 1470 of file clipmap.cpp. 01471 { 01472 const DWORD Increment = 1024 * sizeof(WCHAR); 01473 DWORD CurrentSize = 0; 01474 DWORD MaxSize = Increment; 01475 01476 #if (_OLE_VER >= 0x200) 01477 01478 // If necessary allocate the memory. 01479 BOOL fDidAlloc = FALSE; 01480 HANDLE hGlobalMem = m_hMem; 01481 if (hGlobalMem) 01482 { 01483 // We have some already. Set the size. 01484 MaxSize = m_cbMemSize; 01485 } 01486 else 01487 { 01488 // We don't have any, so try to allocate and remember that we did so. 01489 hGlobalMem = m_hMem = GlobalAlloc(GHND, MaxSize); 01490 if (!hGlobalMem) return 0; 01491 fDidAlloc = TRUE; 01492 } 01493 01494 #else 01495 01496 // Allocate a block of global memory to store the text 01497 HANDLE hGlobalMem = GlobalAlloc(GHND, MaxSize); 01498 01499 if (hGlobalMem == NULL) 01500 return(NULL); 01501 01502 #endif 01503 01504 // Get a UNICODE text buffer 01505 WCHAR *buff = (WCHAR *)GlobalLock(hGlobalMem); 01506 if (buff == NULL) 01507 { 01508 return(NULL); 01509 } 01510 01511 // Scan the entire document tree, and lob every TextChar we find into the export buffer 01512 // NOTE that the Global{Re}Alloc zeros memory, so we don't need to worry about 0-termination. 01513 Node *pSubtree = InternalClipboard::GetInsertionLayer(); 01514 Node *pNode = pSubtree->FindFirstDepthFirst(); 01515 while (pNode != NULL) 01516 { 01517 if (pNode->IsKindOf(CC_RUNTIME_CLASS(TextChar)) || pNode->IsKindOf(CC_RUNTIME_CLASS(EOLNode))) 01518 { 01519 if (pNode->IsKindOf(CC_RUNTIME_CLASS(TextChar))) 01520 { 01521 buff[CurrentSize] = ((TextChar *) pNode)->GetUnicodeValue(); 01522 CurrentSize++; 01523 } 01524 else 01525 { 01526 buff[CurrentSize++] = 0x000D; // CRLF - newline 01527 buff[CurrentSize++] = 0x000A; 01528 } 01529 01530 // Check if we've overrun the buffer - if so, we need to make the buffer bigger 01531 // (Allow 3 entries at the end (1 to guarantee we have a zero terminator, and 2 more 01532 // to allow room to fit the 2-char newline sequence in!) 01533 if ( (CurrentSize * sizeof(WCHAR)) >= MaxSize - 3) 01534 { 01535 #if (_OLE_VER >= 0x200) 01536 // If we didn't allocate the block then we can't resize it. 01537 if (!fDidAlloc) return 0; 01538 m_hMem = 0; 01539 #endif 01540 01541 GlobalUnlock(hGlobalMem); 01542 01543 MaxSize += Increment; 01544 HANDLE hNewMem = GlobalReAlloc(hGlobalMem, MaxSize, GHND); 01545 if (hNewMem == NULL) 01546 { 01547 GlobalFree(hGlobalMem); 01548 return(NULL); 01549 } 01550 01551 hGlobalMem = hNewMem; 01552 buff = (WCHAR *)GlobalLock(hGlobalMem); 01553 01554 if (buff == NULL) 01555 { 01556 GlobalFree(hGlobalMem); 01557 return(NULL); 01558 } 01559 01560 #if (_OLE_VER >= 0x200) 01561 // Remember this block. 01562 m_hMem = hNewMem; 01563 #endif 01564 } 01565 } 01566 pNode = pNode->FindNextDepthFirst(pSubtree); 01567 } 01568 01569 // We must unlock the block before giving it to the clipboard 01570 GlobalUnlock(hGlobalMem); 01571 01572 return(hGlobalMem); 01573 }
|
|
Calls the parent filter as appropriate to import the given data from the external clipboard.
Reimplemented from ClipboardMapping. Definition at line 1297 of file clipmap.cpp. 01298 { 01299 WCHAR *buff=(WCHAR*)GlobalLock(ClipboardData); 01300 if (buff != NULL && buff[0] != 0) 01301 { 01302 // position arbitarily on clipboard - when pasted the clip contents are centered anyway 01303 TextStory* TheStory=TextStory::CreateFromChars(DocCoord(100,100), NULL, buff, 01304 InternalClipboard::Instance(), NULL, TRUE); 01305 01306 // Unlock the clipboard data, as we won't need it again 01307 GlobalUnlock(ClipboardData); 01308 01309 if (TheStory!=NULL) 01310 { 01311 // OK, attach the new story to the clipboard document 01312 TheStory->AttachNode(InternalClipboard::GetInsertionLayer(), LASTCHILD); 01313 TheStory->NormaliseAttributes(); 01314 01315 // And make it reformat itself properly 01316 TheStory->FormatAndChildren(NULL,FALSE,FALSE); 01317 return(TRUE); 01318 } 01319 01320 // We failed (no text story), so report and ensure the clipboard is 'clean' 01321 InformError(); 01322 InternalClipboard::Clear(); 01323 } 01324 01325 // We failed 01326 return(FALSE); 01327 }
|
|
Reimplemented from ClipboardMapping. |
|
Reimplemented from ClipboardMapping. |
|
Reimplemented from ClipboardMapping. |