Exemple #1
0
/*----------------------------------------------------------------------------------------------
	Fix up the 'next' or 'basedOn' attributes in the styles, now that we have a complete
	list.
	Attribute:
		flid		- attribute to set
		hmhvostu	- map containing the values ofthe attribute
----------------------------------------------------------------------------------------------*/
void WpStylesheet::FixStyleReferenceAttrs(int flid, HashMap<HVO, StrUni> & hmhvostu)
{
	WpDaPtr wpda = dynamic_cast<WpDa *>(m_qsda.Ptr());

	//	Generate a list of all the style names.
	Vector<StrUni> vstuNames;
	int cst;
	CheckHr(m_qsda->get_VecSize(khvoText, kflidStText_Styles, &cst));
	Assert(cst == m_vhcStyles.Size());
	for (int ist = 0; ist < cst; ist++)
	{
		SmartBstr sbstr;
		CheckHr(wpda->get_UnicodeProp(m_vhcStyles[ist].hvo, kflidStStyle_Name, &sbstr));
		vstuNames.Push(StrUni(sbstr.Chars()));
	}

	//	For each style, if it has a value in the map, find the corresponding style
	//	and set the attribute.
	for (int ist = 0; ist < cst; ist++)
	{
		HVO hvo = m_vhcStyles[ist].hvo;
		StrUni stuRef;
		if (hmhvostu.Retrieve(hvo, &stuRef))
		{
			for (int istTmp = 0; istTmp < cst; istTmp++)
			{
				if (vstuNames[istTmp] == stuRef)
				{
					CheckHr(wpda->CacheObjProp(hvo, flid, m_vhcStyles[istTmp].hvo));
					break;
				}
			}
		}
	}
}
Exemple #2
0
/*----------------------------------------------------------------------------------------------
	If there are no settings for this feature, fill in with the default boolean settings.
----------------------------------------------------------------------------------------------*/
void GdlFeatureDefn::FillInBoolean(GrcSymbolTable * psymtbl)
{
	if (m_fStdLang)
		return;

	bool fBoolean = false;

	if (m_vpfset.Size() == 0)
	{
		GdlFeatureSetting * pfsetFalse = new GdlFeatureSetting();
		pfsetFalse->CopyLineAndFile(*this);
		pfsetFalse->m_nValue = 0;
		pfsetFalse->m_fHasValue = true;
		pfsetFalse->m_staName = StrAnsi("false");
		pfsetFalse->m_vextname.Push(GdlExtName(StrUni("False"), LG_USENG));
		m_vpfset.Push(pfsetFalse);

		GdlFeatureSetting * pfsetTrue = new GdlFeatureSetting();
		pfsetTrue->CopyLineAndFile(*this);
		pfsetTrue->m_nValue = 1;
		pfsetTrue->m_fHasValue = true;
		pfsetTrue->m_staName = StrAnsi("true");
		pfsetTrue->m_vextname.Push(GdlExtName(StrUni("True"), LG_USENG));
		m_vpfset.Push(pfsetTrue);

		if (!m_fDefaultSet)
			m_nDefault = 0;
		m_fDefaultSet = true;

		fBoolean = true;

	}
	else if (m_vpfset.Size() == 2)
	{
		fBoolean = ((m_vpfset[0]->m_nValue == 0 && m_vpfset[1]->m_nValue == 1)
			|| (m_vpfset[0]->m_nValue == 1 && m_vpfset[1]->m_nValue == 0));
	}

	if (fBoolean)
	{
		// Mark the expression type as boolean, not number.
		Symbol psymFeat = psymtbl->FindSymbol(m_staName);
		Assert(psymFeat->ExpType() == kexptNumber);
		psymFeat->SetExpType(kexptBoolean);
	}
}
Exemple #3
0
void ViewTest2::WrapOnTyping(char *pchinput, int _cchBackspace, int _cchDelForward,
							 char *_chFirst, RECT _rcSrc, RECT _rcDst)
{
	OLECHAR oleChar = _chFirst[0];
	SmartBstr _bstrInput = StrUni(pchinput).Bstr();

	m_psts->OutputFormat("  FUNCTION: OnTyping(m_qvg, \"%s\", %d, %d, '%s', {%d,%d,%d,%d}, "
		"{%d,%d,%d,%d})\n", pchinput, _cchBackspace, _cchDelForward, _chFirst, _rcSrc.left,
		_rcSrc.top, _rcSrc.right, _rcSrc.bottom, _rcDst.left, _rcDst.top, _rcDst.right,
		_rcDst.bottom);
	CheckHr(m_qrootb->OnTyping(m_qvg, _bstrInput, _cchBackspace, _cchDelForward, oleChar,
		_rcSrc, _rcDst));
}
Exemple #4
0
/*----------------------------------------------------------------------------------------------
	Convert the 16-bit Unicode string to UTF-8, returning the length in bytes of the UTF-8
	string.  Care is taken not to overflow the output buffer.

	@param rgchDst Pointer to an output array of (8-bit) characters.
	@param cchMaxDst Maximum number of (8-bit) characters that can be stored in rgchDst.
	@param rgchwSrc Pointer to an input array of wide (Unicode) characters.
	@param cchwSrc Number of wide characters in rgchwSrc.  This may be greater than the number
					of actual Unicode characters due to surrogate pairs.
	@param fXml Flag whether the output needs to have XML character code escapes for "<>&"".

	@return Number of characters required for the output buffer. If cchMaxDst is less than or
					equal to the return value, all of the output was written.
----------------------------------------------------------------------------------------------*/
int ConvertUtf16ToXmlUtf8(char * rgchDst, int cchMaxDst, const wchar * rgchwSrc, int cchwSrc,
	bool fXml)
{
	AssertArray(rgchDst, cchMaxDst);
	AssertArray(rgchwSrc, cchwSrc);

	int cchChar;
	char rgchChar[8];
	const char * prgchChar;
	const wchar * pchw;
	const wchar * pchwLim = rgchwSrc + cchwSrc;

	// TODO SteveMc(ShonK): This needs a better name. When you decide on hungarian tags for
	// the constants above use the same tag here.
	byte bFirstMark = 0;

	int cchDst = 0;

	for (pchw = rgchwSrc; pchw < pchwLim; )
	{
		ulong luChar = *pchw++;
		if (kSurrogateHighFirst <= luChar && luChar <= kSurrogateHighLast && pchw < pchwLim)
		{
			ulong luChar2 = *pchw;
			if (kSurrogateLowFirst <= luChar2 && luChar2 <= kSurrogateLowLast)
			{
				luChar -= kSurrogateHighFirst;
				luChar <<= kSurrogateShift;
				luChar += luChar2 - kSurrogateLowFirst;
				luChar += kSurrogateBase;
				++pchw;
			}
		}
		if (luChar > kUnicodeMax)
		{
			luChar = kReplacementChar;
		}

		prgchChar = NULL;

		if (luChar < kUtf8Min2)
		{
			if (fXml)
			{
				switch (luChar)
				{
				case '<':
					prgchChar = "&lt;";
					cchChar = 4;
					break;
				case '>':
					prgchChar = "&gt;";
					cchChar = 4;
					break;
				case '&':
					prgchChar = "&amp;";
					cchChar = 5;
					break;
				case '"':
					prgchChar = "&quot;";
					cchChar = 6;
					break;
				default:
					bFirstMark = kUtf8Flag1;
					cchChar = 1;
					break;
				}
			}
			else
			{
				bFirstMark = kUtf8Flag1;
				cchChar = 1;
			}
		}
		else if (luChar < kUtf8Min3)
		{
			bFirstMark = kUtf8Flag2;
			cchChar = 2;
		}
		else if (luChar < kUtf8Min4)
		{
			bFirstMark = kUtf8Flag3;
			cchChar = 3;
		}
		else if (luChar < kUtf8Min5)
		{
			bFirstMark = kUtf8Flag4;
			cchChar = 4;
		}
		else if (luChar < kUtf8Min6)
		{
			bFirstMark = kUtf8Flag5;
			cchChar = 5;
		}
		else
		{
			bFirstMark = kUtf8Flag6;
			cchChar = 6;
		}

		if (!prgchChar)
		{
			prgchChar = rgchChar;

			char * pch = &rgchChar[cchChar];

			switch (cchChar)
			{
			case 6:
				*--pch = (char)((luChar & kByteMask) | kByteMark);
				luChar >>= kByteShift;
				// fall through
			case 5:
				*--pch = (char)((luChar & kByteMask) | kByteMark);
				luChar >>= kByteShift;
				// fall through
			case 4:
				*--pch = (char)((luChar & kByteMask) | kByteMark);
				luChar >>= kByteShift;
				// fall through
			case 3:
				*--pch = (char)((luChar & kByteMask) | kByteMark);
				luChar >>= kByteShift;
				// fall through
			case 2:
				*--pch = (char)((luChar & kByteMask) | kByteMark);
				luChar >>= kByteShift;
				// fall through
			case 1:
				*--pch = (char)(luChar | bFirstMark);
				break;
			default:
				Assert(false);		// can't happen!!
			}
		}

		if (cchDst < cchMaxDst)
		{
			CopyItems(prgchChar, rgchDst + cchDst, Min(cchChar, cchMaxDst - cchDst));
		}
		else
		{
			// REVIEW: should we somehow signal an error on overflowing the output buffer?
			ThrowHr(E_OUTOFMEMORY, StrUni(L"BUFFER OVERFLOW in ConvertUtf16ToXmlUtf8()").Chars());
		}
		cchDst += cchChar;
	}