patch from Dekel

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@767 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2000-05-23 19:53:56 +00:00
parent 2649fe2b52
commit b18c63a393
5 changed files with 40 additions and 8 deletions

View File

@ -1,3 +1,9 @@
2000-05-21 Dekel Tsur <dekel@math.tau.ac.il>
* src/paragraph.C (String): Several fixes/improvements
* src/insets/insetbib.[Ch] (InsetCitation::Ascii) New method
2000-05-22 Lars Gullik Bjønnes <larsbj@lyx.org> 2000-05-22 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/paragraph.C (String): give more correct output. * src/paragraph.C (String): give more correct output.

View File

@ -204,6 +204,11 @@ string InsetCitation::getScreenLabel() const
return temp + ']'; return temp + ']';
} }
int InsetCitation::Ascii(ostream & os) const
{
os << getScreenLabel();;
return 0;
}
InsetBibKey::InsetBibKey(string const & key, string const & label): InsetBibKey::InsetBibKey(string const & key, string const & label):
InsetCommand("bibitem", key, label) InsetCommand("bibitem", key, label)

View File

@ -43,6 +43,7 @@ public:
EDITABLE Editable() const { EDITABLE Editable() const {
return IS_EDITABLE; return IS_EDITABLE;
} }
int Ascii(std::ostream &) const;
/// ///
struct Holder { struct Holder {
InsetCitation * inset; InsetCitation * inset;

View File

@ -4276,7 +4276,7 @@ bool LyXParagraph::isMultiLingual()
string LyXParagraph::String(bool label) string LyXParagraph::String(bool label)
{ {
string s; string s;
if (label && !IsDummy()) if (label && !IsDummy() && !labelstring.empty())
s += labelstring + ' '; s += labelstring + ' ';
string::size_type len = s.size(); string::size_type len = s.size();
@ -4313,6 +4313,20 @@ string LyXParagraph::String(LyXParagraph::size_type beg,
LyXParagraph::size_type end) LyXParagraph::size_type end)
{ {
string s; string s;
int actcell = 0;
int cell = 1;
if (table)
for (LyXParagraph::size_type i = 0; i < beg; ++i)
if (IsNewline(i)) {
if (cell >= table->NumberOfCellsInRow(actcell))
cell = 1;
else
++cell;
++actcell;
}
if (beg == 0 && !IsDummy() && !labelstring.empty())
s += labelstring + ' ';
for (LyXParagraph::size_type i = beg; i < end; ++i) { for (LyXParagraph::size_type i = beg; i < end; ++i) {
unsigned char c = GetChar(i); unsigned char c = GetChar(i);
@ -4327,16 +4341,21 @@ string LyXParagraph::String(LyXParagraph::size_type beg,
GetInset(i)->Ascii(ost); GetInset(i)->Ascii(ost);
ost << '\0'; ost << '\0';
#endif #endif
s += subst(ost.str(),'\n',' '); s += ost.str();
} else if (table && IsNewlineChar(c)) {
if (cell >= table->NumberOfCellsInRow(actcell)) {
s += '\n';
cell = 1;
} else {
s += ' ';
++cell;
}
++actcell;
} }
} }
//if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE) //if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
// s += NextAfterFootnote()->String(false); // s += NextAfterFootnote()->String(false);
if (!IsDummy()) {
if (isRightToLeftPar())
reverse(s.begin(), s.end());
}
return s; return s;
} }

View File

@ -1086,13 +1086,14 @@ string LyXText::selectionAsString() const
// First paragraph in selection // First paragraph in selection
result += sel_start_cursor.par->String(sel_start_cursor.pos, result += sel_start_cursor.par->String(sel_start_cursor.pos,
sel_start_cursor.par->Last()); sel_start_cursor.par->Last())
+ "\n\n";
// The paragraphs in between (if any) // The paragraphs in between (if any)
LyXCursor tmpcur(sel_start_cursor); LyXCursor tmpcur(sel_start_cursor);
tmpcur.par = tmpcur.par->Next(); tmpcur.par = tmpcur.par->Next();
while (tmpcur.par != sel_end_cursor.par) { while (tmpcur.par != sel_end_cursor.par) {
result += tmpcur.par->String(false); result += tmpcur.par->String(0, tmpcur.par->Last()) + "\n\n";
tmpcur.par = tmpcur.par->Next(); // Or NextAfterFootnote?? tmpcur.par = tmpcur.par->Next(); // Or NextAfterFootnote??
} }