new document option to suppress the default date, fileformat change, fixes #5823

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31028 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2009-08-14 00:52:33 +00:00
parent 50fa5f24d3
commit 33eec90086
7 changed files with 175 additions and 126 deletions

View File

@ -1,6 +1,10 @@
LyX file-format changes LyX file-format changes
----------------------- -----------------------
2009-07-20 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 370: introduce a document option to
suppress the default date.
2009-07-22 Vincent van Ravesteijn <vfr@lyx.org> 2009-07-22 Vincent van Ravesteijn <vfr@lyx.org>
* Format incremented to 369: add the author ids to the list of * Format incremented to 369: add the author ids to the list of
authors and let the numbering start with 1 in stead of 0. authors and let the numbering start with 1 in stead of 0.

View File

@ -950,7 +950,7 @@ def revert_hspace_glue_lengths(document):
def convert_author_id(document): def convert_author_id(document):
" Add the author_id to the \\author definition and make sure 0 is not used" " Add the author_id to the \\author definition and make sure 0 is not used"
i = 0 i = 0
j = 1 j = 1
while True: while True:
i = find_token(document.header, "\\author", i) i = find_token(document.header, "\\author", i)
if i == -1: if i == -1:
@ -959,28 +959,28 @@ def convert_author_id(document):
r = re.compile(r'(\\author) (\".*\")\s?(.*)$') r = re.compile(r'(\\author) (\".*\")\s?(.*)$')
m = r.match(document.header[i]) m = r.match(document.header[i])
if m != None: if m != None:
name = m.group(2) name = m.group(2)
email = '' email = ''
if m.lastindex == 3: if m.lastindex == 3:
email = m.group(3) email = m.group(3)
document.header[i] = "\\author %i %s %s" % (j, name, email) document.header[i] = "\\author %i %s %s" % (j, name, email)
j = j + 1 j = j + 1
i = i + 1 i = i + 1
k = 0 k = 0
while True: while True:
k = find_token(document.body, "\\change_", k) k = find_token(document.body, "\\change_", k)
if k == -1: if k == -1:
break break
change = document.body[k].split(' '); change = document.body[k].split(' ');
if len(change) == 3: if len(change) == 3:
type = change[0] type = change[0]
author_id = int(change[1]) author_id = int(change[1])
time = change[2] time = change[2]
document.body[k] = "%s %i %s" % (type, author_id + 1, time) document.body[k] = "%s %i %s" % (type, author_id + 1, time)
k = k + 1 k = k + 1
def revert_author_id(document): def revert_author_id(document):
" Remove the author_id from the \\author definition " " Remove the author_id from the \\author definition "
@ -997,11 +997,11 @@ def revert_author_id(document):
if m != None: if m != None:
author_id = int(m.group(2)) author_id = int(m.group(2))
idmap[author_id] = j idmap[author_id] = j
name = m.group(3) name = m.group(3)
email = '' email = ''
if m.lastindex == 4: if m.lastindex == 4:
email = m.group(4) email = m.group(4)
document.header[i] = "\\author %s %s" % (name, email) document.header[i] = "\\author %s %s" % (name, email)
i = i + 1 i = i + 1
j = j + 1 j = j + 1
@ -1011,16 +1011,33 @@ def revert_author_id(document):
k = find_token(document.body, "\\change_", k) k = find_token(document.body, "\\change_", k)
if k == -1: if k == -1:
break break
change = document.body[k].split(' '); change = document.body[k].split(' ');
if len(change) == 3: if len(change) == 3:
type = change[0] type = change[0]
author_id = int(change[1]) author_id = int(change[1])
time = change[2] time = change[2]
document.body[k] = "%s %i %s" % (type, idmap[author_id], time) document.body[k] = "%s %i %s" % (type, idmap[author_id], time)
k = k + 1 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 # Conversion hub
# #
@ -1049,10 +1066,12 @@ convert = [[346, []],
[366, []], [366, []],
[367, []], [367, []],
[368, []], [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]], [367, [revert_hspace_glue_lengths]],
[366, [revert_percent_vspace_lengths, revert_percent_hspace_lengths]], [366, [revert_percent_vspace_lengths, revert_percent_hspace_lengths]],
[365, [revert_percent_skip_lengths]], [365, [revert_percent_skip_lengths]],

View File

