Esempio n. 1
0
void MainWindow::autoConvert(QString fromFile, QString toFile)
{
   QFile file(fromFile);
   if (! file.open(QIODevice::ReadOnly)) {
      printf("Error: Unable to open %s, error %s", csPrintable(fromFile), csPrintable(file.error()) );
      return;
   }

   // read file
   QByteArray data;

   data = file.readAll();
   file.close();

   // strip comments
   int posBeg;
   int posEnd;

   while (true) {
      posBeg = data.indexOf("#");

      if (posBeg == -1) {
         break;
      }

      posEnd = data.indexOf("\n",posBeg);
      data.remove(posBeg, posEnd-posBeg);
   }

   // verify a few fields to ensure this is an old project file
   if (! data.contains("PROJECT_NAME") || ! data.contains("OUTPUT_DIRECTORY"))  {
      printf("Doxygen project file is missing required information, Convert aborted");
      return;
   }

   m_curFile = toFile;

   convertDoxy(data);
   saveDoxy_Internal();
}
void LatexDocVisitor::visit(DocVerbatim *s)
{
   if (m_hide) {
      return;
   }

   QString lang = m_langExt;
   if (! s->language().isEmpty()) { 
      // explicit language setting
      lang = s->language();
   }

   SrcLangExt langExt = getLanguageFromFileName(lang);

   switch (s->type()) {
      case DocVerbatim::Code: {
         m_t << "\n\\begin{DoxyCode}\n";
         Doxy_Globals::parserManager->getParser(lang)
         ->parseCode(m_ci, s->context(), s->text(), langExt,
                     s->isExample(), s->exampleFile());
         m_t << "\\end{DoxyCode}\n";
      }
      break;

      case DocVerbatim::Verbatim:
         m_t << "\\begin{DoxyVerb}";
         m_t << s->text();
         m_t << "\\end{DoxyVerb}\n";
         break;

      case DocVerbatim::HtmlOnly:
      case DocVerbatim::XmlOnly:
      case DocVerbatim::ManOnly:
      case DocVerbatim::RtfOnly:
      case DocVerbatim::DocbookOnly:
         /* nothing */
         break;

      case DocVerbatim::LatexOnly:
         m_t << s->text();
         break;

      case DocVerbatim::Dot: {
         static int dotindex = 1;

         QString latexOutput = Config::getString("latex-output") + "/inline_dotgraph_";        
         QString fileName = QString("%1%2.dot").arg(latexOutput).arg(dotindex++);

         QFile file(fileName);

         if (! file.open(QIODevice::WriteOnly)) {
            err("Unable to open file %s for writing, error: %d\n", csPrintable(fileName), file.error()); 
 
         } else {

            file.write( s->text().toUtf8() );
            file.close();
       
            startDotFile(fileName, s->width(), s->height(), s->hasCaption());
            visitCaption(this, s->children());
            endDotFile(s->hasCaption());

            if (Config::getBool("dot-cleanup")) {
               file.remove();
            }
         } 
      }
      break;

      case DocVerbatim::Msc: {
         static int mscindex = 1;

         QString latexOutput = Config::getString("latex-output") + "/inline_mscgraph_";
         QString baseName = QString("%1%2").arg(latexOutput).arg(mscindex++);

         QFile file(baseName + ".msc");

         if (! file.open(QIODevice::WriteOnly)) {
            err("Unable to open file %s.msc for writing, error: %d\n", qPrintable(baseName), file.error()); 

         } else {

            QString text = "msc {";
            text += s->text();
            text += "}";
   
            file.write( text.toUtf8() );
            file.close();
   
            writeMscFile(baseName, s);
   
            if (Config::getBool("dot-cleanup")) {
               file.remove();
            }
         }
      }
      break;

      case DocVerbatim::PlantUML: {
         QString latexOutput = Config::getString("latex-output");
         QString baseName    = writePlantUMLSource(latexOutput, s->exampleFile(), s->text());

         writePlantUMLFile(baseName, s);
      }
      break;
   }
}