From bcb5133e54620f554fcd2f097c70dae54bf04b64 Mon Sep 17 00:00:00 2001 From: Michael Schmitt Date: Fri, 16 Feb 2007 09:53:51 +0000 Subject: [PATCH] * src/insets/insetcaption.*: fix plaintext(); add private computeFullLabel() to refactor code used at two places git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17219 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/insetcaption.C | 37 +++++++++++++++++++++++++------------ src/insets/insetcaption.h | 10 ++++++---- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index cb617de8a1..2a4fea822c 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -125,13 +125,9 @@ bool InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const { int const width_offset = TEXT_TO_INSET_OFFSET / 2; mi.base.textwidth -= width_offset; - if (type_.empty()) - full_label_ = _("Senseless!!! "); - else { - docstring const number = convert(counter_); - docstring label = custom_label_.empty()? _(type_): custom_label_; - full_label_ = bformat(from_ascii("%1$s %2$s:"), label, number); - } + + computeFullLabel(); + labelwidth_ = theFontMetrics(mi.base.font).width(full_label_); // add some space to separate the label from the inset text labelwidth_ += 2 * TEXT_TO_INSET_OFFSET; @@ -229,7 +225,7 @@ bool InsetCaption::getStatus(LCursor & cur, FuncRequest const & cmd, int InsetCaption::latex(Buffer const & buf, odocstream & os, - OutputParams const & runparams_in) const + OutputParams const & runparams_in) const { // This is a bit too simplistic to take advantage of // caption options we must add more later. (Lgb) @@ -250,15 +246,20 @@ int InsetCaption::latex(Buffer const & buf, odocstream & os, int InsetCaption::plaintext(Buffer const & buf, odocstream & os, - OutputParams const & runparams) const + OutputParams const & runparams) const { - os << full_label_ << ' '; - return InsetText::plaintext(buf, os, runparams); + computeFullLabel(); + + os << '[' << full_label_ << "\n"; + InsetText::plaintext(buf, os, runparams); + os << "\n]"; + + return 1 + runparams.linelen; // one char on a separate line } int InsetCaption::docbook(Buffer const & buf, odocstream & os, - OutputParams const & runparams) const + OutputParams const & runparams) const { int ret; os << ""; @@ -268,6 +269,18 @@ int InsetCaption::docbook(Buffer const & buf, odocstream & os, } +void InsetCaption::computeFullLabel() const +{ + if (type_.empty()) + full_label_ = _("Senseless!!! "); + else { + docstring const number = convert<docstring>(counter_); + docstring label = custom_label_.empty()? _(type_): custom_label_; + full_label_ = bformat(from_ascii("%1$s %2$s:"), label, number); + } +} + + auto_ptr<InsetBase> InsetCaption::doClone() const { return auto_ptr<InsetBase>(new InsetCaption(*this)); diff --git a/src/insets/insetcaption.h b/src/insets/insetcaption.h index dc87c29324..8ea09c548d 100644 --- a/src/insets/insetcaption.h +++ b/src/insets/insetcaption.h @@ -60,14 +60,14 @@ public: /// virtual bool wide() const { return false; } /// - virtual int latex(Buffer const & buf, odocstream & os, - OutputParams const &) const; + int latex(Buffer const & buf, odocstream & os, + OutputParams const &) const; /// int plaintext(Buffer const & buf, odocstream & os, - OutputParams const & runparams) const; + OutputParams const & runparams) const; /// int docbook(Buffer const & buf, odocstream & os, - OutputParams const & runparams) const; + OutputParams const & runparams) const; /// void setCount(int c) { counter_ = c; } /// @@ -78,6 +78,8 @@ public: void addToToc(TocList &, Buffer const &) const; private: + /// + void computeFullLabel() const; /// virtual std::auto_ptr<InsetBase> doClone() const; /// -- 2.39.5