diff --git a/src/bufferparams.C b/src/bufferparams.C index b03e7b7489..3dda1e505f 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -915,17 +915,20 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features, texrow.newline(); } - if (secnumdepth != tclass.secnumdepth()) { - os << "\\setcounter{secnumdepth}{" - << secnumdepth - << "}\n"; - texrow.newline(); - } - if (tocdepth != tclass.tocdepth()) { - os << "\\setcounter{tocdepth}{" - << tocdepth - << "}\n"; - texrow.newline(); + // Only if class has a ToC hierarchy + if (tclass.hasTocLevels()) { + if (secnumdepth != tclass.secnumdepth()) { + os << "\\setcounter{secnumdepth}{" + << secnumdepth + << "}\n"; + texrow.newline(); + } + if (tocdepth != tclass.tocdepth()) { + os << "\\setcounter{tocdepth}{" + << tocdepth + << "}\n"; + texrow.newline(); + } } if (paragraph_separation) { @@ -1068,8 +1071,11 @@ void BufferParams::useClassDefaults() columns = tclass.columns(); pagestyle = tclass.pagestyle(); options = tclass.options(); - secnumdepth = tclass.secnumdepth(); - tocdepth = tclass.tocdepth(); + // Only if class has a ToC hierarchy + if (tclass.hasTocLevels()) { + secnumdepth = tclass.secnumdepth(); + tocdepth = tclass.tocdepth(); + } } diff --git a/src/frontends/qt2/QDocument.C b/src/frontends/qt2/QDocument.C index cf6134338e..06be8428e3 100644 --- a/src/frontends/qt2/QDocument.C +++ b/src/frontends/qt2/QDocument.C @@ -267,8 +267,10 @@ void QDocument::apply() params.language = languages.getLanguage(lang_[pos]); // numbering - params.tocdepth = dialog_->numberingModule->tocSL->value(); - params.secnumdepth = dialog_->numberingModule->depthSL->value(); + 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,19 +508,19 @@ 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->depthSL->setMinValue(min_toclevel - 1); + dialog_->numberingModule->depthSL->setMaxValue(max_toclevel); + dialog_->numberingModule->depthSL->setValue(params.secnumdepth); + dialog_->numberingModule->tocSL->setMinValue(min_toclevel - 1); + dialog_->numberingModule->tocSL->setMaxValue(max_toclevel); + dialog_->numberingModule->tocSL->setValue(params.tocdepth); + dialog_->updateNumbering(); + } 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); - dialog_->numberingModule->tocSL->setMinValue(min_toclevel - 1); - dialog_->numberingModule->tocSL->setMaxValue(max_toclevel); - dialog_->numberingModule->tocSL->setValue(params.tocdepth); - dialog_->updateNumbering(); // bullets dialog_->bulletsModule->setBullet(0,params.user_defined_bullet(0)); diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 739abd997c..d3bc408374 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -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( 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; - - params.tocdepth = int(fl_get_counter_value(options_->counter_tocdepth)); + 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); - fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth); - fl_set_counter_value(options_->counter_tocdepth, params.tocdepth); + + 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()); diff --git a/src/frontends/xforms/FormDocument.h b/src/frontends/xforms/FormDocument.h index f7488ae220..429d036e79 100644 --- a/src/frontends/xforms/FormDocument.h +++ b/src/frontends/xforms/FormDocument.h @@ -96,7 +96,7 @@ private: /// bool language_apply(BufferParams &); /// - bool options_apply(BufferParams &); + void options_apply(BufferParams &); /// void bullets_apply(BufferParams &); /// diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index ffcf474176..5d3aecae6a 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -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) { diff --git a/src/lyxtextclass.h b/src/lyxtextclass.h index e602b4041b..1204e5215c 100644 --- a/src/lyxtextclass.h +++ b/src/lyxtextclass.h @@ -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 &);