Esempio n. 1
0
/*----------------------------------------------------------------------------------------------
	Close the current editor, saving changes that were made. hwnd is the editor hwnd.
	@param fForce True if we want to force the editor closed without making any
		validity checks or saving any changes.
----------------------------------------------------------------------------------------------*/
void AfDeFeEdBoxBut::EndEdit(bool fForce)
{
	SuperClass::EndEdit(fForce);
	if (!fForce)
	{
		if (!SaveEdit())
		{
			Assert(false); // Should have called IsOkToClose() first.
		}
		EndTempEdit();
		SaveFullCursorInfo();
	}
	// Get rid of the edit box and button.
	::DestroyWindow(m_hwnd);
	m_hwnd = 0;
	m_hwndButton = 0;
}
Esempio n. 2
0
/*----------------------------------------------------------------------------------------------
	Save changes that have been made to the current editor.
	which should happen when we use File...Save, but for some reason we aren't getting there.
	There is a lot of overlap with EndEdit that should be eliminated.
----------------------------------------------------------------------------------------------*/
bool AfDeFeSt::SaveEdit()
{
	if (!SuperClass::SaveEdit())
		return false;
	SaveFullCursorInfo();
	if (m_qvcdMissing)
	{
		ComBool fDirty;
		ISilDataAccessPtr qsdaTemp;
		CheckHr(m_qvcdMissing->QueryInterface(IID_ISilDataAccess, (void **)&qsdaTemp));
		qsdaTemp->IsDirty(&fDirty);
		if (!fDirty)
			return true;
		// The text got edited. So, make a real text and copy the relevant info.
		// First get the paragraph list
		HvoVec vhvoParas;
		int chvoParas;
		CheckHr(qsdaTemp->get_VecSize(m_hvoText, kflidStText_Paragraphs, &chvoParas));
		int ihvo; // used twice
		for (ihvo = 0; ihvo < chvoParas; ihvo++)
		{
			HVO hvoPara;
			CheckHr(qsdaTemp->get_VecItem(m_hvoText, kflidStText_Paragraphs, ihvo,
				&hvoPara));
			vhvoParas.Push(hvoPara);
		}
		// Actually, we may have had a real text...if so, skip this step
		if (m_hvoText < 0)
		{
			m_qcvd->MakeNewObject(kclidStText, m_hvoObj, m_flid, -2, &m_hvoText);
		}
		else
		{
			// Check if the record has been edited by someone else since we first loaded data.
			HRESULT hrTemp;
			if ((hrTemp = m_qcvd->CheckTimeStamp(m_hvoText)) != S_OK)
			{
				// If it was changed and the user does not want to overwrite it, perform a
				// refresh so the displayed field will revert to it's original value.
				// REVIEW KenZ (PaulP):  There may need to be a refresh call made here.  It's
				// difficult to know, however, since I haven't tracked down when this method
				// actually gets called.
				m_fDirty = false;
				return true;
			}
		}

		// Now make real paragraph objects and set their properties.
		for (ihvo = 0; ihvo < chvoParas; ihvo++)
		{
			HVO hvoPara = vhvoParas[ihvo];
			ITsStringPtr qtss;
			ITsTextPropsPtr qttp;
			IUnknownPtr qunkTtp;
			CheckHr(qsdaTemp->get_UnknownProp(hvoPara, kflidStStyle_Rules, &qunkTtp));
			CheckHr(qunkTtp->QueryInterface(IID_ITsTextProps, (void **) &qttp));
			CheckHr(qsdaTemp->get_StringProp(hvoPara, kflidStTxtPara_Contents,
				&qtss));
			CheckHr(m_qcvd->MakeNewObject(kclidStTxtPara, m_hvoText, kflidStText_Paragraphs,
				ihvo, &hvoPara));
			if (qttp)
				CheckHr(m_qcvd->SetUnknown(hvoPara, kflidStPara_StyleRules, qttp));
			CheckHr(m_qcvd->SetString(hvoPara, kflidStTxtPara_Contents, qtss));
		}
		m_qvcdMissing.Clear();
		// Update the root object to point at the real text we just made.
		int frag = kfrText;
		IVwViewConstructor * pvvc = m_qstvc;
		CheckHr(m_qrootb->putref_DataAccess(m_qcvd));
		CheckHr(m_qrootb->SetRootObjects(&m_hvoText, &pvvc, &frag,
			GetLpInfo()->GetAfStylesheet(), 1));
		CheckHr(m_qcvd->PropChanged(m_qrootb, kpctNotifyAllButMe, m_hvoObj, m_flid, 0,
					1, 1));
	}
	m_fDirty = false;
	return true;
}