Пример #1
0
void MetarPlugin::downloadFailed (int state, QNetworkReply *reply, QNetworkReply::NetworkError code)
{
	(void)state; // There is only one download

	if (code==QNetworkReply::ContentNotFoundError)
		outputText (tr ("Error: METAR page not found (404)"));
	else
		outputText (reply->errorString ());
}
Пример #2
0
void MetarPlugin::downloadSucceeded (int state, QNetworkReply *reply)
{
	(void)state; // There is only one download

	QString metar=extractMetar (*reply);

	if (metar.isEmpty ())
		outputText (tr ("Error: no METAR found for %1").arg (airport));
	else
		outputText (metar);
}
Пример #3
0
void MetarPlugin::refresh ()
{
	QString icao=airport.trimmed ().toUpper ();

	if (icao.isEmpty ())
		outputText (tr ("No airport specified"));
	if (!airport.contains (QRegExp (notr ("^[A-Z]{4,4}$"))))
		outputText (tr ("%1 is not a valid ICAO code").arg (airport));
	else
	{
		QString url=qnotr ("http://weather.noaa.gov/mgetmetar.php?cccc=%1").arg (icao);
		outputText (tr ("Retrieving METAR for %1...").arg (icao));
		downloader->startDownload (0, url);
	}
}
void CTextInfoForm::OnClickedButtonSave()
{
	CString	filter;
	CString	filename;

	filter = _T("Log Files (*.log,*.txt)|*.log;*.txt|All Files (*.*)|*.*|");

	CFileDialog dlg(FALSE,_T("log"),NULL,OFN_OVERWRITEPROMPT|OFN_ENABLESIZING|OFN_PATHMUSTEXIST,filter);
    INT_PTR ret = dlg.DoModal();

	filename = dlg.GetPathName();
	if (ret == IDOK)
    {
		CPath path(filename);
		if (path.GetExtension() == _T(""))
        {
			path.AddExtension(_T(".log"));
			filename = CString(path);
		}

        CFile file(filename, CFile::modeCreate|CFile::modeWrite);
        
        CString	text;
        edit_report.GetWindowText(text);
        CT2CA outputText(text, CP_UTF8);
        file.Write(outputText, (DWORD) ::strlen(outputText));
    }
}
Пример #5
0
// Takes UTF16 input in logical order and applies Arabic shaping to the input while maintaining
// logical order. Output won't be intelligible until the bidirectional algorithm is applied
std::u16string applyArabicShaping(const std::u16string& input) {
    UErrorCode errorCode = U_ZERO_ERROR;

    const int32_t outputLength =
        u_shapeArabic(mbgl::utf16char_cast<const UChar*>(input.c_str()), static_cast<int32_t>(input.size()), nullptr, 0,
                      (U_SHAPE_LETTERS_SHAPE & U_SHAPE_LETTERS_MASK) |
                          (U_SHAPE_TEXT_DIRECTION_LOGICAL & U_SHAPE_TEXT_DIRECTION_MASK),
                      &errorCode);

    // Pre-flighting will always set U_BUFFER_OVERFLOW_ERROR
    errorCode = U_ZERO_ERROR;

    std::u16string outputText(outputLength, 0);

    u_shapeArabic(mbgl::utf16char_cast<const UChar*>(input.c_str()), static_cast<int32_t>(input.size()), mbgl::utf16char_cast<UChar*>(&outputText[0]), outputLength,
                  (U_SHAPE_LETTERS_SHAPE & U_SHAPE_LETTERS_MASK) |
                      (U_SHAPE_TEXT_DIRECTION_LOGICAL & U_SHAPE_TEXT_DIRECTION_MASK),
                  &errorCode);

    // If the algorithm fails for any reason, fall back to non-transformed text
    if (U_FAILURE(errorCode))
        return input;

    return outputText;
}
Пример #6
0
std::u16string BiDi::getLine(std::size_t start, std::size_t end) {
    UErrorCode errorCode = U_ZERO_ERROR;
    ubidi_setLine(impl->bidiText, static_cast<int32_t>(start), static_cast<int32_t>(end), impl->bidiLine, &errorCode);

    if (U_FAILURE(errorCode)) {
        throw std::runtime_error(std::string("BiDi::getLine (setLine): ") + u_errorName(errorCode));
    }

    // Because we set UBIDI_REMOVE_BIDI_CONTROLS, the output may be smaller than what we reserve
    //  Setting UBIDI_INSERT_LRM_FOR_NUMERIC would require
    //  ubidi_getLength(pBiDi)+2*ubidi_countRuns(pBiDi)
    const int32_t outputLength = ubidi_getProcessedLength(impl->bidiLine);
    std::u16string outputText(outputLength, 0);

    // UBIDI_DO_MIRRORING: Apply unicode mirroring of characters like parentheses
    // UBIDI_REMOVE_BIDI_CONTROLS: Now that all the lines are set, remove control characters so that
    // they don't show up on screen (some fonts have glyphs representing them)
    int32_t finalLength = ubidi_writeReordered(impl->bidiLine,
                                               mbgl::utf16char_cast<UChar*>(&outputText[0]),
                                               outputLength,
                                               UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS,
                                               &errorCode);

    outputText.resize(finalLength); // REMOVE_BIDI_CONTROLS may have shrunk the string

    if (U_FAILURE(errorCode)) {
        throw std::runtime_error(std::string("BiDi::getLine (writeReordered): ") +
                                 u_errorName(errorCode));
    }

    return outputText;
}
// functia pentru desenarea HUD-ului
void drawHUD()
{
    // obtinem limitele viewportului pentru calcularea aspectului
    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);

    // pregatim matricea de proiectie
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(viewport[0], viewport[2], viewport[3], viewport[1], -1, 20);


    // salveaza matricea MODELView
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    // pregateste noua matrice MODELView
    glLoadIdentity();

    /****** afiseaza elementele HUD-ului *****/
    glColor3f(1.0,1.0,1.0);

    // actualizez frame-rate
    frame++;
    int time = glutGet(GLUT_ELAPSED_TIME);
    if (time - last_time > 1000) {
        fps = frame * 1000.0 / (time - last_time);
        last_time = time;
        frame = 0;
    }


    // afiseaza texte
    outputText(HUD_COLUMN_1,HUD_TOP,0,"Sistem curent: %d/%d) %s",currentTest, testCount, psDescriptions.c_str());
    outputText(HUD_COLUMN_1,HUD_TOP+HUD_SPACING,0,"Numar Particule: %d",manager->getParticleCount());
    outputText(HUD_FPS, HUD_TOP, 0,"FPS: %2.3f", fps);


    // revenim la matricea MODELView anterioara
    glPopMatrix();

    // revenim la matricea de proiectie normala
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

}
Пример #8
0
void UpgradeChecker::reportError(const QString& s)
{
	if (!m_errorReported)
	{
		outputText("<br/><b>"+ tr("Error: %1").arg(s)+"</b>");
		m_errorReported=true;
	}
}
Пример #9
0
bool InjectedBundle::booleanForKey(WKDictionaryRef dictionary, const char* key)
{
    WKRetainPtr<WKStringRef> wkKey(AdoptWK, WKStringCreateWithUTF8CString(key));
    WKTypeRef value = WKDictionaryGetItemForKey(dictionary, wkKey.get());
    if (WKGetTypeID(value) != WKBooleanGetTypeID()) {
        outputText(makeString("Boolean value for key", key, " not found in dictionary\n"));
        return false;
    }
    return WKBooleanGetValue(static_cast<WKBooleanRef>(value));
}
Пример #10
0
void UpgradeChecker::downloadFinished()
{
	if (m_networkReply->error())
		outputText(QString("Failed: %1").arg(qPrintable(m_networkReply->errorString())));
	else
	{
		m_file->reset();
		process();
		m_fin=true;
		show(m_networkReply->error()!=QNetworkReply::NoError);
	}
}
Пример #11
0
wxString Ocr::recognize(const wxImage & image) const
{
  char * text = _api->TesseractRect(image.GetData(), 
                                    3,
                                    3 * image.GetWidth(),
                                    0,
                                    0,
                                    image.GetWidth(),
                                    image.GetHeight());
  wxString outputText(text, wxConvUTF8);
  delete[] text;
  return outputText;
}
Пример #12
0
void DecoderSingleTest::run( BeamSearchDecoder *decoder , FILE *archive_fd )
{
    clock_t start_time , end_time ;
    int start_index = 0 ;

    // The data file hasn't been loaded yet - load it
    loadDataFile( archive_fd ) ;

    // Now look at the type of data that was in the file and compare it with the
    //   type expected by the phone set.
    if ( ((n_emission_probs == 0) && (phone_models->input_vecs_are_features == false)) ||
         ((n_features == 0) && (phone_models->input_vecs_are_features == true)) )
    {
        // We've got feature vectors (or nothing), but the phone_models is expecting
        //   vectors of emission probabilities (or vice versa).
        error("DecoderSingleTest::run - datafile format does not agree with phone_models\n") ;
    }

    if ( (n_features != phone_models->n_features) && 
         (n_emission_probs != phone_models->n_emission_probs) )
    {
        error("DecoderSingleTest::run - input vector size does not agree with phone_models\n") ;
    }
   
    // If the input vectors are features and we are calculating emission probs
    //   using an MLP, we need to initialise the context window of the MLP.
    if ( (phone_models->input_vecs_are_features == true) && (phone_models->mlp != NULL) )
        start_index = phone_models->mlp->initContextWindow( decoder_input ) ;
    n_frames -= start_index ;
    
    // invoke the decoder
    start_time = clock() ;
    decoder->decode( decoder_input+start_index , n_frames , &n_actual_words , 
                     &actual_words , &actual_words_times ) ;
    end_time = clock() ;
    decode_time = (real)(end_time-start_time) / CLOCKS_PER_SEC ;
    
    // process the decoding result
    if ( remove_sent_marks == true )
        removeSentMarksFromActual( decoder->vocabulary ) ;
    if ( output_result == true )
        outputText( decoder->vocabulary ) ;

    // Free up some memory
    for( int i=0 ; i<(n_frames+start_index) ; i++ )
        free( decoder_input[i] ) ;
    free( decoder_input ) ;
    decoder_input = NULL ;
    n_emission_probs = 0 ;
    n_features = 0 ;
}
Пример #13
0
inline void CommInterface::onInputLine(std::string line)
{
	inputStream << line << "\n";
	if (line == "go"||
		line == "ready")
	{
		emit processTurn();
		inputStream.str("");

		std::string text = outputStream.str();
		QByteArray buf(text.c_str(), text.size());
		outputText(buf);
		outputStream.clear();
		outputStream.str("");
	}
}
Пример #14
0
void UpgradeChecker::fetch()
{
	QString filename("scribusversions.xml");
	m_tempFile=ScPaths::getTempFileDir()+filename;

	m_fin=false;

	m_file=new QFile(m_tempFile);
	m_networkManager=new QNetworkAccessManager(this);
	if (m_networkManager!=0 && m_file!=0)
	{
		outputText( tr("No data on your computer will be sent to an external location"));
		qApp->processEvents();
		if(m_file->open(QIODevice::ReadWrite))
		{
			QString hostname("services.scribus.net");
			QString filepath("/"+filename);
			QUrl fileURL(QString("http://%1%2").arg(hostname).arg(filepath));
			outputText("<b>"+ tr("Attempting to get the Scribus version update file:")+"</b>");
			outputText(fileURL.toString());

			QNetworkRequest networkRequest(fileURL);
			m_networkReply = m_networkManager->get(networkRequest);
			connect(m_networkReply, SIGNAL(finished()), SLOT(downloadFinished()));
			connect(m_networkReply, SIGNAL(readyRead()), SLOT(downloadReadyRead()));

			int waitCount=0;
			while (!m_fin && waitCount<20)
			{
					sleep(1);
					++waitCount;
					if (m_writeToConsole)
							std::cout << ". " << std::flush;
					outputText( ".", true );
					qApp->processEvents();
			}
			if (m_writeToConsole)
					std::cout << std::endl;
			if (waitCount>=20)
			{
					outputText("<b>"+ tr("Timed out when attempting to get update file.")+"</b>");
			}
			m_file->close();
		}
		m_file->remove();
	}
	delete m_file;
	m_file=0;
	outputText( tr("Finished") );
	m_networkReply->deleteLater();
	m_networkManager->deleteLater();
}
Пример #15
0
void UpgradeChecker::show(bool error)
{
	outputText("<br/>");
	if (error)
	{
		outputText("<b>"+ tr("An error occurred while looking for updates for Scribus, please check your internet connection.")+"</b>");
		return;
	}
	if (m_updates.isEmpty())
		outputText("<b>"+ tr("No updates are available for your version of Scribus %1").arg(m_version)+"</b>");
	else
	{
		outputText("<b>"+ tr("One or more updates for your version of Scribus (%1) are available:").arg(m_version)+"</b>");
		outputText( tr("This list may contain development/unstable versions."));
		for ( QStringList::Iterator it = m_updates.begin(); it != m_updates.end(); ++it )
			outputText(*it);
		outputText("<b>"+ tr("Please visit www.scribus.net for details.")+"</b>");
	}
	outputText(m_message);
}
Пример #16
0
void ExternalInfoPlugin::start ()
{
	terminate ();

	if (isBlank (command)) OUTPUT_AND_RETURN (tr ("No command specified"));

	QString commandProper;
	QString parameters;
	SkProcess::splitCommand (commandProper, parameters, command);

	QString resolved=resolveFilename (commandProper, Settings::instance ().pluginPaths);
	if (isBlank (resolved)) OUTPUT_AND_RETURN (tr ("Command not found"));
	if (!QFile::exists (resolved)) OUTPUT_AND_RETURN (tr ("Command does not exist"));

	if (!process->startAndWait (resolved+notr (" ")+parameters)) OUTPUT_AND_RETURN (tr ("Error: %1").arg (process->getProcess ()->errorString ()));
	outputText (tr ("Process started"));

	// Note that on Windows, we may have to add the interpreter explicitly.
}
Пример #17
0
bool MTest::compareFiles(const QString& saveName, const QString& compareWith) const
{
    QString cmd = "diff";
    QStringList args;
    args.append("-u");
    args.append(saveName);
    args.append(root + "/" + compareWith);
    QProcess p;
    qDebug() << "Running " << cmd << " with arg1:" << saveName << " and arg2: " << compareWith;
    p.start(cmd, args);
    if (!p.waitForFinished() || p.exitCode()) {
        QByteArray ba = p.readAll();
        //qDebug("%s", qPrintable(ba));
        //qDebug("   <diff -u %s %s failed", qPrintable(saveName),
        //   qPrintable(QString(root + "/" + compareWith)));
        QTextStream outputText(stdout);
        outputText << QString(ba);
        outputText << QString("   <diff -u %1 %2 failed").arg(QString(saveName)).arg(QString(root + "/" + compareWith));
        return false;
    }
    return true;
}
Пример #18
0
std::u16string BiDi::writeReverse(const std::u16string& input, std::size_t logicalStart, std::size_t logicalEnd) {
    UErrorCode errorCode = U_ZERO_ERROR;
    int32_t logicalLength = static_cast<int32_t>(logicalEnd - logicalStart);
    std::u16string outputText(logicalLength + 1, 0);
    
    // UBIDI_DO_MIRRORING: Apply unicode mirroring of characters like parentheses
    // UBIDI_REMOVE_BIDI_CONTROLS: Now that all the lines are set, remove control characters so that
    // they don't show up on screen (some fonts have glyphs representing them)
    int32_t outputLength =
        ubidi_writeReverse(mbgl::utf16char_cast<const UChar*>(&input[logicalStart]),
                           logicalLength,
                           mbgl::utf16char_cast<UChar*>(&outputText[0]),
                           logicalLength + 1, // Extra room for null terminator, although we don't really need to have ICU write it for us
                           UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS,
                           &errorCode);
    
    if (U_FAILURE(errorCode)) {
        throw std::runtime_error(std::string("BiDi::writeReverse: ") + u_errorName(errorCode));
    }
    
    outputText.resize(outputLength); // REMOVE_BIDI_CONTROLS may have shrunk the string

    return outputText;
}
Пример #19
0
void ConsoleBox::errorThrowAction(std::string* _message)
{
  outputText("> " + *_message, false, 0, 0xFFFF0000);
}
Пример #20
0
void ConsoleBox::outputPrintAction(std::string* _message)
{
  outputText("> " + *_message, false);
}
Пример #21
0
void ConsoleBox::inputPrintAction(std::string* _message)
{
  outputText("$:" + *_message);
}
Пример #22
0
bool UpgradeChecker::process()
{
	if (!m_file)
		return false;
	QTextStream ts(m_file);
	ts.setCodec(QTextCodec::codecForName("UTF-8"));
	QString errorMsg;
	int eline;
	int ecol;
	QDomDocument doc( "scribusversions" );
	QString data(ts.readAll());
	if ( !doc.setContent( data, &errorMsg, &eline, &ecol )) 
	{
		if (data.toLower().contains("404 not found"))
			outputText("<b>"+ tr("File not found on server")+"</b>");
		else
			outputText("<b>"+ tr("Could not open version file: %1\nError:%2 at line: %3, row: %4").arg(m_file->fileName()).arg(errorMsg).arg(eline).arg(ecol)+"</b>");
		return false;
	}
	
	QDomElement docElem = doc.documentElement();
	QDomNode n = docElem.firstChild();
	while( !n.isNull() ) {
		QDomElement e = n.toElement();
		if( !e.isNull() ) {
			if (e.tagName()=="release")
			{
				if (e.hasAttribute("stability") && e.hasAttribute("platform") && e.hasAttribute("version"))
				{
					if (e.attribute("platform")==m_platform)
					{
						bool newVersion = false;
						QString verA(e.attribute("version"));
						QString verAStripped=verA.toLower();
						bool verIsCVS=verAStripped.contains("cvs");
						if (verIsCVS)
							verAStripped.remove("cvs");
						uint verMajor=verAStripped.section('.',0,0).toInt();
						uint verMinor=verAStripped.section('.',1,1).toInt();
						uint verRevsion1=verAStripped.section('.',2,2).toInt();
						uint verRevsion2=verAStripped.section('.',3,3).toInt();
						//If we found a release whe a user is running an old CVS version
						if (verMajor==major && verMinor==minor && verRevsion1==m_revision1 && verRevsion2==m_revision2 && m_isCVS && !verIsCVS && !m_updates.contains(verA))
							newVersion = true;
						else
						//If we found a version that is not the same as what we are running
						if (!(verMajor==major && verMinor==minor && verRevsion1==m_revision1 && verRevsion2==m_revision2))
						{
							if (
								((verMajor>major) ||
								(verMajor==major && verMinor>minor) ||
								(verMajor==major && verMinor==minor && verRevsion1>m_revision1) ||
								(verMajor==major && verMinor==minor && verRevsion1==m_revision1 && verRevsion2>m_revision2))
								&& !m_updates.contains(verA)
								)
								newVersion = true;
						}
						if (newVersion)
						{
							QString ver = verA;
							QString link = e.attribute("link", "");
							if (!link.isEmpty())
							{
								QString linkStr = QString("<a href=\"%1\">%2</a>").arg(link).arg(link);
								ver = QString("%1 : %2").arg(verA).arg(linkStr);
							}
							m_updates.append(ver);
						}
					}
				}
			}
			else
			if (e.tagName()=="message")
			{
				m_message+=e.text();
			}
		}
		n = n.nextSibling();
	}
	return true;
}
Пример #23
0
void ExternalInfoPlugin::lineReceived (const QString &line)
{
	outputText (line, richText?Qt::RichText:Qt::PlainText);
}
Пример #24
0
void display()
{
   ImObj current = Controller.curr;
   float zoom = Controller.GZOOM;


   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   glOrtho (0, current.w*zoom, current.h*zoom, 0, -1, 1);
   glMatrixMode (GL_MODELVIEW);



   if(1){

      // TODO: THE TEXTURE DOES NOT NEED TO BE CREATED AND DESTROYED AT EACH DISPLAY CYCLE
      // allocate a texture name
      GLuint texture;
      glGenTextures( 1, &texture);

      // select our current texture
      glBindTexture( GL_TEXTURE_2D, texture );

      // select modulate to mix texture with color for shading
      glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
      // when texture area is small, bilinear filter the closest mipmap
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
      // when texture area is large, bilinear filter the first mipmap
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);


      float* data2   = current.x;
      int width      = current.w;
      int height     = current.h;

      // SCALE THE RANGE

      glPixelTransferf( GL_RED_BIAS,   Controller.GSHIFT);
      glPixelTransferf( GL_GREEN_BIAS, Controller.GSHIFT);
      glPixelTransferf( GL_BLUE_BIAS,  Controller.GSHIFT);

      glPixelTransferf( GL_RED_SCALE,   1./Controller.GSCALE);
      glPixelTransferf( GL_GREEN_SCALE, 1./Controller.GSCALE);
      glPixelTransferf( GL_BLUE_SCALE,  1./Controller.GSCALE);

      // build our texture mipmaps
      if(current.dim ==3)
           glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width,height, 0, GL_RGB, GL_FLOAT, data2);
