]> git.lyx.org Git - features.git/commitdiff
* src/output_plaintext.C: check line length before outputting
authorMichael Schmitt <michael.schmitt@teststep.org>
Thu, 15 Feb 2007 16:07:36 +0000 (16:07 +0000)
committerMichael Schmitt <michael.schmitt@teststep.org>
Thu, 15 Feb 2007 16:07:36 +0000 (16:07 +0000)
a word in front of an inset; make sensible use of plaintext()
return value (IMHO totally broken before)
* insets/insetfoot.[Ch]: add plaintext()
* insets/insethfill.[Ch]: adjust plaintext(); make the
number of characters determinitic; minor header cleanup
* insets/insetbase.h: add comment on return value
of plaintext() - before its meaning was unclear

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17200 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/insetbase.h
src/insets/insetfoot.C
src/insets/insetfoot.h
src/insets/insethfill.C
src/insets/insethfill.h
src/output_plaintext.C

index 7794811ad8d046c17aef5695107e64508e570527..c05df372d92fbe1f901a8578dc25d0bc2791bf8e 100644 (file)
@@ -201,6 +201,8 @@ public:
        virtual void infoize2(odocstream &) const {}
 
        /// plain text output in ucs4 encoding
+       /// return the number of characters, in case of multiple lines of
+       /// output, add runparams.linelen to the number of chars in the last line
        virtual int plaintext(Buffer const &, odocstream &,
                OutputParams const &) const;
        /// docbook output
index b9be27578b7835d9ee2798557114dcf6c0365da1..2a1536973b3d1dcf8e2362c6712a989d943df90f 100644 (file)
@@ -80,6 +80,17 @@ int InsetFoot::latex(Buffer const & buf, odocstream & os,
 }
 
 
+int InsetFoot::plaintext(Buffer const & buf, odocstream & os,
+                          OutputParams const & runparams) const
+{
+       os << '[' << _("footnote") << ":\n";
+       InsetText::plaintext(buf, os, runparams);
+       os << "\n]";
+
+       return 1 + runparams.linelen; // one char on a separate line
+}
+
+
 int InsetFoot::docbook(Buffer const & buf, odocstream & os,
                       OutputParams const & runparams) const
 {
index 46caafc48683b3f8e3883e42f7ecf7cf2f33f61d..6918b2830cea678d6ba4fe4a5c9c47eac8cf75cf 100644 (file)
@@ -31,8 +31,11 @@ public:
        int latex(Buffer const &, odocstream &,
                  OutputParams const &) const;
        ///
+       int plaintext(Buffer const &, odocstream &,
+                     OutputParams const &) const;
+       ///
        int docbook(Buffer const &, odocstream &,
-                   OutputParams const & runparams) const;
+                   OutputParams const &) const;
        ///
        virtual docstring const editMessage() const;
 protected:
index 1f20b3deab603dd7bf1b3ff6a7ece1eb3e2135ba..defc3c011bdb2a1026fe4be825bbc8bbc11bb725 100644 (file)
@@ -50,10 +50,10 @@ docstring const InsetHFill::getScreenLabel(Buffer const &) const
 
 
 int InsetHFill::plaintext(Buffer const &, odocstream & os,
-                     OutputParams const &) const
+                          OutputParams const &) const
 {
-       os << '\t';
-       return 0;
+       os << "     ";
+       return 5; 
 }
 
 
index 51f5b59fa1ddc4103eceb1d7f2ea2f0258000c79..04e46e2d6572e92d4a8ed741af702c39eae7ebba 100644 (file)
@@ -30,10 +30,10 @@ public:
        InsetBase::Code lyxCode() const { return InsetBase::HFILL_CODE; }
        ///
        int plaintext(Buffer const &, odocstream &,
-                 OutputParams const & runparams) const;
+                     OutputParams const &) const;
        ///
        int docbook(Buffer const &, odocstream &,
-                   OutputParams const & runparams) const;
+                   OutputParams const &) const;
        ///
        void write(Buffer const & buf, std::ostream & os) const;
        /// We don't need \begin_inset and \end_inset
index ae70ac44d14fae4d71e5ec022be9c72b044c6ad0..809db27eb0435a5973fbfe7847d89140c30d2ba5 100644 (file)
@@ -198,18 +198,24 @@ void writePlaintextParagraph(Buffer const & buf,
                char_type c = par.getUChar(buf.params(), i);
                switch (c) {
                case Paragraph::META_INSET: {
-                       InsetBase const * inset = par.getInset(i);
-
+                       if (runparams.linelen > 0 &&
+                           currlinelen + word.length() > runparams.linelen) {
+                               os << '\n';
+                               pair<int, docstring> p = addDepth(depth, ltype_depth);
+                               os << p.second;
+                               currlinelen = p.first;
+                       }
                        os << word;
                        currlinelen += word.length();
                        word.erase();
 
                        OutputParams rp = runparams;
                        rp.depth = par.params().depth();
-                       if (inset->plaintext(buf, os, rp)) {
-                               // to be sure it breaks paragraph
-                               currlinelen += runparams.linelen;
-                       }
+                       int len = par.getInset(i)->plaintext(buf, os, rp);
+                       if (len >= runparams.linelen)
+                               currlinelen = len - runparams.linelen;
+                       else
+                               currlinelen += len;
                        break;
                }