]> git.lyx.org Git - features.git/commitdiff
This patch continues 19964. It takes advantage of the work there to simplify a few...
authorRichard Heck <rgheck@comcast.net>
Sat, 1 Sep 2007 04:03:24 +0000 (04:03 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 1 Sep 2007 04:03:24 +0000 (04:03 +0000)
That makes another simplification both possible and desirable. For some reason, whenever you change the Document Class combobox in Document Settings, LyX tries to read whatever you choose _before_ you try to hit "Apply". Why? I see no good reason. You get the warning earlier that way, but maybe you weren't going to try to load it anyway and were going to change your mind. So I have removed that behavior, in which case you'll get the warning when you try to apply the parameters. This means we can also remove ControlDocument::loadTextclass().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19965 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferParams.cpp
src/BufferParams.h
src/frontends/controllers/ControlDocument.cpp
src/frontends/controllers/ControlDocument.h
src/frontends/qt4/GuiDocument.cpp

index 3dbd9b7e9662165eab2e465f9ecc877c7c444ba4..c18e9b9e7db0a7694898e5a92f3e20e8dddbe362 100644 (file)
@@ -1225,10 +1225,19 @@ void BufferParams::setTextClass(TextClass_ptr tc) {
 }
 
 
-void BufferParams::setBaseClass(textclass_type tc)
+bool BufferParams::setBaseClass(textclass_type tc)
 {
+       if (!textclasslist[tc].load()) {
+               docstring s = bformat(_("The document class %1$s."
+                                       "could not be loaded."),
+                from_utf8(textclasslist[tc].name()));
+               frontend::Alert::error(_("Could not load class"), s);
+               return false;
+       }
+       
        baseClass_ = tc;
        makeTextClass();
+       return true;
 }
 
 
index 7922c66792b28c8ad10a5c41f402886c6e39704a..620b78e2a9aacf838dee6c243aef4607ed6a1222 100644 (file)
@@ -103,7 +103,7 @@ public:
        ///Set the LyX TextClass (that is, the layout file) this document is using.
        ///NOTE This also calls makeTextClass(), to update the local
        ///TextClass.
-       void setBaseClass(textclass_type);
+       bool setBaseClass(textclass_type);
        ///Returns the TextClass currently in use: the BaseClass as modified
        ///by modules.
        TextClass const & getTextClass() const;
index e7452ac2bee98e80625a877d301c415c7bd430a2..d2ef46d55bb71a732bea82795c3e10b0bbfb4373 100644 (file)
@@ -111,25 +111,12 @@ void ControlDocument::dispatchParams()
        // This must come first so that a language change is correctly noticed
        setLanguage();
 
-       // Set the document class.
-       textclass_type const old_class =
-               kernel().buffer().params().getBaseClass();
-       textclass_type const new_class = bp_->getBaseClass();
-       if (new_class != old_class) {
-               string const name = textclasslist[new_class].name();
-               kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_APPLY, name));
-       }
-
-       int const old_secnumdepth = kernel().buffer().params().secnumdepth;
-       int const new_secnumdepth = bp_->secnumdepth;
-
-       // Apply the BufferParams.
+       // Apply the BufferParams. Note that this will set the base class
+       // and then update the buffer's layout.
+       //FIXME Could this be done last? Then, I think, we'd get the automatic
+       //update mentioned in the next FIXME...
        dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_PARAMS_APPLY);
 
-       // redo the numbering if necessary
-       if (new_secnumdepth != old_secnumdepth)
-               updateLabels(kernel().buffer());
-
        // Generate the colours requested by each new branch.
        BranchList & branchlist = params().branchlist();
        if (!branchlist.empty()) {
@@ -166,17 +153,6 @@ void ControlDocument::setLanguage() const
 }
 
 
-bool ControlDocument::loadTextclass(textclass_type tc) const
-{
-       string const name = textclasslist[tc].name();
-       kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_LOAD, name));
-
-       // Report back whether we were able to change the class.
-       bool const success = textclasslist[tc].loaded();
-       return success;
-}
-
-
 void ControlDocument::saveAsDefault() const
 {
        dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
index 71f7d01122075c9935840130694f5907cab6a3e1..2e725bfa0a9a3d8b68285a26e33824666efa7810 100644 (file)
@@ -59,8 +59,6 @@ public:
        ///
        void saveAsDefault() const;
        ///
-       bool loadTextclass(textclass_type tc) const;
-       ///
        bool const isFontAvailable(std::string const & font) const;
        /// does this font provide Old Style figures?
        bool const providesOSF(std::string const & font) const;
index 8f61c641eb9a37147c083313164c732c3084310c..954a433e3d9ee313dd761141ca883eff458cd34b 100644 (file)
@@ -825,19 +825,12 @@ void GuiDocumentDialog::updatePagestyle(string const & items, string const & sel
 
 void GuiDocumentDialog::classChanged()
 {
-       ControlDocument & cntrl = form_->controller();
-       BufferParams & params = cntrl.params();
-
+       BufferParams & params = form_->controller().params();
        textclass_type const tc = latexModule->classCO->currentIndex();
-
-       if (form_->controller().loadTextclass(tc)) {
-               params.setJustBaseClass(tc);
-               if (lyxrc.auto_reset_options)
-                       params.useClassDefaults();
-               form_->update_contents();
-       } else {
-               latexModule->classCO->setCurrentIndex(params.getBaseClass());
-       }
+       params.setJustBaseClass(tc);
+       if (lyxrc.auto_reset_options)
+               params.useClassDefaults();
+       form_->update_contents();
 }