예제 #1
0
SOM_Scope any*  SOMLINK anyMethod(MemoryManagement *somSelf,  Environment *ev,
                                  any* inParameter, any** outParameter,
                                  any** inOutParameter)
{
    MemoryManagementData *somThis = MemoryManagementGetData(somSelf);
    MemoryManagementMethodDebug("MemoryManagement","anyMethod");

#if (defined(__MEMORY_MGMT_OBJECT_OWNED__) || defined(__MEMORY_MGMT_DUAL_OWNED__))
 /* Check to see if any of the parameters are currently allocated, in some
    instances, the server code may want to reuse the storage, but since this is a
    sample, the memeory will simply be freed and realloced */
    if (somThis->saveReturnAny != NULL) {
       SOMFree(somThis->saveReturnAny->_value);
       SOMFree(somThis->saveInAny);
       }
    if (somThis->saveInAny != NULL) {
       SOMFree(somThis->saveInAny->_value);
       SOMFree(somThis->saveInAny);
       }
    if (somThis->saveOutAny != NULL) {
       SOMFree(somThis->saveOutAny->_value);
       SOMFree(somThis->saveOutAny);
       }
    if (somThis->saveInOutAny != NULL) {
       SOMFree(somThis->saveInOutAny->_value);
       SOMFree(somThis->saveInOutAny);
       }
#endif

    *outParameter = new any;
    (*outParameter)->_type = tcNew(tk_long);
    long * tempLong = (long *)SOMMalloc(sizeof(long));
    *tempLong = 100;
    (*outParameter)->_value = (void *)tempLong;

    tempLong = (long *)(*inOutParameter)->_value;
    (*tempLong) *= 4;

    any * retVal = new any;
    retVal->_type = TypeCodeNew(tk_long);
    tempLong = (long *)SOMMalloc(sizeof(long));
    *tempLong = 10;
    retVal->_value = (void *)tempLong;

#if (defined(__MEMORY_MGMT_OBJECT_OWNED__) || defined(__MEMORY_MGMT_DUAL_OWNED__))
    /* Save pointers to the storage so that they can be freed or reused later */
    somThis->saveReturnAny = retVal;
    somThis->saveInAny = inParameter;
    somThis->saveOutAny = *outParameter;
    somThis->saveInOutAny = *inOutParameter;
#endif



    return (retVal);
}
예제 #2
0
QString validHtml(const QString &html, bool allowReplacement, QTextCursor *tc)
	{
	QDesktopWidget dw;
	ValidDocument oValidDocument(allowReplacement);

	QRectF qr = dw.availableGeometry();
	oValidDocument.setTextWidth(qr.width() / 2);
	oValidDocument.setDefaultStyleSheet(qApp->styleSheet());

	oValidDocument.setHtml(html);
	bool fIsValid = oValidDocument.isValid();

	QStringList qslAllowed = allowedSchemes();
	for (QTextBlock qtb = oValidDocument.begin(); qtb != oValidDocument.end(); qtb = qtb.next())
		{
		for (QTextBlock::iterator qtbi = qtb.begin(); qtbi != qtb.end(); ++qtbi)
			{
			const QTextFragment &qtf = qtbi.fragment();
			QTextCharFormat qcf = qtf.charFormat();
			if (! qcf.anchorHref().isEmpty())
				{
				QUrl url(qcf.anchorHref());
				if (! url.isValid() || ! qslAllowed.contains(url.scheme()))
					{
					QTextCharFormat qcfn = QTextCharFormat();
					QTextCursor qtc(&oValidDocument);
					qtc.setPosition(qtf.position(), QTextCursor::MoveAnchor);
					qtc.setPosition(qtf.position()+qtf.length(), QTextCursor::KeepAnchor);
					qtc.setCharFormat(qcfn);
					qtbi = qtb.begin();
					}
				}
			if (qcf.isImageFormat())
				{
				QTextImageFormat qtif = qcf.toImageFormat();
				QUrl url(qtif.name());
				if (! qtif.name().isEmpty() && ! url.isValid())
					fIsValid = false;
				}
			}
		}

	oValidDocument.adjustSize();
	QSizeF s = oValidDocument.size();

	if (!fIsValid || (s.width() > qr.width()) || (s.height() > qr.height())) {
		oValidDocument.setPlainText(html);
		oValidDocument.adjustSize();
		s = oValidDocument.size();

		if ((s.width() > qr.width()) || (s.height() > qr.height())) {
			QString errorMessage = "[[ Text object too large to display ]]";
			if (tc) {
				tc->insertText(errorMessage);
				return QString();
			} else {
				return errorMessage;
			}
		}
	}

	if (tc) {
		QTextCursor tcNew(&oValidDocument);
		tcNew.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
		tc->insertFragment(tcNew.selection());
		return QString();
	} else {
		return oValidDocument.toHtml();
	}
}
예제 #3
0
파일: tconst.c 프로젝트: hemmecke/aldor
void
tcNewSat1(TForm owner, AbLogic known, AbSyn ab0, TForm S, TForm T, AbSyn a)
{
	tcNew(TC_Satisfies, owner, ablogCopy(known), a, ab0, 2, S, T);
}