コード例 #1
0
ファイル: ModuleEntry.cpp プロジェクト: agran147/FieldWorks
void ModuleEntry::ShutDown()
{
	ModuleEntry * pme;

	for (pme = s_pmeFirst; pme; pme = pme->m_pobjNext)
	{
		try
		{
			pme->ProcessDetach();
		}
		catch (const Throwable & thr)
		{
			WarnHr(thr.Error());
		}
		catch (...)
		{
			return WarnHr(E_FAIL);
		}
	}

	// Uninitialize COM, first shutting down the clipboard.
	if (s_qdobjClipboard.Ptr())
	{
		hr = OleIsCurrentClipboard(s_qdobjClipboard.Ptr());
		WarnHr(hr);
		if (hr == S_OK)
		{
			WarnHr(OleFlushClipboard());
		}
		s_qdobjClipboard.Clear();
	}
	OleUninitialize();
}
コード例 #2
0
/*----------------------------------------------------------------------------------------------
	Read the given number of bytes from the stream / file.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::Read(void * pv, ULONG cb, ULONG * pcbRead)
{
	BEGIN_COM_METHOD;
	ChkComArrayArg((byte *)pv, cb);
	ChkComArgPtrN(pcbRead);

	if (m_hfile == NULL)
		ThrowHr(WarnHr(E_UNEXPECTED));

	if (cb == 0)
	{
		if (pcbRead)
			*pcbRead = 0;
		return S_OK;
	}

	if (!SetFilePosRaw())
		ThrowHr(WarnHr(STG_E_SEEKERROR));
	DWORD cbRead = 0;
	if (!ReadFile(m_hfile, pv, cb, &cbRead, NULL))
		ThrowHr(WarnHr(STG_E_READFAULT));
	m_ibFilePos.QuadPart += cbRead;
	if (pcbRead)
		*pcbRead = cbRead;

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #3
0
STDMETHODIMP LgLanguageEnumerator::Next(int * pnLoc, BSTR * pbstrName)
{
    BEGIN_COM_METHOD
    ChkComOutPtr(pnLoc);
    ChkComOutPtr(pbstrName);
    if (!m_prgLangIds)
        ThrowHr(WarnHr(E_UNEXPECTED));
    if (m_iLangId >= m_ulCount)
        return S_OK; // past end, leave *pnLoc 0 and *pbstrName null.

    wchar   szLangName[MAX_PATH];

    //Get the language name and print it to the debug window.
    if( 0 == GetLocaleInfoW(MAKELCID(m_prgLangIds[m_iLangId], SORT_DEFAULT),
                            LOCALE_SLANGUAGE,
                            szLangName,
                            MAX_PATH))
    {
        //InKey can give values that are not supported by the operating system.
        //Return the bad id with an error message
        *pnLoc = m_prgLangIds[m_iLangId++];
        return E_FAIL;
    }

    *pbstrName = SysAllocString(szLangName);
    if (!*pbstrName)
        ThrowHr(WarnHr(E_OUTOFMEMORY));
    *pnLoc = m_prgLangIds[m_iLangId++];

    END_COM_METHOD(g_factLang, IID_ILgLanguageEnumerator);
}
コード例 #4
0
/*----------------------------------------------------------------------------------------------
	Write the given number of bytes to the stream / file.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::Write(const void * pv, ULONG cb, ULONG * pcbWritten)
{
	BEGIN_COM_METHOD;
	ChkComArrayArg((byte *)pv, cb);
	ChkComArgPtrN(pcbWritten);

	if (m_hfile == NULL)
		ThrowHr(WarnHr(E_UNEXPECTED));
	if (cb == 0)
	{
		if (pcbWritten)
			*pcbWritten = 0;
		return S_OK;
	}

	if (!SetFilePosRaw())
		ThrowHr(WarnHr(STG_E_SEEKERROR));
	DWORD cbWritten = 0;
	if (!WriteFile(m_hfile, pv, cb, &cbWritten, NULL))
		ThrowHr(WarnHr(STG_E_WRITEFAULT));

	m_ibFilePos.QuadPart += cbWritten;
	if (pcbWritten)
		*pcbWritten = cbWritten;

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #5
0
ファイル: ModuleEntry.cpp プロジェクト: agran147/FieldWorks
/*----------------------------------------------------------------------------------------------
	Static method that returns the path name of the dll or exe.
----------------------------------------------------------------------------------------------*/
LPCTSTR ModuleEntry::GetModulePathName()
{
#if WIN32
	if (s_strbpPath.Length() == 0)
	{
		ULONG cchMod;

		s_strbpPath.SetLength(MAX_PATH);
		cchMod = GetModuleFileName(s_hmod, &s_strbpPath[0], MAX_PATH);
		s_strbpPath.SetLength(cchMod);
		if (!cchMod)
			ThrowHr(WarnHr(E_FAIL));
	}

	return s_strbpPath.Chars();
#else
	if (s_strbpPath[0] == 0)
	{
		ULONG cchMod;

		cchMod = GetModuleFileName(s_hmod, &s_strbpPath[0], MAX_PATH);
		if (!cchMod)
			ThrowHr(WarnHr(E_FAIL));
	}

	return s_strbpPath;
#endif
}
コード例 #6
0
/*----------------------------------------------------------------------------------------------
	Get the status of an open IStream (file).
	If the caller uses the value STATFLAG_DEFAULT for grfStatFlag then the user must free
	the memory which this method allocates for the file name at pstatstg->pwcsName.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::Stat(STATSTG * pstatstg, DWORD grfStatFlag)
{
	BEGIN_COM_METHOD;
	ChkComArgPtr(pstatstg);

	if (m_hfile == NULL)
		ThrowHr(WarnHr(E_UNEXPECTED));

	BY_HANDLE_FILE_INFORMATION bhfi;

	if (!GetFileInformationByHandle(m_hfile, &bhfi))
	{
		// The caller does not have sufficient permissions for accessing statistics for this
		// stream object.
		ThrowHr(WarnHr(STG_E_ACCESSDENIED));
	}

	pstatstg->pwcsName = NULL;

	switch (grfStatFlag)
	{
	case STATFLAG_DEFAULT:
		// Requests that the statistics include the pwcsName member of the STATSTG structure.
		{
			StrUniBufPath stubpName = m_staPath.Chars();

			pstatstg->pwcsName = (wchar *)CoTaskMemAlloc(
				(stubpName.Length() + 1) * isizeof(wchar));
			if (NULL == pstatstg->pwcsName)
				ThrowHr(WarnHr(STG_E_INSUFFICIENTMEMORY));

			memcpy(pstatstg->pwcsName, stubpName.Chars(), stubpName.Length() * isizeof(wchar));
			pstatstg->pwcsName[stubpName.Length()] = 0;
		}
		// Fall Through.
	case STATFLAG_NONAME:
		// Requests that the statistics not include the pwcsName member of the STATSTG
		// structure. If the name is omitted, there is no need for the Stat methods to allocate
		// and free memory for the string value for the name and the method can save an Alloc
		// and the caller a Free operation.
		pstatstg->type = STGTY_STREAM;
		pstatstg->cbSize.HighPart = bhfi.nFileSizeHigh;
		pstatstg->cbSize.LowPart = bhfi.nFileSizeLow;
		pstatstg->mtime = bhfi.ftLastWriteTime;
		pstatstg->ctime = bhfi.ftCreationTime;
		pstatstg->atime = bhfi.ftLastAccessTime;
		pstatstg->grfMode = m_grfstgm;
		pstatstg->grfLocksSupported = 0;
		pstatstg->clsid = CLSID_NULL;
		pstatstg->grfStateBits = 0;
		return S_OK;

	default:
		ThrowHr(WarnHr(STG_E_INVALIDFLAG));
	}
	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #7
0
ファイル: ModuleEntry.cpp プロジェクト: agran147/FieldWorks
/*----------------------------------------------------------------------------------------------
	Static method to find a class factory (from the given CLSID) from all the class factories
	that are in the linked list. If the requested class factory is not found, *ppv is set
	to NULL and CLASS_E_CLASSNOTAVAILABLE is returned.
----------------------------------------------------------------------------------------------*/
HRESULT ModuleEntry::ModuleGetClassObject(REFCLSID clsid, REFIID iid, void ** ppv)
{
	AssertPtrN(ppv);
	if (!ppv)
		return WarnHr(E_POINTER);
	*ppv = NULL;

	// This block of code is largely copied from the AssertNoErrorInfo method in throwable.h.
	// Here, however, we don't assert, but just dump a warning to the output window and
	// discard the spurious error info. This prevents asserts if Windows.Forms calls
	// a class factory (as it has been known to do) with spurious error info registered.
#ifdef DEBUG
	IErrorInfo * pIErrorInfo = NULL;
	HRESULT hr = GetErrorInfo(0, &pIErrorInfo);
	Assert(SUCCEEDED(hr));

	if(pIErrorInfo != NULL) {
		BSTR bstr;
		hr = pIErrorInfo->GetDescription(&bstr);
		Assert(SUCCEEDED(hr));
		::OutputDebugString(bstr);
		::SysFreeString(bstr);
		hr = pIErrorInfo->GetSource(&bstr);
		Assert(SUCCEEDED(hr));
		::OutputDebugString(bstr);
		::SysFreeString(bstr);
		pIErrorInfo->Release();
	}
#endif

	ModuleEntry * pme;

	try
	{
		for (pme = s_pmeFirst; pme; pme = pme->m_pobjNext)
		{
			AssertPtr(pme);
			pme->GetClassFactory(clsid, iid, ppv);
			if (*ppv)
				return S_OK;
		}
	}
	catch (const Throwable & thr)
	{
		return thr.Error();
	}
	catch (...)
	{
		return WarnHr(E_FAIL);
	}

	return CLASS_E_CLASSNOTAVAILABLE;
}
コード例 #8
0
/*----------------------------------------------------------------------------------------------
	Copy cb bytes from the current position in this stream to the current position in
	the stream *pstm.
	Uses FileStream ${#Read} and ${#Write} methods. Note that though it would be more efficient
	in some	cases to bypass the Read method for several consecutive reads, the case of copying
	to a clone would require special handling.
	There is no check for overlapping read & write areas. REVIEW (JohnL): Should there be?
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::CopyTo(IStream * pstm, ULARGE_INTEGER cb, ULARGE_INTEGER * pcbRead,
	ULARGE_INTEGER * pcbWritten)
{
	BEGIN_COM_METHOD;
	ChkComArgPtr(pstm);
	ChkComArgPtrN(pcbRead);
	ChkComArgPtrN(pcbWritten);

	if (cb.HighPart)
		ThrowHr(WarnHr(STG_E_INVALIDPARAMETER)); // handle only 32-bit byte counts
	// REVIEW JohnL: should we nevertheless handle cb == max ULARGE_INTEGER as a special case?
	if (pstm == this)
		ThrowHr(WarnHr(STG_E_INVALIDPARAMETER)); // prevent copy to self
	// REVIEW JohnL: is this correct?

	if (pcbRead)
		(*pcbRead).QuadPart = 0;
	if (pcbWritten)
		(*pcbWritten).QuadPart = 0;

	const ULONG kcbBufferSize = 4096;
	ULONG cbReadTotal;
	ULONG cbWrittenTotal = 0;
	byte prgbBuffer[kcbBufferSize];
	ULONG cbRead = 0;
	ULONG cbWritten;
	ULONG cbr = 0;

	for (cbReadTotal = 0; (cbReadTotal < cb.LowPart) && (cbRead == cbr); )
	{
		cbr = cb.LowPart - cbReadTotal;
		if (cbr > kcbBufferSize)
			cbr = kcbBufferSize;
		CheckHr(Read((void *)prgbBuffer, cbr, &cbRead));
		cbReadTotal += cbRead;
		if (cbRead)
		{
			CheckHr(pstm->Write((void *)prgbBuffer, cbRead, &cbWritten));
			cbWrittenTotal += cbWritten;
		}
	}
	if (pcbRead)
		(*pcbRead).LowPart = cbReadTotal;
	if (pcbWritten)
		(*pcbWritten).LowPart = cbWrittenTotal;

	// REVIEW JohnL: How do we define "success" for CopyTo? Should we return a failure if
	//                 cbWrittenTotal != cbReadTotal?
	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #9
0
/*----------------------------------------------------------------------------------------------
	Flush the file's buffer. Since we are dealing with a file opened in director mode, we
	just flush the buffer and ignore the grfCommitFlags.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::Commit(DWORD grfCommitFlags)
{
	BEGIN_COM_METHOD;
	// FlushFileBuffers may return an error if m_hfile doesn't have GENERIC_WRITE access.
	if (!(m_grfstgm & (kfstgmReadWrite | kfstgmWrite)))
		ThrowHr(WarnHr(STG_E_INVALIDFUNCTION));

	if (!FlushFileBuffers(m_hfile))
	{
		// REVIEW JohnL: Should we check for medium full before returning this code?
		ThrowHr(WarnHr(STG_E_MEDIUMFULL));
	}

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #10
0
ファイル: VwAccessRoot.cpp プロジェクト: agran147/FieldWorks
//:>********************************************************************************************
//:>	IUnknown Methods
//:>********************************************************************************************
STDMETHODIMP VwAccessRoot::QueryInterface(REFIID riid, void **ppv)
{
	AssertPtr(ppv);
	if (!ppv)
		return WarnHr(E_POINTER);
	*ppv = NULL;

	if (riid == IID_IUnknown)
		*ppv = static_cast<IUnknown *>(static_cast<IAccessible *>(this));
	else if (riid == IID_IAccessible)
		*ppv = static_cast<IAccessible *>(this);
	else if (riid == IID_IServiceProvider)
		*ppv = static_cast<IServiceProvider *>(this);
	else if (riid == IID_IDispatch)
		*ppv = static_cast<IDispatch *>(this);
	else if (riid == IID_IEnumVARIANT)
		*ppv = static_cast<IEnumVARIANT *>(this);
	else if (riid == IID_ISupportErrorInfo)
	{
		*ppv = NewObj CSupportErrorInfo3(static_cast<IAccessible *>(this),
			IID_IAccessible, IID_IServiceProvider, IID_IEnumVARIANT);
		return S_OK;
	}
	else
		return E_NOINTERFACE;

	AddRef();
	return NOERROR;
}
コード例 #11
0
/*----------------------------------------------------------------------------------------------
	Get a pointer to the desired interface if possible.  IUnknown, IDataObject, and ITsString
	are supported.  Note that the ITsString interface refers to an internal variable, and cannot
	be used to get back to the IDataObject or the original IUnknown.

	This is a standard COM IUnknown method.

	@param riid Reference to the GUID of the desired COM interface.
	@param ppv Address of a pointer for returning the desired COM interface.

	@return SOK, STG_E_INVALIDPOINTER, or E_NOINTERFACE.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP LgTsDataObject::QueryInterface(REFIID riid, void ** ppv)
{
	AssertPtr(ppv);
	if (!ppv)
		return WarnHr(E_POINTER);
	*ppv = NULL;

	if (riid == IID_IUnknown)
		*ppv = static_cast<IUnknown *>(static_cast<ILgTsDataObject *>(this));
	else if (riid == IID_IDataObject)
		*ppv = static_cast<IDataObject *>(this);
	else if (riid == IID_ILgTsDataObject)
		*ppv = static_cast<ILgTsDataObject *>(this);
	else if (riid == IID_ISupportErrorInfo)
	{
		*ppv = NewObj CSupportErrorInfo(static_cast<IDataObject *>(this), IID_IDataObject);
//		*ppv = NewObj CSupportErrorInfo(this, IID_ITsString);
		return S_OK;
	}
	else
		return E_NOINTERFACE;

	reinterpret_cast<IUnknown *>(*ppv)->AddRef();
	return S_OK;
}
コード例 #12
0
/*----------------------------------------------------------------------------------------------
	Create and subclass the HWND associated with this AfWnd object.

	@param wcs Pointer to the object containing the values for calling ::CreateWindowEx.
----------------------------------------------------------------------------------------------*/
void AfWnd::CreateAndSubclassHwnd(WndCreateStruct & wcs)
{
	AssertObj(this);
	Assert(!m_hwnd);

	PreCreateHwnd(wcs);

	HWND hwnd = ::CreateWindowEx(wcs.dwExStyle, wcs.lpszClass, wcs.lpszName, wcs.style,
		wcs.x, wcs.y, wcs.cx, wcs.cy, wcs.hwndParent, wcs.hMenu, wcs.hInstance,
		wcs.lpCreateParams);

	Assert(!m_hwnd);
	if (!hwnd)
		ThrowHr(WarnHr(E_FAIL));

	try
	{
		SubclassHwnd(hwnd);
	}
	catch (...)
	{
		::DestroyWindow(hwnd);
		throw;
	}
}
コード例 #13
0
/*----------------------------------------------------------------------------------------------
	Create the HWND associated with this AfWnd object.

	@param wcs Pointer to the object containing the values for calling ::CreateWindowEx.
----------------------------------------------------------------------------------------------*/
void AfWnd::CreateHwnd(WndCreateStruct & wcs)
{
	AssertObj(this);
	Assert(!m_hwnd);

	PreCreateHwnd(wcs);

	AfWndCreate afwc = { this, wcs.lpCreateParams };

	HWND hwnd = ::CreateWindowEx(wcs.dwExStyle, wcs.lpszClass, wcs.lpszName, wcs.style,
		wcs.x, wcs.y, wcs.cx, wcs.cy, wcs.hwndParent, wcs.hMenu, wcs.hInstance, &afwc);

	Assert(m_hwnd == hwnd);
	if (!hwnd)
	{
#if 0
		// Popup DEBUG explanation of failure.
		LPVOID lpMsgBuf;
		::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL, ::GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
		::MessageBox(NULL, (LPCTSTR)lpMsgBuf, _T("DEBUG"), MB_OK);
		::LocalFree(lpMsgBuf);
#endif
		ThrowHr(WarnHr(E_FAIL));
	}
}
コード例 #14
0
/*----------------------------------------------------------------------------------------------
Creates a new stream object with its own seek pointer that references the same bytes
as the original stream.
The m_qstrmBase member in the clone is set to the IStream interface pointer of the original
FileStream object for ${#AddRef} and ${#Release} calls which are used to prevent that object
from being deleted until after all clones have been deleted.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::Clone(IStream ** ppstm)
{
	BEGIN_COM_METHOD;
	ChkComOutPtr(ppstm);

	FileStream * pfist;

	pfist = NewObj FileStream;
	if (!pfist)
		ThrowHr(WarnHr(STG_E_INSUFFICIENTMEMORY));

	pfist->m_staPath = m_staPath;

	// If this is the first clone, a pointer to the current object is fine. Otherwise (if we
	// are making a clone from a clone) copy the current pointer.
	if (!m_qstrmBase)
	{
		pfist->m_qstrmBase = this;
	}
	else
	{
		pfist->m_qstrmBase = m_qstrmBase;
	}

	pfist->m_hfile = m_hfile;
	pfist->m_ibFilePos = m_ibFilePos;
	pfist->m_grfstgm = m_grfstgm;
	*ppstm = pfist;

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #15
0
ファイル: TextServ.cpp プロジェクト: agran147/FieldWorks
/*----------------------------------------------------------------------------------------------
	Allocate our TLS slot.
----------------------------------------------------------------------------------------------*/
void TextServGlobals::ProcessAttach(void)
{
#if WIN32
	s_luTls = TlsAlloc();
	if (0xFFFFFFFF == s_luTls)
		ThrowHr(WarnHr(E_FAIL));
#else
	if (pthread_key_create(&s_luTls, 0) != 0)
		ThrowHr(WarnHr(E_FAIL));
#endif //WIN32
#if WIN32
	InitializeCriticalSection(&g_crs);
#else
	pthread_mutex_init(&g_crs, 0);
#endif //WIN32
}
コード例 #16
0
/*----------------------------------------------------------------------------------------------
	QueryInterface.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP TsPropsFact::QueryInterface(REFIID iid, void ** ppv)
{
	AssertPtr(ppv);
	if (!ppv)
		return WarnHr(E_POINTER);
	*ppv = NULL;

	if (iid == IID_IUnknown)
		*ppv = static_cast<IUnknown *>(this);
	else if (iid == IID_ITsPropsFactory)
		*ppv = static_cast<ITsPropsFactory *>(this);
	else if (iid == IID_ISupportErrorInfo)
	{
		*ppv = NewObj CSupportErrorInfo(this, IID_ITsPropsFactory);
		return S_OK;
	}
#if WIN32
	else if (iid == IID_IMarshal)
		return m_qunkMarshaler->QueryInterface(iid, ppv);
#endif
	else
		return E_NOINTERFACE;

	reinterpret_cast<IUnknown *>(*ppv)->AddRef();
	return S_OK;
}
コード例 #17
0
STDMETHODIMP VwInvertedEnv::OpenMappedPara()
{
	BEGIN_COM_METHOD;
	Assert(false); // "This type of box is not yet supported in inverted views");
	ThrowHr(WarnHr(E_NOTIMPL));
	END_COM_METHOD(dfactEnv, IID_IVwEnv);
}
コード例 #18
0
STDMETHODIMP VwInvertedEnv::AddLazyVecItems(int tag, IVwViewConstructor * pvvc, int frag)
{
	BEGIN_COM_METHOD;
	Assert(false); // "This type of box is not yet supported in inverted views");
	ThrowHr(WarnHr(E_NOTIMPL));
	END_COM_METHOD(dfactEnv, IID_IVwEnv);
}
コード例 #19
0
//:>********************************************************************************************
//:>	   IUnknown Methods
//:>********************************************************************************************
STDMETHODIMP LgInputMethodEditor::QueryInterface(REFIID riid, void **ppv)
{
	AssertPtr(ppv);
	if (!ppv)
		return WarnHr(E_POINTER);
	*ppv = NULL;

	if (riid == IID_IUnknown)
		*ppv = static_cast<IUnknown *>(static_cast<ILgInputMethodEditor *>(this));
	else if (riid == IID_ISimpleInit)
		*ppv = static_cast<ISimpleInit *>(this);
	else if (riid == IID_ILgInputMethodEditor)
		*ppv = static_cast<ILgInputMethodEditor *>(this);
	else if (riid == IID_ISupportErrorInfo)
	{
		*ppv = NewObj CSupportErrorInfo2(static_cast<ILgInputMethodEditor *>(this),
			IID_ISimpleInit, IID_ILgInputMethodEditor);
		return S_OK;
	}
	else
		return E_NOINTERFACE;

	AddRef();
	return NOERROR;
}
コード例 #20
0
/*----------------------------------------------------------------------------------------------
	Adjust the stream seek pointer, returning the new value.
	@return STG_E_SEEKERROR if the new position would be negative.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin,
	ULARGE_INTEGER * plibNewPosition)
{
	BEGIN_COM_METHOD;
	ChkComArgPtrN(plibNewPosition);
	if (m_hfile == NULL)
		ThrowHr(WarnHr(E_UNEXPECTED));

	DWORD dwLow;
	long dwHigh;
	LARGE_INTEGER dlibNew; // attempted new seek position

	switch (dwOrigin)
	{
	case STREAM_SEEK_SET:
		dlibNew.QuadPart = dlibMove.QuadPart;
		break;
	case STREAM_SEEK_CUR:
		dlibNew.QuadPart = (int64)m_ibFilePos.QuadPart + dlibMove.QuadPart;
		break;
	case STREAM_SEEK_END:
		// Find out where EOF is by calling for a zero move of the file pointer
		dwHigh = 0;
		dwLow = SetFilePointer(m_hfile, 0, &dwHigh, FILE_END);
		if (dwLow == 0xFFFFFFFF && GetLastError() != NO_ERROR)
			ThrowHr(WarnHr(STG_E_SEEKERROR));

		// Work out new attempted seek pointer value
		dlibNew.LowPart = dwLow;
		dlibNew.HighPart = dwHigh;
		dlibNew.QuadPart += dlibMove.QuadPart;
		break;
	default:
		ThrowHr(WarnHr(STG_E_INVALIDFUNCTION));
	}

	if (dlibNew.QuadPart < 0)
		ThrowHr(WarnHr(STG_E_SEEKERROR));

	// Update the current position.
	m_ibFilePos.QuadPart = (uint64)dlibNew.QuadPart;

	if (plibNewPosition)
		plibNewPosition->QuadPart = (uint64)dlibNew.QuadPart;

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #21
0
ファイル: TstLanguage.cpp プロジェクト: agran147/FieldWorks
/*----------------------------------------------------------------------------------------------
	Perform some tests on the LgCharacterPropertyEngine class.
	Return S_OK if all tests succeed; do not return otherwise.
	REVIEW LarsH: will this really not return after *any* failure?
----------------------------------------------------------------------------------------------*/
HRESULT TestCharacterPropertyEngine::Run()
{
#ifdef OLD_SOURCE_TREE
	HRESULT hr;

	IClassInitMonikerPtr qcim;
	hr = qcim.CreateInstance(CLSID_ClassInitMoniker);
	WarnHr(hr);

	hr = qcim->InitNew(CLSID_LgCharacterPropertyEngine, NULL, 0);
	WarnHr(hr);
#endif // def OLD_SOURCE_TREE

	try
	{
		m_qpropeng.CreateInstance(CLSID_LgCharacterPropertyEngine);
	}
	catch (Throwable & thr)
	{
		return thr.Error();
	}
	catch (...)
	{
		return WarnHr(E_FAIL);
	}

#ifdef OLD_SOURCE_TREE
	IBindCtxPtr qbc;
	hr = ::CreateBindCtx(NULL, &qbc);
	WarnHr(hr);
	hr = qcim->BindToObject(qbc, NULL, IID_ILgCharacterPropertyEngine, (void **)&m_qpropeng);
	WarnHr(hr);
#endif // def OLD_SOURCE_TREE

	SpotCheckProperties();

	// REVIEW LarsH: set up a condition so that this test is only run when exhaustive,
	// time-consuming tests are called for.  Maybe make it a separate test from
	// the spot check.  Yes.  And its name should include a hint, like "brute force".
	// However, ExhTestProperties() will assume that SpotCheck()
	// is also being run, and will not cover all the same ground.


	// TestCaseConversion(); TODO LarsH

	return S_OK;
}
コード例 #22
0
ファイル: TestStVc.cpp プロジェクト: FieldDB/FieldWorks
/*----------------------------------------------------------------------------------------------
	This is the main interesting method of displaying objects and fragments of them.
	Here a text is displayed by displaying its paragraphs;
	and a paragraph is displayed by invoking its style rule, making a paragraph,
	and displaying its contents.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP TestStVc::Display(IVwEnv * pvwenv, HVO hvo, int frag)
{
	try
	{
		switch(frag)
		{
		case kfrText:
			{// BLOCK for var skip warnings
				// We need to show something, since the current view code can't handle a property
				// containing no boxes.
				// Review JohnT: should we show an empty string or something?
				// Should we prevent the occurrence of texts with no paragraphs?
				int cpara = 0;
				ISilDataAccessPtr qsda;
				CheckHr(pvwenv->get_DataAccess(&qsda));
				if (hvo)
					CheckHr(qsda->get_VecSize(hvo, kflidStText_Paragraphs, &cpara));
				if (!cpara)
				{
					// Either we have no ST object at all, or it is empty of paragraphs. The
					// current view code can't handle either, so stick something in.
					ITsStrFactoryPtr qtsf;
					qtsf.CreateInstance(CLSID_TsStrFactory);
					ITsStringPtr qtssMissing;
					CheckHr(qtsf->MakeStringRgch(L"<no paragraphs>", 15, 0, &qtssMissing));
					CheckHr(pvwenv->AddString(qtssMissing));
					break;
				}
				CheckHr(pvwenv->AddObjVecItems(kflidStText_Paragraphs, this, kfrPara));
			}
			break;
		case kfrPara:
			{ // BLOCK
				// Invoke the paragraph's style rule if any
				ISilDataAccessPtr qsda;
				CheckHr(pvwenv->get_DataAccess(&qsda));
				ITsTextPropsPtr qttp;
				CheckHr(qsda->get_UnknownProp(hvo, kflidStPara_StyleRules, IID_ITsTextProps,
					(void **) &qttp));
				if (qttp)
					CheckHr(pvwenv->put_Props(qttp));
				// And make the paragraph containing the paragraph contents.
				CheckHr(pvwenv->OpenParagraph());
				CheckHr(pvwenv->AddStringProp(kflidStTxtPara_Contents));
				CheckHr(pvwenv->CloseParagraph());
			}
			break;
		}
	}
	catch (Throwable & thr)
	{
		return thr.Error();
	}
	catch (...)
	{
		return WarnHr(E_FAIL);
	}
	return S_OK;
}
コード例 #23
0
ファイル: ResourceStrm.cpp プロジェクト: bbriggs/FieldWorks
/*----------------------------------------------------------------------------------------------
	Change the size of the data stream.
	NOTE: this is not supported by ResourceStream.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ResourceStream::SetSize(ULARGE_INTEGER libNewSize)
{
	BEGIN_COM_METHOD;

	ThrowHr(WarnHr(STG_E_ACCESSDENIED));

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #24
0
ファイル: ResourceStrm.cpp プロジェクト: bbriggs/FieldWorks
/*----------------------------------------------------------------------------------------------
	Ensure that any changes made to this transacted stream are reflected in the parent storage
	object.
	NOTE: this is not supported by ResourceStream.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ResourceStream::Commit(DWORD grfCommitFlags)
{
	BEGIN_COM_METHOD;

	ThrowHr(WarnHr(STG_E_INVALIDFUNCTION));

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #25
0
ファイル: ResourceStrm.cpp プロジェクト: bbriggs/FieldWorks
/*----------------------------------------------------------------------------------------------
	Discard all changes that have been made to this transacted stream since the last
	IStream::Commit call.
	NOTE: this is not supported by ResourceStream.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ResourceStream::Revert(void)
{
	BEGIN_COM_METHOD;

	ThrowHr(WarnHr(STG_E_INVALIDFUNCTION));

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #26
0
STDMETHODIMP VwInvertedEnv::OpenConcPara(int ichMinItem, int ichLimItem, VwConcParaOpts cpoFlags,
								int dmpAlign)
{
	BEGIN_COM_METHOD;
	Assert(false); // "This type of box is not yet supported in inverted views");
	ThrowHr(WarnHr(E_NOTIMPL));
	END_COM_METHOD(dfactEnv, IID_IVwEnv);
}
コード例 #27
0
STDMETHODIMP VwInvertedEnv::OpenOverridePara(int cOverrideProperties,
									 DispPropOverride *prgOverrideProperties)
{
	BEGIN_COM_METHOD;
	Assert(false); // "This type of box is not yet supported in inverted views");
	ThrowHr(WarnHr(E_NOTIMPL));
	END_COM_METHOD(dfactEnv, IID_IVwEnv);
}
コード例 #28
0
/*----------------------------------------------------------------------------------------------
	This should just return the appropriate error code. See the definition of IStream.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::Revert(void)
{
	BEGIN_COM_METHOD;

	// This should not be implemented, no transaction support.
	ThrowHr(WarnHr(STG_E_INVALIDFUNCTION));

	END_COM_METHOD(g_fact, IID_IStream);
}
コード例 #29
0
// Get the nth locale variant. (ICU getVariant.)
STDMETHODIMP LgIcuLocaleEnumerator::get_Variant(int iloc, BSTR * pbstrName)
{
	BEGIN_COM_METHOD
	ChkComOutPtr(pbstrName);
	if (iloc >= m_clocale)
		ThrowHr(WarnHr(E_INVALIDARG));
	*pbstrName = AsciiToBstr(m_prgLocales[iloc].getVariant());
	END_COM_METHOD(g_factLocEnum, IID_ILgIcuLocaleEnumerator);
}
コード例 #30
0
/*----------------------------------------------------------------------------------------------
	Remove the access restriction on a range of bytes previously restricted with
	IStream::LockRegion.
	NOTE: this is not supported by FileStream.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FileStream::UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,
	DWORD dwLockType)
{
	BEGIN_COM_METHOD;

	ThrowHr(WarnHr(STG_E_INVALIDFUNCTION));

	END_COM_METHOD(g_fact, IID_IStream);
}