On 05/03/2010 22:06, [email protected] wrote:
Author: rgheck
Date: Fri Mar 5 22:06:22 2010
New Revision: 33631
URL: http://www.lyx.org/trac/changeset/33631
Log:
Let floats decide for themselves what command is used to create a list
of them. This is preparatory for introducing a layout tag that lets us
customize that command for builtin floats.
Modified:
lyx-devel/trunk/src/Floating.cpp
lyx-devel/trunk/src/Floating.h
lyx-devel/trunk/src/insets/InsetFloatList.cpp
Modified: lyx-devel/trunk/src/Floating.cpp
==============================================================================
--- lyx-devel/trunk/src/Floating.cpp Fri Mar 5 21:47:50 2010 (r33630)
+++ lyx-devel/trunk/src/Floating.cpp Fri Mar 5 22:06:22 2010 (r33631)
@@ -14,7 +14,9 @@
#include "Floating.h"
+#include "support/docstring.h"
#include "support/lstrings.h"
+#include "support/Messages.h"
using namespace std;
@@ -38,6 +40,26 @@
{}
+docstring const& Floating::listCommand(string const& lang) const
+{
+ if (listcommand_.empty()) {
if (!listcommand_.empty())
return listcommand_;
+ 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())
Modified: lyx-devel/trunk/src/Floating.h
==============================================================================
--- lyx-devel/trunk/src/Floating.h Fri Mar 5 21:47:50 2010 (r33630)
+++ lyx-devel/trunk/src/Floating.h Fri Mar 5 22:06:22 2010 (r33631)
@@ -12,11 +12,13 @@
#ifndef FLOATING_H
#define FLOATING_H
+#include "support/strfwd.h"
+
#include<string>
namespace lyx {
-
+
/** This is a "float layout" object. It contains the parameters for how to
* handle the different kinds of floats, default ones and user created ones.
* Objects of this class is stored in a container in FloatList. The different
@@ -46,8 +48,13 @@
std::string const& style() const { return style_; }
///
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;
///
bool needsFloatPkg() const { return needsfloatpkg_; }
/// style information, for preamble
@@ -74,6 +81,8 @@
///
std::string listname_;
///
+ mutable docstring listcommand_;
+ ///
bool needsfloatpkg_;
///
mutable std::string html_tag_;
Modified: lyx-devel/trunk/src/insets/InsetFloatList.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetFloatList.cpp Fri Mar 5 21:47:50
2010 (r33630)
+++ lyx-devel/trunk/src/insets/InsetFloatList.cpp Fri Mar 5 22:06:22
2010 (r33631)
@@ -18,6 +18,7 @@
#include "Floating.h"
#include "FloatList.h"
#include "FuncRequest.h"
+#include "Language.h"
#include "LaTeXFeatures.h"
#include "Lexer.h"
#include "MetricsInfo.h"
@@ -119,23 +120,10 @@
FloatList::const_iterator cit = floats[to_ascii(getParam("type"))];
if (cit != floats.end()) {
- if (!cit->second.needsFloatPkg()) {
- // Only two different types allowed here:
- string const type = cit->second.floattype();
- if (type == "table") {
- os<< "\\listoftables\n";
- } else if (type == "figure") {
- os<< "\\listoffigures\n";
- } else {
- os<< "%% unknown builtin float\n";
- }
- } else {
- os<< "\\listof{"<< getParam("type")<< "}{"
- << buffer().B_(cit->second.listName())<< "}\n";
- }
+ os<<
cit->second.listCommand(buffer().params().language->code());
} else {
os<< "%%\\listof{"<< getParam("type")<< "}{"
- << bformat(_("List of %1$s"), from_utf8(cit->second.name()))
+ << bformat(_("List of %1$s"), getParam("type"))
<< "}\n";
}
return 1;