]> git.lyx.org Git - features.git/commitdiff
Added linelen to insets-ascii-function, some fixes and new support
authorJürgen Vigna <jug@sad.it>
Tue, 26 Sep 2000 15:25:14 +0000 (15:25 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 26 Sep 2000 15:25:14 +0000 (15:25 +0000)
functions.

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

32 files changed:
ChangeLog
lib/bind/menus.bind
src/buffer.C
src/buffer.h
src/bufferlist.C
src/insets/figinset.C
src/insets/figinset.h
src/insets/insetcollapsable.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/inseterror.h
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinfo.C
src/insets/insetinfo.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulamacro.C
src/tabular.C

index faf0a38f2f4cadffb4dd9e8530bb87595cbbc955..7377cb66f79d212dfd76965c0e9a9b092e022d42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2000-09-26  Juergen Vigna  <jug@sad.it>
+
+       * src/buffer.C (asciiParagraph): new function.
+       (writeFileAscii): new function with parameter ostream.
+       (writeFileAscii): use now asciiParagraph.
+
+       * various inset files: added the linelen parameter to the Ascii-func.
+       
+       * src/tabular.C (Write): fixed error in writing file introduced by
+       the last changes from Lars.
+
+       * lib/bind/menus.bind: removed not supported functions.
+
+       * src/insets/insettext.C (Ascii): implemented this function.
+
+       * src/insets/lyxinset.h (Ascii): added linelen parameter.
+
+       * src/tabular.C (write_attribute[int,string,bool]): new functions.
+       (Write): use of the write_attribute functions.
+
+       * src/bufferlist.C (close): fixed reasking question!
+
 2000-09-26  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/support/unlink.C src/support/remove.C src/support/mkdir.C:
index 07d7a1c390866c958ec0e2e7cd02e8f40ae9dc25..dec163a9ee781e48f6a61b9057eef4af998c9fc5 100644 (file)
@@ -96,9 +96,6 @@
 \bind "M-l c"                  "layout-character"
 \bind "M-l p"                  "layout-paragraph"
 \bind "M-l d"                  "layout-document"
-\bind "M-l a"                  "layout-paper"
-\bind "M-l e"                  "layout-table"
-\bind "M-l q"                  "layout-quotes" 
 \bind "M-l m"                  "font-emph" 
 \bind "M-l n"                  "font-noun" 
 \bind "M-l b"                  "font-bold" 
 \bind "M-l l"                  "layout-preamble"
 \bind "M-l s"                  "layout-save-default"
 \bind "M-l space"              "menu-open Layout"  
-\bind "M-l i"                  "buffer-itemize-bullets-select"
 \bind "M-l x"                  "appendix"
 
 #
index 7f3372b60b20a376f900f8c7d2e72992335db186..6d8b78a8463e9736ac413e3436891c7453d91ca8 100644 (file)
@@ -92,6 +92,7 @@
 #include "frontends/Dialogs.h"
 #include "encoding.h"
 #include "exporter.h"
+#include "Lsstream.h"
 
 using std::ostream;
 using std::ofstream;
@@ -1288,6 +1289,7 @@ bool Buffer::writeFile(string const & fname, bool flag) const
 }
 
 
+#if 0
 void Buffer::writeFileAscii(string const & fname, int linelen) 
 {
        Inset * inset;
@@ -1503,7 +1505,243 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
    
        ofs << "\n";
 }