//         gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, GL_RGB , GL_FLOAT, data2 );
      if(current.dim ==1)
           glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width,height, 0, GL_LUMINANCE, GL_FLOAT, data2);
//         gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, GL_LUMINANCE , GL_FLOAT, data2 );
      if(current.dim ==4)
           glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width,height, 0, GL_RGBA, GL_FLOAT, data2);
//         gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, GL_RGBA , GL_FLOAT, data2 );
      if(current.dim ==2)
           glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, width,height, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, data2);
 //        gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height, GL_LUMINANCE_ALPHA , GL_FLOAT, data2 );  



      glEnable( GL_TEXTURE_2D );
      glBegin( GL_QUADS );
      glColor3f(1.0, 1.0, 1.0);
      glTexCoord2d(0.0,0.0); glVertex3d(0,0,0);
      glTexCoord2d(1.0,0.0); glVertex3d(width *zoom,0,0);
      glTexCoord2d(1.0,1.0); glVertex3d(width *zoom ,height*zoom,0);
      glTexCoord2d(0.0,1.0); glVertex3d(0,height*zoom,0);
      glEnd();
      glDisable( GL_TEXTURE_2D );
      glDeleteTextures( 1, &texture );
   }

   // write text
   if(0){
      //  glClear(GL_COLOR_BUFFER_BIT);
      char teststr[1024];
      //glClearColor(0, 0, 0, 1);
      glColor3f(0.0, 1.0, 0.0);

      glPushMatrix();

      glTranslatef(-.5, -.5, 0);

      sprintf(teststr, "Keys 1 to 6 display objects");
      outputText(0.,0.,teststr);

      glPopMatrix();

   }


   glutSwapBuffers();
}
void CStatisticForm::OnExportClick()
{
	CString	fileFilter;
	CString	filename;

	fileFilter = _T("CSV Files (*.csv)|*.csv|All Files (*.*)|*.*|");

	CFileDialog dlg(FALSE,_T("statistics"),NULL,OFN_OVERWRITEPROMPT|OFN_ENABLESIZING|OFN_PATHMUSTEXIST,fileFilter);
    INT_PTR ret = dlg.DoModal();

	filename = dlg.GetPathName();
	if (ret == IDOK)
    {
		CPath path(filename);
		if (path.GetExtension() == _T(""))
        {
			path.AddExtension(_T(".csv"));
			filename = CString(path);
		}

        CFile file(filename, CFile::modeCreate|CFile::modeWrite);
        CString csvSep = GetCsvSeparator();

        // Output header
        CString row = _T("");
        for(int field=0; field < 7; field++)
        {
            LVCOLUMN column = { 0 };
            column.mask = LVCF_TEXT;
            column.cchTextMax = 100;
            column.pszText = new TCHAR[column.cchTextMax];
            m_listCtrl.GetColumn(field, &column);

            if (field > 0)
                row.Append(csvSep);
            row.Append(column.pszText);

            delete [] column.pszText;
        }
        row.Append(_T("\n"));
        CT2CA outputHeaderText(row, CP_UTF8);
        file.Write(outputHeaderText, (DWORD) ::strlen(outputHeaderText));

        // Output data
        const LONG entryCount = GetEntryCount(false);
        for(LONG i = 0; i<entryCount; i++)
        {
            row = _T("");
            for(int field=0; field<7; field++)
            {
                if (field > 0)
                    row.Append(csvSep);
                row.Append(GetEntryString(i,field));
            }
            row.Append(_T("\n"));

            CT2CA outputText(row, CP_UTF8);
            file.Write(outputText, (DWORD) ::strlen(outputText));
        }
    }
}
Пример #26
0
/*
 * StatusWndDrawLine - draws a line in the status bar
 */
