From: Jürgen Spitzmüller Date: Sun, 12 Oct 2008 09:36:00 +0000 (+0000) Subject: ** fix bug 2114. Fileformat change. X-Git-Tag: 1.6.10~3070 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d45ca67d1d3e2d4fdc344cd2a1517725bc91723a;p=lyx.git ** fix bug 2114. Fileformat change. ** fix bug 5343 (patch from Richard, prerequisite for the other fix) * Buffer.cpp: - increment format to 343 * src/BufferParams.{cpp,h}: - new param \use_default_options that allows to select/deselect the "Other" class options defined in the layout file. * src/frontends/qt4/GuiDocument.cpp: * src/frontends/qt4/ui/LaTeXUi.ui: - add GUI to set \use_default_options, display predefined options in the dialog - update dialog correctly on class change. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26860 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/FORMAT b/development/FORMAT index e7a0ff85b7..aa9d26851f 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,10 @@ LyX file-format changes ----------------------- +2008-10-12 Jürgen Spitzmüller + * Format incremented to 343: new param \use_default_options + (fix bug 2114). + 2008-10-12 Uwe Stöhr * Format incremented to 342: support for Mongolian. diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 87d0d4b4a4..3b98896ac6 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -2955,6 +2955,22 @@ def revert_mongolian(document): j = j + 1 +def revert_default_options(document): + ' Remove param use_default_options ' + i = find_token(document.header, "\\use_default_options", 0) + if i != -1: + del document.header[i] + + +def convert_default_options(document): + ' Add param use_default_options and set it to false ' + i = find_token(document.header, "\\textclass", 0) + if i == -1: + document.warning("Malformed LyX document: Missing `\\textclass'.") + return + document.header.insert(i, '\\use_default_options false') + + ## # Conversion hub # @@ -3025,10 +3041,12 @@ convert = [[277, [fix_wrong_tables]], [339, []], [340, [add_plain_layout]], [341, []], - [342, []] + [342, []], + [343, [convert_default_options]] ] -revert = [[341, [revert_mongolian]], +revert = [[342, [revert_default_options]], + [341, [revert_mongolian]], [340, [revert_tabulators, revert_tabsize]], [339, []], [338, [revert_removed_modules]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index f46f7b0029..2e60e5c43c 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -115,7 +115,7 @@ namespace os = support::os; namespace { -int const LYX_FORMAT = 342; //uwestoehr: support for Mongolian +int const LYX_FORMAT = 343; typedef map DepClean; typedef map > RefCache; diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 45eebbb551..b177409dd1 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -335,6 +335,7 @@ BufferParams::BufferParams() use_bibtopic = false; trackChanges = false; outputChanges = false; + use_default_options = true; secnumdepth = 3; tocdepth = 3; language = default_language; @@ -495,6 +496,8 @@ string BufferParams::readToken(Lexer & lex, string const & token, } else if (token == "\\options") { lex.eatLine(); options = lex.getString(); + } else if (token == "\\use_default_options") { + lex >> use_default_options; } else if (token == "\\master") { lex.eatLine(); master = lex.getString(); @@ -692,6 +695,10 @@ void BufferParams::writeFile(ostream & os) const os << "\\options " << options << '\n'; } + // use the class options defined in the layout? + os << "\\use_default_options " + << convert(use_default_options) << "\n"; + // the master document if (!master.empty()) { os << "\\master " << master << '\n'; @@ -1073,6 +1080,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, clsoptions << language_options.str() << ','; } + // the predefined options from the layout + if (use_default_options && !tclass.options().empty()) + clsoptions << tclass.options() << ','; + // the user-defined options if (!options.empty()) { clsoptions << options << ','; @@ -1444,7 +1455,7 @@ void BufferParams::useClassDefaults() sides = tclass.sides(); columns = tclass.columns(); pagestyle = tclass.pagestyle(); - options = tclass.options(); + use_default_options = true; // Only if class has a ToC hierarchy if (tclass.hasTocLevels()) { secnumdepth = tclass.secnumdepth(); @@ -1460,7 +1471,7 @@ bool BufferParams::hasClassDefaults() const return sides == tclass.sides() && columns == tclass.columns() && pagestyle == tclass.pagestyle() - && options == tclass.options() + && use_default_options && secnumdepth == tclass.secnumdepth() && tocdepth == tclass.tocdepth(); } @@ -1499,7 +1510,7 @@ bool BufferParams::setBaseClass(string const & classname) } bool const success = bcl[classname].load(); - if (!success) { + if (!success) { docstring s = bformat(_("The document class %1$s could not be loaded."), from_utf8(classname)); @@ -1516,14 +1527,14 @@ bool BufferParams::setBaseClass(string const & classname) for (; mit != men; mit++) { string const & modName = *mit; // see if we're already in use - if (find(layoutModules_.begin(), layoutModules_.end(), modName) != + if (find(layoutModules_.begin(), layoutModules_.end(), modName) != layoutModules_.end()) { LYXERR(Debug::TCLASS, "Default module `" << modName << "' not added because already used."); continue; } // make sure the user hasn't removed it - if (find(removedModules_.begin(), removedModules_.end(), modName) != + if (find(removedModules_.begin(), removedModules_.end(), modName) != removedModules_.end()) { LYXERR(Debug::TCLASS, "Default module `" << modName << "' not added because removed by user."); diff --git a/src/BufferParams.h b/src/BufferParams.h index e2c97e4235..743467a9a6 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -236,6 +236,8 @@ public: std::string local_layout; /// std::string options; + /// use the class options defined in the layout? + bool use_default_options; /// std::string master; /// diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 6a9cdf79e4..dcc118de19 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -896,6 +896,8 @@ GuiDocument::GuiDocument(GuiView & lv) // latex class connect(latexModule->optionsLE, SIGNAL(textChanged(QString)), this, SLOT(change_adaptor())); + connect(latexModule->defaultOptionsCB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); connect(latexModule->psdriverCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(latexModule->classCO, SIGNAL(activated(int)), @@ -913,7 +915,7 @@ GuiDocument::GuiDocument(GuiView & lv) connect(latexModule->childDocPB, SIGNAL(clicked()), this, SLOT(browseMaster())); - selectionManager = + selectionManager = new ModuleSelectionManager(latexModule->availableLV, latexModule->selectedLV, latexModule->addPB, latexModule->deletePB, @@ -1348,13 +1350,14 @@ void GuiDocument::classChanged() applyView(); } bp_.useClassDefaults(); - paramsToDialog(bp_); } // FIXME There's a little bug here connected with auto_reset, namely, // that, if the preceding is skipped and the user has changed the // modules before changing the class, those changes will be lost on // update. But maybe that's what we want? updateSelectedModules(); + bp_.makeDocumentClass(); + paramsToDialog(bp_); } @@ -1700,6 +1703,9 @@ void GuiDocument::apply(BufferParams & params) params.options = fromqstr(latexModule->optionsLE->text()); + params.use_default_options = + latexModule->defaultOptionsCB->isChecked(); + if (latexModule->childDocGB->isChecked()) params.master = fromqstr(latexModule->childDocLE->text()); @@ -1995,6 +2001,24 @@ void GuiDocument::paramsToDialog(BufferParams const & params) latexModule->optionsLE->setText(QString()); } + latexModule->defaultOptionsCB->setChecked( + params.use_default_options); + + if (!documentClass().options().empty()) { + latexModule->defaultOptionsLE->setText( + toqstr(documentClass().options())); + } else { + latexModule->defaultOptionsLE->setText( + toqstr(_("[No options predefined]"))); + } + + latexModule->defaultOptionsLE->setEnabled( + params.use_default_options + && !documentClass().options().empty()); + + latexModule->defaultOptionsCB->setEnabled( + !documentClass().options().empty()); + if (!params.master.empty()) { latexModule->childDocGB->setChecked(true); latexModule->childDocLE->setText( diff --git a/src/frontends/qt4/ui/LaTeXUi.ui b/src/frontends/qt4/ui/LaTeXUi.ui index 7d4903376b..2c65719637 100644 --- a/src/frontends/qt4/ui/LaTeXUi.ui +++ b/src/frontends/qt4/ui/LaTeXUi.ui @@ -6,7 +6,7 @@ 0 0 381 - 413 + 449 @@ -19,54 +19,6 @@ 6 - - - - Select if the current document is included to a master file - - - - - - Select de&fault master document - - - true - - - - 9 - - - 6 - - - - - &Master: - - - childDocLE - - - - - - - &Browse... - - - - - - - Enter the name of the default master document - - - - - - @@ -160,18 +112,53 @@ - - - - Qt::Horizontal + + + + Select if the current document is included to a master file - - - 261 - 22 - + + - + + Select de&fault master document + + + true + + + + 9 + + + 6 + + + + + &Master: + + + childDocLE + + + + + + + &Browse... + + + + + + + Enter the name of the default master document + + + + + @@ -190,16 +177,23 @@ - - - - - - - &Options: + + + + Qt::Horizontal - - optionsLE + + + 261 + 22 + + + + + + + + 20 @@ -231,26 +225,64 @@ - - - - 20 + + + + Class options + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + The options that are predefined in the layout file. Click to the left to select/deselect. + + + true + + + + + + + + + + + + Enable to use the options that are predefined in the layout file + + + P&redefined: + + + + + + + Cust&om: + + + optionsLE + + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -269,5 +301,22 @@ qt_i18n.h - + + + defaultOptionsCB + toggled(bool) + defaultOptionsLE + setEnabled(bool) + + + 63 + 79 + + + 237 + 82 + + + +