예제 #1
0
void KPrWebPresentation::writeStartOfHeader(QTextStream& streamOut, QTextCodec *codec, const QString& subtitle, const QString& next)
{
    QString mimeName ( codec->mimeName() );
    if ( isXML() )
    {   //Write out the XML declaration
        streamOut << "<?xml version=\"1.0\" encoding=\""
                  << mimeName << "\"?>\n";
    }
    // write <!DOCTYPE
    streamOut << "<!DOCTYPE ";
    if ( isXML() )
    {
        streamOut << "html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"";
        streamOut << " \"DTD/xhtml1-transitional.dtd\">\n";
    }
    else
    {
        streamOut << "HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"";
        streamOut << " \"http://www.w3.org/TR/html4/loose.dtd\">\n";
    }
    streamOut << "<html";
    if ( isXML() )
    {
        // XHTML has an extra attribute defining its namespace (in the <html> opening tag)
        streamOut << " xmlns=\"http://www.w3.org/1999/xhtml\"";
    }
    streamOut << ">\n" << "<head>\n";

    // Declare what charset we are using
    streamOut << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=";
    streamOut << mimeName << '"' << ( isXML() ?" /":"") << ">\n" ;

    // Tell who we are (with the CVS revision number) in case we have a bug in our output!
    QString strVersion("$Revision: 508787 $");
    // Eliminate the dollar signs
    //  (We don't want that the version number changes if the HTML file is itself put in a CVS storage.)
    streamOut << "<meta name=\"Generator\" content=\"KPresenter's Web Presentation "
              << strVersion.mid(10).replace("$","")
              << "\""<< ( isXML() ?" /":"") // X(HT)ML closes empty elements, HTML not!
              << ">\n";

    // Load the next slide after time elapsed
    if ( (timeBetweenSlides > 0) && ( ! next.isNull() ) )
    {
        streamOut << "<meta http-equiv=\"refresh\" content=\""
                  << timeBetweenSlides
                  << ";url=" << next
                  << "\">\n";
    }

    streamOut << "<title>"<< escapeHtmlText( codec, title ) << " - " << escapeHtmlText( codec, subtitle ) << "</title>\n";

    // ### TODO: transform documentinfo.xml into many <META> elements (at least the author!)
}
예제 #2
0
/**Função que prepara as figuras para desenhar a partir de uma fonte .xml e invoca o ciclo glut*/
int gerar_cena(vector<string> args)
{
	string filename;
	string form;

	if (args.size() < 2){
		cout << ERROR_NUMBER_ARGS;
		return -1;
	}
	try{
		filename = args.at(1);
		if (isXML(filename) && lookUpFile(filename)){
			printf("a recolher dados para desenhar cena ...\n");
			readFromXML(filename); // Internamente à leitura geramos os modelos enquanto que na 1ª etapa
								   // eram gerados nesta mesma função
		
			// Chamada explícita para desenhar cena
			prepare_glut();
		}
	}
	catch (invalid_argument ia){
		cout << ERROR_INVALID_ARGS;
	}
	return -1;
}
예제 #3
0
/**Função que prepara as figuras para desenhar a partir de uma fonte .xml e invoca o ciclo glut*/
int gerar_cena(vector<string> args)
{
	string filename;
	string form;

	if (args.size() < 2){
		cout << ERROR_NUMBER_ARGS;
		return -1;
	}
	try{
		filename = args.at(1);
		if (isXML(filename) && lookUpFile(filename)){
			printf("a recolher dados para desenhar cena ...\n");
			vector<string> files = readFromXML(filename);
			for (std::vector<string>::iterator it = files.begin(); it != files.end(); ++it){
				ifstream f((*it));
				f >> form;

				Forma* s;
				if (form.compare(FORMA_RECTANGULO) == 0){
					s = new Rectangulo();
				}
				else if (form.compare(FORMA_TRIANGULO) == 0){
					s = new Triangulo();
				}
				else if (form.compare(FORMA_CIRCULO) == 0){
					s = new Circulo();
				}
				else if (form.compare(FORMA_PARALEL) == 0){
					s = new Paralelepipedo();
				}
				else if (form.compare(FORMA_ESFERA)==0){
					s = new Esfera();
				}
				else if (form.compare(FORMA_CONE)==0){
					s = new Cone();
				}
				s->read3DfromFile((*it));
				Formas.push_back(s);
			}
			// Chamada explícita para desenhar cena
			prepare_glut();
		}
	}
	catch (invalid_argument ia){
		cout << ERROR_INVALID_ARGS;
	}
	return -1;
}
예제 #4
0
    // Read APNGAsm object from spec file.
    // Return true if read succeeded.
    bool SpecReader::read(const std::string& filePath)
    {
      if( !_pApngasm )
        return false;

      boost::scoped_ptr<priv::ISpecReaderImpl> pImpl;

      // json file.
      if( isJSON(filePath) )
      {
        pImpl.reset(new priv::JSONSpecReaderImpl());
      }
      // xml file.
      else if( isXML(filePath) )
      {
        pImpl.reset(new priv::XMLSpecReaderImpl());
      }
      // unknown file.
      else
        return false;

      // Read frame information from spec file.
      if( !pImpl->read(filePath) )
        return false;

      // Create frames from spec file.
      const std::vector<priv::FrameInfo>& frameInfos = pImpl->getFrameInfos();
      const int count = frameInfos.size();
      for(int i = 0;  i < count;  ++i)
      {
        const priv::FrameInfo& current = frameInfos[i];
        _pApngasm->addFrame(current.filePath, current.delay.num, current.delay.den);
      }

      // Set parameter from spec file.
      _pApngasm->setLoops(pImpl->getLoops());
      _pApngasm->setSkipFirst(pImpl->isSkipFirst());

      return true;
    }
