Exemplo n.º 1
0
void UpdateChecker::onRequestFinished(QNetworkReply* reply)
{
    if(reply->error() != QNetworkReply::NoError){
        qDebug("Error while checking update [%s]\n", reply->errorString().toLatin1().constData());
        return;
    }

    QSettings s;
    s.beginGroup("Update");
    s.setValue("lastUpdateDate", QDateTime::currentDateTime());
    s.endGroup();

    QByteArray data = reply->readAll();
    QXmlStreamReader reader(data);
    QString version;
    QString upgradeRevision;
    QString downloadUrl;
    QString infoUrl;
    QString description;
    QString releaseType;

    while (!reader.atEnd() && !reader.hasError()) {
        QXmlStreamReader::TokenType token = reader.readNext();
        if(token == QXmlStreamReader::StartDocument) {
            continue;
        }
        if(token == QXmlStreamReader::StartElement) {
            if(reader.name() == "version") {
                version = parseText(reader);
            }else if (reader.name() == "revision") {
                upgradeRevision = parseText(reader);
            }else if (reader.name() == "downloadUrl") {
                downloadUrl = parseText(reader);
            }else if (reader.name() == "infoUrl") {
                infoUrl = parseText(reader);
            }else if (reader.name() == "description") {
                description = parseText(reader);
            }
        }
    }

    if (reader.error())
        qDebug() << reader.error() << reader.errorString();

    QString message = QString(tr("An update for MuseScore is available: <a href=\"%1\">MuseScore %2 r.%3</a>")).arg(downloadUrl).arg(version).arg(upgradeRevision);
//    qDebug("revision %s\n", revision.toLatin1().constData());
    if(!version.isEmpty() &&  upgradeRevision > revision ){
        QMessageBox msgBox;
        msgBox.setWindowTitle(tr("Update Available"));
        msgBox.setText(message);
        msgBox.setTextFormat(Qt::RichText);
        msgBox.exec();
    }else if(manual){
        QMessageBox msgBox;
        msgBox.setWindowTitle(tr("No Update Available"));
        msgBox.setText(tr("No Update Available"));
        msgBox.setTextFormat(Qt::RichText);
        msgBox.exec();
    }
}
Exemplo n.º 2
0
void CTextHelper::loadFromFile(const std::string& fileName)
{
	std::string tmpStr = "";
	std::ifstream file;
	try
	{
		file.open(fileName);
		if (!file.is_open())
		{
			CLog::getInstance()->addError("Cant open" + fileName);
			return;
		}

		while (!file.eof())
		{
			std::getline(file, tmpStr);
			parseText(tmpStr);
		}
	}
	catch (...)
	{
		CLog::getInstance()->addError("Cant read " + fileName);
	}
		
	file.close();
}
Exemplo n.º 3
0
/**
* Queues a text job.
*/
uint SpeechData::setText( const QString &text, const QString &talker, const QCString &appId)
{
    // kdDebug() << "Running: SpeechData::setText" << endl;
    mlJob* job = new mlJob;
    ++jobCounter;
    if (jobCounter == 0) ++jobCounter;  // Overflow is OK, but don't want any 0 jobNums.
    uint jobNum = jobCounter;
    job->jobNum = jobNum;
    job->appId = appId;
    job->talker = talker;
    job->state = KSpeech::jsQueued;
    job->seq = 0;
    job->partCount = 1;
#if NO_FILTERS
    QStringList tempList = parseText(text, appId);
    job->sentences = tempList;
    job->partSeqNums.append(tempList.count());
    textJobs.append(job);
    emit textSet(appId, jobNum);
#else
    job->sentences = QStringList();
    job->partSeqNums = QValueList<int>();
    textJobs.append(job);
    startJobFiltering(job, text, false);
#endif
    return jobNum;
}
String Communication::getUnpackedMessage(String message) {
  // Check Start of Header
  if (!checkStartOfHeader(message)) {
    return "";
  }
  
  // Parse Header
  int message_size = parseHeader(message);
  if (message_size < 0) {
    return "";
  }

  // Parse Text
  String unpacked_message = parseText(message); 
  if (unpacked_message == "") {
    return "";
  }

  // Check Message Size
  if (message_size != unpacked_message.length()) {
    return "";
  }
  
  // Compute & Compare Checksums
  String incoming_checksum = parseFooter(message);
  String computed_checksum = getChecksum(unpacked_message);
  if (incoming_checksum != computed_checksum) {
    return "";
  }
  
  // Received Valid Message
  return unpacked_message;
}
PassRefPtrWillBeRawPtr<Text> GranularityStrategyTest::setupRotate(String str)
{
    setInnerHTML(
        "<html>"
        "<head>"
        "<style>"
            "div {"
                "transform: translate(0px,600px) rotate(90deg);"
            "}"
        "</style>"
        "</head>"
        "<body>"
        "<div id='mytext'></div>"
        "</body>"
        "</html>");

    RefPtrWillBeRawPtr<Text> text = document().createTextNode(str);
    Element* div = document().getElementById("mytext");
    div->appendChild(text);

    document().view()->updateAllLifecyclePhases();

    parseText(text.get());
    return text.release();
}
Exemplo n.º 6
0
bool KNMusicLrcParser::parseFile(const QString &filePath,
                                 QList<qint64> &positionList,
                                 QStringList &textList)
{
    //Read the file contents.
    QFile lyricsFile(filePath);
    if(!lyricsFile.open(QIODevice::ReadOnly))
    {
        return false;
    }
    QByteArray lyricsContent=lyricsFile.readAll();
    lyricsFile.close();
    //Try to parse the lyrics data via UTF-8 codecs.
    QTextCodec::ConverterState convState;
    QString lyricsTextData=m_utf8Codec->toUnicode(lyricsContent.constData(),
                                                  lyricsContent.size(),
                                                  &convState);
    //If we can't decode it, try to use default codec.
    if(convState.invalidChars>0)
    {
        lyricsTextData=m_localeCodec->toUnicode(lyricsContent.constData(),
                                                lyricsContent.size(),
                                                &convState);
        //If we still cannot decode it, ask user to select a codec.
        if(convState.invalidChars>0)
        {
            //! FIXME: add ask user to choice the text codec.
            ;
        }
    }
    //Parse the lyrics data.
    return parseText(lyricsTextData, positionList, textList);
}
Exemplo n.º 7
0
int main  ( int argc, char **argv ) {
#ifdef DEBUG
	printf("IN MAIN\n");
#endif
	/*Displays Help Command*/
	if(argc!=MIN_REQUIRED || !strcmp(argv[1], "-h")) {
		return help();
	}
	double time_spent;
	char* stringFile = readFile(argv[1]);
	if(stringFile == NULL){
		return help();
	}
	int numberWords=countCharacters(stringFile, ' ', '\n', '\t');
#ifdef DEBUG
	printf("File: %s\nTotal number of Words: %d\n %s\n",argv[1], numberWords, stringFile);
#endif
	clock_t tic = clock();
	parseText(stringFile, numberWords);
	clock_t toc = clock();
	printList();
	time_spent=(double)(toc-tic)/CLOCKS_PER_SEC;
	time_spent=time_spent/1000000;
#ifdef DEBUG
	printf("\n =========\n TIME SPENT: %.032f \n =========\n", time_spent);
#endif
#ifdef DEBUG
	printf("OUT OF MAIN\n");
#endif
	freeList();
	free(stringFile);
	return 0;
  }
