mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
Added linelen to insets-ascii-function, some fixes and new support
functions. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1042 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d6665cba42
commit
99d6f056e4
22
ChangeLog
22
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>
|
2000-09-26 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||||
|
|
||||||
* src/support/unlink.C src/support/remove.C src/support/mkdir.C:
|
* src/support/unlink.C src/support/remove.C src/support/mkdir.C:
|
||||||
|
@ -96,9 +96,6 @@
|
|||||||
\bind "M-l c" "layout-character"
|
\bind "M-l c" "layout-character"
|
||||||
\bind "M-l p" "layout-paragraph"
|
\bind "M-l p" "layout-paragraph"
|
||||||
\bind "M-l d" "layout-document"
|
\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 m" "font-emph"
|
||||||
\bind "M-l n" "font-noun"
|
\bind "M-l n" "font-noun"
|
||||||
\bind "M-l b" "font-bold"
|
\bind "M-l b" "font-bold"
|
||||||
@ -107,7 +104,6 @@
|
|||||||
\bind "M-l l" "layout-preamble"
|
\bind "M-l l" "layout-preamble"
|
||||||
\bind "M-l s" "layout-save-default"
|
\bind "M-l s" "layout-save-default"
|
||||||
\bind "M-l space" "menu-open Layout"
|
\bind "M-l space" "menu-open Layout"
|
||||||
\bind "M-l i" "buffer-itemize-bullets-select"
|
|
||||||
\bind "M-l x" "appendix"
|
\bind "M-l x" "appendix"
|
||||||
|
|
||||||
#
|
#
|
||||||
|
238
src/buffer.C
238
src/buffer.C
@ -92,6 +92,7 @@
|
|||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
#include "exporter.h"
|
#include "exporter.h"
|
||||||
|
#include "Lsstream.h"
|
||||||
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::ofstream;
|
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)
|
void Buffer::writeFileAscii(string const & fname, int linelen)
|
||||||
{
|
{
|
||||||
Inset * inset;
|
Inset * inset;
|
||||||
@ -1503,7 +1505,243 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
|
|||||||
|
|
||||||
ofs << "\n";
|
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,
|
void Buffer::makeLaTeXFile(string const & fname,
|
||||||
string const & original_path,
|
string const & original_path,
|
||||||
|
@ -150,7 +150,8 @@ public:
|
|||||||
|
|
||||||
///
|
///
|
||||||
void writeFileAscii(string const & , int);
|
void writeFileAscii(string const & , int);
|
||||||
|
void writeFileAscii(std::ostream &, int);
|
||||||
|
string const asciiParagraph(LyXParagraph const *, int linelen) const;
|
||||||
///
|
///
|
||||||
void makeLaTeXFile(string const & filename,
|
void makeLaTeXFile(string const & filename,
|
||||||
string const & original_path,
|
string const & original_path,
|
||||||
|
@ -192,6 +192,7 @@ bool BufferList::close(Buffer * buf)
|
|||||||
reask = !MenuWriteAs(buf);
|
reask = !MenuWriteAs(buf);
|
||||||
else if (buf->save()) {
|
else if (buf->save()) {
|
||||||
lastfiles->newFile(buf->fileName());
|
lastfiles->newFile(buf->fileName());
|
||||||
|
reask = false;
|
||||||
} else {
|
} else {
|
||||||
if (buf->getUser())
|
if (buf->getUser())
|
||||||
AllowInput(buf->getUser());
|
AllowInput(buf->getUser());
|
||||||
|
@ -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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
///
|
///
|
||||||
int Latex(Buffer const *, std::ostream &, bool fragile, bool free_space) const;
|
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;
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -94,7 +94,7 @@ public:
|
|||||||
int Latex(Buffer const *, std::ostream &,
|
int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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; }
|
int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
|
||||||
///
|
///
|
||||||
|
@ -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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public:
|
|||||||
virtual int Latex(Buffer const *, std::ostream &,
|
virtual int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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;
|
virtual int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
///
|
///
|
||||||
int Latex(Buffer const *, std::ostream &, bool, bool) const { return 0; }
|
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; }
|
int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
|
||||||
///
|
///
|
||||||
|
@ -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);
|
return write("Ascii", buf, os);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
virtual int Latex(Buffer const *, std::ostream &, bool fragile,
|
virtual int Latex(Buffer const *, std::ostream &, bool fragile,
|
||||||
bool free_spc) const;
|
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;
|
virtual int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -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.
|
// No graphics in ascii output.
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
int Latex(Buffer const *, std::ostream &,
|
int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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;
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
int Latex(Buffer const *, std::ostream &,
|
int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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;
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -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;
|
os << contents;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
int Latex(Buffer const *, std::ostream &,
|
int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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;
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -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 << "\"";
|
os << "\"";
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -89,7 +89,7 @@ public:
|
|||||||
int Latex(Buffer const *, std::ostream &,
|
int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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;
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -196,7 +196,7 @@ int InsetSpecialChar::Latex(Buffer const *, ostream & os, bool /*fragile*/,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InsetSpecialChar::Ascii(Buffer const *, ostream & os) const
|
int InsetSpecialChar::Ascii(Buffer const *, ostream & os, int) const
|
||||||
{
|
{
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case HYPHENATION: break;
|
case HYPHENATION: break;
|
||||||
@ -211,13 +211,13 @@ int InsetSpecialChar::Ascii(Buffer const *, ostream & os) const
|
|||||||
|
|
||||||
int InsetSpecialChar::Linuxdoc(Buffer const * buf, 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
|
int InsetSpecialChar::DocBook(Buffer const * buf, ostream & os) const
|
||||||
{
|
{
|
||||||
return Ascii(buf, os);
|
return Ascii(buf, os, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
int Latex(Buffer const *, std::ostream &,
|
int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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;
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -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
|
// This should be changed to a real ascii export
|
||||||
return tabular->Latex(buf, os, false, false);
|
return tabular->Latex(buf, os, false, false);
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
///
|
///
|
||||||
int Latex(Buffer const *, std::ostream &, bool, bool) const;
|
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;
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -108,7 +108,8 @@ void InsetText::init(InsetText const * ins)
|
|||||||
InsetText::~InsetText()
|
InsetText::~InsetText()
|
||||||
{
|
{
|
||||||
for(Cache::const_iterator cit=cache.begin(); cit != cache.end(); ++cit)
|
for(Cache::const_iterator cit=cache.begin(); cit != cache.end(); ++cit)
|
||||||
deleteLyXText((*cit).first);
|
delete (*cit).second;
|
||||||
|
// deleteLyXText((*cit).first);
|
||||||
LyXParagraph * p = par->next;
|
LyXParagraph * p = par->next;
|
||||||
delete par;
|
delete par;
|
||||||
while(p) {
|
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
|
void InsetText::Validate(LaTeXFeatures & features) const
|
||||||
{
|
{
|
||||||
LyXParagraph * p = par;
|
LyXParagraph * p = par;
|
||||||
|
@ -126,7 +126,7 @@ public:
|
|||||||
int Latex(Buffer const *, std::ostream &,
|
int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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; }
|
int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
|
||||||
///
|
///
|
||||||
|
@ -171,7 +171,7 @@ public:
|
|||||||
virtual int Latex(Buffer const *, std::ostream &, bool fragile,
|
virtual int Latex(Buffer const *, std::ostream &, bool fragile,
|
||||||
bool free_spc) const = 0;
|
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;
|
virtual int Linuxdoc(Buffer const *, std::ostream &) const = 0;
|
||||||
///
|
///
|
||||||
|
@ -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);
|
par->Write(os, false);
|
||||||
return 0;
|
return 0;
|
||||||
@ -340,13 +340,13 @@ int InsetFormula::Ascii(Buffer const *, ostream & os) const
|
|||||||
|
|
||||||
int InsetFormula::Linuxdoc(Buffer const * buf, 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
|
int InsetFormula::DocBook(Buffer const * buf, ostream & os) const
|
||||||
{
|
{
|
||||||
return Ascii(buf, os);
|
return Ascii(buf, os, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
int Latex(Buffer const *, std::ostream &,
|
int Latex(Buffer const *, std::ostream &,
|
||||||
bool fragile, bool free_spc) const;
|
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;
|
int Linuxdoc(Buffer const *, std::ostream &) const;
|
||||||
///
|
///
|
||||||
|
@ -83,13 +83,13 @@ int InsetFormulaMacro::Latex(Buffer const *, ostream & os, bool /*fragile*/,
|
|||||||
|
|
||||||
int InsetFormulaMacro::Linuxdoc(Buffer const * buf, ostream & os) const
|
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
|
int InsetFormulaMacro::DocBook(Buffer const * buf, ostream & os) const
|
||||||
{
|
{
|
||||||
return Ascii(buf, os);
|
return Ascii(buf, os, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
void LyXTabular::Write(Buffer const * buf, ostream & os) const
|
||||||
{
|
{
|
||||||
// header line
|
// header line
|
||||||
os << "<LyXTabular version=1 rows=" << rows_
|
os << "<LyXTabular" <<
|
||||||
<< " columns=" << columns_ << ">\n";
|
write_attribute("version", 1) <<
|
||||||
|
write_attribute("rows", rows_) <<
|
||||||
|
write_attribute("columns", columns_) <<
|
||||||
|
">\n";
|
||||||
// global longtable options
|
// global longtable options
|
||||||
os << "<Features rotate=" << rotate
|
os << "<Features" <<
|
||||||
<< " islongtable=" << is_long_tabular
|
write_attribute("rotate", rotate) <<
|
||||||
<< " endhead=" << endhead
|
write_attribute("islongtable", is_long_tabular) <<
|
||||||
<< " endfirsthead=" << endfirsthead
|
write_attribute("endhead", endhead) <<
|
||||||
<< " endfoot=" << endfoot
|
write_attribute("endfirsthead", endfirsthead) <<
|
||||||
<< " endlastfoot=" << endlastfoot << ">\n\n";
|
write_attribute("endfoot", endfoot) <<
|
||||||
|
write_attribute("endlastfoot", endlastfoot) <<
|
||||||
|
">\n\n";
|
||||||
for (int i = 0; i < rows_; ++i) {
|
for (int i = 0; i < rows_; ++i) {
|
||||||
os << "<Row topline=" << row_info[i].top_line
|
os << "<Row" <<
|
||||||
<< " bottomline=" << row_info[i].bottom_line
|
write_attribute("topline", row_info[i].top_line) <<
|
||||||
<< " newpage=" << row_info[i].newpage << ">\n";
|
write_attribute("bottomline", row_info[i].bottom_line) <<
|
||||||
|
write_attribute("newpage", row_info[i].newpage) <<
|
||||||
|
">\n";
|
||||||
for (int j = 0; j < columns_; ++j) {
|
for (int j = 0; j < columns_; ++j) {
|
||||||
if (!i) {
|
if (!i) {
|
||||||
os << "<Column alignment=" << column_info[j].alignment
|
os << "<Column" <<
|
||||||
<< " valignment=" << column_info[j].valignment
|
write_attribute("alignment", column_info[j].alignment) <<
|
||||||
<< " leftline=" << column_info[j].left_line
|
write_attribute("valignment", column_info[j].valignment) <<
|
||||||
<< " rightline=" << column_info[j].right_line
|
write_attribute("leftline", column_info[j].left_line) <<
|
||||||
<< " width=\"" << VSpace(column_info[j].p_width).asLyXCommand()
|
write_attribute("rightline", column_info[j].right_line) <<
|
||||||
<< "\" special=\"" << column_info[j].align_special
|
write_attribute("width", VSpace(column_info[j].p_width).asLyXCommand()) <<
|
||||||
<< "\"\n>";
|
write_attribute("special", column_info[j].align_special) <<
|
||||||
|
">\n";
|
||||||
} else {
|
} else {
|
||||||
os << "<Column>\n";
|
os << "<Column>\n";
|
||||||
}
|
}
|
||||||
os << "<Cell multicolumn=" << cell_info[i][j].multicolumn
|
os << "<Cell" <<
|
||||||
<< " alignment=" << cell_info[i][j].alignment
|
write_attribute("multicolumn", cell_info[i][j].multicolumn) <<
|
||||||
<< " valignment=" << cell_info[i][j].valignment
|
write_attribute("alignment", cell_info[i][j].alignment) <<
|
||||||
<< " topline=" << cell_info[i][j].top_line
|
write_attribute("valignment", cell_info[i][j].valignment) <<
|
||||||
<< " bottomline=" << cell_info[i][j].bottom_line
|
write_attribute("topline", cell_info[i][j].top_line) <<
|
||||||
<< " leftline=" << cell_info[i][j].left_line
|
write_attribute("bottomline", cell_info[i][j].bottom_line) <<
|
||||||
<< " rightline=" << cell_info[i][j].right_line
|
write_attribute("leftline", cell_info[i][j].left_line) <<
|
||||||
<< " rotate=" << cell_info[i][j].rotate
|
write_attribute("rightline", cell_info[i][j].right_line) <<
|
||||||
<< " usebox=" << (int)cell_info[i][j].usebox
|
write_attribute("rotate", cell_info[i][j].rotate) <<
|
||||||
<< " width=\"" << cell_info[i][j].p_width
|
write_attribute("usebox", (int)cell_info[i][j].usebox) <<
|
||||||
<< "\" special=\"" << cell_info[i][j].align_special
|
write_attribute("width", cell_info[i][j].p_width) <<
|
||||||
<< "\">\n";
|
write_attribute("special", cell_info[i][j].align_special) <<
|
||||||
|
">\n";
|
||||||
os << "\\begin_inset ";
|
os << "\\begin_inset ";
|
||||||
cell_info[i][j].inset.Write(buf, os);
|
cell_info[i][j].inset.Write(buf, os);
|
||||||
os << "\n\\end_inset \n"
|
os << "\n\\end_inset \n"
|
||||||
<< "</Cell>\n"
|
<< "</Cell>\n"
|
||||||
<< "</Column\n>";
|
<< "</Column>\n";
|
||||||
}
|
}
|
||||||
os << "</Row>\n";
|
os << "</Row>\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user