mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
file format change due to r29770.
No automatic width calculation is done for old documents, because these might rely on settings in nomencl.cfg. A GUI to alter this is needed. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29775 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7ba2bfb81d
commit
18cfe15b64
@ -1,6 +1,10 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2009-04-26 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 359: param set_width for nomencl_print
|
||||
CommandInset.
|
||||
|
||||
2009-04-26 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 358: support for custom bibtex and
|
||||
makeindex commands.
|
||||
|
@ -660,6 +660,34 @@ def revert_custom_processors(document):
|
||||
del document.header[i]
|
||||
|
||||
|
||||
def convert_nomencl_width(document):
|
||||
" Add set_width param to nomencl_print "
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset CommandInset nomencl_print", i)
|
||||
if i == -1:
|
||||
break
|
||||
document.body.insert(i + 2, "set_width \"none\"")
|
||||
i = i + 1
|
||||
|
||||
|
||||
def revert_nomencl_width(document):
|
||||
" Remove set_width param from nomencl_print "
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset CommandInset nomencl_print", i)
|
||||
if i == -1:
|
||||
break
|
||||
j = find_end_of_inset(document.body, i)
|
||||
l = find_token(document.body, "set_width", i, j)
|
||||
if l == -1:
|
||||
document.warning("Can't find set_width option for nomencl_print!")
|
||||
i = j
|
||||
continue
|
||||
del document.body[l]
|
||||
i = i + 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -677,10 +705,12 @@ convert = [[346, []],
|
||||
[355, []],
|
||||
[356, []],
|
||||
[357, []],
|
||||
[358, []]
|
||||
[358, []],
|
||||
[359, [convert_nomencl_width]]
|
||||
]
|
||||
|
||||
revert = [[357, [revert_custom_processors]],
|
||||
revert = [[358, [revert_nomencl_width]],
|
||||
[357, [revert_custom_processors]],
|
||||
[356, [revert_ulinelatex]],
|
||||
[355, [revert_uulinewave]],
|
||||
[354, [revert_strikeout]],
|
||||
|
@ -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 = 358; // jspitzm: customizable bibtex/makeindex calls
|
||||
int const LYX_FORMAT = 359; // jspitzm: nomencl auto calculation
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -209,8 +209,11 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
|
||||
return new InsetPrintIndex(icp);
|
||||
}
|
||||
|
||||
case LFUN_NOMENCL_PRINT:
|
||||
return new InsetPrintNomencl(InsetCommandParams(NOMENCL_PRINT_CODE));
|
||||
case LFUN_NOMENCL_PRINT: {
|
||||
InsetCommandParams icp(NOMENCL_PRINT_CODE);
|
||||
icp["set_width"] = from_ascii("auto");
|
||||
return new InsetPrintNomencl(icp);
|
||||
}
|
||||
|
||||
case LFUN_TOC_INSERT:
|
||||
return new InsetTOC(InsetCommandParams(TOC_CODE));
|
||||
|
@ -125,10 +125,15 @@ InsetPrintNomencl::InsetPrintNomencl(InsetCommandParams const & p)
|
||||
|
||||
ParamInfo const & InsetPrintNomencl::findInfo(string const & /* cmdName */)
|
||||
{
|
||||
// there are no parameters to give because the symbol width is set via
|
||||
// nomencl's \nomlabelwidth in InsetPrintNomencl::latex and not as
|
||||
// optional parameter of \printnomenclature
|
||||
// The symbol width is set via nomencl's \nomlabelwidth in
|
||||
// InsetPrintNomencl::latex and not as optional parameter of
|
||||
// \printnomenclature
|
||||
static ParamInfo param_info_;
|
||||
if (param_info_.empty()) {
|
||||
// how is the width set?
|
||||
// values: none|auto
|
||||
param_info_.add("set_width", ParamInfo::LYX_INTERNAL);
|
||||
}
|
||||
return param_info_;
|
||||
}
|
||||
|
||||
@ -163,10 +168,11 @@ int InsetPrintNomencl::docbook(odocstream & os, OutputParams const &) const
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
docstring nomenclWidest(Buffer const & buffer)
|
||||
{
|
||||
// nomenclWidest() determines and returns the widest used nomenclature
|
||||
// symbol in the document
|
||||
// nomenclWidest() determines and returns the widest used
|
||||
// nomenclature symbol in the document
|
||||
|
||||
int w = 0;
|
||||
docstring symb;
|
||||
@ -199,20 +205,29 @@ docstring nomenclWidest(Buffer const & buffer)
|
||||
symb = symb + "W";
|
||||
return symb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int InsetPrintNomencl::latex(odocstream & os, OutputParams const &) const
|
||||
{
|
||||
int lines = 0;
|
||||
docstring widest = nomenclWidest(buffer());
|
||||
// set the label width via nomencl's command \nomlabelwidth
|
||||
// this must be output before the command \printnomenclature
|
||||
if (!widest.empty()) {
|
||||
// assure that the width is never below the predefined value of 1 cm
|
||||
os << "\\settowidth{\\nomlabelwidth}{" << widest <<"}\n";
|
||||
os << "\\ifthenelse{%\n \\lengthtest{\\nomlabelwidth < 1cm}}\n";
|
||||
os << " {\\setlength{\\nomlabelwidth}{1cm}}\n {}\n";
|
||||
++lines;
|
||||
if (getParam("set_width") == "auto") {
|
||||
docstring widest = nomenclWidest(buffer());
|
||||
// set the label width via nomencl's command
|
||||
// \nomlabelwidth. This must be output before the command
|
||||
// \printnomenclature
|
||||
if (!widest.empty()) {
|
||||
// assure that the width is never below the
|
||||
// predefined value of 1 cm
|
||||
os << "\\settowidth{\\nomlabelwidth}{"
|
||||
<< widest
|
||||
<< "}\n";
|
||||
os << "\\ifthenelse{%\n";
|
||||
os << "\\lengthtest{\\nomlabelwidth < 1cm}}\n";
|
||||
os << " {\\setlength{\\nomlabelwidth}{1cm}}\n";
|
||||
os << " {}\n";
|
||||
lines += 5;
|
||||
}
|
||||
}
|
||||
// output the command \printnomenclature
|
||||
os << getCommand();
|
||||
|
@ -80,14 +80,8 @@ public:
|
||||
int latex(odocstream &, OutputParams const &) const;
|
||||
private:
|
||||
Inset * clone() const { return new InsetPrintNomencl(*this); }
|
||||
///
|
||||
friend docstring nomenclWidest(Buffer const & buffer);
|
||||
};
|
||||
|
||||
/// return the widest symbol of all nomenclature entries of the document
|
||||
docstring nomenclWidest(Buffer const &);
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user