Example #1
0
/// converting <mtable> ... </mtable>
void CMathMLToTeX::mtableNode(QString &text)
{
  int sumCols = 0;

  if (text.contains("<mtr>"))
    {
      int posA = text.indexOf("<mtr>");
      int posB = text.indexOf("</mtr>");
      QString mtrText = text.mid(posA, posB - posA + 6);

      sumCols = mtrText.count("<mtd");
    }

  CStructureParser xmlParser(sumCols);
  QXmlSimpleReader xmlReader;

  xmlReader.setContentHandler(&xmlParser);

  QXmlInputSource xmlSource;
  xmlSource.setData(text);

  xmlReader.parse(xmlSource);

  text = xmlParser.getTeX();
}
Example #2
0
bool VOCatalogDataParser::parse(const QByteArray &data, QList<VOCatalogHeader> &catalogs, QList<VOCooSys> &cooSys, QList<QStringList> &dataOut)
{
  QXmlInputSource   xmlInputStream;
  QXmlSimpleReader  xml;

  if (data.isEmpty())
  {
    return false;
  }

  xmlInputStream.setData(data);

  xml.setContentHandler(this);
  xml.setErrorHandler(this);

  if (xml.parse(&xmlInputStream))
  {
    catalogs = m_list;
    cooSys = m_cooSys;
    dataOut = m_data;
    return true;
  }

  return false;
}
Example #3
0
int CRobLink::ReadSensors()
{
    char xml[4096];
    int n = port.recv_info(xml, 4096);
    if (n == -1) return n;

    //cerr << "ReadSensors: " << "\"" << xml << "\"";
    
    /* set source of xml document */
    QXmlInputSource source;
    source.setData(QString(xml));

    /* set parser handler */
    StructureParser handler(simParam.nBeacons);

    //cerr << "ReadSensors: nBeacons=" << simParam.nBeacons << "\n";

    /* parse xml document with handler */
    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);
    reader.parse(source);

    ///////////////////////////////////////////////////
    measures = *(handler.getMeasures());  
    //measures.showValues();
    ///////////////////////////////////////////////////
    
