]> git.lyx.org Git - features.git/commitdiff
* src/insets/insetcaption.*: fix plaintext(); add private computeFullLabel() to
authorMichael Schmitt <michael.schmitt@teststep.org>
Fri, 16 Feb 2007 09:53:51 +0000 (09:53 +0000)
committerMichael Schmitt <michael.schmitt@teststep.org>
Fri, 16 Feb 2007 09:53:51 +0000 (09:53 +0000)
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
src/insets/insetcaption.h

index cb617de8a11617fe5c3a3713aa6660d3aaae1112..2a4fea822cfed6487bae4b6a13cf9c856ed8d46b 100644 (file)
@@ -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<docstring>(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 << "<title>";
@@ -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));
index dc87c293243de19e99835669aaa25b6742c8bb8f..8ea09c548d4e074d65aa2d28489db0b22fb8a374 100644 (file)
@@ -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;
        ///