Esempio n. 1
0
FARINTERNAL UtDIBFileStmToPBrushNativeStm
	(LPSTREAM pstmDIBFile, LPSTREAM pstmPBrush)
{
	BITMAPFILEHEADER bfh;
	HRESULT	error;
	
	if (error = pstmDIBFile->Read(&bfh, sizeof(bfh), 0))
		return error;
	
	// seek to the begining of the stream
	LARGE_INTEGER large_int;
	LISet32( large_int, 0);
	if (error = pstmDIBFile->Seek(large_int, STREAM_SEEK_SET, 0))
		return error;
	
	if (error = pstmPBrush->Write(&(bfh.bfSize), sizeof(DWORD), 0))
		return error;
	
	ULARGE_INTEGER ularge_int;
	ULISet32(ularge_int, bfh.bfSize);
	
	if ((error = pstmDIBFile->CopyTo(pstmPBrush, ularge_int,
			NULL, NULL)) == NOERROR)
		StSetSize(pstmPBrush, 0, TRUE);
	
	return error;
}
Esempio n. 2
0
STDMETHODIMP CArchiveStream::Seek(LARGE_INTEGER uliOffset, DWORD dwOrigin,
	ULARGE_INTEGER* puliNew)
{
	// can't handle offsets with really large magnitude
	if ((uliOffset.HighPart != 0) &&
		((uliOffset.HighPart != -1) || ((long)uliOffset.LowPart >= 0)))
		return E_NOTIMPL;

	CFile* pFile = m_pArchive->GetFile();
	if (pFile == NULL)
		return E_NOTIMPL;
	m_pArchive->Flush();

	ASSERT(STREAM_SEEK_SET == CFile::begin);
	ASSERT(STREAM_SEEK_CUR == CFile::current);
	ASSERT(STREAM_SEEK_END == CFile::end);
	LONG lNew;
	TRY
	{
		lNew = pFile->Seek((LONG)uliOffset.LowPart, (UINT)dwOrigin);
	}
	CATCH_ALL(e)
	{
		DELETE_EXCEPTION(e);
		return E_UNEXPECTED;
	}
	END_CATCH_ALL

	if (puliNew != NULL)
		ULISet32(*puliNew, lNew);

	return NOERROR;
}
Esempio n. 3
0
FARINTERNAL UtPlaceableMFStmToMSDrawNativeStm
	(LPSTREAM pstmPMF, LPSTREAM pstmMSDraw)
{
	DWORD	dwSize;	// size of metafile bits excluding the placeable MF header
	LONG	xExt;
	LONG	yExt;
	WORD	wBuf[5]; // dwSize(DWORD), mm(int), xExt(int), yExt(int)
	HRESULT error;
	
	if (error = UtGetSizeAndExtentsFromPlaceableMFStm(pstmPMF, &dwSize,
			&xExt, &yExt))
		return error;		

	*((DWORD FAR*) wBuf) = dwSize + 3*sizeof(WORD);
	wBuf[2] = MM_ANISOTROPIC;
	wBuf[3] = (int) xExt;
	wBuf[4] = (int) yExt;
	
	if (error = pstmMSDraw->Write(wBuf, sizeof(wBuf), 0))
		return error;

	ULARGE_INTEGER ularge_int;
	ULISet32(ularge_int, dwSize);
	if ((error = pstmPMF->CopyTo(pstmMSDraw, ularge_int,
			NULL, NULL)) == NOERROR)
		StSetSize(pstmMSDraw, 0, TRUE);
	
	return error;
				
}
Esempio n. 4
0
BOOL CswFile::SetFileSize (DWORD dwSize)
{
	ULARGE_INTEGER uliSize;
	ULISet32 (uliSize, dwSize);
	if (SUCCEEDED(m_pStream->SetSize (uliSize)))
		return TRUE;
	return FALSE;
}
Esempio n. 5
0
STDMETHODIMP CPerfBar::GetSizeMax(ULARGE_INTEGER* pcbSize)
{
    if (pcbSize == nullptr) {
        return E_INVALIDARG;
    }

    ULISet32(*pcbSize, 0);

    return S_OK;
}
Esempio n. 6
0
//+---------------------------------------------------------------
//
//  Member:     FatStream::Seek
//
//  Synopsis:   method of IStream interface
//
//----------------------------------------------------------------
STDMETHODIMP FatStream::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
{
    DWORD newpos;

    if(_hfile == INVALID_HANDLE_VALUE)
    {
        RRETURN(E_FAIL);
    }

    if(dlibMove.HighPart!=0 && dlibMove.HighPart!=-1)
    {
        RRETURN(E_FAIL);
    }

    newpos = SetFilePointer(_hfile, (LONG)dlibMove.LowPart, NULL, (int)dwOrigin);

    if(plibNewPosition != NULL)
    {
        ULISet32(*plibNewPosition, (LONG)newpos);
    }

    RRETURN(newpos==-1 ? E_FAIL : S_OK);
}
Esempio n. 7
0
//+---------------------------------------------------------------
//
//  Member:     FatStream::Stat
//
//  Synopsis:   method of IStream interface
//
//----------------------------------------------------------------
STDMETHODIMP FatStream::Stat(STATSTG* pstatstg, DWORD grfStatFlag)
{
    HRESULT hr = S_OK;

    if(_hfile == INVALID_HANDLE_VALUE)
    {
        hr = E_FAIL;
        goto Cleanup;
    }

    if(pstatstg != NULL)
    {
        pstatstg->pwcsName = NULL;
        if(grfStatFlag != STATFLAG_NONAME)
        {
            int cchFileName = _cstrFileName.Length();
            if(cchFileName)
            {
                pstatstg->pwcsName = (LPOLESTR)CoTaskMemAlloc(sizeof(TCHAR)*(cchFileName+1));
                if(!pstatstg->pwcsName)
                {
                    hr = E_OUTOFMEMORY;
                    goto Cleanup;
                }
                _tcscpy(pstatstg->pwcsName, _cstrFileName);
            }
        }

        pstatstg->type = STGTY_STREAM;
        ULISet32(pstatstg->cbSize, (LONG)GetFileSize(_hfile, NULL));
        pstatstg->grfLocksSupported = 0; // no locking supported
    }

Cleanup:
    RRETURN (hr);
}
Esempio n. 8
0
FARINTERNAL Ut10NativeStmToContentsStm
	(LPSTORAGE pstg, REFCLSID rclsid, BOOL fDeleteSrcStm)
{

	CLIPFORMAT	cfOld;
	CLIPFORMAT	cfNew;	
	LPOLESTR	lpszUserType = NULL;
	HRESULT		error;
	LPSTREAM	pstmSrc = NULL;
	LPSTREAM	pstmDst = NULL;

	
	if (error = ReadFmtUserTypeStg(pstg, &cfOld, &lpszUserType))
		return error;

	if (rclsid == CLSID_StaticDib)
		cfNew = CF_DIB;
	else if (rclsid == CLSID_StaticMetafile)
		cfNew = CF_METAFILEPICT;
	else {
		AssertSz(FALSE, "Internal Error: this routine shouldn't have been called for this class");
		return ResultFromScode(E_FAIL);
	}
	
	if (cfOld == g_cfPBrush) {
		if (cfNew != CF_DIB) {
			error = ResultFromScode(DV_E_CLIPFORMAT);			
			goto errRtn;
		}
	} else if (cfOld == g_cfMSDraw) {
		if (cfNew != CF_METAFILEPICT) {
			error = ResultFromScode(DV_E_CLIPFORMAT);			
			goto errRtn;
		}
	} else {
		// Converted to static object from some class other than PBrush or
		// MSDraw. The data must be in a proper format in the CONTENTS
		// stream.
		return NOERROR;
	}
	
	if (error = pstg->OpenStream(OLE10_NATIVE_STREAM, NULL,
						(STGM_READ|STGM_SHARE_EXCLUSIVE),
						0, &pstmSrc))
		goto errRtn;
	
	if (error = OpenOrCreateStream(pstg, OLE_CONTENTS_STREAM, &pstmDst))
		goto errRtn;
	
	DWORD dwSize;
	if (error = pstmSrc->Read(&dwSize, sizeof(DWORD), NULL))
		goto errRtn;
			
	if (cfOld == g_cfMSDraw) {
		WORD mfp[3]; // mm, xExt, yExt
	
		if (error = pstmSrc->Read(mfp, sizeof(mfp), NULL))
			goto errRtn;
		
		dwSize -= sizeof(mfp);
		
		error = UtMFStmToPlaceableMFStm(pstmSrc, dwSize,
					(LONG) mfp[1], (LONG) mfp[2], pstmDst);
		
	} else {
		// The PBrush native data format is DIB File format. So all we got to
		// do is CopyTo.
		
		ULARGE_INTEGER ularge_int;
		ULISet32(ularge_int, dwSize);
		if ((error = pstmSrc->CopyTo(pstmDst, ularge_int, NULL,
				NULL)) == NOERROR)
			StSetSize(pstmDst, 0, TRUE);		
	}
	
errRtn:
	if (pstmDst)
		pstmDst->Release();
			
	if (pstmSrc)
		pstmSrc->Release();
	
	if (error == NOERROR) {
 		error = WriteFmtUserTypeStg(pstg, cfNew, lpszUserType);

		if (fDeleteSrcStm)				
			pstg->DestroyElement(OLE10_NATIVE_STREAM);

	} else {
		pstg->DestroyElement(OLE_CONTENTS_STREAM);	
	}	
	
	if (lpszUserType)
		PubMemFree(lpszUserType);
	
	return error;
}