* Per-document setting for bibtex and makeindex.

File format change.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29774 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-05-22 07:20:00 +00:00
parent ce473c810a
commit 7ba2bfb81d
14 changed files with 403 additions and 123 deletions

View File

@ -1,13 +1,17 @@
LyX file-format changes
-----------------------
2009-05-05 Pavel Sanda, Enrico Forestieri
* Format incremented to 357: Change of the latex output for underline
from \underbar to ulem's \uline.
2009-04-26 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 358: support for custom bibtex and
makeindex commands.
2009-05-05 Pavel Sanda <sanda@lyx.org>, Enrico Forestieri <forenr@lyx.org>
* Format incremented to 357: Change of the latex output for
underline from \underbar to ulem's \uline.
2009-05-05 Pavel Sanda <sanda@lyx.org>
* Format incremented to 356: support for double and wave underline character
styles via ulem's \uuline and \uwave
* Format incremented to 356: support for double and wave underline
character styles via ulem's \uuline and \uwave
2009-05-03 Pavel Sanda <sanda@lyx.org>
* Format incremented to 355: support for strikeout character
@ -25,7 +29,8 @@ LyX file-format changes
* Format incremented to 352: splitindex support.
2009-04-11 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 351: support to set a page background color.
* Format incremented to 351: support to set a page background
color.
2009-04-06 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 350: new param \default_output_format.

View File