//    for(unsigned int i=0; i<5;i++)
//       if (measures.hearMessage[i]!=QString())
//           printf("ReadSensors: Message From %d: \"%s\"\n", i, measures.hearMessage[i].latin1());

    return n;
}
Example #4
0
bool StyleParser::parseStyleFile()
{
  QXmlSimpleReader reader;

  QXmlInputSource source;
  source.setData( mDocument->styles() );

  QString errorMsg;
  int errorLine, errorCol;

  QDomDocument document;
  if ( !document.setContent( &source, &reader, &errorMsg, &errorLine, &errorCol ) ) {
    qDebug( "%s at (%d,%d)", qPrintable( errorMsg ), errorLine, errorCol );
    return false;
  }

  const QDomElement documentElement = document.documentElement();
  QDomElement element = documentElement.firstChildElement();
  while ( !element.isNull() ) {
    if ( element.tagName() == QLatin1String( "styles" ) ) {
      if ( !parseAutomaticStyles( element ) )
        return false;
    } else if ( element.tagName() == QLatin1String( "automatic-styles" ) ) {
      if ( !parseAutomaticStyles( element ) )
        return false;
    } else if ( element.tagName() == QLatin1String( "master-styles" ) ) {
      if ( !parseMasterStyles( element ) )
        return false;
    }

    element = element.nextSiblingElement();
  }

  return true;
}
Example #5
0
const QString PatternParser::parseSimplePattern(const QString& pattern,
        int cdno, const int nooftracks,
        const QString& artist, const QString& title,
        const QString& date, const QString& genre, const QString& suffix,
        bool fat32compatible) {

  SaxHandler handler;
  handler.setCDNo(cdno);
  handler.setNoOfTracks(nooftracks);
  handler.setArtist(artist);
  handler.setTitle(title);
  handler.setDate(date);
  handler.setGenre(genre);
  handler.setSuffix(suffix);
  handler.setFAT32Compatible(fat32compatible);
  handler.setReplaceSpacesWithUnderscores(false);
  handler.set2DigitsTrackNum(false);

  QXmlInputSource inputSource;
  inputSource.setData("<simplepattern>"+p_xmlize_pattern(pattern)+"</simplepattern>");
  QXmlSimpleReader reader;
  reader.setContentHandler(&handler);
  reader.setErrorHandler(&handler);
  reader.parse(inputSource);

  return handler.text();

}
Example #6
0
void PatternParser::parseInfoText(QStringList& text,
        const QString& artist, const QString& title,
        const QString& date, const QString& genre,
        const quint32 discid, const qreal size, const int length, const int nooftracks) {

  SaxHandler handler;
  handler.setArtist(artist);
  handler.setTitle(title);
  handler.setDate(date);
  handler.setGenre(genre);
  handler.setDiscid(discid);
  handler.setSize(size);
  handler.setLength(length);
  handler.setNoOfTracks(nooftracks);
  handler.set2DigitsTrackNum(false);

  QXmlInputSource inputSource;
  inputSource.setData("<textpattern>"+p_xmlize_pattern(text.join("\n"))+"</textpattern>");
  QXmlSimpleReader reader;
  reader.setContentHandler(&handler);
  reader.setErrorHandler(&handler);
  reader.parse(inputSource);

  text = handler.text().split('\n');

}
Example #7
0
bool ThemeManager::applyTheme(const ThemeDocument &kd)
{
    // tDebug() << "Applying theme" << endl;

    bool ok = false;
    QXmlSimpleReader reader;
    reader.setContentHandler(this);
    reader.setErrorHandler(this);
    QXmlInputSource xmlsource;
    xmlsource.setData(kd.toString());

    if (reader.parse(&xmlsource)) {
        ok = true;
    } else {
        #ifdef K_DEBUG
            QString msg = "ThemeManager::applyTheme() - Fatal Error: Can't process theme document";
            #ifdef Q_OS_WIN
                qDebug() << msg;
            #else
                tError() << msg;
            #endif
        #endif

        ok = false;
    }
    
    return ok;
}
Example #8
0
const QString PatternParser::parseFilenamePattern(const QString& pattern,
        int trackno, int cdno, int trackoffset, int nooftracks,
        const QString& artist, const QString& title,
        const QString& tartist, const QString& ttitle,
        const QString& date, const QString& genre, const QString& suffix,
        bool fat32compatible, bool replacespaceswithunderscores, bool _2digitstracknum) {

  SaxHandler handler;
  handler.setTrackNo(trackno);
  handler.setCDNo(cdno);
  handler.setTrackOffset(trackoffset);
  handler.setNoOfTracks(nooftracks);
  handler.setArtist(artist);
  handler.setTitle(title);
  handler.setTrackArtist(tartist);
  handler.setTrackTitle(ttitle);
  handler.setDate(date);
  handler.setGenre(genre);
  handler.setSuffix(suffix);
  handler.setFAT32Compatible(fat32compatible);
  handler.setReplaceSpacesWithUnderscores(replacespaceswithunderscores);
  handler.set2DigitsTrackNum(_2digitstracknum);

  QXmlInputSource inputSource;
  inputSource.setData("<filenamepattern>"+p_xmlize_pattern(pattern)+"</filenamepattern>");
  QXmlSimpleReader reader;
  reader.setContentHandler(&handler);
  reader.setErrorHandler(&handler);
  reader.parse(inputSource);

  return handler.text();

}
Example #9
0
void cbSimulator::setDefaultParameters(void)
{
	QXmlInputSource *source;

	source = new QXmlInputSource;
    source->setData(QByteArray(SIMPARAM));

    QXmlSimpleReader xmlParser;

	cbParamHandler *paramHandler = new cbParamHandler(param);
	xmlParser.setContentHandler(paramHandler);

    cbParameters *param;
    if(xmlParser.parse(*source))
        param = paramHandler->parsedParameters();
	else {
        cerr << "Error parsing DEFAULT parameters\n";
        gui->appendMessage(QString("Error parsing DEFAULT parameters"), true);
		assert(0);
	}

    setParameters(param);
	delete paramHandler;
	delete source;

	//cout << " done.\n";
}
Example #10
0
/*!
 * Waits for server reply and parses status, simulation parameters and
 * assigns the new UDP port to this robot.
 */
