#include <clipmap.h>
Inheritance diagram for BodgeTextClipMap:
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 | |
BodgeTextClipMap () | |
BodgeTextClipMap (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 |
Notes: This mapping is used twice - once for CF_TEXT, and once as an alias for CF_OEMTEXT (which the clipboard will convert to CF_TEXT when we ask for it)
Definition at line 281 of file clipmap.h.
|
Definition at line 818 of file clipmap.cpp. 00819 { 00820 ERROR3("Please don't press that button again"); 00821 }
|
|
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 850 of file clipmap.cpp. 00851 : ClipboardMapping(TheType, NULL, InternalClipboardFormat(CLIPTYPE_TEXT), 00852 CF_TEXT, 50) 00853 { 00854 if (ClaimType != 0) 00855 ExternalDataType = ClaimType; 00856 }
|
|
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 883 of file clipmap.cpp. 00884 { 00885 BodgeTextClipMap *Mapping = new BodgeTextClipMap(TheType, ClaimType); 00886 if (Mapping == NULL) 00887 InformError(); 00888 else 00889 ExternalClipboard::RegisterDataType(Mapping); 00890 }
|
|
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 1082 of file clipmap.cpp. 01083 { 01084 const DWORD Increment = 1024 * sizeof(char); 01085 DWORD CurrentSize = 0; 01086 DWORD MaxSize = Increment; 01087 01088 #if (_OLE_VER >= 0x200) 01089 01090 // If necessary allocate the memory. 01091 BOOL fDidAlloc = FALSE; 01092 HANDLE hGlobalMem = m_hMem; 01093 if (hGlobalMem) 01094 { 01095 // We have some already. Set the size. 01096 MaxSize = m_cbMemSize; 01097 } 01098 else 01099 { 01100 // We don't have any, so try to allocate and remember that we did so. 01101 hGlobalMem = m_hMem = GlobalAlloc(GHND, MaxSize); 01102 if (!hGlobalMem) return 0; 01103 fDidAlloc = TRUE; 01104 } 01105 01106 #else 01107 01108 // Allocate a block of global memory to store the text 01109 HANDLE hGlobalMem = GlobalAlloc(GHND, MaxSize); 01110 01111 if (hGlobalMem == NULL) 01112 return(NULL); 01113 01114 #endif 01115 01116 // Get a UNICODE text buffer 01117 char* buff = (char*) GlobalLock(hGlobalMem); 01118 if (buff == NULL) 01119 { 01120 return(NULL); 01121 } 01122 01123 // Scan the entire document tree, and lob every TextChar we find into the export buffer 01124 // NOTE that the Global{Re}Alloc zeros memory, so we don't need to worry about 0-termination. 01125 Node *pSubtree = InternalClipboard::GetInsertionLayer(); 01126 Node *pNode = pSubtree->FindFirstDepthFirst(); 01127 while (pNode != NULL) 01128 { 01129 if (pNode->IsKindOf(CC_RUNTIME_CLASS(TextChar)) || pNode->IsKindOf(CC_RUNTIME_CLASS(EOLNode))) 01130 { 01131 if (pNode->IsKindOf(CC_RUNTIME_CLASS(TextChar))) 01132 { 01133 UINT32 ComposedChar = UnicodeManager::UnicodeToMultiByte(((TextChar *) pNode)->GetUnicodeValue()); 01134 BYTE LeadByte = 0; 01135 BYTE TrailByte = 0; 01136 UnicodeManager::DecomposeMultiBytes(ComposedChar, &LeadByte, &TrailByte); 01137 01138 if (LeadByte != 0) 01139 buff[CurrentSize++] = LeadByte; 01140 01141 buff[CurrentSize++] = TrailByte; 01142 } 01143 else 01144 { 01145 if (!((EOLNode*)pNode)->IsVirtual()) 01146 { 01147 buff[CurrentSize++] = (char) 0x0D; // CRLF - newline 01148 buff[CurrentSize++] = (char) 0x0A; 01149 } 01150 } 01151 01152 // Check if we've overrun the buffer - if so, we need to make the buffer bigger 01153 // (Allow 3 entries at the end (1 to guarantee we have a zero terminator, and 2 more 01154 // to allow room to fit the 2-char newline sequence in!) 01155 if ( (CurrentSize * sizeof(char)) >= MaxSize - 3) 01156 { 01157 #if (_OLE_VER >= 0x200) 01158 // If we didn't allocate the block then we can't resize it. 01159 if (!fDidAlloc) return 0; 01160 m_hMem = 0; 01161 #endif 01162 01163 GlobalUnlock(hGlobalMem); 01164 01165 MaxSize += Increment; 01166 HANDLE hNewMem = GlobalReAlloc(hGlobalMem, MaxSize, GHND); 01167 if (hNewMem == NULL) 01168 { 01169 GlobalFree(hGlobalMem); 01170 return(NULL); 01171 } 01172 01173 hGlobalMem = hNewMem; 01174 buff = (char *)GlobalLock(hGlobalMem); 01175 01176 if (buff == NULL) 01177 { 01178 GlobalFree(hGlobalMem); 01179 return(NULL); 01180 } 01181 01182 #if (_OLE_VER >= 0x200) 01183 // Remember this block. 01184 m_hMem = hNewMem; 01185 #endif 01186 } 01187 } 01188 pNode = pNode->FindNextDepthFirst(pSubtree); 01189 } 01190 01191 // We must unlock the block before giving it to the clipboard 01192 GlobalUnlock(hGlobalMem); 01193 01194 return(hGlobalMem); 01195 }
|
|
Calls the parent filter as appropriate to import the given data from the external clipboard.
Reimplemented from ClipboardMapping. Definition at line 909 of file clipmap.cpp. 00910 { 00911 char *buff=(char*)GlobalLock(ClipboardData); 00912 if (buff != NULL && buff[0] != 0) 00913 { 00914 // position arbitarily on clipboard - when pasted the clip contents are centered anyway 00915 TextStory* TheStory=TextStory::CreateFromChars(DocCoord(100,100), buff, NULL, 00916 InternalClipboard::Instance(), NULL, TRUE); 00917 00918 // Unlock the clipboard data, as we won't need it again 00919 GlobalUnlock(ClipboardData); 00920 00921 if (TheStory!=NULL) 00922 { 00923 // OK, attach the new story to the clipboard document 00924 TheStory->AttachNode(InternalClipboard::GetInsertionLayer(), LASTCHILD); 00925 TheStory->NormaliseAttributes(); 00926 00927 // And make it reformat itself properly 00928 TheStory->FormatAndChildren(NULL,FALSE,FALSE); 00929 return(TRUE); 00930 } 00931 00932 // We failed (no text story), so report and ensure the clipboard is 'clean' 00933 InformError(); 00934 InternalClipboard::Clear(); 00935 } 00936 00937 // We failed 00938 return(FALSE); 00939 }
|
|
Reimplemented from ClipboardMapping. |
|
Reimplemented from ClipboardMapping. |
|
Reimplemented from ClipboardMapping. |