Partial fix to bug 2355.

* src/bufferparams.C
	(bool BufferParams::writeLaTeX):
	(void BufferParams::useClassDefaults): only take action when there is
	a ToC structure

	* src/frontends/qt2/QDocument.C
	(void QDocument::apply):
	(void QDocument::update_contents): only take action when there is
        a ToC structure

	* src/frontends/xforms/FormDocument.C
	(bool FormDocument::language_apply):
	(bool FormDocument::options_apply):
	(void FormDocument::options_update): only take action when there is
        a ToC structure; disable 
	(void FormDocument::UpdateClassParams): disable the secnumdepth and
	tocdepth widgets when there is no ToC structure

	* src/frontends/xforms/FormDocument.h
	(options_apply): do not return a bool (was not used)

	* src/lyxtextclass.C
	(hasTocLevels): new method.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13471 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2006-03-24 11:57:19 +00:00
parent 9d6cad3fe6
commit a9b0afd3b5
6 changed files with 55 additions and 38 deletions

View File

@ -915,6 +915,8 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
texrow.newline();
}
// Only if class has a ToC hierarchy
if (tclass.hasTocLevels()) {
if (secnumdepth != tclass.secnumdepth()) {
os << "\\setcounter{secnumdepth}{"
<< secnumdepth
@ -927,6 +929,7 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
<< "}\n";
texrow.newline();
}
}
if (paragraph_separation) {
switch (getDefSkip().kind()) {
@ -1068,9 +1071,12 @@ void BufferParams::useClassDefaults()
columns = tclass.columns();
pagestyle = tclass.pagestyle();
options = tclass.options();
// Only if class has a ToC hierarchy
if (tclass.hasTocLevels()) {
secnumdepth = tclass.secnumdepth();
tocdepth = tclass.tocdepth();
}
}
bool BufferParams::hasClassDefaults() const

View File

@ -267,8 +267,10 @@ void QDocument::apply()
params.language = languages.getLanguage(lang_[pos]);
// numbering
if (params.getLyXTextClass().hasTocLevels()) {
params.tocdepth = dialog_->numberingModule->tocSL->value();
params.secnumdepth = dialog_->numberingModule->depthSL->value();
}
// bullets
params.user_defined_bullet(0) = dialog_->bulletsModule->getBullet(0);
@ -506,12 +508,8 @@ void QDocument::update_contents()
// numbering
int const min_toclevel = controller().textClass().min_toclevel();
int const max_toclevel = controller().textClass().max_toclevel();
if (min_toclevel != LyXLayout::NOT_IN_TOC)
if (controller().textClass().hasTocLevels()) {
dialog_->numberingModule->setEnabled(true);
else {
dialog_->numberingModule->setEnabled(false);
dialog_->numberingModule->tocLV->clear();
}
dialog_->numberingModule->depthSL->setMinValue(min_toclevel - 1);
dialog_->numberingModule->depthSL->setMaxValue(max_toclevel);
dialog_->numberingModule->depthSL->setValue(params.secnumdepth);
@ -519,6 +517,10 @@ void QDocument::update_contents()
dialog_->numberingModule->tocSL->setMaxValue(max_toclevel);
dialog_->numberingModule->tocSL->setValue(params.tocdepth);
dialog_->updateNumbering();
} else {
dialog_->numberingModule->setEnabled(false);
dialog_->numberingModule->tocLV->clear();
}
// bullets
dialog_->bulletsModule->setBullet(0,params.user_defined_bullet(0));

View File

@ -949,10 +949,8 @@ bool FormDocument::language_apply(BufferParams & params)
}
bool FormDocument::options_apply(BufferParams & params)
void FormDocument::options_apply(BufferParams & params)
{
bool redo = false;
params.graphicsDriver = getString(options_->choice_postscript_driver);
params.use_amsmath = static_cast<BufferParams::AMS>(
fl_get_choice(options_->choice_ams_math) - 1);
@ -975,17 +973,14 @@ bool FormDocument::options_apply(BufferParams & params)
params.use_bibtopic = fl_get_button(options_->check_bibtopic);
int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
if (params.secnumdepth != tmpchar)
redo = true;
params.secnumdepth = tmpchar;
if (params.getLyXTextClass().hasTocLevels()) {
params.secnumdepth = int(fl_get_counter_value(options_->counter_secnumdepth));
params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth));
}
params.float_placement =
getString(options_->input_float_placement);
return redo;
}
@ -1011,7 +1006,7 @@ void FormDocument::UpdateClassParams(BufferParams const & params)
// These are the params that have to be updated on any class change
// (even if the class defaults are not used) (JSpitzm 2002-04-08)
LyXTextClass const & tclass = textclasslist[params.textclass];
LyXTextClass const & tclass = params.getLyXTextClass();
fl_set_combox(class_->combox_class, params.textclass + 1);
fl_clear_choice(class_->choice_fontsize);
@ -1028,6 +1023,8 @@ void FormDocument::UpdateClassParams(BufferParams const & params)
params.pagestyle.c_str());
fl_set_input(class_->input_extra, tclass.options().c_str());
setEnabled(options_->counter_secnumdepth, tclass.hasTocLevels());
setEnabled(options_->counter_tocdepth, tclass.hasTocLevels());
}
void FormDocument::class_update(BufferParams const & params)
@ -1158,8 +1155,12 @@ void FormDocument::options_update(BufferParams const & params)
fl_set_choice(options_->choice_cite_engine, cite_choice);
fl_set_button(options_->check_bibtopic, params.use_bibtopic);
if (params.getLyXTextClass().hasTocLevels()) {
fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
}
if (!params.float_placement.empty())
fl_set_input(options_->input_float_placement,
params.float_placement.c_str());

View File

@ -96,7 +96,7 @@ private:
///
bool language_apply(BufferParams &);
///
bool options_apply(BufferParams &);
void options_apply(BufferParams &);
///
void bullets_apply(BufferParams &);
///

View File

@ -1095,6 +1095,12 @@ int LyXTextClass::max_toclevel() const
}
bool LyXTextClass::hasTocLevels() const
{
return min_toclevel_ != LyXLayout::NOT_IN_TOC;
}
ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
{
switch (p) {

View File

@ -176,6 +176,8 @@ public:
int min_toclevel() const;
/// The maximal TocLevel of sectioning layouts
int max_toclevel() const;
/// returns true if the class has a ToC structure
bool hasTocLevels() const;
private:
///
bool delete_layout(std::string const &);