void CRobLink::parse_server_reply(void)
{
    // get reply confirming or denying registration 
    char xml[MSGMAXSIZE];
    int recv_ret = port.recv_info(xml, MSGMAXSIZE);
    if(recv_ret == -1)
    {
        cerr << "Failed Init confirmation" << recv_ret << endl;
        Status = -1;
        return;
    }
    //cerr << "XML=\"" << xml <<"\"\nXMLEND\n";

    /* set source of xml document */
    QXmlInputSource source;
    source.setData(QString(xml));

    /* set parser handler */
    StructureParser handler(simParam.nBeacons);

    /* parse xml document with handler */
    QXmlSimpleReader reader;
    reader.setContentHandler(&handler);
    if( !reader.parse(source) ) {
       Status=-1;
       return;
    }


    simParam = *(handler.getSimParam());
    simParam.showValues();

    port.SetRemote(port.GetLastSender());
}
Example #11
0
void cbSimulator::setDefaultGrid(void)
{
	QXmlInputSource *source;

    source = new QXmlInputSource;
        source->setData(QByteArray(GRID));

        QXmlSimpleReader xmlParser;

	cbGridHandler *gridHandler = new cbGridHandler;
	xmlParser.setContentHandler(gridHandler);

    cbGrid *grid;
	if(xmlParser.parse(*source))
        grid = gridHandler->parsedGrid();
	else {
        cerr << "Error parsing DEFAULT grid\n";
        gui->appendMessage(QString("Error parsing DEFAULT grid"), true);
		assert(0);
	}

    setGrid(grid);
	delete gridHandler;
	delete source;

	//rebuild graph
	if(lab!=0) {
        buildGraph();
        setDistMaxFromGridToTarget();
	}

    // update parameters
    //param->gridFilename = "";
}
Example #12
0
void RemoteController::processReadData(const QByteArray &data) {
	QXmlSimpleReader reader;
	RemoteController::XmlHandler *xmlHandler = new RemoteController::XmlHandler();

	reader.setContentHandler(xmlHandler);
	QXmlInputSource buffer;
	buffer.setData(data);
	reader.parse(&buffer);

	isStarted = xmlHandler->my_started;
	isGameOver = xmlHandler->my_gameover;

	if (isStarted == 1) {
		myLeftBtn->setEnabled(true);
		myRightBtn->setEnabled(true);
		myStartBtn->setEnabled(false);
	}
	if (isGameOver == 1) {
		myLeftBtn->setEnabled(false);
		myRightBtn->setEnabled(false);
		--myLostBalls;
		if (myLostBalls > 0) {
			myLostBallsLbl->setText(QString::number(myLostBalls));
			myStartBtn->setEnabled(true);
		} else {
			myLostBallsLbl->setText("The game is over :(");
			myStartBtn->setEnabled(false);
		}
	}
}
Example #13
0
/* Append fragment or a real xml file QXmlInputSource source; */
QDomElement UnionXml::insertFragmentorFile(const QString fragment) {

    bool check;
    /* if is a file insert dom tree and convert to element */
    if (is_file(fragment)) {
        QFile ext_file(fragment);
        ext_file.open(QIODevice::ReadOnly);
        QXmlInputSource sxml;
        sxml.setData(ext_file.readAll());
        QDomElement eimport = fromdevice(sxml);
        ext_file.close();
        return eimport;
    } else {
        /* is not a file */
        /// make buffer null clear
        QXmlInputSource fxml;
        /// setBuffer setData
        const QString heads = fragment.mid(0, 100);
        if (heads.contains("encoding") || heads.contains("?xml")) {
            fxml.setData(fragment);
        } else {
            QString dd = QString("<?xml version=\"1.0\"?>\n<dummyroot>%1</dummyroot>").arg(fragment);
            fxml.setData(dd);
        }
        return fromdevice(fxml);
    }
}
Example #14
0
bool CTConfToyRing::setParameters(QString xml)
{
//    qDebug() << xml;

    int num_stimuli = NUM_LIGHTS + NUM_SPEAKERS;
    int num_actions = NUM_LIGHTS + NUM_SPEAKERS;

    QXmlSimpleReader xmlReader;
    QXmlInputSource *source = new QXmlInputSource();
    source->setData(xml);

    CTXmlHandler *handler = new CTXmlHandler;
    /*
     *Passing pointer of the class to the xml parser handler,
     *in order to set the parsed values into it's input fields
     */
    handler->setWidget(2, this, num_stimuli, num_actions);
    QList<CTLight*> empty1;
    QList<CTScreen*> empty2;
    QList<CTBigLight*> empty3;
    QList<CTButton*> empty4;
    handler->setStimuli(light_stimuli, speaker_stimuli, empty1, empty2,empty3,empty4);
    handler->setActions(light_actions, speaker_actions, empty2,empty3,empty4, empty1);
    xmlReader.setContentHandler(handler);
    xmlReader.setErrorHandler(handler);

    bool ok = xmlReader.parse(source);
    qDebug() << "The parsing went ok? " << ok;
    block_duration = handler->getBlockDuration();
    if(ok)
    {
        updateBlockRuntime(1.0);
    }
    return true;
}
Example #15
0
void StatCrewScanner::updateStats(QNetworkReply * reply) {
//    QFile file(statFile);
    QXmlSimpleReader r;
    r.setContentHandler(statCrew);
    r.setErrorHandler(statCrew);
    QXmlInputSource src;
    src.setData(reply->readAll());
    r.parse(src);
}
Example #16
0
QString NewsFeed::parseFeed(const QString &feed, int limit) {
	QXmlSimpleReader reader;
	RssReader handler(limit);
	reader.setContentHandler(&handler);
	QXmlInputSource source;
	source.setData(feed);
	reader.parse(&source);
	return handler.getOutput();
}
void Digester::parseMemory(const char* data, unsigned int length)
{
	DigesterParser handler(this);
	QXmlInputSource source;
	source.setData(QString::fromUtf8(data, length));
	QXmlSimpleReader reader;
	reader.setContentHandler( &handler );
	reader.setErrorHandler( &handler );
	reader.parse( source );
}
QXmlAttributes XMLAttributeReader::readAttrs(bool &ok)
{
    // parse xml file
    QXmlInputSource source;
    source.setData("<?xml version=\"1.0\"?><attrs "+m_attrString+" />");
    QXmlSimpleReader reader;
    reader.setContentHandler( this );
    ok = reader.parse( source );
    return attrs;
}
void Digester::parseMemory(const Xml_string& data)
{
	DigesterParser handler(this);
	QXmlInputSource source;
	source.setData(data);
	QXmlSimpleReader reader;
	reader.setContentHandler( &handler );
	reader.setErrorHandler( &handler );
	reader.parse( source );
}
void Parser::parse(QString msg){
    Handler h;
    QXmlInputSource input;
    input.setData(msg);
    reader->setContentHandler(&h);
    reader->parse(&input,false);
    reader->setErrorHandler(&h);
    update = h.getUpdate();
    theReply=h.getReply();
}
Example #21
0
Pult::State* Pult::State::createInstance(const QByteArray &str) {
    Pult::State *state = new Pult::State();
    Pult::PultXmlHandler* handler = new Pult::PultXmlHandler(state);
    QXmlSimpleReader reader;
    reader.setContentHandler(handler);
    QXmlInputSource buf;
    buf.setData(str);
    reader.parse(&buf);
    delete handler;
    return state;
}
/*!
  \internal
  \since 4.4

  See task 166278.
 */
