mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
moved some converter/format functions to more appropriate places
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7300 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
52b22859af
commit
dfbd44997a
@ -1,3 +1,9 @@
|
||||
2003-07-17 Alfredo Braunstein <abraunst@libero.it>
|
||||
|
||||
* format.[Ch] (papersize): moved to BufferParams
|
||||
* converter.[Ch] (dvips_options): moved to BufferParams
|
||||
(dvipdfm_options): moved to anon namespace
|
||||
* bufferparams.[Ch]: added above functions.
|
||||
|
||||
2003-07-17 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
@ -32,9 +32,9 @@ Buffer * newFile(string const & filename, string const & templatename,
|
||||
|
||||
///return the format of the buffer on a string
|
||||
string const BufferFormat(Buffer const & buffer);
|
||||
|
||||
///
|
||||
void bufferErrors(Buffer const &, TeXErrors const &);
|
||||
|
||||
///
|
||||
void bufferErrors(Buffer const &, ErrorList const &);
|
||||
|
||||
#endif // BUFFER_FUNCS_H
|
||||
|
@ -959,3 +959,60 @@ void BufferParams::readGraphicsDriver(LyXLex & lex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string const BufferParams::paperSizeName() const
|
||||
{
|
||||
char real_papersize = papersize;
|
||||
if (real_papersize == PAPER_DEFAULT)
|
||||
real_papersize = lyxrc.default_papersize;
|
||||
|
||||
switch (real_papersize) {
|
||||
case PAPER_A3PAPER:
|
||||
return "a3";
|
||||
case PAPER_A4PAPER:
|
||||
return "a4";
|
||||
case PAPER_A5PAPER:
|
||||
return "a5";
|
||||
case PAPER_B5PAPER:
|
||||
return "b5";
|
||||
case PAPER_EXECUTIVEPAPER:
|
||||
return "foolscap";
|
||||
case PAPER_LEGALPAPER:
|
||||
return "legal";
|
||||
case PAPER_USLETTER:
|
||||
default:
|
||||
return "letter";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string const BufferParams::dvips_options() const
|
||||
{
|
||||
string result;
|
||||
|
||||
if (use_geometry
|
||||
&& papersize2 == VM_PAPER_CUSTOM
|
||||
&& !lyxrc.print_paper_dimension_flag.empty()
|
||||
&& !paperwidth.empty()
|
||||
&& !paperheight.empty()) {
|
||||
// using a custom papersize
|
||||
result = lyxrc.print_paper_dimension_flag;
|
||||
result += ' ' + paperwidth;
|
||||
result += ',' + paperheight;
|
||||
} else {
|
||||
string const paper_option = paperSizeName();
|
||||
if (paper_option != "letter" ||
|
||||
orientation != ORIENTATION_LANDSCAPE) {
|
||||
// dvips won't accept -t letter -t landscape.
|
||||
// In all other cases, include the paper size
|
||||
// explicitly.
|
||||
result = lyxrc.print_paper_flag;
|
||||
result += ' ' + paper_option;
|
||||
}
|
||||
}
|
||||
if (orientation == ORIENTATION_LANDSCAPE &&
|
||||
papersize2 != VM_PAPER_CUSTOM)
|
||||
result += ' ' + lyxrc.print_landscape_flag;
|
||||
return result;
|
||||
}
|
||||
|
@ -238,6 +238,10 @@ public:
|
||||
|
||||
/// map of the file's author IDs to buffer author IDs
|
||||
std::vector<int> author_map;
|
||||
///
|
||||
string const dvips_options() const;
|
||||
///
|
||||
string const paperSizeName() const;
|
||||
|
||||
private:
|
||||
/// the author list
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "format.h"
|
||||
#include "lyxrc.h"
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "bufferview_funcs.h"
|
||||
#include "errorlist.h"
|
||||
@ -62,6 +63,23 @@ string const add_options(string const & command, string const & options)
|
||||
return head + ' ' + options + ' ' + tail;
|
||||
}
|
||||
|
||||
|
||||
string const dvipdfm_options(BufferParams const & bp)
|
||||
{
|
||||
string result;
|
||||
|
||||
if (bp.papersize2 != BufferParams::VM_PAPER_CUSTOM) {
|
||||
string const paper_size = bp.paperSizeName();
|
||||
if (paper_size != "b5" && paper_size != "foolscap")
|
||||
result = "-p "+ paper_size;
|
||||
|
||||
if (bp.orientation == BufferParams::ORIENTATION_LANDSCAPE)
|
||||
result += " -l";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
@ -115,7 +133,6 @@ bool operator<(Converter const & a, Converter const & b)
|
||||
}
|
||||
|
||||
|
||||
|
||||
class compare_Converter {
|
||||
public:
|
||||
compare_Converter(string const & f, string const & t)
|
||||
@ -327,10 +344,10 @@ bool Converters::convert(Buffer const * buffer,
|
||||
|
||||
if (conv.from == "dvi" && conv.to == "ps")
|
||||
command = add_options(command,
|
||||
dvips_options(buffer));
|
||||
buffer->params.dvips_options());
|
||||
else if (conv.from == "dvi" && prefixIs(conv.to, "pdf"))
|
||||
command = add_options(command,
|
||||
dvipdfm_options(buffer));
|
||||
dvipdfm_options(buffer->params));
|
||||
|
||||
lyxerr[Debug::FILES] << "Calling " << command << endl;
|
||||
if (buffer)
|
||||
@ -545,56 +562,6 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command,
|
||||
}
|
||||
|
||||
|
||||
string const Converters::dvips_options(Buffer const * buffer)
|
||||
{
|
||||
string result;
|
||||
if (!buffer)
|
||||
return result;
|
||||
|
||||
if (buffer->params.use_geometry
|
||||
&& buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
|
||||
&& !lyxrc.print_paper_dimension_flag.empty()
|
||||
&& !buffer->params.paperwidth.empty()
|
||||
&& !buffer->params.paperheight.empty()) {
|
||||
// using a custom papersize
|
||||
result = lyxrc.print_paper_dimension_flag;
|
||||
result += ' ' + buffer->params.paperwidth;
|
||||
result += ',' + buffer->params.paperheight;
|
||||
} else {
|
||||
string const paper_option = papersize(buffer);
|
||||
if (paper_option != "letter" ||
|
||||
buffer->params.orientation != BufferParams::ORIENTATION_LANDSCAPE) {
|
||||
// dvips won't accept -t letter -t landscape. In all other
|
||||
// cases, include the paper size explicitly.
|
||||
result = lyxrc.print_paper_flag;
|
||||
result += ' ' + paper_option;
|
||||
}
|
||||
}
|
||||
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE &&
|
||||
buffer->params.papersize2 != BufferParams::VM_PAPER_CUSTOM)
|
||||
result += ' ' + lyxrc.print_landscape_flag;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
string const Converters::dvipdfm_options(Buffer const * buffer)
|
||||
{
|
||||
string result;
|
||||
if (!buffer)
|
||||
return result;
|
||||
|
||||
if (buffer->params.papersize2 != BufferParams::VM_PAPER_CUSTOM) {
|
||||
string const paper_size = papersize(buffer);
|
||||
if (paper_size != "b5" && paper_size != "foolscap")
|
||||
result = "-p "+ paper_size;
|
||||
|
||||
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
|
||||
result += " -l";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void Converters::buildGraph()
|
||||
{
|
||||
|
@ -108,10 +108,6 @@ public:
|
||||
string const & from_file, string const & to_file_base,
|
||||
string const & from_format, string const & to_format);
|
||||
///
|
||||
string const dvips_options(Buffer const * buffer);
|
||||
///
|
||||
string const dvipdfm_options(Buffer const * buffer);
|
||||
///
|
||||
void update(Formats const & formats);
|
||||
///
|
||||
void updateLast(Formats const & formats);
|
||||
|
27
src/format.C
27
src/format.C
@ -12,6 +12,7 @@
|
||||
|
||||
#include "format.h"
|
||||
#include "buffer.h"
|
||||
#include "buffer_funcs.h"
|
||||
#include "lyxrc.h"
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
@ -173,7 +174,7 @@ bool Formats::view(Buffer const * buffer, string const & filename,
|
||||
if (format_name == "dvi" &&
|
||||
!lyxrc.view_dvi_paper_option.empty()) {
|
||||
command += ' ' + lyxrc.view_dvi_paper_option;
|
||||
string paper_size = papersize(buffer);
|
||||
string paper_size = buffer->params.paperSizeName();
|
||||
if (paper_size == "letter")
|
||||
paper_size = "us";
|
||||
command += ' ' + paper_size;
|
||||
@ -226,30 +227,6 @@ string const Formats::extension(string const & name) const
|
||||
}
|
||||
|
||||
|
||||
string const papersize(Buffer const * buffer)
|
||||
{
|
||||
char real_papersize = buffer->params.papersize;
|
||||
if (real_papersize == BufferParams::PAPER_DEFAULT)
|
||||
real_papersize = lyxrc.default_papersize;
|
||||
|
||||
switch (real_papersize) {
|
||||
case BufferParams::PAPER_A3PAPER:
|
||||
return "a3";
|
||||
case BufferParams::PAPER_A4PAPER:
|
||||
return "a4";
|
||||
case BufferParams::PAPER_A5PAPER:
|
||||
return "a5";
|
||||
case BufferParams::PAPER_B5PAPER:
|
||||
return "b5";
|
||||
case BufferParams::PAPER_EXECUTIVEPAPER:
|
||||
return "foolscap";
|
||||
case BufferParams::PAPER_LEGALPAPER:
|
||||
return "legal";
|
||||
case BufferParams::PAPER_USLETTER:
|
||||
default:
|
||||
return "letter";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Formats formats;
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
class Buffer;
|
||||
|
||||
string const papersize(Buffer const * buffer) ;
|
||||
|
||||
class Format {
|
||||
public:
|
||||
///
|
||||
|
@ -16,11 +16,11 @@
|
||||
#include "ButtonController.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "bufferparams.h"
|
||||
#include "gettext.h"
|
||||
#include "helper_funcs.h"
|
||||
#include "PrinterParams.h"
|
||||
#include "exporter.h"
|
||||
#include "converter.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
|
||||
@ -154,7 +154,7 @@ void ControlPrint::apply()
|
||||
command += lyxrc.print_extra_options + ' ';
|
||||
}
|
||||
|
||||
command += converters.dvips_options(buffer()) + ' ';
|
||||
command += buffer()->params.dvips_options() + ' ';
|
||||
|
||||
if (!Exporter::Export(buffer(), "dvi", true)) {
|
||||
showPrintError(buffer()->fileName());
|
||||
|
Loading…
Reference in New Issue
Block a user