Fix remaining parts of bug 3146.

* src/Cursor.cpp:
	- new helper function parbreak that checks whether a blank line is
	  to be inserted or not (currently only relevant for ERT content)
	- (selectionAsString): use parbreak instead of hardcoded "\n\n"

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18220 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-05-07 08:57:53 +00:00
parent 9ff14f38ef
commit 8b238ec805

View File

@ -245,6 +245,16 @@ namespace {
return true;
}
docstring parbreak(Paragraph const & par)
{
odocstringstream ods;
ods << '\n';
// only add blank line if we're not in an ERT inset
if (par.ownerCode() != Inset::ERT_CODE)
ods << '\n';
return ods.str();
}
} // namespace anon
@ -1178,12 +1188,14 @@ docstring Cursor::selectionAsString(bool label) const
// First paragraph in selection
docstring result = pars[startpit].
asString(buffer, startpos, pars[startpit].size(), label) + "\n\n";
asString(buffer, startpos, pars[startpit].size(), label)
+ parbreak(pars[startpit]);
// The paragraphs in between (if any)
for (pit_type pit = startpit + 1; pit != endpit; ++pit) {
Paragraph const & par = pars[pit];
result += par.asString(buffer, 0, par.size(), label) + "\n\n";
result += par.asString(buffer, 0, par.size(), label)
+ parbreak(pars[pit]);
}
// Last paragraph in selection