@ -630,6 +630,7 @@ def revert_uulinewave(document):
return
del document.body[i]
def revert_ulinelatex(document):
" Reverts \\uline character style "
i = find_token(document.body, '\\bar under', 0)
@ -645,6 +646,20 @@ def revert_ulinelatex(document):
+ '\\renewcommand{\\underbar}[1]{{\\let\\cite\\b@xcite\\uline{#1}}}\n')
def revert_custom_processors(document):
" Remove bibtex_command and index_command params "
i = find_token(document.header, '\\bibtex_command', 0)
if i == -1:
document.warning("Malformed LyX document: Missing \\bibtex_command.")
return
del document.header[i]
i = find_token(document.header, '\\index_command', 0)
if i == -1:
document.warning("Malformed LyX document: Missing \\index_command.")
return
del document.header[i]
##
# Conversion hub
#
@ -661,10 +676,12 @@ convert = [[346, []],
[354, []],
[355, []],
[356, []],
[357, []]
[357, []],
[358, []]
]
revert = [[356, [revert_ulinelatex]],
revert = [[357, [revert_custom_processors]],
[356, [revert_ulinelatex]],
[355, [revert_uulinewave]],
[354, [revert_strikeout]],
[353, [revert_printindexall]],

View File

@ -125,7 +125,7 @@ namespace {
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
int const LYX_FORMAT = 357; // sanda: change latex output for various underline commands
int const LYX_FORMAT = 358; // jspitzm: customizable bibtex/makeindex calls
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;

View File

@ -355,6 +355,8 @@ BufferParams::BufferParams()
inputenc = "auto";
graphicsDriver = "default";
defaultOutputFormat = "default";
bibtex_command = "default";
index_command = "default";
sides = OneSide;
columns = 1;
listings_params = string();
@ -531,6 +533,12 @@ string BufferParams::readToken(Lexer & lex, string const & token,
readGraphicsDriver(lex);
} else if (token == "\\default_output_format") {
lex >> defaultOutputFormat;
} else if (token == "\\bibtex_command") {
lex.eatLine();
bibtex_command = lex.getString();
} else if (token == "\\index_command") {
lex.eatLine();
index_command = lex.getString();
} else if (token == "\\font_roman") {
lex.eatLine();
fontsRoman = lex.getString();
@ -813,6 +821,8 @@ void BufferParams::writeFile(ostream & os) const
}
os << "\n\\graphics " << graphicsDriver << '\n';
os << "\\default_output_format " << defaultOutputFormat << '\n';
os << "\\bibtex_command " << bibtex_command << '\n';
os << "\\index_command " << index_command << '\n';
if (!float_placement.empty()) {
os << "\\float_placement " << float_placement << '\n';

View File

@ -184,6 +184,10 @@ public:
std::string graphicsDriver;
/// The default output format
std::string defaultOutputFormat;
/// customized bibliography processor
std::string bibtex_command;
/// customized index processor
std::string index_command;
/// the rm font
std::string fontsRoman;
/// the sf font

View File

@ -329,6 +329,10 @@ bool Converters::convert(Buffer const * buffer,
if (buffer) {
runparams.use_japanese = buffer->bufferFormat() == "platex";
runparams.use_indices = buffer->params().use_indices;
runparams.bibtex_command = (buffer->params().bibtex_command == "default") ?
string() : buffer->params().bibtex_command;
runparams.index_command = (buffer->params().index_command == "default") ?
string() : buffer->params().index_command;
}
// Some converters (e.g. lilypond) can only output files to the

View File

@ -50,7 +50,6 @@ namespace os = support::os;
// different way.
// - the makeindex style files should be taken care of with
// the dependency mechanism.
// - makeindex commandline options should be supported
// - somewhere support viewing of bibtex and makeindex log files.
// - we should perhaps also scan the bibtex log file
@ -414,6 +413,9 @@ bool LaTeX::runMakeIndex(string const & f, OutputParams const & runparams,
{
string tmp = runparams.use_japanese ?
lyxrc.jindex_command : lyxrc.index_command;
if (!runparams.index_command.empty())
tmp = runparams.index_command;
LYXERR(Debug::LATEX,
"idx file has been made, running index processor ("
@ -570,6 +572,9 @@ bool LaTeX::runBibTeX(vector<AuxInfo> const & bibtex_info,
string tmp = runparams.use_japanese ?
lyxrc.jbibtex_command : lyxrc.bibtex_command;
if (!runparams.bibtex_command.empty())
tmp = runparams.bibtex_command;
tmp += " ";
// onlyFilename() is needed for cygwin
tmp += quoteName(onlyFilename(removeExtension(

View File

@ -127,6 +127,14 @@ public:
*/
bool use_japanese;
/** Customized bibtex_command
*/
mutable std::string bibtex_command;
/** Customized index_command
*/
mutable std::string index_command;
/** Line length to use with plaintext export.
*/
size_type linelen;

View File

@ -859,10 +859,23 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor()));
connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(biblioModule->bibtexCO, SIGNAL(activated(int)),
this, SLOT(bibtexChanged(int)));
connect(biblioModule->bibtexOptionsED, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor()));
// biblio
biblioModule->citeStyleCO->addItem(qt_("Author-year"));
biblioModule->citeStyleCO->addItem(qt_("Numerical"));
biblioModule->citeStyleCO->setCurrentIndex(0);
biblioModule->bibtexCO->clear();
biblioModule->bibtexCO->addItem(qt_("Default"), QString("default"));
for (vector<string>::const_iterator it = lyxrc.bibtex_alternatives.begin();
it != lyxrc.bibtex_alternatives.end(); ++it) {
QString const command = toqstr(*it).left(toqstr(*it).indexOf(" "));
biblioModule->bibtexCO->addItem(command, command);
}
// indices
indicesModule = new GuiIndices;
@ -1498,6 +1511,13 @@ void GuiDocument::classChanged()
}
void GuiDocument::bibtexChanged(int n)
{
biblioModule->bibtexOptionsED->setEnabled(n != 0);
changed();
}
namespace {
// This is an insanely complicated attempt to make this sort of thing
// work with RTL languages.
@ -1721,6 +1741,15 @@ void GuiDocument::applyView()
bp_.use_bibtopic =
biblioModule->bibtopicCB->isChecked();
string const bibtex_command =
fromqstr(biblioModule->bibtexCO->itemData(
biblioModule->bibtexCO->currentIndex()).toString());
if (bibtex_command == "default")
bp_.bibtex_command = bibtex_command;
else
bp_.bibtex_command = bibtex_command + " "
+ fromqstr(biblioModule->bibtexOptionsED->text());
// Indices
indicesModule->apply(bp_);
@ -2058,6 +2087,21 @@ void GuiDocument::paramsToDialog()
biblioModule->bibtopicCB->setChecked(
bp_.use_bibtopic);
string command;
string options =
split(bp_.bibtex_command, command, ' ');
int const bpos = biblioModule->bibtexCO->findData(toqstr(command));
if (bpos != -1) {
biblioModule->bibtexCO->setCurrentIndex(bpos);
biblioModule->bibtexOptionsED->setText(toqstr(options).trimmed());
} else {
biblioModule->bibtexCO->setCurrentIndex(0);
biblioModule->bibtexOptionsED->clear();
}
biblioModule->bibtexOptionsED->setEnabled(
biblioModule->bibtexCO->currentIndex() != 0);
// indices
indicesModule->update(bp_);

View File

@ -99,6 +99,7 @@ private Q_SLOTS:
void browseLayout();
void browseMaster();
void classChanged();
void bibtexChanged(int);
void updateModuleInfo();
void modulesChanged();
void changeBackgroundColor();

View File

@ -22,6 +22,7 @@
#include "frontends/alert.h"
#include "BufferParams.h"
#include "LyXRC.h"
#include "support/gettext.h"
#include "support/lstrings.h"
@ -34,6 +35,10 @@
#include <QColorDialog>
using namespace std;
using namespace lyx::support;
namespace lyx {
namespace frontend {
@ -46,6 +51,14 @@ GuiIndices::GuiIndices(QWidget * parent)
indicesTW->headerItem()->setText(0, qt_("Name"));
indicesTW->headerItem()->setText(1, qt_("Label Color"));
indicesTW->setSortingEnabled(true);
indexCO->clear();
indexCO->addItem(qt_("Default"), QString("default"));
for (vector<string>::const_iterator it = lyxrc.index_alternatives.begin();
it != lyxrc.index_alternatives.end(); ++it) {
QString const command = toqstr(*it).left(toqstr(*it).indexOf(" "));
indexCO->addItem(command, command);
}
}
void GuiIndices::update(BufferParams const & params)
@ -60,6 +73,22 @@ void GuiIndices::update(BufferParams const & params)
availableLA->setEnabled(state);
removePB->setEnabled(state);
colorPB->setEnabled(state);
string command;
string options =
split(params.index_command, command, ' ');
int const pos = indexCO->findData(toqstr(command));
if (pos != -1) {
indexCO->setCurrentIndex(pos);
indexOptionsED->setText(toqstr(options).trimmed());
} else {
indexCO->setCurrentIndex(0);
indexOptionsED->clear();
}
indexOptionsED->setEnabled(
indexCO->currentIndex() != 0);
updateView();
}
@ -103,6 +132,28 @@ void GuiIndices::apply(BufferParams & params) const
{
params.use_indices = multipleIndicesCB->isChecked();
params.indiceslist() = indiceslist_;
string const index_command =
fromqstr(indexCO->itemData(
indexCO->currentIndex()).toString());
if (index_command == "default")
params.index_command = index_command;
else
params.index_command = index_command + " "
+ fromqstr(indexOptionsED->text());
}
void GuiIndices::on_indexCO_activated(int n)
{
indexOptionsED->setEnabled(n != 0);
changed();
}
void GuiIndices::on_indexOptionsED_textChanged(QString)
{
changed();
}

View File

@ -44,6 +44,8 @@ protected:
void updateView();
protected Q_SLOTS:
void on_indexCO_activated(int n);
void on_indexOptionsED_textChanged(QString);
void on_addIndexPB_pressed();
void on_renamePB_clicked();
void on_removePB_pressed();

View File

@ -12,32 +12,23 @@
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<layout class="QGridLayout" name="gridLayout_3" >
<item row="0" column="0" >
<widget class="QGroupBox" name="CiteStyleBG" >
<property name="title" >
<string>Citation Style</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="2" column="0" >
<widget class="QRadioButton" name="citeJurabibRB" >
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QRadioButton" name="citeDefaultRB" >
<property name="toolTip" >
<string>Use the jurabib styles for law and humanities</string>
<string>Use BibTeX's default numerical styles</string>
</property>
<property name="text" >
<string>&amp;Jurabib</string>
<string>&amp;Default (numerical)</string>
</property>
</widget>
</item>
@ -51,24 +42,14 @@
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QRadioButton" name="citeDefaultRB" >
<property name="toolTip" >
<string>Use BibTeX's default numerical styles</string>
</property>
<property name="text" >
<string>&amp;Default (numerical)</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="citationStyleL" >
<property name="enabled" >
@ -88,9 +69,7 @@
<bool>false</bool>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -99,23 +78,33 @@
</item>
</layout>
</item>
<item row="1" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" >
<widget class="QRadioButton" name="citeJurabibRB" >
<property name="toolTip" >
<string>Use the jurabib styles for law and humanities</string>
</property>
<property name="text" >
<string>&amp;Jurabib</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2" >
<item row="1" column="0" >
<widget class="QCheckBox" name="bibtopicCB" >
<property name="toolTip" >
<string>Select this if you want to split your bibliography into sections</string>
@ -125,7 +114,77 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<item row="2" column="0" >
<widget class="QGroupBox" name="bibtexGB" >
<property name="toolTip" >
<string>Here you can define an alternative program to or specific options of bibtex.</string>
</property>
<property name="title" >
<string>Bibliography generation</string>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="bibtexLA" >
<property name="text" >
<string>&amp;Processor:</string>
</property>
<property name="buddy" >
<cstring>bibtexCO</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="bibtexCO" >
<property name="toolTip" >
<string>Select a processor</string>
</property>
</widget>
</item>
</layout>
</item>
<item rowspan="2" row="0" column="1" >
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>183</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QLabel" name="bibtexOptionsLA" >
<property name="text" >
<string>&amp;Options:</string>
</property>
<property name="buddy" >
<cstring>bibtexOptionsED</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="bibtexOptionsED" >
<property name="toolTip" >
<string>Define options such as --min-crossrefs (see man bibtex).</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
@ -133,7 +192,7 @@
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>

View File

@ -12,21 +12,102 @@
<property name="windowTitle" >
<string/>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="2" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QGroupBox" name="indexGB" >
<property name="toolTip" >
<string>Here you can define an alternative index processor and specify its options.</string>
</property>
<property name="title" >
<string>Index generation</string>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="indexLA" >
<property name="text" >
<string>&amp;Processor:</string>
</property>
<property name="buddy" >
<cstring>indexCO</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="indexCO" >
<property name="toolTip" >
<string>Select a processor</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QLabel" name="indexOptionsLA" >
<property name="text" >
<string>&amp;Options:</string>
</property>
<property name="buddy" >
<cstring>indexOptionsED</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="indexOptionsED" >
<property name="toolTip" >
<string>Define program options of the selected processor.</string>
</property>
</widget>
</item>
</layout>
</item>
<item rowspan="2" row="0" column="1" >
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>183</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="multipleIndicesCB" >
<property name="toolTip" >
<string>Check if you need multiple indexes (e.g., an Index of Names)</string>
</property>
<property name="text" >
<string>&amp;Use multiple indexes</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="newIndexLA" >
<property name="text" >
@ -56,33 +137,7 @@
</item>
</layout>
</item>
<item row="4" column="1" >
<widget class="QPushButton" name="removePB" >
<property name="toolTip" >
<string>Remove the selected index</string>
</property>
<property name="text" >
<string>&amp;Remove</string>
</property>
</widget>
</item>
<item row="7" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>121</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" >
<item row="4" column="0" >
<widget class="QLabel" name="availableLA" >
<property name="text" >
<string>A&amp;vailable Indexes:</string>
@ -92,37 +147,26 @@
</property>
</widget>
</item>
<item rowspan="4" row="4" column="0" >
<widget class="QTreeWidget" name="indicesTW" />
</item>
<item row="0" column="0" >
<widget class="QCheckBox" name="multipleIndicesCB" >
<property name="toolTip" >
<string>Check if you need multiple indexes (e.g., an Index of Names)</string>
</property>
<property name="text" >
<string>&amp;Use multiple indexes</string>
</property>
<item rowspan="4" row="5" column="0" >
<widget class="QTreeWidget" name="indicesTW" >
<column>
<property name="text" >
<string>1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
<item row="5" column="1" >
<widget class="QPushButton" name="removePB" >
<property name="toolTip" >
<string>Remove the selected index</string>
</property>
<property name="text" >
<string>&amp;Remove</string>
</property>
</widget>
</item>
<item row="6" column="1" >
<widget class="QPushButton" name="colorPB" >
<property name="toolTip" >
<string>Define or change button color</string>
</property>
<property name="text" >
<string>Alter Co&amp;lor...</string>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QPushButton" name="renamePB" >
<property name="toolTip" >
<string>Rename the selected index</string>
@ -132,6 +176,32 @@
</property>
</widget>
</item>
<item row="7" column="1" >
<widget class="QPushButton" name="colorPB" >
<property name="toolTip" >
<string>Define or change button color</string>
</property>
<property name="text" >
<string>Alter Co&amp;lor...</string>
</property>
</widget>
</item>
<item row="8" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>121</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<includes>