Ejemplo n.º 1
0
RImage* QSLItemData::Load2(
	LPSTORAGE	pIStorage,			// @parm storage
	BOOL        fDescOnly )
{
	RImage* pImage = NULL;
	char	strDescription[kBufLength];

	TRY
	{
		COleStreamFile  str;

		if (!fDescOnly)
		{
			// open stream
			CString  szStream = "PREVIEW";

			if (str.OpenStream (pIStorage, szStream, CFile::modeRead | CFile::shareExclusive))
			{
				// Read in the image data
				RTempFileBuffer	buffer;
				buffer.Resize( str.GetLength() );
				str.Read( buffer.GetBuffer(), str.GetLength() );
				str.Close();

				// Create the image
				pImage = RImageLibrary().ImportImage( buffer );
			}
		}

		if (fDescOnly)
		{
			// open stream
			CString szStream = "DESCRIPTION";

			if (str.OpenStream (pIStorage, szStream, CFile::modeRead | CFile::shareExclusive))
			{
				str.Read (&strDescription, min( kBufLength, str.GetLength() ));
				str.Close();
			}

			// return bitmap handle and description string
			m_strDesc = strDescription;
		}

	} // End try

	CATCH(CArchiveException, archExcept)
	{
		//CBExceptionReporter::ArchiveException(archExcept);
	}
	END_CATCH


	return pImage;
}
Ejemplo n.º 2
0
void COleDocument::LoadFromStorage()
{
	ASSERT(m_lpRootStg != NULL);

	// open Contents stream
	COleStreamFile file;
	CFileException fe;
	if (!file.OpenStream(m_lpRootStg, _T("Contents"),
			CFile::modeRead|CFile::shareExclusive, &fe) &&
		!file.CreateStream(m_lpRootStg, _T("Contents"),
			CFile::modeRead|CFile::shareExclusive|CFile::modeCreate, &fe))
	{
		if (fe.m_cause == CFileException::fileNotFound)
			AfxThrowArchiveException(CArchiveException::badSchema);
		else
			AfxThrowFileException(fe.m_cause, fe.m_lOsError);
	}

	// load it with CArchive (loads from Contents stream)
	CArchive loadArchive(&file, CArchive::load | CArchive::bNoFlushOnDelete);
	loadArchive.m_pDocument = this;
	loadArchive.m_bForceFlat = FALSE;

	TRY
	{
		if (file.GetLength() != 0)
			Serialize(loadArchive);     // load main contents
		loadArchive.Close();
		file.Close();
	}
	CATCH_ALL(e)
	{
		file.Abort();   // will not throw an exception
		DeleteContents();   // removed failed contents
		NO_CPP_EXCEPTION(loadArchive.Abort());
		THROW_LAST();
	}
	END_CATCH_ALL
}