diff --git a/development/FORMAT b/development/FORMAT index 9c66c43069..b96b0faa4e 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,10 @@ LyX file-format changes ----------------------- +2009-07-20 Uwe Stöhr + * Format incremented to 370: introduce a document option to + suppress the default date. + 2009-07-22 Vincent van Ravesteijn * Format incremented to 369: add the author ids to the list of authors and let the numbering start with 1 in stead of 0. diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index c648509bec..d088f7773d 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -950,7 +950,7 @@ def revert_hspace_glue_lengths(document): def convert_author_id(document): " Add the author_id to the \\author definition and make sure 0 is not used" i = 0 - j = 1 + j = 1 while True: i = find_token(document.header, "\\author", i) if i == -1: @@ -959,28 +959,28 @@ def convert_author_id(document): r = re.compile(r'(\\author) (\".*\")\s?(.*)$') m = r.match(document.header[i]) if m != None: - name = m.group(2) - - email = '' - if m.lastindex == 3: - email = m.group(3) - document.header[i] = "\\author %i %s %s" % (j, name, email) + name = m.group(2) + + email = '' + if m.lastindex == 3: + email = m.group(3) + document.header[i] = "\\author %i %s %s" % (j, name, email) j = j + 1 - i = i + 1 - - k = 0 - while True: - k = find_token(document.body, "\\change_", k) - if k == -1: - break - - change = document.body[k].split(' '); - if len(change) == 3: - type = change[0] - author_id = int(change[1]) - time = change[2] - document.body[k] = "%s %i %s" % (type, author_id + 1, time) - k = k + 1 + i = i + 1 + + k = 0 + while True: + k = find_token(document.body, "\\change_", k) + if k == -1: + break + + change = document.body[k].split(' '); + if len(change) == 3: + type = change[0] + author_id = int(change[1]) + time = change[2] + document.body[k] = "%s %i %s" % (type, author_id + 1, time) + k = k + 1 def revert_author_id(document): " Remove the author_id from the \\author definition " @@ -997,11 +997,11 @@ def revert_author_id(document): if m != None: author_id = int(m.group(2)) idmap[author_id] = j - name = m.group(3) - - email = '' - if m.lastindex == 4: - email = m.group(4) + name = m.group(3) + + email = '' + if m.lastindex == 4: + email = m.group(4) document.header[i] = "\\author %s %s" % (name, email) i = i + 1 j = j + 1 @@ -1011,16 +1011,33 @@ def revert_author_id(document): k = find_token(document.body, "\\change_", k) if k == -1: break - - change = document.body[k].split(' '); - if len(change) == 3: - type = change[0] - author_id = int(change[1]) - time = change[2] + + change = document.body[k].split(' '); + if len(change) == 3: + type = change[0] + author_id = int(change[1]) + time = change[2] document.body[k] = "%s %i %s" % (type, idmap[author_id], time) k = k + 1 +def revert_suppress_date(document): + " Revert suppressing of default document date to preamble code " + i = 0 + while True: + i = find_token(document.header, "\\suppress_date", i) + if i == -1: + break + # remove the preamble line and write to the preamble + # when suppress_date was true + date = get_value(document.header, "\\suppress_date", i) + if date == "true": + add_to_preamble(document, ["% this command was inserted by lyx2lyx"]) + add_to_preamble(document, ["\\date{}"]) + del document.header[i] + i = i + 1 + + ## # Conversion hub # @@ -1049,10 +1066,12 @@ convert = [[346, []], [366, []], [367, []], [368, []], - [369, [convert_author_id]] + [369, [convert_author_id]], + [370, []], ] -revert = [[368, [revert_author_id]], +revert = [[369, [revert_suppress_date]], + [368, [revert_author_id]], [367, [revert_hspace_glue_lengths]], [366, [revert_percent_vspace_lengths, revert_percent_hspace_lengths]], [365, [revert_percent_skip_lengths]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index c97a6cddf4..e2266d03ba 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -126,7 +126,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 369; // vfr: add author ids to list of authors +int const LYX_FORMAT = 370; // uwestoehr: option to suppress default date typedef map DepClean; typedef map > RefCache; diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 96aaf7af28..90c2a187d6 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -363,6 +363,7 @@ BufferParams::BufferParams() columns = 1; listings_params = string(); pagestyle = "default"; + suppress_date = false; // white is equal to no background color backgroundcolor = lyx::rgbFromHexName("#ffffff"); compressed = false; @@ -539,6 +540,8 @@ string BufferParams::readToken(Lexer & lex, string const & token, } else if (token == "\\master") { lex.eatLine(); master = lex.getString(); + } else if (token == "\\suppress_date") { + lex >> suppress_date; } else if (token == "\\language") { readLanguage(lex); } else if (token == "\\inputencoding") { @@ -863,6 +866,7 @@ void BufferParams::writeFile(ostream & os) const << "\n\\use_bibtopic " << convert(use_bibtopic) << "\n\\use_indices " << convert(use_indices) << "\n\\paperorientation " << string_orientation[orientation] + << "\n\\suppress_date " << convert(suppress_date) << '\n'; if (backgroundcolor != lyx::rgbFromHexName("#ffffff")) os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n'; @@ -1459,6 +1463,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // Line spacing lyxpreamble += from_utf8(spacing().writePreamble(tclass.provides("SetSpace"))); + // date + if (suppress_date) + lyxpreamble += "\\date{}\n"; + // PDF support. // * Hyperref manual: "Make sure it comes last of your loaded // packages, to give it a fighting chance of not being over-written, diff --git a/src/BufferParams.h b/src/BufferParams.h index 65e133b1a1..0be946c37f 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -259,6 +259,8 @@ public: /// std::string master; /// + bool suppress_date; + /// std::string float_placement; /// unsigned int columns; diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 515f10791e..510f532c25 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -932,6 +932,8 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(change_adaptor())); connect(latexModule->childDocPB, SIGNAL(clicked()), this, SLOT(browseMaster())); + connect(latexModule->suppressDateCB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); // postscript drivers for (int n = 0; tex_graphics[n][0]; ++n) { @@ -1777,6 +1779,9 @@ void GuiDocument::applyView() // preamble preambleModule->apply(bp_); + // date + bp_.suppress_date = latexModule->suppressDateCB->isChecked(); + // biblio bp_.setCiteEngine(ENGINE_BASIC); @@ -2148,6 +2153,9 @@ void GuiDocument::paramsToDialog() // preamble preambleModule->update(bp_, id()); + // date + latexModule->suppressDateCB->setChecked(bp_.suppress_date); + // biblio biblioModule->citeDefaultRB->setChecked( bp_.citeEngine() == ENGINE_BASIC); diff --git a/src/frontends/qt4/ui/LaTeXUi.ui b/src/frontends/qt4/ui/LaTeXUi.ui index 140a44c9f9..d068a7963d 100644 --- a/src/frontends/qt4/ui/LaTeXUi.ui +++ b/src/frontends/qt4/ui/LaTeXUi.ui @@ -1,57 +1,49 @@ - + LaTeXUi - - + + 0 0 341 - 301 + 319 - + - - - 9 - - - 6 - - - - + + + + Document &class - - + + 9 - + 6 - - - + + + 20 - - - - - 0 - 0 + + + + 0 0 - + Click to select a local document class definition file - + &Local Layout... @@ -59,57 +51,57 @@ - - - + + + Class options - - + + 9 - + 6 - - - - 0 - - + + + 6 + + 0 + - - + + 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 @@ -117,29 +109,29 @@ - - - + + + &Graphics driver: - + psdriverCO - - - + + + false - - - + + + Qt::Horizontal - + 261 22 @@ -147,47 +139,47 @@ - - - + + + 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 @@ -195,12 +187,28 @@ - - - + + + + true + + + + 0 + 0 + + + + Suppress default date on front page + + + + + + Qt::Vertical - + 20 2 @@ -216,7 +224,7 @@ psdriverCO - qt_i18n.h + qt_i18n.h @@ -226,11 +234,11 @@ defaultOptionsLE setEnabled(bool) - + 63 79 - + 237 82