// From IDataObject STDMETHODIMP ZDragClip_Win_DataObject::GetData(FORMATETC* iRequestedFORMATETC, STGMEDIUM* oSTGMEDIUM) { ZAssertStop(1, iRequestedFORMATETC && oSTGMEDIUM); if (iRequestedFORMATETC->tymed & TYMED_HGLOBAL) { bool isString; string theRequestedMIME; if (ZDragClipManager::sGet()->LookupCLIPFORMAT(iRequestedFORMATETC->cfFormat, theRequestedMIME, isString)) { ZTuple::const_iterator iter = fTuple.IteratorOf(theRequestedMIME); if (iter != fTuple.end()) { ZType propertyType = fTuple.TypeOf(iter); if (propertyType == eZType_Raw) { const void* theAddress; size_t theSize; fTuple.GetRawAttributes(iter, &theAddress, &theSize); HGLOBAL theHGLOBAL = ::GlobalAlloc(0, theSize); void* globalPtr = ::GlobalLock(theHGLOBAL); ZBlockCopy(theAddress, globalPtr, theSize); ::GlobalUnlock(theHGLOBAL); oSTGMEDIUM->tymed = TYMED_HGLOBAL; oSTGMEDIUM->hGlobal = theHGLOBAL; oSTGMEDIUM->pUnkForRelease = nil; return NOERROR; } else if (propertyType == eZType_String)// && iRequestedFORMATETC->cfFormat == CF_TEXT) { string theString = fTuple.GetString(iter); size_t theSize = theString.size(); HGLOBAL theHGLOBAL = ::GlobalAlloc(0, theSize + 1); void* globalPtr = ::GlobalLock(theHGLOBAL); if (theSize) ZBlockCopy(theString.data(), globalPtr, theSize); reinterpret_cast<char*>(globalPtr)[theSize] = 0; ::GlobalUnlock(theHGLOBAL); oSTGMEDIUM->tymed = TYMED_HGLOBAL; oSTGMEDIUM->hGlobal = theHGLOBAL; oSTGMEDIUM->pUnkForRelease = nil; return NOERROR; } } } } return E_FAIL; }
void StreamW_Chunk::Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten) { const uint8* localSource = reinterpret_cast<const uint8*>(iSource); while (iCount) { if (fBufferUsed == 255) this->Internal_Flush(); size_t countToCopy = min(iCount, size_t(255 - fBufferUsed)); ZBlockCopy(localSource, fBuffer + fBufferUsed, countToCopy); fBufferUsed += countToCopy; iCount -= countToCopy; localSource += countToCopy; } if (oCountWritten) *oCountWritten = localSource - reinterpret_cast<const uint8*>(iSource); }