-/* This file is part of
- * ======================================================
+/**
+ * \file paragraph.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Asger Alstrup
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ * \author Angus Leeming
+ * \author John Levon
+ * \author André Pönitz
+ * \author Dekel Tsur
+ * \author Jürgen Vigna
*
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS.
+ */
#include <config.h>
using lyx::pos_type;
-// this is a minibuffer
-
-namespace {
-
-char minibuffer_char;
-LyXFont minibuffer_font;
-InsetOld * minibuffer_inset;
-
-} // namespace anon
-
-
Paragraph::Paragraph()
- : pimpl_(new Paragraph::Pimpl(this))
+ : y(0), pimpl_(new Paragraph::Pimpl(this))
{
enumdepth = 0;
itemdepth = 0;
Paragraph::Paragraph(Paragraph const & lp)
- : pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
+ : y(0), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
{
enumdepth = 0;
itemdepth = 0;
for (; it != end; ++it) {
// currently we hold Inset*, not InsetBase*
it->inset = static_cast<InsetOld*>(it->inset->clone().release());
- // tell the new inset who is the boss now
- it->inset->parOwner(this);
}
}
// needed as we will destroy the pimpl_ before copying it
if (&lp != this)
return;
- lyxerr << "Paragraph::operator=()\n";
+
+ lyxerr << "Paragraph::operator=()" << endl;
+
delete pimpl_;
pimpl_ = new Pimpl(*lp.pimpl_, this);
InsetList::iterator end = insetlist.end();
for (; it != end; ++it) {
it->inset = static_cast<InsetOld*>(it->inset->clone().release());
- // tell the new inset who is the boss now
- it->inset->parOwner(this);
}
}
}
-void Paragraph::write(Buffer const * buf, ostream & os,
+void Paragraph::write(Buffer const & buf, ostream & os,
BufferParams const & bparams,
depth_type & dth) const
{
}
-// First few functions needed for cut and paste and paragraph breaking.
-void Paragraph::copyIntoMinibuffer(Buffer const & buffer, pos_type pos) const
-{
- BufferParams bparams = buffer.params;
-
- minibuffer_char = getChar(pos);
- minibuffer_font = getFontSettings(bparams, pos);
- minibuffer_inset = 0;
- if (minibuffer_char == Paragraph::META_INSET) {
- if (getInset(pos)) {
- minibuffer_inset = static_cast<InsetOld *>(getInset(pos)->clone().release());
- } else {
- minibuffer_inset = 0;
- minibuffer_char = ' ';
- // This reflects what GetInset() does (ARRae)
- }
- }
-}
-
-
-void Paragraph::cutIntoMinibuffer(BufferParams const & bparams, pos_type pos)
-{
- minibuffer_char = getChar(pos);
- minibuffer_font = getFontSettings(bparams, pos);
- minibuffer_inset = 0;
- if (minibuffer_char == Paragraph::META_INSET) {
- if (getInset(pos)) {
- // the inset is not in a paragraph anymore
- minibuffer_inset = insetlist.release(pos);
- minibuffer_inset->parOwner(0);
- } else {
- minibuffer_inset = 0;
- minibuffer_char = ' ';
- // This reflects what GetInset() does (ARRae)
- }
- }
-}
-
-
-bool Paragraph::insertFromMinibuffer(pos_type pos)
-{
- if (minibuffer_char == Paragraph::META_INSET) {
- if (!insetAllowed(minibuffer_inset->lyxCode()))
- return false;
- insertInset(pos, minibuffer_inset, minibuffer_font);
- } else {
- LyXFont f = minibuffer_font;
- if (!checkInsertChar(f))
- return false;
- insertChar(pos, minibuffer_char, f);
- }
- return true;
-}
-
-// end of minibuffer
-
-
void Paragraph::eraseIntern(lyx::pos_type pos)
{
pimpl_->eraseIntern(pos);
}
-void Paragraph::insertInset(pos_type pos, InsetOld * inset, LyXFont const & font, Change change)
+void Paragraph::insertInset(pos_type pos, InsetOld * inset,
+ LyXFont const & font, Change change)
{
pimpl_->insertInset(pos, inset, font, change);
}
return cit->pos();
// This should not happen, but if so, we take no chances.
- lyxerr << "Pararaph::getEndPosOfFontSpan: This should not happen!\n";
+ //lyxerr << "Paragraph::getEndPosOfFontSpan: This should not happen!"
+ // << endl;
return pos;
}
// This one spits out the text of the paragraph
-bool Paragraph::simpleTeXOnePar(Buffer const * buf,
+bool Paragraph::simpleTeXOnePar(Buffer const & buf,
BufferParams const & bparams,
LyXFont const & outerfont,
ostream & os, TexRow & texrow,
for (; cit != end; ++cit)
if (cit->font().language() != ignore_language &&
cit->font().language() != latex_language &&
- cit->font().language() != doc_language)
+ cit->font().language() != doc_language)
return true;
return false;
}
// Convert the paragraph to a string.
// Used for building the table of contents
-string const Paragraph::asString(Buffer const * buffer, bool label) const
+string const Paragraph::asString(Buffer const & buffer, bool label) const
{
#if 0
string s;
}
-string const Paragraph::asString(Buffer const * buffer,
+string const Paragraph::asString(Buffer const & buffer,
pos_type beg, pos_type end, bool label) const
{
ostringstream os;
os << params().labelString() << ' ';
for (pos_type i = beg; i < end; ++i) {
- value_type const c = getUChar(buffer->params, i);
+ value_type const c = getUChar(buffer.params, i);
if (IsPrintable(c))
os << c;
else if (c == META_INSET)
}
-void Paragraph::resizeInsetsLyXText(BufferView * bv)
-{
- insetlist.resizeInsetsLyXText(bv);
-}
-
-
void Paragraph::setContentsFromPar(Paragraph const & par)
{
pimpl_->setContentsFromPar(par);
return true;
// for now we just need this, later should we need this in some
- // other way we can always add a function to InsetOld::() too.
+ // other way we can always add a function to InsetOld too.
if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
- return (pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE);
+ return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
return false;
}
if (layout()->keepempty)
return true;
if (pimpl_->inset_owner && pimpl_->inset_owner->owner())
- return (pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE);
+ return pimpl_->inset_owner->owner()->lyxCode() == InsetOld::ERT_CODE;
return false;
}
-
-
-bool operator==(Paragraph const & lhs, Paragraph const & rhs)
-{
-#warning FIXME this implementatoin must be completely wrong...
- return &lhs == &rhs;
-}