コード例 #1
0
bool SaxHandler::startElement( const QString &ns, const QString &ln, const QString &qn,
			       const QXmlAttributes &attrs )
{
    if ( !jshandler.isValid() ) {
	error = ErrorNoHandler;
	return false;
    }

    KJS::Identifier funName("startElement");
    if ( !jshandler.hasProperty(exec, funName) )
	return QXmlDefaultHandler::startElement( ns, ln, qn, attrs );

    KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
    if ( !fun.implementsCall() ) {
	error = ErrorNotCallable;
	return false;
    }

    KJS::List args;
    args.append( KJS::String(ns) );
    args.append( KJS::String(ln) );
    args.append( KJS::String(qn) );
    // TODO: XmlAttributes not yet supported

    KJS::Value ret = fun.call( exec, jshandler, args );
    return ret.toBoolean( exec );
}
コード例 #2
0
KJS::Value KJSEmbedPart::callMethod( const QString & methodName, const KJS::List & args ) const
{
  KJS::ExecState *exec = js->globalExec();
  KJS::Identifier id = KJS::Identifier( KJS::UString(methodName.latin1() ));
  KJS::Object obj = js->globalObject();
  KJS::Object fun = obj.get(exec, id ).toObject( exec );
  KJS::Value retValue;
  if ( !fun.implementsCall() )
  {
  	// We need to create an exception here...
  }
  else
        retValue = fun.call(exec, obj, args);
	kdDebug( 80001 ) << "Returned type is: " << retValue.type() << endl;  
	if( exec->hadException() )
	{
		kdWarning( 80001 ) << "Got error: " << exec->exception().toString(exec).qstring() << endl;
		return exec->exception();
	}
	else
	{
		if( retValue.type() == 1 && retValue.type() == 0)
		{
			kdDebug( 80001 ) << "Got void return type. " << endl;
			return KJS::Null();
		}
	}
  return retValue;
}
コード例 #3
0
void KstBindTimeInterpretation::setActive(KJS::ExecState *exec, const KJS::Value& value) {
  if (!_d) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return;
  }
  if (value.type() != KJS::BooleanType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstWriteLocker wl(_d->_d);
  bool isIt;
  KstAxisInterpretation interp;
  KstAxisDisplay disp;
  if (_d->_xAxis) {
    _d->_d->getXAxisInterpretation(isIt, interp, disp);
    _d->_d->setXAxisInterpretation(value.toBoolean(exec), interp, disp);
  } else {
    _d->_d->getYAxisInterpretation(isIt, interp, disp);
    _d->_d->setYAxisInterpretation(value.toBoolean(exec), interp, disp);
  }
  _d->_d->setDirty();
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
}
コード例 #4
0
void KstBindCubicBezier::setLineStyle(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned w = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(w)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstViewBezierPtr d = makeBezier(_d);
  if (d) {
    KstWriteLocker wl(d);
    switch (w) {
      case 0:
        d->setPenStyle(Qt::SolidLine);
        break;
      case 1:
        d->setPenStyle(Qt::DashLine);
        break;
      case 2:
        d->setPenStyle(Qt::DotLine);
        break;
      case 3:
        d->setPenStyle(Qt::DashDotLine);
        break;
      case 4:
        d->setPenStyle(Qt::DashDotDotLine);
        break;
      default:
        return;
    }
    KstApp::inst()->paintAll(P_PAINT);
  }
}
コード例 #5
0
void KstBindImage::setMap(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned i = 0;

  if (value.type() != KJS::NumberType || !value.toUInt32(i)) {
    return createPropertyTypeError(exec);
  }

  if (i > 2) {
    return createPropertyRangeError(exec);
  }

  KstImagePtr d = makeImage(_d);
  if (d) {
    KstWriteLocker wl(d);
    switch (i) {
      case 0:
        d->setHasContourMap(false);
        d->setHasColorMap(true);
        break;
      case 1:
        d->setHasContourMap(true);
        d->setHasColorMap(false);
        break;
      case 2:
        d->setHasContourMap(true);
        d->setHasColorMap(true);
        break;
    }
  }
}
コード例 #6
0
void KstBindLine::setCapStyle(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned w = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(w)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstViewLinePtr d = makeLine(_d);
  if (d) {
    KstWriteLocker wl(d);
    switch (w) {
      case 0:
        d->setCapStyle(Qt::FlatCap);
        break;
      case 1:
        d->setCapStyle(Qt::SquareCap);
        break;
      case 2:
        d->setCapStyle(Qt::RoundCap);
        break;
      default:
        return;
    }
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
コード例 #7
0
KJS::List KJSEmbedPart::constructorList() const
{
    KJS::List items;

    KJS::Object obj = js->globalObject();
    KJS::ExecState *exec = js->globalExec();

    KJS::ReferenceList l = obj.propList( exec );
    KJS::ReferenceListIterator propIt = l.begin();
    while ( propIt != l.end() ) {

	KJS::Identifier name = propIt->getPropertyName( exec );

	if ( obj.hasProperty( exec, name ) ) {
	    KJS::Value v = obj.get( exec, name );
	    KJS::Object vobj = v.toObject( exec );

	    if ( vobj.implementsConstruct() )
		items.append( KJS::String( name.ustring() ) );
	}

	propIt++;
    }

    return items;
}
コード例 #8
0
void KstBindLine::setLineStyle(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned w = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(w)) {
    return createPropertyTypeError(exec);
  }
  KstViewLinePtr d = makeLine(_d);
  if (d) {
    KstWriteLocker wl(d);
    switch (w) {
      case 0:
        d->setPenStyle(Qt::SolidLine);
        break;
      case 1:
        d->setPenStyle(Qt::DashLine);
        break;
      case 2:
        d->setPenStyle(Qt::DotLine);
        break;
      case 3:
        d->setPenStyle(Qt::DashDotLine);
        break;
      case 4:
        d->setPenStyle(Qt::DashDotDotLine);
        break;
      default:
        return createPropertyRangeError(exec);
    }
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
コード例 #9
0
void KstBindPoint::setX(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::NumberType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  _x = value.toNumber(exec);
}
コード例 #10
0
void KstBindDocument::setName(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::StringType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstApp::inst()->document()->setTitle(value.toString(exec).qstring());
}
コード例 #11
0
void KstBindSize::setW(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned int w = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(w)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  _sz.setWidth(w);
}
コード例 #12
0
void KstBindWindow::setWindowName(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::StringType) {
    return createPropertyTypeError(exec);
  }
  KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(value.toString(exec).qstring()));
  if (w) {
    return createPropertyGeneralError(exec, i18n("A window of this name already exists."));
  }
  _d->setCaption(value.toString(exec).qstring());
}
コード例 #13
0
void KstBindPlot::setTopLabel(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::StringType) {
    return createPropertyTypeError(exec);
  }
  Kst2DPlotPtr d = makePlot(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->topLabel()->setText(value.toString(exec).qstring());
  }
}
コード例 #14
0
void KstBindTimeInterpretation::setOutput(KJS::ExecState *exec, const KJS::Value& value) {
  if (!_d) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
    exec->setException(eobj);
    return;
  }
  unsigned i = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(i)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstWriteLocker wl(_d->_d);
  bool isIt;
  KstAxisInterpretation interp;
  KstAxisDisplay disp, newDisp;
  switch (i) {
    default:
    case 0:
      newDisp = AXIS_DISPLAY_DDMMYYHHMMSS_SS;
      break;
    case 1:
      newDisp = AXIS_DISPLAY_YYMMDDHHMMSS_SS;
      break;
    case 2:
      newDisp = AXIS_DISPLAY_JD;
      break;
    case 3:
      newDisp = AXIS_DISPLAY_MJD;
      break;
    case 4:
      newDisp = AXIS_DISPLAY_RJD;
      break;
    case 5:
      newDisp = AXIS_DISPLAY_YEAR;
      break;
    case 6:
      newDisp = AXIS_DISPLAY_KDE_SHORTDATE;
      break;
    case 7:
      newDisp = AXIS_DISPLAY_KDE_LONGDATE;
      break;
  }
    
  if (_d->_xAxis) {
    _d->_d->getXAxisInterpretation(isIt, interp, disp);
    _d->_d->setXAxisInterpretation(isIt, interp, newDisp);
  } else {
    _d->_d->getYAxisInterpretation(isIt, interp, disp);
    _d->_d->setYAxisInterpretation(isIt, interp, newDisp);
  }
  _d->_d->setDirty();
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
}
コード例 #15
0
void KstBindLegend::setTitle(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::StringType) {
    return createPropertyTypeError(exec);
  }
  KstViewLegendPtr d = makeLegend(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setTitle(value.toString(exec).qstring());
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
コード例 #16
0
void KstBindPlot::setTied(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::BooleanType) {
    return createPropertyTypeError(exec);
  }
  Kst2DPlotPtr d = makePlot(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setTied(value.toBoolean(exec));
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
コード例 #17
0
void KstBindCurve::setHasBars(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::BooleanType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setHasBars(value.toBoolean(exec));
  }
}
コード例 #18
0
void KstBindPowerSpectrum::setRUnits(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::StringType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstPSDPtr d = makePSD(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setRUnits(value.toString(exec).qstring());
  }
}
コード例 #19
0
void KstBindPowerSpectrum::setFrequency(KJS::ExecState *exec, const KJS::Value& value) {
  if (value.type() != KJS::NumberType) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstPSDPtr d = makePSD(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setFreq(value.toNumber(exec));
  }
}
コード例 #20
0
void KstBindLegend::setFontSize(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned int i = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(i)) {
    return createPropertyTypeError(exec);
  }
  KstViewLegendPtr d = makeLegend(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setFontSize(i);
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
コード例 #21
0
void KstBindPlotLabel::setFont(KJS::ExecState *exec, const KJS::Value& value) {
  if (!_d) {
    return createPropertyInternalError(exec);
  }
  if (value.type() != KJS::StringType) {
    return createPropertyTypeError(exec);
  }
  KstWriteLocker wl(_d);
  _d->topLabel()->setFontName(value.toString(exec).qstring());
  _d->setDirty();
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
}
コード例 #22
0
void KstBindLine::setWidth(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned w = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(w)) {
    return createPropertyTypeError(exec);
  }
  KstViewLinePtr d = makeLine(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setWidth(w);
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
コード例 #23
0
void KstBindLine::setTo(KJS::ExecState *exec, const KJS::Value& value) {
  KstBindPoint *imp = 0L;
  if (value.type() != KJS::ObjectType || !(imp = dynamic_cast<KstBindPoint*>(value.toObject(exec).imp()))) {
    return createPropertyTypeError(exec);
  }
  KstViewLinePtr d = makeLine(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setTo(QPoint(int(imp->_x), int(imp->_y)));
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
コード例 #24
0
void KstBindPowerSpectrum::setLength(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned val;
  if (value.type() != KJS::NumberType || !value.toUInt32(val)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstPSDPtr d = makePSD(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setLen(val);
  }
}
コード例 #25
0
static KJS::Object getObj(KJS::Interpreter *js, KJS::Value mightBeArray, int id) {
	KJS::ExecState *exec=js->globalExec();
    	KJS::Object constrs=mightBeArray.toObject(exec);
	KJS::Value constr;
	if (!exec->hadException()) {
		if (QString(constrs.classInfo()->className)=="Array") {
			kdDebug()<<"config page  constructor array detected"<<endl;
			constr=constrs.get(exec,id);
		} else constr=mightBeArray;
	
	}
	return constr.toObject(js->globalExec());
}
コード例 #26
0
void KstBindPlotLabel::setDataPrecision(KJS::ExecState *exec, const KJS::Value& value) {
  uint i = 0;
  if (!_d) {
    return createPropertyInternalError(exec);
  }
  if (value.type() != KJS::NumberType || !value.toUInt32(i)) {
    return createPropertyTypeError(exec);
  }
  KstWriteLocker wl(_d);
  _d->topLabel()->setDataPrecision(i);
  _d->setDirty();
  KstApp::inst()->paintAll(KstPainter::P_PAINT);
}
コード例 #27
0
static KJS::Object scopeWalker( KJS::ExecState *exec, const KJS::Object &root, const QString &objectString )
{
  KJS::Object returnObject = root;
  QStringList objects = QStringList::split(".", objectString);
  for( uint idx = 0; idx < objects.count(); ++idx)
  {
    KJS::Identifier id = KJS::Identifier( KJS::UString( objects[idx] ));
    KJS::Value newObject = returnObject.get(exec, id );
    if( newObject.isValid() )
    	returnObject = newObject.toObject(exec);
  }
  return returnObject;
}
コード例 #28
0
void KstBindCurve::setBarStyle(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned i = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(i)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setBarStyle(i);
  }
}
コード例 #29
0
void KstBindEllipse::setBorderWidth(KJS::ExecState *exec, const KJS::Value& value) {
  unsigned w = 0;
  if (value.type() != KJS::NumberType || !value.toUInt32(w)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstViewEllipsePtr d = makeEllipse(_d);
  if (d) {
    KstWriteLocker wl(d);
    d->setBorderWidth(w);
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
コード例 #30
0
QStringList KJSEmbedPart::constructorNames() const
{
    QStringList classes;

    KJS::List cons = constructorList();
    KJS::ListIterator it = cons.begin();
    while ( it != cons.end() ) {
	KJS::Value v = *it;
	classes += v.toString( js->globalExec() ).qstring();
	it++;
    }

    return classes;
}