mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Rework and partially revert r33631.
This patch introduces a "ListCommand" tag for Float layout. This tag defines the command used to generate a list of such floats, in the cases where float.sty is not used (i.e., where NeedsFloatPkg is true). We were previously hardcoding the commands \listoftables and \listoffigures. But in other cases, such as achemso.layout, which defines lists of schemes, charts, etc, we could not output such lists. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33633 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9d6979f0eb
commit
abc81b5c07
@ -12539,6 +12539,73 @@ HTML*
|
||||
|
||||
These are used for XHTML output.
|
||||
See
|
||||
\begin_inset CommandInset ref
|
||||
LatexCommand ref
|
||||
reference "sec:Tags-for-XHTML"
|
||||
|
||||
\end_inset
|
||||
|
||||
.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
\begin_inset Flex CharStyle:Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
ListCommand
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
[
|
||||
\begin_inset Flex CharStyle:Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
string
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
=
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
] The command used to generate a list of floats of this type; the leading
|
||||
`
|
||||
\backslash
|
||||
' should be omitted.
|
||||
This
|
||||
\emph on
|
||||
must
|
||||
\emph default
|
||||
be given if
|
||||
\begin_inset Flex CharStyle:Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
NeedsFloatPkg
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
is false, since there is no standard way to generate this command.
|
||||
It is ignored if
|
||||
\begin_inset Flex CharStyle:Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
NeedsFloatPkg
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
is true, since in that case there is a standard way.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Description
|
||||
|
@ -85,7 +85,8 @@ import os, re, string, sys
|
||||
# Added Spellcheck tag.
|
||||
|
||||
# Incremented to format 24, 5 March 2010 by rgh
|
||||
# Changed LaTeXBuiltin tag to NeedsFloatPkg.
|
||||
# Changed LaTeXBuiltin tag to NeedsFloatPkg and
|
||||
# added new tag ListCommand.
|
||||
|
||||
# Do not forget to document format change in Customization
|
||||
# Manual (section "Declaring a new text class").
|
||||
@ -174,6 +175,8 @@ def convert(lines):
|
||||
re_TocLevel = re.compile(r'^(\s*)(TocLevel)(\s+)(\S+)', re.IGNORECASE)
|
||||
re_I18nPreamble = re.compile(r'^(\s*)I18nPreamble', re.IGNORECASE)
|
||||
re_EndI18nPreamble = re.compile(r'^(\s*)EndI18nPreamble', re.IGNORECASE)
|
||||
re_Float = re.compile(r'^\s*Float\s*$', re.IGNORECASE)
|
||||
re_Type = re.compile(r'\s*Type\s+(\w+)', re.IGNORECASE)
|
||||
re_Builtin = re.compile(r'^(\s*)LaTeXBuiltin\s+(\w*)', re.IGNORECASE)
|
||||
re_True = re.compile(r'^\s*(?:true|1)\s*$', re.IGNORECASE)
|
||||
|
||||
@ -265,17 +268,45 @@ def convert(lines):
|
||||
continue
|
||||
|
||||
if format == 23:
|
||||
match = re_Builtin.match(lines[i])
|
||||
if match:
|
||||
ws = match.group(1)
|
||||
arg = match.group(2)
|
||||
match = re_Float.match(lines[i])
|
||||
i += 1
|
||||
if not match:
|
||||
continue
|
||||
# we need to do two things:
|
||||
# (i) Convert Builtin to NeedsFloatPkg
|
||||
# (ii) Write ListCommand lines for the builtin floats table and figure
|
||||
builtin = False
|
||||
cmd = ""
|
||||
while True and i < len(lines):
|
||||
m1 = re_End.match(lines[i])
|
||||
if m1:
|
||||
if builtin and cmd:
|
||||
line = " ListCommand " + cmd
|
||||
lines.insert(i, line)
|
||||
i += 1
|
||||
break
|
||||
m2 = re_Builtin.match(lines[i])
|
||||
if m2:
|
||||
builtin = True
|
||||
ws1 = m2.group(1)
|
||||
arg = m2.group(2)
|
||||
newarg = ""
|
||||
if re_True.match(arg):
|
||||
newarg = "false"
|
||||
else:
|
||||
newarg = "true"
|
||||
lines[i] = ws + "NeedsFloatPkg " + newarg
|
||||
|
||||
lines[i] = ws1 + "NeedsFloatPkg " + newarg
|
||||
m3 = re_Type.match(lines[i])
|
||||
if m3:
|
||||
fltype = m3.group(1)
|
||||
fltype = fltype.lower()
|
||||
if fltype == "table":
|
||||
cmd = "listoftables"
|
||||
elif fltype == "figure":
|
||||
cmd = "listoffigures"
|
||||
# else unknown, which is why we're doing this
|
||||
i += 1
|
||||
continue
|
||||
|
||||
# This just involved new features, not any changes to old ones
|
||||
if format >= 14 and format <= 22:
|
||||
|
@ -14,9 +14,8 @@
|
||||
|
||||
#include "Floating.h"
|
||||
|
||||
#include "support/docstring.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Messages.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -31,35 +30,16 @@ Floating::Floating()
|
||||
Floating::Floating(string const & type, string const & placement,
|
||||
string const & ext, string const & within,
|
||||
string const & style, string const & name,
|
||||
string const & listName, string const & htmlTag,
|
||||
string const & htmlAttrib, string const & htmlStyle,
|
||||
bool needsfloat)
|
||||
string const & listName, std::string const & listCmd,
|
||||
string const & htmlTag, string const & htmlAttrib,
|
||||
string const & htmlStyle, bool needsfloat)
|
||||
: floattype_(type), placement_(placement), ext_(ext), within_(within),
|
||||
style_(style), name_(name), listname_(listName), needsfloatpkg_(needsfloat),
|
||||
html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle)
|
||||
style_(style), name_(name), listname_(listName), listcommand_(listCmd),
|
||||
needsfloatpkg_(needsfloat), html_tag_(htmlTag), html_attrib_(htmlAttrib),
|
||||
html_style_(htmlStyle)
|
||||
{}
|
||||
|
||||
|
||||
docstring const & Floating::listCommand(string const & lang) const
|
||||
{
|
||||
if (listcommand_.empty()) {
|
||||
if (needsFloatPkg())
|
||||
listcommand_ = from_ascii("\\listof{" + floattype_ + "}{")
|
||||
+ getMessages(lang).get(listName()) + "}";
|
||||
else {
|
||||
if (floattype_ == "table")
|
||||
listcommand_ = from_ascii("\\listoftables");
|
||||
else if (floattype_ == "figure")
|
||||
listcommand_ = from_ascii("\\listoffigures");
|
||||
else
|
||||
// FIXME We really need a special tag for this.
|
||||
listcommand_ = from_ascii("\\listof" + floattype_ + "s");
|
||||
}
|
||||
}
|
||||
return listcommand_;
|
||||
}
|
||||
|
||||
|
||||
string const & Floating::htmlAttrib() const
|
||||
{
|
||||
if (html_attrib_.empty())
|
||||
|
@ -12,8 +12,6 @@
|
||||
#ifndef FLOATING_H
|
||||
#define FLOATING_H
|
||||
|
||||
#include "support/strfwd.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@ -33,9 +31,9 @@ public:
|
||||
Floating(std::string const & type, std::string const & placement,
|
||||
std::string const & ext, std::string const & within,
|
||||
std::string const & style, std::string const & name,
|
||||
std::string const & listName, std::string const & htmlType,
|
||||
std::string const & htmlClass, std::string const & htmlStyle,
|
||||
bool builtin = false);
|
||||
std::string const & listName, std::string const & listCmd,
|
||||
std::string const & htmlType, std::string const & htmlClass,
|
||||
std::string const & htmlStyle, bool builtin = false);
|
||||
///
|
||||
std::string const & floattype() const { return floattype_; }
|
||||
///
|
||||
@ -50,11 +48,10 @@ public:
|
||||
std::string const & name() const { return name_; }
|
||||
/// the title of a list of this kind of float
|
||||
std::string const & listName() const { return listname_; }
|
||||
/// the command used to generate that list, in LaTeX
|
||||
/// if needsFloatPkg() is true, then this is
|
||||
/// \listof{floattype()}
|
||||
/// otherwise it is hardcoded, at present.
|
||||
docstring const & listCommand(std::string const & lang) const;
|
||||
/// the command used to generate that list. this has to be given
|
||||
/// if needsFloatPkg() is false. note that this should not contain
|
||||
/// the leading "\".
|
||||
std::string const & listCommand() const { return listcommand_; }
|
||||
///
|
||||
bool needsFloatPkg() const { return needsfloatpkg_; }
|
||||
/// style information, for preamble
|
||||
@ -81,7 +78,7 @@ private:
|
||||
///
|
||||
std::string listname_;
|
||||
///
|
||||
mutable docstring listcommand_;
|
||||
std::string listcommand_;
|
||||
///
|
||||
bool needsfloatpkg_;
|
||||
///
|
||||
|
@ -860,6 +860,7 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
FT_HTMLSTYLE,
|
||||
FT_HTMLATTR,
|
||||
FT_HTMLTAG,
|
||||
FT_LISTCOMMAND,
|
||||
FT_END
|
||||
};
|
||||
|
||||
@ -870,6 +871,7 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
{ "htmlattr", FT_HTMLATTR },
|
||||
{ "htmlstyle", FT_HTMLSTYLE },
|
||||
{ "htmltag", FT_HTMLTAG },
|
||||
{ "listcommand", FT_LISTCOMMAND },
|
||||
{ "listname", FT_LISTNAME },
|
||||
{ "needsfloatpkg", FT_NEEDSFLOAT },
|
||||
{ "numberwithin", FT_WITHIN },
|
||||
@ -885,6 +887,7 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
string htmlstyle;
|
||||
string htmltag;
|
||||
string listName;
|
||||
string listCommand;
|
||||
string name;
|
||||
string placement;
|
||||
string style;
|
||||
@ -914,6 +917,7 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
name = fl.name();
|
||||
listName = fl.listName();
|
||||
needsfloat = fl.needsFloatPkg();
|
||||
listCommand = fl.listCommand();
|
||||
}
|
||||
break;
|
||||
case FT_NAME:
|
||||
@ -938,6 +942,10 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
lexrc.next();
|
||||
style = lexrc.getString();
|
||||
break;
|
||||
case FT_LISTCOMMAND:
|
||||
lexrc.next();
|
||||
listCommand = lexrc.getString();
|
||||
break;
|
||||
case FT_LISTNAME:
|
||||
lexrc.next();
|
||||
listName = lexrc.getString();
|
||||
@ -964,10 +972,15 @@ void TextClass::readFloat(Lexer & lexrc)
|
||||
}
|
||||
}
|
||||
|
||||
// Here if have a full float if getout == true
|
||||
// Here we have a full float if getout == true
|
||||
if (getout) {
|
||||
if (!needsfloat && listCommand.empty())
|
||||
LYXERR0("The layout does not provide a list command " <<
|
||||
"for the builtin float `" << type << "'. LyX will " <<
|
||||
"not be able to produce a float list.");
|
||||
Floating fl(type, placement, ext, within, style, name,
|
||||
listName, htmltag, htmlattr, htmlstyle, needsfloat);
|
||||
listName, listCommand, htmltag, htmlattr, htmlstyle,
|
||||
needsfloat);
|
||||
floatlist_.newFloat(fl);
|
||||
// each float has its own counter
|
||||
counters_.newCounter(from_ascii(type), from_ascii(within),
|
||||
|
@ -120,7 +120,12 @@ int InsetFloatList::latex(odocstream & os, OutputParams const &) const
|
||||
FloatList::const_iterator cit = floats[to_ascii(getParam("type"))];
|
||||
|
||||
if (cit != floats.end()) {
|
||||
os << cit->second.listCommand(buffer().params().language->code());
|
||||
Floating const & fl = cit->second;
|
||||
if (fl.needsFloatPkg())
|
||||
os << "\\listof{" << getParam("type") << "}{"
|
||||
<< buffer().B_(fl.listName()) << "}\n";
|
||||
else
|
||||
os << "\\" << from_ascii(fl.listCommand()) << "\n";
|
||||
} else {
|
||||
os << "%%\\listof{" << getParam("type") << "}{"
|
||||
<< bformat(_("List of %1$s"), getParam("type"))
|
||||
|
Loading…
Reference in New Issue
Block a user