Exemplo n.º 8
0
DraggableElement::DraggableElement(const QString& identifier, const QString& text, const QColor& color, Sprite* sprite, QWidget* parent) :
    QWidget(parent),
    _color(color),
    _text(text),
    _identifier(identifier),
    _static(false),
    _sprite(sprite),
    _path(QPoint(0, 0)),
    _currentDock(0),
    _prevElem(0),
    _nextElem(0)
{
    _paramLayout = new QHBoxLayout();
    _paramLayout->setSpacing(5);
    _paramLayout->setSizeConstraint(QLayout::SetFixedSize);
    _paramLayout->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);

    hide();
    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
    connect(this, SIGNAL(dragElemContextMenuRequested(QPoint,DraggableElement*)), sMainWindow, SLOT(dragElemContextMenuRequested(QPoint,DraggableElement*)));

    if(_sprite)
        _sprite->addElement(this);

    parseText(text);
}
Exemplo n.º 9
0
// Each text sample consists of a string of text, optionally with sample
// modifier description. The modifier description could specify a new
// text style for the string of text. These descriptions are present only
// if they are needed. This method is used to extract the modifier
// description and append it at the end of the text.
status_t TimedTextASSSource::in_extractAndAppendLocalDescriptions(
        int64_t timeUs, const MediaBuffer *textBuffer, Parcel *parcel) {
    const void *data;
    size_t size = 0;
    int32_t flag = TextDescriptions::LOCAL_DESCRIPTIONS;

    const char *mime;
    CHECK(mInSource->getFormat()->findCString(kKeyMIMEType, &mime));
    CHECK(strcasecmp(mime, MEDIA_MIMETYPE_TEXT_ASS) == 0);

    data = textBuffer->data();
    size = textBuffer->size();

	MagicString* textData = parseText((const char*)data, size);
	MagicString::print("[Internal ASS Subtitle] ", *textData);

	if(NULL != textData){
		if (size > 0) {
	      parcel->freeData();
	      flag |= TextDescriptions::IN_BAND_TEXT_ASS;
	      return TextDescriptions::getParcelOfDescriptions(
	          (const uint8_t *)textData->c_str(), textData->length(), flag, timeUs / 1000, parcel);
	    }
		free(textData);
	}
    return OK;
}
Exemplo n.º 10
0
  static int run_main(int ac, char* av[]) {
    namespace po = boost::program_options;
    try {
      po::options_description generic("Allowed options");

      add(generic)("config-file,c", po::value<std::string>(), "config file name");
      add(generic)("help,h", "produce help message");

      po::options_description hidden("Hidden options");
      hidden.add_options()("input-file", po::value<std::string>(), "input file");

      po::options_description cmdline_options;
      cmdline_options.add(generic).add(hidden);

      po::options_description config_file_options;
      config_file_options.add(generic).add(hidden);

      po::positional_options_description p;
      p.add("input-file", -1);

      po::variables_map vm;
      store(po::command_line_parser(ac, av).options(cmdline_options).positional(p).run(), vm);

      if (vm.count("config-file")) {
        Util::Input ifs(vm["config-file"].as<std::string>());
        store(parse_config_file(*ifs, config_file_options), vm);
        notify(vm);
      }

      if (vm.count("help")) {
        std::cout << generic << "\n\n";
        std::cout << "Convert FSM (in hypergraph format) to OpenFst text format" << '\n';
        return EXIT_FAILURE;
      }

      std::string file;
      if (vm.count("input-file")) {
        file = vm["input-file"].as<std::string>();
      }

      typedef ViterbiWeightTpl<float> Weight;
      typedef Hypergraph::ArcTpl<Weight> Arc;

      IVocabularyPtr pVoc = Vocabulary::createDefaultVocab();

      Util::Input in_(file);

      MutableHypergraph<Arc> hg;
      hg.setVocabulary(pVoc);
      parseText(*in_, file, &hg);

      writeOpenFstFormat(std::cout, hg);

      assert(hg.checkValid());
    } catch (std::exception& e) {
      std::cerr << e.what() << '\n';
      return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;
  }
Exemplo n.º 11
0
int GUIText::Update(void)
{
	if (!isConditionTrue())
		return 0;

	static int updateCounter = 3;

	// This hack just makes sure we update at least once a minute for things like clock and battery
	if (updateCounter)  updateCounter--;
	else
	{
		mVarChanged = 1;
		updateCounter = 3;
	}

	if (mIsStatic || !mVarChanged)
		return 0;

	std::string newValue = parseText();
	if (mLastValue == newValue)
		return 0;
	else
		mLastValue = newValue;
	return 2;
}
// Tests moving extent over to the other side of the vase and immediately
// passing the word boundary and going into word granularity.
TEST_F(GranularityStrategyTest, DirectionSwitchSideWordGranularityThenShrink)
{
    dummyPageHolder().frame().settings()->setDefaultFontSize(12);
    String str = "ab cd efghijkl mnopqr iiin, abc";
    RefPtrWillBeRawPtr<Text> text = document().createTextNode(str);
    document().body()->appendChild(text);
    dummyPageHolder().frame().settings()->setSelectionStrategy(SelectionStrategy::Direction);

    parseText(text.get());

    // "abcd efgh ijkl mno^pqr|> iiin, abc" (^ means base, | means extent, < means start, and > means end).
    selection().setSelection(VisibleSelection(Position(text, 18), Position(text, 21)));
    EXPECT_EQ_SELECTED_TEXT("pqr");
    // Move to the middle of word #4 selecting it - this will set the offset to
    // be half the width of "iiin".
    selection().moveRangeSelectionExtent(m_wordMiddles[4]);
    EXPECT_EQ_SELECTED_TEXT("pqr iiin");
    // Move to the middle of word #2 - extent will switch over to the other
    // side of the base, and we should enter word granularity since we pass
    // the word boundary. The offset should become negative since the width
    // of "efghjkkl" is greater than that of "iiin".
    int offset = m_letterPos[26].x() - m_wordMiddles[4].x();
    IntPoint p = IntPoint(m_wordMiddles[2].x() - offset - 1, m_wordMiddles[2].y());
    selection().moveRangeSelectionExtent(p);
    EXPECT_EQ_SELECTED_TEXT("efghijkl mno");
    p.move(m_letterPos[7].x() - m_letterPos[6].x(), 0);
    selection().moveRangeSelectionExtent(p);
    EXPECT_EQ_SELECTED_TEXT("fghijkl mno");
}
Exemplo n.º 13
0
void SnippetWidget::slotExecuted(QListViewItem * item)
{
  SnippetItem *pSnippet = dynamic_cast<SnippetItem*>( item );
  if (!pSnippet || dynamic_cast<SnippetGroup*>(item))
      return;

  //process variables if any, then insert into the active view
  insertIntoActiveView( parseText(pSnippet->getText(), _SnippetConfig.getDelimiter()) );
}
Exemplo n.º 14
0
void Configuration::add( const EString & l )
{
    uint i = 0;
    while ( i < l.length() && ( l[i] == ' ' || l[i] == '\t' ) )
        i++;
    if ( i == l.length() || l[i] == '#' )
        return;

    while ( i < l.length() &&
            ( ( l[i] >= 'a' && l[i] <= 'z' ) ||
              ( l[i] >= 'A' && l[i] <= 'Z' ) ||
              ( l[i] >= '0' && l[i] <= '9' ) ||
              ( l[i] == '-' ) ) )
        i++;
    EString name = l.mid( 0, i ).lower().simplified();
    while ( l[i] == ' ' || l[i] == '\t' )
        i++;
    if ( l[i] == '#' ) {
        log( "comment immediately after variable name: " + l, Log::Disaster );
        return;
    }
    if ( l[i] != '=' ) {
        log( "no '=' after variable name: " + l, Log::Disaster );
        return;
    }
    i++;
    while ( l[i] == ' ' || l[i] == '\t' )
        i++;
    if ( d->contains( name ) )
        log( "Variable specified twice: " + name, Log::Disaster );
    d->seen.append( name );

    uint n = 0;
    while ( n < NumScalars && name != scalarDefaults[n].name )
        n++;
    if ( n < NumScalars ) {
        parseScalar( n, l.mid( i ) );
        return;
    }
    n = 0;
    while ( n < NumTexts && name != textDefaults[n].name )
        n++;
    if ( n < NumTexts ) {
        parseText( n, l.mid( i ) );
        return;
    }
    n = 0;
    while ( n < NumToggles && name != toggleDefaults[n].name )
        n++;
    if ( n < NumToggles ) {
        parseToggle( n, l.mid( i ) );
        return;
    }

    log( "Unknown variable: " + name, Log::Disaster );
}
Exemplo n.º 15
0
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp (bool allowEmpty, bool ignoreOneShot)
{
    if (Token token = getNextToken())
    {
        if (token==Token (Token::Type_OneShot))
            token = getNextToken();

        if (token)
            switch (token.mType)
            {
                case Token::Type_Keyword_True:

                    return boost::shared_ptr<CSMFilter::Node> (new BooleanNode (true));

                case Token::Type_Keyword_False:

                    return boost::shared_ptr<CSMFilter::Node> (new BooleanNode (false));

                case Token::Type_Keyword_And:
                case Token::Type_Keyword_Or:

                    return parseNAry (token);

                case Token::Type_Keyword_Not:
                {
                    boost::shared_ptr<CSMFilter::Node> node = parseImp();

                    if (mError)
                        return boost::shared_ptr<Node>();

                    return boost::shared_ptr<CSMFilter::Node> (new NotNode (node));
                }

                case Token::Type_Keyword_Text:

                    return parseText();

                case Token::Type_Keyword_Value:

                    return parseValue();

                case Token::Type_EOS:

                    if (!allowEmpty)
                        error();

                    return boost::shared_ptr<Node>();

                default:

                    error();
            }
    }

    return boost::shared_ptr<Node>();
}
Exemplo n.º 16
0
void TextLnk::execute()
{
	QClipboard* cb = QApplication::clipboard();
	parseText();
	cb->setText(m_params[1]);
	QWSServer::sendKeyEvent('V'-'@',Qt::Key_V, Qt::ControlButton,
		true, false);
	QWSServer::sendKeyEvent('V'-'@',Qt::Key_V, Qt::ControlButton,
		false, false);
}
Exemplo n.º 17
0
	XMLNode* XMLDecoderUTF8::parseElement()
	{
		String name;
		advance(1);
		/* spec says no whitespaces allowd - whatever */
		skipWhitespace();
		if(!parseName( name))
			throw CVTException("Malformed element name");

		/* START Tag */
		XMLElement* element = new XMLElement( name );
		while( _rlen ) {
			skipWhitespace();
			if( match( "/>" ) ) {
				advance( 2 );
				return element;
			} else if( match( '>' ) )	{
				advance( 1 );
				break;
			} else {
				element->addChild( parseAttribute() );
			}
		}

		/* Content */
		 skipWhitespace();
		 while( !match("</") ) {
			if( match("<?") )
				element->addChild( parsePI() );
			else if( match("<!--") )
				element->addChild( parseComment() );
			else if( match("<") )
				element->addChild( parseElement() );
			else if( match("<![CDATA[") )
				element->addChild( parseCData() );
			else
				element->addChild( parseText() );
			skipWhitespace();
		}

		/* END Tag */
		advance( 2 );
		/* spec says no whitespaces allowd - whatever */
		skipWhitespace();
		String ename;
		if( ! parseName( ename ) )
			throw CVTException("Malformed element name");
		if( name != ename )
			throw CVTException("Names in start- and end-tag differ");
		skipWhitespace();
		if( !match('>') )
			throw CVTException("Missing '>'");
		advance( 1 );
		return element;
	}
Exemplo n.º 18
0
GUIText::GUIText(xml_node<>* node)
    : Conditional(node)
{
    xml_attribute<>* attr;
    xml_node<>* child;

    mFont = NULL;
    mIsStatic = 1;
    mVarChanged = 0;
    mFontHeight = 0;
    maxWidth = 0;
    charSkip = 0;

    if (!node)      return;

    // Initialize color to solid black
    memset(&mColor, 0, sizeof(COLOR));
    mColor.alpha = 255;

    attr = node->first_attribute("color");
    if (attr)
    {
        std::string color = attr->value();
        ConvertStrToColor(color, &mColor);
    }

    // Load the font, and possibly override the color
    child = node->first_node("font");
    if (child)
    {
        attr = child->first_attribute("resource");
        if (attr)
            mFont = PageManager::FindResource(attr->value());

        attr = child->first_attribute("color");
        if (attr)
        {
            std::string color = attr->value();
            ConvertStrToColor(color, &mColor);
        }
    }

    // Load the placement
    LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH, &mPlacement);

    child = node->first_node("text");
    if (child)  mText = child->value();

    // Simple way to check for static state
    mLastValue = parseText();
    if (mLastValue != mText)   mIsStatic = 0;

    gr_getFontDetails(mFont ? mFont->GetResource() : NULL, (unsigned*) &mFontHeight, NULL);
    return;
}
Exemplo n.º 19
0
int GUIText::GetCurrentBounds(int& w, int& h)
{
	void* fontResource = NULL;

	if (mFont)
		fontResource = mFont->GetResource();

	h = mFontHeight;
	mLastValue = parseText();
	w = gr_measureEx(mLastValue.c_str(), fontResource);
	return 0;
}
Exemplo n.º 20
0
	void testParse()
	{
		// From RFC-2047
		VASSERT_EQ("1", "[text: [[word: charset=US-ASCII, buffer=Keith Moore]]]",
			parseText("=?US-ASCII?Q?Keith_Moore?="));

		VASSERT_EQ("2", "[text: [[word: charset=ISO-8859-1, buffer=Keld J\xf8rn Simonsen]]]",
			parseText("=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?="));

		VASSERT_EQ("3", "[text: [[word: charset=ISO-8859-1, buffer=Andr\xe9]," \
			                 "[word: charset=us-ascii, buffer= Pirard]]]",
			parseText("=?ISO-8859-1?Q?Andr=E9?= Pirard"));

		VASSERT_EQ("4", "[text: [[word: charset=ISO-8859-1, buffer=If you can read this yo]," \
			                 "[word: charset=ISO-8859-2, buffer=u understand the example.]]]",
			parseText("=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\r\n " \
				"=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?="));

		// Bugfix: in "=?charset?q?=XX=YY?=", the "?=" finish
		// sequence was not correctly found (should be the one
		// after '=YY' and not the one after '?q').
		VASSERT_EQ("5", "[text: [[word: charset=abc, buffer=\xe9\xe9]]]",
			parseText("=?abc?q?=E9=E9?="));

		// Question marks (?) in the middle of the string
		VASSERT_EQ("6", "[text: [[word: charset=iso-8859-1, buffer=Know wh\xe4t? It works!]]]",
			parseText("=?iso-8859-1?Q?Know_wh=E4t?_It_works!?="));

		// TODO: add more
	}