예제 #5
0
void KPrWebPresentation::createSlidesHTML( KProgress *progressBar )
{
    QTextCodec *codec = KGlobal::charsets()->codecForName( m_encoding );

    const QString brtag ( "<br" + QString(isXML()?" /":"") + ">" );

    for ( unsigned int i = 0; i < slideInfos.count(); i++ ) {

        unsigned int pgNum = i + 1; // pgquiles # elpauer . org - I think this is a bug, seems to be an overflow if we have max_unsigned_int slides
        KTempFile tmp;
        QString dest= QString( "%1/html/slide_%2.html" ).arg( path ).arg( pgNum );
        QString next= QString( "slide_%2.html" ).arg( pgNum<slideInfos.count() ? pgNum+1 : (m_bLoopSlides ? 1 : pgNum ) ); // Ugly, but it works

        QFile file( tmp.name() );
        file.open( IO_WriteOnly );
        QTextStream streamOut( &file );
        streamOut.setCodec( codec );

        writeStartOfHeader( streamOut, codec, slideInfos[ i ].slideTitle, next );

        // ### TODO: transform documentinfo.xml into many <META> elements (at least the author!)

        if ( i > 0 ) {
            streamOut <<  "<link rel=\"first\" href=\"slide_1.html\"" << ( isXML() ?" /":"") << ">\n";
            streamOut <<  "<link rel=\"prev\" href=\"slide_" << pgNum - 1 << ".html\"" << ( isXML() ?" /":"") << ">\n";
        }
        if ( i < slideInfos.count() - 1 ) {
            streamOut <<  "<link rel=\"next\" href=\"slide_" << pgNum + 1 << ".html\"" << ( isXML() ?" /":"") << ">\n";
            streamOut <<  "<link rel=\"last\" href=\"slide_" << slideInfos.count() << ".html\"" << ( isXML() ?" /":"") << ">\n";
        }
        streamOut <<  "<link rel=\"contents\" href=\"../index.html\"" << ( isXML() ?" /":"") << ">\n";

        streamOut << "</head>\n";
        streamOut << "<body bgcolor=\"" << backColor.name() << "\" text=\"" << textColor.name() << "\">\n";

        if (m_bWriteHeader) {
            streamOut << "  <center>\n";

            if ( i > 0 )
                streamOut << "    <a href=\"slide_1.html\">";
                streamOut << "<img src=\"../pics/first.png\" border=\"0\" alt=\"" << i18n( "First" )
                              << "\" title=\"" << i18n( "First" ) << "\"" << ( isXML() ?" /":"") << ">";
            if ( i > 0 )
                streamOut << "</a>";

            streamOut << "\n";

            if ( i > 0 )
                streamOut << "    <a href=\"slide_" << pgNum - 1 << ".html\">";
                streamOut << "<img src=\"../pics/prev.png\" border=\"0\" alt=\"" << i18n( "Previous" )
                              << "\" title=\"" << i18n( "Previous" ) << "\"" << ( isXML() ?" /":"") << ">";
            if ( i > 0 )
                streamOut << "</a>";

            streamOut << "\n";

            if ( (m_bLoopSlides) || (i < slideInfos.count() - 1 ) )
                streamOut << "    <a href=\"" << next << "\">";
                streamOut << "<img src=\"../pics/next.png\" border=\"0\" alt=\"" << i18n( "Next" )
                          << "\" title=\"" << i18n( "Next" ) << "\"" << ( isXML() ?" /":"") << ">";
            if ( (m_bLoopSlides) || (i < slideInfos.count() - 1 ) )
                streamOut << "</a>";

            streamOut << "\n";

            if ( i < slideInfos.count() - 1 )
                streamOut << "    <a href=\"slide_" << slideInfos.count() << ".html\">";
                streamOut << "<img src=\"../pics/last.png\" border=\"0\" alt=\"" << i18n( "Last" )
                      << "\" title=\"" << i18n( "Last" ) << "\"" << ( isXML() ?" /":"") << ">";
            if ( i < slideInfos.count() - 1 )
                streamOut << "</a>";

            streamOut << "\n" << "    &nbsp; &nbsp; &nbsp; &nbsp;\n";

            streamOut << "    <a href=\"../index.html\">";
            streamOut << "<img src=\"../pics/home.png\" border=\"0\" alt=\"" << i18n( "Home" )
                      << "\" title=\"" << i18n( "Home" ) << "\"" << ( isXML() ?" /":"") << ">";
            streamOut << "</a>\n";

            streamOut << " </center>" << brtag << "<hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">\n"; // ### TODO: is noshade W3C?

            streamOut << "  <center>\n    <font color=\"" << escapeHtmlText( codec, titleColor.name() ) << "\">\n";
            streamOut << "    <b>" << escapeHtmlText( codec, title ) << "</b> - <i>" << escapeHtmlText( codec, slideInfos[ i ].slideTitle ) << "</i>\n";

            streamOut << "    </font>\n  </center>\n";

            streamOut << "<hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">" << brtag << "\n";
	}

        streamOut << "  <center>\n    ";

	if ( (m_bLoopSlides) || (i < slideInfos.count() - 1) )
            streamOut << "<a href=\"" << next << "\">";

	    streamOut << "<img src=\"../pics/slide_" << pgNum << ".png\" border=\"0\" alt=\""
                      << i18n( "Slide %1" ).arg( pgNum ) << "\"" << ( isXML() ?" /":"") << ">";

	    if ( i < slideInfos.count() - 1 )
                streamOut << "</a>";

            streamOut << "\n";

            streamOut << "    </center>\n";

	if (m_bWriteFooter) {
	    	streamOut << brtag << "<hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">\n";

            QPtrList<KPrPage> _tmpList( doc->getPageList() );
            QString note ( escapeHtmlText( codec, _tmpList.at(i)->noteText() ) );
            if ( !note.isEmpty() ) {
                streamOut << "  <b>" << escapeHtmlText( codec, i18n( "Note" ) ) << "</b>\n";
                streamOut << " <blockquote>\n";

                streamOut << note.replace( "\n", brtag );

                streamOut << "  </blockquote><hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">\n";
            }

            streamOut << "  <center>\n";

            QString htmlAuthor;
            if (email.isEmpty())
                htmlAuthor=escapeHtmlText( codec, author );
            else
                htmlAuthor=QString("<a href=\"mailto:%1\">%2</a>").arg( escapeHtmlText( codec, email )).arg( escapeHtmlText( codec, author ));
            streamOut << EscapeEncodingOnly ( codec, i18n( "Created on %1 by <i>%2</i> with <a href=\"http://www.koffice.org/kpresenter\">KPresenter</a>" )
                                          .arg( KGlobal::locale()->formatDate ( QDate::currentDate() ) ).arg( htmlAuthor ) );

            streamOut << "    </center><hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">\n";
        }

        streamOut << "</body>\n</html>\n";

        file.close();

        KIO::NetAccess::file_move( tmp.name(), dest, -1, true /*overwrite*/);

        int p = progressBar->progress();
        progressBar->setProgress( ++p );
        kapp->processEvents();
    }
}