]> git.lyx.org Git - features.git/commitdiff
Partial fix to bug 2355.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 24 Mar 2006 11:57:19 +0000 (11:57 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 24 Mar 2006 11:57:19 +0000 (11:57 +0000)
* 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

src/bufferparams.C
src/frontends/qt2/QDocument.C
src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormDocument.h
src/lyxtextclass.C
src/lyxtextclass.h

index b03e7b7489dc1fefd7622020e00e28351760c110..3dda1e505ff995a9a592cfd9938a59e65c51560e 100644 (file)
@@ -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();
+       }
 }
 
 
index cf6134338eb672a462a4d7bbd1eacf8237acb329..06be8428e3fa28ff3a20968c4bfd7cf4a2a37e7a 100644 (file)
@@ -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));
index 739abd997c806969469afe930441e0be0794cacf..d3bc40837415ae673294388e84e37f622dfc20bf 100644 (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;
-
-       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());
index f7488ae220faf596f48a03f397103dab0dd5a1e5..429d036e796c9bda8e74cbcdba8b2ef5f34322f3 100644 (file)
@@ -96,7 +96,7 @@ private:
        ///
        bool language_apply(BufferParams &);
        ///
-       bool options_apply(BufferParams &);
+       void options_apply(BufferParams &);
        ///
        void bullets_apply(BufferParams &);
        ///
index ffcf4741761976e09c2dbf8b44588daeeaa886f6..5d3aecae6a487634178bf247bc9130a46857da72 100644 (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) {
index e602b4041b453a6238509d191a3ff56905da67f1..1204e5215c0b619b7a7de313d3e4f4a15b6f2095 100644 (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 &);