Exemplo n.º 21
0
void ServerIO_Thread(void*)
{
    while(alive)
    {
	   sock.getData();
	   if(sock.len > 1)
	   {
            //con.addText(sock.recv_buf,sock.len,true);
			parseText(sock.recv_buf);
			//con.draw();
	   }
    }
	_endthread();
}
Exemplo n.º 22
0
int GUIText::Render(void)
{
	if (!isConditionTrue())
		return 0;

	void* fontResource = NULL;
	string displayValue;

	if (mFont)
		fontResource = mFont->GetResource();

	mLastValue = parseText();
	displayValue = mLastValue;

	if (charSkip)
		displayValue.erase(0, charSkip);

	mVarChanged = 0;

	int x = mRenderX, y = mRenderY;
	int width = gr_measureEx(displayValue.c_str(), fontResource);

	if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
	{
		if (mPlacement == CENTER || mPlacement == CENTER_X_ONLY)
			x -= (width / 2);
		else
			x -= width;
	}
	if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
	{
		if (mPlacement == CENTER)
			y -= (mFontHeight / 2);
		else if (mPlacement == BOTTOM_LEFT || mPlacement == BOTTOM_RIGHT)
			y -= mFontHeight;
	}

	if (hasHighlightColor && isHighlighted)
		gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
	else
		gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);

	if (maxWidth)
		gr_textExW(x, y, displayValue.c_str(), fontResource, maxWidth + x);
	else
		gr_textEx(x, y, displayValue.c_str(), fontResource);
	return 0;
}
Exemplo n.º 23
0
IniFile::IniFile(const char* strFileName, const bool isDocumentFile,const TDesKey& desKey, bool isDocDecrypt): m_txtFileName(strFileName), m_isChanged(false), m_isDecrypt(isDocDecrypt),m_desKey(desKey)
{
    BufInputStream* txtFile=0;
    if (isDocumentFile)
    {
        if (m_isDecrypt)
            txtFile=new MyTextFileInputStream(strFileName, m_desKey);
        else
            txtFile=new MyTextFileInputStream(strFileName);
    }
    else{
        txtFile=new MyTextFileInputStream(strFileName);
    }
    parseText(*txtFile);
    delete txtFile;
}
Exemplo n.º 24
0
/**
 *  \copydoc MythUIType::ParseElement()
 */
