fix bug 2148 (preferences saves wrong papersizes); also finally dispose dead PAPER_PACKAGES enum

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10657 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2005-12-12 11:13:03 +00:00
parent 80d4e59b81
commit 9bd413bfd7
10 changed files with 94 additions and 19 deletions

View File

@ -1,3 +1,9 @@
2005-12-12 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* lyxrc.C: set default_papersize to PAPER_DEFAULT;
handle PAPER_DEFAULT in LyXRC::read and LyXRC::write (bug 2148).
* paper.h: dispose dead PAPER_PACKAGES enum.
2005-12-07 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* Makefile.am (OTHERLIBS): add SOCKET_LIBS in case we compile

View File

@ -1,3 +1,9 @@
2005-12-12 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* ControlPrefs.[Ch]: new helper functions toPaperSize and
fromPaperSize that prevent off-by-x errors in the papersize
combos (bug 2148).
2005-11-28 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* ControlErrorList.C (goTo): give a better error message when pid

View File

@ -18,6 +18,7 @@
#include "bufferlist.h"
#include "gettext.h"
#include "funcrequest.h"
#include "paper.h"
#include "LColor.h"
#include "support/filefilterlist.h"
@ -160,5 +161,59 @@ string const ControlPrefs::browsedir(string const & path,
return browseDir(path, title);
}
// We support less paper sizes than the document dialog
// Therefore this adjustment is needed.
PAPER_SIZE const ControlPrefs::toPaperSize(int i) const
{
switch (i) {
case 0:
return PAPER_DEFAULT;
case 1:
return PAPER_USLETTER;
case 2:
return PAPER_USLEGAL;
case 3:
return PAPER_USEXECUTIVE;
case 4:
return PAPER_A3;
case 5:
return PAPER_A4;
case 6:
return PAPER_A5;
case 7:
return PAPER_B5;
default:
// should not happen
return PAPER_DEFAULT;
}
}
int const ControlPrefs::fromPaperSize(PAPER_SIZE papersize) const
{
switch (papersize) {
case PAPER_DEFAULT:
return 0;
case PAPER_USLETTER:
return 1;
case PAPER_USLEGAL:
return 2;
case PAPER_USEXECUTIVE:
return 3;
case PAPER_A3:
return 4;
case PAPER_A4:
return 5;
case PAPER_A5:
return 6;
case PAPER_B5:
return 7;
default:
// should not happen
return 0;
}
}
} // namespace frontend
} // namespace lyx

View File

@ -73,6 +73,11 @@ public:
/// update the screen fonts after change
void updateScreenFonts();
/// adjust the prefs paper sizes
PAPER_SIZE const toPaperSize(int i) const;
/// adjust the prefs paper sizes
int const fromPaperSize(PAPER_SIZE papersize) const;
private:
/// temporary lyxrc
LyXRC rc_;

View File

@ -1,3 +1,8 @@
2005-12-12 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* QPrefs.C: fix off-by-x errors in paper size setting
by using new helper functions fromPaperSize/toPaperSize (bug 2148).
2005-11-17 Michael Gerz <michael.gerz@teststep.org>
* ui/*.ui: remove dummy captions that pollute the po files

View File

@ -212,7 +212,7 @@ void QPrefs::apply()
rc.auto_reset_options = latexmod->latexAutoresetCB->isChecked();
rc.view_dvi_paper_option = fromqstr(latexmod->latexDviPaperED->text());
rc.default_papersize =
static_cast<PAPER_SIZE>(latexmod->latexPaperSizeCO->currentItem());
controller().toPaperSize(latexmod->latexPaperSizeCO->currentItem());
QPrefDisplayModule * displaymod(dialog_->displayModule);
@ -549,7 +549,8 @@ void QPrefs::update_contents()
latexmod->latexIndexED->setText(toqstr(rc.index_command));
latexmod->latexAutoresetCB->setChecked(rc.auto_reset_options);
latexmod->latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
latexmod->latexPaperSizeCO->setCurrentItem(rc.default_papersize);
latexmod->latexPaperSizeCO->setCurrentItem(
controller().fromPaperSize(rc.default_papersize));
QPrefDisplayModule * displaymod(dialog_->displayModule);

View File

@ -1,3 +1,8 @@
2005-12-12 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* FormPreferences.C: fix off-by-x errors in paper size setting
by using new helper functions fromPaperSize/toPaperSize (bug 2148).
2005-10-05 Angus Leeming <leeming@lyx.org>
* FormGraphics.C (build):

View File

@ -2064,7 +2064,7 @@ void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
int const choice =
fl_get_choice(dialog_->choice_default_papersize) - 1;
rc.default_papersize = static_cast<PAPER_SIZE>(choice);
rc.default_papersize = parent_.controller().toPaperSize(choice);
rc.ascii_roff_command = getString(dialog_->input_ascii_roff);
rc.chktex_command = getString(dialog_->input_checktex);
@ -2158,7 +2158,7 @@ void FormPreferences::OutputsMisc::update(LyXRC const & rc)
fl_set_input(dialog_->input_tex_encoding,
rc.fontenc.c_str());
fl_set_choice(dialog_->choice_default_papersize,
rc.default_papersize + 1);
parent_.controller().fromPaperSize(rc.default_papersize) + 1);
fl_set_input(dialog_->input_ascii_roff,
rc.ascii_roff_command.c_str());
fl_set_input(dialog_->input_checktex,

View File

@ -211,7 +211,7 @@ void LyXRC::setDefaults() {
document_path.erase();
tempdir_path = "/tmp";
view_dvi_paper_option.erase();
default_papersize = PAPER_USLETTER;
default_papersize = PAPER_DEFAULT;
custom_export_format = "ps";
chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
bibtex_command = "bibtex";
@ -586,6 +586,9 @@ int LyXRC::read(LyXLex & lexrc)
else if (size == "b5")
default_papersize =
PAPER_B5;
else if (size == "default")
default_papersize =
PAPER_DEFAULT;
}
break;
@ -1297,6 +1300,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
os << "# The default papersize to use.\n"
<< "\\default_papersize \"";
switch (default_papersize) {
case PAPER_DEFAULT:
os << "default"; break;
case PAPER_USLETTER:
os << "usletter"; break;
case PAPER_USLEGAL:
@ -1311,8 +1316,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
os << "a5"; break;
case PAPER_B5:
os << "b5"; break;
case PAPER_DEFAULT:
case PAPER_CUSTOM:
case PAPER_CUSTOM:
case PAPER_B3:
case PAPER_B4: break;
}

View File

@ -15,18 +15,6 @@
#ifndef PAPER_H
#define PAPER_H
///
enum PAPER_PACKAGES {
///
PACKAGE_NONE,
///
PACKAGE_A4,
///
PACKAGE_A4WIDE,
///
PACKAGE_WIDEMARGINSA4
};
///
enum PAPER_SIZE {
///