2000-08-30 03:40:51 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
|
|
|
#ifndef CONVERTER_H
|
|
|
|
#define CONVERTER_H
|
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
/**
|
|
|
|
* \file converter.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Dekel Tsur
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
2000-11-13 10:35:02 +00:00
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
#include "graph.h"
|
2002-07-16 21:17:10 +00:00
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
#include <vector>
|
2001-02-16 09:25:43 +00:00
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
class Format;
|
|
|
|
class Formats;
|
2001-02-16 09:25:43 +00:00
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
class Buffer;
|
2000-11-13 10:35:02 +00:00
|
|
|
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-11-13 10:35:02 +00:00
|
|
|
class Converter {
|
|
|
|
public:
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-11-13 10:35:02 +00:00
|
|
|
Converter(string const & f, string const & t, string const & c,
|
2003-02-28 09:49:49 +00:00
|
|
|
string const & l);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
void readFlags();
|
2000-11-13 10:35:02 +00:00
|
|
|
///
|
|
|
|
string from;
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2000-11-13 10:35:02 +00:00
|
|
|
string to;
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
|
|
|
string command;
|
2000-11-13 10:35:02 +00:00
|
|
|
///
|
|
|
|
string flags;
|
|
|
|
///
|
|
|
|
Format const * From;
|
|
|
|
///
|
|
|
|
Format const * To;
|
|
|
|
|
2000-10-23 12:16:05 +00:00
|
|
|
/// The converter is latex or its derivatives
|
|
|
|
bool latex;
|
2000-09-11 15:42:17 +00:00
|
|
|
/// Do we need to run the converter in the original directory?
|
2000-08-30 03:40:51 +00:00
|
|
|
bool original_dir;
|
2000-09-11 15:42:17 +00:00
|
|
|
/// This converter needs the .aux files
|
|
|
|
bool need_aux;
|
|
|
|
/// If the converter put the result in a directory, then result_dir
|
|
|
|
/// is the name of the directory
|
|
|
|
string result_dir;
|
|
|
|
/// If the converter put the result in a directory, then result_file
|
|
|
|
/// is the name of the main file in that directory
|
|
|
|
string result_file;
|
2000-10-02 16:44:47 +00:00
|
|
|
/// Command to convert the program output to a LaTeX log file format
|
|
|
|
string parselog;
|
2000-08-30 03:40:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-08-30 04:38:32 +00:00
|
|
|
///
|
2000-11-13 10:35:02 +00:00
|
|
|
class Converters {
|
2000-08-30 03:40:51 +00:00
|
|
|
public:
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
|
|
|
typedef std::vector<int> EdgePath; // to be removed SOON
|
|
|
|
///
|
2002-03-21 17:27:08 +00:00
|
|
|
typedef std::vector<Converter> ConverterList;
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2000-11-13 10:35:02 +00:00
|
|
|
typedef ConverterList::const_iterator const_iterator;
|
2000-10-23 12:16:05 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
Converter const & get(int i) const {
|
|
|
|
return converterlist_[i];
|
2000-11-13 10:35:02 +00:00
|
|
|
}
|
2000-11-06 11:20:22 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
Converter const * getConverter(string const & from, string const & to);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
int getNumber(string const & from, string const & to);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
void add(string const & from, string const & to,
|
2000-08-30 03:40:51 +00:00
|
|
|
string const & command, string const & flags);
|
2000-11-13 10:35:02 +00:00
|
|
|
//
|
2001-07-30 11:56:00 +00:00
|
|
|
void erase(string const & from, string const & to);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
void sort();
|
2000-10-16 13:27:56 +00:00
|
|
|
///
|
2000-11-13 10:35:02 +00:00
|
|
|
std::vector<Format const *> const
|
2001-07-30 11:56:00 +00:00
|
|
|
getReachableTo(string const & target, bool clear_visited);
|
2000-11-13 10:35:02 +00:00
|
|
|
///
|
|
|
|
std::vector<Format const *> const
|
2001-07-30 11:56:00 +00:00
|
|
|
getReachable(string const & from, bool only_viewable,
|
2000-11-13 10:35:02 +00:00
|
|
|
bool clear_visited);
|
2000-10-23 12:16:05 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
bool isReachable(string const & from, string const & to);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2003-02-28 09:49:49 +00:00
|
|
|
Graph::EdgePath const getPath(string const & from, string const & to);
|
2000-11-13 10:35:02 +00:00
|
|
|
///
|
2003-02-28 09:49:49 +00:00
|
|
|
bool usePdflatex(Graph::EdgePath const & path);
|
2000-11-13 10:35:02 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
bool convert(Buffer const * buffer,
|
2000-10-23 12:16:05 +00:00
|
|
|
string const & from_file, string const & to_file_base,
|
|
|
|
string const & from_format, string const & to_format,
|
2000-11-13 10:35:02 +00:00
|
|
|
string & to_file);
|
2000-10-16 13:27:56 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
bool convert(Buffer const * buffer,
|
2000-10-23 12:16:05 +00:00
|
|
|
string const & from_file, string const & to_file_base,
|
2000-11-13 10:35:02 +00:00
|
|
|
string const & from_format, string const & to_format);
|
2000-09-05 13:16:19 +00:00
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string const dvips_options(Buffer const * buffer);
|
2000-10-16 13:27:56 +00:00
|
|
|
///
|
2001-01-28 16:52:27 +00:00
|
|
|
string const dvipdfm_options(Buffer const * buffer);
|
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
void update(Formats const & formats);
|
2000-11-08 09:39:46 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
void updateLast(Formats const & formats);
|
2000-11-13 10:35:02 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
bool formatIsUsed(string const & format);
|
2000-11-13 10:35:02 +00:00
|
|
|
///
|
|
|
|
const_iterator begin() const {
|
2001-07-30 11:56:00 +00:00
|
|
|
return converterlist_.begin();
|
2000-11-13 10:35:02 +00:00
|
|
|
}
|
|
|
|
const_iterator end() const {
|
2001-07-30 11:56:00 +00:00
|
|
|
return converterlist_.end();
|
2000-11-13 10:35:02 +00:00
|
|
|
}
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
|
|
|
void buildGraph();
|
2000-08-30 03:40:51 +00:00
|
|
|
private:
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
|
|
|
std::vector<Format const *> const
|
|
|
|
Converters::intToFormat(std::vector<int> const & input);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2002-03-21 17:27:08 +00:00
|
|
|
bool scanLog(Buffer const * buffer, string const & command,
|
2000-10-02 16:44:47 +00:00
|
|
|
string const & filename);
|
|
|
|
///
|
2000-10-12 15:17:42 +00:00
|
|
|
bool runLaTeX(Buffer const * buffer, string const & command);
|
2000-08-30 03:40:51 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
ConverterList converterlist_;
|
2000-09-11 15:42:17 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
string latex_command_;
|
2000-11-13 10:35:02 +00:00
|
|
|
///
|
2001-07-30 11:56:00 +00:00
|
|
|
bool move(string const & from, string const & to, bool copy);
|
2003-02-28 09:49:49 +00:00
|
|
|
///
|
|
|
|
Graph G_;
|
2000-08-30 03:40:51 +00:00
|
|
|
};
|
|
|
|
|
2000-11-13 10:35:02 +00:00
|
|
|
extern Converters converters;
|
2000-11-06 11:20:22 +00:00
|
|
|
|
2000-11-13 10:35:02 +00:00
|
|
|
extern Converters system_converters;
|
2000-11-06 11:20:22 +00:00
|
|
|
|
2003-02-28 09:49:49 +00:00
|
|
|
#endif //CONVERTER_H
|