bool MythUIButton::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    if (element.tagName() == "value")
    {
        m_ValueText = qApp->translate("ThemeUI",
                                      parseText(element).toUtf8(), NULL,
                                      QCoreApplication::UnicodeUTF8);
    }
    else
    {
        return MythUIType::ParseElement(filename, element, showWarnings);
    }

    return true;
}
// Make sure we switch to word granularity right away when starting on a
// word boundary and extending.
TEST_F(GranularityStrategyTest, DirectionSwitchStartOnBoundary)
{
    dummyPageHolder().frame().settings()->setDefaultFontSize(12);
    String str = "ab cd efghijkl mnopqr iiin, abc";
    RefPtrWillBeRawPtr<Text> text = document().createTextNode(str);
    document().body()->appendChild(text);
    dummyPageHolder().frame().settings()->setSelectionStrategy(SelectionStrategy::Direction);

    parseText(text.get());

    // "ab cd efghijkl ^mnopqr |>stuvwi inm," (^ means base and | means extent,
    // > means end).
    selection().setSelection(VisibleSelection(Position(text, 15), Position(text, 22)));
    EXPECT_EQ_SELECTED_TEXT("mnopqr ");
    selection().moveRangeSelectionExtent(m_wordMiddles[4]);
    EXPECT_EQ_SELECTED_TEXT("mnopqr iiin");
}
Exemplo n.º 26
0
int main  ( int argc, char **argv ) {
	/*Displays Help Command*/
	if(argc!=2 || !strcmp(argv[1], "-h")) {
		return help();
	}
	clock_t tic = clock();
	double time_spent;
	char* stringFile = readFile(argv[1]);
	int numberWords=countCharacters(stringFile, ' ', '\n', '\t'), i;
	printf("File: %s\nTotal number of Words: %d\n %s\n",argv[1], numberWords, stringFile);
	printf("%d\n", hash("bob", 100)% 100);
	parseText(stringFile, numberWords);
	clock_t toc = clock();
	time_spent=(double)(toc-tic)/CLOCKS_PER_SEC;
	time_spent=time_spent/1000000;
	printf("\n =========\n TIME SPENT: %.06f \n =========\n", time_spent);
	return 0;
}
Exemplo n.º 27
0
void Sketch_Files::readXml(QString FileName)//Opens the sketch file
{
    if(FileName.contains(".xml")||FileName.contains(".skh"))
    {
         QFile fd(FileName);
         fd.open(QFile::ReadWrite);
         QXmlStreamReader rw(&fd);

         while(!rw.atEnd())
         {
            object = new Scene_Objects;
            if(rw.name()=="Type")//what type of object ex:line,rect...
            {
                QTextStream readline;
                QString str,subText;
                str=rw.readElementText();
                readline.setString(&str,QIODevice::ReadWrite);

                while(!readline.atEnd())
                {
                    readline>>subText;
                    if(subText.contains("Line"))
                        object->ObjectId=1;
                    if(subText.contains("Rectangle"))
                        object->ObjectId=2;
                    if(subText.contains("Ellipse"))
                        object->ObjectId=3;
                    if(subText.contains("RoundRect"))
                        object->ObjectId=5;
                }


            }

            if(rw.name()=="Dim")
            {
              parseText(rw.readElementText());
              object->print();
            }

            rw.readNext();
         }
Exemplo n.º 28
0
XFigParser::XFigParser( QIODevice* device )
  : m_Document(0)
  , m_XFigStreamLineReader( device )
{
    if( (device == 0) || (m_XFigStreamLineReader.hasError()) )
        return;

    const QTextCodec* codec = QTextCodec::codecForName("ISO 8859-1");
    m_TextDecoder = codec->makeDecoder();

    // setup
    if (! parseHeader())
        return;

    XFigPage* page = new XFigPage;

    while (! m_XFigStreamLineReader.readNextObjectLine()) {
        const int objectCode = m_XFigStreamLineReader.objectCode();
        const QString objectComment = m_XFigStreamLineReader.comment();

        if (objectCode == XFig3_2ColorObjectId) {
            parseColorObject();
        } else if ((XFig3_2EllipseObjectId<=objectCode) && (objectCode<=XFig3_2CompoundObjectId)) {
            XFigAbstractObject* object =
                (objectCode == XFig3_2EllipseObjectId) ?  parseEllipse() :
                (objectCode == XFig3_2PolylineObjectId) ? parsePolyline() :
                (objectCode == XFig3_2SplineObjectId) ?   parseSpline() :
                (objectCode == XFig3_2TextObjectId) ?     parseText() :
                (objectCode == XFig3_2ArcObjectId) ?      parseArc() :
                /*else XFig3_2CompoundObjectId)*/         parseCompoundObject();
            if (object != 0) {
                object->setComment(objectComment);
                page->addObject(object);
            }
        } else {
            // should not occur
            qWarning() << "unknown object type:" << objectCode;
        }
    }

    m_Document->addPage( page );
}
Exemplo n.º 29
0
/**
 *  \copydoc MythUIType::ParseElement()
 */
bool MythUIClock::ParseElement(
    const QString &filename, QDomElement &element, bool showWarnings)
{
    if (element.tagName() == "format" ||
        element.tagName() == "template")
    {
        QString format = parseText(element);
        format.replace("%TIME%", m_TimeFormat, Qt::CaseInsensitive);
        format.replace("%DATE%", m_DateFormat, Qt::CaseInsensitive);
        format.replace("%SHORTDATE%", m_ShortDateFormat, Qt::CaseInsensitive);
        m_Format = format;
        m_Message = QDateTime::currentDateTime().toString(m_Format);
    }
    else
    {
        m_Message = QDateTime::currentDateTime().toString(m_Format);
        return MythUIText::ParseElement(filename, element, showWarnings);
    }

    return true;
}
void GranularityStrategyTest::setupTextSpan(String str1, String str2, String str3, size_t selBegin, size_t selEnd)
{
    RefPtrWillBeRawPtr<Text> text1 = document().createTextNode(str1);
    RefPtrWillBeRawPtr<Text> text2 = document().createTextNode(str2);
    RefPtrWillBeRawPtr<Text> text3 = document().createTextNode(str3);
    RefPtrWillBeRawPtr<Element> span = HTMLSpanElement::create(document());
    Element* div = document().getElementById("mytext");
    div->appendChild(text1);
    div->appendChild(span);
    span->appendChild(text2);
    div->appendChild(text3);

    document().view()->updateAllLifecyclePhases();

    Vector<IntPoint> letterPos;
    Vector<IntPoint> wordMiddlePos;

    TextNodeVector textNodes;
    textNodes.append(text1);
    textNodes.append(text2);
    textNodes.append(text3);
    parseText(textNodes);

    Position p1;
    Position p2;
    if (selBegin < str1.length())
        p1 = Position(text1, selBegin);
    else if (selBegin < str1.length() + str2.length())
        p1 = Position(text2, selBegin - str1.length());
    else
        p1 = Position(text3, selBegin - str1.length() - str2.length());
    if (selEnd < str1.length())
        p2 = Position(text1, selEnd);
    else if (selEnd < str1.length() + str2.length())
        p2 = Position(text2, selEnd - str1.length());
    else
        p2 = Position(text3, selEnd - str1.length() - str2.length());

    selection().setSelection(VisibleSelection(p1, p2));
}