if (pars.empty())
return;
- // FIXME UNICODE
+ string const & type = fl.type();
docstring const counter = from_ascii(fl.type());
+ // FIXME UNICODE
docstring const label = from_utf8(fl.name());
ParagraphList::iterator p = pars.begin();
// We found a caption!
counters.step(counter);
int number = counters.value(counter);
- static_cast<InsetCaption &>(icap).setCount(number);
- static_cast<InsetCaption &>(icap).setLabel(label);
+ InsetCaption & ic = static_cast<InsetCaption &>(icap);
+ ic.setType(type);
+ ic.setCount(number);
+ ic.setCustomLabel(label);
}
}
}
#include "metricsinfo.h"
#include "output_latex.h"
#include "paragraph.h"
+#include "TocBackend.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include <sstream>
-namespace lyx {
-
-using support::bformat;
-
using std::auto_ptr;
using std::endl;
using std::string;
using std::ostream;
+namespace lyx {
+
+using support::bformat;
+
InsetCaption::InsetCaption(BufferParams const & bp)
- : InsetText(bp), textclass_(bp.getLyXTextClass()), counter_(-1)
+ : InsetText(bp), textclass_(bp.getLyXTextClass())
{
setAutoBreakRows(true);
setDrawFrame(true);
}
-void InsetCaption::setLabel(docstring const & label)
+void InsetCaption::setCustomLabel(docstring const & label)
{
- label_ = _(to_ascii(label));
+ if (!support::isAscii(label) || label.empty())
+ // This must be a user defined layout. We cannot translate
+ // this, since gettext accepts only ascii keys.
+ custom_label_ = label;
+ else
+ custom_label_ = _(to_ascii(label));
+}
+
+
+void InsetCaption::addToToc(TocList & toclist, Buffer const & buf) const
+{
+ if (type_.empty())
+ return;
+
+ ParConstIterator pit = par_const_iterator_begin(*this);
+
+ Toc & toc = toclist[type_];
+ docstring const str = convert<docstring>(counter_)
+ + ". " + pit->asString(buf, false);
+ toc.push_back(TocItem(pit, 0, str));
}
bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
{
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
- if (counter_ < 0)
+ if (type_.empty())
full_label_ = _("Senseless!!! ");
else {
docstring const number = convert<docstring>(counter_);
- full_label_ = bformat(from_ascii("%1$s %2$s:"), label_, number);
+ docstring label = custom_label_.empty()? _(type_): custom_label_;
+ full_label_ = bformat(from_ascii("%1$s %2$s:"), label, number);
}
labelwidth_ = theFontMetrics(mi.base.font).width(full_label_);
dim.wid = labelwidth_;
///
void setCount(int c) { counter_ = c; }
///
- void setLabel(docstring const & label);
+ void setType(std::string const & type) { type_ = type; }
+ ///
+ void setCustomLabel(docstring const & label);
+ ///
+ void addToToc(TocList &, Buffer const &) const;
private:
///
///
mutable int labelwidth_;
///
- docstring label_;
+ std::string type_;
+ ///
+ docstring custom_label_;
///
int counter_;
///
void InsetFloat::addToToc(TocList & toclist, Buffer const & buf) const
{
+ // Is there a need to provide a list of float insets?
+ return;
+
+ // Abdel (01/02/2006): I'll let this code for reference in case
+ // there's a need to do something similar for another kind of
+ // inset.
ParConstIterator pit = par_const_iterator_begin(*this);
ParConstIterator end = par_const_iterator_end(*this);
void InsetWrap::addToToc(TocList & toclist, Buffer const & buf) const
{
- ParConstIterator pit = par_const_iterator_begin(*this);
- ParConstIterator end = par_const_iterator_end(*this);
-
- // Find a caption layout in one of the (child inset's) pars
- for (; pit != end; ++pit) {
- if (pit->layout()->labeltype == LABEL_SENSITIVE) {
- Toc & toc = toclist[params_.type];
- docstring const str =
- convert<docstring>(toc.size() + 1)
- + ". " + pit->asString(buf, false);
- toc.push_back(TocItem(pit, 0, str));
- }
- }
+ // Is there a need to provide a list of wrap insets?
+ return;
}