mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-12 22:14:35 +00:00
ascii export of paragraphs, fix small compile problem.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3699 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
19e6fc3513
commit
f3f601b0cf
@ -1,3 +1,9 @@
|
|||||||
|
2002-03-07 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||||
|
|
||||||
|
* buffer.C (asciiParagraph): redo some of the word and line length
|
||||||
|
handling.
|
||||||
|
(getLists): look for Caption instead of caption.
|
||||||
|
|
||||||
2002-03-07 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
2002-03-07 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
|
||||||
|
|
||||||
* buffer.C (Buffer): initialize niceFile to true
|
* buffer.C (Buffer): initialize niceFile to true
|
||||||
|
168
src/buffer.C
168
src/buffer.C
@ -1788,16 +1788,27 @@ bool Buffer::writeFile(string const & fname, bool flag) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
pair<int, string> const addDepth(int depth, int ldepth)
|
||||||
|
{
|
||||||
|
int d = depth * 2;
|
||||||
|
if (ldepth > depth)
|
||||||
|
d += (ldepth - depth) * 2;
|
||||||
|
return make_pair(d, string(d, ' '));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string const Buffer::asciiParagraph(Paragraph const * par,
|
string const Buffer::asciiParagraph(Paragraph const * par,
|
||||||
unsigned int linelen,
|
unsigned int linelen,
|
||||||
bool noparbreak) const
|
bool noparbreak) const
|
||||||
{
|
{
|
||||||
ostringstream buffer;
|
ostringstream buffer;
|
||||||
ostringstream word;
|
|
||||||
Paragraph::depth_type depth = 0;
|
Paragraph::depth_type depth = 0;
|
||||||
int ltype = 0;
|
int ltype = 0;
|
||||||
Paragraph::depth_type ltype_depth = 0;
|
Paragraph::depth_type ltype_depth = 0;
|
||||||
string::size_type currlinelen = 0;
|
|
||||||
bool ref_printed = false;
|
bool ref_printed = false;
|
||||||
// if (!par->previous()) {
|
// if (!par->previous()) {
|
||||||
#if 0
|
#if 0
|
||||||
@ -1861,12 +1872,16 @@ string const Buffer::asciiParagraph(Paragraph const * par,
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// linelen <= 0 is special and means we don't have pargraph breaks
|
// linelen <= 0 is special and means we don't have pargraph breaks
|
||||||
|
|
||||||
|
string::size_type currlinelen = 0;
|
||||||
|
|
||||||
if (!noparbreak) {
|
if (!noparbreak) {
|
||||||
if (linelen > 0)
|
if (linelen > 0)
|
||||||
buffer << "\n\n";
|
buffer << "\n\n";
|
||||||
for (Paragraph::depth_type j = 0; j < depth; ++j)
|
|
||||||
buffer << " ";
|
buffer << string(depth * 2, ' ');
|
||||||
currlinelen = depth * 2;
|
currlinelen += depth * 2;
|
||||||
|
|
||||||
//--
|
//--
|
||||||
// we should probably change to the paragraph language in the
|
// we should probably change to the paragraph language in the
|
||||||
// gettext here (if possible) so that strings are outputted in
|
// gettext here (if possible) so that strings are outputted in
|
||||||
@ -1878,46 +1893,52 @@ string const Buffer::asciiParagraph(Paragraph const * par,
|
|||||||
case 5: // Description
|
case 5: // Description
|
||||||
break;
|
break;
|
||||||
case 6: // Abstract
|
case 6: // Abstract
|
||||||
if (linelen > 0)
|
if (linelen > 0) {
|
||||||
buffer << _("Abstract") << "\n\n";
|
buffer << _("Abstract") << "\n\n";
|
||||||
else
|
currlinelen = 0;
|
||||||
buffer << _("Abstract: ");
|
} else {
|
||||||
|
string const abst = _("Abstract: ");
|
||||||
|
buffer << abst;
|
||||||
|
currlinelen += abst.length();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 7: // Bibliography
|
case 7: // Bibliography
|
||||||
if (!ref_printed) {
|
if (!ref_printed) {
|
||||||
if (linelen > 0)
|
if (linelen > 0) {
|
||||||
buffer << _("References") << "\n\n";
|
buffer << _("References") << "\n\n";
|
||||||
else
|
currlinelen = 0;
|
||||||
buffer << _("References: ");
|
} else {
|
||||||
|
string const refs = _("References: ");
|
||||||
|
buffer << refs;
|
||||||
|
currlinelen += refs.length();
|
||||||
|
}
|
||||||
|
|
||||||
ref_printed = true;
|
ref_printed = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
buffer << par->params().labelString() << " ";
|
{
|
||||||
break;
|
string const parlab = par->params().labelString();
|
||||||
|
buffer << parlab << " ";
|
||||||
|
currlinelen += parlab.length() + 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string s = buffer.str();
|
|
||||||
if (s.rfind('\n') != string::npos) {
|
|
||||||
string dummy;
|
|
||||||
s = rsplit(buffer.str().c_str(), dummy, '\n');
|
|
||||||
}
|
|
||||||
currlinelen = s.length();
|
|
||||||
if (!currlinelen) {
|
if (!currlinelen) {
|
||||||
for (Paragraph::depth_type j = 0; j < depth; ++j)
|
pair<int, string> p = addDepth(depth, ltype_depth);
|
||||||
buffer << " ";
|
buffer << p.second;
|
||||||
currlinelen = depth * 2;
|
currlinelen += p.first;
|
||||||
if (ltype_depth > depth) {
|
|
||||||
for (Paragraph::depth_type j = ltype_depth;
|
|
||||||
j > depth; --j)
|
|
||||||
{
|
|
||||||
buffer << " ";
|
|
||||||
}
|
|
||||||
currlinelen += (ltype_depth-depth)*2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// this is to change the linebreak to do it by word a bit more intelligent
|
|
||||||
// hopefully! (only in the case where we have a max linelenght!) (Jug)
|
// this is to change the linebreak to do it by word a bit more
|
||||||
|
// intelligent hopefully! (only in the case where we have a
|
||||||
|
// max linelenght!) (Jug)
|
||||||
|
|
||||||
|
string word;
|
||||||
|
|
||||||
for (pos_type i = 0; i < par->size(); ++i) {
|
for (pos_type i = 0; i < par->size(); ++i) {
|
||||||
char c = par->getUChar(params, i);
|
char c = par->getUChar(params, i);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -1926,82 +1947,73 @@ string const Buffer::asciiParagraph(Paragraph const * par,
|
|||||||
Inset const * inset = par->getInset(i);
|
Inset const * inset = par->getInset(i);
|
||||||
if (inset) {
|
if (inset) {
|
||||||
if (linelen > 0) {
|
if (linelen > 0) {
|
||||||
buffer << word.str();
|
buffer << word;
|
||||||
word.str("");
|
currlinelen += word.length();
|
||||||
|
word.erase();
|
||||||
}
|
}
|
||||||
if (inset->ascii(this, buffer, linelen)) {
|
if (inset->ascii(this, buffer, linelen)) {
|
||||||
// to be sure it breaks paragraph
|
// to be sure it breaks paragraph
|
||||||
currlinelen += linelen;
|
currlinelen += linelen;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
else {
|
|
||||||
string dummy;
|
|
||||||
string const s =
|
|
||||||
rsplit(buffer.str().c_str(),
|
|
||||||
dummy, '\n');
|
|
||||||
currlinelen = s.length();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Paragraph::META_NEWLINE:
|
case Paragraph::META_NEWLINE:
|
||||||
if (linelen > 0) {
|
if (linelen > 0) {
|
||||||
buffer << word.str() << "\n";
|
buffer << word << "\n";
|
||||||
word.str("");
|
word.erase();
|
||||||
for (Paragraph::depth_type j = 0;
|
|
||||||
j < depth; ++j)
|
pair<int, string> p = addDepth(depth,
|
||||||
buffer << " ";
|
ltype_depth);
|
||||||
currlinelen = depth * 2;
|
buffer << p.second;
|
||||||
if (ltype_depth > depth) {
|
currlinelen = p.first;
|
||||||
for (Paragraph::depth_type j = ltype_depth;
|
|
||||||
j > depth; --j)
|
|
||||||
buffer << " ";
|
|
||||||
currlinelen += (ltype_depth - depth) * 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Paragraph::META_HFILL:
|
case Paragraph::META_HFILL:
|
||||||
buffer << word.str() << "\t";
|
buffer << word << "\t";
|
||||||
currlinelen += word.str().length() + 1;
|
currlinelen += word.length() + 1;
|
||||||
word.str("");
|
word.erase();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (c == ' ') {
|
if (c == ' ') {
|
||||||
buffer << word.str() << ' ';
|
if (linelen > 0 &&
|
||||||
currlinelen += word.str().length() + 1;
|
currlinelen + word.length() > linelen - 10) {
|
||||||
word.str("");
|
buffer << "\n";
|
||||||
|
pair<int, string> p =
|
||||||
|
addDepth(depth, ltype_depth);
|
||||||
|
buffer << p.second;
|
||||||
|
currlinelen = p.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer << word << ' ';
|
||||||
|
currlinelen += word.length() + 1;
|
||||||
|
word.erase();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (c != '\0') {
|
if (c != '\0') {
|
||||||
word << c;
|
word.push_back(c);
|
||||||
} else {
|
} else {
|
||||||
lyxerr[Debug::INFO] <<
|
lyxerr[Debug::INFO] <<
|
||||||
"writeAsciiFile: NULL char in structure." << endl;
|
"writeAsciiFile: NULL char in structure." << endl;
|
||||||
}
|
}
|
||||||
if ((linelen > 0) &&
|
if ((linelen > 0) &&
|
||||||
(currlinelen+word.str().length()) > linelen)
|
(currlinelen + word.length()) > linelen)
|
||||||
{
|
{
|
||||||
buffer << "\n";
|
buffer << "\n";
|
||||||
for (Paragraph::depth_type j = 0; j < depth; ++j)
|
|
||||||
buffer << " ";
|
pair<int, string> p =
|
||||||
currlinelen = depth * 2;
|
addDepth(depth, ltype_depth);
|
||||||
if (ltype_depth > depth) {
|
buffer << p.second;
|
||||||
for (Paragraph::depth_type j = ltype_depth;
|
currlinelen = p.first;
|
||||||
j > depth; --j)
|
|
||||||
{
|
|
||||||
buffer << " ";
|
|
||||||
}
|
|
||||||
currlinelen += (ltype_depth-depth)*2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer << word.str();
|
buffer << word;
|
||||||
return buffer.str().c_str();
|
return buffer.str().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3601,8 +3613,8 @@ Buffer::Lists const Buffer::getLists() const
|
|||||||
Paragraph * par = paragraph;
|
Paragraph * par = paragraph;
|
||||||
|
|
||||||
LyXTextClass const & textclass = textclasslist[params.textclass];
|
LyXTextClass const & textclass = textclasslist[params.textclass];
|
||||||
bool found = textclass.hasLayout("caption");
|
bool found = textclass.hasLayout("Caption");
|
||||||
string const layout("caption");
|
string const layout("Caption");
|
||||||
|
|
||||||
while (par) {
|
while (par) {
|
||||||
char const labeltype = textclass[par->layout()].labeltype;
|
char const labeltype = textclass[par->layout()].labeltype;
|
||||||
@ -3648,7 +3660,7 @@ Buffer::Lists const Buffer::getLists() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lyxerr << "caption not found" << endl;
|
lyxerr << "Caption not found" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
par = par->next();
|
par = par->next();
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2002-03-07 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||||
|
|
||||||
|
* ControlSendto.C (allFormats): fix a iterators are not pointers
|
||||||
|
problem.
|
||||||
|
|
||||||
2002-03-06 Angus Leeming <a.leeming@ic.ac.uk>
|
2002-03-06 Angus Leeming <a.leeming@ic.ac.uk>
|
||||||
|
|
||||||
* ControlShowFile.h: add a #include "LString.h"
|
* ControlShowFile.h: add a #include "LString.h"
|
||||||
|
@ -71,7 +71,7 @@ vector<Format const *> const ControlSendto::allFormats() const
|
|||||||
Formats::const_iterator fo_end = formats.end();
|
Formats::const_iterator fo_end = formats.end();
|
||||||
for (; fo_it != fo_end; ++fo_it) {
|
for (; fo_it != fo_end; ++fo_it) {
|
||||||
if (converters.isReachable(*ex_it, fo_it->name())) {
|
if (converters.isReachable(*ex_it, fo_it->name())) {
|
||||||
to.push_back(fo_it);
|
to.push_back(&(*fo_it));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user