+//----------------------------------------------------------------------------
+#else
+//----------------------------------------------------------------------------
+string const Buffer::asciiParagraph(LyXParagraph const * par, int linelen) const
+{
+       ostringstream buffer;
+       LyXFont font1, font2;
+       Inset const * inset;
+       char c, footnoteflag = 0, depth = 0;
+       string tmp;
+       LyXParagraph::size_type i;
+       int j;
+       int ltype = 0;
+       int ltype_depth = 0;
+       int actcell = 0;
+       int currlinelen = 0;
+       bool ref_printed = false;
 
+       string fname1 = TmpFileName();
+
+       int noparbreak = 0;
+       int islatex = 0;
+       if (
+#ifndef NEW_INSETS
+               par->footnoteflag != LyXParagraph::NO_FOOTNOTE ||
+#endif
+               !par->previous
+#ifndef NEW_INSETS
+               || par->previous->footnoteflag == LyXParagraph::NO_FOOTNOTE
+#endif
+               ){
+#ifndef NEW_INSETS
+               /* begins a footnote environment ? */ 
+               if (footnoteflag != par->footnoteflag) {
+                       footnoteflag = par->footnoteflag;
+                       if (footnoteflag) {
+                               j = strlen(string_footnotekinds[par->footnotekind])+4;
+                               if ((linelen > 0) &&
+                                   ((currlinelen + j) > linelen)) {
+                                       buffer << "\n";
+                                       currlinelen = 0;
+                               }
+                               buffer <<
+                                   "([" <<
+                                   string_footnotekinds[par->footnotekind] <<
+                                   "] ";
+                               currlinelen += j;
+                       }
+               }
+#endif
+               /* begins or ends a deeper area ?*/ 
+               if (depth != par->depth) {
+                       if (par->depth > depth) {
+                               while (par->depth > depth) {
+                                       ++depth;
+                               }
+                       }
+                       else {
+                               while (par->depth < depth) {
+                                       --depth;
+                               }
+                       }
+               }
+               
+               /* First write the layout */
+               tmp = textclasslist.NameOfLayout(params.textclass, par->layout);
+               if (tmp == "Itemize") {
+                       ltype = 1;
+                       ltype_depth = depth+1;
+               } else if (tmp == "Enumerate") {
+                       ltype = 2;
+                       ltype_depth = depth+1;
+               } else if (strstr(tmp.c_str(), "ection")) {
+                       ltype = 3;
+                       ltype_depth = depth+1;
+               } else if (strstr(tmp.c_str(), "aragraph")) {
+                       ltype = 4;
+                       ltype_depth = depth+1;
+               } else if (tmp == "Description") {
+                       ltype = 5;
+                       ltype_depth = depth+1;
+               } else if (tmp == "Abstract") {
+                       ltype = 6;
+                       ltype_depth = 0;
+               } else if (tmp == "Bibliography") {
+                       ltype = 7;
+                       ltype_depth = 0;
+               } else {
+                       ltype = 0;
+                       ltype_depth = 0;
+               }
+               
+               /* maybe some vertical spaces */ 
+               
+               /* the labelwidthstring used in lists */ 
+               
+               /* some lines? */ 
+               
+               /* some pagebreaks? */ 
+               
+               /* noindent ? */ 
+               
+               /* what about the alignment */ 
+       } else {
+#ifndef NEW_INSETS
+               /* dummy layout, that means a footnote ended */ 
+               footnoteflag = LyXParagraph::NO_FOOTNOTE;
+               buffer << ") ";
+               noparbreak = 1;
+#else
+               lyxerr << "Should this ever happen?" << endl;
+#endif
+       }
+      
+       font1 = LyXFont(LyXFont::ALL_INHERIT, params.language_info);
+       actcell = 0;
+       for (i = 0; i < par->size(); ++i) {
+               if (!i && !footnoteflag && !noparbreak){
+                       buffer << "\n\n";
+                       for(j = 0; j < depth; ++j)
+                               buffer << "  ";
+                       currlinelen = depth * 2;
+                       switch(ltype) {
+                       case 0: /* Standard */
+                       case 4: /* (Sub)Paragraph */
+                       case 5: /* Description */
+                               break;
+                       case 6: /* Abstract */
+                               buffer << "Abstract\n\n";
+                               break;
+                       case 7: /* Bibliography */
+                               if (!ref_printed) {
+                                       buffer << "References\n\n";
+                                       ref_printed = true;
+                               }
+                               break;
+                       default:
+                               buffer << par->labelstring << " ";
+                               break;
+                       }
+                       if (ltype_depth > depth) {
+                               for(j = ltype_depth - 1; j > depth; --j)
+                                       buffer << "  ";
+                               currlinelen += (ltype_depth-depth)*2;
+                       }
+               }
+               font2 = par->GetFontSettings(params, i);
+               if (font1.latex() != font2.latex()) {
+                       if (font2.latex() == LyXFont::OFF)
+                               islatex = 0;
+                       else
+                               islatex = 1;
+               } else {
+                       islatex = 0;
+               }
+               c = par->GetChar(i);
+               if (islatex)
+                       continue;
+               switch (c) {
+               case LyXParagraph::META_INSET:
+                       if ((inset = par->GetInset(i))) {
+                               if (!inset->Ascii(this, buffer)) {
+                                       string dummy;
+                                       string s = rsplit(buffer.str(),
+                                                         dummy, '\n');
+                                       currlinelen += s.length();
+                               } else {
+                                       // to be sure it breaks paragraph
+                                       currlinelen += linelen;
+                               }
+                       }
+                       break;
+               case LyXParagraph::META_NEWLINE:
+                       buffer << "\n";
+                       for(j = 0; j < depth; ++j)
+                               buffer << "  ";
+                       currlinelen = depth * 2;
+                       if (ltype_depth > depth) {
+                               for(j = ltype_depth;
+                                   j > depth; --j)
+                                       buffer << "  ";
+                               currlinelen += (ltype_depth - depth) * 2;
+                       }
+                       break;
+               case LyXParagraph::META_HFILL: 
+                       buffer << "\t";
+                       break;
+               case '\\':
+                       buffer << "\\";
+                       break;
+               default:
+                       if ((linelen > 0) && (currlinelen > (linelen - 10)) &&
+                           (c == ' ') && ((i + 2) < par->size()))
+                       {
+                               buffer << "\n";
+                               for(j = 0; j < depth; ++j)
+                                       buffer << "  ";
+                               currlinelen = depth * 2;
+                               if (ltype_depth > depth) {
+                                       for(j = ltype_depth;
+                                           j > depth; --j)
+                                               buffer << "  ";
+                                       currlinelen += (ltype_depth-depth)*2;
+                               }
+                       } else if (c != '\0')
+                               buffer << c;
+                       else if (c == '\0')
+                               lyxerr.debug() << "writeAsciiFile: NULL char in structure." << endl;
+                       ++currlinelen;
+                       break;
+               }
+       }
+       return buffer.str();
+}
+
+
+void Buffer::writeFileAscii(string const & fname, int linelen) 
+{
+       ofstream ofs(fname.c_str());
+       if (!ofs) {
+               WriteFSAlert(_("Error: Cannot write file:"), fname);
+               return;
+       }
+       writeFileAscii(ofs, linelen);
+}
+
+
+void Buffer::writeFileAscii(ostream & ofs, int linelen) 
+{
+       LyXParagraph * par = paragraph;
+       while (par) {
+               ofs << asciiParagraph(par, linelen);
+               par = par->next;
+       }
+       ofs << "\n";
+}
+#endif
 
 void Buffer::makeLaTeXFile(string const & fname, 
                           string const & original_path,
index 39e5a51dfc8acae90bc3e7a868a6e838946cd201..53df1feade9359992004e5af90d50d4f32d10a0d 100644 (file)
@@ -150,7 +150,8 @@ public:
        
        ///
        void writeFileAscii(string const & , int);
-       
+       void writeFileAscii(std::ostream &, int);
+       string const asciiParagraph(LyXParagraph const *, int linelen) const;
        ///
        void makeLaTeXFile(string const & filename,
                           string const & original_path,
index 0d4d6602504cc36a5891c3bfd65c196bcf4be86f..677e92a3f0782fde98fed3f76c03896eed0fc1f8 100644 (file)
@@ -192,6 +192,7 @@ bool BufferList::close(Buffer * buf)
                                        reask = !MenuWriteAs(buf);
                                else if (buf->save()) {
                                        lastfiles->newFile(buf->fileName());
+                                       reask = false;
                                } else {
                                        if (buf->getUser())
                                                AllowInput(buf->getUser());
index 35b4a6a63a8d6e4d6f1324ce33383f4b9cd89e91..4b71d58a55f0844f92644207d103ffcd2b91aba3 100644 (file)
@@ -1155,7 +1155,7 @@ int InsetFig::Latex(Buffer const *, ostream & os,
 }
 
 
-int InsetFig::Ascii(Buffer const *, ostream &) const
+int InsetFig::Ascii(Buffer const *, ostream &, int) const
 {
        return 0;
 }
index 8c0799cca051404425a859733d69b0baa6a8e8ca..58afd4ebe67f9ec9d9b1fd90b8d899b1fd4c1abf 100644 (file)
@@ -38,7 +38,7 @@ public:
        ///
        int Latex(Buffer const *, std::ostream &, bool fragile, bool free_space) const;
        ///
-       int Ascii(Buffer const *, std::ostream &) const;
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index e01b0cbc198f41594e4caf5585bf20c7d0100439..52b317f5ca940845ec2fab9785ccbf55e0cf5229 100644 (file)
@@ -94,7 +94,7 @@ public:
     int Latex(Buffer const *, std::ostream &,
              bool fragile, bool free_spc) const;
     ///
-    int Ascii(Buffer const *, std::ostream &) const { return 0; }
+    int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
     ///
     int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
     ///
index 0530cc516e5bfa33d92ec795b996bc65fc2b70dc..e7ad117674fbdb1ed5bc8554467e9815f917e547 100644 (file)
@@ -199,7 +199,7 @@ int InsetCommand::Latex(Buffer const *, ostream & os,
 }
 
 
-int InsetCommand::Ascii(Buffer const *, ostream &) const
+int InsetCommand::Ascii(Buffer const *, ostream &, int) const
 {
        return 0;
 }
index 469b65bc53b4716a47b058bfa161823bbbe28d97..857563903206a426993df57eecd680c5b54bc228 100644 (file)
@@ -97,7 +97,7 @@ public:
        virtual int Latex(Buffer const *, std::ostream &,
                          bool fragile, bool free_spc) const;
        ///
-       int Ascii(Buffer const *, std::ostream &) const;
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        virtual int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index 47a67a9bc250b2edb7755a6f911684b319dc3f7c..d2b79d33cb84195919231a91d47dcfa5a152968a 100644 (file)
@@ -51,7 +51,7 @@ public:
        ///
        int Latex(Buffer const *, std::ostream &, bool, bool) const { return 0; }
        ///
-       int Ascii(Buffer const *, std::ostream &) const { return 0; }
+       int Ascii(Buffer const *, std::ostream &, int) const { return 0; }
        ///
        int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
        ///
index 7af977b034df247b43333beeb818605a5c0d8b75..cd42207704983bfafb0da17fd5132d0f9a27dd45 100644 (file)
@@ -356,7 +356,7 @@ int InsetExternal::Latex(Buffer const * buf,
 }
 
 
-int InsetExternal::Ascii(Buffer const * buf, std::ostream & os) const
+int InsetExternal::Ascii(Buffer const * buf, std::ostream & os, int) const
 {
        return write("Ascii", buf, os);
 }
index 2c02c285d1942d47b421a3772fe0bb9490537658..6162638a5e1de07e05acd735b0638530e2f0ffeb 100644 (file)
@@ -47,7 +47,7 @@ public:
        virtual int Latex(Buffer const *, std::ostream &, bool fragile,
                          bool free_spc) const;
        ///
-       virtual int Ascii(Buffer const *, std::ostream &) const;
+       virtual int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        virtual int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index 7449f34f3f60bb3a1d497d8d052ec1e9c6f2fe03..4435b3f4612af50f7b54bfb28f219a382deb833b 100644 (file)
@@ -592,7 +592,7 @@ int InsetGraphics::Latex(Buffer const *buf, ostream & os,
 }
 
 
-int InsetGraphics::Ascii(Buffer const *, ostream &) const
+int InsetGraphics::Ascii(Buffer const *, ostream &, int) const
 {
        // No graphics in ascii output.
        return 0;
index ec1c1bae114f77386bcdadd3a4a6380879711adc..72e9cafef0327515abe5526a7dae361dcdc3c8bc 100644 (file)
@@ -71,7 +71,7 @@ public:
        int Latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
        ///
-       int Ascii(Buffer const *, std::ostream &) const;
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index 55d6cf911193f9d45f20904afffebd8de59a0530..ae77a9b5cea8f457b01b67b759a5bdf6e426e607 100644 (file)
@@ -144,7 +144,7 @@ int InsetInfo::Latex(Buffer const *, ostream &,
 }
 
 
-int InsetInfo::Ascii(Buffer const *, ostream &) const
+int InsetInfo::Ascii(Buffer const *, ostream &, int) const
 {
        return 0;
 }
index 9e9b342e582915cf336878308153eceb85c3ea08..08f1ebc95a2d5daf148baa96c6d60d39544a86fc 100644 (file)
@@ -53,7 +53,7 @@ public:
        int Latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
        ///
-       int Ascii(Buffer const *, std::ostream &) const;
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index dbb81062054078bf8c3cc560541face95d4f9119..a6a5b0a324b4dc29a40e182c98d1fbfc7cd0951c 100644 (file)
@@ -629,7 +629,7 @@ int InsetLatexAccent::Latex(Buffer const *, ostream & os,
 }
 
 
-int InsetLatexAccent::Ascii(Buffer const *, ostream & os) const
+int InsetLatexAccent::Ascii(Buffer const *, ostream & os, int) const
 {
        os << contents;
        return 0;
index c61bfec1c6677456be5bbbd5b3d4235224146847..e583ab57ce1ac7e07947587d9a509fa4d0701e8f 100644 (file)
@@ -57,7 +57,7 @@ public:
        int Latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
        ///
-       int Ascii(Buffer const *, std::ostream &) const;
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index b03780babeb3c91a14be7b618eb3f2a89824a9aa..8444ee0aa9819e67dd4a2e56c209fb3bee75ff89 100644 (file)
@@ -259,7 +259,7 @@ int InsetQuotes::Latex(Buffer const *, ostream & os,
 }
 
 
-int InsetQuotes::Ascii(Buffer const *, ostream & os) const
+int InsetQuotes::Ascii(Buffer const *, ostream & os, int) const
 {
        os << "\"";
        return 0;
index eb4ce51012575e488ad99da1d2138684223c820b..978891bc48d44d85440f3539efa0ef34f3be573d 100644 (file)
@@ -89,7 +89,7 @@ public:
        int Latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
        ///
-       int Ascii(Buffer const *, std::ostream &) const;
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index 48fa451654926ef6f221768d8f3b27fb15a746d5..ca1b9cb4de8937012a370284231114937d11e102 100644 (file)
@@ -196,7 +196,7 @@ int InsetSpecialChar::Latex(Buffer const *, ostream & os, bool /*fragile*/,
        return 0;
 }
 
-int InsetSpecialChar::Ascii(Buffer const *, ostream & os) const
+int InsetSpecialChar::Ascii(Buffer const *, ostream & os, int) const
 {
        switch (kind) {
        case HYPHENATION:                       break;
@@ -211,13 +211,13 @@ int InsetSpecialChar::Ascii(Buffer const *, ostream & os) const
 
 int InsetSpecialChar::Linuxdoc(Buffer const * buf, ostream & os) const
 {
-       return Ascii(buf, os);
+       return Ascii(buf, os, 0);
 }
 
 
 int InsetSpecialChar::DocBook(Buffer const * buf, ostream & os) const
 {
-       return Ascii(buf, os);
+       return Ascii(buf, os, 0);
 }
 
 
index 8a2bbf90e5eca35283041eecc7e0f01313ac8327..928892878be2697a88f8b9f39ab0da6947992c78 100644 (file)
@@ -59,7 +59,7 @@ public:
        int Latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
        ///
-       int Ascii(Buffer const *, std::ostream &) const;
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index 59fb7c7732a4b5e801ca501a1dd1cca867ed80f4..ada68fc0addece9da40e613d29f37b314b42aaa1 100644 (file)
@@ -896,7 +896,7 @@ int InsetTabular::Latex(Buffer const * buf, ostream & os,
 }
 
 
-int InsetTabular::Ascii(Buffer const * buf, ostream & os) const
+int InsetTabular::Ascii(Buffer const * buf, ostream & os, int) const
 {
     // This should be changed to a real ascii export
     return tabular->Latex(buf, os, false, false);
index 64191fa33bc0d7fdb4a22a596ac8d6c2ff2a0f30..df4d05a0c136c10bd0d3af275129fe3d6282e362 100644 (file)
@@ -135,7 +135,7 @@ public:
     ///
     int Latex(Buffer const *, std::ostream &, bool, bool) const;
     ///
-    int Ascii(Buffer const *, std::ostream &) const;
+    int Ascii(Buffer const *, std::ostream &, int linelen) const;
     ///
     int Linuxdoc(Buffer const *, std::ostream &) const;
     ///
index d75373a07667e81b352c060d2c42c6ce46b2aff0..3b224b9b4945b1f7583beac871109e154be621c4 100644 (file)
@@ -108,7 +108,8 @@ void InsetText::init(InsetText const * ins)
 InsetText::~InsetText()
 {
     for(Cache::const_iterator cit=cache.begin(); cit != cache.end(); ++cit)
-       deleteLyXText((*cit).first);
+       delete (*cit).second;
+//     deleteLyXText((*cit).first);
     LyXParagraph * p = par->next;
     delete par;
     while(p) {
@@ -1022,6 +1023,17 @@ int InsetText::Latex(Buffer const * buf, ostream & os, bool, bool) const
 }
 
 
+int InsetText::Ascii(Buffer const * buf, ostream & os, int linelen) const
+{
+    LyXParagraph * p = par;
+    while (p) {
+       os << buf->asciiParagraph(p, linelen);
+       p = p->next;
+    }
+    os << "\n";
+}
+
+
 void InsetText::Validate(LaTeXFeatures & features) const
 {
     LyXParagraph * p = par;
index eb92980d4cedcdf6feb958974aec95e7736bcd86..24c72ca05452cb6d93a7bd887866f02f3521a592 100644 (file)
@@ -126,7 +126,7 @@ public:
     int Latex(Buffer const *, std::ostream &,
              bool fragile, bool free_spc) const;
     ///
-    int Ascii(Buffer const *, std::ostream &) const { return 0; }
+    int Ascii(Buffer const *, std::ostream &, int linelen) const;
     ///
     int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
     ///
index a894d97511c363bcad948bcfe0ad458e49a7ebc4..14831464cbcb552b8648b3b5a224b3474dfce946 100644 (file)
@@ -171,7 +171,7 @@ public:
        virtual int Latex(Buffer const *, std::ostream &, bool fragile,
                          bool free_spc) const = 0;
        ///
-       virtual int Ascii(Buffer const *, std::ostream &) const = 0;
+       virtual int Ascii(Buffer const *, std::ostream &, int linelen=0) const = 0;
        ///
        virtual int Linuxdoc(Buffer const *, std::ostream &) const = 0;
        ///
index e4a457621da4f653a34a0ceba347a3a24085ac46..7cae85ba81a6874900fa74dd4f9575b7f46d4c21 100644 (file)
@@ -331,7 +331,7 @@ int InsetFormula::Latex(Buffer const *, ostream & os, bool fragile, bool) const
 }
 
 
-int InsetFormula::Ascii(Buffer const *, ostream & os) const
+int InsetFormula::Ascii(Buffer const *, ostream & os, int) const
 {
     par->Write(os, false);
     return 0;
@@ -340,13 +340,13 @@ int InsetFormula::Ascii(Buffer const *, ostream & os) const
 
 int InsetFormula::Linuxdoc(Buffer const * buf, ostream & os) const
 {
-    return Ascii(buf, os);
+    return Ascii(buf, os, 0);
 }
 
 
 int InsetFormula::DocBook(Buffer const * buf, ostream & os) const
 {
-    return Ascii(buf, os);
+    return Ascii(buf, os, 0);
 }
 
 
index 926a029f70fa1f54b0110999ab9a3efd10c3c1cc..dbee7144b7791e9e4e82e20a8bb150be4e04418f 100644 (file)
@@ -56,7 +56,7 @@ public:
        int Latex(Buffer const *, std::ostream &,
                  bool fragile, bool free_spc) const;
        ///
-       int Ascii(Buffer const *, std::ostream &) const;
+       int Ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        int Linuxdoc(Buffer const *, std::ostream &) const;
        ///
index 638ef72d1d897f91fd57380c0a555b413ee43116..d74a5b3bfff7da3146e748c8feb8609ef9151da0 100644 (file)
@@ -83,13 +83,13 @@ int InsetFormulaMacro::Latex(Buffer const *, ostream & os, bool /*fragile*/,
 
 int InsetFormulaMacro::Linuxdoc(Buffer const * buf, ostream & os) const
 {
-    return Ascii(buf, os);
+    return Ascii(buf, os, 0);
 }
 
 
 int InsetFormulaMacro::DocBook(Buffer const * buf, ostream & os) const
 {
-    return Ascii(buf, os);
+    return Ascii(buf, os, 0);
 }
 
 
index 275cfb132b58996a1caa08925ac842a7bfcea7a2..2f4abff8016375b2e76c8e832fa428eb280a9e16 100644 (file)
@@ -918,51 +918,81 @@ int LyXTabular::right_column_of_cell(int cell) const
 }
 
 
+const string write_attribute(const string name, const int value)
+{
+    string str = " " + name + "=\"" + tostr(value) + "\"";
+    return str;
+}
+
+
+const string write_attribute(string name, const string & value)
+{
+    string str = " " + name + "=\"" + value + "\"";
+    return str;
+}
+
+
+const string write_attribute(string name, const bool value)
+{
+    string str = " " + name + "=\"" + tostr((int)value) + "\"";
+    return str;
+}
+
+
 void LyXTabular::Write(Buffer const * buf, ostream & os) const
 {
     // header line
-    os << "<LyXTabular version=1 rows=" << rows_
-       << " columns=" << columns_ << ">\n";
+    os << "<LyXTabular" <<
+       write_attribute("version", 1) <<
+       write_attribute("rows", rows_) <<
+       write_attribute("columns", columns_) <<
+       ">\n";
     // global longtable options
-    os << "<Features rotate=" << rotate
-       << " islongtable=" << is_long_tabular
-       << " endhead=" << endhead
-       << " endfirsthead=" << endfirsthead
-       << " endfoot=" << endfoot
-       << " endlastfoot=" << endlastfoot << ">\n\n";
+    os << "<Features" <<
+       write_attribute("rotate", rotate) <<
+       write_attribute("islongtable", is_long_tabular) <<
+       write_attribute("endhead", endhead) <<
+       write_attribute("endfirsthead", endfirsthead) <<
+       write_attribute("endfoot", endfoot) <<
+       write_attribute("endlastfoot", endlastfoot) <<
+       ">\n\n";
     for (int i = 0; i < rows_; ++i) {
-       os << "<Row topline=" << row_info[i].top_line
-          << " bottomline=" << row_info[i].bottom_line
-          << " newpage=" << row_info[i].newpage << ">\n";
+       os << "<Row" <<
+           write_attribute("topline", row_info[i].top_line) <<
+           write_attribute("bottomline", row_info[i].bottom_line) <<
+           write_attribute("newpage", row_info[i].newpage) <<
+           ">\n";
        for (int j = 0; j < columns_; ++j) {
            if (!i) {
-               os << "<Column alignment=" << column_info[j].alignment
-                  << " valignment=" << column_info[j].valignment
-                  << " leftline=" << column_info[j].left_line
-                  << " rightline=" << column_info[j].right_line
-                  << " width=\"" << VSpace(column_info[j].p_width).asLyXCommand()
-                  << "\" special=\"" << column_info[j].align_special
-                  << "\"\n>";
+               os << "<Column" <<
+                   write_attribute("alignment", column_info[j].alignment) <<
+                   write_attribute("valignment", column_info[j].valignment) <<
+                   write_attribute("leftline", column_info[j].left_line) <<
+                   write_attribute("rightline", column_info[j].right_line) <<
+                   write_attribute("width", VSpace(column_info[j].p_width).asLyXCommand()) <<
+                   write_attribute("special", column_info[j].align_special) <<
+                   ">\n";
            } else {
                os << "<Column>\n";
            }
-           os << "<Cell multicolumn=" << cell_info[i][j].multicolumn
-              << " alignment=" << cell_info[i][j].alignment
-              << " valignment=" << cell_info[i][j].valignment
-              << " topline=" << cell_info[i][j].top_line
-              << " bottomline=" << cell_info[i][j].bottom_line
-              << " leftline=" << cell_info[i][j].left_line
-              << " rightline=" << cell_info[i][j].right_line
-              << " rotate=" << cell_info[i][j].rotate
-              << " usebox=" << (int)cell_info[i][j].usebox
-              << " width=\"" << cell_info[i][j].p_width
-              << "\" special=\"" << cell_info[i][j].align_special
-              << "\">\n";
+           os << "<Cell" <<
+               write_attribute("multicolumn", cell_info[i][j].multicolumn) <<
+               write_attribute("alignment", cell_info[i][j].alignment) <<
+               write_attribute("valignment", cell_info[i][j].valignment) <<
+               write_attribute("topline", cell_info[i][j].top_line) <<
+               write_attribute("bottomline", cell_info[i][j].bottom_line) <<
+               write_attribute("leftline", cell_info[i][j].left_line) <<
+               write_attribute("rightline", cell_info[i][j].right_line) <<
+               write_attribute("rotate", cell_info[i][j].rotate) <<
+               write_attribute("usebox", (int)cell_info[i][j].usebox) <<
+               write_attribute("width", cell_info[i][j].p_width) <<
+               write_attribute("special", cell_info[i][j].align_special) <<
+               ">\n";
            os << "\\begin_inset ";
            cell_info[i][j].inset.Write(buf, os);
            os << "\n\\end_inset \n"
               << "</Cell>\n"
-              << "</Column\n>";
+              << "</Column>\n";
        }
        os << "</Row>\n";
     }