void StatusWndDrawLine( statwnd *sw, WPI_PRES pres, WPI_FONT hfont, const char *str, UINT flags )
{
    WPI_RECT    rect;
    char        buff[256];
    char        *bptr;
    int         curr_block;

    curr_block = 0;
#ifdef __NT__
    hfont = hfont;
    sw->sectionDataFont = systemDataFont;
#else
    sw->sectionDataFont = hfont;
#endif
#ifdef __NT__
    if( !IsCommCtrlLoaded() ) {
#endif
        if( !initPRES( sw, pres ) ) {
            return;
        }
        getRect( sw, &rect, curr_block );
        makeInsideRect( &rect );
        bptr = (char *)str;
        if( flags == DT_ESC_CONTROLLED  ) {
            flags = DT_VCENTER | DT_LEFT;
            bptr = buff;
            while( *str != '\0' ) {
                if( *str == STATUS_ESC_CHAR ) {
                    str++;
                    switch( *str ) {
                    case STATUS_NEXT_BLOCK:
                        *bptr = '\0';
                        outputText( sw, pres, buff, &rect, flags, curr_block );
                        curr_block++;
                        getRect( sw, &rect, curr_block );
                        makeInsideRect( &rect );
                        flags = DT_VCENTER | DT_LEFT;
                        bptr = buff;
                        break;
                    case STATUS_FORMAT_CENTER:
                        flags &= ~(DT_RIGHT | DT_LEFT);
                        flags |= DT_CENTER;
                        break;
                    case STATUS_FORMAT_RIGHT:
                        flags &= ~(DT_CENTER | DT_LEFT);
                        flags |= DT_RIGHT;
                        break;
                    case STATUS_FORMAT_LEFT:
                        flags &= ~(DT_CENTER | DT_RIGHT);
                        flags |= DT_LEFT;
                        break;
                    }
                } else {
                    *bptr++ = *str;
                }
                str++;
            }
            *bptr = '\0';
            bptr = buff;
        }
        outputText( sw, pres, bptr, &rect, flags, curr_block );
        finiPRES( pres );
#ifdef __NT__
    } else {
        bptr = (char *)str;
        if( flags == DT_ESC_CONTROLLED ) {
            bptr = buff;
            while( *str != '\0' ) {
                if( *str == STATUS_ESC_CHAR ) {
                    str++;
                    if( *str == STATUS_NEXT_BLOCK ) {
                        *bptr = '\0';
                        if( strlen( buff ) > 0 ) {
                            SendMessage( sw->win, SB_SETTEXT, curr_block, (LPARAM)buff );
                        }
                        curr_block++;
                        bptr = buff;
                    }
                } else {
                    *bptr++ = *str;
                }
                str++;
            }
            *bptr = '\0';
            bptr = buff;
        }
        if( strlen( bptr ) > 0 ) {
            SendMessage( sw->win, SB_SETTEXT, curr_block, (LPARAM)bptr );
        }
    }
#endif

} /* StatusWndDrawLine */