void tst_QXmlInputSource::resetSimplified() const
{
    const QString input(QString::fromLatin1("<element/>"));

    QXmlSimpleReader reader;

    QXmlInputSource source;
    source.setData(input);

    QVERIFY(reader.parse(source));
    source.reset();
    QCOMPARE(source.data(), input);
}
Example #23
0
QDomDocument FoxGroundDocument::xmltoken() {
    QXmlSimpleReader reader;
    QXmlInputSource source;
    source.setData(d->data());
    QString errorMsg;
    QDomDocument document;
    if (!document.setContent(&source, &reader, &errorMsg)) {
        setError(QString("Invalid XML document: %1").arg(errorMsg));
        setError(QString("Invalid XML Size: %1").arg(d->data().size()));
        return QDomDocument();
    }
    return document;
}
bool WebContentManager::parseReply(const QString &str)
{
    QXmlSimpleReader reader;
    QXmlInputSource source;

    parser.reset(new XMLParser);

    source.setData(str.toAscii());

    reader.setContentHandler(parser.data());
    reader.setErrorHandler(parser.data());

    return reader.parse(&source);
}
Example #25
0
bool TupXmlParserBase::parse(const QString &doc)
{
     QXmlSimpleReader reader;

     reader.setContentHandler(this);
     reader.setErrorHandler(this);

     QXmlInputSource xmlsource;
     xmlsource.setData(doc);

     k->document = doc;

     return reader.parse(&xmlsource);
}
Example #26
0
/// normal equation node
void CMathMLToTeX::mNode(QString &text)
{
  CStructureParser xmlParser(0);
  QXmlSimpleReader xmlReader;

  xmlReader.setContentHandler(&xmlParser);

  QXmlInputSource xmlSource;
  xmlSource.setData(text);

  xmlReader.parse(xmlSource);

  text = xmlParser.getTeX();
}
Example #27
0
bool StyleParser::parseMetaFile()
{
  QXmlSimpleReader reader;

  QXmlInputSource source;
  source.setData( mDocument->meta() );

  QString errorMsg;
  int errorLine, errorCol;

  QDomDocument document;
  if ( !document.setContent( &source, &reader, &errorMsg, &errorLine, &errorCol ) ) {
    qDebug( "%s at (%d,%d)", qPrintable( errorMsg ), errorLine, errorCol );
    return false;
  }

  const QDomElement documentElement = document.documentElement();
  QDomElement element = documentElement.firstChildElement();
  while ( !element.isNull() ) {
    if ( element.tagName() == QLatin1String( "meta" ) ) {
      QDomElement child = element.firstChildElement();
      while ( !child.isNull() ) {
        if ( child.tagName() == QLatin1String( "generator" ) ) {
          mStyleInformation->addMetaInformation( "producer", child.text(), i18n( "Producer" ) );
        } else if ( child.tagName() == QLatin1String( "creation-date" ) ) {
          const QDateTime dateTime = QDateTime::fromString( child.text(), Qt::ISODate );
          qDebug() << "### dateTime  ...  " << dateTime << " file" <<  __FILE__ << ":" << __LINE__;
          ////  mStyleInformation->addMetaInformation( "creationDate", KGlobal::locale()->formatDateTime( dateTime, KLocale::LongDate, true ),i18n( "Created" ) );
        } else if ( child.tagName() == QLatin1String( "initial-creator" ) ) {
          mStyleInformation->addMetaInformation( "creator", child.text(), i18n( "Creator" ) );
        } else if ( child.tagName() == QLatin1String( "creator" ) ) {
          mStyleInformation->addMetaInformation( "author", child.text(), i18n( "Author" ) );
        } else if ( child.tagName() == QLatin1String( "date" ) ) {
          const QDateTime dateTime = QDateTime::fromString( child.text(), Qt::ISODate );
          qDebug() << "### dateTime  ...  " << dateTime << " file" <<  __FILE__ << ":" << __LINE__;
          //// mStyleInformation->addMetaInformation( "modificationDate", KGlobal::locale()->formatDateTime( dateTime, KLocale::LongDate, true ), i18n( "Modified" ) );
        }

        child = child.nextSiblingElement();
      }
    }

    element = element.nextSiblingElement();
  }

  return true;
}
void PlaylistModel::requestReceived(QNetworkReply*reply) {
    if(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()==401) {
        DataItem *item = new DataItem;
        item->name="Authentication error, check settings";
        item->id="-1";
        dataItems.append(*item);
        insertRows(0,1,QModelIndex());
        return;
    }
    QXmlInputSource *xInSrc = new QXmlInputSource();
    xInSrc->setData(reply->readAll());
    QXmlSimpleReader *reader = new QXmlSimpleReader();

    reader->setContentHandler(m_handler);
    reader->setErrorHandler(m_handler);
    reader->parse(xInSrc);
}
QString HtmlDocument::read_docx_index(QByteArray xml, int findertype, const QString Xid) {
    QXmlSimpleReader reader;
    QXmlInputSource source;
    source.setData(xml);
    QString errorMsg;
    QDomDocument document;
    if (!document.setContent(&source, &reader, &errorMsg)) {
        setError(QString("Invalid XML document: %1").arg(errorMsg));
        return QString();
    }
    /* TargetMode="External"/> is link http to image */
    const QDomElement documentElement = document.documentElement();
    QDomElement element = documentElement.firstChildElement();
    while (!element.isNull()) {
        if (element.tagName() == QLatin1String("Relationship")) {
            const QString target = element.attribute("Target", "NULL");
            QString pathimage = "word/" + target; /// if 1??findertype
            const QString uuid = element.attribute("Id", "NULL");
            const QString type = element.attribute("Type", "NULL");
            ////BASICDOCDEBUG() << "image:" << target << " Id:" << uuid;
            //// check image == 1 findertype if need other?? 
            if (target.startsWith("media") && type.endsWith("image") &&
                    findertype == 1 && uuid == Xid) {
                QByteArray xdata = docitem(pathimage);
                QImage pic;
                pic.loadFromData(xdata);
                if (!pic.isNull()) {
                    QFileInfo pic(pathimage);
                    QString blob = "data:image/" + pic.completeSuffix().toLower() + ";base64,";
                    QString imagembed(xdata.toBase64().constData());
                    blob.append(imagembed);
                    const QString imagehtml = blob;
                    return imagehtml;
                } else {
                    QString errorimage = QString("Invalid Image Format! is not a conventional Open Image format: %1 ").arg(pathimage);
                    setError(errorimage);
                }
            }
        }
        element = element.nextSiblingElement();
    }

    ///// BASICDOCDEBUG() << "index docx xml:" << document.toString(5);

    return QString();
}
Example #30
0
QString KSVGLoader::getCharacterData(::KURL url, const QString &id)
{
	QXmlSimpleReader reader;

	CharacterDataSearcher searcher(id);
	reader.setContentHandler(&searcher);
	reader.setErrorHandler(&searcher);

	QString s = loadXML(url);

	QXmlInputSource source;
	source.setData(s);

	reader.parse(&source);

	return searcher.result();
}