mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
* src/BufferParams.{cpp,h}:
- (paperSizeName): add missing paper sizes. Add an argument to the function that returns context-sensitive information (depending on the purpose) - (paperSizeName): Do not hardcode "letter" for default paper size (bug 2098). - (dvips_options): pass purpose DVIPS to paperSizeName * src/Converter.cpp: - (dvipdfm_options): pass purpose DVIPDFM to paperSizeName. * src/Format.cpp: - (view): pass purpose XDVI to paperSizeName (fix bug 4432). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22664 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
267d9b4001
commit
f62fbd05d2
@ -1577,27 +1577,62 @@ void BufferParams::readModules(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
string const BufferParams::paperSizeName() const
|
||||
string const BufferParams::paperSizeName(Papersize_Purpose const & purpose) const
|
||||
{
|
||||
char real_papersize = papersize;
|
||||
if (real_papersize == PAPER_DEFAULT)
|
||||
real_papersize = lyxrc.default_papersize;
|
||||
|
||||
switch (real_papersize) {
|
||||
case PAPER_DEFAULT:
|
||||
// could be anything, so don't guess
|
||||
return string();
|
||||
case PAPER_CUSTOM: {
|
||||
if (purpose == XDVI && !paperwidth.empty() &&
|
||||
!paperheight.empty()) {
|
||||
// heightxwidth<unit>
|
||||
string first = paperwidth;
|
||||
string second = paperheight;
|
||||
if (orientation == ORIENTATION_LANDSCAPE)
|
||||
first.swap(second);
|
||||
// cut off unit.
|
||||
return first.erase(first.length() - 2)
|
||||
+ "x" + second;
|
||||
}
|
||||
return string();
|
||||
}
|
||||
case PAPER_A3:
|
||||
return "a3";
|
||||
case PAPER_A4:
|
||||
return "a4";
|
||||
case PAPER_A5:
|
||||
return "a5";
|
||||
case PAPER_B3:
|
||||
// dvips and dvipdfm do not know this
|
||||
if (purpose == DVIPS || purpose == DVIPDFM)
|
||||
return string();
|
||||
return "b3";
|
||||
case PAPER_B4:
|
||||
// dvipdfm does not know this
|
||||
if (purpose == DVIPDFM)
|
||||
return string();
|
||||
return "b4";
|
||||
case PAPER_B5:
|
||||
// dvipdfm does not know this
|
||||
if (purpose == DVIPDFM)
|
||||
return string();
|
||||
return "b5";
|
||||
case PAPER_USEXECUTIVE:
|
||||
// dvipdfm does not know this
|
||||
if (purpose == DVIPDFM)
|
||||
return string();
|
||||
return "foolscap";
|
||||
case PAPER_USLEGAL:
|
||||
return "legal";
|
||||
case PAPER_USLETTER:
|
||||
default:
|
||||
if (purpose == XDVI)
|
||||
return "us";
|
||||
return "letter";
|
||||
}
|
||||
}
|
||||
@ -1617,9 +1652,9 @@ string const BufferParams::dvips_options() const
|
||||
result += ' ' + paperwidth;
|
||||
result += ',' + paperheight;
|
||||
} else {
|
||||
string const paper_option = paperSizeName();
|
||||
if (paper_option != "letter" ||
|
||||
orientation != ORIENTATION_LANDSCAPE) {
|
||||
string const paper_option = paperSizeName(DVIPS);
|
||||
if (!paper_option.empty() && (paper_option != "letter" ||
|
||||
orientation != ORIENTATION_LANDSCAPE)) {
|
||||
// dvips won't accept -t letter -t landscape.
|
||||
// In all other cases, include the paper size
|
||||
// explicitly.
|
||||
|
@ -274,8 +274,20 @@ public:
|
||||
std::vector<unsigned int> author_map;
|
||||
///
|
||||
std::string const dvips_options() const;
|
||||
/** The return value of paperSizeName() depends on the
|
||||
* purpose for which the paper size is needed, since they
|
||||
* support different subsets of paper sizes.
|
||||
*/
|
||||
enum Papersize_Purpose {
|
||||
///
|
||||
DVIPS,
|
||||
///
|
||||
DVIPDFM,
|
||||
///
|
||||
XDVI
|
||||
};
|
||||
///
|
||||
std::string const paperSizeName() const;
|
||||
std::string const paperSizeName(Papersize_Purpose const & purpose) const;
|
||||
/// set up if and how babel is called
|
||||
std::string const babelCall(std::string const & lang_opts) const;
|
||||
/// handle inputenc etc.
|
||||
|
@ -65,8 +65,8 @@ string const dvipdfm_options(BufferParams const & bp)
|
||||
string result;
|
||||
|
||||
if (bp.papersize != PAPER_CUSTOM) {
|
||||
string const paper_size = bp.paperSizeName();
|
||||
if (paper_size != "b5" && paper_size != "foolscap")
|
||||
string const paper_size = bp.paperSizeName(BufferParams::DVIPDFM);
|
||||
if (!paper_size.empty())
|
||||
result = "-p "+ paper_size;
|
||||
|
||||
if (bp.orientation == ORIENTATION_LANDSCAPE)
|
||||
|
@ -279,13 +279,14 @@ bool Formats::view(Buffer const & buffer, FileName const & filename,
|
||||
|
||||
if (format_name == "dvi" &&
|
||||
!lyxrc.view_dvi_paper_option.empty()) {
|
||||
command += ' ' + lyxrc.view_dvi_paper_option;
|
||||
string paper_size = buffer.params().paperSizeName();
|
||||
if (paper_size == "letter")
|
||||
paper_size = "us";
|
||||
command += ' ' + paper_size;
|
||||
if (buffer.params().orientation == ORIENTATION_LANDSCAPE)
|
||||
command += 'r';
|
||||
string paper_size = buffer.params().paperSizeName(BufferParams::XDVI);
|
||||
if (!paper_size.empty()) {
|
||||
command += ' ' + lyxrc.view_dvi_paper_option;
|
||||
command += ' ' + paper_size;
|
||||
if (buffer.params().orientation == ORIENTATION_LANDSCAPE &&
|
||||
buffer.params().papersize != PAPER_CUSTOM)
|
||||
command += 'r';
|
||||
}
|
||||
}
|
||||
|
||||
if (!contains(command, token_from_format))
|
||||
|
Loading…
Reference in New Issue
Block a user