@ -126,7 +126,7 @@ namespace {
// Do not remove the comment below, so we get merge conflict in // Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own. // 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<string, bool> DepClean; typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache; typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;

View File

@ -363,6 +363,7 @@ BufferParams::BufferParams()
columns = 1; columns = 1;
listings_params = string(); listings_params = string();
pagestyle = "default"; pagestyle = "default";
suppress_date = false;
// white is equal to no background color // white is equal to no background color
backgroundcolor = lyx::rgbFromHexName("#ffffff"); backgroundcolor = lyx::rgbFromHexName("#ffffff");
compressed = false; compressed = false;
@ -539,6 +540,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
} else if (token == "\\master") { } else if (token == "\\master") {
lex.eatLine(); lex.eatLine();
master = lex.getString(); master = lex.getString();
} else if (token == "\\suppress_date") {
lex >> suppress_date;
} else if (token == "\\language") { } else if (token == "\\language") {
readLanguage(lex); readLanguage(lex);
} else if (token == "\\inputencoding") { } else if (token == "\\inputencoding") {
@ -863,6 +866,7 @@ void BufferParams::writeFile(ostream & os) const
<< "\n\\use_bibtopic " << convert<string>(use_bibtopic) << "\n\\use_bibtopic " << convert<string>(use_bibtopic)
<< "\n\\use_indices " << convert<string>(use_indices) << "\n\\use_indices " << convert<string>(use_indices)
<< "\n\\paperorientation " << string_orientation[orientation] << "\n\\paperorientation " << string_orientation[orientation]
<< "\n\\suppress_date " << convert<string>(suppress_date)
<< '\n'; << '\n';
if (backgroundcolor != lyx::rgbFromHexName("#ffffff")) if (backgroundcolor != lyx::rgbFromHexName("#ffffff"))
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n'; os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
@ -1459,6 +1463,10 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
// Line spacing // Line spacing
lyxpreamble += from_utf8(spacing().writePreamble(tclass.provides("SetSpace"))); lyxpreamble += from_utf8(spacing().writePreamble(tclass.provides("SetSpace")));
// date
if (suppress_date)
lyxpreamble += "\\date{}\n";
// PDF support. // PDF support.
// * Hyperref manual: "Make sure it comes last of your loaded // * Hyperref manual: "Make sure it comes last of your loaded
// packages, to give it a fighting chance of not being over-written, // packages, to give it a fighting chance of not being over-written,

View File

@ -259,6 +259,8 @@ public:
/// ///
std::string master; std::string master;
/// ///
bool suppress_date;
///
std::string float_placement; std::string float_placement;
/// ///
unsigned int columns; unsigned int columns;

View File

@ -932,6 +932,8 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(latexModule->childDocPB, SIGNAL(clicked()), connect(latexModule->childDocPB, SIGNAL(clicked()),
this, SLOT(browseMaster())); this, SLOT(browseMaster()));
connect(latexModule->suppressDateCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
// postscript drivers // postscript drivers
for (int n = 0; tex_graphics[n][0]; ++n) { for (int n = 0; tex_graphics[n][0]; ++n) {
@ -1777,6 +1779,9 @@ void GuiDocument::applyView()
// preamble // preamble
preambleModule->apply(bp_); preambleModule->apply(bp_);
// date
bp_.suppress_date = latexModule->suppressDateCB->isChecked();
// biblio // biblio
bp_.setCiteEngine(ENGINE_BASIC); bp_.setCiteEngine(ENGINE_BASIC);
@ -2148,6 +2153,9 @@ void GuiDocument::paramsToDialog()
// preamble // preamble
preambleModule->update(bp_, id()); preambleModule->update(bp_, id());
// date
latexModule->suppressDateCB->setChecked(bp_.suppress_date);
// biblio // biblio
biblioModule->citeDefaultRB->setChecked( biblioModule->citeDefaultRB->setChecked(
bp_.citeEngine() == ENGINE_BASIC); bp_.citeEngine() == ENGINE_BASIC);

View File

@ -1,57 +1,49 @@
<ui version="4.0" > <ui version="4.0">
<class>LaTeXUi</class> <class>LaTeXUi</class>
<widget class="QWidget" name="LaTeXUi" > <widget class="QWidget" name="LaTeXUi">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>341</width> <width>341</width>
<height>301</height> <height>319</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string/> <string/>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" name="gridLayout">
<property name="margin" > <item row="0" column="0" colspan="3">
<number>9</number> <widget class="QGroupBox" name="groupBox">
</property> <property name="title">
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" colspan="3" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Document &amp;class</string> <string>Document &amp;class</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout">
<property name="margin" > <property name="margin">
<number>9</number> <number>9</number>
</property> </property>
<property name="spacing" > <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0" > <item row="0" column="0">
<widget class="QComboBox" name="classCO" > <widget class="QComboBox" name="classCO">
<property name="maxVisibleItems" > <property name="maxVisibleItems">
<number>20</number> <number>20</number>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" > <item row="0" column="1">
<widget class="QPushButton" name="layoutPB" > <widget class="QPushButton" name="layoutPB">
<property name="sizePolicy" > <property name="sizePolicy">
<sizepolicy> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="toolTip" > <property name="toolTip">
<string>Click to select a local document class definition file</string> <string>Click to select a local document class definition file</string>
</property> </property>
<property name="text" > <property name="text">
<string>&amp;Local Layout...</string> <string>&amp;Local Layout...</string>
</property> </property>
</widget> </widget>
@ -59,57 +51,57 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="3" > <item row="1" column="0" colspan="3">
<widget class="QGroupBox" name="optionsGB" > <widget class="QGroupBox" name="optionsGB">
<property name="title" > <property name="title">
<string>Class options</string> <string>Class options</string>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout">
<property name="margin" > <property name="margin">
<number>9</number> <number>9</number>
</property> </property>
<property name="spacing" > <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item rowspan="2" row="0" column="1" > <item row="0" column="1" rowspan="2">
<layout class="QVBoxLayout" > <layout class="QVBoxLayout">
<property name="margin" > <property name="spacing">
<number>0</number>
</property>
<property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QLineEdit" name="defaultOptionsLE" > <widget class="QLineEdit" name="defaultOptionsLE">
<property name="toolTip" > <property name="toolTip">
<string>The options that are predefined in the layout file. Click to the left to select/deselect.</string> <string>The options that are predefined in the layout file. Click to the left to select/deselect.</string>
</property> </property>
<property name="readOnly" > <property name="readOnly">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="optionsLE" /> <widget class="QLineEdit" name="optionsLE"/>
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="0" > <item row="0" column="0">
<widget class="QCheckBox" name="defaultOptionsCB" > <widget class="QCheckBox" name="defaultOptionsCB">
<property name="toolTip" > <property name="toolTip">
<string>Enable to use the options that are predefined in the layout file</string> <string>Enable to use the options that are predefined in the layout file</string>
</property> </property>
<property name="text" > <property name="text">
<string>P&amp;redefined:</string> <string>P&amp;redefined:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" > <item row="1" column="0">
<widget class="QLabel" name="optionsL" > <widget class="QLabel" name="optionsL">
<property name="text" > <property name="text">
<string>Cust&amp;om:</string> <string>Cust&amp;om:</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>optionsLE</cstring> <cstring>optionsLE</cstring>
</property> </property>
</widget> </widget>
@ -117,29 +109,29 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0" > <item row="2" column="0">
<widget class="QLabel" name="psdriverL" > <widget class="QLabel" name="psdriverL">
<property name="text" > <property name="text">
<string>&amp;Graphics driver:</string> <string>&amp;Graphics driver:</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>psdriverCO</cstring> <cstring>psdriverCO</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" > <item row="2" column="2">
<widget class="QComboBox" name="psdriverCO" > <widget class="QComboBox" name="psdriverCO">
<property name="duplicatesEnabled" > <property name="duplicatesEnabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2" > <item row="2" column="3">
<spacer> <spacer name="horizontalSpacer_1">
<property name="orientation" > <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>261</width> <width>261</width>
<height>22</height> <height>22</height>
@ -147,47 +139,47 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="0" colspan="3" > <item row="3" column="0" colspan="4">
<widget class="QGroupBox" name="childDocGB" > <widget class="QGroupBox" name="childDocGB">
<property name="toolTip" > <property name="toolTip">
<string>Select if the current document is included to a master file</string> <string>Select if the current document is included to a master file</string>
</property> </property>
<property name="statusTip" > <property name="statusTip">
<string/> <string/>
</property> </property>
<property name="title" > <property name="title">
<string>Select de&amp;fault master document</string> <string>Select de&amp;fault master document</string>
</property> </property>
<property name="checkable" > <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout">
<property name="margin" > <property name="margin">
<number>9</number> <number>9</number>
</property> </property>
<property name="spacing" > <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0" > <item row="0" column="0">
<widget class="QLabel" name="childDocLA" > <widget class="QLabel" name="childDocLA">
<property name="text" > <property name="text">
<string>&amp;Master:</string> <string>&amp;Master:</string>
</property> </property>
<property name="buddy" > <property name="buddy">
<cstring>childDocLE</cstring> <cstring>childDocLE</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2" > <item row="0" column="2">
<widget class="QPushButton" name="childDocPB" > <widget class="QPushButton" name="childDocPB">
<property name="text" > <property name="text">
<string>&amp;Browse...</string> <string>&amp;Browse...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" > <item row="0" column="1">
<widget class="QLineEdit" name="childDocLE" > <widget class="QLineEdit" name="childDocLE">
<property name="toolTip" > <property name="toolTip">
<string>Enter the name of the default master document</string> <string>Enter the name of the default master document</string>
</property> </property>
</widget> </widget>
@ -195,12 +187,28 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="0" > <item row="4" column="0" colspan="4">
<spacer> <widget class="QCheckBox" name="suppressDateCB">
<property name="orientation" > <property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Suppress default date on front page</string>
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>2</height> <height>2</height>
@ -216,7 +224,7 @@
<tabstop>psdriverCO</tabstop> <tabstop>psdriverCO</tabstop>
</tabstops> </tabstops>
<includes> <includes>
<include location="local" >qt_i18n.h</include> <include location="local">qt_i18n.h</include>
</includes> </includes>
<resources/> <resources/>
<connections> <connections>
@ -226,11 +234,11 @@
<receiver>defaultOptionsLE</receiver> <receiver>defaultOptionsLE</receiver>
<slot>setEnabled(bool)</slot> <slot>setEnabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>63</x> <x>63</x>
<y>79</y> <y>79</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>237</x> <x>237</x>
<y>82</y> <y>82</y>
</hint> </hint>