Get rid of Paragraph::ownerCode().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30934 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2009-08-09 14:33:35 +00:00
parent 8d7b7175a4
commit 34fde774f8
4 changed files with 24 additions and 24 deletions

View File

@ -246,16 +246,6 @@ bool bruteFind3(Cursor & cur, int x, int y, bool up)
return true;
}
docstring parbreak(Paragraph const & par)
{
odocstringstream os;
os << '\n';
// only add blank line if we're not in an ERT or Listings inset
if (par.ownerCode() != ERT_CODE && par.ownerCode() != LISTINGS_CODE)
os << '\n';
return os.str();
}
} // namespace anon
@ -1925,6 +1915,17 @@ void Cursor::errorMessage(docstring const & msg) const
}
static docstring parbreak(InsetCode code)
{
odocstringstream os;
os << '\n';
// only add blank line if we're not in an ERT or Listings inset
if (code != ERT_CODE && code != LISTINGS_CODE)
os << '\n';
return os.str();
}
docstring Cursor::selectionAsString(bool with_label) const
{
if (!selection())
@ -1956,13 +1957,13 @@ docstring Cursor::selectionAsString(bool with_label) const
// First paragraph in selection
docstring result = pars[startpit].
asString(startpos, pars[startpit].size(), label)
+ parbreak(pars[startpit]);
+ parbreak(inset().lyxCode());
// The paragraphs in between (if any)
for (pit_type pit = startpit + 1; pit != endpit; ++pit) {
Paragraph const & par = pars[pit];
result += par.asString(0, par.size(), label)
+ parbreak(pars[pit]);
+ parbreak(inset().lyxCode());
}
// Last paragraph in selection

View File

@ -173,6 +173,12 @@ public:
/// match a string against a particular point in the paragraph
bool isTextAt(string const & str, pos_type pos) const;
InsetCode Private::ownerCode() const
{
return inset_owner_ ? inset_owner_->lyxCode() : NO_CODE;
}
/// Which Paragraph owns us?
Paragraph * owner_;
@ -1807,7 +1813,7 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
}
string const begin_tag = "\\begin";
InsetCode code = owner_->ownerCode();
InsetCode code = ownerCode();
bool const lastpar = runparams.isLastPar;
switch (curAlign) {
@ -1875,7 +1881,7 @@ int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
}
string const end_tag = "\n\\par\\end";
InsetCode code = owner_->ownerCode();
InsetCode code = ownerCode();
bool const lastpar = runparams.isLastPar;
switch (curAlign) {
@ -2641,12 +2647,6 @@ Inset const & Paragraph::inInset() const
}
InsetCode Paragraph::ownerCode() const
{
return d->inset_owner_ ? d->inset_owner_->lyxCode() : NO_CODE;
}
ParagraphParameters & Paragraph::params()
{
return d->params_;

View File

@ -178,8 +178,6 @@ public:
///
Inset const & inInset() const;
///
InsetCode ownerCode() const;
///
bool forcePlainLayout() const;
///
bool allowParagraphCustomization() const;

View File

@ -1043,6 +1043,7 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
++maxdesc;
ParagraphList const & pars = text_->paragraphs();
Inset const & inset = par.inInset();
// is it a top line?
if (first == 0 && topBottomSpace) {
@ -1050,8 +1051,8 @@ Dimension TextMetrics::rowHeight(pit_type const pit, pos_type const first,
// some parskips VERY EASY IMPLEMENTATION
if (bufparams.paragraph_separation
== BufferParams::ParagraphSkipSeparation
&& par.ownerCode() != ERT_CODE
&& par.ownerCode() != LISTINGS_CODE
&& inset.lyxCode() != ERT_CODE
&& inset.lyxCode() != LISTINGS_CODE
&& pit > 0
&& ((layout.isParagraph() && par.getDepth() == 0)
|| (pars[pit - 1].layout().isParagraph()