示例#1
0
/*----------------------------------------------------------------------------------------------
	${IActionHandler#BreakUndoTask}
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ActionHandler::BreakUndoTask(BSTR bstrUndo, BSTR bstrRedo)
{
	BEGIN_COM_METHOD;
	ChkComBstrArg(bstrUndo);
	ChkComBstrArg(bstrRedo);

	if (m_fUndoOrRedoInProgress)
		return S_OK;

	int nSaveDepth = m_nDepth;

	EndOuterUndoTask();

	BeginUndoTask(bstrUndo, bstrRedo);

	m_nDepth = nSaveDepth;

#ifdef DEBUG_ACTION_HANDLER
	StrAnsi sta;
	sta.Format("BreakUndoTask:");
	sta.FormatAppend(" m_iCurrSeq=%d, m_viSeqStart=%d, m_iuactCurr=%d, m_vquact=%d, m_viMarks=%d, m_nDepth=%d\n",
		m_iCurrSeq, m_viSeqStart.Size(), m_iuactCurr, m_vquact.Size(), m_viMarks.Size(), m_nDepth);
	::OutputDebugStringA(sta.Chars());
#endif//DEBUG_ACTION_HANDLER

	END_COM_METHOD(g_factActh, IID_IActionHandler);
}
示例#2
0
/*----------------------------------------------------------------------------------------------
	${IActionHandler#StartSeq}
----------------------------------------------------------------------------------------------*/
STDMETHODIMP ActionHandler::StartSeq(BSTR bstrUndo, BSTR bstrRedo, IUndoAction * puact)
{
	BEGIN_COM_METHOD;
	ChkComBstrArg(bstrUndo);
	ChkComBstrArg(bstrRedo);
	ChkComArgPtr(puact);

	if (m_fUndoOrRedoInProgress)
		return S_OK;

	BeginUndoTask(bstrUndo, bstrRedo);
	// Add the current action.
	AddActionAux(puact);
	EndUndoTask();

#ifdef DEBUG_ACTION_HANDLER
	StrAnsi sta(bstrUndo);
	sta.Replace(0, 0, "StartSeq:");
	sta.FormatAppend(" m_iCurrSeq=%d, m_viSeqStart=%d, m_iuactCurr=%d, m_vquact=%d, m_viMarks=%d, m_nDepth=%d\n",
		m_iCurrSeq, m_viSeqStart.Size(), m_iuactCurr, m_vquact.Size(), m_viMarks.Size(), m_nDepth);
	::OutputDebugStringA(sta.Chars());
#endif//DEBUG_ACTION_HANDLER

	END_COM_METHOD(g_factActh, IID_IActionHandler);
}
示例#3
0
/*----------------------------------------------------------------------------------------------
	Open a main window on a particular object in a particular database on a particular field
	in a particular object using a particular view.
	Will fail if the specified tool cannot handle the specified top-level object.
	Returns a value which can be used to identify the particular window in subsequent calls.
	@param bstrServerName Name of the MSDE/SQLServer computer.
	@param bstrDbName Name of the database.
	@param hvoLangProj Which languate project within the database.
	@param hvoMainObj The top-level object on which to open the window.
	@param encUi The user-interface writing system.
	@param nTool A tool-dependent identifier of which tool to use.
	@param nParam Another tool-dependent parameter.
	@param prghvo Pointer to an array of object ids.
	@param chvo Number of object ids in prghvo.
	@param prgflid Pointer to an array of flids.
	@param cflid Number of flids in prgflid.
	@param ichCur Cursor offset from beginning of field.
	@param nView The view to display when showing the first object. Use -1 to use the first
		data entry view.
	@param ppidNew Process id of the new main window's process.
	@param phtool Handle to the newly created window.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP AfFwTool::NewMainWndWithSel(BSTR bstrServerName, BSTR bstrDbName, int hvoLangProj,
	int hvoMainObj, int encUi, int nTool, int nParam, const HVO * prghvo, int chvo,
		const int * prgflid, int cflid, int ichCur, int nView, int * ppidNew, long * phtool)
{
	BEGIN_COM_METHOD
	ChkComBstrArg(bstrServerName);
	ChkComBstrArg(bstrDbName);
	ChkComArrayArg(prghvo, chvo);
	ChkComArrayArg(prgflid, cflid);
	ChkComOutPtr(ppidNew);
	ChkComOutPtr(phtool);

	const CLSID * pclsid = AfApp::Papp()->GetAppClsid();
	DWORD dwRegister = 0;
	if (pclsid)
	{
		// Check to see if the application is already running.
		IRunningObjectTablePtr qrot;
		CheckHr(::GetRunningObjectTable(0, &qrot));
		IMonikerPtr qmnk;
		CheckHr(::CreateClassMoniker(*pclsid, &qmnk));
		IUnknownPtr qunk;
		IFwToolPtr qtool;
		if (SUCCEEDED(qrot->GetObject(qmnk, &qunk)))
		{
			if (SUCCEEDED(qunk->QueryInterface(IID_IFwTool, (void **)&qtool)) &&
				qtool.Ptr() != this)
			{
				// The document is already open in another process, so create a new
				// window in that process.
				qtool->NewMainWndWithSel(bstrServerName, bstrDbName, hvoLangProj, hvoMainObj,
					encUi, nTool, nParam, prghvo, chvo, prgflid, cflid, ichCur, nView,
					ppidNew, phtool);
				// After we create the new window in the other process, we exit here.
				// When the IFwTool pointer pointing to 'this' goes out of scope, the
				// second process (if it was launched from Windows Explorer or the
				// command line) will shut down automatically.
				return S_OK;
			}
		}
		else
		{
			// Note: ROTFLAGS_ALLOWANYCLIENT causes an error on Win2K (The class is
			// configured to run as a security ID different from the caller).
			CheckHr(qrot->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, this, qmnk,
				&dwRegister));
		}
	}
	AfApp::Papp()->NewMainWndWithSel(bstrServerName, bstrDbName, hvoLangProj, hvoMainObj,
		encUi, nTool, nParam, prghvo, chvo, prgflid, cflid, ichCur, nView, dwRegister);
	// The handle we return is actually the hwnd of the top-level window.
	// ENHANCE JohnT: we should probably make htool a long...
	*phtool = (long)(AfApp::Papp()->GetCurMainWnd()->Hwnd());
	if (ppidNew)
		*ppidNew = (int)::GetCurrentProcessId();

	return S_OK;

	END_COM_METHOD(g_fact, IID_IFwTool);
}
示例#4
0
/*----------------------------------------------------------------------------------------------
	Close any windows associated with a database, save the database, clear all caches, and
	shutdown the connection to the database.
	@param bstrSvrName Name of the server hosting the database.
	@param bstrDbName Name of the database to close.
	@param fOkToClose True to close the application if there are no further connections after
		the requested connection is closed. False leaves the application open.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP AfFwTool::CloseDbAndWindows(BSTR bstrSvrName, BSTR bstrDbName, ComBool fOkToClose)
{
	BEGIN_COM_METHOD
	ChkComBstrArg(bstrSvrName);
	ChkComBstrArg(bstrDbName);

	OLECHAR * pszDb = bstrDbName ? bstrDbName : L"";
	OLECHAR * pszSvr = bstrSvrName ? bstrSvrName : L"";
	AfApp::Papp()->CloseDbAndWindows(pszDb, pszSvr, (bool)fOkToClose);

	return S_OK;

	END_COM_METHOD(g_fact, IID_IFwTool);
}
示例#5
0
/*----------------------------------------------------------------------------------------------
 Sets the name of the class that this is a virtual property of. Normally set by
 whatever creates the handler. The cache does not call this, so it may be
 left unimplemented if there is a more convenient way to initialize the
 property.
---------------------------------------------------------------------------------------------*/
STDMETHODIMP VwBaseVirtualHandler::put_ClassName(BSTR bstr)
{
    BEGIN_COM_METHOD;
    ChkComBstrArg(bstr)
    m_stuClass.Assign(bstr, BstrLen(bstr));
    END_COM_METHOD(g_fact, IID_IVwVirtualHandler);
}
示例#6
0
/*----------------------------------------------------------------------------------------------
	Generate the sort key as a BSTR
----------------------------------------------------------------------------------------------*/
STDMETHODIMP LgUnicodeCollater::get_SortKey(BSTR bstrValue, LgCollatingOptions colopt,
	BSTR * pbstrKey)
{
	BEGIN_COM_METHOD
	ChkComBstrArg(bstrValue);
	ChkComOutPtr(pbstrKey);

	HRESULT hr;
	int cchw;
	*pbstrKey = NULL;
	// Passing 0 and null just produces a length
	IgnoreHr(hr = SortKeyRgch(bstrValue, BstrLen(bstrValue), colopt, 0, NULL, &cchw));
	if (FAILED(hr))
		return hr;

	BSTR bstrOut;
	bstrOut = SysAllocStringLen(NULL, cchw);
	if (!bstrOut)
		return E_OUTOFMEMORY;
	IgnoreHr(hr = SortKeyRgch(bstrValue, BstrLen(bstrValue), colopt, cchw, bstrOut, &cchw));
	if (FAILED(hr))
	{
		SysFreeString(bstrOut);
		return hr;
	}
	*pbstrKey = bstrOut;
	END_COM_METHOD(g_fact, IID_ILgCollatingEngine);
}
示例#7
0
/*----------------------------------------------------------------------------------------------
	Generate the sort key as a BSTR
----------------------------------------------------------------------------------------------*/
STDMETHODIMP LgIcuCollator::get_SortKey(BSTR bstrValue, LgCollatingOptions colopt,
	BSTR * pbstrKey)
{
	BEGIN_COM_METHOD
	ChkComBstrArg(bstrValue);
	ChkComOutPtr(pbstrKey);

	return E_NOTIMPL;

	END_COM_METHOD(g_fact, IID_ILgCollatingEngine);
}
示例#8
0
/*----------------------------------------------------------------------------------------------
	Do a direct string comparison.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP LgUnicodeCollater::Compare(BSTR bstrValue1, BSTR bstrValue2,
	LgCollatingOptions colopt, int * pnVal)
{
	BEGIN_COM_METHOD
	ChkComBstrArg(bstrValue1);
	ChkComBstrArg(bstrValue2);
	ChkComOutPtr(pnVal);

	HRESULT hr;

	int cchw1;
	int cchw2;

	IgnoreHr(hr = SortKeyRgch(bstrValue1, BstrLen(bstrValue1), colopt, 0, NULL, &cchw1));
	if (FAILED(hr))
		return hr;
	IgnoreHr(hr = SortKeyRgch(bstrValue2, BstrLen(bstrValue2), colopt, 0, NULL, &cchw2));
	if (FAILED(hr))
		return hr;

	OLECHAR * pchKey1 = (OLECHAR *) _alloca(cchw1 * isizeof(OLECHAR));
	OLECHAR * pchKey2 = (OLECHAR *) _alloca(cchw2 * isizeof(OLECHAR));

	IgnoreHr(hr = SortKeyRgch(bstrValue1, BstrLen(bstrValue1), colopt, cchw1, pchKey1, &cchw1));
	if (FAILED(hr))
		return hr;
	IgnoreHr(hr = SortKeyRgch(bstrValue2, BstrLen(bstrValue2), colopt, cchw2, pchKey2, &cchw2));
	if (FAILED(hr))
		return hr;
	int nVal = u_strncmp(pchKey1, pchKey2, min(cchw1, cchw2));
	if (!nVal)
	{
		// equal as far as length of shortest key
		if (BstrLen(bstrValue1) < BstrLen(bstrValue2))
			nVal = -1;
		else if (BstrLen(bstrValue1) > BstrLen(bstrValue2))
			nVal = 1;
	}
	*pnVal = nVal;
	END_COM_METHOD(g_fact, IID_ILgCollatingEngine);
}
示例#9
0
/*----------------------------------------------------------------------------------------------
	The user clicked on the object.

	@param pguid Pointer to a database object's assigned GUID.
	@param hvoOwner The database ID of the object.
	@param tag Identifier used to select one particular property of the object.
	@param ptss Pointer to an ITsString COM object containing a string that embeds a link to the
					object.
	@param ichObj Offset in the string to the pseudo-character that represents the object link.

	@return S_OK, E_POINTER, E_INVALIDARG, or E_FAIL.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP CleRecVc::DoHotLinkAction(BSTR bstrData, HVO hvoOwner, PropTag tag,
	ITsString * ptss, int ichObj)
{
	BEGIN_COM_METHOD;
	ChkComBstrArg(bstrData);
	ChkComArgPtr(ptss);

	// TODO (DarrellZ): This is currently not called because something else is handling the
	// click.
	return SuperClass::DoHotLinkAction(bstrData, hvoOwner, tag, ptss, ichObj);

	END_COM_METHOD(g_fact2, IID_IVwViewConstructor)
}
示例#10
0
/*----------------------------------------------------------------------------------------------
	Initialize the string crawler / database fixup process.

	@param bstrServer Name of the database server.
	@param bstrDatabase Name of the database.
	@param pstrmLog Optional output stream for logging (may be NULL).
	@param hvoRootObj Database id of the program's root object.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP FwDbMergeStyles::Initialize(BSTR bstrServer, BSTR bstrDatabase, IStream * pstrmLog,
	int hvoRootObj, const GUID * pclsidApp)
{
	BEGIN_COM_METHOD;
	ChkComBstrArg(bstrServer);
	ChkComBstrArg(bstrDatabase);
	ChkComArgPtrN(pstrmLog);
	ChkComArgPtr(pclsidApp);

	m_hvoRoot = hvoRootObj;
	m_pclsidApp = pclsidApp;
	StrUni stuServer(bstrServer);
	StrUni stuDatabase(bstrDatabase);
	m_qprog.Create();
	IAdvInd3Ptr qadvi3;
	m_qprog->QueryInterface(IID_IAdvInd3, (void **)&qadvi3);
	// Note that the set of styles is different for each program.
	if (!Init(stuServer, stuDatabase, pstrmLog, qadvi3))
	{
		Terminate(m_hvoRoot);
		ThrowHr(WarnHr(E_FAIL));
	}
	END_COM_METHOD(g_fact, IID_IFwDbMergeStyles);
}
示例#11
0
// Initialize the root resource bundle. The path may be null to use the standard
// FieldWorks ICU data directory.
STDMETHODIMP LgIcuResourceBundle::Init(BSTR bstrPath, BSTR bstrLocale)
{
	BEGIN_COM_METHOD
	ChkComBstrArgN(bstrPath);
	ChkComBstrArg(bstrLocale);
	StrUtil::InitIcuDataDir();
	StrUni stuDir;
	UnicodeString usDir;
	if (bstrPath)
		stuDir = bstrPath;
		// Otherwise let ICU figure out the right directory
	usDir = stuDir.Chars();

	UErrorCode uerr = U_ZERO_ERROR;
	StrAnsi staLocale(bstrLocale);
	ResourceBundle rbt(usDir, Locale(staLocale.Chars()), uerr);
	if (U_FAILURE(uerr))
		ThrowHr(E_FAIL);
	m_rb = rbt;
	END_COM_METHOD(g_factRb, IID_ILgIcuResourceBundle);
}
示例#12
0
/*----------------------------------------------------------------------------------------------
	Return the text string that gets shown to the user when this object needs to be displayed.
	This is the method for displaying the name of a single reference. This view shows the
	name for an RnGenericRec consisting of the type of record, hyphen, title, hyphen,
	creation date. "Subevent - Fishing for pirana - 3/22/2001"

	@param pguid Pointer to a database object's assigned GUID.
	@param pptss Address of a pointer to an ITsString COM object used for returning the text
					string.

	@return S_OK, E_POINTER, or E_FAIL.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP CleRecVc::GetStrForGuid(BSTR bstrGuid, ITsString ** pptss)
{
	Assert(false);  // rework

	BEGIN_COM_METHOD;
	ChkComBstrArg(bstrGuid);
	ChkComOutPtr(pptss);

	if (BstrLen(bstrGuid) != 8)
		ReturnHr(E_INVALIDARG);

	CleMainWnd * pcmw = dynamic_cast<CleMainWnd *>(AfApp::Papp()->GetCurMainWnd());
	AssertPtr(pcmw);
	CleLpInfo * plpi = dynamic_cast<CleLpInfo *>(pcmw->GetLpInfo());
	AssertPtr(plpi);

	HVO hvo = plpi->GetDbInfo()->GetIdFromGuid((GUID *)bstrGuid);

	CustViewDaPtr qcvd;
	plpi->GetDataAccess(&qcvd);
	AssertPtr(qcvd);
	int clid;
	HVO hvoOwn;
	int64 ntim;
	ITsStringPtr qtssTitle;
	CheckHr(qcvd->get_IntProp(hvo, kflidCmObject_Class, &clid));
	CheckHr(qcvd->get_ObjectProp(hvo, kflidCmObject_Owner, &hvoOwn));
			// REVIEW KenZ(RandyR) Whey are DN flids in this app?
	CheckHr(qcvd->get_TimeProp(hvo, kflidRnGenericRec_DateCreated, &ntim));
	CheckHr(qcvd->get_StringProp(hvo, kflidRnGenericRec_Title, &qtssTitle));

	int stid;
			// REVIEW KenZ(RandyR) Whey are DN flids in this app?
	if (clid == kclidRnEvent)
	{
		if (pcmw->GetRootObj() == hvoOwn)
			stid = kstidEvent;
		else
			stid = kstidSubevent;
	}
	else if (clid == kclidRnAnalysis)
	{
		if (pcmw->GetRootObj() == hvoOwn)
			stid = kstidAnalysis;
		else
			stid = kstidSubanalysis;
	}
	StrUni stu(stid);
	StrUni stuSep(kstidSpHyphenSp);

	ITsStrFactoryPtr qtsf;
	ITsIncStrBldrPtr qtisb;
	qtsf.CreateInstance(CLSID_TsStrFactory);
	CheckHr(qtsf->GetIncBldr(&qtisb));
	CheckHr(qtisb->Append(stu.Bstr()));

	CheckHr(qtisb->Append(stuSep.Bstr()));
	CheckHr(qtisb->AppendTsString(qtssTitle)); // The title.
	CheckHr(qtisb->Append(stuSep.Bstr()));
	// Leave the date blank if a date doesn't exist.
	if (ntim)
	{
		// Convert the date to a system date.
		SilTime tim = ntim;
		SYSTEMTIME stim;
		stim.wYear = (unsigned short) tim.Year();
		stim.wMonth = (unsigned short) tim.Month();
		stim.wDay = (unsigned short) tim.Date();

		// Then format it to a time based on the current user locale.
		achar rgchDate[50]; // Tuesday, August 15, 2000		mardi 15 août 2000
		::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &stim, NULL, rgchDate, 50);
		stu = rgchDate;
		CheckHr(qtisb->Append(stu.Bstr()));
	}
	CheckHr(qtisb->GetString(pptss));

	return S_OK;

	END_COM_METHOD(g_fact2, IID_IVwViewConstructor)
}